@uns-kit/core 2.0.40 → 2.0.41

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.
Files changed (54) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +170 -147
  3. package/dist/index.d.ts +9 -8
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +8 -7
  6. package/dist/index.js.map +1 -1
  7. package/dist/tools/datahub/datahub-client.js.map +1 -1
  8. package/dist/tools/file-utils.d.ts +2 -2
  9. package/dist/tools/file-utils.js +24 -24
  10. package/dist/tools/generate-uns-dictionary.d.ts +23 -23
  11. package/dist/tools/generate-uns-dictionary.js +154 -154
  12. package/dist/tools/generate-uns-measurements.d.ts +21 -21
  13. package/dist/tools/generate-uns-measurements.js +126 -126
  14. package/dist/tools/generate-uns-reference.d.ts +2 -2
  15. package/dist/tools/generate-uns-reference.js +85 -85
  16. package/dist/tools/refresh-uns.js +50 -50
  17. package/dist/tools/sync-uns-schema.d.ts +2 -2
  18. package/dist/tools/sync-uns-schema.js +489 -489
  19. package/dist/uns/service-metadata.d.ts +53 -0
  20. package/dist/uns/service-metadata.d.ts.map +1 -0
  21. package/dist/uns/service-metadata.js +56 -0
  22. package/dist/uns/service-metadata.js.map +1 -0
  23. package/dist/uns/uns-asset.d.ts +1 -1
  24. package/dist/uns/uns-asset.js +1 -1
  25. package/dist/uns/uns-attributes.d.ts +6 -6
  26. package/dist/uns/uns-attributes.js +9 -9
  27. package/dist/uns/uns-dictionary-registry.d.ts +4 -4
  28. package/dist/uns/uns-dictionary-registry.js +20 -20
  29. package/dist/uns/uns-dictionary.generated.d.ts +663 -663
  30. package/dist/uns/uns-dictionary.generated.js +745 -745
  31. package/dist/uns/uns-interfaces.d.ts +365 -365
  32. package/dist/uns/uns-measurements.generated.d.ts +362 -362
  33. package/dist/uns/uns-measurements.generated.js +359 -359
  34. package/dist/uns/uns-object.d.ts +20 -20
  35. package/dist/uns/uns-object.js +9 -9
  36. package/dist/uns/uns-packet.js +263 -263
  37. package/dist/uns/uns-path.d.ts +2 -2
  38. package/dist/uns/uns-path.js +10 -10
  39. package/dist/uns/uns-proxy-process.d.ts +11 -0
  40. package/dist/uns/uns-proxy-process.d.ts.map +1 -1
  41. package/dist/uns/uns-proxy-process.js +224 -203
  42. package/dist/uns/uns-proxy-process.js.map +1 -1
  43. package/dist/uns/uns-proxy.d.ts +51 -51
  44. package/dist/uns/uns-proxy.js +190 -190
  45. package/dist/uns-config/uns-core-schema.d.ts +3276 -3276
  46. package/dist/uns-grpc/uns-gateway.proto +104 -104
  47. package/dist/uns-mqtt/mqtt-topic-builder.d.ts +6 -0
  48. package/dist/uns-mqtt/mqtt-topic-builder.d.ts.map +1 -1
  49. package/dist/uns-mqtt/mqtt-topic-builder.js +8 -0
  50. package/dist/uns-mqtt/mqtt-topic-builder.js.map +1 -1
  51. package/dist/uns-mqtt/uns-mqtt-proxy.js +477 -477
  52. package/package.json +1 -1
  53. package/dist/app-config.d.ts.map +0 -1
  54. package/dist/app-config.js.map +0 -1
@@ -1,52 +1,52 @@
1
- import { IApiObject, ITopicObject, UnsEvents } from "./uns-interfaces.js";
2
- import { UnsEventEmitter } from "./uns-event-emitter.js";
3
- import { UnsAsset } from "./uns-asset.js";
4
- import { UnsObjectId, UnsObjectType } from "./uns-object.js";
5
- import { IApiCatchallMapping } from "./uns-interfaces.js";
6
- export default class UnsProxy {
7
- private publishInterval;
8
- event: UnsEventEmitter<UnsEvents>;
9
- protected instanceStatusTopic: string;
10
- protected instanceNameWithSuffix: string;
11
- private producedTopics;
12
- private producedApiEndpoints;
13
- private producedApiCatchall;
14
- private readonly controllerNameEnv;
15
- private readonly controllerHostEnv;
16
- private readonly controllerPortEnv;
17
- private readonly controllerPublicBaseEnv;
18
- constructor();
19
- /**
20
- * Publishes the list of produced topics to the MQTT broker.
21
- */
22
- private emitProducedTopics;
23
- /**
24
- * Publishes the list of produced API endpoints to the MQTT broker.
25
- */
26
- private emitProducedApiEndpoints;
27
- /**
28
- * Publishes the list of catch-all API mappings to the MQTT broker.
29
- */
30
- private emitProducedApiCatchall;
31
- /**
32
- * Registers a unique topic and keeps its timestamp current.
33
- *
34
- * On first call the full entry is created and immediately emitted so the
35
- * controller can persist the new schema node. On subsequent calls only the
36
- * timestamp is updated in-place; the 60-second heartbeat interval will carry
37
- * the updated value to the controller, making the timestamp reflect the time
38
- * of the most recent data publication rather than the one-off registration
39
- * moment.
40
- *
41
- * @param topicObject - The object containing topic details.
42
- */
43
- protected registerUniqueTopic(topicObject: ITopicObject): void;
44
- /**
45
- * Registers an API endpoint to handle requests for a specific topic and attribute.
46
- */
47
- protected registerApiEndpoint(apiObject: IApiObject): void;
48
- protected registerApiCatchAll(mapping: IApiCatchallMapping): void;
49
- protected unregisterApiEndpoint(topic: string, asset: UnsAsset, objectType: UnsObjectType, objectId: UnsObjectId, attribute: string): void;
50
- stop(): Promise<void>;
51
- }
1
+ import { IApiObject, ITopicObject, UnsEvents } from "./uns-interfaces.js";
2
+ import { UnsEventEmitter } from "./uns-event-emitter.js";
3
+ import { UnsAsset } from "./uns-asset.js";
4
+ import { UnsObjectId, UnsObjectType } from "./uns-object.js";
5
+ import { IApiCatchallMapping } from "./uns-interfaces.js";
6
+ export default class UnsProxy {
7
+ private publishInterval;
8
+ event: UnsEventEmitter<UnsEvents>;
9
+ protected instanceStatusTopic: string;
10
+ protected instanceNameWithSuffix: string;
11
+ private producedTopics;
12
+ private producedApiEndpoints;
13
+ private producedApiCatchall;
14
+ private readonly controllerNameEnv;
15
+ private readonly controllerHostEnv;
16
+ private readonly controllerPortEnv;
17
+ private readonly controllerPublicBaseEnv;
18
+ constructor();
19
+ /**
20
+ * Publishes the list of produced topics to the MQTT broker.
21
+ */
22
+ private emitProducedTopics;
23
+ /**
24
+ * Publishes the list of produced API endpoints to the MQTT broker.
25
+ */
26
+ private emitProducedApiEndpoints;
27
+ /**
28
+ * Publishes the list of catch-all API mappings to the MQTT broker.
29
+ */
30
+ private emitProducedApiCatchall;
31
+ /**
32
+ * Registers a unique topic and keeps its timestamp current.
33
+ *
34
+ * On first call the full entry is created and immediately emitted so the
35
+ * controller can persist the new schema node. On subsequent calls only the
36
+ * timestamp is updated in-place; the 60-second heartbeat interval will carry
37
+ * the updated value to the controller, making the timestamp reflect the time
38
+ * of the most recent data publication rather than the one-off registration
39
+ * moment.
40
+ *
41
+ * @param topicObject - The object containing topic details.
42
+ */
43
+ protected registerUniqueTopic(topicObject: ITopicObject): void;
44
+ /**
45
+ * Registers an API endpoint to handle requests for a specific topic and attribute.
46
+ */
47
+ protected registerApiEndpoint(apiObject: IApiObject): void;
48
+ protected registerApiCatchAll(mapping: IApiCatchallMapping): void;
49
+ protected unregisterApiEndpoint(topic: string, asset: UnsAsset, objectType: UnsObjectType, objectId: UnsObjectId, attribute: string): void;
50
+ stop(): Promise<void>;
51
+ }
52
52
  //# sourceMappingURL=uns-proxy.d.ts.map
@@ -1,191 +1,191 @@
1
- import logger from "../logger.js";
2
- import { UnsEventEmitter } from "./uns-event-emitter.js";
3
- import { UnsPacket } from "./uns-packet.js";
4
- import { buildUnsIdentityPath } from "./uns-path.js";
5
- export default class UnsProxy {
6
- publishInterval = null;
7
- event = new UnsEventEmitter();
8
- instanceStatusTopic;
9
- instanceNameWithSuffix; //was prot
10
- producedTopics = new Map();
11
- producedApiEndpoints = new Map();
12
- producedApiCatchall = new Map();
13
- controllerNameEnv;
14
- controllerHostEnv;
15
- controllerPortEnv;
16
- controllerPublicBaseEnv;
17
- constructor() {
18
- this.controllerNameEnv = process.env["UNS_CONTROLLER_NAME"];
19
- this.controllerHostEnv = process.env["UNS_CONTROLLER_HOST"];
20
- this.controllerPortEnv = process.env["UNS_CONTROLLER_PORT"];
21
- this.controllerPublicBaseEnv =
22
- process.env["UNS_CONTROLLER_PUBLIC_BASE"] ?? process.env["UNS_PUBLIC_BASE"];
23
- // Set up interval to publish produced topics every 60 seconds.
24
- this.publishInterval = setInterval(() => {
25
- this.emitProducedTopics();
26
- this.emitProducedApiEndpoints();
27
- this.emitProducedApiCatchall();
28
- }, 60000);
29
- }
30
- /**
31
- * Publishes the list of produced topics to the MQTT broker.
32
- */
33
- async emitProducedTopics() {
34
- if (this.instanceStatusTopic !== "") {
35
- const topicsArray = [...this.producedTopics.values()];
36
- if (topicsArray.length > 0) {
37
- try {
38
- this.event.emit("unsProxyProducedTopics", { producedTopics: topicsArray, statusTopic: this.instanceStatusTopic + "topics" });
39
- }
40
- catch (error) {
41
- logger.error(`${this.instanceNameWithSuffix} - Error publishing produced topics: ${error.message}`);
42
- }
43
- logger.debug(`${this.instanceNameWithSuffix} - Published produced topics.`);
44
- }
45
- }
46
- }
47
- /**
48
- * Publishes the list of produced API endpoints to the MQTT broker.
49
- */
50
- async emitProducedApiEndpoints() {
51
- if (this.instanceStatusTopic !== "") {
52
- const apiEndpointsArray = [...this.producedApiEndpoints.values()];
53
- if (apiEndpointsArray.length > 0) {
54
- try {
55
- if (apiEndpointsArray.length > 0) {
56
- this.event.emit("unsProxyProducedApiEndpoints", { producedApiEndpoints: apiEndpointsArray, statusTopic: this.instanceStatusTopic + "api-endpoints" });
57
- }
58
- }
59
- catch (error) {
60
- logger.error(`${this.instanceNameWithSuffix} - Error publishing produced API endpoints: ${error.message}`);
61
- }
62
- logger.debug(`${this.instanceNameWithSuffix} - Published produced API endpoints.`);
63
- }
64
- }
65
- }
66
- /**
67
- * Publishes the list of catch-all API mappings to the MQTT broker.
68
- */
69
- async emitProducedApiCatchall() {
70
- if (this.instanceStatusTopic !== "") {
71
- const catchallArray = [...this.producedApiCatchall.values()];
72
- if (catchallArray.length > 0) {
73
- try {
74
- this.event.emit("unsProxyProducedApiCatchAll", {
75
- producedCatchall: catchallArray,
76
- statusTopic: this.instanceStatusTopic + "api-catchall",
77
- });
78
- }
79
- catch (error) {
80
- logger.error(`${this.instanceNameWithSuffix} - Error publishing catch-all API mappings: ${error.message}`);
81
- }
82
- logger.debug(`${this.instanceNameWithSuffix} - Published catch-all API mappings.`);
83
- }
84
- }
85
- }
86
- /**
87
- * Registers a unique topic and keeps its timestamp current.
88
- *
89
- * On first call the full entry is created and immediately emitted so the
90
- * controller can persist the new schema node. On subsequent calls only the
91
- * timestamp is updated in-place; the 60-second heartbeat interval will carry
92
- * the updated value to the controller, making the timestamp reflect the time
93
- * of the most recent data publication rather than the one-off registration
94
- * moment.
95
- *
96
- * @param topicObject - The object containing topic details.
97
- */
98
- registerUniqueTopic(topicObject) {
99
- if (this.instanceStatusTopic !== "") {
100
- const fullTopic = buildUnsIdentityPath(topicObject.topic, topicObject.asset, topicObject.objectType, topicObject.objectId, topicObject.attribute);
101
- if (!this.producedTopics.has(fullTopic)) {
102
- this.producedTopics.set(fullTopic, {
103
- timestamp: topicObject.timestamp,
104
- topic: topicObject.topic,
105
- attribute: topicObject.attribute,
106
- attributeType: topicObject.attributeType,
107
- description: topicObject.description,
108
- tags: topicObject.tags,
109
- attributeNeedsPersistence: topicObject.attributeNeedsPersistence ?? true,
110
- dataGroup: topicObject.dataGroup ?? "",
111
- asset: topicObject.asset,
112
- assetDescription: topicObject.assetDescription,
113
- objectType: topicObject.objectType,
114
- objectTypeDescription: topicObject.objectTypeDescription,
115
- objectId: topicObject.objectId,
116
- ...(topicObject.validityMode ? { validityMode: topicObject.validityMode } : {}),
117
- ...(topicObject.expectedIntervalMs ? { expectedIntervalMs: topicObject.expectedIntervalMs } : {}),
118
- ...(topicObject.lifecycleEndValue ? { lifecycleEndValue: topicObject.lifecycleEndValue } : {}),
119
- });
120
- this.emitProducedTopics();
121
- logger.info(`${this.instanceNameWithSuffix} - Registered new topic: ${fullTopic}`);
122
- }
123
- else {
124
- // Already registered — refresh only the timestamp so the periodic
125
- // heartbeat reflects actual data flow rather than frozen startup time.
126
- this.producedTopics.get(fullTopic).timestamp = topicObject.timestamp;
127
- }
128
- }
129
- }
130
- /**
131
- * Registers an API endpoint to handle requests for a specific topic and attribute.
132
- */
133
- registerApiEndpoint(apiObject) {
134
- if (this.instanceStatusTopic !== "") {
135
- const fullTopic = buildUnsIdentityPath(apiObject.topic, apiObject.asset, apiObject.objectType, apiObject.objectId, apiObject.attribute);
136
- if (!this.producedApiEndpoints.has(fullTopic)) {
137
- const time = UnsPacket.formatToISO8601(new Date());
138
- this.producedApiEndpoints.set(fullTopic, {
139
- timestamp: time,
140
- topic: apiObject.topic,
141
- attribute: apiObject.attribute,
142
- apiHost: apiObject.apiHost,
143
- apiEndpoint: apiObject.apiEndpoint,
144
- apiMethod: apiObject.apiMethod,
145
- apiQueryParams: apiObject.apiQueryParams,
146
- apiDescription: apiObject.apiDescription,
147
- attributeType: apiObject.attributeType,
148
- apiSwaggerEndpoint: apiObject.apiSwaggerEndpoint,
149
- asset: apiObject.asset,
150
- objectType: apiObject.objectType,
151
- objectId: apiObject.objectId,
152
- ...(this.controllerNameEnv ? { controllerName: this.controllerNameEnv } : {}),
153
- ...(this.controllerHostEnv ? { controllerHost: this.controllerHostEnv } : {}),
154
- ...(this.controllerPortEnv ? { controllerPort: this.controllerPortEnv } : {}),
155
- ...(this.controllerPublicBaseEnv ? { controllerPublicBase: this.controllerPublicBaseEnv } : {}),
156
- });
157
- this.emitProducedApiEndpoints();
158
- logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);
159
- }
160
- }
161
- }
162
- registerApiCatchAll(mapping) {
163
- if (this.instanceStatusTopic !== "") {
164
- const key = mapping.topic.replace(/\/+$/, "");
165
- if (!this.producedApiCatchall.has(key)) {
166
- this.producedApiCatchall.set(key, mapping);
167
- }
168
- else {
169
- this.producedApiCatchall.set(key, { ...this.producedApiCatchall.get(key), ...mapping });
170
- }
171
- this.emitProducedApiCatchall();
172
- logger.info(`${this.instanceNameWithSuffix} - Registered catch-all API mapping: ${key}`);
173
- }
174
- }
175
- unregisterApiEndpoint(topic, asset, objectType, objectId, attribute) {
176
- const fullTopic = buildUnsIdentityPath(topic, asset, objectType, objectId, attribute);
177
- if (this.producedApiEndpoints.has(fullTopic)) {
178
- this.producedApiEndpoints.delete(fullTopic);
179
- this.emitProducedApiEndpoints();
180
- logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);
181
- }
182
- }
183
- async stop() {
184
- // Clear the publishing interval.
185
- if (this.publishInterval) {
186
- clearInterval(this.publishInterval);
187
- this.publishInterval = null;
188
- }
189
- }
190
- }
1
+ import logger from "../logger.js";
2
+ import { UnsEventEmitter } from "./uns-event-emitter.js";
3
+ import { UnsPacket } from "./uns-packet.js";
4
+ import { buildUnsIdentityPath } from "./uns-path.js";
5
+ export default class UnsProxy {
6
+ publishInterval = null;
7
+ event = new UnsEventEmitter();
8
+ instanceStatusTopic;
9
+ instanceNameWithSuffix; //was prot
10
+ producedTopics = new Map();
11
+ producedApiEndpoints = new Map();
12
+ producedApiCatchall = new Map();
13
+ controllerNameEnv;
14
+ controllerHostEnv;
15
+ controllerPortEnv;
16
+ controllerPublicBaseEnv;
17
+ constructor() {
18
+ this.controllerNameEnv = process.env["UNS_CONTROLLER_NAME"];
19
+ this.controllerHostEnv = process.env["UNS_CONTROLLER_HOST"];
20
+ this.controllerPortEnv = process.env["UNS_CONTROLLER_PORT"];
21
+ this.controllerPublicBaseEnv =
22
+ process.env["UNS_CONTROLLER_PUBLIC_BASE"] ?? process.env["UNS_PUBLIC_BASE"];
23
+ // Set up interval to publish produced topics every 60 seconds.
24
+ this.publishInterval = setInterval(() => {
25
+ this.emitProducedTopics();
26
+ this.emitProducedApiEndpoints();
27
+ this.emitProducedApiCatchall();
28
+ }, 60000);
29
+ }
30
+ /**
31
+ * Publishes the list of produced topics to the MQTT broker.
32
+ */
33
+ async emitProducedTopics() {
34
+ if (this.instanceStatusTopic !== "") {
35
+ const topicsArray = [...this.producedTopics.values()];
36
+ if (topicsArray.length > 0) {
37
+ try {
38
+ this.event.emit("unsProxyProducedTopics", { producedTopics: topicsArray, statusTopic: this.instanceStatusTopic + "topics" });
39
+ }
40
+ catch (error) {
41
+ logger.error(`${this.instanceNameWithSuffix} - Error publishing produced topics: ${error.message}`);
42
+ }
43
+ logger.debug(`${this.instanceNameWithSuffix} - Published produced topics.`);
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * Publishes the list of produced API endpoints to the MQTT broker.
49
+ */
50
+ async emitProducedApiEndpoints() {
51
+ if (this.instanceStatusTopic !== "") {
52
+ const apiEndpointsArray = [...this.producedApiEndpoints.values()];
53
+ if (apiEndpointsArray.length > 0) {
54
+ try {
55
+ if (apiEndpointsArray.length > 0) {
56
+ this.event.emit("unsProxyProducedApiEndpoints", { producedApiEndpoints: apiEndpointsArray, statusTopic: this.instanceStatusTopic + "api-endpoints" });
57
+ }
58
+ }
59
+ catch (error) {
60
+ logger.error(`${this.instanceNameWithSuffix} - Error publishing produced API endpoints: ${error.message}`);
61
+ }
62
+ logger.debug(`${this.instanceNameWithSuffix} - Published produced API endpoints.`);
63
+ }
64
+ }
65
+ }
66
+ /**
67
+ * Publishes the list of catch-all API mappings to the MQTT broker.
68
+ */
69
+ async emitProducedApiCatchall() {
70
+ if (this.instanceStatusTopic !== "") {
71
+ const catchallArray = [...this.producedApiCatchall.values()];
72
+ if (catchallArray.length > 0) {
73
+ try {
74
+ this.event.emit("unsProxyProducedApiCatchAll", {
75
+ producedCatchall: catchallArray,
76
+ statusTopic: this.instanceStatusTopic + "api-catchall",
77
+ });
78
+ }
79
+ catch (error) {
80
+ logger.error(`${this.instanceNameWithSuffix} - Error publishing catch-all API mappings: ${error.message}`);
81
+ }
82
+ logger.debug(`${this.instanceNameWithSuffix} - Published catch-all API mappings.`);
83
+ }
84
+ }
85
+ }
86
+ /**
87
+ * Registers a unique topic and keeps its timestamp current.
88
+ *
89
+ * On first call the full entry is created and immediately emitted so the
90
+ * controller can persist the new schema node. On subsequent calls only the
91
+ * timestamp is updated in-place; the 60-second heartbeat interval will carry
92
+ * the updated value to the controller, making the timestamp reflect the time
93
+ * of the most recent data publication rather than the one-off registration
94
+ * moment.
95
+ *
96
+ * @param topicObject - The object containing topic details.
97
+ */
98
+ registerUniqueTopic(topicObject) {
99
+ if (this.instanceStatusTopic !== "") {
100
+ const fullTopic = buildUnsIdentityPath(topicObject.topic, topicObject.asset, topicObject.objectType, topicObject.objectId, topicObject.attribute);
101
+ if (!this.producedTopics.has(fullTopic)) {
102
+ this.producedTopics.set(fullTopic, {
103
+ timestamp: topicObject.timestamp,
104
+ topic: topicObject.topic,
105
+ attribute: topicObject.attribute,
106
+ attributeType: topicObject.attributeType,
107
+ description: topicObject.description,
108
+ tags: topicObject.tags,
109
+ attributeNeedsPersistence: topicObject.attributeNeedsPersistence ?? true,
110
+ dataGroup: topicObject.dataGroup ?? "",
111
+ asset: topicObject.asset,
112
+ assetDescription: topicObject.assetDescription,
113
+ objectType: topicObject.objectType,
114
+ objectTypeDescription: topicObject.objectTypeDescription,
115
+ objectId: topicObject.objectId,
116
+ ...(topicObject.validityMode ? { validityMode: topicObject.validityMode } : {}),
117
+ ...(topicObject.expectedIntervalMs ? { expectedIntervalMs: topicObject.expectedIntervalMs } : {}),
118
+ ...(topicObject.lifecycleEndValue ? { lifecycleEndValue: topicObject.lifecycleEndValue } : {}),
119
+ });
120
+ this.emitProducedTopics();
121
+ logger.info(`${this.instanceNameWithSuffix} - Registered new topic: ${fullTopic}`);
122
+ }
123
+ else {
124
+ // Already registered — refresh only the timestamp so the periodic
125
+ // heartbeat reflects actual data flow rather than frozen startup time.
126
+ this.producedTopics.get(fullTopic).timestamp = topicObject.timestamp;
127
+ }
128
+ }
129
+ }
130
+ /**
131
+ * Registers an API endpoint to handle requests for a specific topic and attribute.
132
+ */
133
+ registerApiEndpoint(apiObject) {
134
+ if (this.instanceStatusTopic !== "") {
135
+ const fullTopic = buildUnsIdentityPath(apiObject.topic, apiObject.asset, apiObject.objectType, apiObject.objectId, apiObject.attribute);
136
+ if (!this.producedApiEndpoints.has(fullTopic)) {
137
+ const time = UnsPacket.formatToISO8601(new Date());
138
+ this.producedApiEndpoints.set(fullTopic, {
139
+ timestamp: time,
140
+ topic: apiObject.topic,
141
+ attribute: apiObject.attribute,
142
+ apiHost: apiObject.apiHost,
143
+ apiEndpoint: apiObject.apiEndpoint,
144
+ apiMethod: apiObject.apiMethod,
145
+ apiQueryParams: apiObject.apiQueryParams,
146
+ apiDescription: apiObject.apiDescription,
147
+ attributeType: apiObject.attributeType,
148
+ apiSwaggerEndpoint: apiObject.apiSwaggerEndpoint,
149
+ asset: apiObject.asset,
150
+ objectType: apiObject.objectType,
151
+ objectId: apiObject.objectId,
152
+ ...(this.controllerNameEnv ? { controllerName: this.controllerNameEnv } : {}),
153
+ ...(this.controllerHostEnv ? { controllerHost: this.controllerHostEnv } : {}),
154
+ ...(this.controllerPortEnv ? { controllerPort: this.controllerPortEnv } : {}),
155
+ ...(this.controllerPublicBaseEnv ? { controllerPublicBase: this.controllerPublicBaseEnv } : {}),
156
+ });
157
+ this.emitProducedApiEndpoints();
158
+ logger.info(`${this.instanceNameWithSuffix} - Registered new api endpoint: /${fullTopic}`);
159
+ }
160
+ }
161
+ }
162
+ registerApiCatchAll(mapping) {
163
+ if (this.instanceStatusTopic !== "") {
164
+ const key = mapping.topic.replace(/\/+$/, "");
165
+ if (!this.producedApiCatchall.has(key)) {
166
+ this.producedApiCatchall.set(key, mapping);
167
+ }
168
+ else {
169
+ this.producedApiCatchall.set(key, { ...this.producedApiCatchall.get(key), ...mapping });
170
+ }
171
+ this.emitProducedApiCatchall();
172
+ logger.info(`${this.instanceNameWithSuffix} - Registered catch-all API mapping: ${key}`);
173
+ }
174
+ }
175
+ unregisterApiEndpoint(topic, asset, objectType, objectId, attribute) {
176
+ const fullTopic = buildUnsIdentityPath(topic, asset, objectType, objectId, attribute);
177
+ if (this.producedApiEndpoints.has(fullTopic)) {
178
+ this.producedApiEndpoints.delete(fullTopic);
179
+ this.emitProducedApiEndpoints();
180
+ logger.info(`${this.instanceNameWithSuffix} - Unregistered API endpoint: ${fullTopic}`);
181
+ }
182
+ }
183
+ async stop() {
184
+ // Clear the publishing interval.
185
+ if (this.publishInterval) {
186
+ clearInterval(this.publishInterval);
187
+ this.publishInterval = null;
188
+ }
189
+ }
190
+ }
191
191
  //# sourceMappingURL=uns-proxy.js.map