@camstack/server 1.2.828 → 1.2.830
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 +20 -3
- package/dist/agent/agent-boot-mode.js +14 -1
- package/dist/agent/agent-http.js +12 -0
- package/dist/agent/agent-hub-rediscovery.js +205 -0
- package/dist/agent/agent-membership-watch.js +29 -1
- package/dist/agent/agent-pairing-store.js +47 -3
- package/dist/agent/hubs-found.js +1 -0
- package/dist/agent/main.js +64 -6
- package/dist/api/core/agent-pairing.router.js +9 -0
- package/dist/api/core/cluster-update.provider.js +98 -0
- package/dist/api/mesh-membership-routes.js +3 -2
- package/dist/api/trpc/generated-cap-mounts.js +2 -1
- package/dist/api/trpc/generated-cap-routers.js +2339 -2286
- package/dist/api/trpc/server-provided-caps.js +1 -0
- package/dist/api/trpc/trpc.router.js +5 -0
- package/dist/auth/auth-provider-gate.js +6 -2
- package/dist/core/addon/device-meta-mirror.js +1 -0
- package/dist/core/cluster-update/cluster-update-job-store.js +106 -0
- package/dist/core/cluster-update/cluster-update-plan.js +147 -0
- package/dist/core/cluster-update/cluster-update-seams.js +13 -0
- package/dist/core/cluster-update/cluster-update-steps.js +293 -0
- package/dist/core/cluster-update/cluster-update.service.js +319 -0
- package/dist/main.js +3 -0
- package/dist/manual-boot.js +19 -0
- package/package.json +12 -11
- package/system/dist/addon-runner.js +12 -0
- package/system/dist/addon-runner.mjs +12 -0
- 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 +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- 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.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- 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-aggregation.d.ts +25 -1
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +6 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +354 -7
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +354 -7
- package/system/dist/builtins/device-manager/device-meta-actions.d.ts +6 -0
- package/system/dist/builtins/device-manager/device-meta-types.d.ts +4 -0
- package/system/dist/builtins/device-manager/device-row-store.d.ts +2 -1
- package/system/dist/builtins/device-manager/device-search.d.ts +42 -0
- 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/hub-mdns.d.ts +5 -1
- package/system/dist/builtins/local-network/local-network.addon.js +24 -13
- package/system/dist/builtins/local-network/local-network.addon.mjs +24 -13
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- 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/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +59 -20
- package/system/dist/builtins/system-config/system-config.addon.mjs +48 -10
- 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-1A7HAX3x.js → capture-engine-6_V-PR8O.js} +1 -1
- package/system/dist/{capture-engine-B0yQx6hA.mjs → capture-engine-cp3my4VK.mjs} +1 -1
- package/system/dist/{composition-sources-CyJ0d6Sc.mjs → composition-sources-C-iX_Uuu.mjs} +1 -1
- package/system/dist/{composition-sources-BzM19ASO.js → composition-sources-JwBPIhdO.js} +1 -1
- package/system/dist/{constants-DSO4ZEO3.js → constants-C4V2z-GT.js} +1 -1
- package/system/dist/{constants-B_FLEjP_.mjs → constants-D5oNuYLD.mjs} +1 -1
- package/system/dist/{device-ca-CveuNCHp.mjs → device-ca-CXPTrORC.mjs} +1 -1
- package/system/dist/{device-ca-DLTDsonl.js → device-ca-DAuMNieL.js} +1 -1
- package/system/dist/{dist-CIyyHwVx.mjs → dist-B8dBvJJK.mjs} +469 -27
- package/system/dist/{dist-DhbzVygm.js → dist-DVrLQr6W.js} +469 -27
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{agent-https-BlLVD9hG.js → hub-identity-Cg1_bzoY.js} +120 -1
- package/system/dist/{agent-https-BSxTUzKT.mjs → hub-identity-D2sSTELW.mjs} +97 -2
- package/system/dist/{hub-mdns-ciao-C_ITDs0-.js → hub-mdns-ciao-DCHShuFh.js} +18 -18
- package/system/dist/{hub-mdns-ciao-CQdCUsrI.mjs → hub-mdns-ciao-Twxwj9Vh.mjs} +2 -2
- package/system/dist/index.js +61 -44
- package/system/dist/index.mjs +22 -10
- package/system/dist/kernel/hub-identity.d.ts +17 -0
- package/system/dist/kernel/index.d.ts +2 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-membership.d.ts +7 -0
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/agent-pairing.d.ts +11 -1
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/hub-pairing.d.ts +5 -0
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/index.d.ts +1 -1
- package/system/dist/kernel/moleculer/mesh-mtls/pairing/pairing-protocol.d.ts +2 -0
- package/system/dist/{legacy-integration-rows-door-D_tfRhsx.js → legacy-integration-rows-door-i0gANn4l.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-tX6Qktxd.mjs → legacy-integration-rows-door-lRhfbNBc.mjs} +1 -1
- package/system/dist/{rename-composition-block-DNhbAonr.js → rename-composition-block-BRy-9srI.js} +1 -1
- package/system/dist/{rename-composition-block-COaMxshT.mjs → rename-composition-block-C2IbabFp.mjs} +1 -1
- package/system/dist/{restore-archive-BMqp_hMT.mjs → restore-archive-CkyWtDIi.mjs} +1 -1
- package/system/dist/{restore-archive-Dbzuv5hK.js → restore-archive-_y4JaVgy.js} +1 -1
- package/system/dist/{wal-maintenance-CWODOTsa.js → wal-maintenance-BfkwceLa.js} +0 -0
- package/system/dist/{wal-maintenance-ITsLGvFA.mjs → wal-maintenance-Dn2cx4Km.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Ar as enumerateSchemaFields, Bn as canonicalIconKey, Ec as isDeviceConfigCap, Er as deviceStatusCapability, Fa as resolveTemplateRef, Fr as expandContainer, J as DEVICE_TEMPLATE_MAX_LENGTH, Jc as resolveSecretMarkers, Jr as generateDeviceAlias, Js as WELL_KNOWN_TAB_MAP, Ka as settleDeviceFeatures, Kr as formatMinutes, Ln as buildStreamParamsConfigSchema, Nc as isSecretMarker, Pc as isSecretMarkerLike, Qa as siteZoneKey, R as DAY_NAMES, Ra as runtimeFieldUnit, Si as locationIconKey, Sr as deviceManagerCapability, Tr as deviceStateCapability, Un as checkDeviceAlias, Us as SECRET_CLEAR, Wi as normalizeUnit, Y as DEVICE_TEMPLATE_MAX_OUTPUT, Z as DEVICE_TEMPLATE_VALUES_CAP, Zc as secretTreeFromPaths, Zi as parseStreamParamsFormPatch, _i as legacyAutoLinkIds, b as CAP_NAMES_WITH_STATUS, br as deviceExtensionCapability, cl as DeviceFeature, cr as createDeviceExtensionProvider, dl as errMsg$1, el as sleep$2, en as STREAM_PROFILE_META, hr as defineExtensionSlotProvider, il as userError, it as DiscoveryProposalBodySchema, jc as isSecretClear, k as ConditionMirror, kc as isKeychainStoredField, kr as enumerateItemArrayFields, kt as MINUTES_PER_DAY, li as isKernelDerivedFeature, ll as DeviceRole, mc as defineRecordKinds, mt as FieldClaimSchema, nl as toSecretFieldView, nt as DeviceStatusSchema, oc as collectZodSecretPaths$1, pa as reconcileReportedFeatures, pl as EventCategory$1, ps as BaseAddon, pt as FieldClaimModeSchema, q as DEVICE_TEMPLATE_FILTERS, rl as transformSecretWrite, rt as DeviceTombstoneSchema, s as ALL_CAPABILITY_DEFINITIONS, sc as commandEffect, tc as auditedFields, ts as implementedMethodsOf$1, ul as DeviceType$1, v as CAMERA_SWITCH_ORDER, vc as expandCapMethods$1, wc as isCommand$1, za as runtimeStatePolicyFor } from "../../dist-
|
|
1
|
+
import { Ar as enumerateSchemaFields, Bn as canonicalIconKey, Ec as isDeviceConfigCap, Er as deviceStatusCapability, Fa as resolveTemplateRef, Fr as expandContainer, J as DEVICE_TEMPLATE_MAX_LENGTH, Jc as resolveSecretMarkers, Jr as generateDeviceAlias, Js as WELL_KNOWN_TAB_MAP, Ka as settleDeviceFeatures, Kr as formatMinutes, Ln as buildStreamParamsConfigSchema, Nc as isSecretMarker, Pc as isSecretMarkerLike, Qa as siteZoneKey, R as DAY_NAMES, Ra as runtimeFieldUnit, Si as locationIconKey, Sr as deviceManagerCapability, Tr as deviceStateCapability, Un as checkDeviceAlias, Us as SECRET_CLEAR, Wi as normalizeUnit, Y as DEVICE_TEMPLATE_MAX_OUTPUT, Z as DEVICE_TEMPLATE_VALUES_CAP, Zc as secretTreeFromPaths, Zi as parseStreamParamsFormPatch, _i as legacyAutoLinkIds, b as CAP_NAMES_WITH_STATUS, br as deviceExtensionCapability, cl as DeviceFeature, cr as createDeviceExtensionProvider, dl as errMsg$1, el as sleep$2, en as STREAM_PROFILE_META, hr as defineExtensionSlotProvider, il as userError, it as DiscoveryProposalBodySchema, jc as isSecretClear, k as ConditionMirror, kc as isKeychainStoredField, kr as enumerateItemArrayFields, kt as MINUTES_PER_DAY, li as isKernelDerivedFeature, ll as DeviceRole, mc as defineRecordKinds, mt as FieldClaimSchema, nl as toSecretFieldView, nt as DeviceStatusSchema, oc as collectZodSecretPaths$1, pa as reconcileReportedFeatures, pl as EventCategory$1, ps as BaseAddon, pt as FieldClaimModeSchema, q as DEVICE_TEMPLATE_FILTERS, rl as transformSecretWrite, rt as DeviceTombstoneSchema, s as ALL_CAPABILITY_DEFINITIONS, sc as commandEffect, tc as auditedFields, ts as implementedMethodsOf$1, ul as DeviceType$1, v as CAMERA_SWITCH_ORDER, vc as expandCapMethods$1, wc as isCommand$1, za as runtimeStatePolicyFor } from "../../dist-B8dBvJJK.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
3
|
import { a as redactLogText, i as redactLogMeta, n as isSecretArgumentKey } from "../../log-redactor-XLDrPzOi.mjs";
|
|
4
|
-
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-
|
|
4
|
+
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-C2IbabFp.mjs";
|
|
5
5
|
import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
|
|
6
6
|
import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
|
|
7
7
|
import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-u6xQA6r7.mjs";
|
|
@@ -451,6 +451,7 @@ function toDeviceInfo(addonId, device, metadata = null, metaRow = null) {
|
|
|
451
451
|
...metaRow?.linkDeviceId !== void 0 ? { linkDeviceId: metaRow.linkDeviceId } : {},
|
|
452
452
|
...metaRow?.primaryChildEntityId !== void 0 ? { primaryChildEntityId: metaRow.primaryChildEntityId } : {},
|
|
453
453
|
...metaRow?.childLayout !== void 0 ? { childLayout: metaRow.childLayout } : {},
|
|
454
|
+
...metaRow?.primaryChildPreference !== void 0 ? { primaryChildPreference: metaRow.primaryChildPreference } : {},
|
|
454
455
|
...metaRow?.display !== void 0 ? { display: metaRow.display } : {}
|
|
455
456
|
};
|
|
456
457
|
}
|
|
@@ -2895,6 +2896,7 @@ async function listAll(pctx, input) {
|
|
|
2895
2896
|
...m.linkDeviceId !== void 0 ? { linkDeviceId: m.linkDeviceId } : {},
|
|
2896
2897
|
...m.primaryChildEntityId !== void 0 ? { primaryChildEntityId: m.primaryChildEntityId } : {},
|
|
2897
2898
|
...m.childLayout !== void 0 ? { childLayout: m.childLayout } : {},
|
|
2899
|
+
...m.primaryChildPreference !== void 0 ? { primaryChildPreference: m.primaryChildPreference } : {},
|
|
2898
2900
|
...m.display !== void 0 ? { display: m.display } : {},
|
|
2899
2901
|
...(() => {
|
|
2900
2902
|
if (slim) return {};
|
|
@@ -2946,6 +2948,7 @@ async function getDevice(pctx, input) {
|
|
|
2946
2948
|
...m.linkDeviceId !== void 0 ? { linkDeviceId: m.linkDeviceId } : {},
|
|
2947
2949
|
...m.primaryChildEntityId !== void 0 ? { primaryChildEntityId: m.primaryChildEntityId } : {},
|
|
2948
2950
|
...m.childLayout !== void 0 ? { childLayout: m.childLayout } : {},
|
|
2951
|
+
...m.primaryChildPreference !== void 0 ? { primaryChildPreference: m.primaryChildPreference } : {},
|
|
2949
2952
|
...m.display !== void 0 ? { display: m.display } : {},
|
|
2950
2953
|
...sourceInfoGetDevice !== void 0 ? { sourceInfo: sourceInfoGetDevice } : {}
|
|
2951
2954
|
};
|
|
@@ -3024,6 +3027,7 @@ function projectChildren(pctx, parentDeviceId, ownerAddonId, childRows, liveChil
|
|
|
3024
3027
|
...m.linkDeviceId !== void 0 ? { linkDeviceId: m.linkDeviceId } : {},
|
|
3025
3028
|
...m.primaryChildEntityId !== void 0 ? { primaryChildEntityId: m.primaryChildEntityId } : {},
|
|
3026
3029
|
...m.childLayout !== void 0 ? { childLayout: m.childLayout } : {},
|
|
3030
|
+
...m.primaryChildPreference !== void 0 ? { primaryChildPreference: m.primaryChildPreference } : {},
|
|
3027
3031
|
...m.display !== void 0 ? { display: m.display } : {},
|
|
3028
3032
|
...sourceInfoChild !== void 0 ? { sourceInfo: sourceInfoChild } : {}
|
|
3029
3033
|
});
|
|
@@ -4506,6 +4510,273 @@ async function getWireableFields(deps, input) {
|
|
|
4506
4510
|
return { caps };
|
|
4507
4511
|
}
|
|
4508
4512
|
//#endregion
|
|
4513
|
+
//#region src/builtins/device-manager/device-search.ts
|
|
4514
|
+
/** A shortlist, not a second list. */
|
|
4515
|
+
var SUGGESTED_MAX = 8;
|
|
4516
|
+
function sortKeyOf(c) {
|
|
4517
|
+
return [
|
|
4518
|
+
c.compatible ? 0 : 1,
|
|
4519
|
+
c.device.type,
|
|
4520
|
+
c.device.name.toLowerCase(),
|
|
4521
|
+
c.device.id
|
|
4522
|
+
];
|
|
4523
|
+
}
|
|
4524
|
+
function compareKeys(a, b) {
|
|
4525
|
+
if (a[0] !== b[0]) return a[0] - b[0];
|
|
4526
|
+
if (a[1] !== b[1]) return a[1] < b[1] ? -1 : 1;
|
|
4527
|
+
if (a[2] !== b[2]) return a[2] < b[2] ? -1 : 1;
|
|
4528
|
+
return a[3] - b[3];
|
|
4529
|
+
}
|
|
4530
|
+
function encodeCursor(key) {
|
|
4531
|
+
return Buffer.from(JSON.stringify(key), "utf8").toString("base64url");
|
|
4532
|
+
}
|
|
4533
|
+
function decodeCursor(cursor) {
|
|
4534
|
+
try {
|
|
4535
|
+
const parsed = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
4536
|
+
if (!Array.isArray(parsed) || parsed.length !== 4) return null;
|
|
4537
|
+
const c = parsed[0];
|
|
4538
|
+
const t = parsed[1];
|
|
4539
|
+
const n = parsed[2];
|
|
4540
|
+
const i = parsed[3];
|
|
4541
|
+
if (typeof c !== "number" || typeof t !== "string" || typeof n !== "string") return null;
|
|
4542
|
+
if (typeof i !== "number") return null;
|
|
4543
|
+
return [
|
|
4544
|
+
c,
|
|
4545
|
+
t,
|
|
4546
|
+
n,
|
|
4547
|
+
i
|
|
4548
|
+
];
|
|
4549
|
+
} catch {
|
|
4550
|
+
return null;
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
/** `colourTemperature` / `battery_level` → `Colour temperature` / `Battery level`. */
|
|
4554
|
+
function labelOfPath(path) {
|
|
4555
|
+
const words = (path.split(".").pop() ?? path).replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim().toLowerCase();
|
|
4556
|
+
return words.length === 0 ? path : words.charAt(0).toUpperCase() + words.slice(1);
|
|
4557
|
+
}
|
|
4558
|
+
function readAtPath(status, path) {
|
|
4559
|
+
let cursor = status;
|
|
4560
|
+
for (const segment of path.split(".")) {
|
|
4561
|
+
if (cursor === null || typeof cursor !== "object") return null;
|
|
4562
|
+
cursor = Reflect.get(cursor, segment);
|
|
4563
|
+
}
|
|
4564
|
+
if (typeof cursor === "string") return cursor;
|
|
4565
|
+
if (typeof cursor === "number" || typeof cursor === "boolean") return String(cursor);
|
|
4566
|
+
return null;
|
|
4567
|
+
}
|
|
4568
|
+
function matches(selected, value) {
|
|
4569
|
+
if (selected === void 0 || selected.length === 0) return true;
|
|
4570
|
+
return value !== null && selected.includes(value);
|
|
4571
|
+
}
|
|
4572
|
+
function facetList(counts) {
|
|
4573
|
+
return [...counts.entries()].map(([value, count]) => ({
|
|
4574
|
+
value,
|
|
4575
|
+
count
|
|
4576
|
+
})).sort((a, b) => b.count - a.count || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0));
|
|
4577
|
+
}
|
|
4578
|
+
function bump(counts, key) {
|
|
4579
|
+
if (key === null) return;
|
|
4580
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
4581
|
+
}
|
|
4582
|
+
async function searchDevices(deps, input) {
|
|
4583
|
+
const [fleet, labels] = await Promise.all([deps.listDevices(), deps.integrationLabels()]);
|
|
4584
|
+
const requiredCaps = input.requires?.caps ?? [];
|
|
4585
|
+
const mode = input.requires?.mode ?? "any";
|
|
4586
|
+
const candidates = fleet.map((device) => {
|
|
4587
|
+
const integrationId = device.integrationId ?? null;
|
|
4588
|
+
const integrationLabel = integrationId === null ? null : labels.get(integrationId) ?? null;
|
|
4589
|
+
return {
|
|
4590
|
+
device,
|
|
4591
|
+
integrationId,
|
|
4592
|
+
integrationLabel,
|
|
4593
|
+
haystack: [
|
|
4594
|
+
device.name,
|
|
4595
|
+
device.location ?? "",
|
|
4596
|
+
device.type,
|
|
4597
|
+
integrationId ?? "",
|
|
4598
|
+
integrationLabel ?? "",
|
|
4599
|
+
String(device.id)
|
|
4600
|
+
].join("\0").toLowerCase(),
|
|
4601
|
+
matchedCaps: [],
|
|
4602
|
+
compatible: requiredCaps.length === 0
|
|
4603
|
+
};
|
|
4604
|
+
});
|
|
4605
|
+
if (input.ids !== void 0) return resolveIds(deps, input, candidates);
|
|
4606
|
+
const needle = (input.text ?? "").trim().toLowerCase();
|
|
4607
|
+
const textPass = needle === "" ? candidates : candidates.filter((c) => c.haystack.includes(needle));
|
|
4608
|
+
if (requiredCaps.length > 0) {
|
|
4609
|
+
const bound = await deps.boundCaps(textPass.map((c) => c.device.id));
|
|
4610
|
+
for (const c of textPass) {
|
|
4611
|
+
const have = new Set(bound.get(c.device.id) ?? []);
|
|
4612
|
+
const matched = requiredCaps.filter((cap) => have.has(cap));
|
|
4613
|
+
c.matchedCaps = matched;
|
|
4614
|
+
c.compatible = mode === "all" ? matched.length === requiredCaps.length : matched.length > 0;
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4617
|
+
const locationCounts = /* @__PURE__ */ new Map();
|
|
4618
|
+
const integrationCounts = /* @__PURE__ */ new Map();
|
|
4619
|
+
const typeCounts = /* @__PURE__ */ new Map();
|
|
4620
|
+
const listed = [];
|
|
4621
|
+
let compatibleTotal = 0;
|
|
4622
|
+
let hiddenIncompatible = 0;
|
|
4623
|
+
const filters = input.filters;
|
|
4624
|
+
for (const c of textPass) {
|
|
4625
|
+
const okLocation = matches(filters?.locations, c.device.location);
|
|
4626
|
+
const okIntegration = matches(filters?.integrationIds, c.integrationId);
|
|
4627
|
+
const okType = matches(filters?.types, c.device.type);
|
|
4628
|
+
if (c.compatible) {
|
|
4629
|
+
if (okIntegration && okType) bump(locationCounts, c.device.location);
|
|
4630
|
+
if (okLocation && okType) bump(integrationCounts, c.integrationId);
|
|
4631
|
+
if (okLocation && okIntegration) bump(typeCounts, c.device.type);
|
|
4632
|
+
}
|
|
4633
|
+
if (!(okLocation && okIntegration && okType)) continue;
|
|
4634
|
+
if (c.compatible) {
|
|
4635
|
+
compatibleTotal += 1;
|
|
4636
|
+
listed.push(c);
|
|
4637
|
+
} else {
|
|
4638
|
+
hiddenIncompatible += 1;
|
|
4639
|
+
if (input.includeIncompatible === true) listed.push(c);
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
const keyed = listed.map((c) => ({
|
|
4643
|
+
c,
|
|
4644
|
+
key: sortKeyOf(c)
|
|
4645
|
+
})).sort((a, b) => compareKeys(a.key, b.key));
|
|
4646
|
+
const limit = Math.min(input.limit ?? 50, 200);
|
|
4647
|
+
let start = 0;
|
|
4648
|
+
if (input.cursor !== void 0 && input.cursor !== null) {
|
|
4649
|
+
const after = decodeCursor(input.cursor);
|
|
4650
|
+
if (after === null) deps.logger.warn("deviceManager.search: undecodable cursor — restarting from the first page");
|
|
4651
|
+
else {
|
|
4652
|
+
const next = keyed.findIndex((k) => compareKeys(k.key, after) > 0);
|
|
4653
|
+
start = next === -1 ? keyed.length : next;
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4656
|
+
const page = keyed.slice(start, start + limit).map((k) => k.c);
|
|
4657
|
+
const last = keyed[start + limit - 1];
|
|
4658
|
+
const nextCursor = start + limit < keyed.length && last !== void 0 ? encodeCursor(last.key) : null;
|
|
4659
|
+
const suggestedCandidates = start === 0 ? suggestFor(input, keyed, fleet) : [];
|
|
4660
|
+
const items = await withValues(deps, [...page, ...suggestedCandidates], requiredCaps);
|
|
4661
|
+
const byId = new Map(items.map((i) => [i.id, i]));
|
|
4662
|
+
const facets = {
|
|
4663
|
+
locations: facetList(locationCounts),
|
|
4664
|
+
integrations: [...integrationCounts.entries()].map(([id, count]) => ({
|
|
4665
|
+
id,
|
|
4666
|
+
label: labels.get(id) ?? id,
|
|
4667
|
+
count
|
|
4668
|
+
})).sort((a, b) => b.count - a.count || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)),
|
|
4669
|
+
types: facetList(typeCounts)
|
|
4670
|
+
};
|
|
4671
|
+
return {
|
|
4672
|
+
items: page.map((c) => byId.get(c.device.id)).filter(isItem),
|
|
4673
|
+
nextCursor,
|
|
4674
|
+
total: listed.length,
|
|
4675
|
+
compatibleTotal,
|
|
4676
|
+
fleetTotal: fleet.length,
|
|
4677
|
+
hiddenIncompatible,
|
|
4678
|
+
facets,
|
|
4679
|
+
suggested: suggestedCandidates.map((c) => byId.get(c.device.id)).filter(isItem),
|
|
4680
|
+
missingIds: []
|
|
4681
|
+
};
|
|
4682
|
+
}
|
|
4683
|
+
function isItem(value) {
|
|
4684
|
+
return value !== void 0;
|
|
4685
|
+
}
|
|
4686
|
+
/** Compatible devices at the context device's location, in list order. */
|
|
4687
|
+
function suggestFor(input, keyed, fleet) {
|
|
4688
|
+
if (input.contextDeviceId === void 0) return [];
|
|
4689
|
+
const context = fleet.find((d) => d.id === input.contextDeviceId);
|
|
4690
|
+
if (context === void 0 || context.location === null) return [];
|
|
4691
|
+
return keyed.map((k) => k.c).filter((c) => c.compatible && c.device.location === context.location && c.device.id !== context.id).slice(0, SUGGESTED_MAX);
|
|
4692
|
+
}
|
|
4693
|
+
async function resolveIds(deps, input, candidates) {
|
|
4694
|
+
const requiredCaps = input.requires?.caps ?? [];
|
|
4695
|
+
const mode = input.requires?.mode ?? "any";
|
|
4696
|
+
const byId = new Map(candidates.map((c) => [c.device.id, c]));
|
|
4697
|
+
const asked = [...new Set(input.ids ?? [])];
|
|
4698
|
+
const found = [];
|
|
4699
|
+
const missingIds = [];
|
|
4700
|
+
for (const id of asked) {
|
|
4701
|
+
const c = byId.get(id);
|
|
4702
|
+
if (c === void 0) missingIds.push(id);
|
|
4703
|
+
else found.push(c);
|
|
4704
|
+
}
|
|
4705
|
+
if (requiredCaps.length > 0 && found.length > 0) {
|
|
4706
|
+
const bound = await deps.boundCaps(found.map((c) => c.device.id));
|
|
4707
|
+
for (const c of found) {
|
|
4708
|
+
const have = new Set(bound.get(c.device.id) ?? []);
|
|
4709
|
+
c.matchedCaps = requiredCaps.filter((cap) => have.has(cap));
|
|
4710
|
+
c.compatible = mode === "all" ? c.matchedCaps.length === requiredCaps.length : c.matchedCaps.length > 0;
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
const items = await withValues(deps, found, requiredCaps);
|
|
4714
|
+
return {
|
|
4715
|
+
items,
|
|
4716
|
+
nextCursor: null,
|
|
4717
|
+
total: items.length,
|
|
4718
|
+
compatibleTotal: found.filter((c) => c.compatible).length,
|
|
4719
|
+
fleetTotal: candidates.length,
|
|
4720
|
+
hiddenIncompatible: found.filter((c) => !c.compatible).length,
|
|
4721
|
+
facets: {
|
|
4722
|
+
locations: [],
|
|
4723
|
+
integrations: [],
|
|
4724
|
+
types: []
|
|
4725
|
+
},
|
|
4726
|
+
suggested: [],
|
|
4727
|
+
missingIds
|
|
4728
|
+
};
|
|
4729
|
+
}
|
|
4730
|
+
/**
|
|
4731
|
+
* Build the wire items for a set of candidates, reading live status once for
|
|
4732
|
+
* the whole set. A failed read is `reading: null` on that value — the device
|
|
4733
|
+
* and its values stay listed.
|
|
4734
|
+
*/
|
|
4735
|
+
async function withValues(deps, candidates, requiredCaps) {
|
|
4736
|
+
const unique = [...new Map(candidates.map((c) => [c.device.id, c])).values()];
|
|
4737
|
+
let status = {};
|
|
4738
|
+
if (requiredCaps.length > 0 && unique.some((c) => c.compatible && c.matchedCaps.length > 0)) try {
|
|
4739
|
+
status = await deps.readStatus(unique.filter((c) => c.compatible && c.matchedCaps.length > 0).map((c) => c.device.id), requiredCaps);
|
|
4740
|
+
} catch (err) {
|
|
4741
|
+
deps.logger.warn("deviceManager.search: status read failed — readings left empty", { meta: {
|
|
4742
|
+
error: errMsg$1(err),
|
|
4743
|
+
devices: unique.length
|
|
4744
|
+
} });
|
|
4745
|
+
}
|
|
4746
|
+
return unique.map((c) => {
|
|
4747
|
+
const values = [];
|
|
4748
|
+
for (const cap of c.compatible ? c.matchedCaps : []) {
|
|
4749
|
+
const fields = deps.fieldsOf(cap);
|
|
4750
|
+
if (fields === null) continue;
|
|
4751
|
+
const capStatus = status[String(c.device.id)]?.[cap];
|
|
4752
|
+
for (const f of fields.fields) {
|
|
4753
|
+
if (f.item === true) continue;
|
|
4754
|
+
values.push({
|
|
4755
|
+
cap,
|
|
4756
|
+
path: f.path,
|
|
4757
|
+
label: labelOfPath(f.path),
|
|
4758
|
+
reading: readAtPath(capStatus, f.path),
|
|
4759
|
+
unit: null,
|
|
4760
|
+
...f.quantity !== void 0 ? { quantity: f.quantity } : {}
|
|
4761
|
+
});
|
|
4762
|
+
}
|
|
4763
|
+
}
|
|
4764
|
+
const d = c.device;
|
|
4765
|
+
return {
|
|
4766
|
+
id: d.id,
|
|
4767
|
+
name: d.name,
|
|
4768
|
+
type: d.type,
|
|
4769
|
+
location: d.location,
|
|
4770
|
+
integrationId: c.integrationId,
|
|
4771
|
+
integrationLabel: c.integrationLabel,
|
|
4772
|
+
online: d.online,
|
|
4773
|
+
disabled: d.disabled,
|
|
4774
|
+
compatible: c.compatible,
|
|
4775
|
+
values
|
|
4776
|
+
};
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
//#endregion
|
|
4509
4780
|
//#region src/builtins/device-manager/discovery-orchestrator.ts
|
|
4510
4781
|
/** A provider without the method (an older addon) or one that fails it is a legacy provider. */
|
|
4511
4782
|
async function declaredModes(provider) {
|
|
@@ -5040,6 +5311,7 @@ function toLinkCandidate(row) {
|
|
|
5040
5311
|
type,
|
|
5041
5312
|
stableId: row.meta.stableId,
|
|
5042
5313
|
...row.meta.primaryChildEntityId !== void 0 ? { primaryChildEntityId: row.meta.primaryChildEntityId } : {},
|
|
5314
|
+
...row.meta.primaryChildPreference !== void 0 ? { primaryChildPreference: row.meta.primaryChildPreference } : {},
|
|
5043
5315
|
...row.meta.role !== void 0 ? { role: row.meta.role } : {},
|
|
5044
5316
|
name: row.meta.name
|
|
5045
5317
|
};
|
|
@@ -6460,10 +6732,10 @@ async function reloadMigratedDevices(pctx, targets) {
|
|
|
6460
6732
|
* removeDevice), config persistence (persistConfig, loadConfig), the meta
|
|
6461
6733
|
* surface load (loadMeta, loadRuntimeState), every meta setter (setName,
|
|
6462
6734
|
* setLocation, setType, setIntegrationId, setLinkDeviceId,
|
|
6463
|
-
* setPrimaryChildEntityId, setChildLayout,
|
|
6464
|
-
* applyInitialMeta, setMetadata, setDisabled), and the
|
|
6465
|
-
* (listLocations, addLocation, removeLocation,
|
|
6466
|
-
* map (listLocationIcons, setLocationIcon).
|
|
6735
|
+
* setPrimaryChildEntityId, setChildLayout, setPrimaryChildPreference,
|
|
6736
|
+
* setRole, setDisplay, applyInitialMeta, setMetadata, setDisabled), and the
|
|
6737
|
+
* location registry (listLocations, addLocation, removeLocation,
|
|
6738
|
+
* renameLocation) with its icon map (listLocationIcons, setLocationIcon).
|
|
6467
6739
|
*
|
|
6468
6740
|
* EXACT ordering and side effects preserved — notably registerDevice's
|
|
6469
6741
|
* name-precedence reconcile + field-preservation spreads, the
|
|
@@ -7442,6 +7714,32 @@ async function setChildLayout(pctx, input) {
|
|
|
7442
7714
|
});
|
|
7443
7715
|
}
|
|
7444
7716
|
/**
|
|
7717
|
+
* Set (or replace) a container's provider-declared primary-child preference:
|
|
7718
|
+
* accessory `childKey`s, most preferred first. Mirrors {@link setChildLayout}.
|
|
7719
|
+
* The operator's `primaryChildEntityId` still wins over it at resolution.
|
|
7720
|
+
*/
|
|
7721
|
+
async function setPrimaryChildPreference(pctx, input) {
|
|
7722
|
+
const { deviceId, primaryChildPreference } = input;
|
|
7723
|
+
await pctx.metaStore.withMetaWriteLock(async () => {
|
|
7724
|
+
if (!await pctx.metaStore.resolvePersistedById(deviceId)) throw new Error(`[device-manager] setPrimaryChildPreference: unknown device id=${deviceId}`);
|
|
7725
|
+
await pctx.metaStore.rows.patch(deviceId, { primaryChildPreference });
|
|
7726
|
+
});
|
|
7727
|
+
pctx.host.ctx.eventBus.emit({
|
|
7728
|
+
id: randomUUID(),
|
|
7729
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
7730
|
+
source: {
|
|
7731
|
+
type: "device",
|
|
7732
|
+
id: deviceId
|
|
7733
|
+
},
|
|
7734
|
+
category: EventCategory$1.DeviceMetaChanged,
|
|
7735
|
+
data: {
|
|
7736
|
+
deviceId,
|
|
7737
|
+
field: "primaryChildPreference",
|
|
7738
|
+
value: primaryChildPreference
|
|
7739
|
+
}
|
|
7740
|
+
});
|
|
7741
|
+
}
|
|
7742
|
+
/**
|
|
7445
7743
|
* Stamp (or update) the semantic role on the device's meta row.
|
|
7446
7744
|
* Called by the kernel's `create()` / `spawnAccessoryChild`
|
|
7447
7745
|
* pre-seed when `initialMeta.role` is set (analogous to
|
|
@@ -9636,6 +9934,10 @@ var DEVICE_ROWS_COLUMNS = [
|
|
|
9636
9934
|
name: "childLayout",
|
|
9637
9935
|
type: "JSON"
|
|
9638
9936
|
},
|
|
9937
|
+
{
|
|
9938
|
+
name: "primaryChildPreference",
|
|
9939
|
+
type: "JSON"
|
|
9940
|
+
},
|
|
9639
9941
|
{
|
|
9640
9942
|
name: "role",
|
|
9641
9943
|
type: "TEXT"
|
|
@@ -9761,6 +10063,7 @@ function decodeDeviceRow(data) {
|
|
|
9761
10063
|
const role = readString(data["role"]);
|
|
9762
10064
|
const alias = readString(data["alias"]);
|
|
9763
10065
|
const rawChildLayout = data["childLayout"];
|
|
10066
|
+
const primaryChildPreference = readStringArray(data["primaryChildPreference"]);
|
|
9764
10067
|
const rawDisplay = data["display"];
|
|
9765
10068
|
const rawMetadata = data["metadata"];
|
|
9766
10069
|
return {
|
|
@@ -9781,6 +10084,7 @@ function decodeDeviceRow(data) {
|
|
|
9781
10084
|
...linkDeviceId !== void 0 ? { linkDeviceId } : {},
|
|
9782
10085
|
...primaryChildEntityId !== void 0 ? { primaryChildEntityId } : {},
|
|
9783
10086
|
...isChildLayout(rawChildLayout) ? { childLayout: rawChildLayout } : {},
|
|
10087
|
+
...primaryChildPreference !== void 0 ? { primaryChildPreference } : {},
|
|
9784
10088
|
...role !== void 0 ? { role } : {},
|
|
9785
10089
|
...isPlainObject$1(rawDisplay) ? { display: toDisplayOverride(rawDisplay) } : {}
|
|
9786
10090
|
},
|
|
@@ -9825,6 +10129,7 @@ function encodeDeviceRow(meta, extra = {}) {
|
|
|
9825
10129
|
linkDeviceId: meta.linkDeviceId ?? null,
|
|
9826
10130
|
primaryChildEntityId: meta.primaryChildEntityId ?? null,
|
|
9827
10131
|
childLayout: meta.childLayout ?? null,
|
|
10132
|
+
primaryChildPreference: meta.primaryChildPreference === void 0 ? null : [...meta.primaryChildPreference],
|
|
9828
10133
|
role: meta.role ?? null,
|
|
9829
10134
|
display: meta.display ?? null
|
|
9830
10135
|
};
|
|
@@ -13017,6 +13322,46 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
13017
13322
|
...this.deviceFormSecrets ? { deviceFormSecrets: this.deviceFormSecrets } : {}
|
|
13018
13323
|
};
|
|
13019
13324
|
}
|
|
13325
|
+
/**
|
|
13326
|
+
* `deviceManager.search` — the picker query (see `device-search.ts`). The
|
|
13327
|
+
* fleet is `listAll`, the values are the `getWireableFields` derivation over
|
|
13328
|
+
* each device's own bindings, the readings are the status aggregate.
|
|
13329
|
+
*/
|
|
13330
|
+
searchDevices(pctx, input) {
|
|
13331
|
+
const registry = this.capabilityRegistry;
|
|
13332
|
+
return searchDevices({
|
|
13333
|
+
listDevices: () => listAll(pctx, { projection: "slim" }),
|
|
13334
|
+
boundCaps: async (deviceIds) => {
|
|
13335
|
+
const batch = await getBindingsBatch(this.bindingsDeps, { deviceIds });
|
|
13336
|
+
const out = /* @__PURE__ */ new Map();
|
|
13337
|
+
for (const { deviceId, entries } of batch) out.set(deviceId, entries.map((e) => e.capName).filter((cap) => {
|
|
13338
|
+
const def = registry?.getDefinition(cap);
|
|
13339
|
+
return def !== void 0 && def !== null && def.kind !== "wrapper";
|
|
13340
|
+
}));
|
|
13341
|
+
return out;
|
|
13342
|
+
},
|
|
13343
|
+
fieldsOf: (cap) => {
|
|
13344
|
+
const def = registry?.getDefinition(cap);
|
|
13345
|
+
return def ? wireableEntryForDef(cap, def) : null;
|
|
13346
|
+
},
|
|
13347
|
+
readStatus: (deviceIds, caps) => getDeviceStatusAggregateBatch(this.aggregationDeps, {
|
|
13348
|
+
deviceIds,
|
|
13349
|
+
caps
|
|
13350
|
+
}),
|
|
13351
|
+
integrationLabels: async () => {
|
|
13352
|
+
const api = this.ctx.api;
|
|
13353
|
+
if (api === void 0) return /* @__PURE__ */ new Map();
|
|
13354
|
+
try {
|
|
13355
|
+
const list = await api.integrations.list.query();
|
|
13356
|
+
return new Map(list.map((i) => [i.id, i.name]));
|
|
13357
|
+
} catch (err) {
|
|
13358
|
+
this.ctx.logger.warn("deviceManager.search: integration names unavailable", { meta: { error: errMsg$1(err) } });
|
|
13359
|
+
return /* @__PURE__ */ new Map();
|
|
13360
|
+
}
|
|
13361
|
+
},
|
|
13362
|
+
logger: this.ctx.logger
|
|
13363
|
+
}, input);
|
|
13364
|
+
}
|
|
13020
13365
|
async getDeviceAggregate(deviceId, kind) {
|
|
13021
13366
|
return getDeviceAggregate(this.aggregationDeps, deviceId, kind);
|
|
13022
13367
|
}
|
|
@@ -13198,6 +13543,7 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
13198
13543
|
setLinkDeviceId: (input) => setLinkDeviceId(pctx, input),
|
|
13199
13544
|
setPrimaryChildEntityId: (input) => setPrimaryChildEntityId(pctx, input),
|
|
13200
13545
|
setChildLayout: (input) => setChildLayout(pctx, input),
|
|
13546
|
+
setPrimaryChildPreference: (input) => setPrimaryChildPreference(pctx, input),
|
|
13201
13547
|
setRole: (input) => setRole(pctx, input),
|
|
13202
13548
|
setDisplay: (input) => setDisplay(pctx, input),
|
|
13203
13549
|
getRoleDisplayDefaults: (input) => getRoleDisplayDefaults(pctx, input),
|
|
@@ -13350,7 +13696,8 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
13350
13696
|
},
|
|
13351
13697
|
getDeviceStatusAggregate: async (input) => this.getDeviceStatusAggregate(input),
|
|
13352
13698
|
getDeviceStatusAggregateBatch: async (input) => getDeviceStatusAggregateBatch(this.aggregationDeps, input),
|
|
13353
|
-
getWireableFields: (input) => getWireableFields(this.aggregationDeps, input)
|
|
13699
|
+
getWireableFields: (input) => getWireableFields(this.aggregationDeps, input),
|
|
13700
|
+
search: (input) => this.searchDevices(pctx, input)
|
|
13354
13701
|
};
|
|
13355
13702
|
this.ctx.logger.info("registered device-manager capability", { meta: { liveRegistry: registry !== null } });
|
|
13356
13703
|
if (registry) {
|
|
@@ -147,6 +147,12 @@ export declare function setPrimaryChildEntityId(pctx: ProviderContext, input: Pa
|
|
|
147
147
|
*/
|
|
148
148
|
export declare function setChildLayout(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setChildLayout"]>[0]): ReturnType<IDeviceManagerProvider["setChildLayout"]>;
|
|
149
149
|
/**
|
|
150
|
+
* Set (or replace) a container's provider-declared primary-child preference:
|
|
151
|
+
* accessory `childKey`s, most preferred first. Mirrors {@link setChildLayout}.
|
|
152
|
+
* The operator's `primaryChildEntityId` still wins over it at resolution.
|
|
153
|
+
*/
|
|
154
|
+
export declare function setPrimaryChildPreference(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setPrimaryChildPreference"]>[0]): ReturnType<IDeviceManagerProvider["setPrimaryChildPreference"]>;
|
|
155
|
+
/**
|
|
150
156
|
* Stamp (or update) the semantic role on the device's meta row.
|
|
151
157
|
* Called by the kernel's `create()` / `spawnAccessoryChild`
|
|
152
158
|
* pre-seed when `initialMeta.role` is set (analogous to
|
|
@@ -161,6 +161,10 @@ export interface PersistedDeviceMeta {
|
|
|
161
161
|
* re-sync-stable accessory `stableIdSuffix`. Set at create, preserved across
|
|
162
162
|
* re-register/restore — same lifecycle as `primaryChildEntityId`. */
|
|
163
163
|
childLayout?: ChildLayout;
|
|
164
|
+
/** Provider-declared primary-child preference of a CONTAINER: accessory
|
|
165
|
+
* `childKey`s, most preferred first. Set at create, preserved across
|
|
166
|
+
* re-register/restore — same lifecycle as `childLayout`. */
|
|
167
|
+
primaryChildPreference?: readonly string[];
|
|
164
168
|
/** Semantic role string (`DeviceRole`), stamped at create via `setRole`.
|
|
165
169
|
* Optional: only present for accessory children that carry a known role
|
|
166
170
|
* (e.g. 'numeric-sensor', 'binary-sensor'). `null` clears a previous role. */
|
|
@@ -198,6 +198,7 @@ export interface DeviceRowPatch {
|
|
|
198
198
|
readonly linkDeviceId?: number | null;
|
|
199
199
|
readonly primaryChildEntityId?: string | null;
|
|
200
200
|
readonly childLayout?: ChildLayout | null;
|
|
201
|
+
readonly primaryChildPreference?: readonly string[] | null;
|
|
201
202
|
readonly role?: string | null;
|
|
202
203
|
readonly display?: DeviceDisplayOverride | null;
|
|
203
204
|
readonly metadata?: Record<string, unknown> | null;
|
|
@@ -213,7 +214,7 @@ export interface DeviceRowPatch {
|
|
|
213
214
|
* required here, and the type is what keeps it that way.
|
|
214
215
|
*
|
|
215
216
|
* Columns NOT listed — `integrationId`, `linkDeviceId`, `primaryChildEntityId`,
|
|
216
|
-
* `childLayout`, `role`, `display`, `metadata` — are not in the statement at
|
|
217
|
+
* `childLayout`, `primaryChildPreference`, `role`, `display`, `metadata` — are not in the statement at
|
|
217
218
|
* all, so re-registering preserves them. The blob shape had to re-state each
|
|
218
219
|
* one to avoid clobbering it, and every field added since has been one more
|
|
219
220
|
* spread somebody had to remember.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `deviceManager.search` — the device → value picker's server side.
|
|
3
|
+
*
|
|
4
|
+
* Reuses the two sources that already exist and builds neither again:
|
|
5
|
+
* - the fleet is `listAll` (slim projection) — one registry, one filter for
|
|
6
|
+
* which devices the caller sees;
|
|
7
|
+
* - the values a device can supply for a cap are the `getWireableFields`
|
|
8
|
+
* derivation (`wireableEntryForDef`), restricted to the device's own
|
|
9
|
+
* bindings (D12: per-device aggregation walks `getBindings`, never the
|
|
10
|
+
* global cap list).
|
|
11
|
+
*
|
|
12
|
+
* Everything that costs a read per device (bindings, status) is paid only for
|
|
13
|
+
* what the answer needs: bindings once for the devices that survive the text
|
|
14
|
+
* filter and only when a cap is required, live readings only for the devices
|
|
15
|
+
* actually returned (a page, the suggestions, the resolved ids) — never the
|
|
16
|
+
* fleet.
|
|
17
|
+
*/
|
|
18
|
+
import type { DeviceInfo, DeviceSearchInput, DeviceSearchResult, DeviceValueOption, IScopedLogger } from "@camstack/types";
|
|
19
|
+
/** The wireable fields of one capability, as `wireableEntryForDef` derives them. */
|
|
20
|
+
export interface SearchCapFields {
|
|
21
|
+
readonly cap: string;
|
|
22
|
+
readonly fields: ReadonlyArray<{
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly item?: boolean;
|
|
25
|
+
readonly quantity?: DeviceValueOption["quantity"];
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/** Everything the search reads, injected so the module owns no registry of its own. */
|
|
29
|
+
export interface DeviceSearchDeps {
|
|
30
|
+
/** The caller's fleet (`listAll`, slim). */
|
|
31
|
+
readonly listDevices: () => Promise<readonly DeviceInfo[]>;
|
|
32
|
+
/** Capability names bound to each device, wrapper caps already dropped. */
|
|
33
|
+
readonly boundCaps: (deviceIds: readonly number[]) => Promise<ReadonlyMap<number, readonly string[]>>;
|
|
34
|
+
/** The wireable fields of a cap; `null` when it exposes none (a cap can still make a device compatible). */
|
|
35
|
+
readonly fieldsOf: (cap: string) => SearchCapFields | null;
|
|
36
|
+
/** Live status per device id (string key) per cap; a cap that could not be read is `null`. */
|
|
37
|
+
readonly readStatus: (deviceIds: readonly number[], caps: readonly string[]) => Promise<Readonly<Record<string, Readonly<Record<string, unknown>>>>>;
|
|
38
|
+
/** Integration id → display name. */
|
|
39
|
+
readonly integrationLabels: () => Promise<ReadonlyMap<string, string>>;
|
|
40
|
+
readonly logger: Pick<IScopedLogger, "warn">;
|
|
41
|
+
}
|
|
42
|
+
export declare function searchDevices(deps: DeviceSearchDeps, input: DeviceSearchInput): Promise<DeviceSearchResult>;
|
|
@@ -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-DVrLQr6W.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.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 { Ti as logDestinationCapability, ps as BaseAddon } from "../../dist-
|
|
1
|
+
import { Ti as logDestinationCapability, ps as BaseAddon } from "../../dist-B8dBvJJK.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
4
4
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -3,11 +3,11 @@ 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-
|
|
7
|
-
const require_device_ca = require("../../device-ca-
|
|
6
|
+
const require_dist = require("../../dist-DVrLQr6W.js");
|
|
7
|
+
const require_device_ca = require("../../device-ca-DAuMNieL.js");
|
|
8
8
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
9
|
-
const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-
|
|
10
|
-
const require_constants = require("../../constants-
|
|
9
|
+
const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-i0gANn4l.js");
|
|
10
|
+
const require_constants = require("../../constants-C4V2z-GT.js");
|
|
11
11
|
const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
13
13
|
let _camstack_types_node = require("@camstack/types/node");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ct as KEYCHAIN_RESET_TRIGGER_ACTOR, Tt as KeychainResetRecordSchema, Vc as normalizeSecretOwner, Wc as parseSecretRef, gi as keychainCapability, hi as keychainAdminCapability, mc as defineRecordKinds, pl as EventCategory, ps as BaseAddon, wt as KeychainAuditEntrySchema, yc as formatSecretScope } from "../../dist-
|
|
2
|
-
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-
|
|
1
|
+
import { Ct as KEYCHAIN_RESET_TRIGGER_ACTOR, Tt as KeychainResetRecordSchema, Vc as normalizeSecretOwner, Wc as parseSecretRef, gi as keychainCapability, hi as keychainAdminCapability, mc as defineRecordKinds, pl as EventCategory, ps as BaseAddon, wt as KeychainAuditEntrySchema, yc as formatSecretScope } from "../../dist-B8dBvJJK.mjs";
|
|
2
|
+
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-CXPTrORC.mjs";
|
|
3
3
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
4
|
-
import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-
|
|
5
|
-
import { a as MESH_CA_KEY_REF } from "../../constants-
|
|
4
|
+
import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-lRhfbNBc.mjs";
|
|
5
|
+
import { a as MESH_CA_KEY_REF } from "../../constants-D5oNuYLD.mjs";
|
|
6
6
|
import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
|
|
7
7
|
import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
|
|
@@ -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-DVrLQr6W.js");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Gt as RECORDING_SOURCE_CAMSTACK_ADDON, Jt as RecordingStatusSchema, dl as errMsg, ki as mayWriteToLocation, lc as createEvent, pl as EventCategory, ps as BaseAddon } from "../../dist-
|
|
1
|
+
import { Gt as RECORDING_SOURCE_CAMSTACK_ADDON, Jt as RecordingStatusSchema, dl as errMsg, ki as mayWriteToLocation, lc as createEvent, pl as EventCategory, ps as BaseAddon } from "../../dist-B8dBvJJK.mjs";
|
|
2
2
|
import { constants } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as fsp from "node:fs/promises";
|
|
@@ -3,10 +3,10 @@ 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-DVrLQr6W.js");
|
|
7
7
|
const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
|
|
8
8
|
const require_ms$1 = require("../../ms-LB3giGoU.js");
|
|
9
|
-
const require_device_ca = require("../../device-ca-
|
|
9
|
+
const require_device_ca = require("../../device-ca-DAuMNieL.js");
|
|
10
10
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
11
11
|
let zod = require("zod");
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import { Dn as authProviderCapability, E as CREDENTIAL_TOKEN_AUDIENCE, Fn as buildDeviceSignatureMessage, Gr as formatDeviceRevoker, Ht as PreferenceNamespaceSchema, Ic as makeSecretMarker, It as PREFERENCES_MAX_VALUE_BYTES, N as CredentialTokenClaimsSchema, Nc as isSecretMarker, Pn as buildDeviceEnrollmentLink, Ut as PreferenceValueSchema, V as DEVICE_ENROLLMENT_TTL_MS, Vt as PreferenceDeviceIdSchema, W as DEVICE_NONCE_TTL_MS, an as SsoBridgeClaimsSchema, bo as userManagementCapability, fn as TokenScopeSchema, il as userError, mc as defineRecordKinds, mn as UserRecordSchema, oi as isCredentialTokenPayload, ps as BaseAddon, rn as ScopedTokenSchema, yr as deviceCredentialsCapability } from "../../dist-
|
|
2
|
+
import { Dn as authProviderCapability, E as CREDENTIAL_TOKEN_AUDIENCE, Fn as buildDeviceSignatureMessage, Gr as formatDeviceRevoker, Ht as PreferenceNamespaceSchema, Ic as makeSecretMarker, It as PREFERENCES_MAX_VALUE_BYTES, N as CredentialTokenClaimsSchema, Nc as isSecretMarker, Pn as buildDeviceEnrollmentLink, Ut as PreferenceValueSchema, V as DEVICE_ENROLLMENT_TTL_MS, Vt as PreferenceDeviceIdSchema, W as DEVICE_NONCE_TTL_MS, an as SsoBridgeClaimsSchema, bo as userManagementCapability, fn as TokenScopeSchema, il as userError, mc as defineRecordKinds, mn as UserRecordSchema, oi as isCredentialTokenPayload, ps as BaseAddon, rn as ScopedTokenSchema, yr as deviceCredentialsCapability } from "../../dist-B8dBvJJK.mjs";
|
|
3
3
|
import { t as require_safe_buffer } from "../../safe-buffer-B1OjL1I9.mjs";
|
|
4
4
|
import { t as require_ms } from "../../ms-CgH2OFlD.mjs";
|
|
5
|
-
import { _ as setProcessJwtSigningKey, a as importDevicePublicKey, c as rebuildDeviceCaCertificate, d as JWT_SIGNING_KEY_REF, g as processJwtSigningKey, h as loadJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, r as DEVICE_CA_SETTINGS_SECTION, s as loadDeviceCa, t as DEVICE_CA_FIELD, u as verifyDeviceSignature } from "../../device-ca-
|
|
5
|
+
import { _ as setProcessJwtSigningKey, a as importDevicePublicKey, c as rebuildDeviceCaCertificate, d as JWT_SIGNING_KEY_REF, g as processJwtSigningKey, h as loadJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, r as DEVICE_CA_SETTINGS_SECTION, s as loadDeviceCa, t as DEVICE_CA_FIELD, u as verifyDeviceSignature } from "../../device-ca-CXPTrORC.mjs";
|
|
6
6
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import * as crypto$1 from "node:crypto";
|