@jini-ai/devops 0.7.3-next.2 → 0.7.3-next.3

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 (390) hide show
  1. package/README.md +16 -0
  2. package/dist/backup/site/archive-extensions.d.ts +73 -0
  3. package/dist/backup/site/archive-extensions.js +129 -0
  4. package/dist/backup/site/archive-manifest.d.ts +85 -0
  5. package/dist/backup/site/archive-manifest.js +176 -0
  6. package/dist/backup/site/archive-media.d.ts +121 -0
  7. package/dist/backup/site/archive-media.js +93 -0
  8. package/dist/backup/site/backup-service.credentials.d.ts +31 -0
  9. package/dist/backup/site/backup-service.credentials.js +161 -0
  10. package/dist/backup/site/backup-service.d.ts +331 -0
  11. package/dist/backup/site/backup-service.js +125 -0
  12. package/dist/backup/site/backup-service.plan.d.ts +64 -0
  13. package/dist/backup/site/backup-service.plan.js +207 -0
  14. package/dist/backup/site/backup-service.push.d.ts +29 -0
  15. package/dist/backup/site/backup-service.push.js +82 -0
  16. package/dist/backup/site/backup-service.shared.d.ts +40 -0
  17. package/dist/backup/site/backup-service.shared.js +37 -0
  18. package/dist/backup/site/bundled-export-file-policy.d.ts +38 -0
  19. package/dist/backup/site/bundled-export-file-policy.js +40 -0
  20. package/dist/backup/site/credential-warnings.d.ts +41 -0
  21. package/dist/backup/site/credential-warnings.js +50 -0
  22. package/dist/backup/site/import-backend-steps.d.ts +167 -0
  23. package/dist/backup/site/import-backend-steps.js +170 -0
  24. package/dist/backup/site/import-backend.d.ts +167 -0
  25. package/dist/backup/site/import-backend.js +298 -0
  26. package/dist/backup/site/import-database.d.ts +118 -0
  27. package/dist/backup/site/import-database.js +167 -0
  28. package/dist/backup/site/import-index/admission.d.ts +54 -0
  29. package/dist/backup/site/import-index/admission.js +46 -0
  30. package/dist/backup/site/import-index/backfill.d.ts +106 -0
  31. package/dist/backup/site/import-index/backfill.js +137 -0
  32. package/dist/backup/site/import-index/errors.d.ts +28 -0
  33. package/dist/backup/site/import-index/errors.js +38 -0
  34. package/dist/backup/site/import-index/migrations/checksums.d.ts +4 -0
  35. package/dist/backup/site/import-index/migrations/checksums.js +4 -0
  36. package/dist/backup/site/import-index/migrations/site-imports-v1.d.ts +2 -0
  37. package/dist/backup/site/import-index/migrations/site-imports-v1.js +10 -0
  38. package/dist/backup/site/import-index/mode.d.ts +191 -0
  39. package/dist/backup/site/import-index/mode.js +272 -0
  40. package/dist/backup/site/import-index/open.d.ts +40 -0
  41. package/dist/backup/site/import-index/open.js +87 -0
  42. package/dist/backup/site/import-index/paging.d.ts +28 -0
  43. package/dist/backup/site/import-index/paging.js +66 -0
  44. package/dist/backup/site/import-index/payload-namespace.d.ts +80 -0
  45. package/dist/backup/site/import-index/payload-namespace.js +156 -0
  46. package/dist/backup/site/import-index/rows.d.ts +32 -0
  47. package/dist/backup/site/import-index/rows.js +61 -0
  48. package/dist/backup/site/import-index/schema.d.ts +8 -0
  49. package/dist/backup/site/import-index/schema.js +31 -0
  50. package/dist/backup/site/import-index/store.d.ts +27 -0
  51. package/dist/backup/site/import-index/store.js +33 -0
  52. package/dist/backup/site/import-index/sweep.d.ts +10 -0
  53. package/dist/backup/site/import-index/sweep.js +26 -0
  54. package/dist/backup/site/import-keep-off.d.ts +128 -0
  55. package/dist/backup/site/import-keep-off.js +204 -0
  56. package/dist/backup/site/import-plugin-state.d.ts +74 -0
  57. package/dist/backup/site/import-plugin-state.js +67 -0
  58. package/dist/backup/site/import-registry.d.ts +110 -0
  59. package/dist/backup/site/import-registry.js +205 -0
  60. package/dist/backup/site/import-restore-placement.d.ts +94 -0
  61. package/dist/backup/site/import-restore-placement.js +158 -0
  62. package/dist/backup/site/import-restore.d.ts +111 -0
  63. package/dist/backup/site/import-restore.js +120 -0
  64. package/dist/backup/site/import-verifier-inventory.d.ts +137 -0
  65. package/dist/backup/site/import-verifier-inventory.js +236 -0
  66. package/dist/backup/site/import-verifier-projection.d.ts +78 -0
  67. package/dist/backup/site/import-verifier-projection.js +100 -0
  68. package/dist/backup/site/import-verifier.d.ts +126 -0
  69. package/dist/backup/site/import-verifier.js +53 -0
  70. package/dist/backup/site/owned-temp-root.d.ts +12 -0
  71. package/dist/backup/site/owned-temp-root.js +2 -0
  72. package/dist/backup/site/package-file-inventory.d.ts +63 -0
  73. package/dist/backup/site/package-file-inventory.js +56 -0
  74. package/dist/backup/site/push-content.d.ts +70 -0
  75. package/dist/backup/site/push-content.js +56 -0
  76. package/dist/backup/site/react/ShowMoreImports.d.ts +21 -0
  77. package/dist/backup/site/react/ShowMoreImports.js +8 -0
  78. package/dist/backup/site/saved-keys-port.d.ts +47 -0
  79. package/dist/backup/site/saved-keys-port.js +3 -0
  80. package/dist/backup/site/saved-keys.d.ts +25 -0
  81. package/dist/backup/site/saved-keys.js +38 -0
  82. package/dist/backup/site/share-backend.d.ts +243 -0
  83. package/dist/backup/site/share-backend.js +284 -0
  84. package/dist/backup/site/share-database/projection.d.ts +195 -0
  85. package/dist/backup/site/share-database/projection.js +90 -0
  86. package/dist/backup/site/share-database/projection.media.d.ts +38 -0
  87. package/dist/backup/site/share-database/projection.media.js +179 -0
  88. package/dist/backup/site/share-database/projection.tables.d.ts +46 -0
  89. package/dist/backup/site/share-database/projection.tables.js +193 -0
  90. package/dist/backup/site/share-expiry.d.ts +75 -0
  91. package/dist/backup/site/share-expiry.js +49 -0
  92. package/dist/backup/site/share-export-failure.d.ts +17 -0
  93. package/dist/backup/site/share-export-failure.js +16 -0
  94. package/dist/backup/site/share-file-policy.d.ts +60 -0
  95. package/dist/backup/site/share-file-policy.js +146 -0
  96. package/dist/backup/site/share-hosting.d.ts +107 -0
  97. package/dist/backup/site/share-hosting.js +148 -0
  98. package/dist/backup/site/share-preparation-steps.d.ts +180 -0
  99. package/dist/backup/site/share-preparation-steps.js +109 -0
  100. package/dist/backup/site/share-preparation.d.ts +122 -0
  101. package/dist/backup/site/share-preparation.js +43 -0
  102. package/dist/backup/site/share-refusal.d.ts +21 -0
  103. package/dist/backup/site/share-refusal.js +20 -0
  104. package/dist/backup/site/share-registry.d.ts +124 -0
  105. package/dist/backup/site/share-registry.js +219 -0
  106. package/dist/backup/site/share-retention.d.ts +62 -0
  107. package/dist/backup/site/share-retention.js +126 -0
  108. package/dist/backup/site/share-service.d.ts +128 -0
  109. package/dist/backup/site/share-service.js +194 -0
  110. package/dist/backup/site/share-zip.d.ts +115 -0
  111. package/dist/backup/site/share-zip.js +144 -0
  112. package/dist/backup/site/sources.d.ts +344 -0
  113. package/dist/backup/site/sources.js +595 -0
  114. package/dist/backup/site/static-copy.d.ts +122 -0
  115. package/dist/backup/site/static-copy.js +165 -0
  116. package/dist/backup/site/static-download-html.d.ts +76 -0
  117. package/dist/backup/site/static-download-html.js +149 -0
  118. package/dist/backup/site/static-download-landing.d.ts +52 -0
  119. package/dist/backup/site/static-download-landing.js +95 -0
  120. package/dist/backup/site/static-download-layout.d.ts +96 -0
  121. package/dist/backup/site/static-download-layout.js +325 -0
  122. package/dist/backup/site/static-export-selection.d.ts +50 -0
  123. package/dist/backup/site/static-export-selection.js +76 -0
  124. package/dist/backup/site/static-site-packager.d.ts +42 -0
  125. package/dist/backup/site/static-site-packager.js +32 -0
  126. package/dist/backup/site/tool-registrations.d.ts +74 -0
  127. package/dist/backup/site/tool-registrations.js +201 -0
  128. package/dist/checks/complexity-debt.d.ts +100 -0
  129. package/dist/checks/complexity-debt.js +131 -0
  130. package/dist/checks/coverage/diff.js +5 -1
  131. package/dist/checks/env-access.d.ts +14 -1
  132. package/dist/checks/env-access.js +92 -6
  133. package/dist/checks/live-verify-checks.d.ts +29 -0
  134. package/dist/checks/live-verify-checks.js +30 -0
  135. package/dist/checks/quality-gates.d.ts +137 -0
  136. package/dist/checks/quality-gates.js +209 -0
  137. package/dist/core/deploy-types.d.ts +2 -0
  138. package/dist/deploy/admin-http/site-update-status.d.ts +8 -0
  139. package/dist/deploy/admin-http/site-update-status.js +15 -0
  140. package/dist/deploy/host-kit.d.ts +3 -0
  141. package/dist/deploy/index.d.ts +6 -0
  142. package/dist/deploy/index.js +6 -0
  143. package/dist/deploy/ops-runner.js +7 -0
  144. package/dist/deploy/ops-tool-contracts.d.ts +10 -1
  145. package/dist/deploy/react/Deployment.d.ts +37 -0
  146. package/dist/deploy/react/Deployment.js +94 -0
  147. package/dist/deploy/react/DockerfileTab.d.ts +72 -0
  148. package/dist/deploy/react/DockerfileTab.js +131 -0
  149. package/dist/deploy/react/HistoryTab.d.ts +43 -0
  150. package/dist/deploy/react/HistoryTab.js +12 -0
  151. package/dist/deploy/react/OverviewTab.d.ts +60 -0
  152. package/dist/deploy/react/OverviewTab.js +75 -0
  153. package/dist/deploy/react/PublishRunResult.d.ts +5 -1
  154. package/dist/deploy/react/PublishRunResult.js +4 -4
  155. package/dist/deploy/react/SiteUpdateNotice.d.ts +22 -0
  156. package/dist/deploy/react/SiteUpdateNotice.js +25 -0
  157. package/dist/deploy/react/StaticCredentialFields.d.ts +36 -0
  158. package/dist/deploy/react/StaticCredentialFields.js +63 -0
  159. package/dist/deploy/react/StaticCredentialSteps.d.ts +23 -0
  160. package/dist/deploy/react/StaticCredentialSteps.js +155 -0
  161. package/dist/deploy/react/StaticExportCard.d.ts +11 -0
  162. package/dist/deploy/react/StaticExportCard.js +97 -0
  163. package/dist/deploy/react/StaticPublishCredentials.d.ts +50 -0
  164. package/dist/deploy/react/StaticPublishCredentials.js +77 -0
  165. package/dist/deploy/react/StaticPublishForm.d.ts +12 -0
  166. package/dist/deploy/react/StaticPublishForm.js +91 -0
  167. package/dist/deploy/react/StaticSiteTab.d.ts +207 -0
  168. package/dist/deploy/react/StaticSiteTab.js +117 -0
  169. package/dist/deploy/react/deployment-visuals.d.ts +207 -0
  170. package/dist/deploy/react/deployment-visuals.js +101 -0
  171. package/dist/deploy/react/download-dockerfile.d.ts +14 -0
  172. package/dist/deploy/react/download-dockerfile.js +15 -0
  173. package/dist/deploy/react/hooks/publish-credential-draft.d.ts +33 -0
  174. package/dist/deploy/react/hooks/publish-credential-draft.js +54 -0
  175. package/dist/deploy/react/hooks/publish-credential-selection.d.ts +13 -0
  176. package/dist/deploy/react/hooks/publish-credential-selection.js +34 -0
  177. package/dist/deploy/react/hooks/publish-credential-writes.d.ts +20 -0
  178. package/dist/deploy/react/hooks/publish-credential-writes.js +99 -0
  179. package/dist/deploy/react/hooks/static-publish-actions.d.ts +10 -0
  180. package/dist/deploy/react/hooks/static-publish-actions.js +62 -0
  181. package/dist/deploy/react/hooks/static-publish-form.hooks.d.ts +38 -0
  182. package/dist/deploy/react/hooks/static-publish-form.hooks.js +103 -0
  183. package/dist/deploy/react/hooks/static-publish-run.hooks.d.ts +28 -0
  184. package/dist/deploy/react/hooks/static-publish-run.hooks.js +92 -0
  185. package/dist/deploy/react/hooks/use-dockerfile-source.hooks.d.ts +148 -0
  186. package/dist/deploy/react/hooks/use-dockerfile-source.hooks.js +155 -0
  187. package/dist/deploy/react/hooks/use-publish-credentials.hooks.d.ts +268 -0
  188. package/dist/deploy/react/hooks/use-publish-credentials.hooks.js +52 -0
  189. package/dist/deploy/react/hooks/use-static-export.hooks.d.ts +128 -0
  190. package/dist/deploy/react/hooks/use-static-export.hooks.js +159 -0
  191. package/dist/deploy/react/hooks/use-static-publish.hooks.d.ts +208 -0
  192. package/dist/deploy/react/hooks/use-static-publish.hooks.js +48 -0
  193. package/dist/deploy/react/index.d.ts +4 -0
  194. package/dist/deploy/react/index.js +2 -0
  195. package/dist/deploy/react/rules.d.ts +363 -0
  196. package/dist/deploy/react/rules.js +314 -0
  197. package/dist/deploy/react/use-deployment-overview.hooks.d.ts +41 -0
  198. package/dist/deploy/react/use-deployment-overview.hooks.js +11 -0
  199. package/dist/deploy/site/agent-tools.d.ts +42 -0
  200. package/dist/deploy/site/agent-tools.js +119 -0
  201. package/dist/deploy/site/deploy-config-registry.d.ts +155 -0
  202. package/dist/deploy/site/deploy-config-registry.js +124 -0
  203. package/dist/deploy/site/deploy-config.d.ts +97 -0
  204. package/dist/deploy/site/deploy-config.js +115 -0
  205. package/dist/deploy/site/deploy-ops/agent-tools.d.ts +22 -0
  206. package/dist/deploy/site/deploy-ops/agent-tools.js +76 -0
  207. package/dist/deploy/site/deploy-ops/registry.d.ts +134 -0
  208. package/dist/deploy/site/deploy-ops/registry.js +106 -0
  209. package/dist/deploy/site/deploy-ops/run-ops.d.ts +66 -0
  210. package/dist/deploy/site/deploy-ops/run-ops.js +34 -0
  211. package/dist/deploy/site/deploy-ops/secret-confirm.d.ts +36 -0
  212. package/dist/deploy/site/deploy-ops/secret-confirm.js +27 -0
  213. package/dist/deploy/site/deploy-targets/host-kit.d.ts +28 -0
  214. package/dist/deploy/site/deploy-targets/host-kit.js +120 -0
  215. package/dist/deploy/site/deploy-targets/registry.d.ts +157 -0
  216. package/dist/deploy/site/deploy-targets/registry.js +132 -0
  217. package/dist/deploy/site/deploy-targets/types.d.ts +27 -0
  218. package/dist/deploy/site/deploy-targets/types.js +2 -0
  219. package/dist/deploy/site/dockerfile.d.ts +137 -0
  220. package/dist/deploy/site/dockerfile.js +101 -0
  221. package/dist/deploy/site/export-run.d.ts +137 -0
  222. package/dist/deploy/site/export-run.js +152 -0
  223. package/dist/deploy/site/ports.d.ts +115 -0
  224. package/dist/deploy/site/ports.js +2 -0
  225. package/dist/deploy/site/publish-agent-tools.d.ts +18 -0
  226. package/dist/deploy/site/publish-agent-tools.js +120 -0
  227. package/dist/deploy/site/publish-candidate.d.ts +26 -0
  228. package/dist/deploy/site/publish-candidate.js +37 -0
  229. package/dist/deploy/site/publish-credentials/account-label-heal-scheduler.d.ts +78 -0
  230. package/dist/deploy/site/publish-credentials/account-label-heal-scheduler.js +88 -0
  231. package/dist/deploy/site/publish-credentials/compatibility-port.d.ts +38 -0
  232. package/dist/deploy/site/publish-credentials/compatibility-port.js +19 -0
  233. package/dist/deploy/site/publish-credentials/execution-mode.d.ts +43 -0
  234. package/dist/deploy/site/publish-credentials/execution-mode.js +19 -0
  235. package/dist/deploy/site/publish-credentials/store-owner.d.ts +11 -0
  236. package/dist/deploy/site/publish-credentials/store-owner.js +9 -0
  237. package/dist/deploy/site/publish-credentials/store-resolution.d.ts +55 -0
  238. package/dist/deploy/site/publish-credentials/store-resolution.js +100 -0
  239. package/dist/deploy/site/publish-credentials/store-validation.d.ts +68 -0
  240. package/dist/deploy/site/publish-credentials/store-validation.js +182 -0
  241. package/dist/deploy/site/publish-credentials/store.d.ts +322 -0
  242. package/dist/deploy/site/publish-credentials/store.js +372 -0
  243. package/dist/deploy/site/publish-credentials/types.d.ts +85 -0
  244. package/dist/deploy/site/publish-credentials/types.js +2 -0
  245. package/dist/deploy/site/publish-tool-capabilities.d.ts +123 -0
  246. package/dist/deploy/site/publish-tool-capabilities.js +175 -0
  247. package/dist/deploy/site/publish-tool-credential.d.ts +48 -0
  248. package/dist/deploy/site/publish-tool-credential.js +284 -0
  249. package/dist/deploy/site/publish-tool-deps.d.ts +205 -0
  250. package/dist/deploy/site/publish-tool-deps.js +15 -0
  251. package/dist/deploy/site/publish-tool-execution.d.ts +78 -0
  252. package/dist/deploy/site/publish-tool-execution.js +313 -0
  253. package/dist/deploy/site/publish-tool-schema.d.ts +29 -0
  254. package/dist/deploy/site/publish-tool-schema.js +38 -0
  255. package/dist/deploy/site/static-publish/adapter-export.d.ts +54 -0
  256. package/dist/deploy/site/static-publish/adapter-export.js +89 -0
  257. package/dist/deploy/site/static-publish/adapter-plan.d.ts +99 -0
  258. package/dist/deploy/site/static-publish/adapter-plan.js +112 -0
  259. package/dist/deploy/site/static-publish/adapter.d.ts +182 -0
  260. package/dist/deploy/site/static-publish/adapter.js +321 -0
  261. package/dist/deploy/site/static-publish/admin-publish-read.d.ts +209 -0
  262. package/dist/deploy/site/static-publish/admin-publish-read.js +116 -0
  263. package/dist/deploy/site/static-publish/credentials.d.ts +110 -0
  264. package/dist/deploy/site/static-publish/credentials.js +290 -0
  265. package/dist/deploy/site/static-publish/domain-publish-rows.d.ts +25 -0
  266. package/dist/deploy/site/static-publish/domain-publish-rows.js +43 -0
  267. package/dist/deploy/site/static-publish/domain-publish-tool.d.ts +19 -0
  268. package/dist/deploy/site/static-publish/domain-publish-tool.js +111 -0
  269. package/dist/deploy/site/static-publish/inspection.d.ts +24 -0
  270. package/dist/deploy/site/static-publish/inspection.js +69 -0
  271. package/dist/deploy/site/static-publish/publish-history.d.ts +197 -0
  272. package/dist/deploy/site/static-publish/publish-history.js +153 -0
  273. package/dist/deploy/site/static-publish/publish-run.d.ts +156 -0
  274. package/dist/deploy/site/static-publish/publish-run.js +186 -0
  275. package/dist/deploy/site/static-publish/types.d.ts +165 -0
  276. package/dist/deploy/site/static-publish/types.js +2 -0
  277. package/dist/deploy/site/static-publish/verify.d.ts +217 -0
  278. package/dist/deploy/site/static-publish/verify.js +248 -0
  279. package/dist/deploy/site/tool-registrations.d.ts +97 -0
  280. package/dist/deploy/site/tool-registrations.js +130 -0
  281. package/dist/deploy/site/types.d.ts +51 -0
  282. package/dist/deploy/site/types.js +2 -0
  283. package/dist/deploy/site-update/check-for-update.d.ts +19 -0
  284. package/dist/deploy/site-update/check-for-update.js +19 -0
  285. package/dist/deploy/site-update/contracts.d.ts +161 -0
  286. package/dist/deploy/site-update/contracts.js +94 -0
  287. package/dist/deploy/site-update/desktop-site-update.d.ts +66 -0
  288. package/dist/deploy/site-update/desktop-site-update.js +43 -0
  289. package/dist/deploy/site-update/fake-site-update.d.ts +39 -0
  290. package/dist/deploy/site-update/fake-site-update.js +52 -0
  291. package/dist/deploy/site-update/run-site-update.d.ts +121 -0
  292. package/dist/deploy/site-update/run-site-update.js +219 -0
  293. package/dist/deploy/site-update/self-hosted-site-update.d.ts +71 -0
  294. package/dist/deploy/site-update/self-hosted-site-update.js +79 -0
  295. package/dist/deploy/target-contracts.d.ts +3 -0
  296. package/dist/deploy/tool.d.ts +5 -8
  297. package/dist/deploy/tool.js +6 -9
  298. package/dist/dns/binding-sweeper.d.ts +72 -0
  299. package/dist/dns/binding-sweeper.js +53 -0
  300. package/dist/dns/index.d.ts +1 -0
  301. package/dist/dns/index.js +1 -0
  302. package/dist/dns/site/binding.repo.d.ts +71 -0
  303. package/dist/dns/site/binding.repo.js +45 -0
  304. package/dist/dns/site/dns-changes.d.ts +90 -0
  305. package/dist/dns/site/dns-changes.js +271 -0
  306. package/dist/dns/site/dns-tools.d.ts +46 -0
  307. package/dist/dns/site/dns-tools.js +204 -0
  308. package/dist/dns/site/mail-dns-status.d.ts +111 -0
  309. package/dist/dns/site/mail-dns-status.js +190 -0
  310. package/dist/dns/site/mail-dns-tools.d.ts +33 -0
  311. package/dist/dns/site/mail-dns-tools.js +62 -0
  312. package/dist/dns/site/mail-requirements.d.ts +30 -0
  313. package/dist/dns/site/mail-requirements.js +78 -0
  314. package/dist/dns/site/tool-deps.d.ts +21 -0
  315. package/dist/dns/site/tool-deps.js +2 -0
  316. package/dist/dns/site/tools.d.ts +74 -0
  317. package/dist/dns/site/tools.js +124 -0
  318. package/dist/local-dev/bind-host.d.ts +80 -0
  319. package/dist/local-dev/bind-host.js +90 -0
  320. package/dist/local-dev/dev-proxy-upstream.d.ts +69 -0
  321. package/dist/local-dev/dev-proxy-upstream.js +63 -0
  322. package/dist/local-dev/index.d.ts +28 -0
  323. package/dist/local-dev/index.js +25 -0
  324. package/dist/packaging/electron/archive.d.ts +2 -9
  325. package/dist/packaging/electron/asar-adapter.d.ts +2 -1
  326. package/dist/packaging/electron/entry.d.ts +2 -0
  327. package/dist/packaging/electron/move-to-applications.d.ts +165 -0
  328. package/dist/packaging/electron/move-to-applications.js +162 -0
  329. package/dist/packaging/electron/policies.d.ts +33 -4
  330. package/dist/packaging/electron/policies.js +29 -10
  331. package/dist/packaging/electron/ports.d.ts +1 -6
  332. package/dist/packaging/electron/staging.d.ts +11 -2
  333. package/dist/packaging/electron/staging.js +15 -5
  334. package/dist/react/site-share-expiry/ShareExpiryControls.d.ts +29 -0
  335. package/dist/react/site-share-expiry/ShareExpiryControls.js +7 -0
  336. package/dist/react/site-share-expiry/index.d.ts +2 -0
  337. package/dist/react/site-share-expiry/index.js +2 -0
  338. package/dist/source-control/react/ProvidersTab.d.ts +98 -0
  339. package/dist/source-control/react/ProvidersTab.js +195 -0
  340. package/dist/source-control/react/SourceControl.d.ts +51 -0
  341. package/dist/source-control/react/SourceControl.js +61 -0
  342. package/dist/source-control/react/hooks/use-source-control-credentials.hooks.d.ts +128 -0
  343. package/dist/source-control/react/hooks/use-source-control-credentials.hooks.js +102 -0
  344. package/dist/source-control/react/rules.d.ts +167 -0
  345. package/dist/source-control/react/rules.js +125 -0
  346. package/dist/source-control/react/source-control-visuals.d.ts +75 -0
  347. package/dist/source-control/react/source-control-visuals.js +48 -0
  348. package/dist/source-control/site/agent-tools.d.ts +5 -0
  349. package/dist/source-control/site/agent-tools.js +30 -0
  350. package/dist/source-control/site/bundled-provider-registry.d.ts +33 -0
  351. package/dist/source-control/site/bundled-provider-registry.js +37 -0
  352. package/dist/source-control/site/commit-schema.d.ts +40 -0
  353. package/dist/source-control/site/commit-schema.js +29 -0
  354. package/dist/source-control/site/commit-target.d.ts +26 -0
  355. package/dist/source-control/site/commit-target.js +58 -0
  356. package/dist/source-control/site/credential-form.d.ts +36 -0
  357. package/dist/source-control/site/credential-form.js +102 -0
  358. package/dist/source-control/site/credential-setup.d.ts +107 -0
  359. package/dist/source-control/site/credential-setup.js +216 -0
  360. package/dist/source-control/site/provider-kit.d.ts +37 -0
  361. package/dist/source-control/site/provider-kit.js +35 -0
  362. package/dist/source-control/site/provider-module.d.ts +251 -0
  363. package/dist/source-control/site/provider-module.js +2 -0
  364. package/dist/source-control/site/saved-key-bindings.d.ts +4 -0
  365. package/dist/source-control/site/saved-key-bindings.js +4 -0
  366. package/dist/source-control/site/static-site-packager-port.d.ts +37 -0
  367. package/dist/source-control/site/static-site-packager-port.js +2 -0
  368. package/dist/source-control/site/store.d.ts +209 -0
  369. package/dist/source-control/site/store.js +374 -0
  370. package/dist/source-control/site/store.validation.d.ts +72 -0
  371. package/dist/source-control/site/store.validation.js +168 -0
  372. package/dist/source-control/site/tool-registrations.d.ts +190 -0
  373. package/dist/source-control/site/tool-registrations.js +379 -0
  374. package/dist/static-export/site/export-preflight.d.ts +48 -0
  375. package/dist/static-export/site/export-preflight.js +82 -0
  376. package/dist/static-export/site/media-original-urls.d.ts +57 -0
  377. package/dist/static-export/site/media-original-urls.js +109 -0
  378. package/dist/static-export/site/ports.d.ts +82 -0
  379. package/dist/static-export/site/ports.js +29 -0
  380. package/dist/static-export/site/public-origin-policy.d.ts +32 -0
  381. package/dist/static-export/site/public-origin-policy.js +68 -0
  382. package/dist/static-export/site/route-manifest.d.ts +65 -0
  383. package/dist/static-export/site/route-manifest.js +139 -0
  384. package/dist/static-export/site/site-exporter.d.ts +158 -0
  385. package/dist/static-export/site/site-exporter.js +112 -0
  386. package/dist/static-export/site/static-security-headers.d.ts +39 -0
  387. package/dist/static-export/site/static-security-headers.js +43 -0
  388. package/dist/static-export/site/theme-preview-manifest.d.ts +35 -0
  389. package/dist/static-export/site/theme-preview-manifest.js +28 -0
  390. package/package.json +911 -7
@@ -0,0 +1,204 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { parseFragment, serialize } from "parse5";
4
+ /**
5
+ * @file What an imported archive may leave switched ON. Imported themes and HTML pages count as
6
+ * code, so they stay installed and a person turns them on. Never a refusal: an owner's own exported
7
+ * site still imports whole.
8
+ *
9
+ * Themes are judged by byte identity with this site's own copy. Pages keep their look when the shared page
10
+ * sanitizer's allow-list would leave them untouched, since most real HTML pages hold no code.
11
+ */
12
+ const LIVE_THEME_FILE = /^themes\/((?:static|declarative)\/([^/]+))\/(.+)$/;
13
+ /** Outside the page sanitizer's allow-list but plain text styling. The generated privacy page uses it. */
14
+ const INERT_DROPS = new Set(["mark"]);
15
+ const MAX_PAGE_NOTICES = 20;
16
+ const MAX_NOTICE_TITLE = 80;
17
+ /**
18
+ * Ids of live theme trees that are not byte-identical to the copy this new site already holds.
19
+ * Must run before restore replaces those trees.
20
+ * @complexity O(staged theme files + their bytes), bounded by the 300 MiB import cap.
21
+ */
22
+ export function unrecognisedThemes(required) {
23
+ const unrecognised = new Set();
24
+ for (const file of required.files) {
25
+ const match = LIVE_THEME_FILE.exec(file);
26
+ if (!match || !required.liveThemes.has(match[1]) || unrecognised.has(match[2]))
27
+ continue;
28
+ if (!sameBytes({ left: path.join(required.root, file), right: path.join(required.dir, file) }))
29
+ unrecognised.add(match[2]);
30
+ }
31
+ return unrecognised;
32
+ }
33
+ function sameBytes({ left, right }, _optional = {}) {
34
+ return fs.existsSync(right) && fs.readFileSync(left).equals(fs.readFileSync(right));
35
+ }
36
+ /**
37
+ * Whether a page body counts as code: `true` unless the allow-list keeps every element and
38
+ * attribute and no attribute value holds markup or an escape.
39
+ * @complexity O(html length).
40
+ */
41
+ export function pageBodyMayRunScript(required) {
42
+ let dropped = false;
43
+ required.host.sanitizePageHtml({ html: required.html }, { reportDrops: ({ dropped: drops }) => { dropped ||= Object.keys(drops).some(drop => !INERT_DROPS.has(drop)); } });
44
+ return dropped || attributeHoldsMarkup(parseFragment(required.html));
45
+ }
46
+ /** Native form grouping and input hints are inert; check behavior without changing stored HTML. */
47
+ function formBodyMayRunScript(required, _optional = {}) {
48
+ const root = parseFragment(required.html);
49
+ const pending = root.childNodes.map(node => ({ node, depth: 0 }));
50
+ const tags = new Set(["fieldset", "legend", "optgroup"]);
51
+ const attrs = new Set(["maxlength", "pattern", "accept", "inputmode", "spellcheck", "autocapitalize", "readonly", "label"]);
52
+ while (pending.length) {
53
+ const next = pending.pop();
54
+ if (next === undefined)
55
+ throw new Error("Imported markup scan has no pending node");
56
+ const { node, depth } = next;
57
+ if (!("tagName" in node))
58
+ continue;
59
+ if (depth >= 128)
60
+ return true;
61
+ stripInertFormHints(node, tags, attrs);
62
+ pending.push(...[...node.childNodes, ...("content" in node ? node.content.childNodes : [])].map(node => ({ node, depth: depth + 1 })));
63
+ }
64
+ return pageBodyMayRunScript({ html: serialize(root), host: required.host });
65
+ }
66
+ function stripInertFormHints(node, tags, attrs) {
67
+ if (node.namespaceURI === "http://www.w3.org/1999/xhtml") {
68
+ // Keep option grouping valid inside select so reparsing preserves its attributes.
69
+ if (tags.has(node.tagName))
70
+ node.tagName = node.nodeName = node.tagName === "optgroup" ? "option" : "div";
71
+ node.attrs = node.attrs.filter(attr => attr.namespace || attr.prefix || !attrs.has(attr.name));
72
+ }
73
+ }
74
+ function attributeHoldsMarkup(root) {
75
+ // Depth is bounded by the sanitizer above: anything deeper than its limit counts as a drop.
76
+ const pending = [...root.childNodes];
77
+ while (pending.length) {
78
+ const node = pending.pop();
79
+ if (node === undefined)
80
+ throw new Error("Imported attribute scan has no pending node");
81
+ if (!("tagName" in node))
82
+ continue;
83
+ if (node.attrs.some(attr => /[<>\\]/.test(attr.value)))
84
+ return true;
85
+ pending.push(...node.childNodes, ...("content" in node ? node.content.childNodes : []));
86
+ }
87
+ return false;
88
+ }
89
+ /**
90
+ * Leaves an active theme on only when it is this site's own, and moves every other one to the
91
+ * fallback, which the archive can never replace.
92
+ * @returns One notice per imported theme that was active.
93
+ * @complexity O(workspaces), one update per changed row.
94
+ */
95
+ async function keepThemesOff(required) {
96
+ const { store, host, fallback, liveThemeIds, unrecognised } = required;
97
+ const notices = new Set();
98
+ for (const active of await store.activeThemeIds()) {
99
+ const own = active === fallback || liveThemeIds.has(active);
100
+ if (active === host.noThemeId || (own && !unrecognised.has(active)))
101
+ continue;
102
+ if (unrecognised.has(active))
103
+ notices.add(host.notices.themeKeptOff({ themeId: active }));
104
+ await store.reassignActiveTheme({ from: active, to: fallback });
105
+ }
106
+ return [...notices];
107
+ }
108
+ /**
109
+ * Turns every published HTML page that could run script into a draft.
110
+ * @returns At most {@link MAX_PAGE_NOTICES} page notices plus one summary line.
111
+ * @complexity O(published HTML pages + their bytes) once per import; one update per kept-off page.
112
+ */
113
+ async function keepPagesOff(required) {
114
+ const { store, host } = required;
115
+ const kept = (await store.publishedHtmlPages()).filter(page => pageBodyMayRunScript({ html: page.bodyHtml ?? "", host }));
116
+ for (const page of kept)
117
+ await store.draftPage({ id: page.id });
118
+ const notices = kept.slice(0, MAX_PAGE_NOTICES).map(page => host.notices.pageDrafted({ title: String(page.title).slice(0, MAX_NOTICE_TITLE) }));
119
+ const more = kept.length - MAX_PAGE_NOTICES;
120
+ const morePagesDrafted = more === 1 ? host.notices.morePagesDrafted.singular : host.notices.morePagesDrafted.plural;
121
+ return more > 0 ? [...notices, morePagesDrafted({ count: more })] : notices;
122
+ }
123
+ /**
124
+ * Restore's one step that decides what stays on in the new database.
125
+ * @returns Notices for the person importing, in plain words.
126
+ * @throws Whatever the database throws; the caller's restore then fails and cleans up.
127
+ */
128
+ export async function keepImportedCodeOff(required) {
129
+ const store = required.openStore({ filePath: required.dbPath });
130
+ const { host } = required;
131
+ const ctx = { store, host };
132
+ try {
133
+ const liveThemeIds = new Set([...required.liveThemes].flatMap(id => {
134
+ if (id.startsWith("__"))
135
+ return [];
136
+ const name = id.split("/").at(-1);
137
+ if (name === undefined)
138
+ throw new Error("Imported live theme has no ID");
139
+ return [name];
140
+ }));
141
+ const setAside = required.setAside ? [host.notices.setAside({ fallback: required.fallback })] : [];
142
+ return [...setAside, ...await keepThemesOff({ ...ctx, fallback: required.fallback, liveThemeIds, unrecognised: required.unrecognised }), ...await keepPagesOff(ctx), ...await keepMenusOff(ctx), ...await keepFormsOff(ctx)];
143
+ }
144
+ finally {
145
+ await store.close();
146
+ }
147
+ }
148
+ /**
149
+ * Switches every HTML-mode menu that could run script back to items mode.
150
+ * @returns At most {@link MAX_PAGE_NOTICES} menu notices plus one summary line.
151
+ * @complexity O(menus + their bytes) once per import; one update per kept-off menu.
152
+ */
153
+ async function keepMenusOff(required, _optional = {}) {
154
+ const { store, host } = required;
155
+ const menuNotices = [];
156
+ for (const menu of await store.menus()) {
157
+ let doc;
158
+ try {
159
+ doc = JSON.parse(menu.docJson);
160
+ }
161
+ catch {
162
+ continue;
163
+ }
164
+ if (!doc || doc.mode !== "html" || typeof doc.html !== "string" || !pageBodyMayRunScript({ html: doc.html, host }))
165
+ continue;
166
+ // Draft menus still resolve at markers; items mode keeps the original HTML without serving it.
167
+ await store.setMenuDoc({ id: menu.id, docJson: JSON.stringify({ ...doc, mode: "items" }) });
168
+ menuNotices.push(host.notices.menuKeptOff({ title: String(menu.title).slice(0, MAX_NOTICE_TITLE), id: menu.id }));
169
+ }
170
+ const moreMenus = menuNotices.length - MAX_PAGE_NOTICES;
171
+ const notices = menuNotices.slice(0, MAX_PAGE_NOTICES);
172
+ if (moreMenus > 0)
173
+ notices.push(host.notices.moreMenusKeptOff({ count: moreMenus }));
174
+ return notices;
175
+ }
176
+ /**
177
+ * Disables every HTML-mode form that could run script.
178
+ * @returns At most {@link MAX_PAGE_NOTICES} form notices plus one summary line.
179
+ * @complexity O(forms + their bytes) once per import; one update per kept-off form.
180
+ */
181
+ async function keepFormsOff(required, _optional = {}) {
182
+ const { store, host } = required;
183
+ const formNotices = [];
184
+ for (const form of await store.forms()) {
185
+ let fields;
186
+ try {
187
+ fields = JSON.parse(form.fieldsJson);
188
+ }
189
+ catch {
190
+ continue;
191
+ }
192
+ if (!fields || fields.mode !== "html" || typeof fields.html !== "string" || !formBodyMayRunScript({ html: fields.html, host }))
193
+ continue;
194
+ // Disabled forms do not resolve at markers; keep the authored envelope byte-for-byte.
195
+ await store.disableForm({ id: form.id });
196
+ formNotices.push(host.notices.formDisabled({ name: String(form.name).slice(0, MAX_NOTICE_TITLE), id: form.id }));
197
+ }
198
+ const moreForms = formNotices.length - MAX_PAGE_NOTICES;
199
+ const notices = formNotices.slice(0, MAX_PAGE_NOTICES);
200
+ if (moreForms > 0)
201
+ notices.push(host.notices.moreFormsDisabled({ count: moreForms }));
202
+ return notices;
203
+ }
204
+ //# sourceMappingURL=import-keep-off.js.map
@@ -0,0 +1,74 @@
1
+ import type { AgentPluginLayout } from "@jini-ai/core/contracts/headless/plugin-host";
2
+ /** The slice of a manifest's plugin row this step reads (the host's archive plugin satisfies it). */
3
+ export interface ImportedArchivePlugin {
4
+ readonly kind: string;
5
+ readonly id: string;
6
+ readonly digest: string;
7
+ readonly enabled: boolean;
8
+ }
9
+ /** One plugin as the host's lifecycle lists it after seeding. */
10
+ export interface InstalledImportPlugin {
11
+ readonly pluginId: string;
12
+ readonly archiveDigest?: string | undefined;
13
+ }
14
+ /** The host agent-plugin lifecycle operations the import restore drives. */
15
+ export interface ImportPluginLifecycle {
16
+ /** The host's "Soon" lock catalog, handed back to {@link ImportPluginStateDeps.findSoonAgentPlugin}. */
17
+ readonly soonCatalog: unknown;
18
+ seedBundledAgentPlugins(required: {
19
+ layout: AgentPluginLayout;
20
+ workspaceId: string;
21
+ sourceRoot: string;
22
+ }): Promise<unknown>;
23
+ listInstalledPlugins(required: {
24
+ workspaceRoot: string;
25
+ }): Promise<readonly InstalledImportPlugin[]>;
26
+ setAgentPluginActivation(required: {
27
+ workspaceRoot: string;
28
+ pluginId: string;
29
+ enabled: boolean;
30
+ actor: string;
31
+ }): Promise<unknown>;
32
+ }
33
+ /** Host values the restore cannot own: lifecycle, "Soon" lock, starter workspace id and path policy. */
34
+ export interface ImportPluginStateDeps {
35
+ /** Folder of this build's bundled agent-plugin sources. */
36
+ sourceRoot: string;
37
+ createLifecycle(required: {
38
+ layout: AgentPluginLayout;
39
+ sourceRoot: string;
40
+ }): ImportPluginLifecycle;
41
+ /** Truthy when the host locks this plugin off ("Soon"); locked plugins are written off, not refused. */
42
+ findSoonAgentPlugin(required: {
43
+ catalog: unknown;
44
+ workspaceRoot: string;
45
+ pluginId: string;
46
+ }): Promise<unknown>;
47
+ /** The workspace id the starter template seeds. */
48
+ starterWorkspaceId(): string;
49
+ validatePath(required: {
50
+ path: string;
51
+ }): void;
52
+ }
53
+ /** Functional private staging state; discarded with the import stage, never an import history report. */
54
+ export interface ImportedExtensionState {
55
+ plugins: readonly ImportedArchivePlugin[];
56
+ trustedPlugins: readonly ImportedArchivePlugin[];
57
+ modified: readonly string[];
58
+ /** Code units staged switched off because this install does not recognise them. Absent in
59
+ * stages written before this field existed. */
60
+ keptOff?: readonly string[];
61
+ }
62
+ /** Seed only THIS install's code before applying imported activation choices by plugin id.
63
+ * Shipped code remains quarantined (see `importedActivation` for the per-plugin decision).
64
+ * @complexity O(local bundled package bytes + imported memory bytes), bounded by share caps.
65
+ */
66
+ export declare function restoreImportedPluginState(required: {
67
+ root: string;
68
+ dir: string;
69
+ layout: AgentPluginLayout;
70
+ state: ImportedExtensionState;
71
+ files: readonly string[];
72
+ deps: ImportPluginStateDeps;
73
+ }, _optional?: Record<string, never>): Promise<ReadonlySet<string>>;
74
+ //# sourceMappingURL=import-plugin-state.d.ts.map
@@ -0,0 +1,67 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { writeExclusive } from "./import-restore-placement.js";
4
+ /** Seed only THIS install's code before applying imported activation choices by plugin id.
5
+ * Shipped code remains quarantined (see `importedActivation` for the per-plugin decision).
6
+ * @complexity O(local bundled package bytes + imported memory bytes), bounded by share caps.
7
+ */
8
+ export async function restoreImportedPluginState(required, _optional = {}) {
9
+ if (!required.state.plugins.some(plugin => plugin.kind === "agent"))
10
+ return new Set();
11
+ const { layout } = required;
12
+ const { deps } = required;
13
+ const workspaceId = deps.starterWorkspaceId();
14
+ const { sourceRoot } = deps;
15
+ const lifecycle = deps.createLifecycle({ layout, sourceRoot });
16
+ await lifecycle.seedBundledAgentPlugins({ layout, workspaceId, sourceRoot });
17
+ const workspace = layout.forWorkspace({ workspaceId });
18
+ const installed = await lifecycle.listInstalledPlugins({ workspaceRoot: workspace.root });
19
+ const trusted = new Set(required.state.trustedPlugins.map(plugin => plugin.id));
20
+ const enabledUnits = new Set();
21
+ for (const plugin of required.state.plugins.filter(plugin => plugin.kind === "agent")) {
22
+ const edited = required.state.modified.includes("agent-plugins/" + plugin.id);
23
+ // A "Soon" plugin is locked off (host "Soon" lock, owner 2026-11-10): written off
24
+ // rather than refused, so one locked plugin never aborts the rest of the import.
25
+ const enabled = importedActivation({ plugin, installed, trusted, edited })
26
+ && !(await deps.findSoonAgentPlugin({ catalog: lifecycle.soonCatalog, workspaceRoot: workspace.root, pluginId: plugin.id }));
27
+ await lifecycle.setAgentPluginActivation({ workspaceRoot: workspace.root, pluginId: plugin.id, enabled, actor: "system:import" });
28
+ if (enabled)
29
+ enabledUnits.add("agent-plugins/" + plugin.id);
30
+ }
31
+ // Cross-build choices can enable local code after staging classified the source as unrecognised.
32
+ // Completion notices must reflect the activation we wrote, while source bytes stay quarantined.
33
+ const keptOff = (required.state.keptOff ?? []).filter(unit => !enabledUnits.has(unit));
34
+ fs.writeFileSync(path.join(required.root, ".archive-state.json"), JSON.stringify({ ...required.state, keptOff }), { mode: 0o600 });
35
+ return placeImportedMemory({ root: required.root, dir: required.dir, files: required.files, workspace, pluginIds: new Set(installed.map(plugin => plugin.pluginId)), validatePath: deps.validatePath });
36
+ }
37
+ /**
38
+ * The activation an imported agent plugin writes onto this install's own bundled code.
39
+ * - This install ships the same id under a different digest (the source ran another build
40
+ * version) and the copy was not edited: carry the operator's choice by id, including an
41
+ * explicit `false` so later boots preserve it. The imported code stays quarantined.
42
+ * - Otherwise only bundled-identical, trusted code carries the source's `enabled` over; an
43
+ * unrecognised or edited version explicitly stays off.
44
+ * `trusted` already excludes edited units.
45
+ */
46
+ function importedActivation(required) {
47
+ const { plugin } = required;
48
+ const local = required.installed.find(local => local.pluginId === plugin.id);
49
+ if (local && local.archiveDigest !== plugin.digest && !required.edited)
50
+ return plugin.enabled;
51
+ return Boolean(local && required.trusted.has(plugin.id) && plugin.enabled);
52
+ }
53
+ /** Places imported agent-plugin memory for plugins installed here; returns the staged files it placed.
54
+ * @complexity O(files + memory bytes). */
55
+ function placeImportedMemory(required) {
56
+ const placed = new Set();
57
+ for (const file of required.files) {
58
+ const match = /^agent-plugins\/([^/]+)\/memory\/(notes|learned)\/(.+)$/.exec(file);
59
+ if (!match || !required.pluginIds.has(match[1]))
60
+ continue;
61
+ const memoryDir = required.workspace.pluginMemoryDir({ pluginId: match[1], kind: match[2] });
62
+ placed.add(file);
63
+ writeExclusive({ root: required.dir, relative: path.relative(required.dir, path.join(memoryDir, match[3])), bytes: fs.readFileSync(path.join(required.root, file)), validatePath: required.validatePath });
64
+ }
65
+ return placed;
66
+ }
67
+ //# sourceMappingURL=import-plugin-state.js.map
@@ -0,0 +1,110 @@
1
+ import type { SiteImportRecord, ImportHistoryPolicy } from "@jini-ai/core/contracts/site/site-import-history";
2
+ import type { SqliteSyncClient } from "@jini-ai/core/contracts/storage";
3
+ import type { ImportIndexStore } from "./import-index/store.js";
4
+ export interface SiteImportUpload {
5
+ uploadId: string;
6
+ principalId: string;
7
+ createdAt: number;
8
+ consumedBy?: string;
9
+ }
10
+ /** Only the share origin remains in finished history. Upload sources are unchanged. @complexity O(url length). */
11
+ export declare function withoutQuery(required: {
12
+ source: SiteImportRecord["source"];
13
+ }): SiteImportRecord["source"];
14
+ /** Request replay can compare a link without retaining its path in finished history. */
15
+ export declare function importSourceDigest(required: {
16
+ source: SiteImportRecord["source"];
17
+ }, _optional?: {}): string | undefined;
18
+ /** CMS import history and private staging. The injected payload ports own atomic JSON replacement and locking.
19
+ * No public list, caller-controlled filesystem path, or source URL in a filename.
20
+ */
21
+ export declare class SiteImportRegistry {
22
+ readonly directory: string;
23
+ readonly history?: {
24
+ read<T>(required: {
25
+ run: (session: {
26
+ kind: "legacy";
27
+ } | {
28
+ kind: "index";
29
+ db: SqliteSyncClient;
30
+ store: ImportIndexStore;
31
+ policy: ImportHistoryPolicy;
32
+ }, optional?: Record<string, never>) => T;
33
+ }, optional?: Record<string, never>): T;
34
+ locked<T>(required: {
35
+ run: (session: {
36
+ kind: "legacy";
37
+ confirm?: (required: Record<string, never>, optional?: Record<string, never>) => void;
38
+ } | {
39
+ kind: "index";
40
+ db: SqliteSyncClient;
41
+ store: ImportIndexStore;
42
+ policy: ImportHistoryPolicy;
43
+ beforeWrite: (required: Record<string, never>, optional?: Record<string, never>) => void;
44
+ expireHistory: (required: Record<string, never>, optional?: Record<string, never>) => void;
45
+ sweep: (required: Record<string, never>, optional?: Record<string, never>) => void;
46
+ }, optional?: Record<string, never>) => Promise<T>;
47
+ }, optional?: Record<string, never>): Promise<T>;
48
+ } | undefined;
49
+ session: Parameters<Parameters<NonNullable<SiteImportRegistry["history"]>["locked"]>[0]["run"]>[0];
50
+ readonly payloadDirectory: string;
51
+ readonly clock: {
52
+ nowMs(): number;
53
+ };
54
+ private readonly paths;
55
+ private readonly payload;
56
+ private ready;
57
+ private readonly log;
58
+ /** @param options.log Reports an entry the expiry sweep could not clear; defaults to `console.error`. */
59
+ constructor(required: {
60
+ directory: string;
61
+ payload: SiteImportRegistry["payload"];
62
+ history?: SiteImportRegistry["history"];
63
+ }, options?: {
64
+ log?: (line: string, error: unknown) => void;
65
+ });
66
+ private file;
67
+ /** Reads one history record; an unreadable file is refused (with the caller's wording) and left in place. */
68
+ private readRecord;
69
+ get(required: {
70
+ importId: string;
71
+ principalId: string;
72
+ }, _options?: Record<string, never>): SiteImportRecord;
73
+ put(required: {
74
+ row: SiteImportRecord;
75
+ }, _options?: Record<string, never>): void;
76
+ /** Before a legacy JSON put, confirm under the held lock that the snapshot is still the authority. */
77
+ private confirmLegacyAuthority;
78
+ list(required: {
79
+ principalId?: string;
80
+ }, _options?: Record<string, never>): SiteImportRecord[];
81
+ uploadPath(required: {
82
+ uploadId: string;
83
+ }, _options?: Record<string, never>): string;
84
+ stagePath(required: {
85
+ importId: string;
86
+ }, _options?: Record<string, never>): string;
87
+ saveUpload(required: {
88
+ row: SiteImportUpload;
89
+ }, _options?: Record<string, never>): void;
90
+ getUpload(required: {
91
+ uploadId: string;
92
+ principalId: string;
93
+ }, _options?: Record<string, never>): SiteImportUpload;
94
+ /** One process-wide/disk-backed transfer lane bounds buffered memory and cross-process retries. */
95
+ exclusive<T>(required: {
96
+ run: () => Promise<T>;
97
+ }, _options?: Record<string, never>): Promise<T>;
98
+ expirePayloads(_required: Record<string, never>, _optional?: Record<string, never>): void;
99
+ countStagedPayloads(_required: Record<string, never>, _optional?: Record<string, never>): number;
100
+ /** Fails an owner setup past its deadline and discards its stage; history keeps the named failure. */
101
+ private expireOwnerSetup;
102
+ /** Expired payloads are disposable; retain history with a named failure rather than dead setup.
103
+ * Crash leftovers (a ZIP without metadata, a stage without a pending record) are removed too, so
104
+ * they never pin the staging budget. Callers hold the import lock: an upload writes its ZIP
105
+ * before its metadata, so an unlocked sweep could remove a payload that is still being saved.
106
+ */
107
+ expire(_required: Record<string, never>, _options?: Record<string, never>): void;
108
+ expireHistory(_required: Record<string, never>, _options?: Record<string, never>): void;
109
+ }
110
+ //# sourceMappingURL=import-registry.d.ts.map
@@ -0,0 +1,205 @@
1
+ import fs from "node:fs";
2
+ import { createHash } from "node:crypto";
3
+ import path from "node:path";
4
+ import { payloadPaths, ensurePayloadNamespace, expirePayloads, countStagedPayloads } from "./import-index/payload-namespace.js";
5
+ import { SiteShareRefusal } from "./share-refusal.js";
6
+ const ID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
7
+ /** A staged upload is claimable for one hour after it is saved. */
8
+ const UPLOAD_TTL_MS = 3600_000;
9
+ /** The statuses whose import may still own a `<id>.stage` directory. */
10
+ const STAGED_STATUSES = new Set(["verifying", "needs-owner", "creating"]);
11
+ /** Only the share origin remains in finished history. Upload sources are unchanged. @complexity O(url length). */
12
+ export function withoutQuery(required) {
13
+ const { source } = required;
14
+ if (!("url" in source))
15
+ return source;
16
+ const url = new URL(source.url);
17
+ return { url: url.origin };
18
+ }
19
+ /** Request replay can compare a link without retaining its path in finished history. */
20
+ export function importSourceDigest(required, _optional = {}) {
21
+ if (!("url" in required.source))
22
+ return undefined;
23
+ const url = new URL(required.source.url);
24
+ return createHash("sha256").update(url.href).digest("hex");
25
+ }
26
+ /** The import id behind an `<id>.json` history record name; undefined for every other file. */
27
+ function recordIdOf({ name }, _optional = {}) {
28
+ const id = name.slice(0, -5);
29
+ return name.endsWith(".json") && ID.test(id) ? id : undefined;
30
+ }
31
+ /** CMS import history and private staging. The injected payload ports own atomic JSON replacement and locking.
32
+ * No public list, caller-controlled filesystem path, or source URL in a filename.
33
+ */
34
+ export class SiteImportRegistry {
35
+ directory;
36
+ history;
37
+ session = { kind: "legacy" };
38
+ payloadDirectory;
39
+ clock;
40
+ paths;
41
+ payload;
42
+ ready = false;
43
+ log;
44
+ /** @param options.log Reports an entry the expiry sweep could not clear; defaults to `console.error`. */
45
+ constructor(required, options = {}) {
46
+ this.log = options.log ?? ((line, error) => console.error(line, error));
47
+ this.directory = path.resolve(required.directory);
48
+ this.payload = required.payload;
49
+ this.history = required.history;
50
+ this.clock = required.payload.clock;
51
+ this.paths = payloadPaths({ root: this.directory });
52
+ this.payloadDirectory = this.paths.dir;
53
+ fs.mkdirSync(this.directory, { recursive: true, mode: 0o700 });
54
+ fs.chmodSync(this.directory, 0o700);
55
+ }
56
+ file({ id, suffix }, _optional = {}) {
57
+ if (!ID.test(id))
58
+ throw new SiteShareRefusal({ code: "INVALID_INPUT", message: "Invalid import or upload id." });
59
+ return path.join(this.directory, id + suffix);
60
+ }
61
+ /** Reads one history record; an unreadable file is refused (with the caller's wording) and left in place. */
62
+ readRecord(required) {
63
+ const read = this.payload.readJsonAt({ file: this.file({ id: required.importId, suffix: ".json" }) });
64
+ if (read.state === "unreadable")
65
+ throw new SiteShareRefusal({ code: "REGISTRY_UNREADABLE", message: required.unreadable });
66
+ return read.state === "ok" ? read.value : undefined;
67
+ }
68
+ get(required, _options = {}) {
69
+ this.file({ id: required.importId, suffix: ".json" });
70
+ const row = this.session.kind === "index" ? this.session.store.get(required) : this.history
71
+ ? this.history.read({ run: (session, _optional = {}) => session.kind === "index" ? session.store.get(required) : this.readRecord({ importId: required.importId, unreadable: "Import record is unreadable; it was left untouched." }) })
72
+ : this.readRecord({ importId: required.importId, unreadable: "Import record is unreadable; it was left untouched." });
73
+ if (!row || row.principalId !== required.principalId)
74
+ throw new SiteShareRefusal({ code: "NOT_FOUND", message: "Import not found." });
75
+ return row;
76
+ }
77
+ put(required, _options = {}) {
78
+ if (this.session.kind === "index") {
79
+ this.session.store.put({ row: required.row, beforeWrite: this.session.beforeWrite });
80
+ return;
81
+ }
82
+ this.confirmLegacyAuthority({});
83
+ // History is kept for good; a finished import no longer needs the share link's path or query.
84
+ const row = required.row.status === "ready" || required.row.status === "failed" ? { ...required.row, source: withoutQuery({ source: required.row.source }) } : required.row;
85
+ this.payload.writeJsonAt({ file: this.file({ id: required.row.importId, suffix: ".json" }), value: row });
86
+ fs.chmodSync(this.file({ id: required.row.importId, suffix: ".json" }), 0o600);
87
+ }
88
+ /** Before a legacy JSON put, confirm under the held lock that the snapshot is still the authority. */
89
+ confirmLegacyAuthority(_required) {
90
+ if (!this.history)
91
+ return;
92
+ // Another process may have moved authority to the index since this lock's resolution; a stale JSON
93
+ // write then could let a pre-index reader create the same site twice.
94
+ if (this.session.kind !== "legacy" || !this.session.confirm)
95
+ throw new Error("Legacy import history writes need the import lock.");
96
+ this.session.confirm({});
97
+ }
98
+ list(required, _options = {}) {
99
+ return fs.readdirSync(this.directory).map(name => recordIdOf({ name })).filter(id => id !== undefined).flatMap(importId => {
100
+ const row = this.readRecord({ importId, unreadable: "Import history is unreadable; it was left untouched." });
101
+ return row && (required.principalId === undefined || row.principalId === required.principalId) ? [row] : [];
102
+ }).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
103
+ }
104
+ uploadPath(required, _options = {}) { return this.paths.upload(required); }
105
+ stagePath(required, _options = {}) { return this.paths.stage(required); }
106
+ saveUpload(required, _options = {}) { this.payload.writeJsonAt({ file: this.paths.uploadMeta(required.row), value: required.row }); }
107
+ getUpload(required, _options = {}) {
108
+ const read = this.payload.readJsonAt({ file: this.paths.uploadMeta(required) });
109
+ const row = read.state === "ok" ? read.value : undefined;
110
+ if (!row || row.principalId !== required.principalId || row.createdAt + UPLOAD_TTL_MS < this.clock.nowMs())
111
+ throw new SiteShareRefusal({ code: "NOT_FOUND", message: "Upload not found or expired. Upload the ZIP again." });
112
+ return row;
113
+ }
114
+ /** One process-wide/disk-backed transfer lane bounds buffered memory and cross-process retries. */
115
+ async exclusive(required, _options = {}) {
116
+ return this.payload.lock.withFileLock({ lockPath: path.join(this.directory, ".import.lock"), run: async () => {
117
+ if (!this.ready) {
118
+ // Nonmutating refusal check first: a refused workspace must not create or move payload directories.
119
+ this.history?.read({ run: (_session, _optional = {}) => undefined });
120
+ ensurePayloadNamespace({ root: this.directory, paths: this.paths, fs: this.payload.fs });
121
+ this.ready = true;
122
+ }
123
+ if (!this.history)
124
+ return required.run();
125
+ return this.history.locked({ run: async (session, _optional = {}) => {
126
+ this.session = session;
127
+ try {
128
+ return await required.run();
129
+ }
130
+ finally {
131
+ this.session = { kind: "legacy" };
132
+ }
133
+ } });
134
+ } }, { staleMs: Infinity });
135
+ }
136
+ expirePayloads(_required, _optional = {}) {
137
+ expirePayloads({ paths: this.paths, fs: this.payload.fs, clock: this.clock,
138
+ // A null row can never be claimed (getUpload refuses it), so it expires like an old one.
139
+ readUpload: ({ uploadId }, _optional = {}) => this.payload.readJsonAt({ file: this.paths.uploadMeta({ uploadId }) }),
140
+ statusOf: ({ importId }, _optional = {}) => {
141
+ if (this.session.kind === "index") {
142
+ const status = this.session.store.statusOf({ importId });
143
+ if (status === undefined)
144
+ return "absent";
145
+ return STAGED_STATUSES.has(status) ? "active" : "terminal";
146
+ }
147
+ const read = this.payload.readJsonAt({ file: this.file({ id: importId, suffix: ".json" }) });
148
+ if (read.state === "unreadable")
149
+ return "unreadable";
150
+ if (read.state !== "ok" || read.value === null)
151
+ return "absent";
152
+ return STAGED_STATUSES.has(read.value.status) ? "active" : "terminal";
153
+ },
154
+ report: ({ operation, error }, _optional = {}) => this.log(`[site-backup] ${operation}`, error), });
155
+ }
156
+ countStagedPayloads(_required, _optional = {}) {
157
+ return countStagedPayloads({ paths: this.paths, fs: this.payload.fs });
158
+ }
159
+ /** Fails an owner setup past its deadline and discards its stage; history keeps the named failure. */
160
+ expireOwnerSetup(required) {
161
+ const read = this.payload.readJsonAt({ file: this.file({ id: required.importId, suffix: ".json" }) });
162
+ if (read.state !== "ok")
163
+ return;
164
+ const row = read.value;
165
+ if (row === null)
166
+ return;
167
+ if (row.status === "needs-owner" && row.expiresAt < this.clock.nowMs()) {
168
+ fs.rmSync(this.stagePath(row), { recursive: true, force: true });
169
+ this.put({ row: { ...row, status: "failed", error: "Owner setup expired. Import the archive again." } });
170
+ }
171
+ // Reuse the existing history pass to remove link details from older finished records too.
172
+ if ((row.status === "ready" || row.status === "failed") && "url" in row.source && row.source.url !== new URL(row.source.url).origin)
173
+ this.put({ row });
174
+ }
175
+ /** Expired payloads are disposable; retain history with a named failure rather than dead setup.
176
+ * Crash leftovers (a ZIP without metadata, a stage without a pending record) are removed too, so
177
+ * they never pin the staging budget. Callers hold the import lock: an upload writes its ZIP
178
+ * before its metadata, so an unlocked sweep could remove a payload that is still being saved.
179
+ */
180
+ expire(_required, _options = {}) {
181
+ this.expirePayloads({});
182
+ this.expireHistory({});
183
+ }
184
+ expireHistory(_required, _options = {}) {
185
+ if (this.session.kind === "index") {
186
+ this.session.expireHistory({});
187
+ return;
188
+ }
189
+ // Legacy history expiry stays separate until indexed mode.
190
+ for (const filename of fs.readdirSync(this.directory)) {
191
+ const importId = recordIdOf({ name: filename });
192
+ // Unrecognized files are outside the import registry.
193
+ if (importId === undefined)
194
+ continue;
195
+ // One entry that cannot be removed (permissions, a busy file) must not stop the rest of the sweep.
196
+ try {
197
+ this.expireOwnerSetup({ importId });
198
+ }
199
+ catch (error) {
200
+ this.log(`[site-backup] import registry could not clear expired entry ${filename}; the rest of the sweep continues`, error);
201
+ }
202
+ }
203
+ }
204
+ }
205
+ //# sourceMappingURL=import-registry.js.map