@uns-kit/core 3.0.20 → 3.0.21
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.
- package/MIGRATIONS.md +20 -0
- package/dist/uns/uns-proxy.d.ts +6 -0
- package/dist/uns/uns-proxy.d.ts.map +1 -1
- package/dist/uns/uns-proxy.js +20 -2
- package/dist/uns/uns-proxy.js.map +1 -1
- package/package.json +1 -1
package/MIGRATIONS.md
CHANGED
|
@@ -9,6 +9,26 @@ Agents must inspect the application's existing ownership and shutdown flow
|
|
|
9
9
|
before editing it. The examples below describe the intended behavior, not a
|
|
10
10
|
mechanical search-and-replace operation.
|
|
11
11
|
|
|
12
|
+
## 3.0.21 - Explicit publisher topic reconciliation
|
|
13
|
+
|
|
14
|
+
Applications upgrading from `<3.0.21` to `>=3.0.21` can opt into
|
|
15
|
+
`UnsProxy.retainProducedTopics(fullTopics)`. Pass the complete set of configured
|
|
16
|
+
UNS attribute paths for that proxy. The method removes previously observed topic
|
|
17
|
+
metadata outside that set and immediately announces the remaining metadata,
|
|
18
|
+
including an empty list when the last observed topic is removed. It returns the
|
|
19
|
+
number of removed entries. Configured paths that have never published data are
|
|
20
|
+
not registered by this call.
|
|
21
|
+
|
|
22
|
+
A bridge/runtime must stop accepting events for removed mappings and drain
|
|
23
|
+
already accepted publications before reconciliation; a later publication can
|
|
24
|
+
register its topic again. Keep configured-but-stopped mappings and shared targets
|
|
25
|
+
in the retained set. Connection Stop alone is not a reason to remove metadata.
|
|
26
|
+
|
|
27
|
+
This API affects only the proxy's publisher metadata cache. It does not delete
|
|
28
|
+
UNS definitions, retained MQTT business values, archiver mappings, historical
|
|
29
|
+
sources or physical data. Existing publishers need no change; their default
|
|
30
|
+
registration and heartbeat behavior remains the same.
|
|
31
|
+
|
|
12
32
|
## 3.0.19 - Provider-bound Asset identity candidates
|
|
13
33
|
|
|
14
34
|
Apply this migration when upgrading a publisher from `@uns-kit/core` `<3.0.19`
|
package/dist/uns/uns-proxy.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export default class UnsProxy {
|
|
|
23
23
|
* Publishes the list of produced topics to the MQTT broker.
|
|
24
24
|
*/
|
|
25
25
|
private emitProducedTopics;
|
|
26
|
+
/**
|
|
27
|
+
* Reconcile this publisher's observed metadata with its configured targets.
|
|
28
|
+
* Does not register unseen targets, touch other publishers, clear MQTT values,
|
|
29
|
+
* remove UNS objects, or delete historical data. Empty snapshots are explicit.
|
|
30
|
+
*/
|
|
31
|
+
retainProducedTopics(fullTopics: Iterable<string>): number;
|
|
26
32
|
/**
|
|
27
33
|
* Publishes the list of produced API endpoints to the MQTT broker.
|
|
28
34
|
*/
|
|
@@ -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,C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,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"}
|
package/dist/uns/uns-proxy.js
CHANGED
|
@@ -36,10 +36,10 @@ export default class UnsProxy {
|
|
|
36
36
|
/**
|
|
37
37
|
* Publishes the list of produced topics to the MQTT broker.
|
|
38
38
|
*/
|
|
39
|
-
async emitProducedTopics() {
|
|
39
|
+
async emitProducedTopics(includeEmpty = false) {
|
|
40
40
|
if (this.instanceStatusTopic !== "") {
|
|
41
41
|
const topicsArray = [...this.producedTopics.values()];
|
|
42
|
-
if (topicsArray.length > 0) {
|
|
42
|
+
if (topicsArray.length > 0 || includeEmpty) {
|
|
43
43
|
try {
|
|
44
44
|
this.event.emit("unsProxyProducedTopics", { producedTopics: topicsArray, statusTopic: this.instanceStatusTopic + "topics" });
|
|
45
45
|
}
|
|
@@ -50,6 +50,24 @@ export default class UnsProxy {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Reconcile this publisher's observed metadata with its configured targets.
|
|
55
|
+
* Does not register unseen targets, touch other publishers, clear MQTT values,
|
|
56
|
+
* remove UNS objects, or delete historical data. Empty snapshots are explicit.
|
|
57
|
+
*/
|
|
58
|
+
retainProducedTopics(fullTopics) {
|
|
59
|
+
const retained = new Set(Array.from(fullTopics, topic => buildUnsIdentityPath(topic)));
|
|
60
|
+
let removed = 0;
|
|
61
|
+
for (const topic of this.producedTopics.keys()) {
|
|
62
|
+
if (!retained.has(topic)) {
|
|
63
|
+
this.producedTopics.delete(topic);
|
|
64
|
+
removed++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (removed > 0)
|
|
68
|
+
void this.emitProducedTopics(true);
|
|
69
|
+
return removed;
|
|
70
|
+
}
|
|
53
71
|
/**
|
|
54
72
|
* Publishes the list of produced API endpoints to the MQTT broker.
|
|
55
73
|
*/
|
|
@@ -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,CAAC,UAAU;IAC5C,cAAc,GAA8B,IAAI,GAAG,EAAE,CAAC;IACtD,oBAAoB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC1D,wBAAwB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC9D,0BAA0B,GAA4B,IAAI,GAAG,EAAE,CAAC;IAChE,mBAAmB,GAAqC,IAAI,GAAG,EAAE,CAAC;IAClE,yBAAyB,GAAyB,IAAI,GAAG,EAAE,CAAC;IACnD,iBAAiB,CAAqB;IACtC,iBAAiB,CAAqB;IACtC,iBAAiB,CAAqB;IACtC,uBAAuB,CAAqB;IAE7D;QACE,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAC5D,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAC5D,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAC5D,IAAI,CAAC,uBAAuB;YAC1B,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAi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,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 ...(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
|
+
{"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,CAAC,UAAU;IAC5C,cAAc,GAA8B,IAAI,GAAG,EAAE,CAAC;IACtD,oBAAoB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC1D,wBAAwB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC9D,0BAA0B,GAA4B,IAAI,GAAG,EAAE,CAAC;IAChE,mBAAmB,GAAqC,IAAI,GAAG,EAAE,CAAC;IAClE,yBAAyB,GAAyB,IAAI,GAAG,EAAE,CAAC;IACnD,iBAAiB,CAAqB;IACtC,iBAAiB,CAAqB;IACtC,iBAAiB,CAAqB;IACtC,uBAAuB,CAAqB;IAE7D;QACE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,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(includeEmpty = false): Promise<void> {\n if (this.instanceStatusTopic !== \"\") {\n const topicsArray = [...this.producedTopics.values()];\n if (topicsArray.length > 0 || includeEmpty) {\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 * Reconcile this publisher's observed metadata with its configured targets.\n * Does not register unseen targets, touch other publishers, clear MQTT values,\n * remove UNS objects, or delete historical data. Empty snapshots are explicit.\n */\n public retainProducedTopics(fullTopics: Iterable<string>): number {\n const retained = new Set(Array.from(fullTopics, topic => buildUnsIdentityPath(topic)));\n let removed = 0;\n for (const topic of this.producedTopics.keys()) {\n if (!retained.has(topic)) {\n this.producedTopics.delete(topic);\n removed++;\n }\n }\n if (removed > 0) void this.emitProducedTopics(true);\n return removed;\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"]}
|