@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
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Aljoša Vister
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Aljoša Vister
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,63 +1,86 @@
1
- # @uns-kit/core
2
-
3
- Core utilities and runtime building blocks for Unified Namespace (UNS) applications. The package bundles the process lifecycle manager, MQTT integrations, gRPC gateway helpers, configuration tooling, and shared type definitions that power the UNS ecosystem.
4
-
5
- Note: Apps built with uns-kit are intended to be managed by the **UNS Datahub controller**.
6
-
7
- ## uns-kit in context
8
-
9
- | Package | Description |
10
- | --- | --- |
11
- | [`@uns-kit/core`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-core) | Base runtime (UnsProxyProcess, MQTT helpers, config tooling, gRPC gateway). |
12
- | [`@uns-kit/api`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-api) | Express plugin — HTTP endpoints, JWT/JWKS auth, Swagger, UNS metadata. |
13
- | [`@uns-kit/cron`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cron) | Cron-driven scheduler that emits UNS events on a fixed cadence. |
14
- | [`@uns-kit/cli`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cli) | CLI for scaffolding new UNS applications. |
15
-
16
- ## Installation
17
-
18
- ```bash
19
- pnpm add @uns-kit/core
20
- # or
21
- npm install @uns-kit/core
22
- ```
23
-
24
- ## Key concepts
25
-
26
- - **UnsProxyProcess** — the central runtime class. It manages the MQTT connection, plugin lifecycle, and the instance status topic. Plugins (`@uns-kit/api`, `@uns-kit/cron`) augment it with domain-specific proxy factories.
27
- - **UnsProxy** — base class extended by all plugin proxies. Tracks produced topics, API endpoints, and catch-all mappings; re-publishes them to the controller on a 60-second cadence.
28
- - **ConfigFile** — loads and validates `config.json` at startup. On a real server this file is provided by the UNS Datahub controller; in development you maintain it yourself.
29
- - **MQTT helpers** — resilient publishers, topic builders, throttled queues, and handover support.
30
- - **gRPC gateway** — infrastructure to bridge Python workers into the UNS message fabric.
31
-
32
- ## Basic usage
33
-
34
- ```ts
35
- import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
36
- import { ConfigFile } from "@uns-kit/core";
37
-
38
- const config = await ConfigFile.loadConfig();
39
-
40
- // Connect to MQTT broker; processName identifies this service in the controller.
41
- const proc = new UnsProxyProcess(config.infra.host!, { processName: config.uns.processName });
42
- ```
43
-
44
- Extend it with plugins:
45
-
46
- ```ts
47
- import "@uns-kit/api";
48
- import "@uns-kit/cron";
49
- import { type UnsProxyProcessWithApi } from "@uns-kit/api";
50
- import { type UnsProxyProcessWithCron } from "@uns-kit/cron";
51
-
52
- const proc = new UnsProxyProcess(config.infra.host!, { processName: config.uns.processName })
53
- as UnsProxyProcessWithApi & UnsProxyProcessWithCron;
54
-
55
- const api = await proc.createApiProxy("my-service", { jwtSecret: "CHANGEME" });
56
- const cron = await proc.createCrontabProxy("*/5 * * * *", { event: "tick" });
57
- ```
58
-
59
- ## Datahub client (last value)
60
-
1
+ # @uns-kit/core
2
+
3
+ Core utilities and runtime building blocks for Unified Namespace (UNS) applications. The package bundles the process lifecycle manager, MQTT integrations, gRPC gateway helpers, configuration tooling, and shared type definitions that power the UNS ecosystem.
4
+
5
+ Note: Apps built with uns-kit are intended to be managed by the **UNS Datahub controller**.
6
+
7
+ ## uns-kit in context
8
+
9
+ | Package | Description |
10
+ | --- | --- |
11
+ | [`@uns-kit/core`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-core) | Base runtime (UnsProxyProcess, MQTT helpers, config tooling, gRPC gateway). |
12
+ | [`@uns-kit/api`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-api) | Express plugin — HTTP endpoints, JWT/JWKS auth, Swagger, UNS metadata. |
13
+ | [`@uns-kit/cron`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cron) | Cron-driven scheduler that emits UNS events on a fixed cadence. |
14
+ | [`@uns-kit/cli`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cli) | CLI for scaffolding new UNS applications. |
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pnpm add @uns-kit/core
20
+ # or
21
+ npm install @uns-kit/core
22
+ ```
23
+
24
+ ## Key concepts
25
+
26
+ - **UnsProxyProcess** — the central runtime class. It manages the MQTT connection, plugin lifecycle, and the instance status topic. Plugins (`@uns-kit/api`, `@uns-kit/cron`) augment it with domain-specific proxy factories.
27
+ - **UnsProxy** — base class extended by all plugin proxies. Tracks produced topics, API endpoints, and catch-all mappings; re-publishes them to the controller on a 60-second cadence.
28
+ - **ConfigFile** — loads and validates `config.json` at startup. On a real server this file is provided by the UNS Datahub controller; in development you maintain it yourself.
29
+ - **MQTT helpers** — resilient publishers, topic builders, throttled queues, and handover support.
30
+ - **gRPC gateway** — infrastructure to bridge Python workers into the UNS message fabric.
31
+
32
+ ## Basic usage
33
+
34
+ ```ts
35
+ import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
36
+ import { ConfigFile } from "@uns-kit/core";
37
+
38
+ const config = await ConfigFile.loadConfig();
39
+
40
+ // Connect to MQTT broker; processName identifies this service in the controller.
41
+ const proc = new UnsProxyProcess(config.infra.host!, { processName: config.uns.processName });
42
+ ```
43
+
44
+ Publish retained service metadata when a runtime should be discoverable by the
45
+ controller as a core service, addon, or built-in capability:
46
+
47
+ ```ts
48
+ await proc.publishServiceMetadata({
49
+ serviceId: "uns-bridge-mqtt",
50
+ kind: "addon",
51
+ addonId: "uns-bridge-mqtt",
52
+ capabilities: ["mqtt-source-browser", "runtime-mappings"],
53
+ apiRoutes: [
54
+ {
55
+ path: "/api/system/bridge/mqtt/runtime/service/bridge/health",
56
+ kind: "health",
57
+ },
58
+ ],
59
+ });
60
+ ```
61
+
62
+ The metadata is retained on
63
+ `uns-infra/<package>/<version>/<processName>/service-metadata`. Controllers
64
+ combine this identity/capability payload with live process telemetry and route
65
+ health before marking a service healthy.
66
+
67
+ Extend it with plugins:
68
+
69
+ ```ts
70
+ import "@uns-kit/api";
71
+ import "@uns-kit/cron";
72
+ import { type UnsProxyProcessWithApi } from "@uns-kit/api";
73
+ import { type UnsProxyProcessWithCron } from "@uns-kit/cron";
74
+
75
+ const proc = new UnsProxyProcess(config.infra.host!, { processName: config.uns.processName })
76
+ as UnsProxyProcessWithApi & UnsProxyProcessWithCron;
77
+
78
+ const api = await proc.createApiProxy("my-service", { jwtSecret: "CHANGEME" });
79
+ const cron = await proc.createCrontabProxy("*/5 * * * *", { event: "tick" });
80
+ ```
81
+
82
+ ## Datahub client (last value)
83
+
61
84
  `UnsClient` provides a minimal REST client for the UNS Datahub API, including the batch last-value endpoint. Prefer a long-lived service token if available; you can pass it directly and skip username/password auth.
62
85
 
63
86
  ```ts
@@ -73,90 +96,90 @@ const values = await client.lastValue([
73
96
  ]);
74
97
  console.log(values);
75
98
  ```
76
-
77
- ## Validity / Liveliness
78
-
79
- UNS attributes can declare how the controller decides whether they are live or stale; in most apps this is primarily used to drive UI liveliness/activity indicators. In app-level modeling we use two modes only:
80
-
81
- - `interval`: continuously refreshed values (stale after ~2× `expectedIntervalMs`)
82
- - `lifecycle`: event-driven activity that stays active until a defined end value (`lifecycleEndValue`)
83
-
84
- ```ts
85
- await proxy.publishMqttMessage({
86
- topic: "raw/data/",
87
- asset: "line-1",
88
- objectType: "motor",
89
- objectId: "main",
90
- attributes: {
91
- attribute: "status",
92
- data: { time: new Date().toISOString(), value: "RUNNING" },
93
- validityMode: "lifecycle",
94
- lifecycleEndValue: "STOPPED",
95
- },
96
- });
97
- ```
98
-
99
- ## Sync UNS schema from the controller
100
-
101
- `sync-uns-schema` fetches the canonical UNS dictionary and measurements from the controller REST API and refreshes local JSON files and generated TypeScript artifacts.
102
-
103
- ```bash
104
- # Run inside a generated microservice project:
105
- pnpm run sync-uns-schema
106
-
107
- # The controller URL is read from config.json (uns.rest) automatically.
108
- # You will be prompted for the bearer token if not set via env var.
109
- ```
110
-
111
- Or with explicit options:
112
-
113
- ```bash
114
- pnpm run sync-uns-schema --controller-url http://localhost:3200 --token <bearer-token>
115
- ```
116
-
117
- **What it updates (inside a generated project):**
118
- - `uns-dictionary.json`
119
- - `uns-measurements.json`
120
- - `src/uns/uns-dictionary.generated.ts`
121
- - `src/uns/uns-measurements.generated.ts`
122
-
123
- **Options:**
124
-
125
- | Flag | Default | Description |
126
- |---|---|---|
127
- | `--controller-url` | from `config.json` `uns.rest` or `UNS_CONTROLLER_URL` | Controller base URL |
128
- | `--token` | interactive prompt or `UNS_CONTROLLER_TOKEN` | Admin bearer token |
129
- | `--status` | `active` | Dictionary filter: `active`, `draft`, `deprecated`, `all` |
130
- | `--dry-run` | — | Report changes without writing |
131
- | `--dictionary-only` | — | Skip measurements sync |
132
- | `--measurements-only` | — | Skip dictionary sync |
133
- | `--skip-generate` | — | Skip TS regeneration |
134
- | `--project-root <dir>` | auto-detect | Target project root |
135
-
136
- ## Config schema generation
137
-
138
- Edit `src/config/project.config.extension.ts` inside your project and run:
139
-
140
- ```bash
141
- pnpm run generate-config-schema
142
- ```
143
-
144
- This regenerates `config.schema.json` and `src/config/app-config.ts`, keeping editor completions and runtime types in sync with your config extensions.
145
-
146
- ## Infisical secret resolution
147
-
148
- - Looks for `INFISICAL_TOKEN` / `INFISICAL_PERSONAL_TOKEN`, then `/run/secrets/infisical_token`.
149
- - If unavailable, logs a warning and returns `default` (or `undefined` for `optional: true` secrets).
150
- - Required secrets throw with the original error message when Infisical is unreachable.
151
- - Call `resolveInfisicalConfig()` to inspect the resolved token/projectId/siteUrl.
152
-
153
- ## Development
154
-
155
- ```bash
156
- pnpm run typecheck # type-check sources
157
- pnpm run build # emit JS + declarations to dist/
158
- ```
159
-
160
- ## License
161
-
162
- MIT © Aljoša Vister
99
+
100
+ ## Validity / Liveliness
101
+
102
+ UNS attributes can declare how the controller decides whether they are live or stale; in most apps this is primarily used to drive UI liveliness/activity indicators. In app-level modeling we use two modes only:
103
+
104
+ - `interval`: continuously refreshed values (stale after ~2× `expectedIntervalMs`)
105
+ - `lifecycle`: event-driven activity that stays active until a defined end value (`lifecycleEndValue`)
106
+
107
+ ```ts
108
+ await proxy.publishMqttMessage({
109
+ topic: "raw/data/",
110
+ asset: "line-1",
111
+ objectType: "motor",
112
+ objectId: "main",
113
+ attributes: {
114
+ attribute: "status",
115
+ data: { time: new Date().toISOString(), value: "RUNNING" },
116
+ validityMode: "lifecycle",
117
+ lifecycleEndValue: "STOPPED",
118
+ },
119
+ });
120
+ ```
121
+
122
+ ## Sync UNS schema from the controller
123
+
124
+ `sync-uns-schema` fetches the canonical UNS dictionary and measurements from the controller REST API and refreshes local JSON files and generated TypeScript artifacts.
125
+
126
+ ```bash
127
+ # Run inside a generated microservice project:
128
+ pnpm run sync-uns-schema
129
+
130
+ # The controller URL is read from config.json (uns.rest) automatically.
131
+ # You will be prompted for the bearer token if not set via env var.
132
+ ```
133
+
134
+ Or with explicit options:
135
+
136
+ ```bash
137
+ pnpm run sync-uns-schema --controller-url http://localhost:3200 --token <bearer-token>
138
+ ```
139
+
140
+ **What it updates (inside a generated project):**
141
+ - `uns-dictionary.json`
142
+ - `uns-measurements.json`
143
+ - `src/uns/uns-dictionary.generated.ts`
144
+ - `src/uns/uns-measurements.generated.ts`
145
+
146
+ **Options:**
147
+
148
+ | Flag | Default | Description |
149
+ |---|---|---|
150
+ | `--controller-url` | from `config.json` `uns.rest` or `UNS_CONTROLLER_URL` | Controller base URL |
151
+ | `--token` | interactive prompt or `UNS_CONTROLLER_TOKEN` | Admin bearer token |
152
+ | `--status` | `active` | Dictionary filter: `active`, `draft`, `deprecated`, `all` |
153
+ | `--dry-run` | — | Report changes without writing |
154
+ | `--dictionary-only` | — | Skip measurements sync |
155
+ | `--measurements-only` | — | Skip dictionary sync |
156
+ | `--skip-generate` | — | Skip TS regeneration |
157
+ | `--project-root <dir>` | auto-detect | Target project root |
158
+
159
+ ## Config schema generation
160
+
161
+ Edit `src/config/project.config.extension.ts` inside your project and run:
162
+
163
+ ```bash
164
+ pnpm run generate-config-schema
165
+ ```
166
+
167
+ This regenerates `config.schema.json` and `src/config/app-config.ts`, keeping editor completions and runtime types in sync with your config extensions.
168
+
169
+ ## Infisical secret resolution
170
+
171
+ - Looks for `INFISICAL_TOKEN` / `INFISICAL_PERSONAL_TOKEN`, then `/run/secrets/infisical_token`.
172
+ - If unavailable, logs a warning and returns `default` (or `undefined` for `optional: true` secrets).
173
+ - Required secrets throw with the original error message when Infisical is unreachable.
174
+ - Call `resolveInfisicalConfig()` to inspect the resolved token/projectId/siteUrl.
175
+
176
+ ## Development
177
+
178
+ ```bash
179
+ pnpm run typecheck # type-check sources
180
+ pnpm run build # emit JS + declarations to dist/
181
+ ```
182
+
183
+ ## License
184
+
185
+ MIT © Aljoša Vister
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- export { default as UnsProxyProcess } from "./uns/uns-proxy-process.js";
2
- export type { UnsProxyProcessPlugin, UnsProxyProcessPluginApi, UnsProxyProcessPluginMethod, UnsProxyProcessPluginMethods, } from "./uns/uns-proxy-process.js";
3
- export * from "./uns/uns-interfaces.js";
4
- export { ConfigFile } from "./config-file.js";
5
- export { default as logger } from "./logger.js";
6
- export { getLogger } from "./logger.js";
7
- export { resolveInfisicalConfig } from "./uns-config/secret-resolver.js";
8
- export { UnsClient, LastValueResult, LastValueClientError } from "./tools/datahub/datahub-client.js";
1
+ export { default as UnsProxyProcess } from "./uns/uns-proxy-process.js";
2
+ export type { UnsProxyProcessPlugin, UnsProxyProcessPluginApi, UnsProxyProcessPluginMethod, UnsProxyProcessPluginMethods, } from "./uns/uns-proxy-process.js";
3
+ export * from "./uns/uns-interfaces.js";
4
+ export * from "./uns/service-metadata.js";
5
+ export { ConfigFile } from "./config-file.js";
6
+ export { default as logger } from "./logger.js";
7
+ export { getLogger } from "./logger.js";
8
+ export { resolveInfisicalConfig } from "./uns-config/secret-resolver.js";
9
+ export { UnsClient, LastValueResult, LastValueClientError } from "./tools/datahub/datahub-client.js";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,YAAY,EACV,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,YAAY,EACV,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- export { default as UnsProxyProcess } from "./uns/uns-proxy-process.js";
2
- export * from "./uns/uns-interfaces.js";
3
- export { ConfigFile } from "./config-file.js";
4
- export { default as logger } from "./logger.js";
5
- export { getLogger } from "./logger.js";
6
- export { resolveInfisicalConfig } from "./uns-config/secret-resolver.js";
7
- export { UnsClient, LastValueResult, LastValueClientError } from "./tools/datahub/datahub-client.js";
1
+ export { default as UnsProxyProcess } from "./uns/uns-proxy-process.js";
2
+ export * from "./uns/uns-interfaces.js";
3
+ export * from "./uns/service-metadata.js";
4
+ export { ConfigFile } from "./config-file.js";
5
+ export { default as logger } from "./logger.js";
6
+ export { getLogger } from "./logger.js";
7
+ export { resolveInfisicalConfig } from "./uns-config/secret-resolver.js";
8
+ export { UnsClient, LastValueResult, LastValueClientError } from "./tools/datahub/datahub-client.js";
8
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOxE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["export { default as UnsProxyProcess } from \"./uns/uns-proxy-process.js\";\nexport type {\n UnsProxyProcessPlugin,\n UnsProxyProcessPluginApi,\n UnsProxyProcessPluginMethod,\n UnsProxyProcessPluginMethods,\n} from \"./uns/uns-proxy-process.js\";\nexport * from \"./uns/uns-interfaces.js\";\nexport { ConfigFile } from \"./config-file.js\";\nexport { default as logger } from \"./logger.js\";\nexport { getLogger } from \"./logger.js\";\nexport { resolveInfisicalConfig } from \"./uns-config/secret-resolver.js\";\nexport { UnsClient, LastValueResult, LastValueClientError } from \"./tools/datahub/datahub-client.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOxE,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["export { default as UnsProxyProcess } from \"./uns/uns-proxy-process.js\";\nexport type {\n UnsProxyProcessPlugin,\n UnsProxyProcessPluginApi,\n UnsProxyProcessPluginMethod,\n UnsProxyProcessPluginMethods,\n} from \"./uns/uns-proxy-process.js\";\nexport * from \"./uns/uns-interfaces.js\";\nexport * from \"./uns/service-metadata.js\";\nexport { ConfigFile } from \"./config-file.js\";\nexport { default as logger } from \"./logger.js\";\nexport { getLogger } from \"./logger.js\";\nexport { resolveInfisicalConfig } from \"./uns-config/secret-resolver.js\";\nexport { UnsClient, LastValueResult, LastValueClientError } from \"./tools/datahub/datahub-client.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"datahub-client.js","sourceRoot":"","sources":["../../../src/tools/datahub/datahub-client.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,eAAe;IACjB,KAAK,CAAS;IACd,KAAK,CAAU;IACf,MAAM,CAAkC;IACxC,GAAG,CAAiB;IACpB,SAAS,CAAiB;IAC1B,SAAS,CAAiB;IAC1B,KAAK,CAAiB;IACtB,MAAM,CAAS;IAExB,YAAY,OAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC;QACrC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,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AC,CAAC,IAAI,QAAQ,EAAE,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import { AuthClient } from \"../auth/auth-client.js\";\r\n\r\nexport type LastValuePayload = {\r\n topic: string;\r\n value: unknown;\r\n values?: Record<string, unknown> | null;\r\n uom?: string | null;\r\n timestamp?: string | null;\r\n dataGroup?: string | null;\r\n ageMs?: number | null;\r\n source: string;\r\n};\r\n\r\nexport class LastValueResult {\r\n readonly topic: string;\r\n readonly value: unknown;\r\n readonly values?: Record<string, unknown> | null;\r\n readonly uom?: string | null;\r\n readonly timestamp?: string | null;\r\n readonly dataGroup?: string | null;\r\n readonly ageMs?: number | null;\r\n readonly source: string;\r\n\r\n constructor(payload: LastValuePayload) {\r\n this.topic = payload.topic;\r\n this.value = payload.value;\r\n this.values = payload.values ?? null;\r\n this.uom = payload.uom ?? null;\r\n this.timestamp = payload.timestamp ?? null;\r\n this.dataGroup = payload.dataGroup ?? null;\r\n this.ageMs = payload.ageMs ?? null;\r\n this.source = payload.source;\r\n }\r\n\r\n static fromMapping(value: Record<string, unknown>): LastValueResult {\r\n const rawValues = value.values;\r\n return new LastValueResult({\r\n topic: typeof value.topic === \"string\" ? value.topic : \"\",\r\n value: value.value,\r\n values: rawValues && typeof rawValues === \"object\" && !Array.isArray(rawValues) ? (rawValues as Record<string, unknown>) : null,\r\n uom: typeof value.uom === \"string\" ? value.uom : null,\r\n timestamp: typeof value.timestamp === \"string\" ? value.timestamp : null,\r\n dataGroup: typeof value.dataGroup === \"string\" ? value.dataGroup : null,\r\n ageMs: typeof value.ageMs === \"number\" ? value.ageMs : null,\r\n source: typeof value.source === \"string\" ? value.source : \"miss\",\r\n });\r\n }\r\n\r\n get hit(): boolean {\r\n return this.source === \"cache\";\r\n }\r\n\r\n toObject(): LastValuePayload {\r\n return {\r\n topic: this.topic,\r\n value: this.value,\r\n values: this.values ?? null,\r\n uom: this.uom ?? null,\r\n timestamp: this.timestamp ?? null,\r\n dataGroup: this.dataGroup ?? null,\r\n ageMs: this.ageMs ?? null,\r\n source: this.source,\r\n };\r\n }\r\n}\r\n\r\nexport class LastValueClientError extends Error {\r\n readonly statusCode?: number;\r\n\r\n constructor(message: string, statusCode?: number) {\r\n super(message);\r\n this.statusCode = statusCode;\r\n }\r\n}\r\n\r\nexport type UnsClientOptions = {\n apiBasePath?: string;\n token?: string;\n timeoutMs?: number;\n authClient?: AuthClient;\n};\n\r\nexport class UnsClient {\r\n private readonly apiBasePath: string;\r\n private readonly baseUrl: string;\n private readonly apiUrl: string;\n private readonly timeoutMs: number;\n private readonly authClient?: AuthClient;\n private accessToken?: string;\n\n constructor(baseUrl: string, options: UnsClientOptions = {}) {\n const apiBasePath = UnsClient.normalizeBasePath(options.apiBasePath ?? \"/api\");\r\n const strippedBase = baseUrl.replace(/\\/$/, \"\");\r\n if (apiBasePath && strippedBase.endsWith(apiBasePath)) {\r\n this.apiUrl = strippedBase;\r\n this.baseUrl = strippedBase.slice(0, -apiBasePath.length).replace(/\\/$/, \"\");\r\n } else {\r\n this.baseUrl = strippedBase;\r\n this.apiUrl = `${strippedBase}${apiBasePath}`;\r\n }\r\n this.apiBasePath = apiBasePath;\n this.timeoutMs = options.timeoutMs ?? 10_000;\n this.authClient = options.authClient;\n this.accessToken = options.token;\n }\n\r\n setToken(token?: string): void {\r\n this.accessToken = token;\r\n }\r\n\r\n async ensureToken(): Promise<string | undefined> {\n if (this.accessToken) return this.accessToken;\n if (!this.authClient) return undefined;\n const token = await this.authClient.getAccessToken();\n this.accessToken = token;\n return token;\n }\n\r\n async get(endpoint: string, params?: Record<string, string | number | boolean>, options: { baseUrl?: string; authorize?: boolean } = {}): Promise<Record<string, unknown>> {\r\n const authorize = options.authorize ?? true;\r\n const token = authorize ? await this.ensureToken() : undefined;\r\n const search = params ? `?${new URLSearchParams(this.stringifyQueryParams(params))}` : \"\";\r\n return this.requestJson(\"GET\", `${this.buildUrl(endpoint, options.baseUrl)}${search}`, undefined, token);\r\n }\r\n\r\n async post(endpoint: string, body?: Record<string, unknown>, options: { baseUrl?: string; authorize?: boolean } = {}): Promise<Record<string, unknown>> {\r\n const authorize = options.authorize ?? true;\r\n const token = authorize ? await this.ensureToken() : undefined;\r\n return this.requestJson(\"POST\", this.buildUrl(endpoint, options.baseUrl), body ?? {}, token);\r\n }\r\n\r\n async lastValue(topics: string | string[], options: { token?: string } = {}): Promise<Record<string, LastValuePayload> | null> {\n const topicList = Array.isArray(topics) ? topics : [topics];\r\n if (!topicList.length) {\r\n throw new Error(\"topics must contain at least one topic.\");\r\n }\r\n if (topicList.length > 500) {\r\n throw new Error(\"Maximum 500 topics per request.\");\r\n }\n const token = options.token ?? (await this.ensureToken());\n try {\n const payload = await this.requestJson(\"POST\", this.buildUrl(\"catchall//batch/last\"), { topics: topicList }, token);\n const rawResults = payload.results;\n if (!Array.isArray(rawResults)) {\n throw new LastValueClientError(\"Last-value response did not include a results array.\");\n }\r\n const results = rawResults\r\n .filter((item): item is Record<string, unknown> => !!item && typeof item === \"object\" && !Array.isArray(item))\r\n .map((item) => LastValueResult.fromMapping(item));\r\n return Object.fromEntries(results.map((result) => [result.topic, result.toObject()]));\r\n } catch (error) {\r\n if (error instanceof LastValueClientError && error.statusCode === 404) {\r\n return null;\r\n }\r\n throw error;\r\n }\n }\n\n private async requestJson(\n method: \"GET\" | \"POST\",\n url: string,\n body?: Record<string, unknown>,\r\n token?: string,\r\n ): Promise<Record<string, unknown>> {\r\n const controller = new AbortController();\r\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\r\n try {\r\n const resp = await fetch(url, {\r\n method,\r\n headers: {\r\n \"Accept\": \"application/json\",\r\n ...(body ? { \"Content-Type\": \"application/json\" } : {}),\r\n ...(token ? { \"Authorization\": `Bearer ${token}` } : {}),\r\n },\r\n ...(body ? { body: JSON.stringify(body) } : {}),\r\n signal: controller.signal,\r\n });\r\n const text = await resp.text();\r\n if (!resp.ok) {\r\n throw new LastValueClientError(\r\n `UNS request failed with HTTP ${resp.status}: ${text || resp.statusText}`,\r\n resp.status,\r\n );\r\n }\r\n if (!text) return {};\r\n const parsed = JSON.parse(text);\r\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\r\n throw new LastValueClientError(\"UNS response must be a JSON object.\");\r\n }\r\n return parsed as Record<string, unknown>;\r\n } catch (error: any) {\r\n if (error instanceof LastValueClientError) {\r\n throw error;\r\n }\r\n if (error?.name === \"AbortError\") {\r\n throw new LastValueClientError(\"UNS request timed out.\");\r\n }\r\n throw new LastValueClientError(`UNS request failed: ${error?.message ?? String(error)}`);\r\n } finally {\r\n clearTimeout(timeout);\r\n }\r\n }\n\n private buildUrl(endpoint: string, baseUrl?: string): string {\n if (endpoint.startsWith(\"http://\") || endpoint.startsWith(\"https://\")) {\r\n return endpoint;\r\n }\r\n const root = (baseUrl ?? this.apiUrl).replace(/\\/$/, \"\");\r\n let path = endpoint.startsWith(\"/\") ? endpoint : `/${endpoint}`;\r\n if (!baseUrl && this.apiBasePath && (path === this.apiBasePath || path.startsWith(`${this.apiBasePath}/`))) {\r\n path = path.slice(this.apiBasePath.length) || \"/\";\r\n }\r\n return `${root}${path}`;\r\n }\r\n\r\n private stringifyQueryParams(params: Record<string, string | number | boolean>): Record<string, string> {\r\n return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, String(value)]));\r\n }\r\n\r\n private static normalizeBasePath(value: string): string {\r\n const stripped = value.trim();\r\n if (!stripped) return \"\";\r\n return stripped.startsWith(\"/\") ? stripped : `/${stripped}`;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"datahub-client.js","sourceRoot":"","sources":["../../../src/tools/datahub/datahub-client.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,eAAe;IACjB,KAAK,CAAS;IACd,KAAK,CAAU;IACf,MAAM,CAAkC;IACxC,GAAG,CAAiB;IACpB,SAAS,CAAiB;IAC1B,SAAS,CAAiB;IAC1B,KAAK,CAAiB;IACtB,MAAM,CAAS;IAExB,YAAY,OAAyB;QACnC,IAAI,CAAC,KAAK,G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B,CAAC,MAAiD;QAC5E,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;IAEO,MAAM,CAAC,iBAAiB,CAAC,KAAa;QAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import { AuthClient } from \"../auth/auth-client.js\";\n\nexport type LastValuePayload = {\n topic: string;\n value: unknown;\n values?: Record<string, unknown> | null;\n uom?: string | null;\n timestamp?: string | null;\n dataGroup?: string | null;\n ageMs?: number | null;\n source: string;\n};\n\nexport class LastValueResult {\n readonly topic: string;\n readonly value: unknown;\n readonly values?: Record<string, unknown> | null;\n readonly uom?: string | null;\n readonly timestamp?: string | null;\n readonly dataGroup?: string | null;\n readonly ageMs?: number | null;\n readonly source: string;\n\n constructor(payload: LastValuePayload) {\n this.topic = payload.topic;\n this.value = payload.value;\n this.values = payload.values ?? null;\n this.uom = payload.uom ?? null;\n this.timestamp = payload.timestamp ?? null;\n this.dataGroup = payload.dataGroup ?? null;\n this.ageMs = payload.ageMs ?? null;\n this.source = payload.source;\n }\n\n static fromMapping(value: Record<string, unknown>): LastValueResult {\n const rawValues = value.values;\n return new LastValueResult({\n topic: typeof value.topic === \"string\" ? value.topic : \"\",\n value: value.value,\n values: rawValues && typeof rawValues === \"object\" && !Array.isArray(rawValues) ? (rawValues as Record<string, unknown>) : null,\n uom: typeof value.uom === \"string\" ? value.uom : null,\n timestamp: typeof value.timestamp === \"string\" ? value.timestamp : null,\n dataGroup: typeof value.dataGroup === \"string\" ? value.dataGroup : null,\n ageMs: typeof value.ageMs === \"number\" ? value.ageMs : null,\n source: typeof value.source === \"string\" ? value.source : \"miss\",\n });\n }\n\n get hit(): boolean {\n return this.source === \"cache\";\n }\n\n toObject(): LastValuePayload {\n return {\n topic: this.topic,\n value: this.value,\n values: this.values ?? null,\n uom: this.uom ?? null,\n timestamp: this.timestamp ?? null,\n dataGroup: this.dataGroup ?? null,\n ageMs: this.ageMs ?? null,\n source: this.source,\n };\n }\n}\n\nexport class LastValueClientError extends Error {\n readonly statusCode?: number;\n\n constructor(message: string, statusCode?: number) {\n super(message);\n this.statusCode = statusCode;\n }\n}\n\nexport type UnsClientOptions = {\n apiBasePath?: string;\n token?: string;\n timeoutMs?: number;\n authClient?: AuthClient;\n};\n\nexport class UnsClient {\n private readonly apiBasePath: string;\n private readonly baseUrl: string;\n private readonly apiUrl: string;\n private readonly timeoutMs: number;\n private readonly authClient?: AuthClient;\n private accessToken?: string;\n\n constructor(baseUrl: string, options: UnsClientOptions = {}) {\n const apiBasePath = UnsClient.normalizeBasePath(options.apiBasePath ?? \"/api\");\n const strippedBase = baseUrl.replace(/\\/$/, \"\");\n if (apiBasePath && strippedBase.endsWith(apiBasePath)) {\n this.apiUrl = strippedBase;\n this.baseUrl = strippedBase.slice(0, -apiBasePath.length).replace(/\\/$/, \"\");\n } else {\n this.baseUrl = strippedBase;\n this.apiUrl = `${strippedBase}${apiBasePath}`;\n }\n this.apiBasePath = apiBasePath;\n this.timeoutMs = options.timeoutMs ?? 10_000;\n this.authClient = options.authClient;\n this.accessToken = options.token;\n }\n\n setToken(token?: string): void {\n this.accessToken = token;\n }\n\n async ensureToken(): Promise<string | undefined> {\n if (this.accessToken) return this.accessToken;\n if (!this.authClient) return undefined;\n const token = await this.authClient.getAccessToken();\n this.accessToken = token;\n return token;\n }\n\n async get(endpoint: string, params?: Record<string, string | number | boolean>, options: { baseUrl?: string; authorize?: boolean } = {}): Promise<Record<string, unknown>> {\n const authorize = options.authorize ?? true;\n const token = authorize ? await this.ensureToken() : undefined;\n const search = params ? `?${new URLSearchParams(this.stringifyQueryParams(params))}` : \"\";\n return this.requestJson(\"GET\", `${this.buildUrl(endpoint, options.baseUrl)}${search}`, undefined, token);\n }\n\n async post(endpoint: string, body?: Record<string, unknown>, options: { baseUrl?: string; authorize?: boolean } = {}): Promise<Record<string, unknown>> {\n const authorize = options.authorize ?? true;\n const token = authorize ? await this.ensureToken() : undefined;\n return this.requestJson(\"POST\", this.buildUrl(endpoint, options.baseUrl), body ?? {}, token);\n }\n\n async lastValue(topics: string | string[], options: { token?: string } = {}): Promise<Record<string, LastValuePayload> | null> {\n const topicList = Array.isArray(topics) ? topics : [topics];\n if (!topicList.length) {\n throw new Error(\"topics must contain at least one topic.\");\n }\n if (topicList.length > 500) {\n throw new Error(\"Maximum 500 topics per request.\");\n }\n const token = options.token ?? (await this.ensureToken());\n try {\n const payload = await this.requestJson(\"POST\", this.buildUrl(\"catchall//batch/last\"), { topics: topicList }, token);\n const rawResults = payload.results;\n if (!Array.isArray(rawResults)) {\n throw new LastValueClientError(\"Last-value response did not include a results array.\");\n }\n const results = rawResults\n .filter((item): item is Record<string, unknown> => !!item && typeof item === \"object\" && !Array.isArray(item))\n .map((item) => LastValueResult.fromMapping(item));\n return Object.fromEntries(results.map((result) => [result.topic, result.toObject()]));\n } catch (error) {\n if (error instanceof LastValueClientError && error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n private async requestJson(\n method: \"GET\" | \"POST\",\n url: string,\n body?: Record<string, unknown>,\n token?: string,\n ): Promise<Record<string, unknown>> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n const resp = await fetch(url, {\n method,\n headers: {\n \"Accept\": \"application/json\",\n ...(body ? { \"Content-Type\": \"application/json\" } : {}),\n ...(token ? { \"Authorization\": `Bearer ${token}` } : {}),\n },\n ...(body ? { body: JSON.stringify(body) } : {}),\n signal: controller.signal,\n });\n const text = await resp.text();\n if (!resp.ok) {\n throw new LastValueClientError(\n `UNS request failed with HTTP ${resp.status}: ${text || resp.statusText}`,\n resp.status,\n );\n }\n if (!text) return {};\n const parsed = JSON.parse(text);\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new LastValueClientError(\"UNS response must be a JSON object.\");\n }\n return parsed as Record<string, unknown>;\n } catch (error: any) {\n if (error instanceof LastValueClientError) {\n throw error;\n }\n if (error?.name === \"AbortError\") {\n throw new LastValueClientError(\"UNS request timed out.\");\n }\n throw new LastValueClientError(`UNS request failed: ${error?.message ?? String(error)}`);\n } finally {\n clearTimeout(timeout);\n }\n }\n\n private buildUrl(endpoint: string, baseUrl?: string): string {\n if (endpoint.startsWith(\"http://\") || endpoint.startsWith(\"https://\")) {\n return endpoint;\n }\n const root = (baseUrl ?? this.apiUrl).replace(/\\/$/, \"\");\n let path = endpoint.startsWith(\"/\") ? endpoint : `/${endpoint}`;\n if (!baseUrl && this.apiBasePath && (path === this.apiBasePath || path.startsWith(`${this.apiBasePath}/`))) {\n path = path.slice(this.apiBasePath.length) || \"/\";\n }\n return `${root}${path}`;\n }\n\n private stringifyQueryParams(params: Record<string, string | number | boolean>): Record<string, string> {\n return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, String(value)]));\n }\n\n private static normalizeBasePath(value: string): string {\n const stripped = value.trim();\n if (!stripped) return \"\";\n return stripped.startsWith(\"/\") ? stripped : `/${stripped}`;\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- export declare function readTextFileIfExists(filePath: string): Promise<string | undefined>;
2
- export declare function writeTextFileIfChanged(filePath: string, content: string): Promise<boolean>;
1
+ export declare function readTextFileIfExists(filePath: string): Promise<string | undefined>;
2
+ export declare function writeTextFileIfChanged(filePath: string, content: string): Promise<boolean>;
3
3
  //# sourceMappingURL=file-utils.d.ts.map
@@ -1,25 +1,25 @@
1
- import { mkdir, readFile, writeFile } from "node:fs/promises";
2
- import path from "node:path";
3
- export async function readTextFileIfExists(filePath) {
4
- const absolutePath = path.resolve(process.cwd(), filePath);
5
- try {
6
- return await readFile(absolutePath, "utf8");
7
- }
8
- catch (error) {
9
- if (error.code === "ENOENT") {
10
- return undefined;
11
- }
12
- throw error;
13
- }
14
- }
15
- export async function writeTextFileIfChanged(filePath, content) {
16
- const absolutePath = path.resolve(process.cwd(), filePath);
17
- const current = await readTextFileIfExists(absolutePath);
18
- if (current === content) {
19
- return false;
20
- }
21
- await mkdir(path.dirname(absolutePath), { recursive: true });
22
- await writeFile(absolutePath, content, "utf8");
23
- return true;
24
- }
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ export async function readTextFileIfExists(filePath) {
4
+ const absolutePath = path.resolve(process.cwd(), filePath);
5
+ try {
6
+ return await readFile(absolutePath, "utf8");
7
+ }
8
+ catch (error) {
9
+ if (error.code === "ENOENT") {
10
+ return undefined;
11
+ }
12
+ throw error;
13
+ }
14
+ }
15
+ export async function writeTextFileIfChanged(filePath, content) {
16
+ const absolutePath = path.resolve(process.cwd(), filePath);
17
+ const current = await readTextFileIfExists(absolutePath);
18
+ if (current === content) {
19
+ return false;
20
+ }
21
+ await mkdir(path.dirname(absolutePath), { recursive: true });
22
+ await writeFile(absolutePath, content, "utf8");
23
+ return true;
24
+ }
25
25
  //# sourceMappingURL=file-utils.js.map
@@ -1,24 +1,24 @@
1
- #!/usr/bin/env node
2
- type DictionaryEntry = {
3
- description?: string | null;
4
- descriptions?: Record<string, string | null | undefined>;
5
- [key: string]: unknown;
6
- };
7
- type ObjectTypeEntry = DictionaryEntry & {
8
- attributes?: string[] | null;
9
- };
10
- type UnsDictionary = {
11
- schemaVersion?: unknown;
12
- objectTypes?: Record<string, ObjectTypeEntry>;
13
- attributes?: Record<string, DictionaryEntry>;
14
- [key: string]: unknown;
15
- };
16
- type CliArgs = {
17
- input: string;
18
- output: string;
19
- lang: string;
20
- };
21
- export declare function generateUnsDictionary(args: Partial<CliArgs>): Promise<void>;
22
- export declare function renderDictionaryTs(dictionary: UnsDictionary, lang: string): string;
23
- export {};
1
+ #!/usr/bin/env node
2
+ type DictionaryEntry = {
3
+ description?: string | null;
4
+ descriptions?: Record<string, string | null | undefined>;
5
+ [key: string]: unknown;
6
+ };
7
+ type ObjectTypeEntry = DictionaryEntry & {
8
+ attributes?: string[] | null;
9
+ };
10
+ type UnsDictionary = {
11
+ schemaVersion?: unknown;
12
+ objectTypes?: Record<string, ObjectTypeEntry>;
13
+ attributes?: Record<string, DictionaryEntry>;
14
+ [key: string]: unknown;
15
+ };
16
+ type CliArgs = {
17
+ input: string;
18
+ output: string;
19
+ lang: string;
20
+ };
21
+ export declare function generateUnsDictionary(args: Partial<CliArgs>): Promise<void>;
22
+ export declare function renderDictionaryTs(dictionary: UnsDictionary, lang: string): string;
23
+ export {};
24
24
  //# sourceMappingURL=generate-uns-dictionary.d.ts.map