@uns-kit/core 3.0.28 → 3.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATIONS.md +118 -0
- package/README.md +10 -0
- package/dist/config/app-config.d.ts +15 -0
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/configuration-group-authorization.d.ts +50 -0
- package/dist/runtime/configuration-group-authorization.d.ts.map +1 -0
- package/dist/runtime/configuration-group-authorization.js +113 -0
- package/dist/runtime/configuration-group-authorization.js.map +1 -0
- package/dist/runtime/configuration-group-contract.d.ts +75 -0
- package/dist/runtime/configuration-group-contract.d.ts.map +1 -0
- package/dist/runtime/configuration-group-contract.js +233 -0
- package/dist/runtime/configuration-group-contract.js.map +1 -0
- package/dist/runtime/mqtt-output-state-contract.d.ts +27 -0
- package/dist/runtime/mqtt-output-state-contract.d.ts.map +1 -0
- package/dist/runtime/mqtt-output-state-contract.js +32 -0
- package/dist/runtime/mqtt-output-state-contract.js.map +1 -0
- package/dist/runtime/mqtt-output-state-contract.json +8 -0
- package/dist/runtime/mqtt-output-state-program.d.mts +28 -0
- package/dist/runtime/mqtt-output-state-program.mjs +511 -0
- package/dist/runtime/process-group-authorization.d.ts +2 -0
- package/dist/runtime/process-group-authorization.d.ts.map +1 -1
- package/dist/runtime/process-group-authorization.js +34 -12
- package/dist/runtime/process-group-authorization.js.map +1 -1
- package/dist/runtime/process-group-backup-contract.d.ts +22 -0
- package/dist/runtime/process-group-backup-contract.d.ts.map +1 -0
- package/dist/runtime/process-group-backup-contract.js +20 -0
- package/dist/runtime/process-group-backup-contract.js.map +1 -0
- package/dist/runtime/process-group-backup-contract.json +7 -0
- package/dist/runtime/process-group-configured-upgrade.d.ts +4 -0
- package/dist/runtime/process-group-configured-upgrade.d.ts.map +1 -0
- package/dist/runtime/process-group-configured-upgrade.js +107 -0
- package/dist/runtime/process-group-configured-upgrade.js.map +1 -0
- package/dist/runtime/process-group-generation.d.ts +166 -0
- package/dist/runtime/process-group-generation.d.ts.map +1 -0
- package/dist/runtime/process-group-generation.js +278 -0
- package/dist/runtime/process-group-generation.js.map +1 -0
- package/dist/runtime/process-group-inspection.d.ts +2 -0
- package/dist/runtime/process-group-inspection.d.ts.map +1 -1
- package/dist/runtime/process-group-inspection.js +120 -40
- package/dist/runtime/process-group-inspection.js.map +1 -1
- package/dist/runtime/process-group-resources.d.ts +1 -0
- package/dist/runtime/process-group-resources.d.ts.map +1 -1
- package/dist/runtime/process-group-resources.js +8 -0
- package/dist/runtime/process-group-resources.js.map +1 -1
- package/dist/runtime/process-group-runtime-selection.d.ts +14 -0
- package/dist/runtime/process-group-runtime-selection.d.ts.map +1 -0
- package/dist/runtime/process-group-runtime-selection.js +29 -0
- package/dist/runtime/process-group-runtime-selection.js.map +1 -0
- package/dist/runtime/process-group-snapshot.mjs +60 -8
- package/dist/runtime/process-group-staging.d.ts +2 -2
- package/dist/runtime/process-group-staging.d.ts.map +1 -1
- package/dist/runtime/process-group-staging.js +6 -4
- package/dist/runtime/process-group-staging.js.map +1 -1
- package/dist/runtime/process-group-supervision.d.ts +2 -2
- package/dist/runtime/process-group-supervision.d.ts.map +1 -1
- package/dist/runtime/process-group-supervision.js +3 -2
- package/dist/runtime/process-group-supervision.js.map +1 -1
- package/dist/runtime/process-group-upgrade.d.ts +76 -6
- package/dist/runtime/process-group-upgrade.d.ts.map +1 -1
- package/dist/runtime/process-group-upgrade.js +7 -1
- package/dist/runtime/process-group-upgrade.js.map +1 -1
- package/dist/uns/uns-interfaces.d.ts +3 -0
- package/dist/uns/uns-interfaces.d.ts.map +1 -1
- package/dist/uns/uns-interfaces.js.map +1 -1
- package/dist/uns/uns-proxy-process.d.ts.map +1 -1
- package/dist/uns/uns-proxy-process.js +3 -0
- package/dist/uns/uns-proxy-process.js.map +1 -1
- package/dist/uns-config/config-schema.d.ts +20 -0
- package/dist/uns-config/config-schema.d.ts.map +1 -1
- package/dist/uns-config/mqtt-channel.d.ts +1 -1
- package/dist/uns-config/mqtt-channel.d.ts.map +1 -1
- package/dist/uns-config/mqtt-channel.js +3 -0
- package/dist/uns-config/mqtt-channel.js.map +1 -1
- package/dist/uns-config/uns-core-schema.d.ts +145 -0
- package/dist/uns-config/uns-core-schema.d.ts.map +1 -1
- package/dist/uns-config/uns-core-schema.js +6 -1
- package/dist/uns-config/uns-core-schema.js.map +1 -1
- package/dist/uns-mqtt/mqtt-interfaces.d.ts +5 -0
- package/dist/uns-mqtt/mqtt-interfaces.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-interfaces.js.map +1 -1
- package/dist/uns-mqtt/mqtt-proxy.d.ts +3 -0
- package/dist/uns-mqtt/mqtt-proxy.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-proxy.js +26 -1
- package/dist/uns-mqtt/mqtt-proxy.js.map +1 -1
- package/dist/uns-mqtt/mqtt-worker.d.ts +3 -1
- package/dist/uns-mqtt/mqtt-worker.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-worker.js +45 -8
- package/dist/uns-mqtt/mqtt-worker.js.map +1 -1
- package/dist/uns-mqtt/publish-queue-contract.d.ts +37 -0
- package/dist/uns-mqtt/publish-queue-contract.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue-contract.js +19 -0
- package/dist/uns-mqtt/publish-queue-contract.js.map +1 -0
- package/dist/uns-mqtt/publish-queue-store.d.ts +34 -0
- package/dist/uns-mqtt/publish-queue-store.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue-store.js +176 -0
- package/dist/uns-mqtt/publish-queue-store.js.map +1 -0
- package/dist/uns-mqtt/publish-queue.d.ts +43 -0
- package/dist/uns-mqtt/publish-queue.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue.js +235 -0
- package/dist/uns-mqtt/publish-queue.js.map +1 -0
- package/dist/uns-mqtt/uns-mqtt-proxy.d.ts +7 -0
- package/dist/uns-mqtt/uns-mqtt-proxy.d.ts.map +1 -1
- package/dist/uns-mqtt/uns-mqtt-proxy.js +98 -5
- package/dist/uns-mqtt/uns-mqtt-proxy.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { readConfigurationSelector } from "./process-group-contract.js";
|
|
6
|
+
import { readProcessGroupResource } from "./process-group-resources.js";
|
|
7
|
+
const identity = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);
|
|
8
|
+
const digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
9
|
+
const selector = z
|
|
10
|
+
.array(z
|
|
11
|
+
.string()
|
|
12
|
+
.regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/)
|
|
13
|
+
.refine((v) => !["__proto__", "prototype", "constructor"].includes(v)))
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(8);
|
|
16
|
+
const MAX_BYTES = 1024 * 1024;
|
|
17
|
+
/** Versioned canonical JSON: binary key order, no locale, executable values or accessors. */
|
|
18
|
+
export function configurationResourceJson(value) {
|
|
19
|
+
let nodes = 0, bytes = 0;
|
|
20
|
+
const ancestors = new Set();
|
|
21
|
+
const charge = (size) => {
|
|
22
|
+
bytes += size;
|
|
23
|
+
if (bytes > MAX_BYTES)
|
|
24
|
+
throw Error("Configuration resource exceeds 1 MiB");
|
|
25
|
+
};
|
|
26
|
+
function visit(v, depth) {
|
|
27
|
+
if (++nodes > 65536 || depth > 32)
|
|
28
|
+
throw Error("Configuration resource exceeds its structural budget");
|
|
29
|
+
if (v === null || typeof v === "boolean") {
|
|
30
|
+
charge(v === null ? 4 : v ? 4 : 5);
|
|
31
|
+
return JSON.stringify(v);
|
|
32
|
+
}
|
|
33
|
+
if (typeof v === "string") {
|
|
34
|
+
if (Buffer.byteLength(v) > MAX_BYTES)
|
|
35
|
+
throw Error("Configuration resource string exceeds 1 MiB");
|
|
36
|
+
const encoded = JSON.stringify(v);
|
|
37
|
+
charge(Buffer.byteLength(encoded));
|
|
38
|
+
return encoded;
|
|
39
|
+
}
|
|
40
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
41
|
+
const encoded = JSON.stringify(v);
|
|
42
|
+
charge(encoded.length);
|
|
43
|
+
return encoded;
|
|
44
|
+
}
|
|
45
|
+
if (!v || typeof v !== "object" || ancestors.has(v))
|
|
46
|
+
throw Error("Configuration resource must contain finite plain JSON only");
|
|
47
|
+
if (Array.isArray(v)
|
|
48
|
+
? Object.getPrototypeOf(v) !== Array.prototype
|
|
49
|
+
: Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null)
|
|
50
|
+
throw Error("Configuration resource must contain plain JSON objects");
|
|
51
|
+
if (Object.getOwnPropertySymbols(v).length)
|
|
52
|
+
throw Error("Configuration resource cannot contain symbol properties");
|
|
53
|
+
const descriptors = Object.getOwnPropertyDescriptors(v);
|
|
54
|
+
for (const [key, d] of Object.entries(descriptors)) {
|
|
55
|
+
if (Array.isArray(v) && key === "length")
|
|
56
|
+
continue;
|
|
57
|
+
if (!d.enumerable || !Object.hasOwn(d, "value"))
|
|
58
|
+
throw Error("Configuration resource cannot contain hidden properties or accessors");
|
|
59
|
+
}
|
|
60
|
+
ancestors.add(v);
|
|
61
|
+
charge(2); // Container brackets/braces.
|
|
62
|
+
let result;
|
|
63
|
+
if (Array.isArray(v)) {
|
|
64
|
+
if (v.length > 65536 || Object.keys(v).length !== v.length || Object.keys(v).some((k, i) => k !== String(i)))
|
|
65
|
+
throw Error("Configuration resource arrays must be dense JSON arrays");
|
|
66
|
+
charge(Math.max(0, v.length - 1));
|
|
67
|
+
result = "[" + Array.from({ length: v.length }, (_, i) => visit(descriptors[String(i)].value, depth + 1)).join(",") + "]";
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
result =
|
|
71
|
+
"{" +
|
|
72
|
+
Object.keys(v)
|
|
73
|
+
.sort()
|
|
74
|
+
.map((k, i) => {
|
|
75
|
+
if (Buffer.byteLength(k) > MAX_BYTES)
|
|
76
|
+
throw Error("Configuration resource key exceeds 1 MiB");
|
|
77
|
+
charge(Buffer.byteLength(JSON.stringify(k)) + 1 + (i ? 1 : 0));
|
|
78
|
+
return JSON.stringify(k) + ":" + visit(descriptors[k].value, depth + 1);
|
|
79
|
+
})
|
|
80
|
+
.join(",") +
|
|
81
|
+
"}";
|
|
82
|
+
ancestors.delete(v);
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
const json = visit(value, 0);
|
|
86
|
+
if (Buffer.byteLength(json) > MAX_BYTES)
|
|
87
|
+
throw Error("Configuration resource exceeds 1 MiB");
|
|
88
|
+
return json;
|
|
89
|
+
}
|
|
90
|
+
export function configurationResourceHash(value) {
|
|
91
|
+
return createHash("sha256").update("uns-configuration-json-v1\n").update(configurationResourceJson(value)).digest("hex");
|
|
92
|
+
}
|
|
93
|
+
export const configurationGroupProfileSchema = z.strictObject({
|
|
94
|
+
id: identity,
|
|
95
|
+
processName: identity,
|
|
96
|
+
dataGroup: identity,
|
|
97
|
+
resource: z.unknown(),
|
|
98
|
+
});
|
|
99
|
+
export const configurationGroupSchema = z.strictObject({
|
|
100
|
+
schemaVersion: z.literal(2),
|
|
101
|
+
id: identity,
|
|
102
|
+
inputTopic: z
|
|
103
|
+
.string()
|
|
104
|
+
.min(1)
|
|
105
|
+
.max(512)
|
|
106
|
+
.regex(/^[^#+\0]+$/),
|
|
107
|
+
processName: identity,
|
|
108
|
+
receiverProcessName: identity,
|
|
109
|
+
profiles: z.array(configurationGroupProfileSchema).min(2).max(16),
|
|
110
|
+
});
|
|
111
|
+
export const configurationGroupDescriptorSchema = z
|
|
112
|
+
.strictObject({
|
|
113
|
+
protocolVersion: z.literal(2),
|
|
114
|
+
namespace: identity,
|
|
115
|
+
publisherPath: selector,
|
|
116
|
+
groupPath: selector,
|
|
117
|
+
memberPath: selector,
|
|
118
|
+
journalPath: selector,
|
|
119
|
+
runtimeRolePath: selector,
|
|
120
|
+
receiverRole: identity,
|
|
121
|
+
match: z.strictObject({ path: selector, value: z.string().min(1).max(100) }).optional(),
|
|
122
|
+
})
|
|
123
|
+
.superRefine((d, context) => {
|
|
124
|
+
const independent = [d.publisherPath, d.journalPath, d.runtimeRolePath].map((p) => p.join("."));
|
|
125
|
+
if (new Set(independent).size !== independent.length || independent.some((p, i) => independent.some((q, j) => i !== j && q.startsWith(p + "."))))
|
|
126
|
+
context.addIssue({ code: "custom", message: "Independent publisher, journal and role selectors required" });
|
|
127
|
+
const parent = d.publisherPath.join(".") + ".", group = d.groupPath.join("."), member = d.memberPath.join(".");
|
|
128
|
+
if (!group.startsWith(parent) ||
|
|
129
|
+
!member.startsWith(parent) ||
|
|
130
|
+
group === member ||
|
|
131
|
+
group.startsWith(member + ".") ||
|
|
132
|
+
member.startsWith(group + "."))
|
|
133
|
+
context.addIssue({ code: "custom", message: "Distinct group/member selectors within the publisher required" });
|
|
134
|
+
});
|
|
135
|
+
const snapshots = new WeakSet();
|
|
136
|
+
function freeze(value) {
|
|
137
|
+
if (value && typeof value === "object") {
|
|
138
|
+
for (const child of Object.values(value))
|
|
139
|
+
freeze(child);
|
|
140
|
+
Object.freeze(value);
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
export function configurationGroupSnapshot(value) {
|
|
145
|
+
// Bound and copy before schema traversal; caller mutation cannot change a running revision.
|
|
146
|
+
const group = configurationGroupSchema.parse(JSON.parse(configurationResourceJson(value)));
|
|
147
|
+
const names = [group.processName, group.receiverProcessName, ...group.profiles.map((p) => p.processName)];
|
|
148
|
+
if (new Set(names).size !== names.length || new Set(group.profiles.map((p) => p.id)).size !== group.profiles.length)
|
|
149
|
+
throw Error("Configuration group identities overlap");
|
|
150
|
+
const profiles = group.profiles.map((p) => ({ ...p, resourceSha256: configurationResourceHash(p.resource) }));
|
|
151
|
+
const result = freeze({ group, sha256: configurationResourceHash(group), profiles });
|
|
152
|
+
snapshots.add(result);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
export function assertConfigurationGroupSnapshot(value) {
|
|
156
|
+
if (!snapshots.has(value))
|
|
157
|
+
throw Error("Exact SDK-issued configuration group snapshot required");
|
|
158
|
+
}
|
|
159
|
+
/** Optional data-only capability; packages without it keep their existing behavior. */
|
|
160
|
+
export function configurationGroupDescriptor(packageRoot) {
|
|
161
|
+
const file = path.join(packageRoot, "package.json");
|
|
162
|
+
// Ordinary Node/Python deployments do not opt in by existing on the host.
|
|
163
|
+
if (!fs.existsSync(file))
|
|
164
|
+
return undefined;
|
|
165
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
166
|
+
let bytes;
|
|
167
|
+
try {
|
|
168
|
+
const stat = fs.fstatSync(fd);
|
|
169
|
+
if (!stat.isFile() || stat.size > MAX_BYTES)
|
|
170
|
+
throw Error("Invalid installed runtime metadata");
|
|
171
|
+
bytes = fs.readFileSync(fd);
|
|
172
|
+
if (bytes.length > MAX_BYTES)
|
|
173
|
+
throw Error("Installed runtime metadata is too large");
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
fs.closeSync(fd);
|
|
177
|
+
}
|
|
178
|
+
const pkg = JSON.parse(bytes.toString());
|
|
179
|
+
const value = pkg.unsDatahub?.processGroupConfigurationRuntime;
|
|
180
|
+
if (value !== undefined && !readProcessGroupResource(file).equals(bytes))
|
|
181
|
+
throw Error("Installed runtime metadata changed during discovery");
|
|
182
|
+
return value === undefined ? undefined : configurationGroupDescriptorSchema.parse(value);
|
|
183
|
+
}
|
|
184
|
+
export function selectedConfigurationGroup(packageRoot, raw) {
|
|
185
|
+
const descriptor = configurationGroupDescriptor(packageRoot);
|
|
186
|
+
if (!descriptor)
|
|
187
|
+
return undefined;
|
|
188
|
+
const value = readConfigurationSelector(raw, descriptor.groupPath);
|
|
189
|
+
if (value === undefined)
|
|
190
|
+
return undefined;
|
|
191
|
+
if (descriptor.match && readConfigurationSelector(raw, descriptor.match.path) !== descriptor.match.value)
|
|
192
|
+
throw Error("Configuration group capability selector does not match");
|
|
193
|
+
return { descriptor, snapshot: configurationGroupSnapshot(value) };
|
|
194
|
+
}
|
|
195
|
+
export const configurationGroupJournalSchema = z.strictObject({
|
|
196
|
+
directory: z.string().startsWith("/").max(512),
|
|
197
|
+
journalId: z.string().uuid().optional(),
|
|
198
|
+
generationId: identity,
|
|
199
|
+
groupSha256: digest,
|
|
200
|
+
minFreeBytes: z
|
|
201
|
+
.number()
|
|
202
|
+
.int()
|
|
203
|
+
.min(1024 * 1024)
|
|
204
|
+
.max(1024 * 1024 * 1024)
|
|
205
|
+
.default(64 * 1024 * 1024),
|
|
206
|
+
maxRecords: z.number().int().min(1).max(100000).default(20000),
|
|
207
|
+
maxBytes: z
|
|
208
|
+
.number()
|
|
209
|
+
.int()
|
|
210
|
+
.min(1024)
|
|
211
|
+
.max(256 * 1024 * 1024)
|
|
212
|
+
.default(32 * 1024 * 1024),
|
|
213
|
+
});
|
|
214
|
+
export function configurationGroupJournalContract(snapshot, sourceIdentity, config, profiles) {
|
|
215
|
+
assertConfigurationGroupSnapshot(snapshot);
|
|
216
|
+
const journal = configurationGroupJournalSchema.parse(config);
|
|
217
|
+
if (journal.groupSha256 !== snapshot.sha256 || !digest.safeParse(sourceIdentity).success)
|
|
218
|
+
throw Error("Configuration group journal revision differs");
|
|
219
|
+
const expected = snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup }));
|
|
220
|
+
const normalize = (v) => [...v].sort((a, b) => (a.processName < b.processName ? -1 : a.processName > b.processName ? 1 : 0));
|
|
221
|
+
if (configurationResourceHash(normalize([...profiles])) !== configurationResourceHash(normalize(expected)))
|
|
222
|
+
throw Error("Configuration group journal profiles differ");
|
|
223
|
+
return configurationResourceJson({
|
|
224
|
+
version: 2,
|
|
225
|
+
generationId: journal.generationId,
|
|
226
|
+
groupSha256: snapshot.sha256,
|
|
227
|
+
sourceIdentity,
|
|
228
|
+
maxRecords: journal.maxRecords,
|
|
229
|
+
maxBytes: journal.maxBytes,
|
|
230
|
+
profiles: normalize(expected),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=configuration-group-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-group-contract.js","sourceRoot":"","sources":["../../src/runtime/configuration-group-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAC5D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAClD,MAAM,QAAQ,GAAG,CAAC;KACf,KAAK,CACJ,CAAC;KACE,MAAM,EAAE;KACR,KAAK,CAAC,+BAA+B,CAAC;KACtC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACzE;KACA,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,CAAC,CAAC,CAAC;AACV,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9B,6FAA6F;AAC7F,MAAM,UAAU,yBAAyB,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":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport { readConfigurationSelector } from \"./process-group-contract.js\";\nimport { readProcessGroupResource } from \"./process-group-resources.js\";\n\nconst identity = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);\nconst digest = z.string().regex(/^[a-f0-9]{64}$/);\nconst selector = z\n .array(\n z\n .string()\n .regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/)\n .refine((v) => ![\"__proto__\", \"prototype\", \"constructor\"].includes(v)),\n )\n .min(1)\n .max(8);\nconst MAX_BYTES = 1024 * 1024;\n\n/** Versioned canonical JSON: binary key order, no locale, executable values or accessors. */\nexport function configurationResourceJson(value: unknown): string {\n let nodes = 0,\n bytes = 0;\n const ancestors = new Set<object>();\n const charge = (size: number) => {\n bytes += size;\n if (bytes > MAX_BYTES) throw Error(\"Configuration resource exceeds 1 MiB\");\n };\n function visit(v: unknown, depth: number): string {\n if (++nodes > 65536 || depth > 32) throw Error(\"Configuration resource exceeds its structural budget\");\n if (v === null || typeof v === \"boolean\") {\n charge(v === null ? 4 : v ? 4 : 5);\n return JSON.stringify(v);\n }\n if (typeof v === \"string\") {\n if (Buffer.byteLength(v) > MAX_BYTES) throw Error(\"Configuration resource string exceeds 1 MiB\");\n const encoded = JSON.stringify(v);\n charge(Buffer.byteLength(encoded));\n return encoded;\n }\n if (typeof v === \"number\" && Number.isFinite(v)) {\n const encoded = JSON.stringify(v);\n charge(encoded.length);\n return encoded;\n }\n if (!v || typeof v !== \"object\" || ancestors.has(v)) throw Error(\"Configuration resource must contain finite plain JSON only\");\n if (\n Array.isArray(v)\n ? Object.getPrototypeOf(v) !== Array.prototype\n : Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null\n )\n throw Error(\"Configuration resource must contain plain JSON objects\");\n if (Object.getOwnPropertySymbols(v).length) throw Error(\"Configuration resource cannot contain symbol properties\");\n const descriptors = Object.getOwnPropertyDescriptors(v);\n for (const [key, d] of Object.entries(descriptors)) {\n if (Array.isArray(v) && key === \"length\") continue;\n if (!d.enumerable || !Object.hasOwn(d, \"value\")) throw Error(\"Configuration resource cannot contain hidden properties or accessors\");\n }\n ancestors.add(v);\n charge(2); // Container brackets/braces.\n let result: string;\n if (Array.isArray(v)) {\n if (v.length > 65536 || Object.keys(v).length !== v.length || Object.keys(v).some((k, i) => k !== String(i)))\n throw Error(\"Configuration resource arrays must be dense JSON arrays\");\n charge(Math.max(0, v.length - 1));\n result = \"[\" + Array.from({ length: v.length }, (_, i) => visit(descriptors[String(i)]!.value, depth + 1)).join(\",\") + \"]\";\n } else\n result =\n \"{\" +\n Object.keys(v)\n .sort()\n .map((k, i) => {\n if (Buffer.byteLength(k) > MAX_BYTES) throw Error(\"Configuration resource key exceeds 1 MiB\");\n charge(Buffer.byteLength(JSON.stringify(k)) + 1 + (i ? 1 : 0));\n return JSON.stringify(k) + \":\" + visit(descriptors[k]!.value, depth + 1);\n })\n .join(\",\") +\n \"}\";\n ancestors.delete(v);\n return result;\n }\n const json = visit(value, 0);\n if (Buffer.byteLength(json) > MAX_BYTES) throw Error(\"Configuration resource exceeds 1 MiB\");\n return json;\n}\n\nexport function configurationResourceHash(value: unknown): string {\n return createHash(\"sha256\").update(\"uns-configuration-json-v1\\n\").update(configurationResourceJson(value)).digest(\"hex\");\n}\n\nexport const configurationGroupProfileSchema = z.strictObject({\n id: identity,\n processName: identity,\n dataGroup: identity,\n resource: z.unknown(),\n});\nexport const configurationGroupSchema = z.strictObject({\n schemaVersion: z.literal(2),\n id: identity,\n inputTopic: z\n .string()\n .min(1)\n .max(512)\n .regex(/^[^#+\\0]+$/),\n processName: identity,\n receiverProcessName: identity,\n profiles: z.array(configurationGroupProfileSchema).min(2).max(16),\n});\nexport const configurationGroupDescriptorSchema = z\n .strictObject({\n protocolVersion: z.literal(2),\n namespace: identity,\n publisherPath: selector,\n groupPath: selector,\n memberPath: selector,\n journalPath: selector,\n runtimeRolePath: selector,\n receiverRole: identity,\n match: z.strictObject({ path: selector, value: z.string().min(1).max(100) }).optional(),\n })\n .superRefine((d, context) => {\n const independent = [d.publisherPath, d.journalPath, d.runtimeRolePath].map((p) => p.join(\".\"));\n if (new Set(independent).size !== independent.length || independent.some((p, i) => independent.some((q, j) => i !== j && q.startsWith(p + \".\"))))\n context.addIssue({ code: \"custom\", message: \"Independent publisher, journal and role selectors required\" });\n const parent = d.publisherPath.join(\".\") + \".\",\n group = d.groupPath.join(\".\"),\n member = d.memberPath.join(\".\");\n if (\n !group.startsWith(parent) ||\n !member.startsWith(parent) ||\n group === member ||\n group.startsWith(member + \".\") ||\n member.startsWith(group + \".\")\n )\n context.addIssue({ code: \"custom\", message: \"Distinct group/member selectors within the publisher required\" });\n });\nexport type ConfigurationGroupDescriptor = z.infer<typeof configurationGroupDescriptorSchema>;\nexport type ConfigurationGroup = z.infer<typeof configurationGroupSchema>;\nexport interface ConfigurationGroupProfile {\n readonly id: string;\n readonly processName: string;\n readonly dataGroup: string;\n readonly resourceSha256: string;\n readonly resource: unknown;\n}\nexport interface ConfigurationGroupSnapshot {\n readonly group: Readonly<ConfigurationGroup>;\n readonly sha256: string;\n readonly profiles: readonly ConfigurationGroupProfile[];\n}\nconst snapshots = new WeakSet<object>();\nfunction freeze<T>(value: T): T {\n if (value && typeof value === \"object\") {\n for (const child of Object.values(value)) freeze(child);\n Object.freeze(value);\n }\n return value;\n}\nexport function configurationGroupSnapshot(value: unknown): ConfigurationGroupSnapshot {\n // Bound and copy before schema traversal; caller mutation cannot change a running revision.\n const group = configurationGroupSchema.parse(JSON.parse(configurationResourceJson(value)));\n const names = [group.processName, group.receiverProcessName, ...group.profiles.map((p) => p.processName)];\n if (new Set(names).size !== names.length || new Set(group.profiles.map((p) => p.id)).size !== group.profiles.length)\n throw Error(\"Configuration group identities overlap\");\n const profiles = group.profiles.map((p) => ({ ...p, resourceSha256: configurationResourceHash(p.resource) }));\n const result = freeze({ group, sha256: configurationResourceHash(group), profiles });\n snapshots.add(result);\n return result;\n}\nexport function assertConfigurationGroupSnapshot(value: ConfigurationGroupSnapshot): void {\n if (!snapshots.has(value)) throw Error(\"Exact SDK-issued configuration group snapshot required\");\n}\n\n/** Optional data-only capability; packages without it keep their existing behavior. */\nexport function configurationGroupDescriptor(packageRoot: string): ConfigurationGroupDescriptor | undefined {\n const file = path.join(packageRoot, \"package.json\");\n // Ordinary Node/Python deployments do not opt in by existing on the host.\n if (!fs.existsSync(file)) return undefined;\n const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n let bytes: Buffer;\n try {\n const stat = fs.fstatSync(fd);\n if (!stat.isFile() || stat.size > MAX_BYTES) throw Error(\"Invalid installed runtime metadata\");\n bytes = fs.readFileSync(fd);\n if (bytes.length > MAX_BYTES) throw Error(\"Installed runtime metadata is too large\");\n } finally {\n fs.closeSync(fd);\n }\n const pkg = JSON.parse(bytes.toString());\n const value = pkg.unsDatahub?.processGroupConfigurationRuntime;\n if (value !== undefined && !readProcessGroupResource(file).equals(bytes)) throw Error(\"Installed runtime metadata changed during discovery\");\n return value === undefined ? undefined : configurationGroupDescriptorSchema.parse(value);\n}\nexport function selectedConfigurationGroup(\n packageRoot: string,\n raw: Record<string, unknown>,\n):\n | {\n descriptor: ConfigurationGroupDescriptor;\n snapshot: ConfigurationGroupSnapshot;\n }\n | undefined {\n const descriptor = configurationGroupDescriptor(packageRoot);\n if (!descriptor) return undefined;\n const value = readConfigurationSelector(raw, descriptor.groupPath);\n if (value === undefined) return undefined;\n if (descriptor.match && readConfigurationSelector(raw, descriptor.match.path) !== descriptor.match.value)\n throw Error(\"Configuration group capability selector does not match\");\n return { descriptor, snapshot: configurationGroupSnapshot(value) };\n}\n\nexport const configurationGroupJournalSchema = z.strictObject({\n directory: z.string().startsWith(\"/\").max(512),\n journalId: z.string().uuid().optional(),\n generationId: identity,\n groupSha256: digest,\n minFreeBytes: z\n .number()\n .int()\n .min(1024 * 1024)\n .max(1024 * 1024 * 1024)\n .default(64 * 1024 * 1024),\n maxRecords: z.number().int().min(1).max(100000).default(20000),\n maxBytes: z\n .number()\n .int()\n .min(1024)\n .max(256 * 1024 * 1024)\n .default(32 * 1024 * 1024),\n});\nexport type ConfigurationGroupJournal = z.infer<typeof configurationGroupJournalSchema>;\nexport function configurationGroupJournalContract(\n snapshot: ConfigurationGroupSnapshot,\n sourceIdentity: string,\n config: ConfigurationGroupJournal,\n profiles: readonly { processName: string; resourceSha256: string; dataGroup: string }[],\n): string {\n assertConfigurationGroupSnapshot(snapshot);\n const journal = configurationGroupJournalSchema.parse(config);\n if (journal.groupSha256 !== snapshot.sha256 || !digest.safeParse(sourceIdentity).success)\n throw Error(\"Configuration group journal revision differs\");\n const expected = snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup }));\n const normalize = (v: typeof expected) => [...v].sort((a, b) => (a.processName < b.processName ? -1 : a.processName > b.processName ? 1 : 0));\n if (configurationResourceHash(normalize([...profiles])) !== configurationResourceHash(normalize(expected)))\n throw Error(\"Configuration group journal profiles differ\");\n return configurationResourceJson({\n version: 2,\n generationId: journal.generationId,\n groupSha256: snapshot.sha256,\n sourceIdentity,\n maxRecords: journal.maxRecords,\n maxBytes: journal.maxBytes,\n profiles: normalize(expected),\n });\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const mqttOutputStateLimits: Readonly<{
|
|
3
|
+
schemaVersion: 1;
|
|
4
|
+
maximumQueues: 32;
|
|
5
|
+
maximumRecordsPerQueue: 100000;
|
|
6
|
+
maximumManifestBytes: 262144;
|
|
7
|
+
maximumSnapshotBytes: 536870912;
|
|
8
|
+
maximumCapsuleBytes: 1073741824;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const mqttOutputStateBackupSchema: z.ZodObject<{
|
|
11
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
12
|
+
state: z.ZodEnum<{
|
|
13
|
+
included: "included";
|
|
14
|
+
empty: "empty";
|
|
15
|
+
}>;
|
|
16
|
+
rootSha256: z.ZodString;
|
|
17
|
+
queues: z.ZodNumber;
|
|
18
|
+
records: z.ZodNumber;
|
|
19
|
+
bytes: z.ZodNumber;
|
|
20
|
+
sha256: z.ZodString;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
/** Controller inspection of standard SDK configuration, without application code. */
|
|
23
|
+
export declare function managedMqttOutputBinding(config: unknown, root: string | undefined): {
|
|
24
|
+
directory: string;
|
|
25
|
+
relative: string;
|
|
26
|
+
} | undefined;
|
|
27
|
+
//# sourceMappingURL=mqtt-output-state-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mqtt-output-state-contract.d.ts","sourceRoot":"","sources":["../../src/runtime/mqtt-output-state-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,qBAAqB;;;;;;;EAA2B,CAAC;AAC9D,eAAO,MAAM,2BAA2B;;;;;;;;;;;kBAcqD,CAAC;AAE9F,qFAAqF;AACrF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAOvI"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { mqttPublishQueueSchema } from "../uns-mqtt/publish-queue-contract.js";
|
|
3
|
+
import fixed from "./mqtt-output-state-contract.json" with { type: "json" };
|
|
4
|
+
import { outputStateLimits } from "./mqtt-output-state-program.mjs";
|
|
5
|
+
import { outputStateRelative } from "./mqtt-output-state-program.mjs";
|
|
6
|
+
export const mqttOutputStateLimits = outputStateLimits(fixed);
|
|
7
|
+
export const mqttOutputStateBackupSchema = z
|
|
8
|
+
.strictObject({
|
|
9
|
+
schemaVersion: z.literal(1),
|
|
10
|
+
state: z.enum(["included", "empty"]),
|
|
11
|
+
rootSha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
12
|
+
queues: z.number().int().min(0).max(mqttOutputStateLimits.maximumQueues),
|
|
13
|
+
records: z
|
|
14
|
+
.number()
|
|
15
|
+
.int()
|
|
16
|
+
.min(0)
|
|
17
|
+
.max(mqttOutputStateLimits.maximumQueues * mqttOutputStateLimits.maximumRecordsPerQueue),
|
|
18
|
+
bytes: z.number().int().positive().max(mqttOutputStateLimits.maximumCapsuleBytes),
|
|
19
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
20
|
+
})
|
|
21
|
+
.refine((v) => (v.state === "included" ? v.queues > 0 : v.queues === 0 && v.records === 0));
|
|
22
|
+
/** Controller inspection of standard SDK configuration, without application code. */
|
|
23
|
+
export function managedMqttOutputBinding(config, root) {
|
|
24
|
+
const value = config;
|
|
25
|
+
if (value?.output?.publishQueue === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
const queue = mqttPublishQueueSchema.parse(value.output.publishQueue);
|
|
28
|
+
if (queue.storage !== "runtime" || !root)
|
|
29
|
+
throw Error("Controller-managed MQTT output requires storage=runtime and a reviewed persistent Runtime mount");
|
|
30
|
+
return { directory: queue.directory, relative: outputStateRelative(root, queue.directory) };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=mqtt-output-state-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mqtt-output-state-contract.js","sourceRoot":"","sources":["../../src/runtime/mqtt-output-state-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,MAAM,mCAAmC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCA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AAK,GAAG,MAAiD,CAAC;IAChE,IAAI,KAAK,EAAE,MAAM,EAAE,YAAY,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAChE,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,IAAI;QACtC,MAAM,KAAK,CAAC,iGAAiG,CAAC,CAAC;IACjH,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;AAC9F,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { mqttPublishQueueSchema } from \"../uns-mqtt/publish-queue-contract.js\";\nimport fixed from \"./mqtt-output-state-contract.json\" with { type: \"json\" };\nimport { outputStateLimits } from \"./mqtt-output-state-program.mjs\";\nimport { outputStateRelative } from \"./mqtt-output-state-program.mjs\";\n\nexport const mqttOutputStateLimits = outputStateLimits(fixed);\nexport const mqttOutputStateBackupSchema = z\n .strictObject({\n schemaVersion: z.literal(1),\n state: z.enum([\"included\", \"empty\"]),\n rootSha256: z.string().regex(/^[a-f0-9]{64}$/),\n queues: z.number().int().min(0).max(mqttOutputStateLimits.maximumQueues),\n records: z\n .number()\n .int()\n .min(0)\n .max(mqttOutputStateLimits.maximumQueues * mqttOutputStateLimits.maximumRecordsPerQueue),\n bytes: z.number().int().positive().max(mqttOutputStateLimits.maximumCapsuleBytes),\n sha256: z.string().regex(/^[a-f0-9]{64}$/),\n })\n .refine((v) => (v.state === \"included\" ? v.queues > 0 : v.queues === 0 && v.records === 0));\n\n/** Controller inspection of standard SDK configuration, without application code. */\nexport function managedMqttOutputBinding(config: unknown, root: string | undefined): { directory: string; relative: string } | undefined {\n const value = config as { output?: { publishQueue?: unknown } };\n if (value?.output?.publishQueue === undefined) return undefined;\n const queue = mqttPublishQueueSchema.parse(value.output.publishQueue);\n if (queue.storage !== \"runtime\" || !root)\n throw Error(\"Controller-managed MQTT output requires storage=runtime and a reviewed persistent Runtime mount\");\n return { directory: queue.directory, relative: outputStateRelative(root, queue.directory) };\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function openManagedOutputRoot(
|
|
2
|
+
directory: string,
|
|
3
|
+
root: string | undefined,
|
|
4
|
+
): { rootId: string; relative: string; schema: "2"; close(): void } | undefined;
|
|
5
|
+
export function validateOutputRow(row: unknown): {
|
|
6
|
+
seq: number;
|
|
7
|
+
id: string;
|
|
8
|
+
topic: string;
|
|
9
|
+
message: string;
|
|
10
|
+
options: { qos: 1 | 2; retain: boolean };
|
|
11
|
+
bytes: number;
|
|
12
|
+
};
|
|
13
|
+
export function outputStateLimits(
|
|
14
|
+
value: unknown,
|
|
15
|
+
): Readonly<{
|
|
16
|
+
schemaVersion: 1;
|
|
17
|
+
maximumQueues: 32;
|
|
18
|
+
maximumRecordsPerQueue: 100000;
|
|
19
|
+
maximumManifestBytes: 262144;
|
|
20
|
+
maximumSnapshotBytes: 536870912;
|
|
21
|
+
maximumCapsuleBytes: 1073741824;
|
|
22
|
+
}>;
|
|
23
|
+
export function runOutputStateProgram(args: string[]): Promise<unknown>;
|
|
24
|
+
export function validateOutputSnapshot(directory: string, limits: unknown): { queues: unknown[]; rootId: string };
|
|
25
|
+
|
|
26
|
+
export function outputStateRelative(root: string, directory: string): string;
|
|
27
|
+
|
|
28
|
+
export function outputStateMain(args?: string[]): Promise<void>;
|