@camstack/system 1.2.34 → 1.2.36
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/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/block-type-defs.d.ts +14 -0
- package/dist/builtins/core-blocks/compile-block.d.ts +21 -0
- package/dist/builtins/core-blocks/core-block-store.d.ts +73 -0
- package/dist/builtins/core-blocks/core-blocks.addon.d.ts +19 -0
- package/dist/builtins/core-blocks/core-blocks.addon.js +418 -0
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +411 -0
- package/dist/builtins/core-blocks/index.d.ts +4 -0
- package/dist/builtins/core-blocks/index.js +12 -0
- package/dist/builtins/core-blocks/index.mjs +2 -0
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +10 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{dist-Bqyu3d1X.js → dist-CFinlH7b.js} +263 -1
- package/dist/{dist-BjUYsgkj.mjs → dist-DO76YVO2.mjs} +252 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -2
- package/dist/index.mjs +17 -3
- package/dist/main-CVLq8IzA.js +2356 -0
- package/dist/main-CzH19GkU.mjs +2353 -0
- package/package.json +14 -1
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
+
import { S as coreBlocksCapability, ct as BaseAddon, o as CoreBlockSchema } from "../../dist-DO76YVO2.mjs";
|
|
3
|
+
import * as path$1 from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
//#region src/builtins/core-blocks/compile-block.ts
|
|
7
|
+
/** An esbuild error carries the position; the shape is narrow enough to read
|
|
8
|
+
* defensively rather than to type against the package. */
|
|
9
|
+
function positionOf(err) {
|
|
10
|
+
if (err === null || typeof err !== "object") return {};
|
|
11
|
+
const errors = err.errors;
|
|
12
|
+
if (!Array.isArray(errors) || errors.length === 0) return {};
|
|
13
|
+
const location = errors[0].location;
|
|
14
|
+
if (location === null || typeof location !== "object") return {};
|
|
15
|
+
const l = location;
|
|
16
|
+
return {
|
|
17
|
+
...typeof l.line === "number" ? { line: l.line } : {},
|
|
18
|
+
...typeof l.column === "number" ? { column: l.column } : {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function messageOf(err) {
|
|
22
|
+
if (err === null || typeof err !== "object") return String(err);
|
|
23
|
+
const errors = err.errors;
|
|
24
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
25
|
+
const text = errors[0].text;
|
|
26
|
+
if (typeof text === "string") return text;
|
|
27
|
+
}
|
|
28
|
+
return err instanceof Error ? err.message : String(err);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Never throws. A compile failure is an ANSWER — the author needs to read it,
|
|
32
|
+
* and a thrown error at this layer becomes a 500 with the useful part buried.
|
|
33
|
+
*/
|
|
34
|
+
async function compileBlock(transpiler, code) {
|
|
35
|
+
if (code.trim().length === 0) return {
|
|
36
|
+
ok: false,
|
|
37
|
+
error: "the block is empty — it must export a default function"
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
return {
|
|
41
|
+
ok: true,
|
|
42
|
+
js: (await transpiler.transform(code, {
|
|
43
|
+
loader: "ts",
|
|
44
|
+
format: "esm",
|
|
45
|
+
target: "node22"
|
|
46
|
+
})).code
|
|
47
|
+
};
|
|
48
|
+
} catch (err) {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
error: messageOf(err),
|
|
52
|
+
...positionOf(err)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/builtins/core-blocks/core-block-store.ts
|
|
58
|
+
var CORE_BLOCKS_COLLECTION = "core_blocks";
|
|
59
|
+
var CORE_BLOCKS_COLUMNS = [
|
|
60
|
+
{
|
|
61
|
+
name: "id",
|
|
62
|
+
type: "TEXT",
|
|
63
|
+
primaryKey: true,
|
|
64
|
+
notNull: true
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "name",
|
|
68
|
+
type: "TEXT",
|
|
69
|
+
notNull: true
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "enabled",
|
|
73
|
+
type: "BOOLEAN",
|
|
74
|
+
notNull: true
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "placement",
|
|
78
|
+
type: "TEXT",
|
|
79
|
+
notNull: true
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "updatedAt",
|
|
83
|
+
type: "INTEGER",
|
|
84
|
+
notNull: true
|
|
85
|
+
},
|
|
86
|
+
(
|
|
87
|
+
/** The FULL block, Zod-validated on read; the scalars above are indexed
|
|
88
|
+
* projections for the list view. */
|
|
89
|
+
{
|
|
90
|
+
name: "block",
|
|
91
|
+
type: "JSON",
|
|
92
|
+
notNull: true
|
|
93
|
+
})
|
|
94
|
+
];
|
|
95
|
+
var CORE_BLOCKS_INDEXES = [{
|
|
96
|
+
name: "idx_core_blocks_enabled",
|
|
97
|
+
columns: ["enabled"]
|
|
98
|
+
}];
|
|
99
|
+
var CoreBlockStore = class {
|
|
100
|
+
byId = /* @__PURE__ */ new Map();
|
|
101
|
+
store;
|
|
102
|
+
logger;
|
|
103
|
+
now;
|
|
104
|
+
newId;
|
|
105
|
+
constructor(deps) {
|
|
106
|
+
this.store = deps.store;
|
|
107
|
+
this.logger = deps.logger;
|
|
108
|
+
this.now = deps.now ?? (() => Date.now());
|
|
109
|
+
this.newId = deps.newId ?? (() => randomUUID());
|
|
110
|
+
}
|
|
111
|
+
static async declare(store) {
|
|
112
|
+
await store.declareCollection.mutate({
|
|
113
|
+
collection: CORE_BLOCKS_COLLECTION,
|
|
114
|
+
columns: [...CORE_BLOCKS_COLUMNS],
|
|
115
|
+
indexes: [...CORE_BLOCKS_INDEXES]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Hydrate every block.
|
|
120
|
+
*
|
|
121
|
+
* A row whose JSON no longer validates is SKIPPED with a warning rather than
|
|
122
|
+
* dropped or repaired: it is somebody's code, and the honest answer to "I
|
|
123
|
+
* cannot read this" is to leave it on disk and say so.
|
|
124
|
+
*/
|
|
125
|
+
async load() {
|
|
126
|
+
try {
|
|
127
|
+
const rows = await this.store.query.query({
|
|
128
|
+
collection: CORE_BLOCKS_COLLECTION,
|
|
129
|
+
filter: { limit: 1e3 }
|
|
130
|
+
});
|
|
131
|
+
this.byId.clear();
|
|
132
|
+
let skipped = 0;
|
|
133
|
+
for (const row of rows) {
|
|
134
|
+
const parsed = CoreBlockSchema.safeParse(row.data["block"]);
|
|
135
|
+
if (!parsed.success) {
|
|
136
|
+
skipped += 1;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
this.byId.set(parsed.data.id, parsed.data);
|
|
140
|
+
}
|
|
141
|
+
if (skipped > 0) this.logger.warn("core blocks skipped as unreadable — left on disk, not repaired", { meta: { skipped } });
|
|
142
|
+
} catch (err) {
|
|
143
|
+
this.logger.warn("core block load failed", { meta: { error: String(err) } });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
list() {
|
|
147
|
+
return [...this.byId.values()].toSorted((a, b) => a.name.localeCompare(b.name));
|
|
148
|
+
}
|
|
149
|
+
get(blockId) {
|
|
150
|
+
return this.byId.get(blockId) ?? null;
|
|
151
|
+
}
|
|
152
|
+
/** Blocks that should be running here. The runner's input. */
|
|
153
|
+
enabledFor(nodeId) {
|
|
154
|
+
return this.list().filter((b) => b.enabled && b.placement === nodeId);
|
|
155
|
+
}
|
|
156
|
+
async create(input, createdBy) {
|
|
157
|
+
const now = this.now();
|
|
158
|
+
const block = CoreBlockSchema.parse({
|
|
159
|
+
...input,
|
|
160
|
+
id: this.newId(),
|
|
161
|
+
createdBy,
|
|
162
|
+
createdAt: now,
|
|
163
|
+
updatedAt: now,
|
|
164
|
+
status: "stopped",
|
|
165
|
+
lastChangedAt: now
|
|
166
|
+
});
|
|
167
|
+
await this.persist(block);
|
|
168
|
+
this.byId.set(block.id, block);
|
|
169
|
+
return block;
|
|
170
|
+
}
|
|
171
|
+
/** Apply a partial patch. Immutable: returns the NEW block. */
|
|
172
|
+
async update(blockId, patch) {
|
|
173
|
+
const existing = this.byId.get(blockId);
|
|
174
|
+
if (!existing) throw new Error(`core block not found: ${blockId}`);
|
|
175
|
+
const updated = CoreBlockSchema.parse({
|
|
176
|
+
...existing,
|
|
177
|
+
...patch,
|
|
178
|
+
id: existing.id,
|
|
179
|
+
createdBy: existing.createdBy,
|
|
180
|
+
createdAt: existing.createdAt,
|
|
181
|
+
updatedAt: this.now()
|
|
182
|
+
});
|
|
183
|
+
await this.persist(updated);
|
|
184
|
+
this.byId.set(updated.id, updated);
|
|
185
|
+
return updated;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Record what the runner did with this block.
|
|
189
|
+
*
|
|
190
|
+
* Separate from {@link update} on purpose: status is the RUNNER's to write
|
|
191
|
+
* and the author's to read, and letting an edit set it would let the UI claim
|
|
192
|
+
* a block is running because somebody renamed it.
|
|
193
|
+
*/
|
|
194
|
+
async setStatus(blockId, status, error) {
|
|
195
|
+
const existing = this.byId.get(blockId);
|
|
196
|
+
if (!existing) return;
|
|
197
|
+
const next = {
|
|
198
|
+
...existing,
|
|
199
|
+
status,
|
|
200
|
+
lastChangedAt: this.now(),
|
|
201
|
+
...error !== void 0 ? { lastError: error } : {}
|
|
202
|
+
};
|
|
203
|
+
if (error === void 0 && next.lastError !== void 0 && status === "running") delete next.lastError;
|
|
204
|
+
await this.persist(next);
|
|
205
|
+
this.byId.set(blockId, next);
|
|
206
|
+
}
|
|
207
|
+
/** Idempotent delete — an unknown id is a no-op. */
|
|
208
|
+
async delete(blockId) {
|
|
209
|
+
this.byId.delete(blockId);
|
|
210
|
+
await this.store.delete.mutate({
|
|
211
|
+
collection: CORE_BLOCKS_COLLECTION,
|
|
212
|
+
key: blockId
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
async persist(block) {
|
|
216
|
+
await this.store.set.mutate({
|
|
217
|
+
collection: CORE_BLOCKS_COLLECTION,
|
|
218
|
+
key: block.id,
|
|
219
|
+
value: {
|
|
220
|
+
name: block.name,
|
|
221
|
+
enabled: block.enabled,
|
|
222
|
+
placement: block.placement,
|
|
223
|
+
updatedAt: block.updatedAt,
|
|
224
|
+
block
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/builtins/core-blocks/block-type-defs.ts
|
|
231
|
+
/** Where Monaco must think the files live for `@camstack/types` to resolve. */
|
|
232
|
+
var VIRTUAL_ROOT = "file:///node_modules/@camstack/types";
|
|
233
|
+
/**
|
|
234
|
+
* Read every `.d.ts` under the installed `@camstack/types` dist.
|
|
235
|
+
*
|
|
236
|
+
* Best-effort by design: a node that cannot find them serves an EMPTY list, and
|
|
237
|
+
* the editor then registers an empty lib set rather than keeping a stale one —
|
|
238
|
+
* so an author sees "no types" instead of validating against a contract that
|
|
239
|
+
* has moved.
|
|
240
|
+
*/
|
|
241
|
+
async function loadBlockTypeDefs(logger) {
|
|
242
|
+
const root = await resolveTypesDist();
|
|
243
|
+
if (root === null) {
|
|
244
|
+
logger.warn("core-blocks: @camstack/types declarations not found — the editor gets no types");
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
const out = [];
|
|
248
|
+
await walk(root, root, out);
|
|
249
|
+
return out;
|
|
250
|
+
}
|
|
251
|
+
async function resolveTypesDist() {
|
|
252
|
+
try {
|
|
253
|
+
const entry = await import.meta.resolve?.("@camstack/types");
|
|
254
|
+
if (typeof entry === "string") {
|
|
255
|
+
const dir = path$1.dirname(entry.replace("file://", ""));
|
|
256
|
+
if (await exists(path$1.join(dir, "index.d.ts"))) return dir;
|
|
257
|
+
}
|
|
258
|
+
} catch {}
|
|
259
|
+
const guess = path$1.resolve(process.cwd(), "node_modules/@camstack/types/dist");
|
|
260
|
+
return await exists(guess) ? guess : null;
|
|
261
|
+
}
|
|
262
|
+
async function exists(p) {
|
|
263
|
+
try {
|
|
264
|
+
await fs.access(p);
|
|
265
|
+
return true;
|
|
266
|
+
} catch {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function walk(root, dir, out) {
|
|
271
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
272
|
+
for (const entry of entries) {
|
|
273
|
+
const full = path$1.join(dir, entry.name);
|
|
274
|
+
if (entry.isDirectory()) {
|
|
275
|
+
await walk(root, full, out);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (!entry.name.endsWith(".d.ts")) continue;
|
|
279
|
+
const content = await fs.readFile(full, "utf-8");
|
|
280
|
+
const relative = path$1.relative(root, full).split(path$1.sep).join("/");
|
|
281
|
+
out.push({
|
|
282
|
+
filePath: `${VIRTUAL_ROOT}/${relative}`,
|
|
283
|
+
content
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/builtins/core-blocks/core-blocks.addon.ts
|
|
289
|
+
/**
|
|
290
|
+
* The `core-blocks` provider — CRUD over user-authored TypeScript, with the
|
|
291
|
+
* compile gate in front of every write.
|
|
292
|
+
*
|
|
293
|
+
* A builtin because a block belongs to the kernel, not to an addon: it is user
|
|
294
|
+
* code the node runs, and it must exist on every install with no opt-in step.
|
|
295
|
+
*
|
|
296
|
+
* **This slice stores and serves. It does not EXECUTE.** The runner (fork per
|
|
297
|
+
* block, `ctx` over UDS, `CrashSupervisor`) is the next piece, and a block
|
|
298
|
+
* therefore sits at `status: 'stopped'` no matter what it says. That is stated
|
|
299
|
+
* here rather than implied because a system that accepted code and quietly
|
|
300
|
+
* never ran it would be the exact failure this repo keeps paying for.
|
|
301
|
+
*/
|
|
302
|
+
var CoreBlocksAddon = class extends BaseAddon {
|
|
303
|
+
store = null;
|
|
304
|
+
transpiler = null;
|
|
305
|
+
typeDefs = null;
|
|
306
|
+
async onInitialize() {
|
|
307
|
+
const settingsStore = this.ctx.api?.settingsStore;
|
|
308
|
+
if (!settingsStore) throw new Error("core-blocks: settings-store API not available — refusing to register the cap");
|
|
309
|
+
await CoreBlockStore.declare(settingsStore);
|
|
310
|
+
this.store = new CoreBlockStore({
|
|
311
|
+
store: settingsStore,
|
|
312
|
+
logger: this.ctx.logger.child("store")
|
|
313
|
+
});
|
|
314
|
+
await this.store.load();
|
|
315
|
+
this.transpiler = await loadTranspiler(this.ctx.logger);
|
|
316
|
+
this.ctx.logger.info("core-blocks ready", { meta: {
|
|
317
|
+
blocks: this.store.list().length,
|
|
318
|
+
compile: this.transpiler !== null
|
|
319
|
+
} });
|
|
320
|
+
return [{
|
|
321
|
+
capability: coreBlocksCapability,
|
|
322
|
+
provider: this.buildProvider()
|
|
323
|
+
}];
|
|
324
|
+
}
|
|
325
|
+
async onShutdown() {
|
|
326
|
+
this.store = null;
|
|
327
|
+
this.transpiler = null;
|
|
328
|
+
this.typeDefs = null;
|
|
329
|
+
}
|
|
330
|
+
requireStore() {
|
|
331
|
+
if (this.store === null) throw new Error("core-blocks: not initialized");
|
|
332
|
+
return this.store;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Compile, or explain why not.
|
|
336
|
+
*
|
|
337
|
+
* A missing transpiler REFUSES the write rather than waving it through: code
|
|
338
|
+
* that reached disk uncompiled is code the runner will fail on, far from the
|
|
339
|
+
* person who wrote it.
|
|
340
|
+
*/
|
|
341
|
+
async gate(code) {
|
|
342
|
+
if (this.transpiler === null) throw new Error("core-blocks: the compiler is unavailable — refusing to store unchecked code");
|
|
343
|
+
const result = await compileBlock(this.transpiler, code);
|
|
344
|
+
if (!result.ok) {
|
|
345
|
+
const where = result.line !== void 0 ? ` (line ${result.line})` : "";
|
|
346
|
+
throw new Error(`core-blocks: the code does not compile${where}: ${result.error ?? "unknown"}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
buildProvider() {
|
|
350
|
+
return {
|
|
351
|
+
list: async () => ({ blocks: [...this.requireStore().list()] }),
|
|
352
|
+
get: async ({ blockId }) => ({ block: this.requireStore().get(blockId) }),
|
|
353
|
+
create: async ({ block, caller }) => {
|
|
354
|
+
await this.gate(block.code);
|
|
355
|
+
const created = await this.requireStore().create(block, caller.userId);
|
|
356
|
+
this.ctx.logger.info("core block created", { meta: {
|
|
357
|
+
blockId: created.id,
|
|
358
|
+
name: created.name,
|
|
359
|
+
by: caller.userId
|
|
360
|
+
} });
|
|
361
|
+
return { block: created };
|
|
362
|
+
},
|
|
363
|
+
update: async ({ blockId, block, caller }) => {
|
|
364
|
+
if (block.code !== void 0) await this.gate(block.code);
|
|
365
|
+
const updated = await this.requireStore().update(blockId, block);
|
|
366
|
+
this.ctx.logger.info("core block updated", { meta: {
|
|
367
|
+
blockId,
|
|
368
|
+
by: caller.userId
|
|
369
|
+
} });
|
|
370
|
+
return { block: updated };
|
|
371
|
+
},
|
|
372
|
+
delete: async ({ blockId }) => {
|
|
373
|
+
await this.requireStore().delete(blockId);
|
|
374
|
+
return { success: true };
|
|
375
|
+
},
|
|
376
|
+
setEnabled: async ({ blockId, enabled }) => {
|
|
377
|
+
return { block: await this.requireStore().update(blockId, { enabled }) };
|
|
378
|
+
},
|
|
379
|
+
compile: async ({ code }) => {
|
|
380
|
+
if (this.transpiler === null) return {
|
|
381
|
+
ok: false,
|
|
382
|
+
error: "the compiler is unavailable on this node"
|
|
383
|
+
};
|
|
384
|
+
const { js: _js, ...verdict } = await compileBlock(this.transpiler, code);
|
|
385
|
+
return verdict;
|
|
386
|
+
},
|
|
387
|
+
getTypeDefs: async () => {
|
|
388
|
+
this.typeDefs ??= await loadBlockTypeDefs(this.ctx.logger);
|
|
389
|
+
return { libs: this.typeDefs.map((l) => ({
|
|
390
|
+
filePath: l.filePath,
|
|
391
|
+
content: l.content
|
|
392
|
+
})) };
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
/** Load esbuild lazily. Returns null — never throws — so a node without it
|
|
398
|
+
* still boots, with the compile gate refusing writes rather than the node
|
|
399
|
+
* refusing to start. */
|
|
400
|
+
async function loadTranspiler(logger) {
|
|
401
|
+
try {
|
|
402
|
+
const transform = (await import("../../main-CzH19GkU.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).transform;
|
|
403
|
+
if (typeof transform !== "function") return null;
|
|
404
|
+
return { transform };
|
|
405
|
+
} catch (err) {
|
|
406
|
+
logger.warn("core-blocks: esbuild unavailable — code cannot be compiled on this node", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
//#endregion
|
|
411
|
+
export { CoreBlocksAddon, compileBlock as i, CORE_BLOCKS_COLLECTION as n, CoreBlockStore as r, loadBlockTypeDefs as t };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CoreBlocksAddon as default, CoreBlocksAddon } from './core-blocks.addon.js';
|
|
2
|
+
export { CoreBlockStore, CORE_BLOCKS_COLLECTION } from './core-block-store.js';
|
|
3
|
+
export { compileBlock, type BlockTranspiler } from './compile-block.js';
|
|
4
|
+
export { loadBlockTypeDefs, type BlockTypeLib } from './block-type-defs.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
require("../../chunk-Cek0wNdY.js");
|
|
6
|
+
const require_builtins_core_blocks_core_blocks_addon = require("./core-blocks.addon.js");
|
|
7
|
+
exports.CORE_BLOCKS_COLLECTION = require_builtins_core_blocks_core_blocks_addon.CORE_BLOCKS_COLLECTION;
|
|
8
|
+
exports.CoreBlockStore = require_builtins_core_blocks_core_blocks_addon.CoreBlockStore;
|
|
9
|
+
exports.CoreBlocksAddon = require_builtins_core_blocks_core_blocks_addon.CoreBlocksAddon;
|
|
10
|
+
exports.compileBlock = require_builtins_core_blocks_core_blocks_addon.compileBlock;
|
|
11
|
+
exports.default = require_builtins_core_blocks_core_blocks_addon.CoreBlocksAddon;
|
|
12
|
+
exports.loadBlockTypeDefs = require_builtins_core_blocks_core_blocks_addon.loadBlockTypeDefs;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CoreBlocksAddon, i as compileBlock, n as CORE_BLOCKS_COLLECTION, r as CoreBlockStore, t as loadBlockTypeDefs } from "./core-blocks.addon.mjs";
|
|
2
|
+
export { CORE_BLOCKS_COLLECTION, CoreBlockStore, CoreBlocksAddon, CoreBlocksAddon as default, compileBlock, loadBlockTypeDefs };
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
let _camstack_types_node = require("@camstack/types/node");
|
|
8
8
|
let zod = require("zod");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as enumerateSchemaFields, E as deviceStatusCapability, Et as isDeviceConfigCap, J as parseStreamParamsFormPatch, K as normalizeUnit, Nt as sleep, P as getByPath, Pt as EventCategory, Q as setByPath, T as deviceStateCapability, _t as WELL_KNOWN_TAB_MAP, a as CAP_NAMES_WITH_STATUS, ct as BaseAddon, ft as DeviceFeature, it as toExpressionValue, j as evaluateLinkExpression, k as enumerateItemArrayFields, mt as DeviceType, ot as validateExpressionSource, pt as DeviceRole, s as DeviceStatusSchema, st as errMsg, t as ALL_CAPABILITY_DEFINITIONS, u as STREAM_PROFILE_META, v as applyTransform, w as deviceManagerCapability, x as buildStreamParamsConfigSchema } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
import { canonicalDeviceFingerprint } from "@camstack/types/node";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
//#region src/builtins/doorbell/trigger-engine.ts
|
|
8
8
|
/**
|
|
9
9
|
* Pure trigger logic for the virtual-doorbell builtin — edge detection over
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as doorbellCapability, Pt as EventCategory, ct as BaseAddon, mt as DeviceType, st as errMsg, xt as createEvent } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
//#region src/builtins/doorbell/trigger-engine.ts
|
|
3
3
|
/**
|
|
4
4
|
* Pure trigger logic for the virtual-doorbell builtin — edge detection over
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
9
9
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as logDestinationCapability, ct as BaseAddon } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
4
4
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
4
4
|
//#region src/builtins/liveness-monitor/liveness-checks.ts
|
|
5
5
|
var NO_DEVICES = "liveness:no-devices";
|
|
6
6
|
var ALL_OFFLINE = "liveness:all-devices-offline";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Pt as EventCategory, ct as BaseAddon, st as errMsg, xt as createEvent } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
//#region src/builtins/liveness-monitor/liveness-checks.ts
|
|
3
3
|
var NO_DEVICES = "liveness:no-devices";
|
|
4
4
|
var ALL_OFFLINE = "liveness:all-devices-offline";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
let node_crypto = require("node:crypto");
|
|
8
8
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
9
9
|
let crypto$1 = require("crypto");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { at as userManagementCapability, ct as BaseAddon, d as ScopedTokenSchema, p as UserRecordSchema, r as ApiKeyRecordSchema, y as authProviderCapability } from "../../dist-DO76YVO2.mjs";
|
|
3
3
|
import * as crypto$1 from "node:crypto";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import nodeCrypto from "crypto";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
4
4
|
let node_os = require("node:os");
|
|
5
5
|
node_os = require_chunk.__toESM(node_os);
|
|
6
6
|
//#region src/builtins/local-network/local-network.addon.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Pt as EventCategory, V as localNetworkCapability, ct as BaseAddon } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
//#region src/builtins/local-network/local-network.addon.ts
|
|
4
4
|
/**
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
//#region src/builtins/loki-logging/loki-payload.ts
|
|
8
8
|
/**
|
|
9
9
|
* Loki rejects a label name that is not a valid Prometheus label
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as logDestinationCapability, ct as BaseAddon } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
//#region src/builtins/loki-logging/loki-payload.ts
|
|
3
3
|
/**
|
|
4
4
|
* Loki rejects a label name that is not a valid Prometheus label
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
9
9
|
let node_child_process = require("node:child_process");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as metricsProviderCapability, Pt as EventCategory, ct as BaseAddon, xt as createEvent } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import { execFile, execFileSync } from "node:child_process";
|
|
4
4
|
import { promisify } from "node:util";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
9
9
|
let node_child_process = require("node:child_process");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Ct as emitReadiness, O as enumerateInferenceDevices, Pt as EventCategory, Y as platformProbeCapability, Z as scoreRuntimes, ct as BaseAddon, st as errMsg } from "../../dist-DO76YVO2.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { promisify } from "node:util";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
//#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
|
|
8
8
|
/**
|
|
9
9
|
* Reconcile the durable `enabledProviders` set against authoritative
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Pt as EventCategory, ct as BaseAddon } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
//#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
|
|
3
3
|
/**
|
|
4
4
|
* Reconcile the durable `enabledProviders` set against authoritative
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
let node_child_process = require("node:child_process");
|
|
8
8
|
//#region src/builtins/snapshot/snapshot-coalescing.ts
|
|
9
9
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dt as nodePin, ct as BaseAddon, et as snapshotCapability, ft as DeviceFeature, i as BatteryStatusSchema, mt as DeviceType, rt as streamQualityLabel, st as errMsg } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
//#region src/builtins/snapshot/snapshot-coalescing.ts
|
|
4
4
|
/**
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CFinlH7b.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
9
9
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as filesystemBrowseCapability, ct as BaseAddon, nt as storageProviderCapability } from "../../dist-DO76YVO2.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { basename, dirname, join, resolve, sep } from "node:path";
|