@rebasepro/cli 0.31.0 → 0.33.0

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 (196) hide show
  1. package/dist/{agent-setup-DqAcoDcn.js → agent-setup-Cg_zBWoW.js} +3 -3
  2. package/dist/{agent-setup-DqAcoDcn.js.map → agent-setup-Cg_zBWoW.js.map} +1 -1
  3. package/dist/api-TbmW33D7.js +275 -0
  4. package/dist/api-TbmW33D7.js.map +1 -0
  5. package/dist/{api-keys-eIUjMqWn.js → api-keys-fPQ55DCm.js} +151 -158
  6. package/dist/api-keys-fPQ55DCm.js.map +1 -0
  7. package/dist/{apps-DExO4PEl.js → apps-DBTRoOeP.js} +18 -13
  8. package/dist/apps-DBTRoOeP.js.map +1 -0
  9. package/dist/{args-CaCcrYE1.js → args-DHyrshtI.js} +3 -132
  10. package/dist/args-DHyrshtI.js.map +1 -0
  11. package/dist/{atlas-dev-database-DOCKk6ht.js → atlas-dev-database-D6h65f2x.js} +3 -3
  12. package/dist/{atlas-dev-database-DOCKk6ht.js.map → atlas-dev-database-D6h65f2x.js.map} +1 -1
  13. package/dist/{auth-ofQETpM5.js → auth-BpyYLEFY.js} +93 -12
  14. package/dist/auth-BpyYLEFY.js.map +1 -0
  15. package/dist/auth-session-B6aT0Dyj.js +371 -0
  16. package/dist/auth-session-B6aT0Dyj.js.map +1 -0
  17. package/dist/{backend-guard-C0mVkXBw.js → backend-guard-Cf8eMK_f.js} +2 -2
  18. package/dist/{backend-guard-C0mVkXBw.js.map → backend-guard-Cf8eMK_f.js.map} +1 -1
  19. package/dist/{branch-pointer-DMPyvZoK.js → branch-pointer-BJOF2Ubv.js} +1 -1
  20. package/dist/{build-CA5R07tw.js → build-E5hfEWKj.js} +23 -10
  21. package/dist/build-E5hfEWKj.js.map +1 -0
  22. package/dist/{bundle-DgILeA5b.js → bundle-CIiKGrte.js} +78 -12
  23. package/dist/bundle-CIiKGrte.js.map +1 -0
  24. package/dist/bundle.d.ts +31 -1
  25. package/dist/{cloud-CYMk92iG.js → cloud-DNJyUU0T.js} +1715 -1516
  26. package/dist/cloud-DNJyUU0T.js.map +1 -0
  27. package/dist/{cms-directories-BK3vcswg.js → cms-directories-BaV-Is9a.js} +2 -2
  28. package/dist/{cms-directories-BK3vcswg.js.map → cms-directories-BaV-Is9a.js.map} +1 -1
  29. package/dist/codemod/collections-to-tables/backend.d.ts +0 -2
  30. package/dist/codemod/collections-to-tables/customization.d.ts +7 -1
  31. package/dist/codemod/collections-to-tables/modules.d.ts +32 -0
  32. package/dist/codemod/collections-to-tables/plan-context.d.ts +7 -1
  33. package/dist/{command-D5lhW_-B.js → command-Bks5xkrQ.js} +89 -44
  34. package/dist/command-Bks5xkrQ.js.map +1 -0
  35. package/dist/commands/api-keys.d.ts +89 -52
  36. package/dist/commands/api.d.ts +114 -0
  37. package/dist/commands/auth-session.d.ts +94 -0
  38. package/dist/commands/auth.d.ts +1 -1
  39. package/dist/commands/cloud/alerts.d.ts +29 -0
  40. package/dist/commands/cloud/context.d.ts +8 -0
  41. package/dist/commands/cloud/debug.d.ts +16 -1
  42. package/dist/commands/cloud/deploy-hooks.d.ts +19 -0
  43. package/dist/commands/cloud/deploy.d.ts +25 -0
  44. package/dist/commands/cloud/env.d.ts +12 -1
  45. package/dist/commands/cloud/index.d.ts +5 -0
  46. package/dist/commands/cloud/maintenance.d.ts +26 -1
  47. package/dist/commands/cloud/not-served.d.ts +27 -0
  48. package/dist/commands/cloud/orgs.d.ts +5 -0
  49. package/dist/commands/cloud/resources.d.ts +82 -2
  50. package/dist/commands/cloud/runtime-logs.d.ts +57 -0
  51. package/dist/commands/cloud/service-key.d.ts +33 -1
  52. package/dist/commands/cloud/settings.d.ts +3 -0
  53. package/dist/commands/cron.d.ts +68 -0
  54. package/dist/commands/data.d.ts +197 -0
  55. package/dist/commands/functions.d.ts +38 -0
  56. package/dist/commands/logs.d.ts +22 -0
  57. package/dist/commands/rls.d.ts +31 -0
  58. package/dist/commands/schema-reconcile.d.ts +2 -1
  59. package/dist/commands/schema-show.d.ts +38 -0
  60. package/dist/commands/storage-objects.d.ts +88 -0
  61. package/dist/commands/storage.d.ts +18 -2
  62. package/dist/commands/users.d.ts +147 -0
  63. package/dist/{consent-BXLIrMl8.js → consent-UV6ObCME.js} +2 -2
  64. package/dist/{consent-BXLIrMl8.js.map → consent-UV6ObCME.js.map} +1 -1
  65. package/dist/{console-DjThnr3f.js → console-BVoYOLAO.js} +6 -6
  66. package/dist/{console-DjThnr3f.js.map → console-BVoYOLAO.js.map} +1 -1
  67. package/dist/{context--JwaHaZp.js → context-BOMEoKxn.js} +80 -9
  68. package/dist/{context--JwaHaZp.js.map → context-BOMEoKxn.js.map} +1 -1
  69. package/dist/cron-CpUsQ739.js +298 -0
  70. package/dist/cron-CpUsQ739.js.map +1 -0
  71. package/dist/cron-ZRXsla0v.js +259 -0
  72. package/dist/cron-ZRXsla0v.js.map +1 -0
  73. package/dist/{daemon-w30PsdwV.js → daemon-D5gdG7gx.js} +3 -3
  74. package/dist/{daemon-w30PsdwV.js.map → daemon-D5gdG7gx.js.map} +1 -1
  75. package/dist/{daemon-entry-zOC1revO.js → daemon-entry--ummUJnk.js} +2 -2
  76. package/dist/{daemon-entry-zOC1revO.js.map → daemon-entry--ummUJnk.js.map} +1 -1
  77. package/dist/data-BJ9AZFUC.js +947 -0
  78. package/dist/data-BJ9AZFUC.js.map +1 -0
  79. package/dist/{db-Bz2RFGJj.js → db-D_iF4E-v.js} +38 -34
  80. package/dist/{db-Bz2RFGJj.js.map → db-D_iF4E-v.js.map} +1 -1
  81. package/dist/debug-nNbbxAeo.js +1114 -0
  82. package/dist/debug-nNbbxAeo.js.map +1 -0
  83. package/dist/{derive-C3ezmY-p.js → derive-Mky_u59_.js} +3 -3
  84. package/dist/{derive-C3ezmY-p.js.map → derive-Mky_u59_.js.map} +1 -1
  85. package/dist/{dev-D8TxrE_I.js → dev-bj6dEeSQ.js} +13 -13
  86. package/dist/{dev-D8TxrE_I.js.map → dev-bj6dEeSQ.js.map} +1 -1
  87. package/dist/dev-db/pull.d.ts +13 -3
  88. package/dist/{dev-preflight-DjvcV6SK.js → dev-preflight-BMOf2N6r.js} +2 -2
  89. package/dist/{dev-preflight-DjvcV6SK.js.map → dev-preflight-BMOf2N6r.js.map} +1 -1
  90. package/dist/{dev-server-BLxCbQEP.js → dev-server-2XHSHM_q.js} +2 -2
  91. package/dist/{dev-server-BLxCbQEP.js.map → dev-server-2XHSHM_q.js.map} +1 -1
  92. package/dist/{doctor-Du-mSxoE.js → doctor-FaBObSlb.js} +29 -10
  93. package/dist/doctor-FaBObSlb.js.map +1 -0
  94. package/dist/doctor-environment.d.ts +9 -0
  95. package/dist/{eject-Bhzd6hgb.js → eject-DK_M9kor.js} +4 -4
  96. package/dist/{eject-Bhzd6hgb.js.map → eject-DK_M9kor.js.map} +1 -1
  97. package/dist/{fold-static-CKewnAPX.js → fold-static-2t3UUX4z.js} +10 -6
  98. package/dist/fold-static-2t3UUX4z.js.map +1 -0
  99. package/dist/fold-static.d.ts +7 -0
  100. package/dist/functions-B4JR6EZL.js +120 -0
  101. package/dist/functions-B4JR6EZL.js.map +1 -0
  102. package/dist/{generate-view-CTOluXvH.js → generate-view-BMaLQm8H.js} +5 -5
  103. package/dist/{generate-view-CTOluXvH.js.map → generate-view-BMaLQm8H.js.map} +1 -1
  104. package/dist/{generate_sdk-De-aLC1L.js → generate_sdk-ByD-gTsK.js} +7 -7
  105. package/dist/{generate_sdk-De-aLC1L.js.map → generate_sdk-ByD-gTsK.js.map} +1 -1
  106. package/dist/index.es.js +123 -47
  107. package/dist/index.es.js.map +1 -1
  108. package/dist/{init-Dtl-IcXf.js → init-DHCe5mJ5.js} +59 -11
  109. package/dist/init-DHCe5mJ5.js.map +1 -0
  110. package/dist/{invoked-command-CG_rIa_o.js → invoked-command-FBeIBS8o.js} +2 -2
  111. package/dist/{invoked-command-CG_rIa_o.js.map → invoked-command-FBeIBS8o.js.map} +1 -1
  112. package/dist/last-dev-database-CBVkEUEl.js +2 -0
  113. package/dist/legacy-layout-DI2VeQSV.js +36 -0
  114. package/dist/legacy-layout-DI2VeQSV.js.map +1 -0
  115. package/dist/logs-DpuMukJe.js +192 -0
  116. package/dist/logs-DpuMukJe.js.map +1 -0
  117. package/dist/{manifest-C3uLDrrJ.js → manifest-RjqxfCpb.js} +114 -5
  118. package/dist/manifest-RjqxfCpb.js.map +1 -0
  119. package/dist/{migrate-VrKoi3nB.js → migrate-CSY9ZDKy.js} +5 -4
  120. package/dist/{migrate-VrKoi3nB.js.map → migrate-CSY9ZDKy.js.map} +1 -1
  121. package/dist/{normalize-imports-DwxqEMYq.js → normalize-imports-P86NVfpo.js} +3 -3
  122. package/dist/{normalize-imports-DwxqEMYq.js.map → normalize-imports-P86NVfpo.js.map} +1 -1
  123. package/dist/{path-flags-7O5uPBcQ.js → path-flags-ekLdkbra.js} +3 -3
  124. package/dist/{path-flags-7O5uPBcQ.js.map → path-flags-ekLdkbra.js.map} +1 -1
  125. package/dist/{prepare-Ccxspoj-.js → prepare-BaJe0Zik.js} +4 -4
  126. package/dist/{prepare-Ccxspoj-.js.map → prepare-BaJe0Zik.js.map} +1 -1
  127. package/dist/{project-CLcF5i8c.js → project-DALmhb5R.js} +2 -2
  128. package/dist/{project-CLcF5i8c.js.map → project-DALmhb5R.js.map} +1 -1
  129. package/dist/project-command-Cl9EZzjr.js +662 -0
  130. package/dist/project-command-Cl9EZzjr.js.map +1 -0
  131. package/dist/{project-schema-CsSOG2gE.js → project-schema-Dm6Jk0Y_.js} +4 -2
  132. package/dist/{project-schema-CsSOG2gE.js.map → project-schema-Dm6Jk0Y_.js.map} +1 -1
  133. package/dist/{pull-BMuiUyjb.js → pull-CTIsST6T.js} +66 -5
  134. package/dist/pull-CTIsST6T.js.map +1 -0
  135. package/dist/resolve-C36px9tR.js +2 -0
  136. package/dist/{resources-Dpfs2y8P.js → resources-Db3USuPO.js} +5 -5
  137. package/dist/{resources-Dpfs2y8P.js.map → resources-Db3USuPO.js.map} +1 -1
  138. package/dist/rls-BxrQ0P50.js +133 -0
  139. package/dist/rls-BxrQ0P50.js.map +1 -0
  140. package/dist/{schema-Dv6nHkb0.js → schema-_FzZEoB8.js} +54 -40
  141. package/dist/schema-_FzZEoB8.js.map +1 -0
  142. package/dist/{schema-dir-Cd1kvYbf.js → schema-dir-ChcYfWjP.js} +2 -2
  143. package/dist/{schema-dir-Cd1kvYbf.js.map → schema-dir-ChcYfWjP.js.map} +1 -1
  144. package/dist/schema-reconcile-DV14XY4o.js +2 -0
  145. package/dist/schema-show-h72UJ9zH.js +127 -0
  146. package/dist/schema-show-h72UJ9zH.js.map +1 -0
  147. package/dist/{skills-CXjA9TWw.js → skills-DQ2bZGkj.js} +6 -5
  148. package/dist/{skills-CXjA9TWw.js.map → skills-DQ2bZGkj.js.map} +1 -1
  149. package/dist/star-nudge.d.ts +28 -0
  150. package/dist/{start-Bwbtt2W5.js → start-Cjx4W0bJ.js} +7 -7
  151. package/dist/{start-Bwbtt2W5.js.map → start-Cjx4W0bJ.js.map} +1 -1
  152. package/dist/{status-BTgTWzlQ.js → status-CDBk25VO.js} +9 -9
  153. package/dist/{status-BTgTWzlQ.js.map → status-CDBk25VO.js.map} +1 -1
  154. package/dist/{storage-iTqj5-Av.js → storage-Clc8dLG8.js} +79 -36
  155. package/dist/storage-Clc8dLG8.js.map +1 -0
  156. package/dist/storage-objects-CfRKlTDe.js +279 -0
  157. package/dist/storage-objects-CfRKlTDe.js.map +1 -0
  158. package/dist/{telemetry-BP_1Cl9r.js → telemetry-DZU2-NCm.js} +5 -4
  159. package/dist/{telemetry-BP_1Cl9r.js.map → telemetry-DZU2-NCm.js.map} +1 -1
  160. package/dist/{telemetry-M3HjlyhZ.js → telemetry-EVtASbKb.js} +2 -2
  161. package/dist/{telemetry-M3HjlyhZ.js.map → telemetry-EVtASbKb.js.map} +1 -1
  162. package/dist/unknown-command-DnZ2uhGs.js +139 -0
  163. package/dist/unknown-command-DnZ2uhGs.js.map +1 -0
  164. package/dist/{upgrade-oZzJ13jM.js → upgrade-ZASvgxWM.js} +41 -9
  165. package/dist/{upgrade-oZzJ13jM.js.map → upgrade-ZASvgxWM.js.map} +1 -1
  166. package/dist/users-5PkqBY6R.js +561 -0
  167. package/dist/users-5PkqBY6R.js.map +1 -0
  168. package/dist/utils/legacy-layout.d.ts +22 -0
  169. package/dist/utils/project-command.d.ts +38 -0
  170. package/dist/utils/project-target.d.ts +193 -0
  171. package/dist/{verify-BkUVGLqo.js → verify-BdeqNb-V.js} +138 -12
  172. package/dist/verify-BdeqNb-V.js.map +1 -0
  173. package/dist/{version-Buyyo1ut.js → version-ONIeo7jl.js} +7 -2
  174. package/dist/{version-Buyyo1ut.js.map → version-ONIeo7jl.js.map} +1 -1
  175. package/package.json +10 -10
  176. package/templates/overlays/baas/backend/package.json +3 -1
  177. package/templates/template/backend/package.json +3 -1
  178. package/dist/api-keys-eIUjMqWn.js.map +0 -1
  179. package/dist/apps-DExO4PEl.js.map +0 -1
  180. package/dist/args-CaCcrYE1.js.map +0 -1
  181. package/dist/auth-ofQETpM5.js.map +0 -1
  182. package/dist/build-CA5R07tw.js.map +0 -1
  183. package/dist/bundle-DgILeA5b.js.map +0 -1
  184. package/dist/cloud-CYMk92iG.js.map +0 -1
  185. package/dist/command-D5lhW_-B.js.map +0 -1
  186. package/dist/doctor-Du-mSxoE.js.map +0 -1
  187. package/dist/fold-static-CKewnAPX.js.map +0 -1
  188. package/dist/init-Dtl-IcXf.js.map +0 -1
  189. package/dist/last-dev-database-Dc8cP01o.js +0 -2
  190. package/dist/manifest-C3uLDrrJ.js.map +0 -1
  191. package/dist/pull-BMuiUyjb.js.map +0 -1
  192. package/dist/resolve-BY7bSFRT.js +0 -2
  193. package/dist/schema-Dv6nHkb0.js.map +0 -1
  194. package/dist/schema-reconcile-CjxLaRHB.js +0 -2
  195. package/dist/storage-iTqj5-Av.js.map +0 -1
  196. package/dist/verify-BkUVGLqo.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-BkUVGLqo.js","names":[],"sources":["../src/commands/verify-cms.ts","../src/commands/verify.ts"],"sourcesContent":["/**\n * `rebase verify`, step \"CMS customizations\": the project's\n * `customizeTable(...)` calls held to the tables they customize.\n *\n * The panel applies a customization at runtime and, for a slug or a field the\n * tables do not have, only warns in the browser console in development\n * (`applyTableCustomizations`). An agent that misspells a slug, keeps a field\n * after renaming its column, or hides a required column from the form ships a\n * panel that silently ignores the edit — or one that cannot create a record.\n * The post-edit hook runs `rebase verify` after edits under `frontend/src/cms`,\n * so this step is what answers for those files.\n *\n * **Read statically.** A customization module imports `@rebasepro/cms` (React,\n * the browser panel) and the project's own components, so it cannot be\n * imported in Node without the frontend's toolchain. The calls are read with\n * ts-morph instead: the slug, the keys of `fields`, and the literal values of\n * the form options of each field. What a static read cannot see — a slug or\n * options computed at runtime, a spread, a computed key, a `dynamicProps` /\n * `conditions` that hides a field on some records, a global `beforeSave` hook\n * in `backend/hooks.ts` that fills a column — is either reported as not read\n * (`cms-not-static`) or not judged; it is never reported as a problem.\n *\n * Checks (stable ids):\n *\n * - `cms-unknown-table` — `customizeTable(\"x\")` for a slug no table declares.\n * - `cms-unknown-field` — a `fields` key that is neither a column key nor a\n * relation of that table.\n * - `cms-hidden-required` — a field kept off the form (`hiddenInForm`,\n * `readOnly`, `disabled`) whose column is `NOT NULL` with no default, that\n * neither the database nor the server fills, and that the customization does\n * not mark `filledByServer`: no record can be created from the panel. A\n * warning instead of an error when the table declares a `beforeSave` hook\n * (or the column a `beforeSave` transform), which may be what fills it.\n * - `cms-duplicate-customization` — two `customizeTable` calls for one slug.\n * The panel refuses to mount with both.\n * - `cms-not-static` — a call this step could not read (warning).\n * - `cms-ui-config-not-mounted` — `src/cms/ui-config.json` exists, where the\n * collection editor saves presentation in development, but no `<RebaseCMS>`\n * in the frontend passes `uiConfig`: the editor's changes are lost on\n * reload and never ship (warning). Said only when a `<RebaseCMS>` element\n * was found and none of them passes `uiConfig` or spreads props into it.\n * - `cms-backend-guard-missing` — the project has `backend/` and a frontend\n * whose Vite config does not use `rebaseBackendGuard()`: nothing refuses a\n * value import of a table, which would ship its server hooks to every\n * visitor (`utils/backend-guard.ts`). Quiet when the config imports a local\n * module that may add it, and checked whether or not `src/cms` exists.\n */\nimport fs from \"fs\";\nimport path from \"path\";\nimport type { ColumnDescriptor, TableDescriptor } from \"@rebasepro/types\";\nimport type { Expression, Node, ObjectLiteralExpression, Project, SourceFile } from \"ts-morph\";\nimport { cmsDirectories } from \"../utils/cms-directories\";\nimport { BACKEND_GUARD_FIX, backendGuardMissingMessage, backendGuardStates } from \"../utils/backend-guard\";\n\ntype TsMorph = typeof import(\"ts-morph\");\n\n/** The package `customizeTable` is imported from. */\nconst CMS_PACKAGE = \"@rebasepro/cms\";\nconst CUSTOMIZE = \"customizeTable\";\n/** The panel's mount, and the file the collection editor writes presentation to in development. */\nconst MOUNT = \"RebaseCMS\";\nconst UI_CONFIG_FILE = \"ui-config.json\";\nconst SOURCE = /\\.(ts|tsx|mts|js|jsx|mjs)$/;\nconst NOT_SOURCE = /\\.(d|test|spec)\\.[cm]?[jt]sx?$/;\n\n/** The form options that keep a field from being edited on the form. */\nconst OFF_FORM_OPTIONS = [\"hiddenInForm\", \"readOnly\", \"disabled\"] as const;\ntype OffFormOption = typeof OFF_FORM_OPTIONS[number];\n\n/** A finding of this step, in `rebase verify`'s finding shape (step `cms`). */\nexport interface CmsFinding {\n check: \"cms-unknown-table\" | \"cms-unknown-field\" | \"cms-hidden-required\" | \"cms-duplicate-customization\" | \"cms-not-static\" | \"cms-ui-config-not-mounted\" | \"cms-backend-guard-missing\";\n severity: \"error\" | \"warning\";\n message: string;\n fix?: string;\n table?: string;\n /** Relative to the project root. */\n file: string;\n line: number;\n /** `customizeTable(\"posts\").fields.title`. */\n path?: string;\n}\n\n/** What the step read and found. */\nexport interface CmsCheckResult {\n /** The customization directories read, relative to the project root. Empty: nothing to check. */\n directories: string[];\n /** How many `customizeTable` calls were found. */\n customizations: number;\n findings: CmsFinding[];\n}\n\n/** One field of a customization, as far as a static read says. */\ninterface FieldRead {\n key: string;\n line: number;\n /** The off-form options written as `true` (an object for `disabled` counts). */\n offForm: OffFormOption[];\n /** `filledByServer` as written: true or false, `undefined` when not stated, `\"unknown\"` when not a literal. */\n filledByServer: boolean | undefined | \"unknown\";\n /** A spread in the field's options: what it carries is not known. */\n opaque: boolean;\n}\n\n/** One `customizeTable(...)` call, as far as a static read says. */\ninterface CustomizationRead {\n slug: string;\n file: string;\n line: number;\n fields: FieldRead[];\n /** What could not be read in it. */\n unread: string[];\n}\n\nfunction sourceFiles(dir: string): string[] {\n const out: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) out.push(...sourceFiles(full));\n else if (SOURCE.test(entry.name) && !NOT_SOURCE.test(entry.name)) out.push(full);\n }\n return out.sort();\n}\n\n// ─── The static read ──────────────────────────────────────────────────────────\n\nclass Reader {\n constructor(private readonly tsm: TsMorph) {}\n\n private unwrap(node: Node): Node {\n const N = this.tsm.Node;\n let current = node;\n while (N.isAsExpression(current) || N.isSatisfiesExpression(current) || N.isParenthesizedExpression(current) ||\n N.isNonNullExpression(current) || N.isTypeAssertion(current)) {\n current = current.getExpression();\n }\n return current;\n }\n\n /** The initializer of the top-level `const` an identifier names, in its own file. */\n private constOf(node: Node): Expression | undefined {\n const N = this.tsm.Node;\n if (!N.isIdentifier(node)) return undefined;\n const declaration = node.getSourceFile().getVariableDeclaration(node.getText());\n const statement = declaration?.getVariableStatement();\n if (!declaration || !statement || !N.isSourceFile(statement.getParent())) return undefined;\n if (statement.getDeclarationKind() !== this.tsm.VariableDeclarationKind.Const) return undefined;\n return declaration.getInitializer();\n }\n\n /** A string a node denotes: a literal, or a same-file `const` holding one. */\n string(node: Node | undefined, depth = 0): string | undefined {\n if (!node || depth > 4) return undefined;\n const N = this.tsm.Node;\n const current = this.unwrap(node);\n if (N.isStringLiteral(current) || N.isNoSubstitutionTemplateLiteral(current)) return current.getLiteralValue();\n const initializer = this.constOf(current);\n return initializer ? this.string(initializer, depth + 1) : undefined;\n }\n\n /** The object literal a node denotes: itself, or a same-file `const` holding one. */\n object(node: Node | undefined, depth = 0): ObjectLiteralExpression | undefined {\n if (!node || depth > 4) return undefined;\n const N = this.tsm.Node;\n const current = this.unwrap(node);\n if (N.isObjectLiteralExpression(current)) return current;\n const initializer = this.constOf(current);\n return initializer ? this.object(initializer, depth + 1) : undefined;\n }\n\n /** A property's name as written, or undefined for a computed one. */\n name(member: Node): string | undefined {\n const N = this.tsm.Node;\n if (!N.isPropertyAssignment(member) && !N.isShorthandPropertyAssignment(member) && !N.isMethodDeclaration(member)) return undefined;\n const nameNode = member.getNameNode();\n if (N.isIdentifier(nameNode)) return nameNode.getText();\n if (N.isStringLiteral(nameNode) || N.isNoSubstitutionTemplateLiteral(nameNode)) return nameNode.getLiteralValue();\n if (N.isNumericLiteral(nameNode)) return String(nameNode.getLiteralValue());\n if (N.isComputedPropertyName(nameNode)) return this.string(nameNode.getExpression());\n return undefined;\n }\n\n /** The value of a member: an assignment's initializer, a shorthand's identifier. */\n value(member: Node): Node | undefined {\n const N = this.tsm.Node;\n if (N.isPropertyAssignment(member)) return member.getInitializer();\n if (N.isShorthandPropertyAssignment(member)) return member.getNameNode();\n return undefined;\n }\n\n /** `true` / `false` as written, an object literal as `true` (for `disabled: { … }`), else unknown. */\n flag(node: Node | undefined, objectIsTrue: boolean): boolean | \"unknown\" {\n if (!node) return \"unknown\";\n const N = this.tsm.Node;\n const { SyntaxKind } = this.tsm;\n const current = this.unwrap(node);\n if (current.getKind() === SyntaxKind.TrueKeyword) return true;\n if (current.getKind() === SyntaxKind.FalseKeyword) return false;\n if (objectIsTrue && N.isObjectLiteralExpression(current)) return true;\n return \"unknown\";\n }\n\n /** The local names `customizeTable` is bound to, and namespaces of the CMS package. */\n private bindings(sf: SourceFile): { names: Set<string>; namespaces: Set<string> } {\n const names = new Set<string>();\n const namespaces = new Set<string>();\n for (const declaration of sf.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== CMS_PACKAGE || declaration.isTypeOnly()) continue;\n const namespace = declaration.getNamespaceImport();\n if (namespace) namespaces.add(namespace.getText());\n for (const named of declaration.getNamedImports()) {\n if (named.getName() === CUSTOMIZE && !named.isTypeOnly()) names.add(named.getAliasNode()?.getText() ?? CUSTOMIZE);\n }\n }\n return { names, namespaces };\n }\n\n field(key: string, member: Node): FieldRead {\n const N = this.tsm.Node;\n const read: FieldRead = { key, line: member.getStartLineNumber(), offForm: [], filledByServer: undefined, opaque: false };\n const options = this.object(this.value(member));\n if (!options) {\n read.opaque = true;\n return read;\n }\n for (const property of options.getProperties()) {\n if (N.isSpreadAssignment(property)) {\n read.opaque = true;\n continue;\n }\n const name = this.name(property);\n if (name === undefined) {\n read.opaque = true;\n continue;\n }\n const value = this.value(property);\n if (name === \"filledByServer\") read.filledByServer = this.flag(value, false);\n const option = OFF_FORM_OPTIONS.find(candidate => candidate === name);\n if (option && this.flag(value, option === \"disabled\") === true) read.offForm.push(option);\n }\n return read;\n }\n\n /** Every `customizeTable(...)` call in a file, read as far as the source says. */\n customizations(sf: SourceFile, relativeFile: string): CustomizationRead[] {\n const N = this.tsm.Node;\n const { SyntaxKind } = this.tsm;\n const { names, namespaces } = this.bindings(sf);\n if (names.size === 0 && namespaces.size === 0) return [];\n const out: CustomizationRead[] = [];\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression();\n const isCustomize = (N.isIdentifier(callee) && names.has(callee.getText())) ||\n (N.isPropertyAccessExpression(callee) && callee.getName() === CUSTOMIZE && namespaces.has(callee.getExpression().getText()));\n if (!isCustomize) continue;\n const [slugNode, optionsNode] = call.getArguments();\n const read: CustomizationRead = { slug: \"\", file: relativeFile, line: call.getStartLineNumber(), fields: [], unread: [] };\n const slug = this.string(slugNode);\n if (slug === undefined) {\n read.unread.push(`the slug \\`${slugNode?.getText() ?? \"\"}\\` is not a string literal or a \\`const\\` of one in this file`);\n out.push(read);\n continue;\n }\n read.slug = slug;\n const options = this.object(optionsNode);\n if (!options) {\n read.unread.push(`the options \\`${optionsNode?.getText().split(\"\\n\")[0] ?? \"\"}\\` are not an object literal or a \\`const\\` of one in this file`);\n out.push(read);\n continue;\n }\n let fieldsNode: Node | undefined;\n for (const property of options.getProperties()) {\n if (N.isSpreadAssignment(property)) {\n read.unread.push(`\\`...${property.getExpression().getText()}\\` (line ${property.getStartLineNumber()}) may carry \\`fields\\``);\n continue;\n }\n if (this.name(property) === \"fields\") fieldsNode = this.value(property);\n }\n if (fieldsNode) {\n const fields = this.object(fieldsNode);\n if (!fields) {\n read.unread.push(`\\`fields\\` (line ${fieldsNode.getStartLineNumber()}) is not an object literal or a \\`const\\` of one in this file`);\n } else {\n for (const member of fields.getProperties()) {\n const key = this.name(member);\n if (key === undefined) {\n read.unread.push(`\\`${member.getText().split(\"\\n\")[0]}\\` (line ${member.getStartLineNumber()}) in \\`fields\\``);\n continue;\n }\n read.fields.push(this.field(key, member));\n }\n }\n }\n out.push(read);\n }\n return out;\n }\n}\n\n// ─── The checks ───────────────────────────────────────────────────────────────\n\n/** Levenshtein distance, for \"did you mean\". */\nfunction distance(a: string, b: string): number {\n const row = Array.from({ length: b.length + 1 }, (_, i) => i);\n for (let i = 1; i <= a.length; i++) {\n let previous = row[0];\n row[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const current = row[j];\n row[j] = Math.min(row[j] + 1, row[j - 1] + 1, previous + (a[i - 1].toLowerCase() === b[j - 1].toLowerCase() ? 0 : 1));\n previous = current;\n }\n }\n return row[b.length];\n}\n\nfunction closest(name: string, candidates: Iterable<string>): string | undefined {\n let best: string | undefined;\n let bestDistance = Math.max(2, Math.floor(name.length / 3)) + 1;\n for (const candidate of candidates) {\n const d = distance(name, candidate);\n if (d < bestDistance) {\n best = candidate;\n bestDistance = d;\n }\n }\n return best;\n}\n\nconst SERIAL_KINDS: ReadonlySet<string> = new Set([\"smallserial\", \"serial\", \"bigserial\"]);\n\n/**\n * Whether a create may leave the column out and still succeed without the\n * server's help from a hook: it is nullable, has a default (literal, SQL,\n * random uuid, identity, the database's), is a serial, is generated, is\n * stamped or read-only (the server writes it), or is the tenant column (the\n * server fills it from the caller).\n */\nfunction fillsItself(table: TableDescriptor, column: ColumnDescriptor): boolean {\n return column.nullable ||\n column.default !== undefined ||\n SERIAL_KINDS.has(column.type.kind) ||\n column.generated !== undefined ||\n column.stamp !== undefined ||\n column.readOnly === true ||\n table.tenant?.field === column.key;\n}\n\n/** The column a field key edits: the column itself, or the foreign key of a `belongsTo` relation. */\nfunction columnOfField(table: TableDescriptor, key: string): ColumnDescriptor | undefined {\n return table.columns.find(column => column.key === key) ??\n table.columns.find(column => column.foreignKeyOf === key);\n}\n\nfunction describeOffForm(options: readonly OffFormOption[]): string {\n return options.map(option => `\\`${option}\\``).join(\" and \");\n}\n\nfunction checkCustomization(read: CustomizationRead, table: TableDescriptor): CmsFinding[] {\n const findings: CmsFinding[] = [];\n const where = `customizeTable(\"${read.slug}\")`;\n const columnKeys = new Set(table.columns.map(column => column.key));\n const relationNames = new Set(table.relations.map(relation => relation.name));\n for (const field of read.fields) {\n const at = { table: table.slug, file: read.file, line: field.line, path: `${where}.fields.${field.key}` };\n if (!columnKeys.has(field.key) && !relationNames.has(field.key)) {\n const bySqlName = table.columns.find(column => column.column === field.key);\n const guess = bySqlName?.key ?? closest(field.key, [...columnKeys, ...relationNames]);\n findings.push({\n check: \"cms-unknown-field\",\n severity: \"error\",\n ...at,\n message: `${where} customizes \\`fields.${field.key}\\`, which is neither a column nor a relation of the \"${table.slug}\" table` +\n (bySqlName ? ` — that is the SQL name of the column whose key is \\`${bySqlName.key}\\`.` : \".\"),\n fix: guess\n ? `Rename the key to \\`${guess}\\`${bySqlName ? \" (fields are keyed by the column's key, as in `columns`)\" : \"\"}, or remove it.`\n : \"Remove it, or key it by one of the table's columns or relations (`columns` / `relations` in its `defineTable`).\"\n });\n continue;\n }\n if (field.offForm.length === 0 || field.filledByServer === true) continue;\n // A spread or a non-literal `filledByServer` may say it: not judged.\n if (field.opaque || field.filledByServer === \"unknown\") continue;\n const column = columnOfField(table, field.key);\n if (!column || fillsItself(table, column)) continue;\n const hooked = table.hooks?.beforeSave === true || column.transforms?.beforeSave === true;\n const what = column.key === field.key ? `the column \\`${column.column}\\`` : `its foreign key \\`${column.column}\\``;\n findings.push({\n check: \"cms-hidden-required\",\n severity: hooked ? \"warning\" : \"error\",\n ...at,\n message: `${where} keeps \\`${field.key}\\` off the form (${describeOffForm(field.offForm)}), but ${what} is NOT NULL with no default ` +\n (hooked\n ? `and only the table's \\`beforeSave\\` hook could fill it: unless it does, creating a record from the panel fails.`\n : `and nothing on the server fills it: creating a \"${table.slug}\" record from the panel always fails.`),\n fix: hooked\n ? `If the hook fills it on create, say so: \\`${field.key}: { …, filledByServer: true }\\`. Otherwise let the form edit it.`\n : `Let the form edit it (drop ${describeOffForm(field.offForm)}), give the column a default in its \\`defineTable\\` (\\`.default(…)\\`), ` +\n `or fill it in a \\`beforeSave\\` hook and mark the field \\`filledByServer: true\\`.`\n });\n }\n return findings;\n}\n\n/**\n * Read every `customizeTable(...)` call under the project's customization\n * directories and hold it to `tables`. Never throws on a file it cannot parse\n * as intended: what it cannot read is a `cms-not-static` warning.\n */\nexport async function checkCmsCustomizations(projectRoot: string, tables: readonly TableDescriptor[]): Promise<CmsCheckResult> {\n const directories = cmsDirectories(projectRoot);\n const result: CmsCheckResult = { directories: directories.map(dir => path.relative(projectRoot, dir)), customizations: 0, findings: [] };\n result.findings.push(...await backendGuardFindings(projectRoot));\n if (directories.length === 0) return result;\n\n const tsm: TsMorph = await import(\"ts-morph\");\n const project = new tsm.Project({\n useInMemoryFileSystem: true,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: { allowJs: true, jsx: tsm.ts.JsxEmit.Preserve, noLib: true }\n });\n const reader = new Reader(tsm);\n const bySlug = new Map(tables.map(table => [table.slug, table]));\n const first = new Map<string, CustomizationRead>();\n\n for (const dir of directories) {\n for (const file of sourceFiles(dir)) {\n const text = fs.readFileSync(file, \"utf-8\");\n if (!text.includes(CUSTOMIZE)) continue;\n const relativeFile = path.relative(projectRoot, file);\n const sf = project.createSourceFile(file, text, { overwrite: true });\n for (const read of reader.customizations(sf, relativeFile)) {\n result.customizations++;\n const label = read.slug ? `customizeTable(\"${read.slug}\")` : \"customizeTable(…)\";\n if (read.unread.length > 0) {\n result.findings.push({\n check: \"cms-not-static\",\n severity: \"warning\",\n file: read.file,\n line: read.line,\n ...(read.slug && { table: read.slug, path: label }),\n message: `${label} was not fully checked: ${read.unread.join(\"; \")}. ` +\n \"`rebase verify` reads customizations without running them, so only literals in the call are checked.\",\n fix: \"Write the slug and the `fields` object as literals in the call (a `const` in the same file also works), or ignore this warning.\"\n });\n }\n if (!read.slug) continue;\n const earlier = first.get(read.slug);\n if (earlier) {\n result.findings.push({\n check: \"cms-duplicate-customization\",\n severity: \"error\",\n table: read.slug,\n file: read.file,\n line: read.line,\n path: label,\n message: `${label} is written twice: here and in ${earlier.file}:${earlier.line}. The panel refuses to start with both.`,\n fix: \"Merge them into one `customizeTable` call and remove the other.\"\n });\n continue;\n }\n first.set(read.slug, read);\n const table = bySlug.get(read.slug);\n if (!table) {\n const guess = closest(read.slug, bySlug.keys());\n result.findings.push({\n check: \"cms-unknown-table\",\n severity: \"error\",\n table: read.slug,\n file: read.file,\n line: read.line,\n path: label,\n message: `${label} customizes \"${read.slug}\", which no table in the schema declares as its slug. The panel ignores it.`,\n fix: guess\n ? `Did you mean \"${guess}\"? The first argument is the table's slug (its \\`defineTable\\` name, unless it sets \\`slug\\`).`\n : \"Pass the slug of a table the schema index exports (its `defineTable` name, unless it sets `slug`), or remove the customization.\"\n });\n continue;\n }\n result.findings.push(...checkCustomization(read, table));\n }\n project.removeSourceFile(sf);\n }\n const unmounted = uiConfigNotMounted(tsm, project, projectRoot, dir);\n if (unmounted) result.findings.push(unmounted);\n }\n return result;\n}\n\n/**\n * The `cms-ui-config-not-mounted` finding for one customization directory, or\n * nothing. Undecided — no `<RebaseCMS>` element found under `src/` (mounted\n * through a wrapper, rendered without JSX) — is nothing, not a warning.\n */\nfunction uiConfigNotMounted(tsm: TsMorph, project: Project, projectRoot: string, cmsDir: string): CmsFinding | undefined {\n const uiConfig = path.join(cmsDir, UI_CONFIG_FILE);\n if (!fs.existsSync(uiConfig)) return undefined;\n const N = tsm.Node;\n const { SyntaxKind } = tsm;\n const mounts: { file: string; line: number; passes: boolean }[] = [];\n for (const file of sourceFiles(path.dirname(cmsDir))) {\n const text = fs.readFileSync(file, \"utf-8\");\n if (!text.includes(MOUNT)) continue;\n const sf = project.createSourceFile(file, text, { overwrite: true });\n const names = new Set<string>();\n for (const declaration of sf.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== CMS_PACKAGE) continue;\n for (const named of declaration.getNamedImports()) {\n if (named.getName() === MOUNT) names.add(named.getAliasNode()?.getText() ?? MOUNT);\n }\n }\n const elements = [\n ...sf.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),\n ...sf.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n ];\n for (const element of elements) {\n if (!names.has(element.getTagNameNode().getText())) continue;\n const passes = element.getAttributes().some(attribute =>\n N.isJsxSpreadAttribute(attribute) || attribute.getNameNode().getText() === \"uiConfig\");\n mounts.push({ file: path.relative(projectRoot, file), line: element.getStartLineNumber(), passes });\n }\n project.removeSourceFile(sf);\n }\n if (mounts.length === 0 || mounts.some(mount => mount.passes)) return undefined;\n const [first] = mounts;\n return {\n check: \"cms-ui-config-not-mounted\",\n severity: \"warning\",\n file: first.file,\n line: first.line,\n message: `${path.relative(projectRoot, uiConfig)} holds what the collection editor saves in development, but \\`<RebaseCMS>\\` is not given it: ` +\n \"presentation edited in the editor is gone after a reload and never ships.\",\n fix: `Import it and pass it: \\`import uiConfig from \"./cms/${UI_CONFIG_FILE}\";\\` and \\`<RebaseCMS … uiConfig={uiConfig} />\\` ` +\n \"(the frontend's tsconfig needs `resolveJsonModule`).\"\n };\n}\n\n/**\n * `cms-backend-guard-missing`, one per frontend whose Vite config does not use\n * the guard. Nothing for a frontend the static read cannot decide.\n */\nasync function backendGuardFindings(projectRoot: string): Promise<CmsFinding[]> {\n return (await backendGuardStates(projectRoot))\n .filter(state => state.state === \"missing\")\n .map(state => ({\n check: \"cms-backend-guard-missing\",\n severity: \"error\",\n file: state.viteConfig,\n line: state.line,\n message: backendGuardMissingMessage(state),\n fix: BACKEND_GUARD_FIX\n }));\n}\n","/**\n * CLI command: rebase verify\n *\n * One command that says whether the tables are safe to ship, fast enough to\n * run after every edit. An agent editing `backend/schema/*.ts` gets a table\n * definition wrong — a relation to a table the index does not export, an\n * `rls: \"inherit\"` with no `defaultRls`, a table with no primary key — or\n * writes rules that hand every row of a per-user table to everyone; each of\n * those used to surface late: at boot, in review, or never. The project's\n * Claude Code hook (written by `rebase init` and `rebase skills --hooks`) runs\n * this after each edit to a schema file, and CI runs it on every push.\n *\n * Five steps, each reported on its own:\n *\n * 1. **Table definitions** — `backend/schema` loads and compiles through\n * `loadBackendSchema`, the loader the backend boots from, so every problem\n * it would refuse to boot on is a finding here, one per problem.\n * 2. **RLS coverage** — a table with a `user_id` / `owner_id` /\n * `organization_id` / `tenant_id` column whose rules (its own, or the\n * `defaultRls` it inherits) let a role read every row regardless of it.\n * `rls` itself is mandatory, so \"no rules at all\" is a step-1 error now.\n * 3. **CMS customizations** — every `customizeTable(...)` under\n * `frontend/src/cms`, read statically (`verify-cms.ts`): a slug no table\n * declares, a field that is not a column or relation of its table, a\n * required column kept off the form, one table customized twice. A\n * project without `frontend/src/cms` (headless) skips it.\n * 4. **Migration freshness** — whether `drizzle/migrations` still builds the\n * tables and columns the schema declares (offline), and with `--live`\n * whether the database has applied every migration.\n * 5. **Live RLS audit** — with `--live`, the `@rebasepro/rls-check` catalogue\n * against the project's database, resolved as `db *` resolves it (the\n * managed one unless something names another).\n *\n * `--json` prints one object an agent can act on: every finding carries the\n * file, the dotted path into the table and the fix.\n */\nimport chalk from \"chalk\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport {\n parseEnvBoolean,\n type SecurityRule,\n type TableDescriptor\n} from \"@rebasepro/types\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\nimport { failAsJson, findBackendDir, getActiveBackendPlugin, readEnvFile, requireProjectRoot } from \"../utils/project\";\nimport { SCHEMA_DIR_FLAG_HELP, missingSchemaDir, refuseRemovedCollectionsFlag } from \"../utils/path-flags\";\nimport { resolveSchemaDir } from \"../utils/schema-dir\";\nimport { loadProjectSchema, type ModuleAliases, type ProjectSchema } from \"../utils/project-schema\";\nimport { checkCmsCustomizations } from \"./verify-cms\";\n\n/** The flags `rebase verify` takes. */\nexport const VERIFY_FLAGS = {\n \"--schema-dir\": String,\n \"--json\": Boolean,\n \"--quiet\": Boolean,\n \"-q\": \"--quiet\",\n \"--live\": Boolean,\n \"--database-url\": String,\n \"--docker\": Boolean\n} as const;\n\nconst VERIFY_FLAG_HELP: Record<string, string> = {\n \"--schema-dir\": SCHEMA_DIR_FLAG_HELP,\n \"--json\": \"Print one JSON object: every step, and every finding with its file, path and fix\",\n \"--quiet, -q\": \"Print nothing when everything passes; only the problems when something fails\",\n \"--live\": \"Also connect to the project's database: check migrations are applied and run the rls-check audit\",\n \"--database-url\": \"With --live: audit this database instead of the project's\",\n \"--docker\": \"With --live: use the database from docker compose, starting it if needed\"\n};\n\nexport type VerifyStepId = \"schema\" | \"rls\" | \"cms\" | \"migrations\" | \"live\";\n\nexport interface VerifyFinding {\n step: VerifyStepId;\n /** Stable, kebab-case: what kind of problem. An agent can branch on it. */\n check: string;\n severity: \"error\" | \"warning\";\n message: string;\n /** What to change, when there is one thing to change. */\n fix?: string;\n /** The table's slug. */\n table?: string;\n /** The file to open, relative to the project root. */\n file?: string;\n /** The line in {@link file}, when the finding points at one. */\n line?: number;\n /** Dotted path into the table definition — `posts.rls[0]`, `posts.author`. */\n path?: string;\n}\n\nexport interface VerifyStep {\n id: VerifyStepId;\n title: string;\n status: \"passed\" | \"failed\" | \"warnings\" | \"skipped\";\n /** Why a step was skipped, or what it covered. */\n detail?: string;\n}\n\nexport interface VerifyReport {\n ok: boolean;\n /** The schema directory, relative to the project root. */\n schemaDir: string;\n steps: VerifyStep[];\n findings: VerifyFinding[];\n summary: { errors: number; warnings: number };\n}\n\nexport interface VerifyOptions {\n projectRoot: string;\n /** The schema directory, absolute. */\n schemaDir: string;\n /** The backend package, where `drizzle/migrations` lives. Null for a project without one. */\n backendDir: string | null;\n live: boolean;\n databaseUrl?: string;\n /** Why no `databaseUrl` could be resolved for `--live`, when resolving it failed. */\n databaseUnavailable?: string;\n /**\n * Whether the backend refuses a request with no token (`AUTH_REQUIRE`, on\n * unless set to `false`). Decides how a Rebase-compiled public read reads.\n * Defaults to true, the runtime's default.\n */\n authRequired?: boolean;\n /** Module specifiers mapped to files when importing the schema (in-repo runs and tests). */\n moduleAliases?: ModuleAliases;\n}\n\nconst STEP_TITLES: Record<VerifyStepId, string> = {\n schema: \"Table definitions\",\n rls: \"RLS coverage\",\n cms: \"CMS customizations\",\n migrations: \"Migration freshness\",\n live: \"Live RLS audit\"\n};\n\n/**\n * Columns that say \"this row belongs to someone\". A table carrying one and\n * served without a row filter is the classic multi-tenant leak.\n */\nconst OWNER_COLUMNS: readonly string[] = [\"user_id\", \"owner_id\", \"organization_id\", \"tenant_id\"];\n\nconst MODULE_EXTENSIONS = [\".ts\", \".mts\", \".js\", \".mjs\"] as const;\n\n// ─── Step 1: table definitions ────────────────────────────────────────────────\n\n/** The schema as far as the later steps need it: the compiled tables, and where each one is written. */\ninterface VerifiedSchema {\n schema: ProjectSchema;\n descriptors: TableDescriptor[];\n /** The file each table is written in, by slug, relative to the project root. */\n files: Map<string, string>;\n}\n\n/**\n * Where a table is written, as far as the files say without running them:\n * the conventional `<schema>/<name>.ts` (or its slug, or its SQL name), else\n * the index that exports it.\n */\nfunction tableFile(projectRoot: string, schemaDir: string, indexFile: string, names: readonly string[]): string | undefined {\n for (const name of names) {\n for (const extension of MODULE_EXTENSIONS) {\n const candidate = path.join(schemaDir, `${name}${extension}`);\n if (fs.existsSync(candidate)) return path.relative(projectRoot, candidate);\n }\n }\n return indexFile ? path.relative(projectRoot, indexFile) : undefined;\n}\n\n/**\n * Load the schema the way the backend boots from it. A schema that does not\n * load or does not compile is a set of findings, not a crash — after an\n * agent's edit it is the most likely problem of all.\n */\nasync function loadSchema(\n options: VerifyOptions\n): Promise<{ verified: VerifiedSchema; failures: [] } | { verified: null; failures: VerifyFinding[] }> {\n const relative = (file: string) => path.relative(options.projectRoot, file);\n const indexOf = (): string => MODULE_EXTENSIONS\n .map(extension => path.join(options.schemaDir, `index${extension}`))\n .find(candidate => fs.existsSync(candidate)) ?? \"\";\n try {\n const schema = await loadProjectSchema(options.projectRoot, options.schemaDir, options.moduleAliases);\n const descriptors = schema.compiled.descriptors;\n const files = new Map<string, string>();\n for (const descriptor of descriptors) {\n const file = tableFile(options.projectRoot, options.schemaDir, schema.loaded.indexFile,\n [descriptor.name, descriptor.slug, descriptor.table]);\n if (file) files.set(descriptor.slug, file);\n }\n return { verified: { schema, descriptors, files }, failures: [] };\n } catch (error) {\n if (isSchemaDefinitionError(error)) {\n const index = indexOf();\n return {\n verified: null,\n failures: error.problems.map((problem): VerifyFinding => {\n const file = tableFile(options.projectRoot, options.schemaDir, index, [problem.table]);\n return {\n step: \"schema\",\n check: \"schema-definition\",\n severity: \"error\",\n table: problem.table,\n ...(file && { file }),\n path: problem.key ? `${problem.table}.${problem.key}` : problem.table,\n message: problem.message,\n fix: \"Change the definition as the message says. The backend refuses to boot on the same schema.\"\n };\n })\n };\n }\n const file = typeof error === \"object\" && error !== null && \"file\" in error && typeof error.file === \"string\"\n ? relative(error.file)\n : undefined;\n return {\n verified: null,\n failures: [{\n step: \"schema\",\n check: \"schema-load\",\n severity: \"error\",\n ...(file && { file }),\n message: error instanceof Error ? error.message : String(error),\n fix: \"Fix the module as the message says. The backend refuses to boot on the same files.\"\n }]\n };\n }\n}\n\n// ─── Step 2: RLS coverage ─────────────────────────────────────────────────────\n\n/** Whether a rule applies to reads. */\nfunction coversSelect(rule: SecurityRule): boolean {\n const operations = rule.operations ?? [rule.operation ?? \"all\"];\n return operations.includes(\"select\") || operations.includes(\"all\");\n}\n\n/**\n * A permissive read rule with no row filter: every row, to everyone the rule\n * names. `access: \"public\"` is the same thing said on purpose, so it is not\n * this; `roles: [\"admin\"]` restates the default admin read and adds nothing.\n */\nfunction isUnfilteredRead(rule: SecurityRule): boolean {\n if (!coversSelect(rule) || rule.mode === \"restrictive\") return false;\n if (rule.access === \"public\" || rule.ownerField || rule.condition) return false;\n if (rule.using !== undefined && !/^\\s*\\(?\\s*true\\s*\\)?\\s*$/i.test(rule.using)) return false;\n // A write-only check (`withCheck` with no `using`) filters nothing on read,\n // and it is not a read rule either.\n if (rule.using === undefined && rule.withCheck !== undefined) return false;\n const roles = rule.roles ?? [];\n return !(roles.length > 0 && roles.every(role => role === \"admin\"));\n}\n\n/** A read rule that returns every row to someone: an unfiltered one, or `access: \"public\"`. */\nfunction opensEveryRow(rule: SecurityRule): boolean {\n return isUnfilteredRead(rule) || (rule.access === \"public\" && coversSelect(rule) && rule.mode !== \"restrictive\");\n}\n\nfunction describeRuleTarget(rule: Pick<SecurityRule, \"roles\">): string {\n return rule.roles?.length ? `role${rule.roles.length > 1 ? \"s\" : \"\"} ${rule.roles.map(r => `\"${r}\"`).join(\", \")}` : \"every signed-in user\";\n}\n\nfunction checkRls(verified: VerifiedSchema): VerifyFinding[] {\n const findings: VerifyFinding[] = [];\n const defaultsFile = verified.schema.loaded.indexFile\n ? path.basename(verified.schema.loaded.indexFile)\n : \"the schema index\";\n for (const table of verified.descriptors) {\n // A view takes the policies of the tables it reads; the auth table gets\n // a self-read policy and an admin-only write gate from the framework.\n if (table.kind !== \"table\" || table.auth) continue;\n // `\"admin-only\"`, declared or inherited, is a posture said on purpose.\n if (table.rls.posture !== \"rules\") continue;\n // A tenant-scoped table is filtered by the tenant policy before any rule.\n if (table.tenant) continue;\n\n const owner = table.columns.find(column => OWNER_COLUMNS.includes(column.column));\n if (!owner) continue;\n\n const slug = table.slug;\n const file = verified.files.get(slug);\n const ownerField = owner.column;\n const perUser = ownerField === \"user_id\" || ownerField === \"owner_id\";\n const fix = perUser\n ? `Give it rules of its own: \\`rls: [{ operation: \"all\", ownerField: \"${ownerField}\" }]\\` so each user reaches only their own rows. ` +\n \"A table meant to be readable by everyone says so on the table: `{ operation: \\\"select\\\", access: \\\"public\\\" }`.\"\n : `Scope it with \\`tenant: { field: \"${owner.key}\", from: { claim: \"${ownerField}\" } }\\` (the claim that carries the caller's tenant), ` +\n \"plus the `rls` rules that grant access inside a tenant — e.g. `[{ operation: \\\"select\\\", access: \\\"public\\\" }]`.\";\n\n if (table.rls.inherited) {\n const opening = table.rls.rules.find(opensEveryRow);\n if (!opening) continue;\n // `defaultRls` is written for every table. On a tenant column,\n // inheriting an all-rows read is the cross-tenant leak; on a per-user\n // column it is often a public profile or author list, so it is said,\n // not failed.\n findings.push({\n step: \"rls\",\n check: perUser ? \"rls-inherited-read\" : \"rls-inherited-tenant-read\",\n severity: perUser ? \"warning\" : \"error\",\n table: slug,\n ...(file && { file }),\n path: `${slug}.rls`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column and \\`rls: \"inherit\"\\`, so it takes \\`defaultRls\\` from ${defaultsFile}, ` +\n `which lets ${describeRuleTarget(opening)} read every row regardless of \\`${ownerField}\\`.`,\n fix\n });\n continue;\n }\n\n table.rls.rules.forEach((rule, index) => {\n if (!isUnfilteredRead(rule)) return;\n findings.push({\n step: \"rls\",\n check: \"rls-unfiltered-read\",\n severity: \"warning\",\n table: slug,\n ...(file && { file }),\n path: `${slug}.rls[${index}]`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column, and rls[${index}] lets ${describeRuleTarget(rule)} read every row of it with no row filter.`,\n fix: `Filter the rule — \\`ownerField: \"${ownerField}\"\\` or a \\`condition\\` — or, if every row really is meant for ${describeRuleTarget(rule)}, keep it and ignore this warning.`\n });\n });\n }\n return findings;\n}\n\n// ─── Step 3: migration freshness ──────────────────────────────────────────────\n\nconst POSTGRES_PLUGIN = \"@rebasepro/server-postgres\";\n\n/** One row of `rebase.atlas_schema_revisions`, as far as \"applied\" needs it. */\nexport interface AppliedRevision {\n version: string;\n /** Atlas's revision type, a bit set: 1 baseline, 2 executed, 4 resolved (`migrate set`). */\n type: number;\n}\n\n/** Atlas's baseline bit in `atlas_schema_revisions.type`. */\nconst REVISION_TYPE_BASELINE = 1;\n\n/**\n * The migration files the database has not run, as Atlas's own `migrate status`\n * counts them.\n *\n * A file is applied when its version has a row, or when it is at or behind the\n * newest *baseline* row: `migrate apply --baseline V` records V alone, and\n * means \"everything up to V is already here\". `rebase db migrate --baseline` is\n * what the CLI prescribes for a booted database, so set membership alone\n * reported the earlier migrations of every baselined database as not applied —\n * and prescribed `rebase db migrate`, which answers \"No migration files to\n * execute\". That run failed forever.\n */\nexport function pendingMigrations(\n files: readonly string[],\n revisions: readonly AppliedRevision[],\n compare: (a: string, b: string) => number,\n versionOf: (file: string) => string\n): string[] {\n const recorded = new Set(revisions.map(row => row.version));\n const baseline = revisions\n .filter(row => (Number(row.type) & REVISION_TYPE_BASELINE) !== 0)\n .map(row => row.version)\n .reduce<string | null>((newest, version) => (newest === null || compare(version, newest) > 0 ? version : newest), null);\n return files.filter((file) => {\n const version = versionOf(file);\n if (recorded.has(version)) return false;\n return baseline === null || compare(version, baseline) > 0;\n });\n}\n\nasync function checkMigrations(\n options: VerifyOptions,\n verified: VerifiedSchema,\n step: VerifyStep\n): Promise<VerifyFinding[]> {\n const skip = (detail: string): VerifyFinding[] => {\n step.status = \"skipped\";\n step.detail = detail;\n return [];\n };\n if (!options.backendDir) return skip(\"no backend/ directory\");\n const plugin = getActiveBackendPlugin(options.backendDir);\n if (plugin !== POSTGRES_PLUGIN) {\n return skip(`migrations are checked for ${POSTGRES_PLUGIN} projects${plugin ? `; this one uses ${plugin}` : \"\"}`);\n }\n const migrationsDir = path.join(options.backendDir, \"drizzle\", \"migrations\");\n const files = fs.existsSync(migrationsDir)\n ? fs.readdirSync(migrationsDir).filter(f => f.endsWith(\".sql\")).sort()\n : [];\n if (files.length === 0) {\n return skip(\"no migrations yet — the schema is applied with `rebase db push`; `rebase db generate` starts versioned migrations\");\n }\n\n const relativeDir = path.relative(options.projectRoot, migrationsDir);\n const { findUnmigratedSchema } = await import(\"@rebasepro/server-postgres\");\n const findings: VerifyFinding[] = [];\n const fix = \"Run `rebase db generate` to write the migration, then `rebase db migrate` to apply it.\";\n\n let changes: ReturnType<typeof findUnmigratedSchema>;\n try {\n changes = findUnmigratedSchema(\n verified.schema.compiled.tables,\n files.map(f => fs.readFileSync(path.join(migrationsDir, f), \"utf-8\"))\n );\n } catch (error) {\n return [{\n step: \"migrations\",\n check: \"migration-plan\",\n severity: \"error\",\n message: `Could not derive the SQL schema from the tables: ${error instanceof Error ? error.message : String(error)}`,\n fix: \"`rebase schema generate` reports the same problem with more context.\"\n }];\n }\n\n for (const change of changes) {\n const where = change.column ? `${change.table}.${change.column}` : change.table;\n const message = change.kind === \"missing-table\"\n ? `Table ${where} is declared in the schema but no migration in ${relativeDir} creates it.`\n : change.kind === \"missing-column\"\n ? `Column ${where} is declared in the schema but no migration in ${relativeDir} adds it.`\n : `Column ${where} is no longer declared in the schema, but the migrations in ${relativeDir} still create it.`;\n const file = change.slug ? verified.files.get(change.slug) : undefined;\n findings.push({\n step: \"migrations\",\n check: change.kind === \"removed-column\" ? \"migration-stale-column\" : \"migration-missing\",\n severity: \"error\",\n message,\n fix,\n ...(change.slug && { table: change.slug }),\n ...(file && { file })\n });\n }\n\n step.detail = `${files.length} migration${files.length === 1 ? \"\" : \"s\"} in ${relativeDir}`;\n\n if (options.live && options.databaseUrl) {\n findings.push(...await checkAppliedMigrations(options.databaseUrl, files));\n }\n return findings;\n}\n\n/** Which migration files the database has not run, from Atlas's revision table. */\nasync function checkAppliedMigrations(databaseUrl: string, files: string[]): Promise<VerifyFinding[]> {\n const pg = await import(\"pg\");\n const client = new pg.default.Client({ connectionString: databaseUrl, connectionTimeoutMillis: 5_000 });\n try {\n await client.connect();\n const present = await client.query<{ present: boolean }>(\n \"SELECT to_regclass('rebase.atlas_schema_revisions') IS NOT NULL AS present\"\n );\n if (!present.rows[0]?.present) {\n return [{\n step: \"migrations\",\n check: \"migration-unapplied\",\n severity: \"warning\",\n message: \"The database has no migration history (rebase.atlas_schema_revisions) — it was provisioned with `rebase db push`, or never migrated.\",\n fix: \"`rebase db migrate --baseline <version>` adopts an existing database; `rebase db migrate` applies the migrations to a new one.\"\n }];\n }\n const applied = await client.query<{ version: string; type: string | number }>(\n \"SELECT version, type FROM rebase.atlas_schema_revisions WHERE error IS NULL OR error = ''\"\n );\n const { compareMigrationVersions, migrationVersionOf } = await import(\"@rebasepro/server-postgres\");\n const pending = pendingMigrations(\n files,\n applied.rows.map(row => ({ version: row.version, type: Number(row.type) })),\n compareMigrationVersions,\n migrationVersionOf\n );\n if (pending.length === 0) return [];\n return [{\n step: \"migrations\",\n check: \"migration-unapplied\",\n severity: \"error\",\n message: `${pending.length} migration${pending.length === 1 ? \" has\" : \"s have\"} not been applied to the database: ${pending.join(\", \")}.`,\n fix: \"Run `rebase db migrate`.\"\n }];\n } catch (error) {\n return [{\n step: \"migrations\",\n check: \"migration-unapplied\",\n severity: \"warning\",\n message: `Could not read the database's migration history: ${error instanceof Error ? error.message : String(error)}`\n }];\n } finally {\n await client.end().catch(() => undefined);\n }\n}\n\n// ─── Step 4: live RLS audit ───────────────────────────────────────────────────\n\n/** rls-check's severities, folded onto this command's two. `info` is not reported. */\nfunction liveSeverity(severity: string): VerifyFinding[\"severity\"] | null {\n if (severity === \"critical\" || severity === \"high\") return \"error\";\n if (severity === \"medium\" || severity === \"low\") return \"warning\";\n return null;\n}\n\n/**\n * Why the database `--live` was pointed at cannot be opened, or `null` when it\n * can. Asked once, before the live steps, so an unreachable database is one\n * error rather than a skipped audit and a migration warning: under `--live`\n * the audit was asked for, and a CI run in which it never ran is not green.\n */\nasync function databaseUnreachable(databaseUrl: string): Promise<string | null> {\n const pg = await import(\"pg\");\n const client = new pg.default.Client({ connectionString: databaseUrl, connectionTimeoutMillis: 5_000 });\n try {\n await client.connect();\n return null;\n } catch (error) {\n return error instanceof Error ? error.message : String(error);\n } finally {\n await client.end().catch(() => undefined);\n }\n}\n\n/**\n * A `USING (true)` read policy Rebase compiled from an `access: \"public\"`\n * select rule, on a backend that refuses a request with no token.\n *\n * rls-check reads the policy alone, and for the role every signed-in request\n * runs as it is \"every row to everyone\": critical. But the API answers 401\n * before RLS is consulted unless `AUTH_REQUIRE=false`, so what it grants is\n * every row to every *signed-in* user — exactly what step 2 accepts as a rule\n * said on purpose, and what boot reports as an info line. A fresh blog\n * scaffold failed its own `verify --live` with three such errors. It is a\n * warning here, as an unfiltered read is in step 2; with `AUTH_REQUIRE=false`\n * the rows really are public and it stays an error.\n */\nfunction isTokenGatedPublicRead(\n finding: { id: string; target: { table?: string; policy?: string } },\n authRequired: boolean,\n isGeneratedPolicyName: (name: string, table: string) => boolean\n): boolean {\n if (!authRequired || finding.id !== \"policy-always-true\") return false;\n const { table, policy } = finding.target;\n if (!table || !policy) return false;\n return isGeneratedPolicyName(policy, table) && policy.startsWith(`${table}_select_`);\n}\n\nasync function checkLive(databaseUrl: string, step: VerifyStep, authRequired: boolean): Promise<VerifyFinding[]> {\n const { scan, CHECKS } = await import(\"@rebasepro/rls-check\");\n const { isGeneratedPolicyName } = await import(\"@rebasepro/server-postgres\");\n let result: Awaited<ReturnType<typeof scan>>;\n try {\n result = await scan({ connectionString: databaseUrl, statementTimeoutMs: 10_000 });\n } catch (error) {\n step.detail = \"the audit did not run\";\n return [{\n step: \"live\",\n check: \"live-scan-failed\",\n severity: \"error\",\n message: `The live RLS audit failed: ${error instanceof Error ? error.message : String(error)}`,\n fix: \"`npx @rebasepro/rls-check <database-url>` runs the same audit on its own and reports the failure in full.\"\n }];\n }\n step.detail = `${CHECKS.length} rls-check checks against ${result.database.host}/${result.database.name}`;\n\n const findings: VerifyFinding[] = [];\n for (const finding of result.findings) {\n const severity = liveSeverity(finding.severity);\n if (!severity) continue;\n const tokenGated = severity === \"error\" && isTokenGatedPublicRead(finding, authRequired, isGeneratedPolicyName);\n findings.push({\n step: \"live\",\n check: finding.id,\n severity: tokenGated ? \"warning\" : severity,\n message: tokenGated\n ? `${finding.title} — compiled from an \\`access: \"public\"\\` read rule: every signed-in user reads every row. ` +\n \"A request with no token is refused by the API (AUTH_REQUIRE is on), so it is not an anonymous read.\"\n : finding.title,\n ...(finding.fix && { fix: finding.fix }),\n path: finding.target.table ? `${finding.target.schema}.${finding.target.table}` : finding.target.schema\n });\n }\n for (const degraded of result.diagnostics.degraded) {\n findings.push({\n step: \"live\",\n check: \"rls-check-degraded\",\n severity: \"warning\",\n message: `The audit could not read ${degraded.what}: ${degraded.error}. A clean result does not cover it.`\n });\n }\n return findings;\n}\n\n// ─── The run ──────────────────────────────────────────────────────────────────\n\nfunction settle(step: VerifyStep, findings: VerifyFinding[]): VerifyStep {\n if (step.status === \"skipped\") return step;\n const mine = findings.filter(f => f.step === step.id);\n step.status = mine.some(f => f.severity === \"error\") ? \"failed\" : mine.length > 0 ? \"warnings\" : \"passed\";\n return step;\n}\n/**\n * Run every step and return the report. Prints nothing and never exits, so a\n * caller — the command, a test — decides what to do with it.\n */\nexport async function runVerify(options: VerifyOptions): Promise<VerifyReport> {\n const findings: VerifyFinding[] = [];\n const steps: VerifyStep[] = ([\"schema\", \"rls\", \"cms\", \"migrations\", \"live\"] as const).map(id => ({\n id,\n title: STEP_TITLES[id],\n status: \"passed\"\n }));\n const [schemaStep, rlsStep, cmsStep, migrationsStep, liveStep] = steps;\n const schemaDir = path.relative(options.projectRoot, options.schemaDir) || \".\";\n const skipAll = (detail: string): VerifyReport => {\n for (const step of steps) {\n step.status = \"skipped\";\n step.detail = detail;\n }\n return { ok: true, schemaDir, steps, findings, summary: { errors: 0, warnings: 0 } };\n };\n\n // No schema is a project that declares no tables — its API is introspected\n // from the database (a headless one). A skip, not a failure.\n if (!fs.existsSync(options.schemaDir) || !fs.statSync(options.schemaDir).isDirectory()) {\n return skipAll(`no schema directory at ${schemaDir}`);\n }\n\n const { verified, failures } = await loadSchema(options);\n findings.push(...failures);\n if (verified && !verified.schema.loaded.indexFile) {\n return skipAll(`${schemaDir} has no index.ts, so it declares no tables`);\n }\n\n if (verified) {\n const tables = verified.descriptors.length;\n schemaStep.detail = `${tables} table${tables === 1 ? \"\" : \"s\"}, compiled as the backend boots them`;\n rlsStep.detail = `${tables} table${tables === 1 ? \"\" : \"s\"}`;\n findings.push(...checkRls(verified));\n const cms = await checkCmsCustomizations(options.projectRoot, verified.descriptors);\n if (cms.directories.length === 0) {\n cmsStep.status = \"skipped\";\n cmsStep.detail = \"no frontend/src/cms\";\n // A frontend without src/cms still builds without the backend guard.\n for (const finding of cms.findings) findings.push({ step: \"cms\", ...finding });\n } else {\n cmsStep.detail = `${cms.customizations} customization${cms.customizations === 1 ? \"\" : \"s\"} in ${cms.directories.join(\", \")}, read without running them`;\n for (const finding of cms.findings) findings.push({ step: \"cms\", ...finding });\n }\n } else {\n for (const step of [rlsStep, cmsStep]) {\n step.status = \"skipped\";\n step.detail = \"fix the table definitions first\";\n }\n }\n\n // The database the live steps read, once it is known to answer. Under\n // `--live` a database that is missing or does not answer is an error: the\n // audit was asked for, and exit 0 without it is a green CI run over nothing.\n let liveUrl: string | undefined;\n if (options.live) {\n if (!options.databaseUrl) {\n liveStep.detail = \"no database to audit\";\n findings.push({\n step: \"live\",\n check: \"live-no-database\",\n severity: \"error\",\n message: options.databaseUnavailable\n ? `--live was asked for, and the database could not be prepared: ${options.databaseUnavailable}`\n : \"--live was asked for, and no database is configured to audit.\",\n fix: \"Pass --database-url <url> (or set DATABASE_URL), or run without --live for the offline checks.\"\n });\n } else {\n const unreachable = await databaseUnreachable(options.databaseUrl);\n if (unreachable) {\n liveStep.detail = \"the database did not answer\";\n findings.push({\n step: \"live\",\n check: \"live-unreachable\",\n severity: \"error\",\n message: `--live was asked for, and the database could not be reached: ${unreachable}. Neither the migration check nor the RLS audit ran.`,\n fix: \"Check the database is running and the URL is right (`rebase db url` prints the one this project resolves), or run without --live for the offline checks.\"\n });\n } else {\n liveUrl = options.databaseUrl;\n }\n }\n }\n\n if (!verified) {\n migrationsStep.status = \"skipped\";\n migrationsStep.detail = \"fix the table definitions first\";\n } else {\n findings.push(...await checkMigrations({ ...options, databaseUrl: liveUrl }, verified, migrationsStep));\n }\n\n if (!options.live) {\n liveStep.status = \"skipped\";\n liveStep.detail = \"pass --live to audit the database\";\n } else if (liveUrl) {\n findings.push(...await checkLive(liveUrl, liveStep, options.authRequired ?? true));\n }\n\n steps.forEach(step => settle(step, findings));\n const errors = findings.filter(f => f.severity === \"error\").length;\n return {\n ok: errors === 0,\n schemaDir,\n steps,\n findings,\n summary: { errors, warnings: findings.length - errors }\n };\n}\n\n// ─── Output ───────────────────────────────────────────────────────────────────\n\nfunction printFinding(finding: VerifyFinding): void {\n const mark = finding.severity === \"error\" ? chalk.red(\"✗\") : chalk.yellow(\"!\");\n const file = finding.file && finding.line !== undefined ? `${finding.file}:${finding.line}` : finding.file;\n const where = [file, finding.path].filter(Boolean).join(\" → \");\n console.log(` ${mark} ${where ? `${chalk.bold(where)} ` : \"\"}${finding.message}`);\n if (finding.fix) console.log(chalk.gray(` fix: ${finding.fix}`));\n}\n\nfunction summaryLine(report: VerifyReport): string {\n const { errors, warnings } = report.summary;\n return `${errors} error${errors === 1 ? \"\" : \"s\"}, ${warnings} warning${warnings === 1 ? \"\" : \"s\"}`;\n}\n\nexport function printReport(report: VerifyReport, quiet: boolean): void {\n if (quiet) {\n if (report.findings.length === 0) return;\n if (!report.ok) console.log(chalk.red(`rebase verify: ${summaryLine(report)}`));\n for (const finding of report.findings) printFinding(finding);\n return;\n }\n\n console.log(\"\");\n console.log(` ${chalk.bold(\"rebase verify\")} ${chalk.gray(report.schemaDir)}`);\n console.log(\"\");\n for (const step of report.steps) {\n const mark = step.status === \"passed\" ? chalk.green(\"✓\")\n : step.status === \"failed\" ? chalk.red(\"✗\")\n : step.status === \"warnings\" ? chalk.yellow(\"!\")\n : chalk.gray(\"–\");\n const detail = step.detail ? chalk.gray(step.status === \"skipped\" ? `skipped: ${step.detail}` : step.detail) : \"\";\n console.log(` ${mark} ${step.title.padEnd(22)} ${detail}`);\n }\n if (report.findings.length > 0) {\n console.log(\"\");\n for (const finding of report.findings) printFinding(finding);\n }\n console.log(\"\");\n console.log(report.ok ? chalk.green(` ✓ ${summaryLine(report)}`) : chalk.red(` ✗ ${summaryLine(report)}`));\n console.log(\"\");\n}\n\nfunction printVerifyHelp(): void {\n console.log(`\n${chalk.bold(\"rebase verify\")} — Check the tables are safe to ship\n\n${chalk.green.bold(\"Usage\")}\n rebase verify [options]\n\n${chalk.green.bold(\"Options\")}\n${Object.entries(VERIFY_FLAG_HELP).map(([flag, help]) => ` ${chalk.blue(flag.padEnd(20))} ${help}`).join(\"\\n\")}\n\n${chalk.green.bold(\"Steps\")}\n 1. Table definitions backend/schema loads and compiles as the backend boots it\n 2. RLS coverage owner and tenant columns are filtered on by the rules that read them\n 3. CMS customizations frontend/src/cms: each customizeTable names a table, its fields, and a form that can create\n 4. Migration freshness drizzle/migrations builds every declared table and column\n 5. Live RLS audit with --live: the rls-check catalogue against the project's database\n\nExits 1 when any step reports an error; warnings do not fail. Under --live, a\ndatabase that is missing or does not answer is an error. Fast and offline\nwithout --live: for CI, and for the Claude Code hook that ${chalk.cyan(\"rebase skills --hooks\")} installs.\n`);\n}\n\n/**\n * Whether the backend refuses a request with no token: `AUTH_REQUIRE` from the\n * environment, else `.env`, read as every boolean env var is read\n * (`parseEnvBoolean`: `false`/`0`/`no`/`off` turn it off). On unless one of\n * those says otherwise — the runtime's default. Compared raw, `AUTH_REQUIRE=0`\n * read as \"on\", and a compiled public read was reported as token-gated on a\n * backend that serves it to anyone.\n */\nexport function authRequiredFrom(\n environment: Record<string, string | undefined>,\n envFile: Record<string, string | undefined>\n): boolean {\n return parseEnvBoolean(environment.AUTH_REQUIRE ?? envFile.AUTH_REQUIRE) !== false;\n}\n\n/**\n * The database `--live` audits, resolved as every other database door resolves\n * it (`db *`, `console`, `doctor`): `--database-url`, `DATABASE_URL`, `.env`,\n * `--docker` or the last `rebase dev --docker`, and otherwise the managed\n * development database — started if it is not running. Reading only\n * `DATABASE_URL` meant the audit never ran on a fresh scaffold, whose database\n * is the managed one.\n *\n * Progress goes to stderr, so `--json` keeps stdout to the report.\n */\nasync function resolveLiveDatabase(\n projectRoot: string,\n rawArgs: readonly string[],\n options: { flagUrl: string | null; flagDocker: boolean; quiet: boolean }\n): Promise<Pick<VerifyOptions, \"databaseUrl\" | \"databaseUnavailable\">> {\n try {\n const { ensureDockerDatabase, databaseUrlOf } = await import(\"./db\");\n await ensureDockerDatabase(projectRoot, rawArgs);\n const { prepareDatabaseEnv } = await import(\"../dev-db/prepare\");\n const prepared = await prepareDatabaseEnv(projectRoot, {\n flagUrl: options.flagUrl,\n flagDocker: options.flagDocker,\n quiet: options.quiet,\n onProgress: options.quiet ? undefined : (line) => console.error(chalk.gray(` ${line}`))\n });\n return { databaseUrl: databaseUrlOf(prepared, readEnvFile(projectRoot)) };\n } catch (error) {\n return { databaseUnavailable: error instanceof Error ? error.message : String(error) };\n }\n}\n\nexport async function verifyCommand(rawArgs: string[]): Promise<void> {\n if (wantsHelp(rawArgs)) {\n printVerifyHelp();\n return;\n }\n refuseRemovedCollectionsFlag(rawArgs.slice(2), \"verify\");\n const { flags } = parseCommandArgs({\n spec: VERIFY_FLAGS,\n rawArgs,\n commandWords: 1,\n command: \"verify\",\n maxPositionals: 0\n });\n\n const projectRoot = requireProjectRoot();\n const backendDir = findBackendDir(projectRoot);\n const typedDir = flags[\"--schema-dir\"];\n if (typedDir) {\n // A mistyped path used to skip every step and print \"0 errors\" with\n // exit 0 — a green CI run over nothing. Refused as `doctor` and\n // `schema` refuse it. Without the flag, a project with no schema\n // directory (a headless one) is still a skip, not a failure.\n const refusal = missingSchemaDir(rawArgs, process.cwd(), backendDir ?? projectRoot, \"verify\");\n if (refusal) {\n if (flags[\"--json\"]) {\n failAsJson(\n `Schema directory not found: \"${typedDir}\" (resolved to ${path.resolve(process.cwd(), typedDir)}).`,\n \"schema_dir_not_found\",\n \"Leave --schema-dir out (backend/schema is the default), or pass a directory that exists; relative paths are resolved from where you run the command.\"\n );\n }\n console.error(\"\");\n for (const line of refusal) console.error(line);\n console.error(\"\");\n process.exit(1);\n }\n }\n const schemaDir = typedDir ? path.resolve(process.cwd(), typedDir) : resolveSchemaDir(projectRoot);\n const live = flags[\"--live\"] === true;\n const database = live\n ? await resolveLiveDatabase(projectRoot, rawArgs, {\n flagUrl: flags[\"--database-url\"] ?? null,\n flagDocker: flags[\"--docker\"] === true,\n quiet: flags[\"--quiet\"] === true\n })\n : {};\n\n const report = await runVerify({\n projectRoot,\n schemaDir,\n backendDir,\n live,\n ...database,\n authRequired: authRequiredFrom(process.env, readEnvFile(projectRoot))\n });\n\n if (flags[\"--json\"]) {\n console.log(JSON.stringify(report, null, 2));\n } else {\n printReport(report, flags[\"--quiet\"] === true);\n }\n if (!report.ok) process.exitCode = 1;\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAM,cAAc;AACpB,IAAM,YAAY;;AAElB,IAAM,QAAQ;AACd,IAAM,iBAAiB;AACvB,IAAM,SAAS;AACf,IAAM,aAAa;;AAGnB,IAAM,mBAAmB;CAAC;CAAgB;CAAY;AAAU;AAgDhE,SAAS,YAAY,KAAuB;CACxC,MAAM,MAAgB,CAAC;CACv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