@uns-kit/core 2.0.44 → 2.0.46

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.
@@ -9,7 +9,10 @@ export default class UnsProxy {
9
9
  instanceNameWithSuffix; //was prot
10
10
  producedTopics = new Map();
11
11
  producedApiEndpoints = new Map();
12
+ producedServiceEndpoints = new Map();
13
+ producedDataOfferEndpoints = new Map();
12
14
  producedApiCatchall = new Map();
15
+ producedDataCatalogOffers = new Map();
13
16
  controllerNameEnv;
14
17
  controllerHostEnv;
15
18
  controllerPortEnv;
@@ -24,7 +27,10 @@ export default class UnsProxy {
24
27
  this.publishInterval = setInterval(() => {
25
28
  this.emitProducedTopics();
26
29
  this.emitProducedApiEndpoints();
30
+ this.emitProducedServiceEndpoints();
31
+ this.emitProducedDataOfferEndpoints();
27
32
  this.emitProducedApiCatchall();
33
+ this.emitProducedDataCatalogOffers();
28
34
  }, 60000);
29
35
  }
30
36
  /**
@@ -83,6 +89,57 @@ export default class UnsProxy {
83
89
  }
84
90
  }
85
91
  }
92
+ async emitProducedServiceEndpoints() {
93
+ if (this.instanceStatusTopic !== "") {
94
+ const serviceEndpointsArray = [...this.producedServiceEndpoints.values()];
95
+ if (serviceEndpointsArray.length > 0) {
96
+ try {
97
+ this.event.emit("unsProxyProducedServiceEndpoints", {
98
+ producedServiceEndpoints: serviceEndpointsArray,
99
+ statusTopic: this.instanceStatusTopic + "service-endpoints",
100
+ });
101
+ }
102
+ catch (error) {
103
+ logger.error(`${this.instanceNameWithSuffix} - Error publishing produced service endpoints: ${error.message}`);
104
+ }
105
+ logger.debug(`${this.instanceNameWithSuffix} - Published produced service endpoints.`);
106
+ }
107
+ }
108
+ }
109
+ async emitProducedDataOfferEndpoints() {
110
+ if (this.instanceStatusTopic !== "") {
111
+ const dataOfferEndpointsArray = [...this.producedDataOfferEndpoints.values()];
112
+ if (dataOfferEndpointsArray.length > 0) {
113
+ try {
114
+ this.event.emit("unsProxyProducedDataOfferEndpoints", {
115
+ producedDataOfferEndpoints: dataOfferEndpointsArray,
116
+ statusTopic: this.instanceStatusTopic + "data-offer-endpoints",
117
+ });
118
+ }
119
+ catch (error) {
120
+ logger.error(`${this.instanceNameWithSuffix} - Error publishing produced data offer endpoints: ${error.message}`);
121
+ }
122
+ logger.debug(`${this.instanceNameWithSuffix} - Published produced data offer endpoints.`);
123
+ }
124
+ }
125
+ }
126
+ async emitProducedDataCatalogOffers() {
127
+ if (this.instanceStatusTopic !== "") {
128
+ const offersArray = [...this.producedDataCatalogOffers.values()];
129
+ if (offersArray.length > 0) {
130
+ try {
131
+ this.event.emit("unsProxyProducedDataCatalogOffers", {
132
+ producedDataCatalogOffers: offersArray,
133
+ statusTopic: this.instanceStatusTopic + "data-catalog-offers",
134
+ });
135
+ }
136
+ catch (error) {
137
+ logger.error(`${this.instanceNameWithSuffix} - Error publishing data catalog offers: ${error.message}`);
138
+ }
139
+ logger.debug(`${this.instanceNameWithSuffix} - Published data catalog offers.`);
140
+ }
141
+ }
142
+ }
86
143
  /**
87
144
  * Registers a unique topic and keeps its timestamp current.
88
145
  *
@@ -133,17 +190,25 @@ export default class UnsProxy {
133
190
  registerApiEndpoint(apiObject) {
134
191
  if (this.instanceStatusTopic !== "") {
135
192
  const fullTopic = buildUnsIdentityPath(apiObject.topic, apiObject.asset, apiObject.objectType, apiObject.objectId, apiObject.attribute);
136
- if (!this.producedApiEndpoints.has(fullTopic)) {
193
+ const targetRegistry = apiObject.registryTopic === "service-endpoints"
194
+ ? this.producedServiceEndpoints
195
+ : apiObject.registryTopic === "data-offer-endpoints"
196
+ ? this.producedDataOfferEndpoints
197
+ : this.producedApiEndpoints;
198
+ if (!targetRegistry.has(fullTopic)) {
137
199
  const time = UnsPacket.formatToISO8601(new Date());
138
- this.producedApiEndpoints.set(fullTopic, {
200
+ targetRegistry.set(fullTopic, {
139
201
  timestamp: time,
140
202
  topic: apiObject.topic,
141
203
  attribute: apiObject.attribute,
204
+ ...(apiObject.routeOnly === true ? { routeOnly: true } : {}),
205
+ ...(apiObject.registryTopic ? { registryTopic: apiObject.registryTopic } : {}),
142
206
  apiHost: apiObject.apiHost,
143
207
  apiEndpoint: apiObject.apiEndpoint,
144
208
  apiMethod: apiObject.apiMethod,
145
209
  apiQueryParams: apiObject.apiQueryParams,
146
210
  apiDescription: apiObject.apiDescription,
211
+ ...(apiObject.serviceApi ? { serviceApi: apiObject.serviceApi } : {}),
147
212
  attributeType: apiObject.attributeType,
148
213
  apiSwaggerEndpoint: apiObject.apiSwaggerEndpoint,
149
214
  asset: apiObject.asset,
@@ -154,8 +219,18 @@ export default class UnsProxy {
154
219
  ...(this.controllerPortEnv ? { controllerPort: this.controllerPortEnv } : {}),
155
220
  ...(this.controllerPublicBaseEnv ? { controllerPublicBase: this.controllerPublicBaseEnv } : {}),
156
221
  });
157
- this.emitProducedApiEndpoints();
158
- logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);
222
+ if (apiObject.registryTopic === "service-endpoints") {
223
+ this.emitProducedServiceEndpoints();
224
+ logger.info(`${this.instanceNameWithSuffix} - Registered new service endpoint: /${fullTopic}`);
225
+ }
226
+ else if (apiObject.registryTopic === "data-offer-endpoints") {
227
+ this.emitProducedDataOfferEndpoints();
228
+ logger.info(`${this.instanceNameWithSuffix} - Registered new data offer endpoint: /${fullTopic}`);
229
+ }
230
+ else {
231
+ this.emitProducedApiEndpoints();
232
+ logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);
233
+ }
159
234
  }
160
235
  }
161
236
  }
@@ -174,12 +249,38 @@ export default class UnsProxy {
174
249
  }
175
250
  unregisterApiEndpoint(topic, asset, objectType, objectId, attribute) {
176
251
  const fullTopic = buildUnsIdentityPath(topic, asset, objectType, objectId, attribute);
252
+ let removed = false;
177
253
  if (this.producedApiEndpoints.has(fullTopic)) {
178
254
  this.producedApiEndpoints.delete(fullTopic);
179
255
  this.emitProducedApiEndpoints();
256
+ removed = true;
257
+ }
258
+ if (this.producedServiceEndpoints.has(fullTopic)) {
259
+ this.producedServiceEndpoints.delete(fullTopic);
260
+ this.emitProducedServiceEndpoints();
261
+ removed = true;
262
+ }
263
+ if (this.producedDataOfferEndpoints.has(fullTopic)) {
264
+ this.producedDataOfferEndpoints.delete(fullTopic);
265
+ this.emitProducedDataOfferEndpoints();
266
+ removed = true;
267
+ }
268
+ if (removed) {
180
269
  logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);
181
270
  }
182
271
  }
272
+ registerDataCatalogOffer(offer) {
273
+ if (this.instanceStatusTopic === "") {
274
+ return;
275
+ }
276
+ const offerId = typeof offer.offerId === "string" ? offer.offerId.trim() : "";
277
+ if (!offerId) {
278
+ return;
279
+ }
280
+ this.producedDataCatalogOffers.set(offerId, offer);
281
+ this.emitProducedDataCatalogOffers();
282
+ logger.info(`${this.instanceNameWithSuffix} - Registered data catalog offer: ${offerId}`);
283
+ }
183
284
  async stop() {
184
285
  // Clear the publishing interval.
185
286
  if (this.publishInterval) {
@@ -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,mBAAmB,GAAqC,IAAI,GAAG,EAAE,CAAC;I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,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 producedApiCatchall: Map<string, IApiCatchallMapping> = 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.emitProducedApiCatchall();\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 /**\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 dataGroup: topicObject.dataGroup ?? \"\",\n asset: topicObject.asset,\n assetDescription: topicObject.assetDescription,\n objectType: topicObject.objectType,\n objectTypeDescription: topicObject.objectTypeDescription,\n objectId: topicObject.objectId,\n ...(topicObject.validityMode ? { validityMode: topicObject.validityMode } : {}),\n ...(topicObject.expectedIntervalMs ? { expectedIntervalMs: topicObject.expectedIntervalMs } : {}),\n ...(topicObject.lifecycleEndValue ? { lifecycleEndValue: topicObject.lifecycleEndValue } : {}),\n });\n this.emitProducedTopics();\n logger.info(`${this.instanceNameWithSuffix} - Registered new topic: ${fullTopic}`);\n } else {\n // Already registered — refresh only the timestamp so the periodic\n // heartbeat reflects actual data flow rather than frozen startup time.\n this.producedTopics.get(fullTopic)!.timestamp = topicObject.timestamp;\n }\n }\n }\n\n /**\n * Registers an API endpoint to handle requests for a specific topic and attribute.\n */\n protected registerApiEndpoint(apiObject: IApiObject): void {\n if (this.instanceStatusTopic !== \"\") {\n const fullTopic = buildUnsIdentityPath(\n apiObject.topic,\n apiObject.asset,\n apiObject.objectType,\n apiObject.objectId,\n apiObject.attribute,\n );\n if (!this.producedApiEndpoints.has(fullTopic)) {\n const time = UnsPacket.formatToISO8601(new Date());\n this.producedApiEndpoints.set(fullTopic, {\n timestamp: time,\n topic: apiObject.topic,\n attribute: apiObject.attribute,\n apiHost: apiObject.apiHost,\n apiEndpoint: apiObject.apiEndpoint,\n apiMethod: apiObject.apiMethod,\n apiQueryParams: apiObject.apiQueryParams,\n apiDescription: apiObject.apiDescription,\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 this.emitProducedApiEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);\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 if (this.producedApiEndpoints.has(fullTopic)) {\n this.producedApiEndpoints.delete(fullTopic);\n this.emitProducedApiEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);\n }\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;AACz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aces.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 dataGroup: topicObject.dataGroup ?? \"\",\n asset: topicObject.asset,\n assetDescription: topicObject.assetDescription,\n objectType: topicObject.objectType,\n objectTypeDescription: topicObject.objectTypeDescription,\n objectId: topicObject.objectId,\n ...(topicObject.validityMode ? { validityMode: topicObject.validityMode } : {}),\n ...(topicObject.expectedIntervalMs ? { expectedIntervalMs: topicObject.expectedIntervalMs } : {}),\n ...(topicObject.lifecycleEndValue ? { lifecycleEndValue: topicObject.lifecycleEndValue } : {}),\n });\n this.emitProducedTopics();\n logger.info(`${this.instanceNameWithSuffix} - Registered new topic: ${fullTopic}`);\n } else {\n // Already registered — refresh only the timestamp so the periodic\n // heartbeat reflects actual data flow rather than frozen startup time.\n this.producedTopics.get(fullTopic)!.timestamp = topicObject.timestamp;\n }\n }\n }\n\n /**\n * Registers an API endpoint to handle requests for a specific topic and attribute.\n */\n protected registerApiEndpoint(apiObject: IApiObject): void {\n if (this.instanceStatusTopic !== \"\") {\n const fullTopic = buildUnsIdentityPath(\n apiObject.topic,\n apiObject.asset,\n apiObject.objectType,\n apiObject.objectId,\n apiObject.attribute,\n );\n const targetRegistry =\n apiObject.registryTopic === \"service-endpoints\"\n ? this.producedServiceEndpoints\n : apiObject.registryTopic === \"data-offer-endpoints\"\n ? this.producedDataOfferEndpoints\n : this.producedApiEndpoints;\n if (!targetRegistry.has(fullTopic)) {\n const time = UnsPacket.formatToISO8601(new Date());\n targetRegistry.set(fullTopic, {\n timestamp: time,\n topic: apiObject.topic,\n attribute: apiObject.attribute,\n ...(apiObject.routeOnly === true ? { routeOnly: true } : {}),\n ...(apiObject.registryTopic ? { registryTopic: apiObject.registryTopic } : {}),\n apiHost: apiObject.apiHost,\n apiEndpoint: apiObject.apiEndpoint,\n apiMethod: apiObject.apiMethod,\n apiQueryParams: apiObject.apiQueryParams,\n apiDescription: apiObject.apiDescription,\n ...(apiObject.serviceApi ? { serviceApi: apiObject.serviceApi } : {}),\n attributeType: apiObject.attributeType,\n apiSwaggerEndpoint: apiObject.apiSwaggerEndpoint,\n asset: apiObject.asset,\n objectType: apiObject.objectType,\n objectId: apiObject.objectId,\n ...(this.controllerNameEnv ? { controllerName: this.controllerNameEnv } : {}),\n ...(this.controllerHostEnv ? { controllerHost: this.controllerHostEnv } : {}),\n ...(this.controllerPortEnv ? { controllerPort: this.controllerPortEnv } : {}),\n ...(this.controllerPublicBaseEnv ? { controllerPublicBase: this.controllerPublicBaseEnv } : {}),\n });\n if (apiObject.registryTopic === \"service-endpoints\") {\n this.emitProducedServiceEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new service endpoint: /${fullTopic}`);\n } else if (apiObject.registryTopic === \"data-offer-endpoints\") {\n this.emitProducedDataOfferEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new data offer endpoint: /${fullTopic}`);\n } else {\n this.emitProducedApiEndpoints();\n logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);\n }\n }\n }\n }\n\n protected registerApiCatchAll(mapping: IApiCatchallMapping): void {\n if (this.instanceStatusTopic !== \"\") {\n const key = mapping.topic.replace(/\\/+$/, \"\");\n if (!this.producedApiCatchall.has(key)) {\n this.producedApiCatchall.set(key, mapping);\n } else {\n this.producedApiCatchall.set(key, { ...this.producedApiCatchall.get(key)!, ...mapping });\n }\n this.emitProducedApiCatchall();\n logger.info(`${this.instanceNameWithSuffix} - Registered catch-all API mapping: ${key}`);\n }\n }\n\n protected unregisterApiEndpoint(topic: string, asset:UnsAsset, objectType: UnsObjectType, objectId: UnsObjectId, attribute: string): void {\n const fullTopic = buildUnsIdentityPath(topic, asset, objectType, objectId, attribute);\n let removed = false;\n if (this.producedApiEndpoints.has(fullTopic)) {\n this.producedApiEndpoints.delete(fullTopic);\n this.emitProducedApiEndpoints();\n removed = true;\n }\n if (this.producedServiceEndpoints.has(fullTopic)) {\n this.producedServiceEndpoints.delete(fullTopic);\n this.emitProducedServiceEndpoints();\n removed = true;\n }\n if (this.producedDataOfferEndpoints.has(fullTopic)) {\n this.producedDataOfferEndpoints.delete(fullTopic);\n this.emitProducedDataOfferEndpoints();\n removed = true;\n }\n if (removed) {\n logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);\n }\n }\n\n protected registerDataCatalogOffer(offer: { offerId: string } & Record<string, unknown>): void {\n if (this.instanceStatusTopic === \"\") {\n return;\n }\n const offerId = typeof offer.offerId === \"string\" ? offer.offerId.trim() : \"\";\n if (!offerId) {\n return;\n }\n this.producedDataCatalogOffers.set(offerId, offer);\n this.emitProducedDataCatalogOffers();\n logger.info(`${this.instanceNameWithSuffix} - Registered data catalog offer: ${offerId}`);\n }\n public async stop() {\n // Clear the publishing interval.\n if (this.publishInterval) {\n clearInterval(this.publishInterval);\n this.publishInterval = null;\n }\n\n }\n\n}\n"]}
@@ -698,9 +698,9 @@ export declare const unsCoreSchema: z.ZodObject<{
698
698
  projectId?: string;
699
699
  };
700
700
  processName?: string;
701
- email?: string;
702
701
  graphql?: string;
703
702
  rest?: string;
703
+ email?: string;
704
704
  instanceMode?: "wait" | "force" | "handover";
705
705
  supervisor?: {
706
706
  enabled?: boolean;
@@ -730,9 +730,9 @@ export declare const unsCoreSchema: z.ZodObject<{
730
730
  projectId?: string;
731
731
  };
732
732
  processName?: string;
733
- email?: string;
734
733
  graphql?: string;
735
734
  rest?: string;
735
+ email?: string;
736
736
  instanceMode?: "wait" | "force" | "handover";
737
737
  supervisor?: {
738
738
  enabled?: boolean;
@@ -2687,9 +2687,9 @@ export declare const unsCoreSchema: z.ZodObject<{
2687
2687
  projectId?: string;
2688
2688
  };
2689
2689
  processName?: string;
2690
- email?: string;
2691
2690
  graphql?: string;
2692
2691
  rest?: string;
2692
+ email?: string;
2693
2693
  instanceMode?: "wait" | "force" | "handover";
2694
2694
  supervisor?: {
2695
2695
  enabled?: boolean;
@@ -3016,9 +3016,9 @@ export declare const unsCoreSchema: z.ZodObject<{
3016
3016
  projectId?: string;
3017
3017
  };
3018
3018
  processName?: string;
3019
- email?: string;
3020
3019
  graphql?: string;
3021
3020
  rest?: string;
3021
+ email?: string;
3022
3022
  instanceMode?: "wait" | "force" | "handover";
3023
3023
  supervisor?: {
3024
3024
  enabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/core",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "Core utilities and runtime building blocks for UNS-based realtime transformers.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,8 +0,0 @@
1
- /**
2
- * Retrieves a persistent process name.
3
- * - Checks if a process name is provided via command-line args.
4
- * - Otherwise, reads the process name from a file.
5
- * - If the file does not exist, generates a new name and stores it.
6
- */
7
- export declare function getProcessName(): string;
8
- //# sourceMappingURL=process-name-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-name-service.d.ts","sourceRoot":"","sources":["../../src/uns/process-name-service.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAoBvC"}
@@ -1,29 +0,0 @@
1
- import { readFileSync, writeFileSync } from "fs";
2
- import { PROCESS_NAME_FILE } from "./process-config.js";
3
- import logger from "../logger.js";
4
- /**
5
- * Retrieves a persistent process name.
6
- * - Checks if a process name is provided via command-line args.
7
- * - Otherwise, reads the process name from a file.
8
- * - If the file does not exist, generates a new name and stores it.
9
- */
10
- export function getProcessName() {
11
- // Try to read the process name from the configuration file.
12
- try {
13
- return readFileSync(PROCESS_NAME_FILE, "utf8").trim();
14
- }
15
- catch {
16
- // Generate a new process name if reading fails
17
- const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
18
- const newProcessName = Array.from({ length: 6 }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join("");
19
- // Write the new process name to the file for persistence
20
- try {
21
- writeFileSync(PROCESS_NAME_FILE, newProcessName, "utf8");
22
- }
23
- catch (err) {
24
- logger.error("Failed to write process name file:", err);
25
- }
26
- return newProcessName;
27
- }
28
- }
29
- //# sourceMappingURL=process-name-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-name-service.js","sourceRoot":"","sources":["../../src/uns/process-name-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,4DAA4D;IAC5D,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,+CAA+C;QAC/C,MAAM,KAAK,GAAG,sCAAsC,CAAC;QACrD,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CACpD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CACvD,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEX,yDAAyD;QACzD,IAAI,CAAC;YACH,aAAa,CAAC,iBAAiB,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;AACH,CAAC","sourcesContent":["import { readFileSync, writeFileSync } from \"fs\";\nimport { PROCESS_NAME_FILE } from \"./process-config.js\";\nimport logger from \"../logger.js\";\n\n/**\n * Retrieves a persistent process name.\n * - Checks if a process name is provided via command-line args.\n * - Otherwise, reads the process name from a file.\n * - If the file does not exist, generates a new name and stores it.\n */\nexport function getProcessName(): string {\n // Try to read the process name from the configuration file.\n try {\n return readFileSync(PROCESS_NAME_FILE, \"utf8\").trim();\n } catch {\n // Generate a new process name if reading fails\n const chars = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n const newProcessName = Array.from({ length: 6 }, () =>\n chars.charAt(Math.floor(Math.random() * chars.length))\n ).join(\"\");\n\n // Write the new process name to the file for persistence\n try {\n writeFileSync(PROCESS_NAME_FILE, newProcessName, \"utf8\");\n } catch (err) {\n logger.error(\"Failed to write process name file:\", err);\n }\n\n return newProcessName;\n }\n}\n"]}