@camstack/server 1.2.943 → 1.2.945

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 (170) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/closure-pins.json +350 -0
  3. package/dist/api/core/auth-sessions.procedures.js +18 -0
  4. package/dist/api/core/auth.router.js +19 -6
  5. package/dist/api/server-upload.js +17 -1
  6. package/dist/api/trpc/generated-cap-mounts.js +18 -1
  7. package/dist/api/trpc/generated-cap-routers.js +2662 -2542
  8. package/dist/auth/native-return.js +9 -3
  9. package/dist/auth/sso-routes.js +5 -1
  10. package/dist/core/addon/instance-lifecycle.js +4 -1
  11. package/dist/core/auth/handoff-code.service.js +35 -1
  12. package/dist/server-root/index.js +313 -70
  13. package/package.json +15 -11
  14. package/system/assets/apps-aggregator/icon.svg +5 -0
  15. package/system/dist/{action-index-B_cLRwXJ.js → action-index-Bcnb-jyg.js} +9 -1
  16. package/system/dist/{action-index-B1fgpQBt.mjs → action-index-DwPHO2nz.mjs} +9 -1
  17. package/system/dist/{addon-settings.cap-CZ4MC7ha.mjs → addon-settings.cap-CHpmuaQG.mjs} +1 -1
  18. package/system/dist/{addon-settings.cap-DrLdMFIe.js → addon-settings.cap-nZVHPo3X.js} +1 -1
  19. package/system/dist/{alert-episode-Be--PngO.mjs → alert-episode-D-1VUUkZ.mjs} +1 -1
  20. package/system/dist/{alert-episode-Bqktmt-i.js → alert-episode-DaQ3prSe.js} +1 -1
  21. package/system/dist/apps.cap-Bqb9NpYx.mjs +130 -0
  22. package/system/dist/apps.cap-CLjgnuUe.js +141 -0
  23. package/system/dist/{base-addon-CRsXtYFG.js → base-addon-BG7p06Hb.js} +136 -15
  24. package/system/dist/{base-addon-BcS6r1cT.mjs → base-addon-BcVoYZbC.mjs} +136 -15
  25. package/system/dist/{base-device-DAdWzDOl.js → base-device-DeSNiwZ4.js} +4 -4
  26. package/system/dist/{base-device-DJXF5eDN.mjs → base-device-w_MD0Bf4.mjs} +4 -4
  27. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  28. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  29. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  30. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  31. package/system/dist/builtins/alerts/alerts.addon.js +3 -3
  32. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  33. package/system/dist/builtins/apps-aggregator/aggregate-apps.d.ts +24 -0
  34. package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.d.ts +16 -0
  35. package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.js +109 -0
  36. package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.mjs +103 -0
  37. package/system/dist/builtins/apps-aggregator/index.d.ts +1 -0
  38. package/system/dist/builtins/apps-aggregator/index.js +8 -0
  39. package/system/dist/builtins/apps-aggregator/index.mjs +2 -0
  40. package/system/dist/builtins/autotrack/index.js +1 -1
  41. package/system/dist/builtins/autotrack/index.mjs +1 -1
  42. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  43. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  44. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  45. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  46. package/system/dist/builtins/camera-grid/index.js +3 -3
  47. package/system/dist/builtins/camera-grid/index.mjs +3 -3
  48. package/system/dist/builtins/composer/composer.addon.js +7 -7
  49. package/system/dist/builtins/composer/composer.addon.mjs +7 -7
  50. package/system/dist/builtins/console-logging/index.js +1 -1
  51. package/system/dist/builtins/console-logging/index.mjs +1 -1
  52. package/system/dist/builtins/core-blocks/actions-store.d.ts +2 -0
  53. package/system/dist/builtins/core-blocks/block-supervisor.d.ts +16 -4
  54. package/system/dist/builtins/core-blocks/core-block-store.d.ts +2 -0
  55. package/system/dist/builtins/core-blocks/core-blocks.addon.js +1018 -323
  56. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +986 -291
  57. package/system/dist/builtins/core-blocks/migrations/index.d.ts +5 -2
  58. package/system/dist/builtins/core-blocks/migrations/tag-ids.d.ts +42 -0
  59. package/system/dist/builtins/core-blocks/migrations/tags-as-records.d.ts +47 -0
  60. package/system/dist/builtins/core-blocks/record-kinds.d.ts +12 -1
  61. package/system/dist/builtins/core-blocks/runs-api.d.ts +3 -1
  62. package/system/dist/builtins/core-blocks/runs-ledger.d.ts +3 -1
  63. package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +2 -0
  64. package/system/dist/builtins/core-blocks/tags-service.d.ts +52 -27
  65. package/system/dist/builtins/core-blocks/tags-wiring.d.ts +2 -0
  66. package/system/dist/builtins/core-notifier/core-notifier.addon.js +76 -67
  67. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +76 -67
  68. package/system/dist/builtins/device-history/device-history.addon.js +4 -4
  69. package/system/dist/builtins/device-history/device-history.addon.mjs +4 -4
  70. package/system/dist/builtins/device-manager/device-manager.addon.js +1618 -755
  71. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1604 -741
  72. package/system/dist/builtins/device-manager/device-meta-actions.d.ts +13 -136
  73. package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
  74. package/system/dist/builtins/device-manager/device-provider-context.d.ts +9 -0
  75. package/system/dist/builtins/device-manager/device-row-store.d.ts +21 -4
  76. package/system/dist/builtins/device-manager/device-search.d.ts +6 -0
  77. package/system/dist/builtins/device-manager/location-alignment.d.ts +9 -2
  78. package/system/dist/builtins/device-manager/migrate-device.d.ts +7 -2
  79. package/system/dist/builtins/device-manager/migrate-hardware-state.d.ts +132 -1
  80. package/system/dist/builtins/device-manager/migrations/device-tag-ids.d.ts +25 -0
  81. package/system/dist/builtins/device-manager/migrations/index.d.ts +16 -0
  82. package/system/dist/builtins/device-manager/migrations/orphan-children.d.ts +33 -0
  83. package/system/dist/builtins/device-manager/migrations/ports.d.ts +17 -0
  84. package/system/dist/builtins/device-manager/migrations/rooms-as-records.d.ts +52 -0
  85. package/system/dist/builtins/device-manager/record-kinds.d.ts +3 -1
  86. package/system/dist/builtins/device-manager/removal-cleanup.d.ts +7 -0
  87. package/system/dist/builtins/device-manager/room-actions.d.ts +27 -0
  88. package/system/dist/builtins/device-manager/room-store.d.ts +19 -0
  89. package/system/dist/builtins/device-manager/tag-names.d.ts +32 -0
  90. package/system/dist/builtins/device-manager/wireable-enum-catalog.d.ts +18 -0
  91. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  92. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  93. package/system/dist/builtins/keychain/index.js +3 -3
  94. package/system/dist/builtins/keychain/index.mjs +3 -3
  95. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  96. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  97. package/system/dist/builtins/local-auth/local-auth.addon.js +1 -1
  98. package/system/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  99. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  100. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  101. package/system/dist/builtins/loki-logging/index.js +2 -2
  102. package/system/dist/builtins/loki-logging/index.mjs +2 -2
  103. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  104. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  105. package/system/dist/builtins/platform-probe/index.js +1 -1
  106. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  107. package/system/dist/builtins/record-entries/index.js +1 -1
  108. package/system/dist/builtins/record-entries/index.mjs +1 -1
  109. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  110. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  111. package/system/dist/builtins/snapshot/index.js +1 -1
  112. package/system/dist/builtins/snapshot/index.mjs +1 -1
  113. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  114. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  115. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  116. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  117. package/system/dist/builtins/sqlite-storage/migrations/migration-engine.d.ts +3 -1
  118. package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +1 -0
  119. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +15 -10
  120. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +15 -10
  121. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  122. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  123. package/system/dist/builtins/system-config/system-config.addon.js +2 -2
  124. package/system/dist/builtins/system-config/system-config.addon.mjs +2 -2
  125. package/system/dist/builtins/winston-logging/index.js +2 -2
  126. package/system/dist/builtins/winston-logging/index.mjs +2 -2
  127. package/system/dist/{command-catalog-C29hVOOg.js → command-catalog-A_ONlLfF.js} +1 -1
  128. package/system/dist/{command-catalog-xAeqxbZk.mjs → command-catalog-CZDlLhxO.mjs} +1 -1
  129. package/system/dist/{composition-sources-Do5qM6EB.js → composition-sources-D1nPv7dJ.js} +1 -1
  130. package/system/dist/{composition-sources-C327LGFn.mjs → composition-sources-DubMf_ii.mjs} +1 -1
  131. package/system/dist/{core-blocks.cap-CdTGUKtr.js → core-blocks.cap-DEYCvF9J.js} +125 -373
  132. package/system/dist/{core-blocks.cap-DLkEfV5b.mjs → core-blocks.cap-sW5HLDlB.mjs} +109 -327
  133. package/system/dist/{device-manager.cap-DJs8izI6.js → device-manager.cap-B9qVf7ag.js} +163 -22
  134. package/system/dist/{device-manager.cap-eYrj1Ezp.mjs → device-manager.cap-CV4KGp3e.mjs} +134 -17
  135. package/system/dist/{error.cap-CU1FB6uE.mjs → error.cap-B8l7L8e4.mjs} +7 -1
  136. package/system/dist/{error.cap-BuKbL3Ac.js → error.cap-BqlvgBJd.js} +7 -1
  137. package/system/dist/file-host-worker.js +1 -1
  138. package/system/dist/file-host-worker.mjs +1 -1
  139. package/system/dist/index.js +8 -8
  140. package/system/dist/index.mjs +7 -7
  141. package/system/dist/{legacy-integration-rows-door-CdqYAj-o.js → legacy-integration-rows-door-BK8eoGlF.js} +1 -1
  142. package/system/dist/{legacy-integration-rows-door-LSgpClpX.mjs → legacy-integration-rows-door-CwzC5XNk.mjs} +1 -1
  143. package/system/dist/{migration-DGAc6ywR.mjs → migration-BvbfW9g-.mjs} +6 -0
  144. package/system/dist/{migration-BOQlFZCN.js → migration-CHPdAdNh.js} +6 -0
  145. package/system/dist/{prefix-walk-Mtij0NNT.mjs → named-entity-store-Cq2oVrN5.mjs} +195 -89
  146. package/system/dist/{prefix-walk-BFnw8NBu.js → named-entity-store-O_hi1y_o.js} +244 -90
  147. package/system/dist/{notification-rules.cap-BUIuYPlQ.mjs → notification-rules.cap-ClvK6QT1.mjs} +10 -5
  148. package/system/dist/{notification-rules.cap-BJKUjizS.js → notification-rules.cap-uSLoe2pA.js} +10 -5
  149. package/system/dist/{notification-targets-DMW7xgR2.js → notification-targets-ChqpBbtR.js} +2 -2
  150. package/system/dist/{notification-targets-4bGYH5J7.mjs → notification-targets-DUA6-F2t.mjs} +2 -2
  151. package/system/dist/{device-row-store-CTocYKqC.mjs → record-kinds-BD2xv4Pd.mjs} +222 -93
  152. package/system/dist/{device-row-store-C0P2H18h.js → record-kinds-BV8Gcpsx.js} +246 -93
  153. package/system/dist/records/named-entity-store.d.ts +60 -0
  154. package/system/dist/{rename-composition-block-D9Uc1AF7.js → rename-composition-block-C60O0P16.js} +137 -33
  155. package/system/dist/{rename-composition-block-Cdh-dRmY.mjs → rename-composition-block-DcX3vkwS.mjs} +137 -33
  156. package/system/dist/{retention-source.cap-C6Hy0hlM.js → retention-source.cap-A-TMhU5O.js} +1 -1
  157. package/system/dist/{retention-source.cap-550kkyp5.mjs → retention-source.cap-Ct07pM30.mjs} +1 -1
  158. package/system/dist/{storage-admin.cap-Ci4QbL6P.mjs → storage-admin.cap-C54s9_B9.mjs} +8 -2
  159. package/system/dist/{storage-admin.cap-DqW1ol4j.js → storage-admin.cap-DSPHi7ut.js} +8 -2
  160. package/system/dist/{stream-catalog.cap-CjEQFknc.js → stream-catalog.cap-7WPsugOy.js} +1 -1
  161. package/system/dist/{stream-catalog.cap-DVniDdRD.mjs → stream-catalog.cap-CzwRDaqT.mjs} +1 -1
  162. package/system/dist/{tag-BxLazvVb.js → tag-BLraBqvp.js} +12 -0
  163. package/system/dist/{tag-uZBAq6ox.mjs → tag-DU8pm9Bi.mjs} +7 -1
  164. package/system/dist/time-window-B6UhCArd.js +679 -0
  165. package/system/dist/time-window-BnUBULgu.mjs +578 -0
  166. package/system/dist/{wal-maintenance-BgYiAy5b.js → wal-maintenance-CkPfVApC.js} +0 -0
  167. package/system/dist/{wal-maintenance-Bey5ChBb.mjs → wal-maintenance-u84_1sVl.mjs} +0 -0
  168. package/system/package.json +16 -1
  169. /package/system/dist/{constants-Ba3FTIHl.js → constants-Ba3FTIHl2.js} +0 -0
  170. /package/system/dist/{constants-DB4piTD5.mjs → constants-DB4piTD52.mjs} +0 -0
@@ -1,14 +1,14 @@
1
1
  import { i as __require } from "./chunk-CNf5ZN-e.mjs";
2
- import { b as EventCategory$1, i as collectSecretMarkerRefs, p as createEvent$1 } from "./base-addon-BcS6r1cT.mjs";
2
+ import { b as EventCategory$1, i as collectSecretMarkerRefs, p as createEvent$1 } from "./base-addon-BcVoYZbC.mjs";
3
3
  import { Z as errMsg$1 } from "./scoped-settings-DVWUIP7Z.mjs";
4
- import { Un as lifecycleJobSchema, a as isCollectionArrayMethod, c as kebabToCamel$1, d as objectInputDeclaresRequiredDeviceId, dr as compareVersions, f as procedureAuthKey, fr as describeUnmet, i as isArrayOutputSchema, l as looseSchema, m as ALL_CAPABILITY_DEFINITIONS, o as isObjectInput, p as resolveMethodAuth, pr as unmetRequirements, r as extractNestedAddonId, s as isVoidInput, u as objectInputDeclaresAddonId, ur as PackageRequiresSchema } from "./rename-composition-block-Cdh-dRmY.mjs";
4
+ import { Un as lifecycleJobSchema, a as isCollectionArrayMethod, c as kebabToCamel$1, d as objectInputDeclaresRequiredDeviceId, dr as compareVersions, f as procedureAuthKey, fr as describeUnmet, i as isArrayOutputSchema, l as looseSchema, m as ALL_CAPABILITY_DEFINITIONS, o as isObjectInput, p as resolveMethodAuth, pr as unmetRequirements, r as extractNestedAddonId, s as isVoidInput, u as objectInputDeclaresAddonId, ur as PackageRequiresSchema } from "./rename-composition-block-DcX3vkwS.mjs";
5
5
  import { t as userError } from "./camstack-error-viZYfcj9.mjs";
6
6
  import { a as expandCapMethods, n as DEVICE_STATUS_METHOD, t as DEVICE_SETTINGS_CONTRIBUTION_METHODS, u as resolveCapMount } from "./capability-definition-C1TLUVJR.mjs";
7
7
  import { s as defineRecordKinds } from "./record-kind-ub6NXqfh.mjs";
8
- import { D as RecordsEngine, J as asNumber, X as parseJsonObject, Y as asString$1, Z as parseJsonUnknown, l as SqliteSettingsBackend, q as asJsonObject$1 } from "./wal-maintenance-Bey5ChBb.mjs";
8
+ import { D as RecordsEngine, J as asNumber, X as parseJsonObject, Y as asString$1, Z as parseJsonUnknown, l as SqliteSettingsBackend, q as asJsonObject$1 } from "./wal-maintenance-u84_1sVl.mjs";
9
9
  import { f as AppPageLangSchema } from "./device-certificate-Cddm4Idn.mjs";
10
- import { i as addonSettingsCapability } from "./addon-settings.cap-CZ4MC7ha.mjs";
11
- import { t as loadPrefixed } from "./prefix-walk-Mtij0NNT.mjs";
10
+ import { i as addonSettingsCapability } from "./addon-settings.cap-CHpmuaQG.mjs";
11
+ import { a as loadPrefixed } from "./named-entity-store-Cq2oVrN5.mjs";
12
12
  import { a as AGENT_MDNS_TXT_KEYS, i as AGENT_MDNS_SERVICE_TYPE } from "./network-access.cap-Dx5K0I5i.mjs";
13
13
  import { t as RUNTIME_DEFAULTS } from "./constants-DCLpoF4L.mjs";
14
14
  import { t as bareAddonId } from "./addon-id-CVg1_r5E.mjs";
@@ -41,13 +41,13 @@ import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index
41
41
  import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
42
42
  import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
43
43
  import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
44
- import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-LSgpClpX.mjs";
44
+ import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-CwzC5XNk.mjs";
45
45
  import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
46
46
  import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
47
47
  import { StorageOrchestratorAddon, a as createHubCapForwardService, i as HUB_CAP_FWD_SERVICE, o as stripForwardedCaller, r as HUB_CAP_FWD_ACTION, s as buildStorageLocationRegistry, t as StorageOrchestratorService, u as storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/storage-orchestrator.addon.mjs";
48
48
  import "./builtins/storage-orchestrator/index.mjs";
49
49
  import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-DjMN9Ac2.mjs";
50
- import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-DB4piTD5.mjs";
50
+ import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-DB4piTD52.mjs";
51
51
  import { $ as getProcessMeshCaState, A as emitProcessNodeRegistered, At as readCidrSetting, B as getProcessMeshTlsListenerState, C as verifyMembershipAnswer, Ct as isInsecureOrigin, D as ServiceBroker, Dt as createCidrMatcher, E as Errors, Et as readOriginSetting, F as onProcessNodeRegistered, G as MeshCertificateRegistry, H as setProcessMeshTlsListenerState, I as setProcessMeshHandshakeReporter, J as getProcessMeshCertificateRegistry, K as RENEWAL_ABANDONED, L as setProcessMeshPeerTransportLookup, M as getProcessNodeMeshTransport, N as getProcessPeerLeaf, O as setProcessMeshTlsEnabler, Ot as normalizeIp, P as isProcessVerifiedMeshPeer, Q as MeshCaKeeper, R as renewMeshCertificate, S as signMembershipProof, St as OPAQUE_ORIGIN, SystemConfigAddon, T as TlsTcpTransporter, Tt as parseOriginList, U as MESH_NODE_CERTIFICATES_COLLECTION, V as openMeshTlsWhenRevocationsLoaded, W as MESH_NODE_CERTIFICATES_COLUMNS, X as MeshCrl, Y as setProcessMeshCertificateRegistry, Z as processMeshCrl, _ as keyFingerprintShort, _t as isAllowedAgentDashboardReturnTo, a as dialableHubHost, at as generateMeshCa, b as MEMBERSHIP_PATHS, bt as verifyAgentUiUnlockTicket, c as PAIRING_MAX_CODE_ATTEMPTS, ct as issueMeshLeafForNode, d as PAIRING_PIN_DIGITS, dt as AGENT_DASHBOARD_ORIGINS_FIELD, et as requireProcessMeshCa, f as PAIRING_PROTOCOL, ft as AGENT_UI_UNLOCK_TTL_MS, g as describeCsr, gt as UnlockTicketJtiStore, h as computePairingSas, ht as AGENT_UI_UNLOCK_VERSION, i as AgentPairing, it as exportMeshPrivateKeyPem, j as getProcessMeshHandshakeReporter, k as dropProcessPeer, kt as parseCidrList, l as PAIRING_MAX_SESSIONS, lt as issueMeshLeafFromCsr, m as computePairingCommitment, mt as AGENT_UI_UNLOCK_USE, n as HubPairing, nt as caFingerprintCompact, o as hubHostFromMeshAddress, ot as generateMeshKeyPair, p as PAIRING_TTL_MS, pt as AGENT_UI_UNLOCK_TYP, q as describeMeshLeaf, r as PairingHttpError, rt as createMeshCsrPem, s as PAIRING_CODE_DIGITS, st as isValidAgentNodeId, tt as caFingerprint, u as PAIRING_PATHS, ut as loadMeshCa, v as signPairingProof, vt as mintAgentUiUnlockTicket, w as MESH_TLS_PORT_HELLO_FIELD, wt as normalizeOrigin, x as MembershipResponder, xt as InvalidCorsOriginError, y as verifyPairingProof, yt as parseAgentDashboardOrigins, z as revokeMeshCertificate } from "./builtins/system-config/system-config.addon.mjs";
52
52
  import "./builtins/system-config/index.mjs";
53
53
  import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
@@ -1,4 +1,4 @@
1
- const require_base_addon = require("./base-addon-CRsXtYFG.js");
1
+ const require_base_addon = require("./base-addon-BG7p06Hb.js");
2
2
  //#region src/builtins/sqlite-storage/migrations/legacy-integration-rows-door.ts
3
3
  /**
4
4
  * Migration-only door for the leftover integration rows (planning#416).
@@ -1,4 +1,4 @@
1
- import { i as collectSecretMarkerRefs } from "./base-addon-BcS6r1cT.mjs";
1
+ import { i as collectSecretMarkerRefs } from "./base-addon-BcVoYZbC.mjs";
2
2
  //#region src/builtins/sqlite-storage/migrations/legacy-integration-rows-door.ts
3
3
  /**
4
4
  * Migration-only door for the leftover integration rows (planning#416).
@@ -169,6 +169,12 @@ var MigrationEditSchema = /* @__PURE__ */ z.discriminatedUnion("op", [
169
169
  table: /* @__PURE__ */ z.string().min(1),
170
170
  key: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
171
171
  row: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
172
+ /**
173
+ * The columns of the EXISTING row the precondition covers. Absent = the whole row (`SELECT *`).
174
+ * A plan that owns a few plain columns of a wide row (the legacy `location` of a device row)
175
+ * names them, so a concurrent write to a column it never read does not refuse it.
176
+ */
177
+ preconditionColumns: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string().min(1)).min(1).optional(),
172
178
  precondition: PreconditionSchema
173
179
  }),
174
180
  /* @__PURE__ */ z.object({
@@ -169,6 +169,12 @@ var MigrationEditSchema = /* @__PURE__ */ zod.z.discriminatedUnion("op", [
169
169
  table: /* @__PURE__ */ zod.z.string().min(1),
170
170
  key: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown()),
171
171
  row: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown()),
172
+ /**
173
+ * The columns of the EXISTING row the precondition covers. Absent = the whole row (`SELECT *`).
174
+ * A plan that owns a few plain columns of a wide row (the legacy `location` of a device row)
175
+ * names them, so a concurrent write to a column it never read does not refuse it.
176
+ */
177
+ preconditionColumns: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string().min(1)).min(1).optional(),
172
178
  precondition: PreconditionSchema
173
179
  }),
174
180
  /* @__PURE__ */ zod.z.object({
@@ -1,93 +1,8 @@
1
- import { $t as localDateOf, Bt as describeWantedFaults, Ht as readFault, It as isEventLeaf, Kt as isQuantityValue, Lt as compareValues, Nt as eventLeafIdAt, Pt as forEachLeaf, Qt as isKnownTimeZone, Rt as describeHoldMs, Ut as anySubjectMatches, Vt as faultMatches, rn as weekdayOfLocalDate, tn as occurrenceOn } from "./core-blocks.cap-DLkEfV5b.mjs";
1
+ import { Ft as forEachLeaf, Ht as faultMatches, Lt as isEventLeaf, Pt as eventLeafIdAt, Rt as compareValues, Ut as readFault, Vt as describeWantedFaults, Wt as anySubjectMatches, qt as isQuantityValue, zt as describeHoldMs } from "./core-blocks.cap-sW5HLDlB.mjs";
2
2
  import { lt as toExpressionValue, st as evaluateExpressionSource } from "./compile-OBMHlqD-.mjs";
3
+ import { a as judgeTimeWindow } from "./time-window-BnUBULgu.mjs";
4
+ import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
3
5
  import { t as prefixRange } from "./prefix-range-Dl0znowN.mjs";
4
- //#region ../types/dist/esm/time/time-window.mjs
5
- /**
6
- * A daily window as a STATE: is this instant inside it, and when does that
7
- * next change? Pure — the answer is built per local date from
8
- * {@link occurrenceOn}, so a DST change needs no special case.
9
- *
10
- * Rules:
11
- * - A window whose `to` is not after its `from` on the same local date WRAPS:
12
- * it runs from `from` on day D to `to` on D+1.
13
- * - `days` names the local day a window STARTS on. 22:00-06:00 on weekdays is
14
- * inside at 01:00 Saturday (it started Friday). With `days` and no
15
- * `between` the window is the whole local day.
16
- * - A sun event that does not happen on a day (polar day or night) gives that
17
- * day no window. A sun event on a site WITHOUT a location (or an unknown
18
- * zone) cannot be judged at all: the result is `unknown`, never a guess.
19
- */
20
- var MIDNIGHT = {
21
- kind: "clock",
22
- hh: 0,
23
- mm: 0
24
- };
25
- /** Start dates looked at for a boundary: yesterday .. the day after tomorrow. */
26
- var LOOKAHEAD_DAYS = 2;
27
- function addDays(localDate, days) {
28
- const [y, m, d] = localDate.split("-").map(Number);
29
- return new Date(Date.UTC(y ?? 0, (m ?? 1) - 1, (d ?? 1) + days)).toISOString().slice(0, 10);
30
- }
31
- function unresolvable(window, site) {
32
- if (!isKnownTimeZone(site.timeZone)) return `the site time zone "${site.timeZone}" is not a known IANA zone`;
33
- if (window.between !== void 0 && (window.between.from.kind === "sun" || window.between.to.kind === "sun") && site.zoneOnly === true) return "a sun time needs the site location, and none is set";
34
- return null;
35
- }
36
- /** The interval that STARTS on local day `startDate`, or null when that day has none. */
37
- function intervalStartingOn(window, startDate, site) {
38
- if (window.days !== void 0 && !window.days.includes(weekdayOfLocalDate(startDate))) return null;
39
- if (window.between === void 0) {
40
- const start = occurrenceOn(MIDNIGHT, startDate, site);
41
- const end = occurrenceOn(MIDNIGHT, addDays(startDate, 1), site);
42
- return start === null || end === null ? null : {
43
- start,
44
- end
45
- };
46
- }
47
- const start = occurrenceOn(window.between.from, startDate, site);
48
- const sameDayEnd = occurrenceOn(window.between.to, startDate, site);
49
- if (start === null || sameDayEnd === null) return null;
50
- if (sameDayEnd > start) return {
51
- start,
52
- end: sameDayEnd
53
- };
54
- const end = occurrenceOn(window.between.to, addDays(startDate, 1), site);
55
- return end === null || end <= start ? null : {
56
- start,
57
- end
58
- };
59
- }
60
- function judgeTimeWindow(window, nowMs, site) {
61
- const blocked = unresolvable(window, site);
62
- if (blocked !== null) return {
63
- inside: false,
64
- unknown: true,
65
- nextChangeAtMs: null,
66
- why: `cannot be judged: ${blocked}`
67
- };
68
- const today = localDateOf(nowMs, site.timeZone);
69
- let inside = false;
70
- let next = null;
71
- for (let offset = -1; offset <= LOOKAHEAD_DAYS; offset += 1) {
72
- const interval = intervalStartingOn(window, addDays(today, offset), site);
73
- if (interval === null) continue;
74
- if (interval.start <= nowMs && nowMs < interval.end) inside = true;
75
- for (const boundary of [interval.start, interval.end]) if (boundary > nowMs && (next === null || boundary < next)) next = boundary;
76
- }
77
- if (window.between === void 0) {
78
- const midnight = occurrenceOn(MIDNIGHT, addDays(today, 1), site);
79
- if (midnight !== null && midnight > nowMs && (next === null || midnight < next)) next = midnight;
80
- }
81
- const days = window.days === void 0 ? "" : ` on ${window.days.join(", ")}`;
82
- const span = window.between === void 0 ? "the whole day" : "the window";
83
- return {
84
- inside,
85
- unknown: false,
86
- nextChangeAtMs: next,
87
- why: inside ? `inside ${span}${days}` : `outside ${span}${days}`
88
- };
89
- }
90
- //#endregion
91
6
  //#region ../types/dist/esm/automation/condition-eval.mjs
92
7
  /**
93
8
  * Evaluating an automation's condition tree against the ConditionMirror.
@@ -701,6 +616,40 @@ function hasHoldLeaves(when) {
701
616
  return found;
702
617
  }
703
618
  //#endregion
619
+ //#region ../types/dist/esm/entities/entity-id.mjs
620
+ /** The fold every entity name compares by: trimmed, lower-cased. */
621
+ function entityNameKey(name) {
622
+ return name.trim().toLowerCase();
623
+ }
624
+ /** cyrb53 — a small, well-mixed 53-bit string hash. */
625
+ function mix53(text, seed) {
626
+ let h1 = 3735928559 ^ seed;
627
+ let h2 = 1103547991 ^ seed;
628
+ for (let i = 0; i < text.length; i++) {
629
+ const ch = text.charCodeAt(i);
630
+ h1 = Math.imul(h1 ^ ch, 2654435761);
631
+ h2 = Math.imul(h2 ^ ch, 1597334677);
632
+ }
633
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
634
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
635
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
636
+ }
637
+ function hex14(n) {
638
+ return n.toString(16).padStart(14, "0");
639
+ }
640
+ /** The id a migration mints for `kind` from the entity's folded `key`. Pure. */
641
+ function entityIdFromKey(kind, key) {
642
+ const folded = `${kind}:${entityNameKey(key)}`;
643
+ return `${kind}_${hex14(mix53(folded, 1))}${hex14(mix53(folded, 2))}`;
644
+ }
645
+ var roomIdFromKey = (key) => entityIdFromKey("room", key);
646
+ var tagIdFromKey = (key) => entityIdFromKey("tag", key);
647
+ var zoneIdFromKey = (key) => entityIdFromKey("zone", key);
648
+ /** A fresh random id for an entity created after the migrations. */
649
+ function newEntityId(kind) {
650
+ return `${kind}_${globalThis.crypto.randomUUID().replaceAll("-", "")}`;
651
+ }
652
+ //#endregion
704
653
  //#region src/kernel/prefix-walk.ts
705
654
  function isRecord(value) {
706
655
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -787,4 +736,161 @@ async function loadPrefixed(door, collection, prefix, decode = unwrapStoredValue
787
736
  }
788
737
  }
789
738
  //#endregion
790
- export { evaluateWhenTree as a, nextTimeBoundaryInMs as c, collectWhenMirrorSources as i, stableIdMapOf as l, unwrapStoredValue as n, hasHoldLeaves as o, ConditionMirror as r, hasTimeLeaves as s, loadPrefixed as t };
739
+ //#region src/builtins/device-manager/write-lock.ts
740
+ function createWriteLock() {
741
+ let chain = Promise.resolve();
742
+ return async (fn) => {
743
+ const previous = chain;
744
+ let release = () => {};
745
+ chain = new Promise((resolve) => {
746
+ release = resolve;
747
+ });
748
+ try {
749
+ await previous.catch(() => {});
750
+ return await fn();
751
+ } finally {
752
+ release();
753
+ }
754
+ };
755
+ }
756
+ //#endregion
757
+ //#region src/records/named-entity-store.ts
758
+ /**
759
+ * A set of named entities held as records with an id (D1089): a room, a site
760
+ * zone, a tag.
761
+ *
762
+ * The store reads every record once (few, hand-made) and keeps the working copy
763
+ * here; a write goes to the record first and lands in the map only when it
764
+ * succeeded. ONE operation is ONE `put` of ONE record — a rename never touches
765
+ * a record that merely references the entity.
766
+ *
767
+ * A name is unique within the store, compared by `entityNameKey`. `ensure` of a
768
+ * name that exists returns the existing entity, so "type a new name in the
769
+ * picker" is one call. A reference whose id is unknown reads as `null`
770
+ * ({@link nameOf}): a reader never throws on it and never shows the raw id.
771
+ */
772
+ var import_read_all_rows = require_read_all_rows();
773
+ /** Refused: the name belongs to another entity of the same kind. */
774
+ var EntityNameTakenError = class extends Error {
775
+ entityKind;
776
+ name;
777
+ constructor(entityKind, name) {
778
+ super(`[${entityKind}] name already taken: ${name}`);
779
+ this.entityKind = entityKind;
780
+ this.name = name;
781
+ this.name = "EntityNameTakenError";
782
+ }
783
+ };
784
+ /** Refused: no entity has this id. */
785
+ var EntityNotFoundError = class extends Error {
786
+ entityKind;
787
+ id;
788
+ constructor(entityKind, id) {
789
+ super(`[${entityKind}] not found: ${id}`);
790
+ this.entityKind = entityKind;
791
+ this.id = id;
792
+ this.name = "EntityNotFoundError";
793
+ }
794
+ };
795
+ var NamedEntityStore = class {
796
+ entityKind;
797
+ kind;
798
+ validate;
799
+ entities = /* @__PURE__ */ new Map();
800
+ lock = createWriteLock();
801
+ constructor(entityKind, kind, validate) {
802
+ this.entityKind = entityKind;
803
+ this.kind = kind;
804
+ this.validate = validate;
805
+ }
806
+ async load() {
807
+ const rows = await (0, import_read_all_rows.readAllRows)(this.kind);
808
+ this.entities = new Map(rows.map((row) => [row.id, {
809
+ ...row.data,
810
+ id: row.id
811
+ }]));
812
+ }
813
+ /** The name of entity `id`, or `null` when unset or unknown. Never the id. */
814
+ nameOf(id) {
815
+ if (id === null || id === void 0) return null;
816
+ return this.entities.get(id)?.name ?? null;
817
+ }
818
+ get(id) {
819
+ return this.entities.get(id) ?? null;
820
+ }
821
+ /** The entity named `name` (trimmed, case-insensitive), or `null`. */
822
+ findByName(name) {
823
+ const key = entityNameKey(name);
824
+ for (const entity of this.entities.values()) if (entityNameKey(entity.name) === key) return entity;
825
+ return null;
826
+ }
827
+ list() {
828
+ return [...this.entities.values()].toSorted((a, b) => {
829
+ const ao = orderOf(a);
830
+ const bo = orderOf(b);
831
+ if (ao !== bo) return ao - bo;
832
+ return a.name.localeCompare(b.name, void 0, { sensitivity: "base" });
833
+ });
834
+ }
835
+ /**
836
+ * Create the entity named `name`, or return the one that has it. `preferredId` is the id a
837
+ * migration already wrote into referencing rows: it is adopted when no entity holds it (a record
838
+ * that arrives late never orphans a migrated id), else a fresh id is minted.
839
+ */
840
+ async ensure(name, extra, preferredId) {
841
+ return this.lock(async () => {
842
+ const existing = this.findByName(name);
843
+ if (existing !== null) return existing;
844
+ const body = this.validate({
845
+ ...extra,
846
+ name: name.trim()
847
+ });
848
+ const id = preferredId !== void 0 && !this.entities.has(preferredId) ? preferredId : newEntityId(this.entityKind);
849
+ await this.kind.put({
850
+ id,
851
+ data: body
852
+ });
853
+ const created = {
854
+ ...body,
855
+ id
856
+ };
857
+ this.entities.set(id, created);
858
+ return created;
859
+ });
860
+ }
861
+ /** Replace the body of `id` with `next(current)`: ONE put. */
862
+ async update(id, next) {
863
+ return this.lock(async () => {
864
+ const current = this.entities.get(id);
865
+ if (current === void 0) throw new EntityNotFoundError(this.entityKind, id);
866
+ const { id: _id, ...currentBody } = current;
867
+ const body = this.validate(next(this.validate(currentBody)));
868
+ const holder = this.findByName(body.name);
869
+ if (holder !== null && holder.id !== id) throw new EntityNameTakenError(this.entityKind, body.name);
870
+ await this.kind.put({
871
+ id,
872
+ data: body
873
+ });
874
+ const updated = {
875
+ ...body,
876
+ id
877
+ };
878
+ this.entities.set(id, updated);
879
+ return updated;
880
+ });
881
+ }
882
+ /** Remove the record. Returns whether it existed. The caller clears references. */
883
+ async delete(id) {
884
+ return this.lock(async () => {
885
+ if (!this.entities.has(id)) return false;
886
+ await this.kind.delete(id);
887
+ this.entities.delete(id);
888
+ return true;
889
+ });
890
+ }
891
+ };
892
+ function orderOf(entity) {
893
+ return entity.order ?? Number.MAX_SAFE_INTEGER;
894
+ }
895
+ //#endregion
896
+ export { stableIdMapOf as _, loadPrefixed as a, roomIdFromKey as c, ConditionMirror as d, collectWhenMirrorSources as f, nextTimeBoundaryInMs as g, hasTimeLeaves as h, createWriteLock as i, tagIdFromKey as l, hasHoldLeaves as m, EntityNotFoundError as n, unwrapStoredValue as o, evaluateWhenTree as p, NamedEntityStore as r, entityNameKey as s, EntityNameTakenError as t, zoneIdFromKey as u };