@rebasepro/cli 0.29.0 → 0.29.2

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 (56) hide show
  1. package/dist/{apps-Dg0NnmmJ.js → apps-MKQbgDtN.js} +3 -3
  2. package/dist/{apps-Dg0NnmmJ.js.map → apps-MKQbgDtN.js.map} +1 -1
  3. package/dist/{auth-DifFaOyq.js → auth-Bv0rTbQX.js} +3 -3
  4. package/dist/{auth-DifFaOyq.js.map → auth-Bv0rTbQX.js.map} +1 -1
  5. package/dist/{build-1Zo35L6a.js → build-BuKTnec8.js} +3 -3
  6. package/dist/{build-1Zo35L6a.js.map → build-BuKTnec8.js.map} +1 -1
  7. package/dist/{bundle-CTkzO2WG.js → bundle-BAH4FCju.js} +2 -2
  8. package/dist/{bundle-CTkzO2WG.js.map → bundle-BAH4FCju.js.map} +1 -1
  9. package/dist/{cloud-CFotGK2-.js → cloud-DWL-lxU_.js} +6 -6
  10. package/dist/cloud-DWL-lxU_.js.map +1 -0
  11. package/dist/commands/cloud/context.d.ts +1 -1
  12. package/dist/commands/doctor.d.ts +1 -0
  13. package/dist/{console-BXB6-8GT.js → console-CdwIYOMV.js} +2 -2
  14. package/dist/{console-BXB6-8GT.js.map → console-CdwIYOMV.js.map} +1 -1
  15. package/dist/{context-DN1b9pCR.js → context-AXdAh-q8.js} +2 -2
  16. package/dist/{context-DN1b9pCR.js.map → context-AXdAh-q8.js.map} +1 -1
  17. package/dist/{db-KzlqddGD.js → db-DBbKpjYX.js} +35 -6
  18. package/dist/{db-KzlqddGD.js.map → db-DBbKpjYX.js.map} +1 -1
  19. package/dist/{dev-CzOazEHW.js → dev-C93d4QIv.js} +2 -2
  20. package/dist/{dev-CzOazEHW.js.map → dev-C93d4QIv.js.map} +1 -1
  21. package/dist/{doctor-BuqSHNrd.js → doctor-BBPQUO2g.js} +12 -4
  22. package/dist/{doctor-BuqSHNrd.js.map → doctor-BBPQUO2g.js.map} +1 -1
  23. package/dist/eject-DABcDnPN.js.map +1 -1
  24. package/dist/{fold-static-vbZJeo37.js → fold-static-BWzxNn06.js} +2 -2
  25. package/dist/{fold-static-vbZJeo37.js.map → fold-static-BWzxNn06.js.map} +1 -1
  26. package/dist/{generate_sdk-DCUUogIP.js → generate_sdk-DNmNuFuW.js} +2 -2
  27. package/dist/{generate_sdk-DCUUogIP.js.map → generate_sdk-DNmNuFuW.js.map} +1 -1
  28. package/dist/index.es.js +21 -21
  29. package/dist/{init-YzfyEffT.js → init-vL1DWOeC.js} +2 -2
  30. package/dist/{init-YzfyEffT.js.map → init-vL1DWOeC.js.map} +1 -1
  31. package/dist/manifest-BtzDy7KQ.js.map +1 -1
  32. package/dist/{normalize-imports-xpSL_GuU.js → normalize-imports-Bd5Y4yLp.js} +2 -2
  33. package/dist/{normalize-imports-xpSL_GuU.js.map → normalize-imports-Bd5Y4yLp.js.map} +1 -1
  34. package/dist/resources/status.d.ts +2 -2
  35. package/dist/{schema-CApM25cs.js → schema-DtLPsXbT.js} +3 -3
  36. package/dist/{schema-CApM25cs.js.map → schema-DtLPsXbT.js.map} +1 -1
  37. package/dist/schema-reconcile-DkArN9jF.js +2 -0
  38. package/dist/{start-28EztR4R.js → start-YOr3X5Zm.js} +2 -2
  39. package/dist/{start-28EztR4R.js.map → start-YOr3X5Zm.js.map} +1 -1
  40. package/dist/status-BREvtzJm.js.map +1 -1
  41. package/dist/{verify-D7UsV_qe.js → verify-Y3rWSgfA.js} +2 -2
  42. package/dist/{verify-D7UsV_qe.js.map → verify-Y3rWSgfA.js.map} +1 -1
  43. package/package.json +8 -8
  44. package/templates/generated-schemas/blank.ts +8 -8
  45. package/templates/generated-schemas/blog.ts +33 -33
  46. package/templates/generated-schemas/ecommerce.ts +23 -23
  47. package/templates/overlays/baas/ai-instructions.md +1 -1
  48. package/templates/template/.cursorrules +1 -1
  49. package/templates/template/.github/copilot-instructions.md +1 -1
  50. package/templates/template/.windsurfrules +1 -1
  51. package/templates/template/AGENTS.md +1 -1
  52. package/templates/template/CLAUDE.md +1 -1
  53. package/templates/template/ai-instructions.md +1 -1
  54. package/templates/template/backend/functions/hello.ts +4 -3
  55. package/dist/cloud-CFotGK2-.js.map +0 -1
  56. package/dist/schema-reconcile-CX1_6Xqm.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"verify-D7UsV_qe.js","names":[],"sources":["../src/commands/verify.ts"],"sourcesContent":["/**\n * CLI command: rebase verify\n *\n * One command that says whether the collections are safe to ship, fast enough\n * to run after every edit. An agent writing `config/collections/*.ts` gets three\n * things wrong more than anything else — an option that does not exist, a UI\n * widget outside `admin: { … }`, and no `securityRules` — and every one of them\n * used to surface late: at boot, in review, or never. The project's Claude Code\n * hook (`.claude/hooks/post-edit-collection.sh`, written by `rebase init` and\n * `rebase skills --hooks`) runs this after each edit to a collection file, and\n * CI runs it on every push.\n *\n * Four steps, each reported on its own:\n *\n * 1. **Collection config** — every file under `config/collections/` loads and\n * passes `findCollectionConfigProblems` with unknown keys as errors: the same\n * validator the backend runs at boot, at its strictest.\n * 2. **RLS coverage** — a collection that declares no `securityRules` and\n * inherits none, or one with a `user_id` / `owner_id` / `organization_id` /\n * `tenant_id` column that leans on directory defaults instead of its own\n * rules; and a rule that lets a role read every row of such a table.\n * 3. **Migration freshness** — whether `drizzle/migrations` still builds the\n * tables and columns the collections declare (offline), and with `--live`\n * whether the database has applied every migration.\n * 4. **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 config and the fix.\n */\nimport chalk from \"chalk\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport {\n parseEnvBoolean,\n isFirebaseCollectionConfig,\n isRelationalCollectionConfig,\n type CollectionConfig,\n type Property,\n type SecurityRule\n} from \"@rebasepro/types\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\nimport { failAsJson, findBackendDir, getActiveBackendPlugin, readEnvFile, requireProjectRoot } from \"../utils/project\";\nimport { COLLECTIONS_FLAG_HELP, missingCollectionsPath } from \"../utils/path-flags\";\nimport { isLoadedCollectionFile } from \"../utils/collection-drift\";\nimport { resolveCollectionsDir } from \"../utils/collections-dir\";\n\n/** The flags `rebase verify` takes. */\nexport const VERIFY_FLAGS = {\n \"--collections\": String,\n \"-c\": \"--collections\",\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 \"--collections, -c\": COLLECTIONS_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 = \"config\" | \"rls\" | \"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 collection's slug. */\n collection?: string;\n /** The file to open, relative to the project root. */\n file?: string;\n /** Dotted path into the collection config — `posts.properties.title.widget`. */\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 /** Relative to the project root. */\n collectionsDir: string;\n steps: VerifyStep[];\n findings: VerifyFinding[];\n summary: { errors: number; warnings: number };\n}\n\nexport interface VerifyOptions {\n projectRoot: string;\n collectionsDir: 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}\n\nconst STEP_TITLES: Record<VerifyStepId, string> = {\n config: \"Collection config\",\n rls: \"RLS coverage\",\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 isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** What a collection file must default-export to be loaded as one. */\nfunction isCollection(value: unknown): value is CollectionConfig {\n return isRecord(value) && typeof value.slug === \"string\" && isRecord(value.properties);\n}\n\n/** `organizationId` → `organization_id`, as the generator derives a column from a key. */\nfunction snake(key: string): string {\n return key.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\").replace(/[\\s-]+/g, \"_\").toLowerCase();\n}\n\n// ─── Loading ──────────────────────────────────────────────────────────────────\n\ninterface LoadedCollections {\n collections: CollectionConfig[];\n /** Parallel to `collections`: the file each one came from, relative to the project root. */\n sources: string[];\n /** Each collection's `securityRules` as its file declares them, before directory defaults. */\n ownRules: (readonly SecurityRule[] | undefined)[];\n /** `defaultSecurityRules` from the directory's `index.ts`. */\n defaults: readonly SecurityRule[] | undefined;\n defaultsFile?: string;\n failures: VerifyFinding[];\n}\n\n/**\n * Load the collections the way the backend finds them: every top-level file\n * the loader reads (`isLoadedCollectionFile`), each default-exporting one\n * collection, plus `defaultSecurityRules` from the directory's `index.ts`.\n *\n * Through jiti, with its caches off: the CLI is plain Node and the files are\n * TypeScript, and a verifier that answered from the previous edit's module\n * would be worse than none. A file that does not load is a finding, not a\n * crash — after an agent's edit it is the most likely problem of all.\n */\nasync function loadCollectionFiles(projectRoot: string, collectionsDir: string): Promise<LoadedCollections> {\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(path.join(collectionsDir, \"index.ts\"), {\n interopDefault: true,\n moduleCache: false,\n fsCache: false\n });\n const relative = (file: string) => path.relative(projectRoot, file);\n\n const loaded: LoadedCollections = { collections: [], sources: [], ownRules: [], defaults: undefined, failures: [] };\n\n for (const name of fs.readdirSync(collectionsDir).filter(isLoadedCollectionFile).sort()) {\n const file = path.join(collectionsDir, name);\n try {\n const exported = await jiti.import<unknown>(file, { default: true });\n if (!isCollection(exported)) {\n loaded.failures.push({\n step: \"config\",\n check: \"config-no-collection\",\n severity: \"error\",\n file: relative(file),\n message: `${name} does not default-export a collection (an object with a \\`slug\\` and \\`properties\\`).`,\n fix: \"End the file with `export default defineCollection({ slug, name, properties, … })` — the backend refuses to boot on a collection file that exports anything else.\"\n });\n continue;\n }\n loaded.collections.push(exported);\n loaded.sources.push(relative(file));\n loaded.ownRules.push(exported.securityRules);\n } catch (error) {\n loaded.failures.push({\n step: \"config\",\n check: \"config-load\",\n severity: \"error\",\n file: relative(file),\n message: `${name} does not load: ${error instanceof Error ? error.message : String(error)}`,\n fix: \"Fix the syntax or import error. The backend refuses to boot on the same file.\"\n });\n }\n }\n\n for (const index of [\"index.ts\", \"index.js\"]) {\n const file = path.join(collectionsDir, index);\n if (!fs.existsSync(file)) continue;\n try {\n const mod = await jiti.import<unknown>(file);\n const rules = isRecord(mod) ? mod.defaultSecurityRules : undefined;\n if (Array.isArray(rules)) {\n loaded.defaults = rules;\n loaded.defaultsFile = relative(file);\n }\n } catch (error) {\n loaded.failures.push({\n step: \"config\",\n check: \"config-load\",\n severity: \"error\",\n file: relative(file),\n message: `${index} does not load: ${error instanceof Error ? error.message : String(error)}`,\n fix: \"Fix the file, or delete it if the project declares no `defaultSecurityRules`. The backend refuses to boot without reading it.\"\n });\n }\n break;\n }\n\n return loaded;\n}\n\n// ─── Step 1: collection config ────────────────────────────────────────────────\n\nasync function checkConfig(loaded: LoadedCollections): Promise<VerifyFinding[]> {\n const { findCollectionConfigProblems } = await import(\"@rebasepro/server\");\n const fileBySlug = new Map(loaded.collections.map((c, i) => [c.slug, loaded.sources[i]]));\n const problems = findCollectionConfigProblems(loaded.collections, {\n unknownKeys: \"error\",\n sources: loaded.sources\n });\n return problems.map((problem): VerifyFinding => {\n const slug = problem.path.split(\".\")[0];\n const file = fileBySlug.get(slug);\n return {\n step: \"config\",\n check: problem.kind === \"key\" ? \"config-key\" : \"config-incoherent\",\n severity: problem.severity,\n message: problem.message,\n path: problem.path,\n ...(fileBySlug.has(slug) && { collection: slug }),\n ...(file && { file })\n };\n });\n}\n\n// ─── Step 2: RLS coverage ─────────────────────────────────────────────────────\n\n/** An owner-ish column a collection's table carries, and the property that declares it. */\ninterface OwnerColumn {\n column: string;\n key: string;\n}\n\n/** The owner-ish columns a collection's table carries: plain columns and `belongsTo` keys. */\nfunction ownerColumnsOf(collection: CollectionConfig): OwnerColumn[] {\n const found: OwnerColumn[] = [];\n const consider = (column: string, key: string) => {\n if (OWNER_COLUMNS.includes(column)) found.push({ column, key });\n };\n for (const [key, property] of Object.entries<Property>(collection.properties ?? {})) {\n if (!isRecord(property)) continue;\n if (property.type === \"relation\") {\n const relation = property.relation;\n if (isRecord(relation) && relation.kind === \"belongsTo\") {\n // As the generator names it (`generateForeignKeyName` in\n // `@rebasepro/utils`, which the CLI does not depend on): from\n // the relation's name, which is the property key only when\n // `relationName` is not set.\n const name = typeof relation.relationName === \"string\" && relation.relationName ? relation.relationName : key;\n const singular = /[^s]s$/.test(name) ? name.slice(0, -1) : name;\n consider(typeof relation.localKey === \"string\" ? relation.localKey : `${snake(singular)}_id`, key);\n }\n continue;\n }\n consider(typeof property.columnName === \"string\" ? property.columnName : snake(key), key);\n }\n return found;\n}\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(loaded: LoadedCollections): VerifyFinding[] {\n const findings: VerifyFinding[] = [];\n loaded.collections.forEach((collection, i) => {\n // Firestore does not implement `securityRules` at all — its own rules\n // language governs it, and nothing here can say anything about that.\n if (isFirebaseCollectionConfig(collection)) return;\n\n const slug = collection.slug;\n const file = loaded.sources[i];\n const own = loaded.ownRules[i] ?? [];\n const owners = ownerColumnsOf(collection);\n const tenantScoped = isRelationalCollectionConfig(collection) && isRecord(collection.tenant);\n const ownerField = owners[0]?.column ?? \"user_id\";\n\n if (own.length === 0) {\n // An auth collection gets a self-read policy and an admin-only write\n // gate from the framework; it is never served unfiltered.\n if (collection.auth) return;\n\n if (owners.length > 0 && !tenantScoped) {\n const perUser = ownerField === \"user_id\" || ownerField === \"owner_id\";\n const fix = perUser\n ? `Add \\`securityRules: [{ operation: \"all\", ownerField: \"${ownerField}\" }]\\` so each user reaches only their own rows. ` +\n \"A table meant to be readable by everyone says so: `{ operation: \\\"select\\\", access: \\\"public\\\" }`.\"\n : `Scope it with \\`tenant: { field: \"${owners[0].key}\", from: { claim: \"${ownerField}\" } }\\` (the claim that carries the caller's tenant), ` +\n \"plus the `securityRules` that grant access inside a tenant — e.g. `[{ operation: \\\"select\\\", access: \\\"public\\\" }]`.\";\n const inherited = loaded.defaults ?? [];\n if (inherited.length === 0) {\n findings.push({\n step: \"rls\",\n check: \"rls-missing\",\n severity: \"error\",\n collection: slug,\n file,\n path: `${slug}.securityRules`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column but declares no \\`securityRules\\`, and inherits none: nothing says which rows belong to whom (by default only admins can read or write it).`,\n fix\n });\n } else if (inherited.some(opensEveryRow)) {\n // Directory defaults are written for every table. On a\n // tenant column, inheriting an all-rows read is the\n // cross-tenant leak; on a per-user column it is often a\n // public profile or author list, so it is said, not failed.\n findings.push({\n step: \"rls\",\n check: perUser ? \"rls-inherited-read\" : \"rls-missing\",\n severity: perUser ? \"warning\" : \"error\",\n collection: slug,\n file,\n path: `${slug}.securityRules`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column but declares no \\`securityRules\\` of its own, so it inherits \\`defaultSecurityRules\\` from ${loaded.defaultsFile}, which let ${describeRuleTarget(inherited.find(opensEveryRow) ?? {})} read every row regardless of \\`${ownerField}\\`.`,\n fix\n });\n }\n return;\n }\n\n if (!loaded.defaults?.length) {\n findings.push({\n step: \"rls\",\n check: \"rls-missing\",\n severity: \"error\",\n collection: slug,\n file,\n path: `${slug}.securityRules`,\n message: `\"${slug}\" declares no \\`securityRules\\` and inherits none, so nothing says who may read or write it (by default only admins can).`,\n fix: \"Declare its access: `securityRules: [{ operation: \\\"select\\\", access: \\\"public\\\" }, { operations: [\\\"insert\\\", \\\"update\\\", \\\"delete\\\"], roles: [\\\"admin\\\"] }]` \" +\n \"for a public table, `{ operation: \\\"all\\\", ownerField: \\\"user_id\\\" }` for per-user rows, \" +\n \"or `{ operation: \\\"all\\\", roles: [\\\"admin\\\"] }` to keep it admin-only on purpose.\"\n });\n }\n return;\n }\n\n if (owners.length === 0 || tenantScoped) return;\n own.forEach((rule, index) => {\n if (!isUnfilteredRead(rule)) return;\n findings.push({\n step: \"rls\",\n check: \"rls-unfiltered-read\",\n severity: \"warning\",\n collection: slug,\n file,\n path: `${slug}.securityRules[${index}]`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column, and securityRules[${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 loaded: LoadedCollections,\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 const fileBySlug = new Map(loaded.collections.map((c, i) => [c.slug, loaded.sources[i]]));\n\n let changes: ReturnType<typeof findUnmigratedSchema>;\n try {\n changes = findUnmigratedSchema(\n loaded.collections,\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 schema from the collections: ${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 by the collections but no migration in ${relativeDir} creates it.`\n : change.kind === \"missing-column\"\n ? `Column ${where} is declared by the collections but no migration in ${relativeDir} adds it.`\n : `Column ${where} is no longer declared by the collections, but the migrations in ${relativeDir} still create it.`;\n const file = change.slug ? fileBySlug.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 && { collection: 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/**\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[] = ([\"config\", \"rls\", \"migrations\", \"live\"] as const).map(id => ({\n id,\n title: STEP_TITLES[id],\n status: \"passed\"\n }));\n const [configStep, rlsStep, migrationsStep, liveStep] = steps;\n const collectionsDir = path.relative(options.projectRoot, options.collectionsDir) || \".\";\n\n if (!fs.existsSync(options.collectionsDir) || !fs.statSync(options.collectionsDir).isDirectory()) {\n for (const step of steps) {\n step.status = \"skipped\";\n step.detail = `no collections directory at ${collectionsDir}`;\n }\n return { ok: true, collectionsDir, steps, findings, summary: { errors: 0, warnings: 0 } };\n }\n\n const loaded = await loadCollectionFiles(options.projectRoot, options.collectionsDir);\n findings.push(...loaded.failures);\n\n if (loaded.collections.length > 0) {\n findings.push(...await checkConfig(loaded));\n }\n const counted = `${loaded.collections.length} collection${loaded.collections.length === 1 ? \"\" : \"s\"}`;\n configStep.detail = `${counted}, unknown keys are errors`;\n rlsStep.detail = counted;\n\n // Directory defaults reach a collection the way the loader applies them, so\n // the migration step plans the same policies the backend would.\n if (loaded.defaults?.length) {\n const { applyCollectionDefaults } = await import(\"@rebasepro/server\");\n applyCollectionDefaults(loaded.collections, { defaultSecurityRules: [...loaded.defaults] });\n }\n\n findings.push(...checkRls(loaded));\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 (findings.some(f => f.step === \"config\" && f.severity === \"error\")) {\n migrationsStep.status = \"skipped\";\n migrationsStep.detail = \"fix the collection config errors first\";\n } else {\n findings.push(...await checkMigrations({ ...options, databaseUrl: liveUrl }, loaded, 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 collectionsDir,\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 where = [finding.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.collectionsDir)}`);\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 collections 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. Collection config every file loads and passes the boot validator, unknown keys as errors\n 2. RLS coverage securityRules are declared, and owner/tenant columns are filtered on\n 3. Migration freshness drizzle/migrations builds every declared table and column\n 4. 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 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 if (flags[\"--collections\"]) {\n // A mistyped `-c` 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 collections\n // directory (a headless one) is still a skip, not a failure.\n const refusal = missingCollectionsPath(rawArgs, process.cwd(), backendDir ?? projectRoot, \"verify\");\n if (refusal) {\n if (flags[\"--json\"]) {\n failAsJson(\n `Collections path not found: \"${flags[\"--collections\"]}\" (resolved to ${path.resolve(process.cwd(), flags[\"--collections\"])}).`,\n \"collections_not_found\",\n \"Leave --collections out (config/collections 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 collectionsDir = flags[\"--collections\"]\n ? path.resolve(process.cwd(), flags[\"--collections\"])\n : resolveCollectionsDir(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 collectionsDir,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,eAAe;CACxB,iBAAiB;CACjB,MAAM;CACN,UAAU;CACV,WAAW;CACX,MAAM;CACN,UAAU;CACV,kBAAkB;CAClB,YAAY;AAChB;AAEA,IAAM,mBAA2C;CAC7C,qBAAqB;CACrB,UAAU;CACV,eAAe;CACf,UAAU;CACV,kBAAkB;CAClB,YAAY;AAChB;AAsDA,IAAM,cAA4C;CAC9C,QAA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G;EACpB,gBAAgB;EAChB;CACJ;CACA,MAAM,EAAE,UAAU,iBAAiB;EAC/B,MAAM;EACN;EACA,cAAc;EACd,SAAS;EACT,gBAAgB;CACpB,CAAC;CAED,MAAM,cAAc,mBAAmB;CACvC,MAAM,aAAa,eAAe,WAAW;CAC7C,IAAI,MAAM,kBAAkB;EAKxB,MAAM,UAAU,uBAAuB,SAAS,QAAQ,IAAI,GAAG,cAAc,aAAa,QAAQ;EAClG,IAAI,SAAS;GACT,IAAI,MAAM,WACN,WACI,gCAAgC,MAAM,iBAAiB,iBAAiB,KAAK,QAAQ,QAAQ,IAAI,GAAG,MAAM,gBAAgB,EAAE,KAC5H,yBACA,2JACJ;GAEJ,QAAQ,MAAM,EAAE;GAChB,KAAK,MAAM,QAAQ,SAAS,QAAQ,MAAM,IAAI;GAC9C,QAAQ,MAAM,EAAE;GAChB,QAAQ,KAAK,CAAC;EAClB;CACJ;CACA,MAAM,iBAAiB,MAAM,mBACvB,KAAK,QAAQ,QAAQ,IAAI,GAAG,MAAM,gBAAgB,IAClD,sBAAsB,WAAW;CACvC,MAAM,OAAO,MAAM,cAAc;CASjC,MAAM,SAAS,MAAM,UAAU;EAC3B;EACA;EACA;EACA;EACA,GAba,OACX,MAAM,oBAAoB,aAAa,SAAS;GAC9C,SAAS,MAAM,qBAAqB;GACpC,YAAY,MAAM,gBAAgB;GAClC,OAAO,MAAM,eAAe;EAChC,CAAC,IACC,CAAC;EAQH,cAAc,iBAAiB,QAAQ,KAAK,YAAY,WAAW,CAAC;CACxE,CAAC;CAED,IAAI,MAAM,WACN,QAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;MAE3C,YAAY,QAAQ,MAAM,eAAe,IAAI;CAEjD,IAAI,CAAC,OAAO,IAAI,QAAQ,WAAW;AACvC"}
1
+ {"version":3,"file":"verify-Y3rWSgfA.js","names":[],"sources":["../src/commands/verify.ts"],"sourcesContent":["/**\n * CLI command: rebase verify\n *\n * One command that says whether the collections are safe to ship, fast enough\n * to run after every edit. An agent writing `config/collections/*.ts` gets three\n * things wrong more than anything else — an option that does not exist, a UI\n * widget outside `admin: { … }`, and no `securityRules` — and every one of them\n * used to surface late: at boot, in review, or never. The project's Claude Code\n * hook (`.claude/hooks/post-edit-collection.sh`, written by `rebase init` and\n * `rebase skills --hooks`) runs this after each edit to a collection file, and\n * CI runs it on every push.\n *\n * Four steps, each reported on its own:\n *\n * 1. **Collection config** — every file under `config/collections/` loads and\n * passes `findCollectionConfigProblems` with unknown keys as errors: the same\n * validator the backend runs at boot, at its strictest.\n * 2. **RLS coverage** — a collection that declares no `securityRules` and\n * inherits none, or one with a `user_id` / `owner_id` / `organization_id` /\n * `tenant_id` column that leans on directory defaults instead of its own\n * rules; and a rule that lets a role read every row of such a table.\n * 3. **Migration freshness** — whether `drizzle/migrations` still builds the\n * tables and columns the collections declare (offline), and with `--live`\n * whether the database has applied every migration.\n * 4. **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 config and the fix.\n */\nimport chalk from \"chalk\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport {\n parseEnvBoolean,\n isFirebaseCollectionConfig,\n isRelationalCollectionConfig,\n type CollectionConfig,\n type Property,\n type SecurityRule\n} from \"@rebasepro/types\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\nimport { failAsJson, findBackendDir, getActiveBackendPlugin, readEnvFile, requireProjectRoot } from \"../utils/project\";\nimport { COLLECTIONS_FLAG_HELP, missingCollectionsPath } from \"../utils/path-flags\";\nimport { isLoadedCollectionFile } from \"../utils/collection-drift\";\nimport { resolveCollectionsDir } from \"../utils/collections-dir\";\n\n/** The flags `rebase verify` takes. */\nexport const VERIFY_FLAGS = {\n \"--collections\": String,\n \"-c\": \"--collections\",\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 \"--collections, -c\": COLLECTIONS_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 = \"config\" | \"rls\" | \"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 collection's slug. */\n collection?: string;\n /** The file to open, relative to the project root. */\n file?: string;\n /** Dotted path into the collection config — `posts.properties.title.widget`. */\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 /** Relative to the project root. */\n collectionsDir: string;\n steps: VerifyStep[];\n findings: VerifyFinding[];\n summary: { errors: number; warnings: number };\n}\n\nexport interface VerifyOptions {\n projectRoot: string;\n collectionsDir: 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}\n\nconst STEP_TITLES: Record<VerifyStepId, string> = {\n config: \"Collection config\",\n rls: \"RLS coverage\",\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 isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** What a collection file must default-export to be loaded as one. */\nfunction isCollection(value: unknown): value is CollectionConfig {\n return isRecord(value) && typeof value.slug === \"string\" && isRecord(value.properties);\n}\n\n/** `organizationId` → `organization_id`, as the generator derives a column from a key. */\nfunction snake(key: string): string {\n return key.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\").replace(/[\\s-]+/g, \"_\").toLowerCase();\n}\n\n// ─── Loading ──────────────────────────────────────────────────────────────────\n\ninterface LoadedCollections {\n collections: CollectionConfig[];\n /** Parallel to `collections`: the file each one came from, relative to the project root. */\n sources: string[];\n /** Each collection's `securityRules` as its file declares them, before directory defaults. */\n ownRules: (readonly SecurityRule[] | undefined)[];\n /** `defaultSecurityRules` from the directory's `index.ts`. */\n defaults: readonly SecurityRule[] | undefined;\n defaultsFile?: string;\n failures: VerifyFinding[];\n}\n\n/**\n * Load the collections the way the backend finds them: every top-level file\n * the loader reads (`isLoadedCollectionFile`), each default-exporting one\n * collection, plus `defaultSecurityRules` from the directory's `index.ts`.\n *\n * Through jiti, with its caches off: the CLI is plain Node and the files are\n * TypeScript, and a verifier that answered from the previous edit's module\n * would be worse than none. A file that does not load is a finding, not a\n * crash — after an agent's edit it is the most likely problem of all.\n */\nasync function loadCollectionFiles(projectRoot: string, collectionsDir: string): Promise<LoadedCollections> {\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(path.join(collectionsDir, \"index.ts\"), {\n interopDefault: true,\n moduleCache: false,\n fsCache: false\n });\n const relative = (file: string) => path.relative(projectRoot, file);\n\n const loaded: LoadedCollections = { collections: [], sources: [], ownRules: [], defaults: undefined, failures: [] };\n\n for (const name of fs.readdirSync(collectionsDir).filter(isLoadedCollectionFile).sort()) {\n const file = path.join(collectionsDir, name);\n try {\n const exported = await jiti.import<unknown>(file, { default: true });\n if (!isCollection(exported)) {\n loaded.failures.push({\n step: \"config\",\n check: \"config-no-collection\",\n severity: \"error\",\n file: relative(file),\n message: `${name} does not default-export a collection (an object with a \\`slug\\` and \\`properties\\`).`,\n fix: \"End the file with `export default defineCollection({ slug, name, properties, … })` — the backend refuses to boot on a collection file that exports anything else.\"\n });\n continue;\n }\n loaded.collections.push(exported);\n loaded.sources.push(relative(file));\n loaded.ownRules.push(exported.securityRules);\n } catch (error) {\n loaded.failures.push({\n step: \"config\",\n check: \"config-load\",\n severity: \"error\",\n file: relative(file),\n message: `${name} does not load: ${error instanceof Error ? error.message : String(error)}`,\n fix: \"Fix the syntax or import error. The backend refuses to boot on the same file.\"\n });\n }\n }\n\n for (const index of [\"index.ts\", \"index.js\"]) {\n const file = path.join(collectionsDir, index);\n if (!fs.existsSync(file)) continue;\n try {\n const mod = await jiti.import<unknown>(file);\n const rules = isRecord(mod) ? mod.defaultSecurityRules : undefined;\n if (Array.isArray(rules)) {\n loaded.defaults = rules;\n loaded.defaultsFile = relative(file);\n }\n } catch (error) {\n loaded.failures.push({\n step: \"config\",\n check: \"config-load\",\n severity: \"error\",\n file: relative(file),\n message: `${index} does not load: ${error instanceof Error ? error.message : String(error)}`,\n fix: \"Fix the file, or delete it if the project declares no `defaultSecurityRules`. The backend refuses to boot without reading it.\"\n });\n }\n break;\n }\n\n return loaded;\n}\n\n// ─── Step 1: collection config ────────────────────────────────────────────────\n\nasync function checkConfig(loaded: LoadedCollections): Promise<VerifyFinding[]> {\n const { findCollectionConfigProblems } = await import(\"@rebasepro/server\");\n const fileBySlug = new Map(loaded.collections.map((c, i) => [c.slug, loaded.sources[i]]));\n const problems = findCollectionConfigProblems(loaded.collections, {\n unknownKeys: \"error\",\n sources: loaded.sources\n });\n return problems.map((problem): VerifyFinding => {\n const slug = problem.path.split(\".\")[0];\n const file = fileBySlug.get(slug);\n return {\n step: \"config\",\n check: problem.kind === \"key\" ? \"config-key\" : \"config-incoherent\",\n severity: problem.severity,\n message: problem.message,\n path: problem.path,\n ...(fileBySlug.has(slug) && { collection: slug }),\n ...(file && { file })\n };\n });\n}\n\n// ─── Step 2: RLS coverage ─────────────────────────────────────────────────────\n\n/** An owner-ish column a collection's table carries, and the property that declares it. */\ninterface OwnerColumn {\n column: string;\n key: string;\n}\n\n/** The owner-ish columns a collection's table carries: plain columns and `belongsTo` keys. */\nfunction ownerColumnsOf(collection: CollectionConfig): OwnerColumn[] {\n const found: OwnerColumn[] = [];\n const consider = (column: string, key: string) => {\n if (OWNER_COLUMNS.includes(column)) found.push({ column, key });\n };\n for (const [key, property] of Object.entries<Property>(collection.properties ?? {})) {\n if (!isRecord(property)) continue;\n if (property.type === \"relation\") {\n const relation = property.relation;\n if (isRecord(relation) && relation.kind === \"belongsTo\") {\n // As the generator names it (`generateForeignKeyName` in\n // `@rebasepro/utils`, which the CLI does not depend on): from\n // the relation's name, which is the property key only when\n // `relationName` is not set.\n const name = typeof relation.relationName === \"string\" && relation.relationName ? relation.relationName : key;\n const singular = /[^s]s$/.test(name) ? name.slice(0, -1) : name;\n consider(typeof relation.localKey === \"string\" ? relation.localKey : `${snake(singular)}_id`, key);\n }\n continue;\n }\n consider(typeof property.columnName === \"string\" ? property.columnName : snake(key), key);\n }\n return found;\n}\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(loaded: LoadedCollections): VerifyFinding[] {\n const findings: VerifyFinding[] = [];\n loaded.collections.forEach((collection, i) => {\n // Firestore does not implement `securityRules` at all — its own rules\n // language governs it, and nothing here can say anything about that.\n if (isFirebaseCollectionConfig(collection)) return;\n\n const slug = collection.slug;\n const file = loaded.sources[i];\n const own = loaded.ownRules[i] ?? [];\n const owners = ownerColumnsOf(collection);\n const tenantScoped = isRelationalCollectionConfig(collection) && isRecord(collection.tenant);\n const ownerField = owners[0]?.column ?? \"user_id\";\n\n if (own.length === 0) {\n // An auth collection gets a self-read policy and an admin-only write\n // gate from the framework; it is never served unfiltered.\n if (collection.auth) return;\n\n if (owners.length > 0 && !tenantScoped) {\n const perUser = ownerField === \"user_id\" || ownerField === \"owner_id\";\n const fix = perUser\n ? `Add \\`securityRules: [{ operation: \"all\", ownerField: \"${ownerField}\" }]\\` so each user reaches only their own rows. ` +\n \"A table meant to be readable by everyone says so: `{ operation: \\\"select\\\", access: \\\"public\\\" }`.\"\n : `Scope it with \\`tenant: { field: \"${owners[0].key}\", from: { claim: \"${ownerField}\" } }\\` (the claim that carries the caller's tenant), ` +\n \"plus the `securityRules` that grant access inside a tenant — e.g. `[{ operation: \\\"select\\\", access: \\\"public\\\" }]`.\";\n const inherited = loaded.defaults ?? [];\n if (inherited.length === 0) {\n findings.push({\n step: \"rls\",\n check: \"rls-missing\",\n severity: \"error\",\n collection: slug,\n file,\n path: `${slug}.securityRules`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column but declares no \\`securityRules\\`, and inherits none: nothing says which rows belong to whom (by default only admins can read or write it).`,\n fix\n });\n } else if (inherited.some(opensEveryRow)) {\n // Directory defaults are written for every table. On a\n // tenant column, inheriting an all-rows read is the\n // cross-tenant leak; on a per-user column it is often a\n // public profile or author list, so it is said, not failed.\n findings.push({\n step: \"rls\",\n check: perUser ? \"rls-inherited-read\" : \"rls-missing\",\n severity: perUser ? \"warning\" : \"error\",\n collection: slug,\n file,\n path: `${slug}.securityRules`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column but declares no \\`securityRules\\` of its own, so it inherits \\`defaultSecurityRules\\` from ${loaded.defaultsFile}, which let ${describeRuleTarget(inherited.find(opensEveryRow) ?? {})} read every row regardless of \\`${ownerField}\\`.`,\n fix\n });\n }\n return;\n }\n\n if (!loaded.defaults?.length) {\n findings.push({\n step: \"rls\",\n check: \"rls-missing\",\n severity: \"error\",\n collection: slug,\n file,\n path: `${slug}.securityRules`,\n message: `\"${slug}\" declares no \\`securityRules\\` and inherits none, so nothing says who may read or write it (by default only admins can).`,\n fix: \"Declare its access: `securityRules: [{ operation: \\\"select\\\", access: \\\"public\\\" }, { operations: [\\\"insert\\\", \\\"update\\\", \\\"delete\\\"], roles: [\\\"admin\\\"] }]` \" +\n \"for a public table, `{ operation: \\\"all\\\", ownerField: \\\"user_id\\\" }` for per-user rows, \" +\n \"or `{ operation: \\\"all\\\", roles: [\\\"admin\\\"] }` to keep it admin-only on purpose.\"\n });\n }\n return;\n }\n\n if (owners.length === 0 || tenantScoped) return;\n own.forEach((rule, index) => {\n if (!isUnfilteredRead(rule)) return;\n findings.push({\n step: \"rls\",\n check: \"rls-unfiltered-read\",\n severity: \"warning\",\n collection: slug,\n file,\n path: `${slug}.securityRules[${index}]`,\n message: `\"${slug}\" has a \\`${ownerField}\\` column, and securityRules[${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 loaded: LoadedCollections,\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 const fileBySlug = new Map(loaded.collections.map((c, i) => [c.slug, loaded.sources[i]]));\n\n let changes: ReturnType<typeof findUnmigratedSchema>;\n try {\n changes = findUnmigratedSchema(\n loaded.collections,\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 schema from the collections: ${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 by the collections but no migration in ${relativeDir} creates it.`\n : change.kind === \"missing-column\"\n ? `Column ${where} is declared by the collections but no migration in ${relativeDir} adds it.`\n : `Column ${where} is no longer declared by the collections, but the migrations in ${relativeDir} still create it.`;\n const file = change.slug ? fileBySlug.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 && { collection: 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/**\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[] = ([\"config\", \"rls\", \"migrations\", \"live\"] as const).map(id => ({\n id,\n title: STEP_TITLES[id],\n status: \"passed\"\n }));\n const [configStep, rlsStep, migrationsStep, liveStep] = steps;\n const collectionsDir = path.relative(options.projectRoot, options.collectionsDir) || \".\";\n\n if (!fs.existsSync(options.collectionsDir) || !fs.statSync(options.collectionsDir).isDirectory()) {\n for (const step of steps) {\n step.status = \"skipped\";\n step.detail = `no collections directory at ${collectionsDir}`;\n }\n return { ok: true, collectionsDir, steps, findings, summary: { errors: 0, warnings: 0 } };\n }\n\n const loaded = await loadCollectionFiles(options.projectRoot, options.collectionsDir);\n findings.push(...loaded.failures);\n\n if (loaded.collections.length > 0) {\n findings.push(...await checkConfig(loaded));\n }\n const counted = `${loaded.collections.length} collection${loaded.collections.length === 1 ? \"\" : \"s\"}`;\n configStep.detail = `${counted}, unknown keys are errors`;\n rlsStep.detail = counted;\n\n // Directory defaults reach a collection the way the loader applies them, so\n // the migration step plans the same policies the backend would.\n if (loaded.defaults?.length) {\n const { applyCollectionDefaults } = await import(\"@rebasepro/server\");\n applyCollectionDefaults(loaded.collections, { defaultSecurityRules: [...loaded.defaults] });\n }\n\n findings.push(...checkRls(loaded));\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 (findings.some(f => f.step === \"config\" && f.severity === \"error\")) {\n migrationsStep.status = \"skipped\";\n migrationsStep.detail = \"fix the collection config errors first\";\n } else {\n findings.push(...await checkMigrations({ ...options, databaseUrl: liveUrl }, loaded, 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 collectionsDir,\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 where = [finding.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.collectionsDir)}`);\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 collections 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. Collection config every file loads and passes the boot validator, unknown keys as errors\n 2. RLS coverage securityRules are declared, and owner/tenant columns are filtered on\n 3. Migration freshness drizzle/migrations builds every declared table and column\n 4. 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 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 if (flags[\"--collections\"]) {\n // A mistyped `-c` 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 collections\n // directory (a headless one) is still a skip, not a failure.\n const refusal = missingCollectionsPath(rawArgs, process.cwd(), backendDir ?? projectRoot, \"verify\");\n if (refusal) {\n if (flags[\"--json\"]) {\n failAsJson(\n `Collections path not found: \"${flags[\"--collections\"]}\" (resolved to ${path.resolve(process.cwd(), flags[\"--collections\"])}).`,\n \"collections_not_found\",\n \"Leave --collections out (config/collections 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 collectionsDir = flags[\"--collections\"]\n ? path.resolve(process.cwd(), flags[\"--collections\"])\n : resolveCollectionsDir(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 collectionsDir,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,eAAe;CACxB,iBAAiB;CACjB,MAAM;CACN,UAAU;CACV,WAAW;CACX,MAAM;CACN,UAAU;CACV,kBAAkB;CAClB,YAAY;AAChB;AAEA,IAAM,mBAA2C;CAC7C,qBAAqB;CACrB,UAAU;CACV,eAAe;CACf,UAAU;CACV,kBAAkB;CAClB,YAAY;AAChB;AAsDA,IAAM,cAA4C;CAC9C,QAAQ;CACR,KAAK;CACL,YAAY;CACZ,MAAM;AACV;;;;;AAMA,IAAM,gBAAmC;CAAC;CAAW;CAAY;CAAmB;AAAW;AAE/F,IAAM,YAAY,UACd,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;;AAGvE,SAAS,aAAa,OAA2C;CAC7D,OAAO,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,YAAY,SAAS,MAAM,UAAU;AACzF;;AAGA,SAAS,M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T,IAAI,MAAM,WACN,WACI,gCAAgC,MAAM,iBAAiB,iBAAiB,KAAK,QAAQ,QAAQ,IAAI,GAAG,MAAM,gBAAgB,EAAE,KAC5H,yBACA,2JACJ;GAEJ,QAAQ,MAAM,EAAE;GAChB,KAAK,MAAM,QAAQ,SAAS,QAAQ,MAAM,IAAI;GAC9C,QAAQ,MAAM,EAAE;GAChB,QAAQ,KAAK,CAAC;EAClB;CACJ;CACA,MAAM,iBAAiB,MAAM,mBACvB,KAAK,QAAQ,QAAQ,IAAI,GAAG,MAAM,gBAAgB,IAClD,sBAAsB,WAAW;CACvC,MAAM,OAAO,MAAM,cAAc;CASjC,MAAM,SAAS,MAAM,UAAU;EAC3B;EACA;EACA;EACA;EACA,GAba,OACX,MAAM,oBAAoB,aAAa,SAAS;GAC9C,SAAS,MAAM,qBAAqB;GACpC,YAAY,MAAM,gBAAgB;GAClC,OAAO,MAAM,eAAe;EAChC,CAAC,IACC,CAAC;EAQH,cAAc,iBAAiB,QAAQ,KAAK,YAAY,WAAW,CAAC;CACxE,CAAC;CAED,IAAI,MAAM,WACN,QAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;MAE3C,YAAY,QAAQ,MAAM,eAAe,IAAI;CAEjD,IAAI,CAAC,OAAO,IAAI,QAAQ,WAAW;AACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/cli",
3
- "version": "0.29.0",
3
+ "version": "0.29.2",
4
4
  "description": "Developer tools for Rebase projects",
5
5
  "keywords": [
6
6
  "cli",
@@ -44,13 +44,13 @@
44
44
  "inquirer": "14.0.2",
45
45
  "jiti": "^2.7.0",
46
46
  "pg": "^8.22.0",
47
- "@rebasepro/agent-skills": "0.29.0",
48
- "@rebasepro/client": "0.29.0",
49
- "@rebasepro/rls-check": "0.29.0",
50
- "@rebasepro/server": "0.29.0",
51
- "@rebasepro/codegen": "0.29.0",
52
- "@rebasepro/types": "0.29.0",
53
- "@rebasepro/server-postgres": "0.29.0"
47
+ "@rebasepro/agent-skills": "0.29.2",
48
+ "@rebasepro/client": "0.29.2",
49
+ "@rebasepro/rls-check": "0.29.2",
50
+ "@rebasepro/server": "0.29.2",
51
+ "@rebasepro/codegen": "0.29.2",
52
+ "@rebasepro/server-postgres": "0.29.2",
53
+ "@rebasepro/types": "0.29.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^26.1.2",
@@ -20,14 +20,14 @@ export const users = rebaseSchema.table("users", {
20
20
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`now()`),
21
21
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).default(sql`now()`)
22
22
  }, (table) => ([
23
- pgPolicy("users_select_5f32f06", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
24
- pgPolicy("users_insert_3561e70_0", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
25
- pgPolicy("users_update_3561e70_1", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
26
- pgPolicy("users_delete_3561e70_2", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
27
- pgPolicy("users_default_admin_read", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
28
- pgPolicy("users_default_admin_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
29
- pgPolicy("users_default_admin_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
30
- pgPolicy("users_default_admin_write_delete", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
23
+ pgPolicy("users_select_5f32f06", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
24
+ pgPolicy("users_insert_3561e70_0", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
25
+ pgPolicy("users_update_3561e70_1", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
26
+ pgPolicy("users_delete_3561e70_2", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
27
+ pgPolicy("users_default_admin_read", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
28
+ pgPolicy("users_default_admin_write_insert", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
29
+ pgPolicy("users_default_admin_write_update", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
30
+ pgPolicy("users_default_admin_write_delete", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
31
31
  pgPolicy("users_default_self_read", { as: "permissive", for: "select", to: ["public"], using: sql`(id)::text = (SELECT rebase.uid())` }),
32
32
  pgPolicy("users_require_admin_write_insert", { as: "restrictive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
33
33
  pgPolicy("users_require_admin_write_update", { as: "restrictive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
@@ -14,13 +14,13 @@ export const authors = pgTable("authors", {
14
14
  picture: text("picture")
15
15
  }, (table) => ([
16
16
  pgPolicy("authors_select_841c287", { as: "permissive", for: "select", to: ["public"], using: sql`true` }),
17
- pgPolicy("authors_insert_3561e70_0", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
18
- pgPolicy("authors_update_3561e70_1", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
19
- pgPolicy("authors_delete_3561e70_2", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
20
- pgPolicy("authors_default_admin_read", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
21
- pgPolicy("authors_default_admin_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
22
- pgPolicy("authors_default_admin_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
23
- pgPolicy("authors_default_admin_write_delete", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
17
+ pgPolicy("authors_insert_3561e70_0", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
18
+ pgPolicy("authors_update_3561e70_1", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
19
+ pgPolicy("authors_delete_3561e70_2", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
20
+ pgPolicy("authors_default_admin_read", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
21
+ pgPolicy("authors_default_admin_write_insert", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
22
+ pgPolicy("authors_default_admin_write_update", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
23
+ pgPolicy("authors_default_admin_write_delete", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
24
24
  ])).enableRLS();
25
25
 
26
26
  export const posts = pgTable("posts", {
@@ -32,13 +32,13 @@ export const posts = pgTable("posts", {
32
32
  }, (table) => ([
33
33
  index("posts_author_id_ix_00ad191").on(table.authorId.asc().nullsLast()),
34
34
  pgPolicy("posts_select_841c287", { as: "permissive", for: "select", to: ["public"], using: sql`true` }),
35
- pgPolicy("posts_insert_3561e70_0", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
36
- pgPolicy("posts_update_3561e70_1", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
37
- pgPolicy("posts_delete_3561e70_2", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
38
- pgPolicy("posts_default_admin_read", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
39
- pgPolicy("posts_default_admin_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
40
- pgPolicy("posts_default_admin_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
41
- pgPolicy("posts_default_admin_write_delete", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
35
+ pgPolicy("posts_insert_3561e70_0", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
36
+ pgPolicy("posts_update_3561e70_1", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
37
+ pgPolicy("posts_delete_3561e70_2", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
38
+ pgPolicy("posts_default_admin_read", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
39
+ pgPolicy("posts_default_admin_write_insert", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
40
+ pgPolicy("posts_default_admin_write_update", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
41
+ pgPolicy("posts_default_admin_write_delete", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
42
42
  ])).enableRLS();
43
43
 
44
44
  export const postsTags = pgTable("posts_tags", {
@@ -47,10 +47,10 @@ export const postsTags = pgTable("posts_tags", {
47
47
  }, (table) => ([
48
48
  primaryKey({ columns: [table.post_id, table.tag_id] }),
49
49
  index("posts_tags_tag_id_ix_d4456f1").on(table.tag_id.asc().nullsLast()),
50
- pgPolicy("posts_tags_default_admin_read", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
51
- pgPolicy("posts_tags_default_admin_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
52
- pgPolicy("posts_tags_default_admin_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
53
- pgPolicy("posts_tags_default_admin_write_delete", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
50
+ pgPolicy("posts_tags_default_admin_read", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
51
+ pgPolicy("posts_tags_default_admin_write_insert", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
52
+ pgPolicy("posts_tags_default_admin_write_update", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
53
+ pgPolicy("posts_tags_default_admin_write_delete", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
54
54
  pgPolicy("posts_tags_default_edge_read", { as: "permissive", for: "select", to: ["public"], using: sql`(EXISTS (SELECT 1 FROM "public"."posts" "_ex0" WHERE "_ex0".id = "public"."posts_tags".post_id)) AND (EXISTS (SELECT 1 FROM "public"."tags" "_ex1" WHERE "_ex1".id = "public"."posts_tags".tag_id))` }),
55
55
  pgPolicy("posts_tags_default_edge_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`EXISTS (SELECT 1 FROM "public"."posts" "_ex0" WHERE ("_ex0".id = "public"."posts_tags".post_id) AND ((SELECT (string_to_array(rebase.roles(), ',') && ARRAY['admin']))))` }),
56
56
  pgPolicy("posts_tags_default_edge_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`EXISTS (SELECT 1 FROM "public"."posts" "_ex0" WHERE ("_ex0".id = "public"."posts_tags".post_id) AND ((SELECT (string_to_array(rebase.roles(), ',') && ARRAY['admin']))))`, withCheck: sql`EXISTS (SELECT 1 FROM "public"."posts" "_ex0" WHERE ("_ex0".id = "public"."posts_tags".post_id) AND ((SELECT (string_to_array(rebase.roles(), ',') && ARRAY['admin']))))` }),
@@ -62,13 +62,13 @@ export const tags = pgTable("tags", {
62
62
  name: text("name").notNull()
63
63
  }, (table) => ([
64
64
  pgPolicy("tags_select_841c287", { as: "permissive", for: "select", to: ["public"], using: sql`true` }),
65
- pgPolicy("tags_insert_3561e70_0", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
66
- pgPolicy("tags_update_3561e70_1", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
67
- pgPolicy("tags_delete_3561e70_2", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
68
- pgPolicy("tags_default_admin_read", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
69
- pgPolicy("tags_default_admin_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
70
- pgPolicy("tags_default_admin_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
71
- pgPolicy("tags_default_admin_write_delete", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
65
+ pgPolicy("tags_insert_3561e70_0", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
66
+ pgPolicy("tags_update_3561e70_1", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
67
+ pgPolicy("tags_delete_3561e70_2", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
68
+ pgPolicy("tags_default_admin_read", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
69
+ pgPolicy("tags_default_admin_write_insert", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
70
+ pgPolicy("tags_default_admin_write_update", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
71
+ pgPolicy("tags_default_admin_write_delete", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
72
72
  ])).enableRLS();
73
73
 
74
74
  export const users = rebaseSchema.table("users", {
@@ -85,14 +85,14 @@ export const users = rebaseSchema.table("users", {
85
85
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`now()`),
86
86
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).default(sql`now()`)
87
87
  }, (table) => ([
88
- pgPolicy("users_select_5f32f06", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
89
- pgPolicy("users_insert_3561e70_0", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
90
- pgPolicy("users_update_3561e70_1", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
91
- pgPolicy("users_delete_3561e70_2", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
92
- pgPolicy("users_default_admin_read", { as: "permissive", for: "select", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
93
- pgPolicy("users_default_admin_write_insert", { as: "permissive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
94
- pgPolicy("users_default_admin_write_update", { as: "permissive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
95
- pgPolicy("users_default_admin_write_delete", { as: "permissive", for: "delete", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
88
+ pgPolicy("users_select_5f32f06", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
89
+ pgPolicy("users_insert_3561e70_0", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
90
+ pgPolicy("users_update_3561e70_1", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])`, withCheck: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
91
+ pgPolicy("users_delete_3561e70_2", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT string_to_array(rebase.roles(), ',') && ARRAY['admin'])` }),
92
+ pgPolicy("users_default_admin_read", { as: "permissive", for: "select", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
93
+ pgPolicy("users_default_admin_write_insert", { as: "permissive", for: "insert", to: ["rebase_admin"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
94
+ pgPolicy("users_default_admin_write_update", { as: "permissive", for: "update", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
95
+ pgPolicy("users_default_admin_write_delete", { as: "permissive", for: "delete", to: ["rebase_admin"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
96
96
  pgPolicy("users_default_self_read", { as: "permissive", for: "select", to: ["public"], using: sql`(id)::text = (SELECT rebase.uid())` }),
97
97
  pgPolicy("users_require_admin_write_insert", { as: "restrictive", for: "insert", to: ["public"], withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),
98
98
  pgPolicy("users_require_admin_write_update", { as: "restrictive", for: "update", to: ["public"], using: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))`, withCheck: sql`(SELECT (rebase.uid() IS NULL) OR (string_to_array(rebase.roles(), ',') && ARRAY['admin']))` }),