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

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 (402) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +16 -0
  3. package/dist/backup/site/archive-extensions.d.ts +73 -0
  4. package/dist/backup/site/archive-extensions.js +129 -0
  5. package/dist/backup/site/archive-manifest.d.ts +85 -0
  6. package/dist/backup/site/archive-manifest.js +176 -0
  7. package/dist/backup/site/archive-media.d.ts +121 -0
  8. package/dist/backup/site/archive-media.js +93 -0
  9. package/dist/backup/site/backup-service.credentials.d.ts +31 -0
  10. package/dist/backup/site/backup-service.credentials.js +158 -0
  11. package/dist/backup/site/backup-service.d.ts +336 -0
  12. package/dist/backup/site/backup-service.js +127 -0
  13. package/dist/backup/site/backup-service.plan.d.ts +64 -0
  14. package/dist/backup/site/backup-service.plan.js +207 -0
  15. package/dist/backup/site/backup-service.push.d.ts +29 -0
  16. package/dist/backup/site/backup-service.push.js +94 -0
  17. package/dist/backup/site/backup-service.shared.d.ts +40 -0
  18. package/dist/backup/site/backup-service.shared.js +37 -0
  19. package/dist/backup/site/bundled-export-file-policy.d.ts +38 -0
  20. package/dist/backup/site/bundled-export-file-policy.js +39 -0
  21. package/dist/backup/site/credential-warnings.d.ts +41 -0
  22. package/dist/backup/site/credential-warnings.js +50 -0
  23. package/dist/backup/site/import-backend-steps.d.ts +167 -0
  24. package/dist/backup/site/import-backend-steps.js +170 -0
  25. package/dist/backup/site/import-backend.d.ts +167 -0
  26. package/dist/backup/site/import-backend.js +298 -0
  27. package/dist/backup/site/import-database.d.ts +118 -0
  28. package/dist/backup/site/import-database.js +167 -0
  29. package/dist/backup/site/import-index/admission.d.ts +54 -0
  30. package/dist/backup/site/import-index/admission.js +46 -0
  31. package/dist/backup/site/import-index/backfill.d.ts +106 -0
  32. package/dist/backup/site/import-index/backfill.js +137 -0
  33. package/dist/backup/site/import-index/errors.d.ts +28 -0
  34. package/dist/backup/site/import-index/errors.js +38 -0
  35. package/dist/backup/site/import-index/migrations/checksums.d.ts +4 -0
  36. package/dist/backup/site/import-index/migrations/checksums.js +4 -0
  37. package/dist/backup/site/import-index/migrations/site-imports-v1.d.ts +2 -0
  38. package/dist/backup/site/import-index/migrations/site-imports-v1.js +10 -0
  39. package/dist/backup/site/import-index/mode.d.ts +191 -0
  40. package/dist/backup/site/import-index/mode.js +272 -0
  41. package/dist/backup/site/import-index/open.d.ts +40 -0
  42. package/dist/backup/site/import-index/open.js +87 -0
  43. package/dist/backup/site/import-index/paging.d.ts +28 -0
  44. package/dist/backup/site/import-index/paging.js +66 -0
  45. package/dist/backup/site/import-index/payload-namespace.d.ts +80 -0
  46. package/dist/backup/site/import-index/payload-namespace.js +156 -0
  47. package/dist/backup/site/import-index/rows.d.ts +32 -0
  48. package/dist/backup/site/import-index/rows.js +61 -0
  49. package/dist/backup/site/import-index/schema.d.ts +8 -0
  50. package/dist/backup/site/import-index/schema.js +31 -0
  51. package/dist/backup/site/import-index/store.d.ts +27 -0
  52. package/dist/backup/site/import-index/store.js +33 -0
  53. package/dist/backup/site/import-index/sweep.d.ts +10 -0
  54. package/dist/backup/site/import-index/sweep.js +26 -0
  55. package/dist/backup/site/import-keep-off.d.ts +128 -0
  56. package/dist/backup/site/import-keep-off.js +204 -0
  57. package/dist/backup/site/import-plugin-state.d.ts +74 -0
  58. package/dist/backup/site/import-plugin-state.js +67 -0
  59. package/dist/backup/site/import-registry.d.ts +110 -0
  60. package/dist/backup/site/import-registry.js +205 -0
  61. package/dist/backup/site/import-restore-placement.d.ts +94 -0
  62. package/dist/backup/site/import-restore-placement.js +158 -0
  63. package/dist/backup/site/import-restore.d.ts +111 -0
  64. package/dist/backup/site/import-restore.js +120 -0
  65. package/dist/backup/site/import-verifier-inventory.d.ts +137 -0
  66. package/dist/backup/site/import-verifier-inventory.js +236 -0
  67. package/dist/backup/site/import-verifier-projection.d.ts +78 -0
  68. package/dist/backup/site/import-verifier-projection.js +100 -0
  69. package/dist/backup/site/import-verifier.d.ts +126 -0
  70. package/dist/backup/site/import-verifier.js +53 -0
  71. package/dist/backup/site/owned-temp-root.d.ts +12 -0
  72. package/dist/backup/site/owned-temp-root.js +2 -0
  73. package/dist/backup/site/package-file-inventory.d.ts +63 -0
  74. package/dist/backup/site/package-file-inventory.js +56 -0
  75. package/dist/backup/site/push-content.d.ts +70 -0
  76. package/dist/backup/site/push-content.js +56 -0
  77. package/dist/backup/site/react/ShowMoreImports.d.ts +21 -0
  78. package/dist/backup/site/react/ShowMoreImports.js +8 -0
  79. package/dist/backup/site/saved-keys-port.d.ts +47 -0
  80. package/dist/backup/site/saved-keys-port.js +3 -0
  81. package/dist/backup/site/saved-keys.d.ts +25 -0
  82. package/dist/backup/site/saved-keys.js +38 -0
  83. package/dist/backup/site/share-backend.d.ts +243 -0
  84. package/dist/backup/site/share-backend.js +284 -0
  85. package/dist/backup/site/share-database/projection.d.ts +197 -0
  86. package/dist/backup/site/share-database/projection.js +90 -0
  87. package/dist/backup/site/share-database/projection.media.d.ts +38 -0
  88. package/dist/backup/site/share-database/projection.media.js +179 -0
  89. package/dist/backup/site/share-database/projection.tables.d.ts +46 -0
  90. package/dist/backup/site/share-database/projection.tables.js +210 -0
  91. package/dist/backup/site/share-expiry.d.ts +75 -0
  92. package/dist/backup/site/share-expiry.js +49 -0
  93. package/dist/backup/site/share-export-failure.d.ts +17 -0
  94. package/dist/backup/site/share-export-failure.js +16 -0
  95. package/dist/backup/site/share-file-policy.d.ts +60 -0
  96. package/dist/backup/site/share-file-policy.js +146 -0
  97. package/dist/backup/site/share-hosting.d.ts +107 -0
  98. package/dist/backup/site/share-hosting.js +148 -0
  99. package/dist/backup/site/share-preparation-steps.d.ts +180 -0
  100. package/dist/backup/site/share-preparation-steps.js +107 -0
  101. package/dist/backup/site/share-preparation.d.ts +122 -0
  102. package/dist/backup/site/share-preparation.js +43 -0
  103. package/dist/backup/site/share-refusal.d.ts +21 -0
  104. package/dist/backup/site/share-refusal.js +20 -0
  105. package/dist/backup/site/share-registry.d.ts +124 -0
  106. package/dist/backup/site/share-registry.js +219 -0
  107. package/dist/backup/site/share-retention.d.ts +62 -0
  108. package/dist/backup/site/share-retention.js +126 -0
  109. package/dist/backup/site/share-service.d.ts +128 -0
  110. package/dist/backup/site/share-service.js +194 -0
  111. package/dist/backup/site/share-zip.d.ts +115 -0
  112. package/dist/backup/site/share-zip.js +144 -0
  113. package/dist/backup/site/sources.d.ts +344 -0
  114. package/dist/backup/site/sources.js +595 -0
  115. package/dist/backup/site/static-copy.d.ts +122 -0
  116. package/dist/backup/site/static-copy.js +165 -0
  117. package/dist/backup/site/static-download-html.d.ts +76 -0
  118. package/dist/backup/site/static-download-html.js +149 -0
  119. package/dist/backup/site/static-download-landing.d.ts +52 -0
  120. package/dist/backup/site/static-download-landing.js +95 -0
  121. package/dist/backup/site/static-download-layout.d.ts +96 -0
  122. package/dist/backup/site/static-download-layout.js +325 -0
  123. package/dist/backup/site/static-export-selection.d.ts +50 -0
  124. package/dist/backup/site/static-export-selection.js +75 -0
  125. package/dist/backup/site/static-site-packager.d.ts +42 -0
  126. package/dist/backup/site/static-site-packager.js +32 -0
  127. package/dist/backup/site/tool-registrations.d.ts +74 -0
  128. package/dist/backup/site/tool-registrations.js +204 -0
  129. package/dist/checks/complexity-debt.d.ts +100 -0
  130. package/dist/checks/complexity-debt.js +131 -0
  131. package/dist/checks/coverage/diff.js +5 -1
  132. package/dist/checks/coverage/lcov.js +1 -1
  133. package/dist/checks/env-access.d.ts +14 -1
  134. package/dist/checks/env-access.js +92 -6
  135. package/dist/checks/live-verify-checks.d.ts +29 -0
  136. package/dist/checks/live-verify-checks.js +30 -0
  137. package/dist/checks/quality-gates.d.ts +137 -0
  138. package/dist/checks/quality-gates.js +209 -0
  139. package/dist/core/deploy-types.d.ts +2 -0
  140. package/dist/deploy/admin-http/site-update-status.d.ts +8 -0
  141. package/dist/deploy/admin-http/site-update-status.js +15 -0
  142. package/dist/deploy/host-kit.d.ts +3 -0
  143. package/dist/deploy/index.d.ts +6 -0
  144. package/dist/deploy/index.js +6 -0
  145. package/dist/deploy/ops-runner.js +7 -0
  146. package/dist/deploy/ops-tool-contracts.d.ts +10 -1
  147. package/dist/deploy/react/Deployment.d.ts +37 -0
  148. package/dist/deploy/react/Deployment.js +94 -0
  149. package/dist/deploy/react/DockerfileTab.d.ts +72 -0
  150. package/dist/deploy/react/DockerfileTab.js +131 -0
  151. package/dist/deploy/react/HistoryTab.d.ts +43 -0
  152. package/dist/deploy/react/HistoryTab.js +12 -0
  153. package/dist/deploy/react/OverviewTab.d.ts +60 -0
  154. package/dist/deploy/react/OverviewTab.js +75 -0
  155. package/dist/deploy/react/PublishRunResult.d.ts +5 -1
  156. package/dist/deploy/react/PublishRunResult.js +4 -4
  157. package/dist/deploy/react/SiteUpdateNotice.d.ts +22 -0
  158. package/dist/deploy/react/SiteUpdateNotice.js +25 -0
  159. package/dist/deploy/react/StaticCredentialFields.d.ts +36 -0
  160. package/dist/deploy/react/StaticCredentialFields.js +63 -0
  161. package/dist/deploy/react/StaticCredentialSteps.d.ts +23 -0
  162. package/dist/deploy/react/StaticCredentialSteps.js +152 -0
  163. package/dist/deploy/react/StaticExportCard.d.ts +11 -0
  164. package/dist/deploy/react/StaticExportCard.js +97 -0
  165. package/dist/deploy/react/StaticPublishCredentials.d.ts +50 -0
  166. package/dist/deploy/react/StaticPublishCredentials.js +77 -0
  167. package/dist/deploy/react/StaticPublishForm.d.ts +12 -0
  168. package/dist/deploy/react/StaticPublishForm.js +91 -0
  169. package/dist/deploy/react/StaticSiteTab.d.ts +207 -0
  170. package/dist/deploy/react/StaticSiteTab.js +117 -0
  171. package/dist/deploy/react/deployment-visuals.d.ts +207 -0
  172. package/dist/deploy/react/deployment-visuals.js +101 -0
  173. package/dist/deploy/react/download-dockerfile.d.ts +14 -0
  174. package/dist/deploy/react/download-dockerfile.js +15 -0
  175. package/dist/deploy/react/hooks/publish-credential-draft.d.ts +33 -0
  176. package/dist/deploy/react/hooks/publish-credential-draft.js +54 -0
  177. package/dist/deploy/react/hooks/publish-credential-selection.d.ts +13 -0
  178. package/dist/deploy/react/hooks/publish-credential-selection.js +34 -0
  179. package/dist/deploy/react/hooks/publish-credential-writes.d.ts +20 -0
  180. package/dist/deploy/react/hooks/publish-credential-writes.js +99 -0
  181. package/dist/deploy/react/hooks/static-publish-actions.d.ts +10 -0
  182. package/dist/deploy/react/hooks/static-publish-actions.js +62 -0
  183. package/dist/deploy/react/hooks/static-publish-form.hooks.d.ts +38 -0
  184. package/dist/deploy/react/hooks/static-publish-form.hooks.js +103 -0
  185. package/dist/deploy/react/hooks/static-publish-run.hooks.d.ts +28 -0
  186. package/dist/deploy/react/hooks/static-publish-run.hooks.js +92 -0
  187. package/dist/deploy/react/hooks/use-dockerfile-source.hooks.d.ts +148 -0
  188. package/dist/deploy/react/hooks/use-dockerfile-source.hooks.js +155 -0
  189. package/dist/deploy/react/hooks/use-publish-credentials.hooks.d.ts +268 -0
  190. package/dist/deploy/react/hooks/use-publish-credentials.hooks.js +52 -0
  191. package/dist/deploy/react/hooks/use-static-export.hooks.d.ts +128 -0
  192. package/dist/deploy/react/hooks/use-static-export.hooks.js +159 -0
  193. package/dist/deploy/react/hooks/use-static-publish.hooks.d.ts +208 -0
  194. package/dist/deploy/react/hooks/use-static-publish.hooks.js +48 -0
  195. package/dist/deploy/react/index.d.ts +4 -0
  196. package/dist/deploy/react/index.js +2 -0
  197. package/dist/deploy/react/rules.d.ts +363 -0
  198. package/dist/deploy/react/rules.js +314 -0
  199. package/dist/deploy/react/use-deployment-overview.hooks.d.ts +41 -0
  200. package/dist/deploy/react/use-deployment-overview.hooks.js +11 -0
  201. package/dist/deploy/site/agent-tools.d.ts +42 -0
  202. package/dist/deploy/site/agent-tools.js +119 -0
  203. package/dist/deploy/site/deploy-config-registry.d.ts +155 -0
  204. package/dist/deploy/site/deploy-config-registry.js +124 -0
  205. package/dist/deploy/site/deploy-config.d.ts +97 -0
  206. package/dist/deploy/site/deploy-config.js +115 -0
  207. package/dist/deploy/site/deploy-ops/agent-tools.d.ts +22 -0
  208. package/dist/deploy/site/deploy-ops/agent-tools.js +76 -0
  209. package/dist/deploy/site/deploy-ops/registry.d.ts +134 -0
  210. package/dist/deploy/site/deploy-ops/registry.js +106 -0
  211. package/dist/deploy/site/deploy-ops/run-ops.d.ts +66 -0
  212. package/dist/deploy/site/deploy-ops/run-ops.js +34 -0
  213. package/dist/deploy/site/deploy-ops/secret-confirm.d.ts +36 -0
  214. package/dist/deploy/site/deploy-ops/secret-confirm.js +27 -0
  215. package/dist/deploy/site/deploy-targets/host-kit.d.ts +28 -0
  216. package/dist/deploy/site/deploy-targets/host-kit.js +120 -0
  217. package/dist/deploy/site/deploy-targets/registry.d.ts +157 -0
  218. package/dist/deploy/site/deploy-targets/registry.js +130 -0
  219. package/dist/deploy/site/deploy-targets/types.d.ts +27 -0
  220. package/dist/deploy/site/deploy-targets/types.js +2 -0
  221. package/dist/deploy/site/dockerfile.d.ts +137 -0
  222. package/dist/deploy/site/dockerfile.js +101 -0
  223. package/dist/deploy/site/export-run.d.ts +137 -0
  224. package/dist/deploy/site/export-run.js +152 -0
  225. package/dist/deploy/site/ports.d.ts +115 -0
  226. package/dist/deploy/site/ports.js +2 -0
  227. package/dist/deploy/site/publish-agent-tools.d.ts +18 -0
  228. package/dist/deploy/site/publish-agent-tools.js +120 -0
  229. package/dist/deploy/site/publish-candidate.d.ts +26 -0
  230. package/dist/deploy/site/publish-candidate.js +37 -0
  231. package/dist/deploy/site/publish-credentials/account-label-heal-scheduler.d.ts +78 -0
  232. package/dist/deploy/site/publish-credentials/account-label-heal-scheduler.js +88 -0
  233. package/dist/deploy/site/publish-credentials/compatibility-port.d.ts +38 -0
  234. package/dist/deploy/site/publish-credentials/compatibility-port.js +19 -0
  235. package/dist/deploy/site/publish-credentials/execution-mode.d.ts +43 -0
  236. package/dist/deploy/site/publish-credentials/execution-mode.js +19 -0
  237. package/dist/deploy/site/publish-credentials/store-owner.d.ts +11 -0
  238. package/dist/deploy/site/publish-credentials/store-owner.js +9 -0
  239. package/dist/deploy/site/publish-credentials/store-resolution.d.ts +55 -0
  240. package/dist/deploy/site/publish-credentials/store-resolution.js +100 -0
  241. package/dist/deploy/site/publish-credentials/store-validation.d.ts +68 -0
  242. package/dist/deploy/site/publish-credentials/store-validation.js +182 -0
  243. package/dist/deploy/site/publish-credentials/store.d.ts +321 -0
  244. package/dist/deploy/site/publish-credentials/store.js +367 -0
  245. package/dist/deploy/site/publish-credentials/types.d.ts +85 -0
  246. package/dist/deploy/site/publish-credentials/types.js +2 -0
  247. package/dist/deploy/site/publish-tool-capabilities.d.ts +123 -0
  248. package/dist/deploy/site/publish-tool-capabilities.js +175 -0
  249. package/dist/deploy/site/publish-tool-credential.d.ts +48 -0
  250. package/dist/deploy/site/publish-tool-credential.js +284 -0
  251. package/dist/deploy/site/publish-tool-deps.d.ts +205 -0
  252. package/dist/deploy/site/publish-tool-deps.js +15 -0
  253. package/dist/deploy/site/publish-tool-execution.d.ts +78 -0
  254. package/dist/deploy/site/publish-tool-execution.js +313 -0
  255. package/dist/deploy/site/publish-tool-schema.d.ts +29 -0
  256. package/dist/deploy/site/publish-tool-schema.js +38 -0
  257. package/dist/deploy/site/static-publish/adapter-export.d.ts +54 -0
  258. package/dist/deploy/site/static-publish/adapter-export.js +89 -0
  259. package/dist/deploy/site/static-publish/adapter-plan.d.ts +99 -0
  260. package/dist/deploy/site/static-publish/adapter-plan.js +112 -0
  261. package/dist/deploy/site/static-publish/adapter.d.ts +182 -0
  262. package/dist/deploy/site/static-publish/adapter.js +321 -0
  263. package/dist/deploy/site/static-publish/admin-publish-read.d.ts +209 -0
  264. package/dist/deploy/site/static-publish/admin-publish-read.js +118 -0
  265. package/dist/deploy/site/static-publish/credentials.d.ts +114 -0
  266. package/dist/deploy/site/static-publish/credentials.js +298 -0
  267. package/dist/deploy/site/static-publish/domain-publish-rows.d.ts +25 -0
  268. package/dist/deploy/site/static-publish/domain-publish-rows.js +43 -0
  269. package/dist/deploy/site/static-publish/domain-publish-tool.d.ts +19 -0
  270. package/dist/deploy/site/static-publish/domain-publish-tool.js +111 -0
  271. package/dist/deploy/site/static-publish/inspection.d.ts +24 -0
  272. package/dist/deploy/site/static-publish/inspection.js +69 -0
  273. package/dist/deploy/site/static-publish/publish-history.d.ts +197 -0
  274. package/dist/deploy/site/static-publish/publish-history.js +153 -0
  275. package/dist/deploy/site/static-publish/publish-run.d.ts +156 -0
  276. package/dist/deploy/site/static-publish/publish-run.js +186 -0
  277. package/dist/deploy/site/static-publish/types.d.ts +168 -0
  278. package/dist/deploy/site/static-publish/types.js +2 -0
  279. package/dist/deploy/site/static-publish/verify.d.ts +237 -0
  280. package/dist/deploy/site/static-publish/verify.js +284 -0
  281. package/dist/deploy/site/tool-registrations.d.ts +97 -0
  282. package/dist/deploy/site/tool-registrations.js +130 -0
  283. package/dist/deploy/site/types.d.ts +51 -0
  284. package/dist/deploy/site/types.js +2 -0
  285. package/dist/deploy/site-update/check-for-update.d.ts +19 -0
  286. package/dist/deploy/site-update/check-for-update.js +19 -0
  287. package/dist/deploy/site-update/contracts.d.ts +161 -0
  288. package/dist/deploy/site-update/contracts.js +94 -0
  289. package/dist/deploy/site-update/desktop-site-update.d.ts +66 -0
  290. package/dist/deploy/site-update/desktop-site-update.js +43 -0
  291. package/dist/deploy/site-update/fake-site-update.d.ts +39 -0
  292. package/dist/deploy/site-update/fake-site-update.js +52 -0
  293. package/dist/deploy/site-update/run-site-update.d.ts +121 -0
  294. package/dist/deploy/site-update/run-site-update.js +219 -0
  295. package/dist/deploy/site-update/self-hosted-site-update.d.ts +71 -0
  296. package/dist/deploy/site-update/self-hosted-site-update.js +79 -0
  297. package/dist/deploy/target-contracts.d.ts +3 -0
  298. package/dist/deploy/tool.d.ts +5 -8
  299. package/dist/deploy/tool.js +6 -9
  300. package/dist/dns/binding-sweeper.d.ts +72 -0
  301. package/dist/dns/binding-sweeper.js +53 -0
  302. package/dist/dns/index.d.ts +1 -0
  303. package/dist/dns/index.js +1 -0
  304. package/dist/dns/site/binding.repo.d.ts +71 -0
  305. package/dist/dns/site/binding.repo.js +45 -0
  306. package/dist/dns/site/dns-changes.d.ts +90 -0
  307. package/dist/dns/site/dns-changes.js +271 -0
  308. package/dist/dns/site/dns-tools.d.ts +46 -0
  309. package/dist/dns/site/dns-tools.js +204 -0
  310. package/dist/dns/site/mail-dns-status.d.ts +111 -0
  311. package/dist/dns/site/mail-dns-status.js +190 -0
  312. package/dist/dns/site/mail-dns-tools.d.ts +33 -0
  313. package/dist/dns/site/mail-dns-tools.js +62 -0
  314. package/dist/dns/site/mail-requirements.d.ts +30 -0
  315. package/dist/dns/site/mail-requirements.js +78 -0
  316. package/dist/dns/site/tool-deps.d.ts +21 -0
  317. package/dist/dns/site/tool-deps.js +2 -0
  318. package/dist/dns/site/tools.d.ts +74 -0
  319. package/dist/dns/site/tools.js +124 -0
  320. package/dist/local-dev/bind-host.d.ts +80 -0
  321. package/dist/local-dev/bind-host.js +90 -0
  322. package/dist/local-dev/dev-proxy-upstream.d.ts +69 -0
  323. package/dist/local-dev/dev-proxy-upstream.js +63 -0
  324. package/dist/local-dev/index.d.ts +28 -0
  325. package/dist/local-dev/index.js +25 -0
  326. package/dist/packaging/electron/archive.d.ts +2 -9
  327. package/dist/packaging/electron/asar-adapter.d.ts +2 -1
  328. package/dist/packaging/electron/entry.d.ts +2 -0
  329. package/dist/packaging/electron/move-to-applications.d.ts +165 -0
  330. package/dist/packaging/electron/move-to-applications.js +162 -0
  331. package/dist/packaging/electron/policies.d.ts +33 -4
  332. package/dist/packaging/electron/policies.js +29 -10
  333. package/dist/packaging/electron/ports.d.ts +1 -6
  334. package/dist/packaging/electron/staging.d.ts +11 -2
  335. package/dist/packaging/electron/staging.js +15 -5
  336. package/dist/packaging/electron/update-manifest-merge.js +0 -2
  337. package/dist/react/site-share-expiry/ShareExpiryControls.d.ts +29 -0
  338. package/dist/react/site-share-expiry/ShareExpiryControls.js +7 -0
  339. package/dist/react/site-share-expiry/index.d.ts +2 -0
  340. package/dist/react/site-share-expiry/index.js +2 -0
  341. package/dist/source-control/react/ProvidersTab.d.ts +98 -0
  342. package/dist/source-control/react/ProvidersTab.js +195 -0
  343. package/dist/source-control/react/SourceControl.d.ts +51 -0
  344. package/dist/source-control/react/SourceControl.js +61 -0
  345. package/dist/source-control/react/hooks/use-source-control-credentials.hooks.d.ts +128 -0
  346. package/dist/source-control/react/hooks/use-source-control-credentials.hooks.js +102 -0
  347. package/dist/source-control/react/rules.d.ts +167 -0
  348. package/dist/source-control/react/rules.js +125 -0
  349. package/dist/source-control/react/source-control-visuals.d.ts +75 -0
  350. package/dist/source-control/react/source-control-visuals.js +48 -0
  351. package/dist/source-control/site/agent-tools.d.ts +5 -0
  352. package/dist/source-control/site/agent-tools.js +30 -0
  353. package/dist/source-control/site/bundled-provider-registry.d.ts +33 -0
  354. package/dist/source-control/site/bundled-provider-registry.js +37 -0
  355. package/dist/source-control/site/commit-schema.d.ts +40 -0
  356. package/dist/source-control/site/commit-schema.js +29 -0
  357. package/dist/source-control/site/commit-target.d.ts +26 -0
  358. package/dist/source-control/site/commit-target.js +58 -0
  359. package/dist/source-control/site/credential-form.d.ts +36 -0
  360. package/dist/source-control/site/credential-form.js +102 -0
  361. package/dist/source-control/site/credential-setup.d.ts +107 -0
  362. package/dist/source-control/site/credential-setup.js +216 -0
  363. package/dist/source-control/site/provider-kit.d.ts +37 -0
  364. package/dist/source-control/site/provider-kit.js +35 -0
  365. package/dist/source-control/site/provider-module.d.ts +251 -0
  366. package/dist/source-control/site/provider-module.js +2 -0
  367. package/dist/source-control/site/saved-key-bindings.d.ts +4 -0
  368. package/dist/source-control/site/saved-key-bindings.js +4 -0
  369. package/dist/source-control/site/static-site-packager-port.d.ts +37 -0
  370. package/dist/source-control/site/static-site-packager-port.js +2 -0
  371. package/dist/source-control/site/store.d.ts +209 -0
  372. package/dist/source-control/site/store.js +374 -0
  373. package/dist/source-control/site/store.validation.d.ts +72 -0
  374. package/dist/source-control/site/store.validation.js +168 -0
  375. package/dist/source-control/site/tool-registrations.d.ts +190 -0
  376. package/dist/source-control/site/tool-registrations.js +379 -0
  377. package/dist/static-export/asset-crawl.d.ts +30 -0
  378. package/dist/static-export/asset-crawl.js +71 -0
  379. package/dist/static-export/dynamic-asset-locations.d.ts +23 -0
  380. package/dist/static-export/dynamic-asset-locations.js +34 -0
  381. package/dist/static-export/html-url-locations.d.ts +3 -1
  382. package/dist/static-export/html-url-locations.js +43 -9
  383. package/dist/static-export/runner.js +26 -27
  384. package/dist/static-export/site/export-preflight.d.ts +48 -0
  385. package/dist/static-export/site/export-preflight.js +82 -0
  386. package/dist/static-export/site/media-original-urls.d.ts +57 -0
  387. package/dist/static-export/site/media-original-urls.js +109 -0
  388. package/dist/static-export/site/ports.d.ts +82 -0
  389. package/dist/static-export/site/ports.js +29 -0
  390. package/dist/static-export/site/public-origin-policy.d.ts +32 -0
  391. package/dist/static-export/site/public-origin-policy.js +68 -0
  392. package/dist/static-export/site/route-manifest.d.ts +65 -0
  393. package/dist/static-export/site/route-manifest.js +139 -0
  394. package/dist/static-export/site/site-exporter.d.ts +158 -0
  395. package/dist/static-export/site/site-exporter.js +112 -0
  396. package/dist/static-export/site/static-security-headers.d.ts +39 -0
  397. package/dist/static-export/site/static-security-headers.js +43 -0
  398. package/dist/static-export/site/theme-preview-manifest.d.ts +35 -0
  399. package/dist/static-export/site/theme-preview-manifest.js +28 -0
  400. package/dist/static-export/transforms.d.ts +1 -1
  401. package/dist/static-export/transforms.js +3 -3
  402. package/package.json +911 -7
@@ -0,0 +1,595 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstat, mkdtemp, readdir, readFile, realpath, rm, stat, unlink } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { describeErrorForLog } from "@jini-ai/core/model-facing-tool-errors";
5
+ import { SiteShareRefusal } from "./share-refusal.js";
6
+ /** Every scope, in the fixed order the manifest and the confirmation dialog list them. */
7
+ export const SITE_BACKUP_SCOPES = ["database", "media", "themes", "plugins", "settings"];
8
+ const MIB = 1024 * 1024;
9
+ /** Where the database snapshot lives inside the backup folder (the manifest's own path is the host's). */
10
+ export const SITE_BACKUP_DATABASE_PATH = "database/content.db";
11
+ /** Names never backed up wherever they appear. `.publish-staging`/`.publish-previous` are
12
+ * theme-files publish's own scratch and replaced-tree copies (`features/theme/publish-content.ts`) —
13
+ * a backup must never capture a half-staged tree. `.storage-secret.json` is a Postgres site's sealed
14
+ * connection string (`storage-secret.ts`): it lives in the site root, which no scope walks, and is
15
+ * named here for repository backups too. The share profile retains nested copies with warnings. */
16
+ const IGNORED_NAMES = new Set([".DS_Store", ".git", ".publish-staging", ".publish-previous", ".storage-secret.json"]);
17
+ const SYMLINK_REASON = "a symbolic link — never followed, so nothing outside the site can ride along";
18
+ const WALK_FILE_SYSTEM = {
19
+ lstat: ({ file }) => lstat(file),
20
+ lstatBigInt: ({ file }, _optional = {}) => lstat(file, { bigint: true }),
21
+ readdir: ({ dir }, _optional = {}) => readdir(dir, { withFileTypes: true }),
22
+ };
23
+ function isMissing({ err }, _optional = {}) {
24
+ return typeof err === "object" && err !== null && err.code === "ENOENT";
25
+ }
26
+ /** `readdir` that treats a folder that doesn't exist as empty: a site with no themes folder yet has
27
+ * nothing to back up there, which is not an error. */
28
+ async function readdirOrEmpty({ dir, fileSystem }, _optional = {}) {
29
+ try {
30
+ return await fileSystem.readdir({ dir });
31
+ }
32
+ catch (err) {
33
+ if (isMissing({ err }))
34
+ return [];
35
+ throw err;
36
+ }
37
+ }
38
+ /**
39
+ * Adds one regular file to the sink, or records why it was left out. `lstat`, never `stat`: a
40
+ * symlink's own metadata, never its target's.
41
+ *
42
+ * @complexity O(1) — two metadata reads, the second preserving bigint file identity.
43
+ */
44
+ async function addFile(sink, input) {
45
+ if (sink.profile === "share" && sink.deps.sharePolicy.excludedSharePath({ path: input.relPath }, { notices: sink.notices }))
46
+ return;
47
+ let info;
48
+ try {
49
+ info = await sink.fileSystem.lstat({ file: input.absPath });
50
+ }
51
+ catch (err) {
52
+ if (isMissing({ err }))
53
+ return;
54
+ throw err;
55
+ }
56
+ if (info.isSymbolicLink()) {
57
+ sink.skipped.push({ path: input.relPath, reason: SYMLINK_REASON });
58
+ return;
59
+ }
60
+ if (!info.isFile()) {
61
+ sink.skipped.push({ path: input.relPath, reason: "not a regular file" });
62
+ return;
63
+ }
64
+ checkShareFile({ sink, relPath: input.relPath, info });
65
+ const ids = await sink.fileSystem.lstatBigInt({ file: input.absPath }).catch(err => isMissing({ err }) ? null : Promise.reject(err));
66
+ if (ids === null)
67
+ return;
68
+ sink.files.push({ path: input.relPath, bytes: info.size, scope: input.scope, root: input.root, absPath: input.absPath, mtimeMs: info.mtimeMs, identity: sink.deps.reviewedFileIdentity({ info: ids }), nlink: info.nlink });
69
+ }
70
+ /** Sharing refuses existing hardlinks; ordinary backups can preserve files already linked at plan time. */
71
+ function checkShareFile({ sink, relPath, info }, _options = {}) {
72
+ if (sink.profile !== "share")
73
+ return;
74
+ sink.deps.sharePolicy.validateSharePath({ path: relPath });
75
+ if (info.nlink > 1)
76
+ throw new SiteShareRefusal({ code: "UNSAFE_FILE", message: `Share refuses hardlinked file '${relPath}'.` });
77
+ sink.deps.sharePolicy.checkShareLimits({ files: [...sink.files, { path: relPath, bytes: info.size }] });
78
+ }
79
+ /**
80
+ * Recursively adds every regular file under `absDir`. Symlinks (to files or folders) are reported
81
+ * and never entered; {@link IGNORED_NAMES} are dropped silently; `excludeTopLevel` names are dropped
82
+ * at the first level only (`uploads/chat-attachments`).
83
+ *
84
+ * @complexity O(entries under `absDir`) filesystem calls; recursion depth is the folder depth.
85
+ */
86
+ async function walkTree(sink, input) {
87
+ if (sink.profile === "share" && !(await enterShareDirectory({ sink, absDir: input.absDir, relDir: input.relDir })))
88
+ return;
89
+ const entries = await readdirOrEmpty({ dir: input.absDir, fileSystem: sink.fileSystem });
90
+ for (const entry of entries) {
91
+ if (skippedWalkEntry({ sink, relDir: input.relDir, name: entry.name }, { excludeTopLevel: input.excludeTopLevel }))
92
+ continue;
93
+ await walkEntry({ sink, entry, root: input.root ?? input.absDir, absDir: input.absDir, relDir: input.relDir, scope: input.scope });
94
+ }
95
+ }
96
+ /** Share profile: a private folder is not entered, a missing one is empty, a linked or special one refuses. */
97
+ async function enterShareDirectory(required) {
98
+ if (required.sink.deps.sharePolicy.excludedSharePath({ path: required.relDir }, { notices: required.sink.notices }))
99
+ return false;
100
+ const info = await required.sink.fileSystem.lstat({ file: required.absDir }).catch(err => isMissing({ err }) ? null : Promise.reject(err));
101
+ if (!info)
102
+ return false;
103
+ if (!info.isDirectory() || info.isSymbolicLink())
104
+ throw new SiteShareRefusal({ code: "UNSAFE_FILE", message: `Share refuses linked or special directory '${required.relDir}'.` });
105
+ required.sink.deps.sharePolicy.validateSharePath({ path: required.relDir });
106
+ return true;
107
+ }
108
+ function skippedWalkEntry(required, optional) {
109
+ const { name } = required;
110
+ // Finder writes .DS_Store into any folder it opens; it is junk, never content, so drop it before the share refusal list sees it.
111
+ if (name === ".DS_Store")
112
+ return true;
113
+ if (required.sink.profile === "share" && required.sink.deps.sharePolicy.excludedSharePath({ path: `${required.relDir}/${name}` }, { notices: required.sink.notices }))
114
+ return true;
115
+ // A nested credential file is archive content in the share profile; its scan only warns.
116
+ const ignored = IGNORED_NAMES.has(name) && !(required.sink.profile === "share" && name === ".storage-secret.json");
117
+ return ignored || optional.excludeTopLevel?.has(name) === true;
118
+ }
119
+ async function walkEntry(required) {
120
+ const { sink, entry, root, scope } = required;
121
+ const absPath = path.join(required.absDir, entry.name);
122
+ const relPath = `${required.relDir}/${entry.name}`;
123
+ if (entry.isSymbolicLink()) {
124
+ sink.skipped.push({ path: relPath, reason: SYMLINK_REASON });
125
+ }
126
+ else if (entry.isDirectory()) {
127
+ await walkTree(sink, { root, absDir: absPath, relDir: relPath, scope });
128
+ }
129
+ else {
130
+ await addFile(sink, { root, absPath, relPath, scope });
131
+ }
132
+ }
133
+ /** The files each installed-plugin workspace keeps that a restore needs. Everything else there is
134
+ * left out on purpose: `data/` holds plugin OAuth tokens, `staging/` is a half-finished install,
135
+ * and `packages/superseded-*` are replaced versions. */
136
+ const PLUGIN_WORKSPACE_FILES = new Set(["activations.json", "bundled-digests.json"]);
137
+ /** `agent-plugins/<path under the layout root>`, `/`-separated. */
138
+ function agentPluginsRelPath({ layout, absPath }, _optional = {}) {
139
+ return ["agent-plugins", ...path.relative(layout.root, absPath).split(path.sep)].join("/");
140
+ }
141
+ /**
142
+ * Walks `absDir` only when it, and every folder between `baseDir` and it, is a real directory: a
143
+ * symlinked `package/` or `memory/` is reported, never entered, and a missing one is nothing to
144
+ * back up.
145
+ *
146
+ * @complexity O(depth from `baseDir`) `lstat`s, plus the walk itself.
147
+ */
148
+ async function walkOwnedDir(sink, input) {
149
+ let current = input.baseDir;
150
+ for (const segment of path.relative(input.baseDir, input.absDir).split(path.sep)) {
151
+ current = path.join(current, segment);
152
+ const info = await sink.fileSystem.lstat({ file: current }).catch((err) => (isMissing({ err }) ? null : Promise.reject(err)));
153
+ if (info === null)
154
+ return;
155
+ if (info.isSymbolicLink()) {
156
+ sink.skipped.push({ path: agentPluginsRelPath({ layout: input.layout, absPath: current }), reason: SYMLINK_REASON });
157
+ return;
158
+ }
159
+ if (!info.isDirectory())
160
+ return;
161
+ }
162
+ await walkTree(sink, { root: input.layout.workspacesDir, absDir: input.absDir, relDir: agentPluginsRelPath({ layout: input.layout, absPath: input.absDir }), scope: "plugins" });
163
+ }
164
+ /**
165
+ * The plugins scope's `agent-plugins/` half: per workspace, {@link PLUGIN_WORKSPACE_FILES}, the
166
+ * legacy flat `packages/sha256/**` store (a site not yet migrated to per-plugin folders still has its
167
+ * packages there), and per installed plugin its `package/sha256/**` store and its learned/notes
168
+ * memory — nothing else. Memory is included because it is the site's own record (uninstall offers to
169
+ * keep it); a plugin's `data/` is not, since it holds OAuth tokens. Every path comes from
170
+ * `layout`'s helpers, the same ones the installer writes through.
171
+ *
172
+ * @complexity O(entries under each included folder).
173
+ */
174
+ async function walkAgentPlugins(sink, layout) {
175
+ for (const entry of await readdirOrEmpty({ dir: layout.workspacesDir, fileSystem: sink.fileSystem })) {
176
+ const workspace = installerWorkspace({ sink, layout, entry });
177
+ if (workspace)
178
+ await walkPluginWorkspace({ sink, layout, workspace });
179
+ }
180
+ }
181
+ /** The workspace folder `entry` names, or `null` (reported when it is a link or a foreign folder). */
182
+ function installerWorkspace(required) {
183
+ const { sink, layout, entry } = required;
184
+ const absWorkspace = path.join(layout.workspacesDir, entry.name);
185
+ if (entry.isSymbolicLink()) {
186
+ sink.skipped.push({ path: agentPluginsRelPath({ layout, absPath: absWorkspace }), reason: SYMLINK_REASON });
187
+ return null;
188
+ }
189
+ if (!entry.isDirectory())
190
+ return null;
191
+ let workspace;
192
+ try {
193
+ workspace = layout.forWorkspace({ workspaceId: entry.name });
194
+ }
195
+ catch {
196
+ workspace = null;
197
+ }
198
+ // A folder the installer could never have written (an invalid id, or one that only resolves
199
+ // after case-folding to a different folder) is reported rather than walked under a guessed shape.
200
+ if (workspace === null || workspace.root !== absWorkspace) {
201
+ sink.skipped.push({ path: agentPluginsRelPath({ layout, absPath: absWorkspace }), reason: "not a workspace folder the plugin installer writes" });
202
+ return null;
203
+ }
204
+ return workspace;
205
+ }
206
+ async function walkPluginWorkspace(required) {
207
+ const { sink, layout, workspace } = required;
208
+ for (const name of PLUGIN_WORKSPACE_FILES) {
209
+ const absPath = path.join(workspace.root, name);
210
+ await addFile(sink, { root: layout.workspacesDir, absPath, relPath: agentPluginsRelPath({ layout, absPath }), scope: "plugins" });
211
+ }
212
+ await walkOwnedDir(sink, { layout, baseDir: workspace.root, absDir: workspace.packages });
213
+ for (const pluginEntry of await readdirOrEmpty({ dir: workspace.root, fileSystem: sink.fileSystem }))
214
+ await walkInstalledPlugin({ sink, layout, workspace, pluginEntry });
215
+ }
216
+ async function walkInstalledPlugin(required) {
217
+ const { sink, layout, workspace, pluginEntry } = required;
218
+ if (PLUGIN_WORKSPACE_FILES.has(pluginEntry.name) || (!pluginEntry.isDirectory() && !pluginEntry.isSymbolicLink()))
219
+ return;
220
+ let pluginRoot;
221
+ try {
222
+ pluginRoot = workspace.pluginRootDir({ pluginId: pluginEntry.name });
223
+ }
224
+ catch {
225
+ return; // `staging/`, `packages/`, `data/` and anything not named like a plugin id.
226
+ }
227
+ if (pluginEntry.isSymbolicLink()) {
228
+ sink.skipped.push({ path: agentPluginsRelPath({ layout, absPath: pluginRoot }), reason: SYMLINK_REASON });
229
+ return;
230
+ }
231
+ const pluginId = pluginEntry.name;
232
+ for (const absDir of [
233
+ workspace.pluginPackagesDir({ pluginId }),
234
+ workspace.pluginMemoryDir({ pluginId, kind: "learned" }),
235
+ workspace.pluginMemoryDir({ pluginId, kind: "notes" }),
236
+ ]) {
237
+ await walkOwnedDir(sink, { layout, baseDir: pluginRoot, absDir });
238
+ }
239
+ }
240
+ /**
241
+ * Every file on disk the switched-on scopes pick up. The database scope is never a disk walk — see
242
+ * {@link captureDatabaseSnapshot}.
243
+ *
244
+ * @returns `files` sorted by path, `skipped` (symlinks and non-regular files, each with its reason),
245
+ * and `scopeNotes` for a scope whose content could not be collected here at all.
246
+ * @throws SiteShareRefusal for unsafe share files or stale themes, or an unexpected filesystem error
247
+ * (a missing folder is treated as empty).
248
+ * @complexity O(entries + shared theme bytes), plus O(n log n) to sort n files.
249
+ */
250
+ export async function collectSiteBackupFiles(input, optional = {}) {
251
+ const { sources, include } = input;
252
+ const notices = [];
253
+ const sink = { deps: input.deps, files: [], skipped: [], notices, fileSystem: optional.fileSystem ?? WALK_FILE_SYSTEM, ...(optional.profile ? { profile: optional.profile } : {}) };
254
+ const scopeNotes = {};
255
+ if (include.media)
256
+ await collectMediaScope({ sink, sources, scopeNotes });
257
+ if (include.themes)
258
+ await walkTree(sink, { absDir: sources.themesDir, relDir: "themes", scope: "themes" });
259
+ if (include.plugins)
260
+ await collectPluginScope({ sink, sources });
261
+ if (sink.profile === "share") {
262
+ await collectShareOnlyTrees({ sink, sources, include, scopeNotes });
263
+ await pinShareThemeFiles({ sink, siteDir: sources.siteDir });
264
+ }
265
+ if (include.settings) {
266
+ for (const name of ["config.json", ".site-meta.json"]) {
267
+ await addFile(sink, { root: sources.siteDir, absPath: path.join(sources.siteDir, name), relPath: `settings/${name}`, scope: "settings" });
268
+ }
269
+ }
270
+ sink.files.sort(byPath);
271
+ return { files: sink.files, skipped: sink.skipped, scopeNotes, notices };
272
+ }
273
+ /** Pins share themes and overrides through the same no-linked-ancestor read as site plugins.
274
+ * Canonicalize only the trusted site root (macOS's /var can be a link), never the walked descendants.
275
+ * @throws SiteShareRefusal PLAN_STALE when a theme cannot be read as planned.
276
+ * @complexity O(files + theme bytes), one verified read and hash per theme; O(largest theme) bytes.
277
+ */
278
+ async function pinShareThemeFiles(required) {
279
+ const { files } = required.sink;
280
+ if (!files.some(file => file.scope === "themes"))
281
+ return;
282
+ const root = await realpath(required.siteDir);
283
+ const sitePrefix = path.resolve(required.siteDir) + path.sep;
284
+ for (const [index, file] of files.entries()) {
285
+ if (file.scope !== "themes")
286
+ continue;
287
+ // Packaged originals can live outside the site; trust their package root, not the site root.
288
+ // Canonicalize that root once; descendants must still pass the no-linked-ancestor read.
289
+ const inSite = file.absPath.startsWith(sitePrefix);
290
+ const scopeRoot = inSite ? root : await realpath(file.root);
291
+ const relative = path.relative(inSite ? required.siteDir : file.root, file.absPath);
292
+ const planned = { ...file, absPath: path.join(scopeRoot, relative), root: scopeRoot };
293
+ const read = await readDiskFile(planned, { deps: required.sink.deps, unlinkedPath: true });
294
+ if (!read.ok)
295
+ throw new SiteShareRefusal({ code: "PLAN_STALE", message: read.message });
296
+ files[index] = { ...planned, sha256: sha256Hex({ bytes: read.bytes }) };
297
+ }
298
+ }
299
+ /** Code-unit order: -1, 0 or 1, the same as `a < b ? -1 : a > b ? 1 : 0`. */
300
+ function byPath(a, b) {
301
+ return Number(a.path > b.path) - Number(a.path < b.path);
302
+ }
303
+ /** The uploads folder, minus chat attachments; object-storage media is noted, never silently empty. */
304
+ async function collectMediaScope(required) {
305
+ const { mediaUploadsDir, isMediaRemote } = required.sources;
306
+ if (mediaUploadsDir === null || (await isMediaRemote?.()))
307
+ required.scopeNotes.media = required.sink.deps.mediaInObjectStorageNote;
308
+ else
309
+ await walkTree(required.sink, { absDir: mediaUploadsDir, relDir: "uploads", scope: "media", excludeTopLevel: new Set(["chat-attachments"]) });
310
+ }
311
+ /** Installed agent plugins and skills; a share first refuses a linked or special plugin root. */
312
+ async function collectPluginScope(required) {
313
+ const { sink, sources } = required;
314
+ if (sink.profile === "share") {
315
+ for (const root of [sources.agentPlugins.root, sources.agentPlugins.workspacesDir]) {
316
+ const info = await sink.fileSystem.lstat({ file: root }).catch(err => isMissing({ err }) ? null : Promise.reject(err));
317
+ if (info && (!info.isDirectory() || info.isSymbolicLink()))
318
+ throw new SiteShareRefusal({ code: "UNSAFE_FILE", message: "Share refuses a linked plugin root." });
319
+ }
320
+ }
321
+ await walkAgentPlugins(sink, sources.agentPlugins);
322
+ await walkTree(sink, { absDir: sources.skillsDir, relDir: "skills", scope: "plugins" });
323
+ }
324
+ /** Site-local plugin packages and theme overrides travel only in a share. */
325
+ async function collectShareOnlyTrees(required) {
326
+ const { sink, sources, include } = required;
327
+ if (include.plugins)
328
+ await walkSitePlugins(required);
329
+ if (include.themes)
330
+ await walkTree(sink, { absDir: path.join(sources.siteDir, "overrides"), relDir: "overrides", scope: "themes" });
331
+ }
332
+ /**
333
+ * Site plugins exactly as Jini lays them out: for each folder in the install dir, the files
334
+ * `listSitePluginPackage` names for its valid, pinned discovery record (manifest plus integrity files),
335
+ * as `plugins/<id>/package/<path>`. Nothing else under the folder is walked, so no folder name, missing
336
+ * manifest or fallen-forward pin can turn data/ or private memory into package content. A folder that
337
+ * is not a valid installed plugin, or whose files fail their checks, ships nothing and is named in the
338
+ * plugins scope note; the export carries on (the owner never has to repair a folder by hand).
339
+ * @complexity O(install-dir entries + listed files), one read and hash per listed file.
340
+ */
341
+ async function walkSitePlugins(required) {
342
+ const { sink, sources } = required;
343
+ const { installDir, records } = await sources.sitePlugins?.() ?? { installDir: path.join(sources.siteDir, "plugins"), records: [] };
344
+ if (!(await enterShareDirectory({ sink, absDir: installDir, relDir: "plugins" })))
345
+ return;
346
+ const leftOut = [];
347
+ for (const { name } of await readdirOrEmpty({ dir: installDir, fileSystem: sink.fileSystem })) {
348
+ if (name.startsWith("."))
349
+ continue; // Jini's own staging (`.drafts`) and Finder files; never a plugin.
350
+ const record = records.find(candidate => candidate.source === "site" && candidate.id === name);
351
+ const files = record && await sitePluginPackageFiles({ sink, installDir, record });
352
+ if (files)
353
+ sink.files.push(...files);
354
+ else
355
+ leftOut.push(name);
356
+ }
357
+ if (leftOut.length > 0)
358
+ required.scopeNotes.plugins = `Left out because they aren't valid installed plugins (damaged manifest, version not installed, or changed files): ${leftOut.sort().map(name => "'" + name + "'").join(", ")}.`;
359
+ }
360
+ /** One plugin's planned files, each through the walk's guards, read once through no linked folder and
361
+ * checked against its integrity sha256, then pinned to the bytes read (the manifest too) so the ZIP
362
+ * carries exactly them; `null` when Jini will not list it or any listed file is missing, linked,
363
+ * excluded or changed. */
364
+ async function sitePluginPackageFiles(required) {
365
+ const { record } = required;
366
+ // A damaged or changed package is omitted and reported in the backup scope notes.
367
+ const listed = await required.sink.deps.listSitePluginPackage({ installDir: required.installDir, record }).catch((error) => {
368
+ if (!required.sink.deps.isPluginPackagePathError(error))
369
+ console.error("[site-backup] Could not inspect an installed plugin", describeErrorForLog({ err: error }));
370
+ return null;
371
+ });
372
+ if (listed === null)
373
+ return null;
374
+ const staged = { ...required.sink, files: [], skipped: [] };
375
+ for (const file of listed.files) {
376
+ await addFile(staged, { root: listed.rootDir, absPath: path.join(listed.rootDir, file.relativePath), relPath: `plugins/${record.id}/package/${file.relativePath}`, scope: "plugins" });
377
+ }
378
+ // addFile adds nothing for a missing, excluded, linked or non-regular file, so a short list is every refusal.
379
+ if (staged.files.length !== listed.files.length)
380
+ return null;
381
+ return pinSitePluginFiles({ files: staged.files, listed: listed.files, deps: required.sink.deps });
382
+ }
383
+ async function pinSitePluginFiles({ files, listed, deps }, _optional = {}) {
384
+ const pinned = [];
385
+ for (const [index, planned] of files.entries()) {
386
+ const listedFile = listed[index];
387
+ if (listedFile === undefined)
388
+ throw new Error(`Backup source inventory has no file at index ${index}`);
389
+ const expected = listedFile.sha256;
390
+ const read = await readDiskFile(planned, { deps, unlinkedPath: true });
391
+ const sha256 = read.ok ? sha256Hex({ bytes: read.bytes }) : null;
392
+ if (sha256 === null || (expected !== null && sha256 !== expected))
393
+ return null;
394
+ pinned.push({ ...planned, sha256 });
395
+ }
396
+ return pinned;
397
+ }
398
+ function sha256Hex({ bytes }, _optional = {}) {
399
+ return createHash("sha256").update(bytes).digest("hex");
400
+ }
401
+ const SNAPSHOT_FAILED = "the database snapshot failed; nothing was backed up";
402
+ /**
403
+ * A consistent copy of the whole site database, held in memory.
404
+ *
405
+ * Only a cheap file snapshot (SQLite) is accepted: that is the only restore mechanism whose artifact
406
+ * is a single file this process can read back. Anything else is refused BEFORE a capture is attempted.
407
+ * The restore-point file `captureRestorePoint` writes (beside `content.db`, or inside a fresh private
408
+ * folder under `optional.snapshotRoot`) is deleted as soon as it is read, success or not, so a backup
409
+ * never leaves one behind. A site export passes `snapshotRoot` so it never writes into source-site storage.
410
+ *
411
+ * @returns The snapshot bytes and the watermark stamped at capture, or a caller-safe `message` (a
412
+ * capture failure's own text stays in `logDetail`, which is for the server log only).
413
+ * @complexity O(database size) — one full copy, one read, one unlink.
414
+ */
415
+ export async function captureDatabaseSnapshot(input, optional = {}) {
416
+ const { restorePoint } = await input.dbOps.getCapabilities();
417
+ if (restorePoint.costClass !== "cheap" || restorePoint.kind !== "file-snapshot") {
418
+ return {
419
+ ok: false,
420
+ message: `this site's database cannot be snapshotted into a backup file: only SQLite sites are supported (this database reports a '${restorePoint.kind}' restore mechanism)`,
421
+ };
422
+ }
423
+ if (optional.tempRoot) {
424
+ // The restore-point read happens inside `work`: the host-owned root stays locked until the bytes are
425
+ // in memory, so the host's temp-root tidy can never remove the snapshot while it is still being read.
426
+ const scope = optional.tempRoot;
427
+ try {
428
+ return await scope({ work: ({ root }) => readRestorePoint(input, { ...(optional.maxBytes !== undefined ? { maxBytes: optional.maxBytes } : {}), directory: root }) });
429
+ }
430
+ catch (err) {
431
+ return { ok: false, message: SNAPSHOT_FAILED, logDetail: describeErrorForLog({ err }) };
432
+ }
433
+ }
434
+ if (optional.snapshotRoot === undefined)
435
+ return readRestorePoint(input, optional);
436
+ let directory;
437
+ try {
438
+ directory = await mkdtemp(path.join(optional.snapshotRoot, input.snapshotDirPrefix));
439
+ }
440
+ catch (err) {
441
+ return { ok: false, message: SNAPSHOT_FAILED, logDetail: describeErrorForLog({ err }) };
442
+ }
443
+ try {
444
+ return await readRestorePoint(input, { ...optional, directory });
445
+ }
446
+ finally {
447
+ await rm(directory, { recursive: true, force: true }).catch((error) => console.error("[site-backup] Could not remove the snapshot directory", describeErrorForLog({ err: error })));
448
+ }
449
+ }
450
+ /** Captures one restore point (into `directory` when given), reads it back and unlinks it. */
451
+ async function readRestorePoint(input, optional) {
452
+ let artifactRef;
453
+ let watermarkAtCapture;
454
+ try {
455
+ const scope = { scopeId: input.scopeId };
456
+ ({ artifactRef, watermarkAtCapture } = await (optional.directory === undefined ? input.dbOps.captureRestorePoint(scope) : input.dbOps.captureRestorePoint(scope, { directory: optional.directory })));
457
+ }
458
+ catch (err) {
459
+ return { ok: false, message: SNAPSHOT_FAILED, logDetail: describeErrorForLog({ err }) };
460
+ }
461
+ try {
462
+ if (optional.maxBytes !== undefined && (await stat(artifactRef)).size > optional.maxBytes)
463
+ return { ok: false, message: "Database snapshot exceeds the 300 MiB share cap." };
464
+ return { ok: true, bytes: await readFile(artifactRef), watermarkAtCapture };
465
+ }
466
+ catch (err) {
467
+ return { ok: false, message: "the database snapshot could not be read back; nothing was backed up", logDetail: describeErrorForLog({ err }) };
468
+ }
469
+ finally {
470
+ await unlink(artifactRef).catch((error) => {
471
+ // An already removed snapshot needs no further cleanup.
472
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
473
+ console.error("[site-backup] Could not remove the snapshot", describeErrorForLog({ err: error }));
474
+ });
475
+ }
476
+ }
477
+ /** One decimal place, dropped when it is `.0` (`100 MiB`, not `100.0 MiB`). */
478
+ function oneDecimal({ value }, _optional = {}) {
479
+ return value.toFixed(1).replace(/\.0$/, "");
480
+ }
481
+ /** `123 B`, `4.2 KiB`, `12.5 MiB`, `1 GiB` — for messages and the confirmation dialog. */
482
+ export function formatByteSize({ bytes }, _optional = {}) {
483
+ if (bytes < 1024)
484
+ return `${bytes} B`;
485
+ if (bytes < MIB)
486
+ return `${oneDecimal({ value: bytes / 1024 })} KiB`;
487
+ if (bytes < 1024 * MIB)
488
+ return `${oneDecimal({ value: bytes / MIB })} MiB`;
489
+ return `${oneDecimal({ value: bytes / (1024 * MIB) })} GiB`;
490
+ }
491
+ /**
492
+ * Leaves out every disk file over the host's per-file limit, each named in `skipped` with its size,
493
+ * so one huge video does not cost the whole backup (2026-10-06: the owner asked for a full backup
494
+ * that just works). The database is not a disk file here: an oversized snapshot still fails the plan
495
+ * in {@link checkSiteBackupLimits}, because a backup without its database is not a backup.
496
+ *
497
+ * @complexity O(n).
498
+ */
499
+ export function skipOversizedFiles({ files, host }, _optional = {}) {
500
+ const maxFileBytes = host.maxFileBytes;
501
+ if (maxFileBytes === undefined)
502
+ return { files: [...files], skipped: [] };
503
+ const skipped = files
504
+ .filter((file) => file.bytes > maxFileBytes)
505
+ .map((file) => ({ path: file.path, reason: `${formatByteSize({ bytes: file.bytes })}, over ${host.label}'s ${formatByteSize({ bytes: maxFileBytes })} per-file limit` }));
506
+ return { files: files.filter((file) => file.bytes <= maxFileBytes), skipped };
507
+ }
508
+ /**
509
+ * Checks a backup against `limits` (the host's own caps) and the host's own per-file limit (when its
510
+ * plugin declares one) before anything is uploaded. A file over the per-file limit is refused, never truncated or split — and EVERY such file is named, so one retry
511
+ * after removing them is enough. The plan runs {@link skipOversizedFiles} over the disk files first,
512
+ * so in practice only an oversized database snapshot reaches this refusal.
513
+ *
514
+ * @complexity O(n) in the file count.
515
+ */
516
+ export function checkSiteBackupLimits({ files, host, limits }, _optional = {}) {
517
+ const maxFileBytes = host.maxFileBytes;
518
+ const oversized = maxFileBytes === undefined ? [] : files.filter((file) => file.bytes > maxFileBytes);
519
+ if (maxFileBytes !== undefined && oversized.length > 0) {
520
+ // The exact byte count too: a file 1 byte over rounds to the limit's own size.
521
+ const named = oversized.map((file) => `${file.path} (${formatByteSize({ bytes: file.bytes })}, ${file.bytes} bytes)`).join(", ");
522
+ return {
523
+ ok: false,
524
+ message: `${oversized.length} file(s) exceed ${host.label}'s ${formatByteSize({ bytes: maxFileBytes })} per-file limit and cannot be backed up: ${named}. Nothing is truncated or split; remove or shrink these, or turn off the scope that holds them.`,
525
+ };
526
+ }
527
+ if (files.length > limits.maxFiles) {
528
+ return { ok: false, message: `the backup has ${files.length} files, over the ${limits.maxFiles}-file cap. Turn off a scope (media usually holds the most files) and plan again.` };
529
+ }
530
+ const totalBytes = files.reduce((sum, file) => sum + file.bytes, 0);
531
+ if (totalBytes > limits.maxTotalBytes) {
532
+ return { ok: false, message: `the backup totals ${formatByteSize({ bytes: totalBytes })}, over the ${formatByteSize({ bytes: limits.maxTotalBytes })} cap. Turn off a scope (media usually holds the most bytes) and plan again.` };
533
+ }
534
+ return { ok: true, totalBytes };
535
+ }
536
+ /**
537
+ * Reads a planned file at push time, refusing it if it is no longer the file the human reviewed.
538
+ *
539
+ * Opened with `O_NOFOLLOW` and checked through the SAME handle it is read from, so a file swapped
540
+ * for a symlink after the plan cannot be followed, and the size/mtime compared are the bytes
541
+ * actually read. A file planned with a `sha256` must also still be reached through no linked folder
542
+ * and hash to exactly that digest.
543
+ *
544
+ * @complexity O(file size + path depth) — Jini proves identity and plain ancestry; pinned files add a hash.
545
+ */
546
+ export async function readPlannedFile(file, optional) {
547
+ const read = await readDiskFile(file, { ...optional, unlinkedPath: file.sha256 !== undefined });
548
+ return read.ok && file.sha256 !== undefined && sha256Hex({ bytes: read.bytes }) !== file.sha256 ? staleResult(file) : read;
549
+ }
550
+ function staleResult(file) {
551
+ return { ok: false, message: `'${file.path}' changed since the plan was made. Call site_backup_plan again.` };
552
+ }
553
+ /** The one disk read behind planning checks and push: `unlinkedPath` also refuses an `absPath` whose
554
+ * realpath differs, i.e. one reached through a linked folder (`O_NOFOLLOW` guards only the last name). */
555
+ async function readDiskFile(file, optional) {
556
+ // Preserve the stricter absolute-path check for pinned package/theme bytes.
557
+ if (optional.unlinkedPath && (await realpath(file.absPath).catch((error) => {
558
+ // Removed paths and broken links are an ordinary stale-plan refusal.
559
+ if (!(error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR" || error.code === "ELOOP")))
560
+ console.error("[site-backup] Could not resolve the planned file", describeErrorForLog({ err: error }));
561
+ return null;
562
+ })) !== file.absPath)
563
+ return staleResult(file);
564
+ const fileSystem = optional.fileSystem ?? (optional.openFile ? {
565
+ open: optional.openFile, lstat: (file) => lstat(file, { bigint: true }), realpath,
566
+ } : undefined);
567
+ const bytes = await optional.deps.readReviewedFile({ file }, { fileSystem });
568
+ return bytes === null ? staleResult(file) : { ok: true, bytes };
569
+ }
570
+ /**
571
+ * The backup's manifest file: what produced it (the host's version, migration schema), when, which
572
+ * scopes it holds and why any is incomplete, and every file with its sha256 — what a future restore
573
+ * checks before touching anything.
574
+ *
575
+ * @complexity O(n) in the file count.
576
+ */
577
+ export function buildSiteBackupManifest(input, identity) {
578
+ const scopes = Object.fromEntries(SITE_BACKUP_SCOPES.map((scope) => {
579
+ const note = input.scopeNotes[scope];
580
+ return [scope, { included: input.include[scope], ...(note !== undefined ? { note } : {}) }];
581
+ }));
582
+ const manifest = {
583
+ format: identity.format,
584
+ formatVersion: 1,
585
+ createdAt: input.createdAt,
586
+ [identity.producerKey]: { version: input.hostVersion },
587
+ schema: { index: input.schema.index, tag: input.schema.tag },
588
+ site: { name: input.site.name, folderName: input.site.folderName },
589
+ database: input.database === null ? null : { path: SITE_BACKUP_DATABASE_PATH, engine: "sqlite", watermarkAtCapture: input.database.watermarkAtCapture },
590
+ scopes,
591
+ files: input.files.map((file) => ({ path: file.path, bytes: file.bytes, sha256: file.sha256 })),
592
+ };
593
+ return `${JSON.stringify(manifest, null, 2)}\n`;
594
+ }
595
+ //# sourceMappingURL=sources.js.map