From beb88962d8567624b6c69b4ca2526c171710480c Mon Sep 17 00:00:00 2001 From: ingalls Date: Fri, 16 Feb 2024 16:00:47 -0700 Subject: [PATCH] Use Machine --- api/lib/connection-pool.ts | 8 ++++-- api/schema/connection_sinks.json | 8 +++--- api/schema/connections/auth.json | 2 +- api/schema/connections/created.json | 2 +- api/schema/connections/description.json | 2 +- api/schema/connections/enabled.json | 2 +- api/schema/connections/id.json | 2 +- api/schema/connections/name.json | 2 +- api/schema/connections/updated.json | 2 +- api/schema/icons.json | 32 +++++++++++------------ api/schema/iconsets.json | 18 ++++++------- api/schema/imports.json | 18 ++++++------- api/schema/layer_alerts/layer.json | 2 +- api/schema/layers.json | 8 +++--- api/schema/layers/connection.json | 5 +++- api/schema/layers/created.json | 2 +- api/schema/layers/cron.json | 5 +--- api/schema/layers/data.json | 5 +++- api/schema/layers/description.json | 2 +- api/schema/layers/enabled.json | 2 +- api/schema/layers/enabled_styles.json | 2 +- api/schema/layers/id.json | 2 +- api/schema/layers/name.json | 2 +- api/schema/layers/styles.json | 2 +- api/schema/layers/updated.json | 2 +- api/schema/profile_overlays/id.json | 2 +- api/schema/profile_overlays/opacity.json | 2 +- api/schema/profile_overlays/username.json | 5 +++- 28 files changed, 79 insertions(+), 69 deletions(-) diff --git a/api/lib/connection-pool.ts b/api/lib/connection-pool.ts index 556e41aa2..50afbb93c 100644 --- a/api/lib/connection-pool.ts +++ b/api/lib/connection-pool.ts @@ -7,7 +7,9 @@ import Modeler from '@openaddresses/batch-generic'; import { Connection } from './schema.js'; import { InferSelectModel } from 'drizzle-orm'; import sleep from './sleep.js'; -import ConnectionConfig from './connection-config.js'; +import ConnectionConfig, { + MachineConnConfig +}from './connection-config.js'; export class ConnectionClient { config: ConnectionConfig; @@ -68,8 +70,10 @@ export default class ConnectionPool extends Map { stream.on('data', async (conn: InferSelectModel) => { if (conn.enabled && !this.config.local) { - conns.push(this.add(conn)); + conns.push(this.add(new MachineConnConfig(conn))); } + }).on('error', (err) => { + return reject(err); }).on('end', async () => { try { await Promise.all(conns); diff --git a/api/schema/connection_sinks.json b/api/schema/connection_sinks.json index 00ca8ec7e..4b9a2e92c 100644 --- a/api/schema/connection_sinks.json +++ b/api/schema/connection_sinks.json @@ -11,15 +11,15 @@ "updated": { "$ref": "./connection_sinks/updated.json" }, - "name": { - "$ref": "./connection_sinks/name.json" - }, "enabled": { "$ref": "./connection_sinks/enabled.json" }, "connection": { "$ref": "./connection_sinks/connection.json" }, + "name": { + "$ref": "./connection_sinks/name.json" + }, "type": { "$ref": "./connection_sinks/type.json" }, @@ -34,9 +34,9 @@ "id", "created", "updated", - "name", "enabled", "connection", + "name", "type", "body", "logging" diff --git a/api/schema/connections/auth.json b/api/schema/connections/auth.json index 737b0c4bf..bae581de8 100644 --- a/api/schema/connections/auth.json +++ b/api/schema/connections/auth.json @@ -1,5 +1,5 @@ { "type": "object", - "description": "", + "description": "Authentication settings for the connection", "$comment": "json" } \ No newline at end of file diff --git a/api/schema/connections/created.json b/api/schema/connections/created.json index 788d7af55..26814e7fa 100644 --- a/api/schema/connections/created.json +++ b/api/schema/connections/created.json @@ -1,6 +1,6 @@ { "type": "string", - "description": "", + "description": "Creation TimeStamp", "$comment": "timestamptz", "format": "date-time" } \ No newline at end of file diff --git a/api/schema/connections/description.json b/api/schema/connections/description.json index 7fb37f63c..617652769 100644 --- a/api/schema/connections/description.json +++ b/api/schema/connections/description.json @@ -1,5 +1,5 @@ { "type": "string", - "description": "", + "description": "Human readable description", "$comment": "text" } \ No newline at end of file diff --git a/api/schema/connections/enabled.json b/api/schema/connections/enabled.json index 796f691f2..9709e3c6a 100644 --- a/api/schema/connections/enabled.json +++ b/api/schema/connections/enabled.json @@ -1,5 +1,5 @@ { "type": "boolean", - "description": "", + "description": "Is the connection passing CoT messages from layers", "$comment": "bool" } \ No newline at end of file diff --git a/api/schema/connections/id.json b/api/schema/connections/id.json index a38a156c5..00f2bd97e 100644 --- a/api/schema/connections/id.json +++ b/api/schema/connections/id.json @@ -1,5 +1,5 @@ { "type": "number", - "description": "", + "description": "Unique Connection ID", "$comment": "int4" } \ No newline at end of file diff --git a/api/schema/connections/name.json b/api/schema/connections/name.json index 7fb37f63c..383f316fe 100644 --- a/api/schema/connections/name.json +++ b/api/schema/connections/name.json @@ -1,5 +1,5 @@ { "type": "string", - "description": "", + "description": "Unique human readable name", "$comment": "text" } \ No newline at end of file diff --git a/api/schema/connections/updated.json b/api/schema/connections/updated.json index 788d7af55..5f71ede2d 100644 --- a/api/schema/connections/updated.json +++ b/api/schema/connections/updated.json @@ -1,6 +1,6 @@ { "type": "string", - "description": "", + "description": "Updated TimeStamp", "$comment": "timestamptz", "format": "date-time" } \ No newline at end of file diff --git a/api/schema/icons.json b/api/schema/icons.json index 5b8ec1b45..f78dd47e6 100644 --- a/api/schema/icons.json +++ b/api/schema/icons.json @@ -2,39 +2,39 @@ "type": "object", "additionalProperties": false, "properties": { - "id": { - "$ref": "./icons/id.json" - }, - "created": { - "$ref": "./icons/created.json" - }, - "updated": { - "$ref": "./icons/updated.json" + "iconset": { + "$ref": "./icons/iconset.json" }, "name": { "$ref": "./icons/name.json" }, - "iconset": { - "$ref": "./icons/iconset.json" - }, "type2525b": { "$ref": "./icons/type2525b.json" }, + "created": { + "$ref": "./icons/created.json" + }, + "updated": { + "$ref": "./icons/updated.json" + }, "data": { "$ref": "./icons/data.json" }, "path": { "$ref": "./icons/path.json" + }, + "id": { + "$ref": "./icons/id.json" } }, "required": [ - "id", - "created", - "updated", - "name", "iconset", + "name", "type2525b", + "created", + "updated", "data", - "path" + "path", + "id" ] } \ No newline at end of file diff --git a/api/schema/iconsets.json b/api/schema/iconsets.json index bb4da77ea..f2f91bd2d 100644 --- a/api/schema/iconsets.json +++ b/api/schema/iconsets.json @@ -5,12 +5,6 @@ "uid": { "$ref": "./iconsets/uid.json" }, - "created": { - "$ref": "./iconsets/created.json" - }, - "updated": { - "$ref": "./iconsets/updated.json" - }, "version": { "$ref": "./iconsets/version.json" }, @@ -34,12 +28,16 @@ }, "skip_resize": { "$ref": "./iconsets/skip_resize.json" + }, + "created": { + "$ref": "./iconsets/created.json" + }, + "updated": { + "$ref": "./iconsets/updated.json" } }, "required": [ "uid", - "created", - "updated", "version", "name", "default_group", @@ -47,6 +45,8 @@ "default_hostile", "default_neutral", "default_unknown", - "skip_resize" + "skip_resize", + "created", + "updated" ] } \ No newline at end of file diff --git a/api/schema/imports.json b/api/schema/imports.json index 6fc36f1a8..32c37dbcf 100644 --- a/api/schema/imports.json +++ b/api/schema/imports.json @@ -11,9 +11,6 @@ "updated": { "$ref": "./imports/updated.json" }, - "name": { - "$ref": "./imports/name.json" - }, "status": { "$ref": "./imports/status.json" }, @@ -23,30 +20,33 @@ "result": { "$ref": "./imports/result.json" }, + "name": { + "$ref": "./imports/name.json" + }, "username": { "$ref": "./imports/username.json" }, "mode": { "$ref": "./imports/mode.json" }, - "mode_id": { - "$ref": "./imports/mode_id.json" - }, "config": { "$ref": "./imports/config.json" + }, + "mode_id": { + "$ref": "./imports/mode_id.json" } }, "required": [ "id", "created", "updated", - "name", "status", "error", "result", + "name", "username", "mode", - "mode_id", - "config" + "config", + "mode_id" ] } \ No newline at end of file diff --git a/api/schema/layer_alerts/layer.json b/api/schema/layer_alerts/layer.json index a38a156c5..fdff5e5ef 100644 --- a/api/schema/layer_alerts/layer.json +++ b/api/schema/layer_alerts/layer.json @@ -1,5 +1,5 @@ { "type": "number", "description": "", - "$comment": "int4" + "$comment": "int8" } \ No newline at end of file diff --git a/api/schema/layers.json b/api/schema/layers.json index 83de51bf3..413aa7afc 100644 --- a/api/schema/layers.json +++ b/api/schema/layers.json @@ -5,15 +5,15 @@ "id": { "$ref": "./layers/id.json" }, + "name": { + "$ref": "./layers/name.json" + }, "created": { "$ref": "./layers/created.json" }, "updated": { "$ref": "./layers/updated.json" }, - "name": { - "$ref": "./layers/name.json" - }, "description": { "$ref": "./layers/description.json" }, @@ -59,9 +59,9 @@ }, "required": [ "id", + "name", "created", "updated", - "name", "description", "enabled", "enabled_styles", diff --git a/api/schema/layers/connection.json b/api/schema/layers/connection.json index a38a156c5..167fb4125 100644 --- a/api/schema/layers/connection.json +++ b/api/schema/layers/connection.json @@ -1,5 +1,8 @@ { - "type": "number", + "type": [ + "number", + "null" + ], "description": "", "$comment": "int4" } \ No newline at end of file diff --git a/api/schema/layers/created.json b/api/schema/layers/created.json index 788d7af55..26814e7fa 100644 --- a/api/schema/layers/created.json +++ b/api/schema/layers/created.json @@ -1,6 +1,6 @@ { "type": "string", - "description": "", + "description": "Creation TimeStamp", "$comment": "timestamptz", "format": "date-time" } \ No newline at end of file diff --git a/api/schema/layers/cron.json b/api/schema/layers/cron.json index ba5e18a3b..7fb37f63c 100644 --- a/api/schema/layers/cron.json +++ b/api/schema/layers/cron.json @@ -1,8 +1,5 @@ { - "type": [ - "string", - "null" - ], + "type": "string", "description": "", "$comment": "text" } \ No newline at end of file diff --git a/api/schema/layers/data.json b/api/schema/layers/data.json index a38a156c5..167fb4125 100644 --- a/api/schema/layers/data.json +++ b/api/schema/layers/data.json @@ -1,5 +1,8 @@ { - "type": "number", + "type": [ + "number", + "null" + ], "description": "", "$comment": "int4" } \ No newline at end of file diff --git a/api/schema/layers/description.json b/api/schema/layers/description.json index 7fb37f63c..617652769 100644 --- a/api/schema/layers/description.json +++ b/api/schema/layers/description.json @@ -1,5 +1,5 @@ { "type": "string", - "description": "", + "description": "Human readable description", "$comment": "text" } \ No newline at end of file diff --git a/api/schema/layers/enabled.json b/api/schema/layers/enabled.json index 796f691f2..358234faf 100644 --- a/api/schema/layers/enabled.json +++ b/api/schema/layers/enabled.json @@ -1,5 +1,5 @@ { "type": "boolean", - "description": "", + "description": "Is the layer passing CoT messages", "$comment": "bool" } \ No newline at end of file diff --git a/api/schema/layers/enabled_styles.json b/api/schema/layers/enabled_styles.json index 796f691f2..f6c6dbc2f 100644 --- a/api/schema/layers/enabled_styles.json +++ b/api/schema/layers/enabled_styles.json @@ -1,5 +1,5 @@ { "type": "boolean", - "description": "", + "description": "Is styling enabled for the layer", "$comment": "bool" } \ No newline at end of file diff --git a/api/schema/layers/id.json b/api/schema/layers/id.json index a38a156c5..73186f9ba 100644 --- a/api/schema/layers/id.json +++ b/api/schema/layers/id.json @@ -1,5 +1,5 @@ { "type": "number", - "description": "", + "description": "Unique Layer ID", "$comment": "int4" } \ No newline at end of file diff --git a/api/schema/layers/name.json b/api/schema/layers/name.json index 7fb37f63c..383f316fe 100644 --- a/api/schema/layers/name.json +++ b/api/schema/layers/name.json @@ -1,5 +1,5 @@ { "type": "string", - "description": "", + "description": "Unique human readable name", "$comment": "text" } \ No newline at end of file diff --git a/api/schema/layers/styles.json b/api/schema/layers/styles.json index 737b0c4bf..938e3e23f 100644 --- a/api/schema/layers/styles.json +++ b/api/schema/layers/styles.json @@ -1,5 +1,5 @@ { "type": "object", - "description": "", + "description": "Styling rules for the layer", "$comment": "json" } \ No newline at end of file diff --git a/api/schema/layers/updated.json b/api/schema/layers/updated.json index 788d7af55..5f71ede2d 100644 --- a/api/schema/layers/updated.json +++ b/api/schema/layers/updated.json @@ -1,6 +1,6 @@ { "type": "string", - "description": "", + "description": "Updated TimeStamp", "$comment": "timestamptz", "format": "date-time" } \ No newline at end of file diff --git a/api/schema/profile_overlays/id.json b/api/schema/profile_overlays/id.json index a38a156c5..fdff5e5ef 100644 --- a/api/schema/profile_overlays/id.json +++ b/api/schema/profile_overlays/id.json @@ -1,5 +1,5 @@ { "type": "number", "description": "", - "$comment": "int4" + "$comment": "int8" } \ No newline at end of file diff --git a/api/schema/profile_overlays/opacity.json b/api/schema/profile_overlays/opacity.json index a38a156c5..6e2fe0ca7 100644 --- a/api/schema/profile_overlays/opacity.json +++ b/api/schema/profile_overlays/opacity.json @@ -1,5 +1,5 @@ { "type": "number", "description": "", - "$comment": "int4" + "$comment": "float8" } \ No newline at end of file diff --git a/api/schema/profile_overlays/username.json b/api/schema/profile_overlays/username.json index 7fb37f63c..ba5e18a3b 100644 --- a/api/schema/profile_overlays/username.json +++ b/api/schema/profile_overlays/username.json @@ -1,5 +1,8 @@ { - "type": "string", + "type": [ + "string", + "null" + ], "description": "", "$comment": "text" } \ No newline at end of file