Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13ac36e
feat: device schema db model and related fields
jona159 Jun 15, 2026
1d96b97
feat: upload device schema zod validation
jona159 Jun 15, 2026
2c7a3b5
feat: add optional device schema to create device schema
jona159 Jun 15, 2026
4fe422e
feat: example device schema
jona159 Jun 15, 2026
371fd97
feat: translation
jona159 Jun 15, 2026
5e22eb3
feat: import and save schemas on custom devices
jona159 Jun 15, 2026
007d4db
feat: migrations
jona159 Jun 15, 2026
3c6ef4d
fix: rm draft state, fix migrations
jona159 Jun 17, 2026
b02720b
feat: translations
jona159 Jun 17, 2026
a70b61b
feat: add optional schema version and registry fields to sensor schema
jona159 Jun 17, 2026
65deb54
feat: add db methods to manage schemas
jona159 Jun 17, 2026
9695d80
feat: resource route to load schemas for registry
jona159 Jun 17, 2026
074037a
feat: resource route to download public schema of specific version
jona159 Jun 17, 2026
aa57ce7
feat: allow to donwload device schemas from public profile
jona159 Jun 17, 2026
b3364f3
feat: add model and schema version to custom device creation payload
jona159 Jun 17, 2026
48d9708
feat: adjust add and update sensors
jona159 Jun 17, 2026
88c544d
feat: adjust device creation for sensor schema, allow to detach schema
jona159 Jun 17, 2026
8bb2456
feat: add optional schema version id to zod schema
jona159 Jun 17, 2026
4a2b930
feat: translation
jona159 Jun 17, 2026
e732bc2
feat: adjust hook to track copied string
jona159 Jun 17, 2026
f4e72be
feat: manage own schemas on settings profile
jona159 Jun 17, 2026
dd7be25
feat: restrict editing sensors from schema but allow to detach schema…
jona159 Jun 17, 2026
7b6cc69
feat: tab view for browsing schema registry, upload and manual sensors
jona159 Jun 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
457 changes: 400 additions & 57 deletions app/components/device/new/custom-device-config.tsx

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion app/components/device/new/new-device-stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { AdvancedStep } from './advanced-info'
import { DeviceSelectionStep } from './device-info'
import { GeneralInfoStep } from './general-info'
import { LocationStep } from './location-info'
import { sensorSchema, SensorSelectionStep } from './sensors-info'
import {
customDeviceSchemaUploadSchema,
sensorSchema,
SensorSelectionStep,
} from './sensors-info'
import { SummaryInfo } from './summary-info'
import {
Breadcrumb,
Expand Down Expand Up @@ -43,6 +47,9 @@ const sensorsSchema = z.object({
selectedSensors: z
.array(sensorSchema)
.min(1, 'Please select at least one sensor'),
deviceSchema: customDeviceSchemaUploadSchema,
deviceSchemaVersionId: z.string().optional(),
deviceSchemaRegistrySelection: z.any().optional(),
})

const advancedSchema = z.record(z.string(), z.any())
Expand Down
9 changes: 9 additions & 0 deletions app/components/device/new/sensors-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Checkbox } from '~/components/ui/checkbox'
import { Label } from '~/components/ui/label'
import { getSensorsForModel } from '~/lib/model-definitions'
import { cn } from '~/lib/utils'
import { uploadedDeviceSchemaV1 } from '~/lib/device-schemas/device-schema-v1'

export const sensorSchema = z.object({
title: z.string(),
Expand All @@ -23,9 +24,17 @@ export const sensorSchema = z.object({
icon: z.string().optional(),
image: z.string().optional(),
id: z.string().optional(),
sensorWikiType: z.string().optional(),
sensorWikiPhenomenon: z.string().optional(),
sensorWikiUnit: z.string().optional(),
})

export const customDeviceSchemaUploadSchema = uploadedDeviceSchemaV1.optional()

export type Sensor = z.infer<typeof sensorSchema>
export type CustomDeviceSchemaUpload = z.infer<
typeof customDeviceSchemaUploadSchema
>

type SensorGroup = {
sensorType: string
Expand Down
42 changes: 42 additions & 0 deletions app/db/drizzle/0043_low_blur.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CREATE TYPE "public"."device_schema_version_status" AS ENUM('published', 'deprecated');--> statement-breakpoint
CREATE TYPE "public"."device_schema_visibility" AS ENUM('private', 'public');--> statement-breakpoint
CREATE TABLE "device_schema" (
"id" text PRIMARY KEY NOT NULL,
"slug" text NOT NULL,
"name" text NOT NULL,
"description" text,
"tags" text[] DEFAULT ARRAY[]::text[],
"owner_user_id" text NOT NULL,
"visibility" "device_schema_visibility" DEFAULT 'private' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "device_schema_version" (
"id" text PRIMARY KEY NOT NULL,
"device_schema_id" text NOT NULL,
"version" text NOT NULL,
"format_version" text NOT NULL,
"content" jsonb NOT NULL,
"hash" text NOT NULL,
"status" "device_schema_version_status" DEFAULT 'published' NOT NULL,
"created_by_user_id" text NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"published_at" timestamp,
"deprecated_at" timestamp
);
--> statement-breakpoint
ALTER TABLE "device" ADD COLUMN "device_schema_version_id" text;--> statement-breakpoint
ALTER TABLE "device" ADD COLUMN "device_schema_public_id" text;--> statement-breakpoint
ALTER TABLE "device" ADD COLUMN "device_schema_id" text;--> statement-breakpoint
ALTER TABLE "device" ADD COLUMN "device_schema_name" text;--> statement-breakpoint
ALTER TABLE "device" ADD COLUMN "device_schema_version" text;--> statement-breakpoint
ALTER TABLE "device" ADD COLUMN "device_schema_hash" text;--> statement-breakpoint
ALTER TABLE "device_schema" ADD CONSTRAINT "device_schema_owner_user_id_user_id_fk" FOREIGN KEY ("owner_user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "device_schema_version" ADD CONSTRAINT "device_schema_version_device_schema_id_device_schema_id_fk" FOREIGN KEY ("device_schema_id") REFERENCES "public"."device_schema"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "device_schema_version" ADD CONSTRAINT "device_schema_version_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "device_schema_owner_slug_unique" ON "device_schema" USING btree ("owner_user_id","slug");--> statement-breakpoint
CREATE INDEX "device_schema_visibility_idx" ON "device_schema" USING btree ("visibility");--> statement-breakpoint
CREATE UNIQUE INDEX "device_schema_version_unique" ON "device_schema_version" USING btree ("device_schema_id","version");--> statement-breakpoint
CREATE UNIQUE INDEX "device_schema_version_hash_unique" ON "device_schema_version" USING btree ("device_schema_id","hash");--> statement-breakpoint
ALTER TABLE "device" ADD CONSTRAINT "device_device_schema_version_id_device_schema_version_id_fk" FOREIGN KEY ("device_schema_version_id") REFERENCES "public"."device_schema_version"("id") ON DELETE set null ON UPDATE cascade;
Loading