@camstack/system 1.2.443 → 1.2.445
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/assets/record-entries/icon.svg +8 -0
- package/dist/addon-runner.js +81 -42
- package/dist/addon-runner.mjs +82 -43
- package/dist/{agent-https-DlpTMDqA.js → agent-https-CiOW0-sj.js} +810 -12
- package/dist/{agent-https-U0d4uvn2.mjs → agent-https-D4Q8iFNd.mjs} +697 -13
- package/dist/auth/admin-token-manager.d.ts +9 -3
- package/dist/auth/api-key-manager.d.ts +9 -3
- package/dist/auth/auth-audit-log.d.ts +9 -3
- package/dist/auth/device-credential-manager.d.ts +5 -1
- package/dist/auth/external-identity-manager.d.ts +8 -21
- package/dist/auth/login-session-manager.d.ts +11 -3
- package/dist/auth/scoped-token-manager.d.ts +8 -52
- package/dist/auth/totp-manager.d.ts +11 -3
- package/dist/auth/user-manager.d.ts +10 -17
- 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/alert-store.d.ts +32 -0
- package/dist/builtins/alerts/alerts.addon.d.ts +19 -4
- package/dist/builtins/alerts/alerts.addon.js +331 -159
- package/dist/builtins/alerts/alerts.addon.mjs +330 -159
- package/dist/builtins/alerts/record-kinds.d.ts +15 -0
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +1 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +134 -193
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +134 -193
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/record-kinds.d.ts +58 -0
- package/dist/builtins/backup-orchestrator/schedule-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +4 -2
- package/dist/builtins/calendars/calendar-prefs-store.d.ts +13 -5
- package/dist/builtins/calendars/calendars.addon.d.ts +2 -2
- package/dist/builtins/calendars/calendars.addon.js +67 -64
- package/dist/builtins/calendars/calendars.addon.mjs +59 -64
- package/dist/builtins/calendars/record-kinds.d.ts +18 -0
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/cluster-agent/record-kinds.d.ts +36 -0
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/block-settings-store.d.ts +8 -4
- package/dist/builtins/core-blocks/core-block-store.d.ts +8 -16
- package/dist/builtins/core-blocks/core-blocks.addon.js +85 -112
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +86 -113
- package/dist/builtins/core-blocks/index.mjs +1 -1
- package/dist/builtins/core-blocks/record-kinds.d.ts +26 -0
- package/dist/builtins/device-manager/device-manager.addon.js +111 -187
- package/dist/builtins/device-manager/device-manager.addon.mjs +110 -187
- package/dist/builtins/device-manager/device-tombstone-store.d.ts +9 -48
- package/dist/builtins/device-manager/record-kinds.d.ts +14 -0
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +152 -22
- package/dist/builtins/keychain/index.mjs +152 -22
- package/dist/builtins/keychain/keychain-service.d.ts +3 -2
- package/dist/builtins/keychain/keychain-store.d.ts +13 -2
- package/dist/builtins/keychain/record-kinds.d.ts +16 -0
- 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/auth-schema.d.ts +3 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2903 -2123
- package/dist/builtins/local-auth/local-auth.addon.mjs +2904 -2124
- package/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -48
- package/dist/builtins/local-auth/record-kinds.d.ts +141 -0
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- 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/record-entries/entries-service.d.ts +42 -0
- package/dist/builtins/record-entries/index.d.ts +1 -0
- package/dist/builtins/record-entries/index.js +142 -0
- package/dist/builtins/record-entries/index.mjs +136 -0
- package/dist/builtins/record-entries/record-entries.addon.d.ts +13 -0
- package/dist/builtins/records/legacy-table-row-count.d.ts +5 -0
- package/dist/builtins/records/phase6-declare-gate.d.ts +28 -0
- package/dist/builtins/records-isolated.d.ts +10 -0
- 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/file-host-client.d.ts +2 -0
- package/dist/builtins/sqlite-storage/file-host-handlers.d.ts +4 -0
- package/dist/builtins/sqlite-storage/file-host-protocol.d.ts +7 -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/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +30 -0
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +10 -16
- package/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +7 -0
- package/dist/builtins/sqlite-storage/placement-router.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +6 -0
- package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +29 -0
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +51 -0
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +94 -0
- package/dist/builtins/sqlite-storage/records/records-explain.d.ts +18 -0
- package/dist/builtins/sqlite-storage/records/records-plan.d.ts +90 -0
- package/dist/builtins/sqlite-storage/records/records-probe.d.ts +33 -0
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +63 -0
- package/dist/builtins/sqlite-storage/records/records-rows.d.ts +46 -0
- package/dist/builtins/sqlite-storage/records/records-sql.d.ts +41 -0
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +17 -10
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +8 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +446 -5
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +446 -5
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +15 -1
- package/dist/builtins/storage-orchestrator/drain-state-store.d.ts +5 -2
- package/dist/builtins/storage-orchestrator/location-store.d.ts +7 -2
- package/dist/builtins/storage-orchestrator/record-kinds.d.ts +38 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +196 -5
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +195 -6
- package/dist/builtins/system-config/record-kinds.d.ts +32 -0
- package/dist/builtins/system-config/system-config.addon.js +53 -618
- package/dist/builtins/system-config/system-config.addon.mjs +29 -577
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-C8tUG2uL.mjs → composition-sources-BMt5cFYb.mjs} +1 -1
- package/dist/{composition-sources-BUXX1e8j.js → composition-sources-D3fi9Xns.js} +1 -1
- package/dist/{constants-CGwVaAV3.mjs → constants-BMHCxRzb.mjs} +1 -1
- package/dist/{constants-DWmm7_of.js → constants-Br879Axi.js} +1 -1
- package/dist/{device-ca-DGayRmC0.js → device-ca-CnJ_va7i.js} +1 -1
- package/dist/{device-ca-DBfiJ_SB.mjs → device-ca-T8osSMos.mjs} +1 -1
- package/dist/{dist-Bxt_S-9a.mjs → dist-BNunRyXT.mjs} +1133 -93
- package/dist/{dist-D9qT3jHr.js → dist-DgOG8flk.js} +1354 -92
- package/dist/file-host-worker.js +11 -1
- package/dist/file-host-worker.mjs +11 -1
- package/dist/{hub-mdns-ciao-B-wk9nzx.js → hub-mdns-ciao-BIkTHq-n.js} +2 -2
- package/dist/{hub-mdns-ciao-DpPcQDg-.mjs → hub-mdns-ciao-D16oRQ9K.mjs} +2 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3111 -2806
- package/dist/index.mjs +3083 -2795
- package/dist/kernel/index.d.ts +2 -0
- package/dist/kernel/moleculer/event-bus.d.ts +3 -1
- package/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +5 -1
- package/dist/kernel/moleculer/records-api-transport.d.ts +9 -0
- package/dist/kernel/moleculer/remote-logger.d.ts +2 -2
- package/dist/kernel/settings-view-types.d.ts +0 -7
- package/dist/kernel/transport/cap-route-resolver.d.ts +9 -38
- package/dist/phase6-declare-gate-Ci1-8uUn.js +98 -0
- package/dist/phase6-declare-gate-tkKOEitw.mjs +93 -0
- package/dist/read-all-rows-CVoO1ONM.js +29 -0
- package/dist/read-all-rows-TaPqdWNF.mjs +25 -0
- package/dist/records/read-all-rows.d.ts +6 -0
- package/dist/{restore-archive-9CGgeBzD.mjs → restore-archive-DR9MtO7J.mjs} +339 -9
- package/dist/{restore-archive-BMNXwWWD.js → restore-archive-DjJnCgap.js} +353 -5
- package/dist/tls/agent-https-names.d.ts +9 -13
- package/dist/{wal-maintenance-cRHR4rUY.js → wal-maintenance-CODGqhKY.js} +0 -0
- package/dist/{wal-maintenance-sIB32ONp.mjs → wal-maintenance-CfvgtQ7C.mjs} +0 -0
- package/package.json +22 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#0d9488" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<path d="M8 6h13"/>
|
|
3
|
+
<path d="M8 12h13"/>
|
|
4
|
+
<path d="M8 18h13"/>
|
|
5
|
+
<path d="M3 6h.01"/>
|
|
6
|
+
<path d="M3 12h.01"/>
|
|
7
|
+
<path d="M3 18h.01"/>
|
|
8
|
+
</svg>
|
package/dist/addon-runner.js
CHANGED
|
@@ -2895,9 +2895,10 @@ var PeerAnsweredError = class extends Error {
|
|
|
2895
2895
|
* keychain owner-checks on this field, and until 2026-10-08 an unstamped
|
|
2896
2896
|
* call let a child's own `callerAddonId` through untouched.
|
|
2897
2897
|
*
|
|
2898
|
-
*
|
|
2899
|
-
*
|
|
2900
|
-
*
|
|
2898
|
+
* Hub-main in-process contexts that bypass tRPC (addon-registry's stated
|
|
2899
|
+
* transports) never reach this function. Co-located broker/agent callers
|
|
2900
|
+
* stamp here inside `localProviderLink` before the zero-copy invoke.
|
|
2901
|
+
* A non-object `args` (or `null`/array) is returned unchanged: there
|
|
2901
2902
|
* is nowhere to attach a key, and nowhere one could hide.
|
|
2902
2903
|
*/
|
|
2903
2904
|
function stampCallerAddonId(args, callerAddonId) {
|
|
@@ -5319,6 +5320,29 @@ var CapabilityHandle = class {
|
|
|
5319
5320
|
}
|
|
5320
5321
|
};
|
|
5321
5322
|
//#endregion
|
|
5323
|
+
//#region src/kernel/moleculer/records-api-transport.ts
|
|
5324
|
+
function recordsTransportOf(api) {
|
|
5325
|
+
const r = api.records;
|
|
5326
|
+
return {
|
|
5327
|
+
declareKinds: (input) => r.declareKinds.mutate(input),
|
|
5328
|
+
get: (input) => r.get.query(input),
|
|
5329
|
+
getMany: (input) => r.getMany.query(input),
|
|
5330
|
+
secretRefs: (input) => r.secretRefs.query(input),
|
|
5331
|
+
put: (input) => r.put.mutate(input),
|
|
5332
|
+
putMany: (input) => r.putMany.mutate(input),
|
|
5333
|
+
patch: (input) => r.patch.mutate(input),
|
|
5334
|
+
delete: (input) => r.delete.mutate(input),
|
|
5335
|
+
deleteMany: (input) => r.deleteMany.mutate(input),
|
|
5336
|
+
query: (input) => r.query.query(input),
|
|
5337
|
+
count: (input) => r.count.query(input),
|
|
5338
|
+
histogram: (input) => r.histogram.query(input),
|
|
5339
|
+
aggregate: (input) => r.aggregate.query(input),
|
|
5340
|
+
deleteWhere: (input) => r.deleteWhere.mutate(input),
|
|
5341
|
+
deleteDevice: (input) => r.deleteDevice.mutate(input),
|
|
5342
|
+
allocateId: (input) => r.allocateId.mutate(input)
|
|
5343
|
+
};
|
|
5344
|
+
}
|
|
5345
|
+
//#endregion
|
|
5322
5346
|
//#region src/kernel/moleculer/children-batch-loader.ts
|
|
5323
5347
|
/**
|
|
5324
5348
|
* Narrow an untyped cap answer to the fields the reconcile reads.
|
|
@@ -5667,6 +5691,9 @@ function getWorkerNativeCapProvider(capName, deviceId) {
|
|
|
5667
5691
|
if (typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
5668
5692
|
return raw;
|
|
5669
5693
|
}
|
|
5694
|
+
function deviceHasStreamSources(device) {
|
|
5695
|
+
return typeof Reflect.get(device, "getStreamSources") === "function";
|
|
5696
|
+
}
|
|
5670
5697
|
function buildDeviceOpsProvider(device) {
|
|
5671
5698
|
const assertMatch = (incoming) => {
|
|
5672
5699
|
if (incoming !== device.id) throw new Error(`device-ops: deviceId mismatch — expected '${device.id}', got '${incoming}'`);
|
|
@@ -5674,9 +5701,8 @@ function buildDeviceOpsProvider(device) {
|
|
|
5674
5701
|
return {
|
|
5675
5702
|
getStreamSources: async (input) => {
|
|
5676
5703
|
assertMatch(input.deviceId);
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
return [...await maybeCamera.getStreamSources()];
|
|
5704
|
+
if (!deviceHasStreamSources(device)) return [];
|
|
5705
|
+
return [...await device.getStreamSources()];
|
|
5680
5706
|
},
|
|
5681
5707
|
getConfigEntries: async (input) => {
|
|
5682
5708
|
assertMatch(input.deviceId);
|
|
@@ -5726,7 +5752,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
5726
5752
|
const { api, addonId, nodeId, eventBus, registry } = opts;
|
|
5727
5753
|
const deviceSliceSource = (0, _camstack_types_addon.createEventBusSliceSource)({
|
|
5728
5754
|
eventBus,
|
|
5729
|
-
api
|
|
5755
|
+
api: (0, _camstack_types_addon.addonSliceHandleApi)(api)
|
|
5730
5756
|
});
|
|
5731
5757
|
let selfApi;
|
|
5732
5758
|
const childrenLoader = createChildrenBatchLoader({
|
|
@@ -5814,15 +5840,14 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
5814
5840
|
}
|
|
5815
5841
|
const finalProvider = (() => {
|
|
5816
5842
|
if (!cap.status || !cap.runtimeState || !runtimeStateRef) return provider;
|
|
5817
|
-
|
|
5818
|
-
if (typeof asRecord["getStatus"] === "function") return provider;
|
|
5843
|
+
if (typeof Reflect.get(provider, "getStatus") === "function") return provider;
|
|
5819
5844
|
const rsRef = runtimeStateRef;
|
|
5820
5845
|
const defaultGetStatus = async ({ deviceId: dId }) => {
|
|
5821
5846
|
if (typeof dId === "number" && dId !== id) return null;
|
|
5822
5847
|
return rsRef.getCapState(cap.name) ?? null;
|
|
5823
5848
|
};
|
|
5824
5849
|
return {
|
|
5825
|
-
...
|
|
5850
|
+
...provider,
|
|
5826
5851
|
getStatus: defaultGetStatus
|
|
5827
5852
|
};
|
|
5828
5853
|
})();
|
|
@@ -7380,8 +7405,9 @@ function localProviderLink(resolver, observerOpts) {
|
|
|
7380
7405
|
const fn = Reflect.get(provider, parsed.method);
|
|
7381
7406
|
if (typeof fn !== "function") return next(opWithDefaults);
|
|
7382
7407
|
if (observerOpts) recordCapUsage(observerOpts, parsed.capName, parsed.method);
|
|
7408
|
+
const localInput = _camstack_types_addon.CALLER_STAMPED_CAPABILITIES.includes(parsed.capName) ? stampCallerAddonId(opWithDefaults.input, observerOpts?.callerAddonId) : opWithDefaults.input;
|
|
7383
7409
|
return observable((observer) => {
|
|
7384
|
-
Promise.resolve(fn.call(provider,
|
|
7410
|
+
Promise.resolve(fn.call(provider, localInput)).then((data) => {
|
|
7385
7411
|
observer.next({ result: {
|
|
7386
7412
|
type: "data",
|
|
7387
7413
|
data
|
|
@@ -7398,7 +7424,7 @@ function localProviderLink(resolver, observerOpts) {
|
|
|
7398
7424
|
function findServiceCandidates(broker, capName, method, forceServiceName) {
|
|
7399
7425
|
const actionSuffix = capActionSuffix(capName, method);
|
|
7400
7426
|
const bareAction = capBareAction(capName, method);
|
|
7401
|
-
const services = broker
|
|
7427
|
+
const services = Reflect.get(broker, "registry")?.getServiceList?.({
|
|
7402
7428
|
onlyAvailable: true,
|
|
7403
7429
|
withActions: true
|
|
7404
7430
|
}) ?? [];
|
|
@@ -8432,7 +8458,11 @@ function createAddonPeerBytesFacility(args) {
|
|
|
8432
8458
|
res.destroy();
|
|
8433
8459
|
}, Math.max(1e3, Math.floor(stallMs / 4)));
|
|
8434
8460
|
stallTimer.unref();
|
|
8435
|
-
const ended = await Promise.race([(0, node_events.once)(stream, "end").then(() => true),
|
|
8461
|
+
const ended = await Promise.race([(0, node_events.once)(stream, "end").then(() => true), new Promise((resolve) => {
|
|
8462
|
+
res.once("close", () => {
|
|
8463
|
+
resolve(false);
|
|
8464
|
+
});
|
|
8465
|
+
})]).catch(() => false);
|
|
8436
8466
|
clearInterval(stallTimer);
|
|
8437
8467
|
if (ended) {
|
|
8438
8468
|
args.logger.info("peer-bytes: body sent", {
|
|
@@ -8742,6 +8772,10 @@ var AddonDepsManager = class {
|
|
|
8742
8772
|
};
|
|
8743
8773
|
//#endregion
|
|
8744
8774
|
//#region src/kernel/moleculer/event-bus.ts
|
|
8775
|
+
/** Documented boundary: CamStack brokers are always `createBroker` products. */
|
|
8776
|
+
function asBrokerLike(broker) {
|
|
8777
|
+
return broker;
|
|
8778
|
+
}
|
|
8745
8779
|
/**
|
|
8746
8780
|
* Topic prefix for clustered EventBus broadcasts. The `camstack.evt.`
|
|
8747
8781
|
* namespace keeps our events disjoint from Moleculer internal events
|
|
@@ -8914,14 +8948,13 @@ function acceptInboundCrossNode(broker, category) {
|
|
|
8914
8948
|
function registerEventBusService(broker) {
|
|
8915
8949
|
if (eventBusServiceInstalled.has(broker)) return;
|
|
8916
8950
|
eventBusServiceInstalled.add(broker);
|
|
8917
|
-
const bkr = broker;
|
|
8918
8951
|
try {
|
|
8919
|
-
|
|
8952
|
+
broker.createService({
|
|
8920
8953
|
name: "$event-bus",
|
|
8921
8954
|
events: { [EVENT_TOPIC_WILDCARD](ctx) {
|
|
8922
8955
|
const event = ctx.params;
|
|
8923
8956
|
if (!event) return;
|
|
8924
|
-
if (event.sourceNodeId ===
|
|
8957
|
+
if (event.sourceNodeId === broker.nodeID) return;
|
|
8925
8958
|
if (!acceptInboundCrossNode(broker, event.category)) return;
|
|
8926
8959
|
deliverShared(getSharedBusState(broker), event);
|
|
8927
8960
|
} }
|
|
@@ -8929,7 +8962,7 @@ function registerEventBusService(broker) {
|
|
|
8929
8962
|
} catch (err) {
|
|
8930
8963
|
const msg = err instanceof Error ? err.message : String(err);
|
|
8931
8964
|
try {
|
|
8932
|
-
|
|
8965
|
+
broker.logger?.warn?.(`[event-bus] failed to register $event-bus service: ${msg}`);
|
|
8933
8966
|
} catch {}
|
|
8934
8967
|
}
|
|
8935
8968
|
}
|
|
@@ -8941,7 +8974,6 @@ function registerEventBusService(broker) {
|
|
|
8941
8974
|
* nothing and `getRecent` returns `[]`. Events are one-shot everywhere else.
|
|
8942
8975
|
*/
|
|
8943
8976
|
function getBrokerEventBus(broker, options) {
|
|
8944
|
-
const bkr = broker;
|
|
8945
8977
|
const state = getSharedBusState(broker, options?.retainRecent ?? false);
|
|
8946
8978
|
registerEventBusService(broker);
|
|
8947
8979
|
const warnTimestamps = (() => {
|
|
@@ -8956,19 +8988,19 @@ function getBrokerEventBus(broker, options) {
|
|
|
8956
8988
|
emit(event) {
|
|
8957
8989
|
const enriched = {
|
|
8958
8990
|
...event,
|
|
8959
|
-
sourceNodeId:
|
|
8991
|
+
sourceNodeId: broker.nodeID
|
|
8960
8992
|
};
|
|
8961
8993
|
deliverShared(state, enriched);
|
|
8962
8994
|
const topic = clusterEventTopic(event.category);
|
|
8963
8995
|
try {
|
|
8964
|
-
|
|
8996
|
+
broker.broadcast(topic, enriched);
|
|
8965
8997
|
} catch (err) {
|
|
8966
8998
|
const cat = event.category;
|
|
8967
8999
|
const now = Date.now();
|
|
8968
9000
|
if (now - (warnTimestamps.get(`broadcast:${cat}`) ?? 0) > 6e4) {
|
|
8969
9001
|
warnTimestamps.set(`broadcast:${cat}`, now);
|
|
8970
9002
|
try {
|
|
8971
|
-
|
|
9003
|
+
broker.logger?.warn?.(`[event-bus] broker.broadcast('${topic}') failed for category="${cat}" nodeID="${broker.nodeID}": ${err instanceof Error ? err.message : String(err)}`);
|
|
8972
9004
|
} catch {}
|
|
8973
9005
|
}
|
|
8974
9006
|
}
|
|
@@ -9118,7 +9150,7 @@ function setPreferredProvider(capabilityName, addonId, brokerNodeId = "hub") {
|
|
|
9118
9150
|
*/
|
|
9119
9151
|
var bindingSubscriberInstalled = /* @__PURE__ */ new Set();
|
|
9120
9152
|
function ensureBindingSubscription(broker) {
|
|
9121
|
-
const bkr = broker;
|
|
9153
|
+
const bkr = asBrokerLike(broker);
|
|
9122
9154
|
if (bindingSubscriberInstalled.has(bkr.nodeID)) return;
|
|
9123
9155
|
bindingSubscriberInstalled.add(bkr.nodeID);
|
|
9124
9156
|
const handler = (payload) => {
|
|
@@ -9178,7 +9210,7 @@ var READINESS_RECONCILE_INTERVAL_MS = 6e4;
|
|
|
9178
9210
|
* entries already observed locally.
|
|
9179
9211
|
*/
|
|
9180
9212
|
function getOrInitReadinessRegistry(broker, eventBus, logger) {
|
|
9181
|
-
const bkr = broker;
|
|
9213
|
+
const bkr = asBrokerLike(broker);
|
|
9182
9214
|
const existing = brokerReadinessRegistries.get(broker);
|
|
9183
9215
|
if (existing) return existing;
|
|
9184
9216
|
const registry = new _camstack_types_addon.ReadinessRegistry({
|
|
@@ -9306,8 +9338,8 @@ function getOrInitReadinessRegistryForClient(client, eventBus, logger, nodeId) {
|
|
|
9306
9338
|
function buildCapabilitiesAccess(broker, localRegs) {
|
|
9307
9339
|
const collectRemoteEntries = (capName) => {
|
|
9308
9340
|
if (broker === void 0) return [];
|
|
9309
|
-
const bkr = broker;
|
|
9310
|
-
const rawRegistry = Reflect.get(
|
|
9341
|
+
const bkr = asBrokerLike(broker);
|
|
9342
|
+
const rawRegistry = Reflect.get(broker, "registry");
|
|
9311
9343
|
if (rawRegistry === null || typeof rawRegistry !== "object" || !("getServiceList" in rawRegistry)) return [];
|
|
9312
9344
|
const services = rawRegistry.getServiceList({
|
|
9313
9345
|
onlyAvailable: true,
|
|
@@ -9390,7 +9422,7 @@ function buildCapabilitiesAccess(broker, localRegs) {
|
|
|
9390
9422
|
* consumers (e.g. `await maybeProxy` mustn't hang).
|
|
9391
9423
|
*/
|
|
9392
9424
|
function createRemoteProviderProxy(broker, serviceName, capName, nodeId, methods) {
|
|
9393
|
-
const bkr = broker;
|
|
9425
|
+
const bkr = asBrokerLike(broker);
|
|
9394
9426
|
const dispatcher = Object.create(null);
|
|
9395
9427
|
for (const method of methods) dispatcher[method] = (input) => {
|
|
9396
9428
|
return bkr.call(`${serviceName}.${capName}.${method}`, serializeTypedArrays(input), {
|
|
@@ -10129,7 +10161,7 @@ function createRunnerDeviceSettings(client, addonId, before = async () => {}) {
|
|
|
10129
10161
|
//#region src/kernel/moleculer/addon-context-factory.ts
|
|
10130
10162
|
/** This runtime's node id, regardless of mode (broker.nodeID or the UDS child nodeId). */
|
|
10131
10163
|
function runtimeNodeId(runtime) {
|
|
10132
|
-
return runtime.mode === "broker" ? runtime.broker.nodeID : runtime.nodeId;
|
|
10164
|
+
return runtime.mode === "broker" ? asBrokerLike(runtime.broker).nodeID : runtime.nodeId;
|
|
10133
10165
|
}
|
|
10134
10166
|
/**
|
|
10135
10167
|
* Adapt a Moleculer ServiceBroker to the camstack-types `IClusterBroker`
|
|
@@ -10139,7 +10171,7 @@ function runtimeNodeId(runtime) {
|
|
|
10139
10171
|
* forward through a thin object instead of casting at the boundary.
|
|
10140
10172
|
*/
|
|
10141
10173
|
function adaptBrokerToCluster(broker) {
|
|
10142
|
-
const bkr = broker;
|
|
10174
|
+
const bkr = asBrokerLike(broker);
|
|
10143
10175
|
return {
|
|
10144
10176
|
get nodeID() {
|
|
10145
10177
|
return bkr.nodeID;
|
|
@@ -10283,7 +10315,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
10283
10315
|
const scopedEventBus = runtime.mode === "broker" ? createBrokerEventBus(runtime.broker, addonId) : createUdsEventBus(runtime.client, addonId);
|
|
10284
10316
|
const deviceSliceSource = (0, _camstack_types_addon.createEventBusSliceSource)({
|
|
10285
10317
|
eventBus: scopedEventBus,
|
|
10286
|
-
api
|
|
10318
|
+
api: (0, _camstack_types_addon.addonSliceHandleApi)(api)
|
|
10287
10319
|
});
|
|
10288
10320
|
const workerDisposerChain = new _camstack_types_addon.DisposerChain({ onError: (err, index) => {
|
|
10289
10321
|
scopedLogger.error(`Disposer #${index} threw during teardown`, { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -10442,6 +10474,19 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
10442
10474
|
nodeId
|
|
10443
10475
|
});
|
|
10444
10476
|
workerDisposerChain.add(() => peerBytesFacility.dispose());
|
|
10477
|
+
const secrets = (0, _camstack_types_addon.createSecretsAccess)({
|
|
10478
|
+
owner: addonId,
|
|
10479
|
+
transport: {
|
|
10480
|
+
put: (input) => api.keychain.put.mutate({
|
|
10481
|
+
ref: input.ref,
|
|
10482
|
+
value: input.value
|
|
10483
|
+
}),
|
|
10484
|
+
resolve: (input) => api.keychain.resolve.query({ refs: [...input.refs] }),
|
|
10485
|
+
delete: (input) => api.keychain.delete.mutate({ refs: [...input.refs] }),
|
|
10486
|
+
getState: () => api.keychain.getState.query({})
|
|
10487
|
+
},
|
|
10488
|
+
eventBus: scopedEventBus
|
|
10489
|
+
});
|
|
10445
10490
|
return {
|
|
10446
10491
|
id: addonId,
|
|
10447
10492
|
logger: scopedLogger,
|
|
@@ -10454,26 +10499,20 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
10454
10499
|
api,
|
|
10455
10500
|
deps: new AddonDepsManager(addonDataDir, scopedLogger),
|
|
10456
10501
|
settings: settingsView,
|
|
10457
|
-
secrets
|
|
10502
|
+
secrets,
|
|
10503
|
+
records: (0, _camstack_types_addon.createRecordsAccess)({
|
|
10458
10504
|
owner: addonId,
|
|
10459
|
-
transport:
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
value: input.value
|
|
10463
|
-
}),
|
|
10464
|
-
resolve: (input) => api.keychain.resolve.query({ refs: [...input.refs] }),
|
|
10465
|
-
delete: (input) => api.keychain.delete.mutate({ refs: [...input.refs] }),
|
|
10466
|
-
getState: () => api.keychain.getState.query({})
|
|
10467
|
-
},
|
|
10468
|
-
eventBus: scopedEventBus
|
|
10505
|
+
transport: recordsTransportOf(api),
|
|
10506
|
+
secrets,
|
|
10507
|
+
logger: scopedLogger
|
|
10469
10508
|
}),
|
|
10470
10509
|
kernel: (() => {
|
|
10471
10510
|
const streamProbe = runtime.mode === "broker" ? {
|
|
10472
|
-
probe: (url, probeOptions) => runtime.broker.call("$stream-probe.probe", {
|
|
10511
|
+
probe: (url, probeOptions) => asBrokerLike(runtime.broker).call("$stream-probe.probe", {
|
|
10473
10512
|
url,
|
|
10474
10513
|
force: probeOptions?.force ?? false
|
|
10475
10514
|
}),
|
|
10476
|
-
probeField: (key, value) => runtime.broker.call("$stream-probe.probeField", {
|
|
10515
|
+
probeField: (key, value) => asBrokerLike(runtime.broker).call("$stream-probe.probeField", {
|
|
10477
10516
|
key,
|
|
10478
10517
|
value
|
|
10479
10518
|
})
|
package/dist/addon-runner.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import { createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { dirname, isAbsolute, join } from "node:path";
|
|
6
|
-
import { BOOT_RECOVERY_BACKOFF_MS, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, asJsonObject, asString, collectZodSecretPaths, createDeviceProxy, createEventBusSliceSource, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, normalizeAddonInitResult, readErrorI18n, readNodePin, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, withCapInputDefaults } from "@camstack/types/addon";
|
|
6
|
+
import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, normalizeAddonInitResult, readErrorI18n, readNodePin, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, withCapInputDefaults } from "@camstack/types/addon";
|
|
7
7
|
import { execFile } from "node:child_process";
|
|
8
8
|
import { promisify } from "node:util";
|
|
9
9
|
import * as os from "node:os";
|
|
@@ -2871,9 +2871,10 @@ var PeerAnsweredError = class extends Error {
|
|
|
2871
2871
|
* keychain owner-checks on this field, and until 2026-10-08 an unstamped
|
|
2872
2872
|
* call let a child's own `callerAddonId` through untouched.
|
|
2873
2873
|
*
|
|
2874
|
-
*
|
|
2875
|
-
*
|
|
2876
|
-
*
|
|
2874
|
+
* Hub-main in-process contexts that bypass tRPC (addon-registry's stated
|
|
2875
|
+
* transports) never reach this function. Co-located broker/agent callers
|
|
2876
|
+
* stamp here inside `localProviderLink` before the zero-copy invoke.
|
|
2877
|
+
* A non-object `args` (or `null`/array) is returned unchanged: there
|
|
2877
2878
|
* is nowhere to attach a key, and nowhere one could hide.
|
|
2878
2879
|
*/
|
|
2879
2880
|
function stampCallerAddonId(args, callerAddonId) {
|
|
@@ -5295,6 +5296,29 @@ var CapabilityHandle = class {
|
|
|
5295
5296
|
}
|
|
5296
5297
|
};
|
|
5297
5298
|
//#endregion
|
|
5299
|
+
//#region src/kernel/moleculer/records-api-transport.ts
|
|
5300
|
+
function recordsTransportOf(api) {
|
|
5301
|
+
const r = api.records;
|
|
5302
|
+
return {
|
|
5303
|
+
declareKinds: (input) => r.declareKinds.mutate(input),
|
|
5304
|
+
get: (input) => r.get.query(input),
|
|
5305
|
+
getMany: (input) => r.getMany.query(input),
|
|
5306
|
+
secretRefs: (input) => r.secretRefs.query(input),
|
|
5307
|
+
put: (input) => r.put.mutate(input),
|
|
5308
|
+
putMany: (input) => r.putMany.mutate(input),
|
|
5309
|
+
patch: (input) => r.patch.mutate(input),
|
|
5310
|
+
delete: (input) => r.delete.mutate(input),
|
|
5311
|
+
deleteMany: (input) => r.deleteMany.mutate(input),
|
|
5312
|
+
query: (input) => r.query.query(input),
|
|
5313
|
+
count: (input) => r.count.query(input),
|
|
5314
|
+
histogram: (input) => r.histogram.query(input),
|
|
5315
|
+
aggregate: (input) => r.aggregate.query(input),
|
|
5316
|
+
deleteWhere: (input) => r.deleteWhere.mutate(input),
|
|
5317
|
+
deleteDevice: (input) => r.deleteDevice.mutate(input),
|
|
5318
|
+
allocateId: (input) => r.allocateId.mutate(input)
|
|
5319
|
+
};
|
|
5320
|
+
}
|
|
5321
|
+
//#endregion
|
|
5298
5322
|
//#region src/kernel/moleculer/children-batch-loader.ts
|
|
5299
5323
|
/**
|
|
5300
5324
|
* Narrow an untyped cap answer to the fields the reconcile reads.
|
|
@@ -5643,6 +5667,9 @@ function getWorkerNativeCapProvider(capName, deviceId) {
|
|
|
5643
5667
|
if (typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
5644
5668
|
return raw;
|
|
5645
5669
|
}
|
|
5670
|
+
function deviceHasStreamSources(device) {
|
|
5671
|
+
return typeof Reflect.get(device, "getStreamSources") === "function";
|
|
5672
|
+
}
|
|
5646
5673
|
function buildDeviceOpsProvider(device) {
|
|
5647
5674
|
const assertMatch = (incoming) => {
|
|
5648
5675
|
if (incoming !== device.id) throw new Error(`device-ops: deviceId mismatch — expected '${device.id}', got '${incoming}'`);
|
|
@@ -5650,9 +5677,8 @@ function buildDeviceOpsProvider(device) {
|
|
|
5650
5677
|
return {
|
|
5651
5678
|
getStreamSources: async (input) => {
|
|
5652
5679
|
assertMatch(input.deviceId);
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
return [...await maybeCamera.getStreamSources()];
|
|
5680
|
+
if (!deviceHasStreamSources(device)) return [];
|
|
5681
|
+
return [...await device.getStreamSources()];
|
|
5656
5682
|
},
|
|
5657
5683
|
getConfigEntries: async (input) => {
|
|
5658
5684
|
assertMatch(input.deviceId);
|
|
@@ -5702,7 +5728,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
5702
5728
|
const { api, addonId, nodeId, eventBus, registry } = opts;
|
|
5703
5729
|
const deviceSliceSource = createEventBusSliceSource({
|
|
5704
5730
|
eventBus,
|
|
5705
|
-
api
|
|
5731
|
+
api: addonSliceHandleApi(api)
|
|
5706
5732
|
});
|
|
5707
5733
|
let selfApi;
|
|
5708
5734
|
const childrenLoader = createChildrenBatchLoader({
|
|
@@ -5790,15 +5816,14 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
5790
5816
|
}
|
|
5791
5817
|
const finalProvider = (() => {
|
|
5792
5818
|
if (!cap.status || !cap.runtimeState || !runtimeStateRef) return provider;
|
|
5793
|
-
|
|
5794
|
-
if (typeof asRecord["getStatus"] === "function") return provider;
|
|
5819
|
+
if (typeof Reflect.get(provider, "getStatus") === "function") return provider;
|
|
5795
5820
|
const rsRef = runtimeStateRef;
|
|
5796
5821
|
const defaultGetStatus = async ({ deviceId: dId }) => {
|
|
5797
5822
|
if (typeof dId === "number" && dId !== id) return null;
|
|
5798
5823
|
return rsRef.getCapState(cap.name) ?? null;
|
|
5799
5824
|
};
|
|
5800
5825
|
return {
|
|
5801
|
-
...
|
|
5826
|
+
...provider,
|
|
5802
5827
|
getStatus: defaultGetStatus
|
|
5803
5828
|
};
|
|
5804
5829
|
})();
|
|
@@ -7356,8 +7381,9 @@ function localProviderLink(resolver, observerOpts) {
|
|
|
7356
7381
|
const fn = Reflect.get(provider, parsed.method);
|
|
7357
7382
|
if (typeof fn !== "function") return next(opWithDefaults);
|
|
7358
7383
|
if (observerOpts) recordCapUsage(observerOpts, parsed.capName, parsed.method);
|
|
7384
|
+
const localInput = CALLER_STAMPED_CAPABILITIES.includes(parsed.capName) ? stampCallerAddonId(opWithDefaults.input, observerOpts?.callerAddonId) : opWithDefaults.input;
|
|
7359
7385
|
return observable((observer) => {
|
|
7360
|
-
Promise.resolve(fn.call(provider,
|
|
7386
|
+
Promise.resolve(fn.call(provider, localInput)).then((data) => {
|
|
7361
7387
|
observer.next({ result: {
|
|
7362
7388
|
type: "data",
|
|
7363
7389
|
data
|
|
@@ -7374,7 +7400,7 @@ function localProviderLink(resolver, observerOpts) {
|
|
|
7374
7400
|
function findServiceCandidates(broker, capName, method, forceServiceName) {
|
|
7375
7401
|
const actionSuffix = capActionSuffix(capName, method);
|
|
7376
7402
|
const bareAction = capBareAction(capName, method);
|
|
7377
|
-
const services = broker
|
|
7403
|
+
const services = Reflect.get(broker, "registry")?.getServiceList?.({
|
|
7378
7404
|
onlyAvailable: true,
|
|
7379
7405
|
withActions: true
|
|
7380
7406
|
}) ?? [];
|
|
@@ -8408,7 +8434,11 @@ function createAddonPeerBytesFacility(args) {
|
|
|
8408
8434
|
res.destroy();
|
|
8409
8435
|
}, Math.max(1e3, Math.floor(stallMs / 4)));
|
|
8410
8436
|
stallTimer.unref();
|
|
8411
|
-
const ended = await Promise.race([once(stream, "end").then(() => true),
|
|
8437
|
+
const ended = await Promise.race([once(stream, "end").then(() => true), new Promise((resolve) => {
|
|
8438
|
+
res.once("close", () => {
|
|
8439
|
+
resolve(false);
|
|
8440
|
+
});
|
|
8441
|
+
})]).catch(() => false);
|
|
8412
8442
|
clearInterval(stallTimer);
|
|
8413
8443
|
if (ended) {
|
|
8414
8444
|
args.logger.info("peer-bytes: body sent", {
|
|
@@ -8718,6 +8748,10 @@ var AddonDepsManager = class {
|
|
|
8718
8748
|
};
|
|
8719
8749
|
//#endregion
|
|
8720
8750
|
//#region src/kernel/moleculer/event-bus.ts
|
|
8751
|
+
/** Documented boundary: CamStack brokers are always `createBroker` products. */
|
|
8752
|
+
function asBrokerLike(broker) {
|
|
8753
|
+
return broker;
|
|
8754
|
+
}
|
|
8721
8755
|
/**
|
|
8722
8756
|
* Topic prefix for clustered EventBus broadcasts. The `camstack.evt.`
|
|
8723
8757
|
* namespace keeps our events disjoint from Moleculer internal events
|
|
@@ -8890,14 +8924,13 @@ function acceptInboundCrossNode(broker, category) {
|
|
|
8890
8924
|
function registerEventBusService(broker) {
|
|
8891
8925
|
if (eventBusServiceInstalled.has(broker)) return;
|
|
8892
8926
|
eventBusServiceInstalled.add(broker);
|
|
8893
|
-
const bkr = broker;
|
|
8894
8927
|
try {
|
|
8895
|
-
|
|
8928
|
+
broker.createService({
|
|
8896
8929
|
name: "$event-bus",
|
|
8897
8930
|
events: { [EVENT_TOPIC_WILDCARD](ctx) {
|
|
8898
8931
|
const event = ctx.params;
|
|
8899
8932
|
if (!event) return;
|
|
8900
|
-
if (event.sourceNodeId ===
|
|
8933
|
+
if (event.sourceNodeId === broker.nodeID) return;
|
|
8901
8934
|
if (!acceptInboundCrossNode(broker, event.category)) return;
|
|
8902
8935
|
deliverShared(getSharedBusState(broker), event);
|
|
8903
8936
|
} }
|
|
@@ -8905,7 +8938,7 @@ function registerEventBusService(broker) {
|
|
|
8905
8938
|
} catch (err) {
|
|
8906
8939
|
const msg = err instanceof Error ? err.message : String(err);
|
|
8907
8940
|
try {
|
|
8908
|
-
|
|
8941
|
+
broker.logger?.warn?.(`[event-bus] failed to register $event-bus service: ${msg}`);
|
|
8909
8942
|
} catch {}
|
|
8910
8943
|
}
|
|
8911
8944
|
}
|
|
@@ -8917,7 +8950,6 @@ function registerEventBusService(broker) {
|
|
|
8917
8950
|
* nothing and `getRecent` returns `[]`. Events are one-shot everywhere else.
|
|
8918
8951
|
*/
|
|
8919
8952
|
function getBrokerEventBus(broker, options) {
|
|
8920
|
-
const bkr = broker;
|
|
8921
8953
|
const state = getSharedBusState(broker, options?.retainRecent ?? false);
|
|
8922
8954
|
registerEventBusService(broker);
|
|
8923
8955
|
const warnTimestamps = (() => {
|
|
@@ -8932,19 +8964,19 @@ function getBrokerEventBus(broker, options) {
|
|
|
8932
8964
|
emit(event) {
|
|
8933
8965
|
const enriched = {
|
|
8934
8966
|
...event,
|
|
8935
|
-
sourceNodeId:
|
|
8967
|
+
sourceNodeId: broker.nodeID
|
|
8936
8968
|
};
|
|
8937
8969
|
deliverShared(state, enriched);
|
|
8938
8970
|
const topic = clusterEventTopic(event.category);
|
|
8939
8971
|
try {
|
|
8940
|
-
|
|
8972
|
+
broker.broadcast(topic, enriched);
|
|
8941
8973
|
} catch (err) {
|
|
8942
8974
|
const cat = event.category;
|
|
8943
8975
|
const now = Date.now();
|
|
8944
8976
|
if (now - (warnTimestamps.get(`broadcast:${cat}`) ?? 0) > 6e4) {
|
|
8945
8977
|
warnTimestamps.set(`broadcast:${cat}`, now);
|
|
8946
8978
|
try {
|
|
8947
|
-
|
|
8979
|
+
broker.logger?.warn?.(`[event-bus] broker.broadcast('${topic}') failed for category="${cat}" nodeID="${broker.nodeID}": ${err instanceof Error ? err.message : String(err)}`);
|
|
8948
8980
|
} catch {}
|
|
8949
8981
|
}
|
|
8950
8982
|
}
|
|
@@ -9094,7 +9126,7 @@ function setPreferredProvider(capabilityName, addonId, brokerNodeId = "hub") {
|
|
|
9094
9126
|
*/
|
|
9095
9127
|
var bindingSubscriberInstalled = /* @__PURE__ */ new Set();
|
|
9096
9128
|
function ensureBindingSubscription(broker) {
|
|
9097
|
-
const bkr = broker;
|
|
9129
|
+
const bkr = asBrokerLike(broker);
|
|
9098
9130
|
if (bindingSubscriberInstalled.has(bkr.nodeID)) return;
|
|
9099
9131
|
bindingSubscriberInstalled.add(bkr.nodeID);
|
|
9100
9132
|
const handler = (payload) => {
|
|
@@ -9154,7 +9186,7 @@ var READINESS_RECONCILE_INTERVAL_MS = 6e4;
|
|
|
9154
9186
|
* entries already observed locally.
|
|
9155
9187
|
*/
|
|
9156
9188
|
function getOrInitReadinessRegistry(broker, eventBus, logger) {
|
|
9157
|
-
const bkr = broker;
|
|
9189
|
+
const bkr = asBrokerLike(broker);
|
|
9158
9190
|
const existing = brokerReadinessRegistries.get(broker);
|
|
9159
9191
|
if (existing) return existing;
|
|
9160
9192
|
const registry = new ReadinessRegistry({
|
|
@@ -9282,8 +9314,8 @@ function getOrInitReadinessRegistryForClient(client, eventBus, logger, nodeId) {
|
|
|
9282
9314
|
function buildCapabilitiesAccess(broker, localRegs) {
|
|
9283
9315
|
const collectRemoteEntries = (capName) => {
|
|
9284
9316
|
if (broker === void 0) return [];
|
|
9285
|
-
const bkr = broker;
|
|
9286
|
-
const rawRegistry = Reflect.get(
|
|
9317
|
+
const bkr = asBrokerLike(broker);
|
|
9318
|
+
const rawRegistry = Reflect.get(broker, "registry");
|
|
9287
9319
|
if (rawRegistry === null || typeof rawRegistry !== "object" || !("getServiceList" in rawRegistry)) return [];
|
|
9288
9320
|
const services = rawRegistry.getServiceList({
|
|
9289
9321
|
onlyAvailable: true,
|
|
@@ -9366,7 +9398,7 @@ function buildCapabilitiesAccess(broker, localRegs) {
|
|
|
9366
9398
|
* consumers (e.g. `await maybeProxy` mustn't hang).
|
|
9367
9399
|
*/
|
|
9368
9400
|
function createRemoteProviderProxy(broker, serviceName, capName, nodeId, methods) {
|
|
9369
|
-
const bkr = broker;
|
|
9401
|
+
const bkr = asBrokerLike(broker);
|
|
9370
9402
|
const dispatcher = Object.create(null);
|
|
9371
9403
|
for (const method of methods) dispatcher[method] = (input) => {
|
|
9372
9404
|
return bkr.call(`${serviceName}.${capName}.${method}`, serializeTypedArrays(input), {
|
|
@@ -10105,7 +10137,7 @@ function createRunnerDeviceSettings(client, addonId, before = async () => {}) {
|
|
|
10105
10137
|
//#region src/kernel/moleculer/addon-context-factory.ts
|
|
10106
10138
|
/** This runtime's node id, regardless of mode (broker.nodeID or the UDS child nodeId). */
|
|
10107
10139
|
function runtimeNodeId(runtime) {
|
|
10108
|
-
return runtime.mode === "broker" ? runtime.broker.nodeID : runtime.nodeId;
|
|
10140
|
+
return runtime.mode === "broker" ? asBrokerLike(runtime.broker).nodeID : runtime.nodeId;
|
|
10109
10141
|
}
|
|
10110
10142
|
/**
|
|
10111
10143
|
* Adapt a Moleculer ServiceBroker to the camstack-types `IClusterBroker`
|
|
@@ -10115,7 +10147,7 @@ function runtimeNodeId(runtime) {
|
|
|
10115
10147
|
* forward through a thin object instead of casting at the boundary.
|
|
10116
10148
|
*/
|
|
10117
10149
|
function adaptBrokerToCluster(broker) {
|
|
10118
|
-
const bkr = broker;
|
|
10150
|
+
const bkr = asBrokerLike(broker);
|
|
10119
10151
|
return {
|
|
10120
10152
|
get nodeID() {
|
|
10121
10153
|
return bkr.nodeID;
|
|
@@ -10259,7 +10291,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
10259
10291
|
const scopedEventBus = runtime.mode === "broker" ? createBrokerEventBus(runtime.broker, addonId) : createUdsEventBus(runtime.client, addonId);
|
|
10260
10292
|
const deviceSliceSource = createEventBusSliceSource({
|
|
10261
10293
|
eventBus: scopedEventBus,
|
|
10262
|
-
api
|
|
10294
|
+
api: addonSliceHandleApi(api)
|
|
10263
10295
|
});
|
|
10264
10296
|
const workerDisposerChain = new DisposerChain({ onError: (err, index) => {
|
|
10265
10297
|
scopedLogger.error(`Disposer #${index} threw during teardown`, { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -10418,6 +10450,19 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
10418
10450
|
nodeId
|
|
10419
10451
|
});
|
|
10420
10452
|
workerDisposerChain.add(() => peerBytesFacility.dispose());
|
|
10453
|
+
const secrets = createSecretsAccess({
|
|
10454
|
+
owner: addonId,
|
|
10455
|
+
transport: {
|
|
10456
|
+
put: (input) => api.keychain.put.mutate({
|
|
10457
|
+
ref: input.ref,
|
|
10458
|
+
value: input.value
|
|
10459
|
+
}),
|
|
10460
|
+
resolve: (input) => api.keychain.resolve.query({ refs: [...input.refs] }),
|
|
10461
|
+
delete: (input) => api.keychain.delete.mutate({ refs: [...input.refs] }),
|
|
10462
|
+
getState: () => api.keychain.getState.query({})
|
|
10463
|
+
},
|
|
10464
|
+
eventBus: scopedEventBus
|
|
10465
|
+
});
|
|
10421
10466
|
return {
|
|
10422
10467
|
id: addonId,
|
|
10423
10468
|
logger: scopedLogger,
|
|
@@ -10430,26 +10475,20 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
10430
10475
|
api,
|
|
10431
10476
|
deps: new AddonDepsManager(addonDataDir, scopedLogger),
|
|
10432
10477
|
settings: settingsView,
|
|
10433
|
-
secrets
|
|
10478
|
+
secrets,
|
|
10479
|
+
records: createRecordsAccess({
|
|
10434
10480
|
owner: addonId,
|
|
10435
|
-
transport:
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
value: input.value
|
|
10439
|
-
}),
|
|
10440
|
-
resolve: (input) => api.keychain.resolve.query({ refs: [...input.refs] }),
|
|
10441
|
-
delete: (input) => api.keychain.delete.mutate({ refs: [...input.refs] }),
|
|
10442
|
-
getState: () => api.keychain.getState.query({})
|
|
10443
|
-
},
|
|
10444
|
-
eventBus: scopedEventBus
|
|
10481
|
+
transport: recordsTransportOf(api),
|
|
10482
|
+
secrets,
|
|
10483
|
+
logger: scopedLogger
|
|
10445
10484
|
}),
|
|
10446
10485
|
kernel: (() => {
|
|
10447
10486
|
const streamProbe = runtime.mode === "broker" ? {
|
|
10448
|
-
probe: (url, probeOptions) => runtime.broker.call("$stream-probe.probe", {
|
|
10487
|
+
probe: (url, probeOptions) => asBrokerLike(runtime.broker).call("$stream-probe.probe", {
|
|
10449
10488
|
url,
|
|
10450
10489
|
force: probeOptions?.force ?? false
|
|
10451
10490
|
}),
|
|
10452
|
-
probeField: (key, value) => runtime.broker.call("$stream-probe.probeField", {
|
|
10491
|
+
probeField: (key, value) => asBrokerLike(runtime.broker).call("$stream-probe.probeField", {
|
|
10453
10492
|
key,
|
|
10454
10493
|
value
|
|
10455
10494
|
})
|