From c5222c7579c5268c862621ba68a128346ca3d06d Mon Sep 17 00:00:00 2001 From: Ben Beckford Date: Wed, 8 Jul 2026 17:15:48 -0700 Subject: [PATCH] chore(server): use bounded numbers in workflows (#29009) * chore(server): use bounded numbers in workflows * chore: increase precision for lat/lon filtering * chore: re-add integer to a json schema type --- packages/plugin-core/manifest.json | 17 ++++++++++++----- packages/plugin-core/src/index.ts | 6 +++--- server/src/dtos/json-schema.dto.ts | 3 +++ .../lib/components/SchemaConfiguration.svelte | 2 +- web/src/lib/types.ts | 3 +++ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/plugin-core/manifest.json b/packages/plugin-core/manifest.json index ac0f2466e8..66a12c36f2 100644 --- a/packages/plugin-core/manifest.json +++ b/packages/plugin-core/manifest.json @@ -163,19 +163,26 @@ "description": "Filter by distance to a coordinate", "properties": { "latitude": { - "type": "string", + "type": "number", "title": "Latitude", - "description": "GPS latitude of a coordinate which the asset must be close to" + "description": "GPS latitude of a coordinate which the asset must be close to", + "minimum": -90, + "maximum": 90, + "precision": 0.000001 }, "longitude": { - "type": "string", + "type": "number", "title": "Longitude", - "description": "GPS longitude of a coordinate which the asset must be close to" + "description": "GPS longitude of a coordinate which the asset must be close to", + "minimum": -180, + "maximum": 180, + "precision": 0.000001 }, "radius": { "type": "number", "title": "Maximum distance", - "description": "How close in kilometres the asset must be to the given point" + "description": "How close in kilometres the asset must be to the given point", + "minimum": 0 } } } diff --git a/packages/plugin-core/src/index.ts b/packages/plugin-core/src/index.ts index fc6e94a872..706a787e1a 100644 --- a/packages/plugin-core/src/index.ts +++ b/packages/plugin-core/src/index.ts @@ -96,10 +96,10 @@ const methods = wrapper({ return { workflow: { continue: false } }; } - const configLat = Number.parseFloat(config.coordinate?.latitude ?? ''); - const configLon = Number.parseFloat(config.coordinate?.longitude ?? ''); + const configLat = config.coordinate?.latitude; + const configLon = config.coordinate?.longitude; - if (Number.isNaN(configLat) || Number.isNaN(configLat)) { + if (configLat === undefined || configLon === undefined) { return { workflow: { continue: true } }; } diff --git a/server/src/dtos/json-schema.dto.ts b/server/src/dtos/json-schema.dto.ts index 81b14ad62a..7811a08ecf 100644 --- a/server/src/dtos/json-schema.dto.ts +++ b/server/src/dtos/json-schema.dto.ts @@ -12,6 +12,9 @@ const JsonSchemaPropertySchema = z description: z.string().describe('Description'), default: z.any().optional().describe('Default value'), enum: z.array(z.string()).optional().describe('Valid choices for enum types'), + minimum: z.number().optional().describe('Minimum value for number types'), + maximum: z.number().optional().describe('Maximum value for number types'), + precision: z.number().default(1).optional().describe('Smallest interval (granularity) for number types'), array: z.boolean().optional().describe('Type is an array type'), required: z.array(z.string()).optional().describe('A list of required properties'), uiHint: z diff --git a/web/src/lib/components/SchemaConfiguration.svelte b/web/src/lib/components/SchemaConfiguration.svelte index 77727b4163..249331a5e4 100644 --- a/web/src/lib/components/SchemaConfiguration.svelte +++ b/web/src/lib/components/SchemaConfiguration.svelte @@ -100,7 +100,7 @@ {:else if schema.type === 'number'} - + {:else if schema.type === 'string'} diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index ee5a03bb1b..09d882dd7d 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -93,6 +93,9 @@ export type JSONSchemaProperty = { // eslint-disable-next-line @typescript-eslint/no-explicit-any default?: any; enum?: string[]; + minimum?: number; + maximum?: number; + precision?: number; array?: boolean; properties?: Record; required?: string[];