@camstack/server 1.2.928 → 1.2.930

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 (241) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +10 -10
  3. package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
  4. package/system/dist/addon-id-Di0lNJ89.js +50 -0
  5. package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
  6. package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
  7. package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
  8. package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
  9. package/system/dist/addon-utils.mjs +1 -1
  10. package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
  11. package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
  12. package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
  13. package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
  14. package/system/dist/base-device-2sL1DMm1.js +1103 -0
  15. package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
  16. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
  17. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
  18. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
  19. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
  20. package/system/dist/builtins/alerts/alerts.addon.js +113 -56
  21. package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
  22. package/system/dist/builtins/autotrack/index.js +21 -17
  23. package/system/dist/builtins/autotrack/index.mjs +5 -1
  24. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
  25. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
  26. package/system/dist/builtins/calendars/calendars.addon.js +8 -6
  27. package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
  28. package/system/dist/builtins/camera-grid/index.js +615 -58
  29. package/system/dist/builtins/camera-grid/index.mjs +558 -1
  30. package/system/dist/builtins/composer/composer.addon.js +788 -209
  31. package/system/dist/builtins/composer/composer.addon.mjs +583 -4
  32. package/system/dist/builtins/console-logging/index.js +4 -3
  33. package/system/dist/builtins/console-logging/index.mjs +2 -1
  34. package/system/dist/builtins/core-blocks/actions-service.d.ts +18 -1
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +8670 -386
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +8294 -11
  37. package/system/dist/builtins/core-blocks/tcp-connect.d.ts +3 -0
  38. package/system/dist/builtins/core-notifier/core-notifier.addon.js +250 -21
  39. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +230 -1
  40. package/system/dist/builtins/device-history/device-history.addon.js +110 -31
  41. package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
  42. package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
  43. package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
  44. package/system/dist/builtins/hub-forwarder/index.js +4 -3
  45. package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
  46. package/system/dist/builtins/keychain/index.js +31 -28
  47. package/system/dist/builtins/keychain/index.mjs +7 -4
  48. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
  49. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
  50. package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
  51. package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
  52. package/system/dist/builtins/local-network/local-network.addon.js +43 -39
  53. package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
  54. package/system/dist/builtins/loki-logging/index.js +23 -17
  55. package/system/dist/builtins/loki-logging/index.mjs +7 -1
  56. package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
  57. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
  58. package/system/dist/builtins/platform-probe/index.js +25 -23
  59. package/system/dist/builtins/platform-probe/index.mjs +12 -10
  60. package/system/dist/builtins/record-entries/index.js +9 -7
  61. package/system/dist/builtins/record-entries/index.mjs +3 -1
  62. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
  63. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/snapshot/index.js +97 -44
  65. package/system/dist/builtins/snapshot/index.mjs +54 -1
  66. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
  67. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
  68. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  69. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  70. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +87 -61
  71. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
  72. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
  73. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
  74. package/system/dist/builtins/system-config/system-config.addon.js +17 -14
  75. package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
  76. package/system/dist/builtins/winston-logging/index.js +7 -5
  77. package/system/dist/builtins/winston-logging/index.mjs +3 -1
  78. package/system/dist/calendars.cap-CaFlShS9.js +155 -0
  79. package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
  80. package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
  81. package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
  82. package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
  83. package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
  84. package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
  85. package/system/dist/capability-definition-HCmTem8c.js +242 -0
  86. package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
  87. package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
  88. package/system/dist/command-origin-claim-Cief660O.js +35 -0
  89. package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
  90. package/system/dist/composition-sources-BEUWn2s_.mjs +391 -0
  91. package/system/dist/composition-sources-acfR4hDq.js +408 -0
  92. package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
  93. package/system/dist/constants-C860Y6U4.js +26 -0
  94. package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
  95. package/system/dist/constants-DCLpoF4L.mjs +21 -0
  96. package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
  97. package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
  98. package/system/dist/core-blocks.cap-BMeMCBrx.js +18733 -0
  99. package/system/dist/core-blocks.cap-BRPsLAij.mjs +18008 -0
  100. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  101. package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
  102. package/system/dist/custom-actions-D92NRi2c.js +36 -0
  103. package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
  104. package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
  105. package/system/dist/declared-device-BWphj9WE.js +303 -0
  106. package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
  107. package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
  108. package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
  109. package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
  110. package/system/dist/device-certificate-CguVACQO.js +162 -0
  111. package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
  112. package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
  113. package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
  114. package/system/dist/device-kind-CsSiv_YF.js +101 -0
  115. package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
  116. package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
  117. package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
  118. package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
  119. package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
  120. package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
  121. package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
  122. package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
  123. package/system/dist/device-type-CbQsnFdC.js +477 -0
  124. package/system/dist/device-type-DgEvK3ch.mjs +454 -0
  125. package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
  126. package/system/dist/entry-kind-cq90c--V.js +55 -0
  127. package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
  128. package/system/dist/error.cap-DBhgPeWK.js +3848 -0
  129. package/system/dist/file-host-worker.js +1 -1
  130. package/system/dist/file-host-worker.mjs +1 -1
  131. package/system/dist/history-catalog-BKRarIL_.js +831 -0
  132. package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
  133. package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
  134. package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
  135. package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
  136. package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
  137. package/system/dist/index.js +763 -151
  138. package/system/dist/index.mjs +832 -220
  139. package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
  140. package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
  141. package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
  142. package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
  143. package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
  144. package/system/dist/l10n-CGMvp7NF.js +15 -0
  145. package/system/dist/labels-DX5S8deC.js +81 -0
  146. package/system/dist/labels-DsBcU7md.mjs +64 -0
  147. package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
  148. package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
  149. package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
  150. package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
  151. package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
  152. package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
  153. package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
  154. package/system/dist/mask-shape-CmPA2fst.js +92 -0
  155. package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
  156. package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
  157. package/system/dist/migration-BMjgkyG2.js +380 -0
  158. package/system/dist/migration-DRJAtdy7.mjs +321 -0
  159. package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
  160. package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
  161. package/system/dist/notification-rules.cap-BDh0LDhV.js +3428 -0
  162. package/system/dist/notification-rules.cap-DUmiMBQB.mjs +3357 -0
  163. package/system/dist/notification-targets-CRH-9Dy5.js +509 -0
  164. package/system/dist/notification-targets-DaNE-pIt.mjs +486 -0
  165. package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
  166. package/system/dist/ops-log-pxt9176Z.js +81 -0
  167. package/system/dist/pinned-binary-BOhOSNff.js +28 -0
  168. package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
  169. package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
  170. package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
  171. package/system/dist/prefix-walk-BkMxoXpL.js +843 -0
  172. package/system/dist/prefix-walk-ifwg_ukx.mjs +790 -0
  173. package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
  174. package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
  175. package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
  176. package/system/dist/quantity-lY1KiTSZ.js +143 -0
  177. package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
  178. package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
  179. package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
  180. package/system/dist/record-entries.cap-ti1C046R.js +80 -0
  181. package/system/dist/record-kind-DoBfYHCs.js +203 -0
  182. package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
  183. package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
  184. package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
  185. package/system/dist/records.cap-ClcWV64i.js +329 -0
  186. package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
  187. package/system/dist/relocate-CdVQAk-w.js +804 -0
  188. package/system/dist/relocate-CoZZTui1.mjs +661 -0
  189. package/system/dist/rename-composition-block-BJsL58Ih.js +34798 -0
  190. package/system/dist/rename-composition-block-OAtErZgq.mjs +33631 -0
  191. package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
  192. package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
  193. package/system/dist/scoped-settings-CylSSq_8.js +955 -0
  194. package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
  195. package/system/dist/server-name-BIhLuHvX.mjs +35 -0
  196. package/system/dist/server-name-OALNvpqC.js +52 -0
  197. package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
  198. package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
  199. package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
  200. package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
  201. package/system/dist/source-info-DGB7SdB_.mjs +190 -0
  202. package/system/dist/source-info-DtWf4k2j.js +225 -0
  203. package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
  204. package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
  205. package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
  206. package/system/dist/storage-location-CTweDMZf.js +198 -0
  207. package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
  208. package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
  209. package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
  210. package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
  211. package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
  212. package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
  213. package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
  214. package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
  215. package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
  216. package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
  217. package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
  218. package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
  219. package/system/dist/system-reasons-Be_k1W8g.js +25 -0
  220. package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
  221. package/system/dist/tag-BxLazvVb.js +2138 -0
  222. package/system/dist/tag-uZBAq6ox.mjs +2073 -0
  223. package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
  224. package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
  225. package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
  226. package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
  227. package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
  228. package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
  229. package/system/dist/zod-secret-DS7mj1bk.js +78 -0
  230. package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
  231. package/system/package.json +1 -1
  232. package/system/dist/composition-sources-BI614LJx.mjs +0 -141
  233. package/system/dist/composition-sources-v_kkb8A9.js +0 -152
  234. package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
  235. package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
  236. package/system/dist/dist-BCHMSqzc.mjs +0 -143467
  237. package/system/dist/dist-BZfvhfS1.js +0 -146970
  238. package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
  239. package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
  240. package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
  241. package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
@@ -0,0 +1,509 @@
1
+ const require_base_addon = require("./base-addon-DD5dIfcZ.js");
2
+ const require_notification_rules_cap = require("./notification-rules.cap-BDh0LDhV.js");
3
+ const require_entry_kind = require("./entry-kind-cq90c--V.js");
4
+ let zod = require("zod");
5
+ //#region ../types/dist/esm/addon/compose-instance-kinds.mjs
6
+ /** No part holds the id a call named. */
7
+ var UnknownInstanceError = class extends Error {
8
+ instanceId;
9
+ constructor(instanceId) {
10
+ super(`Unknown instance '${instanceId}'`);
11
+ this.instanceId = instanceId;
12
+ this.name = "UnknownInstanceError";
13
+ }
14
+ };
15
+ /** A create or a form named no kind, or a kind no part serves. */
16
+ var UnknownInstanceKindError = class extends Error {
17
+ kindId;
18
+ constructor(kindId) {
19
+ super(kindId === void 0 ? "This provider has several kinds: name one" : `Unknown instance kind '${kindId}'`);
20
+ this.kindId = kindId;
21
+ this.name = "UnknownInstanceKindError";
22
+ }
23
+ };
24
+ function composeInstanceKinds(parts, base) {
25
+ const byKind = (kindId) => {
26
+ if (kindId === void 0) {
27
+ const only = parts.length === 1 ? parts[0] : void 0;
28
+ if (only === void 0) throw new UnknownInstanceKindError(void 0);
29
+ return only;
30
+ }
31
+ const part = parts.find((candidate) => candidate.kind.id === kindId);
32
+ if (part === void 0) throw new UnknownInstanceKindError(kindId);
33
+ return part;
34
+ };
35
+ /**
36
+ * Whether a part's kind offers a Test. A kind that states `canTest` is believed; one that does not
37
+ * takes what its OWN provider declares, never the composed base (a calendar or an integration
38
+ * inherited the account's `canTest: true` and offered a button nothing answered, planning#543).
39
+ */
40
+ const canTestPart = async (part) => part.kind.canTest ?? (await part.provider.describe()).canTest === true;
41
+ /**
42
+ * The part a DRAFT test runs on. A named kind is that kind; an unnamed one is the provider's only
43
+ * testable kind. Several testable kinds and none named is a typed refusal that lists them, never a throw.
44
+ */
45
+ const draftPart = async (kindId) => {
46
+ if (kindId !== void 0) return parts.find((candidate) => candidate.kind.id === kindId) ?? { error: `Unknown instance kind '${kindId}'` };
47
+ const flags = await Promise.all(parts.map(canTestPart));
48
+ const testable = parts.filter((_part, index) => flags[index] === true);
49
+ const only = testable.length === 1 ? testable[0] : parts.length === 1 ? parts[0] : void 0;
50
+ if (only !== void 0) return only;
51
+ return { error: `This provider has several kinds: name one of ${(testable.length > 0 ? testable : parts).map((part) => part.kind.id).join(", ")}` };
52
+ };
53
+ const holderOf = async (id) => {
54
+ for (const part of parts) if (await part.provider.getInstance({ id }) !== null) return part;
55
+ throw new UnknownInstanceError(id);
56
+ };
57
+ const tagged = (part, instance) => ({
58
+ ...instance,
59
+ kind: part.kind.id
60
+ });
61
+ return {
62
+ describe: async () => {
63
+ const links = (await Promise.all(parts.map(async (part) => (await part.provider.describe()).links ?? []))).flat();
64
+ return {
65
+ ...base,
66
+ kinds: await Promise.all(parts.map(async (part) => ({
67
+ ...part.kind,
68
+ canTest: await canTestPart(part)
69
+ }))),
70
+ ...links.length > 0 ? { links } : {}
71
+ };
72
+ },
73
+ instanceFormSchema: async ({ id, kind }) => {
74
+ return (id === null ? byKind(kind) : await holderOf(id)).provider.instanceFormSchema({ id });
75
+ },
76
+ listInstances: async (input) => {
77
+ return (await Promise.all(parts.map(async (part) => (await part.provider.listInstances(input)).map((instance) => tagged(part, instance))))).flat();
78
+ },
79
+ getInstance: async ({ id }) => {
80
+ for (const part of parts) {
81
+ const found = await part.provider.getInstance({ id });
82
+ if (found !== null) return tagged(part, found);
83
+ }
84
+ return null;
85
+ },
86
+ createInstance: async (input) => byKind(input.kind).provider.createInstance(input),
87
+ updateInstance: async (input) => (await holderOf(input.id)).provider.updateInstance(input),
88
+ setInstanceEnabled: async (input) => (await holderOf(input.id)).provider.setInstanceEnabled(input),
89
+ deleteInstance: async (input) => (await holderOf(input.id)).provider.deleteInstance(input),
90
+ testInstance: async (input) => {
91
+ const resolved = input.id === null ? await draftPart(input.kind) : await holderOf(input.id);
92
+ if ("error" in resolved) return {
93
+ success: false,
94
+ status: "inconclusive",
95
+ error: resolved.error
96
+ };
97
+ const test = resolved.provider.testInstance;
98
+ if (test === void 0) return {
99
+ success: false,
100
+ status: "inconclusive",
101
+ error: "This kind cannot be tested"
102
+ };
103
+ return test(input);
104
+ }
105
+ };
106
+ }
107
+ //#endregion
108
+ //#region ../types/dist/esm/addon/instances-of-cap.mjs
109
+ /**
110
+ * The kind's instances answer for `cap`: it is the kind's `functionCap`, or one the kind declares in
111
+ * `alsoServes`. The one rule a link (a picker, a resolver, a delete guard) matches a target by.
112
+ */
113
+ function kindServesCap(kind, cap) {
114
+ return kind.functionCap === cap || (kind.alsoServes ?? []).includes(cap);
115
+ }
116
+ async function instancesOfCap(source, cap, filter = {}) {
117
+ const instances = [];
118
+ const unreadable = [];
119
+ for (const addonId of await source.holders(cap)) try {
120
+ const kinds = ((await source.describe(addonId)).kinds ?? []).filter((kind) => kindServesCap(kind, cap));
121
+ if (kinds.length === 0) continue;
122
+ for (const instance of await source.listInstances(addonId)) {
123
+ const kind = kinds.find((candidate) => candidate.id === instance.kind);
124
+ if (kind === void 0) continue;
125
+ if (filter.kind !== void 0 && (kind.brokerKind ?? kind.id) !== filter.kind) continue;
126
+ instances.push({
127
+ addonId,
128
+ kind,
129
+ instance
130
+ });
131
+ }
132
+ } catch (err) {
133
+ unreadable.push({
134
+ addonId,
135
+ error: err instanceof Error ? err.message : String(err)
136
+ });
137
+ }
138
+ return {
139
+ instances,
140
+ unreadable
141
+ };
142
+ }
143
+ async function providersOf(api, name) {
144
+ const info = await api.capabilities.getCapability.query({ name });
145
+ if (info === null) throw new Error(`the capability registry did not answer for ${name}`);
146
+ return info.providers;
147
+ }
148
+ /**
149
+ * The source over `ctx.api`. Every provider of the cap is a holder, not only those that also serve
150
+ * `integration-instances`: a provider that does not (an addon older than the hub during an update)
151
+ * then fails `describe` and is reported unreadable, so its instances are retried as transient
152
+ * instead of vanishing from the catalogue and failing for good.
153
+ */
154
+ function instanceSourceOverApi(api) {
155
+ return {
156
+ holders: (cap) => providersOf(api, cap),
157
+ describe: (addonId) => api.integrationInstances.describe.query({ addonId }),
158
+ listInstances: (addonId) => api.integrationInstances.listInstances.query({ addonId })
159
+ };
160
+ }
161
+ //#endregion
162
+ //#region ../types/dist/esm/addon/notification-targets.mjs
163
+ /**
164
+ * Notification targets as instances of the function cap `notification-output` (epic #440, step 6).
165
+ *
166
+ * A notification target used to be one row of one record kind (`{ name, kind, addonId, enabled,
167
+ * config }`) with a free-form `config` blob whose secrets nobody could name. Now every target KIND
168
+ * the provider offers (ntfy, telegram, webhook, ...) is a record kind of its own whose flat body IS
169
+ * that kind's form: the adapter's `configSchema` lifted into a Zod object, a `password` field marked
170
+ * `.meta({ secret: true })` so the records door keeps it in the keychain, an `instance-select` field
171
+ * declared as a link so the hub refuses to delete what a target points at.
172
+ *
173
+ * Three providers (notifiers, Home Assistant, Alexa) serve the same shape, so the pieces are shared:
174
+ * - {@link defineNotificationTargetKind}: the record kind of one `TargetKind` descriptor;
175
+ * - {@link NotificationTargetStore}: the `Target`-shaped facade the provider's own code keeps
176
+ * using (send, the notification-center bridge), over one handle per kind;
177
+ * - {@link listNotificationTargets}: the targets as an addon on `ctx.api` reads them;
178
+ * - {@link buildNotificationTargetInstances}: the `integration-instances` provider, one kind each;
179
+ * - {@link moveTargetRows}: the D987 procedure that flattens the old `config` blobs into the bodies.
180
+ */
181
+ /** The function cap every notification target is an instance of. */
182
+ var NOTIFICATION_OUTPUT_CAP = "notification-output";
183
+ /** The most targets one provider lists (a settings page, not a table). */
184
+ var TARGETS_LIST_MAX = 1e3;
185
+ /** The record kind name of one target kind: `telegram` is stored under `notify-telegram`. */
186
+ function notificationTargetKindName(kind) {
187
+ return `notify-${kind}`;
188
+ }
189
+ /** The body schema of a target kind: the entry's name and switch plus the adapter's fields. */
190
+ var TargetBodyBaseSchema = /* @__PURE__ */ zod.z.looseObject({
191
+ name: /* @__PURE__ */ zod.z.string().min(1),
192
+ enabled: /* @__PURE__ */ zod.z.boolean().optional()
193
+ });
194
+ /** The shape of one `editable-array` row: the item fields, a `password` one a secret. */
195
+ function rowSchemaOf(itemFields) {
196
+ const shape = {};
197
+ let idKey = null;
198
+ let hasSecret = false;
199
+ for (const item of itemFields) {
200
+ if (item.type === "password") {
201
+ shape[item.key] = zod.z.string().optional().meta({ secret: true });
202
+ hasSecret = true;
203
+ continue;
204
+ }
205
+ shape[item.key] = zod.z.unknown().optional();
206
+ idKey ??= item.key;
207
+ }
208
+ return {
209
+ row: zod.z.looseObject(shape),
210
+ idKey,
211
+ hasSecret
212
+ };
213
+ }
214
+ /**
215
+ * The Zod fields of a descriptor's form. A `password` field is a secret; an `instance-select` field is
216
+ * a link to an instance of its function cap; an `editable-array` keeps its rows (a password inside a
217
+ * row is a secret matched by the row's first plain field); every other field keeps whatever the
218
+ * adapter's own parse accepts, because the form already validated its shape. The body is loose, so a key
219
+ * the schema does not know (the owner of a personal target) survives a write.
220
+ */
221
+ function fieldsOf(descriptor) {
222
+ const shape = {};
223
+ const secretArrayKeys = {};
224
+ for (const section of descriptor.configSchema.sections) for (const field of section.fields) switch (field.type) {
225
+ case "info": break;
226
+ case "password":
227
+ shape[field.key] = zod.z.string().optional().meta({ secret: true });
228
+ break;
229
+ case "instance-select":
230
+ shape[field.key] = require_base_addon.optionalLinkField({
231
+ cap: field.functionCap,
232
+ ...field.kind !== void 0 ? { kind: field.kind } : {}
233
+ });
234
+ break;
235
+ case "editable-array": {
236
+ const { row, idKey, hasSecret } = rowSchemaOf(field.itemFields);
237
+ shape[field.key] = zod.z.array(row).optional();
238
+ if (hasSecret && idKey !== null) secretArrayKeys[field.key] = idKey;
239
+ break;
240
+ }
241
+ default: shape[field.key] = zod.z.unknown().optional();
242
+ }
243
+ return {
244
+ shape,
245
+ secretArrayKeys
246
+ };
247
+ }
248
+ /** The record kind of one target kind, derived from its descriptor. */
249
+ function defineNotificationTargetKind(descriptor) {
250
+ const { shape, secretArrayKeys } = fieldsOf(descriptor);
251
+ return require_entry_kind.defineEntryKind(notificationTargetKindName(descriptor.kind), {
252
+ title: `${descriptor.label} notification targets`,
253
+ schema: TargetBodyBaseSchema.extend(shape),
254
+ writeTrigger: `an operator adds, edits, switches or removes a ${descriptor.label} notification target`,
255
+ ...Object.keys(secretArrayKeys).length > 0 ? { secretArrayKeys } : {}
256
+ });
257
+ }
258
+ /** The record kinds of a provider's descriptors, keyed by the record kind name (for `records.declare`). */
259
+ function notificationTargetKinds(descriptors) {
260
+ return Object.fromEntries(descriptors.map((descriptor) => {
261
+ const defined = defineNotificationTargetKind(descriptor);
262
+ return [defined.name, defined];
263
+ }));
264
+ }
265
+ /** The body a stored target becomes: the switch and the name, and the config fields flat beside them. */
266
+ function targetBody(target) {
267
+ return {
268
+ ...target.config,
269
+ name: target.name.length > 0 ? target.name : target.id,
270
+ enabled: target.enabled
271
+ };
272
+ }
273
+ /** The `Target` a record of a kind is; null when the row is not a target. */
274
+ function targetOfRecord(addonId, kind, id, data) {
275
+ const { name, enabled: _enabled, ...config } = data;
276
+ const parsed = require_notification_rules_cap.TargetSchema.safeParse({
277
+ id,
278
+ name,
279
+ kind,
280
+ addonId,
281
+ enabled: require_base_addon.isInstanceOn(id),
282
+ config
283
+ });
284
+ return parsed.success ? parsed.data : null;
285
+ }
286
+ function targetOfOld(addonId, row) {
287
+ return {
288
+ id: row.id,
289
+ name: row.name,
290
+ kind: row.kind,
291
+ addonId,
292
+ enabled: row.enabled,
293
+ config: { ...row.config }
294
+ };
295
+ }
296
+ /**
297
+ * The `Target`-shaped facade over one record kind per target kind. `list` returns the stored form (a
298
+ * secret is a keychain marker: every reader redacts it anyway); `getById` returns the target with its
299
+ * secrets resolved, which is what a send, a probe and an edit's secret merge need. A keychain that
300
+ * cannot answer throws: a write never goes ahead with a secret it could not read (D49).
301
+ */
302
+ var NotificationTargetStore = class NotificationTargetStore {
303
+ addonId;
304
+ handles;
305
+ options;
306
+ constructor(addonId, handles, options) {
307
+ this.addonId = addonId;
308
+ this.handles = handles;
309
+ this.options = options;
310
+ }
311
+ static of(records, addonId, kinds, descriptors, options = {}) {
312
+ const handles = [];
313
+ for (const descriptor of descriptors) {
314
+ const defined = kinds[notificationTargetKindName(descriptor.kind)];
315
+ if (defined === void 0) continue;
316
+ handles.push({
317
+ kind: descriptor.kind,
318
+ handle: records.kind(defined)
319
+ });
320
+ }
321
+ return new NotificationTargetStore(addonId, handles, options);
322
+ }
323
+ /** The record handle of each kind, for the migration ports. */
324
+ handlesByKind() {
325
+ return new Map(this.handles.map((entry) => [entry.kind, entry.handle]));
326
+ }
327
+ async list() {
328
+ const out = [];
329
+ for (const { kind, handle } of this.handles) {
330
+ const page = await handle.query({ limit: TARGETS_LIST_MAX });
331
+ for (const record of page.records) {
332
+ const target = targetOfRecord(this.addonId, kind, record.id, record.data);
333
+ if (target !== null) {
334
+ out.push(target);
335
+ continue;
336
+ }
337
+ this.options.logger?.warn("notification target record is not a valid target; left out of the list", { meta: {
338
+ targetId: record.id,
339
+ kind
340
+ } });
341
+ }
342
+ }
343
+ const held = new Set(out.map((target) => target.id));
344
+ for (const row of await this.legacyRows()) if (!held.has(row.id)) out.push(targetOfOld(this.addonId, row));
345
+ return out;
346
+ }
347
+ /** The legacy rows of a kind this provider serves (the others are not ours to show). */
348
+ async legacyRows() {
349
+ const legacy = this.options.legacy;
350
+ if (legacy === void 0) return [];
351
+ const served = new Set(this.handles.map((entry) => entry.kind));
352
+ return (await legacy.list()).filter((row) => served.has(row.kind));
353
+ }
354
+ async getById(id) {
355
+ for (const { kind, handle } of this.handles) {
356
+ const row = await handle.getResolved(id);
357
+ if (row !== null) return targetOfRecord(this.addonId, kind, row.id, row.data);
358
+ }
359
+ const old = (await this.legacyRows()).find((row) => row.id === id);
360
+ return old === void 0 ? null : targetOfOld(this.addonId, old);
361
+ }
362
+ /** Insert or replace by id; a target whose kind changed leaves the record of its old kind. */
363
+ async upsert(target) {
364
+ const own = this.handles.find((entry) => entry.kind === target.kind);
365
+ if (own === void 0) throw new Error(`invalid target '${target.id}': unknown kind '${target.kind}'`);
366
+ const { enabled: _switch, ...data } = targetBody(target);
367
+ await own.handle.put({
368
+ id: target.id,
369
+ data
370
+ });
371
+ require_base_addon.recordInstanceSwitch(target.id, target.enabled);
372
+ for (const other of this.handles) if (other !== own) await other.handle.delete(target.id);
373
+ await this.options.legacy?.delete(target.id);
374
+ }
375
+ async delete(id) {
376
+ for (const { handle } of this.handles) await handle.delete(id);
377
+ await this.options.legacy?.delete(id);
378
+ }
379
+ };
380
+ /**
381
+ * A probe's answer as the tri-state of `testInstance`: `ok` validated; a refusal that carries an HTTP
382
+ * status is the remote saying no (`rejected`); a failure with no answer at all (the network, a missing
383
+ * field) proves nothing about the credentials (`inconclusive`).
384
+ */
385
+ function probeToTestResult(probed) {
386
+ if (probed.ok) return {
387
+ success: true,
388
+ status: "validated",
389
+ ...probed.stateInstance !== void 0 ? { detail: probed.stateInstance } : {}
390
+ };
391
+ const error = probed.error ?? "the probe failed";
392
+ return {
393
+ success: false,
394
+ status: probed.httpStatus !== void 0 ? "rejected" : "inconclusive",
395
+ error
396
+ };
397
+ }
398
+ /** The form of a kind: the adapter's own sections. */
399
+ function formOf(descriptor) {
400
+ return descriptor.configSchema;
401
+ }
402
+ /** The instance kinds of a notification provider, one per target kind: a part a composition can take. */
403
+ function notificationTargetParts(records, spec) {
404
+ return spec.descriptors.flatMap((descriptor) => {
405
+ const defined = spec.kinds[notificationTargetKindName(descriptor.kind)];
406
+ if (defined === void 0) return [];
407
+ const canTest = spec.probe !== void 0 && spec.canProbe(descriptor.kind);
408
+ const kind = {
409
+ id: descriptor.kind,
410
+ label: descriptor.label,
411
+ functionCap: NOTIFICATION_OUTPUT_CAP,
412
+ role: "services",
413
+ canTest,
414
+ ...spec.widgets?.(descriptor.kind) !== void 0 ? { widgets: spec.widgets(descriptor.kind) } : {},
415
+ ...descriptor.iconUrl !== void 0 ? { iconUrl: descriptor.iconUrl } : {},
416
+ ...descriptor.iconMediaType !== void 0 ? { iconMediaType: descriptor.iconMediaType } : {}
417
+ };
418
+ return [{
419
+ kind,
420
+ provider: new require_base_addon.RecordIntegrationInstances(records, defined, {
421
+ description: {
422
+ role: "services",
423
+ instanceMode: "multiple",
424
+ kind: "target",
425
+ canTest,
426
+ kinds: [kind]
427
+ },
428
+ formSchema: () => formOf(descriptor),
429
+ initialBody: (name) => ({ name }),
430
+ mintId: () => spec.mintId(),
431
+ configured: () => true,
432
+ validateWrite: ({ body }) => spec.validate?.({
433
+ kind: descriptor.kind,
434
+ config: body
435
+ }),
436
+ test: async ({ id, values }) => {
437
+ if (spec.probe === void 0 || !canTest) return {
438
+ success: false,
439
+ status: "unsupported",
440
+ error: "This kind cannot be tested"
441
+ };
442
+ return probeToTestResult(await spec.probe({
443
+ kind: descriptor.kind,
444
+ config: values,
445
+ targetId: id ?? void 0
446
+ }));
447
+ }
448
+ }).toProvider()
449
+ }];
450
+ });
451
+ }
452
+ /** The `integration-instances` provider of a notification provider: one kind per target kind. */
453
+ function buildNotificationTargetInstances(records, spec) {
454
+ const parts = notificationTargetParts(records, spec);
455
+ return composeInstanceKinds(parts, {
456
+ role: "services",
457
+ instanceMode: "multiple",
458
+ kind: "target",
459
+ canTest: parts.some((part) => part.kind.canTest === true),
460
+ mintsId: true
461
+ });
462
+ }
463
+ /**
464
+ * Every notification target, read as the instances of `notification-output` (D1013 rule 5). A holder
465
+ * that could not answer is NAMED in `unreadable`: a caller that acts on a target's absence (drops a
466
+ * selection, refuses a send) must check it first, because a partial read is not "deleted" (D315, D49).
467
+ */
468
+ async function listNotificationTargets(api) {
469
+ const { instances, unreadable } = await instancesOfCap(instanceSourceOverApi(api), NOTIFICATION_OUTPUT_CAP);
470
+ return {
471
+ targets: instances.map(({ addonId, kind, instance }) => {
472
+ const owner = instance.formValues["ownerUserId"];
473
+ return {
474
+ id: instance.id,
475
+ name: instance.name,
476
+ kind: kind.id,
477
+ addonId,
478
+ enabled: instance.enabled !== false,
479
+ ...typeof owner === "string" && owner.length > 0 ? { ownerUserId: owner } : {}
480
+ };
481
+ }),
482
+ unreadable
483
+ };
484
+ }
485
+ //#endregion
486
+ Object.defineProperty(exports, "NotificationTargetStore", {
487
+ enumerable: true,
488
+ get: function() {
489
+ return NotificationTargetStore;
490
+ }
491
+ });
492
+ Object.defineProperty(exports, "buildNotificationTargetInstances", {
493
+ enumerable: true,
494
+ get: function() {
495
+ return buildNotificationTargetInstances;
496
+ }
497
+ });
498
+ Object.defineProperty(exports, "listNotificationTargets", {
499
+ enumerable: true,
500
+ get: function() {
501
+ return listNotificationTargets;
502
+ }
503
+ });
504
+ Object.defineProperty(exports, "notificationTargetKinds", {
505
+ enumerable: true,
506
+ get: function() {
507
+ return notificationTargetKinds;
508
+ }
509
+ });