@camstack/server 1.2.893 → 1.2.895

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/core/api-catalog.js +93 -0
  3. package/dist/api/core/api-catalog.router.js +74 -0
  4. package/dist/api/trpc/generated-cap-mounts.js +3 -1
  5. package/dist/api/trpc/generated-cap-routers.js +1528 -1499
  6. package/dist/api/trpc/trpc.middleware.js +17 -0
  7. package/dist/api/trpc/trpc.router.js +10 -3
  8. package/package.json +27 -13
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  15. package/system/dist/builtins/autotrack/index.js +1 -1
  16. package/system/dist/builtins/autotrack/index.mjs +1 -1
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  19. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  20. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  21. package/system/dist/builtins/camera-grid/index.js +1 -1
  22. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  23. package/system/dist/builtins/composer/composer.addon.js +5 -5
  24. package/system/dist/builtins/composer/composer.addon.mjs +5 -5
  25. package/system/dist/builtins/composer/graft-host.d.ts +1 -1
  26. package/system/dist/builtins/console-logging/index.js +1 -1
  27. package/system/dist/builtins/console-logging/index.mjs +1 -1
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  30. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  31. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  32. package/system/dist/builtins/device-manager/device-manager.addon.js +79 -8
  33. package/system/dist/builtins/device-manager/device-manager.addon.mjs +79 -8
  34. package/system/dist/builtins/device-manager/device-provider-context.d.ts +5 -0
  35. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +10 -0
  36. package/system/dist/builtins/device-manager/runtime-state-persist-gate.d.ts +20 -1
  37. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  38. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  39. package/system/dist/builtins/keychain/index.js +4 -4
  40. package/system/dist/builtins/keychain/index.mjs +4 -4
  41. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  42. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  43. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  44. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  45. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  46. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  47. package/system/dist/builtins/loki-logging/index.js +1 -1
  48. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  49. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  50. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  51. package/system/dist/builtins/platform-probe/index.js +1 -1
  52. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  53. package/system/dist/builtins/record-entries/index.js +1 -1
  54. package/system/dist/builtins/record-entries/index.mjs +1 -1
  55. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  56. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  57. package/system/dist/builtins/snapshot/index.js +14 -12
  58. package/system/dist/builtins/snapshot/index.mjs +14 -12
  59. package/system/dist/builtins/snapshot/snapshot.addon.d.ts +6 -4
  60. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  61. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  62. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  63. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  64. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  65. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  66. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  67. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  68. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  69. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  70. package/system/dist/builtins/winston-logging/index.js +1 -1
  71. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  72. package/system/dist/{capture-engine-mZ2J-GD6.js → capture-engine-BgIjQWh6.js} +1 -1
  73. package/system/dist/{capture-engine-CIVKm_jN.mjs → capture-engine-DPn6JaPc.mjs} +1 -1
  74. package/system/dist/{composition-sources-bJP8_Z2o.mjs → composition-sources-B0rdPm85.mjs} +1 -1
  75. package/system/dist/{composition-sources-CGP5ZUYo.js → composition-sources-Bec_hQMM.js} +1 -1
  76. package/system/dist/{constants-BD8oSQro.js → constants-CsYMak6g.js} +1 -1
  77. package/system/dist/{constants-w-6vvTPp.mjs → constants-DsQsO8PD.mjs} +1 -1
  78. package/system/dist/{device-ca-CXxnQaff.js → device-ca-BeK8EI_7.js} +1 -1
  79. package/system/dist/{device-ca-DE_oetBE.mjs → device-ca-BuDqRFZd.mjs} +1 -1
  80. package/system/dist/{dist-B2-Uflhy.js → dist-CHC8tlB1.js} +351 -110
  81. package/system/dist/{dist-Be8yFd71.mjs → dist-DiknL6UU.mjs} +334 -99
  82. package/system/dist/file-host-worker.js +1 -1
  83. package/system/dist/file-host-worker.mjs +1 -1
  84. package/system/dist/{hub-identity-BjYvJU_v.js → hub-identity-BM26oLpK.js} +1 -1
  85. package/system/dist/{hub-identity-C3g7b58L.mjs → hub-identity-Dt-mbtkY.mjs} +1 -1
  86. package/system/dist/{hub-mdns-ciao-BRfv9GfW.js → hub-mdns-ciao-BDgSHCPM.js} +2 -2
  87. package/system/dist/{hub-mdns-ciao-v6X_SbWl.mjs → hub-mdns-ciao-CHq7b1FX.mjs} +2 -2
  88. package/system/dist/index.js +8 -8
  89. package/system/dist/index.mjs +8 -8
  90. package/system/dist/kernel/status-overlay.d.ts +1 -1
  91. package/system/dist/{legacy-integration-rows-door-DG35DG06.mjs → legacy-integration-rows-door-1WauJNCy.mjs} +1 -1
  92. package/system/dist/{legacy-integration-rows-door-B0q34gh3.js → legacy-integration-rows-door-BYJa0xPI.js} +1 -1
  93. package/system/dist/{rename-composition-block-LEbZ4oZE.mjs → rename-composition-block-BOoAElGp.mjs} +1 -1
  94. package/system/dist/{rename-composition-block-DNte3Cs9.js → rename-composition-block-fMaUic9d.js} +1 -1
  95. package/system/dist/{restore-archive-DpFPheMK.js → restore-archive-CeZV08vh.js} +1 -1
  96. package/system/dist/{restore-archive--4ENkU5f.mjs → restore-archive-DZDV10KN.mjs} +82 -82
  97. package/system/dist/{wal-maintenance-DQVDhuVJ.mjs → wal-maintenance-CekT_qH6.mjs} +0 -0
  98. package/system/dist/{wal-maintenance-BWUJktqT.js → wal-maintenance-CmCCUKZO.js} +0 -0
  99. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.895] - 2026-11-17
11
+
12
+ ### Changed
13
+
14
+ - A camera that sleeps now says so through its own capability (low-power-sleep); a device that only reports a battery is no longer kept cold and unwatched as if it slept
15
+
16
+ ## [1.2.894] - 2026-11-17
17
+
18
+ ### Changed
19
+
20
+ - New admin-only apiCatalog.list and apiCatalog.inputSchema: the methods the hub serves, read off the live router, with kind, tier, token scope and input JSON Schema.
21
+
10
22
  ## [1.2.893] - 2026-11-17
11
23
 
12
24
  ### Changed
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.procedureShapeOf = procedureShapeOf;
4
+ exports.buildApiCatalog = buildApiCatalog;
5
+ exports.inputSchemaOf = inputSchemaOf;
6
+ /**
7
+ * The API explorer's catalogue (planning#595): every tRPC method the hub
8
+ * serves, read off the LIVE router's procedure record — capability routers and
9
+ * the hand-written core routers alike. Nothing here lists a method by hand:
10
+ *
11
+ * - path, router, method and kind come from the procedure record;
12
+ * - the tier is the gate the procedure was built behind (`procedureTierOf`);
13
+ * - the token scope of a capability route is its `METHOD_ACCESS_MAP` row
14
+ * (the same row `protectedProcedure` authorizes against); a core route has
15
+ * none — it needs authentication only, plus `adminProcedure` where it says so;
16
+ * - the input schema is the procedure's own Zod parser, as JSON Schema.
17
+ */
18
+ const system_1 = require("@camstack/server/system");
19
+ const zod_1 = require("zod");
20
+ function isKind(value) {
21
+ return value === 'query' || value === 'mutation' || value === 'subscription';
22
+ }
23
+ /** The `_def` of a built tRPC procedure, or `null` for anything else. */
24
+ function procedureShapeOf(procedure) {
25
+ if (typeof procedure !== 'function' && (typeof procedure !== 'object' || procedure === null)) {
26
+ return null;
27
+ }
28
+ const def = Reflect.get(procedure, '_def');
29
+ if (typeof def !== 'object' || def === null)
30
+ return null;
31
+ const kind = Reflect.get(def, 'type');
32
+ const inputs = Reflect.get(def, 'inputs');
33
+ const middlewares = Reflect.get(def, 'middlewares');
34
+ if (!isKind(kind))
35
+ return null;
36
+ return {
37
+ kind,
38
+ inputs: Array.isArray(inputs) ? inputs : [],
39
+ middlewares: Array.isArray(middlewares) ? middlewares : [],
40
+ };
41
+ }
42
+ function scopeOf(path) {
43
+ const row = system_1.METHOD_ACCESS_MAP[path];
44
+ if (row === undefined)
45
+ return null;
46
+ return { capName: row.capName, capScope: row.capScope, access: row.access, role: row.role };
47
+ }
48
+ /** Every procedure of `procedures` as a catalogue entry, sorted by path. */
49
+ function buildApiCatalog(procedures, tierOf) {
50
+ const entries = [];
51
+ for (const [path, procedure] of Object.entries(procedures)) {
52
+ const shape = procedureShapeOf(procedure);
53
+ if (shape === null)
54
+ continue;
55
+ const dot = path.lastIndexOf('.');
56
+ const scope = scopeOf(path);
57
+ entries.push({
58
+ path,
59
+ router: dot < 0 ? '' : path.slice(0, dot),
60
+ method: dot < 0 ? path : path.slice(dot + 1),
61
+ kind: shape.kind,
62
+ tier: tierOf(shape.middlewares),
63
+ source: scope === null ? 'core' : 'capability',
64
+ scope,
65
+ hasInput: shape.inputs.length > 0,
66
+ });
67
+ }
68
+ return entries.toSorted((a, b) => a.path.localeCompare(b.path));
69
+ }
70
+ function jsonSchemaOf(parser) {
71
+ if (!(parser instanceof zod_1.z.ZodType)) {
72
+ throw new Error('the input parser is not a Zod schema');
73
+ }
74
+ // `io: 'input'`: what the CALLER sends — a defaulted field is optional.
75
+ const schema = zod_1.z.toJSONSchema(parser, {
76
+ io: 'input',
77
+ unrepresentable: 'any',
78
+ });
79
+ return schema;
80
+ }
81
+ /** The input JSON schema of a procedure; several chained inputs become `allOf`. */
82
+ function inputSchemaOf(shape) {
83
+ if (shape.inputs.length === 0)
84
+ return { schema: null, error: null };
85
+ try {
86
+ const parts = shape.inputs.map(jsonSchemaOf);
87
+ const schema = parts.length === 1 ? parts[0] : { allOf: parts };
88
+ return { schema: schema ?? null, error: null };
89
+ }
90
+ catch (err) {
91
+ return { schema: null, error: err instanceof Error ? err.message : String(err) };
92
+ }
93
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callableBy = callableBy;
4
+ exports.createApiCatalogRouter = createApiCatalogRouter;
5
+ const types_1 = require("@camstack/types");
6
+ const system_1 = require("@camstack/server/system");
7
+ const zod_1 = require("zod");
8
+ const device_access_js_1 = require("../trpc/device-access.js");
9
+ const principal_authorization_js_1 = require("../trpc/principal-authorization.js");
10
+ const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
11
+ const user_error_js_1 = require("../trpc/user-error.js");
12
+ const api_catalog_js_1 = require("./api-catalog.js");
13
+ const InputSchemaInput = zod_1.z.object({ path: zod_1.z.string().min(1) });
14
+ /**
15
+ * A device-scoped cap method refused at path level, for a principal holding a
16
+ * device grant at the method's access: the matcher refuses only because no
17
+ * device is named (`checkScopeAccess`), so the real call is decided per device.
18
+ */
19
+ function reachedPerDevice(scopes, path) {
20
+ const meta = system_1.METHOD_ACCESS_MAP[path];
21
+ if (meta === undefined || meta.capScope !== 'device')
22
+ return false;
23
+ return (0, types_1.capabilityScopesOf)(scopes).some((s) => s.type === 'device' && s.access.includes(meta.access));
24
+ }
25
+ /** May `user` call the method — `per-device` when it depends on the device the input names. */
26
+ function callableBy(user, entry) {
27
+ if (entry.tier === 'public')
28
+ return 'yes';
29
+ const scopes = (0, device_access_js_1.enforcedScopesOf)(user);
30
+ const pathLevel = (0, principal_authorization_js_1.authorizeProcedure)(scopes, entry.path, undefined).ok
31
+ ? 'yes'
32
+ : reachedPerDevice(scopes, entry.path)
33
+ ? 'per-device'
34
+ : 'no';
35
+ if (pathLevel === 'no')
36
+ return 'no';
37
+ if (entry.tier === 'admin' &&
38
+ !user.isAdmin &&
39
+ !(0, principal_authorization_js_1.viewerPassesAdminTier)(user.scopes ?? [], entry.path)) {
40
+ return 'no';
41
+ }
42
+ return pathLevel;
43
+ }
44
+ function createApiCatalogRouter(getProcedures) {
45
+ // The procedure record is fixed once the app router is built: compute once.
46
+ let cached = null;
47
+ const catalog = () => {
48
+ cached ??= (0, api_catalog_js_1.buildApiCatalog)(getProcedures(), trpc_middleware_js_1.procedureTierOf);
49
+ return cached;
50
+ };
51
+ return (0, trpc_middleware_js_1.trpcRouter)({
52
+ list: trpc_middleware_js_1.adminProcedure.query(({ ctx }) => {
53
+ const user = ctx.user;
54
+ return {
55
+ methods: catalog().map((entry) => ({ ...entry, callable: callableBy(user, entry) })),
56
+ };
57
+ }),
58
+ inputSchema: trpc_middleware_js_1.adminProcedure
59
+ .input(InputSchemaInput)
60
+ .query(({ input }) => {
61
+ const shape = (0, api_catalog_js_1.procedureShapeOf)(getProcedures()[input.path]);
62
+ if (shape === null) {
63
+ throw (0, user_error_js_1.trpcUserError)('NOT_FOUND', 'apiCatalog.unknown-method', { path: input.path }, `No method ${input.path} on this hub`);
64
+ }
65
+ const answer = (0, api_catalog_js_1.inputSchemaOf)(shape);
66
+ return {
67
+ path: input.path,
68
+ hasInput: shape.inputs.length > 0,
69
+ schema: answer.schema,
70
+ error: answer.error,
71
+ };
72
+ }),
73
+ });
74
+ }
@@ -2,7 +2,7 @@
2
2
  // AUTO-GENERATED by scripts/generate-cap-mounts.ts — DO NOT EDIT
3
3
  // Re-run: npx tsx scripts/generate-cap-mounts.ts
4
4
  //
5
- // Mounted: 208 Skipped (legacy): 3
5
+ // Mounted: 210 Skipped (legacy): 3
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LEGACY_SHAPE_SKIP = void 0;
8
8
  exports.mountAllCaps = mountAllCaps;
@@ -424,6 +424,7 @@ function mountAllCaps(services) {
424
424
  getLoginMethods: (0, cap_mount_helpers_js_1.concatCollection)(providers, 'getLoginMethods'),
425
425
  };
426
426
  }, remoteCapProxy),
427
+ lowPowerSleep: (0, generated_cap_routers_js_1.createCapRouter_lowPowerSleep)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'low-power-sleep'), remoteCapProxy),
427
428
  mediaPlayer: (0, generated_cap_routers_js_1.createCapRouter_mediaPlayer)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'media-player'), remoteCapProxy),
428
429
  meshNetwork: (0, generated_cap_routers_js_1.createCapRouter_meshNetwork)((_ctx, addonId) => {
429
430
  if (!reg)
@@ -570,6 +571,7 @@ function mountAllCaps(services) {
570
571
  listComponents: (0, cap_mount_helpers_js_1.concatCollection)(providers, 'listComponents'),
571
572
  };
572
573
  }, remoteCapProxy),
574
+ resync: (0, generated_cap_routers_js_1.createCapRouter_resync)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'resync'), remoteCapProxy),
573
575
  runningState: (0, generated_cap_routers_js_1.createCapRouter_runningState)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'running-state'), remoteCapProxy),
574
576
  sceneMonitor: (0, generated_cap_routers_js_1.createCapRouter_sceneMonitor)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'scene-monitor'), remoteCapProxy),
575
577
  schedulers: (0, generated_cap_routers_js_1.createCapRouter_schedulers)((_ctx) => reg?.getSingleton('schedulers') ?? null, remoteCapProxy),