@uns-kit/core 3.0.17 → 3.0.19

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 /**\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"]}
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 IAssetProviderIdentity = {\n providerId: string;\n externalSystem: string;\n externalType: string;\n externalId: string;\n};\n\nexport type IAssetIdentityPublicationMetadata =\n | {\n assetStableEntityId?: never;\n assetDisplayName?: never;\n assetIdentityProof?: never;\n assetProviderIdentity?: never;\n assetProviderIdentityProof?: 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 assetProviderIdentity?: never;\n assetProviderIdentityProof?: never;\n }\n | {\n assetStableEntityId?: never;\n assetDisplayName?: never;\n assetIdentityProof?: never;\n /** Reviewed provider namespace plus external identifier for a provisional no-ID Asset. */\n assetProviderIdentity: IAssetProviderIdentity;\n /** Short-lived controller-signed proof bound to the provider identifier and exact candidate path. */\n assetProviderIdentityProof: 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 /** Reviewed provider namespace plus external identifier for a provisional no-ID Asset. */\n assetProviderIdentity?: IAssetProviderIdentity;\n /** Short-lived controller-signed evidence for this provider identifier and exact Asset path. */\n assetProviderIdentityProof?: 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 +1 @@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pE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAqB;;IAmB7D;;OAEG;YACW,kBAAkB;IAchC;;OAEG;YACW,wBAAwB;IAgBtC;;OAEG;YACW,uBAAuB;YAiBvB,4BAA4B;YAiB5B,8BAA8B;YAiB9B,6BAA6B;IAiB3C;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI;IAgF9D;;OAEG;IACH,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI;IAqD1D,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAajE,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAuBzI,SAAS,CAAC,wBAAwB,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAYjF,IAAI;CASlB"}
@@ -181,6 +181,10 @@ export default class UnsProxy {
181
181
  ...(topicObject.assetDisplayName ? { assetDisplayName: topicObject.assetDisplayName } : {}),
182
182
  assetIdentityProof: topicObject.assetIdentityProof,
183
183
  } : {}),
184
+ ...(topicObject.assetProviderIdentity && topicObject.assetProviderIdentityProof ? {
185
+ assetProviderIdentity: topicObject.assetProviderIdentity,
186
+ assetProviderIdentityProof: topicObject.assetProviderIdentityProof,
187
+ } : {}),
184
188
  objectType: topicObject.objectType,
185
189
  objectTypeDescription: topicObject.objectTypeDescription,
186
190
  objectId: topicObject.objectId,
@@ -198,7 +202,9 @@ export default class UnsProxy {
198
202
  existing.timestamp = topicObject.timestamp;
199
203
  const identityChanged = existing.assetStableEntityId !== topicObject.assetStableEntityId
200
204
  || existing.assetDisplayName !== topicObject.assetDisplayName
201
- || existing.assetIdentityProof !== topicObject.assetIdentityProof;
205
+ || existing.assetIdentityProof !== topicObject.assetIdentityProof
206
+ || JSON.stringify(existing.assetProviderIdentity) !== JSON.stringify(topicObject.assetProviderIdentity)
207
+ || existing.assetProviderIdentityProof !== topicObject.assetProviderIdentityProof;
202
208
  if (topicObject.assetStableEntityId && topicObject.assetIdentityProof) {
203
209
  existing.assetStableEntityId = topicObject.assetStableEntityId;
204
210
  existing.assetIdentityProof = topicObject.assetIdentityProof;
@@ -212,6 +218,14 @@ export default class UnsProxy {
212
218
  delete existing.assetDisplayName;
213
219
  delete existing.assetIdentityProof;
214
220
  }
221
+ if (topicObject.assetProviderIdentity && topicObject.assetProviderIdentityProof) {
222
+ existing.assetProviderIdentity = topicObject.assetProviderIdentity;
223
+ existing.assetProviderIdentityProof = topicObject.assetProviderIdentityProof;
224
+ }
225
+ else {
226
+ delete existing.assetProviderIdentity;
227
+ delete existing.assetProviderIdentityProof;
228
+ }
215
229
  if (identityChanged)
216
230
  this.emitProducedTopics();
217
231
  }
@@ -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,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,CAAC,OAAO,OAAO,QAAQ;IACnB,eAAe,GAA0B,IAAI,CAAC;IAC/C,KAAK,GAA+B,IAAI,eAAe,EAAa,CAAC;IAClE,mBAAmB,CAAS;IAC5B,sBAAsB,CAAS,CAA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,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.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,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 ...(topicObject.assetProviderIdentity && topicObject.assetProviderIdentityProof ? {\n assetProviderIdentity: topicObject.assetProviderIdentity,\n assetProviderIdentityProof: topicObject.assetProviderIdentityProof,\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 || JSON.stringify(existing.assetProviderIdentity) !== JSON.stringify(topicObject.assetProviderIdentity)\n || existing.assetProviderIdentityProof !== topicObject.assetProviderIdentityProof;\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 (topicObject.assetProviderIdentity && topicObject.assetProviderIdentityProof) {\n existing.assetProviderIdentity = topicObject.assetProviderIdentity;\n existing.assetProviderIdentityProof = topicObject.assetProviderIdentityProof;\n } else {\n delete existing.assetProviderIdentity;\n delete existing.assetProviderIdentityProof;\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"]}
@@ -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;AAiCD,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;IAC5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CAAiC,IAAI,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAOrE,cAAc,CAAC,SAAS,GAAE,MAA8C,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxF,KAAK,CAAC,SAAS,GAAE,MAA8C,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5F;;;;;;OAMG;IACU,kBAAkB,CAAC,WAAW,EAAE,mBAAmB,GAAG,IAAI,EAAE,IAAI,GAAE,WAA6B;IA+I5G,OAAO,CAAC,uBAAuB;IAQ/B;;;;;;OAMG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrG;;;;;OAKG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAI7D;;;;OAIG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAItD;;;;OAIG;IACI,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAI/C;;;;;;;OAOG;YACW,wBAAwB;IAkHtC;;OAEG;IACI,IAAI,CAAC,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC;YAUnD,WAAW;IAmCzB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,0BAA0B;IAgBlC,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,iBAAiB;CAI1B"}
@@ -327,10 +327,15 @@ export default class UnsMqttProxy extends UnsProxy {
327
327
  const attrs = Array.isArray(mqttMessage.attributes)
328
328
  ? mqttMessage.attributes
329
329
  : [mqttMessage.attributes];
330
- const { topic, asset, assetDescription, assetStableEntityId, assetDisplayName, assetIdentityProof, objectType, objectTypeDescription, objectId, virtualGroup: requestVirtualGroup, } = mqttMessage;
330
+ const { topic, asset, assetDescription, assetStableEntityId, assetDisplayName, assetIdentityProof, assetProviderIdentity, assetProviderIdentityProof, objectType, objectTypeDescription, objectId, virtualGroup: requestVirtualGroup, } = mqttMessage;
331
331
  const hasAssetIdentityMetadata = assetStableEntityId !== undefined
332
332
  || assetDisplayName !== undefined
333
333
  || assetIdentityProof !== undefined;
334
+ const hasAssetProviderIdentityMetadata = assetProviderIdentity !== undefined
335
+ || assetProviderIdentityProof !== undefined;
336
+ if (hasAssetIdentityMetadata && hasAssetProviderIdentityMetadata) {
337
+ throw new Error("Stable Asset identity metadata and provider candidate metadata are mutually exclusive.");
338
+ }
334
339
  if (hasAssetIdentityMetadata) {
335
340
  if (typeof assetStableEntityId !== "string"
336
341
  || !assetStableEntityId.trim()
@@ -341,6 +346,15 @@ export default class UnsMqttProxy extends UnsProxy {
341
346
  throw new Error("Asset identity metadata requires assetStableEntityId and assetIdentityProof; assetDisplayName must be non-empty when supplied.");
342
347
  }
343
348
  }
349
+ if (hasAssetProviderIdentityMetadata) {
350
+ const identity = assetProviderIdentity;
351
+ if (!identity
352
+ || typeof assetProviderIdentityProof !== "string"
353
+ || !assetProviderIdentityProof.trim()
354
+ || ["providerId", "externalSystem", "externalType", "externalId"].some((key) => typeof identity[key] !== "string" || !identity[key].trim())) {
355
+ throw new Error("Provider Asset identity metadata requires providerId, externalSystem, externalType, externalId, and assetProviderIdentityProof.");
356
+ }
357
+ }
344
358
  for (const attrEntry of attrs) {
345
359
  const attrDescription = attrEntry.description ?? getAttributeDescription(attrEntry.attribute);
346
360
  const message = "message" in attrEntry && attrEntry.message
@@ -360,6 +374,15 @@ export default class UnsMqttProxy extends UnsProxy {
360
374
  ...(assetDisplayName ? { assetDisplayName: assetDisplayName.trim() } : {}),
361
375
  assetIdentityProof: assetIdentityProof.trim(),
362
376
  } : {}),
377
+ ...(hasAssetProviderIdentityMetadata ? {
378
+ assetProviderIdentity: {
379
+ providerId: assetProviderIdentity.providerId.trim().toLowerCase(),
380
+ externalSystem: assetProviderIdentity.externalSystem.trim().toLowerCase(),
381
+ externalType: assetProviderIdentity.externalType.trim().toLowerCase(),
382
+ externalId: assetProviderIdentity.externalId.trim(),
383
+ },
384
+ assetProviderIdentityProof: assetProviderIdentityProof.trim(),
385
+ } : {}),
363
386
  objectType,
364
387
  objectTypeDescription,
365
388
  objectId,
@@ -516,6 +539,8 @@ export default class UnsMqttProxy extends UnsProxy {
516
539
  assetStableEntityId: msg.assetStableEntityId,
517
540
  assetDisplayName: msg.assetDisplayName,
518
541
  assetIdentityProof: msg.assetIdentityProof,
542
+ assetProviderIdentity: msg.assetProviderIdentity,
543
+ assetProviderIdentityProof: msg.assetProviderIdentityProof,
519
544
  objectType,
520
545
  objectTypeDescription,
521
546
  objectId,