@camstack/server 1.2.816 → 1.2.818
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/CHANGELOG.md +13 -0
- package/dist/api/core/cap-providers.js +2 -43
- package/dist/api/trpc/generated-cap-routers.js +14 -17
- package/dist/core/addon/addon-registry.service.js +3 -3
- package/dist/core/addon/instance-lifecycle.js +79 -4
- package/package.json +13 -9
- package/system/dist/{agent-https-pirjJaDw.js → agent-https-ChriyNA8.js} +1 -1
- package/system/dist/{agent-https-CK_B6QXQ.mjs → agent-https-rhOY61af.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +8 -4
- package/system/dist/builtins/camera-grid/index.mjs +8 -4
- package/system/dist/builtins/composer/composer.addon.js +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +1 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +357 -19
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +357 -19
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +5 -1
- package/system/dist/builtins/core-blocks/migrations/remote-config-migrations.d.ts +62 -0
- package/system/dist/builtins/core-blocks/remote-service.d.ts +2 -2
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +3 -3
- package/system/dist/builtins/loki-logging/index.mjs +3 -3
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +5 -14
- package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -75
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +35 -75
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +9 -32
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-9qCs6J2S.js → capture-engine-Cgt1r0h5.js} +1 -1
- package/system/dist/{capture-engine-MPu8CRiM.mjs → capture-engine-CoK1n1F1.mjs} +1 -1
- package/system/dist/{composition-sources-CAPpmqL0.mjs → composition-sources-DSU28FFP.mjs} +1 -1
- package/system/dist/{composition-sources-N-9OE7DA.js → composition-sources-TkHq8DdF.js} +1 -1
- package/system/dist/{constants-D75PEb9b.mjs → constants-CCezBXPq.mjs} +1 -1
- package/system/dist/{constants-o31-vUsL.js → constants-D3mNibfv.js} +1 -1
- package/system/dist/{device-ca-C3wqsnBw.js → device-ca-CEzeY_zI.js} +1 -1
- package/system/dist/{device-ca-D9C75-ee.mjs → device-ca-CjX1tQP7.mjs} +1 -1
- package/system/dist/{dist-DBoCrtvm.mjs → dist-BNBgsEk0.mjs} +39 -49
- package/system/dist/{dist-BmEptO1d.js → dist-DX1gyM8o.js} +44 -54
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-ho8U9Zs6.mjs → hub-mdns-ciao-BCfG7mv3.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-B8Lh4Gx1.js → hub-mdns-ciao-DBHvpWvv.js} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/{legacy-integration-rows-door-v-8WFbCS.js → legacy-integration-rows-door-7K4_MoAP.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-Cc47aOOP.mjs → legacy-integration-rows-door-C0X4Ijcr.mjs} +1 -1
- package/system/dist/migrations/hub/2026-11-08-storage-locations-write-set.d.ts +3 -0
- package/system/dist/{restore-archive-BYOda1Dl.js → restore-archive-DXlN0NYx.js} +1 -1
- package/system/dist/{restore-archive-DS-Hgq3V.mjs → restore-archive-WBDJlios.mjs} +82 -82
- package/system/dist/{wal-maintenance-DtqrYJN3.mjs → wal-maintenance-BJ0vDek1.mjs} +0 -0
- package/system/dist/{wal-maintenance-D5CHoEtS.js → wal-maintenance-BPmo2JzY.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $o as BaseAddon, gi as logDestinationCapability } from "../../dist-
|
|
1
|
+
import { $o as BaseAddon, gi as logDestinationCapability } from "../../dist-BNBgsEk0.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/console-logging/console-destination.ts
|
|
4
4
|
var LEVEL_RANK = {
|
|
@@ -91,6 +91,7 @@ export declare class CoreBlocksAddon extends BaseAddon {
|
|
|
91
91
|
* process, and the write is already durable.
|
|
92
92
|
*/
|
|
93
93
|
private convergeSoon;
|
|
94
|
+
private requireBlocksInstances;
|
|
94
95
|
private requireActions;
|
|
95
96
|
/**
|
|
96
97
|
* Remove the ledger rows whose block is gone. Armed, not awaited: it is
|
|
@@ -1,9 +1,9 @@
|
|
|
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-DX1gyM8o.js");
|
|
4
4
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
5
|
-
const require_composition_sources = require("../../composition-sources-
|
|
6
|
-
const require_capture_engine = require("../../capture-engine-
|
|
5
|
+
const require_composition_sources = require("../../composition-sources-TkHq8DdF.js");
|
|
6
|
+
const require_capture_engine = require("../../capture-engine-Cgt1r0h5.js");
|
|
7
7
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
8
8
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
9
9
|
let zod = require("zod");
|
|
@@ -2428,6 +2428,279 @@ async function splitPumpCycleFromFountain(ports) {
|
|
|
2428
2428
|
};
|
|
2429
2429
|
}
|
|
2430
2430
|
//#endregion
|
|
2431
|
+
//#region src/builtins/core-blocks/migrations/remote-config-migrations.ts
|
|
2432
|
+
/**
|
|
2433
|
+
* Two shape changes of a stored remote, both owned by core-blocks (it owns the
|
|
2434
|
+
* `remote` key of the per-device store and the `templates` kind).
|
|
2435
|
+
*
|
|
2436
|
+
* 1. `power: { mode }` leaves the configuration. What a Power key and an
|
|
2437
|
+
* explicit on / off do is derived from the bindings now; the stored field is
|
|
2438
|
+
* dropped and nothing else in the config is touched.
|
|
2439
|
+
* 2. The four colour keys have ONE set of roles. A remote that bound
|
|
2440
|
+
* `custom:color_a..d` (Samsung's lettering) is renamed to
|
|
2441
|
+
* `custom:color_red|green|yellow|blue` in its bindings, its custom buttons and
|
|
2442
|
+
* the steps of its sequence sources; a stored layout's button with such a role
|
|
2443
|
+
* takes the matching tone and keeps its letter on the key (`showLegend`).
|
|
2444
|
+
*
|
|
2445
|
+
* The stored value is read as loosely typed JSON on purpose: it is the OLD shape,
|
|
2446
|
+
* which `RemoteConfigSchema` no longer describes. Every key this migration does
|
|
2447
|
+
* not name is written back exactly as it was, and a rerun finds nothing to do.
|
|
2448
|
+
*/
|
|
2449
|
+
var REMOTE_POWER_DROP_ID = "core-blocks/2026-11-09-remote-power-mode-drop";
|
|
2450
|
+
var REMOTE_COLOUR_ROLES_ID = "core-blocks/2026-11-09-remote-colour-roles";
|
|
2451
|
+
/** The key of the per-device store that holds the remote (`REMOTE_STORE_KEY` of remote-wiring). */
|
|
2452
|
+
var STORE_KEY = "remote";
|
|
2453
|
+
function remoteMigrationPortsOver(stores, templates, logger) {
|
|
2454
|
+
return {
|
|
2455
|
+
listStoredRemotes: async () => {
|
|
2456
|
+
const ids = await stores.listDeviceStoreIds();
|
|
2457
|
+
if (ids.length === 0) return [];
|
|
2458
|
+
const batch = await stores.readDeviceStoreBatch(ids);
|
|
2459
|
+
return ids.flatMap((deviceId) => {
|
|
2460
|
+
const raw = batch.get(deviceId)?.[STORE_KEY];
|
|
2461
|
+
return raw === void 0 ? [] : [{
|
|
2462
|
+
deviceId,
|
|
2463
|
+
raw
|
|
2464
|
+
}];
|
|
2465
|
+
});
|
|
2466
|
+
},
|
|
2467
|
+
replaceStoredRemote: async (deviceId, raw) => {
|
|
2468
|
+
await stores.writeDeviceStore(deviceId, { [STORE_KEY]: raw });
|
|
2469
|
+
logger.info("remote migration: a stored remote was rewritten", { tags: { deviceId } });
|
|
2470
|
+
},
|
|
2471
|
+
listTemplateRows: async () => {
|
|
2472
|
+
return (await (0, import_read_all_rows.readAllRows)(templates)).map((row) => ({
|
|
2473
|
+
id: row.id,
|
|
2474
|
+
rev: row.rev,
|
|
2475
|
+
data: row.data
|
|
2476
|
+
}));
|
|
2477
|
+
},
|
|
2478
|
+
replaceTemplateRow: async (id, data, ifRev) => {
|
|
2479
|
+
await templates.put({
|
|
2480
|
+
id,
|
|
2481
|
+
data
|
|
2482
|
+
}, { ifRev });
|
|
2483
|
+
},
|
|
2484
|
+
warnCollision: (deviceId, keys) => {
|
|
2485
|
+
logger.warn(`remote migration: ${keys.join(", ")} had a code and so did its colour role; the lettered one is kept as <key>_kept`, { tags: { deviceId } });
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
var StoredRemoteSchema = zod.z.looseObject({
|
|
2490
|
+
bindings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
2491
|
+
customButtons: zod.z.array(zod.z.looseObject({ key: zod.z.string() })).optional(),
|
|
2492
|
+
sources: zod.z.array(zod.z.unknown()).optional()
|
|
2493
|
+
});
|
|
2494
|
+
var StoredSequenceSchema = zod.z.looseObject({
|
|
2495
|
+
kind: zod.z.literal("sequence"),
|
|
2496
|
+
steps: zod.z.array(zod.z.string())
|
|
2497
|
+
});
|
|
2498
|
+
/** Samsung's lettered keys and the colour each one always was. */
|
|
2499
|
+
var LETTER_TO_COLOUR = {
|
|
2500
|
+
color_a: "red",
|
|
2501
|
+
color_b: "green",
|
|
2502
|
+
color_c: "yellow",
|
|
2503
|
+
color_d: "blue"
|
|
2504
|
+
};
|
|
2505
|
+
var LETTER_OF_KEY = {
|
|
2506
|
+
color_a: "A",
|
|
2507
|
+
color_b: "B",
|
|
2508
|
+
color_c: "C",
|
|
2509
|
+
color_d: "D"
|
|
2510
|
+
};
|
|
2511
|
+
var CUSTOM = "custom:";
|
|
2512
|
+
function newKeyOf(key) {
|
|
2513
|
+
const colour = LETTER_TO_COLOUR[key];
|
|
2514
|
+
return colour === void 0 ? null : `color_${colour}`;
|
|
2515
|
+
}
|
|
2516
|
+
function withoutKeys(record, drop) {
|
|
2517
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => !drop.has(key)));
|
|
2518
|
+
}
|
|
2519
|
+
/** The remote without `power`, or null when it never had it. */
|
|
2520
|
+
function withoutPowerMode(raw) {
|
|
2521
|
+
const parsed = StoredRemoteSchema.safeParse(raw);
|
|
2522
|
+
if (!parsed.success || !("power" in parsed.data)) return null;
|
|
2523
|
+
return withoutKeys(parsed.data, new Set(["power"]));
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* The lettered keys of a remote that already has the colour role of the same colour:
|
|
2527
|
+
* both carry a code, so the lettered one is kept under a fresh key instead of
|
|
2528
|
+
* being dropped.
|
|
2529
|
+
*/
|
|
2530
|
+
function collidingKeys(remote) {
|
|
2531
|
+
const bound = new Set(Object.keys(remote.bindings ?? {}));
|
|
2532
|
+
const buttons = new Set((remote.customButtons ?? []).map((b) => b.key));
|
|
2533
|
+
const out = /* @__PURE__ */ new Set();
|
|
2534
|
+
for (const key of Object.keys(LETTER_TO_COLOUR)) {
|
|
2535
|
+
const target = newKeyOf(key);
|
|
2536
|
+
if (target === null) continue;
|
|
2537
|
+
const hasOld = bound.has(`${CUSTOM}${key}`) || buttons.has(key);
|
|
2538
|
+
const hasNew = bound.has(`${CUSTOM}${target}`) || buttons.has(target);
|
|
2539
|
+
if (hasOld && hasNew) out.add(key);
|
|
2540
|
+
}
|
|
2541
|
+
return out;
|
|
2542
|
+
}
|
|
2543
|
+
/** Where a lettered key goes: its colour key, or `<key>_kept` when the colour key is taken. */
|
|
2544
|
+
function keyAfter(key, kept) {
|
|
2545
|
+
if (kept.has(key)) return `${key}_kept`;
|
|
2546
|
+
return newKeyOf(key);
|
|
2547
|
+
}
|
|
2548
|
+
function roleAfter(role, kept) {
|
|
2549
|
+
if (!role.startsWith(CUSTOM)) return null;
|
|
2550
|
+
const key = keyAfter(role.slice(7), kept);
|
|
2551
|
+
return key === null ? null : `${CUSTOM}${key}`;
|
|
2552
|
+
}
|
|
2553
|
+
function renameBindings(bindings, kept) {
|
|
2554
|
+
let changed = false;
|
|
2555
|
+
const out = {};
|
|
2556
|
+
for (const [role, binding] of Object.entries(bindings)) {
|
|
2557
|
+
const next = roleAfter(role, kept);
|
|
2558
|
+
if (next === null) {
|
|
2559
|
+
out[role] = binding;
|
|
2560
|
+
continue;
|
|
2561
|
+
}
|
|
2562
|
+
changed = true;
|
|
2563
|
+
out[next] = binding;
|
|
2564
|
+
}
|
|
2565
|
+
return changed ? out : null;
|
|
2566
|
+
}
|
|
2567
|
+
function renameCustomButtons(buttons, kept) {
|
|
2568
|
+
const keys = new Set(buttons.map((b) => b.key));
|
|
2569
|
+
let changed = false;
|
|
2570
|
+
const out = [];
|
|
2571
|
+
for (const button of buttons) {
|
|
2572
|
+
const next = keyAfter(button.key, kept);
|
|
2573
|
+
if (next === null) {
|
|
2574
|
+
out.push(button);
|
|
2575
|
+
continue;
|
|
2576
|
+
}
|
|
2577
|
+
changed = true;
|
|
2578
|
+
if (!keys.has(next) || kept.has(button.key)) out.push({
|
|
2579
|
+
...button,
|
|
2580
|
+
key: next
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
return changed ? out : null;
|
|
2584
|
+
}
|
|
2585
|
+
function renameSourceSteps(sources, kept) {
|
|
2586
|
+
let changed = false;
|
|
2587
|
+
const out = sources.map((source) => {
|
|
2588
|
+
const sequence = StoredSequenceSchema.safeParse(source);
|
|
2589
|
+
if (!sequence.success) return source;
|
|
2590
|
+
const steps = sequence.data.steps.map((step) => roleAfter(step, kept) ?? step);
|
|
2591
|
+
if (steps.every((step, i) => step === sequence.data.steps[i])) return source;
|
|
2592
|
+
changed = true;
|
|
2593
|
+
return {
|
|
2594
|
+
...sequence.data,
|
|
2595
|
+
steps
|
|
2596
|
+
};
|
|
2597
|
+
});
|
|
2598
|
+
return changed ? out : null;
|
|
2599
|
+
}
|
|
2600
|
+
/** The remote with the colour roles renamed, or null when it binds none of the lettered ones. */
|
|
2601
|
+
function withColourRoles(raw) {
|
|
2602
|
+
const parsed = StoredRemoteSchema.safeParse(raw);
|
|
2603
|
+
if (!parsed.success) return null;
|
|
2604
|
+
const kept = collidingKeys(parsed.data);
|
|
2605
|
+
const bindings = parsed.data.bindings === void 0 ? null : renameBindings(parsed.data.bindings, kept);
|
|
2606
|
+
const customButtons = parsed.data.customButtons === void 0 ? null : renameCustomButtons(parsed.data.customButtons, kept);
|
|
2607
|
+
const sources = parsed.data.sources === void 0 ? null : renameSourceSteps(parsed.data.sources, kept);
|
|
2608
|
+
if (bindings === null && customButtons === null && sources === null) return null;
|
|
2609
|
+
return {
|
|
2610
|
+
remote: {
|
|
2611
|
+
...parsed.data,
|
|
2612
|
+
...bindings === null ? {} : { bindings },
|
|
2613
|
+
...customButtons === null ? {} : { customButtons },
|
|
2614
|
+
...sources === null ? {} : { sources }
|
|
2615
|
+
},
|
|
2616
|
+
collisions: [...kept]
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
function recolouredButton(button) {
|
|
2620
|
+
if (!button.role.startsWith(CUSTOM)) return null;
|
|
2621
|
+
const oldKey = button.role.slice(7);
|
|
2622
|
+
const colour = LETTER_TO_COLOUR[oldKey];
|
|
2623
|
+
const role = roleAfter(button.role, /* @__PURE__ */ new Set());
|
|
2624
|
+
if (colour === void 0 || role === null) return null;
|
|
2625
|
+
return {
|
|
2626
|
+
...button,
|
|
2627
|
+
role,
|
|
2628
|
+
tone: colour,
|
|
2629
|
+
label: button.label ?? LETTER_OF_KEY[oldKey] ?? colour,
|
|
2630
|
+
showLegend: true
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
/** The layout with its lettered colour keys on the colour roles, or null when it has none. */
|
|
2634
|
+
function withColourButtons(payload) {
|
|
2635
|
+
const parsed = require_dist.RemoteLayoutPayloadSchema.safeParse(payload);
|
|
2636
|
+
if (!parsed.success) return null;
|
|
2637
|
+
let changed = false;
|
|
2638
|
+
const buttons = parsed.data.buttons.map((button) => {
|
|
2639
|
+
const next = recolouredButton(button);
|
|
2640
|
+
if (next === null) return button;
|
|
2641
|
+
changed = true;
|
|
2642
|
+
return next;
|
|
2643
|
+
});
|
|
2644
|
+
return changed ? {
|
|
2645
|
+
...parsed.data,
|
|
2646
|
+
buttons
|
|
2647
|
+
} : null;
|
|
2648
|
+
}
|
|
2649
|
+
async function dropRemotePowerMode(ports) {
|
|
2650
|
+
const remotes = await ports.listStoredRemotes();
|
|
2651
|
+
let devices = 0;
|
|
2652
|
+
for (const { deviceId, raw } of remotes) {
|
|
2653
|
+
const next = withoutPowerMode(raw);
|
|
2654
|
+
if (next === null) continue;
|
|
2655
|
+
await ports.replaceStoredRemote(deviceId, next);
|
|
2656
|
+
devices += 1;
|
|
2657
|
+
}
|
|
2658
|
+
return devices === 0 ? {
|
|
2659
|
+
outcome: "already-done",
|
|
2660
|
+
summary: { devices: 0 }
|
|
2661
|
+
} : {
|
|
2662
|
+
outcome: "done",
|
|
2663
|
+
summary: { devices }
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
async function renameRemoteColourRoles(ports) {
|
|
2667
|
+
const remotes = await ports.listStoredRemotes();
|
|
2668
|
+
let devices = 0;
|
|
2669
|
+
for (const { deviceId, raw } of remotes) {
|
|
2670
|
+
const next = withColourRoles(raw);
|
|
2671
|
+
if (next === null) continue;
|
|
2672
|
+
if (next.collisions.length > 0) ports.warnCollision(deviceId, next.collisions);
|
|
2673
|
+
await ports.replaceStoredRemote(deviceId, next.remote);
|
|
2674
|
+
devices += 1;
|
|
2675
|
+
}
|
|
2676
|
+
let templates = 0;
|
|
2677
|
+
for (const row of await ports.listTemplateRows()) {
|
|
2678
|
+
if (row.data.kind !== "remote") continue;
|
|
2679
|
+
const payload = withColourButtons(row.data.payload);
|
|
2680
|
+
if (payload === null) continue;
|
|
2681
|
+
const updatedAt = Math.max(row.data.updatedAt + 1, ports.now());
|
|
2682
|
+
await ports.replaceTemplateRow(row.id, {
|
|
2683
|
+
...row.data,
|
|
2684
|
+
payload,
|
|
2685
|
+
updatedAt
|
|
2686
|
+
}, row.rev);
|
|
2687
|
+
templates += 1;
|
|
2688
|
+
}
|
|
2689
|
+
return devices === 0 && templates === 0 ? {
|
|
2690
|
+
outcome: "already-done",
|
|
2691
|
+
summary: {
|
|
2692
|
+
devices: 0,
|
|
2693
|
+
templates: 0
|
|
2694
|
+
}
|
|
2695
|
+
} : {
|
|
2696
|
+
outcome: "done",
|
|
2697
|
+
summary: {
|
|
2698
|
+
devices,
|
|
2699
|
+
templates
|
|
2700
|
+
}
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
//#endregion
|
|
2431
2704
|
//#region src/builtins/core-blocks/migrations/index.ts
|
|
2432
2705
|
/** The `core-blocks` catalogue (D987): offered to the engine when the hub-resident addon initialises. */
|
|
2433
2706
|
var ADDON_MIGRATIONS = [
|
|
@@ -2478,6 +2751,38 @@ var ADDON_MIGRATIONS = [
|
|
|
2478
2751
|
fixtureMark: "the block createdBy and name, which the migration does not know"
|
|
2479
2752
|
},
|
|
2480
2753
|
procedure: dropFountainDrinkCounters
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
meta: {
|
|
2757
|
+
id: REMOTE_POWER_DROP_ID,
|
|
2758
|
+
owner: "core-blocks",
|
|
2759
|
+
level: "addon-state",
|
|
2760
|
+
seq: 4,
|
|
2761
|
+
dependsOn: [],
|
|
2762
|
+
store: "settings",
|
|
2763
|
+
scope: "cluster",
|
|
2764
|
+
onFailure: "tolerate",
|
|
2765
|
+
bodyKind: "procedure",
|
|
2766
|
+
description: "Drop the stored power mode (toggle or discrete) from each remote configuration: the Power key and an explicit on / off now follow the bindings",
|
|
2767
|
+
fixtureMark: "the default transmitter and a source name of each remote, which the migration does not know"
|
|
2768
|
+
},
|
|
2769
|
+
procedure: dropRemotePowerMode
|
|
2770
|
+
},
|
|
2771
|
+
{
|
|
2772
|
+
meta: {
|
|
2773
|
+
id: REMOTE_COLOUR_ROLES_ID,
|
|
2774
|
+
owner: "core-blocks",
|
|
2775
|
+
level: "addon-state",
|
|
2776
|
+
seq: 5,
|
|
2777
|
+
dependsOn: [],
|
|
2778
|
+
store: "settings",
|
|
2779
|
+
scope: "cluster",
|
|
2780
|
+
onFailure: "tolerate",
|
|
2781
|
+
bodyKind: "procedure",
|
|
2782
|
+
description: "Rename the lettered colour keys custom:color_a..d to the colour roles custom:color_red..blue in each remote (bindings, custom buttons, sequence sources) and in each stored layout, which keeps the letter on a coloured key",
|
|
2783
|
+
fixtureMark: "the binding action of each lettered key and the label of each layout button"
|
|
2784
|
+
},
|
|
2785
|
+
procedure: renameRemoteColourRoles
|
|
2481
2786
|
}
|
|
2482
2787
|
];
|
|
2483
2788
|
//#endregion
|
|
@@ -5772,7 +6077,7 @@ function remoteCallRedirect(deps) {
|
|
|
5772
6077
|
/**
|
|
5773
6078
|
* The `remote` cap (D963, D964): a button panel over a media-player device. It
|
|
5774
6079
|
* keeps the per-device configuration (layout template, role bindings, custom
|
|
5775
|
-
* buttons
|
|
6080
|
+
* buttons) in the device's settings store and runs a bound ROLE by
|
|
5776
6081
|
* calling the action it is bound to — the shape an Action step has, so an
|
|
5777
6082
|
* infrared code and a smart-TV call are the same thing here.
|
|
5778
6083
|
*
|
|
@@ -5879,7 +6184,6 @@ var RemoteService = class {
|
|
|
5879
6184
|
});
|
|
5880
6185
|
return {
|
|
5881
6186
|
layoutTemplateId: config.layoutTemplateId,
|
|
5882
|
-
power: config.power,
|
|
5883
6187
|
commands,
|
|
5884
6188
|
sources: config.sources
|
|
5885
6189
|
};
|
|
@@ -6035,10 +6339,10 @@ var RemoteService = class {
|
|
|
6035
6339
|
for (const role of rolesFor(input.command)) if (this.isBound(config, role)) return role;
|
|
6036
6340
|
return null;
|
|
6037
6341
|
}
|
|
6038
|
-
/** A role is reachable when bound, or when a
|
|
6342
|
+
/** A role is reachable when bound, or when a bound `power` stands for `power_on` / `power_off`. */
|
|
6039
6343
|
isBound(config, role) {
|
|
6040
6344
|
if (config.bindings[role] !== void 0) return true;
|
|
6041
|
-
return (role === "power_on" || role === "power_off") && config.
|
|
6345
|
+
return (role === "power_on" || role === "power_off") && config.bindings["power"] !== void 0;
|
|
6042
6346
|
}
|
|
6043
6347
|
async currentState(deviceId) {
|
|
6044
6348
|
const running = await this.deps.runningState(deviceId);
|
|
@@ -6217,7 +6521,7 @@ var RemoteService = class {
|
|
|
6217
6521
|
* An `ir` source presses nothing: its own code goes out once (planning#464).
|
|
6218
6522
|
*/
|
|
6219
6523
|
async runSource(deviceId, config, source) {
|
|
6220
|
-
if (source.kind === "ir") return this.runIrSource(deviceId, source);
|
|
6524
|
+
if (source.kind === "ir") return this.runIrSource(deviceId, config, source);
|
|
6221
6525
|
const steps = require_dist.remoteSourceSteps(source);
|
|
6222
6526
|
const missing = steps.findIndex((role) => !this.isBound(config, role));
|
|
6223
6527
|
if (missing >= 0) {
|
|
@@ -6301,12 +6605,24 @@ var RemoteService = class {
|
|
|
6301
6605
|
});
|
|
6302
6606
|
}
|
|
6303
6607
|
/** One train through the source's own transmitter; the source is remembered only after it landed. */
|
|
6304
|
-
async runIrSource(deviceId, source) {
|
|
6608
|
+
async runIrSource(deviceId, config, source) {
|
|
6609
|
+
const transmitterId = source.transmitterId ?? config.defaultTransmitterId;
|
|
6610
|
+
if (transmitterId === null) {
|
|
6611
|
+
this.deps.logger.warn("remote: an infrared source has no emitter, nothing was sent", {
|
|
6612
|
+
tags: { deviceId },
|
|
6613
|
+
meta: { source: source.name }
|
|
6614
|
+
});
|
|
6615
|
+
return {
|
|
6616
|
+
status: "refused",
|
|
6617
|
+
reason: "no-transmitter",
|
|
6618
|
+
detail: `"${source.name}" names no emitter and the remote has no default one`
|
|
6619
|
+
};
|
|
6620
|
+
}
|
|
6305
6621
|
return this.withLock(deviceId, async () => {
|
|
6306
6622
|
const { timings, settings } = require_dist.toTimings(source.payload);
|
|
6307
6623
|
try {
|
|
6308
6624
|
await this.deps.invoke({
|
|
6309
|
-
deviceId:
|
|
6625
|
+
deviceId: transmitterId,
|
|
6310
6626
|
cap: IR_TRANSMITTER_CAP,
|
|
6311
6627
|
method: IR_SEND_METHOD,
|
|
6312
6628
|
args: {
|
|
@@ -6319,7 +6635,7 @@ var RemoteService = class {
|
|
|
6319
6635
|
tags: { deviceId },
|
|
6320
6636
|
meta: {
|
|
6321
6637
|
source: source.name,
|
|
6322
|
-
transmitterId
|
|
6638
|
+
transmitterId,
|
|
6323
6639
|
error: errorText(err)
|
|
6324
6640
|
}
|
|
6325
6641
|
});
|
|
@@ -6352,10 +6668,15 @@ var RemoteService = class {
|
|
|
6352
6668
|
});
|
|
6353
6669
|
}
|
|
6354
6670
|
async runRole(deviceId, config, role, repeat) {
|
|
6671
|
+
const explicit = config.bindings["power_on"] !== void 0 && config.bindings["power_off"] !== void 0;
|
|
6672
|
+
if (role === "power" && config.bindings["power"] === void 0 && explicit) {
|
|
6673
|
+
const now = await this.currentState(deviceId);
|
|
6674
|
+
return this.runRole(deviceId, config, now === "on" ? "power_off" : "power_on", repeat);
|
|
6675
|
+
}
|
|
6355
6676
|
const wantsState = role === "power_on" ? "on" : role === "power_off" ? "off" : null;
|
|
6356
|
-
const viaToggle = wantsState !== null && config.bindings[
|
|
6677
|
+
const viaToggle = wantsState !== null && !explicit && config.bindings["power"] !== void 0;
|
|
6357
6678
|
const bound = viaToggle ? config.bindings["power"] : config.bindings[role];
|
|
6358
|
-
if (bound === void 0
|
|
6679
|
+
if (bound === void 0) return {
|
|
6359
6680
|
status: "refused",
|
|
6360
6681
|
reason: "unbound-role",
|
|
6361
6682
|
detail: `${role} is not bound`
|
|
@@ -8234,6 +8555,12 @@ async function extractSettingsSchema(js) {
|
|
|
8234
8555
|
var CONVERGE_INTERVAL_MS = 15e3;
|
|
8235
8556
|
/** Where block packages are materialised, under this node's data root. */
|
|
8236
8557
|
var BLOCK_PACKAGE_DIRNAME = "core-blocks";
|
|
8558
|
+
/** A node without the per-device settings store cannot read a stored remote: the migration fails loudly rather than record itself as done. */
|
|
8559
|
+
var NO_DEVICE_STORES = {
|
|
8560
|
+
listDeviceStoreIds: () => Promise.reject(/* @__PURE__ */ new Error("core-blocks: no per-device settings store")),
|
|
8561
|
+
readDeviceStoreBatch: () => Promise.reject(/* @__PURE__ */ new Error("core-blocks: no per-device settings store")),
|
|
8562
|
+
writeDeviceStore: () => Promise.reject(/* @__PURE__ */ new Error("core-blocks: no per-device settings store"))
|
|
8563
|
+
};
|
|
8237
8564
|
var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
8238
8565
|
/**
|
|
8239
8566
|
* `super({})` is NOT optional, and its absence is invisible until runtime:
|
|
@@ -8277,7 +8604,10 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
8277
8604
|
await records.declare(coreBlocksRecordKinds);
|
|
8278
8605
|
await records.declare(blocksInstanceRecordKinds);
|
|
8279
8606
|
this.blocksInstances = buildBlocksInstances(records);
|
|
8280
|
-
await this.runMigrations(require_dist.defineAddonMigrations(ADDON_MIGRATIONS,
|
|
8607
|
+
await this.runMigrations(require_dist.defineAddonMigrations(ADDON_MIGRATIONS, {
|
|
8608
|
+
...coreBlocksMigrationPorts(records.kind(coreBlocksRecordKinds.blocks), this.ctx.logger.child("migrations"), () => Date.now()),
|
|
8609
|
+
...remoteMigrationPortsOver(this.ctx.settings ?? NO_DEVICE_STORES, records.kind(coreBlocksRecordKinds.templates), this.ctx.logger.child("migrations"))
|
|
8610
|
+
}));
|
|
8281
8611
|
this.store = CoreBlockStore.of(records, this.ctx.logger.child("store"));
|
|
8282
8612
|
this.prefs = new BlockSettingsStore({
|
|
8283
8613
|
store: settingsStore,
|
|
@@ -8343,10 +8673,10 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
8343
8673
|
capability: require_dist.coreBlocksCapability,
|
|
8344
8674
|
provider: this.buildProvider()
|
|
8345
8675
|
},
|
|
8346
|
-
|
|
8676
|
+
{
|
|
8347
8677
|
capability: require_dist.integrationInstancesCapability,
|
|
8348
|
-
provider: this.
|
|
8349
|
-
}
|
|
8678
|
+
provider: this.requireBlocksInstances().toProvider()
|
|
8679
|
+
},
|
|
8350
8680
|
{
|
|
8351
8681
|
capability: require_dist.actionsCapability,
|
|
8352
8682
|
provider: this.requireActions().service
|
|
@@ -8678,7 +9008,11 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
8678
9008
|
devices: this.ctx.kernel.devices,
|
|
8679
9009
|
localNodeId: this.ctx.kernel.localNodeId,
|
|
8680
9010
|
getIntegration: async (addonId) => api.integrations.getByAddonId.query({ addonId }),
|
|
8681
|
-
createIntegration: async (input) => api.
|
|
9011
|
+
createIntegration: async (input) => api.integrationInstances.createInstance.mutate({
|
|
9012
|
+
addonId: input.addonId,
|
|
9013
|
+
name: input.name,
|
|
9014
|
+
seed: { info: input.info }
|
|
9015
|
+
}),
|
|
8682
9016
|
updateIntegration: async ({ id, info }) => {
|
|
8683
9017
|
await api.integrations.update.mutate({
|
|
8684
9018
|
id,
|
|
@@ -8688,7 +9022,7 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
8688
9022
|
},
|
|
8689
9023
|
listOwnDevices: async () => api.deviceManager.listAll.query({ addonId: require_dist.CORE_BLOCKS_ADDON_ID }),
|
|
8690
9024
|
seedInstance: async (seed) => {
|
|
8691
|
-
|
|
9025
|
+
await require_dist.seedInstanceOnce(this.requireBlocksInstances().toProvider(), seed);
|
|
8692
9026
|
}
|
|
8693
9027
|
});
|
|
8694
9028
|
}
|
|
@@ -8703,6 +9037,10 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
8703
9037
|
convergeSoon() {
|
|
8704
9038
|
this.supervisor?.converge();
|
|
8705
9039
|
}
|
|
9040
|
+
requireBlocksInstances() {
|
|
9041
|
+
if (this.blocksInstances === null) throw new Error("core-blocks: not initialized");
|
|
9042
|
+
return this.blocksInstances;
|
|
9043
|
+
}
|
|
8706
9044
|
requireActions() {
|
|
8707
9045
|
if (this.actions === null) throw new Error("core-blocks: not initialized");
|
|
8708
9046
|
return this.actions;
|