@camstack/core 0.1.15 → 0.1.17

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 (382) hide show
  1. package/dist/addon/addon-api-factory.d.ts +36 -0
  2. package/dist/addon/addon-api-factory.d.ts.map +1 -0
  3. package/dist/addon-routes/addon-route-registry.d.ts +38 -0
  4. package/dist/addon-routes/addon-route-registry.d.ts.map +1 -0
  5. package/dist/auth/api-key-manager.d.ts +27 -0
  6. package/dist/auth/api-key-manager.d.ts.map +1 -0
  7. package/dist/auth/auth-manager.d.ts +47 -0
  8. package/dist/auth/auth-manager.d.ts.map +1 -0
  9. package/dist/auth/parse-record.d.ts +19 -0
  10. package/dist/auth/parse-record.d.ts.map +1 -0
  11. package/dist/auth/scoped-token-manager.d.ts +18 -0
  12. package/dist/auth/scoped-token-manager.d.ts.map +1 -0
  13. package/dist/auth/user-manager.d.ts +34 -0
  14. package/dist/auth/user-manager.d.ts.map +1 -0
  15. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts +54 -0
  16. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts.map +1 -0
  17. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +223 -217
  18. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js.map +1 -1
  19. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +216 -7
  20. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs.map +1 -1
  21. package/dist/builtins/addon-pages-aggregator/index.d.ts +2 -0
  22. package/dist/builtins/addon-pages-aggregator/index.d.ts.map +1 -0
  23. package/dist/builtins/addon-pages-aggregator/index.js +6 -221
  24. package/dist/builtins/addon-pages-aggregator/index.mjs +2 -9
  25. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts +33 -0
  26. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts.map +1 -0
  27. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +199 -197
  28. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js.map +1 -1
  29. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +192 -7
  30. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs.map +1 -1
  31. package/dist/builtins/addon-widgets-aggregator/index.d.ts +2 -0
  32. package/dist/builtins/addon-widgets-aggregator/index.d.ts.map +1 -0
  33. package/dist/builtins/addon-widgets-aggregator/index.js +6 -201
  34. package/dist/builtins/addon-widgets-aggregator/index.mjs +2 -9
  35. package/dist/builtins/alerts/alerts.addon.d.ts +82 -0
  36. package/dist/builtins/alerts/alerts.addon.d.ts.map +1 -0
  37. package/dist/builtins/alerts/alerts.addon.js +590 -430
  38. package/dist/builtins/alerts/alerts.addon.js.map +1 -1
  39. package/dist/builtins/alerts/alerts.addon.mjs +595 -7
  40. package/dist/builtins/alerts/alerts.addon.mjs.map +1 -1
  41. package/dist/builtins/alerts/index.d.ts +2 -0
  42. package/dist/builtins/alerts/index.d.ts.map +1 -0
  43. package/dist/builtins/alerts/index.js +3 -443
  44. package/dist/builtins/alerts/index.mjs +2 -8
  45. package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.d.ts +8 -0
  46. package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.d.ts.map +1 -0
  47. package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.js +56 -0
  48. package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.js.map +1 -0
  49. package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.mjs +50 -0
  50. package/dist/builtins/auth-orchestrator/auth-orchestrator.addon.mjs.map +1 -0
  51. package/dist/builtins/auth-orchestrator/index.d.ts +2 -0
  52. package/dist/builtins/auth-orchestrator/index.d.ts.map +1 -0
  53. package/dist/builtins/auth-orchestrator/index.js +7 -0
  54. package/dist/builtins/auth-orchestrator/index.mjs +2 -0
  55. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +148 -0
  56. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts.map +1 -0
  57. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +7639 -0
  58. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js.map +1 -0
  59. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +7627 -0
  60. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs.map +1 -0
  61. package/dist/builtins/backup-orchestrator/cron-helpers.d.ts +24 -0
  62. package/dist/builtins/backup-orchestrator/cron-helpers.d.ts.map +1 -0
  63. package/dist/builtins/backup-orchestrator/destination-policy.d.ts +73 -0
  64. package/dist/builtins/backup-orchestrator/destination-policy.d.ts.map +1 -0
  65. package/dist/builtins/backup-orchestrator/download-helpers.d.ts +13 -0
  66. package/dist/builtins/backup-orchestrator/download-helpers.d.ts.map +1 -0
  67. package/dist/builtins/backup-orchestrator/index.d.ts +3 -0
  68. package/dist/builtins/backup-orchestrator/index.d.ts.map +1 -0
  69. package/dist/builtins/backup-orchestrator/index.js +7 -0
  70. package/dist/builtins/backup-orchestrator/index.mjs +2 -0
  71. package/dist/builtins/backup-orchestrator/manifest-store.d.ts +78 -0
  72. package/dist/builtins/backup-orchestrator/manifest-store.d.ts.map +1 -0
  73. package/dist/builtins/console-logging/console-destination.d.ts +14 -0
  74. package/dist/builtins/console-logging/console-destination.d.ts.map +1 -0
  75. package/dist/builtins/console-logging/console-logging.addon.d.ts +26 -0
  76. package/dist/builtins/console-logging/console-logging.addon.d.ts.map +1 -0
  77. package/dist/builtins/console-logging/index.d.ts +4 -0
  78. package/dist/builtins/console-logging/index.d.ts.map +1 -0
  79. package/dist/builtins/console-logging/index.js +99 -235
  80. package/dist/builtins/console-logging/index.js.map +1 -1
  81. package/dist/builtins/console-logging/index.mjs +95 -9
  82. package/dist/builtins/console-logging/index.mjs.map +1 -1
  83. package/dist/builtins/device-manager/device-event-propagator.d.ts +27 -0
  84. package/dist/builtins/device-manager/device-event-propagator.d.ts.map +1 -0
  85. package/dist/builtins/device-manager/device-manager.addon.d.ts +259 -0
  86. package/dist/builtins/device-manager/device-manager.addon.d.ts.map +1 -0
  87. package/dist/builtins/device-manager/device-manager.addon.js +2125 -2127
  88. package/dist/builtins/device-manager/device-manager.addon.js.map +1 -1
  89. package/dist/builtins/device-manager/device-manager.addon.mjs +2145 -7
  90. package/dist/builtins/device-manager/device-manager.addon.mjs.map +1 -1
  91. package/dist/builtins/device-manager/index.d.ts +3 -0
  92. package/dist/builtins/device-manager/index.d.ts.map +1 -0
  93. package/dist/builtins/device-manager/index.js +6 -2156
  94. package/dist/builtins/device-manager/index.mjs +2 -10
  95. package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +45 -0
  96. package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts.map +1 -0
  97. package/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts +16 -0
  98. package/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts.map +1 -0
  99. package/dist/builtins/hub-forwarder/index.d.ts +4 -0
  100. package/dist/builtins/hub-forwarder/index.d.ts.map +1 -0
  101. package/dist/builtins/hub-forwarder/index.js +150 -291
  102. package/dist/builtins/hub-forwarder/index.js.map +1 -1
  103. package/dist/builtins/hub-forwarder/index.mjs +145 -9
  104. package/dist/builtins/hub-forwarder/index.mjs.map +1 -1
  105. package/dist/builtins/local-auth/auth-schema.d.ts +12 -0
  106. package/dist/builtins/local-auth/auth-schema.d.ts.map +1 -0
  107. package/dist/builtins/local-auth/index.d.ts +2 -0
  108. package/dist/builtins/local-auth/index.d.ts.map +1 -0
  109. package/dist/builtins/local-auth/index.js +3 -623
  110. package/dist/builtins/local-auth/index.mjs +2 -8
  111. package/dist/builtins/local-auth/local-auth.addon.d.ts +17 -0
  112. package/dist/builtins/local-auth/local-auth.addon.d.ts.map +1 -0
  113. package/dist/builtins/local-auth/local-auth.addon.js +6861 -589
  114. package/dist/builtins/local-auth/local-auth.addon.js.map +1 -1
  115. package/dist/builtins/local-auth/local-auth.addon.mjs +6883 -7
  116. package/dist/builtins/local-auth/local-auth.addon.mjs.map +1 -1
  117. package/dist/builtins/local-network/index.d.ts +3 -0
  118. package/dist/builtins/local-network/index.d.ts.map +1 -0
  119. package/dist/builtins/local-network/index.js +9 -0
  120. package/dist/builtins/local-network/index.mjs +2 -0
  121. package/dist/builtins/local-network/local-network.addon.d.ts +110 -0
  122. package/dist/builtins/local-network/local-network.addon.d.ts.map +1 -0
  123. package/dist/builtins/local-network/local-network.addon.js +399 -0
  124. package/dist/builtins/local-network/local-network.addon.js.map +1 -0
  125. package/dist/builtins/local-network/local-network.addon.mjs +387 -0
  126. package/dist/builtins/local-network/local-network.addon.mjs.map +1 -0
  127. package/dist/builtins/mesh-orchestrator/index.d.ts +2 -0
  128. package/dist/builtins/mesh-orchestrator/index.d.ts.map +1 -0
  129. package/dist/builtins/mesh-orchestrator/index.js +7 -0
  130. package/dist/builtins/mesh-orchestrator/index.mjs +2 -0
  131. package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.d.ts +9 -0
  132. package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.d.ts.map +1 -0
  133. package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.js +83 -0
  134. package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.js.map +1 -0
  135. package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.mjs +77 -0
  136. package/dist/builtins/mesh-orchestrator/mesh-orchestrator.addon.mjs.map +1 -0
  137. package/dist/builtins/native-metrics/index.d.ts +3 -0
  138. package/dist/builtins/native-metrics/index.d.ts.map +1 -0
  139. package/dist/builtins/native-metrics/native-metrics-provider.d.ts +49 -0
  140. package/dist/builtins/native-metrics/native-metrics-provider.d.ts.map +1 -0
  141. package/dist/builtins/native-metrics/native-metrics.addon.d.ts +74 -0
  142. package/dist/builtins/native-metrics/native-metrics.addon.d.ts.map +1 -0
  143. package/dist/builtins/native-metrics/native-metrics.addon.js +887 -861
  144. package/dist/builtins/native-metrics/native-metrics.addon.js.map +1 -1
  145. package/dist/builtins/native-metrics/native-metrics.addon.mjs +914 -5
  146. package/dist/builtins/native-metrics/native-metrics.addon.mjs.map +1 -1
  147. package/dist/builtins/platform-probe/index.d.ts +12 -0
  148. package/dist/builtins/platform-probe/index.d.ts.map +1 -0
  149. package/dist/builtins/platform-probe/index.js +539 -0
  150. package/dist/builtins/platform-probe/index.js.map +1 -0
  151. package/dist/builtins/platform-probe/index.mjs +530 -0
  152. package/dist/builtins/platform-probe/index.mjs.map +1 -0
  153. package/dist/builtins/platform-probe/inference-config-resolver.d.ts +30 -0
  154. package/dist/builtins/platform-probe/inference-config-resolver.d.ts.map +1 -0
  155. package/dist/builtins/platform-probe/platform-scorer.d.ts +22 -0
  156. package/dist/builtins/platform-probe/platform-scorer.d.ts.map +1 -0
  157. package/dist/builtins/remote-access-orchestrator/index.d.ts +2 -0
  158. package/dist/builtins/remote-access-orchestrator/index.d.ts.map +1 -0
  159. package/dist/builtins/remote-access-orchestrator/index.js +7 -0
  160. package/dist/builtins/remote-access-orchestrator/index.mjs +2 -0
  161. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +9 -0
  162. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts.map +1 -0
  163. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +72 -0
  164. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js.map +1 -0
  165. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +66 -0
  166. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs.map +1 -0
  167. package/dist/builtins/snapshot/index.d.ts +3 -0
  168. package/dist/builtins/snapshot/index.d.ts.map +1 -0
  169. package/dist/builtins/snapshot/index.js +481 -491
  170. package/dist/builtins/snapshot/index.js.map +1 -1
  171. package/dist/builtins/snapshot/index.mjs +475 -464
  172. package/dist/builtins/snapshot/index.mjs.map +1 -1
  173. package/dist/builtins/snapshot/snapshot.addon.d.ts +121 -0
  174. package/dist/builtins/snapshot/snapshot.addon.d.ts.map +1 -0
  175. package/dist/builtins/sqlite-storage/config-store.d.ts +9 -0
  176. package/dist/builtins/sqlite-storage/config-store.d.ts.map +1 -0
  177. package/dist/builtins/sqlite-storage/device-store.d.ts +24 -0
  178. package/dist/builtins/sqlite-storage/device-store.d.ts.map +1 -0
  179. package/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts +87 -0
  180. package/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts.map +1 -0
  181. package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +32 -0
  182. package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts.map +1 -0
  183. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +312 -56
  184. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js.map +1 -1
  185. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +305 -7
  186. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs.map +1 -1
  187. package/dist/builtins/sqlite-storage/index.d.ts +12 -0
  188. package/dist/builtins/sqlite-storage/index.d.ts.map +1 -0
  189. package/dist/builtins/sqlite-storage/index.js +229 -1001
  190. package/dist/builtins/sqlite-storage/index.js.map +1 -1
  191. package/dist/builtins/sqlite-storage/index.mjs +268 -26
  192. package/dist/builtins/sqlite-storage/index.mjs.map +1 -1
  193. package/dist/builtins/sqlite-storage/integration-registry.d.ts +28 -0
  194. package/dist/builtins/sqlite-storage/integration-registry.d.ts.map +1 -0
  195. package/dist/builtins/sqlite-storage/settings-store.d.ts +40 -0
  196. package/dist/builtins/sqlite-storage/settings-store.d.ts.map +1 -0
  197. package/dist/builtins/sqlite-storage/sql-schema.d.ts +33 -0
  198. package/dist/builtins/sqlite-storage/sql-schema.d.ts.map +1 -0
  199. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +94 -0
  200. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts.map +1 -0
  201. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +15 -0
  202. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts.map +1 -0
  203. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +586 -653
  204. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js.map +1 -1
  205. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +582 -7
  206. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs.map +1 -1
  207. package/dist/builtins/storage-orchestrator/index.d.ts +7 -0
  208. package/dist/builtins/storage-orchestrator/index.d.ts.map +1 -0
  209. package/dist/builtins/storage-orchestrator/index.js +9 -0
  210. package/dist/builtins/storage-orchestrator/index.mjs +2 -0
  211. package/dist/builtins/storage-orchestrator/location-store.d.ts +50 -0
  212. package/dist/builtins/storage-orchestrator/location-store.d.ts.map +1 -0
  213. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +60 -0
  214. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts.map +1 -0
  215. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +755 -0
  216. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js.map +1 -0
  217. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +746 -0
  218. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs.map +1 -0
  219. package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +121 -0
  220. package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts.map +1 -0
  221. package/dist/builtins/system-backup/system-backup.service.d.ts +138 -0
  222. package/dist/builtins/system-backup/system-backup.service.d.ts.map +1 -0
  223. package/dist/builtins/system-config/index.d.ts +2 -0
  224. package/dist/builtins/system-config/index.d.ts.map +1 -0
  225. package/dist/builtins/system-config/index.js +6 -188
  226. package/dist/builtins/system-config/index.mjs +2 -10
  227. package/dist/builtins/system-config/system-config.addon.d.ts +11 -0
  228. package/dist/builtins/system-config/system-config.addon.d.ts.map +1 -0
  229. package/dist/builtins/system-config/system-config.addon.js +227 -180
  230. package/dist/builtins/system-config/system-config.addon.js.map +1 -1
  231. package/dist/builtins/system-config/system-config.addon.mjs +226 -7
  232. package/dist/builtins/system-config/system-config.addon.mjs.map +1 -1
  233. package/dist/builtins/turn-orchestrator/index.d.ts +2 -0
  234. package/dist/builtins/turn-orchestrator/index.d.ts.map +1 -0
  235. package/dist/builtins/turn-orchestrator/index.js +7 -0
  236. package/dist/builtins/turn-orchestrator/index.mjs +2 -0
  237. package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.d.ts +10 -0
  238. package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.d.ts.map +1 -0
  239. package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.js +78 -0
  240. package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.js.map +1 -0
  241. package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.mjs +72 -0
  242. package/dist/builtins/turn-orchestrator/turn-orchestrator.addon.mjs.map +1 -0
  243. package/dist/builtins/winston-logging/index.d.ts +4 -0
  244. package/dist/builtins/winston-logging/index.d.ts.map +1 -0
  245. package/dist/builtins/winston-logging/index.js +153 -300
  246. package/dist/builtins/winston-logging/index.js.map +1 -1
  247. package/dist/builtins/winston-logging/index.mjs +144 -9
  248. package/dist/builtins/winston-logging/index.mjs.map +1 -1
  249. package/dist/builtins/winston-logging/winston-destination.d.ts +22 -0
  250. package/dist/builtins/winston-logging/winston-destination.d.ts.map +1 -0
  251. package/dist/builtins/winston-logging/winston-logging.addon.d.ts +20 -0
  252. package/dist/builtins/winston-logging/winston-logging.addon.d.ts.map +1 -0
  253. package/dist/chunk-C13QxCFV.js +50 -0
  254. package/dist/chunk-hT5z_Zn9.mjs +35 -0
  255. package/dist/download/model-download-service.d.ts +42 -0
  256. package/dist/download/model-download-service.d.ts.map +1 -0
  257. package/dist/download/model-downloader.d.ts +32 -0
  258. package/dist/download/model-downloader.d.ts.map +1 -0
  259. package/dist/events/event-bus.d.ts +11 -0
  260. package/dist/events/event-bus.d.ts.map +1 -0
  261. package/dist/events/system-event-bus.d.ts +15 -0
  262. package/dist/events/system-event-bus.d.ts.map +1 -0
  263. package/dist/feature/feature-manager.d.ts +12 -0
  264. package/dist/feature/feature-manager.d.ts.map +1 -0
  265. package/dist/formatter-C-5An4Bl.mjs +164 -0
  266. package/dist/formatter-C-5An4Bl.mjs.map +1 -0
  267. package/dist/formatter-Dr_6NNZc.js +169 -0
  268. package/dist/formatter-Dr_6NNZc.js.map +1 -0
  269. package/dist/index.d.ts +76 -1696
  270. package/dist/index.d.ts.map +1 -0
  271. package/dist/index.js +7780 -8035
  272. package/dist/index.js.map +1 -1
  273. package/dist/index.mjs +7707 -2148
  274. package/dist/index.mjs.map +1 -1
  275. package/dist/lifecycle/lifecycle-state-machine.d.ts +29 -0
  276. package/dist/lifecycle/lifecycle-state-machine.d.ts.map +1 -0
  277. package/dist/logging/formatter.d.ts +31 -0
  278. package/dist/logging/formatter.d.ts.map +1 -0
  279. package/dist/logging/log-manager.d.ts +52 -0
  280. package/dist/logging/log-manager.d.ts.map +1 -0
  281. package/dist/logging/log-ring-buffer.d.ts +48 -0
  282. package/dist/logging/log-ring-buffer.d.ts.map +1 -0
  283. package/dist/logging/scoped-logger.d.ts +18 -0
  284. package/dist/logging/scoped-logger.d.ts.map +1 -0
  285. package/dist/network/network-quality.d.ts +12 -0
  286. package/dist/network/network-quality.d.ts.map +1 -0
  287. package/dist/notification/notification-service.d.ts +38 -0
  288. package/dist/notification/notification-service.d.ts.map +1 -0
  289. package/dist/notification/toast-service.d.ts +23 -0
  290. package/dist/notification/toast-service.d.ts.map +1 -0
  291. package/dist/pipeline/engine-manager-resolver.d.ts +16 -0
  292. package/dist/pipeline/engine-manager-resolver.d.ts.map +1 -0
  293. package/dist/pipeline/pipeline-runner.d.ts +9 -0
  294. package/dist/pipeline/pipeline-runner.d.ts.map +1 -0
  295. package/dist/pipeline/pipeline-validator.d.ts +14 -0
  296. package/dist/pipeline/pipeline-validator.d.ts.map +1 -0
  297. package/dist/process/resource-monitor.d.ts +12 -0
  298. package/dist/process/resource-monitor.d.ts.map +1 -0
  299. package/dist/python/python-env-manager.d.ts +13 -0
  300. package/dist/python/python-env-manager.d.ts.map +1 -0
  301. package/dist/repl/interfaces.d.ts +32 -0
  302. package/dist/repl/interfaces.d.ts.map +1 -0
  303. package/dist/repl/repl-engine.d.ts +9 -0
  304. package/dist/repl/repl-engine.d.ts.map +1 -0
  305. package/dist/resource-monitor-CmuWlmap.js +76 -0
  306. package/dist/resource-monitor-CmuWlmap.js.map +1 -0
  307. package/dist/resource-monitor-DcQdKGYU.mjs +59 -0
  308. package/dist/resource-monitor-DcQdKGYU.mjs.map +1 -0
  309. package/dist/storage/fs-storage-backend.d.ts +41 -0
  310. package/dist/storage/fs-storage-backend.d.ts.map +1 -0
  311. package/dist/storage/storage-location-manager.d.ts +24 -0
  312. package/dist/storage/storage-location-manager.d.ts.map +1 -0
  313. package/dist/storage/storage-manager.d.ts +77 -0
  314. package/dist/storage/storage-manager.d.ts.map +1 -0
  315. package/dist/tls/cert-manager.d.ts +27 -0
  316. package/dist/tls/cert-manager.d.ts.map +1 -0
  317. package/dist/tls/index.d.ts +2 -0
  318. package/dist/tls/index.d.ts.map +1 -0
  319. package/package.json +119 -23
  320. package/dist/builtins/addon-pages-aggregator/index.js.map +0 -1
  321. package/dist/builtins/addon-pages-aggregator/index.mjs.map +0 -1
  322. package/dist/builtins/addon-widgets-aggregator/index.js.map +0 -1
  323. package/dist/builtins/addon-widgets-aggregator/index.mjs.map +0 -1
  324. package/dist/builtins/alerts/index.js.map +0 -1
  325. package/dist/builtins/alerts/index.mjs.map +0 -1
  326. package/dist/builtins/device-manager/index.js.map +0 -1
  327. package/dist/builtins/device-manager/index.mjs.map +0 -1
  328. package/dist/builtins/local-auth/index.js.map +0 -1
  329. package/dist/builtins/local-auth/index.mjs.map +0 -1
  330. package/dist/builtins/local-backup/index.js +0 -173
  331. package/dist/builtins/local-backup/index.js.map +0 -1
  332. package/dist/builtins/local-backup/index.mjs +0 -10
  333. package/dist/builtins/local-backup/index.mjs.map +0 -1
  334. package/dist/builtins/system-config/index.js.map +0 -1
  335. package/dist/builtins/system-config/index.mjs.map +0 -1
  336. package/dist/chunk-2CIYKDRN.mjs +0 -1
  337. package/dist/chunk-2CIYKDRN.mjs.map +0 -1
  338. package/dist/chunk-2F76X6NL.mjs +0 -136
  339. package/dist/chunk-2F76X6NL.mjs.map +0 -1
  340. package/dist/chunk-2QUFBZ7M.mjs +0 -1
  341. package/dist/chunk-2QUFBZ7M.mjs.map +0 -1
  342. package/dist/chunk-3BK2Y7GY.mjs +0 -593
  343. package/dist/chunk-3BK2Y7GY.mjs.map +0 -1
  344. package/dist/chunk-4OOHFJHT.mjs +0 -421
  345. package/dist/chunk-4OOHFJHT.mjs.map +0 -1
  346. package/dist/chunk-4XHB7IHT.mjs +0 -809
  347. package/dist/chunk-4XHB7IHT.mjs.map +0 -1
  348. package/dist/chunk-6M2HSSTQ.mjs +0 -98
  349. package/dist/chunk-6M2HSSTQ.mjs.map +0 -1
  350. package/dist/chunk-7FI7SQS7.mjs +0 -135
  351. package/dist/chunk-7FI7SQS7.mjs.map +0 -1
  352. package/dist/chunk-ED57RCQE.mjs +0 -171
  353. package/dist/chunk-ED57RCQE.mjs.map +0 -1
  354. package/dist/chunk-FZN56HGQ.mjs +0 -626
  355. package/dist/chunk-FZN56HGQ.mjs.map +0 -1
  356. package/dist/chunk-GL4OOB25.mjs +0 -51
  357. package/dist/chunk-GL4OOB25.mjs.map +0 -1
  358. package/dist/chunk-KDG2NTDB.mjs +0 -137
  359. package/dist/chunk-KDG2NTDB.mjs.map +0 -1
  360. package/dist/chunk-NRBQWBDM.mjs +0 -191
  361. package/dist/chunk-NRBQWBDM.mjs.map +0 -1
  362. package/dist/chunk-O4V246GG.mjs +0 -2137
  363. package/dist/chunk-O4V246GG.mjs.map +0 -1
  364. package/dist/chunk-QT57H266.mjs +0 -163
  365. package/dist/chunk-QT57H266.mjs.map +0 -1
  366. package/dist/chunk-QX4RH25I.mjs +0 -141
  367. package/dist/chunk-QX4RH25I.mjs.map +0 -1
  368. package/dist/chunk-TB562PZX.mjs +0 -86
  369. package/dist/chunk-TB562PZX.mjs.map +0 -1
  370. package/dist/chunk-TDYPZXK5.mjs +0 -1
  371. package/dist/chunk-TDYPZXK5.mjs.map +0 -1
  372. package/dist/chunk-UJI4LN5P.mjs +0 -36
  373. package/dist/chunk-UJI4LN5P.mjs.map +0 -1
  374. package/dist/chunk-W6RTHQGP.mjs +0 -1
  375. package/dist/chunk-W6RTHQGP.mjs.map +0 -1
  376. package/dist/chunk-ZELBCPDC.mjs +0 -369
  377. package/dist/chunk-ZELBCPDC.mjs.map +0 -1
  378. package/dist/index.d.mts +0 -1696
  379. package/dist/resource-monitor-UZUGPIAU.mjs +0 -9
  380. package/dist/resource-monitor-UZUGPIAU.mjs.map +0 -1
  381. package/dist/storage-location-manager-HFNB3PCS.mjs +0 -7
  382. package/dist/storage-location-manager-HFNB3PCS.mjs.map +0 -1
@@ -0,0 +1,746 @@
1
+ import * as path from "node:path";
2
+ import { BaseAddon, DEFAULT_LOCATION_SUBDIRS, STORAGE_LOCATION_CARDINALITY, StorageLocationTypeSchema, parseJsonObject, storageCapability } from "@camstack/types";
3
+ //#region src/builtins/storage-orchestrator/storage-orchestrator.service.ts
4
+ var StorageOrchestratorService = class {
5
+ locations = /* @__PURE__ */ new Map();
6
+ constructor(logger, getProviders, locationStore = null) {
7
+ this.logger = logger;
8
+ this.getProviders = getProviders;
9
+ this.locationStore = locationStore;
10
+ }
11
+ /**
12
+ * Hydrate the in-memory map from the persistence layer. Called once
13
+ * by the addon during `onInitialize`, before the eager seed pass.
14
+ * Idempotent — running it twice with the same store contents
15
+ * produces the same map. No-op when the service was constructed
16
+ * without a store.
17
+ *
18
+ * Errors loading individual rows are tolerated: the bad row is
19
+ * skipped and logged so a single corrupted record doesn't lock the
20
+ * whole orchestrator out of boot. (The store-side validation pass
21
+ * before insert means only schema-invalid SQL state can produce
22
+ * such a row.)
23
+ */
24
+ async initialize() {
25
+ if (!this.locationStore) return;
26
+ const rows = await this.locationStore.loadAll();
27
+ let upgraded = 0;
28
+ for (const loc of rows) if (!loc.isSystem && loc.id === `${loc.type}:default`) {
29
+ const upgradedLoc = {
30
+ ...loc,
31
+ isSystem: true
32
+ };
33
+ this.locations.set(upgradedLoc.id, upgradedLoc);
34
+ this.locationStore.upsert(upgradedLoc).catch((err) => {
35
+ this.logger.warn("storage-orchestrator: isSystem upgrade persist failed", { meta: {
36
+ id: upgradedLoc.id,
37
+ error: err instanceof Error ? err.message : String(err)
38
+ } });
39
+ });
40
+ upgraded++;
41
+ } else this.locations.set(loc.id, loc);
42
+ this.logger.info("storage-orchestrator: hydrated locations from store", { meta: {
43
+ loaded: this.locations.size,
44
+ isSystemUpgraded: upgraded
45
+ } });
46
+ }
47
+ listLocations(filter) {
48
+ const all = [...this.locations.values()];
49
+ return filter?.type ? all.filter((l) => l.type === filter.type) : all;
50
+ }
51
+ getDefaultLocation(type) {
52
+ for (const loc of this.locations.values()) if (loc.type === type && loc.isDefault) return loc;
53
+ return null;
54
+ }
55
+ /**
56
+ * Insert or update a location. If `isDefault: true`, atomically
57
+ * demotes any other default for the same type — operators always see
58
+ * exactly one default per type.
59
+ *
60
+ * When a persistence store is wired (Task 6), the new record AND any
61
+ * implicitly-demoted siblings are persisted before the in-memory map
62
+ * mutation returns. Persistence errors propagate to the caller.
63
+ */
64
+ upsertLocation(input) {
65
+ const now = Date.now();
66
+ const existing = this.locations.get(input.id);
67
+ if (!existing) {
68
+ if (STORAGE_LOCATION_CARDINALITY[input.type] === "singleton") {
69
+ const already = [...this.locations.values()].find((l) => l.type === input.type);
70
+ if (already) throw new Error(`Storage type "${input.type}" is singleton — only one location allowed (existing: "${already.id}"). Edit it instead of adding a new one.`);
71
+ }
72
+ }
73
+ if (existing?.isSystem === true) input = {
74
+ ...input,
75
+ isSystem: true
76
+ };
77
+ const next = {
78
+ ...input,
79
+ createdAt: existing?.createdAt ?? now,
80
+ updatedAt: now
81
+ };
82
+ const demoted = [];
83
+ if (next.isDefault) {
84
+ for (const [otherId, otherLoc] of this.locations) if (otherLoc.type === next.type && otherLoc.id !== next.id && otherLoc.isDefault) {
85
+ const updated = {
86
+ ...otherLoc,
87
+ isDefault: false,
88
+ updatedAt: now
89
+ };
90
+ this.locations.set(otherId, updated);
91
+ demoted.push(updated);
92
+ }
93
+ }
94
+ this.locations.set(next.id, next);
95
+ this.logger.debug("storage-orchestrator: upsertLocation", { meta: {
96
+ id: next.id,
97
+ type: next.type,
98
+ providerId: next.providerId,
99
+ isDefault: next.isDefault
100
+ } });
101
+ if (this.locationStore) {
102
+ const store = this.locationStore;
103
+ (async () => {
104
+ try {
105
+ for (const d of demoted) await store.upsert(d);
106
+ await store.upsert(next);
107
+ } catch (err) {
108
+ this.logger.error("storage-orchestrator: upsert persistence failed", { meta: {
109
+ id: next.id,
110
+ error: err instanceof Error ? err.message : String(err)
111
+ } });
112
+ }
113
+ })();
114
+ }
115
+ return next;
116
+ }
117
+ /**
118
+ * Remove a location. Refuses to remove the default of a type unless a
119
+ * sibling default exists (defensive — `upsertLocation` already ensures
120
+ * at most one default per type, but the logic guards against future
121
+ * bypass paths e.g. SQLite migration that imports two defaults).
122
+ *
123
+ * Persistence (Task 6) mirrors the delete asynchronously, with errors
124
+ * routed to the logger — see `upsertLocation` for the rationale.
125
+ */
126
+ deleteLocation(id) {
127
+ const loc = this.locations.get(id);
128
+ if (!loc) throw new Error(`Storage location "${id}" not found`);
129
+ if (loc.isSystem) throw new Error(`Storage location "${id}" is system-managed and cannot be deleted. Edit its config (path / providerId) instead.`);
130
+ if (loc.isDefault) {
131
+ if (![...this.locations.values()].find((l) => l.type === loc.type && l.id !== id && l.isDefault)) throw new Error(`Cannot delete default location "${id}" for type "${loc.type}" — promote another location to default first`);
132
+ }
133
+ this.locations.delete(id);
134
+ if (this.locationStore) this.locationStore.delete(id).catch((err) => {
135
+ this.logger.error("storage-orchestrator: delete persistence failed", { meta: {
136
+ id,
137
+ error: err instanceof Error ? err.message : String(err)
138
+ } });
139
+ });
140
+ }
141
+ /**
142
+ * Resolve a `StorageLocationRef` to a concrete `StorageLocation`.
143
+ * - bare type (e.g. `'backups'`) → default location of that type
144
+ * - fully-qualified id (e.g. `'backups:nas-01'`) → that exact instance
145
+ *
146
+ * Throws an actionable error when nothing matches — every consumer of
147
+ * the singleton `storage` cap funnels through here, so the error
148
+ * message is what operators see when the orchestrator's view of the
149
+ * world doesn't match expectations.
150
+ */
151
+ resolveRef(ref) {
152
+ if (ref.includes(":")) {
153
+ const loc = this.locations.get(ref);
154
+ if (!loc) throw new Error(`Storage location "${ref}" not found`);
155
+ return loc;
156
+ }
157
+ const parsed = StorageLocationTypeSchema.safeParse(ref);
158
+ if (!parsed.success) throw new Error(`Invalid storage location ref "${ref}" — expected a StorageLocationType or a fully-qualified id (\`<type>:<slug>\`)`);
159
+ const def = this.getDefaultLocation(parsed.data);
160
+ if (!def) throw new Error(`No default storage location configured for type "${parsed.data}" — register one or pass a fully-qualified id (\`<type>:<slug>\`)`);
161
+ return def;
162
+ }
163
+ /**
164
+ * Find the storage-provider that backs a given location. Lookup is by
165
+ * `location.providerId` against `getProviderInfo().providerId` from
166
+ * each registered collection provider. Throws with both the missing
167
+ * providerId and the offending location id so the operator can pick
168
+ * the right place to fix the config.
169
+ */
170
+ async getProviderFor(location) {
171
+ const providers = this.getProviders();
172
+ for (const p of providers) if ((await p.getProviderInfo()).providerId === location.providerId) return p;
173
+ throw new Error(`No storage-provider registered for providerId "${location.providerId}" (location "${location.id}")`);
174
+ }
175
+ /** Convenience: lookup by id (returns `undefined` if not found). */
176
+ getLocationById(id) {
177
+ return this.locations.get(id);
178
+ }
179
+ /**
180
+ * Seed one default `StorageLocation` per `supportedTypes` entry that
181
+ * doesn't already have one. Idempotent — re-running with the same
182
+ * provider info on a populated map is a no-op (each entry already
183
+ * resolves on `id === <type>:default`).
184
+ *
185
+ * Convention: the bare-type ref `'backups'` resolves via
186
+ * `getDefaultLocation('backups')` (walks `isDefault === true`); the
187
+ * actual stored `id` is `'backups:default'` so it satisfies the
188
+ * `^[a-z][a-z0-9-]*:[a-z0-9-]+$` regex on `StorageLocationSchema.id`.
189
+ *
190
+ * `basePath` is the provider's storage root (e.g. the filesystem
191
+ * provider's `<CAMSTACK_DATA>` dir). Each location's `config.basePath`
192
+ * is set to `<basePath>/<DEFAULT_LOCATION_SUBDIRS[type]>` — except
193
+ * when the subdir is already absolute (today only `cache` →
194
+ * `/tmp/camstack-cache`), in which case it's used verbatim. The
195
+ * filesystem provider re-derives the same path on its own — this
196
+ * config field is purely an operator-visible record of what was
197
+ * provisioned. Task 7 will refactor providers to honour the
198
+ * location's `config.basePath` directly.
199
+ */
200
+ seedDefaults(input) {
201
+ let added = 0;
202
+ for (const type of input.supportedTypes) {
203
+ if (this.hasAnyLocationOfType(type)) continue;
204
+ const subdir = DEFAULT_LOCATION_SUBDIRS[type];
205
+ const fullPath = path.isAbsolute(subdir) ? subdir : path.join(input.basePath, subdir);
206
+ const id = `${type}:default`;
207
+ this.upsertLocation({
208
+ id,
209
+ type,
210
+ displayName: DEFAULT_DISPLAY_NAMES[type],
211
+ providerId: input.providerId,
212
+ config: { basePath: fullPath },
213
+ isDefault: true,
214
+ isSystem: true
215
+ });
216
+ added++;
217
+ }
218
+ if (added > 0) this.logger.info("storage-orchestrator: seeded default locations", { meta: {
219
+ providerId: input.providerId,
220
+ added,
221
+ basePath: input.basePath
222
+ } });
223
+ }
224
+ /** Internal: check whether any location of the given type exists. */
225
+ hasAnyLocationOfType(type) {
226
+ for (const loc of this.locations.values()) if (loc.type === type) return true;
227
+ return false;
228
+ }
229
+ };
230
+ /**
231
+ * Operator-facing names for the default seeded location of each
232
+ * `StorageLocationType`. Kept in this module (not in `interfaces/`)
233
+ * because they're a concern of the orchestrator's seed step — operator
234
+ * UI reads `location.displayName` after seeding.
235
+ */
236
+ var DEFAULT_DISPLAY_NAMES = {
237
+ "data": "Local Data",
238
+ "media": "Local Media",
239
+ "recordings": "Local Recordings",
240
+ "recordings-high": "Local Recordings (High)",
241
+ "recordings-low": "Local Recordings (Low)",
242
+ "recordings-clips": "Local Recordings (Clips)",
243
+ "event-images": "Local Event Images",
244
+ "models": "Local Models",
245
+ "addons-data": "Local Addons Data",
246
+ "cache": "Local Cache",
247
+ "logs": "Local Logs",
248
+ "backups": "Local Backups"
249
+ };
250
+ //#endregion
251
+ //#region src/builtins/storage-orchestrator/location-store.ts
252
+ var STORAGE_LOCATIONS_TABLE = "storage_locations";
253
+ var STORAGE_LOCATIONS_SCHEMA = {
254
+ columns: [
255
+ {
256
+ name: "id",
257
+ type: "TEXT",
258
+ primaryKey: true
259
+ },
260
+ {
261
+ name: "type",
262
+ type: "TEXT",
263
+ notNull: true
264
+ },
265
+ {
266
+ name: "display_name",
267
+ type: "TEXT",
268
+ notNull: true
269
+ },
270
+ {
271
+ name: "provider_id",
272
+ type: "TEXT",
273
+ notNull: true
274
+ },
275
+ {
276
+ name: "config",
277
+ type: "TEXT",
278
+ notNull: true,
279
+ defaultValue: "{}"
280
+ },
281
+ {
282
+ name: "is_default",
283
+ type: "INTEGER",
284
+ notNull: true,
285
+ defaultValue: 0
286
+ },
287
+ {
288
+ name: "is_system",
289
+ type: "INTEGER",
290
+ notNull: true,
291
+ defaultValue: 0
292
+ },
293
+ {
294
+ name: "created_at",
295
+ type: "INTEGER",
296
+ notNull: true
297
+ },
298
+ {
299
+ name: "updated_at",
300
+ type: "INTEGER",
301
+ notNull: true
302
+ }
303
+ ],
304
+ indexes: [{
305
+ name: "idx_storage_locations_type",
306
+ columns: ["type"]
307
+ }]
308
+ };
309
+ /**
310
+ * SQLite-backed implementation of `ILocationStore` — uses the
311
+ * `settings-store` cap's structured-table surface (`ensureTable` /
312
+ * `tableInsert` / `tableUpdate` / `tableDelete` / `tableQuery`). Wired
313
+ * to the live `ISettingsBackend` provider obtained from
314
+ * `kernel.capabilityRegistry.getSingleton('settings-store')`.
315
+ *
316
+ * The cap-router surface (`ctx.api.settingsStore.*`) does NOT expose
317
+ * the `tableXxx` methods — they're only on the raw `ISettingsBackend`.
318
+ * Same constraint that drives `IntegrationRegistry` to take a direct
319
+ * provider reference instead of going through the cap.
320
+ */
321
+ var SqliteLocationStore = class {
322
+ tableEnsured = false;
323
+ constructor(backend) {
324
+ this.backend = backend;
325
+ }
326
+ /**
327
+ * Lazy `ensureTable` — keeps the constructor cheap and async-free.
328
+ * Called from every mutation/read path; the backend's `ensureTable`
329
+ * is itself idempotent (additive migration), so repeated calls are
330
+ * effectively no-ops after the first.
331
+ */
332
+ async ensureTable() {
333
+ if (this.tableEnsured) return;
334
+ if (!this.backend.ensureTable) throw new Error("SqliteLocationStore: settings backend does not implement ensureTable — expected the SQLite settings backend, got a backend without structured-table support");
335
+ await this.backend.ensureTable(STORAGE_LOCATIONS_TABLE, STORAGE_LOCATIONS_SCHEMA);
336
+ this.tableEnsured = true;
337
+ }
338
+ async loadAll() {
339
+ await this.ensureTable();
340
+ if (!this.backend.tableQuery) return [];
341
+ const rows = await this.backend.tableQuery(STORAGE_LOCATIONS_TABLE, { orderBy: {
342
+ field: "created_at",
343
+ direction: "asc"
344
+ } });
345
+ const out = [];
346
+ for (const row of rows) {
347
+ const mapped = mapRowToLocation(row);
348
+ if (mapped) out.push(mapped);
349
+ }
350
+ return out;
351
+ }
352
+ /**
353
+ * Replace-or-insert. Implemented as `delete` + `insert` rather than
354
+ * the conditional `tableUpdate` path because the orchestrator
355
+ * serializes every mutation through the in-memory map before
356
+ * dispatching to the store — there's no contention to lose, and the
357
+ * delete-then-insert path is unconditionally simpler.
358
+ */
359
+ async upsert(loc) {
360
+ await this.ensureTable();
361
+ if (!this.backend.tableDelete || !this.backend.tableInsert) throw new Error("SqliteLocationStore: backend missing tableDelete/tableInsert");
362
+ await this.backend.tableDelete(STORAGE_LOCATIONS_TABLE, { id: loc.id });
363
+ await this.backend.tableInsert(STORAGE_LOCATIONS_TABLE, mapLocationToRow(loc));
364
+ }
365
+ async delete(id) {
366
+ await this.ensureTable();
367
+ if (!this.backend.tableDelete) throw new Error("SqliteLocationStore: backend missing tableDelete");
368
+ await this.backend.tableDelete(STORAGE_LOCATIONS_TABLE, { id });
369
+ }
370
+ };
371
+ function mapLocationToRow(loc) {
372
+ return {
373
+ id: loc.id,
374
+ type: loc.type,
375
+ display_name: loc.displayName,
376
+ provider_id: loc.providerId,
377
+ config: JSON.stringify(loc.config),
378
+ is_default: loc.isDefault ? 1 : 0,
379
+ is_system: loc.isSystem ? 1 : 0,
380
+ created_at: loc.createdAt,
381
+ updated_at: loc.updatedAt
382
+ };
383
+ }
384
+ /**
385
+ * Decode a row read from the structured table. Returns `null` when the
386
+ * row's `type` doesn't parse against the Zod enum — the caller skips
387
+ * the row and logs. Defensive against schema drift across upgrades
388
+ * (e.g. an older build wrote a since-removed `recordings-archive`
389
+ * type and the new build no longer recognises it).
390
+ */
391
+ function mapRowToLocation(row) {
392
+ const typeRaw = row["type"];
393
+ const parsedType = StorageLocationTypeSchema.safeParse(typeRaw);
394
+ if (!parsedType.success) return null;
395
+ const type = parsedType.data;
396
+ const id = String(row["id"] ?? "");
397
+ if (!id) return null;
398
+ const configRaw = row["config"];
399
+ const config = typeof configRaw === "string" && configRaw.length > 0 ? parseJsonObject(configRaw) ?? {} : {};
400
+ return {
401
+ id,
402
+ type,
403
+ displayName: String(row["display_name"] ?? ""),
404
+ providerId: String(row["provider_id"] ?? ""),
405
+ config,
406
+ isDefault: row["is_default"] === 1 || row["is_default"] === true,
407
+ isSystem: row["is_system"] === 1 || row["is_system"] === true,
408
+ createdAt: Number(row["created_at"] ?? 0),
409
+ updatedAt: Number(row["updated_at"] ?? 0)
410
+ };
411
+ }
412
+ //#endregion
413
+ //#region src/builtins/storage-orchestrator/storage-orchestrator.addon.ts
414
+ /**
415
+ * `storage-orchestrator` builtin — singleton owner of the consumer-
416
+ * facing `storage` cap.
417
+ *
418
+ * Responsibilities:
419
+ * - Hold the `locationId → StorageLocation` map (in-memory; Task 6
420
+ * adds persistence).
421
+ * - Resolve `StorageLocationRef` → concrete `StorageLocation`.
422
+ * - Dispatch every cap method to the right `storage-provider`
423
+ * (collection cap, registered by `filesystem-storage` and future
424
+ * SFTP / S3 / WebDAV addons).
425
+ * - Track ownership of upload / download sessions so chunked I/O
426
+ * (which carries no `location` after the first hop) can route
427
+ * subsequent chunks to the same provider.
428
+ * - First-boot seed defaults from each provider's
429
+ * `getProviderInfo().supportedLocationTypes` (Task 5). Re-runs on
430
+ * every `capability:provider-registered` event so providers that
431
+ * register after the orchestrator boots also get seeded — the
432
+ * `hasAnyLocationOfType` guard makes the operation idempotent.
433
+ *
434
+ * Task 6 will plug a persistence backend in front of the in-memory map.
435
+ * Task 7 will migrate consumers off the legacy storage shim.
436
+ */
437
+ var STORAGE_PROVIDER_CAP_NAME = "storage-provider";
438
+ /**
439
+ * Raw event category emitted by `CapabilityRegistry.registerProvider` —
440
+ * not in the typed `EventCategory` enum because it lives in the kernel
441
+ * infra layer (every cap-bound event is a custom-shape payload).
442
+ */
443
+ var CAP_PROVIDER_REGISTERED_CATEGORY = "capability:provider-registered";
444
+ var StorageOrchestratorAddon = class extends BaseAddon {
445
+ service = null;
446
+ /**
447
+ * `uploadId` → providerId. Populated on `beginUpload`, consulted on
448
+ * every subsequent `writeChunk` / `finalizeUpload` / `abortUpload`,
449
+ * cleared on terminal calls. The provider holds the actual session
450
+ * state (open file descriptor, buffered offsets, …) — we just
451
+ * remember which provider owns it.
452
+ */
453
+ uploadOwners = /* @__PURE__ */ new Map();
454
+ /** Symmetric to `uploadOwners` for download sessions. */
455
+ downloadOwners = /* @__PURE__ */ new Map();
456
+ /**
457
+ * Disposers run on `onShutdown` — currently the eventBus subscription
458
+ * for `capability:provider-registered` events used by the lazy seed
459
+ * fallback. Stored separately from the `BaseAddon` disposer chain so
460
+ * it can be inspected in tests.
461
+ */
462
+ seedSubscriptionDisposers = [];
463
+ constructor() {
464
+ super({});
465
+ }
466
+ async onInitialize() {
467
+ const getProviders = () => {
468
+ const reg = this.ctx.kernel.capabilityRegistry;
469
+ if (!reg) return [];
470
+ return reg.getCollection(STORAGE_PROVIDER_CAP_NAME);
471
+ };
472
+ const locationStore = this.resolveLocationStore();
473
+ const service = new StorageOrchestratorService(this.ctx.logger, getProviders, locationStore);
474
+ this.service = service;
475
+ await service.initialize();
476
+ const provider = {
477
+ listLocations: async ({ type }) => {
478
+ return type !== void 0 ? service.listLocations({ type }) : service.listLocations();
479
+ },
480
+ getDefaultLocation: async ({ type }) => service.getDefaultLocation(type),
481
+ upsertLocation: async (input) => service.upsertLocation(input),
482
+ deleteLocation: async ({ id }) => {
483
+ service.deleteLocation(id);
484
+ },
485
+ testLocation: async ({ id }) => {
486
+ const loc = service.getLocationById(id);
487
+ if (!loc) return {
488
+ ok: false,
489
+ error: `Location "${id}" not found`
490
+ };
491
+ try {
492
+ return (await service.getProviderFor(loc)).testLocation({ config: loc.config });
493
+ } catch (err) {
494
+ return {
495
+ ok: false,
496
+ error: err instanceof Error ? err.message : String(err)
497
+ };
498
+ }
499
+ },
500
+ listProviders: async () => {
501
+ const providers = getProviders();
502
+ const out = [];
503
+ for (const p of providers) try {
504
+ const info = await p.getProviderInfo();
505
+ out.push({
506
+ providerId: info.providerId,
507
+ displayName: info.displayName,
508
+ supportedLocationTypes: info.supportedLocationTypes,
509
+ configSchema: info.configSchema
510
+ });
511
+ } catch (err) {
512
+ this.ctx.logger.warn("storage-orchestrator: getProviderInfo failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
513
+ }
514
+ return out;
515
+ },
516
+ testConfig: async ({ providerId, config }) => {
517
+ const providers = getProviders();
518
+ for (const p of providers) try {
519
+ if ((await p.getProviderInfo()).providerId !== providerId) continue;
520
+ return p.testLocation({ config });
521
+ } catch (err) {
522
+ return {
523
+ ok: false,
524
+ error: err instanceof Error ? err.message : String(err)
525
+ };
526
+ }
527
+ return {
528
+ ok: false,
529
+ error: `No storage-provider registered for providerId "${providerId}"`
530
+ };
531
+ },
532
+ resolve: async ({ location, relativePath }) => {
533
+ const loc = service.resolveRef(location);
534
+ return (await service.getProviderFor(loc)).resolve({
535
+ location: loc,
536
+ relativePath
537
+ });
538
+ },
539
+ write: async ({ location, relativePath, data }) => {
540
+ const loc = service.resolveRef(location);
541
+ return (await service.getProviderFor(loc)).write({
542
+ location: loc,
543
+ relativePath,
544
+ data
545
+ });
546
+ },
547
+ read: async ({ location, relativePath }) => {
548
+ const loc = service.resolveRef(location);
549
+ return (await service.getProviderFor(loc)).read({
550
+ location: loc,
551
+ relativePath
552
+ });
553
+ },
554
+ exists: async ({ location, relativePath }) => {
555
+ const loc = service.resolveRef(location);
556
+ return (await service.getProviderFor(loc)).exists({
557
+ location: loc,
558
+ relativePath
559
+ });
560
+ },
561
+ list: async ({ location, prefix }) => {
562
+ const loc = service.resolveRef(location);
563
+ const p = await service.getProviderFor(loc);
564
+ return prefix !== void 0 ? p.list({
565
+ location: loc,
566
+ prefix
567
+ }) : p.list({ location: loc });
568
+ },
569
+ delete: async ({ location, relativePath }) => {
570
+ const loc = service.resolveRef(location);
571
+ return (await service.getProviderFor(loc)).delete({
572
+ location: loc,
573
+ relativePath
574
+ });
575
+ },
576
+ getAvailableSpace: async ({ location }) => {
577
+ const loc = service.resolveRef(location);
578
+ return (await service.getProviderFor(loc)).getAvailableSpace({ location: loc });
579
+ },
580
+ beginUpload: async ({ location, relativePath, sizeBytes }) => {
581
+ const loc = service.resolveRef(location);
582
+ const p = await service.getProviderFor(loc);
583
+ const result = sizeBytes !== void 0 ? await p.beginUpload({
584
+ location: loc,
585
+ relativePath,
586
+ sizeBytes
587
+ }) : await p.beginUpload({
588
+ location: loc,
589
+ relativePath
590
+ });
591
+ this.uploadOwners.set(result.uploadId, loc.providerId);
592
+ return result;
593
+ },
594
+ writeChunk: async (input) => {
595
+ return (await this.resolveByUploadId(input.uploadId)).writeChunk(input);
596
+ },
597
+ finalizeUpload: async (input) => {
598
+ const p = await this.resolveByUploadId(input.uploadId);
599
+ try {
600
+ return await p.finalizeUpload(input);
601
+ } finally {
602
+ this.uploadOwners.delete(input.uploadId);
603
+ }
604
+ },
605
+ abortUpload: async (input) => {
606
+ const p = await this.resolveByUploadId(input.uploadId);
607
+ try {
608
+ return await p.abortUpload(input);
609
+ } finally {
610
+ this.uploadOwners.delete(input.uploadId);
611
+ }
612
+ },
613
+ beginDownload: async ({ location, relativePath }) => {
614
+ const loc = service.resolveRef(location);
615
+ const result = await (await service.getProviderFor(loc)).beginDownload({
616
+ location: loc,
617
+ relativePath
618
+ });
619
+ this.downloadOwners.set(result.downloadId, loc.providerId);
620
+ return result;
621
+ },
622
+ readChunk: async (input) => {
623
+ return (await this.resolveByDownloadId(input.downloadId)).readChunk(input);
624
+ },
625
+ endDownload: async (input) => {
626
+ const p = await this.resolveByDownloadId(input.downloadId);
627
+ try {
628
+ return await p.endDownload(input);
629
+ } finally {
630
+ this.downloadOwners.delete(input.downloadId);
631
+ }
632
+ }
633
+ };
634
+ await this.seedFromAllProviders();
635
+ const eventBus = this.ctx.eventBus;
636
+ if (eventBus) {
637
+ const unsub = eventBus.subscribe({ category: CAP_PROVIDER_REGISTERED_CATEGORY }, (event) => {
638
+ if (event.data?.capability !== STORAGE_PROVIDER_CAP_NAME) return;
639
+ this.seedFromAllProviders();
640
+ });
641
+ this.seedSubscriptionDisposers.push(unsub);
642
+ }
643
+ this.ctx.logger.info("Storage orchestrator initialized");
644
+ return [{
645
+ capability: storageCapability,
646
+ provider
647
+ }];
648
+ }
649
+ async onShutdown() {
650
+ for (const dispose of this.seedSubscriptionDisposers) try {
651
+ dispose();
652
+ } catch {}
653
+ this.seedSubscriptionDisposers.length = 0;
654
+ this.uploadOwners.clear();
655
+ this.downloadOwners.clear();
656
+ this.service = null;
657
+ }
658
+ /**
659
+ * Resolve the live `ISettingsBackend` from the capability registry
660
+ * and wrap it in a `SqliteLocationStore`. Returns `null` when the
661
+ * settings-store cap isn't registered yet — the service falls back
662
+ * to in-memory only. Production boot order (sqlite-settings runs
663
+ * before the orchestrator) makes this the rare path.
664
+ */
665
+ resolveLocationStore() {
666
+ const reg = this.ctx.kernel.capabilityRegistry;
667
+ if (!reg) return null;
668
+ const backend = reg.getSingleton("settings-store");
669
+ if (!backend) {
670
+ this.ctx.logger.warn("storage-orchestrator: no settings-store provider — running in-memory only");
671
+ return null;
672
+ }
673
+ if (!backend.ensureTable || !backend.tableInsert) {
674
+ this.ctx.logger.warn("storage-orchestrator: settings backend lacks structured-table support — running in-memory only");
675
+ return null;
676
+ }
677
+ return new SqliteLocationStore(backend);
678
+ }
679
+ /**
680
+ * Walk every registered `storage-provider` collection provider and
681
+ * call `service.seedDefaults` for each. Idempotent — re-running on
682
+ * a populated map is a no-op (each location's `id` is already in the
683
+ * service's map).
684
+ *
685
+ * `basePath` is derived per-call:
686
+ * - Filesystem providers (and any provider whose `getProviderInfo`
687
+ * doesn't include a `basePath` field) fall back to
688
+ * `process.env.CAMSTACK_DATA ?? path.resolve(process.cwd(), 'camstack-data')`.
689
+ * - Future remote providers (SFTP/S3/WebDAV) will report their own
690
+ * base path through the wizard config — they're not relevant for
691
+ * first-boot seeding (operators add them through the admin UI).
692
+ */
693
+ async seedFromAllProviders() {
694
+ if (!this.service) return;
695
+ const reg = this.ctx.kernel.capabilityRegistry;
696
+ if (!reg) return;
697
+ const providers = reg.getCollection(STORAGE_PROVIDER_CAP_NAME);
698
+ if (providers.length === 0) return;
699
+ const basePath = process.env["CAMSTACK_DATA"] ?? path.resolve(process.cwd(), "camstack-data");
700
+ for (const p of providers) try {
701
+ const info = await p.getProviderInfo();
702
+ this.service.seedDefaults({
703
+ providerId: info.providerId,
704
+ supportedTypes: info.supportedLocationTypes,
705
+ basePath
706
+ });
707
+ } catch (err) {
708
+ this.ctx.logger.warn("storage-orchestrator: seed failed for provider", { meta: { error: err instanceof Error ? err.message : String(err) } });
709
+ }
710
+ }
711
+ async resolveByUploadId(uploadId) {
712
+ const providerId = this.uploadOwners.get(uploadId);
713
+ if (!providerId) throw new Error(`Unknown uploadId "${uploadId}" — orchestrator has no record of beginUpload`);
714
+ return this.providerByProviderId(providerId, `uploadId "${uploadId}"`);
715
+ }
716
+ async resolveByDownloadId(downloadId) {
717
+ const providerId = this.downloadOwners.get(downloadId);
718
+ if (!providerId) throw new Error(`Unknown downloadId "${downloadId}" — orchestrator has no record of beginDownload`);
719
+ return this.providerByProviderId(providerId, `downloadId "${downloadId}"`);
720
+ }
721
+ /**
722
+ * Look up a `storage-provider` by `providerId` only — used for
723
+ * upload / download dispatch where the original `StorageLocation` is
724
+ * no longer in scope. Throws if the provider has gone away (e.g.
725
+ * addon unloaded mid-session).
726
+ */
727
+ async providerByProviderId(providerId, sessionDescriptor) {
728
+ if (!this.service) throw new Error("storage-orchestrator: service not initialized");
729
+ const probe = {
730
+ id: `__session:${sessionDescriptor}`,
731
+ type: "data",
732
+ displayName: sessionDescriptor,
733
+ providerId,
734
+ config: {},
735
+ isDefault: false,
736
+ isSystem: false,
737
+ createdAt: 0,
738
+ updatedAt: 0
739
+ };
740
+ return this.service.getProviderFor(probe);
741
+ }
742
+ };
743
+ //#endregion
744
+ export { StorageOrchestratorAddon, StorageOrchestratorAddon as default, StorageOrchestratorService as n, SqliteLocationStore as t };
745
+
746
+ //# sourceMappingURL=storage-orchestrator.addon.mjs.map