@uns-kit/core 3.0.15 → 3.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"uns-interfaces.js","sourceRoot":"","sources":["../../src/uns/uns-interfaces.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,YAAY,GAAG,+CAA+C,CAAC;IACrE,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAID,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC;AA6CxD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS;IACT,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,cAAc;IACd,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,SAAS;CACD,CAAC;AAEX,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,qBAAqB,CAAC,CAAC;AACvE,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AACnD,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AACnD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAW3C,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/B,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/B,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { UnsAttributeType } from \"../graphql/schema.js\";\nimport { MeasurementUnit } from \"./uns-measurements.js\";\nimport { UnsTags } from \"./uns-tags.js\";\nimport type { UnsObjectId, UnsObjectType } from \"./uns-object.js\";\nimport type { UnsAsset } from \"./uns-asset.js\";\nimport type { IMqttConnectProperties, IMqttPublishOptions, IMqttServerConfig, MqttProtocol } from \"../uns-mqtt/mqtt-interfaces.js\";\nimport { UnsTopics } from \"./uns-topics.js\";\nimport { knownUnsAttributes, type KnownUnsAttributeName } from \"./uns-attributes.js\";\n\nexport type ISO8601 = `${number}-${string}-${string}T${string}:${string}:${string}.${string}Z`;\nexport function isIOS8601Type(value: string): value is ISO8601 {\n const iso8601Regex = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n return iso8601Regex.test(value);\n}\n// Known attribute names (with IntelliSense) while still allowing arbitrary strings.\nexport type UnsAttribute = KnownUnsAttributeName | (string & {});\n\nexport const valueTypes = [\"string\", \"number\"] as const;\nexport type ValueTypeString = (typeof valueTypes)[number];\nexport type ScalarValueType = string | number;\n/** Scalar telemetry or a scalar array used by metadata such as relationship evidence. */\nexport type ValueType = ScalarValueType | ScalarValueType[];\n\nexport type CounterResetPolicy = \"new-value\" | \"null\" | \"rollover\" | (string & {});\n\nexport type UnsAttributeSystemRole =\n | \"relationship-evidence\"\n | \"lifecycle-start\"\n | \"lifecycle-end\"\n | \"lifecycle-time-source\"\n | (string & {});\n\nexport type UnsRelationshipEndpoint = \"source\" | \"target\";\n\nexport interface IUnsRelationshipEvidenceMetadata {\n relationshipKey: string;\n ownerEndpoint?: UnsRelationshipEndpoint;\n valueEndpoint?: UnsRelationshipEndpoint;\n /** Scalar values produce one edge; array values produce one edge per ObjectId value. */\n sourceObjectType?: UnsObjectType | (string & {});\n targetObjectType?: UnsObjectType | (string & {});\n sourceObjectIdFrom?: string;\n targetObjectIdFrom?: string;\n observedAtFrom?: string;\n status?: \"suggested\" | \"accepted\" | (string & {});\n defaultStatus?: \"suggested\" | \"accepted\" | (string & {});\n}\n\nexport interface IUnsLifecycleMetadata {\n timestampFrom?: \"value\" | \"packetTimestamp\" | (string & {});\n startValues?: string[];\n endValues?: string[];\n}\n\nexport interface IUnsTableColumnMetadata {\n name: string;\n valueType?: ValueTypeString | (string & {});\n presentationKind?: string;\n defaultAggregation?: string;\n counterResetPolicy?: CounterResetPolicy;\n}\n\nexport const questDbPrimitiveTypes = [\n \"boolean\",\n \"ipv4\",\n \"byte\",\n \"short\",\n \"char\",\n \"int\",\n \"float\",\n \"symbol\",\n \"varchar\",\n \"string\",\n \"long\",\n \"date\",\n \"timestamp\",\n \"timestamp_ns\",\n \"double\",\n \"uuid\",\n \"binary\",\n \"long256\",\n] as const;\n\nconst questDbPrimitiveTypeSet = new Set<string>(questDbPrimitiveTypes);\nconst questDbGeohashRegex = /^geohash\\(\\d+[bc]\\)$/;\nconst questDbDecimalRegex = /^decimal\\(\\d+,\\d+\\)$/;\nconst questDbArrayRegex = /^array<[^>]+>$/;\n\nexport type QuestDbPrimitiveType = (typeof questDbPrimitiveTypes)[number];\n\n// Supported QuestDB column types for UNS tables.\nexport type QuestDbType =\n | QuestDbPrimitiveType\n | `geohash(${number}${\"b\" | \"c\"})`\n | `decimal(${number},${number})`\n | `array<${string}>`;\n\nexport function isQuestDbType(value: unknown): value is QuestDbType {\n if (typeof value !== \"string\") {\n return false;\n }\n if (questDbPrimitiveTypeSet.has(value)) {\n return true;\n }\n return (\n questDbGeohashRegex.test(value) ||\n questDbDecimalRegex.test(value) ||\n questDbArrayRegex.test(value)\n );\n}\n\nexport interface IUnsParameters {\n mqttSubToTopics?: string | string[];\n username?: string;\n password?: string;\n mqttSSL?: boolean;\n publishThrottlingDelay?: number; // Delay in milliseconds; default is 1ms\n publishConcurrency?: number; // Maximum concurrent outgoing publishes; default is 1\n maxPendingPublishes?: number; // Maximum pending publishes across the API boundary and worker; default is unlimited\n subscribeThrottlingDelay?: number; // Delay in milliseconds; default is 1ms\n rejectUnauthorized?: boolean;\n clientId?: string;\n hosts?: string[];\n servers?: IMqttServerConfig[];\n port?: number;\n protocol?: MqttProtocol;\n keepalive?: number;\n clean?: boolean;\n connectTimeout?: number;\n reconnectPeriod?: number;\n reconnectOnConnackError?: boolean;\n resubscribe?: boolean;\n queueQoSZero?: boolean;\n properties?: IMqttConnectProperties;\n ca?: string;\n cert?: string;\n key?: string;\n servername?: string;\n /**\n * Default MQTT publish options applied to all outgoing messages\n * (e.g., qos, retain, messageExpiryInterval).\n */\n defaultPublishOptions?: IMqttPublishOptions;\n}\n\nexport interface IUnsProcessParameters {\n processName: string;\n mqttSubToTopics?: string | string[];\n username?: string;\n password?: string;\n mqttSSL?: boolean;\n clientId?: string;\n hosts?: string[];\n servers?: IMqttServerConfig[];\n port?: number;\n protocol?: MqttProtocol;\n keepalive?: number;\n clean?: boolean;\n connectTimeout?: number;\n reconnectPeriod?: number;\n reconnectOnConnackError?: boolean;\n resubscribe?: boolean;\n queueQoSZero?: boolean;\n rejectUnauthorized?: boolean;\n properties?: IMqttConnectProperties;\n ca?: string;\n cert?: string;\n key?: string;\n servername?: string;\n}\n\nexport interface UnsEvents {\n // Emitters in MqttProxy, UnsMqttProxy\n input: { topic: string; message: string, packet: any };\n mqttProxyStatus: { event: string, value: number, uom: MeasurementUnit, statusTopic: string };\n \n // Emitters in MqttProxy\n error: { code: number; message: string };\n \n // Emitters in UnsMqttProxy\n mqttWorker: { command: string, instanceName: string; batchSize: number, referenceHash: string };\n\n // Emitter in UnsCronProxy\n cronEvent: { event?: string; cronExpression?: string };\n\n // Emitters in UnsApiProxy\n apiGetEvent: {req: any, res: any};\n apiPostEvent: {req: any, res: any};\n apiPutEvent: {req: any, res: any};\n apiPatchEvent: {req: any, res: any};\n apiDeleteEvent: {req: any, res: any};\n\n // Emitters in UnsProxy\n unsProxyProducedTopics: { producedTopics: ITopicObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedApiEndpoints: { producedApiEndpoints: IApiObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedServiceEndpoints: { producedServiceEndpoints: IApiObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedDataOfferEndpoints: { producedDataOfferEndpoints: IApiObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedApiCatchAll: { producedCatchall: IApiCatchallMapping[], statusTopic: string };\n\n // Emitters in UnsProxy / UnsApiProxy\n unsProxyProducedDataCatalogOffers: { producedDataCatalogOffers: unknown[], statusTopic: string };\n}\n\nexport interface IUnsExtendedData extends IUnsData {\n valueType: ValueTypeString;\n}\n\nexport interface IUnsData {\n /** Domain-specific evidence/context fields may accompany the canonical value. */\n [key: string]: unknown;\n time: ISO8601;\n value: ValueType;\n /** Storage/routing group for consumers such as archivers; not part of the UNS identity path. */\n dataGroup?: string;\n uom?: MeasurementUnit;\n foreignEventKey?: string;\n intervalStart?: ISO8601 | number;\n intervalEnd?: ISO8601 | number;\n windowStart?: ISO8601 | number;\n windowEnd?: ISO8601 | number;\n eventId?: string;\n deleted?: boolean;\n deletedAt?: ISO8601 | number;\n lastSeen?: ISO8601 | number;\n}\n\nexport interface IUnsTableColumn {\n type: QuestDbType;\n value: string | number | boolean | null;\n uom?: MeasurementUnit;\n}\n\n/** MQTT table columns keyed by their stable UNS/QuestDB column name. */\nexport type IUnsTableColumns = Record<string, IUnsTableColumn>;\n\nexport interface IUnsTable {\n time: ISO8601;\n /** Storage/routing group for consumers such as archivers; not part of the UNS identity path. */\n dataGroup?: string;\n columns: IUnsTableColumns;\n intervalStart?: ISO8601 | number;\n intervalEnd?: ISO8601 | number;\n windowStart?: ISO8601 | number;\n windowEnd?: ISO8601 | number;\n eventId?: string;\n deleted?: boolean;\n deletedAt?: ISO8601 | number;\n lastSeen?: ISO8601 | number;\n}\n\nexport interface IMqttAttributeMessage {\n attribute: UnsAttribute;\n description?: string;\n tags?: UnsTags[];\n attributeNeedsPersistence?: boolean | null;\n /** Optional controller/UI grouping hint for this ObjectId node; does not affect storage/table naming. */\n virtualGroup?: string;\n /** Scalar value shape for schema/catalog consumers, for example \"number\" or \"string\". */\n valueType?: ValueTypeString | (string & {});\n /**\n * Operator-facing presentation hint. Use \"counter\" for cumulative counter\n * state; delta/rate should be requested from Datahub history APIs.\n */\n presentationKind?: string;\n /** Preferred aggregation for sampled history views, for example \"last\". */\n defaultAggregation?: string;\n /** Reset handling hint for cumulative counters. Interpreted by Datahub APIs, not by the producer. */\n counterResetPolicy?: CounterResetPolicy;\n /** Field-level metadata for table columns that should behave as chartable series. */\n tableColumns?: IUnsTableColumnMetadata[];\n /** Optional schema-system role published into Datahub's attribute_schema.schema_json. */\n systemRole?: UnsAttributeSystemRole;\n /** Relationship materialization metadata for `systemRole: \"relationship-evidence\"`. */\n relationshipEvidence?: IUnsRelationshipEvidenceMetadata;\n /** Lifecycle metadata for lifecycle system roles. */\n lifecycle?: IUnsLifecycleMetadata;\n /**\n * How the controller determines if this attribute is live or stale.\n * Defaults to `\"interval\"` with the controller's default interval (~120s) when omitted.\n *\n * @example\n * // Sensor publishing every 2 seconds:\n * { validityMode: \"interval\", expectedIntervalMs: 2000 }\n *\n * // Status attribute publishing every 2 seconds (string values like \"HEATING\"):\n * { validityMode: \"interval\", expectedIntervalMs: 2000 }\n *\n * // Material location with ENTERED/EXITED lifecycle:\n * { validityMode: \"lifecycle\", lifecycleEndValue: \"EXITED\" }\n *\n * // Static configuration value:\n * { validityMode: \"static\" }\n */\n validityMode?: ValidityMode;\n /**\n * Expected publish interval in milliseconds. Only meaningful for `validityMode: \"interval\"`.\n * The controller marks the attribute as stale after ~2× this value without a heartbeat update.\n * Ignored for `\"lifecycle\"` and `\"static\"` modes.\n */\n expectedIntervalMs?: number;\n /**\n * The string value that marks a lifecycle as completed. Only meaningful for `validityMode: \"lifecycle\"`.\n * When the attribute's current value matches this, the controller considers the lifecycle done.\n * Example: `\"EXITED\"` for a location attribute with ENTERED/EXITED events.\n */\n lifecycleEndValue?: string;\n}\n\ntype AttributePayload =\n | { message: IUnsMessage; data?: never; table?: never; createdAt?: never; expiresAt?: never }\n | { message?: never; data: IUnsData; table?: never; createdAt?: ISO8601; expiresAt?: ISO8601 }\n | { message?: never; data?: never; table: IUnsTable; createdAt?: ISO8601; expiresAt?: ISO8601 };\n\nexport type IMqttAttributeEntry = IMqttAttributeMessage & AttributePayload;\n\nexport interface IMqttPublishRequest {\n topic: UnsTopics;\n asset: UnsAsset;\n assetDescription?: string;\n objectType: UnsObjectType;\n objectTypeDescription?: string;\n objectId: UnsObjectId;\n /** Optional controller/UI grouping hint for ObjectId nodes; does not affect storage/table naming. */\n virtualGroup?: string;\n attributes: IMqttAttributeEntry | IMqttAttributeEntry[];\n}\n\n// This interface represents a packet for a UNS system\nexport interface IUnsPacket {\n // The message object of the packet\n message: IUnsExtendedMessage;\n \n // The HMAC signature of the message\n messageSignature?: string;\n\n // Automatically calculated interval between two packets in ms\n interval?: number;\n\n // Current library version\n readonly version: string;\n\n // Autogenerated sequence number\n sequenceId?: number;\n}\n\nexport interface IUnsPackatParameters {\n\n}\n\nexport interface IUnsMessage {\n data?: IUnsData;\n table?: IUnsTable;\n expiresAt?: ISO8601;\n createdAt?: ISO8601;\n}\n\nexport interface IUnsExtendedMessage extends IUnsMessage {\n data?: IUnsExtendedData;\n}\n\n/**\n * Controls how the controller determines whether an attribute is live or stale.\n *\n * - `\"interval\"` — Attribute publishes periodically. Stale if no heartbeat within ~2× the expected interval.\n * Use with `expectedIntervalMs`. Works for both numeric sensors (temperature every 2s)\n * and string status attributes (status every 2s). Example:\n * `{ validityMode: \"interval\", expectedIntervalMs: 2000 }`\n *\n * - `\"lifecycle\"` — Attribute represents a lifecycle with a start and end event.\n * Use with `lifecycleEndValue` to mark the end state. Example: material location with \"ENTERED\" / \"EXITED\".\n *\n * - `\"static\"` — Attribute is set once and never changes (configuration, metadata). Always live.\n *\n * When omitted, defaults to `\"interval\"` with the controller's default interval (~120s).\n */\nexport type ValidityMode = \"interval\" | \"lifecycle\" | \"static\";\n\nexport interface ITopicObject {\n timestamp: string;\n attribute:string;\n attributeType: UnsAttributeType;\n topic:string;\n description:string;\n /** Storage/routing group observed on the latest data/table payload for this identity. */\n dataGroup:string;\n /** Optional controller/UI grouping hint for ObjectId nodes; does not affect storage/table naming. */\n virtualGroup?: string;\n tags:string[] | null;\n attributeNeedsPersistence: boolean | null;\n /** Scalar value shape for schema/catalog consumers, for example \"number\" or \"string\". */\n valueType?: ValueTypeString | (string & {});\n /** Operator-facing presentation hint, for example \"counter\" for cumulative counter state. */\n presentationKind?: string;\n /** Preferred aggregation for sampled history views, for example \"last\". */\n defaultAggregation?: string;\n /** Reset handling hint for cumulative counters. Interpreted by Datahub APIs, not by the producer. */\n counterResetPolicy?: CounterResetPolicy;\n /** Field-level metadata for table columns that should behave as chartable series. */\n tableColumns?: IUnsTableColumnMetadata[];\n /** Optional schema-system role published into Datahub's attribute_schema.schema_json. */\n systemRole?: UnsAttributeSystemRole;\n /** Relationship materialization metadata for `systemRole: \"relationship-evidence\"`. */\n relationshipEvidence?: IUnsRelationshipEvidenceMetadata;\n /** Lifecycle metadata for lifecycle system roles. */\n lifecycle?: IUnsLifecycleMetadata;\n asset: UnsAsset;\n assetDescription?: string;\n objectType: UnsObjectType;\n objectTypeDescription?: string;\n objectId: UnsObjectId;\n /** Liveliness validity mode — how the controller determines if this attribute is live/stale. */\n validityMode?: ValidityMode;\n /** For interval mode: expected publish interval in milliseconds (stale after ~2x this value). */\n expectedIntervalMs?: number;\n /** For lifecycle mode: the string value that marks the lifecycle as completed (e.g. \"EXITED\"). */\n lifecycleEndValue?: string;\n}\n\n// API Interfaces below\nexport interface IApiObject {\n timestamp: string;\n attribute:string;\n topic:string;\n attributeType: UnsAttributeType;\n routeOnly?: boolean;\n registryTopic?: \"api-endpoints\" | \"service-endpoints\" | \"data-offer-endpoints\";\n apiDescription?: string; // Optional description for the API endpoint\n apiHost: string; // Hostname of the service\n apiEndpoint: string; // API endpoint for virtual topics\n apiSwaggerEndpoint: string; // Swagger endpoint for API documentation\n apiMethod: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\"; // HTTP method for API endpoint\n apiQueryParams: QueryParamDef[]; // query parameters for the API endpoint\n serviceApi?: Record<string, unknown> | null;\n asset: UnsAsset;\n objectType: UnsObjectType;\n objectId: UnsObjectId;\n controllerName?: string;\n controllerHost?: string;\n controllerPort?: string;\n controllerPublicBase?: string;\n}\n\nexport interface IApiCatchallMapping {\n topic: string;\n apiBase: string;\n apiBasePath: string;\n swaggerPath: string;\n}\n\nexport interface QueryParamDef {\n name: string;\n type: \"string\" | \"number\" | \"boolean\";\n required?: boolean;\n description?: string;\n /**\n * Optional canonical chat alias used by assistant tooling.\n * Typical values: from, to, limit, topic, timezone, summaryOnly.\n */\n chatCanonical?: string;\n /**\n * Optional default query value. Included in generated OpenAPI metadata.\n */\n defaultValue?: string | number | boolean;\n}\n\nexport interface ApiChatDefaults {\n from?: string;\n to?: string;\n limit?: number;\n topic?: string;\n timezone?: string;\n summaryOnly?: boolean;\n [key: string]: string | number | boolean | undefined;\n}\n\nexport interface IApiProxyOptions {\n jwtSecret?: string;\n /**\n * Public origin advertised for generated API endpoint metadata.\n *\n * Use a hostname or origin without a port (for example `127.0.0.1` or\n * `http://service-name`) to keep the API server's actual listening port.\n * An explicitly supplied port is preserved. Defaults to the machine's\n * external IPv4 address for backwards compatibility.\n */\n publishedApiHost?: string;\n jwks?: {\n wellKnownJwksUrl: string;\n activeKidUrl?: string;\n cacheTtlMs?: number;\n algorithms?: (\"RS256\" | \"RS384\" | \"RS512\")[];\n };\n /**\n * Optional base prefixes to mount the API and swagger JSON under (e.g. \"/archiver-3\").\n * Defaults to \"/api\" when not provided.\n */\n apiBasePath?: string;\n swaggerBasePath?: string;\n /**\n * Skip mounting the default \"/api\" route. Useful when rebasing entirely under a custom prefix.\n */\n disableDefaultApiMount?: boolean;\n}\n\nexport interface IGetEndpointOptions {\n apiDescription?: string;\n tags?: string[];\n queryParams?: QueryParamDef[];\n routeOnly?: boolean;\n registryTopic?: \"api-endpoints\" | \"service-endpoints\" | \"data-offer-endpoints\";\n serviceApi?: Record<string, unknown>;\n /**\n * Optional defaults consumed by chat tooling (published as OpenAPI vendor extension x-uns-chat.defaults).\n */\n chatDefaults?: ApiChatDefaults;\n}\n\nexport interface IPostEndpointOptions {\n apiDescription?: string;\n tags?: string[];\n routeOnly?: boolean;\n registryTopic?: \"api-endpoints\" | \"service-endpoints\" | \"data-offer-endpoints\";\n serviceApi?: Record<string, unknown>;\n requestBody?: {\n description?: string;\n required?: boolean;\n schema?: Record<string, unknown>;\n };\n}\n\nexport interface IPutEndpointOptions extends IPostEndpointOptions {}\nexport interface IPatchEndpointOptions extends IPostEndpointOptions {}\nexport interface IDeleteEndpointOptions extends IPostEndpointOptions {}\n"]}
1
+ {"version":3,"file":"uns-interfaces.js","sourceRoot":"","sources":["../../src/uns/uns-interfaces.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,YAAY,GAAG,+CAA+C,CAAC;IACrE,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAID,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC;AA6CxD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS;IACT,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,cAAc;IACd,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,SAAS;CACD,CAAC;AAEX,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,qBAAqB,CAAC,CAAC;AACvE,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AACnD,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AACnD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAW3C,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/B,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/B,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { UnsAttributeType } from \"../graphql/schema.js\";\nimport { MeasurementUnit } from \"./uns-measurements.js\";\nimport { UnsTags } from \"./uns-tags.js\";\nimport type { UnsObjectId, UnsObjectType } from \"./uns-object.js\";\nimport type { UnsAsset } from \"./uns-asset.js\";\nimport type { IMqttConnectProperties, IMqttPublishOptions, IMqttServerConfig, MqttProtocol } from \"../uns-mqtt/mqtt-interfaces.js\";\nimport { UnsTopics } from \"./uns-topics.js\";\nimport { knownUnsAttributes, type KnownUnsAttributeName } from \"./uns-attributes.js\";\n\nexport type ISO8601 = `${number}-${string}-${string}T${string}:${string}:${string}.${string}Z`;\nexport function isIOS8601Type(value: string): value is ISO8601 {\n const iso8601Regex = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n return iso8601Regex.test(value);\n}\n// Known attribute names (with IntelliSense) while still allowing arbitrary strings.\nexport type UnsAttribute = KnownUnsAttributeName | (string & {});\n\nexport const valueTypes = [\"string\", \"number\"] as const;\nexport type ValueTypeString = (typeof valueTypes)[number];\nexport type ScalarValueType = string | number;\n/** Scalar telemetry or a scalar array used by metadata such as relationship evidence. */\nexport type ValueType = ScalarValueType | ScalarValueType[];\n\nexport type CounterResetPolicy = \"new-value\" | \"null\" | \"rollover\" | (string & {});\n\nexport type UnsAttributeSystemRole =\n | \"relationship-evidence\"\n | \"lifecycle-start\"\n | \"lifecycle-end\"\n | \"lifecycle-time-source\"\n | (string & {});\n\nexport type UnsRelationshipEndpoint = \"source\" | \"target\";\n\nexport interface IUnsRelationshipEvidenceMetadata {\n relationshipKey: string;\n ownerEndpoint?: UnsRelationshipEndpoint;\n valueEndpoint?: UnsRelationshipEndpoint;\n /** Scalar values produce one edge; array values produce one edge per ObjectId value. */\n sourceObjectType?: UnsObjectType | (string & {});\n targetObjectType?: UnsObjectType | (string & {});\n sourceObjectIdFrom?: string;\n targetObjectIdFrom?: string;\n observedAtFrom?: string;\n status?: \"suggested\" | \"accepted\" | (string & {});\n defaultStatus?: \"suggested\" | \"accepted\" | (string & {});\n}\n\nexport interface IUnsLifecycleMetadata {\n timestampFrom?: \"value\" | \"packetTimestamp\" | (string & {});\n startValues?: string[];\n endValues?: string[];\n}\n\nexport interface IUnsTableColumnMetadata {\n name: string;\n valueType?: ValueTypeString | (string & {});\n presentationKind?: string;\n defaultAggregation?: string;\n counterResetPolicy?: CounterResetPolicy;\n}\n\nexport const questDbPrimitiveTypes = [\n \"boolean\",\n \"ipv4\",\n \"byte\",\n \"short\",\n \"char\",\n \"int\",\n \"float\",\n \"symbol\",\n \"varchar\",\n \"string\",\n \"long\",\n \"date\",\n \"timestamp\",\n \"timestamp_ns\",\n \"double\",\n \"uuid\",\n \"binary\",\n \"long256\",\n] as const;\n\nconst questDbPrimitiveTypeSet = new Set<string>(questDbPrimitiveTypes);\nconst questDbGeohashRegex = /^geohash\\(\\d+[bc]\\)$/;\nconst questDbDecimalRegex = /^decimal\\(\\d+,\\d+\\)$/;\nconst questDbArrayRegex = /^array<[^>]+>$/;\n\nexport type QuestDbPrimitiveType = (typeof questDbPrimitiveTypes)[number];\n\n// Supported QuestDB column types for UNS tables.\nexport type QuestDbType =\n | QuestDbPrimitiveType\n | `geohash(${number}${\"b\" | \"c\"})`\n | `decimal(${number},${number})`\n | `array<${string}>`;\n\nexport function isQuestDbType(value: unknown): value is QuestDbType {\n if (typeof value !== \"string\") {\n return false;\n }\n if (questDbPrimitiveTypeSet.has(value)) {\n return true;\n }\n return (\n questDbGeohashRegex.test(value) ||\n questDbDecimalRegex.test(value) ||\n questDbArrayRegex.test(value)\n );\n}\n\nexport interface IUnsParameters {\n mqttSubToTopics?: string | string[];\n username?: string;\n password?: string;\n mqttSSL?: boolean;\n publishThrottlingDelay?: number; // Delay in milliseconds; default is 1ms\n publishConcurrency?: number; // Maximum concurrent outgoing publishes; default is 1\n maxPendingPublishes?: number; // Maximum pending publishes across the API boundary and worker; default is unlimited\n subscribeThrottlingDelay?: number; // Delay in milliseconds; default is 1ms\n rejectUnauthorized?: boolean;\n clientId?: string;\n hosts?: string[];\n servers?: IMqttServerConfig[];\n port?: number;\n protocol?: MqttProtocol;\n keepalive?: number;\n clean?: boolean;\n connectTimeout?: number;\n reconnectPeriod?: number;\n reconnectOnConnackError?: boolean;\n resubscribe?: boolean;\n queueQoSZero?: boolean;\n properties?: IMqttConnectProperties;\n ca?: string;\n cert?: string;\n key?: string;\n servername?: string;\n /**\n * Default MQTT publish options applied to all outgoing messages\n * (e.g., qos, retain, messageExpiryInterval).\n */\n defaultPublishOptions?: IMqttPublishOptions;\n}\n\nexport interface IUnsProcessParameters {\n processName: string;\n /**\n * Optional controller-supplied correlation id for one cooperative handover.\n * Older peers ignore it, so it must never be required for normal startup.\n */\n handoverId?: string;\n mqttSubToTopics?: string | string[];\n username?: string;\n password?: string;\n mqttSSL?: boolean;\n clientId?: string;\n hosts?: string[];\n servers?: IMqttServerConfig[];\n port?: number;\n protocol?: MqttProtocol;\n keepalive?: number;\n clean?: boolean;\n connectTimeout?: number;\n reconnectPeriod?: number;\n reconnectOnConnackError?: boolean;\n resubscribe?: boolean;\n queueQoSZero?: boolean;\n rejectUnauthorized?: boolean;\n properties?: IMqttConnectProperties;\n ca?: string;\n cert?: string;\n key?: string;\n servername?: string;\n}\n\nexport interface UnsEvents {\n // Emitters in MqttProxy, UnsMqttProxy\n input: { topic: string; message: string, packet: any };\n mqttProxyStatus: { event: string, value: number, uom: MeasurementUnit, statusTopic: string };\n \n // Emitters in MqttProxy\n error: { code: number; message: string };\n \n // Emitters in UnsMqttProxy\n mqttWorker: { command: string, instanceName: string; batchSize: number, referenceHash: string };\n\n // Emitter in UnsCronProxy\n cronEvent: { event?: string; cronExpression?: string };\n\n // Emitters in UnsApiProxy\n apiGetEvent: {req: any, res: any};\n apiPostEvent: {req: any, res: any};\n apiPutEvent: {req: any, res: any};\n apiPatchEvent: {req: any, res: any};\n apiDeleteEvent: {req: any, res: any};\n\n // Emitters in UnsProxy\n unsProxyProducedTopics: { producedTopics: ITopicObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedApiEndpoints: { producedApiEndpoints: IApiObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedServiceEndpoints: { producedServiceEndpoints: IApiObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedDataOfferEndpoints: { producedDataOfferEndpoints: IApiObject[], statusTopic: string };\n\n // Emitters in UnsProxy\n unsProxyProducedApiCatchAll: { producedCatchall: IApiCatchallMapping[], statusTopic: string };\n\n // Emitters in UnsProxy / UnsApiProxy\n unsProxyProducedDataCatalogOffers: { producedDataCatalogOffers: unknown[], statusTopic: string };\n}\n\nexport interface IUnsExtendedData extends IUnsData {\n valueType: ValueTypeString;\n}\n\nexport interface IUnsData {\n /** Domain-specific evidence/context fields may accompany the canonical value. */\n [key: string]: unknown;\n time: ISO8601;\n value: ValueType;\n /** Storage/routing group for consumers such as archivers; not part of the UNS identity path. */\n dataGroup?: string;\n uom?: MeasurementUnit;\n foreignEventKey?: string;\n intervalStart?: ISO8601 | number;\n intervalEnd?: ISO8601 | number;\n windowStart?: ISO8601 | number;\n windowEnd?: ISO8601 | number;\n eventId?: string;\n deleted?: boolean;\n deletedAt?: ISO8601 | number;\n lastSeen?: ISO8601 | number;\n}\n\nexport interface IUnsTableColumn {\n type: QuestDbType;\n value: string | number | boolean | null;\n uom?: MeasurementUnit;\n}\n\n/** MQTT table columns keyed by their stable UNS/QuestDB column name. */\nexport type IUnsTableColumns = Record<string, IUnsTableColumn>;\n\nexport interface IUnsTable {\n time: ISO8601;\n /** Storage/routing group for consumers such as archivers; not part of the UNS identity path. */\n dataGroup?: string;\n columns: IUnsTableColumns;\n intervalStart?: ISO8601 | number;\n intervalEnd?: ISO8601 | number;\n windowStart?: ISO8601 | number;\n windowEnd?: ISO8601 | number;\n eventId?: string;\n deleted?: boolean;\n deletedAt?: ISO8601 | number;\n lastSeen?: ISO8601 | number;\n}\n\nexport interface IMqttAttributeMessage {\n attribute: UnsAttribute;\n description?: string;\n tags?: UnsTags[];\n attributeNeedsPersistence?: boolean | null;\n /** Optional controller/UI grouping hint for this ObjectId node; does not affect storage/table naming. */\n virtualGroup?: string;\n /** Scalar value shape for schema/catalog consumers, for example \"number\" or \"string\". */\n valueType?: ValueTypeString | (string & {});\n /**\n * Operator-facing presentation hint. Use \"counter\" for cumulative counter\n * state; delta/rate should be requested from Datahub history APIs.\n */\n presentationKind?: string;\n /** Preferred aggregation for sampled history views, for example \"last\". */\n defaultAggregation?: string;\n /** Reset handling hint for cumulative counters. Interpreted by Datahub APIs, not by the producer. */\n counterResetPolicy?: CounterResetPolicy;\n /** Field-level metadata for table columns that should behave as chartable series. */\n tableColumns?: IUnsTableColumnMetadata[];\n /** Optional schema-system role published into Datahub's attribute_schema.schema_json. */\n systemRole?: UnsAttributeSystemRole;\n /** Relationship materialization metadata for `systemRole: \"relationship-evidence\"`. */\n relationshipEvidence?: IUnsRelationshipEvidenceMetadata;\n /** Lifecycle metadata for lifecycle system roles. */\n lifecycle?: IUnsLifecycleMetadata;\n /**\n * How the controller determines if this attribute is live or stale.\n * Defaults to `\"interval\"` with the controller's default interval (~120s) when omitted.\n *\n * @example\n * // Sensor publishing every 2 seconds:\n * { validityMode: \"interval\", expectedIntervalMs: 2000 }\n *\n * // Status attribute publishing every 2 seconds (string values like \"HEATING\"):\n * { validityMode: \"interval\", expectedIntervalMs: 2000 }\n *\n * // Material location with ENTERED/EXITED lifecycle:\n * { validityMode: \"lifecycle\", lifecycleEndValue: \"EXITED\" }\n *\n * // Static configuration value:\n * { validityMode: \"static\" }\n */\n validityMode?: ValidityMode;\n /**\n * Expected publish interval in milliseconds. Only meaningful for `validityMode: \"interval\"`.\n * The controller marks the attribute as stale after ~2× this value without a heartbeat update.\n * Ignored for `\"lifecycle\"` and `\"static\"` modes.\n */\n expectedIntervalMs?: number;\n /**\n * The string value that marks a lifecycle as completed. Only meaningful for `validityMode: \"lifecycle\"`.\n * When the attribute's current value matches this, the controller considers the lifecycle done.\n * Example: `\"EXITED\"` for a location attribute with ENTERED/EXITED events.\n */\n lifecycleEndValue?: string;\n}\n\ntype AttributePayload =\n | { message: IUnsMessage; data?: never; table?: never; createdAt?: never; expiresAt?: never }\n | { message?: never; data: IUnsData; table?: never; createdAt?: ISO8601; expiresAt?: ISO8601 }\n | { message?: never; data?: never; table: IUnsTable; createdAt?: ISO8601; expiresAt?: ISO8601 };\n\nexport type IMqttAttributeEntry = IMqttAttributeMessage & AttributePayload;\n\nexport type IAssetIdentityPublicationMetadata =\n | {\n assetStableEntityId?: never;\n assetDisplayName?: never;\n assetIdentityProof?: never;\n }\n | {\n /** Controller-issued stable Asset UUID. It identifies the Asset, not its current path. */\n assetStableEntityId: string;\n /** Optional operator-facing name; never used as an identity key. */\n assetDisplayName?: string;\n /** Short-lived controller-signed proof bound to this Asset UUID and exact candidate path. */\n assetIdentityProof: string;\n };\n\nexport type IMqttPublishRequest = {\n topic: UnsTopics;\n asset: UnsAsset;\n assetDescription?: string;\n objectType: UnsObjectType;\n objectTypeDescription?: string;\n objectId: UnsObjectId;\n /** Optional controller/UI grouping hint for ObjectId nodes; does not affect storage/table naming. */\n virtualGroup?: string;\n attributes: IMqttAttributeEntry | IMqttAttributeEntry[];\n} & IAssetIdentityPublicationMetadata;\n\n// This interface represents a packet for a UNS system\nexport interface IUnsPacket {\n // The message object of the packet\n message: IUnsExtendedMessage;\n \n // The HMAC signature of the message\n messageSignature?: string;\n\n // Automatically calculated interval between two packets in ms\n interval?: number;\n\n // Current library version\n readonly version: string;\n\n // Autogenerated sequence number\n sequenceId?: number;\n}\n\nexport interface IUnsPackatParameters {\n\n}\n\nexport interface IUnsMessage {\n data?: IUnsData;\n table?: IUnsTable;\n expiresAt?: ISO8601;\n createdAt?: ISO8601;\n}\n\nexport interface IUnsExtendedMessage extends IUnsMessage {\n data?: IUnsExtendedData;\n}\n\n/**\n * Controls how the controller determines whether an attribute is live or stale.\n *\n * - `\"interval\"` — Attribute publishes periodically. Stale if no heartbeat within ~2× the expected interval.\n * Use with `expectedIntervalMs`. Works for both numeric sensors (temperature every 2s)\n * and string status attributes (status every 2s). Example:\n * `{ validityMode: \"interval\", expectedIntervalMs: 2000 }`\n *\n * - `\"lifecycle\"` — Attribute represents a lifecycle with a start and end event.\n * Use with `lifecycleEndValue` to mark the end state. Example: material location with \"ENTERED\" / \"EXITED\".\n *\n * - `\"static\"` — Attribute is set once and never changes (configuration, metadata). Always live.\n *\n * When omitted, defaults to `\"interval\"` with the controller's default interval (~120s).\n */\nexport type ValidityMode = \"interval\" | \"lifecycle\" | \"static\";\n\nexport interface ITopicObject {\n timestamp: string;\n attribute:string;\n attributeType: UnsAttributeType;\n topic:string;\n description:string;\n /** Storage/routing group observed on the latest data/table payload for this identity. */\n dataGroup:string;\n /** Optional controller/UI grouping hint for ObjectId nodes; does not affect storage/table naming. */\n virtualGroup?: string;\n tags:string[] | null;\n attributeNeedsPersistence: boolean | null;\n /** Scalar value shape for schema/catalog consumers, for example \"number\" or \"string\". */\n valueType?: ValueTypeString | (string & {});\n /** Operator-facing presentation hint, for example \"counter\" for cumulative counter state. */\n presentationKind?: string;\n /** Preferred aggregation for sampled history views, for example \"last\". */\n defaultAggregation?: string;\n /** Reset handling hint for cumulative counters. Interpreted by Datahub APIs, not by the producer. */\n counterResetPolicy?: CounterResetPolicy;\n /** Field-level metadata for table columns that should behave as chartable series. */\n tableColumns?: IUnsTableColumnMetadata[];\n /** Optional schema-system role published into Datahub's attribute_schema.schema_json. */\n systemRole?: UnsAttributeSystemRole;\n /** Relationship materialization metadata for `systemRole: \"relationship-evidence\"`. */\n relationshipEvidence?: IUnsRelationshipEvidenceMetadata;\n /** Lifecycle metadata for lifecycle system roles. */\n lifecycle?: IUnsLifecycleMetadata;\n asset: UnsAsset;\n assetDescription?: string;\n /** Optional stable Asset UUID; accepted by the controller only with a valid publication proof. */\n assetStableEntityId?: string;\n /** Optional operator-facing name; never used as an identity key. */\n assetDisplayName?: string;\n /** Short-lived controller-signed evidence for this exact Asset path. */\n assetIdentityProof?: string;\n objectType: UnsObjectType;\n objectTypeDescription?: string;\n objectId: UnsObjectId;\n /** Liveliness validity mode — how the controller determines if this attribute is live/stale. */\n validityMode?: ValidityMode;\n /** For interval mode: expected publish interval in milliseconds (stale after ~2x this value). */\n expectedIntervalMs?: number;\n /** For lifecycle mode: the string value that marks the lifecycle as completed (e.g. \"EXITED\"). */\n lifecycleEndValue?: string;\n}\n\n// API Interfaces below\nexport interface IApiObject {\n timestamp: string;\n attribute:string;\n topic:string;\n attributeType: UnsAttributeType;\n routeOnly?: boolean;\n registryTopic?: \"api-endpoints\" | \"service-endpoints\" | \"data-offer-endpoints\";\n apiDescription?: string; // Optional description for the API endpoint\n apiHost: string; // Hostname of the service\n apiEndpoint: string; // API endpoint for virtual topics\n apiSwaggerEndpoint: string; // Swagger endpoint for API documentation\n apiMethod: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\"; // HTTP method for API endpoint\n apiQueryParams: QueryParamDef[]; // query parameters for the API endpoint\n serviceApi?: Record<string, unknown> | null;\n asset: UnsAsset;\n objectType: UnsObjectType;\n objectId: UnsObjectId;\n controllerName?: string;\n controllerHost?: string;\n controllerPort?: string;\n controllerPublicBase?: string;\n}\n\nexport interface IApiCatchallMapping {\n topic: string;\n apiBase: string;\n apiBasePath: string;\n swaggerPath: string;\n}\n\nexport interface QueryParamDef {\n name: string;\n type: \"string\" | \"number\" | \"boolean\";\n required?: boolean;\n description?: string;\n /**\n * Optional canonical chat alias used by assistant tooling.\n * Typical values: from, to, limit, topic, timezone, summaryOnly.\n */\n chatCanonical?: string;\n /**\n * Optional default query value. Included in generated OpenAPI metadata.\n */\n defaultValue?: string | number | boolean;\n}\n\nexport interface ApiChatDefaults {\n from?: string;\n to?: string;\n limit?: number;\n topic?: string;\n timezone?: string;\n summaryOnly?: boolean;\n [key: string]: string | number | boolean | undefined;\n}\n\nexport interface IApiProxyOptions {\n jwtSecret?: string;\n /**\n * Public origin advertised for generated API endpoint metadata.\n *\n * Use a hostname or origin without a port (for example `127.0.0.1` or\n * `http://service-name`) to keep the API server's actual listening port.\n * An explicitly supplied port is preserved. Defaults to the machine's\n * external IPv4 address for backwards compatibility.\n */\n publishedApiHost?: string;\n jwks?: {\n wellKnownJwksUrl: string;\n activeKidUrl?: string;\n cacheTtlMs?: number;\n algorithms?: (\"RS256\" | \"RS384\" | \"RS512\")[];\n };\n /**\n * Optional base prefixes to mount the API and swagger JSON under (e.g. \"/archiver-3\").\n * Defaults to \"/api\" when not provided.\n */\n apiBasePath?: string;\n swaggerBasePath?: string;\n /**\n * Skip mounting the default \"/api\" route. Useful when rebasing entirely under a custom prefix.\n */\n disableDefaultApiMount?: boolean;\n}\n\nexport interface IGetEndpointOptions {\n apiDescription?: string;\n tags?: string[];\n queryParams?: QueryParamDef[];\n routeOnly?: boolean;\n registryTopic?: \"api-endpoints\" | \"service-endpoints\" | \"data-offer-endpoints\";\n serviceApi?: Record<string, unknown>;\n /**\n * Optional defaults consumed by chat tooling (published as OpenAPI vendor extension x-uns-chat.defaults).\n */\n chatDefaults?: ApiChatDefaults;\n}\n\nexport interface IPostEndpointOptions {\n apiDescription?: string;\n tags?: string[];\n routeOnly?: boolean;\n registryTopic?: \"api-endpoints\" | \"service-endpoints\" | \"data-offer-endpoints\";\n serviceApi?: Record<string, unknown>;\n requestBody?: {\n description?: string;\n required?: boolean;\n schema?: Record<string, unknown>;\n };\n}\n\nexport interface IPutEndpointOptions extends IPostEndpointOptions {}\nexport interface IPatchEndpointOptions extends IPostEndpointOptions {}\nexport interface IDeleteEndpointOptions extends IPostEndpointOptions {}\n"]}
@@ -22,6 +22,7 @@ declare class UnsProxyProcess {
22
22
  private processStatusTopic;
23
23
  private processName;
24
24
  private processId;
25
+ private handoverId;
25
26
  private unsMqttProxies;
26
27
  private unsApiProxies;
27
28
  private processMqttProxy;
@@ -1 +1 @@
1
- {"version":3,"file":"uns-proxy-process.d.ts","sourceRoot":"","sources":["../../src/uns/uns-proxy-process.ts"],"names":[],"mappings":"AAMA,OAAO,YAAY,MAAM,+BAA+B,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAI7E,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,uBAAuB,EAA2B,MAAM,uBAAuB,CAAC;AAEvH,OAAO,EAAe,cAAc,EAAE,qBAAqB,EAAa,MAAM,qBAAqB,CAAC;AAGpG;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAEjG,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;AAEvF,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACpD,eAAe,EAAE,OAAO,eAAe,CAAC;CACzC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAE5E,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAkB;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AAO,CAAC,eAAe,CAA8B;IAGrD,MAAM,CAAC,gBAAgB,SAAK;IAC5B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAoC;IAC7D,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAqB;IACzD,OAAO,CAAC,MAAM,CAAC,OAAO,CAAS;IAE/B,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,qBAAqB;IAOxC,OAAO,CAAC,MAAM,CAAC,WAAW;IA0B1B,OAAO,CAAC,MAAM,CAAC,QAAQ;IAOvB,OAAO,CAAC,gBAAgB,CAAuB;gBAEnC,QAAQ,EAAE,MAAM,EAAE,yBAAyB,EAAE,qBAAqB;IAuE9E;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;OAEG;IACU,kBAAkB,CAC7B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,OAAO,EACjB,aAAa,CAAC,EAAE,cAAc,GAC7B,OAAO,CAAC,YAAY,CAAC;IAqCX,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtD;;;;;;OAMG;IACU,sBAAsB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWnG;;;OAGG;IACI,QAAQ,CAAC,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC;YASvD,eAAe;CAgD9B;AAED,UAAU,eAAe;CAAG;AAE5B,eAAe,eAAe,CAAC;AAC/B,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -14,6 +14,7 @@ class UnsProxyProcess {
14
14
  processStatusTopic;
15
15
  processName;
16
16
  processId;
17
+ handoverId;
17
18
  unsMqttProxies;
18
19
  unsApiProxies;
19
20
  processMqttProxy;
@@ -76,6 +77,7 @@ class UnsProxyProcess {
76
77
  }
77
78
  this.processName = unsProxyProcessParameters.processName;
78
79
  this.processId = randomBytes(16).toString("hex");
80
+ this.handoverId = unsProxyProcessParameters.handoverId ?? process.env["UNS_HANDOVER_ID"];
79
81
  const { name: packageName, version } = PACKAGE_INFO;
80
82
  // Instantiate the topic builder.
81
83
  const topicBuilder = new MqttTopicBuilder(`uns-infra/${MqttTopicBuilder.sanitizeTopicPart(packageName)}/${MqttTopicBuilder.sanitizeTopicPart(version)}/${MqttTopicBuilder.sanitizeTopicPart(this.processName)}/`);
@@ -124,10 +126,10 @@ class UnsProxyProcess {
124
126
  * Initializes the HandoverManager instance and sets up event listeners for handover and MQTT input events.
125
127
  * Determines handover and force start modes based on process arguments.
126
128
  */
127
- initHandoverManager(instanceMode, handover) {
129
+ initHandoverManager(instanceMode, handover, handoverId) {
128
130
  const handoverRequestEnabled = instanceMode == "handover" ? true : false;
129
131
  const forceStartEnabled = instanceMode == "force" ? true : false;
130
- this.handoverManager = new HandoverManager(this.processName, this.processId, this.processMqttProxy, this.unsMqttProxies, handoverRequestEnabled, handover ?? true, forceStartEnabled);
132
+ this.handoverManager = new HandoverManager(this.processName, this.processId, this.processMqttProxy, this.unsMqttProxies, handoverRequestEnabled, handover ?? true, forceStartEnabled, handoverId);
131
133
  // Listen for handover events.
132
134
  this.handoverManager.event.on("handoverManager", (event) => {
133
135
  this.active = event.active;
@@ -146,7 +148,7 @@ class UnsProxyProcess {
146
148
  await this.waitForProcessConnection();
147
149
  // Currently handover manager can handle only mqtt events
148
150
  if (!this.handoverManager) {
149
- this.initHandoverManager(instanceMode, handover);
151
+ this.initHandoverManager(instanceMode, handover, this.handoverId);
150
152
  }
151
153
  const resolvedUnsParameters = {
152
154
  ...(unsParameters ?? {}),
@@ -1 +1 @@
1
- {"version":3,"file":"uns-proxy-process.js","sourceRoot":"","sources":["../../src/uns/uns-proxy-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,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import logger from \"../logger.js\";\nimport { IMqttParameters } from \"../uns-mqtt/mqtt-interfaces.js\";\nimport MqttProxy from \"../uns-mqtt/mqtt-proxy.js\";\nimport { MqttTopicBuilder } from \"../uns-mqtt/mqtt-topic-builder.js\";\nimport UnsMqttProxy from \"../uns-mqtt/uns-mqtt-proxy.js\";\nimport type { UnsMqttProxyStopOptions } from \"../uns-mqtt/uns-mqtt-proxy.js\";\nimport { HandoverManager } from \"./handover-manager.js\";\n// Import configuration and initialization modules.\nimport { MQTT_UPDATE_INTERVAL, PACKAGE_INFO } from \"./process-config.js\";\nimport { type UnsServiceMetadata, type UnsServiceMetadataInput, buildUnsServiceMetadata } from \"./service-metadata.js\";\nimport { StatusMonitor } from \"./status-monitor.js\";\nimport { IUnsMessage, IUnsParameters, IUnsProcessParameters, UnsEvents } from \"./uns-interfaces.js\";\nimport { UnsPacket } from \"./uns-packet.js\";\n\n/**\n * UnsProxyProcess is responsible for managing the process lifecycle,\n * configuring MQTT (subscriptions and publishing for status updates), and\n * handling UNS proxy instances.\n *\n * It leverages HandoverManager for handover events and StatusMonitor for health reporting.\n */\nexport type UnsProxyProcessPluginMethod = (this: UnsProxyProcess, ...args: unknown[]) => unknown;\n\nexport type UnsProxyProcessPluginMethods = Record<string, UnsProxyProcessPluginMethod>;\n\nexport interface UnsProxyProcessPluginApi {\n version: number;\n define(methods: UnsProxyProcessPluginMethods): void;\n UnsProxyProcess: typeof UnsProxyProcess;\n}\n\nexport type UnsProxyProcessPlugin = (api: UnsProxyProcessPluginApi) => void;\n\nclass UnsProxyProcess {\n private active: boolean = false;\n private processStatusTopic: string;\n private processName: string;\n private processId: string;\n private unsMqttProxies: UnsMqttProxy[];\n private unsApiProxies: unknown[];\n private processMqttProxy: MqttProxy;\n private handoverManager: HandoverManager;\n private statusMonitor: StatusMonitor;\n private serviceMetadataTopic: string;\n private shutdownPromise: Promise<void> | null = null;\n\n // Plugin\n static pluginApiVersion = 1;\n private static registered = new Set<UnsProxyProcessPlugin>();\n private static registeredMethodNames = new Set<string>();\n private static applied = false;\n\n static use(plugin: UnsProxyProcessPlugin) {\n if (this.registered.has(plugin)) return this;\n this.registered.add(plugin);\n if (this.applied) this.applyPlugin(plugin);\n return this;\n }\n\n private static applyPlugin(plugin: UnsProxyProcessPlugin) {\n const define: UnsProxyProcessPluginApi[\"define\"] = (methods) => {\n for (const [name, fn] of Object.entries(methods)) {\n if (typeof fn !== \"function\") {\n throw new TypeError(`UnsProxyProcess plugin attempted to register non-function member \\\"${name}\\\".`);\n }\n if (this.registeredMethodNames.has(name) || Reflect.has(this.prototype, name)) {\n throw new Error(`UnsProxyProcess plugin attempted to overwrite existing member \\\"${name}\\\".`);\n }\n Object.defineProperty(this.prototype, name, {\n value: fn,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n this.registeredMethodNames.add(name);\n }\n };\n\n plugin({\n define,\n version: this.pluginApiVersion,\n UnsProxyProcess: this,\n });\n }\n\n private static applyAll() {\n if (this.applied) return;\n this.applied = true;\n for (const p of this.registered) this.applyPlugin(p);\n }\n\n // References for cleanup.\n private mqttInputHandler: (event: any) => void;\n\n constructor(mqttHost: string, unsProxyProcessParameters: IUnsProcessParameters) {\n (this.constructor as typeof UnsProxyProcess).applyAll(); // Activate all the plugins\n\n this.unsMqttProxies = [];\n this.unsApiProxies = [];\n if (!unsProxyProcessParameters?.processName) {\n throw new Error(\"UnsProxyProcess requires a processName in configuration.\");\n }\n this.processName = unsProxyProcessParameters.processName;\n this.processId = randomBytes(16).toString(\"hex\");\n const { name: packageName, version } = PACKAGE_INFO;\n\n // Instantiate the topic builder.\n const topicBuilder = new MqttTopicBuilder(\n `uns-infra/${MqttTopicBuilder.sanitizeTopicPart(packageName)}/${MqttTopicBuilder.sanitizeTopicPart(version)}/${MqttTopicBuilder.sanitizeTopicPart(this.processName)}/`,\n );\n\n // Generate topics.\n const processStatusTopic = topicBuilder.getProcessStatusTopic();\n const handoverTopic = topicBuilder.getHandoverTopic();\n const wildcardActiveTopic = topicBuilder.getWildcardActiveTopic();\n const serviceMetadataTopic = topicBuilder.getServiceMetadataTopic();\n\n this.processStatusTopic = processStatusTopic;\n this.serviceMetadataTopic = serviceMetadataTopic;\n\n // Configure MQTT topics for subscription.\n const mqttSubToTopics = unsProxyProcessParameters?.mqttSubToTopics ?? [wildcardActiveTopic, handoverTopic];\n const mqttParameters: IMqttParameters = {\n mqttSubToTopics,\n username: unsProxyProcessParameters?.username ?? \"\",\n password: unsProxyProcessParameters?.password ?? \"\",\n mqttSSL: unsProxyProcessParameters?.mqttSSL ?? false,\n statusTopic: this.processStatusTopic,\n clientId: unsProxyProcessParameters?.clientId ?? `${this.processName}-${this.processId}`,\n hosts: unsProxyProcessParameters?.hosts,\n servers: unsProxyProcessParameters?.servers,\n port: unsProxyProcessParameters?.port,\n protocol: unsProxyProcessParameters?.protocol,\n keepalive: unsProxyProcessParameters?.keepalive,\n clean: unsProxyProcessParameters?.clean,\n connectTimeout: unsProxyProcessParameters?.connectTimeout,\n reconnectPeriod: unsProxyProcessParameters?.reconnectPeriod,\n reconnectOnConnackError: unsProxyProcessParameters?.reconnectOnConnackError,\n resubscribe: unsProxyProcessParameters?.resubscribe,\n queueQoSZero: unsProxyProcessParameters?.queueQoSZero,\n rejectUnauthorized: unsProxyProcessParameters?.rejectUnauthorized ?? false,\n properties: unsProxyProcessParameters?.properties,\n ca: unsProxyProcessParameters?.ca,\n cert: unsProxyProcessParameters?.cert,\n key: unsProxyProcessParameters?.key,\n servername: unsProxyProcessParameters?.servername,\n };\n\n // Initialize MQTT proxy and start connection.\n this.processMqttProxy = new MqttProxy(mqttHost, this.processName, mqttParameters);\n this.processMqttProxy.start();\n\n // Instantiate and start the StatusMonitor for memory and status updates.\n this.statusMonitor = new StatusMonitor(\n this.processMqttProxy,\n this.processStatusTopic,\n () => this.active,\n MQTT_UPDATE_INTERVAL,\n MQTT_UPDATE_INTERVAL,\n { processName: this.processName, processId: this.processId },\n );\n this.statusMonitor.start();\n }\n\n /**\n * Initializes the HandoverManager instance and sets up event listeners for handover and MQTT input events.\n * Determines handover and force start modes based on process arguments.\n */\n private initHandoverManager(instanceMode: string, handover: boolean) {\n const handoverRequestEnabled = instanceMode == \"handover\" ? true : false;\n const forceStartEnabled = instanceMode == \"force\" ? true : false;\n\n this.handoverManager = new HandoverManager(\n this.processName,\n this.processId,\n this.processMqttProxy,\n this.unsMqttProxies,\n handoverRequestEnabled,\n handover ?? true,\n forceStartEnabled,\n );\n\n // Listen for handover events.\n this.handoverManager.event.on(\"handoverManager\", (event) => {\n this.active = event.active;\n });\n\n // Delegate MQTT events to the HandoverManager.\n this.mqttInputHandler = async (event: UnsEvents[\"input\"]) => {\n await this.handoverManager.handleMqttMessage(event);\n };\n this.processMqttProxy.event.on(\"input\", this.mqttInputHandler);\n }\n\n /**\n * Creates a new UNS proxy instance and stores it for future management.\n */\n public async createUnsMqttProxy(\n mqttHost: string,\n instanceName: string,\n instanceMode: string,\n handover: boolean,\n unsParameters?: IUnsParameters,\n ): Promise<UnsMqttProxy> {\n // Wait until the MQTT connection is established before proceeding.\n await this.waitForProcessConnection();\n\n // Currently handover manager can handle only mqtt events\n if (!this.handoverManager) {\n this.initHandoverManager(instanceMode, handover);\n }\n\n const resolvedUnsParameters: IUnsParameters = {\n ...(unsParameters ?? {}),\n clientId: unsParameters?.clientId ?? `${this.processName}-${instanceName}-${this.processId}`,\n };\n const unsMqttProxy = new UnsMqttProxy(mqttHost, this.processName, instanceName, resolvedUnsParameters);\n\n // Listen for UNS proxy producing topics and publish them via MQTT.\n unsMqttProxy.event.on(\"unsProxyProducedTopics\", (event) => {\n this.processMqttProxy.publish(event.statusTopic, JSON.stringify(event.producedTopics));\n });\n\n // Listen for UNS proxy status events and publish them via MQTT.\n unsMqttProxy.event.on(\"mqttProxyStatus\", (event) => {\n const time = UnsPacket.formatToISO8601(new Date());\n const unsMessage: IUnsMessage = { data: { time, value: event.value, uom: event.uom } };\n UnsPacket.unsPacketFromUnsMessage(unsMessage).then((packet) => {\n this.processMqttProxy.publish(event.statusTopic, JSON.stringify(packet));\n });\n });\n\n this.unsMqttProxies.push(unsMqttProxy);\n return unsMqttProxy;\n }\n\n public async waitForProcessConnection(): Promise<void> {\n while (!this.processMqttProxy?.isConnected) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n\n /**\n * Publishes retained product/system service metadata for controller discovery.\n *\n * The payload is intentionally separate from the volatile active/alive status\n * topics. Controllers can combine this retained identity/capability metadata\n * with live process status to decide whether a service is currently healthy.\n */\n public async publishServiceMetadata(metadata: UnsServiceMetadataInput): Promise<UnsServiceMetadata> {\n await this.waitForProcessConnection();\n const resolved = buildUnsServiceMetadata({\n processName: this.processName,\n processId: this.processId,\n metadata,\n });\n await this.processMqttProxy.publish(this.serviceMetadataTopic, JSON.stringify(resolved), { retain: true });\n return resolved;\n }\n\n /**\n * Shuts down the process by clearing intervals, timeouts, and removing\n * MQTT event listeners, and stopping the StatusMonitor.\n */\n public shutdown(options: UnsMqttProxyStopOptions = {}): Promise<void> {\n if (this.shutdownPromise) {\n return this.shutdownPromise;\n }\n\n this.shutdownPromise = this.performShutdown(options);\n return this.shutdownPromise;\n }\n\n private async performShutdown(options: UnsMqttProxyStopOptions): Promise<void> {\n logger.info(`${this.processName} - Shutting down UnsProxyProcess...`);\n const shutdownErrors: Error[] = [];\n\n try {\n this.statusMonitor.stop();\n await this.statusMonitor.publishInactiveStatus();\n } catch (e: any) {\n const reason = e instanceof Error ? e : new Error(String(e));\n logger.error(`${this.processName} - Error stopping StatusMonitor or publishing passive state: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n\n if (this.mqttInputHandler) {\n try {\n this.processMqttProxy.event.off(\"input\", this.mqttInputHandler);\n } catch (e: any) {\n const reason = e instanceof Error ? e : new Error(String(e));\n logger.error(`${this.processName} - Error removing MQTT input handler: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n }\n\n const proxyStopResults = await Promise.allSettled(this.unsMqttProxies.map((proxy) => proxy.stop(options)));\n for (const result of proxyStopResults) {\n if (result.status === \"rejected\") {\n const reason = result.reason instanceof Error ? result.reason : new Error(String(result.reason));\n logger.error(`${this.processName} - Error stopping UNS MQTT proxy: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n }\n\n try {\n if (typeof this.processMqttProxy.stop === \"function\") {\n await this.processMqttProxy.stop();\n }\n } catch (e: any) {\n const reason = e instanceof Error ? e : new Error(String(e));\n logger.error(`${this.processName} - Error stopping MQTT proxy: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n\n if (shutdownErrors.length > 0) {\n throw new AggregateError(shutdownErrors, `${this.processName} - Shutdown completed with errors.`);\n }\n\n logger.info(`${this.processName} - Shutdown complete.`);\n }\n}\n\ninterface UnsProxyProcess {}\n\nexport default UnsProxyProcess;\nexport type { UnsServiceMetadata, UnsServiceMetadataInput };\nexport { UnsProxyProcess };\n"]}
1
+ {"version":3,"file":"uns-proxy-process.js","sourceRoot":"","sources":["../../src/uns/uns-proxy-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,YAAY,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,mDAAmD;AACnD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAyD,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAqB5C,MAAM,eAAe;IACX,MAAM,GAAY,KAAK,CAAC;IACxB,kBAAkB,CAAS;IAC3B,WAAW,CAAS;IACpB,SAAS,CAAS;I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C,MAAM,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,CAAC;YACH,IAAI,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACrD,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC;QACH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,iCAAiC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YACnF,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,cAAc,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,WAAW,oCAAoC,CAAC,CAAC;QACpG,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,uBAAuB,CAAC,CAAC;IAC1D,CAAC;;AAKH,eAAe,eAAe,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { randomBytes } from \"crypto\";\n\nimport logger from \"../logger.js\";\nimport { IMqttParameters } from \"../uns-mqtt/mqtt-interfaces.js\";\nimport MqttProxy from \"../uns-mqtt/mqtt-proxy.js\";\nimport { MqttTopicBuilder } from \"../uns-mqtt/mqtt-topic-builder.js\";\nimport UnsMqttProxy from \"../uns-mqtt/uns-mqtt-proxy.js\";\nimport type { UnsMqttProxyStopOptions } from \"../uns-mqtt/uns-mqtt-proxy.js\";\nimport { HandoverManager } from \"./handover-manager.js\";\n// Import configuration and initialization modules.\nimport { MQTT_UPDATE_INTERVAL, PACKAGE_INFO } from \"./process-config.js\";\nimport { type UnsServiceMetadata, type UnsServiceMetadataInput, buildUnsServiceMetadata } from \"./service-metadata.js\";\nimport { StatusMonitor } from \"./status-monitor.js\";\nimport { IUnsMessage, IUnsParameters, IUnsProcessParameters, UnsEvents } from \"./uns-interfaces.js\";\nimport { UnsPacket } from \"./uns-packet.js\";\n\n/**\n * UnsProxyProcess is responsible for managing the process lifecycle,\n * configuring MQTT (subscriptions and publishing for status updates), and\n * handling UNS proxy instances.\n *\n * It leverages HandoverManager for handover events and StatusMonitor for health reporting.\n */\nexport type UnsProxyProcessPluginMethod = (this: UnsProxyProcess, ...args: unknown[]) => unknown;\n\nexport type UnsProxyProcessPluginMethods = Record<string, UnsProxyProcessPluginMethod>;\n\nexport interface UnsProxyProcessPluginApi {\n version: number;\n define(methods: UnsProxyProcessPluginMethods): void;\n UnsProxyProcess: typeof UnsProxyProcess;\n}\n\nexport type UnsProxyProcessPlugin = (api: UnsProxyProcessPluginApi) => void;\n\nclass UnsProxyProcess {\n private active: boolean = false;\n private processStatusTopic: string;\n private processName: string;\n private processId: string;\n private handoverId: string | undefined;\n private unsMqttProxies: UnsMqttProxy[];\n private unsApiProxies: unknown[];\n private processMqttProxy: MqttProxy;\n private handoverManager: HandoverManager;\n private statusMonitor: StatusMonitor;\n private serviceMetadataTopic: string;\n private shutdownPromise: Promise<void> | null = null;\n\n // Plugin\n static pluginApiVersion = 1;\n private static registered = new Set<UnsProxyProcessPlugin>();\n private static registeredMethodNames = new Set<string>();\n private static applied = false;\n\n static use(plugin: UnsProxyProcessPlugin) {\n if (this.registered.has(plugin)) return this;\n this.registered.add(plugin);\n if (this.applied) this.applyPlugin(plugin);\n return this;\n }\n\n private static applyPlugin(plugin: UnsProxyProcessPlugin) {\n const define: UnsProxyProcessPluginApi[\"define\"] = (methods) => {\n for (const [name, fn] of Object.entries(methods)) {\n if (typeof fn !== \"function\") {\n throw new TypeError(`UnsProxyProcess plugin attempted to register non-function member \\\"${name}\\\".`);\n }\n if (this.registeredMethodNames.has(name) || Reflect.has(this.prototype, name)) {\n throw new Error(`UnsProxyProcess plugin attempted to overwrite existing member \\\"${name}\\\".`);\n }\n Object.defineProperty(this.prototype, name, {\n value: fn,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n this.registeredMethodNames.add(name);\n }\n };\n\n plugin({\n define,\n version: this.pluginApiVersion,\n UnsProxyProcess: this,\n });\n }\n\n private static applyAll() {\n if (this.applied) return;\n this.applied = true;\n for (const p of this.registered) this.applyPlugin(p);\n }\n\n // References for cleanup.\n private mqttInputHandler: (event: any) => void;\n\n constructor(mqttHost: string, unsProxyProcessParameters: IUnsProcessParameters) {\n (this.constructor as typeof UnsProxyProcess).applyAll(); // Activate all the plugins\n\n this.unsMqttProxies = [];\n this.unsApiProxies = [];\n if (!unsProxyProcessParameters?.processName) {\n throw new Error(\"UnsProxyProcess requires a processName in configuration.\");\n }\n this.processName = unsProxyProcessParameters.processName;\n this.processId = randomBytes(16).toString(\"hex\");\n this.handoverId = unsProxyProcessParameters.handoverId ?? process.env[\"UNS_HANDOVER_ID\"];\n const { name: packageName, version } = PACKAGE_INFO;\n\n // Instantiate the topic builder.\n const topicBuilder = new MqttTopicBuilder(\n `uns-infra/${MqttTopicBuilder.sanitizeTopicPart(packageName)}/${MqttTopicBuilder.sanitizeTopicPart(version)}/${MqttTopicBuilder.sanitizeTopicPart(this.processName)}/`,\n );\n\n // Generate topics.\n const processStatusTopic = topicBuilder.getProcessStatusTopic();\n const handoverTopic = topicBuilder.getHandoverTopic();\n const wildcardActiveTopic = topicBuilder.getWildcardActiveTopic();\n const serviceMetadataTopic = topicBuilder.getServiceMetadataTopic();\n\n this.processStatusTopic = processStatusTopic;\n this.serviceMetadataTopic = serviceMetadataTopic;\n\n // Configure MQTT topics for subscription.\n const mqttSubToTopics = unsProxyProcessParameters?.mqttSubToTopics ?? [wildcardActiveTopic, handoverTopic];\n const mqttParameters: IMqttParameters = {\n mqttSubToTopics,\n username: unsProxyProcessParameters?.username ?? \"\",\n password: unsProxyProcessParameters?.password ?? \"\",\n mqttSSL: unsProxyProcessParameters?.mqttSSL ?? false,\n statusTopic: this.processStatusTopic,\n clientId: unsProxyProcessParameters?.clientId ?? `${this.processName}-${this.processId}`,\n hosts: unsProxyProcessParameters?.hosts,\n servers: unsProxyProcessParameters?.servers,\n port: unsProxyProcessParameters?.port,\n protocol: unsProxyProcessParameters?.protocol,\n keepalive: unsProxyProcessParameters?.keepalive,\n clean: unsProxyProcessParameters?.clean,\n connectTimeout: unsProxyProcessParameters?.connectTimeout,\n reconnectPeriod: unsProxyProcessParameters?.reconnectPeriod,\n reconnectOnConnackError: unsProxyProcessParameters?.reconnectOnConnackError,\n resubscribe: unsProxyProcessParameters?.resubscribe,\n queueQoSZero: unsProxyProcessParameters?.queueQoSZero,\n rejectUnauthorized: unsProxyProcessParameters?.rejectUnauthorized ?? false,\n properties: unsProxyProcessParameters?.properties,\n ca: unsProxyProcessParameters?.ca,\n cert: unsProxyProcessParameters?.cert,\n key: unsProxyProcessParameters?.key,\n servername: unsProxyProcessParameters?.servername,\n };\n\n // Initialize MQTT proxy and start connection.\n this.processMqttProxy = new MqttProxy(mqttHost, this.processName, mqttParameters);\n this.processMqttProxy.start();\n\n // Instantiate and start the StatusMonitor for memory and status updates.\n this.statusMonitor = new StatusMonitor(\n this.processMqttProxy,\n this.processStatusTopic,\n () => this.active,\n MQTT_UPDATE_INTERVAL,\n MQTT_UPDATE_INTERVAL,\n { processName: this.processName, processId: this.processId },\n );\n this.statusMonitor.start();\n }\n\n /**\n * Initializes the HandoverManager instance and sets up event listeners for handover and MQTT input events.\n * Determines handover and force start modes based on process arguments.\n */\n private initHandoverManager(instanceMode: string, handover: boolean, handoverId?: string) {\n const handoverRequestEnabled = instanceMode == \"handover\" ? true : false;\n const forceStartEnabled = instanceMode == \"force\" ? true : false;\n\n this.handoverManager = new HandoverManager(\n this.processName,\n this.processId,\n this.processMqttProxy,\n this.unsMqttProxies,\n handoverRequestEnabled,\n handover ?? true,\n forceStartEnabled,\n handoverId,\n );\n\n // Listen for handover events.\n this.handoverManager.event.on(\"handoverManager\", (event) => {\n this.active = event.active;\n });\n\n // Delegate MQTT events to the HandoverManager.\n this.mqttInputHandler = async (event: UnsEvents[\"input\"]) => {\n await this.handoverManager.handleMqttMessage(event);\n };\n this.processMqttProxy.event.on(\"input\", this.mqttInputHandler);\n }\n\n /**\n * Creates a new UNS proxy instance and stores it for future management.\n */\n public async createUnsMqttProxy(\n mqttHost: string,\n instanceName: string,\n instanceMode: string,\n handover: boolean,\n unsParameters?: IUnsParameters,\n ): Promise<UnsMqttProxy> {\n // Wait until the MQTT connection is established before proceeding.\n await this.waitForProcessConnection();\n\n // Currently handover manager can handle only mqtt events\n if (!this.handoverManager) {\n this.initHandoverManager(\n instanceMode,\n handover,\n this.handoverId,\n );\n }\n\n const resolvedUnsParameters: IUnsParameters = {\n ...(unsParameters ?? {}),\n clientId: unsParameters?.clientId ?? `${this.processName}-${instanceName}-${this.processId}`,\n };\n const unsMqttProxy = new UnsMqttProxy(mqttHost, this.processName, instanceName, resolvedUnsParameters);\n\n // Listen for UNS proxy producing topics and publish them via MQTT.\n unsMqttProxy.event.on(\"unsProxyProducedTopics\", (event) => {\n this.processMqttProxy.publish(event.statusTopic, JSON.stringify(event.producedTopics));\n });\n\n // Listen for UNS proxy status events and publish them via MQTT.\n unsMqttProxy.event.on(\"mqttProxyStatus\", (event) => {\n const time = UnsPacket.formatToISO8601(new Date());\n const unsMessage: IUnsMessage = { data: { time, value: event.value, uom: event.uom } };\n UnsPacket.unsPacketFromUnsMessage(unsMessage).then((packet) => {\n this.processMqttProxy.publish(event.statusTopic, JSON.stringify(packet));\n });\n });\n\n this.unsMqttProxies.push(unsMqttProxy);\n return unsMqttProxy;\n }\n\n public async waitForProcessConnection(): Promise<void> {\n while (!this.processMqttProxy?.isConnected) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n\n /**\n * Publishes retained product/system service metadata for controller discovery.\n *\n * The payload is intentionally separate from the volatile active/alive status\n * topics. Controllers can combine this retained identity/capability metadata\n * with live process status to decide whether a service is currently healthy.\n */\n public async publishServiceMetadata(metadata: UnsServiceMetadataInput): Promise<UnsServiceMetadata> {\n await this.waitForProcessConnection();\n const resolved = buildUnsServiceMetadata({\n processName: this.processName,\n processId: this.processId,\n metadata,\n });\n await this.processMqttProxy.publish(this.serviceMetadataTopic, JSON.stringify(resolved), { retain: true });\n return resolved;\n }\n\n /**\n * Shuts down the process by clearing intervals, timeouts, and removing\n * MQTT event listeners, and stopping the StatusMonitor.\n */\n public shutdown(options: UnsMqttProxyStopOptions = {}): Promise<void> {\n if (this.shutdownPromise) {\n return this.shutdownPromise;\n }\n\n this.shutdownPromise = this.performShutdown(options);\n return this.shutdownPromise;\n }\n\n private async performShutdown(options: UnsMqttProxyStopOptions): Promise<void> {\n logger.info(`${this.processName} - Shutting down UnsProxyProcess...`);\n const shutdownErrors: Error[] = [];\n\n try {\n this.statusMonitor.stop();\n await this.statusMonitor.publishInactiveStatus();\n } catch (e: any) {\n const reason = e instanceof Error ? e : new Error(String(e));\n logger.error(`${this.processName} - Error stopping StatusMonitor or publishing passive state: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n\n if (this.mqttInputHandler) {\n try {\n this.processMqttProxy.event.off(\"input\", this.mqttInputHandler);\n } catch (e: any) {\n const reason = e instanceof Error ? e : new Error(String(e));\n logger.error(`${this.processName} - Error removing MQTT input handler: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n }\n\n const proxyStopResults = await Promise.allSettled(this.unsMqttProxies.map((proxy) => proxy.stop(options)));\n for (const result of proxyStopResults) {\n if (result.status === \"rejected\") {\n const reason = result.reason instanceof Error ? result.reason : new Error(String(result.reason));\n logger.error(`${this.processName} - Error stopping UNS MQTT proxy: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n }\n\n try {\n if (typeof this.processMqttProxy.stop === \"function\") {\n await this.processMqttProxy.stop();\n }\n } catch (e: any) {\n const reason = e instanceof Error ? e : new Error(String(e));\n logger.error(`${this.processName} - Error stopping MQTT proxy: ${reason.message}`);\n shutdownErrors.push(reason);\n }\n\n if (shutdownErrors.length > 0) {\n throw new AggregateError(shutdownErrors, `${this.processName} - Shutdown completed with errors.`);\n }\n\n logger.info(`${this.processName} - Shutdown complete.`);\n }\n}\n\ninterface UnsProxyProcess {}\n\nexport default UnsProxyProcess;\nexport type { UnsServiceMetadata, UnsServiceMetadataInput };\nexport { UnsProxyProcess };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"uns-proxy.d.ts","sourceRoot":"","sources":["../../src/uns/uns-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,eAAe,CAA+B;IAC/C,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,CAAoC;IAC5E,SAAS,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACtC,SAAS,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACzC,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,oBAAoB,CAAsC;IAClE,OAAO,CAAC,wBAAwB,CAAsC;IACtE,OAAO,CAAC,0BAA0B,CAAsC;IACxE,OAAO,CAAC,mBAAmB,CAA+C;IAC1E,OAAO,CAAC,yBAAyB,CAAmC;IACpE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,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Object.virtualGroup ? { virtualGroup: topicObject.virtualGroup } : {}),
177
177
  asset: topicObject.asset,
178
178
  assetDescription: topicObject.assetDescription,
179
+ ...(topicObject.assetStableEntityId && topicObject.assetIdentityProof ? {
180
+ assetStableEntityId: topicObject.assetStableEntityId,
181
+ ...(topicObject.assetDisplayName ? { assetDisplayName: topicObject.assetDisplayName } : {}),
182
+ assetIdentityProof: topicObject.assetIdentityProof,
183
+ } : {}),
179
184
  objectType: topicObject.objectType,
180
185
  objectTypeDescription: topicObject.objectTypeDescription,
181
186
  objectId: topicObject.objectId,
@@ -189,7 +194,26 @@ export default class UnsProxy {
189
194
  else {
190
195
  // Already registered — refresh only the timestamp so the periodic
191
196
  // heartbeat reflects actual data flow rather than frozen startup time.
192
- this.producedTopics.get(fullTopic).timestamp = topicObject.timestamp;
197
+ const existing = this.producedTopics.get(fullTopic);
198
+ existing.timestamp = topicObject.timestamp;
199
+ const identityChanged = existing.assetStableEntityId !== topicObject.assetStableEntityId
200
+ || existing.assetDisplayName !== topicObject.assetDisplayName
201
+ || existing.assetIdentityProof !== topicObject.assetIdentityProof;
202
+ if (topicObject.assetStableEntityId && topicObject.assetIdentityProof) {
203
+ existing.assetStableEntityId = topicObject.assetStableEntityId;
204
+ existing.assetIdentityProof = topicObject.assetIdentityProof;
205
+ if (topicObject.assetDisplayName)
206
+ existing.assetDisplayName = topicObject.assetDisplayName;
207
+ else
208
+ delete existing.assetDisplayName;
209
+ }
210
+ else {
211
+ delete existing.assetStableEntityId;
212
+ delete existing.assetDisplayName;
213
+ delete existing.assetIdentityProof;
214
+ }
215
+ if (identityChanged)
216
+ this.emitProducedTopics();
193
217
  }
194
218
  }
195
219
  }
@@ -1 +1 @@
1
- {"version":3,"file":"uns-proxy.js","sourceRoot":"","sources":["../../src/uns/uns-proxy.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,E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AAE,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,IAAI,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAClD,IAAI,CAAC,8BAA8B,EAAE,CAAC;YACtC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,iCAAiC,SAAS,EAAE,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAES,wBAAwB,CAAC,KAAoD;QACrF,IAAI,IAAI,CAAC,mBAAmB,KAAK,EAAE,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,qCAAqC,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IACM,KAAK,CAAC,IAAI;QACf,iCAAiC;QACjC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACpC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;IAEH,CAAC;CAEF","sourcesContent":["import { IApiObject, ITopicObject, UnsEvents } from \"./uns-interfaces.js\";\nimport logger from \"../logger.js\";\nimport { UnsEventEmitter } from \"./uns-event-emitter.js\";\nimport { UnsPacket } from \"./uns-packet.js\";\nimport { UnsAsset } from \"./uns-asset.js\";\nimport { UnsObjectId, UnsObjectType } from \"./uns-object.js\";\nimport { IApiCatchallMapping } from \"./uns-interfaces.js\";\nimport { buildUnsIdentityPath } from \"./uns-path.js\";\n\nexport default class UnsProxy {\n private publishInterval: NodeJS.Timeout | null = null;\n public event: UnsEventEmitter<UnsEvents> = new UnsEventEmitter<UnsEvents>();\n protected instanceStatusTopic: string;\n protected instanceNameWithSuffix: string; //was prot\n private producedTopics: Map<string, ITopicObject> = new Map();\n private producedApiEndpoints: Map<string, IApiObject> = new Map();\n private producedServiceEndpoints: Map<string, IApiObject> = new Map();\n private producedDataOfferEndpoints: Map<string, IApiObject> = new Map();\n private producedApiCatchall: Map<string, IApiCatchallMapping> = new Map();\n private producedDataCatalogOffers: Map<string, unknown> = new Map();\n private readonly controllerNameEnv: string | undefined;\n private readonly controllerHostEnv: string | undefined;\n private readonly controllerPortEnv: string | undefined;\n private readonly controllerPublicBaseEnv: string | undefined;\n\n constructor() {\n this.controllerNameEnv = process.env[\"UNS_CONTROLLER_NAME\"];\n this.controllerHostEnv = process.env[\"UNS_CONTROLLER_HOST\"];\n this.controllerPortEnv = process.env[\"UNS_CONTROLLER_PORT\"];\n this.controllerPublicBaseEnv =\n process.env[\"UNS_CONTROLLER_PUBLIC_BASE\"] ?? process.env[\"UNS_PUBLIC_BASE\"];\n // Set up interval to publish produced topics every 60 seconds.\n this.publishInterval = setInterval(() => {\n this.emitProducedTopics();\n this.emitProducedApiEndpoints();\n this.emitProducedServiceEndpoints();\n this.emitProducedDataOfferEndpoints();\n this.emitProducedApiCatchall();\n this.emitProducedDataCatalogOffers();\n }, 60000); \n }\n \n /**\n * Publishes the list of produced topics to the MQTT broker.\n */\n private async emitProducedTopics(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const topicsArray = [...this.producedTopics.values()];\n if (topicsArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedTopics\", { producedTopics: topicsArray, statusTopic: this.instanceStatusTopic + \"topics\" });\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced topics: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced topics.`);\n }\n }\n }\n\n /**\n * Publishes the list of produced API endpoints to the MQTT broker.\n */\n private async emitProducedApiEndpoints(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const apiEndpointsArray = [...this.producedApiEndpoints.values()];\n if (apiEndpointsArray.length > 0) {\n try {\n if (apiEndpointsArray.length > 0) {\n this.event.emit(\"unsProxyProducedApiEndpoints\", { producedApiEndpoints: apiEndpointsArray, statusTopic: this.instanceStatusTopic + \"api-endpoints\" });\n }\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced API endpoints: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced API endpoints.`);\n }\n }\n }\n\n /**\n * Publishes the list of catch-all API mappings to the MQTT broker.\n */\n private async emitProducedApiCatchall(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const catchallArray = [...this.producedApiCatchall.values()];\n if (catchallArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedApiCatchAll\", {\n producedCatchall: catchallArray,\n statusTopic: this.instanceStatusTopic + \"api-catchall\",\n });\n } catch (error: any) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing catch-all API mappings: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published catch-all API mappings.`);\n }\n }\n }\n\n private async emitProducedServiceEndpoints(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const serviceEndpointsArray = [...this.producedServiceEndpoints.values()];\n if (serviceEndpointsArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedServiceEndpoints\", {\n producedServiceEndpoints: serviceEndpointsArray,\n statusTopic: this.instanceStatusTopic + \"service-endpoints\",\n });\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced service endpoints: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced service endpoints.`);\n }\n }\n }\n\n private async emitProducedDataOfferEndpoints(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const dataOfferEndpointsArray = [...this.producedDataOfferEndpoints.values()];\n if (dataOfferEndpointsArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedDataOfferEndpoints\", {\n producedDataOfferEndpoints: dataOfferEndpointsArray,\n statusTopic: this.instanceStatusTopic + \"data-offer-endpoints\",\n });\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced data offer endpoints: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced data offer endpoints.`);\n }\n }\n }\n\n private async emitProducedDataCatalogOffers(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const offersArray = [...this.producedDataCatalogOffers.values()];\n if (offersArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedDataCatalogOffers\", {\n producedDataCatalogOffers: offersArray,\n statusTopic: this.instanceStatusTopic + \"data-catalog-offers\",\n });\n } catch (error: any) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing data catalog offers: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published data catalog offers.`);\n }\n }\n }\n\n /**\n * Registers a unique topic and keeps its timestamp current.\n *\n * On first call the full entry is created and immediately emitted so the\n * controller can persist the new schema node. On subsequent calls only the\n * timestamp is updated in-place; the 60-second heartbeat interval will carry\n * the updated value to the controller, making the timestamp reflect the time\n * of the most recent data publication rather than the one-off registration\n * moment.\n *\n * @param topicObject - The object containing topic details.\n */\n protected registerUniqueTopic(topicObject: ITopicObject): void {\n if (this.instanceStatusTopic !== \"\") {\n const fullTopic = buildUnsIdentityPath(\n topicObject.topic,\n topicObject.asset,\n topicObject.objectType,\n topicObject.objectId,\n topicObject.attribute,\n );\n if (!this.producedTopics.has(fullTopic)) {\n this.producedTopics.set(fullTopic, {\n timestamp: topicObject.timestamp,\n topic: topicObject.topic,\n attribute: topicObject.attribute,\n attributeType: topicObject.attributeType,\n description: topicObject.description,\n tags: topicObject.tags,\n attributeNeedsPersistence: topicObject.attributeNeedsPersistence ?? true,\n ...(topicObject.valueType ? { valueType: topicObject.valueType } : {}),\n ...(topicObject.presentationKind ? { presentationKind: topicObject.presentationKind } : {}),\n ...(topicObject.defaultAggregation ? { defaultAggregation: topicObject.defaultAggregation } : {}),\n ...(topicObject.counterResetPolicy ? { counterResetPolicy: topicObject.counterResetPolicy } : {}),\n ...(topicObject.tableColumns?.length ? { tableColumns: topicObject.tableColumns } : {}),\n ...(topicObject.systemRole ? { systemRole: topicObject.systemRole } : {}),\n ...(topicObject.relationshipEvidence ? { relationshipEvidence: topicObject.relationshipEvidence } : {}),\n ...(topicObject.lifecycle ? { lifecycle: topicObject.lifecycle } : {}),\n dataGroup: topicObject.dataGroup ?? \"\",\n ...(topicObject.virtualGroup ? { virtualGroup: topicObject.virtualGroup } : {}),\n asset: topicObject.asset,\n assetDescription: topicObject.assetDescription,\n objectType: topicObject.objectType,\n objectTypeDescription: topicObject.objectTypeDescription,\n objectId: topicObject.objectId,\n ...(topicObject.validityMode ? { validityMode: topicObject.validityMode } : {}),\n ...(topicObject.expectedIntervalMs ? { expectedIntervalMs: topicObject.expectedIntervalMs } : {}),\n ...(topicObject.lifecycleEndValue ? { lifecycleEndValue: topicObject.lifecycleEndValue } : {}),\n });\n this.emitProducedTopics();\n logger.info(`${this.instanceNameWithSuffix} - Registered new topic: ${fullTopic}`);\n } else {\n // Already registered — refresh only the timestamp so the periodic\n // heartbeat reflects actual data flow rather than frozen startup time.\n this.producedTopics.get(fullTopic)!.timestamp = topicObject.timestamp;\n }\n }\n }\n\n /**\n * Registers an API endpoint to handle requests for a specific topic and attribute.\n */\n protected registerApiEndpoint(apiObject: IApiObject): void {\n if (this.instanceStatusTopic !== \"\") {\n const fullTopic = buildUnsIdentityPath(\n apiObject.topic,\n apiObject.asset,\n apiObject.objectType,\n apiObject.objectId,\n apiObject.attribute,\n );\n const targetRegistry =\n apiObject.registryTopic === \"service-endpoints\"\n ? this.producedServiceEndpoints\n : apiObject.registryTopic === \"data-offer-endpoints\"\n ? this.producedDataOfferEndpoints\n : this.producedApiEndpoints;\n if (!targetRegistry.has(fullTopic)) {\n const time = UnsPacket.formatToISO8601(new Date());\n targetRegistry.set(fullTopic, {\n timestamp: time,\n topic: apiObject.topic,\n attribute: apiObject.attribute,\n ...(apiObject.routeOnly === true ? { routeOnly: true } : {}),\n ...(apiObject.registryTopic ? { registryTopic: apiObject.registryTopic } : {}),\n apiHost: apiObject.apiHost,\n apiEndpoint: apiObject.apiEndpoint,\n apiMethod: apiObject.apiMethod,\n apiQueryParams: apiObject.apiQueryParams,\n apiDescription: apiObject.apiDescription,\n ...(apiObject.serviceApi ? { serviceApi: apiObject.serviceApi } : {}),\n attributeType: apiObject.attributeType,\n apiSwaggerEndpoint: apiObject.apiSwaggerEndpoint,\n asset: apiObject.asset,\n objectType: apiObject.objectType,\n objectId: apiObject.objectId,\n ...(this.controllerNameEnv ? { controllerName: this.controllerNameEnv } : {}),\n ...(this.controllerHostEnv ? { controllerHost: this.controllerHostEnv } : {}),\n ...(this.controllerPortEnv ? { controllerPort: this.controllerPortEnv } : {}),\n ...(this.controllerPublicBaseEnv ? { controllerPublicBase: this.controllerPublicBaseEnv } : {}),\n });\n if (apiObject.registryTopic === \"service-endpoints\") {\n this.emitProducedServiceEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new service endpoint: /${fullTopic}`);\n } else if (apiObject.registryTopic === \"data-offer-endpoints\") {\n this.emitProducedDataOfferEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new data offer endpoint: /${fullTopic}`);\n } else {\n this.emitProducedApiEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);\n }\n }\n }\n }\n\n protected registerApiCatchAll(mapping: IApiCatchallMapping): void {\n if (this.instanceStatusTopic !== \"\") {\n const key = mapping.topic.replace(/\\/+$/, \"\");\n if (!this.producedApiCatchall.has(key)) {\n this.producedApiCatchall.set(key, mapping);\n } else {\n this.producedApiCatchall.set(key, { ...this.producedApiCatchall.get(key)!, ...mapping });\n }\n this.emitProducedApiCatchall();\n logger.info(`${this.instanceNameWithSuffix} - Registered catch-all API mapping: ${key}`);\n }\n }\n\n protected unregisterApiEndpoint(topic: string, asset:UnsAsset, objectType: UnsObjectType, objectId: UnsObjectId, attribute: string): void {\n const fullTopic = buildUnsIdentityPath(topic, asset, objectType, objectId, attribute);\n let removed = false;\n if (this.producedApiEndpoints.has(fullTopic)) {\n this.producedApiEndpoints.delete(fullTopic);\n this.emitProducedApiEndpoints();\n removed = true;\n }\n if (this.producedServiceEndpoints.has(fullTopic)) {\n this.producedServiceEndpoints.delete(fullTopic);\n this.emitProducedServiceEndpoints();\n removed = true;\n }\n if (this.producedDataOfferEndpoints.has(fullTopic)) {\n this.producedDataOfferEndpoints.delete(fullTopic);\n this.emitProducedDataOfferEndpoints();\n removed = true;\n }\n if (removed) {\n logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);\n }\n }\n\n protected registerDataCatalogOffer(offer: { offerId: string } & Record<string, unknown>): void {\n if (this.instanceStatusTopic === \"\") {\n return;\n }\n const offerId = typeof offer.offerId === \"string\" ? offer.offerId.trim() : \"\";\n if (!offerId) {\n return;\n }\n this.producedDataCatalogOffers.set(offerId, offer);\n this.emitProducedDataCatalogOffers();\n logger.info(`${this.instanceNameWithSuffix} - Registered data catalog offer: ${offerId}`);\n }\n public async stop() {\n // Clear the publishing interval.\n if (this.publishInterval) {\n clearInterval(this.publishInterval);\n this.publishInterval = null;\n }\n\n }\n\n}\n"]}
1
+ {"version":3,"file":"uns-proxy.js","sourceRoot":"","sources":["../../src/uns/uns-proxy.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAw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CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAClD,IAAI,CAAC,8BAA8B,EAAE,CAAC;YACtC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,iCAAiC,SAAS,EAAE,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAES,wBAAwB,CAAC,KAAoD;QACrF,IAAI,IAAI,CAAC,mBAAmB,KAAK,EAAE,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,qCAAqC,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IACM,KAAK,CAAC,IAAI;QACf,iCAAiC;QACjC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACpC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;IAEH,CAAC;CAEF","sourcesContent":["import { IApiObject, ITopicObject, UnsEvents } from \"./uns-interfaces.js\";\nimport logger from \"../logger.js\";\nimport { UnsEventEmitter } from \"./uns-event-emitter.js\";\nimport { UnsPacket } from \"./uns-packet.js\";\nimport { UnsAsset } from \"./uns-asset.js\";\nimport { UnsObjectId, UnsObjectType } from \"./uns-object.js\";\nimport { IApiCatchallMapping } from \"./uns-interfaces.js\";\nimport { buildUnsIdentityPath } from \"./uns-path.js\";\n\nexport default class UnsProxy {\n private publishInterval: NodeJS.Timeout | null = null;\n public event: UnsEventEmitter<UnsEvents> = new UnsEventEmitter<UnsEvents>();\n protected instanceStatusTopic: string;\n protected instanceNameWithSuffix: string; //was prot\n private producedTopics: Map<string, ITopicObject> = new Map();\n private producedApiEndpoints: Map<string, IApiObject> = new Map();\n private producedServiceEndpoints: Map<string, IApiObject> = new Map();\n private producedDataOfferEndpoints: Map<string, IApiObject> = new Map();\n private producedApiCatchall: Map<string, IApiCatchallMapping> = new Map();\n private producedDataCatalogOffers: Map<string, unknown> = new Map();\n private readonly controllerNameEnv: string | undefined;\n private readonly controllerHostEnv: string | undefined;\n private readonly controllerPortEnv: string | undefined;\n private readonly controllerPublicBaseEnv: string | undefined;\n\n constructor() {\n this.controllerNameEnv = process.env[\"UNS_CONTROLLER_NAME\"];\n this.controllerHostEnv = process.env[\"UNS_CONTROLLER_HOST\"];\n this.controllerPortEnv = process.env[\"UNS_CONTROLLER_PORT\"];\n this.controllerPublicBaseEnv =\n process.env[\"UNS_CONTROLLER_PUBLIC_BASE\"] ?? process.env[\"UNS_PUBLIC_BASE\"];\n // Set up interval to publish produced topics every 60 seconds.\n this.publishInterval = setInterval(() => {\n this.emitProducedTopics();\n this.emitProducedApiEndpoints();\n this.emitProducedServiceEndpoints();\n this.emitProducedDataOfferEndpoints();\n this.emitProducedApiCatchall();\n this.emitProducedDataCatalogOffers();\n }, 60000); \n }\n \n /**\n * Publishes the list of produced topics to the MQTT broker.\n */\n private async emitProducedTopics(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const topicsArray = [...this.producedTopics.values()];\n if (topicsArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedTopics\", { producedTopics: topicsArray, statusTopic: this.instanceStatusTopic + \"topics\" });\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced topics: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced topics.`);\n }\n }\n }\n\n /**\n * Publishes the list of produced API endpoints to the MQTT broker.\n */\n private async emitProducedApiEndpoints(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const apiEndpointsArray = [...this.producedApiEndpoints.values()];\n if (apiEndpointsArray.length > 0) {\n try {\n if (apiEndpointsArray.length > 0) {\n this.event.emit(\"unsProxyProducedApiEndpoints\", { producedApiEndpoints: apiEndpointsArray, statusTopic: this.instanceStatusTopic + \"api-endpoints\" });\n }\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced API endpoints: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced API endpoints.`);\n }\n }\n }\n\n /**\n * Publishes the list of catch-all API mappings to the MQTT broker.\n */\n private async emitProducedApiCatchall(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const catchallArray = [...this.producedApiCatchall.values()];\n if (catchallArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedApiCatchAll\", {\n producedCatchall: catchallArray,\n statusTopic: this.instanceStatusTopic + \"api-catchall\",\n });\n } catch (error: any) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing catch-all API mappings: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published catch-all API mappings.`);\n }\n }\n }\n\n private async emitProducedServiceEndpoints(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const serviceEndpointsArray = [...this.producedServiceEndpoints.values()];\n if (serviceEndpointsArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedServiceEndpoints\", {\n producedServiceEndpoints: serviceEndpointsArray,\n statusTopic: this.instanceStatusTopic + \"service-endpoints\",\n });\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced service endpoints: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced service endpoints.`);\n }\n }\n }\n\n private async emitProducedDataOfferEndpoints(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const dataOfferEndpointsArray = [...this.producedDataOfferEndpoints.values()];\n if (dataOfferEndpointsArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedDataOfferEndpoints\", {\n producedDataOfferEndpoints: dataOfferEndpointsArray,\n statusTopic: this.instanceStatusTopic + \"data-offer-endpoints\",\n });\n } catch (error) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing produced data offer endpoints: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published produced data offer endpoints.`);\n }\n }\n }\n\n private async emitProducedDataCatalogOffers(): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const offersArray = [...this.producedDataCatalogOffers.values()];\n if (offersArray.length > 0) {\n try {\n this.event.emit(\"unsProxyProducedDataCatalogOffers\", {\n producedDataCatalogOffers: offersArray,\n statusTopic: this.instanceStatusTopic + \"data-catalog-offers\",\n });\n } catch (error: any) {\n logger.error(`${this.instanceNameWithSuffix} - Error publishing data catalog offers: ${error.message}`);\n }\n logger.debug(`${this.instanceNameWithSuffix} - Published data catalog offers.`);\n }\n }\n }\n\n /**\n * Registers a unique topic and keeps its timestamp current.\n *\n * On first call the full entry is created and immediately emitted so the\n * controller can persist the new schema node. On subsequent calls only the\n * timestamp is updated in-place; the 60-second heartbeat interval will carry\n * the updated value to the controller, making the timestamp reflect the time\n * of the most recent data publication rather than the one-off registration\n * moment.\n *\n * @param topicObject - The object containing topic details.\n */\n protected registerUniqueTopic(topicObject: ITopicObject): void {\n if (this.instanceStatusTopic !== \"\") {\n const fullTopic = buildUnsIdentityPath(\n topicObject.topic,\n topicObject.asset,\n topicObject.objectType,\n topicObject.objectId,\n topicObject.attribute,\n );\n if (!this.producedTopics.has(fullTopic)) {\n this.producedTopics.set(fullTopic, {\n timestamp: topicObject.timestamp,\n topic: topicObject.topic,\n attribute: topicObject.attribute,\n attributeType: topicObject.attributeType,\n description: topicObject.description,\n tags: topicObject.tags,\n attributeNeedsPersistence: topicObject.attributeNeedsPersistence ?? true,\n ...(topicObject.valueType ? { valueType: topicObject.valueType } : {}),\n ...(topicObject.presentationKind ? { presentationKind: topicObject.presentationKind } : {}),\n ...(topicObject.defaultAggregation ? { defaultAggregation: topicObject.defaultAggregation } : {}),\n ...(topicObject.counterResetPolicy ? { counterResetPolicy: topicObject.counterResetPolicy } : {}),\n ...(topicObject.tableColumns?.length ? { tableColumns: topicObject.tableColumns } : {}),\n ...(topicObject.systemRole ? { systemRole: topicObject.systemRole } : {}),\n ...(topicObject.relationshipEvidence ? { relationshipEvidence: topicObject.relationshipEvidence } : {}),\n ...(topicObject.lifecycle ? { lifecycle: topicObject.lifecycle } : {}),\n dataGroup: topicObject.dataGroup ?? \"\",\n ...(topicObject.virtualGroup ? { virtualGroup: topicObject.virtualGroup } : {}),\n asset: topicObject.asset,\n assetDescription: topicObject.assetDescription,\n ...(topicObject.assetStableEntityId && topicObject.assetIdentityProof ? {\n assetStableEntityId: topicObject.assetStableEntityId,\n ...(topicObject.assetDisplayName ? { assetDisplayName: topicObject.assetDisplayName } : {}),\n assetIdentityProof: topicObject.assetIdentityProof,\n } : {}),\n objectType: topicObject.objectType,\n objectTypeDescription: topicObject.objectTypeDescription,\n objectId: topicObject.objectId,\n ...(topicObject.validityMode ? { validityMode: topicObject.validityMode } : {}),\n ...(topicObject.expectedIntervalMs ? { expectedIntervalMs: topicObject.expectedIntervalMs } : {}),\n ...(topicObject.lifecycleEndValue ? { lifecycleEndValue: topicObject.lifecycleEndValue } : {}),\n });\n this.emitProducedTopics();\n logger.info(`${this.instanceNameWithSuffix} - Registered new topic: ${fullTopic}`);\n } else {\n // Already registered — refresh only the timestamp so the periodic\n // heartbeat reflects actual data flow rather than frozen startup time.\n const existing = this.producedTopics.get(fullTopic)!;\n existing.timestamp = topicObject.timestamp;\n const identityChanged = existing.assetStableEntityId !== topicObject.assetStableEntityId\n || existing.assetDisplayName !== topicObject.assetDisplayName\n || existing.assetIdentityProof !== topicObject.assetIdentityProof;\n if (topicObject.assetStableEntityId && topicObject.assetIdentityProof) {\n existing.assetStableEntityId = topicObject.assetStableEntityId;\n existing.assetIdentityProof = topicObject.assetIdentityProof;\n if (topicObject.assetDisplayName) existing.assetDisplayName = topicObject.assetDisplayName;\n else delete existing.assetDisplayName;\n } else {\n delete existing.assetStableEntityId;\n delete existing.assetDisplayName;\n delete existing.assetIdentityProof;\n }\n if (identityChanged) this.emitProducedTopics();\n }\n }\n }\n\n /**\n * Registers an API endpoint to handle requests for a specific topic and attribute.\n */\n protected registerApiEndpoint(apiObject: IApiObject): void {\n if (this.instanceStatusTopic !== \"\") {\n const fullTopic = buildUnsIdentityPath(\n apiObject.topic,\n apiObject.asset,\n apiObject.objectType,\n apiObject.objectId,\n apiObject.attribute,\n );\n const targetRegistry =\n apiObject.registryTopic === \"service-endpoints\"\n ? this.producedServiceEndpoints\n : apiObject.registryTopic === \"data-offer-endpoints\"\n ? this.producedDataOfferEndpoints\n : this.producedApiEndpoints;\n if (!targetRegistry.has(fullTopic)) {\n const time = UnsPacket.formatToISO8601(new Date());\n targetRegistry.set(fullTopic, {\n timestamp: time,\n topic: apiObject.topic,\n attribute: apiObject.attribute,\n ...(apiObject.routeOnly === true ? { routeOnly: true } : {}),\n ...(apiObject.registryTopic ? { registryTopic: apiObject.registryTopic } : {}),\n apiHost: apiObject.apiHost,\n apiEndpoint: apiObject.apiEndpoint,\n apiMethod: apiObject.apiMethod,\n apiQueryParams: apiObject.apiQueryParams,\n apiDescription: apiObject.apiDescription,\n ...(apiObject.serviceApi ? { serviceApi: apiObject.serviceApi } : {}),\n attributeType: apiObject.attributeType,\n apiSwaggerEndpoint: apiObject.apiSwaggerEndpoint,\n asset: apiObject.asset,\n objectType: apiObject.objectType,\n objectId: apiObject.objectId,\n ...(this.controllerNameEnv ? { controllerName: this.controllerNameEnv } : {}),\n ...(this.controllerHostEnv ? { controllerHost: this.controllerHostEnv } : {}),\n ...(this.controllerPortEnv ? { controllerPort: this.controllerPortEnv } : {}),\n ...(this.controllerPublicBaseEnv ? { controllerPublicBase: this.controllerPublicBaseEnv } : {}),\n });\n if (apiObject.registryTopic === \"service-endpoints\") {\n this.emitProducedServiceEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new service endpoint: /${fullTopic}`);\n } else if (apiObject.registryTopic === \"data-offer-endpoints\") {\n this.emitProducedDataOfferEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new data offer endpoint: /${fullTopic}`);\n } else {\n this.emitProducedApiEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);\n }\n }\n }\n }\n\n protected registerApiCatchAll(mapping: IApiCatchallMapping): void {\n if (this.instanceStatusTopic !== \"\") {\n const key = mapping.topic.replace(/\\/+$/, \"\");\n if (!this.producedApiCatchall.has(key)) {\n this.producedApiCatchall.set(key, mapping);\n } else {\n this.producedApiCatchall.set(key, { ...this.producedApiCatchall.get(key)!, ...mapping });\n }\n this.emitProducedApiCatchall();\n logger.info(`${this.instanceNameWithSuffix} - Registered catch-all API mapping: ${key}`);\n }\n }\n\n protected unregisterApiEndpoint(topic: string, asset:UnsAsset, objectType: UnsObjectType, objectId: UnsObjectId, attribute: string): void {\n const fullTopic = buildUnsIdentityPath(topic, asset, objectType, objectId, attribute);\n let removed = false;\n if (this.producedApiEndpoints.has(fullTopic)) {\n this.producedApiEndpoints.delete(fullTopic);\n this.emitProducedApiEndpoints();\n removed = true;\n }\n if (this.producedServiceEndpoints.has(fullTopic)) {\n this.producedServiceEndpoints.delete(fullTopic);\n this.emitProducedServiceEndpoints();\n removed = true;\n }\n if (this.producedDataOfferEndpoints.has(fullTopic)) {\n this.producedDataOfferEndpoints.delete(fullTopic);\n this.emitProducedDataOfferEndpoints();\n removed = true;\n }\n if (removed) {\n logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);\n }\n }\n\n protected registerDataCatalogOffer(offer: { offerId: string } & Record<string, unknown>): void {\n if (this.instanceStatusTopic === \"\") {\n return;\n }\n const offerId = typeof offer.offerId === \"string\" ? offer.offerId.trim() : \"\";\n if (!offerId) {\n return;\n }\n this.producedDataCatalogOffers.set(offerId, offer);\n this.emitProducedDataCatalogOffers();\n logger.info(`${this.instanceNameWithSuffix} - Registered data catalog offer: ${offerId}`);\n }\n public async stop() {\n // Clear the publishing interval.\n if (this.publishInterval) {\n clearInterval(this.publishInterval);\n this.publishInterval = null;\n }\n\n }\n\n}\n"]}
@@ -39,6 +39,7 @@ export declare const baseSchema: z.ZodObject<{
39
39
  }>>;
40
40
  processName: z.ZodString;
41
41
  handover: z.ZodDefault<z.ZodBoolean>;
42
+ handoverProtocol: z.ZodOptional<z.ZodLiteral<"correlated-v1">>;
42
43
  supervisor: z.ZodOptional<z.ZodObject<{
43
44
  enabled: z.ZodDefault<z.ZodBoolean>;
44
45
  restartOnExit: z.ZodDefault<z.ZodBoolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../src/uns-config/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAAmE,CAAC;AAG3F,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../src/uns-config/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAAmE,CAAC;AAG3F,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -143,6 +143,7 @@ export declare const unsCoreSchema: z.ZodObject<{
143
143
  }>>;
144
144
  processName: z.ZodString;
145
145
  handover: z.ZodDefault<z.ZodBoolean>;
146
+ handoverProtocol: z.ZodOptional<z.ZodLiteral<"correlated-v1">>;
146
147
  supervisor: z.ZodOptional<z.ZodObject<{
147
148
  enabled: z.ZodDefault<z.ZodBoolean>;
148
149
  restartOnExit: z.ZodDefault<z.ZodBoolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"uns-core-schema.d.ts","sourceRoot":"","sources":["../../src/uns-config/uns-core-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0Cf,CAAC;AAEZ,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -91,6 +91,7 @@ export const unsCoreSchema = z
91
91
  instanceMode: z.enum(["wait", "force", "handover"]).default("wait"),
92
92
  processName: z.string().min(1).describe("Process name used in MQTT topics and logs."),
93
93
  handover: z.boolean().default(true),
94
+ handoverProtocol: z.literal("correlated-v1").optional().describe("Opt-in controller-correlated MQTT handover protocol."),
94
95
  supervisor: supervisorSchema.optional(),
95
96
  jwksWellKnownUrl: z.string().url().optional(),
96
97
  kidWellKnownUrl: z.string().url().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"uns-core-schema.js","sourceRoot":"","sources":["../../src/uns-config/uns-core-schema.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,4EAA4E;AAC5E,2EAA2E;AAC3E,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,CA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SACP,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;QACzC,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/C,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC;KAC1C,CAAC;SACD,MAAM,EAAE;SACR,QAAQ,EAAE;IAEb,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;QAC1D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KACtC,CAAC;SACD,MAAM,EAAE;SACR,QAAQ,EAAE;CACd,CAAC;KACD,MAAM,EAAE,CAAC","sourcesContent":["// src/uns-config/uns-core-schema.ts\nimport { z } from \"zod\";\n\nimport { hostValueSchema } from \"./host-placeholders.js\";\nimport { secretValueSchema } from \"./secret-placeholders.js\";\n\n// Zod 4's .int() also enforces Number.isSafeInteger(). Zod 3 accepted every\n// finite integer, so multipleOf(1) preserves the existing config contract.\nconst integerSchema = () => z.number().multipleOf(1);\n\nconst mqttProtocolSchema = z.enum([\"mqtt\", \"mqtts\", \"ws\", \"wss\", \"tcp\", \"ssl\"]);\n\nconst mqttServerSchema = z\n .object({\n host: hostValueSchema,\n port: integerSchema().positive().optional(),\n protocol: mqttProtocolSchema.optional(),\n })\n .strict();\n\nconst mqttConnectPropertiesSchema = z\n .object({\n sessionExpiryInterval: integerSchema().nonnegative().optional(),\n receiveMaximum: integerSchema().positive().optional(),\n maximumPacketSize: integerSchema().positive().optional(),\n topicAliasMaximum: integerSchema().nonnegative().optional(),\n requestResponseInformation: z.boolean().optional(),\n requestProblemInformation: z.boolean().optional(),\n userProperties: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\nconst loggingLevelSchema = z.enum([\"error\", \"warn\", \"info\", \"http\", \"verbose\", \"debug\", \"silly\"]);\n\nconst supervisorSchema = z\n .object({\n enabled: z.boolean().default(false).describe(\"Enable controller/PM2 supervisor handling for this RTT instance.\"),\n restartOnExit: z.boolean().default(false).describe(\"Let PM2 restart the process when it exits unexpectedly.\"),\n maxMemoryMb: z.number().multipleOf(1).positive().optional().describe(\"Optional PM2 memory restart limit in megabytes.\"),\n restartOnUnhealthy: z\n .boolean()\n .default(false)\n .describe(\"Let the controller auto-start this instance when required system-service runtime signals are absent.\"),\n unhealthyAfterMs: z\n .number()\n .multipleOf(1)\n .positive()\n .default(60_000)\n .describe(\"How long runtime signals must stay unhealthy before the controller supervisor can act.\"),\n restartCooldownMs: z\n .number()\n .multipleOf(1)\n .positive()\n .default(300_000)\n .describe(\"Minimum time between controller supervisor restart attempts for this instance.\"),\n })\n .strict()\n .describe(\"Optional PM2/controller supervisor guard settings for this RTT instance.\");\n\nexport const mqttChannelSchema = z\n .object({\n host: hostValueSchema.optional(),\n hosts: z.array(hostValueSchema).optional(),\n servers: z.array(mqttServerSchema).optional(),\n port: integerSchema().positive().optional(),\n protocol: mqttProtocolSchema.optional(),\n username: z.string().optional(),\n password: secretValueSchema.optional(),\n clientId: z.string().optional(),\n clean: z.boolean().optional(),\n keepalive: integerSchema().nonnegative().optional(),\n connectTimeout: integerSchema().nonnegative().optional(),\n reconnectPeriod: integerSchema().nonnegative().optional(),\n reconnectOnConnackError: z.boolean().optional(),\n resubscribe: z.boolean().optional(),\n queueQoSZero: z.boolean().optional(),\n rejectUnauthorized: z.boolean().optional(),\n properties: mqttConnectPropertiesSchema.optional(),\n ca: z.string().optional(),\n cert: z.string().optional(),\n key: z.string().optional(),\n servername: z.string().optional(),\n })\n .strict()\n .refine(\n (value) => {\n return !!value.host || (Array.isArray(value.hosts) && value.hosts.length > 0) || (Array.isArray(value.servers) && value.servers.length > 0);\n },\n {\n message: \"One of host, hosts, or servers must be provided.\",\n },\n );\n\nexport const unsCoreSchema = z\n .object({\n uns: z\n .object({\n graphql: z.string().url(),\n rest: z.string().url(),\n token: secretValueSchema.optional().describe(\"Bearer token used for service-to-service access to the UNS instance.\"),\n email: z.string().email().optional().describe(\"Email used when authenticating to graphql endpoint of the UNS instance.\"),\n password: secretValueSchema.optional().describe(\"Password or secret value paired with the UNS email.\"),\n instanceMode: z.enum([\"wait\", \"force\", \"handover\"]).default(\"wait\"),\n processName: z.string().min(1).describe(\"Process name used in MQTT topics and logs.\"),\n handover: z.boolean().default(true),\n supervisor: supervisorSchema.optional(),\n jwksWellKnownUrl: z.string().url().optional(),\n kidWellKnownUrl: z.string().url().optional(),\n env: z.enum([\"dev\", \"staging\", \"test\", \"prod\"]).default(\"dev\"),\n })\n .strict(),\n\n logging: z\n .object({\n adapter: z.string().min(1).default(\"udp\"),\n host: hostValueSchema,\n port: integerSchema().positive().default(12201),\n level: loggingLevelSchema.default(\"info\"),\n })\n .strict()\n .optional(),\n\n input: mqttChannelSchema.optional(),\n output: mqttChannelSchema.optional(),\n infra: mqttChannelSchema,\n devops: z\n .object({\n provider: z.enum([\"azure-devops\"]).default(\"azure-devops\"),\n organization: z.string().min(1),\n project: z.string().min(1).optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport type UnsCore = z.infer<typeof unsCoreSchema>;\n"]}
1
+ {"version":3,"file":"uns-core-schema.js","sourceRoot":"","sources":["../../src/uns-config/uns-core-schema.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA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Content":["// src/uns-config/uns-core-schema.ts\nimport { z } from \"zod\";\n\nimport { hostValueSchema } from \"./host-placeholders.js\";\nimport { secretValueSchema } from \"./secret-placeholders.js\";\n\n// Zod 4's .int() also enforces Number.isSafeInteger(). Zod 3 accepted every\n// finite integer, so multipleOf(1) preserves the existing config contract.\nconst integerSchema = () => z.number().multipleOf(1);\n\nconst mqttProtocolSchema = z.enum([\"mqtt\", \"mqtts\", \"ws\", \"wss\", \"tcp\", \"ssl\"]);\n\nconst mqttServerSchema = z\n .object({\n host: hostValueSchema,\n port: integerSchema().positive().optional(),\n protocol: mqttProtocolSchema.optional(),\n })\n .strict();\n\nconst mqttConnectPropertiesSchema = z\n .object({\n sessionExpiryInterval: integerSchema().nonnegative().optional(),\n receiveMaximum: integerSchema().positive().optional(),\n maximumPacketSize: integerSchema().positive().optional(),\n topicAliasMaximum: integerSchema().nonnegative().optional(),\n requestResponseInformation: z.boolean().optional(),\n requestProblemInformation: z.boolean().optional(),\n userProperties: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\nconst loggingLevelSchema = z.enum([\"error\", \"warn\", \"info\", \"http\", \"verbose\", \"debug\", \"silly\"]);\n\nconst supervisorSchema = z\n .object({\n enabled: z.boolean().default(false).describe(\"Enable controller/PM2 supervisor handling for this RTT instance.\"),\n restartOnExit: z.boolean().default(false).describe(\"Let PM2 restart the process when it exits unexpectedly.\"),\n maxMemoryMb: z.number().multipleOf(1).positive().optional().describe(\"Optional PM2 memory restart limit in megabytes.\"),\n restartOnUnhealthy: z\n .boolean()\n .default(false)\n .describe(\"Let the controller auto-start this instance when required system-service runtime signals are absent.\"),\n unhealthyAfterMs: z\n .number()\n .multipleOf(1)\n .positive()\n .default(60_000)\n .describe(\"How long runtime signals must stay unhealthy before the controller supervisor can act.\"),\n restartCooldownMs: z\n .number()\n .multipleOf(1)\n .positive()\n .default(300_000)\n .describe(\"Minimum time between controller supervisor restart attempts for this instance.\"),\n })\n .strict()\n .describe(\"Optional PM2/controller supervisor guard settings for this RTT instance.\");\n\nexport const mqttChannelSchema = z\n .object({\n host: hostValueSchema.optional(),\n hosts: z.array(hostValueSchema).optional(),\n servers: z.array(mqttServerSchema).optional(),\n port: integerSchema().positive().optional(),\n protocol: mqttProtocolSchema.optional(),\n username: z.string().optional(),\n password: secretValueSchema.optional(),\n clientId: z.string().optional(),\n clean: z.boolean().optional(),\n keepalive: integerSchema().nonnegative().optional(),\n connectTimeout: integerSchema().nonnegative().optional(),\n reconnectPeriod: integerSchema().nonnegative().optional(),\n reconnectOnConnackError: z.boolean().optional(),\n resubscribe: z.boolean().optional(),\n queueQoSZero: z.boolean().optional(),\n rejectUnauthorized: z.boolean().optional(),\n properties: mqttConnectPropertiesSchema.optional(),\n ca: z.string().optional(),\n cert: z.string().optional(),\n key: z.string().optional(),\n servername: z.string().optional(),\n })\n .strict()\n .refine(\n (value) => {\n return !!value.host || (Array.isArray(value.hosts) && value.hosts.length > 0) || (Array.isArray(value.servers) && value.servers.length > 0);\n },\n {\n message: \"One of host, hosts, or servers must be provided.\",\n },\n );\n\nexport const unsCoreSchema = z\n .object({\n uns: z\n .object({\n graphql: z.string().url(),\n rest: z.string().url(),\n token: secretValueSchema.optional().describe(\"Bearer token used for service-to-service access to the UNS instance.\"),\n email: z.string().email().optional().describe(\"Email used when authenticating to graphql endpoint of the UNS instance.\"),\n password: secretValueSchema.optional().describe(\"Password or secret value paired with the UNS email.\"),\n instanceMode: z.enum([\"wait\", \"force\", \"handover\"]).default(\"wait\"),\n processName: z.string().min(1).describe(\"Process name used in MQTT topics and logs.\"),\n handover: z.boolean().default(true),\n handoverProtocol: z.literal(\"correlated-v1\").optional().describe(\"Opt-in controller-correlated MQTT handover protocol.\"),\n supervisor: supervisorSchema.optional(),\n jwksWellKnownUrl: z.string().url().optional(),\n kidWellKnownUrl: z.string().url().optional(),\n env: z.enum([\"dev\", \"staging\", \"test\", \"prod\"]).default(\"dev\"),\n })\n .strict(),\n\n logging: z\n .object({\n adapter: z.string().min(1).default(\"udp\"),\n host: hostValueSchema,\n port: integerSchema().positive().default(12201),\n level: loggingLevelSchema.default(\"info\"),\n })\n .strict()\n .optional(),\n\n input: mqttChannelSchema.optional(),\n output: mqttChannelSchema.optional(),\n infra: mqttChannelSchema,\n devops: z\n .object({\n provider: z.enum([\"azure-devops\"]).default(\"azure-devops\"),\n organization: z.string().min(1),\n project: z.string().min(1).optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport type UnsCore = z.infer<typeof unsCoreSchema>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"uns-mqtt-proxy.d.ts","sourceRoot":"","sources":["../../src/uns-mqtt/uns-mqtt-proxy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAC;AAM7C,OAAO,EAAE,mBAAmB,EAAsC,UAAU,EAAE,cAAc,EAAmG,SAAS,EAAa,MAAM,0BAA0B,CAAC;AAOtP,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAa3C,oBAAY,WAAW;IACrB,GAAG,QAAQ,CAAM,iCAAiC;IAClD;;;OAGG;IACH,KAAK,UAAU,CAAE,8BAA8B;IAC/C;;;OAGG;IACH,IAAI,SAAS;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8BD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,QAAQ;IAChD,gBAAuB,wBAAwB,SAAU;IACzD,OAAO,CAAC,UAAU,CAA8E;IAChG,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,eAAe,CAAmF;IAC1G,OAAO,CAAC,yBAAyB,CAAqB;IACtD,OAAO,CAAC,aAAa,CAAiB;IACtC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,YAAY,C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