@rebasepro/cli 0.30.1 → 0.31.0-canary.g902a0ce

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 (283) hide show
  1. package/README.md +8 -7
  2. package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
  3. package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
  4. package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
  5. package/dist/api-keys-eIUjMqWn.js.map +1 -0
  6. package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
  7. package/dist/apps-DExO4PEl.js.map +1 -0
  8. package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
  9. package/dist/args-CaCcrYE1.js.map +1 -0
  10. package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
  11. package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
  12. package/dist/{auth-Bv0rTbQX.js → auth-CyADghFQ.js} +7 -6
  13. package/dist/{auth-Bv0rTbQX.js.map → auth-CyADghFQ.js.map} +1 -1
  14. package/dist/backend-guard-C0mVkXBw.js +162 -0
  15. package/dist/backend-guard-C0mVkXBw.js.map +1 -0
  16. package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
  17. package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
  18. package/dist/build-CA5R07tw.js.map +1 -0
  19. package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
  20. package/dist/bundle-DgILeA5b.js.map +1 -0
  21. package/dist/bundle.d.ts +35 -12
  22. package/dist/cli.d.ts +2 -2
  23. package/dist/{cloud-DtADfWwn.js → cloud-CYMk92iG.js} +72 -71
  24. package/dist/cloud-CYMk92iG.js.map +1 -0
  25. package/dist/cms-directories-BK3vcswg.js +33 -0
  26. package/dist/cms-directories-BK3vcswg.js.map +1 -0
  27. package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
  28. package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
  29. package/dist/codemod/collections-to-tables/command.d.ts +35 -0
  30. package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
  31. package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
  32. package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
  33. package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
  34. package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
  35. package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
  36. package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
  37. package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
  38. package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
  39. package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
  40. package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
  41. package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
  42. package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
  43. package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
  44. package/dist/codemod/collections-to-tables/own.d.ts +10 -0
  45. package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
  46. package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
  47. package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
  48. package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
  49. package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
  50. package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
  51. package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
  52. package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
  53. package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
  54. package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
  55. package/dist/codemod/collections-to-tables/types.d.ts +164 -0
  56. package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
  57. package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
  58. package/dist/command-D5lhW_-B.js +9984 -0
  59. package/dist/command-D5lhW_-B.js.map +1 -0
  60. package/dist/commands/agent-setup.d.ts +6 -2
  61. package/dist/commands/cloud/context.d.ts +1 -1
  62. package/dist/commands/cloud/init.d.ts +2 -2
  63. package/dist/commands/console.d.ts +1 -2
  64. package/dist/commands/db.d.ts +5 -6
  65. package/dist/commands/dev.d.ts +18 -17
  66. package/dist/commands/doctor.d.ts +4 -5
  67. package/dist/commands/eject.d.ts +17 -13
  68. package/dist/commands/generate-view.d.ts +20 -9
  69. package/dist/commands/generate_sdk.d.ts +27 -27
  70. package/dist/commands/init.d.ts +21 -8
  71. package/dist/commands/migrate.d.ts +24 -0
  72. package/dist/commands/schema-reconcile.d.ts +1 -1
  73. package/dist/commands/skills.d.ts +8 -0
  74. package/dist/commands/verify-cms.d.ts +28 -0
  75. package/dist/commands/verify.d.ts +14 -9
  76. package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
  77. package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
  78. package/dist/{console-CdwIYOMV.js → console-CMjhgMUE.js} +14 -14
  79. package/dist/console-CMjhgMUE.js.map +1 -0
  80. package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
  81. package/dist/context--JwaHaZp.js.map +1 -0
  82. package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
  83. package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
  84. package/dist/{db-DBbKpjYX.js → db-A7XDCIIO.js} +51 -51
  85. package/dist/db-A7XDCIIO.js.map +1 -0
  86. package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
  87. package/dist/derive-C3ezmY-p.js.map +1 -0
  88. package/dist/dev-db/attver.d.ts +11 -0
  89. package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
  90. package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
  91. package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
  92. package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
  93. package/dist/{dev-C93d4QIv.js → dev-tWwPyWkQ.js} +142 -84
  94. package/dist/dev-tWwPyWkQ.js.map +1 -0
  95. package/dist/{doctor-BBPQUO2g.js → doctor-BBM0dWvZ.js} +39 -62
  96. package/dist/doctor-BBM0dWvZ.js.map +1 -0
  97. package/dist/doctor-environment.d.ts +6 -6
  98. package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
  99. package/dist/eject-Bhzd6hgb.js.map +1 -0
  100. package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
  101. package/dist/fold-static-CKewnAPX.js.map +1 -0
  102. package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
  103. package/dist/generate-view-CTOluXvH.js.map +1 -0
  104. package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
  105. package/dist/generate_sdk-De-aLC1L.js.map +1 -0
  106. package/dist/import-schema-module-Df67TIWj.js +51 -0
  107. package/dist/import-schema-module-Df67TIWj.js.map +1 -0
  108. package/dist/index.es.js +64 -51
  109. package/dist/index.es.js.map +1 -1
  110. package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
  111. package/dist/init-Dtl-IcXf.js.map +1 -0
  112. package/dist/last-dev-database-Dc8cP01o.js +2 -0
  113. package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
  114. package/dist/manifest-C3uLDrrJ.js.map +1 -0
  115. package/dist/manifest.d.ts +79 -24
  116. package/dist/migrate-VrKoi3nB.js +138 -0
  117. package/dist/migrate-VrKoi3nB.js.map +1 -0
  118. package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
  119. package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
  120. package/dist/path-flags-7O5uPBcQ.js +139 -0
  121. package/dist/path-flags-7O5uPBcQ.js.map +1 -0
  122. package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
  123. package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
  124. package/dist/project-CLcF5i8c.js +360 -0
  125. package/dist/project-CLcF5i8c.js.map +1 -0
  126. package/dist/project-schema-CsSOG2gE.js +30 -0
  127. package/dist/project-schema-CsSOG2gE.js.map +1 -0
  128. package/dist/{pull-DDMpsZ5r.js → pull-D9WvpDYY.js} +189 -1
  129. package/dist/pull-D9WvpDYY.js.map +1 -0
  130. package/dist/resolve-BY7bSFRT.js +2 -0
  131. package/dist/resources/derive.d.ts +19 -13
  132. package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
  133. package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
  134. package/dist/{schema-DtLPsXbT.js → schema-DwFDI1iU.js} +41 -39
  135. package/dist/schema-DwFDI1iU.js.map +1 -0
  136. package/dist/schema-dir-Cd1kvYbf.js +98 -0
  137. package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
  138. package/dist/schema-reconcile-Tto54Qbv.js +2 -0
  139. package/dist/schema-text-CpNrsuMe.js +73 -0
  140. package/dist/schema-text-CpNrsuMe.js.map +1 -0
  141. package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
  142. package/dist/skills-CXjA9TWw.js.map +1 -0
  143. package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
  144. package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
  145. package/dist/{status-BREvtzJm.js → status-DQ_PPz4C.js} +12 -12
  146. package/dist/status-DQ_PPz4C.js.map +1 -0
  147. package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
  148. package/dist/storage-iTqj5-Av.js.map +1 -0
  149. package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
  150. package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
  151. package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
  152. package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
  153. package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
  154. package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
  155. package/dist/utils/backend-guard.d.ts +47 -0
  156. package/dist/utils/cms-directories.d.ts +6 -0
  157. package/dist/utils/dev-preflight.d.ts +2 -2
  158. package/dist/utils/import-schema-module.d.ts +16 -0
  159. package/dist/utils/path-flags.d.ts +35 -16
  160. package/dist/utils/project-schema.d.ts +40 -0
  161. package/dist/utils/project.d.ts +8 -2
  162. package/dist/utils/schema-dir.d.ts +32 -0
  163. package/dist/utils/schema-drift.d.ts +6 -0
  164. package/dist/utils/schema-text.d.ts +24 -0
  165. package/dist/verify-DkJqhYPI.js +1160 -0
  166. package/dist/verify-DkJqhYPI.js.map +1 -0
  167. package/package.json +11 -8
  168. package/runtime/dev-server.mjs +5 -1
  169. package/templates/eject/Dockerfile +1 -4
  170. package/templates/eject/backend/src/env.ts +1 -1
  171. package/templates/eject/backend/src/index.ts +53 -40
  172. package/templates/eject/docker-compose.custom.yml +1 -1
  173. package/templates/overlays/baas/README.md +39 -12
  174. package/templates/overlays/baas/ai-instructions.md +8 -8
  175. package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
  176. package/templates/overlays/baas/backend/tsconfig.json +10 -12
  177. package/templates/overlays/baas/package.json +1 -2
  178. package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
  179. package/templates/presets/blank/backend/schema/index.ts +19 -0
  180. package/templates/presets/blank/frontend/src/App.tsx +56 -0
  181. package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
  182. package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
  183. package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
  184. package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
  185. package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
  186. package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
  187. package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
  188. package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
  189. package/templates/resource-graphs/blank.json +2 -2
  190. package/templates/resource-graphs/blog.json +5 -5
  191. package/templates/resource-graphs/ecommerce.json +5 -5
  192. package/templates/resource-graphs/headless.json +1 -1
  193. package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
  194. package/templates/template/.cursorrules +2 -2
  195. package/templates/template/.env.example +6 -17
  196. package/templates/template/.github/copilot-instructions.md +2 -2
  197. package/templates/template/.windsurfrules +2 -2
  198. package/templates/template/AGENTS.md +2 -2
  199. package/templates/template/CLAUDE.md +2 -2
  200. package/templates/template/README.md +47 -13
  201. package/templates/template/ai-instructions.md +15 -14
  202. package/templates/template/backend/functions/hello.ts +1 -1
  203. package/templates/template/backend/package.json +0 -2
  204. package/templates/template/{config → backend}/resources.ts +3 -3
  205. package/templates/template/backend/schema/authors.ts +11 -0
  206. package/templates/template/backend/schema/index.ts +29 -0
  207. package/templates/template/backend/schema/posts.ts +29 -0
  208. package/templates/template/backend/schema/tags.ts +9 -0
  209. package/templates/template/backend/schema/users.ts +32 -0
  210. package/templates/template/{config → backend}/storage.ts +4 -4
  211. package/templates/template/backend/tsconfig.json +15 -20
  212. package/templates/template/docker-compose.yml +3 -3
  213. package/templates/template/frontend/package.json +0 -2
  214. package/templates/template/frontend/src/App.tsx +10 -4
  215. package/templates/template/frontend/src/cms/authors.tsx +7 -0
  216. package/templates/template/frontend/src/cms/posts.tsx +27 -0
  217. package/templates/template/frontend/src/cms/tags.tsx +11 -0
  218. package/templates/template/frontend/src/cms/ui-config.json +3 -0
  219. package/templates/template/frontend/src/cms/users.tsx +54 -0
  220. package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
  221. package/templates/template/frontend/vite.config.ts +6 -2
  222. package/templates/template/gitignore +1 -1
  223. package/templates/template/package.json +1 -2
  224. package/templates/template/pnpm-workspace.yaml +0 -1
  225. package/templates/template/scripts/example.ts +3 -3
  226. package/templates/template/tsconfig.json +1 -1
  227. package/templates/views/AppView.tsx.tmpl +4 -4
  228. package/templates/views/EntityView.tsx.tmpl +3 -4
  229. package/dist/api-keys-Dfw5-9s1.js.map +0 -1
  230. package/dist/apps-MKQbgDtN.js.map +0 -1
  231. package/dist/build-BuKTnec8.js.map +0 -1
  232. package/dist/bundle-BAH4FCju.js.map +0 -1
  233. package/dist/cloud-DtADfWwn.js.map +0 -1
  234. package/dist/collection-drift-BKj_BoMq.js +0 -106
  235. package/dist/collection-drift-BKj_BoMq.js.map +0 -1
  236. package/dist/collections-dir-DlvDhime.js +0 -69
  237. package/dist/collections-dir-DlvDhime.js.map +0 -1
  238. package/dist/console-CdwIYOMV.js.map +0 -1
  239. package/dist/context-AXdAh-q8.js.map +0 -1
  240. package/dist/db-DBbKpjYX.js.map +0 -1
  241. package/dist/derive-ae9UOoOB.js.map +0 -1
  242. package/dist/dev-C93d4QIv.js.map +0 -1
  243. package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
  244. package/dist/doctor-BBPQUO2g.js.map +0 -1
  245. package/dist/eject-DABcDnPN.js.map +0 -1
  246. package/dist/fold-static-BWzxNn06.js.map +0 -1
  247. package/dist/generate-view-IFwCADvb.js.map +0 -1
  248. package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
  249. package/dist/init-vL1DWOeC.js.map +0 -1
  250. package/dist/last-dev-database-DpW5dfoX.js +0 -2
  251. package/dist/manifest-BtzDy7KQ.js.map +0 -1
  252. package/dist/path-flags-DNvtEi2-.js +0 -92
  253. package/dist/path-flags-DNvtEi2-.js.map +0 -1
  254. package/dist/project-CasK56vN.js.map +0 -1
  255. package/dist/pull-DDMpsZ5r.js.map +0 -1
  256. package/dist/resolve-D647F1LA.js +0 -2
  257. package/dist/schema-DtLPsXbT.js.map +0 -1
  258. package/dist/schema-reconcile-DkArN9jF.js +0 -2
  259. package/dist/skills-CbwV6vw_.js.map +0 -1
  260. package/dist/status-BREvtzJm.js.map +0 -1
  261. package/dist/storage-CO9ouK76.js.map +0 -1
  262. package/dist/utils/collection-drift.d.ts +0 -27
  263. package/dist/utils/collections-dir.d.ts +0 -14
  264. package/dist/verify-Y3rWSgfA.js +0 -730
  265. package/dist/verify-Y3rWSgfA.js.map +0 -1
  266. package/templates/overlays/baas/config/index.ts +0 -24
  267. package/templates/overlays/baas/config/package.json +0 -30
  268. package/templates/template/config/cms.d.ts +0 -15
  269. package/templates/template/config/collections/authors.ts +0 -47
  270. package/templates/template/config/collections/index.ts +0 -44
  271. package/templates/template/config/collections/posts.ts +0 -94
  272. package/templates/template/config/collections/presets/blank/index.ts +0 -5
  273. package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
  274. package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
  275. package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
  276. package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
  277. package/templates/template/config/collections/tags.ts +0 -27
  278. package/templates/template/config/collections/users.ts +0 -149
  279. package/templates/template/config/frontend-assets.d.ts +0 -17
  280. package/templates/template/config/index.ts +0 -12
  281. package/templates/template/config/package.json +0 -30
  282. package/templates/template/config/tsconfig.json +0 -35
  283. /package/templates/eject/{config → backend}/resources.ts +0 -0
@@ -1,15 +1,16 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { C as resolveBackendPaths } from "./manifest-C3uLDrrJ.js";
2
3
  import { n as cliVersion } from "./version-Buyyo1ut.js";
3
- import { g as resolveBackendPaths } from "./manifest-BtzDy7KQ.js";
4
+ import { t as createSchemaModuleImporter } from "./import-schema-module-Df67TIWj.js";
4
5
  import { t as analyseFunctionsDirectory } from "./function-portability-BIvlvR9q.js";
5
6
  import fs from "fs";
6
7
  import path from "path";
7
- import { pathToFileURL } from "url";
8
+ import { fileURLToPath } from "url";
8
9
  import { createRequire } from "module";
9
- import { DEFAULT_RESOURCE_KEY, buildResourceGraph, declareFunction, declaredQueueConsumers, declaredResources, declaredSubscriptions, findEnvSuffixCollision, isResourceHandle, resetDeclaredQueueConsumers, resetDeclaredResources, resetDeclaredSubscriptions, resolveResourceRefs, resourceId, resourceKeyOf } from "@rebasepro/types";
10
+ import { DEFAULT_RESOURCE_KEY, buildResourceGraph, declareFunction, declaredQueueConsumers, declaredResources, declaredSubscriptions, findEnvSuffixCollision, isResourceHandle, resetDeclaredQueueConsumers, resetDeclaredResources, resetDeclaredSubscriptions, resourceId } from "@rebasepro/types";
10
11
  //#region src/resources/derive.ts
11
12
  /**
12
- * Deriving the resource graph from a project's config, and recording it.
13
+ * Deriving the resource graph from a project's backend, and recording it.
13
14
  *
14
15
  * ## Why the graph is derived rather than authored
15
16
  *
@@ -20,7 +21,8 @@ import { DEFAULT_RESOURCE_KEY, buildResourceGraph, declareFunction, declaredQueu
20
21
  * place. A `custom` runtime makes it sharper still: it emits no bundle
21
22
  * manifest, so without a committed artifact there is nothing to read at all.
22
23
  *
23
- * So the graph is derived by evaluating the config and written to
24
+ * So the graph is derived by evaluating `backend/resources.ts` and the tables
25
+ * in `backend/schema`, and written to
24
26
  * `rebase.resources.json`, which is committed. Same arrangement as
25
27
  * `schema.generated.ts`: authored in one place, generated into another, and a
26
28
  * gate fails if the two disagree. The file is an *output*, never an input —
@@ -30,7 +32,7 @@ import { DEFAULT_RESOURCE_KEY, buildResourceGraph, declareFunction, declaredQueu
30
32
  * ## Why evaluation rather than static analysis
31
33
  *
32
34
  * Encore parses the source and builds the graph from the AST. Rebase already
33
- * evaluates config to load collections, and evaluation is exact where a parser
35
+ * evaluates `backend/schema` to load the tables, and evaluation is exact where a parser
34
36
  * is approximate — a resource declared in a loop, or behind a helper, is
35
37
  * invisible to a parser and obvious to an interpreter. The cost is running user
36
38
  * code at build time, which this project already accepts everywhere else.
@@ -78,8 +80,8 @@ function installedVersion(specifier, from) {
78
80
  *
79
81
  * `main` runs 497 commits ahead of npm `latest` and the docs site publishes from
80
82
  * `main`, so the shape this exists for is routine: a scaffold pinned to the
81
- * published version, config code written against today's documentation, and an
82
- * error about the config file. The fix is one command and the error named none
83
+ * published version, backend code written against today's documentation, and an
84
+ * error about the project's file. The fix is one command and the error named none
83
85
  * of it — the same failure as `404 No PUT route on collection 'projects'`, one
84
86
  * layer down.
85
87
  *
@@ -105,109 +107,69 @@ function compareVersions(a, b) {
105
107
  for (let i = 0; i < 3; i++) if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) < (y[i] ?? 0) ? -1 : 1;
106
108
  return 0;
107
109
  }
108
- /** Files that declare resources, in the order they are loaded. */
109
- var RESOURCE_ENTRY_NAMES = [
110
- "resources.ts",
111
- "resources.js",
112
- "resources/index.ts",
113
- "resources/index.js"
110
+ /** The spellings of the resources module, tried in order, after its path without extension. */
111
+ var RESOURCE_MODULE_SUFFIXES = [
112
+ ".ts",
113
+ ".mts",
114
+ ".js",
115
+ ".mjs",
116
+ "/index.ts",
117
+ "/index.js"
114
118
  ];
115
- /** Collection files, which may also declare a resource beside the collection using it. */
116
- function collectionFiles(configDir) {
117
- const dir = path.join(configDir, "collections");
118
- if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) return [];
119
- return fs.readdirSync(dir).filter((f) => /\.(ts|js|mts|mjs)$/.test(f) && !/\.(test|spec|d)\./.test(f)).sort().map((f) => path.join(dir, f));
120
- }
121
- /**
122
- * Make the project's own TypeScript loader active in this process.
123
- *
124
- * `import()` below relies on tsx's resolver, and nothing had registered it:
125
- * `rebase build` runs from `node_modules/.bin/rebase`, which is plain Node.
126
- * On a modern Node that *looks* like it works — native type stripping imports
127
- * `collections/index.ts` happily — right up to the first relative specifier
128
- * inside it. The scaffolded template writes `import posts from "./posts.js"`,
129
- * which is the correct thing for TypeScript to emit and which native stripping
130
- * does not remap back to `posts.ts`. So `rebase build` failed on every
131
- * scaffolded project with `Cannot find module …/posts.js`, and the failure
132
- * looked like a broken template rather than a missing loader.
133
- *
134
- * Resolved from the project, not from this package, exactly as `resolveTsx`
135
- * does for the schema-generation subprocess: tsx is the project's dependency
136
- * (the scaffold declares it), and taking it from anywhere else would mean
137
- * evaluating a project's config with a loader it did not choose.
138
- *
139
- * Best-effort by design. A project with no tsx keeps the previous behaviour —
140
- * which is correct for one whose config is plain JavaScript, or whose imports
141
- * carry no extension — rather than failing on a dependency it never needed.
142
- * Registered once per process; `register` is cheap but not free, and deriving
143
- * twice in one process is an ordinary thing for a watch mode to do.
144
- */
145
- var tsxRegistered = false;
146
- async function registerProjectTsx(configDir) {
147
- if (tsxRegistered) return;
148
- tsxRegistered = true;
149
- const projectRoot = path.dirname(configDir);
150
- const bases = [
151
- configDir,
152
- projectRoot,
153
- path.join(projectRoot, "backend")
154
- ];
155
- for (const base of bases) try {
156
- const api = await import(pathToFileURL(createRequire(path.join(base, "noop.js")).resolve("tsx/esm/api")).href);
157
- const register = api.register ?? api.default?.register;
158
- if (typeof register === "function") {
159
- register();
160
- return;
161
- }
162
- } catch {}
163
- }
164
- /**
165
- * Import a module for its side effects.
166
- *
167
- * Plain `import()` so tsx's loader hooks resolve `.ts` and workspace
168
- * specifiers, exactly as the collection loader does.
169
- */
170
- async function evaluate(filePath) {
171
- return await import(pathToFileURL(filePath).href);
119
+ /** The resources module under `base` (a path without extension), or undefined. */
120
+ function findResourcesModule(base) {
121
+ return RESOURCE_MODULE_SUFFIXES.map((suffix) => `${base}${suffix}`).find((candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isFile());
172
122
  }
173
123
  /** The derive options for a backend app, from its manifest entry. */
174
124
  function deriveOptionsFor(projectRoot, app) {
175
125
  const paths = resolveBackendPaths(app, projectRoot);
176
126
  return {
177
127
  projectRoot,
178
- configDir: path.join(projectRoot, paths.config),
128
+ resources: path.join(projectRoot, paths.resources).replace(/\.[mc]?[jt]s$/, ""),
129
+ schemaDir: path.join(projectRoot, paths.tables),
179
130
  cronsDir: path.join(projectRoot, paths.crons),
180
131
  functionsDir: path.join(projectRoot, paths.functions)
181
132
  };
182
133
  }
183
- /** Whether a module's default export looks like a collection. */
184
- function isCollectionLike(value) {
185
- return typeof value === "object" && value !== null && typeof value.slug === "string" && typeof value.properties === "object";
134
+ /** Every storage setting in a JSON shape, with its dotted path below the column. */
135
+ function jsonStorage(shape, prefix) {
136
+ switch (shape.kind) {
137
+ case "string": return shape.storage ? [[prefix, shape.storage]] : [];
138
+ case "object": return Object.entries(shape.fields).flatMap(([name, field]) => jsonStorage(field, `${prefix}.${name}`));
139
+ case "array": return jsonStorage(shape.of, prefix);
140
+ case "oneOf": return Object.entries(shape.variants).flatMap(([name, variant]) => jsonStorage(variant, `${prefix}.${name}`));
141
+ default: return [];
142
+ }
186
143
  }
187
144
  /**
188
- * The resources a collection reaches: its database, and every bucket a
189
- * storage property stores into. Only resources the graph declares get an
190
- * edge — the implicit default database is not in the graph, so a collection
191
- * that names no `dataSource` records nothing.
145
+ * Every storage setting a table's columns carry, keyed by the dotted path to
146
+ * it: a storage column, the items of a storage array, a file inside a JSON
147
+ * document.
192
148
  */
193
- function collectionEdges(collection, declared) {
149
+ function tableStorage(table) {
150
+ return table.columns.flatMap((column) => [
151
+ ...column.storage ? [[column.key, column.storage]] : [],
152
+ ...column.element?.storage ? [[column.key, column.element.storage]] : [],
153
+ ...column.json ? jsonStorage(column.json, column.key) : []
154
+ ]);
155
+ }
156
+ /**
157
+ * The resources a table reaches: its database, and every bucket a storage
158
+ * column stores into. Only resources the graph declares get an edge — the
159
+ * implicit default database is not in the graph, so a table that names no
160
+ * `database` records nothing.
161
+ *
162
+ * The ids are `table:<slug>` and `column:<slug>.<path>`; a host's topology
163
+ * view parses them.
164
+ */
165
+ function tableEdges(table, declared) {
194
166
  const edges = [];
195
- const from = `collection:${collection.slug}`;
196
- const databaseId = resourceId("database", collection.dataSource ?? DEFAULT_RESOURCE_KEY);
197
- if (declared.has(databaseId)) edges.push([databaseId, from]);
198
- const walk = (properties, prefix) => {
199
- for (const [name, raw] of Object.entries(properties ?? {})) {
200
- const property = raw;
201
- if (!property || typeof property !== "object") continue;
202
- if (property.storage) {
203
- const bucketId = resourceId("bucket", property.storage.storageSource === void 0 ? DEFAULT_RESOURCE_KEY : resourceKeyOf(property.storage.storageSource));
204
- if (declared.has(bucketId)) edges.push([bucketId, `property:${collection.slug}.${prefix}${name}`]);
205
- }
206
- if (property.properties) walk(property.properties, `${prefix}${name}.`);
207
- if (property.of && typeof property.of === "object") walk({ [name]: property.of }, `${prefix}`);
208
- }
209
- };
210
- walk(collection.properties, "");
167
+ const databaseId = resourceId("database", table.database ?? DEFAULT_RESOURCE_KEY);
168
+ if (declared.has(databaseId)) edges.push([databaseId, `table:${table.slug}`]);
169
+ for (const [where, storage] of tableStorage(table)) {
170
+ const bucketId = resourceId("bucket", storage.source ?? DEFAULT_RESOURCE_KEY);
171
+ if (declared.has(bucketId)) edges.push([bucketId, `column:${table.slug}.${where}`]);
172
+ }
211
173
  return edges;
212
174
  }
213
175
  /**
@@ -253,16 +215,19 @@ function summariseThrownMessage(message) {
253
215
  return trimmed.split("\n")[0];
254
216
  }
255
217
  /**
256
- * Evaluate a project's config and return the graph it declares.
218
+ * Evaluate a project's resources and tables and return the graph they declare.
257
219
  *
258
220
  * Clears any previously registered declarations first, so deriving twice in one
259
221
  * process — a watch mode, a test — describes the project rather than the union
260
222
  * of every project seen so far.
261
223
  */
262
224
  async function deriveResourceGraph(options) {
263
- const { configDir, includeCollections = true, cronsDir, functionsDir } = options;
264
- const projectRoot = options.projectRoot ?? path.dirname(configDir);
265
- await registerProjectTsx(configDir);
225
+ const { projectRoot, cronsDir, functionsDir } = options;
226
+ let importer;
227
+ const importModule = async (file) => {
228
+ importer ??= await createSchemaModuleImporter(projectRoot, options.moduleAliases);
229
+ return importer(file);
230
+ };
266
231
  resetDeclaredResources();
267
232
  resetDeclaredSubscriptions();
268
233
  resetDeclaredQueueConsumers();
@@ -274,30 +239,37 @@ async function deriveResourceGraph(options) {
274
239
  usedBy.set(resource, list);
275
240
  };
276
241
  const handleExports = /* @__PURE__ */ new Map();
277
- for (const name of RESOURCE_ENTRY_NAMES) {
278
- const candidate = path.join(configDir, name);
279
- if (!fs.existsSync(candidate)) continue;
280
- try {
281
- const mod = await evaluate(candidate);
282
- for (const [exportName, value] of Object.entries(mod)) if (isResourceHandle(value)) handleExports.set(exportName, resourceId(value.kind, value.key));
283
- } catch (err) {
284
- issues.push({
285
- path: path.relative(configDir, candidate),
286
- message: describeIssue(err, projectRoot)
287
- });
288
- }
289
- break;
290
- }
291
- const collections = [];
292
- if (includeCollections) for (const entry of collectionFiles(configDir)) try {
293
- const mod = await evaluate(entry);
294
- if (isCollectionLike(mod.default)) collections.push(resolveResourceRefs(mod.default));
242
+ const resourcesModule = options.resources ? findResourcesModule(options.resources.replace(/\.[mc]?[jt]s$/, "")) : void 0;
243
+ if (resourcesModule) try {
244
+ const mod = await importModule(resourcesModule);
245
+ for (const [exportName, value] of Object.entries(mod)) if (isResourceHandle(value)) handleExports.set(exportName, resourceId(value.kind, value.key));
295
246
  } catch (err) {
296
247
  issues.push({
297
- path: path.relative(configDir, entry),
248
+ path: path.relative(projectRoot, resourcesModule),
298
249
  message: describeIssue(err, projectRoot)
299
250
  });
300
251
  }
252
+ let tables = [];
253
+ if (options.schemaDir) try {
254
+ const { loadBackendSchema, compileLoadedSchema } = await import("@rebasepro/server");
255
+ tables = compileLoadedSchema(await loadBackendSchema(options.schemaDir, {
256
+ projectRoot,
257
+ importModule
258
+ })).descriptors;
259
+ } catch (err) {
260
+ const { isSchemaDefinitionError } = await import("@rebasepro/common");
261
+ if (isSchemaDefinitionError(err)) for (const problem of err.problems) issues.push({
262
+ path: `table.${problem.key ? `${problem.table}.${problem.key}` : problem.table}`,
263
+ message: problem.message
264
+ });
265
+ else {
266
+ const file = typeof err === "object" && err !== null && "file" in err && typeof err.file === "string" ? err.file : options.schemaDir;
267
+ issues.push({
268
+ path: path.relative(projectRoot, file),
269
+ message: describeIssue(err, projectRoot)
270
+ });
271
+ }
272
+ }
301
273
  if (cronsDir && fs.existsSync(cronsDir)) {
302
274
  const previousLevel = process.env.LOG_LEVEL;
303
275
  process.env.LOG_LEVEL = "error";
@@ -310,7 +282,7 @@ async function deriveResourceGraph(options) {
310
282
  });
311
283
  };
312
284
  const crons = await loadCrons(cronsDir, {
313
- importModule: (url) => import(url),
285
+ importModule: (url) => importModule(url.startsWith("file:") ? fileURLToPath(url) : url),
314
286
  onSkip: reportProblem
315
287
  });
316
288
  for (const [id, definition] of Object.entries(crons)) try {
@@ -348,7 +320,7 @@ async function deriveResourceGraph(options) {
348
320
  }
349
321
  }
350
322
  const declared = new Set(declaredResources().map((r) => resourceId(r.kind, r.key)));
351
- for (const collection of collections) for (const [resource, by] of collectionEdges(collection, declared)) recordUse(resource, by);
323
+ for (const table of tables) for (const [resource, by] of tableEdges(table, declared)) recordUse(resource, by);
352
324
  for (const sub of declaredSubscriptions()) {
353
325
  const id = resourceId("topic", sub.topic);
354
326
  if (declared.has(id)) recordUse(id, `subscription:${sub.topic}.${sub.name}`);
@@ -374,16 +346,16 @@ async function deriveResourceGraph(options) {
374
346
  });
375
347
  const databases = new Set(graph.resources.filter((r) => r.kind === "database").map((r) => r.key));
376
348
  const buckets = new Set(graph.resources.filter((r) => r.kind === "bucket").map((r) => r.key));
377
- for (const collection of collections) {
378
- if (collection.dataSource && collection.dataSource !== DEFAULT_RESOURCE_KEY && !databases.has(collection.dataSource)) issues.push({
379
- path: `collection.${collection.slug}`,
380
- message: `routes to dataSource "${collection.dataSource}", which nothing declares. Add database("${collection.dataSource}") to resources.ts, or import the handle and use it here.`
349
+ for (const table of tables) {
350
+ if (table.database && table.database !== DEFAULT_RESOURCE_KEY && !databases.has(table.database)) issues.push({
351
+ path: `table.${table.slug}`,
352
+ message: `lives in database "${table.database}", which nothing declares. Add database("${table.database}") to backend/resources.ts, or import the handle and use it here.`
381
353
  });
382
- for (const [name, raw] of Object.entries(collection.properties ?? {})) {
383
- const key = raw?.storage?.storageSource;
384
- if (typeof key === "string" && key !== DEFAULT_RESOURCE_KEY && buckets.size > 0 && !buckets.has(key)) issues.push({
385
- path: `collection.${collection.slug}.${name}`,
386
- message: `stores into bucket "${key}", which nothing declares. Add bucket("${key}") to resources.ts.`
354
+ for (const [where, storage] of tableStorage(table)) {
355
+ const key = storage.source;
356
+ if (key !== void 0 && key !== DEFAULT_RESOURCE_KEY && buckets.size > 0 && !buckets.has(key)) issues.push({
357
+ path: `table.${table.slug}.${where}`,
358
+ message: `stores into bucket "${key}", which nothing declares. Add bucket("${key}") to backend/resources.ts.`
387
359
  });
388
360
  }
389
361
  }
@@ -404,7 +376,7 @@ function serializeResourceGraph(graph) {
404
376
  ...r.usedBy && r.usedBy.length > 0 ? { usedBy: r.usedBy } : {}
405
377
  }));
406
378
  return JSON.stringify({
407
- $generated: `Generated from config by \`rebase resources\`. Edit the declarations, not this file.`,
379
+ $generated: `Generated from backend/resources.ts and backend/schema by \`rebase resources\`. Edit the declarations, not this file.`,
408
380
  version: graph.version,
409
381
  resources
410
382
  }, null, 4) + "\n";
@@ -418,7 +390,7 @@ function readResourceGraphFile(projectRoot) {
418
390
  * Write the graph, and say whether the file changed.
419
391
  *
420
392
  * The boolean is what a `--check` mode reports on: a project whose committed
421
- * graph disagrees with its config has a host reading one thing and a runtime
393
+ * graph disagrees with its declarations has a host reading one thing and a runtime
422
394
  * doing another.
423
395
  */
424
396
  function writeResourceGraphFile(projectRoot, graph) {
@@ -496,4 +468,4 @@ function projectResourceGraph(graph) {
496
468
  //#endregion
497
469
  export { projectResourceGraph as a, withImplicitDefaults as c, derive_exports as i, writeResourceGraphFile as l, deriveOptionsFor as n, readResourceGraphFile as o, deriveResourceGraph as r, serializeResourceGraph as s, RESOURCE_GRAPH_FILENAME as t };
498
470
 
499
- //# sourceMappingURL=derive-ae9UOoOB.js.map
471
+ //# sourceMappingURL=derive-C3ezmY-p.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive-C3ezmY-p.js","names":[],"sources":["../src/resources/derive.ts"],"sourcesContent":["/**\n * Deriving the resource graph from a project's backend, and recording it.\n *\n * ## Why the graph is derived rather than authored\n *\n * A resource is declared once, in code. But a host has to know what a project\n * needs *before* it runs anything — that is how a console can say \"this project\n * wants a `media` bucket and has none\" on a first deploy, and it is the reason\n * storage topology used to be hand-written into `rebase.json` in the first\n * place. A `custom` runtime makes it sharper still: it emits no bundle\n * manifest, so without a committed artifact there is nothing to read at all.\n *\n * So the graph is derived by evaluating `backend/resources.ts` and the tables\n * in `backend/schema`, and written to\n * `rebase.resources.json`, which is committed. Same arrangement as\n * `schema.generated.ts`: authored in one place, generated into another, and a\n * gate fails if the two disagree. The file is an *output*, never an input —\n * which is what removes the old silent merge, because there is no longer a\n * second declaration for anything to be merged with.\n *\n * ## Why evaluation rather than static analysis\n *\n * Encore parses the source and builds the graph from the AST. Rebase already\n * evaluates `backend/schema` to load the tables, and evaluation is exact where a parser\n * is approximate — a resource declared in a loop, or behind a helper, is\n * invisible to a parser and obvious to an interpreter. The cost is running user\n * code at build time, which this project already accepts everywhere else.\n */\nimport fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\nimport {\n DEFAULT_RESOURCE_KEY,\n buildResourceGraph,\n declareFunction,\n declaredQueueConsumers,\n declaredResources,\n declaredSubscriptions,\n findEnvSuffixCollision,\n isResourceHandle,\n resetDeclaredQueueConsumers,\n resetDeclaredResources,\n resetDeclaredSubscriptions,\n resourceId,\n type ColumnStorage,\n type JsonShape,\n type RebaseBackendAppConfig,\n type ResourceDeclaration,\n type ResourceGraph,\n type TableDescriptor\n} from \"@rebasepro/types\";\nimport { analyseFunctionsDirectory } from \"../function-portability\";\nimport { resolveBackendPaths } from \"../manifest\";\nimport { createSchemaModuleImporter } from \"../utils/import-schema-module\";\nimport type { ModuleAliases } from \"../utils/project-schema\";\nimport type { SchemaModuleImporter } from \"@rebasepro/server\";\nimport { cliVersion } from \"../utils/version\";\n\n/** The committed, generated record of what a project needs. */\nexport const RESOURCE_GRAPH_FILENAME = \"rebase.resources.json\";\n\n/** A problem found while deriving, reported with the rest rather than thrown one at a time. */\nexport interface ResourceIssue {\n path: string;\n message: string;\n}\n\n/**\n * Which `@rebasepro/*` package a module error is about, when it is about one.\n *\n * Both directions of a version skew arrive as an error about the *user's* file:\n * `resources.ts The requested module '@rebasepro/types' does not provide an\n * export named 'queue'`. Nothing in that says which copy of `@rebasepro/types`\n * is installed, what version this CLI is, or that the two disagree — so the\n * reader goes looking for a typo in code they just copied out of the docs.\n *\n * Two shapes, because the two directions produce different errors: a named\n * export the installed copy is too old for, and a package the installed tree\n * does not have at all.\n */\nconst NAMED_EXPORT_MISSING = /does not provide an export named ['\"]([^'\"]+)['\"]/;\nconst SPECIFIER = /(@rebasepro\\/[a-z0-9-]+)/;\n\n/** The version of a package as resolved from the project, or null. */\nfunction installedVersion(specifier: string, from: string): string | null {\n try {\n const require = createRequire(path.join(from, \"noop.js\"));\n const manifest = require.resolve(`${specifier}/package.json`);\n const version: unknown = JSON.parse(fs.readFileSync(manifest, \"utf-8\")).version;\n return typeof version === \"string\" ? version : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The message an issue carries, with the skew named when there is one.\n *\n * `main` runs 497 commits ahead of npm `latest` and the docs site publishes from\n * `main`, so the shape this exists for is routine: a scaffold pinned to the\n * published version, backend code written against today's documentation, and an\n * error about the project's file. The fix is one command and the error named none\n * of it — the same failure as `404 No PUT route on collection 'projects'`, one\n * layer down.\n *\n * Says nothing extra when the two versions agree, or when either is unreadable:\n * a sentence naming one version twice is worse than no sentence.\n */\nexport function describeIssue(err: unknown, projectRoot: string, ownVersion = cliVersion()): string {\n const message = err instanceof Error ? err.message : String(err);\n const code = (err as { code?: unknown } | null)?.code;\n const missingExport = NAMED_EXPORT_MISSING.exec(message);\n const isSkewShaped = missingExport !== null || code === \"ERR_MODULE_NOT_FOUND\";\n if (!isSkewShaped) return message;\n\n const specifier = SPECIFIER.exec(message)?.[1];\n if (!specifier) return message;\n\n // One line, not two: every caller renders an issue as `path message` on a\n // single row, so a newline here would land the useful half unindented under\n // the file name.\n const lead = /[.!?]$/.test(message.trim()) ? message.trim() : `${message.trim()}.`;\n\n const installed = installedVersion(specifier, projectRoot);\n if (installed === null) {\n return `${lead} ${specifier} is not installed in this project; this CLI is ${ownVersion}. `\n + `Run pnpm add ${specifier}@${ownVersion}`;\n }\n if (ownVersion === \"unknown\" || installed === ownVersion) return message;\n\n // Which side to move is the question the reader actually has, and it has a\n // right answer: the CLI is what evaluates this file, so the packages follow\n // it — unless the CLI is the older one, in which case following it would\n // move the project backwards.\n const cliIsNewer = compareVersions(ownVersion, installed) > 0;\n return cliIsNewer\n ? `${lead} ${specifier} ${installed} is installed; this CLI is ${ownVersion}. `\n + `Run pnpm add ${specifier}@${ownVersion}`\n : `${lead} ${specifier} ${installed} is installed; this CLI is ${ownVersion}, which is older. `\n + `Update the CLI to ${installed}, or pin ${specifier} back to ${ownVersion}`;\n}\n\n/** -1 / 0 / 1 on the numeric parts, ignoring any prerelease tail. */\nfunction compareVersions(a: string, b: string): number {\n const parts = (v: string): number[] => v.split(\"-\")[0].split(\".\").map(n => Number(n) || 0);\n const [x, y] = [parts(a), parts(b)];\n for (let i = 0; i < 3; i++) {\n if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) < (y[i] ?? 0) ? -1 : 1;\n }\n return 0;\n}\n\n/** The spellings of the resources module, tried in order, after its path without extension. */\nconst RESOURCE_MODULE_SUFFIXES = [\".ts\", \".mts\", \".js\", \".mjs\", \"/index.ts\", \"/index.js\"];\n\n/** The resources module under `base` (a path without extension), or undefined. */\nfunction findResourcesModule(base: string): string | undefined {\n return RESOURCE_MODULE_SUFFIXES.map(suffix => `${base}${suffix}`)\n .find(candidate => fs.existsSync(candidate) && fs.statSync(candidate).isFile());\n}\n\nexport interface DeriveOptions {\n /** The project root, absolute: what the importer is rooted at and every recorded path is relative to. */\n projectRoot: string;\n /**\n * The resources module, absolute, without or with its extension:\n * `<root>/backend/resources`. Its `database()` / `bucket()` / `topic()` /\n * `queue()` declarations are the graph's nodes.\n */\n resources?: string;\n /**\n * The schema directory, absolute. Its tables are evaluated too: a table\n * reaches its database and every bucket a storage column stores into, and a\n * bucket may be declared beside the table that stores into it.\n */\n schemaDir?: string;\n /**\n * Absolute path to the crons directory. Each file is evaluated through the\n * same loader the runtime uses, which declares the cron under the same id\n * the scheduler runs it as. Absent, or missing on disk: no crons.\n */\n cronsDir?: string;\n /**\n * Absolute path to the functions directory. Read statically — the\n * bundler's portability analysis — never evaluated: a function's module\n * scope belongs to a running backend, not a build.\n */\n functionsDir?: string;\n /** Module specifiers mapped to files when importing (in-repo runs and tests). */\n moduleAliases?: ModuleAliases;\n}\n\n/** The derive options for a backend app, from its manifest entry. */\nexport function deriveOptionsFor(projectRoot: string, app: RebaseBackendAppConfig): DeriveOptions {\n const paths = resolveBackendPaths(app, projectRoot);\n return {\n projectRoot,\n resources: path.join(projectRoot, paths.resources).replace(/\\.[mc]?[jt]s$/, \"\"),\n schemaDir: path.join(projectRoot, paths.tables),\n cronsDir: path.join(projectRoot, paths.crons),\n functionsDir: path.join(projectRoot, paths.functions)\n };\n}\n\n/** Every storage setting in a JSON shape, with its dotted path below the column. */\nfunction jsonStorage(shape: JsonShape, prefix: string): Array<[string, ColumnStorage]> {\n switch (shape.kind) {\n case \"string\":\n return shape.storage ? [[prefix, shape.storage]] : [];\n case \"object\":\n return Object.entries(shape.fields).flatMap(([name, field]) => jsonStorage(field, `${prefix}.${name}`));\n case \"array\":\n return jsonStorage(shape.of, prefix);\n case \"oneOf\":\n return Object.entries(shape.variants).flatMap(([name, variant]) => jsonStorage(variant, `${prefix}.${name}`));\n default:\n return [];\n }\n}\n\n/**\n * Every storage setting a table's columns carry, keyed by the dotted path to\n * it: a storage column, the items of a storage array, a file inside a JSON\n * document.\n */\nfunction tableStorage(table: TableDescriptor): Array<[string, ColumnStorage]> {\n return table.columns.flatMap((column): Array<[string, ColumnStorage]> => [\n ...(column.storage ? [[column.key, column.storage] satisfies [string, ColumnStorage]] : []),\n ...(column.element?.storage ? [[column.key, column.element.storage] satisfies [string, ColumnStorage]] : []),\n ...(column.json ? jsonStorage(column.json, column.key) : [])\n ]);\n}\n\n/**\n * The resources a table reaches: its database, and every bucket a storage\n * column stores into. Only resources the graph declares get an edge — the\n * implicit default database is not in the graph, so a table that names no\n * `database` records nothing.\n *\n * The ids are `table:<slug>` and `column:<slug>.<path>`; a host's topology\n * view parses them.\n */\nfunction tableEdges(table: TableDescriptor, declared: Set<string>): Array<[string, string]> {\n const edges: Array<[string, string]> = [];\n const databaseId = resourceId(\"database\", table.database ?? DEFAULT_RESOURCE_KEY);\n if (declared.has(databaseId)) edges.push([databaseId, `table:${table.slug}`]);\n for (const [where, storage] of tableStorage(table)) {\n const bucketId = resourceId(\"bucket\", storage.source ?? DEFAULT_RESOURCE_KEY);\n if (declared.has(bucketId)) edges.push([bucketId, `column:${table.slug}.${where}`]);\n }\n return edges;\n}\n\n/**\n * A cron file that would not import, said in terms somebody can act on.\n *\n * The graph is derived by evaluating each cron module, in a process with none\n * of the deployment's environment — so a cron that reaches a module validating\n * `DATABASE_URL` at import fails here and works perfectly at boot. The raw\n * message is a Zod error about a variable, which reads as \"the environment is\n * wrong\" when the environment is not the point.\n */\nfunction cronLoadIssue(problem: string): string {\n return `${summariseCronProblem(problem)}\\n` +\n \" `rebase resources` evaluates each cron file to read its schedule, and it is a build \" +\n \"step: no .env, no secrets. Move work that needs the deployment's environment inside the \" +\n \"handler — `const { x } = await import(\\\"…\\\")` — so the module scope imports nothing that \" +\n \"reads configuration.\";\n}\n\n/**\n * The cron loader's `<file> (threw: <message>)`, as one line.\n *\n * The message is whatever the module threw, and the common case is a schema\n * validator: `loadEnv()` at module scope with no `.env` present throws a\n * `ZodError`, whose `.message` is the JSON array of its issues. That arrived\n * here verbatim — ten lines of `{ \"expected\": \"string\", \"code\":\n * \"invalid_type\", … }` — with the sentence that says what to do underneath it,\n * so the reader met \"Invalid input: expected string, received undefined\" twice\n * before reaching the explanation.\n *\n * A validator's own sentences are the useful half of that object, so they are\n * kept and the serialisation is dropped.\n */\nfunction summariseCronProblem(problem: string): string {\n const match = problem.match(/^(.*) \\(threw: ([\\s\\S]*)\\)$/);\n if (!match) return problem.split(\"\\n\")[0];\n const [, file, thrown] = match;\n return `${file}: ${summariseThrownMessage(thrown)}`;\n}\n\n/** One sentence out of a thrown message, whatever shape it arrived in. */\nfunction summariseThrownMessage(message: string): string {\n const trimmed = message.trim();\n if (trimmed.startsWith(\"[\") || trimmed.startsWith(\"{\")) {\n try {\n const parsed: unknown = JSON.parse(trimmed);\n const issues = Array.isArray(parsed) ? parsed : [parsed];\n const sentences = [...new Set(\n issues\n .map(issue => (issue as { message?: unknown } | null)?.message)\n .filter((m): m is string => typeof m === \"string\" && m.length > 0)\n )];\n if (sentences.length > 0) return sentences.join(\"; \");\n } catch {\n // Not JSON after all — fall through to the first line.\n }\n }\n return trimmed.split(\"\\n\")[0];\n}\n\n/**\n * Evaluate a project's resources and tables and return the graph they declare.\n *\n * Clears any previously registered declarations first, so deriving twice in one\n * process — a watch mode, a test — describes the project rather than the union\n * of every project seen so far.\n */\nexport async function deriveResourceGraph(options: DeriveOptions): Promise<{ graph: ResourceGraph; issues: ResourceIssue[] }> {\n const { projectRoot, cronsDir, functionsDir } = options;\n // One importer for everything evaluated here: the resources module, the\n // tables that import its handles and the crons see one copy of each module,\n // so a handle a table imports is the handle the graph declared. A new\n // importer reads every file as it is now, so deriving again in one process\n // evaluates the declarations again. Created on first use: a project with\n // nothing to evaluate pays nothing for it.\n let importer: SchemaModuleImporter | undefined;\n const importModule: SchemaModuleImporter = async (file) => {\n importer ??= await createSchemaModuleImporter(projectRoot, options.moduleAliases);\n return importer(file);\n };\n\n // All three registries, and the side lists are the easy ones to forget:\n // resetting only the resources leaves one project's handlers attached\n // while its topics are gone — every one of them then reads as orphaned\n // against the *next* project. Caught by deriving twice in one process,\n // which is what a watch mode does.\n resetDeclaredResources();\n resetDeclaredSubscriptions();\n resetDeclaredQueueConsumers();\n\n const issues: ResourceIssue[] = [];\n const usedBy = new Map<string, string[]>();\n // `recordUse`, not `use`: React 19 made `use` a hook name, and\n // `react-hooks/rules-of-hooks` refuses a call to one from a plain function\n // — a lint error on a file with no React in it.\n const recordUse = (resource: string, by: string): void => {\n const list = usedBy.get(resource) ?? [];\n if (!list.includes(by)) list.push(by);\n usedBy.set(resource, list);\n };\n\n // ── Declarations ─────────────────────────────────────────────────────\n // Which export name is which resource, so a function's `import { media }`\n // can be recorded as reaching `bucket:media` without evaluating the\n // function. The export name and the key are usually the same word and\n // nothing requires them to be.\n const handleExports = new Map<string, string>();\n const resourcesModule = options.resources ? findResourcesModule(options.resources.replace(/\\.[mc]?[jt]s$/, \"\")) : undefined;\n if (resourcesModule) {\n try {\n const mod = await importModule(resourcesModule);\n for (const [exportName, value] of Object.entries(mod)) {\n if (isResourceHandle(value)) handleExports.set(exportName, resourceId(value.kind, value.key));\n }\n } catch (err) {\n issues.push({ path: path.relative(projectRoot, resourcesModule), message: describeIssue(err, projectRoot) });\n }\n }\n\n // ── Tables ───────────────────────────────────────────────────────────\n // Through the loader the runtime boots from, so a table that would not\n // load at boot is an issue here too, named by its file and table.\n let tables: TableDescriptor[] = [];\n if (options.schemaDir) {\n try {\n const { loadBackendSchema, compileLoadedSchema } = await import(\"@rebasepro/server\");\n const loaded = await loadBackendSchema(options.schemaDir, { projectRoot, importModule });\n tables = compileLoadedSchema(loaded).descriptors;\n } catch (err) {\n // Imported here: `@rebasepro/common` is the whole compiler, and a\n // derivation that never reads a schema has no use for it.\n const { isSchemaDefinitionError } = await import(\"@rebasepro/common\");\n if (isSchemaDefinitionError(err)) {\n for (const problem of err.problems) {\n issues.push({\n path: `table.${problem.key ? `${problem.table}.${problem.key}` : problem.table}`,\n message: problem.message\n });\n }\n } else {\n const file = typeof err === \"object\" && err !== null && \"file\" in err && typeof err.file === \"string\"\n ? err.file\n : options.schemaDir;\n issues.push({ path: path.relative(projectRoot, file), message: describeIssue(err, projectRoot) });\n }\n }\n }\n\n // ── Crons ────────────────────────────────────────────────────────────\n // Through the runtime's own loader, so the id the graph records is the id\n // the scheduler runs — the filename — and a cron that would not load at\n // boot does not load here either.\n //\n // Which means the module is EVALUATED, in a build step that has none of the\n // deployment's environment. A cron whose module scope reaches something that\n // validates `DATABASE_URL` at import therefore derives on a laptop with a\n // `.env` and nowhere else. That is worth an explicit sentence rather than a\n // stack, so `cronLoadIssue` adds one.\n if (cronsDir && fs.existsSync(cronsDir)) {\n // The runtime's loader logs each job as it loads, to stdout, as JSON\n // — which is also where `rebase resources --json` writes the graph.\n // Its problems come back as a list, so the log adds nothing here.\n const previousLevel = process.env.LOG_LEVEL;\n process.env.LOG_LEVEL = \"error\";\n try {\n const { loadCrons, declareCrons } = await import(\"@rebasepro/server\");\n const reportProblem = (problem: string) => {\n issues.push({ path: path.relative(projectRoot, cronsDir), message: cronLoadIssue(problem) });\n };\n // The importer above, not the loader's `new Function` import: plain\n // Node cannot import TypeScript, and a test runner's module sandbox\n // answers that one with \"a dynamic import callback was not\n // specified\" — the same trap the split-roles e2e records.\n const crons = await loadCrons(cronsDir, {\n importModule: url => importModule(url.startsWith(\"file:\") ? fileURLToPath(url) : url),\n onSkip: reportProblem\n });\n // One at a time, so a cron the graph refuses is reported by name\n // and the others are still declared.\n for (const [id, definition] of Object.entries(crons)) {\n try {\n declareCrons({ [id]: definition });\n } catch (err) {\n reportProblem(`${id} (threw: ${err instanceof Error ? err.message : String(err)})`);\n }\n }\n } catch (err) {\n issues.push({\n path: path.relative(projectRoot, cronsDir),\n message: cronLoadIssue(err instanceof Error ? err.message : String(err))\n });\n } finally {\n if (previousLevel === undefined) delete process.env.LOG_LEVEL;\n else process.env.LOG_LEVEL = previousLevel;\n }\n }\n\n // ── Functions ────────────────────────────────────────────────────────\n if (functionsDir && fs.existsSync(functionsDir)) {\n for (const report of analyseFunctionsDirectory(functionsDir, projectRoot)) {\n const requires = [...new Set(\n report.issues\n .filter(issue => issue.kind === \"node-builtin\" || issue.kind === \"node-only-package\")\n .map(issue => issue.message)\n )];\n try {\n declareFunction(report.name, {\n file: report.file,\n portable: report.portable,\n ...(requires.length > 0 ? { requires } : {})\n });\n } catch (err) {\n issues.push({ path: report.file, message: describeIssue(err, projectRoot) });\n }\n for (const imported of report.resourceImports) {\n const resource = handleExports.get(imported);\n if (resource) recordUse(resource, `function:${report.name}`);\n }\n }\n }\n\n // ── Edges ────────────────────────────────────────────────────────────\n const declared = new Set(declaredResources().map(r => resourceId(r.kind, r.key)));\n for (const table of tables) {\n for (const [resource, by] of tableEdges(table, declared)) recordUse(resource, by);\n }\n for (const sub of declaredSubscriptions()) {\n const id = resourceId(\"topic\", sub.topic);\n if (declared.has(id)) recordUse(id, `subscription:${sub.topic}.${sub.name}`);\n }\n for (const consumer of declaredQueueConsumers()) {\n const id = resourceId(\"queue\", consumer.queue);\n if (declared.has(id)) recordUse(id, `handler:${consumer.queue}`);\n }\n\n const graph = buildResourceGraph(usedBy);\n\n // Two resources of a kind whose env suffixes collide would silently read\n // each other's configuration, which is indistinguishable from a\n // misconfigured deployment.\n const byKind = new Map<string, string[]>();\n for (const r of graph.resources) {\n byKind.set(r.kind, [...(byKind.get(r.kind) ?? []), r.key]);\n }\n for (const [kind, keys] of byKind) {\n const collision = findEnvSuffixCollision(keys);\n if (collision) {\n issues.push({\n path: `${kind}.${collision.b}`,\n message:\n `\"${collision.a}\" and \"${collision.b}\" both bind from ${collision.suffix}, so one would ` +\n \"read the other's configuration. Rename one.\"\n });\n }\n }\n\n // A subscription on a topic nobody declared is a handler that will never\n // run, and nothing else would ever say so.\n const topics = new Set(graph.resources.filter(r => r.kind === \"topic\").map(r => r.key));\n for (const sub of declaredSubscriptions()) {\n if (!topics.has(sub.topic)) {\n issues.push({\n path: `topic.${sub.topic}`,\n message:\n `Subscription \"${sub.name}\" is declared on topic \"${sub.topic}\", which nothing declares. ` +\n \"The handler would never run.\"\n });\n }\n }\n\n // A table routed to a database nothing declares boots into a refusal, and\n // a column stored in a bucket nothing declares answers 501 on its first\n // upload. Both are cheaper to hear about here.\n const databases = new Set(graph.resources.filter(r => r.kind === \"database\").map(r => r.key));\n const buckets = new Set(graph.resources.filter(r => r.kind === \"bucket\").map(r => r.key));\n for (const table of tables) {\n if (table.database && table.database !== DEFAULT_RESOURCE_KEY && !databases.has(table.database)) {\n issues.push({\n path: `table.${table.slug}`,\n message:\n `lives in database \"${table.database}\", which nothing declares. ` +\n `Add database(\"${table.database}\") to backend/resources.ts, or import the handle and use it here.`\n });\n }\n for (const [where, storage] of tableStorage(table)) {\n const key = storage.source;\n if (key !== undefined && key !== DEFAULT_RESOURCE_KEY && buckets.size > 0 && !buckets.has(key)) {\n issues.push({\n path: `table.${table.slug}.${where}`,\n message: `stores into bucket \"${key}\", which nothing declares. Add bucket(\"${key}\") to backend/resources.ts.`\n });\n }\n }\n }\n\n return { graph, issues };\n}\n\n/** The graph as it is written to disk: stable key order, trailing newline. */\nexport function serializeResourceGraph(graph: ResourceGraph): string {\n const resources = graph.resources.map(r => ({\n kind: r.kind,\n key: r.key,\n engine: r.engine,\n transport: r.transport,\n ...(r.label !== undefined ? { label: r.label } : {}),\n ...(Object.keys(r.options).length > 0 ? { options: r.options } : {}),\n ...(r.usedBy && r.usedBy.length > 0 ? { usedBy: r.usedBy } : {})\n }));\n return JSON.stringify({\n $generated: `Generated from backend/resources.ts and backend/schema by \\`rebase resources\\`. Edit the declarations, not this file.`,\n version: graph.version,\n resources\n }, null, 4) + \"\\n\";\n}\n\n/** Read the committed graph, or null when a project has none yet. */\nexport function readResourceGraphFile(projectRoot: string): string | null {\n const file = path.join(projectRoot, RESOURCE_GRAPH_FILENAME);\n return fs.existsSync(file) ? fs.readFileSync(file, \"utf-8\") : null;\n}\n\n/**\n * Write the graph, and say whether the file changed.\n *\n * The boolean is what a `--check` mode reports on: a project whose committed\n * graph disagrees with its declarations has a host reading one thing and a runtime\n * doing another.\n */\nexport function writeResourceGraphFile(projectRoot: string, graph: ResourceGraph): { changed: boolean; file: string } {\n const file = path.join(projectRoot, RESOURCE_GRAPH_FILENAME);\n const next = serializeResourceGraph(graph);\n const previous = fs.existsSync(file) ? fs.readFileSync(file, \"utf-8\") : null;\n if (previous === next) return { changed: false, file };\n fs.writeFileSync(file, next);\n return { changed: true, file };\n}\n\n/** Parse a committed graph file, tolerating the `$generated` banner. */\nexport function parseResourceGraph(contents: string): ResourceGraph {\n const raw = JSON.parse(contents) as { version?: number; resources?: unknown };\n if (raw.version !== 1) {\n throw new Error(\n `Unsupported resource graph version ${String(raw.version)}. ` +\n \"This project was generated by a newer Rebase; upgrade rather than provisioning half of it.\"\n );\n }\n const entries = Array.isArray(raw.resources) ? raw.resources as Record<string, unknown>[] : [];\n // `options` is omitted from the file when empty; a reader of the graph\n // expects it present, so it is restored here.\n return { version: 1, resources: entries.map(r => ({ options: {}, ...r })) as ResourceGraph[\"resources\"] };\n}\n\n/**\n * Add the resources a project has without declaring them.\n *\n * A backend has a database whether or not anyone said so, and a project that\n * declares no buckets still gets one default storage source from the plain\n * unsuffixed variables. Both are load-bearing defaults and both are invisible\n * in the graph, so a status view built only from declarations would show an\n * empty screen to the majority of projects — the ones that most need to be told\n * which variable their one database reads.\n *\n * Declaring a *named* one leaves the default where it is, as the server does\n * (`resolveDataSources` and `resolveStorageSources` in `@rebasepro/server`):\n * `bucket(\"media\")` adds a source and never moves the files the default holds,\n * so both are listed. The default is displaced only by declaring it — or, for a\n * bucket, by marking exactly one server-side bucket `default: true`, which then\n * serves the uploads that name no `storageSource`. This used to drop the\n * default once a bucket was declared, and `rebase status` and `rebase\n * resources` stopped listing a source the server was still serving.\n */\nexport function withImplicitDefaults(graph: ResourceGraph): {\n declaration: ResourceDeclaration;\n implicit: boolean;\n}[] {\n const entries = graph.resources.map(declaration => ({ declaration, implicit: false }));\n const declaresDefault = (kind: string) => graph.resources.some(r => r.kind === kind && r.key === DEFAULT_RESOURCE_KEY);\n const markedDefault = graph.resources.filter(r =>\n r.kind === \"bucket\" && (r.transport ?? \"server\") === \"server\" && r.options.default === true);\n\n if (!declaresDefault(\"database\")) {\n entries.unshift({\n declaration: {\n kind: \"database\",\n key: DEFAULT_RESOURCE_KEY,\n engine: \"postgres\",\n transport: \"server\",\n options: {}\n },\n implicit: true\n });\n }\n if (!declaresDefault(\"bucket\") && markedDefault.length !== 1) {\n const implicitBucket = {\n declaration: {\n kind: \"bucket\",\n key: DEFAULT_RESOURCE_KEY,\n // `local` is what an unconfigured default source resolves to,\n // and naming it here keeps the row honest about what a project\n // with no S3 variables actually gets: a directory that a\n // container erases on restart, which production then drops.\n engine: \"local\",\n transport: \"server\" as const,\n options: {}\n },\n implicit: true\n };\n // First among the buckets, as the database default is first among the\n // databases; last when there are none.\n const firstBucket = entries.findIndex(entry => entry.declaration.kind === \"bucket\");\n if (firstBucket === -1) entries.push(implicitBucket);\n else entries.splice(firstBucket, 0, implicitBucket);\n }\n return entries;\n}\n\n/**\n * The resources a project *has*, which is what a person is asking about.\n *\n * One projection, because two of them disagreed. `rebase status` built its\n * rows from {@link withImplicitDefaults} and listed `buckets ✓ (default) local\n * · implicit`; `rebase resources` and `rebase resources --json` built theirs\n * from the raw graph and listed only the database and the function. Two\n * commands whose whole job is to answer \"what does this project need\", on the\n * same stock scaffold, giving different answers.\n *\n * The implicit entries are marked rather than hidden, because the distinction\n * is real and load-bearing: a declared resource is recorded in\n * `rebase.resources.json` for a host to provision, and an implicit one is a\n * default the runtime supplies whether or not anyone wrote it down. That file\n * still holds declarations only — it is a wire contract a host reads, and\n * putting defaults in it would ask for something to be provisioned that\n * nobody declared.\n */\nexport type ProjectedResource = ResourceDeclaration & { implicit?: true };\n\nexport function projectResourceGraph(graph: ResourceGraph): ProjectedResource[] {\n return withImplicitDefaults(graph).map(({ declaration, implicit }) =>\n (implicit ? { ...declaration, implicit: true as const } : declaration));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,IAAa,0BAA0B;;;;;;;;;;;;;;AAqBvC,IAAM,uBAAuB;AAC7B,IAAM,YAAY;;AAGlB,SAAS,iBAAiB,WAAmB,MAA6B;CACtE,IAAI;EAEA,MAAM,WADU,cAAc,KAAK,KAAK,MAAM,SAAS,CACtC,CAAA,CAAQ,QAAQ,GAAG,UAAU,cAAc;EAC5D,MAAM,UAAmB,KAAK,MAAM,GAAG,aAAa,UAAU,OAAO,CAAC,CAAC,CAAC;EACxE,OAAO,OAAO,YAAY,WAAW,UAAU;CACnD,QAAQ;EACJ,OAAO;CACX;AACJ;;;;;;;;;;;;;;AAeA,SAAgB,cAAc,KAAc,aAAqB,aAAa,WAAW,GAAW;CAChG,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAC/D,MAAM,OAAQ,KAAmC;CAGjD,IAAI,EAFkB,qBAAqB,KAAK,OAC3B,MAAkB,QAAQ,SAAS,yBACrC,OAAO;CAE1B,MAAM,YAAY,UAAU,KAAK,OAAO,CAAC,GAAG;CAC5C,IAAI,CAAC,WAAW,OAAO;CAKvB,MAAM,OAAO,SAAS,KAAK,QAAQ,KAAK,CAAC,IAAI,QAAQ,KAAK,IAAI,GAAG,QAAQ,KAAK,EAAE;CAEhF,MAAM,YAAY,iBAAiB,WAAW,WAAW;CACzD,IAAI,cAAc,MACd,OAAO,GAAG,KAAK,GAAG,UAAU,iDAAiD,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KAAK,cAAc,WAAW,GAAG;EAC1D,MAAM,iBAAiB;GACnB,aAAa;IACT,MAAM;IACN,KAAK;IAKL,QAAQ;IACR,WAAW;IACX,SAAS,CAAC;GACd;GACA,UAAU;EACd;EAGA,MAAM,cAAc,QAAQ,WAAU,UAAS,MAAM,YAAY,SAAS,QAAQ;EAClF,IAAI,gBAAgB,IAAI,QAAQ,KAAK,cAAc;OAC9C,QAAQ,OAAO,aAAa,GAAG,cAAc;CACtD;CACA,OAAO;AACX;AAsBA,SAAgB,qBAAqB,OAA2C;CAC5E,OAAO,qBAAqB,KAAK,CAAC,CAAC,KAAK,EAAE,aAAa,eAClD,WAAW;EAAE,GAAG;EAAa,UAAU;CAAc,IAAI,WAAY;AAC9E"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A TOC entry's definition without its `pg_attver` options, as the same
3
+ * number of UTF-8 bytes: what was taken out is spaces.
4
+ */
5
+ export declare function blankAttverOptions(definition: string): string;
6
+ /**
7
+ * Blank every `pg_attver` attribute option in a custom-format dump, in place.
8
+ * Returns how many TOC entries were changed; 0 also for a file this does not
9
+ * recognise, which pg_restore then reads as it is.
10
+ */
11
+ export declare function stripAttverFromArchive(dumpFile: string): number;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { d as readEnvFile } from "./project-CasK56vN.js";
2
+ import { d as readEnvFile } from "./project-CLcF5i8c.js";
3
3
  import { t as Refusal } from "./refusal-ReeeGP8a.js";
4
4
  import chalk from "chalk";
5
5
  import fs from "fs";
@@ -34,7 +34,7 @@ import net from "net";
34
34
  *
35
35
  * The schema push happens only when this function actually started the
36
36
  * container, which is the one moment a local database is known to be new or
37
- * stale relative to the collections. A `dev` against an already-running
37
+ * stale relative to the tables. A `dev` against an already-running
38
38
  * database never mutates its schema.
39
39
  *
40
40
  * One case stops the command instead of stepping aside: the URL is this
@@ -589,7 +589,7 @@ async function refuseForeignListener(options) {
589
589
  * schema if this call is what started it.
590
590
  */
591
591
  async function ensureDevDatabase(options) {
592
- const { projectRoot, databaseUrl, disabled, hasCollections, pushSchema } = options;
592
+ const { projectRoot, databaseUrl, disabled, hasTables, pushSchema } = options;
593
593
  const log = options.log ?? ((message) => console.log(message));
594
594
  if (disabled) return { action: "disabled" };
595
595
  const target = parseLoopbackDsn(databaseUrl);
@@ -699,7 +699,7 @@ async function ensureDevDatabase(options) {
699
699
  };
700
700
  }
701
701
  log(` ${chalk.green("✓")} ${chalk.gray(`Database ready on port ${target.port}`)}`);
702
- if (!hasCollections) return {
702
+ if (!hasTables) return {
703
703
  action: "started",
704
704
  port: target.port,
705
705
  pushed: false
@@ -726,4 +726,4 @@ async function ensureDevDatabase(options) {
726
726
  //#endregion
727
727
  export { parseLoopbackDsn as a, ensureDevDatabase as i, dev_preflight_exports as n, probeTcp as o, dockerClaimedPorts as r, composeDatabaseUrl as t };
728
728
 
729
- //# sourceMappingURL=dev-preflight-Cxv3TiD1.js.map
729
+ //# sourceMappingURL=dev-preflight-DjvcV6SK.js.map