@rebasepro/cli 0.33.2 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-setup-Cg_zBWoW.js → agent-setup-CGeAuP0Q.js} +2 -2
- package/dist/{agent-setup-Cg_zBWoW.js.map → agent-setup-CGeAuP0Q.js.map} +1 -1
- package/dist/{api-keys-fPQ55DCm.js → api-keys-DaWN8dyI.js} +3 -3
- package/dist/{api-keys-fPQ55DCm.js.map → api-keys-DaWN8dyI.js.map} +1 -1
- package/dist/{api-TbmW33D7.js → api-zx1wSK5a.js} +2 -2
- package/dist/{api-TbmW33D7.js.map → api-zx1wSK5a.js.map} +1 -1
- package/dist/{apps-DBTRoOeP.js → apps-D6vtDrkJ.js} +3 -3
- package/dist/{apps-DBTRoOeP.js.map → apps-D6vtDrkJ.js.map} +1 -1
- package/dist/{auth-BpyYLEFY.js → auth-DY7kU0z-.js} +8 -8
- package/dist/{auth-BpyYLEFY.js.map → auth-DY7kU0z-.js.map} +1 -1
- package/dist/{auth-session-B6aT0Dyj.js → auth-session-DCG96UGH.js} +4 -4
- package/dist/{auth-session-B6aT0Dyj.js.map → auth-session-DCG96UGH.js.map} +1 -1
- package/dist/{build-E5hfEWKj.js → build-D0egCUfU.js} +4 -4
- package/dist/{build-E5hfEWKj.js.map → build-D0egCUfU.js.map} +1 -1
- package/dist/{bundle-CIiKGrte.js → bundle-DhdhtD8K.js} +3 -3
- package/dist/{bundle-CIiKGrte.js.map → bundle-DhdhtD8K.js.map} +1 -1
- package/dist/{cloud-DNJyUU0T.js → cloud-DOR7bxDw.js} +218 -27
- package/dist/cloud-DOR7bxDw.js.map +1 -0
- package/dist/{command-Bks5xkrQ.js → command-BzSP5gBh.js} +2 -2
- package/dist/{command-Bks5xkrQ.js.map → command-BzSP5gBh.js.map} +1 -1
- package/dist/commands/cloud/db-connect.d.ts +31 -1
- package/dist/commands/cloud/db-query.d.ts +16 -0
- package/dist/commands/cloud/index.d.ts +1 -0
- package/dist/commands/cloud/resources.d.ts +19 -1
- package/dist/commands/dev.d.ts +15 -0
- package/dist/commands/users.d.ts +1 -0
- package/dist/{context-BOMEoKxn.js → context-xt20FMFA.js} +5 -1
- package/dist/{context-BOMEoKxn.js.map → context-xt20FMFA.js.map} +1 -1
- package/dist/{cron-CpUsQ739.js → cron-BGkXIB1N.js} +4 -4
- package/dist/{cron-CpUsQ739.js.map → cron-BGkXIB1N.js.map} +1 -1
- package/dist/{cron-ZRXsla0v.js → cron-CJ6Xk42E.js} +3 -3
- package/dist/{cron-ZRXsla0v.js.map → cron-CJ6Xk42E.js.map} +1 -1
- package/dist/{data-BJ9AZFUC.js → data-BpkvtCUe.js} +3 -3
- package/dist/{data-BJ9AZFUC.js.map → data-BpkvtCUe.js.map} +1 -1
- package/dist/{debug-nNbbxAeo.js → debug-C7Ss34XB.js} +2 -2
- package/dist/{debug-nNbbxAeo.js.map → debug-C7Ss34XB.js.map} +1 -1
- package/dist/{derive-Mky_u59_.js → derive-ChP6vgfi.js} +2 -2
- package/dist/{derive-Mky_u59_.js.map → derive-ChP6vgfi.js.map} +1 -1
- package/dist/{dev-bj6dEeSQ.js → dev-C7n36E6f.js} +23 -2
- package/dist/dev-C7n36E6f.js.map +1 -0
- package/dist/{doctor-FaBObSlb.js → doctor-D0o54XSQ.js} +2 -2
- package/dist/{doctor-FaBObSlb.js.map → doctor-D0o54XSQ.js.map} +1 -1
- package/dist/{fold-static-2t3UUX4z.js → fold-static-DTpaqbB0.js} +2 -2
- package/dist/{fold-static-2t3UUX4z.js.map → fold-static-DTpaqbB0.js.map} +1 -1
- package/dist/{function-portability-BIvlvR9q.js → function-portability-Dppl6uqg.js} +24 -5
- package/dist/{function-portability-BIvlvR9q.js.map → function-portability-Dppl6uqg.js.map} +1 -1
- package/dist/function-portability.d.ts +9 -0
- package/dist/{functions-B4JR6EZL.js → functions-DLuuldt2.js} +4 -4
- package/dist/{functions-B4JR6EZL.js.map → functions-DLuuldt2.js.map} +1 -1
- package/dist/{generate_sdk-ByD-gTsK.js → generate_sdk-UT1lwwRT.js} +2 -2
- package/dist/{generate_sdk-ByD-gTsK.js.map → generate_sdk-UT1lwwRT.js.map} +1 -1
- package/dist/index.es.js +39 -39
- package/dist/{init-DHCe5mJ5.js → init-u5Xmr1Ct.js} +4 -4
- package/dist/{init-DHCe5mJ5.js.map → init-u5Xmr1Ct.js.map} +1 -1
- package/dist/{logs-DpuMukJe.js → logs-DBYRSs6W.js} +4 -4
- package/dist/{logs-DpuMukJe.js.map → logs-DBYRSs6W.js.map} +1 -1
- package/dist/{migrate-CSY9ZDKy.js → migrate-Cw1FkvUK.js} +3 -3
- package/dist/{migrate-CSY9ZDKy.js.map → migrate-Cw1FkvUK.js.map} +1 -1
- package/dist/{normalize-imports-P86NVfpo.js → normalize-imports-E4yA1HfW.js} +2 -2
- package/dist/{normalize-imports-P86NVfpo.js.map → normalize-imports-E4yA1HfW.js.map} +1 -1
- package/dist/{project-command-Cl9EZzjr.js → project-command-7EGMemEy.js} +5 -5
- package/dist/{project-command-Cl9EZzjr.js.map → project-command-7EGMemEy.js.map} +1 -1
- package/dist/{resources-Db3USuPO.js → resources-CE6BeL94.js} +2 -2
- package/dist/{resources-Db3USuPO.js.map → resources-CE6BeL94.js.map} +1 -1
- package/dist/{rls-BxrQ0P50.js → rls-BxWLfEKl.js} +3 -3
- package/dist/{rls-BxrQ0P50.js.map → rls-BxWLfEKl.js.map} +1 -1
- package/dist/{schema-_FzZEoB8.js → schema-D8xFSBbN.js} +7 -6
- package/dist/{schema-_FzZEoB8.js.map → schema-D8xFSBbN.js.map} +1 -1
- package/dist/schema-reconcile-D_wvZY91.js +2 -0
- package/dist/{schema-show-h72UJ9zH.js → schema-show-C7bY7SgE.js} +3 -3
- package/dist/{schema-show-h72UJ9zH.js.map → schema-show-C7bY7SgE.js.map} +1 -1
- package/dist/{skills-DQ2bZGkj.js → skills-C8WdRTFg.js} +4 -4
- package/dist/{skills-DQ2bZGkj.js.map → skills-C8WdRTFg.js.map} +1 -1
- package/dist/{start-Cjx4W0bJ.js → start-CN_9C205.js} +2 -2
- package/dist/{start-Cjx4W0bJ.js.map → start-CN_9C205.js.map} +1 -1
- package/dist/{status-CDBk25VO.js → status-HWlZbY1E.js} +2 -2
- package/dist/{status-CDBk25VO.js.map → status-HWlZbY1E.js.map} +1 -1
- package/dist/{storage-Clc8dLG8.js → storage-DBE8lgH-.js} +9 -9
- package/dist/{storage-Clc8dLG8.js.map → storage-DBE8lgH-.js.map} +1 -1
- package/dist/{storage-objects-CfRKlTDe.js → storage-objects-ljDmtuH7.js} +3 -3
- package/dist/{storage-objects-CfRKlTDe.js.map → storage-objects-ljDmtuH7.js.map} +1 -1
- package/dist/{users-5PkqBY6R.js → users-DrJEtL9k.js} +9 -6
- package/dist/users-DrJEtL9k.js.map +1 -0
- package/package.json +10 -10
- package/templates/template/.cursorrules +2 -1
- package/templates/template/.github/copilot-instructions.md +2 -1
- package/templates/template/.windsurfrules +2 -1
- package/templates/template/AGENTS.md +2 -1
- package/templates/template/CLAUDE.md +2 -1
- package/templates/template/ai-instructions.md +5 -2
- package/templates/template/frontend/src/index.css +13 -0
- package/dist/cloud-DNJyUU0T.js.map +0 -1
- package/dist/dev-bj6dEeSQ.js.map +0 -1
- package/dist/schema-reconcile-DV14XY4o.js +0 -2
- package/dist/users-5PkqBY6R.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-Bks5xkrQ.js","names":[],"sources":["../src/codemod/collections-to-tables/print-js.ts","../src/codemod/collections-to-tables/ast.ts","../src/codemod/collections-to-tables/own.ts","../src/codemod/collections-to-tables/hooks.ts","../src/codemod/collections-to-tables/modules.ts","../src/codemod/collections-to-tables/helper-hooks.ts","../src/codemod/collections-to-tables/plan-context.ts","../src/codemod/collections-to-tables/backend.ts","../src/codemod/collections-to-tables/vocabulary.ts","../src/codemod/collections-to-tables/comments.ts","../src/codemod/collections-to-tables/dynamic-props.ts","../src/codemod/collections-to-tables/split-constants.ts","../src/codemod/collections-to-tables/customization.ts","../src/codemod/collections-to-tables/firestore.ts","../src/codemod/collections-to-tables/export-changes.ts","../src/codemod/collections-to-tables/moved-symbols.generated.ts","../src/codemod/collections-to-tables/moved-imports.ts","../src/codemod/collections-to-tables/sdk-calls.ts","../src/codemod/collections-to-tables/row-hands.ts","../src/codemod/collections-to-tables/skills-step.ts","../src/codemod/collections-to-tables/journal.ts","../src/codemod/collections-to-tables/legacy-shims.ts","../src/codemod/collections-to-tables/load-legacy.ts","../src/codemod/collections-to-tables/path-aliases.ts","../src/codemod/collections-to-tables/project-files.ts","../src/codemod/collections-to-tables/storage-paths.ts","../src/codemod/collections-to-tables/repoint.ts","../src/codemod/collections-to-tables/verify.ts","../src/codemod/collections-to-tables/migrate.ts","../src/codemod/collections-to-tables/command.ts"],"sourcesContent":["/**\n * Printing plain values as TypeScript source, with code spliced in.\n *\n * The codemod writes two kinds of value: data it read off an evaluated\n * collection (strings, numbers, arrays, objects), printed here, and code it\n * read off the legacy source (a hook, an entity action, a component), carried\n * as {@link RawSource} and printed verbatim, re-indented to where it lands.\n *\n * Same conventions as the shared table printer: four-space indentation,\n * double quotes, no trailing commas, one entry per line for a non-empty\n * object.\n */\n\n/** Source text printed verbatim. Its first line starts at column 0; later lines carry their indentation relative to it. */\nexport class RawSource {\n constructor(readonly text: string) {}\n}\n\nconst INDENT = \" \";\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/** An object key as written: bare when it is an identifier, quoted otherwise. */\nexport function printKey(key: string): string {\n return IDENTIFIER.test(key) ? key : JSON.stringify(key);\n}\n\n/** A string literal, double-quoted. */\nexport function printStringLiteral(value: string): string {\n return JSON.stringify(value);\n}\n\n/**\n * Re-indent raw source to land at `indent`: every line after the first gets\n * the prefix, so the block keeps its own shape.\n */\nexport function reindent(text: string, indent: string): string {\n const lines = text.split(\"\\n\");\n return lines.map((line, index) => (index === 0 || line.length === 0 ? line : `${indent}${line}`)).join(\"\\n\");\n}\n\n/**\n * Strip the indentation a node had in its file: `text` is the node's text\n * (its first line starts at the node), `baseIndent` the leading whitespace of\n * the line it starts on. Later lines that start with that whitespace lose it.\n */\nexport function dedent(text: string, baseIndent: string): string {\n if (baseIndent.length === 0) return text;\n return text\n .split(\"\\n\")\n .map((line, index) => (index > 0 && line.startsWith(baseIndent) ? line.slice(baseIndent.length) : line))\n .join(\"\\n\");\n}\n\n/** Thrown for a value that is code, and that no source text was found for. */\nexport class UnprintableValueError extends Error {\n constructor(readonly path: string, message: string) {\n super(`${path}: ${message}`);\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** Whether a value holds a function anywhere: it then needs source text to print. */\nexport function containsCode(value: unknown, seen: Set<unknown> = new Set()): boolean {\n if (typeof value === \"function\") return true;\n if (value instanceof RawSource) return false;\n if (typeof value !== \"object\" || value === null || seen.has(value)) return false;\n seen.add(value);\n if (Array.isArray(value)) return value.some(entry => containsCode(entry, seen));\n if (!isPlainObject(value)) return true;\n return Object.values(value).some(entry => containsCode(entry, seen));\n}\n\n/**\n * A value as source text, starting at `indent` (the indentation of the line\n * it begins on).\n */\nexport function printValue(value: unknown, indent = \"\", path = \"value\"): string {\n if (value instanceof RawSource) return reindent(value.text, indent);\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n switch (typeof value) {\n case \"string\":\n return printStringLiteral(value);\n case \"number\":\n if (Number.isNaN(value)) return \"NaN\";\n if (!Number.isFinite(value)) return value > 0 ? \"Infinity\" : \"-Infinity\";\n return Object.is(value, -0) ? \"-0\" : String(value);\n case \"boolean\":\n return String(value);\n case \"bigint\":\n return `${value}n`;\n case \"function\":\n throw new UnprintableValueError(path, \"it is a function, and no source text for it was found.\");\n default:\n break;\n }\n const inner = indent + INDENT;\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n const items = value.map((entry, index) => printValue(entry, inner, `${path}[${index}]`));\n const flat = `[${items.join(\", \")}]`;\n if (!flat.includes(\"\\n\") && flat.length + indent.length <= 100 && value.every(entry => typeof entry !== \"object\" || entry === null)) {\n return flat;\n }\n return `[\\n${items.map(item => `${inner}${item}`).join(\",\\n\")}\\n${indent}]`;\n }\n if (value instanceof Date) return `new Date(${printStringLiteral(value.toISOString())})`;\n if (!isPlainObject(value)) {\n throw new UnprintableValueError(path, \"it is an instance of a class, which cannot be printed as a literal.\");\n }\n const entries = Object.entries(value).filter(([, entry]) => entry !== undefined);\n if (entries.length === 0) return \"{}\";\n const lines = entries.map(([key, entry]) => `${inner}${printKey(key)}: ${printValue(entry, inner, `${path}.${key}`)}`);\n return `{\\n${lines.join(\",\\n\")}\\n${indent}}`;\n}\n","/**\n * Reading the legacy source with ts-morph: where a collection's object\n * literal is, the node at a path inside it, and the code a node needs carried\n * with it (the imports and top-level declarations it references).\n *\n * The codemod evaluates collections for their data; it reads the AST only for\n * what a value cannot say — the text of a function, the comment above a\n * property, the module a component came from. So everything here answers one\n * question about one node, and says why when it cannot.\n *\n * ts-morph is loaded once per run (`await import(\"ts-morph\")`) and handed in;\n * nothing here imports it at module load, so the CLI's start-up never pays\n * for it.\n */\nimport path from \"node:path\";\nimport type {\n ArrayLiteralExpression,\n Expression,\n Identifier,\n MethodDeclaration,\n Node,\n ObjectLiteralExpression,\n Project,\n SourceFile,\n Statement\n} from \"ts-morph\";\n\nimport { dedent } from \"./print-js\";\n\n/** The ts-morph module, loaded lazily by the run. */\nexport type TsMorph = typeof import(\"ts-morph\");\n\n/** What every AST helper needs. */\nexport interface AstContext {\n tsm: TsMorph;\n /** An in-memory project holding the legacy files at their absolute paths, and scratch files. */\n project: Project;\n}\n\n/** Create the in-memory project the legacy files are read into. */\nexport function createAstContext(tsm: TsMorph): AstContext {\n const project = new tsm.Project({\n useInMemoryFileSystem: true,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n allowJs: true,\n jsx: tsm.ts.JsxEmit.Preserve,\n target: tsm.ts.ScriptTarget.ES2022,\n module: tsm.ts.ModuleKind.ESNext,\n moduleResolution: tsm.ts.ModuleResolutionKind.Bundler,\n noLib: true\n }\n });\n return { tsm, project };\n}\n\n/** Add a legacy file to the project, at its absolute path. */\nexport function addSourceFile(ctx: AstContext, absolutePath: string, text: string): SourceFile {\n return ctx.project.createSourceFile(absolutePath, text, { overwrite: true });\n}\n\n/** The node a lookup ended on, or why it could not get there. */\nexport type Located<T> = { node: T; reason?: undefined } | { node?: undefined; reason: string };\n\n/** Strip `as`, `satisfies`, parentheses, `!` and `<T>` casts. */\nexport function unwrap(ctx: AstContext, node: Node): Node {\n const { Node: N } = ctx.tsm;\n let current = node;\n for (;;) {\n if (N.isAsExpression(current) || N.isSatisfiesExpression(current) || N.isParenthesizedExpression(current) ||\n N.isNonNullExpression(current) || N.isTypeAssertion(current)) {\n current = current.getExpression();\n continue;\n }\n return current;\n }\n}\n\n/** The top-level `const` an identifier names in its own file, or undefined. */\nexport function sameFileConst(ctx: AstContext, identifier: Identifier): Expression | undefined {\n const { Node: N, VariableDeclarationKind } = ctx.tsm;\n const sf = identifier.getSourceFile();\n const declaration = sf.getVariableDeclaration(identifier.getText());\n if (!declaration) return undefined;\n const list = declaration.getVariableStatement();\n if (!list || !N.isSourceFile(list.getParent())) return undefined;\n if (list.getDeclarationKind() !== VariableDeclarationKind.Const) return undefined;\n return declaration.getInitializer();\n}\n\n/** The names a builder call that wraps a collection literal may have. */\nconst WRAPPER_CALLS = new Set([\"defineCollection\", \"defineFirestoreCollection\"]);\n\n/**\n * Follow a node to the object literal it denotes: through casts, a wrapper\n * call (`defineCollection({...})`) and a same-file `const`.\n */\nexport function resolveObject(ctx: AstContext, node: Node | undefined, depth = 0): Located<ObjectLiteralExpression> {\n const { Node: N } = ctx.tsm;\n if (!node) return { reason: \"there is no expression to read\" };\n if (depth > 8) return { reason: \"the expression refers to itself\" };\n const current = unwrap(ctx, node);\n if (N.isObjectLiteralExpression(current)) return { node: current };\n if (N.isCallExpression(current)) {\n const callee = current.getExpression().getText();\n if (WRAPPER_CALLS.has(callee)) return resolveObject(ctx, current.getArguments()[0], depth + 1);\n return { reason: `it is the result of calling \\`${callee}(...)\\`, which the codemod cannot read through` };\n }\n if (N.isIdentifier(current)) {\n const initializer = sameFileConst(ctx, current);\n if (initializer) return resolveObject(ctx, initializer, depth + 1);\n return { reason: `it is \\`${current.getText()}\\`, which is not a \\`const\\` declared in the same file` };\n }\n return { reason: `it is a ${current.getKindName()}, not an object literal` };\n}\n\n/** Like {@link resolveObject}, for an array literal. */\nexport function resolveArray(ctx: AstContext, node: Node | undefined, depth = 0): Located<ArrayLiteralExpression> {\n const { Node: N } = ctx.tsm;\n if (!node) return { reason: \"there is no expression to read\" };\n if (depth > 8) return { reason: \"the expression refers to itself\" };\n const current = unwrap(ctx, node);\n if (N.isArrayLiteralExpression(current)) return { node: current };\n if (N.isIdentifier(current)) {\n const initializer = sameFileConst(ctx, current);\n if (initializer) return resolveArray(ctx, initializer, depth + 1);\n return { reason: `it is \\`${current.getText()}\\`, which is not a \\`const\\` declared in the same file` };\n }\n return { reason: `it is a ${current.getKindName()}, not an array literal` };\n}\n\n/** The literal text of a property name, or undefined for a computed one that is not a string literal. */\nfunction memberName(ctx: AstContext, member: Node): string | undefined {\n const { Node: N } = ctx.tsm;\n if (!N.isPropertyAssignment(member) && !N.isShorthandPropertyAssignment(member) && !N.isMethodDeclaration(member) &&\n !N.isGetAccessorDeclaration(member) && !N.isSetAccessorDeclaration(member)) {\n return undefined;\n }\n const nameNode = member.getNameNode();\n if (N.isIdentifier(nameNode) || N.isPrivateIdentifier(nameNode)) return nameNode.getText();\n if (N.isStringLiteral(nameNode) || N.isNoSubstitutionTemplateLiteral(nameNode)) return nameNode.getLiteralValue();\n if (N.isNumericLiteral(nameNode)) return String(nameNode.getLiteralValue());\n if (N.isComputedPropertyName(nameNode)) {\n const expression = nameNode.getExpression();\n if (N.isStringLiteral(expression) || N.isNoSubstitutionTemplateLiteral(expression)) return expression.getLiteralValue();\n }\n return undefined;\n}\n\n/** One member of an object literal, found by name. */\nexport interface Member {\n /** The member node: a property assignment, a shorthand, or a method. */\n node: Node;\n /** The value expression (absent for a method, which is its own value). */\n value?: Expression;\n /** Present for a method. */\n method?: MethodDeclaration;\n}\n\n/**\n * The member of an object literal named `name`. Refuses (with the reason)\n * when the literal has a spread or a computed key that could be providing\n * it, because then the literal alone does not say where the value is from.\n */\nexport function memberOf(ctx: AstContext, literal: ObjectLiteralExpression, name: string): Located<Member> {\n const { Node: N } = ctx.tsm;\n let found: Member | undefined;\n let opaque: string | undefined;\n for (const member of literal.getProperties()) {\n if (N.isSpreadAssignment(member)) {\n // A later explicit member wins over a spread; an earlier one does not.\n found = undefined;\n opaque = `\\`...${member.getExpression().getText()}\\` (line ${member.getStartLineNumber()})`;\n continue;\n }\n const memberKey = memberName(ctx, member);\n if (memberKey === undefined) {\n opaque = `the computed key \\`${member.getText().split(\":\")[0]}\\` (line ${member.getStartLineNumber()})`;\n continue;\n }\n if (memberKey !== name) continue;\n opaque = undefined;\n if (N.isPropertyAssignment(member)) found = { node: member, value: member.getInitializerOrThrow() };\n else if (N.isShorthandPropertyAssignment(member)) found = { node: member, value: member.getNameNode() };\n else if (N.isMethodDeclaration(member)) found = { node: member, method: member };\n else return { reason: `\\`${name}\\` is an accessor (line ${member.getStartLineNumber()})` };\n }\n if (found) return { node: found };\n if (opaque) return { reason: `\\`${name}\\` may come from ${opaque}, which the codemod does not read through` };\n return { reason: `there is no \\`${name}\\` in the object literal at line ${literal.getStartLineNumber()}` };\n}\n\n/** Whether an expression is a module-scope name, or a property chain on one (`rules.fixed`): an import or a top-level `const`. */\nfunction isModuleName(ctx: AstContext, node: Node): boolean {\n const { Node: N, SyntaxKind, VariableDeclarationKind } = ctx.tsm;\n if (N.isPropertyAccessExpression(node)) return isModuleName(ctx, node.getExpression());\n if (!N.isIdentifier(node)) return false;\n const declarations = node.getSymbol()?.getDeclarations() ?? [];\n return declarations.length > 0 && declarations.every(declaration => {\n if (N.isImportSpecifier(declaration) || N.isImportClause(declaration) || N.isNamespaceImport(declaration)) return true;\n if (!N.isVariableDeclaration(declaration)) return false;\n const statement = declaration.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n return statement !== undefined && N.isSourceFile(statement.getParent()) && statement.getDeclarationKind() === VariableDeclarationKind.Const;\n });\n}\n\n/**\n * The value at `segments` below an object literal when an object literal on\n * the way spreads the one object that must provide it — `{ ...fixedOnceCreated }`\n * with no `dynamicProps` of its own — as an expression on that object:\n * `fixedOnceCreated.dynamicProps`, the very value the evaluation saw. Returns\n * the spread expression too, whose imports the caller carries.\n *\n * Only when nothing else could provide it: exactly one spread in that literal,\n * no computed key, no member of that name (before or after the spread), a\n * spread of an imported or top-level `const` name (not a call, not a\n * parameter), and only names below it.\n */\nexport function spreadSource(ctx: AstContext, root: ObjectLiteralExpression, segments: readonly PathSegment[]): { text: string; spread: Expression } | undefined {\n const { Node: N } = ctx.tsm;\n let current: Member = { node: root, value: root };\n for (let index = 0; index < segments.length; index++) {\n const segment = segments[index];\n if (typeof segment === \"number\" || current.method) return undefined;\n const object = resolveObject(ctx, current.value);\n if (!object.node) return undefined;\n const member = memberOf(ctx, object.node, segment);\n if (member.node) {\n current = member.node;\n continue;\n }\n const properties = object.node.getProperties();\n const spreads = properties.filter(property => N.isSpreadAssignment(property));\n if (spreads.length !== 1) return undefined;\n for (const property of properties) {\n if (N.isSpreadAssignment(property)) continue;\n const name = memberName(ctx, property);\n if (name === undefined || name === segment) return undefined;\n }\n const rest = segments.slice(index);\n if (!rest.every(part => typeof part === \"string\" && /^[A-Za-z_$][\\w$]*$/.test(part))) return undefined;\n const spreadAssignment = spreads[0];\n if (!spreadAssignment || !N.isSpreadAssignment(spreadAssignment)) return undefined;\n const spread = unwrap(ctx, spreadAssignment.getExpression());\n if (!N.isExpression(spread) || !isModuleName(ctx, spread)) return undefined;\n return { text: `${spread.getText()}.${rest.join(\".\")}`, spread };\n }\n return undefined;\n}\n\n/** A path segment: a member name, or an array index. */\nexport type PathSegment = string | number;\n\n/**\n * The member at `segments` below an object literal: each name read with\n * {@link memberOf}, each index from an array literal, every step resolved\n * through same-file `const`s.\n */\nexport function nodeAtPath(ctx: AstContext, root: ObjectLiteralExpression, segments: readonly PathSegment[]): Located<Member> {\n let current: Member = { node: root, value: root };\n const walked: string[] = [];\n for (const segment of segments) {\n const label = walked.length > 0 ? walked.join(\"\") : \"the collection\";\n if (typeof segment === \"number\") {\n const array = resolveArray(ctx, current.value);\n if (!array.node) return { reason: `${label}: ${array.reason}` };\n const elements = array.node.getElements();\n if (elements.slice(0, segment + 1).some(element => ctx.tsm.Node.isSpreadElement(element))) {\n return { reason: `${label} spreads another array before item ${segment}, which the codemod does not read through` };\n }\n const element = elements[segment];\n if (!element) return { reason: `${label} has no item ${segment}` };\n current = { node: element, value: element };\n walked.push(`[${segment}]`);\n continue;\n }\n if (current.method) return { reason: `${label} is a method, not an object` };\n const object = resolveObject(ctx, current.value);\n if (!object.node) return { reason: `${label}: ${object.reason}` };\n const member = memberOf(ctx, object.node, segment);\n if (!member.node) return { reason: `${label}: ${member.reason}` };\n current = member.node;\n walked.push(walked.length > 0 ? `.${segment}` : segment);\n }\n return { node: current };\n}\n\n/** The whitespace a node's first line starts with in its file. */\nexport function lineIndent(node: Node): string {\n const sf = node.getSourceFile();\n const text = sf.getFullText();\n const start = node.getStart();\n const lineStart = text.lastIndexOf(\"\\n\", start - 1) + 1;\n const prefix = text.slice(lineStart, start);\n const match = /^[ \\t]*/.exec(prefix);\n return match ? match[0] : \"\";\n}\n\n/** A node's text with the indentation of its line removed from every later line. */\nexport function nodeText(node: Node): string {\n return dedent(node.getText(), lineIndent(node));\n}\n\n/** `file:line` for messages, relative to `root`. */\nexport function where(node: Node, root: string): { file: string; line: number } {\n return { file: toPosix(path.relative(root, node.getSourceFile().getFilePath())), line: node.getStartLineNumber() };\n}\n\n/** A path with `/` separators. */\nexport function toPosix(value: string): string {\n return value.split(path.sep).join(\"/\");\n}\n\n// ── The collection literal ───────────────────────────────────────────────────\n\n/** Where a collection file's default export is. */\nexport interface CollectionSite {\n /** The object literal the collection is written as. */\n literal: ObjectLiteralExpression;\n /** The local name the collection is bound to, when it is bound (`usersCollection`). */\n binding?: string;\n /** The statements that declare and default-export it, which are not carried anywhere. */\n statements: Statement[];\n}\n\n/** Find the object literal a collection file default-exports. */\nexport function findCollectionSite(ctx: AstContext, sf: SourceFile): Located<CollectionSite> {\n const { Node: N } = ctx.tsm;\n const statements: Statement[] = [];\n let expression: Node | undefined;\n for (const statement of sf.getStatements()) {\n if (N.isExportAssignment(statement) && !statement.isExportEquals()) {\n expression = statement.getExpression();\n statements.push(statement);\n } else if (N.isExportDeclaration(statement)) {\n for (const specifier of statement.getNamedExports()) {\n if ((specifier.getAliasNode()?.getText() ?? specifier.getName()) === \"default\" && !statement.getModuleSpecifier()) {\n expression = specifier.getNameNode();\n statements.push(statement);\n }\n }\n }\n }\n if (!expression) return { reason: \"the file has no `export default` the codemod can read\" };\n let binding: string | undefined;\n const bare = unwrap(ctx, expression);\n if (N.isIdentifier(bare)) {\n binding = bare.getText();\n const declaration = sf.getVariableDeclaration(binding);\n const statement = declaration?.getVariableStatement();\n if (statement) statements.push(statement);\n }\n const literal = resolveObject(ctx, expression);\n if (!literal.node) return { reason: `the default export is not an object literal the codemod can read: ${literal.reason}` };\n return { node: { literal: literal.node, ...(binding ? { binding } : {}), statements } };\n}\n\n/**\n * Assignments to the collection after its declaration, at the top level of\n * its file: `usersCollection.securityRules = [...]`. Keyed by the assigned\n * path (`securityRules`, `properties.title.callbacks`).\n */\nexport function postDeclarationAssignments(ctx: AstContext, sf: SourceFile, binding: string): Map<string, { value: Expression; statement: Statement }> {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const out = new Map<string, { value: Expression; statement: Statement }>();\n for (const statement of sf.getStatements()) {\n if (!N.isExpressionStatement(statement)) continue;\n const expression = statement.getExpression();\n if (!N.isBinaryExpression(expression) || expression.getOperatorToken().getKind() !== SyntaxKind.EqualsToken) continue;\n const parts: string[] = [];\n let left: Node = expression.getLeft();\n while (N.isPropertyAccessExpression(left)) {\n parts.unshift(left.getName());\n left = left.getExpression();\n }\n if (N.isIdentifier(left) && left.getText() === binding && parts.length > 0) {\n out.set(parts.join(\".\"), { value: expression.getRight(), statement });\n }\n }\n return out;\n}\n\n// ── What a node references ───────────────────────────────────────────────────\n\n/** One import binding a carried node uses. */\nexport interface ImportUse {\n /** The module specifier as written. */\n specifier: string;\n /** The file it was written in (absolute), to resolve a relative specifier from. */\n fromFile: string;\n /** `default`, `*` (namespace) or the imported name. */\n imported: string;\n /** The local name. */\n local: string;\n /** Whether only types are imported. */\n typeOnly: boolean;\n}\n\n/** The imports and top-level declarations some nodes reference, transitively. */\nexport interface References {\n imports: ImportUse[];\n /** Top-level statements, in file order, each once. */\n statements: Statement[];\n /** Names that resolve to a statement that may not be carried (the collection itself). */\n forbidden: { name: string; line: number }[];\n}\n\n/**\n * Whether an identifier is read as a name in scope, rather than written as a\n * property name (`a.b`'s `b`, `{ b: 1 }`'s `b`, a method's or a member's own\n * name). A shorthand `{ b }` is a reference.\n */\nfunction isReferencePosition(ctx: AstContext, identifier: Identifier): boolean {\n const { Node: N } = ctx.tsm;\n const parent = identifier.getParent();\n if (!parent) return true;\n if (N.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) return false;\n if (N.isQualifiedName(parent) && parent.getRight() === identifier) return false;\n if ((N.isPropertyAssignment(parent) || N.isMethodDeclaration(parent) || N.isPropertySignature(parent) ||\n N.isMethodSignature(parent) || N.isPropertyDeclaration(parent) || N.isGetAccessorDeclaration(parent) ||\n N.isSetAccessorDeclaration(parent) || N.isEnumMember(parent)) && parent.getNameNode() === identifier) {\n return false;\n }\n if (N.isBindingElement(parent) && parent.getPropertyNameNode() === identifier) return false;\n if (N.isJsxAttribute(parent)) return false;\n return true;\n}\n\n/** The top-level statement a declaration node belongs to, when it is one. */\nfunction topLevelStatement(ctx: AstContext, declaration: Node): Statement | undefined {\n const { Node: N } = ctx.tsm;\n let current: Node | undefined = declaration;\n while (current && !N.isSourceFile(current.getParent() ?? current)) {\n current = current.getParent();\n }\n if (!current || !N.isStatement(current)) return undefined;\n return N.isSourceFile(current.getParent()) ? current : undefined;\n}\n\n/**\n * Collect what `nodes` reference at the top level of their file: import\n * bindings, and the statements declaring other names (followed\n * transitively). `exclude` are statements that must not be carried — a\n * reference to one is reported in `forbidden`.\n */\nexport function collectReferences(ctx: AstContext, nodes: readonly Node[], exclude: readonly Statement[]): References {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const imports: ImportUse[] = [];\n const statements = new Set<Statement>();\n const forbidden: { name: string; line: number }[] = [];\n const queue: Node[] = [...nodes];\n const visited = new Set<Node>();\n while (queue.length > 0) {\n const node = queue.shift();\n if (!node || visited.has(node)) continue;\n visited.add(node);\n const identifiers = N.isIdentifier(node) ? [node] : node.getDescendantsOfKind(SyntaxKind.Identifier);\n for (const identifier of identifiers) {\n if (!isReferencePosition(ctx, identifier)) continue;\n const symbol = identifier.getSymbol();\n if (!symbol) continue;\n for (const declaration of symbol.getDeclarations()) {\n if (declaration.getSourceFile() !== identifier.getSourceFile()) continue;\n if (N.isImportSpecifier(declaration) || N.isImportClause(declaration) || N.isNamespaceImport(declaration)) {\n const importDeclaration = declaration.getFirstAncestorByKindOrThrow(SyntaxKind.ImportDeclaration);\n const specifier = importDeclaration.getModuleSpecifierValue();\n const local = identifier.getText();\n const typeOnly = importDeclaration.isTypeOnly() || (N.isImportSpecifier(declaration) && declaration.isTypeOnly());\n const imported = N.isImportSpecifier(declaration) ? declaration.getName()\n : N.isNamespaceImport(declaration) ? \"*\"\n : \"default\";\n if (!imports.some(use => use.local === local && use.specifier === specifier)) {\n imports.push({ specifier, fromFile: identifier.getSourceFile().getFilePath(), imported, local, typeOnly });\n }\n continue;\n }\n const statement = topLevelStatement(ctx, declaration);\n if (!statement || nodes.includes(statement)) continue;\n // A declaration inside the node itself (a parameter, a local) is not a reference out of it.\n if (nodes.some(root => root !== statement && (declaration === root || declaration.getAncestors().includes(root)))) continue;\n if (exclude.includes(statement)) {\n if (!forbidden.some(entry => entry.name === identifier.getText())) {\n forbidden.push({ name: identifier.getText(), line: identifier.getStartLineNumber() });\n }\n continue;\n }\n if (!statements.has(statement)) {\n statements.add(statement);\n queue.push(statement);\n }\n }\n }\n }\n const ordered = [...statements].sort((a, b) => a.getStart() - b.getStart());\n return { imports, statements: ordered, forbidden };\n}\n\n/** The leading comments of a node worth carrying: block and line comments, not lint or compiler directives. */\nexport function leadingComments(node: Node): string[] {\n const out: string[] = [];\n for (const range of node.getLeadingCommentRanges()) {\n const text = range.getText();\n if (/^\\/\\/\\s*(@ts-|eslint|prettier|#)/.test(text) || /^\\/\\*\\s*(eslint|prettier|@ts-)/.test(text)) continue;\n out.push(text);\n }\n return out;\n}\n","/**\n * A record's own entry, never one inherited from `Object.prototype`.\n *\n * The codemod looks keys up by names it read from user code, and a name can be\n * `toString` or `constructor`: `RECORD[name]` would hand back a function.\n *\n * @param record a plain record\n * @param key the key, as read\n */\nexport function own<T>(record: Readonly<Record<string, T>>, key: string): T | undefined {\n return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;\n}\n","/**\n * Moving a collection callback's source into a table hook.\n *\n * The code is carried as written. What changes is the props object it is\n * called with: a table hook gets `table` (the descriptor) where a collection\n * callback got `collection`, and `afterRead` / `beforeDelete` / `afterDelete`\n * get the row as `values` where they got `row`. The parameter is rewritten so\n * the body keeps its own names — `({ row })` becomes `({ values: row })` —\n * and where a use cannot be rewritten mechanically (the props passed on\n * whole, a property of the collection the descriptor does not have) the text\n * is kept, a `// TODO(rebase-migrate):` line says what to check, and the run\n * reports it. Nothing is rewritten to something that silently means less.\n */\nimport type { ArrowFunction, FunctionExpression, Identifier, Node, ParameterDeclaration } from \"ts-morph\";\n\nimport type { AstContext, Member } from \"./ast\";\nimport { nodeText } from \"./ast\";\nimport { own } from \"./own\";\n\n/** The props a callback's parameter is renamed on. */\nexport interface PropRenames {\n /** Always `table`: the descriptor replaces the collection. */\n collection: \"table\";\n /** `values`, for the hooks that received the row as `row`. */\n row?: \"values\";\n /**\n * The renamed `collection` was a plain value (a slug) and `table` is the\n * same value — `StorageAuthorizeData.collection` → `.table` — so no use of\n * it needs checking.\n */\n collectionIsValue?: boolean;\n}\n\n/** The hooks whose legacy props named the row `row`. */\nconst ROW_HOOKS = new Set([\"afterRead\", \"beforeDelete\", \"afterDelete\"]);\n\n/** The renames for one table hook, or one column transform. */\nexport function renamesFor(hook: string): PropRenames {\n return ROW_HOOKS.has(hook) ? { collection: \"table\", row: \"values\" } : { collection: \"table\" };\n}\n\n/** Properties of the collection a callback may read on the descriptor too, with the same meaning. */\nconst DESCRIPTOR_SAFE_READS = new Set([\"slug\"]);\n\n/** A function carried into a table, and what to check in it. */\nexport interface CarriedFunction {\n /** The source text, ready to print: its first line at column 0. */\n text: string;\n /** One sentence per use the codemod could not rewrite; each is also a `TODO(rebase-migrate)` line in the text. */\n todos: string[];\n}\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n}\n\nlet scratchCounter = 0;\n\n/** The function text a member denotes: a method becomes the function expression it is. */\nexport function memberFunctionText(ctx: AstContext, member: Member): string {\n const method = member.method;\n if (!method) return member.value ? nodeText(member.value) : nodeText(member.node);\n const { SyntaxKind } = ctx.tsm;\n const body = method.getBody();\n const usesThis = body !== undefined && (\n body.getDescendantsOfKind(SyntaxKind.ThisKeyword).length > 0 ||\n body.getDescendantsOfKind(SyntaxKind.SuperKeyword).length > 0 ||\n body.getDescendantsOfKind(SyntaxKind.Identifier).some(identifier => identifier.getText() === \"arguments\")\n );\n const isAsync = method.isAsync();\n const isGenerator = method.isGenerator();\n const typeParameters = method.getTypeParameters().map(parameter => parameter.getText());\n const typeParameterText = typeParameters.length > 0 ? `<${typeParameters.join(\", \")}>` : \"\";\n const parameters = method.getParameters().map(parameter => parameter.getText()).join(\", \");\n const returnType = method.getReturnTypeNode();\n const returnText = returnType ? `: ${returnType.getText()}` : \"\";\n const bodyText = body ? nodeText(body) : \"{}\";\n if (usesThis || isGenerator) {\n return `${isAsync ? \"async \" : \"\"}function${isGenerator ? \"*\" : \"\"} ${method.getName()}${typeParameterText}(${parameters})${returnText} ${bodyText}`;\n }\n return `${isAsync ? \"async \" : \"\"}${typeParameterText}(${parameters})${returnText} => ${bodyText}`;\n}\n\n/** The identifiers in `scope` bound by `declaration` (the parameter or a binding element). */\nfunction referencesTo(ctx: AstContext, scope: Node, name: Identifier): Identifier[] {\n const { SyntaxKind } = ctx.tsm;\n const symbol = name.getSymbol();\n if (!symbol) return [];\n return scope.getDescendantsOfKind(SyntaxKind.Identifier)\n .filter(identifier => identifier !== name && identifier.getText() === name.getText() && identifier.getSymbol() === symbol);\n}\n\n/** Whether `identifier` is read as `identifier.<safe>` only. */\nfunction isSafeDescriptorRead(ctx: AstContext, identifier: Identifier): boolean {\n const { Node: N } = ctx.tsm;\n const parent = identifier.getParent();\n return parent !== undefined && N.isPropertyAccessExpression(parent) && parent.getExpression() === identifier &&\n DESCRIPTOR_SAFE_READS.has(parent.getName());\n}\n\n/**\n * Rewrite the props a function receives. Returns the edits to make on its\n * text, and the uses it could not rewrite.\n */\nfunction rewriteParameter(\n ctx: AstContext,\n fn: ArrowFunction | FunctionExpression,\n parameter: ParameterDeclaration,\n renames: PropRenames,\n edits: Edit[],\n todos: string[]\n): void {\n const { Node: N } = ctx.tsm;\n const renamed: Record<string, string> = { collection: renames.collection, ...(renames.row ? { row: renames.row } : {}) };\n const nameNode = parameter.getNameNode();\n const body = fn.getBody();\n\n // An inline type for the props names the old keys too: `{ collection: string }`.\n const typeNode = parameter.getTypeNode();\n if (typeNode && N.isTypeLiteral(typeNode)) {\n for (const member of typeNode.getMembers()) {\n if (!N.isPropertySignature(member)) continue;\n const next = own(renamed, member.getName());\n if (next !== undefined) edits.push({ start: member.getNameNode().getStart(), end: member.getNameNode().getEnd(), text: next });\n }\n }\n\n if (N.isObjectBindingPattern(nameNode)) {\n for (const element of nameNode.getElements()) {\n const propertyNameNode = element.getPropertyNameNode();\n const local = element.getNameNode();\n if (element.getDotDotDotToken()) {\n if (!N.isIdentifier(local)) continue;\n rewriteMemberReads(ctx, body, local, renamed, edits, todos, `the rest of the props, \\`...${local.getText()}\\``, renames.collectionIsValue === true);\n continue;\n }\n const key = propertyNameNode ? propertyNameNode.getText() : local.getText();\n const next = own(renamed, key);\n if (next === undefined) continue;\n if (propertyNameNode) {\n edits.push({ start: propertyNameNode.getStart(), end: propertyNameNode.getEnd(), text: next });\n } else {\n edits.push({ start: local.getStart(), end: local.getEnd(), text: `${next}: ${local.getText()}` });\n }\n if (key !== \"collection\" || renames.collectionIsValue) continue;\n if (N.isIdentifier(local)) {\n const unsafe = referencesTo(ctx, body, local).filter(identifier => !isSafeDescriptorRead(ctx, identifier));\n if (unsafe.length > 0) {\n todos.push(`\\`${local.getText()}\\` is now the table's descriptor, not the collection: check every use but \\`.slug\\` (line ${unsafe[0].getStartLineNumber()} of the hook).`);\n }\n } else if (N.isObjectBindingPattern(local)) {\n const reads = local.getElements().map(inner => inner.getPropertyNameNode()?.getText() ?? inner.getNameNode().getText());\n const unsafe = reads.filter(read => !DESCRIPTOR_SAFE_READS.has(read));\n if (unsafe.length > 0) todos.push(`reads ${unsafe.map(read => `\\`${read}\\``).join(\", \")} off the collection; the descriptor it gets now is a table, which may not have them.`);\n } else {\n todos.push(\"destructures the collection in a form the codemod does not rewrite; the descriptor it gets now is a table.\");\n }\n }\n return;\n }\n if (N.isIdentifier(nameNode)) {\n rewriteMemberReads(ctx, body, nameNode, renamed, edits, todos, `the props object, \\`${nameNode.getText()}\\``, renames.collectionIsValue === true);\n return;\n }\n todos.push(\"takes its props in a form the codemod does not rewrite; it now gets `table` for `collection` and `values` for `row`.\");\n}\n\n/** Rewrite `props.row` → `props.values` and `props.collection` → `props.table`; anything else is a TODO. */\nfunction rewriteMemberReads(\n ctx: AstContext,\n scope: Node,\n binding: Identifier,\n renamed: Record<string, string>,\n edits: Edit[],\n todos: string[],\n what: string,\n collectionIsValue = false\n): void {\n const { Node: N } = ctx.tsm;\n for (const reference of referencesTo(ctx, scope, binding)) {\n const parent = reference.getParent();\n if (parent && N.isPropertyAccessExpression(parent) && parent.getExpression() === reference) {\n const name = parent.getName();\n const next = own(renamed, name);\n if (next === undefined) continue;\n const nameNode = parent.getNameNode();\n edits.push({ start: nameNode.getStart(), end: nameNode.getEnd(), text: next });\n if (name === \"collection\" && !collectionIsValue) {\n const outer = parent.getParent();\n const safe = outer !== undefined && N.isPropertyAccessExpression(outer) && outer.getExpression() === parent &&\n DESCRIPTOR_SAFE_READS.has(outer.getName());\n if (!safe) todos.push(`reads \\`${parent.getText()}\\`, which is now the table's descriptor, not the collection (line ${reference.getStartLineNumber()} of the hook).`);\n }\n continue;\n }\n if (parent && N.isElementAccessExpression(parent) && parent.getExpression() === reference) {\n todos.push(`reads ${what} by a computed key (\\`${parent.getText()}\\`); \\`collection\\` is \\`table\\` and \\`row\\` is \\`values\\` now.`);\n continue;\n }\n todos.push(`passes ${what} on (line ${reference.getStartLineNumber()} of the hook); whatever reads it gets \\`table\\` for \\`collection\\`${renamed.row ? \" and `values` for `row`\" : \"\"} now.`);\n }\n}\n\nfunction applyEdits(text: string, edits: Edit[], offset: number): string {\n const sorted = [...edits].sort((a, b) => b.start - a.start);\n let out = text;\n for (const edit of sorted) {\n out = out.slice(0, edit.start - offset) + edit.text + out.slice(edit.end - offset);\n }\n return out;\n}\n\n/** Insert the TODO lines where a reader will see them: first in a block body, above an expression body. */\nfunction withTodos(ctx: AstContext, text: string, todos: readonly string[]): string {\n if (todos.length === 0) return text;\n const comment = todos.map(todo => `// TODO(rebase-migrate): ${todo}`);\n const sf = ctx.project.createSourceFile(`/__rebase_migrate__/todo-${scratchCounter++}.ts`, `const __hook = ${text};`, { overwrite: true });\n const offset = \"const __hook = \".length;\n try {\n const initializer = sf.getVariableDeclarationOrThrow(\"__hook\").getInitializerOrThrow();\n const { Node: N } = ctx.tsm;\n if ((N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) {\n const body = initializer.getBody();\n if (N.isBlock(body)) {\n const first = body.getStatements()[0];\n if (first) {\n const start = first.getStart() - offset;\n const lineStart = text.lastIndexOf(\"\\n\", start - 1) + 1;\n const indent = /^[ \\t]*/.exec(text.slice(lineStart, start))?.[0] ?? \" \";\n return `${text.slice(0, start)}${comment.join(`\\n${indent}`)}\\n${indent}${text.slice(start)}`;\n }\n }\n }\n return `${comment.join(\"\\n\")}\\n${text}`;\n } finally {\n ctx.project.removeSourceFile(sf);\n }\n}\n\n/**\n * The source of one hook (or one transform callback), its props renamed.\n *\n * @param member where it is in the legacy literal\n * @param hook the hook's name: decides whether `row` is renamed\n * @param options `collectionIsValue` when the renamed `collection` held a plain value\n */\nexport function carryHook(ctx: AstContext, member: Member, hook: string, options: { collectionIsValue?: boolean } = {}): CarriedFunction {\n const text = memberFunctionText(ctx, member);\n const renames: PropRenames = { ...renamesFor(hook), ...(options.collectionIsValue ? { collectionIsValue: true } : {}) };\n const sf = ctx.project.createSourceFile(`/__rebase_migrate__/hook-${scratchCounter++}.ts`, `const __hook = ${text};`, { overwrite: true });\n const offset = \"const __hook = \".length;\n const todos: string[] = [];\n try {\n const initializer = sf.getVariableDeclarationOrThrow(\"__hook\").getInitializerOrThrow();\n const { Node: N } = ctx.tsm;\n const edits: Edit[] = [];\n if (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer)) {\n const parameter = initializer.getParameters()[0];\n if (parameter) rewriteParameter(ctx, initializer, parameter, renames, edits, todos);\n } else {\n todos.push(`is \\`${text.split(\"\\n\")[0]}\\`, not a function written here, so the props it receives cannot be rewritten: it now gets \\`table\\` for \\`collection\\`${renames.row ? \" and `values` for `row`\" : \"\"}.`);\n }\n const rewritten = applyEdits(text, edits, offset);\n return { text: withTodos(ctx, rewritten, todos), todos };\n } finally {\n ctx.project.removeSourceFile(sf);\n }\n}\n\n/**\n * The source of a `callbacks` object of a property — `{ beforeSave, afterRead }`\n * — as the column's `.transform({...})` argument, each callback carried with\n * {@link carryHook}.\n */\nexport function carryTransform(ctx: AstContext, members: { name: string; member: Member }[]): CarriedFunction {\n const todos: string[] = [];\n const lines = members.map(({ name, member }) => {\n const carried = carryHook(ctx, member, name);\n todos.push(...carried.todos.map(todo => `${name} ${todo}`));\n return ` ${name}: ${carried.text.split(\"\\n\").join(\"\\n \")}`;\n });\n return { text: `{\\n${lines.join(\",\\n\")}\\n}`, todos };\n}\n","/**\n * Moving code between files: rewriting a module specifier for its new home,\n * copying the helper modules carried code imports, and assembling a module's\n * import block.\n *\n * A relative import from `config/collections/orders.ts` keeps pointing at the\n * same file from `backend/schema/orders.ts` — a module of `config/` included:\n * the project's own modules there stay, importable as before. Only a helper\n * inside `config/collections`, which the migration removes, is copied next to\n * the code that needs it (`backend/lib/…` for server code,\n * `frontend/src/cms/lib/…` for the panel's), its own imports moved the same\n * way. A helper that imports a collection file cannot move (the collection is a\n * table now) and is refused.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { SourceFile } from \"ts-morph\";\n\nimport type { AstContext, ImportUse } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport { own } from \"./own\";\n\n/** Which side of the split a file lives on. */\nexport type Side = \"backend\" | \"frontend\";\n\n/** A module specifier that cannot be moved, and why. */\nexport class RelocationError extends Error {\n constructor(readonly file: string, message: string) {\n super(message);\n }\n}\n\nconst CODE_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".js\", \".jsx\", \".mjs\"];\n\n/** How a relative specifier was written, so the moved one is written the same way. */\nexport type SpecifierStyle = \"extensionless\" | \"directory\" | { extension: string };\n\nexport interface ResolvedSpecifier {\n target: string;\n style: SpecifierStyle;\n}\n\n/** The file a relative specifier written in `fromFile` names, and how it was written. */\nexport function resolveRelative(fromFile: string, specifier: string): ResolvedSpecifier {\n const base = path.resolve(path.dirname(fromFile), specifier);\n const extension = path.extname(specifier);\n if (extension === \".js\" || extension === \".jsx\" || extension === \".mjs\") {\n const stem = base.slice(0, -extension.length);\n for (const candidate of [\".ts\", \".tsx\", \".mts\", extension]) {\n if (fs.existsSync(stem + candidate)) return { target: stem + candidate, style: { extension } };\n }\n }\n if (extension && fs.existsSync(base) && fs.statSync(base).isFile()) return { target: base, style: { extension } };\n for (const candidate of CODE_EXTENSIONS) {\n if (fs.existsSync(base + candidate)) return { target: base + candidate, style: \"extensionless\" };\n }\n for (const candidate of CODE_EXTENSIONS) {\n const index = path.join(base, `index${candidate}`);\n if (fs.existsSync(index)) return { target: index, style: \"directory\" };\n }\n return { target: base, style: extension ? { extension } : \"extensionless\" };\n}\n\n/** A relative specifier from `fromFile` to `target`, written in `style`. */\nexport function writeSpecifier(fromFile: string, target: string, style: SpecifierStyle): string {\n let destination = target;\n if (style === \"directory\") destination = path.dirname(target);\n else if (style === \"extensionless\") destination = target.replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\");\n else if (/\\.(tsx?|mts)$/.test(target) && /^\\.(jsx?|mjs)$/.test(style.extension)) destination = target.replace(/\\.(tsx?|mts)$/, style.extension);\n let relative = toPosix(path.relative(path.dirname(fromFile), destination));\n if (!relative.startsWith(\".\")) relative = `./${relative}`;\n return relative;\n}\n\n/**\n * How the relative imports the codemod writes itself end — the schema index,\n * a table's import of a related table, a customization's type import of its\n * table: `\"js\"` (`./users.js`) or `\"extensionless\"` (`./users`).\n *\n * A project whose backend is built with a plain `tsc` (NodeNext) and run on\n * Node needs `\"js\"`: Node's ESM loader resolves no relative import without\n * its extension. `rebase build` and tsx resolve either spelling.\n */\nexport type GeneratedSpecifierStyle = \"js\" | \"extensionless\";\n\n/**\n * The {@link GeneratedSpecifierStyle} of a project, from the module specifiers\n * its legacy collection sources write (the collection files and the\n * collections index): `\"js\"` when more of their relative specifiers end in\n * a JavaScript extension (`./users.js`) than in none (`./users`, `../lib`);\n * `\"extensionless\"`, the house style, otherwise — a tie, or no relative\n * import at all. A specifier with another extension (`./labels.json`,\n * `./users.schema`) says nothing either way.\n *\n * @param specifiers every module specifier the sources import or re-export from, package names included\n */\nexport function projectSpecifierStyle(specifiers: readonly string[]): GeneratedSpecifierStyle {\n let withExtension = 0;\n let without = 0;\n for (const specifier of specifiers) {\n if (!/^\\.\\.?(\\/|$)/.test(specifier)) continue;\n const last = specifier.split(\"/\").pop() ?? \"\";\n if (/\\.[mc]?jsx?$/.test(last)) withExtension++;\n else if (last === \"\" || last === \".\" || last === \"..\" || !last.includes(\".\")) without++;\n }\n return withExtension > without ? \"js\" : \"extensionless\";\n}\n\n/** The module specifiers a file imports and re-exports from, as written. */\nexport function writtenSpecifiers(sourceFile: SourceFile): string[] {\n return [\n ...sourceFile.getImportDeclarations().map(declaration => declaration.getModuleSpecifierValue()),\n ...sourceFile.getExportDeclarations().flatMap(declaration => declaration.getModuleSpecifierValue() ?? [])\n ];\n}\n\n/**\n * The relative specifier of an import the codemod writes, from `fromFile` to\n * the module `target`, in the project's {@link GeneratedSpecifierStyle}: for\n * `users.ts`, `./users` or `./users.js`. A JavaScript target keeps its own\n * extension in either style.\n */\nexport function generatedSpecifier(fromFile: string, target: string, style: GeneratedSpecifierStyle): string {\n const typescript = /\\.(tsx?|mts)$/.exec(target);\n let relative = toPosix(path.relative(path.dirname(fromFile), typescript ? target.slice(0, -typescript[0].length) : target));\n if (!relative.startsWith(\"../\")) relative = `./${relative}`;\n if (style === \"extensionless\" || !typescript) return relative;\n return `${relative}${typescript[1] === \"mts\" ? \".mjs\" : \".js\"}`;\n}\n\n/** One helper module copied out of `config/`. */\nexport interface HelperCopy {\n /** Where it was, absolute. */\n from: string;\n /** Where it goes, absolute. */\n to: string;\n side: Side;\n}\n\n/**\n * Moves specifiers and collects the helper copies they need. One per run, so\n * a helper used by several files is copied once per side.\n */\nexport class Relocator {\n readonly helpers = new Map<string, HelperCopy>();\n /** Modules of the project's own in config/ that backend code the run writes imports in place. */\n readonly keptBackendModules = new Set<string>();\n /** Modules outside config/collections the run edits in place for the panel (a shared `dynamicProps` builder). */\n readonly keptFrontendModules = new Set<string>();\n /** Edits to a module's own text before it is copied or kept (a helper's callbacks as table hooks), by absolute path. */\n readonly sourceEdits = new Map<string, { start: number; end: number; text: string }[]>();\n\n /**\n * Queue edits to a module's own text (deduplicated by position), dropping\n * any copy of it already made so the next one carries them.\n */\n addSourceEdits(file: string, edits: readonly { start: number; end: number; text: string }[]): void {\n const queued = this.sourceEdits.get(file) ?? [];\n for (const edit of edits) if (!queued.some(other => other.start === edit.start && other.end === edit.end)) queued.push(edit);\n this.sourceEdits.set(file, queued);\n for (const side of [\"backend\", \"frontend\"]) this.contents.delete(`${side}:${file}`);\n }\n\n /** A module's text with its {@link sourceEdits} applied. */\n editedSource(file: string): string {\n let out = fs.readFileSync(file, \"utf8\");\n const edits = this.sourceEdits.get(file);\n if (edits) for (const edit of [...edits].sort((a, b) => b.start - a.start)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n }\n /** Collection files that move rather than become tables (Firestore ones): legacy path → new path. */\n readonly moved = new Map<string, string>();\n\n constructor(\n private readonly ctx: AstContext,\n private readonly projectRoot: string,\n private readonly configDir: string,\n private readonly collectionFiles: ReadonlySet<string>,\n private readonly libDirs: Readonly<Record<Side, string>>\n ) {}\n\n /** The config directory, absolute. */\n get configDirectory(): string {\n return this.configDir;\n }\n\n /** Whether `file` is inside `<config>/collections`, which the migration removes. */\n isInCollections(file: string): boolean {\n const relative = path.relative(path.join(this.configDir, \"collections\"), file);\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n }\n\n /** Whether `file` is inside the config directory. */\n isInConfig(file: string): boolean {\n const relative = path.relative(this.configDir, file);\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n }\n\n /** The specifier `specifier` (written in `fromFile`) becomes when written in `destFile`. */\n relocate(specifier: string, fromFile: string, destFile: string, side: Side): string {\n if (!specifier.startsWith(\".\")) return specifier;\n const { target, style } = resolveRelative(fromFile, specifier);\n const movedTo = this.moved.get(target);\n if (movedTo !== undefined && side === \"frontend\") return writeSpecifier(destFile, movedTo, style);\n if (this.collectionFiles.has(target)) {\n throw new RelocationError(fromFile,\n `${toPosix(path.relative(this.projectRoot, fromFile))} imports the collection file \"${specifier}\" into code the codemod moves. ` +\n \"A collection is a table now: import the table from backend/schema (or move the shared value into a module of its own).\");\n }\n if (!this.isInConfig(target)) return writeSpecifier(destFile, target, style);\n if (!fs.existsSync(target)) {\n throw new RelocationError(fromFile, `${toPosix(path.relative(this.projectRoot, fromFile))} imports \"${specifier}\", which does not exist.`);\n }\n // A module of the project's own in config/ stays where it is: 0.31\n // stops reading config/collections, not config/. Only a helper inside\n // config/collections — a directory that must go — is copied out.\n if (!this.isInCollections(target)) {\n if (side === \"backend\") this.keptBackendModules.add(target);\n return writeSpecifier(destFile, target, style);\n }\n const copy = this.copyHelper(target, side);\n return writeSpecifier(destFile, copy.to, style);\n }\n\n private copyHelper(file: string, side: Side): HelperCopy {\n const key = `${side}:${file}`;\n const existing = this.helpers.get(key);\n if (existing) return existing;\n const to = path.join(this.libDirs[side], path.relative(this.configDir, file));\n const copy: HelperCopy = { from: file, to, side };\n this.helpers.set(key, copy);\n // Its own imports move too (and may queue more copies).\n this.helperContent(copy);\n return copy;\n }\n\n private readonly contents = new Map<string, string>();\n\n /** A helper's content in its new home: its relative specifiers moved. */\n helperContent(copy: HelperCopy): string {\n const key = `${copy.side}:${copy.from}`;\n const cached = this.contents.get(key);\n if (cached !== undefined) return cached;\n const text = this.editedSource(copy.from);\n this.contents.set(key, text);\n const moved = this.moveSpecifiersInText(text, copy.from, copy.to, copy.side);\n this.contents.set(key, moved);\n return moved;\n }\n\n /**\n * A module of config/ that backend code imports in place, with the\n * collection-model types it imports replaced by table-model aliases (as a\n * copy to backend/lib gets them): the hooks it serves are table hooks now.\n */\n keptBackendContent(file: string): string {\n const text = this.editedSource(file);\n const sf = this.ctx.project.createSourceFile(`/__rebase_migrate__/kept-${path.basename(file)}`, text, { overwrite: true });\n try {\n const edits: { start: number; end: number; text: string }[] = [];\n this.legacyTypeEdits(sf, text, edits);\n let out = text;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n } finally {\n this.ctx.project.removeSourceFile(sf);\n }\n }\n\n /** Collection-model types left in moved backend code (used with type arguments), for the report. */\n readonly legacyTypesLeft: { file: string; name: string }[] = [];\n\n /** Edits replacing the collection-model types a moved backend module imports (see {@link replaceLegacyTypes}). */\n private legacyTypeEdits(sf: SourceFile, text: string, edits: { start: number; end: number; text: string }[]): void {\n const aliases: string[] = [];\n const types = new Set<string>();\n for (const declaration of sf.getImportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n if (!LEGACY_TYPE_PACKAGES.has(specifier)) continue;\n const named = declaration.getNamedImports();\n const replaced = named.filter(entry => {\n const replacement = own(LEGACY_TYPE_REPLACEMENTS, entry.getName());\n const local = entry.getAliasNode()?.getText() ?? entry.getName();\n if (!replacement) return false;\n if (new RegExp(`\\\\b${local}\\\\s*<`).test(text)) {\n this.legacyTypesLeft.push({ file: sf.getBaseName(), name: local });\n return false;\n }\n types.add(replacement.type);\n aliases.push(`type ${local} = ${replacement.expression};`);\n return true;\n });\n if (replaced.length === 0) continue;\n const remaining = named.filter(entry => !replaced.includes(entry));\n if (remaining.length === 0 && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) {\n const end = text[declaration.getEnd()] === \"\\n\" ? declaration.getEnd() + 1 : declaration.getEnd();\n edits.push({ start: declaration.getStart(), end, text: \"\" });\n } else {\n const bindings = remaining.map(entry => entry.getText()).join(\", \");\n const typeOnly = declaration.isTypeOnly() ? \"type \" : \"\";\n const head = declaration.getDefaultImport() ? `${declaration.getDefaultImport()?.getText()}, ` : \"\";\n edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: `import ${typeOnly}${head}{ ${bindings} } from ${JSON.stringify(specifier)};` });\n }\n }\n if (aliases.length === 0) return;\n const imports = sf.getImportDeclarations();\n const at = imports.length > 0 ? imports[imports.length - 1].getEnd() : 0;\n edits.push({ start: at, end: at, text: `${imports.length > 0 ? \"\\n\" : \"\"}import type { ${[...types].sort().join(\", \")} } from \"@rebasepro/server/schema\";\\n\\n${aliases.join(\"\\n\")}${imports.length > 0 ? \"\" : \"\\n\"}` });\n }\n\n /**\n * Every module specifier in `text` (static imports, re-exports, dynamic\n * `import()`), moved from `fromFile` to `destFile`.\n */\n moveSpecifiersInText(text: string, fromFile: string, destFile: string, side: Side): string {\n const { Node: N, SyntaxKind } = this.ctx.tsm;\n const sf = this.ctx.project.createSourceFile(`/__rebase_migrate__/move-${this.contents.size}-${path.basename(fromFile)}`, text, { overwrite: true });\n try {\n const edits: { start: number; end: number; text: string }[] = [];\n const literals = [\n ...sf.getImportDeclarations().map(declaration => declaration.getModuleSpecifier()),\n ...sf.getExportDeclarations().map(declaration => declaration.getModuleSpecifier()).filter(literal => literal !== undefined),\n ...sf.getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter(call => call.getExpression().getKind() === SyntaxKind.ImportKeyword)\n .map(call => call.getArguments()[0])\n .filter(argument => argument !== undefined && N.isStringLiteral(argument))\n ];\n for (const literal of literals) {\n if (!N.isStringLiteral(literal)) continue;\n const value = literal.getLiteralValue();\n const moved = this.relocate(value, fromFile, destFile, side);\n if (moved !== value) edits.push({ start: literal.getStart() + 1, end: literal.getEnd() - 1, text: moved });\n }\n if (side === \"backend\") this.legacyTypeEdits(sf, text, edits);\n let out = text;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n } finally {\n this.ctx.project.removeSourceFile(sf);\n }\n }\n}\n\n/** Packages a backend helper imported collection-model types from. */\nconst LEGACY_TYPE_PACKAGES = new Set([\"@rebasepro/common\", \"@rebasepro/types\", \"@rebasepro/server\", \"@rebasepro/cms-types\"]);\n\n/**\n * Collection-model types a backend helper used, and what each is in the table\n * model (from `@rebasepro/server/schema`, which a backend depends on). A\n * helper keeps its own name for the type — `type EntityCallbackContext =\n * TableHookProps[\"context\"];` — so its body is untouched.\n */\nexport const LEGACY_TYPE_REPLACEMENTS: Readonly<Record<string, { type: string; expression: string }>> = {\n EntityCallbackContext: { type: \"TableHookProps\", expression: `TableHookProps[\"context\"]` },\n RebaseCallContext: { type: \"TableHookProps\", expression: `TableHookProps[\"context\"]` },\n CollectionCallbacks: { type: \"TableHooks\", expression: \"TableHooks\" },\n BeforeQueryProps: { type: \"TableBeforeQueryProps\", expression: \"TableBeforeQueryProps\" },\n AfterReadProps: { type: \"TableAfterReadProps\", expression: \"TableAfterReadProps\" },\n BeforeSaveProps: { type: \"TableBeforeSaveProps\", expression: \"TableBeforeSaveProps\" },\n AfterSaveProps: { type: \"TableAfterSaveProps\", expression: \"TableAfterSaveProps\" },\n AfterSaveErrorProps: { type: \"TableAfterSaveErrorProps\", expression: \"TableAfterSaveErrorProps\" },\n BeforeDeleteProps: { type: \"TableDeleteProps\", expression: \"TableDeleteProps\" },\n AfterDeleteProps: { type: \"TableDeleteProps\", expression: \"TableDeleteProps\" },\n PropertyCallbacks: { type: \"ColumnTransform\", expression: \"ColumnTransform\" }\n};\n\n/** What {@link replaceLegacyTypes} decided. */\nexport interface LegacyTypeReplacement {\n /** The uses still imported as they were. */\n kept: ImportUse[];\n /** `import type { … } from \"@rebasepro/server/schema\";`, when any type was replaced. */\n imports: string[];\n /** `type <local> = <replacement>;`, one per replaced binding. */\n aliases: string[];\n /** A binding used with type arguments, which an alias cannot stand for. */\n unreplaceable: string[];\n}\n\n/**\n * Replace collection-model types a backend module imports with their\n * table-model equivalents, as local aliases.\n *\n * @param text the code that uses them, to tell a generic use (`AfterSaveProps<M>`) apart\n */\nexport function replaceLegacyTypes(uses: readonly ImportUse[], text: string): LegacyTypeReplacement {\n const kept: ImportUse[] = [];\n const types = new Set<string>();\n const aliases: string[] = [];\n const unreplaceable: string[] = [];\n for (const use of uses) {\n const replacement = LEGACY_TYPE_PACKAGES.has(use.specifier) ? own(LEGACY_TYPE_REPLACEMENTS, use.imported) : undefined;\n if (!replacement) {\n kept.push(use);\n continue;\n }\n if (new RegExp(`\\\\b${use.local}\\\\s*<`).test(text)) {\n unreplaceable.push(use.local);\n kept.push(use);\n continue;\n }\n types.add(replacement.type);\n aliases.push(`type ${use.local} = ${replacement.expression};`);\n }\n const imports = types.size > 0 ? [`import type { ${[...types].sort().join(\", \")} } from \"@rebasepro/server/schema\";`] : [];\n return { kept, imports, aliases, unreplaceable };\n}\n\n/** One import line's worth of bindings. */\ninterface ImportGroup {\n specifier: string;\n defaultLocal?: string;\n namespaceLocal?: string;\n named: { imported: string; local: string; typeOnly: boolean }[];\n defaultTypeOnly: boolean;\n}\n\n/**\n * The import block of a generated module: the uses, grouped by (moved)\n * specifier, in first-use order, each binding once.\n */\nexport function importLines(uses: readonly ImportUse[], relocate: (use: ImportUse) => string): string[] {\n const groups = new Map<string, ImportGroup>();\n const lines: string[] = [];\n for (const use of uses) {\n const specifier = relocate(use);\n if (use.imported === \"*\") {\n lines.push(`import ${use.typeOnly ? \"type \" : \"\"}* as ${use.local} from ${JSON.stringify(specifier)};`);\n continue;\n }\n let group = groups.get(specifier);\n if (!group) {\n group = { specifier, named: [], defaultTypeOnly: true };\n groups.set(specifier, group);\n }\n if (use.imported === \"default\") {\n group.defaultLocal = use.local;\n group.defaultTypeOnly = use.typeOnly;\n } else if (!group.named.some(entry => entry.local === use.local)) {\n group.named.push({ imported: use.imported, local: use.local, typeOnly: use.typeOnly });\n }\n }\n for (const group of groups.values()) {\n const allTypes = (group.defaultLocal === undefined || group.defaultTypeOnly) && group.named.every(entry => entry.typeOnly);\n const named = group.named.map(entry => {\n const binding = entry.imported === entry.local ? entry.local : `${entry.imported} as ${entry.local}`;\n return !allTypes && entry.typeOnly ? `type ${binding}` : binding;\n });\n const parts: string[] = [];\n if (group.defaultLocal !== undefined) parts.push(group.defaultLocal);\n if (named.length > 0) parts.push(`{ ${named.join(\", \")} }`);\n if (parts.length === 0) continue;\n lines.push(`import ${allTypes ? \"type \" : \"\"}${parts.join(\", \")} from ${JSON.stringify(group.specifier)};`);\n }\n return lines;\n}\n","/**\n * Collection callbacks that come from the project's own helper:\n * `callbacks: softDeleteCallbacks(\"company\")`, `callbacks: customerCallbacks`\n * (imported), `callbacks: readOnlyRecordCallbacks(what, instead)`.\n *\n * The callbacks → hooks conversion is a mapping of each function's props\n * (`values` for `row` in `afterRead` / `beforeDelete` / `afterDelete`, the\n * descriptor for `collection`), so it is applied where the functions are\n * written — the helper's definition, followed through imports, `const`s,\n * property reads and a function's single `return` — and the table says\n * `hooks: softDeleteCallbacks(\"company\")`, importing the helper. The edits to\n * the helper are planned like any other file the run writes (a helper inside\n * `config/collections` is edited in the copy the relocator makes).\n *\n * What cannot be followed statically (a package's export, two returns, a\n * spread) still becomes `hooks: <the same expression>`, with a step naming\n * the hooks to check.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\n\nimport type { Member } from \"./ast\";\nimport { addSourceFile, lineIndent, memberOf, unwrap } from \"./ast\";\nimport { carryHook, memberFunctionText } from \"./hooks\";\nimport { resolveRelative } from \"./modules\";\nimport type { PlanContext } from \"./plan-context\";\n\n/** An edit to a file the run did not write as a collection: offsets into the file as it is on disk. */\nexport interface SourceEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** What following a helper found. */\nexport interface HelperHooks {\n /** Edits to apply to each defining file (absolute path), so its functions take table-hook props. */\n edits: Map<string, SourceEdit[]>;\n /** Lines a carried hook left marked `TODO(rebase-migrate)`, with the file. */\n todos: { file: string; hook: string; todo: string }[];\n /** The defining files outside `config/collections` (edited in place). */\n files: Set<string>;\n /** Why the helper could not be followed, or which hooks were not found in it. */\n unresolved?: string;\n}\n\nexport type Found = { literal: ObjectLiteralExpression; reason?: undefined } | { literal?: undefined; reason: string };\n\nfunction loadFile(plan: PlanContext, file: string): SourceFile | undefined {\n if (!fs.existsSync(file) || file.includes(`${path.sep}node_modules${path.sep}`)) return undefined;\n return plan.ast.project.getSourceFile(file) ?? addSourceFile(plan.ast, file, fs.readFileSync(file, \"utf8\"));\n}\n\n/** The declaration an identifier names: in its file, or the export of a relative import it binds. */\nfunction declarationOf(plan: PlanContext, identifier: Node): Node | string {\n const { Node: N } = plan.ast.tsm;\n let declaration: Node | undefined;\n try {\n declaration = identifier.getSymbol()?.getDeclarations()[0];\n } catch {\n declaration = undefined;\n }\n if (!declaration) return `\\`${identifier.getText()}\\` is not declared in its file`;\n if (N.isImportSpecifier(declaration) || N.isImportClause(declaration)) {\n const importDeclaration = declaration.getFirstAncestor(ancestor => N.isImportDeclaration(ancestor));\n if (!importDeclaration || !N.isImportDeclaration(importDeclaration)) return \"an import the codemod cannot read\";\n const specifier = importDeclaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\")) return `\\`${identifier.getText()}\\` comes from the package \"${specifier}\"`;\n const { target } = resolveRelative(declaration.getSourceFile().getFilePath(), specifier);\n const sf = loadFile(plan, target);\n if (!sf) return `\"${specifier}\" could not be read`;\n const name = N.isImportSpecifier(declaration) ? declaration.getName() : \"default\";\n if (name === \"default\") {\n const assignment = sf.getExportAssignment(candidate => !candidate.isExportEquals());\n return assignment ? assignment.getExpression() : `\"${specifier}\" has no default export`;\n }\n return sf.getVariableDeclaration(name) ?? sf.getFunction(name) ?? `\"${specifier}\" declares no \\`${name}\\` of its own (a re-export?)`;\n }\n return declaration;\n}\n\n/** The function a callee names, if it is a function declaration or a `const` arrow / function expression. */\nfunction functionOf(plan: PlanContext, callee: Node): Node | string {\n const { Node: N } = plan.ast.tsm;\n if (!N.isIdentifier(callee)) return `the call to \\`${callee.getText()}\\` is not to a named function`;\n const declaration = declarationOf(plan, callee);\n if (typeof declaration === \"string\") return declaration;\n if (N.isFunctionDeclaration(declaration)) return declaration;\n if (N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n if (initializer && (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) return initializer;\n }\n return `\\`${callee.getText()}\\` is not a function the codemod can read`;\n}\n\n/** Follow an expression to the object literal it evaluates to. */\nexport function findLiteral(plan: PlanContext, node: Node, depth = 0): Found {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n if (depth > 10) return { reason: \"the helper refers to itself\" };\n const current = unwrap(plan.ast, node);\n if (N.isObjectLiteralExpression(current)) return { literal: current };\n if (N.isIdentifier(current)) {\n const declaration = declarationOf(plan, current);\n if (typeof declaration === \"string\") return { reason: declaration };\n if (N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n return initializer ? findLiteral(plan, initializer, depth + 1) : { reason: `\\`${current.getText()}\\` has no initializer` };\n }\n if (N.isExpression(declaration)) return findLiteral(plan, declaration, depth + 1);\n return { reason: `\\`${current.getText()}\\` is not a value the codemod can read` };\n }\n if (N.isPropertyAccessExpression(current)) {\n const owner = findLiteral(plan, current.getExpression(), depth + 1);\n if (!owner.literal) return owner;\n const member = memberOf(plan.ast, owner.literal, current.getName());\n if (!member.node) return { reason: member.reason };\n if (!member.node.value) return { reason: `\\`${current.getText()}\\` is a method` };\n return findLiteral(plan, member.node.value, depth + 1);\n }\n if (N.isCallExpression(current)) {\n const fn = functionOf(plan, current.getExpression());\n if (typeof fn === \"string\") return { reason: fn };\n if (N.isArrowFunction(fn) && !N.isBlock(fn.getBody())) return findLiteral(plan, fn.getBody(), depth + 1);\n const returns = fn.getDescendantsOfKind(SyntaxKind.ReturnStatement).filter(statement =>\n statement.getFirstAncestor(ancestor => N.isFunctionDeclaration(ancestor) || N.isArrowFunction(ancestor) || N.isFunctionExpression(ancestor) || N.isMethodDeclaration(ancestor)) === fn);\n const values = returns.map(statement => statement.getExpression()).filter((expression): expression is NonNullable<typeof expression> => expression !== undefined);\n if (values.length !== 1 || returns.length !== 1) return { reason: `\\`${current.getExpression().getText()}\\` has ${returns.length} return statements; the codemod follows exactly one` };\n return findLiteral(plan, values[0], depth + 1);\n }\n return { reason: `it is a ${current.getKindName()}` };\n}\n\n/**\n * Follow a callbacks expression that is not an object literal to the\n * helper's object literal, and plan its functions' props as table hooks.\n *\n * @param hookNames the hooks the evaluated collection had\n */\nexport function carryHelperHooks(plan: PlanContext, value: Node, hookNames: readonly string[]): HelperHooks {\n const result: HelperHooks = { edits: new Map(), todos: [], files: new Set() };\n const found = findLiteral(plan, value);\n if (!found.literal) {\n result.unresolved = found.reason;\n return result;\n }\n const literal = found.literal;\n const file = literal.getSourceFile().getFilePath();\n const missing: string[] = [];\n const edits: SourceEdit[] = [];\n for (const hook of hookNames) {\n const located = memberOf(plan.ast, literal, hook);\n if (!located.node) {\n missing.push(`${hook} (${located.reason})`);\n continue;\n }\n const member: Member = located.node;\n const carried = carryHook(plan.ast, member, hook);\n for (const todo of carried.todos) result.todos.push({ file, hook, todo });\n if (carried.text === memberFunctionText(plan.ast, member)) continue;\n // The carried text is dedented; it goes back at the member's own indentation.\n const indent = lineIndent(member.node);\n const text = carried.text.split(\"\\n\").map((line, index) => (index === 0 || line === \"\" ? line : `${indent}${line}`)).join(\"\\n\");\n if (member.method || !member.value) edits.push({ start: member.node.getStart(), end: member.node.getEnd(), text: `${hook}: ${text}` });\n else edits.push({ start: member.value.getStart(), end: member.value.getEnd(), text });\n }\n if (edits.length > 0) result.edits.set(file, edits);\n result.files.add(file);\n if (missing.length > 0) result.unresolved = `the helper's object (${path.basename(file)}, line ${literal.getStartLineNumber()}) does not say where ${missing.join(\", \")} come from`;\n return result;\n}\n\n/** A file's text with source edits applied (offsets into the original text). */\nexport function applySourceEdits(text: string, edits: readonly SourceEdit[] | undefined): string {\n if (!edits || edits.length === 0) return text;\n let out = text;\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n}\n","/**\n * What every planning step shares: where the project is, the AST, the\n * relocator, and the report being written.\n */\nimport path from \"node:path\";\nimport type { SourceFile } from \"ts-morph\";\nimport type { LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\n\nimport type { AstContext, CollectionSite } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport type { GeneratedSpecifierStyle, Relocator } from \"./modules\";\nimport type { SplitConstant } from \"./split-constants\";\nimport type { ManualStep, Note, Refusal } from \"./types\";\n\n/** One legacy collection with everything the planners read about it. */\nexport interface CollectionEntry {\n collection: LegacyCollectionConfig;\n /** The collection file, absolute. */\n file: string;\n /** Its AST. */\n sourceFile: SourceFile;\n /** Where its literal is, when the codemod could find it. */\n site?: CollectionSite;\n /** Why the literal could not be found, when it could not. */\n siteProblem?: string;\n}\n\n/** The shared state of one planning run. */\nexport interface PlanContext {\n /** The project root, absolute. */\n root: string;\n ast: AstContext;\n relocator: Relocator;\n /**\n * How every relative import the run writes itself ends (`./users` or\n * `./users.js`): as the legacy collection sources write theirs, decided\n * once from them (`projectSpecifierStyle`).\n */\n specifierStyle: GeneratedSpecifierStyle;\n /** The frontend app's root directory, absolute, when the project has one. */\n frontendDir?: string;\n /** Planned files: absolute path → content. */\n files: Map<string, { content: string; role: string }>;\n refusals: Refusal[];\n notes: Note[];\n manualSteps: ManualStep[];\n /** Enum constants of `config/` split into backend values and CMS labels (see `split-constants.ts`). */\n splitConstants?: SplitConstant[];\n}\n\n/** A path relative to the project root, `/`-separated. */\nexport function relativeToRoot(plan: PlanContext, file: string): string {\n return toPosix(path.relative(plan.root, file));\n}\n\n/** Record a refusal about one collection. */\nexport function refuse(plan: PlanContext, entry: CollectionEntry | undefined, reason: string, extra: { key?: string; line?: number; file?: string } = {}): void {\n plan.refusals.push({\n file: extra.file ?? (entry ? relativeToRoot(plan, entry.file) : \"\"),\n ...(extra.line !== undefined ? { line: extra.line } : {}),\n ...(entry ? { collection: entry.collection.slug } : {}),\n ...(extra.key !== undefined ? { key: extra.key } : {}),\n reason\n });\n}\n\n/** Record a note about one collection. */\nexport function note(plan: PlanContext, entry: CollectionEntry | undefined, message: string, line?: number): void {\n plan.notes.push({\n file: entry ? relativeToRoot(plan, entry.file) : \"\",\n ...(line !== undefined ? { line } : {}),\n ...(entry ? { collection: entry.collection.slug } : {}),\n message\n });\n}\n\n/** Plan a file, refusing a second, different content for the same path. */\nexport function planFile(plan: PlanContext, file: string, content: string, role: string): void {\n const existing = plan.files.get(file);\n if (existing && existing.content !== content) {\n plan.refusals.push({ file: relativeToRoot(plan, file), reason: `two outputs would be written to this path (${existing.role}; ${role}).` });\n return;\n }\n plan.files.set(file, { content, role });\n}\n","/**\n * `backend/schema/<table>.ts` and `backend/schema/index.ts`.\n *\n * The data comes from the lift (`collectionsToTableDefs`), printed by the\n * shared printer (`printTableSource`), so a migrated table is written exactly\n * as introspection or the schema editor would write it. What a value cannot\n * give — the source of a hook or a transform, the imports and helpers that\n * source uses, the comments above a property — is read off the legacy file\n * and spliced in.\n */\nimport path from \"node:path\";\nimport type { Statement } from \"ts-morph\";\nimport {\n printImportLines,\n printIndexModule,\n printTableSource,\n tableIdentifier,\n type PrintTarget,\n type TableSources\n} from \"@rebasepro/common\";\nimport type { LegacyProperty, LiftResult } from \"@rebasepro/common/migrate\";\nimport { isViewDef, type AnyTableDef, type AnyViewDef, type DefaultRls } from \"@rebasepro/types\";\n\nimport type { Member, PathSegment } from \"./ast\";\nimport { collectReferences, leadingComments, memberOf, nodeAtPath, nodeText, postDeclarationAssignments, resolveObject } from \"./ast\";\nimport { carryHelperHooks } from \"./helper-hooks\";\nimport { carryHook, carryTransform, type CarriedFunction } from \"./hooks\";\nimport { generatedSpecifier, importLines, RelocationError, replaceLegacyTypes } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { note, planFile, refuse, relativeToRoot } from \"./plan-context\";\nimport { dedent, reindent } from \"./print-js\";\n\n/** How one table is named in the new layout. */\nexport interface TableName {\n slug: string;\n /** The exported identifier. */\n identifier: string;\n /** The module, absolute. */\n file: string;\n /** The SQL table name (the definition's name). */\n table: string;\n kind: \"table\" | \"auth-table\" | \"view\";\n}\n\n/** Placeholder tokens for code spliced into printed source. */\nexport class Splices {\n private readonly texts = new Map<string, string>();\n private counter = 0;\n\n /** A token standing for `text` in printed output. */\n token(text: string): string {\n const token = `__REBASE_MIGRATE_SPLICE_${this.counter++}__`;\n this.texts.set(token, text);\n return token;\n }\n\n /** Replace every token by its text, re-indented to the line it sits on. */\n apply(code: string): string {\n return code.split(\"\\n\").map(line => {\n let out = line;\n for (const [token, text] of this.texts) {\n if (!out.includes(token)) continue;\n const indent = /^[ \\t]*/.exec(out)?.[0] ?? \"\";\n out = out.replace(token, () => reindent(text, indent));\n }\n return out;\n }).join(\"\\n\");\n }\n}\n\n/** The builders a printed table imports, which a carried binding must not shadow. */\nconst BUILDER_NAMES = new Set([\"defineTable\", \"defineAuthTable\", \"defineView\", \"col\", \"rel\", \"json\", \"RelationTarget\"]);\n\n/** One function the table carries, where it was. */\ninterface CarriedSite {\n member: Member;\n carried: CarriedFunction;\n label: string;\n}\n\n/** A callback-bearing property, found by walking the evaluated properties. */\ninterface TransformSite {\n /** Path of the property in the literal: `[\"properties\", \"title\"]`. */\n segments: PathSegment[];\n /** The printer's transform path: `title`, `tags[]`, `seo.title`, `content[].text`. */\n transformPath: string;\n /** The callback names that are functions. */\n names: string[];\n}\n\nfunction joinPath(parent: string, segment: string): string {\n if (parent === \"\") return segment;\n return segment === \"[]\" ? `${parent}[]` : `${parent}.${segment}`;\n}\n\nfunction functionNames(value: unknown): string[] {\n if (typeof value !== \"object\" || value === null) return [];\n return Object.entries(value).filter(([, entry]) => typeof entry === \"function\").map(([name]) => name);\n}\n\nfunction collectTransformSites(properties: Record<string, LegacyProperty>, segments: PathSegment[], prefix: string, out: TransformSite[]): void {\n for (const [key, property] of Object.entries(properties)) {\n visitProperty(property, [...segments, key], joinPath(prefix, key), out);\n }\n}\n\nfunction visitProperty(property: LegacyProperty, segments: PathSegment[], transformPath: string, out: TransformSite[]): void {\n const names = functionNames(property.callbacks);\n if (names.length > 0) out.push({ segments, transformPath, names });\n if (property.type === \"array\") {\n if (property.of !== undefined && !Array.isArray(property.of)) {\n visitProperty(property.of, [...segments, \"of\"], joinPath(transformPath, \"[]\"), out);\n }\n if (property.oneOf !== undefined) {\n for (const [variant, variantProperty] of Object.entries(property.oneOf.properties)) {\n visitProperty(variantProperty, [...segments, \"oneOf\", \"properties\", variant], joinPath(joinPath(transformPath, \"[]\"), variant), out);\n }\n }\n }\n if (property.type === \"map\" && property.properties !== undefined) {\n collectTransformSites(property.properties, [...segments, \"properties\"], transformPath, out);\n }\n}\n\n/**\n * The member at `segments` in the collection's literal, or in what a\n * top-level assignment after the declaration put there\n * (`ordersCollection.callbacks = {...}`).\n */\nfunction locate(plan: PlanContext, entry: CollectionEntry, segments: PathSegment[]): { member?: Member; reason?: string } {\n const site = entry.site;\n if (!site) return { reason: entry.siteProblem ?? \"the collection's literal was not found\" };\n const direct = nodeAtPath(plan.ast, site.literal, segments);\n if (direct.node) return { member: direct.node };\n if (site.binding) {\n const assignments = postDeclarationAssignments(plan.ast, entry.sourceFile, site.binding);\n for (let length = segments.length; length > 0; length--) {\n const prefix = segments.slice(0, length);\n if (prefix.some(segment => typeof segment === \"number\")) continue;\n const assigned = assignments.get(prefix.join(\".\"));\n if (!assigned) continue;\n const rest = segments.slice(length);\n if (rest.length === 0) return { member: { node: assigned.statement, value: assigned.value } };\n const object = resolveObject(plan.ast, assigned.value);\n if (!object.node) return { reason: `${prefix.join(\".\")} is assigned at line ${assigned.statement.getStartLineNumber()}, but ${object.reason}` };\n const nested = nodeAtPath(plan.ast, object.node, rest);\n if (nested.node) return { member: nested.node };\n return { reason: nested.reason };\n }\n }\n return { reason: direct.reason };\n}\n\n/** The functions of a callbacks object at `segments`, each carried. */\nfunction carryCallbacks(\n plan: PlanContext,\n entry: CollectionEntry,\n segments: PathSegment[],\n names: readonly string[],\n label: string\n): { members: { name: string; member: Member }[]; failed: boolean } {\n const located = locate(plan, entry, segments);\n if (!located.member) {\n refuse(plan, entry, `${label} holds functions, and their source could not be found: ${located.reason}. Write the callbacks inline in the collection literal (or as a \\`const\\` in the same file) and run the codemod again.`, { key: segments.join(\".\") });\n return { members: [], failed: true };\n }\n const object = resolveObject(plan.ast, located.member.value ?? located.member.node);\n if (!object.node) {\n refuse(plan, entry, `${label} is not an object literal the codemod can read (${object.reason}). Write it inline and run the codemod again.`, { key: segments.join(\".\"), line: located.member.node.getStartLineNumber() });\n return { members: [], failed: true };\n }\n const members: { name: string; member: Member }[] = [];\n let failed = false;\n for (const name of names) {\n const member = memberOf(plan.ast, object.node, name);\n if (!member.node) {\n refuse(plan, entry, `${label}.${name} is a function whose source could not be found: ${member.reason}.`, { key: segments.join(\".\"), line: object.node.getStartLineNumber() });\n failed = true;\n continue;\n }\n members.push({ name, member: member.node });\n }\n return { members, failed };\n}\n\nexport interface BackendPlanInput {\n /** The Postgres collections, in the order they were lifted. */\n entries: CollectionEntry[];\n lift: LiftResult;\n /** `backend/schema`, absolute. */\n schemaDir: string;\n /** The order the index lists the tables in: the legacy index's `collections`, then the rest by file. */\n order: string[];\n}\n\n/** File names and identifiers for every table, unique. */\nexport function nameTables(entries: readonly CollectionEntry[], defs: readonly (AnyTableDef | AnyViewDef)[], schemaDir: string): Map<string, TableName> {\n const byName = new Map<string, number>();\n for (const def of defs) byName.set(def.name, (byName.get(def.name) ?? 0) + 1);\n const names = new Map<string, TableName>();\n defs.forEach((def, index) => {\n const entry = entries[index];\n const schema = isViewDef(def) ? def.config.schema : def.config.schema;\n const base = (byName.get(def.name) ?? 0) > 1 && schema ? `${schema}_${def.name}` : def.name;\n const kind = isViewDef(def) ? \"view\" : def.auth !== undefined ? \"auth-table\" : \"table\";\n names.set(entry.collection.slug, {\n slug: entry.collection.slug,\n identifier: tableIdentifier(base),\n file: path.join(schemaDir, `${base}.ts`),\n table: def.name,\n kind\n });\n });\n return names;\n}\n\n/** Plan the backend schema modules. */\nexport function planBackend(plan: PlanContext, input: BackendPlanInput, names: Map<string, TableName>): void {\n const { entries, lift, schemaDir } = input;\n lift.tables.forEach((def, index) => {\n const entry = entries[index];\n const name = names.get(entry.collection.slug);\n if (!name) return;\n planTableModule(plan, entry, def, name, names);\n });\n const ordered = [...input.order.map(slug => names.get(slug)).filter((value): value is TableName => value !== undefined)];\n for (const name of names.values()) if (!ordered.includes(name)) ordered.push(name);\n const indexFile = path.join(schemaDir, \"index.ts\");\n const index = printIndexModule(\n ordered.map(name => ({ identifier: name.identifier, importPath: generatedSpecifier(indexFile, name.file, plan.specifierStyle) })),\n lift.defaultRls !== undefined ? { defaultRls: lift.defaultRls satisfies DefaultRls } : {}\n );\n planFile(plan, indexFile, index, \"the schema index\");\n}\n\nfunction planTableModule(plan: PlanContext, entry: CollectionEntry, def: AnyTableDef | AnyViewDef, name: TableName, names: Map<string, TableName>): void {\n const collection = entry.collection;\n const splices = new Splices();\n const sources: { hooks?: string | Record<string, string>; transforms?: Record<string, string>; auth?: { onCreateUser?: string; onResetPassword?: string } } = {};\n const carried: CarriedSite[] = [];\n let failed = false;\n\n // Table hooks.\n const hookNames = functionNames(collection.callbacks);\n const callbacksSite = hookNames.length > 0 ? locate(plan, entry, [\"callbacks\"]) : undefined;\n const callbacksValue = callbacksSite?.member && !callbacksSite.member.method ? callbacksSite.member.value : undefined;\n const fromHelper = callbacksValue !== undefined && !resolveObject(plan.ast, callbacksValue).node;\n if (fromHelper && callbacksValue) {\n // `callbacks: softDeleteCallbacks(\"company\")`: the helper's functions take table-hook props where they are written.\n const helper = carryHelperHooks(plan, callbacksValue, hookNames);\n for (const [file, fileEdits] of helper.edits) plan.relocator.addSourceEdits(file, fileEdits);\n for (const file of helper.files) if (!plan.relocator.isInCollections(file)) plan.relocator.keptBackendModules.add(file);\n sources.hooks = splices.token(nodeText(callbacksValue));\n carried.push({ member: { node: callbacksValue, value: callbacksValue }, carried: { text: \"\", todos: [] }, label: \"hooks\" });\n for (const { file, hook, todo } of helper.todos) {\n plan.manualSteps.push({\n title: `Check hooks.${hook} of ${name.table}`,\n detail: `hooks.${hook} (in ${relativeToRoot(plan, file)}, which \\`${callbacksValue.getText().split(\"\\n\")[0]}\\` returns) ${todo} The line is marked \\`TODO(rebase-migrate)\\`.`,\n file: relativeToRoot(plan, file)\n });\n }\n if (helper.unresolved) {\n plan.manualSteps.push({\n title: `Check the hooks ${name.table} gets from \\`${callbacksValue.getText().split(\"\\n\")[0]}\\``,\n detail: `The table says \\`hooks: ${callbacksValue.getText().split(\"\\n\")[0]}\\`, as the collection said \\`callbacks:\\`, but the codemod could not follow it to the functions (${helper.unresolved}). Table hooks get \\`table\\` for \\`collection\\`, and \\`values\\` for \\`row\\` in afterRead / beforeDelete / afterDelete: check ${hookNames.map(hook => `\\`${hook}\\``).join(\", \")} where they are written.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n } else if (hookNames.length > 0) {\n const { members, failed: hookFailure } = carryCallbacks(plan, entry, [\"callbacks\"], hookNames, \"`callbacks`\");\n failed ||= hookFailure;\n const hooks: Record<string, string> = {};\n for (const { name: hook, member } of members) {\n const result = carryHook(plan.ast, member, hook);\n hooks[hook] = splices.token(result.text);\n carried.push({ member, carried: result, label: `hooks.${hook}` });\n }\n sources.hooks = hooks;\n }\n\n // Column transforms.\n const transformSites: TransformSite[] = [];\n collectTransformSites(collection.properties ?? {}, [\"properties\"], \"\", transformSites);\n if (transformSites.length > 0) {\n const transforms: Record<string, string> = {};\n for (const site of transformSites) {\n const { members, failed: transformFailure } = carryCallbacks(plan, entry, [...site.segments, \"callbacks\"], site.names, `the \\`callbacks\\` of \"${site.transformPath}\"`);\n failed ||= transformFailure;\n if (members.length === 0) continue;\n const result = carryTransform(plan.ast, members);\n transforms[site.transformPath] = splices.token(result.text);\n for (const { member } of members) carried.push({ member, carried: { text: \"\", todos: [] }, label: `${site.transformPath}.transform` });\n if (result.todos.length > 0) carried.push({ member: members[0].member, carried: result, label: `${site.transformPath}.transform` });\n }\n sources.transforms = transforms;\n }\n\n // Auth lifecycle functions.\n const auth = typeof collection.auth === \"object\" && collection.auth !== null ? collection.auth : undefined;\n if (auth) {\n for (const key of [\"onCreateUser\", \"onResetPassword\"] as const) {\n if (typeof auth[key] !== \"function\") continue;\n const located = locate(plan, entry, [\"auth\", key]);\n if (!located.member) {\n refuse(plan, entry, `\\`auth.${key}\\` is a function whose source could not be found: ${located.reason}.`, { key: `auth.${key}` });\n failed = true;\n continue;\n }\n const text = located.member.method ? carryHook(plan.ast, located.member, key).text : nodeText(located.member.value ?? located.member.node);\n sources.auth = { ...sources.auth, [key]: splices.token(text) };\n carried.push({ member: located.member, carried: { text, todos: [] }, label: `auth.${key}` });\n }\n }\n if (failed) return;\n\n for (const site of carried) {\n for (const todo of site.carried.todos) {\n plan.manualSteps.push({\n title: `Check ${site.label} of ${name.table}`,\n detail: `${site.label} ${todo} The line is marked \\`TODO(rebase-migrate)\\`.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n }\n\n // What the carried code references, and the other exports of the file.\n const site = entry.site;\n const exclude: Statement[] = site ? site.statements : [];\n const extraExports = site\n ? entry.sourceFile.getStatements().filter(statement => !exclude.includes(statement) && isExportedDeclaration(plan, statement))\n : [];\n const references = collectReferences(plan.ast, [...carried.map(entry_ => entry_.member.node), ...extraExports], exclude);\n for (const forbidden of references.forbidden) {\n refuse(plan, entry, `carried code references \\`${forbidden.name}\\`, the collection itself, which does not exist after the migration. Read what it needs from \\`table\\` (the hook's props) instead.`, { line: forbidden.line });\n failed = true;\n }\n if (failed) return;\n const statements = [...new Set([...references.statements, ...extraExports])].sort((a, b) => a.getStart() - b.getStart());\n for (const statement of extraExports) {\n const names_ = declaredNames(plan, statement);\n plan.manualSteps.push({\n title: `Update the importers of ${names_.join(\", \")}`,\n detail: `${relativeToRoot(plan, entry.file)} exported ${names_.map(n => `\\`${n}\\``).join(\", \")} beside the collection. ${names_.length > 1 ? \"They are\" : \"It is\"} exported from ${relativeToRoot(plan, name.file)} now; point every import of it there.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n\n // Print the table.\n const resolveTarget = (target: { name?: string; slug: string }): PrintTarget => {\n const found = names.get(target.slug);\n if (!found) {\n throw new RelocationError(entry.file, `a relation points at \"${target.slug}\", which is not a collection file in ${relativeToRoot(plan, path.dirname(entry.file))}. Move that collection into the directory (or drop the relation) and run the codemod again.`);\n }\n return {\n identifier: found.identifier,\n importPath: generatedSpecifier(name.file, found.file, plan.specifierStyle),\n table: found.table,\n kind: found.kind === \"view\" ? \"view\" : \"table\"\n };\n };\n let printed;\n try {\n printed = printTableSource(def, { identifier: name.identifier, resolveTarget, sources: sources satisfies TableSources });\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return;\n }\n\n // Imports: the builders and related tables, then what carried code uses.\n // Collection-model types the carried code names become table-model aliases.\n const usesText = [...statements.map(statement => statement.getText()), ...carried.map(site_ => site_.member.node.getText())].join(\"\\n\");\n const legacyTypes = replaceLegacyTypes(references.imports, usesText);\n for (const local of legacyTypes.unreplaceable) {\n plan.manualSteps.push({\n title: `Replace the collection-model type ${local} in ${name.table}`,\n detail: `Carried code uses \\`${local}\\` with type arguments, which a table-model alias cannot stand for. Use the table-model type (\\`TableHooks\\`, \\`TableBeforeSaveProps\\`, … from \\`@rebasepro/server/schema\\`) instead.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n let carriedImports: string[];\n try {\n carriedImports = [\n ...importLines(legacyTypes.kept, use => plan.relocator.relocate(use.specifier, use.fromFile, name.file, \"backend\")),\n ...legacyTypes.imports\n ];\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return;\n }\n const taken = new Set([...printed.imports.builders, ...printed.imports.tables.map(table => table.identifier), name.identifier, ...BUILDER_NAMES]);\n const clashes = [...references.imports.map(use => use.local), ...statements.flatMap(statement => declaredNames(plan, statement))]\n .filter(local => taken.has(local));\n if (clashes.length > 0) {\n refuse(plan, entry, `carried code binds ${[...new Set(clashes)].map(clash => `\\`${clash}\\``).join(\", \")}, which the table module also binds (a builder, a related table, or the table itself). Rename it in the collection file and run the codemod again.`);\n return;\n }\n\n let statementTexts: string[];\n try {\n statementTexts = statements.map(statement => {\n const text = [...leadingComments(statement), nodeText(statement)].join(\"\\n\");\n return text.includes(\"import(\") ? plan.relocator.moveSpecifiersInText(text, entry.file, name.file, \"backend\") : text;\n });\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return;\n }\n\n // Comments: the file header, the collection's own, each property's.\n const header = fileHeader(plan, entry);\n const own = site ? site.statements.flatMap(statement => leadingComments(statement)).filter(comment => !header.includes(comment)) : [];\n let code = printed.code;\n code = splices.apply(code);\n if (code.includes(\"__REBASE_MIGRATE_SPLICE_\")) {\n refuse(plan, entry, \"a spliced source was not placed by the printer (internal): report this.\");\n return;\n }\n if (carried.some(site_ => site_.carried.todos.length > 0)) {\n note(plan, entry, `${name.table}: carried code has TODO(rebase-migrate) lines to check.`);\n }\n\n const parts = [\n ...(header.length > 0 ? [header.join(\"\\n\")] : []),\n [...printImportLines(printed.imports), ...carriedImports].join(\"\\n\"),\n ...(legacyTypes.aliases.length > 0 ? [legacyTypes.aliases.join(\"\\n\")] : []),\n ...statementTexts,\n [...own, code].join(\"\\n\")\n ];\n planFile(plan, name.file, `${parts.join(\"\\n\\n\")}\\n`, `table ${name.table}`);\n}\n\nfunction isExportedDeclaration(plan: PlanContext, statement: Statement): boolean {\n const { Node: N } = plan.ast.tsm;\n if (N.isVariableStatement(statement) || N.isFunctionDeclaration(statement) || N.isClassDeclaration(statement) ||\n N.isInterfaceDeclaration(statement) || N.isTypeAliasDeclaration(statement) || N.isEnumDeclaration(statement)) {\n return statement.isExported() && !statement.isDefaultExport();\n }\n return false;\n}\n\nfunction declaredNames(plan: PlanContext, statement: Statement): string[] {\n const { Node: N } = plan.ast.tsm;\n if (N.isVariableStatement(statement)) return statement.getDeclarations().map(declaration => declaration.getName());\n if (N.isFunctionDeclaration(statement) || N.isClassDeclaration(statement)) {\n const declared = statement.getName();\n return declared ? [declared] : [];\n }\n if (N.isInterfaceDeclaration(statement) || N.isTypeAliasDeclaration(statement) || N.isEnumDeclaration(statement)) return [statement.getName()];\n return [];\n}\n\n/** The comments above the first statement of the file, when that statement is an import: the file's header. */\nfunction fileHeader(plan: PlanContext, entry: CollectionEntry): string[] {\n const first = entry.sourceFile.getStatements()[0];\n if (!first || !plan.ast.tsm.Node.isImportDeclaration(first)) return [];\n return leadingComments(first);\n}\n","/**\n * Where each legacy presentation key goes in `customizeTable`.\n *\n * A migration tool legitimately freezes legacy knowledge, so the table lives\n * here — written out in full, one entry per legacy key, as plain data. It is\n * guarded against the real surface by `tooling/scripts/test/codemod-vocabulary.test.mjs`\n * (`pnpm test:gates`): every destination must be a key `customizeTable`\n * accepts (`TABLE_CUSTOMIZATION_KEYS` / `FIELD_CUSTOMIZATION_KEYS` in\n * `@rebasepro/cms-types`), every renamed key must agree with the hint\n * `customizeTable` refuses the old name with, and every legacy `admin` key\n * (`ADMIN_COLLECTION_KEYS` / `ADMIN_PROPERTY_KEYS` in `@rebasepro/cms-types`) must\n * have an entry here — a destination, or an explicit `dropped` with why.\n *\n * A destination is a key of the customization (`\"fieldOrder\"`) or a path into\n * one (`\"kanban.orderField\"`). Keep the literals plain: the gate test reads\n * this file as source.\n */\n\n/** Where a legacy key goes: a customization key or path, or why it has none. */\nexport type Destination = string | { dropped: string };\n\n/** A collection's `admin` keys → `customizeTable` options. */\nexport const COLLECTION_ADMIN_DESTINATIONS: Readonly<Record<string, Destination>> = {\n Actions: \"Actions\",\n additionalFields: \"additionalFields\",\n alwaysApplyDefaultValues: \"alwaysApplyDefaultValues\",\n browserCallbacks: \"browserCallbacks\",\n components: \"components\",\n customViews: \"customViews\",\n defaultEntityAction: \"defaultEntityAction\",\n defaultFilter: \"defaultFilter\",\n defaultSelectedView: \"defaultSelectedView\",\n defaultSize: \"defaultSize\",\n defaultViewMode: \"defaultViewMode\",\n disableDefaultActions: \"disableDefaultActions\",\n display: \"display\",\n enabledViews: \"enabledViews\",\n entityActions: \"entityActions\",\n entityViews: \"entityViews\",\n exportable: \"exportable\",\n filterPresets: \"filterPresets\",\n fixedFilter: \"fixedFilter\",\n form: \"form\",\n formAutoSave: \"formAutoSave\",\n formView: \"formView\",\n group: \"group\",\n hideFromEntityViews: \"hideFromEntityViews\",\n hideFromNavigation: \"hideFromNavigation\",\n hideIdFromCollection: \"hideIdFromCollection\",\n hideIdFromForm: \"hideIdFromForm\",\n icon: \"icon\",\n includeJsonView: \"includeJsonView\",\n inlineEditing: \"inlineEditing\",\n kanban: \"kanban\",\n listProperties: \"listFields\",\n localChangesBackup: \"localChangesBackup\",\n openEntityMode: \"openEntityMode\",\n orderProperty: \"kanban.orderField\",\n pagination: \"pagination\",\n previewProperties: \"previewFields\",\n propertiesOrder: \"fieldOrder\",\n selectionController: \"selectionController\",\n selectionEnabled: \"selectionEnabled\",\n sideDialogWidth: \"sideDialogWidth\",\n sort: \"sort\"\n};\n\n/** Keys inside a collection's `admin.kanban` → keys of `customizeTable`'s `kanban`. */\nexport const KANBAN_DESTINATIONS: Readonly<Record<string, string>> = {\n columnProperty: \"columnField\",\n orderProperty: \"orderField\"\n};\n\n/** A property's `admin` keys → field-customization options. `disabled: { hidden: true }` also becomes `hiddenInForm`. */\nexport const PROPERTY_ADMIN_DESTINATIONS: Readonly<Record<string, Destination>> = {\n canAddElements: \"canAddElements\",\n clearable: \"clearable\",\n columnWidth: \"columnWidth\",\n customProps: \"customProps\",\n disabled: \"disabled\",\n expanded: \"expanded\",\n Field: \"Field\",\n filledByServer: \"filledByServer\",\n Filter: \"Filter\",\n filterOperators: \"filterOperators\",\n fixedFilter: \"fixedFilter\",\n format: \"format\",\n hideFromCollection: \"hidden\",\n includeEntityLink: \"includeEntityLink\",\n includeId: \"includeId\",\n markdown: \"markdown\",\n minimalistView: \"minimalistView\",\n multiline: \"multiline\",\n Preview: \"Preview\",\n previewAsTag: \"previewAsTag\",\n previewProperties: \"previewFields\",\n readOnly: \"readOnly\",\n renderInForm: \"renderInForm\",\n sortable: \"sortable\",\n span: \"span\",\n spreadChildren: \"spreadChildren\",\n urlPreview: \"urlPreview\",\n widget: \"widget\"\n};\n\n/** Presentation fields of a collection outside its `admin` block (what the lift reports as not carried). */\nexport const COLLECTION_FIELD_DESTINATIONS: Readonly<Record<string, Destination>> = {\n name: \"name\",\n singularName: \"singularName\",\n icon: \"icon\",\n \"auth.actions.resetPassword\": \"resetPasswordAction\",\n admin: { dropped: \"not a destination itself: each of its keys is routed by COLLECTION_ADMIN_DESTINATIONS.\" },\n childCollections: { dropped: \"customizeTable has no child collections: a table's hasMany / manyToMany relations are its record tabs (reported as a manual step).\" },\n ownerId: { dropped: \"stamped by the collection editor; nothing on the request path or in the panel reads it.\" }\n};\n\n/** Presentation fields of a property outside its `admin` block. Labels equal to the derived one are dropped on the way. */\nexport const PROPERTY_FIELD_DESTINATIONS: Readonly<Record<string, Destination>> = {\n name: \"name\",\n description: \"description\",\n enum: \"enumLabels\",\n propertiesOrder: \"fieldOrder\",\n mode: \"mode\",\n timezone: \"timezone\",\n propertyConfig: \"propertyConfig\",\n conditions: \"conditions\",\n dynamicProps: \"dynamicProps\",\n metadata: \"metadata\",\n overrides: \"overrides\",\n \"storage.processFile\": \"storage\",\n \"storage.postProcess\": \"storage\",\n \"storage.previewUrl\": \"storage\",\n \"storage.fileName\": \"storage\",\n admin: { dropped: \"not a destination itself: each of its keys is routed by PROPERTY_ADMIN_DESTINATIONS.\" },\n userSelect: { dropped: \"carried by the lift as `.userId()` on the column; the CMS reads it from the descriptor.\" },\n defaultValue: \"defaultValue\",\n validation: { dropped: \"a relation's `requiredMessage` / `uniqueInArray` are panel messages customizeTable has no option for.\" },\n \"oneOf.propertiesOrder\": { dropped: \"the order the panel offers block types in; customizeTable has no option for it.\" },\n isId: { dropped: \"`\\\"manual\\\"` and `true` are the same key to the server; the difference had no other reader.\" },\n type: { dropped: \"a reference inside a JSON array is a document value; there is nothing to customize.\" }\n};\n\n/**\n * Keys of a rule source renamed with the move to tables, by where they are\n * written: the argument of `policy.existsIn(…)` / a literal\n * `{ kind: \"existsIn\", … }` (`ExistsInPolicyExpression` in `@rebasepro/types`),\n * and a tenant's `membership: { … }` source (`TenantMembershipSource`). The\n * SDK-call pass (`sdk-calls.ts`, rule 11) applies them to the project's own\n * code; the gate test holds each new key to the type's members.\n */\nexport const RULE_KEY_RENAMES: Readonly<Record<\"existsIn\" | \"membership\", Readonly<Record<string, string>>>> = {\n existsIn: { collection: \"table\" },\n membership: { collection: \"table\" }\n};\n","/**\n * Carrying a collection file's comments to the files it became.\n *\n * The shared printer prints tables from values, so it has no comments to\n * print; this is the codemod's own pass over the printed text, run once every\n * file of a collection is planned. A comment moves with what it describes:\n *\n * - above a property (or inside its literal) → above its column, or its\n * relation; above its field in the customization file when the property was\n * presentation only (when both halves exist the schema file keeps it);\n * - above a `securityRules`, `indexes` or `relations` entry → above that rule,\n * index or relation; above a `callbacks` member → above that hook;\n * - above any other carried key (`history`, `search`, …) → above that key;\n * above a presentation key (`name`, `icon`, an `admin` option) → above it in\n * the customization;\n * - comments inside carried functions are part of their text already.\n *\n * A comment that cannot be attached unambiguously is never dropped: it is\n * written at the top of the generated file, under `// From <original file>:`.\n */\nimport path from \"node:path\";\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\nimport type { AnyTableDef, AnyViewDef } from \"@rebasepro/types\";\n\nimport type { AstContext } from \"./ast\";\nimport { memberOf, postDeclarationAssignments, resolveArray, resolveObject, toPosix } from \"./ast\";\nimport type { CollectionEntry } from \"./plan-context\";\nimport { dedent, reindent } from \"./print-js\";\nimport { COLLECTION_ADMIN_DESTINATIONS } from \"./vocabulary\";\nimport { own } from \"./own\";\n\n/** Where a comment goes. */\nexport interface CommentTarget {\n side: \"backend\" | \"cms\";\n /** A top-level key of the definition / customization; absent for \"unattached\". */\n key?: string;\n /** An entry of that key's block: an object key, or an array index. */\n entry?: string | number;\n}\n\n/** One comment and where it goes. */\nexport interface PlacedComment {\n text: string;\n target: CommentTarget;\n}\n\n/** Legacy collection keys carried into the table under a key of their own. */\nconst CARRIED_KEYS: Readonly<Record<string, string>> = {\n slug: \"slug\",\n table: \"table\",\n schema: \"schema\",\n dataSource: \"database\",\n description: \"description\",\n tenant: \"tenant\",\n softDelete: \"softDelete\",\n history: \"history\",\n search: \"search\",\n strictWrites: \"strictWrites\",\n metadata: \"metadata\",\n disableDefaultPolicies: \"defaultPolicies\",\n auth: \"auth\",\n view: \"query\"\n};\n\n/** Presentation keys of a collection outside `admin`. */\nconst PRESENTATION_KEYS = new Set([\"name\", \"singularName\", \"icon\"]);\n\nfunction isInsideFunction(ctx: AstContext, node: Node, boundary: Node): boolean {\n const { Node: N } = ctx.tsm;\n let current: Node | undefined = node;\n while (current && current !== boundary) {\n if (N.isArrowFunction(current) || N.isFunctionExpression(current) || N.isMethodDeclaration(current) || N.isFunctionDeclaration(current)) return true;\n current = current.getParent();\n }\n return false;\n}\n\n/**\n * The comment ranges of a node: before it, and on its line after it — after\n * the comma that ends a member too (`slug: …, // why`), which the parser\n * hands to the next member's leading trivia.\n */\nfunction ownRanges(node: Node): { pos: number; text: string }[] {\n const out = [...node.getLeadingCommentRanges(), ...node.getTrailingCommentRanges()].map(range => ({ pos: range.getPos(), text: range.getText() }));\n const full = node.getSourceFile().getFullText();\n let end = node.getEnd();\n while (end < full.length && (full[end] === \" \" || full[end] === \"\\t\")) end++;\n if (full[end] === \",\") {\n const after = full.slice(end + 1);\n const match = /^[ \\t]*(\\/\\/[^\\n]*|\\/\\*[^\\n]*?\\*\\/)/.exec(after);\n if (match) {\n const pos = end + 1 + after.indexOf(match[1]);\n if (!out.some(range => range.pos === pos)) out.push({ pos, text: match[1] });\n }\n }\n return out;\n}\n\n/** Every comment range anywhere inside a node (not counting the node's own leading ones). */\nfunction innerRanges(node: Node): { pos: number; text: string; owner: Node }[] {\n const out: { pos: number; text: string; owner: Node }[] = [];\n for (const descendant of node.getDescendants()) {\n for (const range of [...descendant.getLeadingCommentRanges(), ...descendant.getTrailingCommentRanges()]) {\n if (range.getPos() >= node.getStart() && range.getEnd() <= node.getEnd()) out.push({ pos: range.getPos(), text: range.getText(), owner: descendant });\n }\n }\n return out;\n}\n\n/** A comment's text with the indentation of its line removed from its later lines. */\nfunction commentText(sf: SourceFile, pos: number, text: string): string {\n const full = sf.getFullText();\n const lineStart = full.lastIndexOf(\"\\n\", pos - 1) + 1;\n const indent = /^[ \\t]*/.exec(full.slice(lineStart, pos))?.[0] ?? \"\";\n return dedent(text, indent);\n}\n\n/** Directives a linter or compiler reads, which mean nothing in another file. */\nfunction isDirective(text: string): boolean {\n return /^\\/\\/\\s*(@ts-|eslint|prettier|#)/.test(text) || /^\\/\\*\\s*(eslint|prettier|@ts-|global\\b)/.test(text);\n}\n\n/**\n * Every comment of a collection file, and where it goes.\n *\n * @param def the definition the collection became (to know its columns and relations)\n * @param skip comments already written by the module printer (the file header, the collection's own doc)\n */\nexport function collectComments(ctx: AstContext, entry: CollectionEntry, def: AnyTableDef | AnyViewDef, skip: ReadonlySet<string>): PlacedComment[] {\n const site = entry.site;\n const sf = entry.sourceFile;\n if (!site) return [];\n const { Node: N } = ctx.tsm;\n const columns = new Set(Object.keys(def.config.columns));\n const relations = new Set(Object.keys(def.config.relations ?? {}));\n const placed = new Set<number>();\n const out: PlacedComment[] = [];\n const put = (pos: number, text: string, target: CommentTarget): void => {\n if (placed.has(pos)) return;\n placed.add(pos);\n if (isDirective(text) || skip.has(text)) return;\n out.push({ text: commentText(sf, pos, text), target });\n };\n const putAll = (node: Node, target: CommentTarget, boundary: Node): void => {\n for (const range of ownRanges(node)) put(range.pos, range.text, target);\n for (const range of innerRanges(node)) {\n if (isInsideFunction(ctx, range.owner, boundary)) {\n placed.add(range.pos);\n continue;\n }\n put(range.pos, range.text, target);\n }\n };\n\n const propertyTarget = (key: string): CommentTarget =>\n columns.has(key) ? { side: \"backend\", key: \"columns\", entry: key }\n : relations.has(key) ? { side: \"backend\", key: \"relations\", entry: key }\n : { side: \"cms\", key: \"fields\", entry: key };\n\n /** One collection-level member (`properties: {…}`) or the value assigned to it later. */\n const member = (key: string, holder: Node, value: Node | undefined): void => {\n const rangesOfHolder = ownRanges(holder);\n if (key === \"properties\") {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"backend\", key: \"columns\" });\n const object = value ? resolveObject(ctx, value).node : undefined;\n if (!object) return;\n for (const property of object.getProperties()) {\n if (N.isSpreadAssignment(property)) continue;\n const nameNode = \"getNameNode\" in property ? property.getNameNode() : undefined;\n const name = nameNode ? nameNode.getText().replace(/^[\"'`]|[\"'`]$/g, \"\") : undefined;\n if (name === undefined) continue;\n putAll(property, propertyTarget(name), property);\n }\n return;\n }\n const arrayKey = key === \"securityRules\" ? \"rls\" : key === \"indexes\" ? \"indexes\" : key === \"relations\" ? \"relations\" : undefined;\n if (arrayKey) {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"backend\", key: arrayKey });\n const array = value ? resolveArray(ctx, value).node : undefined;\n if (!array) return;\n const relationsList = \"relations\" in entry.collection && Array.isArray(entry.collection.relations) ? entry.collection.relations : [];\n array.getElements().forEach((element, index) => {\n if (arrayKey === \"relations\") {\n const name = relationsList[index]?.relationName;\n putAll(element, name !== undefined && relations.has(name) ? { side: \"backend\", key: \"relations\", entry: name } : { side: \"backend\", key: \"relations\" }, element);\n } else {\n putAll(element, { side: \"backend\", key: arrayKey, entry: index }, element);\n }\n });\n return;\n }\n if (key === \"callbacks\") {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"backend\", key: \"hooks\" });\n const object = value ? resolveObject(ctx, value).node : undefined;\n if (!object) return;\n for (const hook of object.getProperties()) {\n const nameNode = \"getNameNode\" in hook ? hook.getNameNode() : undefined;\n if (!nameNode) continue;\n putAll(hook, { side: \"backend\", key: \"hooks\", entry: nameNode.getText() }, hook);\n }\n return;\n }\n if (key === \"admin\") {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"cms\" });\n const object = value ? resolveObject(ctx, value).node : undefined;\n if (!object) return;\n for (const option of object.getProperties()) {\n const nameNode = \"getNameNode\" in option ? option.getNameNode() : undefined;\n const destination = nameNode ? own(COLLECTION_ADMIN_DESTINATIONS, nameNode.getText()) : undefined;\n const top = typeof destination === \"string\" ? destination.split(\".\")[0] : undefined;\n putAll(option, top ? { side: \"cms\", key: top } : { side: \"cms\" }, option);\n }\n return;\n }\n const carried = own(CARRIED_KEYS, key);\n const target: CommentTarget = carried ? { side: \"backend\", key: carried }\n : PRESENTATION_KEYS.has(key) ? { side: \"cms\", key }\n : { side: \"backend\" };\n putAll(holder, target, holder);\n };\n\n const literal: ObjectLiteralExpression = site.literal;\n for (const property of literal.getProperties()) {\n if (N.isSpreadAssignment(property)) {\n putAll(property, { side: \"backend\" }, property);\n continue;\n }\n const nameNode = \"getNameNode\" in property ? property.getNameNode() : undefined;\n if (!nameNode) continue;\n const key = nameNode.getText().replace(/^[\"'`]|[\"'`]$/g, \"\");\n const value = memberOf(ctx, literal, key).node;\n member(key, property, value?.value ?? (value?.method ? value.method : undefined));\n }\n if (site.binding) {\n for (const [assigned, { value, statement }] of postDeclarationAssignments(ctx, sf, site.binding)) {\n if (!assigned.includes(\".\")) member(assigned, statement, value);\n }\n }\n // Every other comment of the file that nothing carried, at the top.\n for (const statement of sf.getStatements()) {\n if (ctx.tsm.Node.isImportDeclaration(statement)) {\n for (const range of ownRanges(statement)) put(range.pos, range.text, { side: \"backend\" });\n continue;\n }\n for (const range of ownRanges(statement)) put(range.pos, range.text, { side: \"backend\" });\n for (const range of innerRanges(statement)) {\n if (placed.has(range.pos)) continue;\n if (isInsideFunction(ctx, range.owner, statement)) {\n placed.add(range.pos);\n continue;\n }\n put(range.pos, range.text, { side: \"backend\" });\n }\n }\n return out;\n}\n\n/** The index of the line that opens the definition / customization call. */\nfunction callLine(lines: readonly string[]): number {\n return lines.findIndex(line => /^export const \\w+ = (define(Table|AuthTable|View)|customizeTable)\\b/.test(line));\n}\n\n/** Where a target lands in printed text, as a line index, or -1. */\nfunction targetLine(lines: readonly string[], target: CommentTarget): number {\n const start = callLine(lines);\n if (start < 0 || target.key === undefined) return -1;\n let keyLine = -1;\n for (let index = start + 1; index < lines.length; index++) {\n if (/^\\}\\)/.test(lines[index])) break;\n if (lines[index].startsWith(` ${target.key}: `) || lines[index] === ` ${target.key}: {` || lines[index] === ` ${target.key}: [`) {\n keyLine = index;\n break;\n }\n }\n if (keyLine < 0 || target.entry === undefined) return keyLine;\n const opener = lines[keyLine];\n if (!opener.endsWith(\"{\") && !opener.endsWith(\"[\")) return keyLine;\n let element = 0;\n for (let index = keyLine + 1; index < lines.length; index++) {\n const line = lines[index];\n if (/^ {4}[\\]}]/.test(line)) break;\n if (!/^ {8}\\S/.test(line) || /^ {8}[}\\]]/.test(line)) continue;\n if (typeof target.entry === \"number\") {\n if (element === target.entry) return index;\n element++;\n } else {\n const match = /^ {8}(\"?)([^\":\\s]+)\\1: /.exec(line);\n if (match && match[2] === target.entry) return index;\n }\n }\n return -1;\n}\n\n/**\n * Insert comments into printed text, each above its target line, indented\n * like it. What has no target there is returned.\n */\nexport function placeComments(text: string, comments: readonly PlacedComment[]): { text: string; leftover: string[] } {\n const lines = text.split(\"\\n\");\n const inserts = new Map<number, string[]>();\n const leftover: string[] = [];\n for (const comment of comments) {\n const line = targetLine(lines, comment.target);\n if (line < 0) {\n leftover.push(comment.text);\n continue;\n }\n const indent = /^[ \\t]*/.exec(lines[line])?.[0] ?? \"\";\n inserts.set(line, [...(inserts.get(line) ?? []), `${indent}${reindent(comment.text, indent)}`]);\n }\n const out: string[] = [];\n lines.forEach((line, index) => {\n out.push(...(inserts.get(index) ?? []), line);\n });\n return { text: out.join(\"\\n\"), leftover };\n}\n\n/** Comments nothing could be attached to, written after the module's imports under `// From <file>:`. */\nexport function addUnattached(text: string, comments: readonly string[], originalFile: string, root: string): string {\n if (comments.length === 0) return text;\n const lines = text.split(\"\\n\");\n let last = -1;\n lines.forEach((line, index) => {\n if (/^import\\s/.test(line)) last = index;\n });\n const block = [\"\", `// From ${toPosix(path.relative(root, originalFile))}:`, ...comments];\n lines.splice(last + 1, 0, ...block);\n return lines.join(\"\\n\");\n}\n\n/**\n * The legacy collections index's comments: those about `defaultSecurityRules`\n * go above `defaultRls`, those about the `collections` array (the panel's\n * order) above `tableCustomizations`, the rest to the schema index's top.\n *\n * @returns the two index files' new text\n */\nexport function placeIndexComments(\n ctx: AstContext,\n legacyIndex: SourceFile,\n schemaIndex: string,\n cmsIndex: string | undefined,\n root: string\n): { schemaIndex: string; cmsIndex?: string } {\n const rules: string[] = [];\n const order: string[] = [];\n const rest: string[] = [];\n for (const statement of legacyIndex.getStatements()) {\n const ranges = [...ownRanges(statement), ...innerRanges(statement).filter(range => !isInsideFunction(ctx, range.owner, statement))];\n const texts = ranges.filter(range => !isDirective(range.text)).map(range => commentText(legacyIndex, range.pos, range.text));\n if (texts.length === 0) continue;\n const declared = ctx.tsm.Node.isVariableStatement(statement) ? statement.getDeclarations().map(declaration => declaration.getName()) : [];\n if (declared.includes(\"defaultSecurityRules\")) rules.push(...texts);\n else if (declared.includes(\"collections\")) order.push(...texts);\n else rest.push(...texts);\n }\n const insertAbove = (text: string, marker: RegExp, comments: readonly string[]): { text: string; placed: boolean } => {\n if (comments.length === 0) return { text, placed: true };\n const lines = text.split(\"\\n\");\n let at = lines.findIndex(line => marker.test(line));\n if (at < 0) return { text, placed: false };\n while (at > 0 && /^(\\/\\*\\*|\\s*\\*|\\/\\/)/.test(lines[at - 1])) at--;\n lines.splice(at, 0, ...comments);\n return { text: lines.join(\"\\n\"), placed: true };\n };\n const withRules = insertAbove(schemaIndex, /^export const defaultRls\\b/, rules);\n let nextSchema = withRules.text;\n const unattached = [...rest, ...(withRules.placed ? [] : rules)];\n let nextCms = cmsIndex;\n if (cmsIndex !== undefined) {\n const withOrder = insertAbove(cmsIndex, /^export const tableCustomizations\\b/, order);\n nextCms = withOrder.text;\n if (!withOrder.placed) unattached.push(...order);\n } else {\n unattached.push(...order);\n }\n if (unattached.length > 0) nextSchema = `// From ${toPosix(path.relative(root, legacyIndex.getFilePath()))}:\\n${unattached.join(\"\\n\")}\\n\\n${nextSchema}`;\n return { schemaIndex: nextSchema, ...(nextCms !== undefined ? { cmsIndex: nextCms } : {}) };\n}\n","/**\n * A `dynamicProps` builder's return shape, 0.30 → 0.31.\n *\n * On 0.30 a builder returned a partial property: `{ admin: { readOnly: true } }`.\n * On 0.31 it returns a field customization, flat: `{ readOnly: true }`, each\n * key under the name `customizeTable` gives it (`hideFromCollection` →\n * `hidden`, as the codemod routes a static `admin`). When every value the\n * function can return is an object literal — directly, through a ternary, an\n * early `return`, or a top-level `const` of the same file used only there —\n * and each holds nothing but an `admin` block of routable keys, the literals\n * are rewritten in place. Anything else (a spread, a computed value, a key\n * that would collide or has no destination) is left for the manual step.\n */\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\n\nimport type { AstContext } from \"./ast\";\nimport { unwrap } from \"./ast\";\nimport type { SourceEdit } from \"./helper-hooks\";\nimport { own } from \"./own\";\nimport { PROPERTY_ADMIN_DESTINATIONS } from \"./vocabulary\";\n\n/** The rewrite of one builder: edits into its file, or why it is left. */\nexport type DynamicPropsRewrite = { edits: SourceEdit[]; reason?: undefined } | { edits?: undefined; reason: string };\n\nfunction propertyName(ctx: AstContext, member: Node): string | undefined {\n const { Node: N } = ctx.tsm;\n if (!N.isPropertyAssignment(member) && !N.isShorthandPropertyAssignment(member)) return undefined;\n const name = member.getNameNode();\n if (N.isIdentifier(name)) return name.getText();\n if (N.isStringLiteral(name) || N.isNoSubstitutionTemplateLiteral(name)) return name.getLiteralValue();\n return undefined;\n}\n\n/** `{ admin: { readOnly: true } }` → `{ readOnly: true }`, or why not. */\nfunction flatten(ctx: AstContext, literal: ObjectLiteralExpression): { text: string } | { reason: string } {\n const { Node: N } = ctx.tsm;\n const properties = literal.getProperties();\n if (properties.length === 0) return { text: literal.getText() };\n const out: string[] = [];\n const seen = new Set<string>();\n for (const property of properties) {\n if (propertyName(ctx, property) !== \"admin\" || !N.isPropertyAssignment(property)) {\n return { reason: `it returns \\`${property.getText().split(\"\\n\")[0]}\\`, which is not an \\`admin\\` block` };\n }\n const admin = unwrap(ctx, property.getInitializerOrThrow());\n if (!N.isObjectLiteralExpression(admin)) return { reason: \"its `admin` block is not an object literal\" };\n for (const entry of admin.getProperties()) {\n const key = propertyName(ctx, entry);\n const destination = key === undefined ? undefined : own(PROPERTY_ADMIN_DESTINATIONS, key);\n if (key === undefined || typeof destination !== \"string\" || key === \"disabled\") {\n return { reason: `its \\`admin.${key ?? entry.getText().split(\"\\n\")[0]}\\` has no flat equivalent the codemod can write` };\n }\n if (seen.has(destination)) return { reason: `two of its \\`admin\\` keys would both be \\`${destination}\\`` };\n seen.add(destination);\n const value = N.isShorthandPropertyAssignment(entry) ? entry.getName() : N.isPropertyAssignment(entry) ? entry.getInitializerOrThrow().getText() : undefined;\n if (value === undefined) return { reason: `its \\`admin.${key}\\` is not a plain value` };\n out.push(`${destination}: ${value}`);\n }\n }\n return { text: out.length === 0 ? \"{}\" : `{ ${out.join(\", \")} }` };\n}\n\n/** The literals a function can return, or why not every return is one. */\nfunction returnedLiterals(ctx: AstContext, fn: Node, sf: SourceFile): { literals: ObjectLiteralExpression[]; consts: Set<string> } | { reason: string } {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const literals: ObjectLiteralExpression[] = [];\n const consts = new Set<string>();\n const leaves = (node: Node): string | undefined => {\n const current = unwrap(ctx, node);\n if (N.isConditionalExpression(current)) return leaves(current.getWhenTrue()) ?? leaves(current.getWhenFalse());\n if (N.isObjectLiteralExpression(current)) {\n literals.push(current);\n return undefined;\n }\n if (N.isIdentifier(current)) {\n const declaration = sf.getVariableDeclaration(current.getText());\n const statement = declaration?.getVariableStatement();\n const initializer = declaration?.getInitializer();\n const value = initializer ? unwrap(ctx, initializer) : undefined;\n if (declaration && statement && N.isSourceFile(statement.getParent()) && value && N.isObjectLiteralExpression(value)) {\n consts.add(current.getText());\n literals.push(value);\n return undefined;\n }\n }\n return `it returns \\`${current.getText().split(\"\\n\")[0]}\\`, not an object literal`;\n };\n if (!(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isMethodDeclaration(fn) || N.isFunctionDeclaration(fn))) return { reason: \"it is not a function written here\" };\n const body = fn.getBody();\n if (!body) return { reason: \"it has no body\" };\n if (!N.isBlock(body)) {\n const problem = leaves(body);\n return problem ? { reason: problem } : { literals, consts };\n }\n const returns = fn.getDescendantsOfKind(SyntaxKind.ReturnStatement).filter(statement =>\n statement.getFirstAncestor(ancestor => N.isArrowFunction(ancestor) || N.isFunctionExpression(ancestor) || N.isFunctionDeclaration(ancestor) || N.isMethodDeclaration(ancestor)) === fn);\n if (returns.length === 0) return { reason: \"it returns nothing\" };\n for (const statement of returns) {\n const expression = statement.getExpression();\n if (!expression) return { reason: \"a `return` gives no value\" };\n const problem = leaves(expression);\n if (problem) return { reason: problem };\n }\n return { literals, consts };\n}\n\n/** Every function of a file written as the value of a `dynamicProps` member. */\nexport function dynamicPropsBuilders(ctx: AstContext, sf: SourceFile): Node[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const out: Node[] = [];\n for (const member of sf.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {\n if (member.getName() !== \"dynamicProps\") continue;\n const value = unwrap(ctx, member.getInitializerOrThrow());\n if (N.isArrowFunction(value) || N.isFunctionExpression(value)) out.push(value);\n }\n for (const method of sf.getDescendantsOfKind(SyntaxKind.MethodDeclaration)) if (method.getName() === \"dynamicProps\") out.push(method);\n return out;\n}\n\n/**\n * Rewrite a builder's returned literals to the flat shape.\n *\n * @param fn the builder (arrow, function expression or method) in `sf`\n * @param ownedBuilders every builder function of the file being rewritten: a\n * `const` returned by one may only be read by such builders\n */\nexport function rewriteDynamicProps(ctx: AstContext, fn: Node, sf: SourceFile, ownedBuilders: readonly Node[] = dynamicPropsBuilders(ctx, sf)): DynamicPropsRewrite {\n const { SyntaxKind } = ctx.tsm;\n const found = returnedLiterals(ctx, fn, sf);\n if (\"reason\" in found) return { reason: found.reason };\n // A shared `const` (`READ_ONLY`) is rewritten only when every read of it is a builder's return.\n for (const name of found.consts) {\n const reads = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === name && identifier.getParentIfKind(SyntaxKind.VariableDeclaration)?.getNameNode() !== identifier);\n const outside = reads.filter(identifier => !ownedBuilders.some(builder => identifier.getAncestors().includes(builder)));\n if (outside.length > 0) return { reason: `\\`${name}\\` is also read outside the builders (line ${outside[0].getStartLineNumber()})` };\n }\n const edits: SourceEdit[] = [];\n for (const literal of found.literals) {\n const flat = flatten(ctx, literal);\n if (\"reason\" in flat) return { reason: flat.reason };\n if (flat.text !== literal.getText()) edits.push({ start: literal.getStart(), end: literal.getEnd(), text: flat.text });\n }\n return { edits };\n}\n","/**\n * Shared enum constants, split into values (the schema's) and labels (the\n * CMS's).\n *\n * A legacy project often keeps a closed set in one module of `config/` —\n * `export const LOCALE_ENUM: EnumValueConfig[] = [{ id: \"en\", label: \"English\" }, …]`\n * — and uses it in a collection, where the ids are the column's values and the\n * labels its presentation. After the split those belong to two sides that may\n * not import each other's code, so the module becomes two:\n *\n * - `backend/lib/<name>.ts`: `export const LOCALES = [\"en\", …] as const;` and\n * `export type Locale = (typeof LOCALES)[number];`\n * - `frontend/src/cms/lib/<name>.ts`: `export const LOCALE_LABELS: Record<Locale, string> = {…}`,\n * typed from the backend's values (a type import, which the frontend may\n * make), so a value added without a label is a type error.\n *\n * The tables name `LOCALES` where they inlined the ids, and the customizations\n * name `LOCALE_LABELS` where they inlined the labels.\n *\n * Done only when it is mechanical: every export of the module is such a\n * constant, every entry is `{ id, label }` with nothing else (no colour, no\n * disabled flag). Otherwise the module stays a manual step that says why.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { plural } from \"@rebasepro/utils\";\n\nimport type { ModuleImporter } from \"./load-legacy\";\nimport { generatedSpecifier } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { planFile, relativeToRoot } from \"./plan-context\";\nimport { printStringLiteral } from \"./print-js\";\n\n/** One constant split in two. */\nexport interface SplitConstant {\n /** The legacy module, absolute. */\n module: string;\n /** The legacy export name (`LOCALE_ENUM`). */\n legacyName: string;\n /** The values, in order. */\n ids: (string | number)[];\n /** The label of each value. */\n labels: Record<string, string>;\n /** `LOCALES`, written in `backend/lib/<name>.ts`. */\n valuesName: string;\n /** `Locale`. */\n typeName: string;\n /** `LOCALE_LABELS`, written in `frontend/src/cms/lib/<name>.ts`. */\n labelsName: string;\n /** The backend module, absolute. */\n backendFile: string;\n /** The frontend module, absolute (absent for a project without a frontend). */\n frontendFile?: string;\n /** The collection files that import the legacy module. */\n importedBy: Set<string>;\n}\n\n/** A module of `config/` that could not be split, and why. */\nexport interface UnsplitModule {\n module: string;\n reason: string;\n}\n\nconst CODE_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".js\", \".mjs\"];\n\nfunction resolveModule(fromFile: string, specifier: string): string | undefined {\n const base = path.resolve(path.dirname(fromFile), specifier).replace(/\\.(m?js|jsx)$/, \"\");\n for (const extension of CODE_EXTENSIONS) if (fs.existsSync(base + extension)) return base + extension;\n for (const extension of CODE_EXTENSIONS) {\n const index = path.join(base, `index${extension}`);\n if (fs.existsSync(index)) return index;\n }\n return undefined;\n}\n\nfunction isEnumEntry(value: unknown): value is { id: string | number; label: string } {\n if (typeof value !== \"object\" || value === null) return false;\n const keys = Object.keys(value);\n return keys.length === 2 && \"id\" in value && \"label\" in value &&\n (typeof value.id === \"string\" || typeof value.id === \"number\") && typeof value.label === \"string\";\n}\n\nfunction names(legacyName: string): { valuesName: string; typeName: string; labelsName: string } {\n const base = legacyName.replace(/_(ENUM|VALUES|OPTIONS|LIST)$/, \"\") || legacyName;\n const lower = base.toLowerCase();\n const plural_ = plural(lower);\n const valuesName = plural_ !== lower ? plural_.toUpperCase() : `${base}_VALUES`;\n const typeName = lower.split(\"_\").filter(Boolean).map(word => word[0].toUpperCase() + word.slice(1)).join(\"\");\n return { valuesName, typeName, labelsName: `${base}_LABELS` };\n}\n\n/**\n * Find the `config/` modules the collections import that are enum constants\n * and nothing else.\n */\nexport async function findSplitConstants(\n plan: PlanContext,\n entries: readonly CollectionEntry[],\n importModule: ModuleImporter,\n cmsDir: string | undefined\n): Promise<{ constants: SplitConstant[]; unsplit: UnsplitModule[] }> {\n const byModule = new Map<string, Set<string>>();\n for (const entry of entries) {\n for (const declaration of entry.sourceFile.getImportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\") || declaration.isTypeOnly()) continue;\n const target = resolveModule(entry.file, specifier);\n if (!target || !plan.relocator.isInConfig(target) || entries.some(other => other.file === target)) continue;\n const set = byModule.get(target) ?? new Set<string>();\n set.add(entry.file);\n byModule.set(target, set);\n }\n }\n const constants: SplitConstant[] = [];\n const unsplit: UnsplitModule[] = [];\n for (const [module, importedBy] of byModule) {\n let exports: Record<string, unknown>;\n try {\n exports = await importModule(module);\n } catch {\n continue;\n }\n const entriesOf = Object.entries(exports).filter(([name]) => name !== \"default\" && name !== \"__esModule\");\n const enumExports = entriesOf.filter(([, value]) => Array.isArray(value) && value.length > 0 && value.every(isEnumEntry));\n if (enumExports.length === 0) continue;\n if (enumExports.length !== entriesOf.length) {\n unsplit.push({ module, reason: `exports ${entriesOf.filter(entry => !enumExports.includes(entry)).map(([name]) => `\\`${name}\\``).join(\", \")} besides its enum constants, so it cannot be split into values and labels mechanically` });\n continue;\n }\n const relative = path.relative(plan.relocator.configDirectory, module);\n for (const [legacyName, value] of enumExports) {\n const list = Array.isArray(value) ? value.filter(isEnumEntry) : [];\n const labels: Record<string, string> = {};\n for (const item of list) labels[String(item.id)] = item.label;\n constants.push({\n module,\n legacyName,\n ids: list.map(item => item.id),\n labels,\n ...names(legacyName),\n backendFile: path.join(plan.root, \"backend\", \"lib\", relative),\n ...(cmsDir ? { frontendFile: path.join(cmsDir, \"lib\", relative) } : {}),\n importedBy\n });\n }\n }\n return { constants, unsplit };\n}\n\n/** The printed form of a constant's ids, as the shared printer writes an array of literals. */\nfunction printedIds(constant: SplitConstant): string {\n return `[${constant.ids.map(id => (typeof id === \"string\" ? printStringLiteral(id) : String(id))).join(\", \")}]`;\n}\n\n/** Insert an import line after a module's import block. */\nfunction addImport(content: string, line: string): string {\n if (content.includes(line)) return content;\n const lines = content.split(\"\\n\");\n let last = -1;\n lines.forEach((text, index) => {\n if (/^import\\s/.test(text)) last = index;\n });\n lines.splice(last + 1, 0, line);\n return lines.join(\"\\n\");\n}\n\n/** Write the split modules and point the planned tables at the values. */\nexport function planSplitConstants(plan: PlanContext, constants: readonly SplitConstant[], tableFiles: ReadonlyMap<string, string>): void {\n const byModule = new Map<string, SplitConstant[]>();\n for (const constant of constants) byModule.set(constant.module, [...(byModule.get(constant.module) ?? []), constant]);\n for (const [module, group] of byModule) {\n const legacy = relativeToRoot(plan, module);\n const backend = group.map(constant => [\n `/** The values of \\`${constant.legacyName}\\` (${legacy}). What the panel calls each one is the CMS's: ${constant.frontendFile ? relativeToRoot(plan, constant.frontendFile) : \"no frontend\"}. */`,\n `export const ${constant.valuesName} = ${printedIds(constant)} as const;`,\n \"\",\n `/** One of {@link ${constant.valuesName}}. */`,\n `export type ${constant.typeName} = (typeof ${constant.valuesName})[number];`\n ].join(\"\\n\"));\n planFile(plan, group[0].backendFile, `${backend.join(\"\\n\\n\")}\\n`, `values of ${legacy}`);\n const frontendFile = group[0].frontendFile;\n if (frontendFile) {\n const typeImport = `import type { ${group.map(constant => constant.typeName).join(\", \")} } from ${JSON.stringify(generatedSpecifier(frontendFile, group[0].backendFile, plan.specifierStyle))};`;\n const frontend = group.map(constant => [\n `/** What the panel calls each value of \\`${constant.legacyName}\\` (${legacy}); the values are the backend's. */`,\n `export const ${constant.labelsName}: Record<${constant.typeName}, string> = {`,\n Object.entries(constant.labels).map(([id, label]) => ` ${/^[A-Za-z_$][\\w$]*$/.test(id) ? id : JSON.stringify(id)}: ${printStringLiteral(label)}`).join(\",\\n\"),\n \"};\"\n ].join(\"\\n\"));\n planFile(plan, frontendFile, `${typeImport}\\n\\n${frontend.join(\"\\n\\n\")}\\n`, `labels of ${legacy}`);\n }\n // The tables that inlined the values name the constant instead.\n for (const [collectionFile, tableFile] of tableFiles) {\n const planned = plan.files.get(tableFile);\n if (!planned) continue;\n let content = planned.content;\n for (const constant of group) {\n if (!constant.importedBy.has(collectionFile)) continue;\n const printed = printedIds(constant);\n if (!content.includes(printed)) continue;\n content = content.split(printed).join(constant.valuesName);\n content = addImport(content, `import { ${constant.valuesName} } from ${JSON.stringify(generatedSpecifier(tableFile, constant.backendFile, plan.specifierStyle))};`);\n }\n if (content !== planned.content) plan.files.set(tableFile, { ...planned, content });\n }\n }\n}\n\n/** The constant whose labels a field's legacy `enum` restates, when one does. */\nexport function constantForEnum(constants: readonly SplitConstant[], collectionFile: string, values: unknown): SplitConstant | undefined {\n if (!Array.isArray(values)) return undefined;\n return constants.find(constant => constant.importedBy.has(collectionFile) &&\n constant.ids.length === values.length &&\n values.every((value, index) => isEnumEntry(value) && value.id === constant.ids[index] && value.label === constant.labels[String(value.id)]));\n}\n","/**\n * `frontend/src/cms/<table>.tsx`: a collection's presentation as\n * `customizeTable(...)`, written only when the collection had any.\n *\n * Everything the lift did not put in the table (`notCarried`) is presentation,\n * and goes here under its new name: the `admin` block (its keys renamed where\n * `customizeTable` renamed them), labels that differ from what the\n * zero-config CMS derives, enum labels and colours, conditions, browser-only\n * storage functions, relation overrides. Data is printed from the evaluated\n * value; a function — an entity action, a display resolver, a component — is\n * printed from its source, its imports carried, a lazy `() => import(\"…\")` or a\n * string path turned into a real import by value.\n *\n * A label equal to the derived one is dropped, so a migrated file states only\n * real deltas, and a collection whose presentation is entirely default gets no\n * file at all.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Node, Statement } from \"ts-morph\";\nimport type { LegacyEnumValues, LiftNote } from \"@rebasepro/common/migrate\";\nimport { enumValueLabel, labelFromIdentifier, singularLabel } from \"@rebasepro/utils\";\n\nimport type { Member, PathSegment } from \"./ast\";\nimport { collectReferences, memberOf, nodeAtPath, nodeText, postDeclarationAssignments, resolveObject, spreadSource, unwrap } from \"./ast\";\nimport { rewriteDynamicProps } from \"./dynamic-props\";\nimport { findLiteral } from \"./helper-hooks\";\nimport { memberFunctionText } from \"./hooks\";\nimport { constantForEnum } from \"./split-constants\";\nimport {\n COLLECTION_ADMIN_DESTINATIONS,\n KANBAN_DESTINATIONS,\n PROPERTY_ADMIN_DESTINATIONS,\n PROPERTY_FIELD_DESTINATIONS\n} from \"./vocabulary\";\nimport { generatedSpecifier, importLines, resolveRelative, type GeneratedSpecifierStyle } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { note, planFile, refuse, relativeToRoot } from \"./plan-context\";\nimport { printValue, RawSource } from \"./print-js\";\nimport type { TableName } from \"./backend\";\nimport { own } from \"./own\";\n\n/** The keys whose string value is a component path (the Vite plugin's `LAZY_COMPONENT_KEYS`). */\nexport const COMPONENT_KEYS = new Set([\"Field\", \"Preview\", \"Builder\", \"Filter\", \"Component\"]);\n\n/**\n * Said of every component the migration turns from a path into an import. One\n * sentence for all of them, so the notes group into one line.\n */\nexport const IMPORTED_COMPONENT_REMARK =\n \"is imported now rather than loaded by path, so the admin's type check reads it against its slot's props \" +\n \"(`FieldPreviewProps` for a Preview, `FieldProps` for a Field): a component that types `customProps` as its own \" +\n \"props type fails `tsc` until it takes `unknown` and narrows it inside.\";\n\n/** A customization module being built. */\ninterface Builder {\n entry: CollectionEntry;\n name: TableName;\n /** The module, absolute. */\n file: string;\n options: Record<string, unknown>;\n /** AST nodes whose source is printed: their references are carried. */\n codeNodes: Node[];\n /** Component imports: local → `import X from \"spec\"` / `import { X } from \"spec\"`. */\n componentImports: Map<string, { specifier: string; imported: string }>;\n /** Named imports of split constants' label modules: specifier → names. */\n libImports: Map<string, Set<string>>;\n failed: boolean;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** A value that is a React component or other code: a function, or an exotic component object. */\nfunction isCode(value: unknown): boolean {\n return typeof value === \"function\" || (typeof value === \"object\" && value !== null && \"$$typeof\" in value);\n}\n\n/** Parse a lift note's key (`content[text].images[]`) into legacy literal segments. */\nexport function noteKeySegments(key: string): { literal: PathSegment[]; field: string[] } {\n const literal: PathSegment[] = [\"properties\"];\n const field: string[] = [];\n const pattern = /([^.[\\]]+)|\\[\\]|\\[([^\\]]+)\\]|\\./g;\n let first = true;\n for (const match of key.matchAll(pattern)) {\n const [token, name, variant] = match;\n if (token === \".\") continue;\n if (name !== undefined) {\n if (!first) {\n literal.push(\"properties\");\n field.push(\"fields\");\n }\n literal.push(name);\n field.push(name);\n } else if (token === \"[]\") {\n literal.push(\"of\");\n field.push(\"of\");\n } else if (variant !== undefined) {\n literal.push(\"oneOf\", \"properties\", variant);\n field.push(\"oneOf\", variant);\n }\n first = false;\n }\n return { literal, field };\n}\n\n/** The last identifier of a note key: what the default label is derived from. */\nfunction lastKey(key: string): string {\n const names = [...key.matchAll(/([^.[\\]]+)/g)].map(match => match[1]);\n return names[names.length - 1] ?? key;\n}\n\n/** Read or create the nested object at `segments` under `root`. */\nfunction at(root: Record<string, unknown>, segments: readonly string[]): Record<string, unknown> {\n let current = root;\n for (const segment of segments) {\n const next = current[segment];\n if (isPlainObject(next)) {\n current = next;\n } else {\n const created: Record<string, unknown> = {};\n current[segment] = created;\n current = created;\n }\n }\n return current;\n}\n\n/** Find the member at `segments` of the collection literal (or what an assignment after it put there). */\nfunction locate(plan: PlanContext, entry: CollectionEntry, segments: readonly PathSegment[]): { member?: Member; reason?: string } {\n const site = entry.site;\n if (!site) return { reason: entry.siteProblem ?? \"the collection's literal was not found\" };\n const direct = nodeAtPath(plan.ast, site.literal, segments);\n if (direct.node) return { member: direct.node };\n if (site.binding) {\n const assignments = postDeclarationAssignments(plan.ast, entry.sourceFile, site.binding);\n for (let length = segments.length; length > 0; length--) {\n const prefix = segments.slice(0, length);\n if (prefix.some(segment => typeof segment === \"number\")) continue;\n const assigned = assignments.get(prefix.join(\".\"));\n if (!assigned) continue;\n const rest = segments.slice(length);\n if (rest.length === 0) return { member: { node: assigned.statement, value: assigned.value } };\n const object = resolveObject(plan.ast, assigned.value);\n if (!object.node) return { reason: object.reason };\n const nested = nodeAtPath(plan.ast, object.node, rest);\n return nested.node ? { member: nested.node } : { reason: nested.reason };\n }\n }\n return { reason: direct.reason };\n}\n\n/** A component's import name, from its module path: `../BodyPartsField` → `BodyPartsField`. */\nfunction componentName(specifier: string, taken: ReadonlySet<string>): string {\n const base = path.basename(specifier).replace(/\\.(tsx?|jsx?|mjs)$/, \"\");\n const stem = base === \"index\" ? path.basename(path.dirname(specifier)) : base;\n const pascal = stem.split(/[^A-Za-z0-9]+/).filter(Boolean).map(word => word[0].toUpperCase() + word.slice(1)).join(\"\") || \"Component\";\n const safe = /^[0-9]/.test(pascal) ? `C${pascal}` : pascal;\n let candidate = safe;\n let counter = 2;\n while (taken.has(candidate)) candidate = `${safe}${counter++}`;\n return candidate;\n}\n\n/** Turn a component path written in the collection file into an import in the customization module. */\nfunction importComponent(plan: PlanContext, builder: Builder, specifier: string, imported: string, writtenIn = builder.entry.file): RawSource {\n const moved = plan.relocator.relocate(specifier, writtenIn, builder.file, \"frontend\");\n for (const [local, existing] of builder.componentImports) {\n if (existing.specifier === moved && existing.imported === imported) return new RawSource(local);\n }\n const taken = new Set(builder.componentImports.keys());\n const local = componentName(imported === \"default\" ? moved : imported, taken);\n builder.componentImports.set(local, { specifier: moved, imported });\n return new RawSource(local);\n}\n\n/**\n * The module that wrote the component path `value`: the collection file when it\n * spells it, else the first module of the collection's relative imports (followed\n * a few levels: a shared helper's own imports) whose source holds it as a string\n * literal. A relative path is relative to the module that wrote it — a shared\n * module one directory away names the same component with another path.\n */\nfunction componentWriter(entry: CollectionEntry, value: string): string {\n const spells = (text: string): boolean => text.includes(`\"${value}\"`) || text.includes(`'${value}'`) || text.includes(`\\`${value}\\``);\n if (spells(entry.sourceFile.getFullText())) return entry.file;\n const seen = new Set<string>([entry.file]);\n let frontier = [entry.file];\n for (let depth = 0; depth < 4 && frontier.length > 0; depth++) {\n const next: string[] = [];\n for (const file of frontier) {\n const text = file === entry.file ? entry.sourceFile.getFullText() : fs.readFileSync(file, \"utf8\");\n for (const match of text.matchAll(/(?:from|import)\\s*\\(?\\s*[\"'](\\.{1,2}\\/[^\"']+)[\"']/g)) {\n const target = resolveRelative(file, match[1]).target;\n if (seen.has(target) || !fs.existsSync(target) || !fs.statSync(target).isFile()) continue;\n seen.add(target);\n if (spells(fs.readFileSync(target, \"utf8\"))) return target;\n next.push(target);\n }\n }\n frontier = next;\n }\n return entry.file;\n}\n\n/** A lazy component thunk — `() => import(\"…\")`, optionally `.then(m => m.X)` — as the import it stands for. */\nfunction lazyImport(plan: PlanContext, node: Node): { specifier: string; imported: string } | undefined {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const fn = unwrap(plan.ast, node);\n if (!N.isArrowFunction(fn) || fn.getParameters().length > 0) return undefined;\n let body: Node = unwrap(plan.ast, fn.getBody());\n let imported = \"default\";\n if (N.isCallExpression(body) && N.isPropertyAccessExpression(body.getExpression()) && body.getExpression().getText().endsWith(\".then\")) {\n const then = body.getArguments()[0];\n if (!then || !N.isArrowFunction(then)) return undefined;\n const parameter = then.getParameters()[0]?.getName();\n const result = unwrap(plan.ast, then.getBody());\n if (N.isPropertyAccessExpression(result) && result.getExpression().getText() === parameter) {\n imported = result.getName();\n } else if (N.isObjectLiteralExpression(result)) {\n const property = result.getProperty(\"default\");\n const initializer = property && N.isPropertyAssignment(property) ? unwrap(plan.ast, property.getInitializerOrThrow()) : undefined;\n if (!initializer || !N.isPropertyAccessExpression(initializer) || initializer.getExpression().getText() !== parameter) return undefined;\n imported = initializer.getName();\n } else {\n return undefined;\n }\n const target: Node = body.getExpression();\n if (!N.isPropertyAccessExpression(target)) return undefined;\n body = unwrap(plan.ast, target.getExpression());\n }\n if (!N.isCallExpression(body) || body.getExpression().getKind() !== SyntaxKind.ImportKeyword) return undefined;\n const argument = body.getArguments()[0];\n if (!argument || !N.isStringLiteral(argument)) return undefined;\n return { specifier: argument.getLiteralValue(), imported };\n}\n\n/** Calls whose result differs from one load to the next: a value computed with one is not data. */\nconst LOAD_TIME_CALLS = /\\bnew\\s+Date\\s*\\(\\s*\\)|\\bDate\\.now\\s*\\(|\\bMath\\.random\\s*\\(|\\bprocess\\.env\\b|\\bimport\\.meta\\.env\\b|\\bcrypto\\.randomUUID\\s*\\(|\\bperformance\\.now\\s*\\(/;\n\n/** How close to the run a date must be to count as the run's clock (a preset of \"today\" lands within hours of it). */\nconst RUN_CLOCK_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;\n\n/** Whether an evaluated value holds a date read from the clock while the codemod loaded the config. */\nfunction holdsRunClock(value: unknown, depth = 0): boolean {\n if (depth > 8) return false;\n const now = Date.now();\n const near = (time: number): boolean => Number.isFinite(time) && Math.abs(time - now) < RUN_CLOCK_WINDOW_MS;\n if (value instanceof Date) return near(value.getTime());\n if (typeof value === \"string\") return /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}/.test(value) && near(Date.parse(value));\n if (typeof value === \"number\") return value > 1e12 && near(value);\n if (Array.isArray(value)) return value.some(item => holdsRunClock(item, depth + 1));\n if (isPlainObject(value)) return Object.values(value).some(item => holdsRunClock(item, depth + 1));\n return false;\n}\n\n/** Whether an expression is written out as data (no call, no reference: what it evaluates to is what it says). */\nfunction isLiteralExpression(plan: PlanContext, node: Node): boolean {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const current = unwrap(plan.ast, node);\n if (N.isStringLiteral(current) || N.isNumericLiteral(current) || N.isNoSubstitutionTemplateLiteral(current) || N.isObjectLiteralExpression(current) || N.isArrayLiteralExpression(current)) return true;\n const kind = current.getKind();\n if (kind === SyntaxKind.TrueKeyword || kind === SyntaxKind.FalseKeyword || kind === SyntaxKind.NullKeyword) return true;\n if (N.isPrefixUnaryExpression(current)) return N.isNumericLiteral(current.getOperand());\n return N.isIdentifier(current) && current.getText() === \"undefined\";\n}\n\n/**\n * A data value the config COMPUTED when it was loaded — `new Date()`, `Date.now()`,\n * `Math.random()`, an environment read, or a helper that read the clock — is not\n * data: printed as evaluated it would be frozen to the codemod's run. Where the\n * expression that computed it is found in the collection's literal, it is carried\n * as that SOURCE (its imports with it); where it cannot be attributed, it is left\n * out and a step names it.\n *\n * @returns `handled` with what to print when this value is decided here;\n * otherwise whether its source was attributed (no need to look again below it)\n */\nfunction loadTimeValue(plan: PlanContext, builder: Builder, value: unknown, segments: PathSegment[], label: string): { handled: true; printed: unknown } | { handled: false; attributed: boolean } {\n if (segments.length === 0) return { handled: false, attributed: false };\n const located = locate(plan, builder.entry, segments);\n const member = located.member;\n if (member && !member.method) {\n const valueNode = member.value ?? member.node;\n if (isLiteralExpression(plan, valueNode)) return { handled: false, attributed: false };\n const source = nodeText(valueNode);\n if (!LOAD_TIME_CALLS.test(source) && !holdsRunClock(value)) return { handled: false, attributed: true };\n builder.codeNodes.push(member.node);\n note(plan, builder.entry, `${label} is computed when the config loads (\\`${source.length > 80 ? `${source.slice(0, 77)}…` : source}\\`): carried as that expression, not as the value it had during the migration. It now runs in the panel, when the customization module loads.`);\n return { handled: true, printed: new RawSource(source) };\n }\n if (!holdsRunClock(value) || Array.isArray(value) || isPlainObject(value)) return { handled: false, attributed: false };\n plan.manualSteps.push({\n title: `Write ${label} of ${builder.name.table} by hand`,\n detail: `${label} held ${JSON.stringify(value)} when the codemod loaded the config — a date read from the clock at load time, whose source cannot be attributed (${located.reason ?? \"it was computed\"}). It was left out rather than frozen to the run's time. Write the expression that computes it in ${relativeToRoot(plan, builder.file)} under the same key.`,\n file: relativeToRoot(plan, builder.file)\n });\n return { handled: true, printed: undefined };\n}\n\n/**\n * A value as something printable: data as itself, code from its source.\n *\n * @param segments where the value is in the legacy literal, for finding a function's source\n */\nfunction printable(plan: PlanContext, builder: Builder, value: unknown, segments: PathSegment[], label: string, attributed = false): unknown {\n if (!isCode(value) && !attributed && value !== undefined) {\n const computed = loadTimeValue(plan, builder, value, segments, label);\n if (computed.handled) return computed.printed;\n attributed = computed.attributed;\n }\n if (isCode(value)) {\n const located = locate(plan, builder.entry, segments);\n if (!located.member) {\n // Spread in from one shared object (`...fixedOnceCreated`): carried as that object's member, its import with it.\n const spread = builder.entry.site ? spreadSource(plan.ast, builder.entry.site.literal, segments) : undefined;\n if (spread) {\n builder.codeNodes.push(spread.spread);\n return new RawSource(spread.text);\n }\n // Presentation code whose source cannot be attributed (a wrapper's output,\n // a member before a spread): the evaluated data around it is printed, the\n // function is left out, and a step says where it was — a form rule, not a\n // reason to block the migration.\n plan.manualSteps.push({\n title: `Add ${label} of ${builder.name.table} by hand`,\n detail: `${label} is a function the collection computed (${located.reason}), so its source cannot be carried; the rest of the customization is printed from the evaluated collection. Write it in the table's customization (${relativeToRoot(plan, builder.file)} — \\`customizeTable\\`, created by hand if the run wrote none) under the same key, from the code that produced it.`,\n file: relativeToRoot(plan, builder.file)\n });\n return undefined;\n }\n const member = located.member;\n const valueNode = member.value ?? member.node;\n const lazy = member.method ? undefined : lazyImport(plan, valueNode);\n if (lazy) {\n try {\n return importComponent(plan, builder, lazy.specifier, lazy.imported);\n } catch (error) {\n refuse(plan, builder.entry, error instanceof Error ? error.message : String(error), { key: segments.join(\".\") });\n builder.failed = true;\n return undefined;\n }\n }\n builder.codeNodes.push(member.node);\n return new RawSource(memberFunctionText(plan.ast, member));\n }\n if (typeof value === \"string\" && COMPONENT_KEYS.has(String(segments[segments.length - 1])) && (value.startsWith(\"./\") || value.startsWith(\"../\"))) {\n try {\n const imported = importComponent(plan, builder, value, \"default\", componentWriter(builder.entry, value));\n // By path, the component was loaded and never type-checked against\n // its slot. As an import it is, by the admin's own `tsc`: SongBuzz's\n // previews typed `customProps` as their own props type, which no\n // slot can hand them, and 37 errors appeared in a build the\n // migration had reported clean.\n note(plan, builder.entry, `${label} ${IMPORTED_COMPONENT_REMARK}`);\n return imported;\n } catch (error) {\n refuse(plan, builder.entry, error instanceof Error ? error.message : String(error), { key: segments.join(\".\") });\n builder.failed = true;\n return undefined;\n }\n }\n if (Array.isArray(value)) return value.map((item, index) => printable(plan, builder, item, [...segments, index], `${label}[${index}]`, attributed));\n if (isPlainObject(value)) {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined) continue;\n out[key] = printable(plan, builder, entry, [...segments, key], `${label}.${key}`, attributed);\n }\n return out;\n }\n return value;\n}\n\n/** The enum labels a field needs: only values whose label or colour is not the derived one. */\nexport function enumLabelsOf(values: LegacyEnumValues): Record<string, unknown> | undefined {\n const entries: { id: string | number; label?: string; color?: unknown; disabled?: boolean }[] = Array.isArray(values)\n ? values.map(value => ({ ...value }))\n : Object.entries(values).map(([id, value]) => (typeof value === \"string\" ? { id, label: value } : { ...value, id }));\n const out: Record<string, unknown> = {};\n for (const entry of entries) {\n const label = entry.label ?? String(entry.id);\n const derived = enumValueLabel(entry.id);\n const extra: Record<string, unknown> = {};\n if (entry.color !== undefined) extra.color = entry.color;\n if (entry.disabled !== undefined) extra.disabled = entry.disabled;\n if (Object.keys(extra).length > 0) out[String(entry.id)] = { label, ...extra };\n else if (label !== derived) out[String(entry.id)] = label;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** A property's `admin` block as field-customization keys. */\nfunction fieldAdmin(plan: PlanContext, builder: Builder, admin: Record<string, unknown>, segments: PathSegment[], target: Record<string, unknown>, label: string): void {\n for (const [key, value] of Object.entries(admin)) {\n if (value === undefined) continue;\n const destination = own(PROPERTY_ADMIN_DESTINATIONS, key);\n if (destination === undefined) {\n note(plan, builder.entry, `${label}.admin.${key} is not an admin option (nothing read it); not carried.`);\n continue;\n }\n if (typeof destination !== \"string\") {\n note(plan, builder.entry, `${label}.admin.${key} is not carried: ${destination.dropped}`);\n continue;\n }\n const printed = printable(plan, builder, value, [...segments, \"admin\", key], `${label}.admin.${key}`);\n if (key === \"disabled\" && isPlainObject(value) && value.hidden === true) {\n target.hiddenInForm = true;\n const { hidden: _hidden, ...rest } = isPlainObject(printed) ? printed : {};\n void _hidden;\n if (Object.keys(rest).length > 0) target.disabled = rest;\n continue;\n }\n target[destination] = printed;\n }\n}\n\n/** The collection `admin` block as `customizeTable` keys. */\nfunction collectionAdmin(plan: PlanContext, builder: Builder, admin: Record<string, unknown>): void {\n const options = builder.options;\n for (const [key, value] of Object.entries(admin)) {\n if (value === undefined) continue;\n const destination = own(COLLECTION_ADMIN_DESTINATIONS, key);\n if (destination === undefined) {\n note(plan, builder.entry, `admin.${key} is not an admin option (nothing read it); not carried.`);\n continue;\n }\n if (typeof destination !== \"string\") {\n note(plan, builder.entry, `admin.${key} is not carried: ${destination.dropped}`);\n continue;\n }\n const printed = printable(plan, builder, value, [\"admin\", key], `admin.${key}`);\n if (destination.includes(\".\")) {\n const path_ = destination.split(\".\");\n at(options, path_.slice(0, -1))[path_[path_.length - 1]] = printed;\n continue;\n }\n if (key === \"kanban\" && isPlainObject(printed)) {\n const kanban = at(options, [\"kanban\"]);\n for (const [kanbanKey, kanbanValue] of Object.entries(printed)) {\n kanban[own(KANBAN_DESTINATIONS, kanbanKey) ?? kanbanKey] = kanbanValue;\n }\n continue;\n }\n if (key === \"form\" && isPlainObject(printed) && Array.isArray(printed.sections)) {\n options.form = {\n ...printed,\n sections: printed.sections.map(section => {\n if (!isPlainObject(section) || !(\"properties\" in section)) return section;\n const { properties, ...rest } = section;\n const ordered: Record<string, unknown> = {};\n for (const [sectionKey, sectionValue] of Object.entries({ ...rest, fields: properties })) {\n ordered[sectionKey] = sectionValue;\n }\n return ordered;\n })\n };\n continue;\n }\n options[destination] = printed;\n }\n const kanban = options.kanban;\n if (isPlainObject(kanban) && kanban.columnField === undefined) {\n delete options.kanban;\n note(plan, builder.entry, \"admin.orderProperty has no kanban board to order (no `kanban.columnProperty`); `customizeTable` keeps the order field on the board, so it is not carried.\");\n }\n}\n\n/** The relation-tab overrides of a relation, flattened as `customizeTable` options. */\nfunction relationOverrides(plan: PlanContext, builder: Builder, value: unknown, segments: PathSegment[], label: string): Record<string, unknown> | undefined {\n if (!isPlainObject(value)) return undefined;\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined) continue;\n if (key === \"admin\" && isPlainObject(entry)) {\n for (const [adminKey, adminValue] of Object.entries(entry)) {\n const destination = own(COLLECTION_ADMIN_DESTINATIONS, adminKey);\n if (typeof destination !== \"string\" || destination.includes(\".\")) {\n note(plan, builder.entry, `${label}.admin.${adminKey} has no relation-tab option in \\`customizeTable\\`; not carried.`);\n continue;\n }\n out[destination] = printable(plan, builder, adminValue, [...segments, \"admin\", adminKey], `${label}.admin.${adminKey}`);\n }\n continue;\n }\n if (key === \"name\" || key === \"singularName\" || key === \"description\" || key === \"metadata\" || key === \"icon\") {\n out[key] = printable(plan, builder, entry, [...segments, key], `${label}.${key}`);\n continue;\n }\n note(plan, builder.entry, `${label}.${key} has no relation-tab option in \\`customizeTable\\`; not carried.`);\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** Where a relation's `overrides` are in the legacy literal. */\nfunction relationSegments(entry: CollectionEntry, key: string): PathSegment[] {\n const relations = \"relations\" in entry.collection && Array.isArray(entry.collection.relations) ? entry.collection.relations : [];\n const index = relations.findIndex(relation => (relation.relationName ?? \"\") === key);\n if (index >= 0) return [\"relations\", index, \"overrides\"];\n const stripped = key.endsWith(\"Relation\") ? key.slice(0, -\"Relation\".length) : key;\n return [\"properties\", stripped, \"relation\", \"overrides\"];\n}\n\n/** Apply one property-level note to the field it is about. */\nfunction applyFieldNote(plan: PlanContext, builder: Builder, item: LiftNote, fields: Record<string, unknown>): void {\n const key = item.key ?? \"\";\n const { literal, field } = noteKeySegments(key);\n const label = `properties.${key}`;\n if (item.kind === \"inert\" || item.kind === \"redundant\" || item.kind === \"derived\" || item.kind === \"meaning\") return;\n if (item.kind === \"unknown\") {\n note(plan, builder.entry, `${label}.${item.field} is not a field of the property model (nothing read it); not carried.`);\n return;\n }\n if (item.kind === \"renamed\") {\n plan.manualSteps.push({\n title: `Relation renamed in ${builder.name.table}`,\n detail: item.reason,\n file: relativeToRoot(plan, builder.name.file)\n });\n return;\n }\n if (item.field === \"overrides\") {\n const overrides = relationOverrides(plan, builder, item.value, relationSegments(builder.entry, key), `relations.${key}.overrides`);\n if (overrides) at(fields, [key]).overrides = overrides;\n return;\n }\n const target = at(fields, field);\n switch (item.field) {\n case \"name\":\n if (typeof item.value === \"string\" && item.value !== labelFromIdentifier(lastKey(key))) target.name = item.value;\n return;\n case \"admin\":\n if (isPlainObject(item.value)) fieldAdmin(plan, builder, item.value, literal, target, label);\n return;\n case \"enum\": {\n const constant = constantForEnum(plan.splitConstants ?? [], builder.entry.file, item.value);\n if (constant?.frontendFile) {\n const specifier = generatedSpecifier(builder.file, constant.frontendFile, plan.specifierStyle);\n builder.libImports.set(specifier, new Set([...(builder.libImports.get(specifier) ?? []), constant.labelsName]));\n target.enumLabels = new RawSource(constant.labelsName);\n return;\n }\n const labels = enumLabelsOf(item.value as LegacyEnumValues);\n if (labels) target.enumLabels = labels;\n return;\n }\n case \"propertiesOrder\":\n target[String(PROPERTY_FIELD_DESTINATIONS.propertiesOrder)] = item.value;\n return;\n case \"defaultValue\": {\n // A relation's pre-fill: `new EntityRelation(…)` objects, which are\n // printed from their source (a class instance has no literal), its\n // imports carried.\n const located = locate(plan, builder.entry, [...literal, \"defaultValue\"]);\n if (!located.member) {\n note(plan, builder.entry, `${label}.defaultValue is not carried: its source could not be found (${located.reason ?? \"unknown\"}). Write it as \\`fields.${key}.defaultValue\\` in the customization.`);\n return;\n }\n builder.codeNodes.push(located.member.node);\n target.defaultValue = new RawSource(memberFunctionText(plan.ast, located.member));\n return;\n }\n case \"storage.storagePath\":\n at(target, [\"storage\"]).path = printable(plan, builder, item.value, [...literal, \"storage\", \"storagePath\"], `${label}.storage.storagePath`);\n return;\n case \"storage.processFile\":\n case \"storage.postProcess\":\n case \"storage.previewUrl\":\n case \"storage.fileName\": {\n const name = item.field.slice(\"storage.\".length);\n at(target, [\"storage\"])[name] = printable(plan, builder, item.value, [...literal, \"storage\", name], `${label}.storage.${name}`);\n return;\n }\n default:\n break;\n }\n const destination = own(PROPERTY_FIELD_DESTINATIONS, item.field);\n if (destination !== undefined && typeof destination !== \"string\") {\n note(plan, builder.entry, `${label}.${item.field} is not carried: ${destination.dropped}`);\n return;\n }\n if (destination !== undefined) {\n target[destination] = printable(plan, builder, item.value, [...literal, item.field], `${label}.${item.field}`);\n if (item.field === \"dynamicProps\" && target[destination] !== undefined && flattenDynamicProps(plan, builder, target, destination, [...literal, item.field])) return;\n if (item.field === \"dynamicProps\" && target[destination] !== undefined) {\n plan.manualSteps.push({\n title: `Check fields.${key}.dynamicProps of ${builder.name.table}`,\n detail: \"`dynamicProps` returns a field customization now (flat keys: `hidden`, `fieldOrder`, …), not a partial property with an `admin` block. Check what it returns.\",\n file: relativeToRoot(plan, builder.file)\n });\n }\n return;\n }\n note(plan, builder.entry, `${label}.${item.field}: ${item.reason} \\`customizeTable\\` has no option for it; not carried.`);\n}\n\n/**\n * A `dynamicProps` builder carried into a customization, its returns rewritten\n * to 0.31's flat shape (see `dynamic-props.ts`): in the printed function when\n * it was written inline, in the defining module (its copy, or in place) when\n * it came from a spread of a shared object. True when nothing is left to\n * check by hand.\n */\nfunction flattenDynamicProps(plan: PlanContext, builder: Builder, target: Record<string, unknown>, destination: string, segments: PathSegment[]): boolean {\n const { Node: N } = plan.ast.tsm;\n const printed = target[destination];\n if (!(printed instanceof RawSource)) return false;\n const located = locate(plan, builder.entry, segments);\n if (located.member) {\n // Written inline: rewrite the printed text (a scratch file of it, so a `const` it reads is not in scope and refuses).\n const scratch = plan.ast.project.createSourceFile(`/__rebase_migrate__/dynamic-props-${builder.name.identifier}.ts`, `const __builder = ${printed.text};`, { overwrite: true });\n try {\n const fn = unwrap(plan.ast, scratch.getVariableDeclarationOrThrow(\"__builder\").getInitializerOrThrow());\n const rewrite = rewriteDynamicProps(plan.ast, fn, scratch, [fn]);\n if (!rewrite.edits) return false;\n const offset = \"const __builder = \".length;\n let text = printed.text;\n for (const edit of [...rewrite.edits].sort((a, b) => b.start - a.start)) text = text.slice(0, edit.start - offset) + edit.text + text.slice(edit.end - offset);\n target[destination] = new RawSource(text);\n return true;\n } finally {\n plan.ast.project.removeSourceFile(scratch);\n }\n }\n const spread = builder.entry.site ? spreadSource(plan.ast, builder.entry.site.literal, segments) : undefined;\n if (!spread) return false;\n const owner = findLiteral(plan, spread.spread);\n if (!owner.literal) return false;\n const member = memberOf(plan.ast, owner.literal, \"dynamicProps\");\n const fn = member.node ? (member.node.method ?? (member.node.value ? unwrap(plan.ast, member.node.value) : undefined)) : undefined;\n if (!fn || !(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isMethodDeclaration(fn))) return false;\n const sf = fn.getSourceFile();\n const rewrite = rewriteDynamicProps(plan.ast, fn, sf);\n if (!rewrite.edits) return false;\n if (rewrite.edits.length > 0) {\n plan.relocator.addSourceEdits(sf.getFilePath(), rewrite.edits);\n if (!plan.relocator.isInCollections(sf.getFilePath())) plan.relocator.keptFrontendModules.add(sf.getFilePath());\n }\n return true;\n}\n\n/**\n * `auth.actions` of an auth collection: `resetPassword: false` takes the\n * panel's reset-password action away, an action replaces it — both\n * `customizeTable`'s `resetPasswordAction` now. `true` is the default.\n */\nfunction authActions(plan: PlanContext, builder: Builder, value: unknown): void {\n if (!isPlainObject(value)) {\n note(plan, builder.entry, \"auth.actions is not an object of actions; not carried.\");\n return;\n }\n for (const [key, entry] of Object.entries(value)) {\n if (key !== \"resetPassword\") {\n note(plan, builder.entry, `auth.actions.${key} is not an auth action (nothing read it); not carried.`);\n continue;\n }\n if (entry === undefined || entry === true) continue;\n builder.options.resetPasswordAction = entry === false\n ? false\n : printable(plan, builder, entry, [\"auth\", \"actions\", \"resetPassword\"], \"auth.actions.resetPassword\");\n }\n}\n\n/** Apply one collection-level note. */\nfunction applyCollectionNote(plan: PlanContext, builder: Builder, item: LiftNote): void {\n const options = builder.options;\n const derivedName = labelFromIdentifier(builder.name.table);\n switch (item.field) {\n case \"name\":\n if (typeof item.value === \"string\" && item.value !== derivedName) options.name = item.value;\n return;\n case \"singularName\":\n if (typeof item.value === \"string\" && item.value !== singularLabel(derivedName)) options.singularName = item.value;\n return;\n case \"icon\":\n options.icon = printable(plan, builder, item.value, [\"icon\"], \"icon\");\n return;\n case \"admin\":\n if (isPlainObject(item.value)) collectionAdmin(plan, builder, item.value);\n return;\n case \"ownerId\":\n return;\n case \"auth.actions\":\n authActions(plan, builder, item.value);\n return;\n case \"childCollections\":\n plan.manualSteps.push({\n title: `Child collections of ${builder.name.table}`,\n detail: \"`childCollections` has no `customizeTable` equivalent. A table's `rel.hasMany` / `rel.manyToMany` relations are shown as tabs on its records: declare the relation on the table instead.\",\n file: relativeToRoot(plan, builder.entry.file)\n });\n return;\n default:\n break;\n }\n if (item.kind === \"inert\" || item.kind === \"redundant\" || item.kind === \"derived\" || item.kind === \"meaning\") return;\n if (item.kind === \"unknown\") {\n note(plan, builder.entry, `${item.field} is not a field of the collection model (nothing read it); not carried.`);\n return;\n }\n note(plan, builder.entry, `${item.field}: ${item.reason} \\`customizeTable\\` has no option for it; not carried.`);\n}\n\n/** The order the customization's top-level keys are written in. */\nconst OPTION_ORDER = [\"name\", \"singularName\", \"description\", \"icon\", \"group\"];\n\nfunction orderedOptions(options: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of OPTION_ORDER) if (options[key] !== undefined) out[key] = options[key];\n for (const [key, value] of Object.entries(options)) if (key !== \"fields\" && out[key] === undefined && value !== undefined) out[key] = value;\n if (isPlainObject(options.fields) && Object.keys(options.fields).length > 0) out.fields = options.fields;\n return out;\n}\n\n/** Remove empty objects a note path created without filling. */\nfunction prune(value: unknown): unknown {\n if (!isPlainObject(value)) return value;\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const pruned = prune(entry);\n if (pruned === undefined || (isPlainObject(pruned) && Object.keys(pruned).length === 0)) continue;\n out[key] = pruned;\n }\n return out;\n}\n\n/**\n * The relations the lift renamed in one collection, old key → new key: a\n * belongsTo that served its foreign key under its own key is `<key>Relation`\n * now, and the column keeps the key.\n */\nfunction relationRenames(notes: readonly LiftNote[], slug: string): Map<string, string> {\n const out = new Map<string, string>();\n for (const item of notes) {\n if (item.collection !== slug || item.kind !== \"renamed\" || item.key === undefined) continue;\n out.set(item.key, `${String(item.value)}Relation`);\n }\n return out;\n}\n\n/** The presentation options that name fields by key, as lists. */\nconst FIELD_LIST_OPTIONS = [\"listFields\", \"previewFields\", \"fieldOrder\"] as const;\n\n/**\n * Point the presentation of a renamed relation at its new key.\n *\n * The panel draws the relation in the column's place (the projection replaces\n * a belongsTo's foreign-key column with the relation), so a customization that\n * still names the column's key labels, lists and titles a field the panel does\n * not have: every entry is skipped with a development warning. What the\n * legacy property said — its name, its column in the list, the title it gave\n * the record — is said of the relation.\n */\nfunction renameRelationKeys(options: Record<string, unknown>, renames: ReadonlyMap<string, string>): void {\n if (renames.size === 0) return;\n const renameList = (value: unknown): unknown =>\n Array.isArray(value) ? value.map(entry => (typeof entry === \"string\" ? renames.get(entry) ?? entry : entry)) : value;\n const fields = options.fields;\n if (isPlainObject(fields)) {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(fields)) {\n const renamed = renames.get(key);\n out[renamed !== undefined && !(renamed in fields) ? renamed : key] = value;\n }\n options.fields = out;\n }\n for (const key of FIELD_LIST_OPTIONS) if (options[key] !== undefined) options[key] = renameList(options[key]);\n const display = options.display;\n if (isPlainObject(display)) {\n for (const [slot, source] of Object.entries(display)) {\n if (typeof source === \"string\" && renames.has(source)) display[slot] = renames.get(source);\n }\n }\n const form = options.form;\n if (isPlainObject(form)) {\n if (form.sidebar !== undefined) form.sidebar = renameList(form.sidebar);\n if (Array.isArray(form.sections)) {\n for (const section of form.sections) if (isPlainObject(section) && section.fields !== undefined) section.fields = renameList(section.fields);\n }\n }\n}\n\n/** What {@link planCustomizations} wrote, for the index and `App.tsx`. */\nexport interface CustomizationOutput {\n /** The exported identifier and module of each customization, in the order given. */\n modules: { identifier: string; file: string; slug: string }[];\n}\n\n/**\n * Plan one `customizeTable` module per collection with non-default\n * presentation.\n *\n * @param notes the lift's `notCarried`\n * @param cmsDir `frontend/src/cms`, absolute\n */\nexport function planCustomizations(\n plan: PlanContext,\n entries: readonly CollectionEntry[],\n names: ReadonlyMap<string, TableName>,\n notes: readonly LiftNote[],\n cmsDir: string\n): CustomizationOutput {\n const modules: CustomizationOutput[\"modules\"] = [];\n for (const entry of entries) {\n const name = names.get(entry.collection.slug);\n if (!name) continue;\n const file = path.join(cmsDir, `${path.basename(name.file, \".ts\")}.tsx`);\n const builder: Builder = { entry, name, file, options: {}, codeNodes: [], componentImports: new Map(), libImports: new Map(), failed: false };\n const fields: Record<string, unknown> = {};\n for (const item of notes) {\n if (item.collection !== entry.collection.slug) continue;\n if (item.key === undefined) applyCollectionNote(plan, builder, item);\n else applyFieldNote(plan, builder, item, fields);\n }\n builder.options.fields = prune(fields);\n renameRelationKeys(builder.options, relationRenames(notes, entry.collection.slug));\n const options = orderedOptions(prune(builder.options) as Record<string, unknown>);\n if (builder.failed || Object.keys(options).length === 0) continue;\n const content = printModule(plan, builder, options);\n if (content === undefined) continue;\n planFile(plan, file, content, `customization ${name.table}`);\n modules.push({ identifier: `${name.identifier}Cms`, file, slug: entry.collection.slug });\n }\n return { modules };\n}\n\nfunction printModule(plan: PlanContext, builder: Builder, options: Record<string, unknown>): string | undefined {\n const { entry, name, file } = builder;\n const exclude: Statement[] = entry.site ? entry.site.statements : [];\n const references = collectReferences(plan.ast, builder.codeNodes, exclude);\n if (references.forbidden.length > 0) {\n for (const forbidden of references.forbidden) {\n refuse(plan, entry, `presentation code references \\`${forbidden.name}\\`, the collection itself, which does not exist after the migration.`, { line: forbidden.line });\n }\n return undefined;\n }\n const identifier = `${name.identifier}Cms`;\n const taken = new Set([\"customizeTable\", name.identifier, identifier, ...builder.componentImports.keys()]);\n const clashes = references.imports.map(use => use.local).filter(local => taken.has(local));\n if (clashes.length > 0) {\n refuse(plan, entry, `presentation code binds ${clashes.map(clash => `\\`${clash}\\``).join(\", \")}, which the customization module also binds. Rename it and run the codemod again.`);\n return undefined;\n }\n let carriedImports: string[];\n let statements: string[];\n try {\n carriedImports = importLines(references.imports, use => plan.relocator.relocate(use.specifier, use.fromFile, file, \"frontend\"));\n statements = references.statements.map(statement => {\n const text = nodeText(statement);\n return text.includes(\"import(\") ? plan.relocator.moveSpecifiersInText(text, entry.file, file, \"frontend\") : text;\n });\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return undefined;\n }\n const componentLines = [...builder.componentImports].map(([local, { specifier, imported }]) =>\n imported === \"default\" ? `import ${local} from ${JSON.stringify(specifier)};` : `import { ${imported === local ? local : `${imported} as ${local}`} } from ${JSON.stringify(specifier)};`);\n const imports = [\n `import { customizeTable } from \"@rebasepro/cms\";`,\n `import type { ${name.identifier} } from ${JSON.stringify(generatedSpecifier(file, name.file, plan.specifierStyle))};`,\n ...componentLines,\n ...[...builder.libImports].map(([specifier, imported]) => `import { ${[...imported].join(\", \")} } from ${JSON.stringify(specifier)};`),\n ...carriedImports\n ];\n // A column list naming an additional field: the key is branded, as the type asks\n // (`\"score\" as AdditionalFieldKey` — a bare string is not a column id).\n if (brandAdditionalFieldKeys(options)) imports.push(`import type { AdditionalFieldKey } from \"@rebasepro/cms-types\";`);\n let body: string;\n try {\n body = printValue(options, \"\", \"options\");\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return undefined;\n }\n const call = `export const ${identifier} = customizeTable<typeof ${name.identifier}>(${JSON.stringify(entry.collection.slug)}, ${body});`;\n return `${[imports.join(\"\\n\"), ...statements, call].join(\"\\n\\n\")}\\n`;\n}\n\n/**\n * Brand the entries of `fieldOrder` / `listFields` that name one of the\n * customization's `additionalFields`: `TableColumnId` accepts a field path, a\n * relation tab, or an `AdditionalFieldKey`, and the key's documented spelling is\n * `\"key\" as AdditionalFieldKey` (the brand is required, so a typo does not pass).\n *\n * @returns whether any entry was branded (the module then imports the type)\n */\nexport function brandAdditionalFieldKeys(options: Record<string, unknown>): boolean {\n const fields = options.additionalFields;\n const keys = new Set((Array.isArray(fields) ? fields : []).flatMap(field => (isPlainObject(field) && typeof field.key === \"string\" ? [field.key] : [])));\n if (keys.size === 0) return false;\n let branded = false;\n for (const list of [\"fieldOrder\", \"listFields\"]) {\n const value = options[list];\n if (!Array.isArray(value)) continue;\n options[list] = value.map(item => {\n if (typeof item !== \"string\" || !keys.has(item)) return item;\n branded = true;\n return new RawSource(`${JSON.stringify(item)} as AdditionalFieldKey`);\n });\n }\n return branded;\n}\n\n/** `frontend/src/cms/index.ts`: the customizations in navigation order, and the external collections. */\nexport function printCmsIndex(\n cmsDir: string,\n customizations: readonly { identifier: string; file: string }[],\n external: readonly { identifier: string; file: string }[],\n style: GeneratedSpecifierStyle\n): string {\n const lines: string[] = [];\n const indexFile = path.join(cmsDir, \"index.ts\");\n const specifier = (file: string): string => JSON.stringify(generatedSpecifier(indexFile, file, style));\n for (const module of customizations) lines.push(`import { ${module.identifier} } from ${specifier(module.file)};`);\n // A Firestore collection file keeps its default export, as it was written.\n for (const module of external) lines.push(`import ${module.identifier} from ${specifier(module.file)};`);\n if (lines.length > 0) lines.push(\"\");\n lines.push(\"/** The table customizations, in the order the panel lists them. */\");\n lines.push(`export const tableCustomizations = [${customizations.map(module => module.identifier).join(\", \")}];`);\n if (external.length > 0) {\n lines.push(\"\");\n lines.push(\"/** Collections whose rows live outside the Postgres backend. */\");\n lines.push(`export const externalCollections = [${external.map(module => module.identifier).join(\", \")}];`);\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * `engine: \"firestore\"` collections → `defineFirestoreCollection(...)` in the\n * CMS (`frontend/src/cms/<name>.ts`).\n *\n * A Firestore collection is not a table, so nothing is lifted: the file is\n * moved and rewritten in place, which keeps every function, comment and\n * import exactly as written. What changes is the shape `@rebasepro/firebase`\n * takes — `properties` is `fields`, a reference names its collection with\n * `target` instead of `path`, there is no `engine` — and the wrapper\n * (`defineFirestoreCollection` instead of `defineCollection` or a typed\n * literal).\n */\nimport path from \"node:path\";\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\n\nimport { findCollectionSite, memberOf, resolveArray, resolveObject } from \"./ast\";\nimport { COMPONENT_KEYS } from \"./customization\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { planFile, refuse, relativeToRoot } from \"./plan-context\";\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n}\n\n/**\n * Rename `path` → `target` on every reference field of a literal fields map, recursively.\n * `renamed` collects the key path of each reference renamed (`store`, `lines.of.product`).\n */\nfunction referenceEdits(plan: PlanContext, fields: ObjectLiteralExpression, edits: Edit[], renamed: Set<string>, prefix = \"\"): void {\n const { Node: N } = plan.ast.tsm;\n for (const member of fields.getProperties()) {\n if (!N.isPropertyAssignment(member)) continue;\n const field = resolveObject(plan.ast, member.getInitializer()).node;\n if (!field || field.getSourceFile() !== fields.getSourceFile()) continue;\n visitField(plan, field, edits, renamed, `${prefix}${member.getName().replace(/^[\"']|[\"']$/g, \"\")}`);\n }\n}\n\nfunction visitField(plan: PlanContext, field: ObjectLiteralExpression, edits: Edit[], renamed: Set<string>, key: string): void {\n const { Node: N } = plan.ast.tsm;\n const type = memberOf(plan.ast, field, \"type\").node?.value;\n const typeText = type && N.isStringLiteral(type) ? type.getLiteralValue() : undefined;\n if (typeText === \"reference\") {\n const pathMember = memberOf(plan.ast, field, \"path\").node;\n if (pathMember && N.isPropertyAssignment(pathMember.node)) {\n const nameNode = pathMember.node.getNameNode();\n edits.push({ start: nameNode.getStart(), end: nameNode.getEnd(), text: \"target\" });\n renamed.add(key);\n }\n }\n for (const nested of [\"properties\", \"of\"] as const) {\n const value = memberOf(plan.ast, field, nested).node?.value;\n const object = value ? resolveObject(plan.ast, value).node : undefined;\n if (!object || object.getSourceFile() !== field.getSourceFile()) continue;\n if (nested === \"properties\") referenceEdits(plan, object, edits, renamed, `${key}.`);\n else visitField(plan, object, edits, renamed, `${key}.of`);\n }\n const oneOf = memberOf(plan.ast, field, \"oneOf\").node?.value;\n const oneOfObject = oneOf ? resolveObject(plan.ast, oneOf).node : undefined;\n const variants = oneOfObject ? memberOf(plan.ast, oneOfObject, \"properties\").node?.value : undefined;\n const variantsObject = variants ? resolveObject(plan.ast, variants).node : undefined;\n if (variantsObject) referenceEdits(plan, variantsObject, edits, renamed, `${key}.oneOf.`);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Every reference field of the EVALUATED collection that still sets `path`,\n * by key path (the same paths {@link referenceEdits} records), with the path.\n */\nfunction evaluatedReferences(properties: unknown, prefix = \"\", out = new Map<string, string>()): Map<string, string> {\n if (!isRecord(properties)) return out;\n for (const [name, field] of Object.entries(properties)) visitEvaluated(field, `${prefix}${name}`, out);\n return out;\n}\n\nfunction visitEvaluated(field: unknown, key: string, out: Map<string, string>): void {\n if (!isRecord(field)) return;\n if (field.type === \"reference\" && \"path\" in field) out.set(key, String(field.path));\n evaluatedReferences(field.properties, `${key}.`, out);\n visitEvaluated(field.of, `${key}.of`, out);\n if (isRecord(field.oneOf)) evaluatedReferences(field.oneOf.properties, `${key}.oneOf.`, out);\n}\n\n/** Marks the edits of {@link brandAdditionalFieldEntries}, so the module imports the type. */\nconst BRANDED = \" as AdditionalFieldKey\";\n\n/**\n * `propertiesOrder` / `listProperties` entries naming one of the collection's\n * `additionalFields`: written `\"key\" as AdditionalFieldKey`, the spelling\n * `ColumnKey` requires of a key that is not a property (a bare string does not\n * type-check under `defineFirestoreCollection`).\n */\nfunction brandAdditionalFieldEntries(plan: PlanContext, entry: CollectionEntry, literal: ObjectLiteralExpression, edits: Edit[]): void {\n const { Node: N } = plan.ast.tsm;\n const collection: unknown = entry.collection;\n const admin: unknown = isRecord(collection) ? collection.admin : undefined;\n const fields: unknown = (isRecord(collection) ? collection.additionalFields : undefined) ?? (isRecord(admin) ? admin.additionalFields : undefined);\n const keys = new Set((Array.isArray(fields) ? fields : []).flatMap((field: unknown) => (isRecord(field) && typeof field.key === \"string\" ? [field.key] : [])));\n if (keys.size === 0) return;\n const holders: ObjectLiteralExpression[] = [literal];\n const adminValue = memberOf(plan.ast, literal, \"admin\").node?.value;\n const adminObject = adminValue ? resolveObject(plan.ast, adminValue).node : undefined;\n if (adminObject && adminObject.getSourceFile() === literal.getSourceFile()) holders.push(adminObject);\n for (const holder of holders) {\n for (const name of [\"propertiesOrder\", \"listProperties\"]) {\n const value = memberOf(plan.ast, holder, name).node?.value;\n const array = value ? resolveArray(plan.ast, value).node : undefined;\n if (!array || array.getSourceFile() !== literal.getSourceFile()) continue;\n for (const element of array.getElements()) {\n if (!N.isStringLiteral(element) || !keys.has(element.getLiteralValue())) continue;\n edits.push({ start: element.getEnd(), end: element.getEnd(), text: BRANDED });\n }\n }\n }\n}\n\n/** The edits that turn the collection literal into `defineFirestoreCollection`'s argument and wrap it. */\nfunction literalEdits(plan: PlanContext, sf: SourceFile, entry: CollectionEntry, destination: string): Edit[] | undefined {\n const { Node: N } = plan.ast.tsm;\n const site = findCollectionSite(plan.ast, sf);\n if (!site.node) {\n refuse(plan, entry, `is a Firestore collection whose literal the codemod cannot find: ${site.reason}.`);\n return undefined;\n }\n const literal = site.node.literal;\n const edits: Edit[] = [];\n for (const member of literal.getProperties()) {\n if (N.isSpreadAssignment(member)) {\n refuse(plan, entry, `is a Firestore collection whose literal spreads \\`${member.getExpression().getText()}\\` (line ${member.getStartLineNumber()}); its \\`properties\\` and \\`engine\\` cannot be rewritten through a spread. Write them in the literal.`);\n return undefined;\n }\n }\n const engine = memberOf(plan.ast, literal, \"engine\").node;\n if (engine) {\n const node = engine.node;\n const text = sf.getFullText();\n let end = node.getEnd();\n if (text[end] === \",\") end += 1;\n const start = node.getFullStart();\n edits.push({ start, end, text: \"\" });\n }\n const properties = memberOf(plan.ast, literal, \"properties\").node;\n if (!properties) {\n refuse(plan, entry, \"is a Firestore collection with no `properties` the codemod can read.\");\n return undefined;\n }\n if (N.isPropertyAssignment(properties.node)) {\n const nameNode = properties.node.getNameNode();\n edits.push({ start: nameNode.getStart(), end: nameNode.getEnd(), text: \"fields\" });\n } else if (N.isShorthandPropertyAssignment(properties.node)) {\n edits.push({ start: properties.node.getStart(), end: properties.node.getEnd(), text: `fields: ${properties.node.getText()}` });\n }\n const fields = resolveObject(plan.ast, properties.value).node;\n const renamed = new Set<string>();\n if (fields && fields.getSourceFile() === sf) referenceEdits(plan, fields, edits, renamed);\n // A reference written outside the literal (a shared module, a helper's return\n // value, a spread of another collection's properties) is not renamed here, and\n // `defineFirestoreCollection` throws at import on its `path`: name each one.\n const outside = [...evaluatedReferences(entry.collection.properties)].filter(([key]) => !renamed.has(key));\n if (outside.length > 0) {\n plan.manualSteps.push({\n title: `Rename path → target in the references of ${entry.collection.slug} written outside its literal`,\n detail: `\\`defineFirestoreCollection\\` throws at import on a reference field that sets \\`path\\` (\"sets \\`path\\`… write target instead\"). ` +\n `These reference fields of ${entry.collection.slug} come from outside the collection's literal — a shared module, a helper's return value, or a spread of another collection's \\`properties\\` — so the codemod did not rename them: ` +\n outside.map(([key, target]) => `fields.${key} (path \"${target}\")`).join(\", \") +\n \". Rename `path` → `target` where each is written. A value read from another converted collection's `properties` is the run-time shape, which carries `path`: spread that collection's `fields` (export them) instead.\",\n file: relativeToRoot(plan, destination)\n });\n }\n\n brandAdditionalFieldEntries(plan, entry, literal, edits);\n\n // The wrapper.\n let parent: Node | undefined = literal.getParent();\n while (parent && (N.isAsExpression(parent) || N.isSatisfiesExpression(parent) || N.isParenthesizedExpression(parent))) parent = parent.getParent();\n if (parent && N.isCallExpression(parent)) {\n const callee = parent.getExpression();\n edits.push({ start: callee.getStart(), end: callee.getEnd(), text: \"defineFirestoreCollection\" });\n const typeArguments = parent.getTypeArguments();\n if (typeArguments.length > 0) {\n const first = typeArguments[0];\n const last = typeArguments[typeArguments.length - 1];\n edits.push({ start: first.getStart() - 1, end: last.getEnd() + 1, text: \"\" });\n }\n } else {\n edits.push({ start: literal.getStart(), end: literal.getStart(), text: \"defineFirestoreCollection(\" });\n edits.push({ start: literal.getEnd(), end: literal.getEnd(), text: \")\" });\n if (parent && N.isVariableDeclaration(parent)) {\n const typeNode = parent.getTypeNode();\n if (typeNode) edits.push({ start: parent.getNameNode().getEnd(), end: typeNode.getEnd(), text: \"\" });\n }\n }\n return edits;\n}\n\n/**\n * Plan the move of one Firestore collection file.\n *\n * @param destination where the module goes; `<cmsDir>/<file name>` by default\n * @returns the new module and the identifier its default export can be imported as\n */\nexport function planFirestoreCollection(plan: PlanContext, entry: CollectionEntry, cmsDir: string, destination = path.join(cmsDir, path.basename(entry.file))): { file: string; identifier: string } | undefined {\n const text = entry.sourceFile.getFullText();\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/firestore-${path.basename(entry.file)}`, text, { overwrite: true });\n try {\n const edits = literalEdits(plan, sf, entry, destination);\n if (!edits) return undefined;\n const { Node: N } = plan.ast.tsm;\n // Drop `defineCollection` from its import, and import the new wrapper.\n for (const declaration of sf.getImportDeclarations()) {\n for (const specifier of declaration.getNamedImports()) {\n if (specifier.getName() !== \"defineCollection\") continue;\n const named = declaration.getNamedImports();\n if (named.length === 1 && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) {\n // The statement and its line break; its leading comments stay (they may be the file's header).\n const end = sf.getFullText()[declaration.getEnd()] === \"\\n\" ? declaration.getEnd() + 1 : declaration.getEnd();\n edits.push({ start: declaration.getStart(), end, text: \"\" });\n } else {\n const end = sf.getFullText()[specifier.getEnd()] === \",\" ? specifier.getEnd() + 1 : specifier.getEnd();\n edits.push({ start: specifier.getStart(), end, text: \"\" });\n }\n }\n }\n // A component named by its module path (`Field: \"../../src/X\"`, which 0.30's Vite plugin\n // loaded lazily) is imported by value: 0.31 takes the component itself.\n const componentImports = new Map<string, string>();\n const taken = new Set(sf.getDescendantsOfKind(plan.ast.tsm.SyntaxKind.Identifier).map(identifier => identifier.getText()));\n for (const literal of sf.getDescendantsOfKind(plan.ast.tsm.SyntaxKind.StringLiteral)) {\n // `Field: \"../X\"`, or the same path cast to the any type (how 0.30 code got a path past the component type).\n const written: Node = N.isAsExpression(literal.getParent()) ? literal.getParentOrThrow() : literal;\n const parent = written.getParent();\n if (!N.isPropertyAssignment(parent) || parent.getInitializer() !== written || !COMPONENT_KEYS.has(parent.getName())) continue;\n const value = literal.getLiteralValue();\n if (!value.startsWith(\"./\") && !value.startsWith(\"../\")) continue;\n let local = componentImports.get(value);\n if (!local) {\n const stem = path.basename(value).replace(/\\.(tsx?|jsx?)$/, \"\");\n const base = stem.split(/[^A-Za-z0-9]+/).filter(Boolean).map(word => word[0].toUpperCase() + word.slice(1)).join(\"\") || \"Component\";\n local = base;\n for (let counter = 2; taken.has(local); counter++) local = `${base}${counter}`;\n taken.add(local);\n componentImports.set(value, local);\n }\n edits.push({ start: written.getStart(), end: written.getEnd(), text: local });\n }\n const imports = sf.getImportDeclarations();\n const insertAt = imports.length > 0 ? imports[0].getStart() : 0;\n const componentLines = [...componentImports].map(([specifier, local]) => `import ${local} from ${JSON.stringify(specifier)};\\n`).join(\"\");\n const brandImport = edits.some(edit => edit.text === BRANDED) ? `import type { AdditionalFieldKey } from \"@rebasepro/cms-types\";\\n` : \"\";\n edits.push({ start: insertAt, end: insertAt, text: `import { defineFirestoreCollection } from \"@rebasepro/firebase\";\\n${brandImport}${componentLines}` });\n let out = text;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n out = plan.relocator.moveSpecifiersInText(out, entry.file, destination, \"frontend\");\n planFile(plan, destination, out, `firestore collection ${entry.collection.slug}`);\n const site = findCollectionSite(plan.ast, entry.sourceFile);\n const binding = site.node?.binding;\n return { file: destination, identifier: binding ?? `${entry.collection.slug.replace(/[^A-Za-z0-9]+(.)?/g, (_, next: string | undefined) => (next ?? \"\").toUpperCase())}Collection` };\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return undefined;\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n}\n","/**\n * What changed in 0.31 beyond the kernel moves, in the spellings a project's\n * own code can hold: exports renamed or removed outside `@rebasepro/types` /\n * `@rebasepro/common`, call options, environment variables, route paths, tool\n * names. `rebase migrate sdk-calls` reads it (`moved-imports.ts`).\n *\n * The kernel moves are not here: they are generated from the headless guard's\n * JSON into `moved-symbols.generated.ts`, and a row there wins over a row here\n * for the same name and package.\n *\n * - A row of {@link EXPORT_CHANGES} with `to` set is rewritten: the meaning is\n * the same and only the spelling (or the package) changed.\n * - A row with `to: null` is not rewritten — the export is gone, or it still\n * exists but takes or returns something different — so the codemod finds\n * the import and prints a manual step with `instead` and the upgrade-guide\n * section.\n * - {@link CALL_OPTION_CHANGES} and {@link CODE_SPELLINGS} are detected the\n * same way, never rewritten.\n *\n * The list is the diff of every package's root exports between 0.30.1 and\n * this release, and the upgrade guide's sections; the coverage of each\n * Breaking entry is recorded in the slice notes. The test\n * (`moved-imports.test.ts`) holds every renamed name to an export of its\n * package today and every `guide` to a heading of the upgrade guide.\n */\nimport type { MovedSymbol } from \"./types\";\n\n/** The upgrade guide this release's manual steps point into. */\nexport const UPGRADE_GUIDE = \"https://rebase.pro/docs/upgrading/0-30-to-0-31/\";\n\n/** Sections of the upgrade guide, by number: the anchor of each heading. */\nexport const GUIDE = {\n tables: \"#108-tables-in-backendschema-replace-configcollections--run-the-codemod-first\",\n configPackage: \"#109-there-is-no-config-package\",\n bootOptions: \"#110-boot-options-and-hooks-name-tables\",\n adminPanel: \"#111-the-admin-panel-renders-the-tables-the-server-serves\",\n sdk: \"#115-the-sdk-addresses-a-table-datatableslug\",\n cliFlags: \"#116-cli-flags---schema-dir-not---collections\",\n schemaEditor: \"#117-the-schema-editor-edits-backendschema-with-tablepatch\",\n componentSlot: \"#118-a-component-slot-is-a-component\",\n uiPreferences: \"#119-panel-preferences-are-ui-preferences\",\n mongo: \"#120-mongodb-is-retired\",\n mcp: \"#122-mcp-tools-are-named-for-tables\",\n rlsCheck: \"#125-rls-check---format-agent-says-rls\",\n review: \"#126-rebaseproplugin-review-reviewrls\",\n codegen: \"#127-rebaseprocodegen-reads-descriptors\",\n jsonCollections: \"#129-usejsoncollectionsconfigcontroller-is-removed\",\n history: \"#132-history-is-served-as-reads\",\n serverExports: \"#133-rebaseproserver-exports-name-tables\",\n postgresExports: \"#134-rebaseproserver-postgres-exports-name-tables\",\n kernel: \"#135-rebaseprotypes-and-rebaseprocommon-drop-the-collection-model-from-their-roots\"\n} as const;\n\nconst removed = (from: string, symbols: readonly string[], instead: string, guide?: string): MovedSymbol[] =>\n symbols.map(symbol => ({ symbol, from, to: null, instead, ...(guide ? { guide } : {}) }));\n\nconst MONGO = \"Nothing: MongoDB is retired and Postgres is the only server engine; move the data to Postgres.\";\nconst COMPONENT = \"Pass the component itself: import it by value in the frontend/src/cms file and give it to the slot (`Field`, `Preview`, `Actions`, `Builder`, …). `customizeTable` refuses a string path or a lazy thunk.\";\nconst COLLECTION_MODEL = \"Nothing: the collection model left the kernel. Read the table's `TableDescriptor` (`compileTables` from @rebasepro/common, `backend.getTableDescriptors()`, `GET /api/schema/tables`).\";\nconst LOADING = \"`compileTables` (@rebasepro/common) checks the tables and throws one `SchemaDefinitionError` naming every problem; `schemaDir` / `loadBackendSchema` load backend/schema.\";\nconst REGISTRY = \"`TableRegistryInterface` from @rebasepro/types: `setGlobalHooks?` / `setTableHooks?` replace `getGlobalCallbacks` / `setGlobalCallbacks?`.\";\nconst SCHEMA_EDIT = \"`TablePatch` from @rebasepro/types: a schema edit is a list of `TablePatch` edits (`POST /api/admin/schema-editor/preview` and `/apply`, live schema `{ patches }`).\";\n\n/** Exports renamed (rewritten) or changed (a manual step) outside the kernel moves. */\nexport const EXPORT_CHANGES: readonly MovedSymbol[] = [\n // Renamed, same signature: rewritten.\n { symbol: \"reviewSecurityRules\", from: \"@rebasepro/plugin-review\", to: \"@rebasepro/plugin-review\", as: \"reviewRls\", guide: GUIDE.review },\n { symbol: \"reviewSecurityRules\", from: \"@rebasepro/plugin-review/config\", to: \"@rebasepro/plugin-review/config\", as: \"reviewRls\", guide: GUIDE.review },\n { symbol: \"assertUploadWithinPropertyLimits\", from: \"@rebasepro/server\", to: \"@rebasepro/server\", as: \"assertUploadWithinColumnLimits\", guide: GUIDE.serverExports },\n { symbol: \"UPLOAD_COLLECTION_FIELD\", from: \"@rebasepro/server\", to: \"@rebasepro/server\", as: \"UPLOAD_TABLE_FIELD\", guide: GUIDE.serverExports },\n { symbol: \"UPLOAD_PROPERTY_FIELD\", from: \"@rebasepro/server\", to: \"@rebasepro/server\", as: \"UPLOAD_COLUMN_FIELD\", guide: GUIDE.serverExports },\n\n // @rebasepro/types\n ...removed(\"@rebasepro/types\", [\"CollectionPatch\", \"CollectionPatchOp\", \"applyCollectionPatch\", \"collectionPatchProblems\", \"isCollectionPatch\", \"nestCollectionPatchPaths\"], SCHEMA_EDIT, GUIDE.schemaEditor),\n ...removed(\"@rebasepro/types\", [\"CollectionRegistryInterface\"], REGISTRY, GUIDE.kernel),\n ...removed(\"@rebasepro/types\", [\"ComponentLike\", \"ComponentRef\", \"LazyComponentRef\", \"isLazyComponentRef\"], COMPONENT, GUIDE.componentSlot),\n ...removed(\"@rebasepro/types\", [\"DocumentAdmin\", \"isDocumentAdmin\", \"MONGODB_CAPABILITIES\", \"MongoDBCollectionConfig\", \"MongoProperties\", \"MongoProperty\", \"isMongoDBCollectionConfig\"], MONGO, GUIDE.mongo),\n ...removed(\"@rebasepro/types\", [\"RUNTIME_ONLY_COLLECTION_KEYS\", \"runtimeOnlyKeyIn\", \"toCollectionJson\", \"diffCollections\", \"diffJsonValues\"], COLLECTION_MODEL, GUIDE.kernel),\n ...removed(\"@rebasepro/types\", [\"ListenOneTarget\"], \"`ListenOneProps` from @rebasepro/types: `ListenOneTarget` was internal, and its fields are `ListenOneProps`'s.\"),\n\n // @rebasepro/common\n ...removed(\"@rebasepro/common\", [\"IntrospectedCollection\", \"IntrospectedRelation\", \"buildCollectionFromTableMetadata\"], \"An introspected table is a `TableDescriptor`; `rebase schema introspect` writes `defineTable` files to backend/schema.\", GUIDE.serverExports),\n ...removed(\"@rebasepro/common\", [\"buildTenantSecurityRule\", \"defaultPoliciesDisabled\", \"getJunctionConfigForRelation\", \"isRelationRequired\", \"relationDeclaringProperty\", \"requireCallbackCollection\", \"restoresSoftDeletedRow\", \"softDeleteFieldOf\"], COLLECTION_MODEL, GUIDE.kernel),\n ...removed(\"@rebasepro/common\", [\"toCollectionAccessor\"], \"Nothing: a typed accessor is the table's name (`client.data.posts`), and a reserved one is `<name>Table`.\", GUIDE.sdk),\n\n // @rebasepro/server\n ...removed(\"@rebasepro/server\", [\"BundleConfigExports\", \"loadBundleConfigExports\"], \"Nothing: there is no config package, and a bundle carries `entry.tables`, `entry.resources`, `entry.storage` and `entry.hooks`.\", GUIDE.configPackage),\n ...removed(\"@rebasepro/server\", [\"CollectionConfigError\", \"ConfigProblem\", \"ValidateCollectionConfigOptions\", \"findCollectionConfigProblems\", \"assertCollectionConfigs\", \"CollectionDefaults\", \"applyCollectionDefaults\", \"UnknownKeyPolicy\", \"unknownKeyPolicyFromEnv\", \"accessModelFromCollections\", \"loadCollectionsFromDirectory\", \"loadUsersCollection\"], LOADING, GUIDE.tables),\n ...removed(\"@rebasepro/server\", [\"CollectionRegistryInterface\"], REGISTRY, GUIDE.kernel),\n ...removed(\"@rebasepro/server\", [\"DataTransformer\"], \"Nothing: the Postgres driver's codecs read the column descriptor.\"),\n ...removed(\"@rebasepro/server\", [\"composeCallbacks\"], \"`composeTableHooks` from @rebasepro/common: table hooks get `table` instead of `collection`, and `values` instead of `row`.\", GUIDE.bootOptions),\n ...removed(\"@rebasepro/server\", [\"createUserThroughAuthCollection\"], \"`createUserThroughAuthTable(adapter, served, body, caller, save)` from @rebasepro/server: it takes the served table, not a collection.\", GUIDE.serverExports),\n ...removed(\"@rebasepro/server\", [\"readUploadPropertyContext\"], \"`readUploadColumnContext` from @rebasepro/server: it returns `{ table, column }` instead of `{ collection, property }`.\", GUIDE.serverExports),\n ...removed(\"@rebasepro/server\", [\"versionProperty\"], \"`versionColumn` from @rebasepro/server: it takes a `TableDescriptor`.\", GUIDE.serverExports),\n\n // @rebasepro/server-postgres\n ...removed(\"@rebasepro/server-postgres\", [\"PostgresCollectionRegistry\"], \"`PostgresTableRegistry` (`getTable` → `getPgTable`, `registerTable` → `registerPgTable`), opened on the compiled tables (`compileSchema`).\", GUIDE.postgresExports),\n ...removed(\"@rebasepro/server-postgres\", [\"CollectionRegistryInterface\"], REGISTRY, GUIDE.kernel),\n ...removed(\"@rebasepro/server-postgres\", [\"DataTransformer\"], \"Nothing: the Postgres driver's codecs read the column descriptor.\"),\n ...removed(\"@rebasepro/server-postgres\", [\"resolveDriftCheckName\"], \"Nothing: the boot drift check reads the tables itself.\", GUIDE.kernel),\n\n // @rebasepro/cms, @rebasepro/cms-types, @rebasepro/app\n ...removed(\"@rebasepro/cms\", [\"useJsonCollectionsConfigController\", \"UseJsonCollectionsConfigControllerOptions\", \"JsonCollectionStore\"], \"Declare the tables with `defineTable` in backend/schema; how the panel shows them lives in UI preferences (`frontend/src/cms/ui-config.json`, passed as `<RebaseCMS uiConfig>`).\", GUIDE.jsonCollections),\n ...removed(\"@rebasepro/cms\", [\"ProposedCollectionChange\"], SCHEMA_EDIT, GUIDE.schemaEditor),\n ...removed(\"@rebasepro/cms-types\", [\"PartialCollectionConfig\"], \"`UiTablePreferences`: `UserConfigurationPersistence` takes `getTablePreferences` / `saveTablePreferences`.\", GUIDE.uiPreferences),\n ...removed(\"@rebasepro/cms-types\", [\"ReactComponentRef\", \"asComponentRef\", \"asReactComponent\"], COMPONENT, GUIDE.componentSlot),\n ...removed(\"@rebasepro/app\", [\"resolveComponentRef\", \"useResolvedComponent\"], COMPONENT, GUIDE.componentSlot),\n\n // Still exported, but they take something else now.\n ...removed(\"@rebasepro/codegen\", [\"generateSDK\", \"generateTypedefs\"], \"Still exported, but it takes `TableDescriptor[]` now — `compileTables(...)` or what `GET /api/schema/tables` serves — instead of collections; or run `rebase generate-sdk`.\", GUIDE.codegen),\n ...removed(\"@rebasepro/codegen\", [\"toCollectionAccessor\"], \"Nothing: a typed accessor is the table's name (`client.data.posts`), and a reserved one is `<name>Table`.\", GUIDE.sdk),\n ...removed(\"@rebasepro/plugin-review\", [\"findReviewConfigProblems\", \"assertReviewConfig\"], \"Still exported, but it takes table descriptors now: pass `services.tables()` or `compileTables(...)`.\", GUIDE.review),\n ...removed(\"@rebasepro/plugin-review/config\", [\"findReviewConfigProblems\", \"assertReviewConfig\"], \"Still exported, but it takes table descriptors now: pass `services.tables()` or `compileTables(...)`.\", GUIDE.review)\n];\n\n/** Packages that are gone: any import of them is a manual step. */\nexport const REMOVED_PACKAGES: Readonly<Record<string, { instead: string; guide: string }>> = {\n \"@rebasepro/server-mongo\": { instead: MONGO, guide: GUIDE.mongo }\n};\n\n/** A call whose options named collections: detected (object-literal arguments), never rewritten. */\nexport interface CallOptionChange {\n /** The function, as called (`openRebase`). */\n callee: string;\n /** Option keys of the collection model. */\n keys: readonly string[];\n instead: string;\n guide: string;\n}\n\n/** Calls whose options named the collection model. */\nexport const CALL_OPTION_CHANGES: readonly CallOptionChange[] = [\n { callee: \"openRebase\", keys: [\"collections\", \"callbacks\"], instead: \"`openRebase({ tables, hooks })` with `tables` from `compileSchema([...])`; the result's `.collections` is `.tables`.\", guide: GUIDE.bootOptions },\n { callee: \"openPostgresDriver\", keys: [\"collections\"], instead: \"`openPostgresDriver(config, { tables })` with `tables` from `compileSchema([...])`; the `collection` props of driver calls are ignored.\", guide: GUIDE.postgresExports },\n { callee: \"createHistoryRoutes\", keys: [\"collections\"], instead: \"`createHistoryRoutes({ tables })`.\", guide: GUIDE.serverExports }\n];\n\n/** A spelling found anywhere in a source file (not only in an import): detected, never rewritten. */\nexport interface CodeSpelling {\n /** What the step calls it. */\n spelling: string;\n /** Where it is: each match is one line of the step. */\n pattern: RegExp;\n /** Only files whose text also matches this are read (a cheap guard against a common word). */\n onlyIf?: RegExp;\n instead: string;\n guide: string;\n}\n\n/** Spellings a project's own code can hold whose meaning changed: each is a manual step. */\nexport const CODE_SPELLINGS: readonly CodeSpelling[] = [\n { spelling: \"REBASE_LIVE_SCHEMA_COLLECTIONS_PATH\", pattern: /\\bREBASE_LIVE_SCHEMA_COLLECTIONS_PATH\\b/g, instead: \"`REBASE_LIVE_SCHEMA_PATH` (default `backend/schema`); the old variable refuses the boot. Rename it in your .env files and deployment variables too.\", guide: GUIDE.schemaEditor },\n { spelling: \"liveSchema.repository.collectionsPath\", pattern: /\\bcollectionsPath\\s*:/g, onlyIf: /\\brepository\\b/, instead: \"`schemaPath` — the directory of the tables (`backend/schema`), not of the collections.\", guide: GUIDE.schemaEditor },\n { spelling: \"REBASE_STRICT_COLLECTION_CONFIG\", pattern: /\\bREBASE_STRICT_COLLECTION_CONFIG\\b/g, instead: \"Nothing: it is no longer read; a schema that does not compile always refuses the boot.\", guide: GUIDE.cliFlags },\n { spelling: \"the schema-editor collection / property routes\", pattern: /\\/schema-editor\\/(?:collection|property)\\/(?:save|delete)\\b/g, instead: \"`GET /api/admin/schema-editor/tables`, `POST /preview` and `POST /apply` with `{ patches: TablePatch[] }`.\", guide: GUIDE.schemaEditor },\n { spelling: \"SCHEMA_EDIT_REFUSED\", pattern: /[\"'`]SCHEMA_EDIT_REFUSED[\"'`]/g, instead: \"A file that changed on disk after the edit was prepared now answers 409 `SCHEMA_EDIT_STALE_FILE` (reload and retry); `SCHEMA_EDIT_REFUSED` is still the code of every other refusal.\", guide: GUIDE.schemaEditor },\n { spelling: \"an MCP tool named for collections\", pattern: /[\"'`](?:list_collections|describe_collection|query_collection|show_collection|count_documents|aggregate_documents|list_documents|get_document|create_document|update_document|delete_document)[\"'`]/g, onlyIf: /mcp/i, instead: \"`list_tables`, `describe_table`, `query_table`, `show_table`, `count_rows`, `aggregate_rows`, `get_row`, `create_row`, `update_row`, `delete_row` (`list_documents` → `query_table`); their `collection` argument is `table`.\", guide: GUIDE.mcp },\n { spelling: \"remediation.rebase.securityRules\", pattern: /\\brebase\\s*\\??\\.\\s*securityRules\\b/g, onlyIf: /remediation/, instead: \"`remediation.rebase.rls` (rls-check agent format version 2).\", guide: GUIDE.rlsCheck },\n { spelling: \"UserConfigurationPersistence.getCollectionConfig / onCollectionModified\", pattern: /\\b(?:getCollectionConfig|onCollectionModified)\\b/g, instead: \"`getTablePreferences` / `saveTablePreferences`, which read and write a `UiTablePreferences` delta.\", guide: GUIDE.uiPreferences },\n { spelling: \"StudioSchemaEditing.updateCollection\", pattern: /\\bupdateCollection\\b/g, onlyIf: /\\bStudioSchemaEditing\\b/, instead: \"`applyTablePatches(slug, patches)`.\", guide: GUIDE.uiPreferences },\n { spelling: \"<CollectionsProvider collections>\", pattern: /<CollectionsProvider\\b[^>]*?\\bcollections\\s*=/g, instead: \"`CollectionsProvider` takes `tableCustomizations`, `externalCollections` and `tables`.\", guide: GUIDE.adminPanel },\n { spelling: \"getGlobalCallbacks / setGlobalCallbacks\", pattern: /\\b(?:getGlobalCallbacks|setGlobalCallbacks)\\b/g, instead: \"A driver's registry is a `TableRegistryInterface`: `setGlobalHooks?` / `setTableHooks?`.\", guide: GUIDE.kernel },\n { spelling: \"a custom DataDriver\", pattern: /\\bimplements\\s+(?:[\\w.]+\\s*,\\s*)*DataDriver\\b/g, instead: \"Implement `serveStoredRows(path, rows)` to serve history: without it the history routes answer 501.\", guide: GUIDE.history }\n];\n\n/** A `package.json` script spelling of the old CLI: detected, never rewritten. */\nexport const SCRIPT_SPELLINGS: readonly CodeSpelling[] = [\n { spelling: \"--collections\", pattern: /\\brebase\\b[^&|;]*\\s(?:--collections\\b|-c\\s)/g, instead: \"`--schema-dir <dir>` (only when the tables are not in backend/schema); `--collections` / `-c` are refused.\", guide: GUIDE.cliFlags },\n { spelling: \"schema introspect --output\", pattern: /\\bschema\\s+introspect\\b[^&|;]*\\s--output\\b/g, instead: \"`rebase schema introspect` writes `defineTable` files to backend/schema: drop `--output`.\", guide: GUIDE.cliFlags }\n];\n","/**\n * GENERATED by tooling/scripts/codemod/moved-symbols-table.mjs from\n * tooling/scripts/headless-guard/moved-symbols.json and\n * tooling/scripts/headless-guard/cms-only-symbols.json — do not edit by hand: change\n * the JSON and run the script again. `moved-imports.test.ts` fails while they disagree.\n *\n * Every symbol that left a package's root in 0.31: `to` is the package to import it from now\n * (`as`: under that name), or null when it is gone and `instead` says what to write.\n */\nimport type { MovedSymbol } from \"./types\";\n\n/** The symbols that moved or were removed, by the package they left. */\nexport const MOVED_SYMBOLS: readonly MovedSymbol[] = [\n { symbol: \"FindResponse\", from: \"@rebasepro/client\", to: null, instead: \"FindResult from @rebasepro/types: what client.data.<table>.find() resolves to.\" },\n { symbol: \"defineCollection\", from: \"@rebasepro/cms-types\", to: null, instead: \"defineTable (backend/schema) + customizeTable for the panel's presentation; defineFirestoreCollection (@rebasepro/firebase) for Firestore; defineLegacyCollection (@rebasepro/common/migrate) for 0.30 fixtures.\" },\n { symbol: \"apiHiddenFieldNames\", from: \"@rebasepro/common\", to: null, instead: \"apiHiddenKeys(descriptor) from @rebasepro/common.\" },\n { symbol: \"applyDefaultValuesOnCreate\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"assertBeforeQueryIsPostgresOnly\", from: \"@rebasepro/common\", to: null, instead: \"Nothing: Postgres is the only server engine.\" },\n { symbol: \"AuthContext\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"buildConditionContext\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"buildPropertyCallbacks\", from: \"@rebasepro/common\", to: null, instead: \"Column transforms: col.*().transform(...) on the table definition.\" },\n { symbol: \"buildRebaseData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"buildRoutedRebaseData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canCreateEntity\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canDeleteEntity\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canEditEntity\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canReadCollection\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canReadField\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canWriteField\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"checkOperation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CheckOperationOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"COLLECTION_PATH_SEPARATOR\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionRegistry\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"collectionsToTableDefs\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"collectionToTableDef\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"compileRulePolicies\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"composeCallbacks\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"copyCarriesRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"createRelationRef\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"createRelationRefWithData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DEFAULT_ONE_OF_TYPE\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DEFAULT_ONE_OF_VALUE\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DEFAULT_STRING_COLUMN_LENGTH\", from: \"@rebasepro/common\", to: null, instead: \"col.varchar({ length }) states the length on the column.\" },\n { symbol: \"defaultUsersCollection\", from: \"@rebasepro/common\", to: null, instead: \"defineAuthTable for the user store; AUTH_SECRET_NAMES lists its secrets.\" },\n { symbol: \"defineCollection\", from: \"@rebasepro/common\", to: null, instead: \"defineTable (backend/schema); the CMS customizes a table with customizeTable; Firestore uses defineFirestoreCollection; legacy fixtures defineLegacyCollection from @rebasepro/common/migrate.\" },\n { symbol: \"effectiveAccess\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityCallbackContext\", from: \"@rebasepro/common\", to: null, instead: \"TableHookProps[\\\"context\\\"] from @rebasepro/types.\" },\n { symbol: \"EntityDataOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"enumToObjectEntries\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"evaluateCondition\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"fieldKeyForColumn\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"findRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"fullPathToCollectionSegments\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getArrayResolvedProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getChildViewDeclaringProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getChildViewRelationPropertyKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getCopyValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDeclaredPrimaryKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDefaultValueFor\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDefaultValueFortype\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDefaultValuesFor\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getEffectiveSecurityRules\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getEffectiveSecurityRulesOnce\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getEntityChildViews\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getGeneratedPolicyNames\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getGeneratedPolicyNamesOnce\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getInjectedSecurityRules\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getJunctionCollectionConfig\", from: \"@rebasepro/common\", to: null, instead: \"junctionPolicyTable(junction) from @rebasepro/common.\" },\n { symbol: \"getJunctionSecurityRules\", from: \"@rebasepro/common\", to: null, instead: \"tableJunctionRules(junction) from @rebasepro/common.\" },\n { symbol: \"getLabelOrConfigFrom\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getPrimaryKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getReferenceFrom\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getRelationFrom\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getRelationTargetPath\", from: \"@rebasepro/common\", to: \"@rebasepro/cms\" },\n { symbol: \"getSubcollections\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getTableName\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getTenantConfig\", from: \"@rebasepro/common\", to: null, instead: \"tenantOf(descriptor) from @rebasepro/common reads a table's tenancy.\" },\n { symbol: \"hasEntityId\", from: \"@rebasepro/common\", to: \"@rebasepro/cms\" },\n { symbol: \"hasFieldAccessRules\", from: \"@rebasepro/common\", to: null, instead: \"hasColumnAccessRules(descriptor) from @rebasepro/common.\" },\n { symbol: \"includableRelationNames\", from: \"@rebasepro/common\", to: null, instead: \"includableRelations(descriptor) from @rebasepro/common.\" },\n { symbol: \"isJunctionBackedRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isPropertyBuilder\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"JunctionDeclaringSide\", from: \"@rebasepro/common\", to: null, instead: \"TableJunctionSide from @rebasepro/common.\" },\n { symbol: \"JunctionEndpoint\", from: \"@rebasepro/common\", to: null, instead: \"TableJunctionEndpoint from @rebasepro/common.\" },\n { symbol: \"JunctionSpec\", from: \"@rebasepro/common\", to: null, instead: \"TableJunction from @rebasepro/common.\" },\n { symbol: \"LegacyPolicyCompileOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"LegacyRulePolicyCompileOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"legacyTableResolver\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"LiftNote\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"LiftNoteKind\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"LiftOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"LiftResult\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"liftRuleSpelling\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"liftTenantSourceSpelling\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"normalizeToEntityRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PolicyClauses\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"policyTableFromCollection\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"policyToPostgres\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"queryableFieldNames\", from: \"@rebasepro/common\", to: null, instead: \"queryableColumnKeys(descriptor) from @rebasepro/common.\" },\n { symbol: \"QueryBuilder\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"registerConditionOperations\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationRef\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationRefWithData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveArrayProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveCollectionRelations\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveEnumValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolveFilenameStringParams\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveJunctionSpecs\", from: \"@rebasepro/common\", to: null, instead: \"resolveTableJunctions(descriptors) from @rebasepro/common.\" },\n { symbol: \"resolvePrimaryKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveProperty\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolvePropertyEnum\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvePropertyProps\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveRelationProperty\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStorageFilenameString\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStoragePathString\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolveStoragePathStringParams\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStorageSource\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStringColumnLength\", from: \"@rebasepro/common\", to: null, instead: \"col.varchar({ length }) states the length on the column.\" },\n { symbol: \"restrictedFieldNames\", from: \"@rebasepro/common\", to: null, instead: \"restrictedKeys(descriptor, viewer, kind) from @rebasepro/common.\" },\n { symbol: \"RoutableData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RoutedRebaseDataParams\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"rowToViewModel\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"sanitizeData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"segmentsToStrippedPath\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"sortProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"stripCollectionPath\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"traverseValueProperty\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"traverseValuesProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"unavailableStorageSource\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"UnknownResolution\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"updateDateAutoValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"updateUserAutoValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"vectorPropertyNames\", from: \"@rebasepro/common\", to: null, instead: \"vectorColumnKeys(descriptor) from @rebasepro/common.\" },\n { symbol: \"withDeprecatedAlias\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"withRelationReferencesOnly\", from: \"@rebasepro/common\", to: null, instead: \"History entries hold the stored (wire) row, which embeds no related row; the history routes serve an older entry's relation refs as keys. Nothing replaces it.\" },\n { symbol: \"wrapAsEntityData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"wrapAsSdkData\", from: \"@rebasepro/common\", to: null, instead: \"buildSdkData(driver) from @rebasepro/common: the SDK is built on the driver's rows; there is no Entity accessor to flatten.\" },\n { symbol: \"composeCallbacks\", from: \"@rebasepro/server\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ListenCollectionRequest\", from: \"@rebasepro/server\", to: null, instead: \"ListenCollectionProps from @rebasepro/types (a subscription's rows are plain rows).\" },\n { symbol: \"ListenEntityRequest\", from: \"@rebasepro/server\", to: null, instead: \"ListenOneProps from @rebasepro/types.\" },\n { symbol: \"ADMIN_COLLECTION_KEYS\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ADMIN_PROPERTY_KEYS\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AdminCollectionKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AdminPropertyKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterDeleteProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterReadProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterSaveErrorProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterSaveProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AnyCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ArrayProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ArrayPropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AuthCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AuthState\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BaseCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BaseProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BeforeDeleteProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BeforeQueryProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BeforeSaveProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BelongsToRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BinaryProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BooleanProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BrinIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BtreeIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ChildViewSource\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionCallbacks\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionRegistryController\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionView\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorHue\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorScheme\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorTone\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ConditionContext\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ConditionRule\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DataTransformer\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: the Postgres driver's codecs read the column descriptor.\" },\n { symbol: \"DataType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DateProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DatePropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"deserializeCollections\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"EffectiveRoleController\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EngineProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Entity\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityChildView\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityReference\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityReferenceProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityValues\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EnumValueConditions\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EnumValueConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EnumValues\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FieldAccess\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FileType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FilterPreset\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FindResponse\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FirebaseCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FirebaseProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FirebaseProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"GeoPoint\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"GeopointProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getCollectionDataPath\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDeclaredSubcollections\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"GinIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"hasForeignKeyOnTarget\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind (hasOne | hasMany).\" },\n { symbol: \"HasManyRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"HasOneRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ImageResize\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"IndexKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"IndexPredicate\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"InferCollectionConfigType\", from: \"@rebasepro/types\", to: null, instead: \"Infer a table's row with InferRow<typeof table>.\" },\n { symbol: \"InferEntityType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"InferPropertyType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"initTextSearch\", from: \"@rebasepro/types\", to: null, instead: \"DataDriver no longer declares it; the Firestore driver (FirestoreDataDriver) declares its own.\" },\n { symbol: \"isFirebaseCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isManyToMany\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind === \\\"manyToMany\\\".\" },\n { symbol: \"isPostgresCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isRelationalCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isSerializedCollectionRef\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"isToMany\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind (hasMany | manyToMany | via).\" },\n { symbol: \"JsonLogicRule\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ManyToManyRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"MapProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"McpAppModuleExport\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"nestAdminCollectionKeys\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"nestAdminKeysOf\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"nestAdminPropertyKeys\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"NoSuchKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"NumberProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"NumberPropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PostgresCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PostgresProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PostgresProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Properties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Property\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyBuilderProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyCallbacks\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyConditions\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyTypeNotOnThisEngine\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"QueryBuilderInterface\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RebaseData\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ReferenceProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Relation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationBase\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedBelongsTo\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedForeignKeyOnTarget\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind (hasOne | hasMany).\" },\n { symbol: \"ResolvedHasMany\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedHasOne\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedManyToMany\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedRelationBase\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedVia\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"serializeCollections\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"SerializedCollectionRef\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"SqlExpression\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StorageConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StrictProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StringProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StringPropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"TableAccessor\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"TableTrashAccessor\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"UnorderedIndexKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"UploadedFileContext\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Vector\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"VectorDistance\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"VectorIndexConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"VectorProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ViaRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" }\n];\n","/**\n * Rewriting a project's imports of names that moved, were renamed or were\n * removed in 0.31 — the third pass of `rebase migrate sdk-calls`, run on the\n * text the SDK-call passes wrote.\n *\n * The table is {@link MOVED_SYMBOLS} (generated from the headless guard's JSON:\n * the CMS view model and helpers that left `@rebasepro/types` /\n * `@rebasepro/common`) and {@link EXPORT_CHANGES} (the renames and removals\n * elsewhere). For every `import { … } from` / `export { … } from` whose module\n * is a package a name left:\n *\n * - a name with a destination moves to an import from that package — merged\n * into an import of it the file already has, `import type` / inline `type`\n * and `as` aliases kept, the rest of the declaration left where it is, a\n * declaration left empty deleted. A rename renames the file's references\n * to it too (an aliased import keeps its alias; a re-export keeps its public\n * name). `import(\"pkg\").Name` in a type is repointed the same way.\n * - a name without one (removed, or still exported with another meaning) is\n * left as written and becomes a manual step with what to write instead.\n * - a namespace import (`import * as T`), `export *`, a dynamic `import()` or\n * a `require()` of such a package that uses a moved name is not guessed at:\n * a manual step names the file, the line and the names.\n *\n * Running it again on its own output changes nothing.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ExportDeclaration, ExportSpecifier, ImportDeclaration, ImportSpecifier, Node, SourceFile } from \"ts-morph\";\n\nimport type { AstContext } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport { CALL_OPTION_CHANGES, CODE_SPELLINGS, EXPORT_CHANGES, REMOVED_PACKAGES, SCRIPT_SPELLINGS, UPGRADE_GUIDE, type CodeSpelling } from \"./export-changes\";\nimport { MOVED_SYMBOLS } from \"./moved-symbols.generated\";\nimport { own } from \"./own\";\nimport type { ManualStep, MovedSymbol, Note } from \"./types\";\n\n/** A replacement of `[start, end)` in a file's text. */\nexport interface TextEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** One name an import or re-export of the file now takes from another package or under another name. */\nexport interface MovedName {\n symbol: string;\n from: string;\n to: string;\n as?: string;\n}\n\n/** What the pass found in one file. */\nexport interface MovedImportsResult {\n edits: TextEdit[];\n moved: MovedName[];\n manualSteps: ManualStep[];\n}\n\nconst key = (from: string, symbol: string): string => `${from}\\0${symbol}`;\n\n/** The table, generated rows over hand-written ones. */\nconst TABLE: ReadonlyMap<string, MovedSymbol> = (() => {\n const table = new Map<string, MovedSymbol>();\n for (const row of EXPORT_CHANGES) table.set(key(row.from, row.symbol), row);\n for (const row of MOVED_SYMBOLS) table.set(key(row.from, row.symbol), row);\n return table;\n})();\n\n/** The names each package lost. */\nconst BY_PACKAGE: ReadonlyMap<string, readonly MovedSymbol[]> = (() => {\n const out = new Map<string, MovedSymbol[]>();\n for (const row of TABLE.values()) out.set(row.from, [...(out.get(row.from) ?? []), row]);\n return out;\n})();\n\n/** The row for a name imported from a module, if it moved or changed. */\nexport function movedSymbol(from: string, symbol: string): MovedSymbol | undefined {\n return TABLE.get(key(from, symbol));\n}\n\n/** Every row of the table (generated rows win), for the report and the tests. */\nexport function movedSymbolTable(): readonly MovedSymbol[] {\n return [...TABLE.values()];\n}\n\n/** The package a module specifier belongs to (`@rebasepro/common/migrate` → `@rebasepro/common`). */\nexport function packageOf(specifier: string): string {\n const parts = specifier.split(\"/\");\n return specifier.startsWith(\"@\") ? parts.slice(0, 2).join(\"/\") : parts[0];\n}\n\nconst guideLink = (row: { guide?: string }): string => (row.guide ? ` See ${UPGRADE_GUIDE}${row.guide}` : \"\");\n\n/** A specifier of an import or re-export, as the model sees it. */\ninterface Spec {\n node: ImportSpecifier | ExportSpecifier;\n name: string;\n alias?: string;\n isType: boolean;\n /** Set when the name is renamed in place (same package): the specifier's new text. */\n renamed?: string;\n}\n\n/** A specifier to add to a declaration. */\ninterface Addition {\n text: string;\n isType: boolean;\n}\n\ninterface DeclarationPlan {\n keep: Spec[];\n add: Addition[];\n /** New declarations written right after this one (or in its place when it ends up empty). */\n after: string[];\n touched: boolean;\n}\n\nfunction specsOf(declaration: ImportDeclaration | ExportDeclaration): Spec[] {\n const typeOnly = declaration.isTypeOnly();\n const named = \"getNamedImports\" in declaration ? declaration.getNamedImports() : declaration.getNamedExports();\n return named.map(node => {\n const alias = node.getAliasNode()?.getText();\n return { node, name: node.getNameNode().getText(), ...(alias ? { alias } : {}), isType: typeOnly || node.isTypeOnly() };\n });\n}\n\n/** The text of a specifier written into a declaration that is (or is not) type-only. */\nfunction specText(text: string, isType: boolean, intoTypeOnly: boolean): string {\n return isType && !intoTypeOnly ? `type ${text}` : text;\n}\n\n/** A spec kept as written, its inline `type` adjusted to the declaration it ends up in. */\nfunction keptText(spec: Spec, intoTypeOnly: boolean): string {\n const bare = spec.renamed ?? (spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);\n return specText(bare, spec.isType, intoTypeOnly);\n}\n\n/** The braces of a declaration (`named`), rebuilt with `items`, in their own one-line or multi-line style. */\nfunction braces(declaration: ImportDeclaration | ExportDeclaration, named: Node, items: string[]): string {\n const original = named.getText();\n if (!original.includes(\"\\n\")) return `{ ${items.join(\", \")} }`;\n const sourceText = declaration.getSourceFile().getFullText();\n const indent = /\\{\\s*\\n([ \\t]*)/.exec(original)?.[1] ?? \" \";\n const declarationStart = declaration.getStart();\n const lineStart = sourceText.lastIndexOf(\"\\n\", declarationStart - 1) + 1;\n const closingIndent = /^[ \\t]*/.exec(sourceText.slice(lineStart, declarationStart))?.[0] ?? \"\";\n return `{\\n${items.map(item => `${indent}${item}`).join(\",\\n\")}\\n${closingIndent}}`;\n}\n\n/**\n * Names that moved to the panel's package but have a backend counterpart: in a\n * backend file the import is not moved to `@rebasepro/cms-types` (the server\n * does not run the panel's model) — the step names what the backend uses.\n */\nconst BACKEND_INSTEAD: Readonly<Record<string, string>> = {\n composeCallbacks: \"on the backend, use `composeTableHooks` from @rebasepro/common: table hooks get `table` instead of `collection`, and `values` instead of `row` in afterRead / beforeDelete / afterDelete.\"\n};\n\n/** Whether a project file is backend code (under a `backend/` directory). */\nfunction isBackendFile(relative: string): boolean {\n return /(^|\\/)backend\\//.test(relative);\n}\n\n/**\n * Plan the moves of one file.\n *\n * @param ctx the AST context\n * @param sf the file, parsed (syntax only)\n * @param relative its path from the project root, for the steps\n */\nexport function rewriteMovedImports(ctx: AstContext, sf: SourceFile, relative: string): MovedImportsResult {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const result: MovedImportsResult = { edits: [], moved: [], manualSteps: [] };\n const removedLines: string[] = [];\n const unresolved: string[] = [];\n\n const imports = sf.getImportDeclarations();\n const reexports = sf.getExportDeclarations().filter(declaration => declaration.getModuleSpecifierValue() !== undefined);\n const plans = new Map<ImportDeclaration | ExportDeclaration, DeclarationPlan>();\n const planOf = (declaration: ImportDeclaration | ExportDeclaration): DeclarationPlan => {\n let plan = plans.get(declaration);\n if (!plan) {\n plan = { keep: specsOf(declaration), add: [], after: [], touched: false };\n plans.set(declaration, plan);\n }\n return plan;\n };\n /** Local names renamed: old → new. */\n const renamedLocals = new Map<string, string>();\n\n const groups: { kind: \"import\" | \"export\"; declarations: (ImportDeclaration | ExportDeclaration)[] }[] = [\n { kind: \"import\", declarations: imports },\n { kind: \"export\", declarations: reexports }\n ];\n for (const { kind, declarations } of groups) {\n // Moves out of each declaration, gathered by destination.\n const byDestination = new Map<string, { anchor: ImportDeclaration | ExportDeclaration; quote: string; specs: { text: string; isType: boolean }[] }>();\n for (const declaration of declarations) {\n const from = declaration.getModuleSpecifierValue();\n if (from === undefined) continue;\n const removedPackage = REMOVED_PACKAGES[from];\n if (removedPackage) {\n removedLines.push(`line ${declaration.getStartLineNumber()}: \\`${from}\\` is gone. ${removedPackage.instead}${guideLink(removedPackage)}`);\n continue;\n }\n if (!BY_PACKAGE.has(from)) continue;\n if (kind === \"import\" && N.isImportDeclaration(declaration) && declaration.getNamespaceImport()) continue;\n for (const spec of specsOf(declaration)) {\n const row = movedSymbol(from, spec.name);\n if (!row) continue;\n if (row.to === null) {\n removedLines.push(`line ${declaration.getStartLineNumber()}: \\`${spec.name}\\` from ${from} — ${row.instead ?? \"it is no longer exported.\"}${guideLink(row)}`);\n continue;\n }\n const backendInstead = isBackendFile(relative) ? own(BACKEND_INSTEAD, spec.name) : undefined;\n if (backendInstead) {\n removedLines.push(`line ${declaration.getStartLineNumber()}: \\`${spec.name}\\` from ${from} — ${backendInstead}`);\n continue;\n }\n const plan = planOf(declaration);\n plan.touched = true;\n const newName = row.as ?? spec.name;\n let text: string;\n if (spec.alias) text = `${newName} as ${spec.alias}`;\n else if (newName !== spec.name && kind === \"export\") text = `${newName} as ${spec.name}`;\n else text = newName;\n if (kind === \"import\" && !spec.alias && newName !== spec.name) renamedLocals.set(spec.name, newName);\n result.moved.push({ symbol: spec.name, from, to: row.to, ...(row.as ? { as: row.as } : {}) });\n if (row.to === from) {\n // Renamed in its own package: rewritten where it stands.\n const kept = plan.keep.find(candidate => candidate.node === spec.node);\n if (kept) kept.renamed = text;\n continue;\n }\n plan.keep = plan.keep.filter(kept => kept.node !== spec.node);\n const quote = declaration.getModuleSpecifier()?.getText().charAt(0) ?? \"\\\"\";\n const group = byDestination.get(row.to) ?? { anchor: declaration, quote: quote === \"'\" ? \"'\" : \"\\\"\", specs: [] };\n if (!group.specs.some(existing => existing.text === text)) group.specs.push({ text, isType: spec.isType });\n byDestination.set(row.to, group);\n }\n }\n for (const [to, group] of byDestination) {\n const needsValue = group.specs.some(spec => !spec.isType);\n const candidates = declarations.filter(declaration => declaration.getModuleSpecifierValue() === to &&\n !(N.isImportDeclaration(declaration) && declaration.getNamespaceImport()) &&\n !(N.isExportDeclaration(declaration) && !declaration.hasNamedExports()));\n const target = needsValue\n ? candidates.find(declaration => !declaration.isTypeOnly())\n : candidates.find(declaration => declaration.isTypeOnly()) ?? candidates[0];\n if (target) {\n const plan = planOf(target);\n const existing = new Set(plan.keep.map(spec => (spec.alias ? `${spec.name} as ${spec.alias}` : spec.name)));\n for (const spec of group.specs) {\n if (existing.has(spec.text) || plan.add.some(added => added.text === spec.text)) continue;\n plan.add.push(spec);\n }\n plan.touched = true;\n continue;\n }\n const typeOnly = !needsValue;\n const items = group.specs.map(spec => specText(spec.text, spec.isType, typeOnly));\n const statement = `${kind} ${typeOnly ? \"type \" : \"\"}{ ${items.join(\", \")} } from ${group.quote}${to}${group.quote};`;\n const plan = planOf(group.anchor);\n plan.after.push(statement);\n plan.touched = true;\n }\n }\n\n // Render each touched declaration once.\n const text = sf.getFullText();\n for (const [declaration, plan] of plans) {\n if (!plan.touched) continue;\n const typeOnly = declaration.isTypeOnly();\n const items = [...plan.keep.map(spec => keptText(spec, typeOnly)), ...plan.add.map(added => specText(added.text, added.isType, typeOnly))];\n const hasDefault = N.isImportDeclaration(declaration) && declaration.getDefaultImport() !== undefined;\n const lineStart = text.lastIndexOf(\"\\n\", declaration.getStart() - 1) + 1;\n const indent = /^[ \\t]*/.exec(text.slice(lineStart, declaration.getStart()))?.[0] ?? \"\";\n const after = plan.after.map(statement => `\\n${indent}${statement}`).join(\"\");\n if (items.length === 0 && !hasDefault) {\n if (plan.after.length > 0) {\n result.edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: plan.after.join(`\\n${indent}`) });\n } else {\n // Delete the declaration and its line.\n let end = declaration.getEnd();\n if (text[end] === \"\\r\") end++;\n if (text[end] === \"\\n\") end++;\n result.edits.push({ start: lineStart, end, text: \"\" });\n }\n continue;\n }\n const named = N.isImportDeclaration(declaration) ? declaration.getImportClause()?.getNamedBindings() : declaration.getFirstChildByKind(SyntaxKind.NamedExports);\n if (named && (N.isNamedImports(named) || N.isNamedExports(named))) {\n const defaultImport = N.isImportDeclaration(declaration) ? declaration.getDefaultImport() : undefined;\n if (items.length === 0 && defaultImport) {\n // `import Default, { moved } from` → `import Default from`.\n result.edits.push({ start: defaultImport.getEnd(), end: named.getEnd(), text: \"\" });\n } else {\n result.edits.push({ start: named.getStart(), end: named.getEnd(), text: braces(declaration, named, items) });\n }\n }\n if (after) result.edits.push({ start: declaration.getEnd(), end: declaration.getEnd(), text: after });\n }\n\n // References to a renamed import.\n if (renamedLocals.size > 0) {\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n const next = renamedLocals.get(identifier.getText());\n if (!next) continue;\n const parent = identifier.getParent();\n if (!parent || N.isImportSpecifier(parent) || N.isImportClause(parent) || N.isNamespaceImport(parent) || N.isImportTypeNode(parent)) continue;\n if (N.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) continue;\n if (N.isQualifiedName(parent) && parent.getRight() === identifier) continue;\n if ((N.isPropertyAssignment(parent) || N.isPropertySignature(parent) || N.isMethodDeclaration(parent) || N.isPropertyDeclaration(parent) ||\n N.isMethodSignature(parent) || N.isGetAccessorDeclaration(parent) || N.isSetAccessorDeclaration(parent)) && parent.getNameNode() === identifier) continue;\n if (N.isShorthandPropertyAssignment(parent)) {\n result.edits.push({ start: identifier.getStart(), end: identifier.getEnd(), text: `${identifier.getText()}: ${next}` });\n continue;\n }\n if (N.isExportSpecifier(parent)) {\n if (parent.getExportDeclaration().getModuleSpecifierValue() !== undefined) continue;\n if (parent.getNameNode() === identifier) {\n result.edits.push({ start: identifier.getStart(), end: identifier.getEnd(), text: parent.getAliasNode() ? next : `${next} as ${identifier.getText()}` });\n }\n continue;\n }\n result.edits.push({ start: identifier.getStart(), end: identifier.getEnd(), text: next });\n }\n }\n\n // `import(\"pkg\").Name` in a type.\n for (const importType of sf.getDescendantsOfKind(SyntaxKind.ImportType)) {\n const argument = importType.getArgument();\n const literal = N.isLiteralTypeNode(argument) ? argument.getLiteral() : undefined;\n if (!literal || !N.isStringLiteral(literal)) continue;\n const from = literal.getLiteralValue();\n const qualifier = importType.getQualifier();\n if (!qualifier || !BY_PACKAGE.has(from)) continue;\n const first = N.isIdentifier(qualifier) ? qualifier : qualifier.getFirstDescendantByKind(SyntaxKind.Identifier);\n if (!first) continue;\n const row = movedSymbol(from, first.getText());\n if (!row) continue;\n if (row.to === null) {\n removedLines.push(`line ${importType.getStartLineNumber()}: \\`import(\"${from}\").${first.getText()}\\` — ${row.instead ?? \"it is no longer exported.\"}${guideLink(row)}`);\n continue;\n }\n const quote = literal.getText().charAt(0);\n result.edits.push({ start: literal.getStart(), end: literal.getEnd(), text: `${quote}${row.to}${quote}` });\n if (row.as) result.edits.push({ start: first.getStart(), end: first.getEnd(), text: row.as });\n result.moved.push({ symbol: first.getText(), from, to: row.to, ...(row.as ? { as: row.as } : {}) });\n }\n\n // Namespace imports, `export *`, dynamic imports and `require()`: not guessed at.\n for (const declaration of imports) {\n const from = declaration.getModuleSpecifierValue();\n const namespace = declaration.getNamespaceImport();\n if (!namespace || !BY_PACKAGE.has(from)) continue;\n const local = namespace.getText();\n const uses = new Map<string, number[]>();\n const record = (name: string, node: Node): void => {\n if (!movedSymbol(from, name)) return;\n uses.set(name, [...(uses.get(name) ?? []), node.getStartLineNumber()]);\n };\n for (const access of sf.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n if (access.getExpression().getText() === local) record(access.getName(), access);\n }\n for (const qualified of sf.getDescendantsOfKind(SyntaxKind.QualifiedName)) {\n if (qualified.getLeft().getText() === local) record(qualified.getRight().getText(), qualified);\n }\n if (uses.size > 0) unresolved.push(`line ${declaration.getStartLineNumber()}: \\`import * as ${local} from \"${from}\"\\` uses ${describeUses(from, uses, local)}`);\n }\n for (const declaration of sf.getExportDeclarations()) {\n const from = declaration.getModuleSpecifierValue();\n if (from === undefined || declaration.hasNamedExports() || !BY_PACKAGE.has(from)) continue;\n const moved = (BY_PACKAGE.get(from) ?? []).filter(row => row.to !== null);\n const destinations = [...new Set(moved.map(row => row.to))];\n if (moved.length === 0) continue;\n unresolved.push(`line ${declaration.getStartLineNumber()}: \\`${declaration.getText()}\\` no longer re-exports ${moved.length} name(s) that moved (${moved.slice(0, 6).map(row => row.symbol).join(\", \")}${moved.length > 6 ? \", …\" : \"\"}). If this module's importers read them through it, also re-export them from ${destinations.join(\", \")}.`);\n }\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression();\n const isDynamic = callee.getKind() === SyntaxKind.ImportKeyword;\n const isRequire = N.isIdentifier(callee) && callee.getText() === \"require\";\n if (!isDynamic && !isRequire) continue;\n const argument = call.getArguments()[0];\n if (!argument || !N.isStringLiteral(argument)) continue;\n const from = argument.getLiteralValue();\n if (!BY_PACKAGE.has(from)) continue;\n const uses = new Map<string, number[]>();\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n if (!movedSymbol(from, identifier.getText())) continue;\n const parent = identifier.getParent();\n if (parent && (N.isImportSpecifier(parent) || N.isExportSpecifier(parent))) continue;\n uses.set(identifier.getText(), [...(uses.get(identifier.getText()) ?? []), identifier.getStartLineNumber()]);\n }\n if (uses.size > 0) unresolved.push(`line ${call.getStartLineNumber()}: \\`${isDynamic ? \"import\" : \"require\"}(\"${from}\")\\` and ${describeUses(from, uses)}`);\n }\n\n if (removedLines.length > 0) {\n result.manualSteps.push({\n title: `Replace what 0.31 removed or changed in ${relative}`,\n detail: `The codemod leaves these imports as written; each needs a hand edit. ${removedLines.join(\"; \")}`,\n file: relative\n });\n }\n if (unresolved.length > 0) {\n result.manualSteps.push({\n title: `Repoint the moved names ${relative} reaches without a named import`,\n detail: `The codemod rewrites named imports only. ${unresolved.join(\"; \")}`,\n file: relative\n });\n }\n return result;\n}\n\nfunction describeUses(from: string, uses: ReadonlyMap<string, number[]>, local?: string): string {\n return [...uses].map(([name, lines]) => {\n const row = movedSymbol(from, name);\n const where = row?.to ? `now in ${row.to}${row.as ? ` as \\`${row.as}\\`` : \"\"}` : `gone — ${row?.instead ?? \"\"}`;\n return `\\`${local ? `${local}.` : \"\"}${name}\\` (line ${[...new Set(lines)].join(\", \")}; ${where})`;\n }).join(\", \");\n}\n\nconst SPELLING_SOURCES = new RegExp([\n \"@rebasepro/\",\n ...CALL_OPTION_CHANGES.map(change => `\\\\b${change.callee}\\\\b`),\n ...CODE_SPELLINGS.map(spelling => spelling.pattern.source)\n].join(\"|\"));\n\n/** Whether a file can hold anything this pass reads (so the rest are never parsed). */\nexport function mayNeedImportPass(text: string): boolean {\n return SPELLING_SOURCES.test(text);\n}\n\n/** The lines of `text` matching a spelling, 1-based. */\nfunction matchingLines(text: string, spelling: CodeSpelling): number[] {\n if (spelling.onlyIf && !spelling.onlyIf.test(text)) return [];\n const lines = new Set<number>();\n for (const match of text.matchAll(spelling.pattern)) lines.add(text.slice(0, match.index).split(\"\\n\").length);\n return [...lines];\n}\n\n/**\n * The spellings of a source file whose meaning changed (never rewritten):\n * {@link CODE_SPELLINGS}, and the call options of {@link CALL_OPTION_CHANGES}.\n */\nexport function detectChangedSpellings(ctx: AstContext, sf: SourceFile, relative: string): ManualStep[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const text = sf.getFullText();\n const found: string[] = [];\n for (const spelling of CODE_SPELLINGS) {\n const lines = matchingLines(text, spelling);\n if (lines.length > 0) found.push(`${spelling.spelling} (line ${lines.join(\", \")}): ${spelling.instead} See ${UPGRADE_GUIDE}${spelling.guide}`);\n }\n for (const change of CALL_OPTION_CHANGES) {\n if (!text.includes(change.callee)) continue;\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression();\n const name = N.isPropertyAccessExpression(callee) ? callee.getName() : callee.getText();\n if (name !== change.callee) continue;\n const keys = call.getArguments().flatMap(argument => (N.isObjectLiteralExpression(argument)\n ? argument.getProperties().flatMap(property => ((N.isPropertyAssignment(property) || N.isShorthandPropertyAssignment(property)) && change.keys.includes(property.getName()) ? [property.getName()] : []))\n : []));\n if (keys.length > 0) found.push(`\\`${change.callee}({ ${keys.join(\", \")} })\\` (line ${call.getStartLineNumber()}): ${change.instead} See ${UPGRADE_GUIDE}${change.guide}`);\n }\n }\n if (found.length === 0) return [];\n return [{\n title: `Update what changed meaning in ${relative}`,\n detail: `The codemod does not rewrite these: the new spelling means something different, so each is yours to adapt. ${found.join(\"; \")}`,\n file: relative\n }];\n}\n\n/** A dependency the run added to a workspace package. */\nexport interface AddedDependency {\n /** The `package.json`, relative to the project root. */\n file: string;\n name: string;\n version: string;\n}\n\ntype JsonObject = Record<string, unknown>;\nconst isObject = (value: unknown): value is JsonObject => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst DEPENDENCY_FIELDS = [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const;\n\n/** The nearest `package.json` above a file, inside the project. */\nfunction nearestPackageJson(root: string, file: string): string | undefined {\n let dir = path.dirname(file);\n for (;;) {\n const candidate = path.join(dir, \"package.json\");\n if (fs.existsSync(candidate)) return candidate;\n if (path.resolve(dir) === path.resolve(root) || path.dirname(dir) === dir) return undefined;\n dir = path.dirname(dir);\n }\n}\n\n/** The range a manifest gives its `@rebasepro/*` packages (the first one listed). */\nfunction rebaseRange(manifest: JsonObject): string | undefined {\n for (const field of DEPENDENCY_FIELDS) {\n const deps = manifest[field];\n if (!isObject(deps)) continue;\n for (const [name, range] of Object.entries(deps)) if (name.startsWith(\"@rebasepro/\") && typeof range === \"string\") return range;\n }\n return undefined;\n}\n\n/**\n * Add each package a moved import now names to the workspace package that\n * imports it, when that package does not depend on it yet: in `dependencies`,\n * with the range it gives its other `@rebasepro/*` packages (or the root's).\n * A package with no such range to copy is a manual step.\n *\n * @param root the project root\n * @param needed source file → the packages its imports now name\n * @param read a file's current text (the migration's planned content first)\n */\nexport function planDependencies(\n root: string,\n needed: ReadonlyMap<string, ReadonlySet<string>>,\n read: (file: string) => string | undefined,\n /** Versions to use for packages the config package declared (carried code moved out of config/). */\n configVersions: ReadonlyMap<string, string> = new Map()\n): { files: Map<string, string>; added: AddedDependency[]; manualSteps: ManualStep[]; notes: Note[] } {\n const out = { files: new Map<string, string>(), added: [] as AddedDependency[], manualSteps: [] as ManualStep[], notes: [] as Note[] };\n const byManifest = new Map<string, Set<string>>();\n for (const [file, packages] of needed) {\n const manifest = nearestPackageJson(root, file);\n if (!manifest) continue;\n const set = byManifest.get(manifest) ?? new Set<string>();\n for (const name of packages) set.add(packageOf(name));\n byManifest.set(manifest, set);\n }\n const parse = (file: string): { value: JsonObject; text: string } | undefined => {\n const text = read(file);\n if (text === undefined) return undefined;\n try {\n const value: unknown = JSON.parse(text);\n return isObject(value) ? { value, text } : undefined;\n } catch {\n return undefined;\n }\n };\n const rootManifest = parse(path.join(root, \"package.json\"));\n for (const [manifest, packages] of [...byManifest].sort(([a], [b]) => a.localeCompare(b))) {\n const parsed = parse(manifest);\n if (!parsed) continue;\n const relative = toPosix(path.relative(root, manifest));\n const declared = (name: string): boolean => DEPENDENCY_FIELDS.some(field => {\n const deps = parsed.value[field];\n return isObject(deps) && name in deps;\n });\n const ownName = typeof parsed.value.name === \"string\" ? parsed.value.name : undefined;\n const missing = [...packages].filter(name => name !== ownName && !declared(name)).sort();\n if (missing.length === 0) continue;\n const range = rebaseRange(parsed.value) ?? (rootManifest ? rebaseRange(rootManifest.value) : undefined);\n // A package config/ declared keeps the version config/ gave it.\n const fromConfig = missing.filter(name => configVersions.has(name) && (!name.startsWith(\"@rebasepro/\") || range === undefined));\n if (fromConfig.length > 0) {\n const dependencies = isObject(parsed.value.dependencies) ? { ...parsed.value.dependencies } : {};\n const keys = Object.keys(dependencies);\n const sorted = keys.every((name, index) => index === 0 || keys[index - 1].localeCompare(name) <= 0);\n for (const name of fromConfig) {\n const version = configVersions.get(name) ?? \"\";\n dependencies[name] = version;\n out.added.push({ file: relative, name, version });\n }\n parsed.value = { ...parsed.value, dependencies: sorted ? Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b))) : dependencies };\n const indent = /\\n([ \\t]+)\"/.exec(parsed.text)?.[1] ?? \" \";\n out.files.set(manifest, `${JSON.stringify(parsed.value, null, indent)}${parsed.text.endsWith(\"\\n\") ? \"\\n\" : \"\"}`);\n out.notes.push({ file: relative, message: `added ${fromConfig.map(name => `${name}@${configVersions.get(name) ?? \"\"}`).join(\", \")} to dependencies: code the run moved out of config/ imports ${fromConfig.length > 1 ? \"them\" : \"it\"}, and only config/package.json declared ${fromConfig.length > 1 ? \"them\" : \"it\"}. Run your package manager's install.` });\n out.manualSteps.push({\n title: `Install the packages added to ${relative}`,\n detail: `Code the run moved out of config/ (a customization, a helper) imports ${fromConfig.join(\", \")}, which only config/package.json declared; the codemod added ${fromConfig.length > 1 ? \"them\" : \"it\"} to ${relative} at the version config/ had. Run your package manager's install.`,\n file: relative\n });\n const rest = missing.filter(name => !fromConfig.includes(name));\n if (rest.length === 0) continue;\n missing.splice(0, missing.length, ...rest);\n }\n if (!range) {\n out.manualSteps.push({\n title: `Add ${missing.join(\", \")} to ${relative}`,\n detail: `Imports under ${path.posix.dirname(relative) || \"the project root\"} now name ${missing.join(\", \")}, which ${relative} does not depend on, and it lists no other @rebasepro package to copy the version from. Add ${missing.length > 1 ? \"them\" : \"it\"} at the version of your other @rebasepro packages, then install.`,\n snippet: missing.map(name => `\"${name}\": \"<the version of your other @rebasepro packages>\"`).join(\",\\n\"),\n file: relative\n });\n continue;\n }\n const dependencies = isObject(parsed.value.dependencies) ? { ...parsed.value.dependencies } : {};\n const keys = Object.keys(dependencies);\n const sorted = keys.every((name, index) => index === 0 || keys[index - 1].localeCompare(name) <= 0);\n for (const name of missing) {\n dependencies[name] = range;\n out.added.push({ file: relative, name, version: range });\n }\n const next = sorted ? Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b))) : dependencies;\n const indent = /\\n([ \\t]+)\"/.exec(parsed.text)?.[1] ?? \" \";\n out.files.set(manifest, `${JSON.stringify({ ...parsed.value, dependencies: next }, null, indent)}${parsed.text.endsWith(\"\\n\") ? \"\\n\" : \"\"}`);\n out.notes.push({ file: relative, message: `added ${missing.map(name => `${name}@${range}`).join(\", \")} to dependencies: imports moved there. Run your package manager's install.` });\n out.manualSteps.push({\n title: `Install the packages added to ${relative}`,\n detail: `Imports moved to ${missing.join(\", \")}, so the codemod added ${missing.length > 1 ? \"them\" : \"it\"} to ${relative} at ${range}, the range of your other @rebasepro packages. Run your package manager's install.`,\n file: relative\n });\n }\n return out;\n}\n\n/** The old CLI spellings in a `package.json`'s scripts: a manual step, never rewritten. */\nexport function detectScriptSpellings(manifestText: string, relative: string): ManualStep[] {\n let scripts: unknown;\n try {\n const value: unknown = JSON.parse(manifestText);\n scripts = isObject(value) ? value.scripts : undefined;\n } catch {\n return [];\n }\n if (!isObject(scripts)) return [];\n const found: string[] = [];\n for (const [name, script] of Object.entries(scripts)) {\n if (typeof script !== \"string\") continue;\n for (const spelling of SCRIPT_SPELLINGS) {\n if (matchingLines(script, spelling).length > 0) found.push(`script \"${name}\" uses ${spelling.spelling}: ${spelling.instead} See ${UPGRADE_GUIDE}${spelling.guide}`);\n }\n }\n if (found.length === 0) return [];\n return [{ title: `Update the CLI flags in ${relative}`, detail: found.join(\"; \"), file: relative }];\n}\n","/**\n * Rewriting a project's own code for the SDK and server renames that came\n * with tables (`rebase migrate sdk-calls`, and part of\n * `rebase migrate collections-to-tables` unless `--skip-sdk-calls`).\n *\n * The rules (from the SDK and server slices):\n *\n * 1. `.collection(` → `.table(` on the SDK data surface: `client.data`,\n * `rebase.data`, `rebase.dataAsAdmin`, `context.data`, `ctx.data`,\n * `openRebase().data`, `useData()` / `useSdkData()`, a `createRebaseClient()`\n * result — type arguments kept (`context.data.collection<T>(\"x\")`).\n * 2. `createRebaseClient({ … })`: `collections:` → `tables:`,\n * `collectionsDictionary` → `tablesDictionary`.\n * 3. From the generated `database.types`: `CollectionName` → `TableName`,\n * `CollectionsDictionary` → `TablesDictionary`.\n * 4. Batch operations: `{ op, collection }` → `{ op, table }`.\n * 5. `CollectionClient` → `TableClient`, `SDKCollectionClient` →\n * `SDKTableClient`, `CollectionAccessor` → `TableAccessor`,\n * `CollectionTrashAccessor` → `TableTrashAccessor`.\n * 6. Error codes: `UNKNOWN_COLLECTION` → `UNKNOWN_TABLE`,\n * `INVALID_COLLECTION_PATH` → `INVALID_TABLE_PATH`, `NO_COLLECTIONS` →\n * `NO_TABLES`, `COLLECTION_READ_ONLY` → `TABLE_READ_ONLY`.\n * 7. `maxCachedQueriesPerCollection` / `maxCachedRowsPerCollection` → `…PerTable`.\n * 8. Typed accessors on the data surface: `xCollection` → `xTable`,\n * `collectionCollection` → `collection`.\n * 9. `setCollectionCallbacks(slug, cb)` → `setTableHooks(slug, hooks)`, the\n * callbacks' props adapted as table hooks are (`collection` → `table`,\n * `row` → `values`), `CollectionCallbacks` → `TableHooks`.\n * 10. `storageAuthorize`'s data: `.collection` → `.table`.\n * 11. The rule vocabulary: an `existsIn` policy names its table with `table`\n * (`policy.existsIn({ collection: X …` → `table: X`, a literal\n * `{ kind: \"existsIn\", collection: X }` the same), and a tenant\n * membership source too (`membership: { collection: X …` →\n * `membership: { table: X …`). Wherever the rule is written: a table's\n * `rls`, a shared rule helper, a `tenant` option.\n *\n * The receiver of a `.collection(` call decides. Where a TypeScript program\n * can be built for the file (its nearest tsconfig, the workspace's sources\n * when aliases are given), a receiver whose type is the SDK's data surface\n * (it has the SDK's `table` method) is rewritten whatever its spelling.\n * Otherwise only the receivers in the list above are. Anything else — a\n * Firestore `collection(db, \"x\")`, a CMS helper, a method of the user's own\n * that happens to share the name — is left as written and reported, with\n * its file and line, so a person can check it.\n *\n * Boot options (`collections`, `collectionsDir`, `callbacks`,\n * `auth.collection`) are rewritten only in the one shape the codemod can\n * prove (`collectionsDir: path.join(__dirname, \"…/config/collections\")`);\n * anything else is a manual step with the snippet. Generated SDK files are\n * never rewritten: `rebase generate-sdk` writes them again.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { CallExpression, Node, ObjectLiteralExpression, Project, SourceFile } from \"ts-morph\";\n\nimport type { AstContext, Member, TsMorph } from \"./ast\";\nimport { createAstContext, nodeText, resolveObject, toPosix } from \"./ast\";\nimport { carryHook } from \"./hooks\";\nimport { detectChangedSpellings, detectScriptSpellings, mayNeedImportPass, packageOf, planDependencies, rewriteMovedImports, type AddedDependency } from \"./moved-imports\";\nimport { own } from \"./own\";\nimport { reindent } from \"./print-js\";\nimport type { ManualStep, Note } from \"./types\";\nimport { RULE_KEY_RENAMES } from \"./vocabulary\";\n\n/** The rules, by the name the report counts them under. */\nexport type SdkRule =\n | \"collection-call\" | \"client-options\" | \"generated-types\" | \"batch-op\" | \"type-names\" | \"error-codes\"\n | \"offline-options\" | \"typed-accessor\" | \"table-hooks\" | \"storage-authorize\" | \"boot-options\" | \"rule-vocabulary\" | \"moved-imports\";\n\n/** One `.collection(` left alone, and why. */\nexport interface LeftUnchanged {\n file: string;\n line: number;\n code: string;\n reason: string;\n}\n\n/** What one rewrite run did. */\nexport interface SdkRewriteReport {\n /** Files rewritten, relative to the root, with how many edits each. */\n files: { path: string; edits: number }[];\n /** Edits by rule. */\n counts: Partial<Record<SdkRule, number>>;\n left: LeftUnchanged[];\n manualSteps: ManualStep[];\n notes: Note[];\n /** Generated SDK files found (not rewritten). */\n generated: string[];\n /** Whether receivers were checked by type in at least one file. */\n typeAware: boolean;\n /** Packages added to a workspace package's dependencies because imports moved there. */\n dependencies: AddedDependency[];\n /**\n * `.collection(` calls rewritten by name alone — an untyped (`any`)\n * receiver that is `dataAsAdmin`, or `.data` with a literal table name —\n * printed under \"Rewritten by name — review\".\n */\n byName: { file: string; line: number; code: string }[];\n}\n\nconst RECEIVER_OWNERS = new Set([\"client\", \"rebase\", \"rebaseClient\", \"context\", \"ctx\"]);\nconst DATA_PROPERTIES = new Set([\"data\", \"dataAsAdmin\"]);\nconst DATA_HOOKS = new Set([\"useData\", \"useSdkData\"]);\nconst CLIENT_FACTORY = \"createRebaseClient\";\nconst TYPE_RENAMES: Readonly<Record<string, string>> = {\n CollectionClient: \"TableClient\",\n SDKCollectionClient: \"SDKTableClient\",\n CollectionAccessor: \"TableAccessor\",\n CollectionTrashAccessor: \"TableTrashAccessor\"\n};\nconst GENERATED_TYPE_RENAMES: Readonly<Record<string, string>> = {\n CollectionName: \"TableName\",\n CollectionsDictionary: \"TablesDictionary\"\n};\nconst ERROR_CODES: Readonly<Record<string, string>> = {\n UNKNOWN_COLLECTION: \"UNKNOWN_TABLE\",\n INVALID_COLLECTION_PATH: \"INVALID_TABLE_PATH\",\n NO_COLLECTIONS: \"NO_TABLES\",\n COLLECTION_READ_ONLY: \"TABLE_READ_ONLY\"\n};\nconst OFFLINE_OPTIONS: Readonly<Record<string, string>> = {\n maxCachedQueriesPerCollection: \"maxCachedQueriesPerTable\",\n maxCachedRowsPerCollection: \"maxCachedRowsPerTable\"\n};\n\nconst SOURCE = /\\.(ts|tsx|mts|js|mjs)$/;\nconst IGNORED_DIRS = new Set([\"node_modules\", \"dist\", \"build\", \"out\", \".git\", \"coverage\", \".turbo\", \".next\", \".rebase\", \"dist-bundle\", \"test-results\"]);\n\n/** A line longer than this is not written by a person: the file is bundled or minified output. */\nconst BUNDLE_LINE_LENGTH = 2000;\n\n/**\n * Whether a JavaScript file is bundled or minified output — a vendored build of\n * the client, say. Its identifiers are the bundle's own internals (a build of\n * `@rebasepro/client` reads `maxCachedQueriesPerCollection` from its own\n * options), so rewriting it would break it: it is replaced, not edited.\n */\nexport function isBundledFile(file: string, text: string): boolean {\n if (!/\\.(js|mjs|cjs)$/.test(file)) return false;\n let start = 0;\n while (start < text.length) {\n const newline = text.indexOf(\"\\n\", start);\n const end = newline === -1 ? text.length : newline;\n if (end - start > BUNDLE_LINE_LENGTH) return true;\n start = end + 1;\n }\n return false;\n}\n\n/**\n * A node's symbol, or undefined when the checker has none to give. The\n * checker throws on some files instead of answering (a `.js` script — not a\n * module — read under a tsconfig without `allowJs`), and one such file must\n * not end the run over every other file.\n */\nfunction symbolOf(node: Node): ReturnType<Node[\"getSymbol\"]> {\n try {\n return node.getSymbol();\n } catch {\n return undefined;\n }\n}\n\n/**\n * Whether a file is generated SDK output, which `rebase generate-sdk` rewrites:\n * the header Rebase's generators write, or a generated SDK file name. A file\n * some other generator marks \"do not edit\" (a project's own build step) is\n * the project's code, and is read like any other.\n */\nexport function isGeneratedSdkFile(file: string, text: string): boolean {\n const head = text.slice(0, 400);\n if (/auto-generated by (Rebase|`rebase generate-sdk)/i.test(head)) return true;\n return /[\\\\/]generated[\\\\/]/.test(file) && /(database\\.types|schema\\.meta|register)\\.ts$/.test(file);\n}\n\n/** Every source file of a project the rewrite reads. */\nexport function sdkSourceFiles(root: string, skipDirs: readonly string[] = []): string[] {\n const out: string[] = [];\n const skip = new Set(skipDirs.map(dir => path.resolve(dir)));\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || IGNORED_DIRS.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (!skip.has(full)) walk(full);\n } else if (SOURCE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) {\n out.push(full);\n }\n }\n };\n walk(root);\n return out.sort();\n}\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n rule: SdkRule;\n}\n\n/** A type checker for the files under one tsconfig, when one can be built. */\nclass TypeOracle {\n private readonly projects = new Map<string, Project | null>();\n used = false;\n\n constructor(private readonly tsm: TsMorph, private readonly root: string, private readonly aliases: Record<string, string>) {}\n\n private tsconfigOf(file: string): string | undefined {\n let dir = path.dirname(file);\n for (;;) {\n const candidate = path.join(dir, \"tsconfig.json\");\n if (fs.existsSync(candidate)) return candidate;\n if (dir === this.root || path.dirname(dir) === dir) return undefined;\n dir = path.dirname(dir);\n }\n }\n\n /** The file as a node of a typed program, or undefined. */\n sourceFile(file: string, text: string): SourceFile | undefined {\n const tsconfig = this.tsconfigOf(file);\n if (!tsconfig) return undefined;\n let project = this.projects.get(tsconfig);\n if (project === undefined) {\n try {\n const paths: Record<string, string[]> = {};\n for (const [specifier, target] of Object.entries(this.aliases)) paths[specifier] = [target];\n project = new this.tsm.Project({\n tsConfigFilePath: tsconfig,\n skipAddingFilesFromTsConfig: true,\n ...(Object.keys(paths).length > 0 ? { compilerOptions: { paths, noEmit: true } } : {})\n });\n } catch {\n project = null;\n }\n this.projects.set(tsconfig, project);\n }\n if (!project) return undefined;\n return project.createSourceFile(file, text, { overwrite: true });\n }\n\n /**\n * Whether a receiver's type is the SDK data surface: it has the SDK's\n * `table` method — or, typed by the 0.30 packages a project still has\n * installed when it migrates, the SDK's `collection` method. Either is\n * the SDK's only when a `@rebasepro` package declares it.\n */\n isSdkData(receiver: Node): boolean | undefined {\n try {\n const type = receiver.getType();\n if (type.isAny() || type.isUnknown()) return undefined;\n const method = type.getProperty(\"table\") ?? type.getProperty(\"collection\");\n if (!method) return false;\n this.used = true;\n return method.getDeclarations().some(declaration => /[\\\\/](packages[\\\\/](client|types|common)|@rebasepro[\\\\/])/.test(declaration.getSourceFile().getFilePath()));\n } catch {\n return undefined;\n }\n }\n}\n\n/** Whether a receiver is on the syntactic list (rule 1), following a same-scope `const` once. */\nfunction isListedReceiver(ctx: AstContext, receiver: Node, depth = 0): boolean {\n const { Node: N } = ctx.tsm;\n if (N.isNonNullExpression(receiver) || N.isParenthesizedExpression(receiver) || N.isAsExpression(receiver)) {\n return isListedReceiver(ctx, receiver.getExpression(), depth);\n }\n if (N.isPropertyAccessExpression(receiver) && DATA_PROPERTIES.has(receiver.getName())) {\n const owner = receiver.getExpression();\n if (N.isIdentifier(owner) && RECEIVER_OWNERS.has(owner.getText())) return true;\n if (N.isPropertyAccessExpression(owner) && RECEIVER_OWNERS.has(owner.getName())) return true;\n if (N.isCallExpression(owner) && owner.getExpression().getText() === \"openRebase\") return true;\n if (N.isAwaitExpression(owner)) {\n const inner = owner.getExpression();\n if (N.isCallExpression(inner) && inner.getExpression().getText() === \"openRebase\") return true;\n }\n if (N.isIdentifier(owner) && depth === 0) return isFactoryResult(ctx, owner);\n return false;\n }\n if (N.isCallExpression(receiver) && DATA_HOOKS.has(receiver.getExpression().getText())) return true;\n if (N.isIdentifier(receiver) && depth === 0) {\n if (isFactoryResult(ctx, receiver)) return true;\n const declaration = symbolOf(receiver)?.getDeclarations()[0];\n if (declaration && N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n if (initializer) return isListedReceiver(ctx, initializer, depth + 1);\n }\n }\n return false;\n}\n\n/**\n * Whether an untyped receiver is the SDK by its name: a `dataAsAdmin` property\n * (whatever owns it, a receiver cast to `any` included), reached directly, through\n * a `const`, or through a `const db = () => rebase.dataAsAdmin` call; or a\n * `.data` property, when the call names its table with a string literal.\n */\nfunction isNamedSdkReceiver(ctx: AstContext, receiver: Node, literalTable: boolean, depth = 0): boolean {\n const { Node: N } = ctx.tsm;\n if (depth > 3) return false;\n if (N.isNonNullExpression(receiver) || N.isParenthesizedExpression(receiver) || N.isAsExpression(receiver)) {\n return isNamedSdkReceiver(ctx, receiver.getExpression(), literalTable, depth);\n }\n if (N.isPropertyAccessExpression(receiver)) {\n if (receiver.getName() === \"dataAsAdmin\") return true;\n return receiver.getName() === \"data\" && literalTable;\n }\n const initializerOf = (identifier: Node): Node | undefined => {\n const declaration = symbolOf(identifier)?.getDeclarations()[0];\n if (!declaration || !N.isVariableDeclaration(declaration)) return undefined;\n const statement = declaration.getVariableStatement();\n if (statement && statement.getDeclarationKind() !== ctx.tsm.VariableDeclarationKind.Const) return undefined;\n return declaration.getInitializer();\n };\n if (N.isIdentifier(receiver)) {\n const initializer = initializerOf(receiver);\n return initializer !== undefined && isNamedSdkReceiver(ctx, initializer, literalTable, depth + 1);\n }\n if (N.isCallExpression(receiver) && receiver.getArguments().length === 0 && N.isIdentifier(receiver.getExpression())) {\n const initializer = initializerOf(receiver.getExpression());\n if (!initializer || !N.isArrowFunction(initializer) || initializer.getParameters().length > 0) return false;\n const body = initializer.getBody();\n return !N.isBlock(body) && isNamedSdkReceiver(ctx, body, literalTable, depth + 1);\n }\n return false;\n}\n\n/** The names a data-surface slot goes by: `context.data`, `rebase.dataAsAdmin`, a `data` parameter. */\nconst DATA_SLOTS = new Set([\"data\", \"dataAsAdmin\"]);\n\n/**\n * Whether a receiver IS a data-surface slot by its spelling alone, whatever its\n * type: an expression ending in `.dataAsAdmin` (or an identifier of that name),\n * or one ending in `.data` (or a `data` identifier) when the call names its table\n * with a string literal. A structural type of the project's own over the SDK\n * (`{ dataAsAdmin: { collection(…) } }`) or a `data: any` parameter has no type\n * that says \"SDK\", and a `.collection(` left on one is a TypeError on 0.31 that no\n * type checker reports — so these are rewritten, and listed for review.\n */\nfunction isDataSlot(ctx: AstContext, receiver: Node, literalTable: boolean): boolean {\n const { Node: N } = ctx.tsm;\n if (N.isNonNullExpression(receiver) || N.isParenthesizedExpression(receiver) || N.isAsExpression(receiver)) return isDataSlot(ctx, receiver.getExpression(), literalTable);\n const name = N.isPropertyAccessExpression(receiver) ? receiver.getName() : N.isIdentifier(receiver) ? receiver.getText() : undefined;\n if (name === \"dataAsAdmin\") return true;\n return name === \"data\" && literalTable;\n}\n\n/** Whether a node is the value held by a data slot: `data: { … }`, `dataAsAdmin: { … }`, `const data = { … }` (through `as`/`satisfies`). */\nfunction holdsDataSlot(ctx: AstContext, node: Node): boolean {\n const { Node: N } = ctx.tsm;\n let current: Node = node;\n let parent = current.getParent();\n while (parent && (N.isAsExpression(parent) || N.isSatisfiesExpression(parent) || N.isParenthesizedExpression(parent))) {\n current = parent;\n parent = current.getParent();\n }\n if (!parent) return false;\n if (N.isPropertyAssignment(parent) && parent.getInitializer() === current) return DATA_SLOTS.has(parent.getName());\n if (N.isPropertySignature(parent) && parent.getTypeNode() === current) return DATA_SLOTS.has(parent.getName());\n if (N.isVariableDeclaration(parent) && parent.getInitializer() === current) return DATA_SLOTS.has(parent.getName());\n return false;\n}\n\n/** Whether the receiver's type declares `collection` in an object type a data slot holds (`context: { data: { collection(…) } }`). */\nfunction memberOfSlotType(ctx: AstContext, receiver: Node): boolean {\n const { Node: N } = ctx.tsm;\n try {\n const declarations = receiver.getType().getProperty(\"collection\")?.getDeclarations() ?? [];\n return declarations.some(declaration => {\n const literal = declaration.getParent();\n return (N.isPropertySignature(declaration) || N.isMethodSignature(declaration)) && literal !== undefined && N.isTypeLiteral(literal) && holdsDataSlot(ctx, literal);\n });\n } catch {\n return false;\n }\n}\n\n/** A test file: under a test directory, or named `*.test.*` / `*.spec.*`. */\nfunction isTestFile(relative: string): boolean {\n return /(^|\\/)(test|tests|__tests__|e2e)\\//.test(relative) || /\\.(test|spec)\\.[cm]?[jt]sx?$/.test(relative);\n}\n\n/** Whether an identifier names a `createRebaseClient(...)` result declared in its file. */\nfunction isFactoryResult(ctx: AstContext, identifier: Node): boolean {\n const { Node: N } = ctx.tsm;\n const declaration = symbolOf(identifier)?.getDeclarations()[0];\n if (!declaration || !N.isVariableDeclaration(declaration)) return false;\n let initializer: Node | undefined = declaration.getInitializer();\n while (initializer && (N.isAwaitExpression(initializer) || N.isAsExpression(initializer) || N.isParenthesizedExpression(initializer))) initializer = initializer.getExpression();\n return initializer !== undefined && N.isCallExpression(initializer) && initializer.getExpression().getText() === CLIENT_FACTORY;\n}\n\n/** The object literal a hooks argument denotes: written there, or a same-scope `const`. */\nfunction hooksObject(ctx: AstContext, argument: Node): ObjectLiteralExpression | undefined {\n const { Node: N } = ctx.tsm;\n if (N.isObjectLiteralExpression(argument)) return argument;\n if (N.isIdentifier(argument)) {\n const declaration = symbolOf(argument)?.getDeclarations()[0];\n if (declaration && N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n return initializer ? resolveObject(ctx, initializer).node : undefined;\n }\n }\n return undefined;\n}\n\n/** Rewrite one function member in place (props renamed), returning its edit and its TODOs. */\nfunction adaptFunctionMember(ctx: AstContext, member: Member, name: string, collectionIsValue: boolean): { edit?: { start: number; end: number; text: string }; todos: string[] } {\n const target = member.method ?? member.value;\n if (!target) return { todos: [] };\n const carried = carryHook(ctx, member, name, { collectionIsValue });\n const original = member.method ? undefined : nodeText(target);\n const indent = (() => {\n const full = target.getSourceFile().getFullText();\n const lineStart = full.lastIndexOf(\"\\n\", target.getStart() - 1) + 1;\n return /^[ \\t]*/.exec(full.slice(lineStart, target.getStart()))?.[0] ?? \"\";\n })();\n if (original === carried.text) return { todos: carried.todos };\n if (member.method) {\n return { edit: { start: member.method.getStart(), end: member.method.getEnd(), text: `${member.method.getName()}: ${reindent(carried.text, indent)}` }, todos: carried.todos };\n }\n return { edit: { start: target.getStart(), end: target.getEnd(), text: reindent(carried.text, indent) }, todos: carried.todos };\n}\n\n/** The members of a hooks object that are functions, by name. */\nfunction functionMembers(ctx: AstContext, object: ObjectLiteralExpression): { name: string; member: Member }[] {\n const { Node: N } = ctx.tsm;\n const out: { name: string; member: Member }[] = [];\n for (const property of object.getProperties()) {\n if (N.isMethodDeclaration(property)) out.push({ name: property.getName(), member: { node: property, method: property } });\n else if (N.isPropertyAssignment(property)) {\n const initializer = property.getInitializerOrThrow();\n if (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer)) out.push({ name: property.getName(), member: { node: property, value: initializer } });\n }\n }\n return out;\n}\n\n/**\n * Which rule source an object literal is (rule 11), and so which of\n * {@link RULE_KEY_RENAMES} apply: the argument of an `existsIn(…)` call\n * (`policy.existsIn`, or the function imported bare) or a literal\n * `{ kind: \"existsIn\", … }`; or the value of a `membership:` property (a\n * tenant's membership source). Anything else is not a rule source.\n */\nfunction ruleSourceOf(ctx: AstContext, object: ObjectLiteralExpression): keyof typeof RULE_KEY_RENAMES | undefined {\n const { Node: N } = ctx.tsm;\n const parent = object.getParent();\n if (parent && N.isCallExpression(parent) && parent.getArguments()[0] === object) {\n const callee = parent.getExpression();\n if ((N.isIdentifier(callee) && callee.getText() === \"existsIn\") ||\n (N.isPropertyAccessExpression(callee) && callee.getName() === \"existsIn\")) return \"existsIn\";\n }\n if (parent && N.isPropertyAssignment(parent) && parent.getInitializer() === object && parent.getName() === \"membership\") return \"membership\";\n const isExistsIn = object.getProperties().some(property => {\n if (!N.isPropertyAssignment(property) || property.getName() !== \"kind\") return false;\n const value = property.getInitializer();\n return value !== undefined && (N.isStringLiteral(value) || N.isNoSubstitutionTemplateLiteral(value)) && value.getLiteralValue() === \"existsIn\";\n });\n return isExistsIn ? \"existsIn\" : undefined;\n}\n\n/** Options of {@link rewriteSdkCalls}. */\nexport interface RewriteSdkOptions {\n /** Files to read instead of the ones on disk (what the migration is about to write). */\n overrides?: ReadonlyMap<string, string>;\n /** Directories not to read (the legacy `config/collections`, which is deleted after the migration). */\n skipDirs?: readonly string[];\n /** Files not to read (what the migration moves out of `config/` and removes). */\n skipFiles?: readonly string[];\n /** Module specifiers → files, for the type checker (the workspace's sources in-repo). */\n aliases?: Record<string, string>;\n /** The `backend/schema` directory a `collectionsDir` boot option becomes. */\n schemaDir?: string;\n /** The legacy collections directory, to recognise a `collectionsDir` that points at it. */\n collectionsDir?: string;\n /** The auth table's module and the collection file it came from (absolute): an `auth.collection` naming either is dropped. */\n authFiles?: readonly string[];\n /**\n * The legacy config package's `package.json`. A file the run writes (an override)\n * that imports a package only that manifest declared — a customization carrying a\n * `@rebasepro/cms-types` type, an action's icon library — gets it added to its own\n * package, at the version config/ declared.\n */\n configManifest?: string;\n}\n\n/** Every dependency a package.json declares (any dependency field), with its range. */\nfunction declaredDependencies(text: string | undefined): Map<string, string> {\n const out = new Map<string, string>();\n if (text === undefined) return out;\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return out;\n }\n if (typeof value !== \"object\" || value === null) return out;\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const deps: unknown = Reflect.get(value, field);\n if (typeof deps !== \"object\" || deps === null) continue;\n for (const [name, range] of Object.entries(deps)) if (typeof range === \"string\" && !out.has(name)) out.set(name, range);\n }\n return out;\n}\n\n/**\n * Rewrite every source file of the project at `root`. Returns the new content\n * of each file that changed, and the report.\n */\nexport async function rewriteSdkCalls(root: string, options: RewriteSdkOptions = {}): Promise<{ files: Map<string, string>; report: SdkRewriteReport }> {\n const tsm: TsMorph = await import(\"ts-morph\");\n const ctx = createAstContext(tsm);\n const oracle = new TypeOracle(tsm, root, options.aliases ?? {});\n const report: SdkRewriteReport = { files: [], counts: {}, left: [], manualSteps: [], notes: [], generated: [], typeAware: false, dependencies: [], byName: [] };\n const read = (file: string): string | undefined => options.overrides?.get(file) ?? (fs.existsSync(file) ? fs.readFileSync(file, \"utf8\") : undefined);\n /** Source file → the packages its moved imports now name. */\n const needed = new Map<string, Set<string>>();\n const out = new Map<string, string>();\n const skipped = new Set((options.skipFiles ?? []).map(file => path.resolve(file)));\n const files = new Set(sdkSourceFiles(root, options.skipDirs).filter(file => !skipped.has(file)));\n for (const file of options.overrides?.keys() ?? []) if (SOURCE.test(file)) files.add(file);\n for (const file of [...files].sort()) {\n const text = options.overrides?.get(file) ?? fs.readFileSync(file, \"utf8\");\n const relative = toPosix(path.relative(root, file));\n if (isGeneratedSdkFile(file, text)) {\n if (/collection/i.test(text)) report.generated.push(relative);\n continue;\n }\n if (isBundledFile(file, text)) {\n if (/collection/i.test(text)) {\n report.manualSteps.push({\n title: `Replace the bundled file ${relative}`,\n detail: `${relative} is bundled or minified JavaScript (a line longer than ${BUNDLE_LINE_LENGTH} characters), which the rewrite never edits: its names are the bundle's own. It mentions \\`collection\\`. If it is a build of a @rebasepro package (a vendored @rebasepro/client, say), replace it with the same package's 0.31 build; if it is a build of your own code, rebuild it after migrating the source it came from.`,\n file: relative\n });\n }\n continue;\n }\n const apply = (source: string, list: readonly { start: number; end: number; text: string }[]): string => {\n let next = source;\n for (const edit of [...list].sort((a, b) => b.start - a.start || b.end - a.end)) next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);\n return next;\n };\n let current = text;\n const fileCounts = new Map<SdkRule, number>();\n let editCount = 0;\n if (/collection|Collection|COLLECTION/.test(text)) {\n const typed = oracle.sourceFile(file, text);\n const sf = typed ?? ctx.project.createSourceFile(file, text, { overwrite: true });\n const edits = rewriteFile(ctx, sf, oracle, typed !== undefined, relative, report, options);\n if (!typed) ctx.project.removeSourceFile(sf);\n const afterFirst = apply(text, edits);\n const second = ctx.project.createSourceFile(file, afterFirst, { overwrite: true });\n const hookEdits = adaptHooks(ctx, second, relative, report);\n ctx.project.removeSourceFile(second);\n const all = [...edits, ...hookEdits];\n if (all.length > 0) {\n current = apply(afterFirst, hookEdits);\n editCount += all.length;\n for (const edit of all) fileCounts.set(edit.rule, (fileCounts.get(edit.rule) ?? 0) + 1);\n }\n }\n // The third pass, on what the first two wrote: names that moved, were renamed or removed.\n if (mayNeedImportPass(current)) {\n const third = ctx.project.createSourceFile(file, current, { overwrite: true });\n const moved = rewriteMovedImports(ctx, third, relative);\n report.manualSteps.push(...moved.manualSteps, ...detectChangedSpellings(ctx, third, relative));\n ctx.project.removeSourceFile(third);\n if (moved.edits.length > 0) {\n current = apply(current, moved.edits);\n editCount += moved.moved.length;\n fileCounts.set(\"moved-imports\", (fileCounts.get(\"moved-imports\") ?? 0) + moved.moved.length);\n const packages = needed.get(file) ?? new Set<string>();\n for (const name of moved.moved) packages.add(name.to);\n needed.set(file, packages);\n }\n }\n if (current !== text) {\n out.set(file, current);\n report.files.push({ path: relative, edits: editCount });\n for (const [rule, count] of fileCounts) report.counts[rule] = (report.counts[rule] ?? 0) + count;\n }\n }\n // Packages only config/ declared, imported by what the run writes (carried code moved out of config/).\n const configDeclared = options.configManifest ? declaredDependencies(read(options.configManifest)) : new Map<string, string>();\n {\n for (const [file, written] of options.overrides ?? []) {\n if (!SOURCE.test(file)) continue;\n const text = out.get(file) ?? written;\n for (const match of text.matchAll(/(?:\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\brequire\\s*\\(\\s*)[\"']([^\"'.\\s][^\"'\\s]*)[\"']/g)) {\n const name = packageOf(match[1]);\n // `@rebasepro/cms-types`, which a customization imports for a branded additional-field key, at the range of the others.\n if (!configDeclared.has(name) && name !== \"@rebasepro/cms-types\") continue;\n const packages = needed.get(file) ?? new Set<string>();\n packages.add(name);\n needed.set(file, packages);\n }\n }\n }\n // The workspace packages: a destination a moved import names becomes a dependency; old CLI flags in scripts are steps.\n const dependencies = planDependencies(root, needed, read, configDeclared);\n for (const [file, content] of dependencies.files) out.set(file, content);\n report.dependencies = dependencies.added;\n report.notes.push(...dependencies.notes);\n report.manualSteps.push(...dependencies.manualSteps);\n const manifests = new Set<string>([path.join(root, \"package.json\")]);\n for (const file of files) {\n let dir = path.dirname(file);\n while (dir.startsWith(root) && dir !== root) {\n const candidate = path.join(dir, \"package.json\");\n if (fs.existsSync(candidate)) {\n manifests.add(candidate);\n break;\n }\n dir = path.dirname(dir);\n }\n }\n for (const manifest of [...manifests].sort()) {\n const text = out.get(manifest) ?? read(manifest);\n if (text !== undefined) report.manualSteps.push(...detectScriptSpellings(text, toPosix(path.relative(root, manifest))));\n }\n report.typeAware = oracle.used;\n if (report.generated.length > 0) {\n report.manualSteps.push({\n title: \"Regenerate the typed SDK\",\n detail: `${report.generated.join(\", \")} ${report.generated.length > 1 ? \"are\" : \"is\"} generated SDK output from before the rename; the rewrite never edits generated files. Once the legacy files are removed (the \\`git rm\\` line this run prints — the command refuses a project that still has config/collections), run \\`rebase generate-sdk\\` (with the same output path and options as before) to write ${report.generated.length > 1 ? \"them\" : \"it\"} again.`,\n snippet: \"rebase generate-sdk\"\n });\n }\n report.byName.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line);\n report.left.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line);\n return { files: out, report };\n}\n\nfunction rewriteFile(\n ctx: AstContext,\n sf: SourceFile,\n oracle: TypeOracle,\n typed: boolean,\n relative: string,\n report: SdkRewriteReport,\n options: RewriteSdkOptions\n): Edit[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const edits: Edit[] = [];\n const taken = (start: number, end: number): boolean => edits.some(edit => start < edit.end && edit.start < end);\n const add = (node: Node, text: string, rule: SdkRule): void => {\n if (taken(node.getStart(), node.getEnd())) return;\n edits.push({ start: node.getStart(), end: node.getEnd(), text, rule });\n };\n // The type decides where there is one: a receiver typed as something else\n // (a structural interface of the project's own that only looks like the\n // SDK) is left, however it is spelled. Without a type, the list decides.\n const isSdk = (receiver: Node): boolean => {\n const byType = typed ? oracle.isSdkData(receiver) : undefined;\n if (byType !== undefined) return byType;\n return isListedReceiver(ctx, receiver);\n };\n /** No type and not on the list, but named as the SDK is: `dataAsAdmin`, or `.data` called with a literal table name. */\n const isSdkByName = (receiver: Node, call: CallExpression): boolean => {\n const literal = call.getArguments()[0];\n const literalTable = literal !== undefined && (N.isStringLiteral(literal) || N.isNoSubstitutionTemplateLiteral(literal));\n // Typed as something else (a structural type of the project's own): only the slot's own name decides —\n // or the type's `collection` member being one this pass renames (an object type a data slot holds), so\n // the call and its type stay in step.\n if (typed && oracle.isSdkData(receiver) !== undefined) return isDataSlot(ctx, receiver, literalTable) || (isDataSlot(ctx, receiver, true) && memberOfSlotType(ctx, receiver));\n return isNamedSdkReceiver(ctx, receiver, literalTable) || isDataSlot(ctx, receiver, literalTable);\n };\n const byName = (node: Node, code: Node): void => {\n report.byName.push({ file: relative, line: node.getStartLineNumber(), code: code.getText().split(\"\\n\")[0].slice(0, 120) });\n };\n\n // Imports: generated types (3), SDK type names (5), CollectionCallbacks with setTableHooks (9).\n const renamedLocals = new Map<string, string>();\n for (const declaration of sf.getImportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n const generated = /database\\.types(\\.js)?$/.test(specifier);\n const rebase = specifier.startsWith(\"@rebasepro/\");\n for (const named of declaration.getNamedImports()) {\n const imported = named.getName();\n const next = (generated ? own(GENERATED_TYPE_RENAMES, imported) : undefined) ?? (rebase ? own(TYPE_RENAMES, imported) : undefined);\n if (!next) continue;\n const alias = named.getAliasNode();\n add(named.getNameNode(), next, generated ? \"generated-types\" : \"type-names\");\n if (!alias) renamedLocals.set(imported, next);\n }\n }\n\n const setTableHookFiles = sf.getText().includes(\"setCollectionCallbacks\");\n if (setTableHookFiles) {\n for (const declaration of sf.getImportDeclarations()) {\n if (!declaration.getModuleSpecifierValue().startsWith(\"@rebasepro/\")) continue;\n for (const named of declaration.getNamedImports()) {\n if (named.getName() !== \"CollectionCallbacks\") continue;\n add(named.getNameNode(), \"TableHooks\", \"table-hooks\");\n if (!named.getAliasNode()) renamedLocals.set(\"CollectionCallbacks\", \"TableHooks\");\n }\n }\n }\n\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n const next = renamedLocals.get(identifier.getText());\n if (!next) continue;\n const parent = identifier.getParent();\n if (parent && (N.isImportSpecifier(parent) || (N.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) ||\n (N.isPropertyAssignment(parent) && parent.getNameNode() === identifier))) continue;\n add(identifier, next, own(GENERATED_TYPE_RENAMES, identifier.getText()) ? \"generated-types\" : identifier.getText() === \"CollectionCallbacks\" ? \"table-hooks\" : \"type-names\");\n }\n\n // String error codes (6).\n for (const literal of [...sf.getDescendantsOfKind(SyntaxKind.StringLiteral), ...sf.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral)]) {\n const next = own(ERROR_CODES, literal.getLiteralValue());\n if (next) add(literal, literal.getText().replace(literal.getLiteralValue(), next), \"error-codes\");\n }\n\n // Offline options (7), wherever they are spelled.\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n const next = own(OFFLINE_OPTIONS, identifier.getText());\n if (next) add(identifier, next, \"offline-options\");\n }\n\n // Object literals: createRebaseClient options (2), batch operations (4), rule sources (11).\n for (const object of sf.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression)) {\n const parent = object.getParent();\n const isClientOptions = parent !== undefined && N.isCallExpression(parent) && parent.getExpression().getText() === CLIENT_FACTORY && parent.getArguments()[0] === object;\n const hasOp = object.getProperties().some(property => (N.isPropertyAssignment(property) || N.isShorthandPropertyAssignment(property)) && property.getName() === \"op\");\n const ruleSource = ruleSourceOf(ctx, object);\n const ruleRenames = ruleSource ? RULE_KEY_RENAMES[ruleSource] : undefined;\n for (const property of object.getProperties()) {\n if (!N.isPropertyAssignment(property) && !N.isShorthandPropertyAssignment(property)) continue;\n const name = property.getName();\n let next: string | undefined;\n let rule: SdkRule = \"client-options\";\n if (isClientOptions && name === \"collections\") next = \"tables\";\n else if (isClientOptions && name === \"collectionsDictionary\") next = \"tablesDictionary\";\n else if (hasOp && name === \"collection\") {\n next = \"table\";\n rule = \"batch-op\";\n } else if (ruleRenames && own(ruleRenames, name)) {\n next = own(ruleRenames, name);\n rule = \"rule-vocabulary\";\n }\n if (!next) continue;\n if (N.isShorthandPropertyAssignment(property)) add(property, `${next}: ${name}`, rule);\n else add(property.getNameNode(), next, rule);\n }\n }\n\n // Calls: .collection( (1), typed accessors (8), setCollectionCallbacks (9), boot options.\n for (const access of sf.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n const name = access.getName();\n const receiver = access.getExpression();\n const parent = access.getParent();\n const isCall = parent !== undefined && N.isCallExpression(parent) && parent.getExpression() === access;\n if (name === \"collection\" && isCall) {\n if (isSdk(receiver)) add(access.getNameNode(), \"table\", \"collection-call\");\n else if (isSdkByName(receiver, parent)) {\n add(access.getNameNode(), \"table\", \"collection-call\");\n report.byName.push({ file: relative, line: access.getStartLineNumber(), code: parent.getText().split(\"\\n\")[0].slice(0, 120) });\n } else {\n report.left.push({\n file: relative,\n line: access.getStartLineNumber(),\n code: parent.getText().split(\"\\n\")[0].slice(0, 120),\n reason: typed ? \"left unchanged: the receiver's type is not the SDK data surface\" : \"left unchanged: receiver not recognised\"\n });\n }\n continue;\n }\n if (name === \"collection\" && !isCall && isSdk(receiver)) {\n // A reference to the method rather than a call: `typeof client.data.collection`,\n // `const open = context.data.collection`.\n add(access.getNameNode(), \"table\", \"collection-call\");\n continue;\n }\n // A test double put in the slot: `ctx.data.collection = vi.fn()`, `const open = rebase.data.collection`.\n const assignedDouble = name === \"collection\" && !isCall && parent !== undefined &&\n ((N.isBinaryExpression(parent) && parent.getLeft() === access && parent.getOperatorToken().getKind() === SyntaxKind.EqualsToken) ||\n (N.isVariableDeclaration(parent) && parent.getInitializer() === access)) &&\n isDataSlot(ctx, receiver, true);\n if (assignedDouble || (name === \"collection\" && !isCall && !(typed && oracle.isSdkData(receiver) !== undefined) && isNamedSdkReceiver(ctx, receiver, false))) {\n add(access.getNameNode(), \"table\", \"collection-call\");\n report.byName.push({ file: relative, line: access.getStartLineNumber(), code: (parent ?? access).getText().split(\"\\n\")[0].slice(0, 120) });\n continue;\n }\n if (/^[a-z]\\w*Collection$/.test(name) && !isCall && isSdk(receiver)) {\n add(access.getNameNode(), name === \"collectionCollection\" ? \"collection\" : `${name.slice(0, -\"Collection\".length)}Table`, \"typed-accessor\");\n continue;\n }\n if (name === \"setCollectionCallbacks\" && isCall) {\n add(access.getNameNode(), \"setTableHooks\", \"table-hooks\");\n continue;\n }\n }\n\n // Test doubles of the data surface: a `collection` member of the object (or\n // object type) a data slot holds — `{ dataAsAdmin: { collection: (name) => … } }`,\n // `context: { data: { collection } }`, `const data = { collection(name) { … } }`.\n const slotMembers = [\n ...sf.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression).filter(object => holdsDataSlot(ctx, object)).flatMap(object => object.getProperties()),\n ...sf.getDescendantsOfKind(SyntaxKind.TypeLiteral).filter(literal => holdsDataSlot(ctx, literal)).flatMap(literal => literal.getMembers())\n ];\n const renamedMembers = new Set<Node>();\n for (const member of slotMembers) {\n if (N.isShorthandPropertyAssignment(member) && member.getName() === \"collection\") {\n add(member, \"table: collection\", \"collection-call\");\n } else if ((N.isPropertyAssignment(member) || N.isMethodDeclaration(member) || N.isPropertySignature(member) || N.isMethodSignature(member)) && member.getName() === \"collection\") {\n add(member.getNameNode(), \"table\", \"collection-call\");\n } else {\n continue;\n }\n renamedMembers.add(member);\n byName(member, member);\n }\n if (isTestFile(relative)) {\n // A double the codemod cannot tie to a slot (`makeContext({ collection: … })`): listed, not renamed.\n for (const object of sf.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression)) {\n for (const member of object.getProperties()) {\n if (renamedMembers.has(member)) continue;\n const isFunction = N.isMethodDeclaration(member) || N.isShorthandPropertyAssignment(member) ||\n (N.isPropertyAssignment(member) && (N.isArrowFunction(member.getInitializerOrThrow()) || N.isFunctionExpression(member.getInitializerOrThrow())));\n if (!isFunction || !(N.isMethodDeclaration(member) || N.isShorthandPropertyAssignment(member) || N.isPropertyAssignment(member)) || member.getName() !== \"collection\") continue;\n report.left.push({ file: relative, line: member.getStartLineNumber(), code: member.getText().split(\"\\n\")[0].slice(0, 120), reason: \"left unchanged: a `collection` member of a test double not held by a `data` / `dataAsAdmin` slot — if it stands for the data surface, rename it `table`\" });\n }\n }\n // Assertions over source text: `'collection(\"contacts\").find'`, `/\\.collection\\(\"x\"\\)/`.\n const textual = [\n ...sf.getDescendantsOfKind(SyntaxKind.StringLiteral),\n ...sf.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral),\n ...sf.getDescendantsOfKind(SyntaxKind.RegularExpressionLiteral)\n ];\n for (const literal of textual) {\n const text = literal.getText();\n const next = text.replace(/(?<![\\w$])collection(?=\\\\?\\()/g, \"table\");\n if (next === text) continue;\n add(literal, next, \"collection-call\");\n byName(literal, literal);\n }\n }\n\n // Feature detection of the old name: `typeof x.collection === \"function\"`,\n // `\"collection\" in x`. Left as written, it now silently takes the other\n // branch (on 0.31 there is no `collection`), so each is a manual step.\n const detections: number[] = [];\n for (const typeOf of sf.getDescendantsOfKind(SyntaxKind.TypeOfExpression)) {\n const operand = typeOf.getExpression();\n const access = N.isParenthesizedExpression(operand) ? operand.getExpression() : operand;\n if (!N.isPropertyAccessExpression(access) || access.getName() !== \"collection\") continue;\n if (edits.some(edit => edit.start === access.getNameNode().getStart())) continue; // rewritten with its receiver\n detections.push(typeOf.getStartLineNumber());\n }\n for (const binary of sf.getDescendantsOfKind(SyntaxKind.BinaryExpression)) {\n const left = binary.getLeft();\n if (binary.getOperatorToken().getKind() === SyntaxKind.InKeyword && N.isStringLiteral(left) && left.getLiteralValue() === \"collection\") detections.push(binary.getStartLineNumber());\n }\n if (detections.length > 0) {\n report.manualSteps.push({\n title: `Replace the checks for \\`collection\\` in ${relative}`,\n detail: `Line ${[...new Set(detections)].sort((a, b) => a - b).join(\", \")}: code that tests whether \\`collection\\` exists (\\`typeof x.collection\\`, \\`\"collection\" in x\\`) silently takes the other branch on 0.31, where the data surface has \\`table\\` instead. Test for \\`table\\` and call \\`.table(…)\\` — or drop the check.`,\n file: relative\n });\n }\n\n // Boot options.\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression().getText();\n if (callee !== \"initializeRebaseBackend\" && callee !== \"createRebaseBackend\") continue;\n bootOptions(ctx, call, relative, report, edits, options);\n }\n // `typeof client.data.collection`: the method named in a type query (rule 1).\n for (const qualified of sf.getDescendantsOfKind(SyntaxKind.QualifiedName)) {\n if (qualified.getRight().getText() !== \"collection\") continue;\n const left = qualified.getLeft();\n if (!N.isQualifiedName(left) || !DATA_PROPERTIES.has(left.getRight().getText())) continue;\n const owner = left.getLeft();\n const ownerName = N.isQualifiedName(owner) ? owner.getRight().getText() : owner.getText();\n if (RECEIVER_OWNERS.has(ownerName) || (N.isIdentifier(owner) && isFactoryResult(ctx, owner))) add(qualified.getRight(), \"table\", \"collection-call\");\n }\n return edits;\n}\n\n/**\n * The second pass, over the text the first one wrote: the hooks given to\n * `setTableHooks` (rule 9) and `storageAuthorize`'s data (rule 10) get their\n * props adapted. Run after the call-site renames so a hook's body already\n * reads `.table(` and its whole text can be replaced; a hook already adapted\n * is left as it is, so a second run changes nothing.\n */\nfunction adaptHooks(ctx: AstContext, sf: SourceFile, relative: string, report: SdkRewriteReport): Edit[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const edits: Edit[] = [];\n const taken = (start: number, end: number): boolean => edits.some(edit => start < edit.end && edit.start < end);\n for (const access of sf.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n const parent = access.getParent();\n if (access.getName() !== \"setTableHooks\" || !parent || !N.isCallExpression(parent) || parent.getExpression() !== access) continue;\n const argument = parent.getArguments()[1];\n const object = argument ? hooksObject(ctx, argument) : undefined;\n if (!object) {\n report.manualSteps.push({\n title: `Adapt the hooks passed to setTableHooks in ${relative}`,\n detail: `Line ${access.getStartLineNumber()}: the hooks are not an object literal the codemod can read (\\`${argument?.getText() ?? \"?\"}\\`). Table hooks get \\`table\\` instead of \\`collection\\`, and afterRead / beforeDelete / afterDelete get \\`values\\` instead of \\`row\\`: adapt their parameters.`,\n file: relative\n });\n continue;\n }\n for (const { name: hook, member } of functionMembers(ctx, object)) {\n const adapted = adaptFunctionMember(ctx, member, hook, false);\n if (adapted.edit && !taken(adapted.edit.start, adapted.edit.end)) edits.push({ ...adapted.edit, rule: \"table-hooks\" });\n for (const todo of adapted.todos) {\n report.manualSteps.push({\n title: `Check the ${hook} hook in ${relative}`,\n detail: `${hook} ${todo} The line is marked \\`TODO(rebase-migrate)\\`.`,\n file: relative\n });\n }\n }\n }\n // storageAuthorize's data (10).\n for (const declaration of sf.getVariableDeclarations()) {\n if (declaration.getName() !== \"storageAuthorize\") continue;\n const initializer = declaration.getInitializer();\n if (!initializer || !(N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) continue;\n const adapted = adaptFunctionMember(ctx, { node: declaration, value: initializer }, \"storageAuthorize\", true);\n if (adapted.edit && !taken(adapted.edit.start, adapted.edit.end)) edits.push({ ...adapted.edit, rule: \"storage-authorize\" });\n }\n\n return edits;\n}\n\n/** The boot options of a backend entry: the provable shape rewritten, the rest a manual step. */\n/** The range of a node with its trailing comma and the rest of its line, when that is only whitespace. */\nfunction rangeWithTrailer(node: Node): { start: number; end: number } {\n const text = node.getSourceFile().getFullText();\n let end = node.getEnd();\n if (text[end] === \",\") end++;\n const lineEnd = text.indexOf(\"\\n\", end);\n if (lineEnd !== -1 && /^[ \\t]*$/.test(text.slice(end, lineEnd))) {\n const lineStart = text.lastIndexOf(\"\\n\", node.getStart() - 1) + 1;\n if (/^[ \\t]*$/.test(text.slice(lineStart, node.getStart()))) return { start: lineStart, end: lineEnd + 1 };\n }\n return { start: node.getStart(), end };\n}\n\n/**\n * Drop `auth: { collection: usersCollection }` from a backend entry when the\n * value is an import of the auth table (or of the collection file it came\n * from): the auth table is the one defined with `defineAuthTable`, so the\n * option goes — and the import with it when nothing else uses it. Anything\n * else stays a manual step.\n */\nfunction removeAuthCollection(ctx: AstContext, sf: SourceFile, property: Node, edits: Edit[], options: RewriteSdkOptions): boolean {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const authFiles = new Set((options.authFiles ?? []).map(file => file.replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\")));\n if (authFiles.size === 0 || !N.isPropertyAssignment(property)) return false;\n const value = property.getInitializer();\n if (!value || !N.isIdentifier(value)) return false;\n const local = value.getText();\n const declaration = sf.getImportDeclarations().find(candidate =>\n candidate.getDefaultImport()?.getText() === local || candidate.getNamedImports().some(named => (named.getAliasNode()?.getText() ?? named.getName()) === local));\n if (!declaration) return false;\n const specifier = declaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\")) return false;\n const target = path.resolve(path.dirname(sf.getFilePath()), specifier).replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\");\n if (!authFiles.has(target)) return false;\n edits.push({ ...rangeWithTrailer(property), text: \"\", rule: \"boot-options\" });\n const otherUses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === local && identifier !== value && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n if (otherUses.length > 0) return true;\n const named = declaration.getNamedImports();\n const onlyThis = (declaration.getDefaultImport() ? 1 : 0) + named.length + (declaration.getNamespaceImport() ? 1 : 0) === 1;\n if (onlyThis) edits.push({ ...rangeWithTrailer(declaration), text: \"\", rule: \"boot-options\" });\n else {\n const binding = named.find(entry => (entry.getAliasNode()?.getText() ?? entry.getName()) === local);\n if (binding) edits.push({ ...rangeWithTrailer(binding), text: \"\", rule: \"boot-options\" });\n }\n return true;\n}\n\n/**\n * `collections` (the array the collections index exports) in a backend entry\n * becomes `schemaDir: path.join(__dirname, \"…/schema\")` — when the value is\n * that import, and the file has `path` and a `__dirname` to write it with —\n * and the import goes. The backend loads the same tables from their index.\n */\nfunction replaceCollectionsOption(ctx: AstContext, sf: SourceFile, property: Node, edits: Edit[], options: RewriteSdkOptions): boolean {\n const { Node: N, SyntaxKind } = ctx.tsm;\n if (!options.schemaDir || !options.collectionsDir) return false;\n const value = N.isShorthandPropertyAssignment(property) ? property.getNameNode() : N.isPropertyAssignment(property) ? property.getInitializer() : undefined;\n if (!value || !N.isIdentifier(value)) return false;\n const local = value.getText();\n const declaration = sf.getImportDeclarations().find(candidate => candidate.getNamedImports().some(named => (named.getAliasNode()?.getText() ?? named.getName()) === local));\n if (!declaration) return false;\n const specifier = declaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\")) return false;\n const target = path.resolve(path.dirname(sf.getFilePath()), specifier).replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\").replace(/[\\\\/]index$/, \"\");\n if (target !== path.resolve(options.collectionsDir)) return false;\n const pathLocal = sf.getImportDeclarations().find(candidate => /^(node:)?path$/.test(candidate.getModuleSpecifierValue()))?.getDefaultImport()?.getText();\n const hasDirname = sf.getVariableDeclaration(\"__dirname\") !== undefined;\n if (!pathLocal || !hasDirname) return false;\n const rel = toPosix(path.relative(path.dirname(sf.getFilePath()), options.schemaDir));\n edits.push({ start: property.getStart(), end: property.getEnd(), text: `schemaDir: ${pathLocal}.join(__dirname, ${JSON.stringify(rel.startsWith(\".\") ? rel : `./${rel}`)})`, rule: \"boot-options\" });\n const otherUses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === local && identifier !== value && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n if (otherUses.length === 0) {\n const named = declaration.getNamedImports();\n if (named.length === 1 && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) edits.push({ ...rangeWithTrailer(declaration), text: \"\", rule: \"boot-options\" });\n else {\n const binding = named.find(entry => (entry.getAliasNode()?.getText() ?? entry.getName()) === local);\n if (binding) edits.push({ ...rangeWithTrailer(binding), text: \"\", rule: \"boot-options\" });\n }\n }\n return true;\n}\n\nfunction bootOptions(ctx: AstContext, call: CallExpression, relative: string, report: SdkRewriteReport, edits: Edit[], options: RewriteSdkOptions): void {\n const { Node: N } = ctx.tsm;\n const object = call.getArguments()[0];\n if (!object || !N.isObjectLiteralExpression(object)) return;\n const legacy: string[] = [];\n for (const property of object.getProperties()) {\n if (!N.isPropertyAssignment(property) && !N.isShorthandPropertyAssignment(property)) continue;\n const name = property.getName();\n if (name === \"collectionsDir\" && N.isPropertyAssignment(property) && options.schemaDir && options.collectionsDir) {\n const value = property.getInitializerOrThrow();\n if (N.isCallExpression(value) && /^path\\.(join|resolve)$/.test(value.getExpression().getText())) {\n const args = value.getArguments();\n const base = args[0]?.getText();\n const rest = args.slice(1);\n if ((base === \"__dirname\" || base === \"import.meta.dirname\") && rest.length > 0 && rest.every(arg => N.isStringLiteral(arg))) {\n const from = path.dirname(path.join(path.dirname(call.getSourceFile().getFilePath()), \"x\"));\n const pointed = path.resolve(from, ...rest.map(arg => (N.isStringLiteral(arg) ? arg.getLiteralValue() : \"\")));\n if (path.resolve(pointed) === path.resolve(options.collectionsDir)) {\n const next = toPosix(path.relative(from, options.schemaDir));\n edits.push({ start: property.getStart(), end: property.getEnd(), text: `schemaDir: ${value.getExpression().getText()}(${base}, ${JSON.stringify(next)})`, rule: \"boot-options\" });\n continue;\n }\n }\n }\n legacy.push(name);\n continue;\n }\n if (name === \"collections\" && replaceCollectionsOption(ctx, call.getSourceFile(), property, edits, options)) continue;\n if (name === \"collections\" || name === \"callbacks\" || name === \"collectionsDir\") legacy.push(name);\n if (name === \"auth\" && N.isPropertyAssignment(property)) {\n const auth = property.getInitializerOrThrow();\n const collection = N.isObjectLiteralExpression(auth) ? auth.getProperty(\"collection\") : undefined;\n if (collection) {\n if (!removeAuthCollection(ctx, call.getSourceFile(), collection, edits, options)) legacy.push(\"auth.collection\");\n }\n }\n }\n if (legacy.length === 0) return;\n report.manualSteps.push({\n title: `Update the backend options in ${relative}`,\n detail: `Line ${call.getStartLineNumber()}: ${legacy.map(name => `\\`${name}\\``).join(\", \")} belong to the collection model. Pass the tables instead — \\`schemaDir\\` (the directory whose index exports them) or \\`tables\\` + \\`defaultRls\\` imported from backend/schema; \\`hooks\\` (backend/hooks.ts) for global hooks; the auth table is the one defined with \\`defineAuthTable\\`, so \\`auth.collection\\` goes.`,\n snippet: `${call.getExpression().getText()}({\\n schemaDir: path.join(__dirname, \"<relative path to backend/schema>\"),\\n // or: tables: Object.values(await import(\"<backend/schema>\")), defaultRls,\\n // hooks, (from backend/hooks.ts, if you had global callbacks)\\n // auth: { … }, (without \\`collection\\`)\\n …\\n})`,\n file: relative\n });\n}\n","/**\n * Row-shaped admin hands: custom views, entity actions, display resolvers and\n * additional fields receive `{ row, id }` on 0.31, not the `entity` view model\n * (`entity.values.x`, `entity.id`). A function that destructures `({ entity })`\n * reads `undefined` at run time — and where it is untyped (a carried\n * customization, a component on a loose prop type) no type check says so.\n *\n * Found in the project's frontend code as the run leaves it — a parameter typed\n * with one of the slot prop types, or a function written in a customization's\n * `entityActions` / `entityViews` / `display` / `additionalFields` — each is\n * rewritten when its body reads `entity` only as `entity.values.x`,\n * `entity.values` or `entity.id` (`row.x`, `row`, `id`), and listed in one\n * grouped step with its file and line otherwise.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Node, ObjectBindingPattern } from \"ts-morph\";\n\nimport type { PlanContext } from \"./plan-context\";\nimport { relativeToRoot } from \"./plan-context\";\n\n/** The prop types of the slots that take a row: a parameter typed with one is a row-shaped hand. */\nconst SLOT_TYPES = /\\b(EntityCustomViewParams|EntityActionClickProps|AdditionalFieldDelegateProps|TableDisplayResolver|EntityCustomView|EntityAction|TableEntityAction|TableEntityView|TableAdditionalField)\\b/;\n\n/** The customization keys whose functions take a row. */\nconst SLOT_KEYS = new Set([\"entityActions\", \"entityViews\", \"display\", \"additionalFields\"]);\n\nconst SOURCE = /\\.(ts|tsx|js|jsx|mts|mjs)$/;\nconst IGNORED = new Set([\"node_modules\", \"dist\", \"build\", \"generated\", \".git\", \"coverage\"]);\n\n/** Whether a function is a slot's: typed with a slot prop type, or written under a slot key of a customization. */\nfunction isSlotFunction(plan: PlanContext, fn: Node, pattern: ObjectBindingPattern): boolean {\n const { Node: N } = plan.ast.tsm;\n const parameter = pattern.getParent();\n if (N.isParameterDeclaration(parameter) && SLOT_TYPES.test(parameter.getTypeNode()?.getText() ?? \"\")) return true;\n const holder = fn.getParent();\n if (holder && N.isVariableDeclaration(holder) && SLOT_TYPES.test(holder.getTypeNode()?.getText() ?? \"\")) return true;\n for (const ancestor of fn.getAncestors()) {\n if (N.isPropertyAssignment(ancestor) && SLOT_KEYS.has(ancestor.getName())) return true;\n if (N.isCallExpression(ancestor) && /^(customizeTable|defineFirestoreCollection)$/.test(ancestor.getExpression().getText())) break;\n }\n return false;\n}\n\ninterface Found {\n file: string;\n line: number;\n rewritten: boolean;\n}\n\n/**\n * Rewrite or list the row-shaped hands in the frontend (planned contents first).\n *\n * @returns nothing; planned files are updated and one grouped step is pushed\n */\nexport function planRowShapedHands(plan: PlanContext, frontendDir: string): void {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const files = new Set<string>();\n const walk = (dir: string): void => {\n if (!fs.existsSync(dir)) return;\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || IGNORED.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) walk(full);\n else if (SOURCE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) files.add(full);\n }\n };\n walk(frontendDir);\n for (const file of plan.files.keys()) if (SOURCE.test(file) && !path.relative(frontendDir, file).startsWith(\"..\")) files.add(file);\n const found: Found[] = [];\n for (const file of [...files].sort()) {\n const planned = plan.files.get(file);\n const text = planned ? planned.content : fs.readFileSync(file, \"utf8\");\n if (!/\\bentity\\b/.test(text)) continue;\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/row-hands-${path.basename(file)}`, text, { overwrite: true });\n const edits: { start: number; end: number; text: string }[] = [];\n try {\n for (const pattern of sf.getDescendantsOfKind(SyntaxKind.ObjectBindingPattern)) {\n const parameter = pattern.getParent();\n if (!N.isParameterDeclaration(parameter)) continue;\n const fn = parameter.getParent();\n if (!fn || !(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isFunctionDeclaration(fn) || N.isMethodDeclaration(fn))) continue;\n if (fn.getParameters()[0] !== parameter) continue;\n const element = pattern.getElements().find(candidate => (candidate.getPropertyNameNode()?.getText() ?? candidate.getName()) === \"entity\");\n if (!element || !isSlotFunction(plan, fn, pattern)) continue;\n const line = parameter.getStartLineNumber();\n const body = fn.getBody();\n const others = pattern.getElements().filter(candidate => candidate !== element).map(candidate => candidate.getName());\n // Mechanical only for a plain `entity` binding read as entity.values.x / entity.values / entity.id.\n const uses = body ? body.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier => identifier.getText() === \"entity\" &&\n !(N.isPropertyAccessExpression(identifier.getParent()) && identifier.getParentOrThrow().getChildAtIndex(2) === identifier) &&\n !(N.isPropertyAssignment(identifier.getParent()) && identifier.getParentOrThrow().getChildAtIndex(0) === identifier)) : [];\n const replacements: { start: number; end: number; text: string }[] = [];\n let needsRow = false;\n let needsId = false;\n let mechanical = element.getPropertyNameNode() === undefined && element.getInitializer() === undefined && !element.getDotDotDotToken() && body !== undefined &&\n !others.includes(\"row\") && !others.includes(\"id\");\n for (const use of uses) {\n if (!mechanical) break;\n const access = use.getParent();\n if (!access || !N.isPropertyAccessExpression(access) || access.getExpression() !== use) {\n mechanical = false;\n break;\n }\n if (access.getName() === \"id\") {\n needsId = true;\n replacements.push({ start: access.getStart(), end: access.getEnd(), text: \"id\" });\n } else if (access.getName() === \"values\") {\n needsRow = true;\n replacements.push({ start: access.getStart(), end: access.getEnd(), text: \"row\" });\n } else {\n mechanical = false;\n }\n }\n // `row` / `id` already meaning something else in the body would be captured.\n if (mechanical && body) {\n const bodyText = body.getText();\n const stripped = bodyText.replace(/\\bentity\\.(values|id)\\b/g, \"\");\n if ((needsRow && /\\brow\\b/.test(stripped)) || (needsId && /\\bid\\b/.test(stripped))) mechanical = false;\n }\n if (mechanical && uses.length > 0) {\n const names = [...(needsRow ? [\"row\"] : []), ...(needsId ? [\"id\"] : [])];\n edits.push({ start: element.getStart(), end: element.getEnd(), text: names.join(\", \") }, ...replacements);\n found.push({ file, line, rewritten: true });\n } else {\n found.push({ file, line, rewritten: false });\n }\n }\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n if (edits.length > 0) {\n let next = text;\n for (const edit of edits.sort((a, b) => b.start - a.start)) next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);\n plan.files.set(file, { content: next, role: planned ? `${planned.role}, row-shaped hands` : `row-shaped hands (${relativeToRoot(plan, file)})` });\n }\n }\n const byHand = found.filter(entry => !entry.rewritten);\n const rewritten = found.filter(entry => entry.rewritten);\n if (rewritten.length > 0) {\n plan.notes.push({\n file: \"\",\n message: `${rewritten.length} custom view / entity action / display resolver / additional field function(s) destructured \\`({ entity })\\` and read only \\`entity.values.x\\` / \\`entity.id\\`: rewritten to \\`({ row, id })\\` (\\`row.x\\`, \\`id\\`) — ${rewritten.map(entry => `${relativeToRoot(plan, entry.file)}:${entry.line}`).join(\", \")}.`\n });\n }\n if (byHand.length > 0) {\n plan.manualSteps.push({\n title: \"Make the admin hands row-shaped\",\n detail: `Custom views, entity actions, display resolvers and additional fields receive \\`{ row, id }\\` on 0.31, not \\`entity\\`: \\`({ entity }) => entity.values.title\\` reads undefined (and untyped, no type check says so). Write \\`({ row, id }) => row.title\\` — \\`row\\` is the record as the server sends it (dates as ISO strings, a belongsTo as its foreign-key column), \\`id\\` its primary key as a string; a view's unsaved edits are \\`modifiedValues\\`. These read \\`entity\\` in a way the codemod does not rewrite: ${byHand.map(entry => `${relativeToRoot(plan, entry.file)}:${entry.line}`).join(\", \")}.`\n });\n }\n}\n","/**\n * The manual step that refreshes a migrated project's agent skills.\n *\n * `rebase skills install` copies the Rebase skills into each agent's own\n * directory (`.claude/skills`, `.cursor/rules`, …), where they stay frozen at\n * the release that wrote them. After the migration those copies still teach\n * `defineCollection` and `config/collections`, so the next agent session\n * writes the old layout back. The codemod does not rewrite them — the skills\n * command owns those files and knows which ones the user edited — it names\n * the command to run instead.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { AGENTS, SKILLS_MANIFEST, isAgentKey, type AgentKey } from \"../../commands/skills\";\nimport type { ManualStep } from \"./types\";\n\n/** The agents whose directory in the project holds Rebase skills: a skills manifest, or a `rebase…` entry from an older install. */\nexport function agentsWithInstalledSkills(projectRoot: string): { agent: AgentKey; dir: string }[] {\n const found: { agent: AgentKey; dir: string }[] = [];\n for (const [key, agent] of Object.entries(AGENTS)) {\n if (!isAgentKey(key)) continue;\n const dir = path.join(projectRoot, agent.targetDir);\n if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) continue;\n const entries = fs.readdirSync(dir);\n if (entries.includes(SKILLS_MANIFEST) || entries.some(entry => entry.startsWith(\"rebase\"))) {\n found.push({ agent: key, dir: agent.targetDir });\n }\n }\n return found;\n}\n\n/**\n * The step, or `undefined` when the project holds no installed Rebase skills.\n *\n * @param projectRoot the project being migrated\n */\nexport function refreshSkillsStep(projectRoot: string): ManualStep | undefined {\n const installed = agentsWithInstalledSkills(projectRoot);\n if (installed.length === 0) return undefined;\n const dirs = installed.map(entry => entry.dir);\n const command = `rebase skills install --agent ${installed.map(entry => entry.agent).join(\",\")}`;\n return {\n title: \"Refresh the project's agent skills\",\n detail: `${dirs.join(\", \")} ${dirs.length > 1 ? \"hold copies\" : \"holds a copy\"} of the Rebase agent skills from before the migration, ` +\n \"which still teach `defineCollection` and `config/collections`: an agent reading them writes the old layout back. \" +\n `Run \\`${command}\\` to replace them with the skills this release ships; it removes the skills the release no longer ships ` +\n \"(`rebase-collections` became `rebase-tables`). Files you edited are kept and listed — add `--force` to replace those too.\",\n snippet: command\n };\n}\n","/**\n * Writing the planned files so that a failed verification leaves nothing\n * behind.\n *\n * The migrated modules have to be verified where they will live: their\n * relative imports point at the project's own files, and their bare imports\n * (`@rebasepro/server/schema`) resolve through the backend workspace's\n * `node_modules`, which a temporary directory elsewhere cannot see. So the\n * files are written in place under a journal — every created file and\n * directory recorded, every replaced file's previous content kept — and\n * {@link Journal.rollback} restores the tree exactly when verification fails.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\n/** What was written, so it can be undone. */\nexport class Journal {\n private readonly created: string[] = [];\n private readonly createdDirs: string[] = [];\n private readonly replaced = new Map<string, Buffer>();\n\n /** Write one file, recording what was there before. */\n write(file: string, content: string): void {\n const dir = path.dirname(file);\n const missing: string[] = [];\n let current = dir;\n while (!fs.existsSync(current)) {\n missing.unshift(current);\n current = path.dirname(current);\n }\n for (const created of missing) {\n fs.mkdirSync(created);\n this.createdDirs.push(created);\n }\n if (fs.existsSync(file)) {\n if (!this.replaced.has(file) && !this.created.includes(file)) this.replaced.set(file, fs.readFileSync(file));\n } else if (!this.created.includes(file)) {\n this.created.push(file);\n }\n fs.writeFileSync(file, content);\n }\n\n /** Put every file and directory back as it was. */\n rollback(): void {\n for (const file of [...this.created].reverse()) fs.rmSync(file, { force: true });\n for (const [file, content] of this.replaced) fs.writeFileSync(file, content);\n for (const dir of [...this.createdDirs].reverse()) {\n try {\n fs.rmdirSync(dir);\n } catch {\n // Not empty: something else lives there now. Leave it.\n }\n }\n this.created.length = 0;\n this.createdDirs.length = 0;\n this.replaced.clear();\n }\n}\n","/**\n * The one value a 0.30 collection file imports that 0.31 no longer exports:\n * `defineCollection`, from `@rebasepro/cms-types` or `@rebasepro/common`.\n *\n * The codemod evaluates `config/collections` with the project's installed\n * packages — after an upgrade, 0.31's — so a file that starts\n * `import { defineCollection } from \"@rebasepro/cms-types\"` would fail to\n * load and the migration could not run on exactly the projects it is for.\n * For that load only, each of the two packages is aliased to a shim that\n * re-exports the package as installed and adds `defineCollection` as 0.30\n * defined it: `resolveResourceRefs(collection)` from `@rebasepro/types` (the\n * legacy loader resolves resource handles the same way afterwards, so a\n * project still on 0.30 packages loads the same values). The shims live in a\n * directory of this run's own ({@link createShimDir}), never in the project.\n */\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\n/**\n * The directory one run writes its shims into, and what it wrote there.\n *\n * Fresh per run — `mkdtemp` under the system's temporary directory, which\n * creates it with a random name and mode 0700 — because the shims are code the\n * run then evaluates: a directory any other user could have written to first\n * (the fixed, content-named path this used to be, on a shared `/tmp`) would\n * run whatever they planted there, `--dry-run` included. Every file is\n * created exclusively (`wx`), so a file the run did not write is never used.\n * {@link removeShimDir} deletes it when the run is over, failed or not.\n */\nexport interface ShimDir {\n /** The directory, absolute. */\n path: string;\n /** The files this run created in it, by name. */\n written: Map<string, string>;\n}\n\n/** A private directory for one run's shims. */\nexport function createShimDir(): ShimDir {\n const dir = fs.mkdtempSync(path.join(os.tmpdir(), \"rebase-legacy-shims-\"));\n // `mkdtemp` already creates it 0700 on POSIX; said again for an umask or\n // platform that does not.\n fs.chmodSync(dir, 0o700);\n return { path: dir, written: new Map() };\n}\n\n/** Delete a run's shim directory and everything in it. */\nexport function removeShimDir(dir: ShimDir): void {\n fs.rmSync(dir.path, { recursive: true, force: true });\n}\n\n/**\n * Write one shim into the run's directory and answer its path. A name this\n * run already wrote with the same text is answered again; anything else on\n * disk under that name is refused (`wx`), never read.\n */\nfunction writeShim(dir: ShimDir, name: string, text: string): string {\n const file = path.join(dir.path, name);\n const previous = dir.written.get(name);\n if (previous === text) return file;\n if (previous !== undefined) {\n throw new Error(`Two different shims were asked for under one name (${name}); this is a bug in the migration.`);\n }\n fs.writeFileSync(file, text, { flag: \"wx\", mode: 0o600 });\n dir.written.set(name, text);\n return file;\n}\n\n/** The packages whose 0.30 `defineCollection` the shim restores. */\nconst SHIMMED = [\"@rebasepro/cms-types\", \"@rebasepro/common\"] as const;\nconst TYPES = \"@rebasepro/types\";\n\n/** Where a specifier resolves for the project's config: an alias, or the config package's own resolution. */\nfunction resolveFrom(configDir: string, aliases: Readonly<Record<string, string>>, specifier: string): string | undefined {\n if (Object.prototype.hasOwnProperty.call(aliases, specifier)) return aliases[specifier];\n try {\n return createRequire(path.join(configDir, \"package.json\")).resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\n/** The subpath exports of an installed package (`@rebasepro/common/migrate`), resolved, so the shim's alias does not swallow them. */\nfunction subpathAliases(configDir: string, aliases: Readonly<Record<string, string>>, name: string): Record<string, string> {\n const out: Record<string, string> = {};\n let manifest: string;\n try {\n manifest = createRequire(path.join(configDir, \"package.json\")).resolve(`${name}/package.json`);\n } catch {\n return out;\n }\n let exportsField: unknown;\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(manifest, \"utf8\"));\n exportsField = typeof parsed === \"object\" && parsed !== null && \"exports\" in parsed ? parsed.exports : undefined;\n } catch {\n return out;\n }\n if (typeof exportsField !== \"object\" || exportsField === null) return out;\n for (const key of Object.keys(exportsField)) {\n if (!key.startsWith(\"./\") || key === \"./package.json\" || key.includes(\"*\")) continue;\n const specifier = `${name}/${key.slice(2)}`;\n const target = resolveFrom(configDir, aliases, specifier);\n if (target) out[specifier] = target;\n }\n return out;\n}\n\n/**\n * The module aliases to evaluate a legacy `config/` with: the given ones,\n * plus a shim for each package that lost `defineCollection`.\n *\n * @param configDir the project's `config/`, absolute\n * @param shimDir the run's private shim directory ({@link createShimDir})\n * @param aliases the run's module aliases (in-repo runs map `@rebasepro/*` to source)\n */\nexport function legacyLoadAliases(configDir: string, shimDir: ShimDir, aliases: Readonly<Record<string, string>> = {}): Record<string, string> {\n const out: Record<string, string> = { ...aliases };\n const types = resolveFrom(configDir, aliases, TYPES);\n if (!types) return out;\n // 0.30's `policy.existsIn({ collection, where })`: 0.31's builder reads `table` and would drop the name.\n const typesShim = [\n `// Written by rebase migrate collections-to-tables to load a 0.30 config/: ${TYPES} as installed, with 0.30's policy.existsIn({ collection }).`,\n `export * from ${JSON.stringify(types)};`,\n `import { policy as installedPolicy } from ${JSON.stringify(types)};`,\n \"export const policy = installedPolicy && {\",\n \" ...installedPolicy,\",\n \" existsIn: (args) => installedPolicy.existsIn({ ...args, table: args.table ?? args.collection })\",\n \"};\",\n \"\"\n ].join(\"\\n\");\n const typesFile = writeShim(shimDir, \"_rebasepro_types.ts\", typesShim);\n Object.assign(out, subpathAliases(configDir, aliases, TYPES));\n out[TYPES] = typesFile;\n for (const name of SHIMMED) {\n const real = resolveFrom(configDir, aliases, name);\n if (!real) continue;\n const text = [\n `// Written by rebase migrate collections-to-tables to load a 0.30 config/: ${name} as installed, plus 0.30's defineCollection.`,\n `export * from ${JSON.stringify(real)};`,\n `export { resolveResourceRefs as defineCollection } from ${JSON.stringify(types)};`,\n \"\"\n ].join(\"\\n\");\n const shim = writeShim(shimDir, `${name.replace(/[@/]/g, \"_\")}.ts`, text);\n Object.assign(out, subpathAliases(configDir, aliases, name));\n out[name] = shim;\n }\n return out;\n}\n\n/** A module importer (the run's jiti importer). */\ntype Importer = (file: string) => Promise<Record<string, unknown>>;\n\n/**\n * Shims for the names a 0.30 `config/` imports from a package that 0.31 moved\n * elsewhere — `import { EntityRelation } from \"@rebasepro/types\"`, now in\n * `@rebasepro/cms-types` — so the collection files load with 0.31's packages\n * installed. A name is re-exported from its new package only when the package\n * as installed no longer exports it and the new one does: a project still on\n * 0.30 packages loads exactly as before.\n *\n * @param shimDir the run's private shim directory ({@link createShimDir})\n * @param aliases the aliases the load uses so far ({@link legacyLoadAliases})\n * @param importModule an importer built with those aliases\n * @param moves the moved-symbol table\n */\nexport async function movedNameAliases(\n configDir: string,\n shimDir: ShimDir,\n aliases: Readonly<Record<string, string>>,\n importModule: Importer,\n moves: readonly { symbol: string; from: string; to: string | null; as?: string }[]\n): Promise<Record<string, string>> {\n const out: Record<string, string> = { ...aliases };\n const byPackage = new Map<string, { symbol: string; to: string; as?: string }[]>();\n for (const move of moves) {\n if (move.to === null || move.to === move.from) continue;\n byPackage.set(move.from, [...(byPackage.get(move.from) ?? []), { symbol: move.symbol, to: move.to, ...(move.as ? { as: move.as } : {}) }]);\n }\n const load = async (file: string): Promise<Record<string, unknown> | undefined> => {\n try {\n return await importModule(file);\n } catch {\n return undefined;\n }\n };\n for (const [name, rows] of byPackage) {\n const current = resolveFrom(configDir, aliases, name);\n if (!current) continue;\n const installed = await load(current);\n if (!installed) continue;\n const lines: string[] = [];\n const byDestination = new Map<string, string[]>();\n for (const row of rows) {\n if (row.symbol in installed) continue;\n const destination = resolveFrom(configDir, aliases, row.to);\n if (!destination) continue;\n const exported = row.as ?? row.symbol;\n const module = await load(destination);\n if (!module || !(exported in module)) continue;\n byDestination.set(destination, [...(byDestination.get(destination) ?? []), exported === row.symbol ? row.symbol : `${exported} as ${row.symbol}`]);\n }\n if (byDestination.size === 0) continue;\n lines.push(`// Written by rebase migrate collections-to-tables to load a 0.30 config/: ${name} as installed, plus the names 0.31 moved out of it.`);\n lines.push(`export * from ${JSON.stringify(current)};`);\n for (const [destination, names] of byDestination) lines.push(`export { ${names.join(\", \")} } from ${JSON.stringify(destination)};`);\n const text = `${lines.join(\"\\n\")}\\n`;\n const shim = writeShim(shimDir, `${name.replace(/[@/]/g, \"_\")}-moved.ts`, text);\n if (!Object.prototype.hasOwnProperty.call(out, name)) Object.assign(out, subpathAliases(configDir, aliases, name));\n out[name] = shim;\n }\n return out;\n}\n","/**\n * Evaluating a legacy project the way its loader does.\n *\n * The legacy loader (`loadCollectionsFromDirectory`) was the one definition\n * of \"the collections\": every top-level file of `<config>/collections` but the\n * index, each default-exporting one collection; the index's\n * `defaultSecurityRules` applied to every collection without rules of its own;\n * resource handles resolved to their keys; the strict parse. This reads the\n * same files in the same order with the same rules, so directory defaults,\n * spreads, shared fragments, computed keys, imported constants and\n * assignments after a declaration (`x.securityRules = [...]`) are all values\n * by the time the codemod sees them — exactly the values the server served.\n *\n * The legacy loader is gone from `@rebasepro/server` (the backend boots from\n * `backend/schema`), so its rule is restated here — the same rule the\n * plan-golden corpus reads legacy directories with. Modules are imported\n * through jiti, because a CLI run has no TypeScript loader installed and a\n * project's imports are extensionless.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { SchemaModuleImporter } from \"@rebasepro/server\";\nimport { isLegacyPostgresCollection, type LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\nimport { resolveResourceRefs, type SecurityRule } from \"@rebasepro/types\";\n\n/** A legacy collection, with the file it came from. */\nexport interface LoadedCollection {\n collection: LegacyCollectionConfig;\n /** The file, absolute. */\n file: string;\n}\n\n/** A legacy project, evaluated. */\nexport interface LegacyProject {\n /** The config directory (`config/`), absolute. */\n configDir: string;\n /** `<config>/collections`, absolute. */\n collectionsDir: string;\n /** Every collection, in the loader's order (file name order). */\n collections: LoadedCollection[];\n /** The index's `defaultSecurityRules`, when it exports any. */\n defaultSecurityRules?: SecurityRule[];\n /** The index's `collections` array, when it exports one: the panel's navigation order. */\n navigationOrder?: LegacyCollectionConfig[];\n /** Named exports of `<config>/index.ts`, when there is one (to find `callbacks`, `storageAuthorize`). */\n configIndexExports: string[];\n /**\n * Files of `<config>/collections` that export no collection at all — no\n * default export, and no named export shaped like one: helpers the\n * collection files import (`_predicates.ts`), absolute. A project that passed\n * its collections as an array never had its directory read, so these were\n * never collections; they are moved like any other module of `config/`.\n */\n helperFiles: string[];\n /**\n * Firestore collections the project builds in a module the loader never\n * read: a file under a subdirectory of `<config>/collections`, or a function\n * the index exports (`getAllFirestoreCollections()`), which the app spread\n * into the panel's collections. Empty when there are none.\n */\n builtFirestore: BuiltFirestoreCollection[];\n /** The zero-argument functions that returned Firestore collections, with what each returned. */\n firestoreBuilders: FirestoreBuilder[];\n}\n\n/** A Firestore collection reached outside the loader's top-level files. */\nexport interface BuiltFirestoreCollection {\n collection: LegacyCollectionConfig;\n /**\n * The module whose default export is this collection's object (or one with\n * its slug), absolute — absent when the collection only exists as what a\n * call returns (built per locale, say), so no literal of its own exists.\n */\n file?: string;\n}\n\n/** An exported zero-argument function that returned Firestore collections. */\nexport interface FirestoreBuilder {\n /** The module that exports it, absolute. */\n file: string;\n /** Its export name. */\n exportName: string;\n /** The slugs it returned, in order. */\n slugs: string[];\n /**\n * The slugs it returned as a different object than their file exports — a\n * copy the builder changed at run time (added a field, say), which a\n * conversion of the file alone does not carry.\n */\n changed: string[];\n}\n\n/** A module importer: the CLI's jiti importer (`createSchemaModuleImporter`), or a stand-in in tests. */\nexport type ModuleImporter = SchemaModuleImporter;\n\n/** The loader's file filter (`isCollectionFile` in `@rebasepro/server`). */\nexport function isLegacyCollectionFile(file: string): boolean {\n return (file.endsWith(\".ts\") || file.endsWith(\".js\") || file.endsWith(\".tsx\")) &&\n !file.startsWith(\".\") &&\n !file.includes(\".test.\") &&\n !file.endsWith(\".d.ts\") &&\n file !== \"index.ts\" && file !== \"index.js\" && file !== \"index.tsx\";\n}\n\nfunction isFirestoreCollection(value: unknown): value is LegacyCollectionConfig {\n return isCollection(value) && \"engine\" in value && value.engine === \"firestore\";\n}\n\n/** Every module under the subdirectories of `dir`, absolute, sorted. */\nfunction nestedModules(dir: string): string[] {\n const out: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n if (!entry.isDirectory() || entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const walk = (current: string): void => {\n for (const child of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n const full = path.join(current, child.name);\n if (child.isDirectory()) {\n if (!child.name.startsWith(\".\") && child.name !== \"node_modules\") walk(full);\n } else if (/\\.(ts|tsx|js)$/.test(child.name) && !child.name.endsWith(\".d.ts\") && !child.name.includes(\".test.\")) {\n out.push(full);\n }\n }\n };\n walk(path.join(dir, entry.name));\n }\n return out;\n}\n\n/**\n * Firestore collections the project serves from modules the loader did not\n * read: the default exports of files in subdirectories of the collections\n * directory, and what the exported zero-argument functions of those modules\n * and of the index return (`getAllFirestoreCollections()`). A module that does\n * not load is skipped: nothing proves it served a collection.\n */\nasync function findBuiltFirestore(collectionsDir: string, indexFile: string | undefined, importModule: ModuleImporter): Promise<{ built: BuiltFirestoreCollection[]; builders: FirestoreBuilder[] }> {\n const modules = [...(indexFile ? [indexFile] : []), ...nestedModules(collectionsDir)];\n const byFile = new Map<string, LegacyCollectionConfig>();\n const loaded: { file: string; mod: Record<string, unknown> }[] = [];\n for (const file of modules) {\n try {\n const mod = await importModule(file);\n loaded.push({ file, mod });\n if (file !== indexFile && isFirestoreCollection(mod.default)) byFile.set(file, mod.default);\n } catch {\n // Not loadable on its own (a React module, say): nothing it builds can be attributed to it.\n }\n }\n const builders: FirestoreBuilder[] = [];\n const reached = new Map<string, LegacyCollectionConfig>();\n const exported = new Map<string, LegacyCollectionConfig>();\n for (const collection of byFile.values()) {\n reached.set(collection.slug, collection);\n if (!exported.has(collection.slug)) exported.set(collection.slug, collection);\n }\n // A builder re-exported by an index is the same function: reported once, where it was met first.\n const called = new Set<unknown>();\n for (const { file, mod } of loaded) {\n for (const [exportName, value] of Object.entries(mod)) {\n if (called.has(value)) continue;\n // Only what names itself a collection builder is called: a module of config/ may export anything.\n if (typeof value !== \"function\" || value.length !== 0 || !/collection/i.test(exportName) || /^[A-Z]/.test(exportName)) continue;\n called.add(value);\n let returned: unknown;\n try {\n returned = value();\n } catch {\n continue;\n }\n const list = Array.isArray(returned) ? returned : [returned];\n const collections = list.filter(isFirestoreCollection);\n if (collections.length === 0) continue;\n builders.push({\n file,\n exportName,\n slugs: collections.map(collection => collection.slug),\n changed: collections.filter(collection => exported.has(collection.slug) && exported.get(collection.slug) !== collection).map(collection => collection.slug)\n });\n for (const collection of collections) if (!reached.has(collection.slug)) reached.set(collection.slug, collection);\n }\n }\n // A builder whose collections another builder returns too (`buildContent()` inside `getAll()`) is part of that one's step.\n const outer = builders.filter(builder => !builders.some(other => other !== builder && other.slugs.length > builder.slugs.length && builder.slugs.every(slug => other.slugs.includes(slug))));\n builders.splice(0, builders.length, ...outer);\n const fileOf = new Map<string, string>();\n for (const [file, collection] of byFile) if (!fileOf.has(collection.slug)) fileOf.set(collection.slug, file);\n const built = [...reached.values()].map(collection => {\n const file = fileOf.get(collection.slug);\n return { collection, ...(file ? { file } : {}) };\n });\n return { built, builders };\n}\n\nfunction isSecurityRuleList(value: unknown): value is SecurityRule[] {\n return Array.isArray(value) && value.every(rule => typeof rule === \"object\" && rule !== null);\n}\n\nfunction isCollection(value: unknown): value is LegacyCollectionConfig {\n return typeof value === \"object\" && value !== null && \"slug\" in value && typeof value.slug === \"string\";\n}\n\n/** Thrown when the legacy project cannot be evaluated: its own loader would refuse it too. */\nexport class LegacyLoadError extends Error {\n constructor(message: string, readonly file?: string) {\n super(message);\n }\n}\n\n/**\n * Evaluate `<config>/collections` of a project.\n *\n * @param configDir the config directory, absolute\n */\nexport async function loadLegacyProject(configDir: string, importModule: ModuleImporter): Promise<LegacyProject> {\n const collectionsDir = path.join(configDir, \"collections\");\n if (!fs.existsSync(collectionsDir) || !fs.statSync(collectionsDir).isDirectory()) {\n throw new LegacyLoadError(`There is no ${collectionsDir} directory: nothing to migrate.`, collectionsDir);\n }\n const files = fs.readdirSync(collectionsDir)\n .filter(file => isLegacyCollectionFile(file) && fs.statSync(path.join(collectionsDir, file)).isFile())\n .sort();\n const collections: LoadedCollection[] = [];\n const helperFiles: string[] = [];\n const failures: string[] = [];\n for (const file of files) {\n const full = path.join(collectionsDir, file);\n try {\n const mod = await importModule(full);\n const exported = mod.default;\n if (isCollection(exported)) collections.push({ collection: exported, file: full });\n // Nothing in it is a collection: a helper. A collection exported by\n // name, or a default export that is something else, may be a table\n // the project serves — dropping it would drop the table — so those\n // still refuse.\n else if (exported === undefined && !Object.values(mod).some(isCollection)) helperFiles.push(full);\n else failures.push(`${file}: no default export of a collection`);\n } catch (error) {\n failures.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n if (failures.length > 0) {\n throw new LegacyLoadError(\n `Could not load ${failures.length} collection file(s) from ${collectionsDir}:\\n` +\n failures.map(failure => ` • ${failure}`).join(\"\\n\") +\n \"\\n\\nThe codemod reads the collections exactly as the server does; fix these files first (the server refuses them too).\"\n );\n }\n\n let defaultSecurityRules: SecurityRule[] | undefined;\n let navigationOrder: LegacyCollectionConfig[] | undefined;\n const collectionsIndex = [\"index.ts\", \"index.js\", \"index.tsx\"].map(name => path.join(collectionsDir, name)).find(file => fs.existsSync(file));\n for (const name of [\"index.ts\", \"index.js\", \"index.tsx\"]) {\n const indexFile = path.join(collectionsDir, name);\n if (!fs.existsSync(indexFile)) continue;\n let mod: Record<string, unknown>;\n try {\n mod = await importModule(indexFile);\n } catch (error) {\n throw new LegacyLoadError(\n `Could not load ${indexFile}: ${error instanceof Error ? error.message : String(error)}. ` +\n \"It may declare `defaultSecurityRules`, which decide the policies of every collection without rules; the codemod will not guess them.\",\n indexFile\n );\n }\n const rules = mod.defaultSecurityRules;\n // The array itself, not a copy: an index that applies its defaults in a\n // loop put this very array on each collection, and the lift reads that\n // identity as \"inherits\".\n if (isSecurityRuleList(rules)) defaultSecurityRules = rules;\n const listed = mod.collections;\n if (Array.isArray(listed)) navigationOrder = listed.filter(isCollection);\n break;\n }\n\n // The loader's rule: references resolved, then the defaults given to every\n // Postgres collection that declares no rules of its own — the same array,\n // so the lift can tell an inherited posture from a declared one.\n for (const entry of collections) entry.collection = resolveResourceRefs(entry.collection);\n if (defaultSecurityRules && defaultSecurityRules.length > 0) {\n for (const { collection } of collections) {\n if (isLegacyPostgresCollection(collection) && !collection.securityRules?.length) {\n collection.securityRules = defaultSecurityRules;\n }\n }\n }\n\n const configIndexExports: string[] = [];\n for (const name of [\"index.ts\", \"index.js\"]) {\n const indexFile = path.join(configDir, name);\n if (!fs.existsSync(indexFile)) continue;\n try {\n configIndexExports.push(...Object.keys(await importModule(indexFile)));\n } catch {\n // The config index only re-exports; the collections were read above.\n }\n break;\n }\n\n const { built: builtFirestore, builders: firestoreBuilders } = await findBuiltFirestore(collectionsDir, collectionsIndex, importModule);\n const topLevel = new Set(collections.map(entry => entry.collection.slug));\n\n return {\n configDir,\n collectionsDir,\n collections,\n builtFirestore: builtFirestore.filter(entry => !topLevel.has(entry.collection.slug)),\n firestoreBuilders,\n ...(defaultSecurityRules ? { defaultSecurityRules } : {}),\n ...(navigationOrder ? { navigationOrder } : {}),\n configIndexExports,\n helperFiles\n };\n}\n","/**\n * Path aliases a project imports `config/` through.\n *\n * A frontend often reaches `config/` as `@config/collections/posts` — a\n * tsconfig `paths` entry for the type checker, a Vite `resolve.alias` for the\n * bundler. Such an import is an import of `config/` like a relative one, so\n * the codemod resolves both kinds of alias to the file they name and treats\n * the import as if it had been written relative.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { toPosix } from \"./ast\";\n\n/** One alias: `prefix` (with its trailing `/` for a wildcard) → an absolute path. */\nexport interface PathAlias {\n /** What a specifier starts with: `@config/` for `@config/*`, `@config` for a Vite alias, the whole key for an exact entry. */\n prefix: string;\n /** Whether the rest of the specifier is appended to `target` (`@config/*`, or a Vite alias). */\n wildcard: boolean;\n /** Exact (non-wildcard) Vite aliases also match `prefix/…`. */\n vite: boolean;\n /** The directory (wildcard) or module (exact) it names, absolute. */\n target: string;\n /** The directory whose files the alias applies to (the tsconfig's or Vite config's), absolute. */\n scope: string;\n}\n\nconst IGNORED = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\"]);\n\n/** JSON with comments and trailing commas, as tsconfig files are written. */\nfunction parseJsonc(text: string): unknown {\n let out = \"\";\n let index = 0;\n while (index < text.length) {\n const char = text[index];\n if (char === \"\\\"\") {\n const start = index++;\n while (index < text.length && text[index] !== \"\\\"\") index += text[index] === \"\\\\\" ? 2 : 1;\n out += text.slice(start, ++index);\n } else if (char === \"/\" && text[index + 1] === \"/\") {\n while (index < text.length && text[index] !== \"\\n\") index++;\n } else if (char === \"/\" && text[index + 1] === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n index = end === -1 ? text.length : end + 2;\n } else {\n out += char;\n index++;\n }\n }\n return JSON.parse(out.replace(/,(\\s*[}\\]])/g, \"$1\"));\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction tsconfigAliases(file: string): PathAlias[] {\n let json: unknown;\n try {\n json = parseJsonc(fs.readFileSync(file, \"utf8\"));\n } catch {\n return [];\n }\n const options = isRecord(json) && isRecord(json.compilerOptions) ? json.compilerOptions : undefined;\n if (!options || !isRecord(options.paths)) return [];\n const dir = path.dirname(file);\n const base = typeof options.baseUrl === \"string\" ? path.resolve(dir, options.baseUrl) : dir;\n const out: PathAlias[] = [];\n for (const [key, value] of Object.entries(options.paths)) {\n const first = Array.isArray(value) ? value.find((entry): entry is string => typeof entry === \"string\") : undefined;\n if (first === undefined) continue;\n const wildcard = key.endsWith(\"/*\") && first.endsWith(\"/*\");\n if (!wildcard && (key.includes(\"*\") || first.includes(\"*\"))) continue;\n out.push(wildcard\n ? { prefix: key.slice(0, -1), wildcard: true, vite: false, target: path.resolve(base, first.slice(0, -2)), scope: dir }\n : { prefix: key, wildcard: false, vite: false, target: path.resolve(base, first), scope: dir });\n }\n return out;\n}\n\n/** `\"@x\": path.resolve(__dirname, \"../config\")` (or `resolve(…)`, `import.meta.dirname`) in a Vite config. */\nconst VITE_ALIAS = /[\"']([^\"'\\s]+)[\"']\\s*:\\s*(?:path\\.)?resolve\\(\\s*(?:__dirname|import\\.meta\\.dirname)\\s*,\\s*[\"']([^\"']+)[\"']\\s*\\)/g;\n\nfunction viteAliases(file: string): PathAlias[] {\n const text = fs.readFileSync(file, \"utf8\");\n const dir = path.dirname(file);\n return [...text.matchAll(VITE_ALIAS)].map(match => ({ prefix: match[1], wildcard: true, vite: true, target: path.resolve(dir, match[2]), scope: dir }));\n}\n\n/**\n * Every alias the project's tsconfig files (`compilerOptions.paths`) and Vite\n * configs (`resolve.alias` written as `path.resolve(__dirname, …)`) declare,\n * in the project root and the directories below it. A tsconfig that extends\n * another is read as written: its own `paths` only.\n */\nexport function readPathAliases(root: string): PathAlias[] {\n const out: PathAlias[] = [];\n const visit = (dir: string, depth: number): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || IGNORED.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (depth < 2) visit(full, depth + 1);\n } else if (/^tsconfig.*\\.json$/.test(entry.name)) {\n out.push(...tsconfigAliases(full));\n } else if (/^vite\\.config\\.(ts|mts|js|mjs)$/.test(entry.name)) {\n out.push(...viteAliases(full));\n }\n }\n };\n visit(root, 0);\n return out;\n}\n\n/**\n * The relative specifier an aliased one stands for, from `fromFile` — or\n * undefined when no alias in scope matches it. Longer prefixes win, as both\n * TypeScript and Vite match the most specific entry.\n */\nexport function aliasToRelative(aliases: readonly PathAlias[], fromFile: string, specifier: string): string | undefined {\n const inScope = aliases\n .filter(alias => {\n const relative = path.relative(alias.scope, fromFile);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n })\n .sort((a, b) => b.prefix.length - a.prefix.length);\n for (const alias of inScope) {\n let target: string | undefined;\n if (alias.vite) {\n if (specifier === alias.prefix) target = alias.target;\n else if (specifier.startsWith(`${alias.prefix}/`)) target = path.join(alias.target, specifier.slice(alias.prefix.length + 1));\n } else if (alias.wildcard) {\n if (specifier.startsWith(alias.prefix)) target = path.join(alias.target, specifier.slice(alias.prefix.length));\n } else if (specifier === alias.prefix) {\n target = alias.target.replace(/\\.(tsx?|mts)$/, \"\");\n }\n if (target === undefined) continue;\n const relative = toPosix(path.relative(path.dirname(fromFile), target));\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n }\n return undefined;\n}\n","/**\n * Everything around the collections: `rebase.json`, the workspace, the\n * packages and tsconfigs that named the config package, the other modules of\n * `config/` (resources, storage access, the generated registration), and the\n * frontend's wiring.\n *\n * Arbitrary code is never rewritten. A file in the scaffold's known shape —\n * the `App.tsx`, `vite.config.ts` and `virtual.d.ts` `rebase init` writes — is\n * rewritten exactly; anything else is reported as a manual step with the\n * snippet to apply. The Vite config gains `rebaseBackendGuard()` either way.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { AstContext } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport { aliasToRelative, type PathAlias } from \"./path-aliases\";\nimport { resolveRelative } from \"./modules\";\nimport type { PlanContext } from \"./plan-context\";\nimport type { ManualStep } from \"./types\";\nimport { note, planFile, relativeToRoot } from \"./plan-context\";\nimport { BACKEND_GUARD_EXPORT, BACKEND_GUARD_SNIPPET } from \"../../utils/backend-guard\";\n\ntype JsonObject = Record<string, unknown>;\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readJson(file: string): { value: JsonObject; text: string } | undefined {\n if (!fs.existsSync(file)) return undefined;\n const text = fs.readFileSync(file, \"utf8\");\n try {\n const value: unknown = JSON.parse(text);\n return isObject(value) ? { value, text } : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** JSON written back with the file's own indentation and trailing newline. */\nfunction writeJson(original: string, value: JsonObject): string {\n const indent = /\\n([ \\t]+)\"/.exec(original)?.[1] ?? \" \";\n return `${JSON.stringify(value, null, indent)}${original.endsWith(\"\\n\") ? \"\\n\" : \"\"}`;\n}\n\n/** What `rebase.json` says about the layout, read raw (the CLI's parser refuses the legacy keys). */\nexport interface RawManifest {\n file: string;\n text: string;\n value: JsonObject;\n /** The backend app's key in `apps`. */\n backendName?: string;\n /** The config directory, relative to the root. */\n configDir: string;\n /** The frontend (static) app's root, relative to the root, when there is one. */\n frontendRoot?: string;\n}\n\n/** Read `rebase.json`, if there is one. */\nexport function readRawManifest(root: string): RawManifest {\n const file = path.join(root, \"rebase.json\");\n const read = readJson(file);\n const apps = read && isObject(read.value.apps) ? read.value.apps : {};\n let backendName: string | undefined;\n let configDir = \"config\";\n let frontendRoot: string | undefined;\n for (const [name, app] of Object.entries(apps)) {\n if (!isObject(app)) continue;\n if (app.type === \"backend\" && backendName === undefined) {\n backendName = name;\n if (typeof app.config === \"string\") configDir = app.config;\n }\n if (app.type === \"static\" && frontendRoot === undefined && typeof app.root === \"string\" && typeof app.cms === \"string\") {\n frontendRoot = app.root;\n }\n }\n if (frontendRoot === undefined && fs.existsSync(path.join(root, \"frontend\", \"src\"))) frontendRoot = \"frontend\";\n return { file, text: read?.text ?? \"\", value: read?.value ?? {}, ...(backendName ? { backendName } : {}), configDir, ...(frontendRoot ? { frontendRoot } : {}) };\n}\n\n/** `rebase.json` without `config` and `usersCollection` (the tables directory is the default, so no `tables` key). */\nexport function planManifest(plan: PlanContext, manifest: RawManifest): void {\n if (!manifest.text || !manifest.backendName) return;\n const apps = manifest.value.apps;\n if (!isObject(apps)) return;\n const backend = apps[manifest.backendName];\n if (!isObject(backend) || (!(\"config\" in backend) && !(\"usersCollection\" in backend))) return;\n const { config: _config, usersCollection: _users, ...rest } = backend;\n void _config;\n void _users;\n const next = { ...manifest.value, apps: { ...apps, [manifest.backendName]: rest } };\n planFile(plan, manifest.file, writeJson(manifest.text, next), \"rebase.json\");\n}\n\n/** The config package's name, from `config/package.json`. */\nfunction configPackageName(configDir: string): string | undefined {\n const read = readJson(path.join(configDir, \"package.json\"));\n return read && typeof read.value.name === \"string\" ? read.value.name : undefined;\n}\n\nconst COLLECTIONS_FLAG = /\\s+--collections(?:=|\\s+)\\S+/g;\n\n/** `--filter \"./config\"` (any quoting) in a workspace script: the package is gone. */\nfunction withoutConfigFilter(script: string, configRelative: string): string {\n const escaped = configRelative.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return script.replace(new RegExp(`\\\\s+--filter(?:=|\\\\s+)([\"']?)(?:\\\\./)?${escaped}\\\\1(?=\\\\s|$)`, \"g\"), \"\");\n}\n\n/** The workspace, the packages and the scripts that named the config package or directory. */\nexport function planWorkspace(plan: PlanContext, configDir: string, frontendRoot: string | undefined, keepConfigPackage = false): void {\n // When config/ keeps modules of the project's own, it stays a workspace\n // package, depended on as before: only the collections flags go.\n const root = plan.root;\n const configRelative = relativeToRoot(plan, configDir);\n const packageName = configPackageName(configDir);\n\n const rootPackage = readJson(path.join(root, \"package.json\"));\n if (rootPackage) {\n const value = { ...rootPackage.value };\n let changed = false;\n if (Array.isArray(value.workspaces) && !keepConfigPackage) {\n const kept = value.workspaces.filter(entry => entry !== configRelative && entry !== `./${configRelative}`);\n if (kept.length !== value.workspaces.length) {\n value.workspaces = kept;\n changed = true;\n }\n }\n if (isObject(value.scripts)) {\n const scripts: JsonObject = {};\n for (const [name, script] of Object.entries(value.scripts)) {\n const flagless = typeof script === \"string\" ? script.replace(COLLECTIONS_FLAG, \"\") : script;\n const next = typeof flagless === \"string\" && !keepConfigPackage ? withoutConfigFilter(flagless, configRelative) : flagless;\n if (next !== script) changed = true;\n scripts[name] = next;\n }\n value.scripts = scripts;\n }\n if (changed) planFile(plan, path.join(root, \"package.json\"), writeJson(rootPackage.text, value), \"package.json (workspaces, scripts)\");\n }\n\n const workspaceFile = path.join(root, \"pnpm-workspace.yaml\");\n if (fs.existsSync(workspaceFile) && !keepConfigPackage) {\n const text = fs.readFileSync(workspaceFile, \"utf8\");\n const escaped = configRelative.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const next = text.replace(new RegExp(`^[ \\\\t]*-[ \\\\t]*[\"']?(?:\\\\./)?${escaped}[\"']?[ \\\\t]*\\\\r?\\\\n`, \"m\"), \"\");\n if (next !== text) planFile(plan, workspaceFile, next, \"pnpm-workspace.yaml\");\n }\n\n const members = [\"backend\", ...(frontendRoot ? [frontendRoot] : [])];\n for (const member of members) {\n const file = path.join(root, member, \"package.json\");\n const read = readJson(file);\n if (!read) continue;\n const value = { ...read.value };\n let changed = false;\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const deps = value[field];\n if (!isObject(deps) || packageName === undefined || !(packageName in deps) || keepConfigPackage) continue;\n const { [packageName]: _removed, ...rest } = deps;\n void _removed;\n value[field] = rest;\n changed = true;\n }\n if (isObject(value.scripts)) {\n const scripts: JsonObject = {};\n for (const [name, script] of Object.entries(value.scripts)) {\n let next = script;\n if (typeof script === \"string\") {\n const flagless = script.replace(COLLECTIONS_FLAG, \"\");\n next = keepConfigPackage ? flagless : flagless.replace(/\\s+--watch=\\.\\.\\/config\\/\\S*/g, \"\");\n }\n if (next !== script) changed = true;\n scripts[name] = next;\n }\n value.scripts = scripts;\n }\n if (changed) planFile(plan, file, writeJson(read.text, value), `${member}/package.json`);\n if (member === \"backend\") {\n const deps = isObject(value.dependencies) ? value.dependencies : {};\n if (!(\"@rebasepro/server\" in deps)) {\n const sibling = Object.entries(deps).find(([name]) => name.startsWith(\"@rebasepro/\"))?.[1];\n plan.manualSteps.push({\n title: \"Add @rebasepro/server to the backend\",\n detail: \"The schema modules import their builders from `@rebasepro/server/schema`, and backend/package.json does not depend on `@rebasepro/server`. Add it beside the other @rebasepro packages, then install.\",\n snippet: `\"@rebasepro/server\": ${JSON.stringify(typeof sibling === \"string\" ? sibling : \"<the version of your other @rebasepro packages>\")}`,\n file: relativeToRoot(plan, file)\n });\n }\n }\n }\n}\n\n/** The comment the scaffold now writes above `rootDir`. */\nconst ROOT_DIR_COMMENT = [\n \" // Everything this program compiles lives under backend/, so the emit\",\n \" // mirrors it: `dist/schema/…`, `dist/functions/…`, `dist/src/…`. Saying so\",\n \" // is required from TypeScript 6, which refuses to infer it (TS5011).\"\n];\n\n/** The `//` comment lines directly above line `index`. */\nfunction commentBlockAbove(lines: readonly string[], index: number): { start: number; end: number } {\n let start = index;\n while (start > 0 && /^\\s*\\/\\//.test(lines[start - 1])) start--;\n return { start, end: index };\n}\n\n/** Drop the paragraphs of a `//` comment block that talk about the config package. */\nfunction withoutConfigParagraphs(block: readonly string[]): string[] {\n const paragraphs: string[][] = [[]];\n for (const line of block) {\n if (/^\\s*\\/\\/\\s*$/.test(line)) paragraphs.push([line]);\n else paragraphs[paragraphs.length - 1].push(line);\n }\n const kept = paragraphs.filter(paragraph => !paragraph.some(line => /\\.\\.\\/config\\b|config\\/\\*\\*|\\bconfig (package|workspace)\\b/.test(line)));\n const out = kept.flat();\n while (out.length > 0 && /^\\s*\\/\\/\\s*$/.test(out[0])) out.shift();\n return out;\n}\n\n/**\n * backend/tsconfig.json once `config/` is gone: `../config/**` out of\n * `include` and the new modules in; `rootDir \"..\"` (which existed only so the\n * program could reach ../config) back to `\".\"`, its comment and the include's\n * comment rid of the config package; a `drizzle.config.ts` include that names\n * no file dropped. With `rootDir \".\"` the emit moves from `dist/backend/src` to\n * `dist/src`, so the scripts, `entrypoint.sh` and Dockerfile that name the old\n * path follow. A tsconfig not in that shape is a manual step.\n */\nexport function planBackendTsconfig(plan: PlanContext, wanted: readonly string[], keepConfig = false): void {\n const backendDir = path.join(plan.root, \"backend\");\n const file = path.join(backendDir, \"tsconfig.json\");\n if (!fs.existsSync(file)) return;\n const original = fs.readFileSync(file, \"utf8\");\n const match = /\"include\"\\s*:\\s*\\[([^\\]]*)\\]/.exec(original);\n const entries = match ? [...match[1].matchAll(/\"((?:[^\"\\\\]|\\\\.)*)\"/g)].map(found => found[1]) : [];\n const namesConfig = entries.some(entry => entry.startsWith(\"../config\"));\n const rootUp = /\"rootDir\"\\s*:\\s*\"\\.\\.\"/.test(original);\n if (keepConfig) {\n // The backend still compiles the project's own modules of config/: only add what the migration writes.\n if (!match) return;\n const covers = (pattern: string): boolean => entries.includes(pattern) || entries.includes(\"**/*\") || entries.includes(\"**/*.ts\");\n const missing = wanted.filter(entry => !covers(entry));\n if (missing.length === 0) return;\n const next = [...entries, ...missing];\n planFile(plan, file, `${original.slice(0, match.index)}\"include\": [${next.map(entry => JSON.stringify(entry)).join(\", \")}]${original.slice(match.index + match[0].length)}`, \"backend/tsconfig.json\");\n return;\n }\n if (!namesConfig && !rootUp) return;\n if (!match) {\n plan.manualSteps.push({\n title: \"Point backend/tsconfig.json at the backend only\",\n detail: \"backend/tsconfig.json has `rootDir: \\\"..\\\"` (it compiled ../config) but no `include` the codemod can read. Set `rootDir` to `\\\".\\\"`, include `schema/**/*` and the other backend modules, and run the built entry from `dist/src/` (it was `dist/backend/src/`).\",\n file: relativeToRoot(plan, file)\n });\n return;\n }\n const kept = entries.filter(entry => !entry.startsWith(\"../config\") && !(entry === \"drizzle.config.ts\" && !fs.existsSync(path.join(backendDir, entry))));\n const covers = (pattern: string): boolean => kept.includes(pattern) || kept.includes(\"**/*\") || kept.includes(\"**/*.ts\");\n const next = [...kept, ...wanted.filter(entry => !covers(entry))];\n let text = `${original.slice(0, match.index)}\"include\": [${next.map(entry => JSON.stringify(entry)).join(\", \")}]${original.slice(match.index + match[0].length)}`;\n\n const lines = text.split(\"\\n\");\n const includeLine = lines.findIndex(line => /\"include\"\\s*:/.test(line));\n if (includeLine >= 0) {\n const block = commentBlockAbove(lines, includeLine);\n lines.splice(block.start, block.end - block.start, ...withoutConfigParagraphs(lines.slice(block.start, block.end)));\n }\n let movedEmit = false;\n const rootLine = lines.findIndex(line => /\"rootDir\"\\s*:\\s*\"\\.\\.\"/.test(line));\n if (rootLine >= 0) {\n lines[rootLine] = lines[rootLine].replace(/\"rootDir\"\\s*:\\s*\"\\.\\.\"/, `\"rootDir\": \".\"`);\n const block = commentBlockAbove(lines, rootLine);\n const comments = lines.slice(block.start, block.end);\n if (comments.length === 0 || comments.some(line => /config/.test(line))) lines.splice(block.start, block.end - block.start, ...ROOT_DIR_COMMENT);\n movedEmit = true;\n }\n // No `rootDir` at all: tsc took the common directory of the inputs, which `../config/**`\n // lifted to the project root. Without it that directory is backend/, so the emit moves the same way.\n if (namesConfig && !/\"rootDir\"\\s*:/.test(original)) movedEmit = true;\n text = lines.join(\"\\n\");\n planFile(plan, file, text, \"backend/tsconfig.json\");\n if (movedEmit) planEmitPathMove(plan);\n}\n\n/** `dist/backend/src` → `dist/src` wherever the project names the old emit path. */\nfunction planEmitPathMove(plan: PlanContext): void {\n const candidates = [\n path.join(plan.root, \"package.json\"),\n path.join(plan.root, \"backend\", \"package.json\"),\n path.join(plan.root, \"backend\", \"entrypoint.sh\"),\n path.join(plan.root, \"backend\", \"Dockerfile\"),\n path.join(plan.root, \"Dockerfile\")\n ];\n for (const candidate of candidates) {\n const planned = plan.files.get(candidate);\n const current = planned?.content ?? (fs.existsSync(candidate) ? fs.readFileSync(candidate, \"utf8\") : undefined);\n if (current === undefined || !current.includes(\"dist/backend/\")) continue;\n const next = current.split(\"dist/backend/\").join(\"dist/\");\n plan.files.set(candidate, { content: next, role: planned ? `${planned.role}, emit path` : `${relativeToRoot(plan, candidate)} (emit path dist/src)` });\n }\n}\n\n/** A legacy config module that moves to `backend/`, with its imports moved. */\nexport function planMove(plan: PlanContext, from: string, to: string, role: string): boolean {\n if (!fs.existsSync(from)) return false;\n const text = fs.readFileSync(from, \"utf8\");\n planFile(plan, to, plan.relocator.moveSpecifiersInText(text, from, to, \"backend\"), role);\n return true;\n}\n\nconst SCAFFOLD_COLLECTIONS_IMPORT = `import { collections } from \"virtual:rebase-collections\";`;\nconst SCAFFOLD_COLLECTIONS_PROP = \"collections={collections}\";\n\n/**\n * The file the collection editor writes presentation to in development, as\n * `rebase init` ships it (`templates/template/frontend/src/cms/ui-config.json`),\n * and the two lines that mount it — the import and the `<RebaseCMS>` prop.\n */\nexport const UI_CONFIG_CONTENT = \"{\\n \\\"tables\\\": {}\\n}\\n\";\nconst UI_CONFIG_IMPORT = \"// How the collection editor laid out the tables in development (labels, columns, views).\\nimport uiConfig from \\\"./cms/ui-config.json\\\";\";\nconst UI_CONFIG_PROP = \"uiConfig={uiConfig}\";\n\n/** The frontend's wiring: `App.tsx`, `vite.config.ts`, `virtual.d.ts`, `src/cms/ui-config.json`. */\nexport function planFrontendWiring(plan: PlanContext, frontendDir: string, hasExternal: boolean): void {\n const names = hasExternal ? \"tableCustomizations, externalCollections\" : \"tableCustomizations\";\n const appFile = path.join(frontendDir, \"src\", \"App.tsx\");\n\n // The collection editor's file: created empty, never overwritten. Without\n // it mounted, what the editor saves in development is gone on reload and\n // never ships.\n const uiConfigFile = path.join(frontendDir, \"src\", \"cms\", \"ui-config.json\");\n const appText = fs.existsSync(appFile) ? fs.readFileSync(appFile, \"utf8\") : \"\";\n const mountsUiConfig = /\\buiConfig\\s*=/.test(appText);\n if (!fs.existsSync(uiConfigFile) && !plan.files.has(uiConfigFile)) {\n planFile(plan, uiConfigFile, UI_CONFIG_CONTENT, \"ui-config.json (the collection editor's presentation file)\");\n }\n const wireUiConfig = !mountsUiConfig;\n const cmsSpecifier = plan.specifierStyle === \"js\" ? \"./cms/index.js\" : \"./cms\";\n const importLine = `import { ${names} } from \"${cmsSpecifier}\";${wireUiConfig ? `\\n${UI_CONFIG_IMPORT}` : \"\"}`;\n const props = [\n \"tableCustomizations={tableCustomizations}\",\n ...(hasExternal ? [\"externalCollections={externalCollections}\"] : []),\n ...(wireUiConfig ? [UI_CONFIG_PROP] : [])\n ];\n if (wireUiConfig) {\n const tsconfig = path.join(frontendDir, \"tsconfig.json\");\n const tsconfigText = fs.existsSync(tsconfig) ? fs.readFileSync(tsconfig, \"utf8\") : undefined;\n if (tsconfigText !== undefined && !tsconfigText.includes(\"resolveJsonModule\") && !tsconfigText.includes(\"\\\"extends\\\"\")) {\n note(plan, undefined, `${relativeToRoot(plan, tsconfig)} does not set \\`resolveJsonModule\\`; the type check needs it for \\`import uiConfig from \"./cms/ui-config.json\"\\` (Vite itself imports JSON as is).`);\n }\n }\n const mountStep = (file: string) => plan.manualSteps.push({\n title: \"Mount the table customizations\",\n detail: \"The admin panel no longer takes `collections`: it projects every table from the backend and layers the customizations over it. Replace the `virtual:rebase-collections` import and the `collections` prop of `<RebaseCMS>`.\" +\n (wireUiConfig ? \" Pass `uiConfig` too: in development the collection editor saves presentation to src/cms/ui-config.json, and without the prop it is lost on reload and never ships.\" : \"\"),\n snippet: `${importLine}\\n\\n<RebaseCMS\\n ${props.join(\"\\n \")}\\n {/* …the other props you pass */}\\n/>`,\n file: relativeToRoot(plan, file)\n });\n const mountsCollections = (text: string) => text.includes(\"virtual:rebase-collections\") || /<RebaseCMS[\\s\\S]*?collections=/.test(text);\n if (fs.existsSync(appFile) && (appText.includes(SCAFFOLD_COLLECTIONS_IMPORT) || mountsCollections(appText))) {\n const text = appText;\n const importCount = text.split(SCAFFOLD_COLLECTIONS_IMPORT).length - 1;\n const propCount = text.split(SCAFFOLD_COLLECTIONS_PROP).length - 1;\n // Any other `collections` in the code is a use the rewrite would break,\n // so it falls back to the printed step. A comment that says the word is\n // not one: SongBuzz's admin, `{/* … what the collections don't show */}`\n // beside <RebaseStudio/>, was left for its author to migrate by hand.\n const rest = withoutComments(text.replace(SCAFFOLD_COLLECTIONS_IMPORT, \"\").replace(SCAFFOLD_COLLECTIONS_PROP, \"\"));\n if (importCount === 1 && propCount === 1 && !/\\bcollections\\b/.test(rest)) {\n const propLine = text.split(\"\\n\").find(line => line.includes(SCAFFOLD_COLLECTIONS_PROP)) ?? \"\";\n const indent = /^[ \\t]*/.exec(propLine)?.[0] ?? \"\";\n const next = text\n .replace(SCAFFOLD_COLLECTIONS_IMPORT, importLine)\n .replace(SCAFFOLD_COLLECTIONS_PROP, props.join(`\\n${indent}`));\n planFile(plan, appFile, next, \"App.tsx (mount the customizations)\");\n } else {\n mountStep(appFile);\n }\n } else {\n // The panel is mounted somewhere other than src/App.tsx (an `AdminApp.tsx`, a\n // route module): name every source file that still imports the collections\n // module or passes `collections` to <RebaseCMS>, or nothing tells the author.\n for (const file of frontendSourceFiles(path.join(frontendDir, \"src\"))) {\n if (mountsCollections(fs.readFileSync(file, \"utf8\"))) mountStep(file);\n }\n }\n\n const viteFile = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\"].map(name => path.join(frontendDir, name)).find(candidate => fs.existsSync(candidate));\n if (viteFile) planViteConfig(plan, viteFile);\n\n const virtualFile = path.join(frontendDir, \"src\", \"virtual.d.ts\");\n if (fs.existsSync(virtualFile)) {\n const text = fs.readFileSync(virtualFile, \"utf8\");\n const block = /\\r?\\n?declare module \"virtual:rebase-collections\" \\{\\s*export const collections: [^;]+;\\s*\\}\\r?\\n?/;\n if (block.test(text)) {\n planFile(plan, virtualFile, text.replace(block, \"\\n\").replace(/\\n{3,}/g, \"\\n\\n\"), \"virtual.d.ts (drop the collections module)\");\n } else if (text.includes(\"virtual:rebase-collections\")) {\n plan.manualSteps.push({\n title: \"Drop the virtual collections module declaration\",\n detail: \"Remove the `declare module \\\"virtual:rebase-collections\\\"` block: nothing provides it any more.\",\n file: relativeToRoot(plan, virtualFile)\n });\n }\n }\n}\n\n/**\n * A TSX source with its `//` and block comments blanked out.\n *\n * For one question only — does a word still occur in the code — so it may be\n * coarse: a `//` inside a string (a URL) cuts the rest of that line, which can\n * only hide a use on a line that also holds a URL, and the rewrite it guards is\n * checked by the build that follows.\n */\nfunction withoutComments(text: string): string {\n return text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \" \").replace(/(^|[^:\"'`])\\/\\/[^\\n]*/g, \"$1\");\n}\n\n/** The frontend's own .ts/.tsx sources (no declaration files, no node_modules, not the generated cms/). */\nfunction frontendSourceFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const out: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (entry.name !== \"node_modules\" && entry.name !== \"cms\") out.push(...frontendSourceFiles(full));\n } else if (/\\.tsx?$/.test(entry.name) && !entry.name.endsWith(\".d.ts\")) {\n out.push(full);\n }\n }\n return out.sort();\n}\n\n/**\n * The frontend's Vite config: the collections plugin goes, the backend guard\n * comes.\n *\n * `rebaseCollectionsPlugin` built the panel's collections from\n * config/collections and kept their server half out of the browser bundle.\n * Tables now live in backend/ with their hooks, and the frontend references\n * them as types; `rebaseBackendGuard()` is what refuses a value import of\n * backend/ in the build (and `rebase build` refuses a frontend without it).\n * In the scaffold's shape — the plugin on a line of its own, imported from\n * `@rebasepro/app/vitePlugin` — the one becomes the other in place; any other\n * shape is a manual step with the exact lines.\n */\nfunction planViteConfig(plan: PlanContext, viteFile: string): void {\n const text = fs.readFileSync(viteFile, \"utf8\");\n const guarded = /\\brebaseBackendGuard\\s*\\(/.test(text);\n const pluginLine = /^([ \\t]*)rebaseCollectionsPlugin\\(\\{\\s*collectionsDir:\\s*[\"'][^\"']*[\"']\\s*\\}\\)(,?)[ \\t]*(\\r?\\n)/m;\n const importLine = /(import\\s*\\{[^}]*?)\\brebaseCollectionsPlugin\\b([^}]*\\}\\s*from\\s*[\"']@rebasepro\\/app\\/vitePlugin[\"'])/;\n const scaffoldShape = pluginLine.test(text) && importLine.test(text) && (text.match(/rebaseCollectionsPlugin/g) ?? []).length === 2;\n if (scaffoldShape) {\n const next = guarded\n ? text\n .replace(pluginLine, \"\")\n .replace(/(import\\s*\\{[^}]*?)\\brebaseCollectionsPlugin\\s*,\\s*/, \"$1\")\n .replace(/(import\\s*\\{[^}]*?),\\s*rebaseCollectionsPlugin\\b/, \"$1\")\n : text\n .replace(pluginLine, (_line, indent: string, comma: string, eol: string) => `${indent}${BACKEND_GUARD_EXPORT}()${comma}${eol}`)\n .replace(importLine, `$1${BACKEND_GUARD_EXPORT}$2`);\n planFile(plan, viteFile, next, guarded ? \"vite config (drop the collections plugin)\" : \"vite config (the collections plugin → rebaseBackendGuard)\");\n return;\n }\n if (text.includes(\"rebaseCollectionsPlugin\")) {\n plan.manualSteps.push({\n title: \"Remove the collections Vite plugin\",\n detail: \"`rebaseCollectionsPlugin` built the panel's collections from config/collections, which no longer exists. Remove it from the plugins (and its import); keep `rebaseMcpViewPlugin`.\",\n file: relativeToRoot(plan, viteFile)\n });\n }\n if (!guarded) {\n plan.manualSteps.push({\n title: \"Add the backend guard to the Vite config\",\n detail: \"The frontend imports the tables in backend/ as types only; a value import would ship their server hooks, and every module and secret they reach, to every visitor. \" +\n \"`rebaseBackendGuard()` fails the build and the dev server when anything in the frontend resolves to a file under backend/, and `rebase build` refuses a frontend whose Vite config does not use it.\",\n snippet: BACKEND_GUARD_SNIPPET,\n file: relativeToRoot(plan, viteFile)\n });\n }\n}\n\n/**\n * The other static apps `rebase.json` declares (a public site beside the\n * panel): `rebase build` refuses every one whose Vite config lacks\n * `rebaseBackendGuard()`, not only `frontend/`. Each without it is a manual\n * step — the codemod does not add a dependency on `@rebasepro/app` to an app\n * that may not have one.\n */\nexport function planStaticAppGuards(plan: PlanContext, frontendDir: string | undefined): void {\n // Read raw: a legacy rebase.json (a backend `config` key) does not validate against today's manifest.\n const read = readJson(path.join(plan.root, \"rebase.json\"));\n const apps = read && isObject(read.value.apps) ? Object.values(read.value.apps) : [];\n const roots = apps.flatMap(app => (isObject(app) && app.type === \"static\" && typeof app.root === \"string\" ? [path.resolve(plan.root, app.root)] : []));\n for (const root of new Set(roots)) {\n if (root === plan.root || (frontendDir && root === path.resolve(frontendDir))) continue;\n const viteFile = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\"].map(name => path.join(root, name)).find(file => fs.existsSync(file));\n if (!viteFile || /\\brebaseBackendGuard\\s*\\(/.test(fs.readFileSync(viteFile, \"utf8\"))) continue;\n const pkgFile = path.join(root, \"package.json\");\n const hasApp = fs.existsSync(pkgFile) && fs.readFileSync(pkgFile, \"utf8\").includes('\"@rebasepro/app\"');\n plan.manualSteps.push({\n title: \"Add the backend guard to the Vite config\",\n detail: `${relativeToRoot(plan, root)}/ is a static app of rebase.json, and \\`rebase build\\` refuses a static app whose Vite config does not use \\`rebaseBackendGuard()\\`` +\n (hasApp ? \".\" : `. Add \\`@rebasepro/app\\` to its devDependencies (${relativeToRoot(plan, pkgFile)}) for \\`@rebasepro/app/vitePlugin\\`.`),\n snippet: BACKEND_GUARD_SNIPPET,\n file: relativeToRoot(plan, viteFile)\n });\n }\n}\n\n/** Files of `config/` nothing the codemod moved needs, which the user should look at before deleting the directory. */\nexport function unmovedConfigFiles(plan: PlanContext, configDir: string, handled: ReadonlySet<string>): string[] {\n const out: string[] = [];\n const skip = new Set([\"node_modules\", \"dist\", \"generated\"]);\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || skip.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n continue;\n }\n if (handled.has(full)) continue;\n if (/\\.d\\.ts$/.test(entry.name) || entry.name === \"package.json\" || /^tsconfig.*\\.json$/.test(entry.name)) continue;\n if (!/\\.(ts|tsx|js|mjs|json)$/.test(entry.name)) continue;\n out.push(relativeToRoot(plan, full));\n }\n };\n if (fs.existsSync(configDir)) walk(configDir);\n return out.sort();\n}\n\n/** Where a module that imported something from `config/` should import it from now. */\nexport interface ConfigImporter {\n file: string;\n line: number;\n /** As written: relative, or through a path alias (`@config/collections/posts`). */\n specifier: string;\n /** The same import written relative to the file (equal to `specifier` when it was). */\n relativeSpecifier: string;\n target: string;\n}\n\nconst SOURCE_FILE = /\\.(ts|tsx|mts|js|jsx|mjs)$/;\nconst SPECIFIER = /(?:\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\brequire\\s*\\(\\s*)[\"']([^\"'\\s]+)[\"']/g;\n\n/**\n * Every module outside `config/` that imports something inside it — a custom\n * backend entry importing `config/collections/users`, a test importing a\n * collection — relative, or through a path alias the project's tsconfig\n * `paths` or Vite `resolve.alias` declares. After the migration those imports\n * point at nothing.\n *\n * @param skip files the run rewrites itself\n */\nexport function findConfigImporters(root: string, configDir: string, skip: ReadonlySet<string>, aliases: readonly PathAlias[] = []): ConfigImporter[] {\n return scanSources(root, configDir, skip, aliases).importers;\n}\n\n/** A use of a server API the table model renamed. */\nexport interface LegacyApiUse {\n file: string;\n line: number;\n /** The legacy name as written. */\n api: string;\n /** What it is now. */\n replacement: string;\n}\n\n/** Server APIs of the collection model, and what replaces each. */\nconst LEGACY_APIS: readonly { pattern: RegExp; api: string; replacement: string }[] = [\n { pattern: /\\bsetCollectionCallbacks\\s*\\(/g, api: \"setCollectionCallbacks\", replacement: \"`backend.setTableHooks(slug, hooks)` — table hooks get `table` for `collection`, and `values` for `row` in afterRead / beforeDelete / afterDelete\" },\n { pattern: /\\bcollectionRegistry\\b/g, api: \"collectionRegistry\", replacement: \"`backend.getTableDescriptor(slug)` / `backend.getTableDescriptors()` to read a table, and `backend.setTableHooks(slug, hooks)` to attach hooks\" },\n { pattern: /\\bcollectionsDir\\s*:/g, api: \"collectionsDir\", replacement: \"`schemaDir` (the directory whose index exports the tables) or `tables`\" }\n];\n\n/** Every use of a renamed collection-model server API in the project's own code (outside `config/`). */\nexport function findLegacyApiUses(root: string, configDir: string, skip: ReadonlySet<string>, handled: ReadonlySet<string> = new Set()): LegacyApiUse[] {\n return scanSources(root, configDir, skip).apis.filter(use => !handled.has(use.api));\n}\n\n/**\n * The text with every comment blanked to spaces, newlines kept, so offsets\n * and line numbers still point into the original. Strings and template\n * literals are skipped over (a `//` inside a URL is not a comment). The\n * scaffold's example script ships its typed-SDK import commented out\n * (`// import type { Database } from \"../config/database.types\"`): read\n * as code, every such project got a manual step for a line that is not there.\n */\nfunction blankComments(text: string): string {\n const out = text.split(\"\");\n let index = 0;\n const blank = (from: number, to: number): void => {\n for (let at = from; at < to; at++) if (out[at] !== \"\\n\") out[at] = \" \";\n };\n while (index < text.length) {\n const char = text[index];\n const next = text[index + 1];\n if (char === \"/\" && next === \"/\") {\n const end = text.indexOf(\"\\n\", index);\n const stop = end === -1 ? text.length : end;\n blank(index, stop);\n index = stop;\n } else if (char === \"/\" && next === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n const stop = end === -1 ? text.length : end + 2;\n blank(index, stop);\n index = stop;\n } else if (char === \"\\\"\" || char === \"'\" || char === \"`\") {\n index++;\n while (index < text.length && text[index] !== char) {\n if (text[index] === \"\\\\\") index++;\n else if (char !== \"`\" && text[index] === \"\\n\") break;\n index++;\n }\n index++;\n } else {\n index++;\n }\n }\n return out.join(\"\");\n}\n\nfunction scanSources(root: string, configDir: string, skip: ReadonlySet<string>, aliases: readonly PathAlias[] = []): { importers: ConfigImporter[]; apis: LegacyApiUse[] } {\n const out: ConfigImporter[] = [];\n const apis: LegacyApiUse[] = [];\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\"]);\n const inConfig = (file: string): boolean => {\n const relative = path.relative(configDir, file);\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n };\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || ignored.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (!inConfig(full)) walk(full);\n continue;\n }\n if (!SOURCE_FILE.test(entry.name) || entry.name.endsWith(\".d.ts\") || skip.has(full)) continue;\n const text = blankComments(fs.readFileSync(full, \"utf8\"));\n for (const legacy of LEGACY_APIS) {\n for (const match of text.matchAll(legacy.pattern)) {\n apis.push({ file: full, line: text.slice(0, match.index).split(\"\\n\").length, api: legacy.api, replacement: legacy.replacement });\n }\n }\n if (!text.includes(\"config\") && !aliases.some(alias => text.includes(alias.prefix))) continue;\n for (const match of text.matchAll(SPECIFIER)) {\n const specifier = match[1];\n const relativeSpecifier = /^\\.{1,2}\\//.test(specifier) ? specifier : aliasToRelative(aliases, full, specifier);\n if (relativeSpecifier === undefined) continue;\n const target = path.resolve(path.dirname(full), relativeSpecifier);\n if (!inConfig(target)) continue;\n const line = text.slice(0, match.index).split(\"\\n\").length;\n out.push({ file: full, line, specifier, relativeSpecifier, target });\n }\n }\n };\n walk(root);\n return { importers: out, apis };\n}\n\n/**\n * The modules of `config/` that are the project's own: everything but what\n * Rebase read — `config/collections`, the wiring the run moves to `backend/`\n * (`resources.ts`, `storage.ts`, `generated/register.ts`), the package's index,\n * declarations and package files. 0.31 stops reading `config/collections`, not\n * `config/`: these stay where they are, importable as before.\n *\n * @param moved the wiring files the run moves, absolute\n */\nexport function keptConfigModules(plan: PlanContext, configDir: string, collectionsDir: string, moved: readonly string[]): string[] {\n const out: string[] = [];\n const skip = new Set([\"node_modules\", \"dist\", \"generated\"]);\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || skip.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (full !== collectionsDir) walk(full);\n continue;\n }\n if (moved.includes(full) || full === path.join(configDir, \"index.ts\") || full === path.join(configDir, \"index.js\")) continue;\n if (/\\.d\\.ts$/.test(entry.name) || entry.name === \"package.json\" || /^tsconfig.*\\.json$/.test(entry.name)) continue;\n if (!/\\.(ts|tsx|mts|js|mjs|json)$/.test(entry.name)) continue;\n out.push(relativeToRoot(plan, full));\n }\n };\n if (fs.existsSync(configDir)) walk(configDir);\n return out.sort();\n}\n\n/**\n * The kept modules of `config/` nothing will import once the run is written:\n * no file outside `config/` (read as the run leaves it), no kept module that is\n * itself imported, and not the kept `config/index.ts`. A module whose only\n * importers were the collections is dead weight once they are tables — it goes\n * in the printed `git rm` line instead of staying as \"the project's own\".\n *\n * @param kept the kept modules, absolute\n * @param removed files the run removes or moves (collections, moved wiring, a dropped index), absolute\n * @param indexKept whether `config/index.ts` stays (its imports are live: the package entry)\n */\nexport function unimportedConfigModules(\n plan: PlanContext,\n configDir: string,\n kept: readonly string[],\n removed: readonly string[],\n indexKept: boolean,\n aliases: readonly PathAlias[] = []\n): string[] {\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\"]);\n const gone = (file: string): boolean => removed.some(target => file === target || !path.relative(target, file).startsWith(\"..\"));\n const inConfig = (file: string): boolean => !path.relative(configDir, file).startsWith(\"..\");\n const configPackage = readJson(path.join(configDir, \"package.json\"));\n const packageName = configPackage && typeof configPackage.value.name === \"string\" ? configPackage.value.name : undefined;\n const files = new Set<string>();\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || ignored.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (gone(full)) continue;\n if (entry.isDirectory()) walk(full);\n else if (SOURCE_FILE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) files.add(full);\n }\n };\n walk(plan.root);\n for (const file of plan.files.keys()) if (SOURCE_FILE.test(file) && !gone(file)) files.add(file);\n const indexFile = [\"index.ts\", \"index.js\"].map(name => path.join(configDir, name)).find(file => fs.existsSync(file));\n const targetsOf = (file: string): string[] => {\n const planned = plan.files.get(file);\n const text = blankComments(planned ? planned.content : fs.readFileSync(file, \"utf8\"));\n const out: string[] = [];\n for (const match of text.matchAll(SPECIFIER)) {\n const specifier = match[1];\n if (packageName && (specifier === packageName || specifier.startsWith(`${packageName}/`))) {\n const sub = specifier.slice(packageName.length + 1);\n if (sub) out.push(resolveRelative(path.join(configDir, \"index.ts\"), `./${sub}`).target);\n else if (indexFile) out.push(indexFile);\n continue;\n }\n const relative = /^\\.{1,2}\\//.test(specifier) ? specifier : aliasToRelative(aliases, file, specifier);\n if (relative !== undefined) out.push(resolveRelative(file, relative).target);\n }\n return out;\n };\n const used = new Set<string>();\n const queue: string[] = [];\n const reach = (target: string): void => {\n if (!kept.includes(target) || used.has(target)) return;\n used.add(target);\n queue.push(target);\n };\n for (const file of files) if (!inConfig(file)) targetsOf(file).forEach(reach);\n if (indexKept && indexFile) targetsOf(indexFile).forEach(reach);\n while (queue.length > 0) {\n const next = queue.pop();\n if (next !== undefined) targetsOf(next).forEach(reach);\n }\n return kept.filter(file => !used.has(file));\n}\n\n/** Files a build or a deploy reads by name: container files, shell scripts, CI and workspace YAML, JS build scripts, manifests. */\nconst DEPLOY_FILE = /^(Dockerfile.*|.*\\.dockerfile|\\.dockerignore.*|Makefile|.*\\.(sh|bash|ya?ml|toml|mjs|cjs|js)|package\\.json)$/i;\n\n/**\n * Build and deploy files that name what the migration removes: the config\n * workspace package by name (`pnpm --filter \"<name>\" run build`, a deploy\n * workspace list, an `allowBuilds` entry) when the package goes, and the\n * collections directory (`COPY config/collections`, a watcher on\n * `../config/**`). The run rewrites `pnpm-workspace.yaml` and the manifests it\n * owns; read as it leaves them, whatever still names these is a step per file\n * with its lines — the codemod does not edit a Dockerfile or a CI pipeline.\n *\n * @param packageGoes whether the config package is removed (nothing of the project's own is left in it)\n */\nexport function findDeployReferences(plan: PlanContext, configDir: string, collectionsDir: string, packageGoes: boolean): ManualStep[] {\n const steps: ManualStep[] = [];\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\", \"generated\"]);\n const configPackage = readJson(path.join(configDir, \"package.json\"));\n const packageName = configPackage && typeof configPackage.value.name === \"string\" ? configPackage.value.name : undefined;\n const escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const configRelative = toPosix(path.relative(plan.root, configDir));\n const patterns: RegExp[] = [new RegExp(`(^|[^\\\\w-])${escape(toPosix(path.relative(plan.root, collectionsDir)))}\\\\b`)];\n if (packageGoes) {\n if (packageName) patterns.push(new RegExp(`(^|[^\\\\w@/-])${escape(packageName)}(?![\\\\w-])`));\n patterns.push(new RegExp(`(\\\\.\\\\./|\\\\./|^|[\\\\s\"'=])${escape(configRelative)}/\\\\*\\\\*`));\n }\n const inConfig = (file: string): boolean => !path.relative(configDir, file).startsWith(\"..\");\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (ignored.has(entry.name) || (entry.name.startsWith(\".\") && !/^\\.(github|gitlab|circleci|dockerignore)/.test(entry.name) && !/\\.gitlab-ci\\.ya?ml$/.test(entry.name))) continue;\n const full = path.join(dir, entry.name);\n if (inConfig(full)) continue;\n if (entry.isDirectory()) {\n walk(full);\n continue;\n }\n if (!DEPLOY_FILE.test(entry.name) || entry.name === \"pnpm-lock.yaml\") continue;\n const planned = plan.files.get(full);\n const text = planned ? planned.content : fs.readFileSync(full, \"utf8\");\n if (text.length > 1_000_000 || !patterns.some(pattern => text.split(\"\\n\").some(line => pattern.test(line)))) continue;\n const lines = text.split(\"\\n\").flatMap((line, index) => (patterns.some(pattern => pattern.test(line)) ? [index + 1] : []));\n const relative = relativeToRoot(plan, full);\n steps.push({\n title: `Update the build and deploy references in ${relative}`,\n detail: `Line${lines.length > 1 ? \"s\" : \"\"} ${lines.join(\", \")}: ${relative} names ${packageGoes && packageName ? `the config workspace package (\\`${packageName}\\`) or ` : \"\"}${toPosix(path.relative(plan.root, collectionsDir))}, which the migration removes. Drop the step (the backend builds from backend/schema; there is no config package to build or copy) or point it at backend/schema.`,\n file: relative\n });\n }\n };\n walk(plan.root);\n return steps;\n}\n\n/** The names a module's text exports (`export { a, b as c }`, `export const x`); `export *` is not followed. */\nexport function exportedNamesOf(text: string): Set<string> {\n const out = new Set<string>();\n for (const match of text.matchAll(/export\\s+(?:type\\s+)?\\{([^}]*)\\}/g)) {\n for (const part of match[1].split(\",\")) {\n const name = part.trim().split(/\\s+as\\s+/).pop()?.trim();\n if (name) out.add(name);\n }\n }\n for (const match of text.matchAll(/export\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class|type|interface|enum)\\s+([A-Za-z_$][\\w$]*)/g)) out.add(match[1]);\n if (/export\\s+default\\b/.test(text)) out.add(\"default\");\n return out;\n}\n\n/**\n * The project's own code that still reads what the migration removes from\n * `config/` in a way no import rewrite can fix — each a manual step with\n * file:line, since the codemod cannot rewrite an assertion:\n *\n * - an import of a name `config/index.ts` no longer exports (`collections`,\n * `storageAuthorize`, … — the re-exports of what Rebase read), relative, through\n * a path alias, or by the config package's name;\n * - a file that reads `config/collections` as TEXT (`readFileSync`, `readdirSync`,\n * a path built with `path.join(…, \"config\", \"collections\")`): a test asserting\n * over the collection files' source, a script listing them.\n *\n * @param removedIndexNames what the index exported before the run and does not after\n * (every export when the index goes)\n */\nexport function findLegacyConfigReads(\n plan: PlanContext,\n configDir: string,\n collectionsDir: string,\n removedIndexNames: ReadonlySet<string>,\n aliases: readonly PathAlias[] = []\n): ManualStep[] {\n const steps: ManualStep[] = [];\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\"]);\n const inConfig = (file: string): boolean => !path.relative(configDir, file).startsWith(\"..\");\n const configPackage = readJson(path.join(configDir, \"package.json\"));\n const packageName = configPackage && typeof configPackage.value.name === \"string\" ? configPackage.value.name : undefined;\n const files = new Set<string>();\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || ignored.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (!inConfig(full)) walk(full);\n } else if (SOURCE_FILE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) {\n files.add(full);\n }\n }\n };\n walk(plan.root);\n for (const file of plan.files.keys()) if (SOURCE_FILE.test(file) && !inConfig(file)) files.add(file);\n const collectionsRelative = toPosix(path.relative(plan.root, collectionsDir));\n const segments = collectionsRelative.split(\"/\").map(segment => `[\"'\\`]${segment.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"'\\`]`).join(\"\\\\s*,\\\\s*\");\n const textRead = new RegExp(`[\"'\\`][^\"'\\`\\\\n]*\\\\b${collectionsRelative.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\b|${segments}`);\n for (const file of [...files].sort()) {\n const planned = plan.files.get(file);\n const text = blankComments(planned ? planned.content : fs.readFileSync(file, \"utf8\"));\n const relative = relativeToRoot(plan, file);\n const lineOf = (index: number | undefined): number => text.slice(0, index ?? 0).split(\"\\n\").length;\n // Imports of names the index lost.\n if (removedIndexNames.size > 0) {\n const lost: string[] = [];\n for (const match of text.matchAll(/import\\s+(type\\s+)?(?:([A-Za-z_$][\\w$]*)\\s*,?\\s*)?(?:\\{([^}]*)\\}|\\*\\s+as\\s+([A-Za-z_$][\\w$]*))?\\s*from\\s*[\"']([^\"']+)[\"']/g)) {\n const specifier = match[5];\n const isPackage = packageName !== undefined && specifier === packageName;\n const relativeSpecifier = /^\\.{1,2}\\//.test(specifier) ? specifier : aliasToRelative(aliases, file, specifier);\n const target = relativeSpecifier !== undefined ? resolveRelative(file, relativeSpecifier).target : undefined;\n const isIndex = isPackage || (target !== undefined && (target === configDir || (path.dirname(target) === configDir && /^index\\.(tsx?|mts|jsx?|mjs)$/.test(path.basename(target)))));\n if (!isIndex) continue;\n const named = (match[3] ?? \"\").split(\",\").map(part => part.trim().replace(/^type\\s+/, \"\").split(/\\s+as\\s+/)[0]?.trim()).filter((name): name is string => Boolean(name));\n const names = named.filter(name => removedIndexNames.has(name));\n const namespace = match[4];\n if (namespace) for (const name of removedIndexNames) if (new RegExp(`\\\\b${namespace}\\\\.${name}\\\\b`).test(text)) names.push(`${namespace}.${name}`);\n if (names.length > 0) lost.push(`line ${lineOf(match.index)}: ${names.map(name => `\\`${name}\\``).join(\", \")} from \"${specifier}\"`);\n }\n if (lost.length > 0) {\n steps.push({\n title: `Replace what ${relative} imports from config/index.ts`,\n detail: `${lost.join(\"; \")} — config/index.ts no longer exports ${lost.length > 1 ? \"these\" : \"this\"}: it re-exported what Rebase read (the collections, storageAuthorize), which is gone or moved. Read the tables from backend/schema (\\`compileTables\\` for their descriptors), presentation from frontend/src/cms, storageAuthorize from backend/storage. The codemod cannot rewrite what a test asserts about them.`,\n file: relative\n });\n }\n }\n // Reads of config/collections as files.\n const lines: number[] = [];\n let offset = 0;\n for (const line of text.split(\"\\n\")) {\n if (textRead.test(line) && !/\\bcollectionsDir\\s*:/.test(line) && !/^\\s*(import|export)\\b|\\bfrom\\s*[\"']|\\bimport\\s*\\(|\\brequire\\s*\\(/.test(line)) lines.push(lineOf(offset));\n offset += line.length + 1;\n }\n if (lines.length > 0) {\n steps.push({\n title: `Stop reading ${collectionsRelative} in ${relative}`,\n detail: `Line${lines.length > 1 ? \"s\" : \"\"} ${lines.join(\", \")}: ${relative} reads ${collectionsRelative} as files (a path to it), which the migration removes. Point it at backend/schema (the tables) or frontend/src/cms (the customizations), or assert on the compiled tables instead of their source text. The codemod cannot rewrite an assertion.`,\n file: relative\n });\n }\n }\n return steps;\n}\n\n/** Where a relative specifier written in `fromFile` points, without its extension. */\nfunction specifierStem(fromFile: string, specifier: string): string {\n return path.resolve(path.dirname(fromFile), specifier).replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\").replace(/[\\\\/]index$/, \"\");\n}\n\n/**\n * `config/index.ts` without its re-exports of what Rebase read\n * (`export { collections } from \"./collections\"`, `export { storageAuthorize }\n * from \"./storage\"`), so the package keeps exporting the project's own modules.\n * Undefined when nothing but comments would be left: the index goes too.\n */\nexport function withoutRebaseReexports(ctx: AstContext, indexFile: string, collectionsDir: string, moved: readonly string[]): string | undefined {\n const text = fs.readFileSync(indexFile, \"utf8\");\n const sf = ctx.project.createSourceFile(`/__rebase_migrate__/config-index-${path.basename(indexFile)}`, text, { overwrite: true });\n try {\n const movedStems = moved.map(file => file.replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\"));\n const isRebases = (specifier: string | undefined): boolean => {\n if (specifier === undefined || !specifier.startsWith(\".\")) return false;\n const stem = specifierStem(indexFile, specifier);\n const relative = path.relative(collectionsDir, stem);\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative)) || movedStems.includes(stem);\n };\n const drop = [...sf.getExportDeclarations(), ...sf.getImportDeclarations()].filter(declaration => isRebases(declaration.getModuleSpecifierValue()));\n if (drop.length === 0) return text;\n let out = text;\n for (const declaration of [...drop].sort((a, b) => b.getStart() - a.getStart())) {\n const end = out[declaration.getEnd()] === \"\\n\" ? declaration.getEnd() + 1 : declaration.getEnd();\n out = out.slice(0, declaration.getFullStart() === 0 ? 0 : declaration.getStart()) + out.slice(end);\n }\n const remaining = ctx.project.createSourceFile(`/__rebase_migrate__/config-index-rest-${path.basename(indexFile)}`, out, { overwrite: true });\n const empty = remaining.getStatements().length === 0;\n ctx.project.removeSourceFile(remaining);\n return empty ? undefined : out;\n } finally {\n ctx.project.removeSourceFile(sf);\n }\n}\n","/**\n * A storage property whose `storagePath` is a function.\n *\n * On 0.30 the panel called the function to choose where an upload goes, and\n * the server enforced the property's `maxSize` / `acceptedFiles` only for an\n * upload that named the property (a function path claimed no keys). On 0.31\n * the split is explicit: the panel's function is the customization's\n * `storage.path`, and the column's `path` template is where the server\n * enforces the limits for any upload landing there — in addition to an upload\n * that names the column.\n *\n * So the column needs a template that claims exactly the keys the function\n * produces. When the function returns one template literal (or string), the\n * template is its static text with each interpolation as `{path}` (any number\n * of segments — an interpolated value may hold a `/`): `` `${owner}/cv` ``\n * → `{path}/cv`, which matches every key the function can write and keys of\n * that same shape only. With no static text at all (or a function the codemod\n * cannot read), no template would be faithful: the lift refuses it, with what\n * to write.\n */\nimport type { LiftNote, LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\n\nimport { nodeAtPath, unwrap } from \"./ast\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The template a storage-path function's single returned template literal stands for, or undefined. */\nfunction templateOf(plan: PlanContext, entry: CollectionEntry, key: string): string | undefined {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const site = entry.site;\n if (!site) return undefined;\n const located = nodeAtPath(plan.ast, site.literal, [\"properties\", key, \"storage\", \"storagePath\"]);\n if (!located.node) return undefined;\n const fn = located.node.method ?? (located.node.value ? unwrap(plan.ast, located.node.value) : undefined);\n if (!fn || !(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isMethodDeclaration(fn))) return undefined;\n let returned;\n const body = fn.getBody();\n if (body && !N.isBlock(body)) returned = body;\n else {\n const returns = fn.getDescendantsOfKind(SyntaxKind.ReturnStatement).filter(statement =>\n statement.getFirstAncestor(ancestor => N.isArrowFunction(ancestor) || N.isFunctionExpression(ancestor) || N.isFunctionDeclaration(ancestor) || N.isMethodDeclaration(ancestor)) === fn);\n if (returns.length !== 1) return undefined;\n returned = returns[0].getExpression();\n }\n if (!returned) return undefined;\n const value = unwrap(plan.ast, returned);\n let template: string;\n if (N.isStringLiteral(value) || N.isNoSubstitutionTemplateLiteral(value)) template = value.getLiteralValue();\n else if (N.isTemplateExpression(value)) {\n template = value.getHead().getLiteralText() + value.getTemplateSpans().map(span => `{path}${span.getLiteral().getLiteralText()}`).join(\"\");\n } else return undefined;\n // Only static text decides what the template claims: none at all would claim every key.\n if (!/[^/{}]/.test(template.replace(/\\{path\\}/g, \"\"))) return undefined;\n return template;\n}\n\n/**\n * Replace each derivable function `storagePath` of the evaluated collections\n * with its template, and return the functions as lift notes (`browser`), so\n * the customization carries them as `storage.path`.\n */\nexport function deriveStoragePaths(plan: PlanContext, entries: readonly CollectionEntry[]): LiftNote[] {\n const notes: LiftNote[] = [];\n for (const entry of entries) {\n const collection: LegacyCollectionConfig = entry.collection;\n const properties: unknown = collection.properties;\n if (!isRecord(properties)) continue;\n for (const [key, property] of Object.entries(properties)) {\n if (!isRecord(property) || !isRecord(property.storage)) continue;\n const storagePath = property.storage.storagePath;\n if (typeof storagePath !== \"function\") continue;\n const template = templateOf(plan, entry, key);\n if (template === undefined) continue;\n property.storage = { ...property.storage, storagePath: template };\n notes.push({\n collection: collection.slug,\n key,\n field: \"storage.storagePath\",\n kind: \"browser\",\n valueKind: \"function\",\n value: storagePath,\n reason: `A function the panel calls to choose the upload path; the column's \\`path\\` is \"${template}\", the keys it produces, where the server enforces the limits.`\n });\n }\n }\n return notes;\n}\n","/**\n * The project's own imports of what the migration removes from `config/`.\n *\n * 0.31 stops reading `config/collections`; the project's other modules of\n * `config/` stay where they are, so an import of one of those is left alone.\n * What changes is an import of something Rebase read:\n *\n * - a collection file, in backend code: repointed to the table module\n * (`import posts from \"…/config/collections/posts\"` →\n * `import { posts } from \"…/backend/schema/posts\"`); the uses that read the\n * object are listed afterwards (see {@link tableUseSteps}), since a table\n * definition is not a collection;\n * - a collection file, in frontend code: a type-only use becomes a type import\n * of the table; a value use (reading `posts.properties.status.enum`) is a\n * manual step naming the customization module;\n * - a helper beside the collections: copied out with the code that needs it\n * (as the relocator does for carried code) and repointed;\n * - `config/resources.ts`, `config/storage.ts`, `config/generated/register.ts`:\n * repointed to their new home in `backend/`;\n * - the collections index, or a config index that is removed: a manual step.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { Node, SourceFile } from \"ts-morph\";\n\nimport { toPosix } from \"./ast\";\nimport { resolveRelative, writeSpecifier, type Side } from \"./modules\";\nimport type { PlanContext } from \"./plan-context\";\nimport { planFile, relativeToRoot } from \"./plan-context\";\nimport type { ConfigImporter } from \"./project-files\";\n\n/** A table a collection file became. */\nexport interface TableHome {\n /** The exported identifier (`posts`). */\n identifier: string;\n /** The table module, absolute. */\n file: string;\n /** The customization module and its export, when one was written. */\n cms?: { identifier: string; file: string };\n}\n\n/** What {@link repointConfigImports} needs to know about the run. */\nexport interface RepointContext {\n configDir: string;\n collectionsDir: string;\n /** Collection files (absolute) → the table each became. */\n tables: ReadonlyMap<string, TableHome>;\n /** Rebase's own modules the run moved (absolute legacy path → new path). */\n movedWiring: ReadonlyMap<string, string>;\n /** Whether `config/index.ts` is removed (it re-exported nothing but what moved). */\n indexRemoved: boolean;\n}\n\n/** An import repointed to a table module, whose uses are checked once the run's rewrites are done. */\nexport interface TableBinding {\n /** The importing file, absolute. */\n file: string;\n /** The local name. */\n local: string;\n /** The table it now names. */\n table: TableHome;\n}\n\nfunction isUnder(dir: string, file: string): boolean {\n const relative = path.relative(dir, file);\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n}\n\nfunction isIndex(file: string, dir: string): boolean {\n return path.dirname(file) === dir && /^index\\.(tsx?|mts|jsx?|mjs)$/.test(path.basename(file));\n}\n\n/**\n * Whether an import of the collections index binds names used only as the\n * `collections` option of a backend entry — which the SDK pass's boot-options\n * rewrite turns into `schemaDir` (or a step of its own).\n */\nfunction onlyBootCollections(plan: PlanContext, sf: SourceFile, declaration: Node | undefined): boolean {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n if (!declaration || !N.isImportDeclaration(declaration) || declaration.getDefaultImport() || declaration.getNamespaceImport()) return false;\n const locals = declaration.getNamedImports().map(named => named.getAliasNode()?.getText() ?? named.getName());\n if (locals.length === 0) return false;\n return locals.every(local => {\n const uses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier => identifier.getText() === local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n return uses.length > 0 && uses.every(identifier => {\n const parent = identifier.getParent();\n const isOption = parent !== undefined && ((N.isShorthandPropertyAssignment(parent) && parent.getName() === \"collections\") ||\n (N.isPropertyAssignment(parent) && parent.getName() === \"collections\" && parent.getInitializer() === identifier));\n const call = identifier.getFirstAncestorByKind(SyntaxKind.CallExpression);\n return isOption && call !== undefined && /^(initializeRebaseBackend|createRebaseBackend)$/.test(call.getExpression().getText());\n });\n });\n}\n\n/** Whether every reference to `local` in the file (but its import) is in a type position. */\nfunction usedAsTypeOnly(plan: PlanContext, sf: SourceFile, local: string): boolean {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const uses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n return uses.every(identifier => identifier.getAncestors().some((ancestor: Node) => N.isTypeNode(ancestor)));\n}\n\n/**\n * Rewrite the project's imports of what the migration removes from `config/`,\n * planning each rewritten file; what cannot be rewritten is a manual step per\n * file. Returns the bindings now naming a table, for {@link tableUseSteps}.\n */\nexport function repointConfigImports(plan: PlanContext, ctx: RepointContext, importers: readonly ConfigImporter[]): TableBinding[] {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const bindings: TableBinding[] = [];\n const files = [...new Set(importers.map(importer => importer.file))].sort();\n /** Aliased specifiers (`@config/collections/posts`) → the relative one each stands for, per file. */\n const aliased = new Map<string, Map<string, string>>();\n for (const importer of importers) {\n if (importer.specifier === importer.relativeSpecifier) continue;\n const map = aliased.get(importer.file) ?? new Map<string, string>();\n map.set(importer.specifier, importer.relativeSpecifier);\n aliased.set(importer.file, map);\n }\n for (const file of files) {\n const side: Side = plan.frontendDir && isUnder(plan.frontendDir, file) ? \"frontend\" : \"backend\";\n const text = plan.files.get(file)?.content ?? fs.readFileSync(file, \"utf8\");\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/repoint-${files.indexOf(file)}-${path.basename(file)}`, text, { overwrite: true });\n const edits: { start: number; end: number; text: string }[] = [];\n const left: string[] = [];\n try {\n const literals = [\n ...sf.getImportDeclarations().map(declaration => declaration.getModuleSpecifier()),\n ...sf.getExportDeclarations().map(declaration => declaration.getModuleSpecifier()).filter(literal => literal !== undefined),\n ...sf.getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter(call => call.getExpression().getKind() === SyntaxKind.ImportKeyword || call.getExpression().getText() === \"require\")\n .map(call => call.getArguments()[0])\n .filter(argument => argument !== undefined && N.isStringLiteral(argument))\n ];\n for (const literal of literals) {\n if (!N.isStringLiteral(literal)) continue;\n const written = literal.getLiteralValue();\n // An aliased import is resolved as the relative import it stands for; the rewrite writes it relative.\n const specifier = written.startsWith(\".\") ? written : aliased.get(file)?.get(written);\n if (specifier === undefined) continue;\n const { target, style } = resolveRelative(file, specifier);\n if (!isUnder(ctx.configDir, target) && target !== ctx.configDir) continue;\n const line = literal.getStartLineNumber();\n const replaceSpecifier = (next: string): void => {\n edits.push({ start: literal.getStart() + 1, end: literal.getEnd() - 1, text: next });\n };\n const movedTo = ctx.movedWiring.get(target);\n if (movedTo) {\n replaceSpecifier(writeSpecifier(file, movedTo, style));\n continue;\n }\n if (isIndex(target, ctx.configDir) || target === ctx.configDir) {\n if (ctx.indexRemoved) left.push(`line ${line}: \"${written}\" — config/index.ts re-exported only what Rebase read (\\`collections\\`, \\`storageAuthorize\\`) and is removed: import the table from backend/schema, storageAuthorize from backend/storage`);\n continue;\n }\n if (!isUnder(ctx.collectionsDir, target)) continue; // the project's own module: it stays\n if (isIndex(target, ctx.collectionsDir) && side === \"backend\" && onlyBootCollections(plan, sf, literal.getParent())) continue; // the boot-options rewrite handles it\n if (isIndex(target, ctx.collectionsDir)) {\n left.push(side === \"backend\"\n ? `line ${line}: \"${written}\" — the collections index: the backend boots from backend/schema (\\`schemaDir\\`, or \\`tables\\` from its index)`\n : `line ${line}: \"${written}\" — the collections index: the panel projects the tables from the backend; customizations are in frontend/src/cms`);\n continue;\n }\n const table = ctx.tables.get(target);\n if (!table) {\n // A helper beside the collections: copied out, like carried code's.\n try {\n replaceSpecifier(plan.relocator.relocate(specifier, file, file, side));\n } catch (error) {\n left.push(`line ${line}: \"${written}\" — ${error instanceof Error ? error.message : String(error)}`);\n }\n continue;\n }\n const declaration = literal.getParent();\n const defaultImport = declaration && N.isImportDeclaration(declaration) ? declaration.getDefaultImport() : undefined;\n const onlyDefault = declaration && N.isImportDeclaration(declaration) && defaultImport && declaration.getNamedImports().length === 0 && !declaration.getNamespaceImport();\n if (!declaration || !N.isImportDeclaration(declaration) || !defaultImport || !onlyDefault) {\n left.push(`line ${line}: \"${written}\" — the collection is the table \\`${table.identifier}\\` now: import it from ${relativeToRoot(plan, table.file)}${side === \"frontend\" ? \" as a type (`import type`)\" : \"\"}`);\n continue;\n }\n const local = defaultImport.getText();\n const binding = table.identifier === local ? local : `${table.identifier} as ${local}`;\n const tableSpecifier = writeSpecifier(file, table.file, style);\n if (side === \"frontend\") {\n if (declaration.isTypeOnly() || usedAsTypeOnly(plan, sf, local)) {\n edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: `import type { ${binding} } from ${JSON.stringify(tableSpecifier)};` });\n } else {\n const cms = table.cms ? `the customization \\`${table.cms.identifier}\\` (${relativeToRoot(plan, table.cms.file)}) for what the panel shows, ` : \"\";\n left.push(`line ${line}: \"${written}\" — \\`${local}\\` is read as a value in the frontend; a collection object is gone and the frontend may import backend/ as types only: use ${cms}or the table descriptor the server serves (\\`GET /api/schema/tables\\`) for its columns and enum values`);\n }\n continue;\n }\n edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: `import ${declaration.isTypeOnly() ? \"type \" : \"\"}{ ${binding} } from ${JSON.stringify(tableSpecifier)};` });\n bindings.push({ file, local, table });\n }\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n if (edits.length > 0) {\n let next = text;\n for (const edit of edits.sort((a, b) => b.start - a.start)) next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);\n const planned = plan.files.get(file);\n planFile(plan, file, next, planned ? `${planned.role}, imports of config/` : `imports of config/ (${relativeToRoot(plan, file)})`);\n }\n if (left.length > 0) {\n plan.manualSteps.push({\n title: `Repoint the imports of ${relativeToRoot(plan, file)}`,\n detail: `What it imports from ${relativeToRoot(plan, ctx.collectionsDir)} is gone, and the codemod could not rewrite these: ${left.join(\"; \")}.`,\n file: relativeToRoot(plan, file)\n });\n }\n }\n return bindings;\n}\n\n/**\n * The uses of a binding repointed to a table that read it as an object, one\n * step per file, given the files as the run writes them (after the SDK\n * rewrite, which may have removed a use, as `auth.collection`). A table\n * definition is not a collection: `columns`, `hooks`, `rls` where a collection\n * had `properties`, `callbacks`, `securityRules`.\n *\n * @param read a file's content as the run writes it\n */\nexport function tableUseSteps(plan: PlanContext, bindings: readonly TableBinding[], read: (file: string) => string): void {\n const { SyntaxKind } = plan.ast.tsm;\n const byFile = new Map<string, TableBinding[]>();\n for (const binding of bindings) byFile.set(binding.file, [...(byFile.get(binding.file) ?? []), binding]);\n for (const [file, list] of byFile) {\n const text = read(file);\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/table-uses-${path.basename(file)}`, text, { overwrite: true });\n const lines: string[] = [];\n try {\n for (const binding of list) {\n const uses = sf.getDescendantsOfKind(SyntaxKind.Identifier)\n .filter(identifier => identifier.getText() === binding.local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration))\n .map(identifier => identifier.getStartLineNumber());\n if (uses.length === 0) continue;\n lines.push(`\\`${binding.local}\\` (now the table \\`${binding.table.identifier}\\`) on line ${[...new Set(uses)].join(\", \")}`);\n }\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n if (lines.length === 0) continue;\n plan.manualSteps.push({\n title: `Check the uses of the tables ${relativeToRoot(plan, file)} imports`,\n detail: `Its imports of collection files now import the table definitions from backend/schema: ${lines.join(\"; \")}. A table definition is not a collection — \\`columns\\`, \\`hooks\\`, \\`rls\\` where a collection had \\`properties\\`, \\`callbacks\\`, \\`securityRules\\` — so check each use.`,\n file: toPosix(path.relative(plan.root, file))\n });\n }\n}\n","/**\n * The proof that a migration is lossless: the legacy collections and the\n * migrated tables render the same SQL.\n *\n * \"Before\" is the collections exactly as the legacy loader serves them.\n * \"After\" is `backend/schema` read back through the new pipeline —\n * `loadBackendSchema` (index authority, sibling check, compile) with the CLI's\n * jiti importer, compiled by `compileLoadedSchema`, the one compile boot, the\n * runtime and the CLI share. The planner reads only compiled tables, so\n * \"before\" is the legacy collections lifted (`collectionsToTableDefs`, the\n * codemod's own core) and compiled. Both go through\n * `renderSchemaOutputs`, the renderer the plan-golden corpus is recorded\n * with: DDL under every option, policies, search, vector, triggers, views,\n * the Drizzle schema and the boot plans. A single byte of difference fails.\n */\nimport type { LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\n\nimport type { ModuleImporter } from \"./load-legacy\";\nimport type { VerificationResult } from \"./types\";\n\n/** The lines around the first and last difference of two texts, as a unified-style excerpt. */\nexport function describeDifference(before: string, after: string, context = 3, limit = 80): string {\n const a = before.split(\"\\n\");\n const b = after.split(\"\\n\");\n let start = 0;\n while (start < a.length && start < b.length && a[start] === b[start]) start++;\n let endA = a.length - 1;\n let endB = b.length - 1;\n while (endA >= start && endB >= start && a[endA] === b[endB]) {\n endA--;\n endB--;\n }\n const from = Math.max(0, start - context);\n const lines: string[] = [`@@ line ${start + 1} @@`];\n for (let index = from; index < start; index++) lines.push(` ${a[index]}`);\n for (let index = start; index <= endA; index++) lines.push(`- ${a[index]}`);\n for (let index = start; index <= endB; index++) lines.push(`+ ${b[index]}`);\n for (let index = endA + 1; index < Math.min(a.length, endA + 1 + context); index++) lines.push(` ${a[index]}`);\n if (lines.length > limit) return [...lines.slice(0, limit), `… ${lines.length - limit} more lines`].join(\"\\n\");\n return lines.join(\"\\n\");\n}\n\n/**\n * Compare what the legacy collections and the migrated schema render.\n *\n * @param legacy the Postgres collections as the legacy loader serves them\n * @param schemaDir the migrated `backend/schema`, absolute\n */\nexport async function verifyMigration(\n legacy: readonly LegacyCollectionConfig[],\n schemaDir: string,\n importModule: ModuleImporter\n): Promise<VerificationResult> {\n const { renderSchemaOutputs } = await import(\"@rebasepro/server-postgres\");\n const { compileLoadedSchema, loadBackendSchema } = await import(\"@rebasepro/server\");\n const { compileSchema } = await import(\"@rebasepro/common\");\n const { collectionsToTableDefs } = await import(\"@rebasepro/common/migrate\");\n let after: Record<string, string>;\n try {\n // Exactly as the server reads it: the index is authoritative, a sibling\n // definition it does not export is refused, every definition compiles.\n // `projectRoot: false` — config/ is still there until the user deletes it.\n const loaded = await loadBackendSchema(schemaDir, { projectRoot: false, importModule });\n if (!loaded.indexFile) throw new Error(`${schemaDir} has no index module.`);\n after = renderSchemaOutputs(compileLoadedSchema(loaded).tables);\n } catch (error) {\n return { identical: false, compared: 0, differences: [], error: `The migrated schema could not be read back: ${error instanceof Error ? error.message : String(error)}` };\n }\n let before: Record<string, string>;\n try {\n const lifted = collectionsToTableDefs(legacy);\n before = renderSchemaOutputs(compileSchema(lifted.tables, lifted.defaultRls ? { defaultRls: lifted.defaultRls } : {}));\n } catch (error) {\n return { identical: false, compared: 0, differences: [], error: `The legacy collections could not be lifted into tables: ${error instanceof Error ? error.message : String(error)}` };\n }\n const differences: VerificationResult[\"differences\"] = [];\n const outputs = [...new Set([...Object.keys(before), ...Object.keys(after)])].sort();\n for (const output of outputs) {\n const a = before[output] ?? \"\";\n const b = after[output] ?? \"\";\n if (a !== b) differences.push({ output, diff: describeDifference(a, b) });\n }\n return { identical: differences.length === 0, compared: outputs.length, differences };\n}\n","/**\n * The collections-to-tables codemod: one run, from a project on the\n * `config/collections` layout to `backend/schema` + `frontend/src/cms`.\n *\n * 1. Evaluate the legacy collections as the server's loader does.\n * 2. Lift them (`collectionsToTableDefs`) and print the tables with the shared\n * printer, splicing in the source of hooks and transforms.\n * 3. Route everything that is presentation to `customizeTable` files, and\n * Firestore collections to `defineFirestoreCollection`.\n * 4. Move the rest of `config/` and rewire the workspace.\n * 5. Refuse, never guess: any construct that cannot be carried exactly blocks\n * the write, with the file, the line and what to change.\n * 6. Write under a journal, read the result back through the new pipeline\n * and require byte-identical SQL; roll back on any difference.\n *\n * `config/` itself is never deleted: the run prints the `git rm -r` line.\n */\nimport { spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { collectionsToTableDefs, isLegacyPostgresCollection, type LegacyCollectionConfig, type LiftResult } from \"@rebasepro/common/migrate\";\n\nimport { addSourceFile, createAstContext, findCollectionSite, postDeclarationAssignments, toPosix, type TsMorph } from \"./ast\";\nimport { nameTables, planBackend } from \"./backend\";\nimport { addUnattached, collectComments, placeComments, placeIndexComments } from \"./comments\";\nimport { planCustomizations, printCmsIndex } from \"./customization\";\nimport { planFirestoreCollection } from \"./firestore\";\nimport { findSplitConstants, planSplitConstants } from \"./split-constants\";\nimport { rewriteSdkCalls } from \"./sdk-calls\";\nimport { planRowShapedHands } from \"./row-hands\";\nimport { refreshSkillsStep } from \"./skills-step\";\nimport { Journal } from \"./journal\";\nimport { createSchemaModuleImporter } from \"../../utils/import-schema-module\";\nimport { createShimDir, legacyLoadAliases, movedNameAliases, removeShimDir, type ShimDir } from \"./legacy-shims\";\nimport { movedSymbolTable } from \"./moved-imports\";\nimport { LegacyLoadError, loadLegacyProject } from \"./load-legacy\";\nimport { projectSpecifierStyle, Relocator, writtenSpecifiers } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { note, planFile, relativeToRoot } from \"./plan-context\";\nimport {\n planBackendTsconfig,\n planFrontendWiring,\n planStaticAppGuards,\n planManifest,\n planMove,\n planWorkspace,\n findConfigImporters,\n findLegacyApiUses,\n readRawManifest,\n unmovedConfigFiles,\n unimportedConfigModules,\n findLegacyConfigReads,\n findDeployReferences,\n exportedNamesOf,\n keptConfigModules,\n withoutRebaseReexports\n} from \"./project-files\";\nimport type { CollectionOutcome, MigrateOptions, MigrationReport, PlannedFile } from \"./types\";\nimport { deriveStoragePaths } from \"./storage-paths\";\nimport { readPathAliases } from \"./path-aliases\";\nimport { repointConfigImports, tableUseSteps, type TableHome } from \"./repoint\";\nimport { verifyMigration } from \"./verify\";\n\n/** The directory every table module is written to. */\nconst SCHEMA_DIR = path.join(\"backend\", \"schema\");\n\n/** Output paths that must not already hold something else (a re-run must find exactly what it would write). */\nfunction isOwnedOutput(plan: PlanContext, file: string, cmsDir: string | undefined): boolean {\n const relative = relativeToRoot(plan, file);\n return relative.startsWith(\"backend/schema/\") || relative.startsWith(\"backend/lib/\") ||\n relative === \"backend/resources.ts\" || relative === \"backend/storage.ts\" || relative.startsWith(\"backend/generated/\") ||\n (cmsDir !== undefined && !path.relative(cmsDir, file).startsWith(\"..\"));\n}\n\n/**\n * Whether the project's git tree is clean, or why it is not usable as a safety net.\n *\n * @param root the project root\n */\nexport function gitState(root: string): { clean: true } | { clean: false; reason: string } {\n const result = spawnSync(\"git\", [\"-C\", root, \"status\", \"--porcelain\", \"--untracked-files=normal\", \"--\", \".\"], { encoding: \"utf8\" });\n if (result.error || result.status !== 0) {\n return { clean: false, reason: `${root} is not inside a git repository, so a run could not be undone with git. Commit the project first, or pass --force.` };\n }\n const dirty = result.stdout.split(\"\\n\").filter(line => line.trim().length > 0);\n if (dirty.length > 0) {\n return { clean: false, reason: `the git tree has ${dirty.length} uncommitted change(s) (${dirty.slice(0, 3).map(line => line.slice(3)).join(\", \")}${dirty.length > 3 ? \", …\" : \"\"}). Commit or stash them, so the migration is one reviewable diff — or pass --force.` };\n }\n return { clean: true };\n}\n\nfunction emptyReport(root: string): MigrationReport {\n return { projectRoot: root, status: \"blocked\", collections: [], files: [], refusals: [], notes: [], manualSteps: [], ruleChanges: [] };\n}\n\n/**\n * Run the codemod on one project.\n *\n * The shims the legacy `config/` is loaded with are written into a directory\n * of this run's own, deleted when the run is over — whether it succeeded,\n * refused or threw (see `ShimDir`).\n */\nexport async function migrateCollectionsToTables(options: MigrateOptions): Promise<MigrationReport> {\n const shimDir = createShimDir();\n try {\n return await migrateWithShims(options, shimDir);\n } finally {\n removeShimDir(shimDir);\n }\n}\n\nasync function migrateWithShims(options: MigrateOptions, shimDir: ShimDir): Promise<MigrationReport> {\n const root = path.resolve(options.projectRoot);\n const report = emptyReport(root);\n const manifest = readRawManifest(root);\n const configDir = path.resolve(root, manifest.configDir);\n const writes = !options.dryRun && !options.check;\n\n // After the printed `git rm`: nothing left to read, and the tables are there.\n // That is the end state, not an error — whichever mode asks.\n const collectionsDir = path.join(configDir, \"collections\");\n if (!fs.existsSync(collectionsDir) && fs.existsSync(path.join(root, SCHEMA_DIR))) {\n report.status = \"already-migrated\";\n report.notes.push({\n file: toPosix(path.relative(root, collectionsDir)),\n message: `is gone and ${toPosix(SCHEMA_DIR)} exists: the project is already migrated. There is nothing left to compare backend/schema with (--check reads config/collections; run it before the git rm line), and nothing to remove.`\n });\n return report;\n }\n\n if (writes && !options.force) {\n const state = gitState(root);\n if (!state.clean) {\n report.refusals.push({ file: \".\", reason: state.reason });\n return report;\n }\n }\n\n // `config/` is evaluated with the packages installed now; 0.31 dropped the `defineCollection` its files import.\n // …and with the names 0.31 moved to another package re-exported where the 0.30 files import them.\n const baseAliases = legacyLoadAliases(configDir, shimDir, options.moduleAliases);\n // (Only for a project that has collections to load: it imports every package once to see what moved.)\n const loadAliases = fs.existsSync(path.join(configDir, \"collections\"))\n ? await movedNameAliases(configDir, shimDir, baseAliases, await createSchemaModuleImporter(root, baseAliases), movedSymbolTable())\n : baseAliases;\n const importModule = await createSchemaModuleImporter(root, loadAliases);\n let legacy;\n try {\n legacy = await loadLegacyProject(configDir, importModule);\n } catch (error) {\n report.refusals.push({\n file: error instanceof LegacyLoadError && error.file ? toPosix(path.relative(root, error.file)) : toPosix(path.relative(root, configDir)),\n reason: error instanceof Error ? error.message : String(error)\n });\n return report;\n }\n for (const helper of legacy.helperFiles) {\n report.notes.push({\n file: toPosix(path.relative(root, helper)),\n message: \"exports no collection: read as a module the collections import, not as a table. It is copied next to the code that imports it, since config/collections goes; when nothing imports it, a step lists it.\"\n });\n }\n\n const tsm: TsMorph = await import(\"ts-morph\");\n const ast = createAstContext(tsm);\n const frontendDir = manifest.frontendRoot ? path.resolve(root, manifest.frontendRoot) : undefined;\n const cmsDir = frontendDir ? path.join(frontendDir, \"src\", \"cms\") : undefined;\n const relocator = new Relocator(ast, root, configDir, new Set(legacy.collections.map(entry => entry.file)), {\n backend: path.join(root, \"backend\", \"lib\"),\n frontend: cmsDir ? path.join(cmsDir, \"lib\") : path.join(root, \"frontend\", \"src\", \"cms\", \"lib\")\n });\n\n // The AST of every collection file.\n const entries: CollectionEntry[] = legacy.collections.map(({ collection, file }) => {\n const sourceFile = addSourceFile(ast, file, fs.readFileSync(file, \"utf8\"));\n const site = findCollectionSite(ast, sourceFile);\n return { collection, file, sourceFile, ...(site.node ? { site: site.node } : { siteProblem: site.reason }) };\n });\n // The relative imports the run writes end as the collection files and their index write theirs:\n // `./users.js` for a project built with a plain `tsc` (NodeNext) and run on Node.\n const legacyIndexFile = [\"index.ts\", \"index.js\"].map(file => path.join(legacy.collectionsDir, file)).find(file => fs.existsSync(file));\n const specifierStyle = projectSpecifierStyle([\n ...entries.flatMap(entry => writtenSpecifiers(entry.sourceFile)),\n ...(legacyIndexFile ? writtenSpecifiers(addSourceFile(ast, legacyIndexFile, fs.readFileSync(legacyIndexFile, \"utf8\"))) : [])\n ]);\n const plan: PlanContext = {\n root,\n ast,\n relocator,\n specifierStyle,\n ...(frontendDir ? { frontendDir } : {}),\n files: new Map(),\n refusals: report.refusals,\n notes: report.notes,\n manualSteps: report.manualSteps\n };\n for (const entry of entries) {\n if (!entry.site?.binding) continue;\n for (const [assigned, { statement }] of postDeclarationAssignments(ast, entry.sourceFile, entry.site.binding)) {\n note(plan, entry, `\\`${entry.site.binding}.${assigned}\\` is assigned after the declaration; the evaluated value is what was carried.`, statement.getStartLineNumber());\n }\n }\n\n const postgres = entries.filter(entry => isLegacyPostgresCollection(entry.collection));\n const firestore = entries.filter(entry => entry.collection.engine === \"firestore\");\n for (const entry of entries) {\n if (!postgres.includes(entry) && !firestore.includes(entry)) {\n plan.refusals.push({ file: relativeToRoot(plan, entry.file), collection: entry.collection.slug, reason: `is a ${String(entry.collection.engine)} collection. Only Postgres collections become tables and Firestore ones \\`defineFirestoreCollection\\`; this engine has no home in the new layout.` });\n }\n }\n if (cmsDir) for (const entry of firestore) relocator.moved.set(entry.file, path.join(cmsDir, path.basename(entry.file)));\n\n // Enum constants of config/ the collections use: values for the schema, labels for the CMS.\n const split = await findSplitConstants(plan, postgres, importModule, cmsDir);\n plan.splitConstants = split.constants;\n\n // The tables.\n let lift: LiftResult | undefined;\n // A function storagePath whose keys a template can name: the template for the server, the function for the panel.\n const storageNotes = deriveStoragePaths(plan, postgres);\n try {\n lift = collectionsToTableDefs(postgres.map(entry => entry.collection), legacy.defaultSecurityRules ? { defaultSecurityRules: legacy.defaultSecurityRules } : {});\n } catch (error) {\n if (!isSchemaDefinitionError(error)) throw error;\n for (const problem of error.problems) {\n const entry = postgres.find(candidate => candidate.collection.slug === problem.table);\n plan.refusals.push({\n file: entry ? relativeToRoot(plan, entry.file) : relativeToRoot(plan, legacy.collectionsDir),\n collection: problem.table,\n ...(problem.key !== undefined ? { key: problem.key } : {}),\n reason: problem.message\n });\n }\n }\n\n const schemaDir = path.join(root, SCHEMA_DIR);\n const outcomes = new Map<string, CollectionOutcome>();\n for (const entry of entries) {\n outcomes.set(entry.collection.slug, { slug: entry.collection.slug, file: relativeToRoot(plan, entry.file), kind: \"refused\" });\n }\n let customizationModules: { identifier: string; file: string; slug: string }[] = [];\n /** Collection files → the table each became, for repointing the project's imports of them. */\n const tableHomes = new Map<string, TableHome>();\n /** The auth table's module and its collection file: an `auth.collection` naming either is dropped. */\n const authFiles: string[] = [];\n if (lift) {\n lift.notCarried.push(...storageNotes);\n for (const item of lift.notCarried) {\n if (item.kind !== \"meaning\") continue;\n const entry = postgres.find(candidate => candidate.collection.slug === item.collection);\n report.ruleChanges.push({\n file: entry ? relativeToRoot(plan, entry.file) : relativeToRoot(plan, legacy.collectionsDir),\n collection: item.collection,\n rule: item.field,\n message: item.reason\n });\n }\n const names = nameTables(postgres, lift.tables, schemaDir);\n const order = (legacy.navigationOrder ?? []).map(collection => collection.slug).filter(slug => names.has(slug));\n planBackend(plan, { entries: postgres, lift, schemaDir, order }, names);\n planSplitConstants(plan, split.constants, new Map(postgres.map(entry => [entry.file, names.get(entry.collection.slug)?.file ?? \"\"])));\n for (const [slug, name] of names) {\n const outcome = outcomes.get(slug);\n if (outcome) {\n outcome.kind = name.kind;\n outcome.backendFile = relativeToRoot(plan, name.file);\n }\n }\n if (cmsDir) {\n const navigation = legacy.navigationOrder ?? [];\n const ordered = [...postgres].sort((a, b) => rank(navigation, a.collection) - rank(navigation, b.collection));\n customizationModules = planCustomizations(plan, ordered, names, lift.notCarried, cmsDir).modules;\n for (const module of customizationModules) {\n const outcome = outcomes.get(module.slug);\n if (outcome) outcome.frontendFile = relativeToRoot(plan, module.file);\n }\n }\n placeCollectionComments(plan, postgres, lift, names, customizationModules);\n for (const entry of postgres) {\n const name = names.get(entry.collection.slug);\n if (!name) continue;\n const cms = customizationModules.find(module => module.slug === entry.collection.slug);\n if (name.kind === \"auth-table\") authFiles.push(name.file, entry.file);\n tableHomes.set(entry.file, { identifier: name.identifier, file: name.file, ...(cms ? { cms: { identifier: cms.identifier, file: cms.file } } : {}) });\n }\n if (!cmsDir && lift.notCarried.some(item => item.kind === \"ui\" || item.kind === \"browser\")) {\n plan.manualSteps.push({\n title: \"Presentation not carried\",\n detail: \"The project has no frontend app (rebase.json declares no static app with `cms`, and there is no frontend/src), so the collections' admin presentation — labels, icons, `admin` blocks — had nowhere to go and was not written. Add a frontend and run the codemod again from the git history if you want it.\"\n });\n }\n }\n\n // Firestore collections.\n const external: { identifier: string; file: string }[] = [];\n for (const entry of firestore) {\n if (!cmsDir) {\n plan.refusals.push({ file: relativeToRoot(plan, entry.file), collection: entry.collection.slug, reason: \"is a Firestore collection, which lives in the CMS (`defineFirestoreCollection` in frontend/src/cms), and the project has no frontend app.\" });\n continue;\n }\n const moved = planFirestoreCollection(plan, entry, cmsDir);\n if (!moved) continue;\n external.push(moved);\n const outcome = outcomes.get(entry.collection.slug);\n if (outcome) {\n outcome.kind = \"firestore\";\n outcome.frontendFile = relativeToRoot(plan, moved.file);\n }\n }\n if (firestore.length > 0 || legacy.builtFirestore.length > 0) {\n note(plan, undefined, \"Firestore collections are moved and rewritten in place; they have no SQL, so the SQL check does not cover them.\");\n }\n\n // Firestore collections the project built in modules the loader never read\n // (a subdirectory, a function the app spread into `collections`).\n const builtHomes = new Map<string, string>();\n for (const built of legacy.builtFirestore) {\n const slug = built.collection.slug;\n outcomes.set(slug, { slug, file: relativeToRoot(plan, built.file ?? legacy.collectionsDir), kind: \"firestore\" });\n if (!cmsDir || !built.file) continue;\n const sourceFile = addSourceFile(ast, built.file, fs.readFileSync(built.file, \"utf8\"));\n const entry: CollectionEntry = { collection: built.collection, file: built.file, sourceFile };\n // A literal the rewrite cannot read is left to the step below, not refused: the run never read these files before.\n const trial: PlanContext = { ...plan, files: new Map(), refusals: [], notes: [], manualSteps: [] };\n const destination = path.join(cmsDir, path.relative(legacy.collectionsDir, built.file));\n const moved = planFirestoreCollection(trial, entry, cmsDir, destination);\n if (!moved || trial.refusals.length > 0) continue;\n for (const [file, planned] of trial.files) plan.files.set(file, planned);\n plan.notes.push(...trial.notes);\n plan.manualSteps.push(...trial.manualSteps);\n external.push(moved);\n builtHomes.set(slug, moved.file);\n const outcome = outcomes.get(slug);\n if (outcome) outcome.frontendFile = relativeToRoot(plan, moved.file);\n }\n const shape = \"`defineFirestoreCollection({ slug, name, fields, … })` from `@rebasepro/firebase` in frontend/src/cms — `properties` → `fields`, a reference's `path` → `target`, no `engine`, components by value — listed in `externalCollections` and mounted as `<RebaseCMS externalCollections={externalCollections}>`\";\n const describeBuilt = (slugs: string[]): string => {\n const converted = slugs.filter(slug => builtHomes.has(slug)).map(slug => `${slug} → ${relativeToRoot(plan, builtHomes.get(slug) ?? \"\")}`);\n const byHand = slugs.filter(slug => !builtHomes.has(slug));\n return (converted.length > 0 ? ` Converted (in externalCollections): ${converted.join(\", \")}.` : \"\") +\n (byHand.length > 0 ? ` No literal of their own the codemod could rewrite (built per call, or several per file) — write each by hand in the target shape: ${byHand.join(\", \")}.` : \"\") +\n ` Target shape: ${shape}.`;\n };\n for (const builder of legacy.firestoreBuilders) {\n plan.manualSteps.push({\n title: `Mount the Firestore collections ${builder.exportName}() built`,\n detail: `\\`${builder.exportName}()\\` builds ${builder.slugs.length} Firestore collection(s) at run time; the 0.30 loader never read its module, the app spread the result into \\`collections\\`, which the panel no longer takes.` +\n describeBuilt(builder.slugs) +\n (builder.changed.length > 0 ? ` It returns changed copies of ${builder.changed.join(\", \")} (it adds to or rewrites what their files export at run time): carry that change into the converted collections by hand.` : \"\") +\n ` Replace the call with \\`externalCollections\\` from ./cms. Its module tree goes with config/collections; where other code still imports it, it was copied as written (0.30 shape) next to that code — keep only what that code reads.`,\n file: relativeToRoot(plan, builder.file)\n });\n }\n const unbuilt = legacy.builtFirestore.map(built => built.collection.slug).filter(slug => !legacy.firestoreBuilders.some(builder => builder.slugs.includes(slug)));\n if (unbuilt.length > 0) {\n plan.manualSteps.push({\n title: \"Mount the Firestore collections of the subdirectories\",\n detail: `Files under subdirectories of config/collections export Firestore collections the 0.30 loader never read (the app imported them).${describeBuilt(unbuilt)} Mount \\`externalCollections\\` from ./cms where the app passed them.`,\n file: relativeToRoot(plan, legacy.collectionsDir)\n });\n }\n\n // The CMS index and the frontend's wiring.\n if (cmsDir && frontendDir) {\n if (customizationModules.length > 0 || external.length > 0) {\n planFile(plan, path.join(cmsDir, \"index.ts\"), printCmsIndex(cmsDir, customizationModules, external, plan.specifierStyle), \"the CMS index\");\n }\n planFrontendWiring(plan, frontendDir, external.length > 0);\n }\n planStaticAppGuards(plan, frontendDir);\n\n // The legacy index's comments, onto the two indexes.\n const schemaIndex = plan.files.get(path.join(schemaDir, \"index.ts\"));\n if (legacyIndexFile && schemaIndex) {\n const cmsIndexPath = cmsDir ? path.join(cmsDir, \"index.ts\") : undefined;\n const cmsIndex = cmsIndexPath ? plan.files.get(cmsIndexPath) : undefined;\n const placed = placeIndexComments(ast, addSourceFile(ast, legacyIndexFile, fs.readFileSync(legacyIndexFile, \"utf8\")), schemaIndex.content, cmsIndex?.content, root);\n plan.files.set(path.join(schemaDir, \"index.ts\"), { ...schemaIndex, content: placed.schemaIndex });\n if (cmsIndexPath && cmsIndex && placed.cmsIndex !== undefined) plan.files.set(cmsIndexPath, { ...cmsIndex, content: placed.cmsIndex });\n }\n\n // The rest of config/.\n const handled = new Set<string>(legacy.collections.map(entry => entry.file));\n for (const name of [\"index.ts\", \"index.js\"]) handled.add(path.join(legacy.collectionsDir, name));\n handled.add(path.join(configDir, \"index.ts\"));\n const backendWanted = [\"schema/**/*\"];\n /** Rebase's own modules of config/ the run moves to backend/ (removed afterwards). */\n const movedWiring: string[] = [];\n for (const [file, target] of [[\"resources.ts\", \"resources.ts\"], [\"storage.ts\", \"storage.ts\"]] as const) {\n const from = path.join(configDir, file);\n try {\n if (planMove(plan, from, path.join(root, \"backend\", target), `backend/${target}`)) {\n handled.add(from);\n movedWiring.push(from);\n backendWanted.push(target);\n }\n } catch (error) {\n plan.refusals.push({ file: relativeToRoot(plan, from), reason: error instanceof Error ? error.message : String(error) });\n }\n }\n // `storageAuthorize` exported by config/index.ts from a module of another name\n // (`export { storageAuthorize } from \"./storage-authorize\"`): 0.30's bundle read\n // it from config/index, 0.31's reads backend/storage only. Without that file the\n // access control is silently dropped on deploy — the boot merely warns.\n const storageTarget = path.join(root, \"backend\", \"storage.ts\");\n if (legacy.configIndexExports.includes(\"storageAuthorize\") && !plan.files.has(storageTarget) && !fs.existsSync(storageTarget)) {\n const indexFile = path.join(configDir, \"index.ts\");\n const source = fs.existsSync(indexFile) ? storageAuthorizeReexport(indexFile, path.dirname(storageTarget)) : undefined;\n if (source) {\n planFile(plan, storageTarget, \"// The runtime reads `storageAuthorize` from backend/storage (0.30 read it from config/index.ts).\\n\" +\n `export { storageAuthorize } from \"${source}\";\\n`, \"backend/storage.ts (storageAuthorize, re-exported)\");\n backendWanted.push(\"storage.ts\");\n } else {\n plan.manualSteps.push({\n title: \"Move storageAuthorize to backend/storage.ts\",\n detail: \"config/index.ts exports `storageAuthorize`, which the 0.30 runtime read from there. 0.31 reads it from `backend/storage.ts` only: without that module, storage access control is gone on deploy (the boot only warns). Export it from backend/storage.ts.\",\n file: relativeToRoot(plan, indexFile)\n });\n }\n }\n const register = path.join(configDir, \"generated\", \"register.ts\");\n try {\n if (planMove(plan, register, path.join(root, \"backend\", \"generated\", \"register.ts\"), \"backend/generated/register.ts\")) {\n handled.add(register);\n movedWiring.push(register);\n backendWanted.push(\"generated/**/*\");\n }\n } catch (error) {\n plan.refusals.push({ file: relativeToRoot(plan, register), reason: error instanceof Error ? error.message : String(error) });\n }\n if (legacy.configIndexExports.includes(\"callbacks\")) {\n plan.manualSteps.push({\n title: \"Move the global collection callbacks\",\n detail: \"config/index.ts exports `callbacks`, which the runtime applied to every collection. Its home is `backend/hooks.ts`, exporting `hooks` (table hooks: `table` replaces `collection`, and `afterRead` / `beforeDelete` / `afterDelete` receive `values` instead of `row`). Move it by hand: the codemod does not rewrite a module it did not read as a collection.\",\n file: relativeToRoot(plan, path.join(configDir, \"index.ts\"))\n });\n }\n\n for (const constant of split.constants) handled.add(constant.module);\n for (const { module, reason } of split.unsplit) {\n handled.add(module);\n // Advice, not a step: the tables inline the values and the customizations the labels, so nothing breaks if the module stays as it is.\n report.notes.push({\n file: relativeToRoot(plan, module),\n message: `holds enum values the collections used; the tables inline the values and the customizations the labels (it was not split because it ${reason}). If it should stay the one source of those values, split it: the values into backend/lib (\\`export const X = [...] as const\\`), the labels into frontend/src/cms/lib (\\`Record<(typeof X)[number], string>\\`), named in the tables and customizations.`\n });\n }\n\n // Helper modules the moved code imports.\n for (const copy of relocator.helpers.values()) {\n handled.add(copy.from);\n planFile(plan, copy.to, relocator.helperContent(copy), `helper ${relativeToRoot(plan, copy.from)} (${copy.side})`);\n if (copy.side === \"backend\") backendWanted.push(\"lib/**/*\");\n const content = relocator.helperContent(copy);\n if (copy.side === \"backend\" && /from\\s+[\"'](react|@rebasepro\\/(cms|cms-types|app|ui|studio))[\"']/.test(content)) {\n plan.manualSteps.push({\n title: `Split ${relativeToRoot(plan, copy.from)}`,\n detail: `The backend uses ${relativeToRoot(plan, copy.from)}, which imports an admin-panel package. It was copied to ${relativeToRoot(plan, copy.to)} as written; the backend may not import React or the CMS (\\`pnpm check:headless\\`): keep only what the backend uses there.`,\n file: relativeToRoot(plan, copy.to)\n });\n }\n }\n\n // Modules the panel's code imports in place, edited for it (a shared dynamicProps builder's 0.31 return shape).\n for (const module of relocator.keptFrontendModules) {\n if (relocator.keptBackendModules.has(module)) continue;\n const content = relocator.editedSource(module);\n if (content !== fs.readFileSync(module, \"utf8\")) planFile(plan, module, content, `${relativeToRoot(plan, module)} (dynamicProps return shape)`);\n }\n\n // The project's own modules backend code imports in place: their collection-model types become table-model aliases.\n for (const module of relocator.keptBackendModules) {\n const content = relocator.keptBackendContent(module);\n if (content !== fs.readFileSync(module, \"utf8\")) planFile(plan, module, content, `${relativeToRoot(plan, module)} (collection-model types → table-model aliases)`);\n }\n\n for (const { file, name } of relocator.legacyTypesLeft) {\n plan.manualSteps.push({\n title: `Replace the collection-model type ${name} in ${file}`,\n detail: `A module the backend uses (copied to backend/lib, or kept in config/) \\`${name}\\` with type arguments; a table-model alias cannot stand for it. Use the table-model type from \\`@rebasepro/server/schema\\` (\\`TableHooks\\`, \\`TableBeforeSaveProps\\`, \\`TableHookProps[\"context\"]\\`, …).`\n });\n }\n\n // config/ minus what Rebase read: the project's own modules, which stay where they are.\n const configLeft = keptConfigModules(plan, configDir, legacy.collectionsDir, movedWiring);\n const configStays = configLeft.length > 0;\n const removed = [legacy.collectionsDir, ...movedWiring];\n const indexFile = path.join(configDir, \"index.ts\");\n if (configStays) {\n if (fs.existsSync(indexFile)) {\n const rewritten = withoutRebaseReexports(ast, indexFile, legacy.collectionsDir, movedWiring);\n if (rewritten === undefined) removed.push(indexFile);\n else if (rewritten !== fs.readFileSync(indexFile, \"utf8\")) planFile(plan, indexFile, rewritten, \"config/index.ts (re-exports of what moved)\");\n }\n report.notes.push({\n file: relativeToRoot(plan, configDir),\n message: `keeps ${configLeft.length} module(s) of the project's own (${configLeft.join(\", \")}): 0.31 stops reading ${relativeToRoot(plan, legacy.collectionsDir)}, not ${relativeToRoot(plan, configDir)}/. They stay where they are, importable as before; only what Rebase read is removed.`\n });\n }\n\n // The project's own imports of what config/ loses: repointed where that is mechanical (see repoint.ts).\n const wiringHomes = new Map<string, string>();\n for (const from of movedWiring) {\n const to = from === path.join(configDir, \"generated\", \"register.ts\") ? path.join(root, \"backend\", \"generated\", \"register.ts\") : path.join(root, \"backend\", path.basename(from));\n wiringHomes.set(from, to);\n }\n for (const [from, to] of relocator.moved) wiringHomes.set(from, to);\n const tableBindings = repointConfigImports(plan, {\n configDir,\n collectionsDir: legacy.collectionsDir,\n tables: tableHomes,\n movedWiring: wiringHomes,\n indexRemoved: !configStays || removed.includes(indexFile)\n }, findConfigImporters(root, configDir, new Set(plan.files.keys()), readPathAliases(root)));\n // Helpers beside the collections the project's own code imports, copied out by the repointing.\n for (const copy of relocator.helpers.values()) {\n if (plan.files.has(copy.to)) continue;\n handled.add(copy.from);\n planFile(plan, copy.to, relocator.helperContent(copy), `helper ${relativeToRoot(plan, copy.from)} (${copy.side})`);\n if (copy.side === \"backend\") backendWanted.push(\"lib/**/*\");\n }\n\n planManifest(plan, manifest);\n planWorkspace(plan, configDir, manifest.frontendRoot, configStays);\n planBackendTsconfig(plan, [...new Set(backendWanted)], configStays);\n\n // Server APIs of the collection model in the project's own code.\n const apiUses = new Map<string, { api: string; replacement: string; lines: number[] }>();\n for (const use of findLegacyApiUses(root, configDir, new Set(plan.files.keys()), options.skipSdkCalls ? new Set() : new Set([\"setCollectionCallbacks\", \"collectionsDir\"]))) {\n const key = `${use.file}\\0${use.api}`;\n const entry = apiUses.get(key) ?? { api: use.api, replacement: use.replacement, lines: [] };\n entry.lines.push(use.line);\n apiUses.set(key, entry);\n }\n for (const [key, { api, replacement, lines }] of apiUses) {\n const file = key.slice(0, key.indexOf(\"\\0\"));\n plan.manualSteps.push({\n title: `Replace ${api} in ${relativeToRoot(plan, file)}`,\n detail: `\\`${api}\\` (line${lines.length > 1 ? \"s\" : \"\"} ${lines.join(\", \")}) belongs to the collection model. Use ${replacement}.`,\n file: relativeToRoot(plan, file)\n });\n }\n\n // The project's own SDK calls and server API uses, renamed (on the files as they are about to be written).\n if (!options.skipSdkCalls) {\n const overrides = new Map([...plan.files].map(([file, { content }]) => [file, content]));\n const sdk = await rewriteSdkCalls(root, {\n overrides,\n // config/collections goes; the project's own modules of config/ are its code like any other.\n skipDirs: [legacy.collectionsDir],\n skipFiles: [...movedWiring, ...(removed.includes(indexFile) ? [indexFile] : [])],\n ...(options.moduleAliases ? { aliases: options.moduleAliases } : {}),\n schemaDir,\n collectionsDir: legacy.collectionsDir,\n authFiles,\n configManifest: path.join(configDir, \"package.json\")\n });\n for (const [file, content] of sdk.files) {\n const planned = plan.files.get(file);\n plan.files.set(file, { content, role: planned ? `${planned.role}, SDK calls` : `SDK calls (${relativeToRoot(plan, file)})` });\n }\n report.sdk = sdk.report;\n plan.manualSteps.push(...sdk.report.manualSteps);\n }\n // Views, actions, display resolvers and additional fields destructuring `({ entity })`: row-shaped on 0.31.\n if (frontendDir) planRowShapedHands(plan, frontendDir);\n tableUseSteps(plan, tableBindings, file => plan.files.get(file)?.content ?? fs.readFileSync(file, \"utf8\"));\n\n // Code that still reads what config/ loses, in a way no import rewrite fixes: names the index stopped exporting, config/collections read as files.\n {\n const indexBefore = fs.existsSync(indexFile) ? fs.readFileSync(indexFile, \"utf8\") : \"\";\n const indexAfter = !configStays || removed.includes(indexFile) ? \"\" : plan.files.get(indexFile)?.content ?? indexBefore;\n const after = exportedNamesOf(indexAfter);\n const lost = new Set([...exportedNamesOf(indexBefore)].filter(name => !after.has(name)));\n plan.manualSteps.push(...findLegacyConfigReads(plan, configDir, legacy.collectionsDir, lost, readPathAliases(root)));\n plan.manualSteps.push(...findDeployReferences(plan, configDir, legacy.collectionsDir, !configStays));\n }\n\n // Kept modules of config/ that only the collections imported: nothing needs them once the run is written.\n if (configStays) {\n const indexGoes = removed.includes(indexFile);\n const unimported = unimportedConfigModules(plan, configDir, configLeft.map(file => path.join(root, file)),\n [legacy.collectionsDir, ...movedWiring, ...(indexGoes ? [indexFile] : [])], !indexGoes && fs.existsSync(indexFile), readPathAliases(root));\n if (unimported.length > 0) {\n removed.push(...unimported);\n report.notes.push({\n file: relativeToRoot(plan, configDir),\n message: `${unimported.map(file => relativeToRoot(plan, file)).join(\", \")}: nothing imports ${unimported.length > 1 ? \"these\" : \"this\"} once the migration is written (only the collections did, and their values are in the tables now); ${unimported.length > 1 ? \"they are\" : \"it is\"} in the printed git rm line.`\n });\n }\n }\n\n const unmoved = unmovedConfigFiles(plan, configDir, handled).filter(file => relocator.isInCollections(path.join(root, file)));\n if (unmoved.length > 0) {\n // Nothing the run writes and nothing of the project imports them: only the collections did, and their values are in the tables now.\n report.notes.push({\n file: relativeToRoot(plan, legacy.collectionsDir),\n message: `${unmoved.join(\", \")}: nothing needs ${unmoved.length > 1 ? \"these\" : \"this\"} after the migration (only the collections imported ${unmoved.length > 1 ? \"them\" : \"it\"}, and their values are in the tables now); ${unmoved.length > 1 ? \"they go\" : \"it goes\"} with ${relativeToRoot(plan, legacy.collectionsDir)}.`\n });\n }\n\n const skills = refreshSkillsStep(root);\n if (skills) plan.manualSteps.push(skills);\n\n // What would be written.\n const files: PlannedFile[] = [];\n for (const [file, { content, role }] of [...plan.files].sort(([a], [b]) => a.localeCompare(b))) {\n const exists = fs.existsSync(file);\n const current = exists ? fs.readFileSync(file, \"utf8\") : undefined;\n const action: PlannedFile[\"action\"] = !exists ? \"create\" : current === content ? \"unchanged\" : \"update\";\n if (action === \"update\" && isOwnedOutput(plan, file, cmsDir) && !options.force) {\n plan.refusals.push({ file: relativeToRoot(plan, file), reason: \"already exists with other content. The codemod does not overwrite edits: move it aside (or pass --force) and run again.\" });\n }\n files.push({ path: relativeToRoot(plan, file), content, action, role });\n }\n report.files = files;\n // A collection any refusal names is refused, whatever was planned for it.\n for (const outcome of outcomes.values()) {\n if (report.refusals.some(refusal => refusal.collection === outcome.slug)) {\n outcome.kind = \"refused\";\n delete outcome.backendFile;\n delete outcome.frontendFile;\n }\n }\n report.collections = [...outcomes.values()];\n\n const legacyPostgres = postgres.map(entry => entry.collection);\n if (report.refusals.length > 0) {\n report.status = \"blocked\";\n return report;\n }\n\n if (options.check) {\n if (!fs.existsSync(schemaDir)) {\n report.refusals.push({ file: toPosix(SCHEMA_DIR), reason: \"does not exist: there is no migrated schema to check. Run without --check to migrate.\" });\n report.status = \"blocked\";\n return report;\n }\n report.verification = await verifyMigration(legacyPostgres, schemaDir, importModule);\n report.status = report.verification.identical ? \"checked\" : \"failed\";\n if (report.status === \"checked\" && report.ruleChanges.length > 0 && !options.acceptRuleChanges) {\n report.status = \"rule-changes\";\n return report;\n }\n if (report.verification.identical) report.removeCommand = removeCommand(plan, configStays ? removed : [configDir]);\n return report;\n }\n if (options.dryRun) {\n report.status = \"planned\";\n return report;\n }\n\n const pending = files.filter(file => file.action !== \"unchanged\");\n const journal = new Journal();\n for (const file of pending) journal.write(path.join(root, file.path), file.content);\n // A fresh importer: the one that read config/ cached modules by path.\n const verification = await verifyMigration(legacyPostgres, schemaDir, await createSchemaModuleImporter(root, options.moduleAliases));\n report.verification = verification;\n if (!verification.identical) {\n journal.rollback();\n report.status = \"failed\";\n return report;\n }\n report.status = pending.length === 0 ? \"already-migrated\" : \"migrated\";\n report.removeCommand = removeCommand(plan, configStays ? removed : [configDir]);\n return report;\n}\n\n/** Every collection file's comments, into the table and customization files it became (see `comments.ts`). */\nfunction placeCollectionComments(\n plan: PlanContext,\n entries: readonly CollectionEntry[],\n lift: LiftResult,\n names: ReadonlyMap<string, { file: string }>,\n customizations: readonly { file: string; slug: string }[]\n): void {\n entries.forEach((entry, index) => {\n const def = lift.tables[index];\n const name = names.get(entry.collection.slug);\n const backend = name ? plan.files.get(name.file) : undefined;\n if (!def || !name || !backend) return;\n const cmsFile = customizations.find(module => module.slug === entry.collection.slug)?.file;\n const cms = cmsFile ? plan.files.get(cmsFile) : undefined;\n const comments = collectComments(plan.ast, entry, def, new Set());\n const fresh = (text: string, content: string): boolean => !content.includes(text);\n const forBackend = comments\n .filter(comment => comment.target.side === \"backend\" || !cms)\n .map(comment => (comment.target.side === \"cms\" ? { text: comment.text, target: { side: \"backend\" as const } } : comment))\n .filter(comment => fresh(comment.text, backend.content));\n const placedBackend = placeComments(backend.content, forBackend);\n plan.files.set(name.file, { ...backend, content: addUnattached(placedBackend.text, placedBackend.leftover, entry.file, plan.root) });\n if (cms && cmsFile) {\n const forCms = comments.filter(comment => comment.target.side === \"cms\" && fresh(comment.text, cms.content));\n const placedCms = placeComments(cms.content, forCms);\n plan.files.set(cmsFile, { ...cms, content: addUnattached(placedCms.text, placedCms.leftover, entry.file, plan.root) });\n }\n });\n}\n\nfunction rank(order: readonly LegacyCollectionConfig[], collection: LegacyCollectionConfig): number {\n const index = order.findIndex(candidate => candidate.slug === collection.slug);\n return index < 0 ? order.length : index;\n}\n\n\nfunction removeCommand(plan: PlanContext, paths: readonly string[]): string {\n return `git rm -r ${paths.filter(file => fs.existsSync(file)).map(file => relativeToRoot(plan, file)).join(\" \")}`;\n}\n\n/**\n * The specifier, relative to `fromDir`, of the module `indexFile` re-exports\n * `storageAuthorize` from (`export { storageAuthorize } from \"./storage-authorize.js\"`),\n * keeping the specifier's extension style. Undefined when the index defines it\n * itself, renames it, or re-exports it from a package.\n */\nfunction storageAuthorizeReexport(indexFile: string, fromDir: string): string | undefined {\n const text = fs.readFileSync(indexFile, \"utf8\");\n for (const match of text.matchAll(/export\\s*(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*[\"']([^\"']+)[\"']/g)) {\n const names = match[1].split(\",\").map(name => name.trim());\n const specifier = match[2];\n if (!names.includes(\"storageAuthorize\") || !specifier.startsWith(\".\")) continue;\n const extension = /\\.(m?[jt]sx?)$/.exec(specifier)?.[0] ?? \"\";\n const stem = path.resolve(path.dirname(indexFile), specifier).replace(/\\.(m?[jt]sx?)$/, \"\");\n const relative = toPosix(path.relative(fromDir, stem));\n return `${relative.startsWith(\".\") ? relative : `./${relative}`}${extension}`;\n }\n return undefined;\n}\n","/**\n * `rebase migrate collections-to-tables [dir]`: the command a project on the\n * `config/collections` layout runs to move to `backend/schema` (+\n * `frontend/src/cms`). The runtime and every CLI command refuse the old layout\n * with this command in the message (`LEGACY_LAYOUT_REMEDY`).\n *\n * Prints the plan and the outcome for a person, or one JSON document\n * (`--json`) for a script or an agent. Exits 1 when the run was refused, the\n * SQL check failed, or `--check` found rules that change meaning without\n * `--accept-rule-changes`.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\n\nimport { gitState, migrateCollectionsToTables } from \"./migrate\";\nimport { rewriteSdkCalls, type SdkRewriteReport } from \"./sdk-calls\";\nimport type { ManualStep, MigrationReport, Note } from \"./types\";\n\n/** The help page. */\nexport function printCollectionsToTablesHelp(): void {\n console.log(`\n${chalk.bold(\"rebase migrate collections-to-tables\")} — move a project from config/collections to backend/schema\n\n${chalk.bold(\"Usage\")}\n rebase migrate collections-to-tables [dir] [options]\n\n ${chalk.gray(\"dir\")} The project root (where rebase.json and config/ are). Default: the current directory.\n\n${chalk.bold(\"What it writes\")}\n backend/schema/<table>.ts defineTable / defineAuthTable / defineView, one per collection\n backend/schema/index.ts every table, and defaultRls when config/collections had defaultSecurityRules\n frontend/src/cms/<table>.tsx customizeTable(...), only for a collection whose presentation was not the default\n frontend/src/cms/<name>.ts defineFirestoreCollection(...), for engine: \"firestore\" collections\n backend/resources.ts, backend/storage.ts, backend/generated/register.ts from their config/ counterparts\n rebase.json, package.json, pnpm-workspace.yaml, backend/tsconfig.json without the config package\n\n${chalk.bold(\"When to use it\")}\n Once, on a project every other command refuses with \"still on the collections layout\".\n Commit first: the run refuses a dirty git tree, so what it changes is one reviewable diff.\n\n${chalk.bold(\"Options\")}\n --dry-run Print the plan (files, refusals, manual steps) and write nothing. Start here.\n --check On a project already migrated, before deleting config/: prove backend/schema still\n renders the same SQL as config/collections. Writes nothing; exits 1 with the diff if not.\n After the git rm line (config/collections gone, backend/schema there) it reports\n \"already migrated\" and exits 0.\n --json One JSON document on stdout: files, refusals, notes, manual steps, the SQL check\n --force Run on a dirty git tree, and replace output files that hold something else\n (an earlier run's output you edited). Without it, both are refused and nothing is written.\n --skip-sdk-calls Leave the project's own code as it is; run rebase migrate sdk-calls later\n --accept-rule-changes With --check: the rules listed under \"Review before deploying\" were reviewed.\n Without it, --check exits 1 while any rule changes meaning.\n\n${chalk.bold(\"Manual steps\")}\n What the codemod cannot carry exactly is not guessed at: it is printed at the end as a numbered\n list of manual steps, each with the file it is about and, where there is one, the code to paste —\n mounting the customizations in <RebaseCMS tableCustomizations>, a module of config/ it did not\n read, an import of config/ to repoint, regenerating the SDK, refreshing the agent skills.\n The migration is done when the list is done and config/ is removed (the run prints the git rm line).\n\n${chalk.bold(\"Safety\")}\n Every run evaluates config/collections as the server did, converts it, writes the result\n and reads it back through the new pipeline: the generated SQL (DDL, policies, search, vector,\n triggers, views, the Drizzle schema) must be byte-identical, or every file is put back.\n A construct the codemod cannot carry exactly is refused with its file and line, and nothing\n is written. config/ itself is never deleted: the run prints the git rm line to run.\n\n That check compiles both sides with this release's compiler, so it proves the files were\n converted faithfully, not that a rule still MEANS what it did. Two things cover that:\n ${chalk.bold(\"Review before deploying\")} — printed last — lists every security rule whose policy now grants\n something different (e.g. a bare access: \"authenticated\", which granted nothing before and\n admits every signed-in caller now). And against the project's database, after migrating:\n rebase db push --dry-run expect \"No changes: the database already matches these tables.\"\n rebase doctor --policies expect no policy drift\n Any policy difference either lists is a change in who can access what.\n`);\n}\n\nfunction printReport(report: MigrationReport): void {\n const tables = report.collections.filter(outcome => outcome.kind === \"table\" || outcome.kind === \"auth-table\" || outcome.kind === \"view\");\n const firestore = report.collections.filter(outcome => outcome.kind === \"firestore\");\n const customized = report.collections.filter(outcome => outcome.frontendFile !== undefined && outcome.kind !== \"firestore\");\n const refused = report.collections.filter(outcome => outcome.kind === \"refused\");\n const firestoreByHand = firestore.filter(outcome => outcome.frontendFile === undefined).length;\n console.log(\"\");\n console.log(chalk.bold(`rebase migrate collections-to-tables — ${report.projectRoot}`));\n console.log(\"\");\n if (report.collections.length > 0) {\n console.log(` ${report.collections.length} collection(s): ${tables.length} table(s), ${firestore.length} Firestore${firestoreByHand > 0 ? ` (${firestoreByHand} to write by hand, see the steps)` : \"\"}, ${refused.length} refused; ${customized.length} customization file(s)`);\n }\n if (report.files.length > 0) {\n const changed = report.files.filter(file => file.action !== \"unchanged\");\n console.log(\"\");\n console.log(chalk.bold(` Files${report.status === \"planned\" || report.status === \"blocked\" ? \" (planned)\" : \"\"}: ${changed.length} to write, ${report.files.length - changed.length} unchanged`));\n for (const file of changed) console.log(` ${file.action === \"create\" ? chalk.green(\"create\") : chalk.yellow(\"update\")} ${file.path}`);\n }\n if (report.refusals.length > 0) {\n console.log(\"\");\n console.log(chalk.red.bold(` Refused (${report.refusals.length}) — nothing was written:`));\n for (const refusal of report.refusals) {\n const where = `${refusal.file}${refusal.line !== undefined ? `:${refusal.line}` : \"\"}`;\n const what = [refusal.collection, refusal.key].filter(Boolean).join(\".\");\n console.log(` ${chalk.red(\"✗\")} ${where}${what ? ` (${what})` : \"\"}`);\n console.log(` ${refusal.reason}`);\n }\n }\n if (report.notes.length > 0) {\n const notes = groupNotes(report.notes);\n console.log(\"\");\n console.log(chalk.bold(` Notes (${report.notes.length}${notes.length < report.notes.length ? `, ${notes.length} kinds` : \"\"}):`));\n for (const line of notes) console.log(` ${chalk.gray(\"·\")} ${line}`);\n }\n if (report.manualSteps.length > 0) {\n const steps = groupSteps(report.manualSteps);\n console.log(\"\");\n console.log(chalk.bold(` Manual steps (${steps.length}${steps.length < report.manualSteps.length ? `, grouped from ${report.manualSteps.length}; --json lists each` : \"\"}):`));\n steps.forEach((step, index) => {\n console.log(` ${index + 1}. ${chalk.bold(step.title)}${step.file ? chalk.gray(` (${step.file})`) : \"\"}`);\n console.log(` ${step.detail}`);\n if (step.snippet) for (const line of step.snippet.split(\"\\n\")) console.log(chalk.cyan(` ${line}`));\n });\n }\n if (report.sdk) printSdkSection(report.sdk);\n const verification = report.verification;\n if (verification) {\n console.log(\"\");\n if (verification.error) {\n console.log(chalk.red(` ✗ SQL check could not run: ${verification.error}`));\n } else if (verification.identical) {\n console.log(chalk.green(` ✓ SQL check: ${verification.compared} outputs byte-identical (DDL, policies, search, vector, triggers, views, Drizzle schema, boot plans)`));\n } else {\n console.log(chalk.red(` ✗ SQL check: ${verification.differences.length} of ${verification.compared} outputs differ${report.status === \"failed\" ? \" — every file was put back\" : \"\"}`));\n for (const difference of verification.differences) {\n console.log(chalk.bold(` ${difference.output}`));\n for (const line of difference.diff.split(\"\\n\")) console.log(` ${line}`);\n }\n }\n }\n console.log(\"\");\n switch (report.status) {\n case \"migrated\":\n console.log(chalk.green(\" Migrated. Review the diff and do the manual steps. Remove the legacy files before running generate-sdk, db push, doctor or verify (they refuse a project that still has config/collections):\"));\n break;\n case \"already-migrated\":\n console.log(chalk.green(report.verification\n ? \" Already migrated: every file holds what the codemod would write, and the SQL matches. Remove the legacy files:\"\n : \" Already migrated: config/collections is gone and backend/schema is in place. Nothing to check or remove.\"));\n break;\n case \"checked\":\n console.log(chalk.green(\" The migrated schema matches config/collections. Remove the legacy files:\"));\n break;\n case \"planned\":\n console.log(\" Dry run: nothing was written. Run without --dry-run to migrate (the SQL check runs then).\");\n break;\n default:\n break;\n }\n if (report.status === \"rule-changes\") {\n console.log(chalk.red(\" The migrated schema matches config/collections, but rules change meaning (below). Review them, then run\"));\n console.log(chalk.red(\" --check again with --accept-rule-changes.\"));\n }\n if (report.removeCommand) console.log(chalk.cyan(` ${report.removeCommand}`));\n if (report.status === \"migrated\" || report.status === \"already-migrated\" || report.status === \"checked\" || report.status === \"rule-changes\") {\n console.log(\"\");\n console.log(\" The SQL check proves the files were converted faithfully, not what the rules mean. Before deploying,\");\n console.log(\" against the project's database:\");\n console.log(chalk.cyan(\" rebase db push --dry-run\") + chalk.gray(\" expect \\\"No changes: the database already matches these tables.\\\"\"));\n console.log(chalk.cyan(\" rebase doctor --policies\") + chalk.gray(\" expect no policy drift\"));\n console.log(\" Any policy difference either lists is a change in who can access what.\");\n }\n printRuleChanges(report);\n console.log(\"\");\n}\n\n/**\n * Manual steps for a person: steps that say the same thing (the same detail,\n * no snippet) about several fields or files — \"Check fields.X.dynamicProps\"\n * once per field — printed once, listing what they are about. `--json` keeps\n * every step.\n */\n/** Kinds of step that come once per relation or file, with details of their own: printed as one step of each kind. */\nconst STEP_FAMILIES: readonly { pattern: RegExp; title: string }[] = [\n { pattern: /^Relation renamed in /, title: \"Relations renamed\" },\n { pattern: /^Update the importers of /, title: \"Exports that moved to backend/schema\" },\n { pattern: /^Check the uses of the tables /, title: \"Imports of collections that are tables now\" },\n { pattern: /^Repoint the imports of /, title: \"Imports of config/collections to repoint\" }\n];\n\nexport function groupSteps(steps: readonly ManualStep[]): ManualStep[] {\n const out: ManualStep[] = [];\n const groups = new Map<string, ManualStep[]>();\n const families = new Map<string, ManualStep[]>();\n for (const step of steps) {\n if (step.snippet) {\n out.push(step);\n continue;\n }\n const family = STEP_FAMILIES.find(candidate => candidate.pattern.test(step.title));\n if (family) {\n const members = families.get(family.title);\n if (members) members.push(step);\n else {\n families.set(family.title, [step]);\n out.push(step);\n }\n continue;\n }\n const group = groups.get(step.detail);\n if (group) group.push(step);\n else {\n const fresh = [step];\n groups.set(step.detail, fresh);\n out.push(step);\n }\n }\n return out.map(step => {\n const family = step.snippet ? undefined : STEP_FAMILIES.find(candidate => candidate.pattern.test(step.title));\n if (family) {\n const members = families.get(family.title) ?? [step];\n if (members.length === 1) return step;\n return { title: `${family.title} (${members.length})`, detail: members.map(member => `${member.file ?? member.title}: ${member.detail}`).join(\" | \") };\n }\n const group = step.snippet ? undefined : groups.get(step.detail);\n if (!group || group.length === 1) return step;\n const about = group.map(member => `${member.title}${member.file ? ` (${member.file})` : \"\"}`);\n return { title: `${group.length} steps that say the same`, detail: `${step.detail} — ${about.join(\"; \")}` };\n });\n}\n\n/** Notes for a person: the same remark about several keys (`properties.id.isId is not carried: …`) printed once with the keys. */\nexport function groupNotes(notes: readonly Note[]): string[] {\n const groups = new Map<string, string[]>();\n for (const item of notes) {\n const where = item.file ? `${item.file}${item.line !== undefined ? `:${item.line}` : \"\"}` : \"\";\n const keyed = /^([\\w$]+(?:\\.[\\w$]+|\\[\\])*\\.[\\w$]+) (.+)$/.exec(item.message);\n const key = keyed ? keyed[2] : item.message;\n const label = keyed ? `${where} ${keyed[1]}`.trim() : where;\n groups.set(key, [...(groups.get(key) ?? []), label]);\n }\n return [...groups].map(([message, labels]) => labels.length === 1\n ? `${labels[0] ? `${labels[0]} ` : \"\"}${message}`\n : `${labels.length}× ${message} — ${labels.join(\", \")}`);\n}\n\n/** The rules that change meaning: last, so they cannot scroll away. */\nfunction printRuleChanges(report: MigrationReport): void {\n if (report.ruleChanges.length === 0) return;\n console.log(\"\");\n console.log(chalk.red.bold(` ⚠ Review before deploying: these rules change meaning (${report.ruleChanges.length})`));\n console.log(chalk.red(\" Each is carried as written and keeps its policy name, but the policy now grants something different.\"));\n for (const change of report.ruleChanges) {\n console.log(` ${chalk.red(\"!\")} ${change.file} (${change.collection} ${change.rule})`);\n console.log(` ${change.message}`);\n }\n}\n\n/**\n * Run the command.\n *\n * @param flags the parsed flags\n * @param dir the project directory, as typed\n * @param moduleAliases specifiers mapped to files for evaluating the project (the in-repo entry points `@rebasepro/*` at source)\n */\nexport async function runCollectionsToTables(\n flags: { check?: boolean; dryRun?: boolean; json?: boolean; force?: boolean; skipSdkCalls?: boolean; acceptRuleChanges?: boolean },\n dir: string | undefined,\n moduleAliases?: Record<string, string>\n): Promise<MigrationReport> {\n const projectRoot = path.resolve(dir ?? process.cwd());\n const report = await migrateCollectionsToTables({\n projectRoot,\n ...(flags.check ? { check: true } : {}),\n ...(flags.dryRun ? { dryRun: true } : {}),\n ...(flags.force ? { force: true } : {}),\n ...(flags.skipSdkCalls ? { skipSdkCalls: true } : {}),\n ...(flags.acceptRuleChanges ? { acceptRuleChanges: true } : {}),\n ...(moduleAliases ? { moduleAliases } : {})\n });\n if (flags.json) console.log(JSON.stringify(report, null, 2));\n else printReport(report);\n if (report.status === \"blocked\" || report.status === \"failed\" || report.status === \"rule-changes\") process.exitCode = 1;\n return report;\n}\n\n/** The SDK-call rewrite's part of a report. */\nfunction printSdkSection(sdk: SdkRewriteReport): void {\n const total = Object.values(sdk.counts).reduce((sum, count) => sum + (count ?? 0), 0);\n console.log(\"\");\n console.log(chalk.bold(` SDK calls: ${total} rewrite(s) in ${sdk.files.length} file(s)${sdk.typeAware ? \" (receivers checked by type where a program could be built)\" : \"\"}`));\n for (const [rule, count] of Object.entries(sdk.counts)) console.log(` ${rule}: ${count}`);\n if (sdk.dependencies.length > 0) {\n console.log(chalk.bold(` Dependencies added (${sdk.dependencies.length}) — imports moved to these packages; run your package manager's install:`));\n for (const added of sdk.dependencies) console.log(` ${added.file}: ${chalk.green(`\"${added.name}\": \"${added.version}\"`)}`);\n }\n if (sdk.byName.length > 0) {\n console.log(chalk.yellow(` Rewritten by name — review (${sdk.byName.length}): no type says \"SDK\" (untyped, \\`any\\`, a structural type of your own, a test double), so the slot's name (\\`dataAsAdmin\\`, \\`data\\` with a literal table) decided. A \\`.collection(\\` left on the data surface is a TypeError on 0.31 that no type check reports:`));\n for (const entry of sdk.byName) console.log(` ${entry.file}:${entry.line} ${chalk.gray(entry.code)}`);\n }\n if (sdk.left.length > 0) {\n console.log(chalk.yellow(` Left unchanged (${sdk.left.length}) — check each:`));\n for (const left of sdk.left) console.log(` ${left.file}:${left.line} ${chalk.gray(left.code)} — ${left.reason}`);\n }\n}\n\n/** The help page of `rebase migrate sdk-calls`. */\nexport function printSdkCallsHelp(): void {\n console.log(`\n${chalk.bold(\"rebase migrate sdk-calls\")} — rewrite a project's own code for the SDK rename\n\n${chalk.bold(\"Usage\")}\n rebase migrate sdk-calls [dir] [--dry-run] [--json] [--force]\n\n Part of ${chalk.cyan(\"rebase migrate collections-to-tables\")}; run it alone on a project already migrated.\n data.collection(\"x\") → data.table(\"x\") on the SDK data surface, createRebaseClient options,\n generated type names, batch operations, error codes, offline options, typed accessors,\n setCollectionCallbacks → setTableHooks (hook props adapted), storageAuthorize data, and the\n rule keys: existsIn({ collection: X }) and membership: { collection: X } → table: X.\n A .collection( call whose receiver is not the SDK is left as written and listed. Where no type\n says \"SDK\" (untyped, any, a structural type of the project's own), a receiver ending in\n .dataAsAdmin, or in .data with a literal table name, is rewritten and listed for review — as are\n test doubles a data/dataAsAdmin slot holds ({ dataAsAdmin: { collection: … } }) and, in test\n files, source-text assertions (collection(\"x\") in a string or regex).\n Generated SDK files are not rewritten: run rebase generate-sdk.\n\n Imports of names 0.31 moved to another package (the admin-panel helpers and types that left\n @rebasepro/types and @rebasepro/common for @rebasepro/cms-types, the migration lift now in\n @rebasepro/common/migrate) are moved to it — merged into an import the file has, import type,\n inline type and as aliases kept — and renamed exports (reviewSecurityRules → reviewRls,\n assertUploadWithinPropertyLimits → assertUploadWithinColumnLimits, …) are renamed with their\n references. A package an import now names is added to that workspace package's dependencies,\n at the range of its other @rebasepro packages.\n\n${chalk.bold(\"When to use it\")}\n On a project already migrated (or migrated with --skip-sdk-calls), and again after pulling in\n code written against the old names. A second run on rewritten code changes nothing.\n\n${chalk.bold(\"Options\")}\n --dry-run Print what would change; write nothing\n --json One JSON document on stdout\n --force Run on a dirty (or absent) git tree. Without it the run refuses, so its edits stay one diff.\n\n${chalk.bold(\"Manual steps\")}\n What it cannot rewrite safely is printed after the counts as a numbered list, each with the file,\n the line and what to write instead: a boot option it cannot prove, a generated SDK file, an export\n that was removed or now means something else, a namespace import, export * or dynamic import that\n uses a moved name, an option, variable, route or MCP tool name whose meaning changed, an old CLI\n flag in a package.json script. Each points at its section of the upgrade guide.\n`);\n}\n\n/**\n * Run \\`rebase migrate sdk-calls\\`.\n *\n * @param dir the project directory, as typed\n * @param aliases specifiers mapped to files, for the type checker (in-repo runs)\n */\nexport async function runSdkCalls(flags: { dryRun?: boolean; json?: boolean; force?: boolean }, dir: string | undefined, aliases?: Record<string, string>): Promise<SdkRewriteReport | undefined> {\n const root = path.resolve(dir ?? process.cwd());\n if (!flags.dryRun && !flags.force) {\n const state = gitState(root);\n if (!state.clean) {\n if (flags.json) console.log(JSON.stringify({ error: { message: state.reason, code: \"dirty_tree\" } }, null, 2));\n else console.error(chalk.red(`✗ ${state.reason}`));\n process.exitCode = 1;\n return undefined;\n }\n }\n const legacyConfig = path.join(root, \"config\", \"collections\");\n const { files, report } = await rewriteSdkCalls(root, { skipDirs: [legacyConfig], ...(aliases ? { aliases } : {}) });\n if (!flags.dryRun) for (const [file, content] of files) fs.writeFileSync(file, content);\n if (flags.json) {\n console.log(JSON.stringify({ status: flags.dryRun ? \"planned\" : files.size > 0 ? \"rewritten\" : \"nothing-to-do\", ...report }, null, 2));\n } else {\n console.log(chalk.bold(`\\nrebase migrate sdk-calls — ${root}`));\n printSdkSection(report);\n const steps = groupSteps(report.manualSteps);\n if (steps.length > 0) console.log(chalk.bold(`\\n Manual steps (${steps.length}):`));\n steps.forEach((step, index) => {\n console.log(` ${index + 1}. ${chalk.bold(step.title)}${step.file ? chalk.gray(` (${step.file})`) : \"\"}`);\n console.log(` ${step.detail}`);\n if (step.snippet) for (const line of step.snippet.split(\"\\n\")) console.log(chalk.cyan(` ${line}`));\n });\n console.log(flags.dryRun ? \"\\n Dry run: nothing was written.\\n\" : files.size > 0 ? \"\\n Rewritten. Review the diff, then run your type check.\\n\" : \"\\n Nothing to rewrite.\\n\");\n }\n return report;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAa,YAAb,MAAuB;CACE;CAArB,YAAY,MAAuB;EAAd,KAAA,OAAA;CAAe;AACxC;AAEA,IAAM,SAAS;AACf,IAAM,aAAa;;AAGnB,SAAgB,SAAS,KAAqB;CAC1C,OAAO,WAAW,KAAK,GAAG,IAAI,MAAM,KAAK,UAAU,GAAG;AAC1D;;AAGA,SAAgB,mBAAmB,OAAuB;CACtD,OAAO,KAAK,UAAU,KAAK;AAC/B;;;;;AAMA,SAAgB,SAAS,MAAc,QAAwB;CAE3D,OADc,KAAK,MAAM,IAClB,CAAA,CAAM,KAAK,MAAM,UAAW,UAAU,KAAK,KAAK,WAAW,IAAI,OAAO,GAAG,SAAS,MAAO,CAAC,CAAC,KAAK,IAAI;AAC/G;;;;;;AAOA,SAAgB,OAAO,MAAc,YAA4B;CAC7D,IAAI,WAAW,WAAW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,WAAW,OAAO,WAAW;EAC3C,IAAI,MAAM,SAAS,GAAG,QAAQ,IAAI,MAAM,KAAK,qBAAqB,MAAM,OAAO,GAAG,CAAC;EACnF,MAAM,SAAS,MAAM,UAAU;GAC3B,QAAQ,IAAI,OAAO,QAAQ,EAAE,IAAI,MAAM,KAAK,KAAK,KAAK,IAAI,KAAK,OAAO,MAAM,KAAK,KAAK,KAAK,KAAK,EAAE,IAAI,IAAI;GAC1G,QAAQ,IAAI,UAAU,KAAK,QAAQ;GACnC,IAAI,KAAK,SAAS,KAAK,MAAM,QAAQ,KAAK,QAAQ,MAAM,IAAI,GAAG,QAAQ,IAAI,MAAM,KAAK,YAAY,MAAM,CAAC;EAC7G,CAAC;EACD,QAAQ,IAAI,MAAM,SAAS,wCAAwC,MAAM,OAAO,IAAI,gEAAgE,2BAA2B;CACnL;CACA,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"command-BzSP5gBh.js","names":[],"sources":["../src/codemod/collections-to-tables/print-js.ts","../src/codemod/collections-to-tables/ast.ts","../src/codemod/collections-to-tables/own.ts","../src/codemod/collections-to-tables/hooks.ts","../src/codemod/collections-to-tables/modules.ts","../src/codemod/collections-to-tables/helper-hooks.ts","../src/codemod/collections-to-tables/plan-context.ts","../src/codemod/collections-to-tables/backend.ts","../src/codemod/collections-to-tables/vocabulary.ts","../src/codemod/collections-to-tables/comments.ts","../src/codemod/collections-to-tables/dynamic-props.ts","../src/codemod/collections-to-tables/split-constants.ts","../src/codemod/collections-to-tables/customization.ts","../src/codemod/collections-to-tables/firestore.ts","../src/codemod/collections-to-tables/export-changes.ts","../src/codemod/collections-to-tables/moved-symbols.generated.ts","../src/codemod/collections-to-tables/moved-imports.ts","../src/codemod/collections-to-tables/sdk-calls.ts","../src/codemod/collections-to-tables/row-hands.ts","../src/codemod/collections-to-tables/skills-step.ts","../src/codemod/collections-to-tables/journal.ts","../src/codemod/collections-to-tables/legacy-shims.ts","../src/codemod/collections-to-tables/load-legacy.ts","../src/codemod/collections-to-tables/path-aliases.ts","../src/codemod/collections-to-tables/project-files.ts","../src/codemod/collections-to-tables/storage-paths.ts","../src/codemod/collections-to-tables/repoint.ts","../src/codemod/collections-to-tables/verify.ts","../src/codemod/collections-to-tables/migrate.ts","../src/codemod/collections-to-tables/command.ts"],"sourcesContent":["/**\n * Printing plain values as TypeScript source, with code spliced in.\n *\n * The codemod writes two kinds of value: data it read off an evaluated\n * collection (strings, numbers, arrays, objects), printed here, and code it\n * read off the legacy source (a hook, an entity action, a component), carried\n * as {@link RawSource} and printed verbatim, re-indented to where it lands.\n *\n * Same conventions as the shared table printer: four-space indentation,\n * double quotes, no trailing commas, one entry per line for a non-empty\n * object.\n */\n\n/** Source text printed verbatim. Its first line starts at column 0; later lines carry their indentation relative to it. */\nexport class RawSource {\n constructor(readonly text: string) {}\n}\n\nconst INDENT = \" \";\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/** An object key as written: bare when it is an identifier, quoted otherwise. */\nexport function printKey(key: string): string {\n return IDENTIFIER.test(key) ? key : JSON.stringify(key);\n}\n\n/** A string literal, double-quoted. */\nexport function printStringLiteral(value: string): string {\n return JSON.stringify(value);\n}\n\n/**\n * Re-indent raw source to land at `indent`: every line after the first gets\n * the prefix, so the block keeps its own shape.\n */\nexport function reindent(text: string, indent: string): string {\n const lines = text.split(\"\\n\");\n return lines.map((line, index) => (index === 0 || line.length === 0 ? line : `${indent}${line}`)).join(\"\\n\");\n}\n\n/**\n * Strip the indentation a node had in its file: `text` is the node's text\n * (its first line starts at the node), `baseIndent` the leading whitespace of\n * the line it starts on. Later lines that start with that whitespace lose it.\n */\nexport function dedent(text: string, baseIndent: string): string {\n if (baseIndent.length === 0) return text;\n return text\n .split(\"\\n\")\n .map((line, index) => (index > 0 && line.startsWith(baseIndent) ? line.slice(baseIndent.length) : line))\n .join(\"\\n\");\n}\n\n/** Thrown for a value that is code, and that no source text was found for. */\nexport class UnprintableValueError extends Error {\n constructor(readonly path: string, message: string) {\n super(`${path}: ${message}`);\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** Whether a value holds a function anywhere: it then needs source text to print. */\nexport function containsCode(value: unknown, seen: Set<unknown> = new Set()): boolean {\n if (typeof value === \"function\") return true;\n if (value instanceof RawSource) return false;\n if (typeof value !== \"object\" || value === null || seen.has(value)) return false;\n seen.add(value);\n if (Array.isArray(value)) return value.some(entry => containsCode(entry, seen));\n if (!isPlainObject(value)) return true;\n return Object.values(value).some(entry => containsCode(entry, seen));\n}\n\n/**\n * A value as source text, starting at `indent` (the indentation of the line\n * it begins on).\n */\nexport function printValue(value: unknown, indent = \"\", path = \"value\"): string {\n if (value instanceof RawSource) return reindent(value.text, indent);\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n switch (typeof value) {\n case \"string\":\n return printStringLiteral(value);\n case \"number\":\n if (Number.isNaN(value)) return \"NaN\";\n if (!Number.isFinite(value)) return value > 0 ? \"Infinity\" : \"-Infinity\";\n return Object.is(value, -0) ? \"-0\" : String(value);\n case \"boolean\":\n return String(value);\n case \"bigint\":\n return `${value}n`;\n case \"function\":\n throw new UnprintableValueError(path, \"it is a function, and no source text for it was found.\");\n default:\n break;\n }\n const inner = indent + INDENT;\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n const items = value.map((entry, index) => printValue(entry, inner, `${path}[${index}]`));\n const flat = `[${items.join(\", \")}]`;\n if (!flat.includes(\"\\n\") && flat.length + indent.length <= 100 && value.every(entry => typeof entry !== \"object\" || entry === null)) {\n return flat;\n }\n return `[\\n${items.map(item => `${inner}${item}`).join(\",\\n\")}\\n${indent}]`;\n }\n if (value instanceof Date) return `new Date(${printStringLiteral(value.toISOString())})`;\n if (!isPlainObject(value)) {\n throw new UnprintableValueError(path, \"it is an instance of a class, which cannot be printed as a literal.\");\n }\n const entries = Object.entries(value).filter(([, entry]) => entry !== undefined);\n if (entries.length === 0) return \"{}\";\n const lines = entries.map(([key, entry]) => `${inner}${printKey(key)}: ${printValue(entry, inner, `${path}.${key}`)}`);\n return `{\\n${lines.join(\",\\n\")}\\n${indent}}`;\n}\n","/**\n * Reading the legacy source with ts-morph: where a collection's object\n * literal is, the node at a path inside it, and the code a node needs carried\n * with it (the imports and top-level declarations it references).\n *\n * The codemod evaluates collections for their data; it reads the AST only for\n * what a value cannot say — the text of a function, the comment above a\n * property, the module a component came from. So everything here answers one\n * question about one node, and says why when it cannot.\n *\n * ts-morph is loaded once per run (`await import(\"ts-morph\")`) and handed in;\n * nothing here imports it at module load, so the CLI's start-up never pays\n * for it.\n */\nimport path from \"node:path\";\nimport type {\n ArrayLiteralExpression,\n Expression,\n Identifier,\n MethodDeclaration,\n Node,\n ObjectLiteralExpression,\n Project,\n SourceFile,\n Statement\n} from \"ts-morph\";\n\nimport { dedent } from \"./print-js\";\n\n/** The ts-morph module, loaded lazily by the run. */\nexport type TsMorph = typeof import(\"ts-morph\");\n\n/** What every AST helper needs. */\nexport interface AstContext {\n tsm: TsMorph;\n /** An in-memory project holding the legacy files at their absolute paths, and scratch files. */\n project: Project;\n}\n\n/** Create the in-memory project the legacy files are read into. */\nexport function createAstContext(tsm: TsMorph): AstContext {\n const project = new tsm.Project({\n useInMemoryFileSystem: true,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n allowJs: true,\n jsx: tsm.ts.JsxEmit.Preserve,\n target: tsm.ts.ScriptTarget.ES2022,\n module: tsm.ts.ModuleKind.ESNext,\n moduleResolution: tsm.ts.ModuleResolutionKind.Bundler,\n noLib: true\n }\n });\n return { tsm, project };\n}\n\n/** Add a legacy file to the project, at its absolute path. */\nexport function addSourceFile(ctx: AstContext, absolutePath: string, text: string): SourceFile {\n return ctx.project.createSourceFile(absolutePath, text, { overwrite: true });\n}\n\n/** The node a lookup ended on, or why it could not get there. */\nexport type Located<T> = { node: T; reason?: undefined } | { node?: undefined; reason: string };\n\n/** Strip `as`, `satisfies`, parentheses, `!` and `<T>` casts. */\nexport function unwrap(ctx: AstContext, node: Node): Node {\n const { Node: N } = ctx.tsm;\n let current = node;\n for (;;) {\n if (N.isAsExpression(current) || N.isSatisfiesExpression(current) || N.isParenthesizedExpression(current) ||\n N.isNonNullExpression(current) || N.isTypeAssertion(current)) {\n current = current.getExpression();\n continue;\n }\n return current;\n }\n}\n\n/** The top-level `const` an identifier names in its own file, or undefined. */\nexport function sameFileConst(ctx: AstContext, identifier: Identifier): Expression | undefined {\n const { Node: N, VariableDeclarationKind } = ctx.tsm;\n const sf = identifier.getSourceFile();\n const declaration = sf.getVariableDeclaration(identifier.getText());\n if (!declaration) return undefined;\n const list = declaration.getVariableStatement();\n if (!list || !N.isSourceFile(list.getParent())) return undefined;\n if (list.getDeclarationKind() !== VariableDeclarationKind.Const) return undefined;\n return declaration.getInitializer();\n}\n\n/** The names a builder call that wraps a collection literal may have. */\nconst WRAPPER_CALLS = new Set([\"defineCollection\", \"defineFirestoreCollection\"]);\n\n/**\n * Follow a node to the object literal it denotes: through casts, a wrapper\n * call (`defineCollection({...})`) and a same-file `const`.\n */\nexport function resolveObject(ctx: AstContext, node: Node | undefined, depth = 0): Located<ObjectLiteralExpression> {\n const { Node: N } = ctx.tsm;\n if (!node) return { reason: \"there is no expression to read\" };\n if (depth > 8) return { reason: \"the expression refers to itself\" };\n const current = unwrap(ctx, node);\n if (N.isObjectLiteralExpression(current)) return { node: current };\n if (N.isCallExpression(current)) {\n const callee = current.getExpression().getText();\n if (WRAPPER_CALLS.has(callee)) return resolveObject(ctx, current.getArguments()[0], depth + 1);\n return { reason: `it is the result of calling \\`${callee}(...)\\`, which the codemod cannot read through` };\n }\n if (N.isIdentifier(current)) {\n const initializer = sameFileConst(ctx, current);\n if (initializer) return resolveObject(ctx, initializer, depth + 1);\n return { reason: `it is \\`${current.getText()}\\`, which is not a \\`const\\` declared in the same file` };\n }\n return { reason: `it is a ${current.getKindName()}, not an object literal` };\n}\n\n/** Like {@link resolveObject}, for an array literal. */\nexport function resolveArray(ctx: AstContext, node: Node | undefined, depth = 0): Located<ArrayLiteralExpression> {\n const { Node: N } = ctx.tsm;\n if (!node) return { reason: \"there is no expression to read\" };\n if (depth > 8) return { reason: \"the expression refers to itself\" };\n const current = unwrap(ctx, node);\n if (N.isArrayLiteralExpression(current)) return { node: current };\n if (N.isIdentifier(current)) {\n const initializer = sameFileConst(ctx, current);\n if (initializer) return resolveArray(ctx, initializer, depth + 1);\n return { reason: `it is \\`${current.getText()}\\`, which is not a \\`const\\` declared in the same file` };\n }\n return { reason: `it is a ${current.getKindName()}, not an array literal` };\n}\n\n/** The literal text of a property name, or undefined for a computed one that is not a string literal. */\nfunction memberName(ctx: AstContext, member: Node): string | undefined {\n const { Node: N } = ctx.tsm;\n if (!N.isPropertyAssignment(member) && !N.isShorthandPropertyAssignment(member) && !N.isMethodDeclaration(member) &&\n !N.isGetAccessorDeclaration(member) && !N.isSetAccessorDeclaration(member)) {\n return undefined;\n }\n const nameNode = member.getNameNode();\n if (N.isIdentifier(nameNode) || N.isPrivateIdentifier(nameNode)) return nameNode.getText();\n if (N.isStringLiteral(nameNode) || N.isNoSubstitutionTemplateLiteral(nameNode)) return nameNode.getLiteralValue();\n if (N.isNumericLiteral(nameNode)) return String(nameNode.getLiteralValue());\n if (N.isComputedPropertyName(nameNode)) {\n const expression = nameNode.getExpression();\n if (N.isStringLiteral(expression) || N.isNoSubstitutionTemplateLiteral(expression)) return expression.getLiteralValue();\n }\n return undefined;\n}\n\n/** One member of an object literal, found by name. */\nexport interface Member {\n /** The member node: a property assignment, a shorthand, or a method. */\n node: Node;\n /** The value expression (absent for a method, which is its own value). */\n value?: Expression;\n /** Present for a method. */\n method?: MethodDeclaration;\n}\n\n/**\n * The member of an object literal named `name`. Refuses (with the reason)\n * when the literal has a spread or a computed key that could be providing\n * it, because then the literal alone does not say where the value is from.\n */\nexport function memberOf(ctx: AstContext, literal: ObjectLiteralExpression, name: string): Located<Member> {\n const { Node: N } = ctx.tsm;\n let found: Member | undefined;\n let opaque: string | undefined;\n for (const member of literal.getProperties()) {\n if (N.isSpreadAssignment(member)) {\n // A later explicit member wins over a spread; an earlier one does not.\n found = undefined;\n opaque = `\\`...${member.getExpression().getText()}\\` (line ${member.getStartLineNumber()})`;\n continue;\n }\n const memberKey = memberName(ctx, member);\n if (memberKey === undefined) {\n opaque = `the computed key \\`${member.getText().split(\":\")[0]}\\` (line ${member.getStartLineNumber()})`;\n continue;\n }\n if (memberKey !== name) continue;\n opaque = undefined;\n if (N.isPropertyAssignment(member)) found = { node: member, value: member.getInitializerOrThrow() };\n else if (N.isShorthandPropertyAssignment(member)) found = { node: member, value: member.getNameNode() };\n else if (N.isMethodDeclaration(member)) found = { node: member, method: member };\n else return { reason: `\\`${name}\\` is an accessor (line ${member.getStartLineNumber()})` };\n }\n if (found) return { node: found };\n if (opaque) return { reason: `\\`${name}\\` may come from ${opaque}, which the codemod does not read through` };\n return { reason: `there is no \\`${name}\\` in the object literal at line ${literal.getStartLineNumber()}` };\n}\n\n/** Whether an expression is a module-scope name, or a property chain on one (`rules.fixed`): an import or a top-level `const`. */\nfunction isModuleName(ctx: AstContext, node: Node): boolean {\n const { Node: N, SyntaxKind, VariableDeclarationKind } = ctx.tsm;\n if (N.isPropertyAccessExpression(node)) return isModuleName(ctx, node.getExpression());\n if (!N.isIdentifier(node)) return false;\n const declarations = node.getSymbol()?.getDeclarations() ?? [];\n return declarations.length > 0 && declarations.every(declaration => {\n if (N.isImportSpecifier(declaration) || N.isImportClause(declaration) || N.isNamespaceImport(declaration)) return true;\n if (!N.isVariableDeclaration(declaration)) return false;\n const statement = declaration.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n return statement !== undefined && N.isSourceFile(statement.getParent()) && statement.getDeclarationKind() === VariableDeclarationKind.Const;\n });\n}\n\n/**\n * The value at `segments` below an object literal when an object literal on\n * the way spreads the one object that must provide it — `{ ...fixedOnceCreated }`\n * with no `dynamicProps` of its own — as an expression on that object:\n * `fixedOnceCreated.dynamicProps`, the very value the evaluation saw. Returns\n * the spread expression too, whose imports the caller carries.\n *\n * Only when nothing else could provide it: exactly one spread in that literal,\n * no computed key, no member of that name (before or after the spread), a\n * spread of an imported or top-level `const` name (not a call, not a\n * parameter), and only names below it.\n */\nexport function spreadSource(ctx: AstContext, root: ObjectLiteralExpression, segments: readonly PathSegment[]): { text: string; spread: Expression } | undefined {\n const { Node: N } = ctx.tsm;\n let current: Member = { node: root, value: root };\n for (let index = 0; index < segments.length; index++) {\n const segment = segments[index];\n if (typeof segment === \"number\" || current.method) return undefined;\n const object = resolveObject(ctx, current.value);\n if (!object.node) return undefined;\n const member = memberOf(ctx, object.node, segment);\n if (member.node) {\n current = member.node;\n continue;\n }\n const properties = object.node.getProperties();\n const spreads = properties.filter(property => N.isSpreadAssignment(property));\n if (spreads.length !== 1) return undefined;\n for (const property of properties) {\n if (N.isSpreadAssignment(property)) continue;\n const name = memberName(ctx, property);\n if (name === undefined || name === segment) return undefined;\n }\n const rest = segments.slice(index);\n if (!rest.every(part => typeof part === \"string\" && /^[A-Za-z_$][\\w$]*$/.test(part))) return undefined;\n const spreadAssignment = spreads[0];\n if (!spreadAssignment || !N.isSpreadAssignment(spreadAssignment)) return undefined;\n const spread = unwrap(ctx, spreadAssignment.getExpression());\n if (!N.isExpression(spread) || !isModuleName(ctx, spread)) return undefined;\n return { text: `${spread.getText()}.${rest.join(\".\")}`, spread };\n }\n return undefined;\n}\n\n/** A path segment: a member name, or an array index. */\nexport type PathSegment = string | number;\n\n/**\n * The member at `segments` below an object literal: each name read with\n * {@link memberOf}, each index from an array literal, every step resolved\n * through same-file `const`s.\n */\nexport function nodeAtPath(ctx: AstContext, root: ObjectLiteralExpression, segments: readonly PathSegment[]): Located<Member> {\n let current: Member = { node: root, value: root };\n const walked: string[] = [];\n for (const segment of segments) {\n const label = walked.length > 0 ? walked.join(\"\") : \"the collection\";\n if (typeof segment === \"number\") {\n const array = resolveArray(ctx, current.value);\n if (!array.node) return { reason: `${label}: ${array.reason}` };\n const elements = array.node.getElements();\n if (elements.slice(0, segment + 1).some(element => ctx.tsm.Node.isSpreadElement(element))) {\n return { reason: `${label} spreads another array before item ${segment}, which the codemod does not read through` };\n }\n const element = elements[segment];\n if (!element) return { reason: `${label} has no item ${segment}` };\n current = { node: element, value: element };\n walked.push(`[${segment}]`);\n continue;\n }\n if (current.method) return { reason: `${label} is a method, not an object` };\n const object = resolveObject(ctx, current.value);\n if (!object.node) return { reason: `${label}: ${object.reason}` };\n const member = memberOf(ctx, object.node, segment);\n if (!member.node) return { reason: `${label}: ${member.reason}` };\n current = member.node;\n walked.push(walked.length > 0 ? `.${segment}` : segment);\n }\n return { node: current };\n}\n\n/** The whitespace a node's first line starts with in its file. */\nexport function lineIndent(node: Node): string {\n const sf = node.getSourceFile();\n const text = sf.getFullText();\n const start = node.getStart();\n const lineStart = text.lastIndexOf(\"\\n\", start - 1) + 1;\n const prefix = text.slice(lineStart, start);\n const match = /^[ \\t]*/.exec(prefix);\n return match ? match[0] : \"\";\n}\n\n/** A node's text with the indentation of its line removed from every later line. */\nexport function nodeText(node: Node): string {\n return dedent(node.getText(), lineIndent(node));\n}\n\n/** `file:line` for messages, relative to `root`. */\nexport function where(node: Node, root: string): { file: string; line: number } {\n return { file: toPosix(path.relative(root, node.getSourceFile().getFilePath())), line: node.getStartLineNumber() };\n}\n\n/** A path with `/` separators. */\nexport function toPosix(value: string): string {\n return value.split(path.sep).join(\"/\");\n}\n\n// ── The collection literal ───────────────────────────────────────────────────\n\n/** Where a collection file's default export is. */\nexport interface CollectionSite {\n /** The object literal the collection is written as. */\n literal: ObjectLiteralExpression;\n /** The local name the collection is bound to, when it is bound (`usersCollection`). */\n binding?: string;\n /** The statements that declare and default-export it, which are not carried anywhere. */\n statements: Statement[];\n}\n\n/** Find the object literal a collection file default-exports. */\nexport function findCollectionSite(ctx: AstContext, sf: SourceFile): Located<CollectionSite> {\n const { Node: N } = ctx.tsm;\n const statements: Statement[] = [];\n let expression: Node | undefined;\n for (const statement of sf.getStatements()) {\n if (N.isExportAssignment(statement) && !statement.isExportEquals()) {\n expression = statement.getExpression();\n statements.push(statement);\n } else if (N.isExportDeclaration(statement)) {\n for (const specifier of statement.getNamedExports()) {\n if ((specifier.getAliasNode()?.getText() ?? specifier.getName()) === \"default\" && !statement.getModuleSpecifier()) {\n expression = specifier.getNameNode();\n statements.push(statement);\n }\n }\n }\n }\n if (!expression) return { reason: \"the file has no `export default` the codemod can read\" };\n let binding: string | undefined;\n const bare = unwrap(ctx, expression);\n if (N.isIdentifier(bare)) {\n binding = bare.getText();\n const declaration = sf.getVariableDeclaration(binding);\n const statement = declaration?.getVariableStatement();\n if (statement) statements.push(statement);\n }\n const literal = resolveObject(ctx, expression);\n if (!literal.node) return { reason: `the default export is not an object literal the codemod can read: ${literal.reason}` };\n return { node: { literal: literal.node, ...(binding ? { binding } : {}), statements } };\n}\n\n/**\n * Assignments to the collection after its declaration, at the top level of\n * its file: `usersCollection.securityRules = [...]`. Keyed by the assigned\n * path (`securityRules`, `properties.title.callbacks`).\n */\nexport function postDeclarationAssignments(ctx: AstContext, sf: SourceFile, binding: string): Map<string, { value: Expression; statement: Statement }> {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const out = new Map<string, { value: Expression; statement: Statement }>();\n for (const statement of sf.getStatements()) {\n if (!N.isExpressionStatement(statement)) continue;\n const expression = statement.getExpression();\n if (!N.isBinaryExpression(expression) || expression.getOperatorToken().getKind() !== SyntaxKind.EqualsToken) continue;\n const parts: string[] = [];\n let left: Node = expression.getLeft();\n while (N.isPropertyAccessExpression(left)) {\n parts.unshift(left.getName());\n left = left.getExpression();\n }\n if (N.isIdentifier(left) && left.getText() === binding && parts.length > 0) {\n out.set(parts.join(\".\"), { value: expression.getRight(), statement });\n }\n }\n return out;\n}\n\n// ── What a node references ───────────────────────────────────────────────────\n\n/** One import binding a carried node uses. */\nexport interface ImportUse {\n /** The module specifier as written. */\n specifier: string;\n /** The file it was written in (absolute), to resolve a relative specifier from. */\n fromFile: string;\n /** `default`, `*` (namespace) or the imported name. */\n imported: string;\n /** The local name. */\n local: string;\n /** Whether only types are imported. */\n typeOnly: boolean;\n}\n\n/** The imports and top-level declarations some nodes reference, transitively. */\nexport interface References {\n imports: ImportUse[];\n /** Top-level statements, in file order, each once. */\n statements: Statement[];\n /** Names that resolve to a statement that may not be carried (the collection itself). */\n forbidden: { name: string; line: number }[];\n}\n\n/**\n * Whether an identifier is read as a name in scope, rather than written as a\n * property name (`a.b`'s `b`, `{ b: 1 }`'s `b`, a method's or a member's own\n * name). A shorthand `{ b }` is a reference.\n */\nfunction isReferencePosition(ctx: AstContext, identifier: Identifier): boolean {\n const { Node: N } = ctx.tsm;\n const parent = identifier.getParent();\n if (!parent) return true;\n if (N.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) return false;\n if (N.isQualifiedName(parent) && parent.getRight() === identifier) return false;\n if ((N.isPropertyAssignment(parent) || N.isMethodDeclaration(parent) || N.isPropertySignature(parent) ||\n N.isMethodSignature(parent) || N.isPropertyDeclaration(parent) || N.isGetAccessorDeclaration(parent) ||\n N.isSetAccessorDeclaration(parent) || N.isEnumMember(parent)) && parent.getNameNode() === identifier) {\n return false;\n }\n if (N.isBindingElement(parent) && parent.getPropertyNameNode() === identifier) return false;\n if (N.isJsxAttribute(parent)) return false;\n return true;\n}\n\n/** The top-level statement a declaration node belongs to, when it is one. */\nfunction topLevelStatement(ctx: AstContext, declaration: Node): Statement | undefined {\n const { Node: N } = ctx.tsm;\n let current: Node | undefined = declaration;\n while (current && !N.isSourceFile(current.getParent() ?? current)) {\n current = current.getParent();\n }\n if (!current || !N.isStatement(current)) return undefined;\n return N.isSourceFile(current.getParent()) ? current : undefined;\n}\n\n/**\n * Collect what `nodes` reference at the top level of their file: import\n * bindings, and the statements declaring other names (followed\n * transitively). `exclude` are statements that must not be carried — a\n * reference to one is reported in `forbidden`.\n */\nexport function collectReferences(ctx: AstContext, nodes: readonly Node[], exclude: readonly Statement[]): References {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const imports: ImportUse[] = [];\n const statements = new Set<Statement>();\n const forbidden: { name: string; line: number }[] = [];\n const queue: Node[] = [...nodes];\n const visited = new Set<Node>();\n while (queue.length > 0) {\n const node = queue.shift();\n if (!node || visited.has(node)) continue;\n visited.add(node);\n const identifiers = N.isIdentifier(node) ? [node] : node.getDescendantsOfKind(SyntaxKind.Identifier);\n for (const identifier of identifiers) {\n if (!isReferencePosition(ctx, identifier)) continue;\n const symbol = identifier.getSymbol();\n if (!symbol) continue;\n for (const declaration of symbol.getDeclarations()) {\n if (declaration.getSourceFile() !== identifier.getSourceFile()) continue;\n if (N.isImportSpecifier(declaration) || N.isImportClause(declaration) || N.isNamespaceImport(declaration)) {\n const importDeclaration = declaration.getFirstAncestorByKindOrThrow(SyntaxKind.ImportDeclaration);\n const specifier = importDeclaration.getModuleSpecifierValue();\n const local = identifier.getText();\n const typeOnly = importDeclaration.isTypeOnly() || (N.isImportSpecifier(declaration) && declaration.isTypeOnly());\n const imported = N.isImportSpecifier(declaration) ? declaration.getName()\n : N.isNamespaceImport(declaration) ? \"*\"\n : \"default\";\n if (!imports.some(use => use.local === local && use.specifier === specifier)) {\n imports.push({ specifier, fromFile: identifier.getSourceFile().getFilePath(), imported, local, typeOnly });\n }\n continue;\n }\n const statement = topLevelStatement(ctx, declaration);\n if (!statement || nodes.includes(statement)) continue;\n // A declaration inside the node itself (a parameter, a local) is not a reference out of it.\n if (nodes.some(root => root !== statement && (declaration === root || declaration.getAncestors().includes(root)))) continue;\n if (exclude.includes(statement)) {\n if (!forbidden.some(entry => entry.name === identifier.getText())) {\n forbidden.push({ name: identifier.getText(), line: identifier.getStartLineNumber() });\n }\n continue;\n }\n if (!statements.has(statement)) {\n statements.add(statement);\n queue.push(statement);\n }\n }\n }\n }\n const ordered = [...statements].sort((a, b) => a.getStart() - b.getStart());\n return { imports, statements: ordered, forbidden };\n}\n\n/** The leading comments of a node worth carrying: block and line comments, not lint or compiler directives. */\nexport function leadingComments(node: Node): string[] {\n const out: string[] = [];\n for (const range of node.getLeadingCommentRanges()) {\n const text = range.getText();\n if (/^\\/\\/\\s*(@ts-|eslint|prettier|#)/.test(text) || /^\\/\\*\\s*(eslint|prettier|@ts-)/.test(text)) continue;\n out.push(text);\n }\n return out;\n}\n","/**\n * A record's own entry, never one inherited from `Object.prototype`.\n *\n * The codemod looks keys up by names it read from user code, and a name can be\n * `toString` or `constructor`: `RECORD[name]` would hand back a function.\n *\n * @param record a plain record\n * @param key the key, as read\n */\nexport function own<T>(record: Readonly<Record<string, T>>, key: string): T | undefined {\n return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;\n}\n","/**\n * Moving a collection callback's source into a table hook.\n *\n * The code is carried as written. What changes is the props object it is\n * called with: a table hook gets `table` (the descriptor) where a collection\n * callback got `collection`, and `afterRead` / `beforeDelete` / `afterDelete`\n * get the row as `values` where they got `row`. The parameter is rewritten so\n * the body keeps its own names — `({ row })` becomes `({ values: row })` —\n * and where a use cannot be rewritten mechanically (the props passed on\n * whole, a property of the collection the descriptor does not have) the text\n * is kept, a `// TODO(rebase-migrate):` line says what to check, and the run\n * reports it. Nothing is rewritten to something that silently means less.\n */\nimport type { ArrowFunction, FunctionExpression, Identifier, Node, ParameterDeclaration } from \"ts-morph\";\n\nimport type { AstContext, Member } from \"./ast\";\nimport { nodeText } from \"./ast\";\nimport { own } from \"./own\";\n\n/** The props a callback's parameter is renamed on. */\nexport interface PropRenames {\n /** Always `table`: the descriptor replaces the collection. */\n collection: \"table\";\n /** `values`, for the hooks that received the row as `row`. */\n row?: \"values\";\n /**\n * The renamed `collection` was a plain value (a slug) and `table` is the\n * same value — `StorageAuthorizeData.collection` → `.table` — so no use of\n * it needs checking.\n */\n collectionIsValue?: boolean;\n}\n\n/** The hooks whose legacy props named the row `row`. */\nconst ROW_HOOKS = new Set([\"afterRead\", \"beforeDelete\", \"afterDelete\"]);\n\n/** The renames for one table hook, or one column transform. */\nexport function renamesFor(hook: string): PropRenames {\n return ROW_HOOKS.has(hook) ? { collection: \"table\", row: \"values\" } : { collection: \"table\" };\n}\n\n/** Properties of the collection a callback may read on the descriptor too, with the same meaning. */\nconst DESCRIPTOR_SAFE_READS = new Set([\"slug\"]);\n\n/** A function carried into a table, and what to check in it. */\nexport interface CarriedFunction {\n /** The source text, ready to print: its first line at column 0. */\n text: string;\n /** One sentence per use the codemod could not rewrite; each is also a `TODO(rebase-migrate)` line in the text. */\n todos: string[];\n}\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n}\n\nlet scratchCounter = 0;\n\n/** The function text a member denotes: a method becomes the function expression it is. */\nexport function memberFunctionText(ctx: AstContext, member: Member): string {\n const method = member.method;\n if (!method) return member.value ? nodeText(member.value) : nodeText(member.node);\n const { SyntaxKind } = ctx.tsm;\n const body = method.getBody();\n const usesThis = body !== undefined && (\n body.getDescendantsOfKind(SyntaxKind.ThisKeyword).length > 0 ||\n body.getDescendantsOfKind(SyntaxKind.SuperKeyword).length > 0 ||\n body.getDescendantsOfKind(SyntaxKind.Identifier).some(identifier => identifier.getText() === \"arguments\")\n );\n const isAsync = method.isAsync();\n const isGenerator = method.isGenerator();\n const typeParameters = method.getTypeParameters().map(parameter => parameter.getText());\n const typeParameterText = typeParameters.length > 0 ? `<${typeParameters.join(\", \")}>` : \"\";\n const parameters = method.getParameters().map(parameter => parameter.getText()).join(\", \");\n const returnType = method.getReturnTypeNode();\n const returnText = returnType ? `: ${returnType.getText()}` : \"\";\n const bodyText = body ? nodeText(body) : \"{}\";\n if (usesThis || isGenerator) {\n return `${isAsync ? \"async \" : \"\"}function${isGenerator ? \"*\" : \"\"} ${method.getName()}${typeParameterText}(${parameters})${returnText} ${bodyText}`;\n }\n return `${isAsync ? \"async \" : \"\"}${typeParameterText}(${parameters})${returnText} => ${bodyText}`;\n}\n\n/** The identifiers in `scope` bound by `declaration` (the parameter or a binding element). */\nfunction referencesTo(ctx: AstContext, scope: Node, name: Identifier): Identifier[] {\n const { SyntaxKind } = ctx.tsm;\n const symbol = name.getSymbol();\n if (!symbol) return [];\n return scope.getDescendantsOfKind(SyntaxKind.Identifier)\n .filter(identifier => identifier !== name && identifier.getText() === name.getText() && identifier.getSymbol() === symbol);\n}\n\n/** Whether `identifier` is read as `identifier.<safe>` only. */\nfunction isSafeDescriptorRead(ctx: AstContext, identifier: Identifier): boolean {\n const { Node: N } = ctx.tsm;\n const parent = identifier.getParent();\n return parent !== undefined && N.isPropertyAccessExpression(parent) && parent.getExpression() === identifier &&\n DESCRIPTOR_SAFE_READS.has(parent.getName());\n}\n\n/**\n * Rewrite the props a function receives. Returns the edits to make on its\n * text, and the uses it could not rewrite.\n */\nfunction rewriteParameter(\n ctx: AstContext,\n fn: ArrowFunction | FunctionExpression,\n parameter: ParameterDeclaration,\n renames: PropRenames,\n edits: Edit[],\n todos: string[]\n): void {\n const { Node: N } = ctx.tsm;\n const renamed: Record<string, string> = { collection: renames.collection, ...(renames.row ? { row: renames.row } : {}) };\n const nameNode = parameter.getNameNode();\n const body = fn.getBody();\n\n // An inline type for the props names the old keys too: `{ collection: string }`.\n const typeNode = parameter.getTypeNode();\n if (typeNode && N.isTypeLiteral(typeNode)) {\n for (const member of typeNode.getMembers()) {\n if (!N.isPropertySignature(member)) continue;\n const next = own(renamed, member.getName());\n if (next !== undefined) edits.push({ start: member.getNameNode().getStart(), end: member.getNameNode().getEnd(), text: next });\n }\n }\n\n if (N.isObjectBindingPattern(nameNode)) {\n for (const element of nameNode.getElements()) {\n const propertyNameNode = element.getPropertyNameNode();\n const local = element.getNameNode();\n if (element.getDotDotDotToken()) {\n if (!N.isIdentifier(local)) continue;\n rewriteMemberReads(ctx, body, local, renamed, edits, todos, `the rest of the props, \\`...${local.getText()}\\``, renames.collectionIsValue === true);\n continue;\n }\n const key = propertyNameNode ? propertyNameNode.getText() : local.getText();\n const next = own(renamed, key);\n if (next === undefined) continue;\n if (propertyNameNode) {\n edits.push({ start: propertyNameNode.getStart(), end: propertyNameNode.getEnd(), text: next });\n } else {\n edits.push({ start: local.getStart(), end: local.getEnd(), text: `${next}: ${local.getText()}` });\n }\n if (key !== \"collection\" || renames.collectionIsValue) continue;\n if (N.isIdentifier(local)) {\n const unsafe = referencesTo(ctx, body, local).filter(identifier => !isSafeDescriptorRead(ctx, identifier));\n if (unsafe.length > 0) {\n todos.push(`\\`${local.getText()}\\` is now the table's descriptor, not the collection: check every use but \\`.slug\\` (line ${unsafe[0].getStartLineNumber()} of the hook).`);\n }\n } else if (N.isObjectBindingPattern(local)) {\n const reads = local.getElements().map(inner => inner.getPropertyNameNode()?.getText() ?? inner.getNameNode().getText());\n const unsafe = reads.filter(read => !DESCRIPTOR_SAFE_READS.has(read));\n if (unsafe.length > 0) todos.push(`reads ${unsafe.map(read => `\\`${read}\\``).join(\", \")} off the collection; the descriptor it gets now is a table, which may not have them.`);\n } else {\n todos.push(\"destructures the collection in a form the codemod does not rewrite; the descriptor it gets now is a table.\");\n }\n }\n return;\n }\n if (N.isIdentifier(nameNode)) {\n rewriteMemberReads(ctx, body, nameNode, renamed, edits, todos, `the props object, \\`${nameNode.getText()}\\``, renames.collectionIsValue === true);\n return;\n }\n todos.push(\"takes its props in a form the codemod does not rewrite; it now gets `table` for `collection` and `values` for `row`.\");\n}\n\n/** Rewrite `props.row` → `props.values` and `props.collection` → `props.table`; anything else is a TODO. */\nfunction rewriteMemberReads(\n ctx: AstContext,\n scope: Node,\n binding: Identifier,\n renamed: Record<string, string>,\n edits: Edit[],\n todos: string[],\n what: string,\n collectionIsValue = false\n): void {\n const { Node: N } = ctx.tsm;\n for (const reference of referencesTo(ctx, scope, binding)) {\n const parent = reference.getParent();\n if (parent && N.isPropertyAccessExpression(parent) && parent.getExpression() === reference) {\n const name = parent.getName();\n const next = own(renamed, name);\n if (next === undefined) continue;\n const nameNode = parent.getNameNode();\n edits.push({ start: nameNode.getStart(), end: nameNode.getEnd(), text: next });\n if (name === \"collection\" && !collectionIsValue) {\n const outer = parent.getParent();\n const safe = outer !== undefined && N.isPropertyAccessExpression(outer) && outer.getExpression() === parent &&\n DESCRIPTOR_SAFE_READS.has(outer.getName());\n if (!safe) todos.push(`reads \\`${parent.getText()}\\`, which is now the table's descriptor, not the collection (line ${reference.getStartLineNumber()} of the hook).`);\n }\n continue;\n }\n if (parent && N.isElementAccessExpression(parent) && parent.getExpression() === reference) {\n todos.push(`reads ${what} by a computed key (\\`${parent.getText()}\\`); \\`collection\\` is \\`table\\` and \\`row\\` is \\`values\\` now.`);\n continue;\n }\n todos.push(`passes ${what} on (line ${reference.getStartLineNumber()} of the hook); whatever reads it gets \\`table\\` for \\`collection\\`${renamed.row ? \" and `values` for `row`\" : \"\"} now.`);\n }\n}\n\nfunction applyEdits(text: string, edits: Edit[], offset: number): string {\n const sorted = [...edits].sort((a, b) => b.start - a.start);\n let out = text;\n for (const edit of sorted) {\n out = out.slice(0, edit.start - offset) + edit.text + out.slice(edit.end - offset);\n }\n return out;\n}\n\n/** Insert the TODO lines where a reader will see them: first in a block body, above an expression body. */\nfunction withTodos(ctx: AstContext, text: string, todos: readonly string[]): string {\n if (todos.length === 0) return text;\n const comment = todos.map(todo => `// TODO(rebase-migrate): ${todo}`);\n const sf = ctx.project.createSourceFile(`/__rebase_migrate__/todo-${scratchCounter++}.ts`, `const __hook = ${text};`, { overwrite: true });\n const offset = \"const __hook = \".length;\n try {\n const initializer = sf.getVariableDeclarationOrThrow(\"__hook\").getInitializerOrThrow();\n const { Node: N } = ctx.tsm;\n if ((N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) {\n const body = initializer.getBody();\n if (N.isBlock(body)) {\n const first = body.getStatements()[0];\n if (first) {\n const start = first.getStart() - offset;\n const lineStart = text.lastIndexOf(\"\\n\", start - 1) + 1;\n const indent = /^[ \\t]*/.exec(text.slice(lineStart, start))?.[0] ?? \" \";\n return `${text.slice(0, start)}${comment.join(`\\n${indent}`)}\\n${indent}${text.slice(start)}`;\n }\n }\n }\n return `${comment.join(\"\\n\")}\\n${text}`;\n } finally {\n ctx.project.removeSourceFile(sf);\n }\n}\n\n/**\n * The source of one hook (or one transform callback), its props renamed.\n *\n * @param member where it is in the legacy literal\n * @param hook the hook's name: decides whether `row` is renamed\n * @param options `collectionIsValue` when the renamed `collection` held a plain value\n */\nexport function carryHook(ctx: AstContext, member: Member, hook: string, options: { collectionIsValue?: boolean } = {}): CarriedFunction {\n const text = memberFunctionText(ctx, member);\n const renames: PropRenames = { ...renamesFor(hook), ...(options.collectionIsValue ? { collectionIsValue: true } : {}) };\n const sf = ctx.project.createSourceFile(`/__rebase_migrate__/hook-${scratchCounter++}.ts`, `const __hook = ${text};`, { overwrite: true });\n const offset = \"const __hook = \".length;\n const todos: string[] = [];\n try {\n const initializer = sf.getVariableDeclarationOrThrow(\"__hook\").getInitializerOrThrow();\n const { Node: N } = ctx.tsm;\n const edits: Edit[] = [];\n if (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer)) {\n const parameter = initializer.getParameters()[0];\n if (parameter) rewriteParameter(ctx, initializer, parameter, renames, edits, todos);\n } else {\n todos.push(`is \\`${text.split(\"\\n\")[0]}\\`, not a function written here, so the props it receives cannot be rewritten: it now gets \\`table\\` for \\`collection\\`${renames.row ? \" and `values` for `row`\" : \"\"}.`);\n }\n const rewritten = applyEdits(text, edits, offset);\n return { text: withTodos(ctx, rewritten, todos), todos };\n } finally {\n ctx.project.removeSourceFile(sf);\n }\n}\n\n/**\n * The source of a `callbacks` object of a property — `{ beforeSave, afterRead }`\n * — as the column's `.transform({...})` argument, each callback carried with\n * {@link carryHook}.\n */\nexport function carryTransform(ctx: AstContext, members: { name: string; member: Member }[]): CarriedFunction {\n const todos: string[] = [];\n const lines = members.map(({ name, member }) => {\n const carried = carryHook(ctx, member, name);\n todos.push(...carried.todos.map(todo => `${name} ${todo}`));\n return ` ${name}: ${carried.text.split(\"\\n\").join(\"\\n \")}`;\n });\n return { text: `{\\n${lines.join(\",\\n\")}\\n}`, todos };\n}\n","/**\n * Moving code between files: rewriting a module specifier for its new home,\n * copying the helper modules carried code imports, and assembling a module's\n * import block.\n *\n * A relative import from `config/collections/orders.ts` keeps pointing at the\n * same file from `backend/schema/orders.ts` — a module of `config/` included:\n * the project's own modules there stay, importable as before. Only a helper\n * inside `config/collections`, which the migration removes, is copied next to\n * the code that needs it (`backend/lib/…` for server code,\n * `frontend/src/cms/lib/…` for the panel's), its own imports moved the same\n * way. A helper that imports a collection file cannot move (the collection is a\n * table now) and is refused.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { SourceFile } from \"ts-morph\";\n\nimport type { AstContext, ImportUse } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport { own } from \"./own\";\n\n/** Which side of the split a file lives on. */\nexport type Side = \"backend\" | \"frontend\";\n\n/** A module specifier that cannot be moved, and why. */\nexport class RelocationError extends Error {\n constructor(readonly file: string, message: string) {\n super(message);\n }\n}\n\nconst CODE_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".js\", \".jsx\", \".mjs\"];\n\n/** How a relative specifier was written, so the moved one is written the same way. */\nexport type SpecifierStyle = \"extensionless\" | \"directory\" | { extension: string };\n\nexport interface ResolvedSpecifier {\n target: string;\n style: SpecifierStyle;\n}\n\n/** The file a relative specifier written in `fromFile` names, and how it was written. */\nexport function resolveRelative(fromFile: string, specifier: string): ResolvedSpecifier {\n const base = path.resolve(path.dirname(fromFile), specifier);\n const extension = path.extname(specifier);\n if (extension === \".js\" || extension === \".jsx\" || extension === \".mjs\") {\n const stem = base.slice(0, -extension.length);\n for (const candidate of [\".ts\", \".tsx\", \".mts\", extension]) {\n if (fs.existsSync(stem + candidate)) return { target: stem + candidate, style: { extension } };\n }\n }\n if (extension && fs.existsSync(base) && fs.statSync(base).isFile()) return { target: base, style: { extension } };\n for (const candidate of CODE_EXTENSIONS) {\n if (fs.existsSync(base + candidate)) return { target: base + candidate, style: \"extensionless\" };\n }\n for (const candidate of CODE_EXTENSIONS) {\n const index = path.join(base, `index${candidate}`);\n if (fs.existsSync(index)) return { target: index, style: \"directory\" };\n }\n return { target: base, style: extension ? { extension } : \"extensionless\" };\n}\n\n/** A relative specifier from `fromFile` to `target`, written in `style`. */\nexport function writeSpecifier(fromFile: string, target: string, style: SpecifierStyle): string {\n let destination = target;\n if (style === \"directory\") destination = path.dirname(target);\n else if (style === \"extensionless\") destination = target.replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\");\n else if (/\\.(tsx?|mts)$/.test(target) && /^\\.(jsx?|mjs)$/.test(style.extension)) destination = target.replace(/\\.(tsx?|mts)$/, style.extension);\n let relative = toPosix(path.relative(path.dirname(fromFile), destination));\n if (!relative.startsWith(\".\")) relative = `./${relative}`;\n return relative;\n}\n\n/**\n * How the relative imports the codemod writes itself end — the schema index,\n * a table's import of a related table, a customization's type import of its\n * table: `\"js\"` (`./users.js`) or `\"extensionless\"` (`./users`).\n *\n * A project whose backend is built with a plain `tsc` (NodeNext) and run on\n * Node needs `\"js\"`: Node's ESM loader resolves no relative import without\n * its extension. `rebase build` and tsx resolve either spelling.\n */\nexport type GeneratedSpecifierStyle = \"js\" | \"extensionless\";\n\n/**\n * The {@link GeneratedSpecifierStyle} of a project, from the module specifiers\n * its legacy collection sources write (the collection files and the\n * collections index): `\"js\"` when more of their relative specifiers end in\n * a JavaScript extension (`./users.js`) than in none (`./users`, `../lib`);\n * `\"extensionless\"`, the house style, otherwise — a tie, or no relative\n * import at all. A specifier with another extension (`./labels.json`,\n * `./users.schema`) says nothing either way.\n *\n * @param specifiers every module specifier the sources import or re-export from, package names included\n */\nexport function projectSpecifierStyle(specifiers: readonly string[]): GeneratedSpecifierStyle {\n let withExtension = 0;\n let without = 0;\n for (const specifier of specifiers) {\n if (!/^\\.\\.?(\\/|$)/.test(specifier)) continue;\n const last = specifier.split(\"/\").pop() ?? \"\";\n if (/\\.[mc]?jsx?$/.test(last)) withExtension++;\n else if (last === \"\" || last === \".\" || last === \"..\" || !last.includes(\".\")) without++;\n }\n return withExtension > without ? \"js\" : \"extensionless\";\n}\n\n/** The module specifiers a file imports and re-exports from, as written. */\nexport function writtenSpecifiers(sourceFile: SourceFile): string[] {\n return [\n ...sourceFile.getImportDeclarations().map(declaration => declaration.getModuleSpecifierValue()),\n ...sourceFile.getExportDeclarations().flatMap(declaration => declaration.getModuleSpecifierValue() ?? [])\n ];\n}\n\n/**\n * The relative specifier of an import the codemod writes, from `fromFile` to\n * the module `target`, in the project's {@link GeneratedSpecifierStyle}: for\n * `users.ts`, `./users` or `./users.js`. A JavaScript target keeps its own\n * extension in either style.\n */\nexport function generatedSpecifier(fromFile: string, target: string, style: GeneratedSpecifierStyle): string {\n const typescript = /\\.(tsx?|mts)$/.exec(target);\n let relative = toPosix(path.relative(path.dirname(fromFile), typescript ? target.slice(0, -typescript[0].length) : target));\n if (!relative.startsWith(\"../\")) relative = `./${relative}`;\n if (style === \"extensionless\" || !typescript) return relative;\n return `${relative}${typescript[1] === \"mts\" ? \".mjs\" : \".js\"}`;\n}\n\n/** One helper module copied out of `config/`. */\nexport interface HelperCopy {\n /** Where it was, absolute. */\n from: string;\n /** Where it goes, absolute. */\n to: string;\n side: Side;\n}\n\n/**\n * Moves specifiers and collects the helper copies they need. One per run, so\n * a helper used by several files is copied once per side.\n */\nexport class Relocator {\n readonly helpers = new Map<string, HelperCopy>();\n /** Modules of the project's own in config/ that backend code the run writes imports in place. */\n readonly keptBackendModules = new Set<string>();\n /** Modules outside config/collections the run edits in place for the panel (a shared `dynamicProps` builder). */\n readonly keptFrontendModules = new Set<string>();\n /** Edits to a module's own text before it is copied or kept (a helper's callbacks as table hooks), by absolute path. */\n readonly sourceEdits = new Map<string, { start: number; end: number; text: string }[]>();\n\n /**\n * Queue edits to a module's own text (deduplicated by position), dropping\n * any copy of it already made so the next one carries them.\n */\n addSourceEdits(file: string, edits: readonly { start: number; end: number; text: string }[]): void {\n const queued = this.sourceEdits.get(file) ?? [];\n for (const edit of edits) if (!queued.some(other => other.start === edit.start && other.end === edit.end)) queued.push(edit);\n this.sourceEdits.set(file, queued);\n for (const side of [\"backend\", \"frontend\"]) this.contents.delete(`${side}:${file}`);\n }\n\n /** A module's text with its {@link sourceEdits} applied. */\n editedSource(file: string): string {\n let out = fs.readFileSync(file, \"utf8\");\n const edits = this.sourceEdits.get(file);\n if (edits) for (const edit of [...edits].sort((a, b) => b.start - a.start)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n }\n /** Collection files that move rather than become tables (Firestore ones): legacy path → new path. */\n readonly moved = new Map<string, string>();\n\n constructor(\n private readonly ctx: AstContext,\n private readonly projectRoot: string,\n private readonly configDir: string,\n private readonly collectionFiles: ReadonlySet<string>,\n private readonly libDirs: Readonly<Record<Side, string>>\n ) {}\n\n /** The config directory, absolute. */\n get configDirectory(): string {\n return this.configDir;\n }\n\n /** Whether `file` is inside `<config>/collections`, which the migration removes. */\n isInCollections(file: string): boolean {\n const relative = path.relative(path.join(this.configDir, \"collections\"), file);\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n }\n\n /** Whether `file` is inside the config directory. */\n isInConfig(file: string): boolean {\n const relative = path.relative(this.configDir, file);\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n }\n\n /** The specifier `specifier` (written in `fromFile`) becomes when written in `destFile`. */\n relocate(specifier: string, fromFile: string, destFile: string, side: Side): string {\n if (!specifier.startsWith(\".\")) return specifier;\n const { target, style } = resolveRelative(fromFile, specifier);\n const movedTo = this.moved.get(target);\n if (movedTo !== undefined && side === \"frontend\") return writeSpecifier(destFile, movedTo, style);\n if (this.collectionFiles.has(target)) {\n throw new RelocationError(fromFile,\n `${toPosix(path.relative(this.projectRoot, fromFile))} imports the collection file \"${specifier}\" into code the codemod moves. ` +\n \"A collection is a table now: import the table from backend/schema (or move the shared value into a module of its own).\");\n }\n if (!this.isInConfig(target)) return writeSpecifier(destFile, target, style);\n if (!fs.existsSync(target)) {\n throw new RelocationError(fromFile, `${toPosix(path.relative(this.projectRoot, fromFile))} imports \"${specifier}\", which does not exist.`);\n }\n // A module of the project's own in config/ stays where it is: 0.31\n // stops reading config/collections, not config/. Only a helper inside\n // config/collections — a directory that must go — is copied out.\n if (!this.isInCollections(target)) {\n if (side === \"backend\") this.keptBackendModules.add(target);\n return writeSpecifier(destFile, target, style);\n }\n const copy = this.copyHelper(target, side);\n return writeSpecifier(destFile, copy.to, style);\n }\n\n private copyHelper(file: string, side: Side): HelperCopy {\n const key = `${side}:${file}`;\n const existing = this.helpers.get(key);\n if (existing) return existing;\n const to = path.join(this.libDirs[side], path.relative(this.configDir, file));\n const copy: HelperCopy = { from: file, to, side };\n this.helpers.set(key, copy);\n // Its own imports move too (and may queue more copies).\n this.helperContent(copy);\n return copy;\n }\n\n private readonly contents = new Map<string, string>();\n\n /** A helper's content in its new home: its relative specifiers moved. */\n helperContent(copy: HelperCopy): string {\n const key = `${copy.side}:${copy.from}`;\n const cached = this.contents.get(key);\n if (cached !== undefined) return cached;\n const text = this.editedSource(copy.from);\n this.contents.set(key, text);\n const moved = this.moveSpecifiersInText(text, copy.from, copy.to, copy.side);\n this.contents.set(key, moved);\n return moved;\n }\n\n /**\n * A module of config/ that backend code imports in place, with the\n * collection-model types it imports replaced by table-model aliases (as a\n * copy to backend/lib gets them): the hooks it serves are table hooks now.\n */\n keptBackendContent(file: string): string {\n const text = this.editedSource(file);\n const sf = this.ctx.project.createSourceFile(`/__rebase_migrate__/kept-${path.basename(file)}`, text, { overwrite: true });\n try {\n const edits: { start: number; end: number; text: string }[] = [];\n this.legacyTypeEdits(sf, text, edits);\n let out = text;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n } finally {\n this.ctx.project.removeSourceFile(sf);\n }\n }\n\n /** Collection-model types left in moved backend code (used with type arguments), for the report. */\n readonly legacyTypesLeft: { file: string; name: string }[] = [];\n\n /** Edits replacing the collection-model types a moved backend module imports (see {@link replaceLegacyTypes}). */\n private legacyTypeEdits(sf: SourceFile, text: string, edits: { start: number; end: number; text: string }[]): void {\n const aliases: string[] = [];\n const types = new Set<string>();\n for (const declaration of sf.getImportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n if (!LEGACY_TYPE_PACKAGES.has(specifier)) continue;\n const named = declaration.getNamedImports();\n const replaced = named.filter(entry => {\n const replacement = own(LEGACY_TYPE_REPLACEMENTS, entry.getName());\n const local = entry.getAliasNode()?.getText() ?? entry.getName();\n if (!replacement) return false;\n if (new RegExp(`\\\\b${local}\\\\s*<`).test(text)) {\n this.legacyTypesLeft.push({ file: sf.getBaseName(), name: local });\n return false;\n }\n types.add(replacement.type);\n aliases.push(`type ${local} = ${replacement.expression};`);\n return true;\n });\n if (replaced.length === 0) continue;\n const remaining = named.filter(entry => !replaced.includes(entry));\n if (remaining.length === 0 && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) {\n const end = text[declaration.getEnd()] === \"\\n\" ? declaration.getEnd() + 1 : declaration.getEnd();\n edits.push({ start: declaration.getStart(), end, text: \"\" });\n } else {\n const bindings = remaining.map(entry => entry.getText()).join(\", \");\n const typeOnly = declaration.isTypeOnly() ? \"type \" : \"\";\n const head = declaration.getDefaultImport() ? `${declaration.getDefaultImport()?.getText()}, ` : \"\";\n edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: `import ${typeOnly}${head}{ ${bindings} } from ${JSON.stringify(specifier)};` });\n }\n }\n if (aliases.length === 0) return;\n const imports = sf.getImportDeclarations();\n const at = imports.length > 0 ? imports[imports.length - 1].getEnd() : 0;\n edits.push({ start: at, end: at, text: `${imports.length > 0 ? \"\\n\" : \"\"}import type { ${[...types].sort().join(\", \")} } from \"@rebasepro/server/schema\";\\n\\n${aliases.join(\"\\n\")}${imports.length > 0 ? \"\" : \"\\n\"}` });\n }\n\n /**\n * Every module specifier in `text` (static imports, re-exports, dynamic\n * `import()`), moved from `fromFile` to `destFile`.\n */\n moveSpecifiersInText(text: string, fromFile: string, destFile: string, side: Side): string {\n const { Node: N, SyntaxKind } = this.ctx.tsm;\n const sf = this.ctx.project.createSourceFile(`/__rebase_migrate__/move-${this.contents.size}-${path.basename(fromFile)}`, text, { overwrite: true });\n try {\n const edits: { start: number; end: number; text: string }[] = [];\n const literals = [\n ...sf.getImportDeclarations().map(declaration => declaration.getModuleSpecifier()),\n ...sf.getExportDeclarations().map(declaration => declaration.getModuleSpecifier()).filter(literal => literal !== undefined),\n ...sf.getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter(call => call.getExpression().getKind() === SyntaxKind.ImportKeyword)\n .map(call => call.getArguments()[0])\n .filter(argument => argument !== undefined && N.isStringLiteral(argument))\n ];\n for (const literal of literals) {\n if (!N.isStringLiteral(literal)) continue;\n const value = literal.getLiteralValue();\n const moved = this.relocate(value, fromFile, destFile, side);\n if (moved !== value) edits.push({ start: literal.getStart() + 1, end: literal.getEnd() - 1, text: moved });\n }\n if (side === \"backend\") this.legacyTypeEdits(sf, text, edits);\n let out = text;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n } finally {\n this.ctx.project.removeSourceFile(sf);\n }\n }\n}\n\n/** Packages a backend helper imported collection-model types from. */\nconst LEGACY_TYPE_PACKAGES = new Set([\"@rebasepro/common\", \"@rebasepro/types\", \"@rebasepro/server\", \"@rebasepro/cms-types\"]);\n\n/**\n * Collection-model types a backend helper used, and what each is in the table\n * model (from `@rebasepro/server/schema`, which a backend depends on). A\n * helper keeps its own name for the type — `type EntityCallbackContext =\n * TableHookProps[\"context\"];` — so its body is untouched.\n */\nexport const LEGACY_TYPE_REPLACEMENTS: Readonly<Record<string, { type: string; expression: string }>> = {\n EntityCallbackContext: { type: \"TableHookProps\", expression: `TableHookProps[\"context\"]` },\n RebaseCallContext: { type: \"TableHookProps\", expression: `TableHookProps[\"context\"]` },\n CollectionCallbacks: { type: \"TableHooks\", expression: \"TableHooks\" },\n BeforeQueryProps: { type: \"TableBeforeQueryProps\", expression: \"TableBeforeQueryProps\" },\n AfterReadProps: { type: \"TableAfterReadProps\", expression: \"TableAfterReadProps\" },\n BeforeSaveProps: { type: \"TableBeforeSaveProps\", expression: \"TableBeforeSaveProps\" },\n AfterSaveProps: { type: \"TableAfterSaveProps\", expression: \"TableAfterSaveProps\" },\n AfterSaveErrorProps: { type: \"TableAfterSaveErrorProps\", expression: \"TableAfterSaveErrorProps\" },\n BeforeDeleteProps: { type: \"TableDeleteProps\", expression: \"TableDeleteProps\" },\n AfterDeleteProps: { type: \"TableDeleteProps\", expression: \"TableDeleteProps\" },\n PropertyCallbacks: { type: \"ColumnTransform\", expression: \"ColumnTransform\" }\n};\n\n/** What {@link replaceLegacyTypes} decided. */\nexport interface LegacyTypeReplacement {\n /** The uses still imported as they were. */\n kept: ImportUse[];\n /** `import type { … } from \"@rebasepro/server/schema\";`, when any type was replaced. */\n imports: string[];\n /** `type <local> = <replacement>;`, one per replaced binding. */\n aliases: string[];\n /** A binding used with type arguments, which an alias cannot stand for. */\n unreplaceable: string[];\n}\n\n/**\n * Replace collection-model types a backend module imports with their\n * table-model equivalents, as local aliases.\n *\n * @param text the code that uses them, to tell a generic use (`AfterSaveProps<M>`) apart\n */\nexport function replaceLegacyTypes(uses: readonly ImportUse[], text: string): LegacyTypeReplacement {\n const kept: ImportUse[] = [];\n const types = new Set<string>();\n const aliases: string[] = [];\n const unreplaceable: string[] = [];\n for (const use of uses) {\n const replacement = LEGACY_TYPE_PACKAGES.has(use.specifier) ? own(LEGACY_TYPE_REPLACEMENTS, use.imported) : undefined;\n if (!replacement) {\n kept.push(use);\n continue;\n }\n if (new RegExp(`\\\\b${use.local}\\\\s*<`).test(text)) {\n unreplaceable.push(use.local);\n kept.push(use);\n continue;\n }\n types.add(replacement.type);\n aliases.push(`type ${use.local} = ${replacement.expression};`);\n }\n const imports = types.size > 0 ? [`import type { ${[...types].sort().join(\", \")} } from \"@rebasepro/server/schema\";`] : [];\n return { kept, imports, aliases, unreplaceable };\n}\n\n/** One import line's worth of bindings. */\ninterface ImportGroup {\n specifier: string;\n defaultLocal?: string;\n namespaceLocal?: string;\n named: { imported: string; local: string; typeOnly: boolean }[];\n defaultTypeOnly: boolean;\n}\n\n/**\n * The import block of a generated module: the uses, grouped by (moved)\n * specifier, in first-use order, each binding once.\n */\nexport function importLines(uses: readonly ImportUse[], relocate: (use: ImportUse) => string): string[] {\n const groups = new Map<string, ImportGroup>();\n const lines: string[] = [];\n for (const use of uses) {\n const specifier = relocate(use);\n if (use.imported === \"*\") {\n lines.push(`import ${use.typeOnly ? \"type \" : \"\"}* as ${use.local} from ${JSON.stringify(specifier)};`);\n continue;\n }\n let group = groups.get(specifier);\n if (!group) {\n group = { specifier, named: [], defaultTypeOnly: true };\n groups.set(specifier, group);\n }\n if (use.imported === \"default\") {\n group.defaultLocal = use.local;\n group.defaultTypeOnly = use.typeOnly;\n } else if (!group.named.some(entry => entry.local === use.local)) {\n group.named.push({ imported: use.imported, local: use.local, typeOnly: use.typeOnly });\n }\n }\n for (const group of groups.values()) {\n const allTypes = (group.defaultLocal === undefined || group.defaultTypeOnly) && group.named.every(entry => entry.typeOnly);\n const named = group.named.map(entry => {\n const binding = entry.imported === entry.local ? entry.local : `${entry.imported} as ${entry.local}`;\n return !allTypes && entry.typeOnly ? `type ${binding}` : binding;\n });\n const parts: string[] = [];\n if (group.defaultLocal !== undefined) parts.push(group.defaultLocal);\n if (named.length > 0) parts.push(`{ ${named.join(\", \")} }`);\n if (parts.length === 0) continue;\n lines.push(`import ${allTypes ? \"type \" : \"\"}${parts.join(\", \")} from ${JSON.stringify(group.specifier)};`);\n }\n return lines;\n}\n","/**\n * Collection callbacks that come from the project's own helper:\n * `callbacks: softDeleteCallbacks(\"company\")`, `callbacks: customerCallbacks`\n * (imported), `callbacks: readOnlyRecordCallbacks(what, instead)`.\n *\n * The callbacks → hooks conversion is a mapping of each function's props\n * (`values` for `row` in `afterRead` / `beforeDelete` / `afterDelete`, the\n * descriptor for `collection`), so it is applied where the functions are\n * written — the helper's definition, followed through imports, `const`s,\n * property reads and a function's single `return` — and the table says\n * `hooks: softDeleteCallbacks(\"company\")`, importing the helper. The edits to\n * the helper are planned like any other file the run writes (a helper inside\n * `config/collections` is edited in the copy the relocator makes).\n *\n * What cannot be followed statically (a package's export, two returns, a\n * spread) still becomes `hooks: <the same expression>`, with a step naming\n * the hooks to check.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\n\nimport type { Member } from \"./ast\";\nimport { addSourceFile, lineIndent, memberOf, unwrap } from \"./ast\";\nimport { carryHook, memberFunctionText } from \"./hooks\";\nimport { resolveRelative } from \"./modules\";\nimport type { PlanContext } from \"./plan-context\";\n\n/** An edit to a file the run did not write as a collection: offsets into the file as it is on disk. */\nexport interface SourceEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** What following a helper found. */\nexport interface HelperHooks {\n /** Edits to apply to each defining file (absolute path), so its functions take table-hook props. */\n edits: Map<string, SourceEdit[]>;\n /** Lines a carried hook left marked `TODO(rebase-migrate)`, with the file. */\n todos: { file: string; hook: string; todo: string }[];\n /** The defining files outside `config/collections` (edited in place). */\n files: Set<string>;\n /** Why the helper could not be followed, or which hooks were not found in it. */\n unresolved?: string;\n}\n\nexport type Found = { literal: ObjectLiteralExpression; reason?: undefined } | { literal?: undefined; reason: string };\n\nfunction loadFile(plan: PlanContext, file: string): SourceFile | undefined {\n if (!fs.existsSync(file) || file.includes(`${path.sep}node_modules${path.sep}`)) return undefined;\n return plan.ast.project.getSourceFile(file) ?? addSourceFile(plan.ast, file, fs.readFileSync(file, \"utf8\"));\n}\n\n/** The declaration an identifier names: in its file, or the export of a relative import it binds. */\nfunction declarationOf(plan: PlanContext, identifier: Node): Node | string {\n const { Node: N } = plan.ast.tsm;\n let declaration: Node | undefined;\n try {\n declaration = identifier.getSymbol()?.getDeclarations()[0];\n } catch {\n declaration = undefined;\n }\n if (!declaration) return `\\`${identifier.getText()}\\` is not declared in its file`;\n if (N.isImportSpecifier(declaration) || N.isImportClause(declaration)) {\n const importDeclaration = declaration.getFirstAncestor(ancestor => N.isImportDeclaration(ancestor));\n if (!importDeclaration || !N.isImportDeclaration(importDeclaration)) return \"an import the codemod cannot read\";\n const specifier = importDeclaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\")) return `\\`${identifier.getText()}\\` comes from the package \"${specifier}\"`;\n const { target } = resolveRelative(declaration.getSourceFile().getFilePath(), specifier);\n const sf = loadFile(plan, target);\n if (!sf) return `\"${specifier}\" could not be read`;\n const name = N.isImportSpecifier(declaration) ? declaration.getName() : \"default\";\n if (name === \"default\") {\n const assignment = sf.getExportAssignment(candidate => !candidate.isExportEquals());\n return assignment ? assignment.getExpression() : `\"${specifier}\" has no default export`;\n }\n return sf.getVariableDeclaration(name) ?? sf.getFunction(name) ?? `\"${specifier}\" declares no \\`${name}\\` of its own (a re-export?)`;\n }\n return declaration;\n}\n\n/** The function a callee names, if it is a function declaration or a `const` arrow / function expression. */\nfunction functionOf(plan: PlanContext, callee: Node): Node | string {\n const { Node: N } = plan.ast.tsm;\n if (!N.isIdentifier(callee)) return `the call to \\`${callee.getText()}\\` is not to a named function`;\n const declaration = declarationOf(plan, callee);\n if (typeof declaration === \"string\") return declaration;\n if (N.isFunctionDeclaration(declaration)) return declaration;\n if (N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n if (initializer && (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) return initializer;\n }\n return `\\`${callee.getText()}\\` is not a function the codemod can read`;\n}\n\n/** Follow an expression to the object literal it evaluates to. */\nexport function findLiteral(plan: PlanContext, node: Node, depth = 0): Found {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n if (depth > 10) return { reason: \"the helper refers to itself\" };\n const current = unwrap(plan.ast, node);\n if (N.isObjectLiteralExpression(current)) return { literal: current };\n if (N.isIdentifier(current)) {\n const declaration = declarationOf(plan, current);\n if (typeof declaration === \"string\") return { reason: declaration };\n if (N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n return initializer ? findLiteral(plan, initializer, depth + 1) : { reason: `\\`${current.getText()}\\` has no initializer` };\n }\n if (N.isExpression(declaration)) return findLiteral(plan, declaration, depth + 1);\n return { reason: `\\`${current.getText()}\\` is not a value the codemod can read` };\n }\n if (N.isPropertyAccessExpression(current)) {\n const owner = findLiteral(plan, current.getExpression(), depth + 1);\n if (!owner.literal) return owner;\n const member = memberOf(plan.ast, owner.literal, current.getName());\n if (!member.node) return { reason: member.reason };\n if (!member.node.value) return { reason: `\\`${current.getText()}\\` is a method` };\n return findLiteral(plan, member.node.value, depth + 1);\n }\n if (N.isCallExpression(current)) {\n const fn = functionOf(plan, current.getExpression());\n if (typeof fn === \"string\") return { reason: fn };\n if (N.isArrowFunction(fn) && !N.isBlock(fn.getBody())) return findLiteral(plan, fn.getBody(), depth + 1);\n const returns = fn.getDescendantsOfKind(SyntaxKind.ReturnStatement).filter(statement =>\n statement.getFirstAncestor(ancestor => N.isFunctionDeclaration(ancestor) || N.isArrowFunction(ancestor) || N.isFunctionExpression(ancestor) || N.isMethodDeclaration(ancestor)) === fn);\n const values = returns.map(statement => statement.getExpression()).filter((expression): expression is NonNullable<typeof expression> => expression !== undefined);\n if (values.length !== 1 || returns.length !== 1) return { reason: `\\`${current.getExpression().getText()}\\` has ${returns.length} return statements; the codemod follows exactly one` };\n return findLiteral(plan, values[0], depth + 1);\n }\n return { reason: `it is a ${current.getKindName()}` };\n}\n\n/**\n * Follow a callbacks expression that is not an object literal to the\n * helper's object literal, and plan its functions' props as table hooks.\n *\n * @param hookNames the hooks the evaluated collection had\n */\nexport function carryHelperHooks(plan: PlanContext, value: Node, hookNames: readonly string[]): HelperHooks {\n const result: HelperHooks = { edits: new Map(), todos: [], files: new Set() };\n const found = findLiteral(plan, value);\n if (!found.literal) {\n result.unresolved = found.reason;\n return result;\n }\n const literal = found.literal;\n const file = literal.getSourceFile().getFilePath();\n const missing: string[] = [];\n const edits: SourceEdit[] = [];\n for (const hook of hookNames) {\n const located = memberOf(plan.ast, literal, hook);\n if (!located.node) {\n missing.push(`${hook} (${located.reason})`);\n continue;\n }\n const member: Member = located.node;\n const carried = carryHook(plan.ast, member, hook);\n for (const todo of carried.todos) result.todos.push({ file, hook, todo });\n if (carried.text === memberFunctionText(plan.ast, member)) continue;\n // The carried text is dedented; it goes back at the member's own indentation.\n const indent = lineIndent(member.node);\n const text = carried.text.split(\"\\n\").map((line, index) => (index === 0 || line === \"\" ? line : `${indent}${line}`)).join(\"\\n\");\n if (member.method || !member.value) edits.push({ start: member.node.getStart(), end: member.node.getEnd(), text: `${hook}: ${text}` });\n else edits.push({ start: member.value.getStart(), end: member.value.getEnd(), text });\n }\n if (edits.length > 0) result.edits.set(file, edits);\n result.files.add(file);\n if (missing.length > 0) result.unresolved = `the helper's object (${path.basename(file)}, line ${literal.getStartLineNumber()}) does not say where ${missing.join(\", \")} come from`;\n return result;\n}\n\n/** A file's text with source edits applied (offsets into the original text). */\nexport function applySourceEdits(text: string, edits: readonly SourceEdit[] | undefined): string {\n if (!edits || edits.length === 0) return text;\n let out = text;\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return out;\n}\n","/**\n * What every planning step shares: where the project is, the AST, the\n * relocator, and the report being written.\n */\nimport path from \"node:path\";\nimport type { SourceFile } from \"ts-morph\";\nimport type { LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\n\nimport type { AstContext, CollectionSite } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport type { GeneratedSpecifierStyle, Relocator } from \"./modules\";\nimport type { SplitConstant } from \"./split-constants\";\nimport type { ManualStep, Note, Refusal } from \"./types\";\n\n/** One legacy collection with everything the planners read about it. */\nexport interface CollectionEntry {\n collection: LegacyCollectionConfig;\n /** The collection file, absolute. */\n file: string;\n /** Its AST. */\n sourceFile: SourceFile;\n /** Where its literal is, when the codemod could find it. */\n site?: CollectionSite;\n /** Why the literal could not be found, when it could not. */\n siteProblem?: string;\n}\n\n/** The shared state of one planning run. */\nexport interface PlanContext {\n /** The project root, absolute. */\n root: string;\n ast: AstContext;\n relocator: Relocator;\n /**\n * How every relative import the run writes itself ends (`./users` or\n * `./users.js`): as the legacy collection sources write theirs, decided\n * once from them (`projectSpecifierStyle`).\n */\n specifierStyle: GeneratedSpecifierStyle;\n /** The frontend app's root directory, absolute, when the project has one. */\n frontendDir?: string;\n /** Planned files: absolute path → content. */\n files: Map<string, { content: string; role: string }>;\n refusals: Refusal[];\n notes: Note[];\n manualSteps: ManualStep[];\n /** Enum constants of `config/` split into backend values and CMS labels (see `split-constants.ts`). */\n splitConstants?: SplitConstant[];\n}\n\n/** A path relative to the project root, `/`-separated. */\nexport function relativeToRoot(plan: PlanContext, file: string): string {\n return toPosix(path.relative(plan.root, file));\n}\n\n/** Record a refusal about one collection. */\nexport function refuse(plan: PlanContext, entry: CollectionEntry | undefined, reason: string, extra: { key?: string; line?: number; file?: string } = {}): void {\n plan.refusals.push({\n file: extra.file ?? (entry ? relativeToRoot(plan, entry.file) : \"\"),\n ...(extra.line !== undefined ? { line: extra.line } : {}),\n ...(entry ? { collection: entry.collection.slug } : {}),\n ...(extra.key !== undefined ? { key: extra.key } : {}),\n reason\n });\n}\n\n/** Record a note about one collection. */\nexport function note(plan: PlanContext, entry: CollectionEntry | undefined, message: string, line?: number): void {\n plan.notes.push({\n file: entry ? relativeToRoot(plan, entry.file) : \"\",\n ...(line !== undefined ? { line } : {}),\n ...(entry ? { collection: entry.collection.slug } : {}),\n message\n });\n}\n\n/** Plan a file, refusing a second, different content for the same path. */\nexport function planFile(plan: PlanContext, file: string, content: string, role: string): void {\n const existing = plan.files.get(file);\n if (existing && existing.content !== content) {\n plan.refusals.push({ file: relativeToRoot(plan, file), reason: `two outputs would be written to this path (${existing.role}; ${role}).` });\n return;\n }\n plan.files.set(file, { content, role });\n}\n","/**\n * `backend/schema/<table>.ts` and `backend/schema/index.ts`.\n *\n * The data comes from the lift (`collectionsToTableDefs`), printed by the\n * shared printer (`printTableSource`), so a migrated table is written exactly\n * as introspection or the schema editor would write it. What a value cannot\n * give — the source of a hook or a transform, the imports and helpers that\n * source uses, the comments above a property — is read off the legacy file\n * and spliced in.\n */\nimport path from \"node:path\";\nimport type { Statement } from \"ts-morph\";\nimport {\n printImportLines,\n printIndexModule,\n printTableSource,\n tableIdentifier,\n type PrintTarget,\n type TableSources\n} from \"@rebasepro/common\";\nimport type { LegacyProperty, LiftResult } from \"@rebasepro/common/migrate\";\nimport { isViewDef, type AnyTableDef, type AnyViewDef, type DefaultRls } from \"@rebasepro/types\";\n\nimport type { Member, PathSegment } from \"./ast\";\nimport { collectReferences, leadingComments, memberOf, nodeAtPath, nodeText, postDeclarationAssignments, resolveObject } from \"./ast\";\nimport { carryHelperHooks } from \"./helper-hooks\";\nimport { carryHook, carryTransform, type CarriedFunction } from \"./hooks\";\nimport { generatedSpecifier, importLines, RelocationError, replaceLegacyTypes } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { note, planFile, refuse, relativeToRoot } from \"./plan-context\";\nimport { dedent, reindent } from \"./print-js\";\n\n/** How one table is named in the new layout. */\nexport interface TableName {\n slug: string;\n /** The exported identifier. */\n identifier: string;\n /** The module, absolute. */\n file: string;\n /** The SQL table name (the definition's name). */\n table: string;\n kind: \"table\" | \"auth-table\" | \"view\";\n}\n\n/** Placeholder tokens for code spliced into printed source. */\nexport class Splices {\n private readonly texts = new Map<string, string>();\n private counter = 0;\n\n /** A token standing for `text` in printed output. */\n token(text: string): string {\n const token = `__REBASE_MIGRATE_SPLICE_${this.counter++}__`;\n this.texts.set(token, text);\n return token;\n }\n\n /** Replace every token by its text, re-indented to the line it sits on. */\n apply(code: string): string {\n return code.split(\"\\n\").map(line => {\n let out = line;\n for (const [token, text] of this.texts) {\n if (!out.includes(token)) continue;\n const indent = /^[ \\t]*/.exec(out)?.[0] ?? \"\";\n out = out.replace(token, () => reindent(text, indent));\n }\n return out;\n }).join(\"\\n\");\n }\n}\n\n/** The builders a printed table imports, which a carried binding must not shadow. */\nconst BUILDER_NAMES = new Set([\"defineTable\", \"defineAuthTable\", \"defineView\", \"col\", \"rel\", \"json\", \"RelationTarget\"]);\n\n/** One function the table carries, where it was. */\ninterface CarriedSite {\n member: Member;\n carried: CarriedFunction;\n label: string;\n}\n\n/** A callback-bearing property, found by walking the evaluated properties. */\ninterface TransformSite {\n /** Path of the property in the literal: `[\"properties\", \"title\"]`. */\n segments: PathSegment[];\n /** The printer's transform path: `title`, `tags[]`, `seo.title`, `content[].text`. */\n transformPath: string;\n /** The callback names that are functions. */\n names: string[];\n}\n\nfunction joinPath(parent: string, segment: string): string {\n if (parent === \"\") return segment;\n return segment === \"[]\" ? `${parent}[]` : `${parent}.${segment}`;\n}\n\nfunction functionNames(value: unknown): string[] {\n if (typeof value !== \"object\" || value === null) return [];\n return Object.entries(value).filter(([, entry]) => typeof entry === \"function\").map(([name]) => name);\n}\n\nfunction collectTransformSites(properties: Record<string, LegacyProperty>, segments: PathSegment[], prefix: string, out: TransformSite[]): void {\n for (const [key, property] of Object.entries(properties)) {\n visitProperty(property, [...segments, key], joinPath(prefix, key), out);\n }\n}\n\nfunction visitProperty(property: LegacyProperty, segments: PathSegment[], transformPath: string, out: TransformSite[]): void {\n const names = functionNames(property.callbacks);\n if (names.length > 0) out.push({ segments, transformPath, names });\n if (property.type === \"array\") {\n if (property.of !== undefined && !Array.isArray(property.of)) {\n visitProperty(property.of, [...segments, \"of\"], joinPath(transformPath, \"[]\"), out);\n }\n if (property.oneOf !== undefined) {\n for (const [variant, variantProperty] of Object.entries(property.oneOf.properties)) {\n visitProperty(variantProperty, [...segments, \"oneOf\", \"properties\", variant], joinPath(joinPath(transformPath, \"[]\"), variant), out);\n }\n }\n }\n if (property.type === \"map\" && property.properties !== undefined) {\n collectTransformSites(property.properties, [...segments, \"properties\"], transformPath, out);\n }\n}\n\n/**\n * The member at `segments` in the collection's literal, or in what a\n * top-level assignment after the declaration put there\n * (`ordersCollection.callbacks = {...}`).\n */\nfunction locate(plan: PlanContext, entry: CollectionEntry, segments: PathSegment[]): { member?: Member; reason?: string } {\n const site = entry.site;\n if (!site) return { reason: entry.siteProblem ?? \"the collection's literal was not found\" };\n const direct = nodeAtPath(plan.ast, site.literal, segments);\n if (direct.node) return { member: direct.node };\n if (site.binding) {\n const assignments = postDeclarationAssignments(plan.ast, entry.sourceFile, site.binding);\n for (let length = segments.length; length > 0; length--) {\n const prefix = segments.slice(0, length);\n if (prefix.some(segment => typeof segment === \"number\")) continue;\n const assigned = assignments.get(prefix.join(\".\"));\n if (!assigned) continue;\n const rest = segments.slice(length);\n if (rest.length === 0) return { member: { node: assigned.statement, value: assigned.value } };\n const object = resolveObject(plan.ast, assigned.value);\n if (!object.node) return { reason: `${prefix.join(\".\")} is assigned at line ${assigned.statement.getStartLineNumber()}, but ${object.reason}` };\n const nested = nodeAtPath(plan.ast, object.node, rest);\n if (nested.node) return { member: nested.node };\n return { reason: nested.reason };\n }\n }\n return { reason: direct.reason };\n}\n\n/** The functions of a callbacks object at `segments`, each carried. */\nfunction carryCallbacks(\n plan: PlanContext,\n entry: CollectionEntry,\n segments: PathSegment[],\n names: readonly string[],\n label: string\n): { members: { name: string; member: Member }[]; failed: boolean } {\n const located = locate(plan, entry, segments);\n if (!located.member) {\n refuse(plan, entry, `${label} holds functions, and their source could not be found: ${located.reason}. Write the callbacks inline in the collection literal (or as a \\`const\\` in the same file) and run the codemod again.`, { key: segments.join(\".\") });\n return { members: [], failed: true };\n }\n const object = resolveObject(plan.ast, located.member.value ?? located.member.node);\n if (!object.node) {\n refuse(plan, entry, `${label} is not an object literal the codemod can read (${object.reason}). Write it inline and run the codemod again.`, { key: segments.join(\".\"), line: located.member.node.getStartLineNumber() });\n return { members: [], failed: true };\n }\n const members: { name: string; member: Member }[] = [];\n let failed = false;\n for (const name of names) {\n const member = memberOf(plan.ast, object.node, name);\n if (!member.node) {\n refuse(plan, entry, `${label}.${name} is a function whose source could not be found: ${member.reason}.`, { key: segments.join(\".\"), line: object.node.getStartLineNumber() });\n failed = true;\n continue;\n }\n members.push({ name, member: member.node });\n }\n return { members, failed };\n}\n\nexport interface BackendPlanInput {\n /** The Postgres collections, in the order they were lifted. */\n entries: CollectionEntry[];\n lift: LiftResult;\n /** `backend/schema`, absolute. */\n schemaDir: string;\n /** The order the index lists the tables in: the legacy index's `collections`, then the rest by file. */\n order: string[];\n}\n\n/** File names and identifiers for every table, unique. */\nexport function nameTables(entries: readonly CollectionEntry[], defs: readonly (AnyTableDef | AnyViewDef)[], schemaDir: string): Map<string, TableName> {\n const byName = new Map<string, number>();\n for (const def of defs) byName.set(def.name, (byName.get(def.name) ?? 0) + 1);\n const names = new Map<string, TableName>();\n defs.forEach((def, index) => {\n const entry = entries[index];\n const schema = isViewDef(def) ? def.config.schema : def.config.schema;\n const base = (byName.get(def.name) ?? 0) > 1 && schema ? `${schema}_${def.name}` : def.name;\n const kind = isViewDef(def) ? \"view\" : def.auth !== undefined ? \"auth-table\" : \"table\";\n names.set(entry.collection.slug, {\n slug: entry.collection.slug,\n identifier: tableIdentifier(base),\n file: path.join(schemaDir, `${base}.ts`),\n table: def.name,\n kind\n });\n });\n return names;\n}\n\n/** Plan the backend schema modules. */\nexport function planBackend(plan: PlanContext, input: BackendPlanInput, names: Map<string, TableName>): void {\n const { entries, lift, schemaDir } = input;\n lift.tables.forEach((def, index) => {\n const entry = entries[index];\n const name = names.get(entry.collection.slug);\n if (!name) return;\n planTableModule(plan, entry, def, name, names);\n });\n const ordered = [...input.order.map(slug => names.get(slug)).filter((value): value is TableName => value !== undefined)];\n for (const name of names.values()) if (!ordered.includes(name)) ordered.push(name);\n const indexFile = path.join(schemaDir, \"index.ts\");\n const index = printIndexModule(\n ordered.map(name => ({ identifier: name.identifier, importPath: generatedSpecifier(indexFile, name.file, plan.specifierStyle) })),\n lift.defaultRls !== undefined ? { defaultRls: lift.defaultRls satisfies DefaultRls } : {}\n );\n planFile(plan, indexFile, index, \"the schema index\");\n}\n\nfunction planTableModule(plan: PlanContext, entry: CollectionEntry, def: AnyTableDef | AnyViewDef, name: TableName, names: Map<string, TableName>): void {\n const collection = entry.collection;\n const splices = new Splices();\n const sources: { hooks?: string | Record<string, string>; transforms?: Record<string, string>; auth?: { onCreateUser?: string; onResetPassword?: string } } = {};\n const carried: CarriedSite[] = [];\n let failed = false;\n\n // Table hooks.\n const hookNames = functionNames(collection.callbacks);\n const callbacksSite = hookNames.length > 0 ? locate(plan, entry, [\"callbacks\"]) : undefined;\n const callbacksValue = callbacksSite?.member && !callbacksSite.member.method ? callbacksSite.member.value : undefined;\n const fromHelper = callbacksValue !== undefined && !resolveObject(plan.ast, callbacksValue).node;\n if (fromHelper && callbacksValue) {\n // `callbacks: softDeleteCallbacks(\"company\")`: the helper's functions take table-hook props where they are written.\n const helper = carryHelperHooks(plan, callbacksValue, hookNames);\n for (const [file, fileEdits] of helper.edits) plan.relocator.addSourceEdits(file, fileEdits);\n for (const file of helper.files) if (!plan.relocator.isInCollections(file)) plan.relocator.keptBackendModules.add(file);\n sources.hooks = splices.token(nodeText(callbacksValue));\n carried.push({ member: { node: callbacksValue, value: callbacksValue }, carried: { text: \"\", todos: [] }, label: \"hooks\" });\n for (const { file, hook, todo } of helper.todos) {\n plan.manualSteps.push({\n title: `Check hooks.${hook} of ${name.table}`,\n detail: `hooks.${hook} (in ${relativeToRoot(plan, file)}, which \\`${callbacksValue.getText().split(\"\\n\")[0]}\\` returns) ${todo} The line is marked \\`TODO(rebase-migrate)\\`.`,\n file: relativeToRoot(plan, file)\n });\n }\n if (helper.unresolved) {\n plan.manualSteps.push({\n title: `Check the hooks ${name.table} gets from \\`${callbacksValue.getText().split(\"\\n\")[0]}\\``,\n detail: `The table says \\`hooks: ${callbacksValue.getText().split(\"\\n\")[0]}\\`, as the collection said \\`callbacks:\\`, but the codemod could not follow it to the functions (${helper.unresolved}). Table hooks get \\`table\\` for \\`collection\\`, and \\`values\\` for \\`row\\` in afterRead / beforeDelete / afterDelete: check ${hookNames.map(hook => `\\`${hook}\\``).join(\", \")} where they are written.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n } else if (hookNames.length > 0) {\n const { members, failed: hookFailure } = carryCallbacks(plan, entry, [\"callbacks\"], hookNames, \"`callbacks`\");\n failed ||= hookFailure;\n const hooks: Record<string, string> = {};\n for (const { name: hook, member } of members) {\n const result = carryHook(plan.ast, member, hook);\n hooks[hook] = splices.token(result.text);\n carried.push({ member, carried: result, label: `hooks.${hook}` });\n }\n sources.hooks = hooks;\n }\n\n // Column transforms.\n const transformSites: TransformSite[] = [];\n collectTransformSites(collection.properties ?? {}, [\"properties\"], \"\", transformSites);\n if (transformSites.length > 0) {\n const transforms: Record<string, string> = {};\n for (const site of transformSites) {\n const { members, failed: transformFailure } = carryCallbacks(plan, entry, [...site.segments, \"callbacks\"], site.names, `the \\`callbacks\\` of \"${site.transformPath}\"`);\n failed ||= transformFailure;\n if (members.length === 0) continue;\n const result = carryTransform(plan.ast, members);\n transforms[site.transformPath] = splices.token(result.text);\n for (const { member } of members) carried.push({ member, carried: { text: \"\", todos: [] }, label: `${site.transformPath}.transform` });\n if (result.todos.length > 0) carried.push({ member: members[0].member, carried: result, label: `${site.transformPath}.transform` });\n }\n sources.transforms = transforms;\n }\n\n // Auth lifecycle functions.\n const auth = typeof collection.auth === \"object\" && collection.auth !== null ? collection.auth : undefined;\n if (auth) {\n for (const key of [\"onCreateUser\", \"onResetPassword\"] as const) {\n if (typeof auth[key] !== \"function\") continue;\n const located = locate(plan, entry, [\"auth\", key]);\n if (!located.member) {\n refuse(plan, entry, `\\`auth.${key}\\` is a function whose source could not be found: ${located.reason}.`, { key: `auth.${key}` });\n failed = true;\n continue;\n }\n const text = located.member.method ? carryHook(plan.ast, located.member, key).text : nodeText(located.member.value ?? located.member.node);\n sources.auth = { ...sources.auth, [key]: splices.token(text) };\n carried.push({ member: located.member, carried: { text, todos: [] }, label: `auth.${key}` });\n }\n }\n if (failed) return;\n\n for (const site of carried) {\n for (const todo of site.carried.todos) {\n plan.manualSteps.push({\n title: `Check ${site.label} of ${name.table}`,\n detail: `${site.label} ${todo} The line is marked \\`TODO(rebase-migrate)\\`.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n }\n\n // What the carried code references, and the other exports of the file.\n const site = entry.site;\n const exclude: Statement[] = site ? site.statements : [];\n const extraExports = site\n ? entry.sourceFile.getStatements().filter(statement => !exclude.includes(statement) && isExportedDeclaration(plan, statement))\n : [];\n const references = collectReferences(plan.ast, [...carried.map(entry_ => entry_.member.node), ...extraExports], exclude);\n for (const forbidden of references.forbidden) {\n refuse(plan, entry, `carried code references \\`${forbidden.name}\\`, the collection itself, which does not exist after the migration. Read what it needs from \\`table\\` (the hook's props) instead.`, { line: forbidden.line });\n failed = true;\n }\n if (failed) return;\n const statements = [...new Set([...references.statements, ...extraExports])].sort((a, b) => a.getStart() - b.getStart());\n for (const statement of extraExports) {\n const names_ = declaredNames(plan, statement);\n plan.manualSteps.push({\n title: `Update the importers of ${names_.join(\", \")}`,\n detail: `${relativeToRoot(plan, entry.file)} exported ${names_.map(n => `\\`${n}\\``).join(\", \")} beside the collection. ${names_.length > 1 ? \"They are\" : \"It is\"} exported from ${relativeToRoot(plan, name.file)} now; point every import of it there.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n\n // Print the table.\n const resolveTarget = (target: { name?: string; slug: string }): PrintTarget => {\n const found = names.get(target.slug);\n if (!found) {\n throw new RelocationError(entry.file, `a relation points at \"${target.slug}\", which is not a collection file in ${relativeToRoot(plan, path.dirname(entry.file))}. Move that collection into the directory (or drop the relation) and run the codemod again.`);\n }\n return {\n identifier: found.identifier,\n importPath: generatedSpecifier(name.file, found.file, plan.specifierStyle),\n table: found.table,\n kind: found.kind === \"view\" ? \"view\" : \"table\"\n };\n };\n let printed;\n try {\n printed = printTableSource(def, { identifier: name.identifier, resolveTarget, sources: sources satisfies TableSources });\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return;\n }\n\n // Imports: the builders and related tables, then what carried code uses.\n // Collection-model types the carried code names become table-model aliases.\n const usesText = [...statements.map(statement => statement.getText()), ...carried.map(site_ => site_.member.node.getText())].join(\"\\n\");\n const legacyTypes = replaceLegacyTypes(references.imports, usesText);\n for (const local of legacyTypes.unreplaceable) {\n plan.manualSteps.push({\n title: `Replace the collection-model type ${local} in ${name.table}`,\n detail: `Carried code uses \\`${local}\\` with type arguments, which a table-model alias cannot stand for. Use the table-model type (\\`TableHooks\\`, \\`TableBeforeSaveProps\\`, … from \\`@rebasepro/server/schema\\`) instead.`,\n file: relativeToRoot(plan, name.file)\n });\n }\n let carriedImports: string[];\n try {\n carriedImports = [\n ...importLines(legacyTypes.kept, use => plan.relocator.relocate(use.specifier, use.fromFile, name.file, \"backend\")),\n ...legacyTypes.imports\n ];\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return;\n }\n const taken = new Set([...printed.imports.builders, ...printed.imports.tables.map(table => table.identifier), name.identifier, ...BUILDER_NAMES]);\n const clashes = [...references.imports.map(use => use.local), ...statements.flatMap(statement => declaredNames(plan, statement))]\n .filter(local => taken.has(local));\n if (clashes.length > 0) {\n refuse(plan, entry, `carried code binds ${[...new Set(clashes)].map(clash => `\\`${clash}\\``).join(\", \")}, which the table module also binds (a builder, a related table, or the table itself). Rename it in the collection file and run the codemod again.`);\n return;\n }\n\n let statementTexts: string[];\n try {\n statementTexts = statements.map(statement => {\n const text = [...leadingComments(statement), nodeText(statement)].join(\"\\n\");\n return text.includes(\"import(\") ? plan.relocator.moveSpecifiersInText(text, entry.file, name.file, \"backend\") : text;\n });\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return;\n }\n\n // Comments: the file header, the collection's own, each property's.\n const header = fileHeader(plan, entry);\n const own = site ? site.statements.flatMap(statement => leadingComments(statement)).filter(comment => !header.includes(comment)) : [];\n let code = printed.code;\n code = splices.apply(code);\n if (code.includes(\"__REBASE_MIGRATE_SPLICE_\")) {\n refuse(plan, entry, \"a spliced source was not placed by the printer (internal): report this.\");\n return;\n }\n if (carried.some(site_ => site_.carried.todos.length > 0)) {\n note(plan, entry, `${name.table}: carried code has TODO(rebase-migrate) lines to check.`);\n }\n\n const parts = [\n ...(header.length > 0 ? [header.join(\"\\n\")] : []),\n [...printImportLines(printed.imports), ...carriedImports].join(\"\\n\"),\n ...(legacyTypes.aliases.length > 0 ? [legacyTypes.aliases.join(\"\\n\")] : []),\n ...statementTexts,\n [...own, code].join(\"\\n\")\n ];\n planFile(plan, name.file, `${parts.join(\"\\n\\n\")}\\n`, `table ${name.table}`);\n}\n\nfunction isExportedDeclaration(plan: PlanContext, statement: Statement): boolean {\n const { Node: N } = plan.ast.tsm;\n if (N.isVariableStatement(statement) || N.isFunctionDeclaration(statement) || N.isClassDeclaration(statement) ||\n N.isInterfaceDeclaration(statement) || N.isTypeAliasDeclaration(statement) || N.isEnumDeclaration(statement)) {\n return statement.isExported() && !statement.isDefaultExport();\n }\n return false;\n}\n\nfunction declaredNames(plan: PlanContext, statement: Statement): string[] {\n const { Node: N } = plan.ast.tsm;\n if (N.isVariableStatement(statement)) return statement.getDeclarations().map(declaration => declaration.getName());\n if (N.isFunctionDeclaration(statement) || N.isClassDeclaration(statement)) {\n const declared = statement.getName();\n return declared ? [declared] : [];\n }\n if (N.isInterfaceDeclaration(statement) || N.isTypeAliasDeclaration(statement) || N.isEnumDeclaration(statement)) return [statement.getName()];\n return [];\n}\n\n/** The comments above the first statement of the file, when that statement is an import: the file's header. */\nfunction fileHeader(plan: PlanContext, entry: CollectionEntry): string[] {\n const first = entry.sourceFile.getStatements()[0];\n if (!first || !plan.ast.tsm.Node.isImportDeclaration(first)) return [];\n return leadingComments(first);\n}\n","/**\n * Where each legacy presentation key goes in `customizeTable`.\n *\n * A migration tool legitimately freezes legacy knowledge, so the table lives\n * here — written out in full, one entry per legacy key, as plain data. It is\n * guarded against the real surface by `tooling/scripts/test/codemod-vocabulary.test.mjs`\n * (`pnpm test:gates`): every destination must be a key `customizeTable`\n * accepts (`TABLE_CUSTOMIZATION_KEYS` / `FIELD_CUSTOMIZATION_KEYS` in\n * `@rebasepro/cms-types`), every renamed key must agree with the hint\n * `customizeTable` refuses the old name with, and every legacy `admin` key\n * (`ADMIN_COLLECTION_KEYS` / `ADMIN_PROPERTY_KEYS` in `@rebasepro/cms-types`) must\n * have an entry here — a destination, or an explicit `dropped` with why.\n *\n * A destination is a key of the customization (`\"fieldOrder\"`) or a path into\n * one (`\"kanban.orderField\"`). Keep the literals plain: the gate test reads\n * this file as source.\n */\n\n/** Where a legacy key goes: a customization key or path, or why it has none. */\nexport type Destination = string | { dropped: string };\n\n/** A collection's `admin` keys → `customizeTable` options. */\nexport const COLLECTION_ADMIN_DESTINATIONS: Readonly<Record<string, Destination>> = {\n Actions: \"Actions\",\n additionalFields: \"additionalFields\",\n alwaysApplyDefaultValues: \"alwaysApplyDefaultValues\",\n browserCallbacks: \"browserCallbacks\",\n components: \"components\",\n customViews: \"customViews\",\n defaultEntityAction: \"defaultEntityAction\",\n defaultFilter: \"defaultFilter\",\n defaultSelectedView: \"defaultSelectedView\",\n defaultSize: \"defaultSize\",\n defaultViewMode: \"defaultViewMode\",\n disableDefaultActions: \"disableDefaultActions\",\n display: \"display\",\n enabledViews: \"enabledViews\",\n entityActions: \"entityActions\",\n entityViews: \"entityViews\",\n exportable: \"exportable\",\n filterPresets: \"filterPresets\",\n fixedFilter: \"fixedFilter\",\n form: \"form\",\n formAutoSave: \"formAutoSave\",\n formView: \"formView\",\n group: \"group\",\n hideFromEntityViews: \"hideFromEntityViews\",\n hideFromNavigation: \"hideFromNavigation\",\n hideIdFromCollection: \"hideIdFromCollection\",\n hideIdFromForm: \"hideIdFromForm\",\n icon: \"icon\",\n includeJsonView: \"includeJsonView\",\n inlineEditing: \"inlineEditing\",\n kanban: \"kanban\",\n listProperties: \"listFields\",\n localChangesBackup: \"localChangesBackup\",\n openEntityMode: \"openEntityMode\",\n orderProperty: \"kanban.orderField\",\n pagination: \"pagination\",\n previewProperties: \"previewFields\",\n propertiesOrder: \"fieldOrder\",\n selectionController: \"selectionController\",\n selectionEnabled: \"selectionEnabled\",\n sideDialogWidth: \"sideDialogWidth\",\n sort: \"sort\"\n};\n\n/** Keys inside a collection's `admin.kanban` → keys of `customizeTable`'s `kanban`. */\nexport const KANBAN_DESTINATIONS: Readonly<Record<string, string>> = {\n columnProperty: \"columnField\",\n orderProperty: \"orderField\"\n};\n\n/** A property's `admin` keys → field-customization options. `disabled: { hidden: true }` also becomes `hiddenInForm`. */\nexport const PROPERTY_ADMIN_DESTINATIONS: Readonly<Record<string, Destination>> = {\n canAddElements: \"canAddElements\",\n clearable: \"clearable\",\n columnWidth: \"columnWidth\",\n customProps: \"customProps\",\n disabled: \"disabled\",\n expanded: \"expanded\",\n Field: \"Field\",\n filledByServer: \"filledByServer\",\n Filter: \"Filter\",\n filterOperators: \"filterOperators\",\n fixedFilter: \"fixedFilter\",\n format: \"format\",\n hideFromCollection: \"hidden\",\n includeEntityLink: \"includeEntityLink\",\n includeId: \"includeId\",\n markdown: \"markdown\",\n minimalistView: \"minimalistView\",\n multiline: \"multiline\",\n Preview: \"Preview\",\n previewAsTag: \"previewAsTag\",\n previewProperties: \"previewFields\",\n readOnly: \"readOnly\",\n renderInForm: \"renderInForm\",\n sortable: \"sortable\",\n span: \"span\",\n spreadChildren: \"spreadChildren\",\n urlPreview: \"urlPreview\",\n widget: \"widget\"\n};\n\n/** Presentation fields of a collection outside its `admin` block (what the lift reports as not carried). */\nexport const COLLECTION_FIELD_DESTINATIONS: Readonly<Record<string, Destination>> = {\n name: \"name\",\n singularName: \"singularName\",\n icon: \"icon\",\n \"auth.actions.resetPassword\": \"resetPasswordAction\",\n admin: { dropped: \"not a destination itself: each of its keys is routed by COLLECTION_ADMIN_DESTINATIONS.\" },\n childCollections: { dropped: \"customizeTable has no child collections: a table's hasMany / manyToMany relations are its record tabs (reported as a manual step).\" },\n ownerId: { dropped: \"stamped by the collection editor; nothing on the request path or in the panel reads it.\" }\n};\n\n/** Presentation fields of a property outside its `admin` block. Labels equal to the derived one are dropped on the way. */\nexport const PROPERTY_FIELD_DESTINATIONS: Readonly<Record<string, Destination>> = {\n name: \"name\",\n description: \"description\",\n enum: \"enumLabels\",\n propertiesOrder: \"fieldOrder\",\n mode: \"mode\",\n timezone: \"timezone\",\n propertyConfig: \"propertyConfig\",\n conditions: \"conditions\",\n dynamicProps: \"dynamicProps\",\n metadata: \"metadata\",\n overrides: \"overrides\",\n \"storage.processFile\": \"storage\",\n \"storage.postProcess\": \"storage\",\n \"storage.previewUrl\": \"storage\",\n \"storage.fileName\": \"storage\",\n admin: { dropped: \"not a destination itself: each of its keys is routed by PROPERTY_ADMIN_DESTINATIONS.\" },\n userSelect: { dropped: \"carried by the lift as `.userId()` on the column; the CMS reads it from the descriptor.\" },\n defaultValue: \"defaultValue\",\n validation: { dropped: \"a relation's `requiredMessage` / `uniqueInArray` are panel messages customizeTable has no option for.\" },\n \"oneOf.propertiesOrder\": { dropped: \"the order the panel offers block types in; customizeTable has no option for it.\" },\n isId: { dropped: \"`\\\"manual\\\"` and `true` are the same key to the server; the difference had no other reader.\" },\n type: { dropped: \"a reference inside a JSON array is a document value; there is nothing to customize.\" }\n};\n\n/**\n * Keys of a rule source renamed with the move to tables, by where they are\n * written: the argument of `policy.existsIn(…)` / a literal\n * `{ kind: \"existsIn\", … }` (`ExistsInPolicyExpression` in `@rebasepro/types`),\n * and a tenant's `membership: { … }` source (`TenantMembershipSource`). The\n * SDK-call pass (`sdk-calls.ts`, rule 11) applies them to the project's own\n * code; the gate test holds each new key to the type's members.\n */\nexport const RULE_KEY_RENAMES: Readonly<Record<\"existsIn\" | \"membership\", Readonly<Record<string, string>>>> = {\n existsIn: { collection: \"table\" },\n membership: { collection: \"table\" }\n};\n","/**\n * Carrying a collection file's comments to the files it became.\n *\n * The shared printer prints tables from values, so it has no comments to\n * print; this is the codemod's own pass over the printed text, run once every\n * file of a collection is planned. A comment moves with what it describes:\n *\n * - above a property (or inside its literal) → above its column, or its\n * relation; above its field in the customization file when the property was\n * presentation only (when both halves exist the schema file keeps it);\n * - above a `securityRules`, `indexes` or `relations` entry → above that rule,\n * index or relation; above a `callbacks` member → above that hook;\n * - above any other carried key (`history`, `search`, …) → above that key;\n * above a presentation key (`name`, `icon`, an `admin` option) → above it in\n * the customization;\n * - comments inside carried functions are part of their text already.\n *\n * A comment that cannot be attached unambiguously is never dropped: it is\n * written at the top of the generated file, under `// From <original file>:`.\n */\nimport path from \"node:path\";\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\nimport type { AnyTableDef, AnyViewDef } from \"@rebasepro/types\";\n\nimport type { AstContext } from \"./ast\";\nimport { memberOf, postDeclarationAssignments, resolveArray, resolveObject, toPosix } from \"./ast\";\nimport type { CollectionEntry } from \"./plan-context\";\nimport { dedent, reindent } from \"./print-js\";\nimport { COLLECTION_ADMIN_DESTINATIONS } from \"./vocabulary\";\nimport { own } from \"./own\";\n\n/** Where a comment goes. */\nexport interface CommentTarget {\n side: \"backend\" | \"cms\";\n /** A top-level key of the definition / customization; absent for \"unattached\". */\n key?: string;\n /** An entry of that key's block: an object key, or an array index. */\n entry?: string | number;\n}\n\n/** One comment and where it goes. */\nexport interface PlacedComment {\n text: string;\n target: CommentTarget;\n}\n\n/** Legacy collection keys carried into the table under a key of their own. */\nconst CARRIED_KEYS: Readonly<Record<string, string>> = {\n slug: \"slug\",\n table: \"table\",\n schema: \"schema\",\n dataSource: \"database\",\n description: \"description\",\n tenant: \"tenant\",\n softDelete: \"softDelete\",\n history: \"history\",\n search: \"search\",\n strictWrites: \"strictWrites\",\n metadata: \"metadata\",\n disableDefaultPolicies: \"defaultPolicies\",\n auth: \"auth\",\n view: \"query\"\n};\n\n/** Presentation keys of a collection outside `admin`. */\nconst PRESENTATION_KEYS = new Set([\"name\", \"singularName\", \"icon\"]);\n\nfunction isInsideFunction(ctx: AstContext, node: Node, boundary: Node): boolean {\n const { Node: N } = ctx.tsm;\n let current: Node | undefined = node;\n while (current && current !== boundary) {\n if (N.isArrowFunction(current) || N.isFunctionExpression(current) || N.isMethodDeclaration(current) || N.isFunctionDeclaration(current)) return true;\n current = current.getParent();\n }\n return false;\n}\n\n/**\n * The comment ranges of a node: before it, and on its line after it — after\n * the comma that ends a member too (`slug: …, // why`), which the parser\n * hands to the next member's leading trivia.\n */\nfunction ownRanges(node: Node): { pos: number; text: string }[] {\n const out = [...node.getLeadingCommentRanges(), ...node.getTrailingCommentRanges()].map(range => ({ pos: range.getPos(), text: range.getText() }));\n const full = node.getSourceFile().getFullText();\n let end = node.getEnd();\n while (end < full.length && (full[end] === \" \" || full[end] === \"\\t\")) end++;\n if (full[end] === \",\") {\n const after = full.slice(end + 1);\n const match = /^[ \\t]*(\\/\\/[^\\n]*|\\/\\*[^\\n]*?\\*\\/)/.exec(after);\n if (match) {\n const pos = end + 1 + after.indexOf(match[1]);\n if (!out.some(range => range.pos === pos)) out.push({ pos, text: match[1] });\n }\n }\n return out;\n}\n\n/** Every comment range anywhere inside a node (not counting the node's own leading ones). */\nfunction innerRanges(node: Node): { pos: number; text: string; owner: Node }[] {\n const out: { pos: number; text: string; owner: Node }[] = [];\n for (const descendant of node.getDescendants()) {\n for (const range of [...descendant.getLeadingCommentRanges(), ...descendant.getTrailingCommentRanges()]) {\n if (range.getPos() >= node.getStart() && range.getEnd() <= node.getEnd()) out.push({ pos: range.getPos(), text: range.getText(), owner: descendant });\n }\n }\n return out;\n}\n\n/** A comment's text with the indentation of its line removed from its later lines. */\nfunction commentText(sf: SourceFile, pos: number, text: string): string {\n const full = sf.getFullText();\n const lineStart = full.lastIndexOf(\"\\n\", pos - 1) + 1;\n const indent = /^[ \\t]*/.exec(full.slice(lineStart, pos))?.[0] ?? \"\";\n return dedent(text, indent);\n}\n\n/** Directives a linter or compiler reads, which mean nothing in another file. */\nfunction isDirective(text: string): boolean {\n return /^\\/\\/\\s*(@ts-|eslint|prettier|#)/.test(text) || /^\\/\\*\\s*(eslint|prettier|@ts-|global\\b)/.test(text);\n}\n\n/**\n * Every comment of a collection file, and where it goes.\n *\n * @param def the definition the collection became (to know its columns and relations)\n * @param skip comments already written by the module printer (the file header, the collection's own doc)\n */\nexport function collectComments(ctx: AstContext, entry: CollectionEntry, def: AnyTableDef | AnyViewDef, skip: ReadonlySet<string>): PlacedComment[] {\n const site = entry.site;\n const sf = entry.sourceFile;\n if (!site) return [];\n const { Node: N } = ctx.tsm;\n const columns = new Set(Object.keys(def.config.columns));\n const relations = new Set(Object.keys(def.config.relations ?? {}));\n const placed = new Set<number>();\n const out: PlacedComment[] = [];\n const put = (pos: number, text: string, target: CommentTarget): void => {\n if (placed.has(pos)) return;\n placed.add(pos);\n if (isDirective(text) || skip.has(text)) return;\n out.push({ text: commentText(sf, pos, text), target });\n };\n const putAll = (node: Node, target: CommentTarget, boundary: Node): void => {\n for (const range of ownRanges(node)) put(range.pos, range.text, target);\n for (const range of innerRanges(node)) {\n if (isInsideFunction(ctx, range.owner, boundary)) {\n placed.add(range.pos);\n continue;\n }\n put(range.pos, range.text, target);\n }\n };\n\n const propertyTarget = (key: string): CommentTarget =>\n columns.has(key) ? { side: \"backend\", key: \"columns\", entry: key }\n : relations.has(key) ? { side: \"backend\", key: \"relations\", entry: key }\n : { side: \"cms\", key: \"fields\", entry: key };\n\n /** One collection-level member (`properties: {…}`) or the value assigned to it later. */\n const member = (key: string, holder: Node, value: Node | undefined): void => {\n const rangesOfHolder = ownRanges(holder);\n if (key === \"properties\") {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"backend\", key: \"columns\" });\n const object = value ? resolveObject(ctx, value).node : undefined;\n if (!object) return;\n for (const property of object.getProperties()) {\n if (N.isSpreadAssignment(property)) continue;\n const nameNode = \"getNameNode\" in property ? property.getNameNode() : undefined;\n const name = nameNode ? nameNode.getText().replace(/^[\"'`]|[\"'`]$/g, \"\") : undefined;\n if (name === undefined) continue;\n putAll(property, propertyTarget(name), property);\n }\n return;\n }\n const arrayKey = key === \"securityRules\" ? \"rls\" : key === \"indexes\" ? \"indexes\" : key === \"relations\" ? \"relations\" : undefined;\n if (arrayKey) {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"backend\", key: arrayKey });\n const array = value ? resolveArray(ctx, value).node : undefined;\n if (!array) return;\n const relationsList = \"relations\" in entry.collection && Array.isArray(entry.collection.relations) ? entry.collection.relations : [];\n array.getElements().forEach((element, index) => {\n if (arrayKey === \"relations\") {\n const name = relationsList[index]?.relationName;\n putAll(element, name !== undefined && relations.has(name) ? { side: \"backend\", key: \"relations\", entry: name } : { side: \"backend\", key: \"relations\" }, element);\n } else {\n putAll(element, { side: \"backend\", key: arrayKey, entry: index }, element);\n }\n });\n return;\n }\n if (key === \"callbacks\") {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"backend\", key: \"hooks\" });\n const object = value ? resolveObject(ctx, value).node : undefined;\n if (!object) return;\n for (const hook of object.getProperties()) {\n const nameNode = \"getNameNode\" in hook ? hook.getNameNode() : undefined;\n if (!nameNode) continue;\n putAll(hook, { side: \"backend\", key: \"hooks\", entry: nameNode.getText() }, hook);\n }\n return;\n }\n if (key === \"admin\") {\n for (const range of rangesOfHolder) put(range.pos, range.text, { side: \"cms\" });\n const object = value ? resolveObject(ctx, value).node : undefined;\n if (!object) return;\n for (const option of object.getProperties()) {\n const nameNode = \"getNameNode\" in option ? option.getNameNode() : undefined;\n const destination = nameNode ? own(COLLECTION_ADMIN_DESTINATIONS, nameNode.getText()) : undefined;\n const top = typeof destination === \"string\" ? destination.split(\".\")[0] : undefined;\n putAll(option, top ? { side: \"cms\", key: top } : { side: \"cms\" }, option);\n }\n return;\n }\n const carried = own(CARRIED_KEYS, key);\n const target: CommentTarget = carried ? { side: \"backend\", key: carried }\n : PRESENTATION_KEYS.has(key) ? { side: \"cms\", key }\n : { side: \"backend\" };\n putAll(holder, target, holder);\n };\n\n const literal: ObjectLiteralExpression = site.literal;\n for (const property of literal.getProperties()) {\n if (N.isSpreadAssignment(property)) {\n putAll(property, { side: \"backend\" }, property);\n continue;\n }\n const nameNode = \"getNameNode\" in property ? property.getNameNode() : undefined;\n if (!nameNode) continue;\n const key = nameNode.getText().replace(/^[\"'`]|[\"'`]$/g, \"\");\n const value = memberOf(ctx, literal, key).node;\n member(key, property, value?.value ?? (value?.method ? value.method : undefined));\n }\n if (site.binding) {\n for (const [assigned, { value, statement }] of postDeclarationAssignments(ctx, sf, site.binding)) {\n if (!assigned.includes(\".\")) member(assigned, statement, value);\n }\n }\n // Every other comment of the file that nothing carried, at the top.\n for (const statement of sf.getStatements()) {\n if (ctx.tsm.Node.isImportDeclaration(statement)) {\n for (const range of ownRanges(statement)) put(range.pos, range.text, { side: \"backend\" });\n continue;\n }\n for (const range of ownRanges(statement)) put(range.pos, range.text, { side: \"backend\" });\n for (const range of innerRanges(statement)) {\n if (placed.has(range.pos)) continue;\n if (isInsideFunction(ctx, range.owner, statement)) {\n placed.add(range.pos);\n continue;\n }\n put(range.pos, range.text, { side: \"backend\" });\n }\n }\n return out;\n}\n\n/** The index of the line that opens the definition / customization call. */\nfunction callLine(lines: readonly string[]): number {\n return lines.findIndex(line => /^export const \\w+ = (define(Table|AuthTable|View)|customizeTable)\\b/.test(line));\n}\n\n/** Where a target lands in printed text, as a line index, or -1. */\nfunction targetLine(lines: readonly string[], target: CommentTarget): number {\n const start = callLine(lines);\n if (start < 0 || target.key === undefined) return -1;\n let keyLine = -1;\n for (let index = start + 1; index < lines.length; index++) {\n if (/^\\}\\)/.test(lines[index])) break;\n if (lines[index].startsWith(` ${target.key}: `) || lines[index] === ` ${target.key}: {` || lines[index] === ` ${target.key}: [`) {\n keyLine = index;\n break;\n }\n }\n if (keyLine < 0 || target.entry === undefined) return keyLine;\n const opener = lines[keyLine];\n if (!opener.endsWith(\"{\") && !opener.endsWith(\"[\")) return keyLine;\n let element = 0;\n for (let index = keyLine + 1; index < lines.length; index++) {\n const line = lines[index];\n if (/^ {4}[\\]}]/.test(line)) break;\n if (!/^ {8}\\S/.test(line) || /^ {8}[}\\]]/.test(line)) continue;\n if (typeof target.entry === \"number\") {\n if (element === target.entry) return index;\n element++;\n } else {\n const match = /^ {8}(\"?)([^\":\\s]+)\\1: /.exec(line);\n if (match && match[2] === target.entry) return index;\n }\n }\n return -1;\n}\n\n/**\n * Insert comments into printed text, each above its target line, indented\n * like it. What has no target there is returned.\n */\nexport function placeComments(text: string, comments: readonly PlacedComment[]): { text: string; leftover: string[] } {\n const lines = text.split(\"\\n\");\n const inserts = new Map<number, string[]>();\n const leftover: string[] = [];\n for (const comment of comments) {\n const line = targetLine(lines, comment.target);\n if (line < 0) {\n leftover.push(comment.text);\n continue;\n }\n const indent = /^[ \\t]*/.exec(lines[line])?.[0] ?? \"\";\n inserts.set(line, [...(inserts.get(line) ?? []), `${indent}${reindent(comment.text, indent)}`]);\n }\n const out: string[] = [];\n lines.forEach((line, index) => {\n out.push(...(inserts.get(index) ?? []), line);\n });\n return { text: out.join(\"\\n\"), leftover };\n}\n\n/** Comments nothing could be attached to, written after the module's imports under `// From <file>:`. */\nexport function addUnattached(text: string, comments: readonly string[], originalFile: string, root: string): string {\n if (comments.length === 0) return text;\n const lines = text.split(\"\\n\");\n let last = -1;\n lines.forEach((line, index) => {\n if (/^import\\s/.test(line)) last = index;\n });\n const block = [\"\", `// From ${toPosix(path.relative(root, originalFile))}:`, ...comments];\n lines.splice(last + 1, 0, ...block);\n return lines.join(\"\\n\");\n}\n\n/**\n * The legacy collections index's comments: those about `defaultSecurityRules`\n * go above `defaultRls`, those about the `collections` array (the panel's\n * order) above `tableCustomizations`, the rest to the schema index's top.\n *\n * @returns the two index files' new text\n */\nexport function placeIndexComments(\n ctx: AstContext,\n legacyIndex: SourceFile,\n schemaIndex: string,\n cmsIndex: string | undefined,\n root: string\n): { schemaIndex: string; cmsIndex?: string } {\n const rules: string[] = [];\n const order: string[] = [];\n const rest: string[] = [];\n for (const statement of legacyIndex.getStatements()) {\n const ranges = [...ownRanges(statement), ...innerRanges(statement).filter(range => !isInsideFunction(ctx, range.owner, statement))];\n const texts = ranges.filter(range => !isDirective(range.text)).map(range => commentText(legacyIndex, range.pos, range.text));\n if (texts.length === 0) continue;\n const declared = ctx.tsm.Node.isVariableStatement(statement) ? statement.getDeclarations().map(declaration => declaration.getName()) : [];\n if (declared.includes(\"defaultSecurityRules\")) rules.push(...texts);\n else if (declared.includes(\"collections\")) order.push(...texts);\n else rest.push(...texts);\n }\n const insertAbove = (text: string, marker: RegExp, comments: readonly string[]): { text: string; placed: boolean } => {\n if (comments.length === 0) return { text, placed: true };\n const lines = text.split(\"\\n\");\n let at = lines.findIndex(line => marker.test(line));\n if (at < 0) return { text, placed: false };\n while (at > 0 && /^(\\/\\*\\*|\\s*\\*|\\/\\/)/.test(lines[at - 1])) at--;\n lines.splice(at, 0, ...comments);\n return { text: lines.join(\"\\n\"), placed: true };\n };\n const withRules = insertAbove(schemaIndex, /^export const defaultRls\\b/, rules);\n let nextSchema = withRules.text;\n const unattached = [...rest, ...(withRules.placed ? [] : rules)];\n let nextCms = cmsIndex;\n if (cmsIndex !== undefined) {\n const withOrder = insertAbove(cmsIndex, /^export const tableCustomizations\\b/, order);\n nextCms = withOrder.text;\n if (!withOrder.placed) unattached.push(...order);\n } else {\n unattached.push(...order);\n }\n if (unattached.length > 0) nextSchema = `// From ${toPosix(path.relative(root, legacyIndex.getFilePath()))}:\\n${unattached.join(\"\\n\")}\\n\\n${nextSchema}`;\n return { schemaIndex: nextSchema, ...(nextCms !== undefined ? { cmsIndex: nextCms } : {}) };\n}\n","/**\n * A `dynamicProps` builder's return shape, 0.30 → 0.31.\n *\n * On 0.30 a builder returned a partial property: `{ admin: { readOnly: true } }`.\n * On 0.31 it returns a field customization, flat: `{ readOnly: true }`, each\n * key under the name `customizeTable` gives it (`hideFromCollection` →\n * `hidden`, as the codemod routes a static `admin`). When every value the\n * function can return is an object literal — directly, through a ternary, an\n * early `return`, or a top-level `const` of the same file used only there —\n * and each holds nothing but an `admin` block of routable keys, the literals\n * are rewritten in place. Anything else (a spread, a computed value, a key\n * that would collide or has no destination) is left for the manual step.\n */\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\n\nimport type { AstContext } from \"./ast\";\nimport { unwrap } from \"./ast\";\nimport type { SourceEdit } from \"./helper-hooks\";\nimport { own } from \"./own\";\nimport { PROPERTY_ADMIN_DESTINATIONS } from \"./vocabulary\";\n\n/** The rewrite of one builder: edits into its file, or why it is left. */\nexport type DynamicPropsRewrite = { edits: SourceEdit[]; reason?: undefined } | { edits?: undefined; reason: string };\n\nfunction propertyName(ctx: AstContext, member: Node): string | undefined {\n const { Node: N } = ctx.tsm;\n if (!N.isPropertyAssignment(member) && !N.isShorthandPropertyAssignment(member)) return undefined;\n const name = member.getNameNode();\n if (N.isIdentifier(name)) return name.getText();\n if (N.isStringLiteral(name) || N.isNoSubstitutionTemplateLiteral(name)) return name.getLiteralValue();\n return undefined;\n}\n\n/** `{ admin: { readOnly: true } }` → `{ readOnly: true }`, or why not. */\nfunction flatten(ctx: AstContext, literal: ObjectLiteralExpression): { text: string } | { reason: string } {\n const { Node: N } = ctx.tsm;\n const properties = literal.getProperties();\n if (properties.length === 0) return { text: literal.getText() };\n const out: string[] = [];\n const seen = new Set<string>();\n for (const property of properties) {\n if (propertyName(ctx, property) !== \"admin\" || !N.isPropertyAssignment(property)) {\n return { reason: `it returns \\`${property.getText().split(\"\\n\")[0]}\\`, which is not an \\`admin\\` block` };\n }\n const admin = unwrap(ctx, property.getInitializerOrThrow());\n if (!N.isObjectLiteralExpression(admin)) return { reason: \"its `admin` block is not an object literal\" };\n for (const entry of admin.getProperties()) {\n const key = propertyName(ctx, entry);\n const destination = key === undefined ? undefined : own(PROPERTY_ADMIN_DESTINATIONS, key);\n if (key === undefined || typeof destination !== \"string\" || key === \"disabled\") {\n return { reason: `its \\`admin.${key ?? entry.getText().split(\"\\n\")[0]}\\` has no flat equivalent the codemod can write` };\n }\n if (seen.has(destination)) return { reason: `two of its \\`admin\\` keys would both be \\`${destination}\\`` };\n seen.add(destination);\n const value = N.isShorthandPropertyAssignment(entry) ? entry.getName() : N.isPropertyAssignment(entry) ? entry.getInitializerOrThrow().getText() : undefined;\n if (value === undefined) return { reason: `its \\`admin.${key}\\` is not a plain value` };\n out.push(`${destination}: ${value}`);\n }\n }\n return { text: out.length === 0 ? \"{}\" : `{ ${out.join(\", \")} }` };\n}\n\n/** The literals a function can return, or why not every return is one. */\nfunction returnedLiterals(ctx: AstContext, fn: Node, sf: SourceFile): { literals: ObjectLiteralExpression[]; consts: Set<string> } | { reason: string } {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const literals: ObjectLiteralExpression[] = [];\n const consts = new Set<string>();\n const leaves = (node: Node): string | undefined => {\n const current = unwrap(ctx, node);\n if (N.isConditionalExpression(current)) return leaves(current.getWhenTrue()) ?? leaves(current.getWhenFalse());\n if (N.isObjectLiteralExpression(current)) {\n literals.push(current);\n return undefined;\n }\n if (N.isIdentifier(current)) {\n const declaration = sf.getVariableDeclaration(current.getText());\n const statement = declaration?.getVariableStatement();\n const initializer = declaration?.getInitializer();\n const value = initializer ? unwrap(ctx, initializer) : undefined;\n if (declaration && statement && N.isSourceFile(statement.getParent()) && value && N.isObjectLiteralExpression(value)) {\n consts.add(current.getText());\n literals.push(value);\n return undefined;\n }\n }\n return `it returns \\`${current.getText().split(\"\\n\")[0]}\\`, not an object literal`;\n };\n if (!(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isMethodDeclaration(fn) || N.isFunctionDeclaration(fn))) return { reason: \"it is not a function written here\" };\n const body = fn.getBody();\n if (!body) return { reason: \"it has no body\" };\n if (!N.isBlock(body)) {\n const problem = leaves(body);\n return problem ? { reason: problem } : { literals, consts };\n }\n const returns = fn.getDescendantsOfKind(SyntaxKind.ReturnStatement).filter(statement =>\n statement.getFirstAncestor(ancestor => N.isArrowFunction(ancestor) || N.isFunctionExpression(ancestor) || N.isFunctionDeclaration(ancestor) || N.isMethodDeclaration(ancestor)) === fn);\n if (returns.length === 0) return { reason: \"it returns nothing\" };\n for (const statement of returns) {\n const expression = statement.getExpression();\n if (!expression) return { reason: \"a `return` gives no value\" };\n const problem = leaves(expression);\n if (problem) return { reason: problem };\n }\n return { literals, consts };\n}\n\n/** Every function of a file written as the value of a `dynamicProps` member. */\nexport function dynamicPropsBuilders(ctx: AstContext, sf: SourceFile): Node[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const out: Node[] = [];\n for (const member of sf.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {\n if (member.getName() !== \"dynamicProps\") continue;\n const value = unwrap(ctx, member.getInitializerOrThrow());\n if (N.isArrowFunction(value) || N.isFunctionExpression(value)) out.push(value);\n }\n for (const method of sf.getDescendantsOfKind(SyntaxKind.MethodDeclaration)) if (method.getName() === \"dynamicProps\") out.push(method);\n return out;\n}\n\n/**\n * Rewrite a builder's returned literals to the flat shape.\n *\n * @param fn the builder (arrow, function expression or method) in `sf`\n * @param ownedBuilders every builder function of the file being rewritten: a\n * `const` returned by one may only be read by such builders\n */\nexport function rewriteDynamicProps(ctx: AstContext, fn: Node, sf: SourceFile, ownedBuilders: readonly Node[] = dynamicPropsBuilders(ctx, sf)): DynamicPropsRewrite {\n const { SyntaxKind } = ctx.tsm;\n const found = returnedLiterals(ctx, fn, sf);\n if (\"reason\" in found) return { reason: found.reason };\n // A shared `const` (`READ_ONLY`) is rewritten only when every read of it is a builder's return.\n for (const name of found.consts) {\n const reads = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === name && identifier.getParentIfKind(SyntaxKind.VariableDeclaration)?.getNameNode() !== identifier);\n const outside = reads.filter(identifier => !ownedBuilders.some(builder => identifier.getAncestors().includes(builder)));\n if (outside.length > 0) return { reason: `\\`${name}\\` is also read outside the builders (line ${outside[0].getStartLineNumber()})` };\n }\n const edits: SourceEdit[] = [];\n for (const literal of found.literals) {\n const flat = flatten(ctx, literal);\n if (\"reason\" in flat) return { reason: flat.reason };\n if (flat.text !== literal.getText()) edits.push({ start: literal.getStart(), end: literal.getEnd(), text: flat.text });\n }\n return { edits };\n}\n","/**\n * Shared enum constants, split into values (the schema's) and labels (the\n * CMS's).\n *\n * A legacy project often keeps a closed set in one module of `config/` —\n * `export const LOCALE_ENUM: EnumValueConfig[] = [{ id: \"en\", label: \"English\" }, …]`\n * — and uses it in a collection, where the ids are the column's values and the\n * labels its presentation. After the split those belong to two sides that may\n * not import each other's code, so the module becomes two:\n *\n * - `backend/lib/<name>.ts`: `export const LOCALES = [\"en\", …] as const;` and\n * `export type Locale = (typeof LOCALES)[number];`\n * - `frontend/src/cms/lib/<name>.ts`: `export const LOCALE_LABELS: Record<Locale, string> = {…}`,\n * typed from the backend's values (a type import, which the frontend may\n * make), so a value added without a label is a type error.\n *\n * The tables name `LOCALES` where they inlined the ids, and the customizations\n * name `LOCALE_LABELS` where they inlined the labels.\n *\n * Done only when it is mechanical: every export of the module is such a\n * constant, every entry is `{ id, label }` with nothing else (no colour, no\n * disabled flag). Otherwise the module stays a manual step that says why.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { plural } from \"@rebasepro/utils\";\n\nimport type { ModuleImporter } from \"./load-legacy\";\nimport { generatedSpecifier } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { planFile, relativeToRoot } from \"./plan-context\";\nimport { printStringLiteral } from \"./print-js\";\n\n/** One constant split in two. */\nexport interface SplitConstant {\n /** The legacy module, absolute. */\n module: string;\n /** The legacy export name (`LOCALE_ENUM`). */\n legacyName: string;\n /** The values, in order. */\n ids: (string | number)[];\n /** The label of each value. */\n labels: Record<string, string>;\n /** `LOCALES`, written in `backend/lib/<name>.ts`. */\n valuesName: string;\n /** `Locale`. */\n typeName: string;\n /** `LOCALE_LABELS`, written in `frontend/src/cms/lib/<name>.ts`. */\n labelsName: string;\n /** The backend module, absolute. */\n backendFile: string;\n /** The frontend module, absolute (absent for a project without a frontend). */\n frontendFile?: string;\n /** The collection files that import the legacy module. */\n importedBy: Set<string>;\n}\n\n/** A module of `config/` that could not be split, and why. */\nexport interface UnsplitModule {\n module: string;\n reason: string;\n}\n\nconst CODE_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".js\", \".mjs\"];\n\nfunction resolveModule(fromFile: string, specifier: string): string | undefined {\n const base = path.resolve(path.dirname(fromFile), specifier).replace(/\\.(m?js|jsx)$/, \"\");\n for (const extension of CODE_EXTENSIONS) if (fs.existsSync(base + extension)) return base + extension;\n for (const extension of CODE_EXTENSIONS) {\n const index = path.join(base, `index${extension}`);\n if (fs.existsSync(index)) return index;\n }\n return undefined;\n}\n\nfunction isEnumEntry(value: unknown): value is { id: string | number; label: string } {\n if (typeof value !== \"object\" || value === null) return false;\n const keys = Object.keys(value);\n return keys.length === 2 && \"id\" in value && \"label\" in value &&\n (typeof value.id === \"string\" || typeof value.id === \"number\") && typeof value.label === \"string\";\n}\n\nfunction names(legacyName: string): { valuesName: string; typeName: string; labelsName: string } {\n const base = legacyName.replace(/_(ENUM|VALUES|OPTIONS|LIST)$/, \"\") || legacyName;\n const lower = base.toLowerCase();\n const plural_ = plural(lower);\n const valuesName = plural_ !== lower ? plural_.toUpperCase() : `${base}_VALUES`;\n const typeName = lower.split(\"_\").filter(Boolean).map(word => word[0].toUpperCase() + word.slice(1)).join(\"\");\n return { valuesName, typeName, labelsName: `${base}_LABELS` };\n}\n\n/**\n * Find the `config/` modules the collections import that are enum constants\n * and nothing else.\n */\nexport async function findSplitConstants(\n plan: PlanContext,\n entries: readonly CollectionEntry[],\n importModule: ModuleImporter,\n cmsDir: string | undefined\n): Promise<{ constants: SplitConstant[]; unsplit: UnsplitModule[] }> {\n const byModule = new Map<string, Set<string>>();\n for (const entry of entries) {\n for (const declaration of entry.sourceFile.getImportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\") || declaration.isTypeOnly()) continue;\n const target = resolveModule(entry.file, specifier);\n if (!target || !plan.relocator.isInConfig(target) || entries.some(other => other.file === target)) continue;\n const set = byModule.get(target) ?? new Set<string>();\n set.add(entry.file);\n byModule.set(target, set);\n }\n }\n const constants: SplitConstant[] = [];\n const unsplit: UnsplitModule[] = [];\n for (const [module, importedBy] of byModule) {\n let exports: Record<string, unknown>;\n try {\n exports = await importModule(module);\n } catch {\n continue;\n }\n const entriesOf = Object.entries(exports).filter(([name]) => name !== \"default\" && name !== \"__esModule\");\n const enumExports = entriesOf.filter(([, value]) => Array.isArray(value) && value.length > 0 && value.every(isEnumEntry));\n if (enumExports.length === 0) continue;\n if (enumExports.length !== entriesOf.length) {\n unsplit.push({ module, reason: `exports ${entriesOf.filter(entry => !enumExports.includes(entry)).map(([name]) => `\\`${name}\\``).join(\", \")} besides its enum constants, so it cannot be split into values and labels mechanically` });\n continue;\n }\n const relative = path.relative(plan.relocator.configDirectory, module);\n for (const [legacyName, value] of enumExports) {\n const list = Array.isArray(value) ? value.filter(isEnumEntry) : [];\n const labels: Record<string, string> = {};\n for (const item of list) labels[String(item.id)] = item.label;\n constants.push({\n module,\n legacyName,\n ids: list.map(item => item.id),\n labels,\n ...names(legacyName),\n backendFile: path.join(plan.root, \"backend\", \"lib\", relative),\n ...(cmsDir ? { frontendFile: path.join(cmsDir, \"lib\", relative) } : {}),\n importedBy\n });\n }\n }\n return { constants, unsplit };\n}\n\n/** The printed form of a constant's ids, as the shared printer writes an array of literals. */\nfunction printedIds(constant: SplitConstant): string {\n return `[${constant.ids.map(id => (typeof id === \"string\" ? printStringLiteral(id) : String(id))).join(\", \")}]`;\n}\n\n/** Insert an import line after a module's import block. */\nfunction addImport(content: string, line: string): string {\n if (content.includes(line)) return content;\n const lines = content.split(\"\\n\");\n let last = -1;\n lines.forEach((text, index) => {\n if (/^import\\s/.test(text)) last = index;\n });\n lines.splice(last + 1, 0, line);\n return lines.join(\"\\n\");\n}\n\n/** Write the split modules and point the planned tables at the values. */\nexport function planSplitConstants(plan: PlanContext, constants: readonly SplitConstant[], tableFiles: ReadonlyMap<string, string>): void {\n const byModule = new Map<string, SplitConstant[]>();\n for (const constant of constants) byModule.set(constant.module, [...(byModule.get(constant.module) ?? []), constant]);\n for (const [module, group] of byModule) {\n const legacy = relativeToRoot(plan, module);\n const backend = group.map(constant => [\n `/** The values of \\`${constant.legacyName}\\` (${legacy}). What the panel calls each one is the CMS's: ${constant.frontendFile ? relativeToRoot(plan, constant.frontendFile) : \"no frontend\"}. */`,\n `export const ${constant.valuesName} = ${printedIds(constant)} as const;`,\n \"\",\n `/** One of {@link ${constant.valuesName}}. */`,\n `export type ${constant.typeName} = (typeof ${constant.valuesName})[number];`\n ].join(\"\\n\"));\n planFile(plan, group[0].backendFile, `${backend.join(\"\\n\\n\")}\\n`, `values of ${legacy}`);\n const frontendFile = group[0].frontendFile;\n if (frontendFile) {\n const typeImport = `import type { ${group.map(constant => constant.typeName).join(\", \")} } from ${JSON.stringify(generatedSpecifier(frontendFile, group[0].backendFile, plan.specifierStyle))};`;\n const frontend = group.map(constant => [\n `/** What the panel calls each value of \\`${constant.legacyName}\\` (${legacy}); the values are the backend's. */`,\n `export const ${constant.labelsName}: Record<${constant.typeName}, string> = {`,\n Object.entries(constant.labels).map(([id, label]) => ` ${/^[A-Za-z_$][\\w$]*$/.test(id) ? id : JSON.stringify(id)}: ${printStringLiteral(label)}`).join(\",\\n\"),\n \"};\"\n ].join(\"\\n\"));\n planFile(plan, frontendFile, `${typeImport}\\n\\n${frontend.join(\"\\n\\n\")}\\n`, `labels of ${legacy}`);\n }\n // The tables that inlined the values name the constant instead.\n for (const [collectionFile, tableFile] of tableFiles) {\n const planned = plan.files.get(tableFile);\n if (!planned) continue;\n let content = planned.content;\n for (const constant of group) {\n if (!constant.importedBy.has(collectionFile)) continue;\n const printed = printedIds(constant);\n if (!content.includes(printed)) continue;\n content = content.split(printed).join(constant.valuesName);\n content = addImport(content, `import { ${constant.valuesName} } from ${JSON.stringify(generatedSpecifier(tableFile, constant.backendFile, plan.specifierStyle))};`);\n }\n if (content !== planned.content) plan.files.set(tableFile, { ...planned, content });\n }\n }\n}\n\n/** The constant whose labels a field's legacy `enum` restates, when one does. */\nexport function constantForEnum(constants: readonly SplitConstant[], collectionFile: string, values: unknown): SplitConstant | undefined {\n if (!Array.isArray(values)) return undefined;\n return constants.find(constant => constant.importedBy.has(collectionFile) &&\n constant.ids.length === values.length &&\n values.every((value, index) => isEnumEntry(value) && value.id === constant.ids[index] && value.label === constant.labels[String(value.id)]));\n}\n","/**\n * `frontend/src/cms/<table>.tsx`: a collection's presentation as\n * `customizeTable(...)`, written only when the collection had any.\n *\n * Everything the lift did not put in the table (`notCarried`) is presentation,\n * and goes here under its new name: the `admin` block (its keys renamed where\n * `customizeTable` renamed them), labels that differ from what the\n * zero-config CMS derives, enum labels and colours, conditions, browser-only\n * storage functions, relation overrides. Data is printed from the evaluated\n * value; a function — an entity action, a display resolver, a component — is\n * printed from its source, its imports carried, a lazy `() => import(\"…\")` or a\n * string path turned into a real import by value.\n *\n * A label equal to the derived one is dropped, so a migrated file states only\n * real deltas, and a collection whose presentation is entirely default gets no\n * file at all.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Node, Statement } from \"ts-morph\";\nimport type { LegacyEnumValues, LiftNote } from \"@rebasepro/common/migrate\";\nimport { enumValueLabel, labelFromIdentifier, singularLabel } from \"@rebasepro/utils\";\n\nimport type { Member, PathSegment } from \"./ast\";\nimport { collectReferences, memberOf, nodeAtPath, nodeText, postDeclarationAssignments, resolveObject, spreadSource, unwrap } from \"./ast\";\nimport { rewriteDynamicProps } from \"./dynamic-props\";\nimport { findLiteral } from \"./helper-hooks\";\nimport { memberFunctionText } from \"./hooks\";\nimport { constantForEnum } from \"./split-constants\";\nimport {\n COLLECTION_ADMIN_DESTINATIONS,\n KANBAN_DESTINATIONS,\n PROPERTY_ADMIN_DESTINATIONS,\n PROPERTY_FIELD_DESTINATIONS\n} from \"./vocabulary\";\nimport { generatedSpecifier, importLines, resolveRelative, type GeneratedSpecifierStyle } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { note, planFile, refuse, relativeToRoot } from \"./plan-context\";\nimport { printValue, RawSource } from \"./print-js\";\nimport type { TableName } from \"./backend\";\nimport { own } from \"./own\";\n\n/** The keys whose string value is a component path (the Vite plugin's `LAZY_COMPONENT_KEYS`). */\nexport const COMPONENT_KEYS = new Set([\"Field\", \"Preview\", \"Builder\", \"Filter\", \"Component\"]);\n\n/**\n * Said of every component the migration turns from a path into an import. One\n * sentence for all of them, so the notes group into one line.\n */\nexport const IMPORTED_COMPONENT_REMARK =\n \"is imported now rather than loaded by path, so the admin's type check reads it against its slot's props \" +\n \"(`FieldPreviewProps` for a Preview, `FieldProps` for a Field): a component that types `customProps` as its own \" +\n \"props type fails `tsc` until it takes `unknown` and narrows it inside.\";\n\n/** A customization module being built. */\ninterface Builder {\n entry: CollectionEntry;\n name: TableName;\n /** The module, absolute. */\n file: string;\n options: Record<string, unknown>;\n /** AST nodes whose source is printed: their references are carried. */\n codeNodes: Node[];\n /** Component imports: local → `import X from \"spec\"` / `import { X } from \"spec\"`. */\n componentImports: Map<string, { specifier: string; imported: string }>;\n /** Named imports of split constants' label modules: specifier → names. */\n libImports: Map<string, Set<string>>;\n failed: boolean;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** A value that is a React component or other code: a function, or an exotic component object. */\nfunction isCode(value: unknown): boolean {\n return typeof value === \"function\" || (typeof value === \"object\" && value !== null && \"$$typeof\" in value);\n}\n\n/** Parse a lift note's key (`content[text].images[]`) into legacy literal segments. */\nexport function noteKeySegments(key: string): { literal: PathSegment[]; field: string[] } {\n const literal: PathSegment[] = [\"properties\"];\n const field: string[] = [];\n const pattern = /([^.[\\]]+)|\\[\\]|\\[([^\\]]+)\\]|\\./g;\n let first = true;\n for (const match of key.matchAll(pattern)) {\n const [token, name, variant] = match;\n if (token === \".\") continue;\n if (name !== undefined) {\n if (!first) {\n literal.push(\"properties\");\n field.push(\"fields\");\n }\n literal.push(name);\n field.push(name);\n } else if (token === \"[]\") {\n literal.push(\"of\");\n field.push(\"of\");\n } else if (variant !== undefined) {\n literal.push(\"oneOf\", \"properties\", variant);\n field.push(\"oneOf\", variant);\n }\n first = false;\n }\n return { literal, field };\n}\n\n/** The last identifier of a note key: what the default label is derived from. */\nfunction lastKey(key: string): string {\n const names = [...key.matchAll(/([^.[\\]]+)/g)].map(match => match[1]);\n return names[names.length - 1] ?? key;\n}\n\n/** Read or create the nested object at `segments` under `root`. */\nfunction at(root: Record<string, unknown>, segments: readonly string[]): Record<string, unknown> {\n let current = root;\n for (const segment of segments) {\n const next = current[segment];\n if (isPlainObject(next)) {\n current = next;\n } else {\n const created: Record<string, unknown> = {};\n current[segment] = created;\n current = created;\n }\n }\n return current;\n}\n\n/** Find the member at `segments` of the collection literal (or what an assignment after it put there). */\nfunction locate(plan: PlanContext, entry: CollectionEntry, segments: readonly PathSegment[]): { member?: Member; reason?: string } {\n const site = entry.site;\n if (!site) return { reason: entry.siteProblem ?? \"the collection's literal was not found\" };\n const direct = nodeAtPath(plan.ast, site.literal, segments);\n if (direct.node) return { member: direct.node };\n if (site.binding) {\n const assignments = postDeclarationAssignments(plan.ast, entry.sourceFile, site.binding);\n for (let length = segments.length; length > 0; length--) {\n const prefix = segments.slice(0, length);\n if (prefix.some(segment => typeof segment === \"number\")) continue;\n const assigned = assignments.get(prefix.join(\".\"));\n if (!assigned) continue;\n const rest = segments.slice(length);\n if (rest.length === 0) return { member: { node: assigned.statement, value: assigned.value } };\n const object = resolveObject(plan.ast, assigned.value);\n if (!object.node) return { reason: object.reason };\n const nested = nodeAtPath(plan.ast, object.node, rest);\n return nested.node ? { member: nested.node } : { reason: nested.reason };\n }\n }\n return { reason: direct.reason };\n}\n\n/** A component's import name, from its module path: `../BodyPartsField` → `BodyPartsField`. */\nfunction componentName(specifier: string, taken: ReadonlySet<string>): string {\n const base = path.basename(specifier).replace(/\\.(tsx?|jsx?|mjs)$/, \"\");\n const stem = base === \"index\" ? path.basename(path.dirname(specifier)) : base;\n const pascal = stem.split(/[^A-Za-z0-9]+/).filter(Boolean).map(word => word[0].toUpperCase() + word.slice(1)).join(\"\") || \"Component\";\n const safe = /^[0-9]/.test(pascal) ? `C${pascal}` : pascal;\n let candidate = safe;\n let counter = 2;\n while (taken.has(candidate)) candidate = `${safe}${counter++}`;\n return candidate;\n}\n\n/** Turn a component path written in the collection file into an import in the customization module. */\nfunction importComponent(plan: PlanContext, builder: Builder, specifier: string, imported: string, writtenIn = builder.entry.file): RawSource {\n const moved = plan.relocator.relocate(specifier, writtenIn, builder.file, \"frontend\");\n for (const [local, existing] of builder.componentImports) {\n if (existing.specifier === moved && existing.imported === imported) return new RawSource(local);\n }\n const taken = new Set(builder.componentImports.keys());\n const local = componentName(imported === \"default\" ? moved : imported, taken);\n builder.componentImports.set(local, { specifier: moved, imported });\n return new RawSource(local);\n}\n\n/**\n * The module that wrote the component path `value`: the collection file when it\n * spells it, else the first module of the collection's relative imports (followed\n * a few levels: a shared helper's own imports) whose source holds it as a string\n * literal. A relative path is relative to the module that wrote it — a shared\n * module one directory away names the same component with another path.\n */\nfunction componentWriter(entry: CollectionEntry, value: string): string {\n const spells = (text: string): boolean => text.includes(`\"${value}\"`) || text.includes(`'${value}'`) || text.includes(`\\`${value}\\``);\n if (spells(entry.sourceFile.getFullText())) return entry.file;\n const seen = new Set<string>([entry.file]);\n let frontier = [entry.file];\n for (let depth = 0; depth < 4 && frontier.length > 0; depth++) {\n const next: string[] = [];\n for (const file of frontier) {\n const text = file === entry.file ? entry.sourceFile.getFullText() : fs.readFileSync(file, \"utf8\");\n for (const match of text.matchAll(/(?:from|import)\\s*\\(?\\s*[\"'](\\.{1,2}\\/[^\"']+)[\"']/g)) {\n const target = resolveRelative(file, match[1]).target;\n if (seen.has(target) || !fs.existsSync(target) || !fs.statSync(target).isFile()) continue;\n seen.add(target);\n if (spells(fs.readFileSync(target, \"utf8\"))) return target;\n next.push(target);\n }\n }\n frontier = next;\n }\n return entry.file;\n}\n\n/** A lazy component thunk — `() => import(\"…\")`, optionally `.then(m => m.X)` — as the import it stands for. */\nfunction lazyImport(plan: PlanContext, node: Node): { specifier: string; imported: string } | undefined {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const fn = unwrap(plan.ast, node);\n if (!N.isArrowFunction(fn) || fn.getParameters().length > 0) return undefined;\n let body: Node = unwrap(plan.ast, fn.getBody());\n let imported = \"default\";\n if (N.isCallExpression(body) && N.isPropertyAccessExpression(body.getExpression()) && body.getExpression().getText().endsWith(\".then\")) {\n const then = body.getArguments()[0];\n if (!then || !N.isArrowFunction(then)) return undefined;\n const parameter = then.getParameters()[0]?.getName();\n const result = unwrap(plan.ast, then.getBody());\n if (N.isPropertyAccessExpression(result) && result.getExpression().getText() === parameter) {\n imported = result.getName();\n } else if (N.isObjectLiteralExpression(result)) {\n const property = result.getProperty(\"default\");\n const initializer = property && N.isPropertyAssignment(property) ? unwrap(plan.ast, property.getInitializerOrThrow()) : undefined;\n if (!initializer || !N.isPropertyAccessExpression(initializer) || initializer.getExpression().getText() !== parameter) return undefined;\n imported = initializer.getName();\n } else {\n return undefined;\n }\n const target: Node = body.getExpression();\n if (!N.isPropertyAccessExpression(target)) return undefined;\n body = unwrap(plan.ast, target.getExpression());\n }\n if (!N.isCallExpression(body) || body.getExpression().getKind() !== SyntaxKind.ImportKeyword) return undefined;\n const argument = body.getArguments()[0];\n if (!argument || !N.isStringLiteral(argument)) return undefined;\n return { specifier: argument.getLiteralValue(), imported };\n}\n\n/** Calls whose result differs from one load to the next: a value computed with one is not data. */\nconst LOAD_TIME_CALLS = /\\bnew\\s+Date\\s*\\(\\s*\\)|\\bDate\\.now\\s*\\(|\\bMath\\.random\\s*\\(|\\bprocess\\.env\\b|\\bimport\\.meta\\.env\\b|\\bcrypto\\.randomUUID\\s*\\(|\\bperformance\\.now\\s*\\(/;\n\n/** How close to the run a date must be to count as the run's clock (a preset of \"today\" lands within hours of it). */\nconst RUN_CLOCK_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;\n\n/** Whether an evaluated value holds a date read from the clock while the codemod loaded the config. */\nfunction holdsRunClock(value: unknown, depth = 0): boolean {\n if (depth > 8) return false;\n const now = Date.now();\n const near = (time: number): boolean => Number.isFinite(time) && Math.abs(time - now) < RUN_CLOCK_WINDOW_MS;\n if (value instanceof Date) return near(value.getTime());\n if (typeof value === \"string\") return /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}/.test(value) && near(Date.parse(value));\n if (typeof value === \"number\") return value > 1e12 && near(value);\n if (Array.isArray(value)) return value.some(item => holdsRunClock(item, depth + 1));\n if (isPlainObject(value)) return Object.values(value).some(item => holdsRunClock(item, depth + 1));\n return false;\n}\n\n/** Whether an expression is written out as data (no call, no reference: what it evaluates to is what it says). */\nfunction isLiteralExpression(plan: PlanContext, node: Node): boolean {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const current = unwrap(plan.ast, node);\n if (N.isStringLiteral(current) || N.isNumericLiteral(current) || N.isNoSubstitutionTemplateLiteral(current) || N.isObjectLiteralExpression(current) || N.isArrayLiteralExpression(current)) return true;\n const kind = current.getKind();\n if (kind === SyntaxKind.TrueKeyword || kind === SyntaxKind.FalseKeyword || kind === SyntaxKind.NullKeyword) return true;\n if (N.isPrefixUnaryExpression(current)) return N.isNumericLiteral(current.getOperand());\n return N.isIdentifier(current) && current.getText() === \"undefined\";\n}\n\n/**\n * A data value the config COMPUTED when it was loaded — `new Date()`, `Date.now()`,\n * `Math.random()`, an environment read, or a helper that read the clock — is not\n * data: printed as evaluated it would be frozen to the codemod's run. Where the\n * expression that computed it is found in the collection's literal, it is carried\n * as that SOURCE (its imports with it); where it cannot be attributed, it is left\n * out and a step names it.\n *\n * @returns `handled` with what to print when this value is decided here;\n * otherwise whether its source was attributed (no need to look again below it)\n */\nfunction loadTimeValue(plan: PlanContext, builder: Builder, value: unknown, segments: PathSegment[], label: string): { handled: true; printed: unknown } | { handled: false; attributed: boolean } {\n if (segments.length === 0) return { handled: false, attributed: false };\n const located = locate(plan, builder.entry, segments);\n const member = located.member;\n if (member && !member.method) {\n const valueNode = member.value ?? member.node;\n if (isLiteralExpression(plan, valueNode)) return { handled: false, attributed: false };\n const source = nodeText(valueNode);\n if (!LOAD_TIME_CALLS.test(source) && !holdsRunClock(value)) return { handled: false, attributed: true };\n builder.codeNodes.push(member.node);\n note(plan, builder.entry, `${label} is computed when the config loads (\\`${source.length > 80 ? `${source.slice(0, 77)}…` : source}\\`): carried as that expression, not as the value it had during the migration. It now runs in the panel, when the customization module loads.`);\n return { handled: true, printed: new RawSource(source) };\n }\n if (!holdsRunClock(value) || Array.isArray(value) || isPlainObject(value)) return { handled: false, attributed: false };\n plan.manualSteps.push({\n title: `Write ${label} of ${builder.name.table} by hand`,\n detail: `${label} held ${JSON.stringify(value)} when the codemod loaded the config — a date read from the clock at load time, whose source cannot be attributed (${located.reason ?? \"it was computed\"}). It was left out rather than frozen to the run's time. Write the expression that computes it in ${relativeToRoot(plan, builder.file)} under the same key.`,\n file: relativeToRoot(plan, builder.file)\n });\n return { handled: true, printed: undefined };\n}\n\n/**\n * A value as something printable: data as itself, code from its source.\n *\n * @param segments where the value is in the legacy literal, for finding a function's source\n */\nfunction printable(plan: PlanContext, builder: Builder, value: unknown, segments: PathSegment[], label: string, attributed = false): unknown {\n if (!isCode(value) && !attributed && value !== undefined) {\n const computed = loadTimeValue(plan, builder, value, segments, label);\n if (computed.handled) return computed.printed;\n attributed = computed.attributed;\n }\n if (isCode(value)) {\n const located = locate(plan, builder.entry, segments);\n if (!located.member) {\n // Spread in from one shared object (`...fixedOnceCreated`): carried as that object's member, its import with it.\n const spread = builder.entry.site ? spreadSource(plan.ast, builder.entry.site.literal, segments) : undefined;\n if (spread) {\n builder.codeNodes.push(spread.spread);\n return new RawSource(spread.text);\n }\n // Presentation code whose source cannot be attributed (a wrapper's output,\n // a member before a spread): the evaluated data around it is printed, the\n // function is left out, and a step says where it was — a form rule, not a\n // reason to block the migration.\n plan.manualSteps.push({\n title: `Add ${label} of ${builder.name.table} by hand`,\n detail: `${label} is a function the collection computed (${located.reason}), so its source cannot be carried; the rest of the customization is printed from the evaluated collection. Write it in the table's customization (${relativeToRoot(plan, builder.file)} — \\`customizeTable\\`, created by hand if the run wrote none) under the same key, from the code that produced it.`,\n file: relativeToRoot(plan, builder.file)\n });\n return undefined;\n }\n const member = located.member;\n const valueNode = member.value ?? member.node;\n const lazy = member.method ? undefined : lazyImport(plan, valueNode);\n if (lazy) {\n try {\n return importComponent(plan, builder, lazy.specifier, lazy.imported);\n } catch (error) {\n refuse(plan, builder.entry, error instanceof Error ? error.message : String(error), { key: segments.join(\".\") });\n builder.failed = true;\n return undefined;\n }\n }\n builder.codeNodes.push(member.node);\n return new RawSource(memberFunctionText(plan.ast, member));\n }\n if (typeof value === \"string\" && COMPONENT_KEYS.has(String(segments[segments.length - 1])) && (value.startsWith(\"./\") || value.startsWith(\"../\"))) {\n try {\n const imported = importComponent(plan, builder, value, \"default\", componentWriter(builder.entry, value));\n // By path, the component was loaded and never type-checked against\n // its slot. As an import it is, by the admin's own `tsc`: SongBuzz's\n // previews typed `customProps` as their own props type, which no\n // slot can hand them, and 37 errors appeared in a build the\n // migration had reported clean.\n note(plan, builder.entry, `${label} ${IMPORTED_COMPONENT_REMARK}`);\n return imported;\n } catch (error) {\n refuse(plan, builder.entry, error instanceof Error ? error.message : String(error), { key: segments.join(\".\") });\n builder.failed = true;\n return undefined;\n }\n }\n if (Array.isArray(value)) return value.map((item, index) => printable(plan, builder, item, [...segments, index], `${label}[${index}]`, attributed));\n if (isPlainObject(value)) {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined) continue;\n out[key] = printable(plan, builder, entry, [...segments, key], `${label}.${key}`, attributed);\n }\n return out;\n }\n return value;\n}\n\n/** The enum labels a field needs: only values whose label or colour is not the derived one. */\nexport function enumLabelsOf(values: LegacyEnumValues): Record<string, unknown> | undefined {\n const entries: { id: string | number; label?: string; color?: unknown; disabled?: boolean }[] = Array.isArray(values)\n ? values.map(value => ({ ...value }))\n : Object.entries(values).map(([id, value]) => (typeof value === \"string\" ? { id, label: value } : { ...value, id }));\n const out: Record<string, unknown> = {};\n for (const entry of entries) {\n const label = entry.label ?? String(entry.id);\n const derived = enumValueLabel(entry.id);\n const extra: Record<string, unknown> = {};\n if (entry.color !== undefined) extra.color = entry.color;\n if (entry.disabled !== undefined) extra.disabled = entry.disabled;\n if (Object.keys(extra).length > 0) out[String(entry.id)] = { label, ...extra };\n else if (label !== derived) out[String(entry.id)] = label;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** A property's `admin` block as field-customization keys. */\nfunction fieldAdmin(plan: PlanContext, builder: Builder, admin: Record<string, unknown>, segments: PathSegment[], target: Record<string, unknown>, label: string): void {\n for (const [key, value] of Object.entries(admin)) {\n if (value === undefined) continue;\n const destination = own(PROPERTY_ADMIN_DESTINATIONS, key);\n if (destination === undefined) {\n note(plan, builder.entry, `${label}.admin.${key} is not an admin option (nothing read it); not carried.`);\n continue;\n }\n if (typeof destination !== \"string\") {\n note(plan, builder.entry, `${label}.admin.${key} is not carried: ${destination.dropped}`);\n continue;\n }\n const printed = printable(plan, builder, value, [...segments, \"admin\", key], `${label}.admin.${key}`);\n if (key === \"disabled\" && isPlainObject(value) && value.hidden === true) {\n target.hiddenInForm = true;\n const { hidden: _hidden, ...rest } = isPlainObject(printed) ? printed : {};\n void _hidden;\n if (Object.keys(rest).length > 0) target.disabled = rest;\n continue;\n }\n target[destination] = printed;\n }\n}\n\n/** The collection `admin` block as `customizeTable` keys. */\nfunction collectionAdmin(plan: PlanContext, builder: Builder, admin: Record<string, unknown>): void {\n const options = builder.options;\n for (const [key, value] of Object.entries(admin)) {\n if (value === undefined) continue;\n const destination = own(COLLECTION_ADMIN_DESTINATIONS, key);\n if (destination === undefined) {\n note(plan, builder.entry, `admin.${key} is not an admin option (nothing read it); not carried.`);\n continue;\n }\n if (typeof destination !== \"string\") {\n note(plan, builder.entry, `admin.${key} is not carried: ${destination.dropped}`);\n continue;\n }\n const printed = printable(plan, builder, value, [\"admin\", key], `admin.${key}`);\n if (destination.includes(\".\")) {\n const path_ = destination.split(\".\");\n at(options, path_.slice(0, -1))[path_[path_.length - 1]] = printed;\n continue;\n }\n if (key === \"kanban\" && isPlainObject(printed)) {\n const kanban = at(options, [\"kanban\"]);\n for (const [kanbanKey, kanbanValue] of Object.entries(printed)) {\n kanban[own(KANBAN_DESTINATIONS, kanbanKey) ?? kanbanKey] = kanbanValue;\n }\n continue;\n }\n if (key === \"form\" && isPlainObject(printed) && Array.isArray(printed.sections)) {\n options.form = {\n ...printed,\n sections: printed.sections.map(section => {\n if (!isPlainObject(section) || !(\"properties\" in section)) return section;\n const { properties, ...rest } = section;\n const ordered: Record<string, unknown> = {};\n for (const [sectionKey, sectionValue] of Object.entries({ ...rest, fields: properties })) {\n ordered[sectionKey] = sectionValue;\n }\n return ordered;\n })\n };\n continue;\n }\n options[destination] = printed;\n }\n const kanban = options.kanban;\n if (isPlainObject(kanban) && kanban.columnField === undefined) {\n delete options.kanban;\n note(plan, builder.entry, \"admin.orderProperty has no kanban board to order (no `kanban.columnProperty`); `customizeTable` keeps the order field on the board, so it is not carried.\");\n }\n}\n\n/** The relation-tab overrides of a relation, flattened as `customizeTable` options. */\nfunction relationOverrides(plan: PlanContext, builder: Builder, value: unknown, segments: PathSegment[], label: string): Record<string, unknown> | undefined {\n if (!isPlainObject(value)) return undefined;\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined) continue;\n if (key === \"admin\" && isPlainObject(entry)) {\n for (const [adminKey, adminValue] of Object.entries(entry)) {\n const destination = own(COLLECTION_ADMIN_DESTINATIONS, adminKey);\n if (typeof destination !== \"string\" || destination.includes(\".\")) {\n note(plan, builder.entry, `${label}.admin.${adminKey} has no relation-tab option in \\`customizeTable\\`; not carried.`);\n continue;\n }\n out[destination] = printable(plan, builder, adminValue, [...segments, \"admin\", adminKey], `${label}.admin.${adminKey}`);\n }\n continue;\n }\n if (key === \"name\" || key === \"singularName\" || key === \"description\" || key === \"metadata\" || key === \"icon\") {\n out[key] = printable(plan, builder, entry, [...segments, key], `${label}.${key}`);\n continue;\n }\n note(plan, builder.entry, `${label}.${key} has no relation-tab option in \\`customizeTable\\`; not carried.`);\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** Where a relation's `overrides` are in the legacy literal. */\nfunction relationSegments(entry: CollectionEntry, key: string): PathSegment[] {\n const relations = \"relations\" in entry.collection && Array.isArray(entry.collection.relations) ? entry.collection.relations : [];\n const index = relations.findIndex(relation => (relation.relationName ?? \"\") === key);\n if (index >= 0) return [\"relations\", index, \"overrides\"];\n const stripped = key.endsWith(\"Relation\") ? key.slice(0, -\"Relation\".length) : key;\n return [\"properties\", stripped, \"relation\", \"overrides\"];\n}\n\n/** Apply one property-level note to the field it is about. */\nfunction applyFieldNote(plan: PlanContext, builder: Builder, item: LiftNote, fields: Record<string, unknown>): void {\n const key = item.key ?? \"\";\n const { literal, field } = noteKeySegments(key);\n const label = `properties.${key}`;\n if (item.kind === \"inert\" || item.kind === \"redundant\" || item.kind === \"derived\" || item.kind === \"meaning\") return;\n if (item.kind === \"unknown\") {\n note(plan, builder.entry, `${label}.${item.field} is not a field of the property model (nothing read it); not carried.`);\n return;\n }\n if (item.kind === \"renamed\") {\n plan.manualSteps.push({\n title: `Relation renamed in ${builder.name.table}`,\n detail: item.reason,\n file: relativeToRoot(plan, builder.name.file)\n });\n return;\n }\n if (item.field === \"overrides\") {\n const overrides = relationOverrides(plan, builder, item.value, relationSegments(builder.entry, key), `relations.${key}.overrides`);\n if (overrides) at(fields, [key]).overrides = overrides;\n return;\n }\n const target = at(fields, field);\n switch (item.field) {\n case \"name\":\n if (typeof item.value === \"string\" && item.value !== labelFromIdentifier(lastKey(key))) target.name = item.value;\n return;\n case \"admin\":\n if (isPlainObject(item.value)) fieldAdmin(plan, builder, item.value, literal, target, label);\n return;\n case \"enum\": {\n const constant = constantForEnum(plan.splitConstants ?? [], builder.entry.file, item.value);\n if (constant?.frontendFile) {\n const specifier = generatedSpecifier(builder.file, constant.frontendFile, plan.specifierStyle);\n builder.libImports.set(specifier, new Set([...(builder.libImports.get(specifier) ?? []), constant.labelsName]));\n target.enumLabels = new RawSource(constant.labelsName);\n return;\n }\n const labels = enumLabelsOf(item.value as LegacyEnumValues);\n if (labels) target.enumLabels = labels;\n return;\n }\n case \"propertiesOrder\":\n target[String(PROPERTY_FIELD_DESTINATIONS.propertiesOrder)] = item.value;\n return;\n case \"defaultValue\": {\n // A relation's pre-fill: `new EntityRelation(…)` objects, which are\n // printed from their source (a class instance has no literal), its\n // imports carried.\n const located = locate(plan, builder.entry, [...literal, \"defaultValue\"]);\n if (!located.member) {\n note(plan, builder.entry, `${label}.defaultValue is not carried: its source could not be found (${located.reason ?? \"unknown\"}). Write it as \\`fields.${key}.defaultValue\\` in the customization.`);\n return;\n }\n builder.codeNodes.push(located.member.node);\n target.defaultValue = new RawSource(memberFunctionText(plan.ast, located.member));\n return;\n }\n case \"storage.storagePath\":\n at(target, [\"storage\"]).path = printable(plan, builder, item.value, [...literal, \"storage\", \"storagePath\"], `${label}.storage.storagePath`);\n return;\n case \"storage.processFile\":\n case \"storage.postProcess\":\n case \"storage.previewUrl\":\n case \"storage.fileName\": {\n const name = item.field.slice(\"storage.\".length);\n at(target, [\"storage\"])[name] = printable(plan, builder, item.value, [...literal, \"storage\", name], `${label}.storage.${name}`);\n return;\n }\n default:\n break;\n }\n const destination = own(PROPERTY_FIELD_DESTINATIONS, item.field);\n if (destination !== undefined && typeof destination !== \"string\") {\n note(plan, builder.entry, `${label}.${item.field} is not carried: ${destination.dropped}`);\n return;\n }\n if (destination !== undefined) {\n target[destination] = printable(plan, builder, item.value, [...literal, item.field], `${label}.${item.field}`);\n if (item.field === \"dynamicProps\" && target[destination] !== undefined && flattenDynamicProps(plan, builder, target, destination, [...literal, item.field])) return;\n if (item.field === \"dynamicProps\" && target[destination] !== undefined) {\n plan.manualSteps.push({\n title: `Check fields.${key}.dynamicProps of ${builder.name.table}`,\n detail: \"`dynamicProps` returns a field customization now (flat keys: `hidden`, `fieldOrder`, …), not a partial property with an `admin` block. Check what it returns.\",\n file: relativeToRoot(plan, builder.file)\n });\n }\n return;\n }\n note(plan, builder.entry, `${label}.${item.field}: ${item.reason} \\`customizeTable\\` has no option for it; not carried.`);\n}\n\n/**\n * A `dynamicProps` builder carried into a customization, its returns rewritten\n * to 0.31's flat shape (see `dynamic-props.ts`): in the printed function when\n * it was written inline, in the defining module (its copy, or in place) when\n * it came from a spread of a shared object. True when nothing is left to\n * check by hand.\n */\nfunction flattenDynamicProps(plan: PlanContext, builder: Builder, target: Record<string, unknown>, destination: string, segments: PathSegment[]): boolean {\n const { Node: N } = plan.ast.tsm;\n const printed = target[destination];\n if (!(printed instanceof RawSource)) return false;\n const located = locate(plan, builder.entry, segments);\n if (located.member) {\n // Written inline: rewrite the printed text (a scratch file of it, so a `const` it reads is not in scope and refuses).\n const scratch = plan.ast.project.createSourceFile(`/__rebase_migrate__/dynamic-props-${builder.name.identifier}.ts`, `const __builder = ${printed.text};`, { overwrite: true });\n try {\n const fn = unwrap(plan.ast, scratch.getVariableDeclarationOrThrow(\"__builder\").getInitializerOrThrow());\n const rewrite = rewriteDynamicProps(plan.ast, fn, scratch, [fn]);\n if (!rewrite.edits) return false;\n const offset = \"const __builder = \".length;\n let text = printed.text;\n for (const edit of [...rewrite.edits].sort((a, b) => b.start - a.start)) text = text.slice(0, edit.start - offset) + edit.text + text.slice(edit.end - offset);\n target[destination] = new RawSource(text);\n return true;\n } finally {\n plan.ast.project.removeSourceFile(scratch);\n }\n }\n const spread = builder.entry.site ? spreadSource(plan.ast, builder.entry.site.literal, segments) : undefined;\n if (!spread) return false;\n const owner = findLiteral(plan, spread.spread);\n if (!owner.literal) return false;\n const member = memberOf(plan.ast, owner.literal, \"dynamicProps\");\n const fn = member.node ? (member.node.method ?? (member.node.value ? unwrap(plan.ast, member.node.value) : undefined)) : undefined;\n if (!fn || !(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isMethodDeclaration(fn))) return false;\n const sf = fn.getSourceFile();\n const rewrite = rewriteDynamicProps(plan.ast, fn, sf);\n if (!rewrite.edits) return false;\n if (rewrite.edits.length > 0) {\n plan.relocator.addSourceEdits(sf.getFilePath(), rewrite.edits);\n if (!plan.relocator.isInCollections(sf.getFilePath())) plan.relocator.keptFrontendModules.add(sf.getFilePath());\n }\n return true;\n}\n\n/**\n * `auth.actions` of an auth collection: `resetPassword: false` takes the\n * panel's reset-password action away, an action replaces it — both\n * `customizeTable`'s `resetPasswordAction` now. `true` is the default.\n */\nfunction authActions(plan: PlanContext, builder: Builder, value: unknown): void {\n if (!isPlainObject(value)) {\n note(plan, builder.entry, \"auth.actions is not an object of actions; not carried.\");\n return;\n }\n for (const [key, entry] of Object.entries(value)) {\n if (key !== \"resetPassword\") {\n note(plan, builder.entry, `auth.actions.${key} is not an auth action (nothing read it); not carried.`);\n continue;\n }\n if (entry === undefined || entry === true) continue;\n builder.options.resetPasswordAction = entry === false\n ? false\n : printable(plan, builder, entry, [\"auth\", \"actions\", \"resetPassword\"], \"auth.actions.resetPassword\");\n }\n}\n\n/** Apply one collection-level note. */\nfunction applyCollectionNote(plan: PlanContext, builder: Builder, item: LiftNote): void {\n const options = builder.options;\n const derivedName = labelFromIdentifier(builder.name.table);\n switch (item.field) {\n case \"name\":\n if (typeof item.value === \"string\" && item.value !== derivedName) options.name = item.value;\n return;\n case \"singularName\":\n if (typeof item.value === \"string\" && item.value !== singularLabel(derivedName)) options.singularName = item.value;\n return;\n case \"icon\":\n options.icon = printable(plan, builder, item.value, [\"icon\"], \"icon\");\n return;\n case \"admin\":\n if (isPlainObject(item.value)) collectionAdmin(plan, builder, item.value);\n return;\n case \"ownerId\":\n return;\n case \"auth.actions\":\n authActions(plan, builder, item.value);\n return;\n case \"childCollections\":\n plan.manualSteps.push({\n title: `Child collections of ${builder.name.table}`,\n detail: \"`childCollections` has no `customizeTable` equivalent. A table's `rel.hasMany` / `rel.manyToMany` relations are shown as tabs on its records: declare the relation on the table instead.\",\n file: relativeToRoot(plan, builder.entry.file)\n });\n return;\n default:\n break;\n }\n if (item.kind === \"inert\" || item.kind === \"redundant\" || item.kind === \"derived\" || item.kind === \"meaning\") return;\n if (item.kind === \"unknown\") {\n note(plan, builder.entry, `${item.field} is not a field of the collection model (nothing read it); not carried.`);\n return;\n }\n note(plan, builder.entry, `${item.field}: ${item.reason} \\`customizeTable\\` has no option for it; not carried.`);\n}\n\n/** The order the customization's top-level keys are written in. */\nconst OPTION_ORDER = [\"name\", \"singularName\", \"description\", \"icon\", \"group\"];\n\nfunction orderedOptions(options: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key of OPTION_ORDER) if (options[key] !== undefined) out[key] = options[key];\n for (const [key, value] of Object.entries(options)) if (key !== \"fields\" && out[key] === undefined && value !== undefined) out[key] = value;\n if (isPlainObject(options.fields) && Object.keys(options.fields).length > 0) out.fields = options.fields;\n return out;\n}\n\n/** Remove empty objects a note path created without filling. */\nfunction prune(value: unknown): unknown {\n if (!isPlainObject(value)) return value;\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const pruned = prune(entry);\n if (pruned === undefined || (isPlainObject(pruned) && Object.keys(pruned).length === 0)) continue;\n out[key] = pruned;\n }\n return out;\n}\n\n/**\n * The relations the lift renamed in one collection, old key → new key: a\n * belongsTo that served its foreign key under its own key is `<key>Relation`\n * now, and the column keeps the key.\n */\nfunction relationRenames(notes: readonly LiftNote[], slug: string): Map<string, string> {\n const out = new Map<string, string>();\n for (const item of notes) {\n if (item.collection !== slug || item.kind !== \"renamed\" || item.key === undefined) continue;\n out.set(item.key, `${String(item.value)}Relation`);\n }\n return out;\n}\n\n/** The presentation options that name fields by key, as lists. */\nconst FIELD_LIST_OPTIONS = [\"listFields\", \"previewFields\", \"fieldOrder\"] as const;\n\n/**\n * Point the presentation of a renamed relation at its new key.\n *\n * The panel draws the relation in the column's place (the projection replaces\n * a belongsTo's foreign-key column with the relation), so a customization that\n * still names the column's key labels, lists and titles a field the panel does\n * not have: every entry is skipped with a development warning. What the\n * legacy property said — its name, its column in the list, the title it gave\n * the record — is said of the relation.\n */\nfunction renameRelationKeys(options: Record<string, unknown>, renames: ReadonlyMap<string, string>): void {\n if (renames.size === 0) return;\n const renameList = (value: unknown): unknown =>\n Array.isArray(value) ? value.map(entry => (typeof entry === \"string\" ? renames.get(entry) ?? entry : entry)) : value;\n const fields = options.fields;\n if (isPlainObject(fields)) {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(fields)) {\n const renamed = renames.get(key);\n out[renamed !== undefined && !(renamed in fields) ? renamed : key] = value;\n }\n options.fields = out;\n }\n for (const key of FIELD_LIST_OPTIONS) if (options[key] !== undefined) options[key] = renameList(options[key]);\n const display = options.display;\n if (isPlainObject(display)) {\n for (const [slot, source] of Object.entries(display)) {\n if (typeof source === \"string\" && renames.has(source)) display[slot] = renames.get(source);\n }\n }\n const form = options.form;\n if (isPlainObject(form)) {\n if (form.sidebar !== undefined) form.sidebar = renameList(form.sidebar);\n if (Array.isArray(form.sections)) {\n for (const section of form.sections) if (isPlainObject(section) && section.fields !== undefined) section.fields = renameList(section.fields);\n }\n }\n}\n\n/** What {@link planCustomizations} wrote, for the index and `App.tsx`. */\nexport interface CustomizationOutput {\n /** The exported identifier and module of each customization, in the order given. */\n modules: { identifier: string; file: string; slug: string }[];\n}\n\n/**\n * Plan one `customizeTable` module per collection with non-default\n * presentation.\n *\n * @param notes the lift's `notCarried`\n * @param cmsDir `frontend/src/cms`, absolute\n */\nexport function planCustomizations(\n plan: PlanContext,\n entries: readonly CollectionEntry[],\n names: ReadonlyMap<string, TableName>,\n notes: readonly LiftNote[],\n cmsDir: string\n): CustomizationOutput {\n const modules: CustomizationOutput[\"modules\"] = [];\n for (const entry of entries) {\n const name = names.get(entry.collection.slug);\n if (!name) continue;\n const file = path.join(cmsDir, `${path.basename(name.file, \".ts\")}.tsx`);\n const builder: Builder = { entry, name, file, options: {}, codeNodes: [], componentImports: new Map(), libImports: new Map(), failed: false };\n const fields: Record<string, unknown> = {};\n for (const item of notes) {\n if (item.collection !== entry.collection.slug) continue;\n if (item.key === undefined) applyCollectionNote(plan, builder, item);\n else applyFieldNote(plan, builder, item, fields);\n }\n builder.options.fields = prune(fields);\n renameRelationKeys(builder.options, relationRenames(notes, entry.collection.slug));\n const options = orderedOptions(prune(builder.options) as Record<string, unknown>);\n if (builder.failed || Object.keys(options).length === 0) continue;\n const content = printModule(plan, builder, options);\n if (content === undefined) continue;\n planFile(plan, file, content, `customization ${name.table}`);\n modules.push({ identifier: `${name.identifier}Cms`, file, slug: entry.collection.slug });\n }\n return { modules };\n}\n\nfunction printModule(plan: PlanContext, builder: Builder, options: Record<string, unknown>): string | undefined {\n const { entry, name, file } = builder;\n const exclude: Statement[] = entry.site ? entry.site.statements : [];\n const references = collectReferences(plan.ast, builder.codeNodes, exclude);\n if (references.forbidden.length > 0) {\n for (const forbidden of references.forbidden) {\n refuse(plan, entry, `presentation code references \\`${forbidden.name}\\`, the collection itself, which does not exist after the migration.`, { line: forbidden.line });\n }\n return undefined;\n }\n const identifier = `${name.identifier}Cms`;\n const taken = new Set([\"customizeTable\", name.identifier, identifier, ...builder.componentImports.keys()]);\n const clashes = references.imports.map(use => use.local).filter(local => taken.has(local));\n if (clashes.length > 0) {\n refuse(plan, entry, `presentation code binds ${clashes.map(clash => `\\`${clash}\\``).join(\", \")}, which the customization module also binds. Rename it and run the codemod again.`);\n return undefined;\n }\n let carriedImports: string[];\n let statements: string[];\n try {\n carriedImports = importLines(references.imports, use => plan.relocator.relocate(use.specifier, use.fromFile, file, \"frontend\"));\n statements = references.statements.map(statement => {\n const text = nodeText(statement);\n return text.includes(\"import(\") ? plan.relocator.moveSpecifiersInText(text, entry.file, file, \"frontend\") : text;\n });\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return undefined;\n }\n const componentLines = [...builder.componentImports].map(([local, { specifier, imported }]) =>\n imported === \"default\" ? `import ${local} from ${JSON.stringify(specifier)};` : `import { ${imported === local ? local : `${imported} as ${local}`} } from ${JSON.stringify(specifier)};`);\n const imports = [\n `import { customizeTable } from \"@rebasepro/cms\";`,\n `import type { ${name.identifier} } from ${JSON.stringify(generatedSpecifier(file, name.file, plan.specifierStyle))};`,\n ...componentLines,\n ...[...builder.libImports].map(([specifier, imported]) => `import { ${[...imported].join(\", \")} } from ${JSON.stringify(specifier)};`),\n ...carriedImports\n ];\n // A column list naming an additional field: the key is branded, as the type asks\n // (`\"score\" as AdditionalFieldKey` — a bare string is not a column id).\n if (brandAdditionalFieldKeys(options)) imports.push(`import type { AdditionalFieldKey } from \"@rebasepro/cms-types\";`);\n let body: string;\n try {\n body = printValue(options, \"\", \"options\");\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return undefined;\n }\n const call = `export const ${identifier} = customizeTable<typeof ${name.identifier}>(${JSON.stringify(entry.collection.slug)}, ${body});`;\n return `${[imports.join(\"\\n\"), ...statements, call].join(\"\\n\\n\")}\\n`;\n}\n\n/**\n * Brand the entries of `fieldOrder` / `listFields` that name one of the\n * customization's `additionalFields`: `TableColumnId` accepts a field path, a\n * relation tab, or an `AdditionalFieldKey`, and the key's documented spelling is\n * `\"key\" as AdditionalFieldKey` (the brand is required, so a typo does not pass).\n *\n * @returns whether any entry was branded (the module then imports the type)\n */\nexport function brandAdditionalFieldKeys(options: Record<string, unknown>): boolean {\n const fields = options.additionalFields;\n const keys = new Set((Array.isArray(fields) ? fields : []).flatMap(field => (isPlainObject(field) && typeof field.key === \"string\" ? [field.key] : [])));\n if (keys.size === 0) return false;\n let branded = false;\n for (const list of [\"fieldOrder\", \"listFields\"]) {\n const value = options[list];\n if (!Array.isArray(value)) continue;\n options[list] = value.map(item => {\n if (typeof item !== \"string\" || !keys.has(item)) return item;\n branded = true;\n return new RawSource(`${JSON.stringify(item)} as AdditionalFieldKey`);\n });\n }\n return branded;\n}\n\n/** `frontend/src/cms/index.ts`: the customizations in navigation order, and the external collections. */\nexport function printCmsIndex(\n cmsDir: string,\n customizations: readonly { identifier: string; file: string }[],\n external: readonly { identifier: string; file: string }[],\n style: GeneratedSpecifierStyle\n): string {\n const lines: string[] = [];\n const indexFile = path.join(cmsDir, \"index.ts\");\n const specifier = (file: string): string => JSON.stringify(generatedSpecifier(indexFile, file, style));\n for (const module of customizations) lines.push(`import { ${module.identifier} } from ${specifier(module.file)};`);\n // A Firestore collection file keeps its default export, as it was written.\n for (const module of external) lines.push(`import ${module.identifier} from ${specifier(module.file)};`);\n if (lines.length > 0) lines.push(\"\");\n lines.push(\"/** The table customizations, in the order the panel lists them. */\");\n lines.push(`export const tableCustomizations = [${customizations.map(module => module.identifier).join(\", \")}];`);\n if (external.length > 0) {\n lines.push(\"\");\n lines.push(\"/** Collections whose rows live outside the Postgres backend. */\");\n lines.push(`export const externalCollections = [${external.map(module => module.identifier).join(\", \")}];`);\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * `engine: \"firestore\"` collections → `defineFirestoreCollection(...)` in the\n * CMS (`frontend/src/cms/<name>.ts`).\n *\n * A Firestore collection is not a table, so nothing is lifted: the file is\n * moved and rewritten in place, which keeps every function, comment and\n * import exactly as written. What changes is the shape `@rebasepro/firebase`\n * takes — `properties` is `fields`, a reference names its collection with\n * `target` instead of `path`, there is no `engine` — and the wrapper\n * (`defineFirestoreCollection` instead of `defineCollection` or a typed\n * literal).\n */\nimport path from \"node:path\";\nimport type { Node, ObjectLiteralExpression, SourceFile } from \"ts-morph\";\n\nimport { findCollectionSite, memberOf, resolveArray, resolveObject } from \"./ast\";\nimport { COMPONENT_KEYS } from \"./customization\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { planFile, refuse, relativeToRoot } from \"./plan-context\";\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n}\n\n/**\n * Rename `path` → `target` on every reference field of a literal fields map, recursively.\n * `renamed` collects the key path of each reference renamed (`store`, `lines.of.product`).\n */\nfunction referenceEdits(plan: PlanContext, fields: ObjectLiteralExpression, edits: Edit[], renamed: Set<string>, prefix = \"\"): void {\n const { Node: N } = plan.ast.tsm;\n for (const member of fields.getProperties()) {\n if (!N.isPropertyAssignment(member)) continue;\n const field = resolveObject(plan.ast, member.getInitializer()).node;\n if (!field || field.getSourceFile() !== fields.getSourceFile()) continue;\n visitField(plan, field, edits, renamed, `${prefix}${member.getName().replace(/^[\"']|[\"']$/g, \"\")}`);\n }\n}\n\nfunction visitField(plan: PlanContext, field: ObjectLiteralExpression, edits: Edit[], renamed: Set<string>, key: string): void {\n const { Node: N } = plan.ast.tsm;\n const type = memberOf(plan.ast, field, \"type\").node?.value;\n const typeText = type && N.isStringLiteral(type) ? type.getLiteralValue() : undefined;\n if (typeText === \"reference\") {\n const pathMember = memberOf(plan.ast, field, \"path\").node;\n if (pathMember && N.isPropertyAssignment(pathMember.node)) {\n const nameNode = pathMember.node.getNameNode();\n edits.push({ start: nameNode.getStart(), end: nameNode.getEnd(), text: \"target\" });\n renamed.add(key);\n }\n }\n for (const nested of [\"properties\", \"of\"] as const) {\n const value = memberOf(plan.ast, field, nested).node?.value;\n const object = value ? resolveObject(plan.ast, value).node : undefined;\n if (!object || object.getSourceFile() !== field.getSourceFile()) continue;\n if (nested === \"properties\") referenceEdits(plan, object, edits, renamed, `${key}.`);\n else visitField(plan, object, edits, renamed, `${key}.of`);\n }\n const oneOf = memberOf(plan.ast, field, \"oneOf\").node?.value;\n const oneOfObject = oneOf ? resolveObject(plan.ast, oneOf).node : undefined;\n const variants = oneOfObject ? memberOf(plan.ast, oneOfObject, \"properties\").node?.value : undefined;\n const variantsObject = variants ? resolveObject(plan.ast, variants).node : undefined;\n if (variantsObject) referenceEdits(plan, variantsObject, edits, renamed, `${key}.oneOf.`);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Every reference field of the EVALUATED collection that still sets `path`,\n * by key path (the same paths {@link referenceEdits} records), with the path.\n */\nfunction evaluatedReferences(properties: unknown, prefix = \"\", out = new Map<string, string>()): Map<string, string> {\n if (!isRecord(properties)) return out;\n for (const [name, field] of Object.entries(properties)) visitEvaluated(field, `${prefix}${name}`, out);\n return out;\n}\n\nfunction visitEvaluated(field: unknown, key: string, out: Map<string, string>): void {\n if (!isRecord(field)) return;\n if (field.type === \"reference\" && \"path\" in field) out.set(key, String(field.path));\n evaluatedReferences(field.properties, `${key}.`, out);\n visitEvaluated(field.of, `${key}.of`, out);\n if (isRecord(field.oneOf)) evaluatedReferences(field.oneOf.properties, `${key}.oneOf.`, out);\n}\n\n/** Marks the edits of {@link brandAdditionalFieldEntries}, so the module imports the type. */\nconst BRANDED = \" as AdditionalFieldKey\";\n\n/**\n * `propertiesOrder` / `listProperties` entries naming one of the collection's\n * `additionalFields`: written `\"key\" as AdditionalFieldKey`, the spelling\n * `ColumnKey` requires of a key that is not a property (a bare string does not\n * type-check under `defineFirestoreCollection`).\n */\nfunction brandAdditionalFieldEntries(plan: PlanContext, entry: CollectionEntry, literal: ObjectLiteralExpression, edits: Edit[]): void {\n const { Node: N } = plan.ast.tsm;\n const collection: unknown = entry.collection;\n const admin: unknown = isRecord(collection) ? collection.admin : undefined;\n const fields: unknown = (isRecord(collection) ? collection.additionalFields : undefined) ?? (isRecord(admin) ? admin.additionalFields : undefined);\n const keys = new Set((Array.isArray(fields) ? fields : []).flatMap((field: unknown) => (isRecord(field) && typeof field.key === \"string\" ? [field.key] : [])));\n if (keys.size === 0) return;\n const holders: ObjectLiteralExpression[] = [literal];\n const adminValue = memberOf(plan.ast, literal, \"admin\").node?.value;\n const adminObject = adminValue ? resolveObject(plan.ast, adminValue).node : undefined;\n if (adminObject && adminObject.getSourceFile() === literal.getSourceFile()) holders.push(adminObject);\n for (const holder of holders) {\n for (const name of [\"propertiesOrder\", \"listProperties\"]) {\n const value = memberOf(plan.ast, holder, name).node?.value;\n const array = value ? resolveArray(plan.ast, value).node : undefined;\n if (!array || array.getSourceFile() !== literal.getSourceFile()) continue;\n for (const element of array.getElements()) {\n if (!N.isStringLiteral(element) || !keys.has(element.getLiteralValue())) continue;\n edits.push({ start: element.getEnd(), end: element.getEnd(), text: BRANDED });\n }\n }\n }\n}\n\n/** The edits that turn the collection literal into `defineFirestoreCollection`'s argument and wrap it. */\nfunction literalEdits(plan: PlanContext, sf: SourceFile, entry: CollectionEntry, destination: string): Edit[] | undefined {\n const { Node: N } = plan.ast.tsm;\n const site = findCollectionSite(plan.ast, sf);\n if (!site.node) {\n refuse(plan, entry, `is a Firestore collection whose literal the codemod cannot find: ${site.reason}.`);\n return undefined;\n }\n const literal = site.node.literal;\n const edits: Edit[] = [];\n for (const member of literal.getProperties()) {\n if (N.isSpreadAssignment(member)) {\n refuse(plan, entry, `is a Firestore collection whose literal spreads \\`${member.getExpression().getText()}\\` (line ${member.getStartLineNumber()}); its \\`properties\\` and \\`engine\\` cannot be rewritten through a spread. Write them in the literal.`);\n return undefined;\n }\n }\n const engine = memberOf(plan.ast, literal, \"engine\").node;\n if (engine) {\n const node = engine.node;\n const text = sf.getFullText();\n let end = node.getEnd();\n if (text[end] === \",\") end += 1;\n const start = node.getFullStart();\n edits.push({ start, end, text: \"\" });\n }\n const properties = memberOf(plan.ast, literal, \"properties\").node;\n if (!properties) {\n refuse(plan, entry, \"is a Firestore collection with no `properties` the codemod can read.\");\n return undefined;\n }\n if (N.isPropertyAssignment(properties.node)) {\n const nameNode = properties.node.getNameNode();\n edits.push({ start: nameNode.getStart(), end: nameNode.getEnd(), text: \"fields\" });\n } else if (N.isShorthandPropertyAssignment(properties.node)) {\n edits.push({ start: properties.node.getStart(), end: properties.node.getEnd(), text: `fields: ${properties.node.getText()}` });\n }\n const fields = resolveObject(plan.ast, properties.value).node;\n const renamed = new Set<string>();\n if (fields && fields.getSourceFile() === sf) referenceEdits(plan, fields, edits, renamed);\n // A reference written outside the literal (a shared module, a helper's return\n // value, a spread of another collection's properties) is not renamed here, and\n // `defineFirestoreCollection` throws at import on its `path`: name each one.\n const outside = [...evaluatedReferences(entry.collection.properties)].filter(([key]) => !renamed.has(key));\n if (outside.length > 0) {\n plan.manualSteps.push({\n title: `Rename path → target in the references of ${entry.collection.slug} written outside its literal`,\n detail: `\\`defineFirestoreCollection\\` throws at import on a reference field that sets \\`path\\` (\"sets \\`path\\`… write target instead\"). ` +\n `These reference fields of ${entry.collection.slug} come from outside the collection's literal — a shared module, a helper's return value, or a spread of another collection's \\`properties\\` — so the codemod did not rename them: ` +\n outside.map(([key, target]) => `fields.${key} (path \"${target}\")`).join(\", \") +\n \". Rename `path` → `target` where each is written. A value read from another converted collection's `properties` is the run-time shape, which carries `path`: spread that collection's `fields` (export them) instead.\",\n file: relativeToRoot(plan, destination)\n });\n }\n\n brandAdditionalFieldEntries(plan, entry, literal, edits);\n\n // The wrapper.\n let parent: Node | undefined = literal.getParent();\n while (parent && (N.isAsExpression(parent) || N.isSatisfiesExpression(parent) || N.isParenthesizedExpression(parent))) parent = parent.getParent();\n if (parent && N.isCallExpression(parent)) {\n const callee = parent.getExpression();\n edits.push({ start: callee.getStart(), end: callee.getEnd(), text: \"defineFirestoreCollection\" });\n const typeArguments = parent.getTypeArguments();\n if (typeArguments.length > 0) {\n const first = typeArguments[0];\n const last = typeArguments[typeArguments.length - 1];\n edits.push({ start: first.getStart() - 1, end: last.getEnd() + 1, text: \"\" });\n }\n } else {\n edits.push({ start: literal.getStart(), end: literal.getStart(), text: \"defineFirestoreCollection(\" });\n edits.push({ start: literal.getEnd(), end: literal.getEnd(), text: \")\" });\n if (parent && N.isVariableDeclaration(parent)) {\n const typeNode = parent.getTypeNode();\n if (typeNode) edits.push({ start: parent.getNameNode().getEnd(), end: typeNode.getEnd(), text: \"\" });\n }\n }\n return edits;\n}\n\n/**\n * Plan the move of one Firestore collection file.\n *\n * @param destination where the module goes; `<cmsDir>/<file name>` by default\n * @returns the new module and the identifier its default export can be imported as\n */\nexport function planFirestoreCollection(plan: PlanContext, entry: CollectionEntry, cmsDir: string, destination = path.join(cmsDir, path.basename(entry.file))): { file: string; identifier: string } | undefined {\n const text = entry.sourceFile.getFullText();\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/firestore-${path.basename(entry.file)}`, text, { overwrite: true });\n try {\n const edits = literalEdits(plan, sf, entry, destination);\n if (!edits) return undefined;\n const { Node: N } = plan.ast.tsm;\n // Drop `defineCollection` from its import, and import the new wrapper.\n for (const declaration of sf.getImportDeclarations()) {\n for (const specifier of declaration.getNamedImports()) {\n if (specifier.getName() !== \"defineCollection\") continue;\n const named = declaration.getNamedImports();\n if (named.length === 1 && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) {\n // The statement and its line break; its leading comments stay (they may be the file's header).\n const end = sf.getFullText()[declaration.getEnd()] === \"\\n\" ? declaration.getEnd() + 1 : declaration.getEnd();\n edits.push({ start: declaration.getStart(), end, text: \"\" });\n } else {\n const end = sf.getFullText()[specifier.getEnd()] === \",\" ? specifier.getEnd() + 1 : specifier.getEnd();\n edits.push({ start: specifier.getStart(), end, text: \"\" });\n }\n }\n }\n // A component named by its module path (`Field: \"../../src/X\"`, which 0.30's Vite plugin\n // loaded lazily) is imported by value: 0.31 takes the component itself.\n const componentImports = new Map<string, string>();\n const taken = new Set(sf.getDescendantsOfKind(plan.ast.tsm.SyntaxKind.Identifier).map(identifier => identifier.getText()));\n for (const literal of sf.getDescendantsOfKind(plan.ast.tsm.SyntaxKind.StringLiteral)) {\n // `Field: \"../X\"`, or the same path cast to the any type (how 0.30 code got a path past the component type).\n const written: Node = N.isAsExpression(literal.getParent()) ? literal.getParentOrThrow() : literal;\n const parent = written.getParent();\n if (!N.isPropertyAssignment(parent) || parent.getInitializer() !== written || !COMPONENT_KEYS.has(parent.getName())) continue;\n const value = literal.getLiteralValue();\n if (!value.startsWith(\"./\") && !value.startsWith(\"../\")) continue;\n let local = componentImports.get(value);\n if (!local) {\n const stem = path.basename(value).replace(/\\.(tsx?|jsx?)$/, \"\");\n const base = stem.split(/[^A-Za-z0-9]+/).filter(Boolean).map(word => word[0].toUpperCase() + word.slice(1)).join(\"\") || \"Component\";\n local = base;\n for (let counter = 2; taken.has(local); counter++) local = `${base}${counter}`;\n taken.add(local);\n componentImports.set(value, local);\n }\n edits.push({ start: written.getStart(), end: written.getEnd(), text: local });\n }\n const imports = sf.getImportDeclarations();\n const insertAt = imports.length > 0 ? imports[0].getStart() : 0;\n const componentLines = [...componentImports].map(([specifier, local]) => `import ${local} from ${JSON.stringify(specifier)};\\n`).join(\"\");\n const brandImport = edits.some(edit => edit.text === BRANDED) ? `import type { AdditionalFieldKey } from \"@rebasepro/cms-types\";\\n` : \"\";\n edits.push({ start: insertAt, end: insertAt, text: `import { defineFirestoreCollection } from \"@rebasepro/firebase\";\\n${brandImport}${componentLines}` });\n let out = text;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n out = plan.relocator.moveSpecifiersInText(out, entry.file, destination, \"frontend\");\n planFile(plan, destination, out, `firestore collection ${entry.collection.slug}`);\n const site = findCollectionSite(plan.ast, entry.sourceFile);\n const binding = site.node?.binding;\n return { file: destination, identifier: binding ?? `${entry.collection.slug.replace(/[^A-Za-z0-9]+(.)?/g, (_, next: string | undefined) => (next ?? \"\").toUpperCase())}Collection` };\n } catch (error) {\n refuse(plan, entry, error instanceof Error ? error.message : String(error));\n return undefined;\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n}\n","/**\n * What changed in 0.31 beyond the kernel moves, in the spellings a project's\n * own code can hold: exports renamed or removed outside `@rebasepro/types` /\n * `@rebasepro/common`, call options, environment variables, route paths, tool\n * names. `rebase migrate sdk-calls` reads it (`moved-imports.ts`).\n *\n * The kernel moves are not here: they are generated from the headless guard's\n * JSON into `moved-symbols.generated.ts`, and a row there wins over a row here\n * for the same name and package.\n *\n * - A row of {@link EXPORT_CHANGES} with `to` set is rewritten: the meaning is\n * the same and only the spelling (or the package) changed.\n * - A row with `to: null` is not rewritten — the export is gone, or it still\n * exists but takes or returns something different — so the codemod finds\n * the import and prints a manual step with `instead` and the upgrade-guide\n * section.\n * - {@link CALL_OPTION_CHANGES} and {@link CODE_SPELLINGS} are detected the\n * same way, never rewritten.\n *\n * The list is the diff of every package's root exports between 0.30.1 and\n * this release, and the upgrade guide's sections; the coverage of each\n * Breaking entry is recorded in the slice notes. The test\n * (`moved-imports.test.ts`) holds every renamed name to an export of its\n * package today and every `guide` to a heading of the upgrade guide.\n */\nimport type { MovedSymbol } from \"./types\";\n\n/** The upgrade guide this release's manual steps point into. */\nexport const UPGRADE_GUIDE = \"https://rebase.pro/docs/upgrading/0-30-to-0-31/\";\n\n/** Sections of the upgrade guide, by number: the anchor of each heading. */\nexport const GUIDE = {\n tables: \"#108-tables-in-backendschema-replace-configcollections--run-the-codemod-first\",\n configPackage: \"#109-there-is-no-config-package\",\n bootOptions: \"#110-boot-options-and-hooks-name-tables\",\n adminPanel: \"#111-the-admin-panel-renders-the-tables-the-server-serves\",\n sdk: \"#115-the-sdk-addresses-a-table-datatableslug\",\n cliFlags: \"#116-cli-flags---schema-dir-not---collections\",\n schemaEditor: \"#117-the-schema-editor-edits-backendschema-with-tablepatch\",\n componentSlot: \"#118-a-component-slot-is-a-component\",\n uiPreferences: \"#119-panel-preferences-are-ui-preferences\",\n mongo: \"#120-mongodb-is-retired\",\n mcp: \"#122-mcp-tools-are-named-for-tables\",\n rlsCheck: \"#125-rls-check---format-agent-says-rls\",\n review: \"#126-rebaseproplugin-review-reviewrls\",\n codegen: \"#127-rebaseprocodegen-reads-descriptors\",\n jsonCollections: \"#129-usejsoncollectionsconfigcontroller-is-removed\",\n history: \"#132-history-is-served-as-reads\",\n serverExports: \"#133-rebaseproserver-exports-name-tables\",\n postgresExports: \"#134-rebaseproserver-postgres-exports-name-tables\",\n kernel: \"#135-rebaseprotypes-and-rebaseprocommon-drop-the-collection-model-from-their-roots\"\n} as const;\n\nconst removed = (from: string, symbols: readonly string[], instead: string, guide?: string): MovedSymbol[] =>\n symbols.map(symbol => ({ symbol, from, to: null, instead, ...(guide ? { guide } : {}) }));\n\nconst MONGO = \"Nothing: MongoDB is retired and Postgres is the only server engine; move the data to Postgres.\";\nconst COMPONENT = \"Pass the component itself: import it by value in the frontend/src/cms file and give it to the slot (`Field`, `Preview`, `Actions`, `Builder`, …). `customizeTable` refuses a string path or a lazy thunk.\";\nconst COLLECTION_MODEL = \"Nothing: the collection model left the kernel. Read the table's `TableDescriptor` (`compileTables` from @rebasepro/common, `backend.getTableDescriptors()`, `GET /api/schema/tables`).\";\nconst LOADING = \"`compileTables` (@rebasepro/common) checks the tables and throws one `SchemaDefinitionError` naming every problem; `schemaDir` / `loadBackendSchema` load backend/schema.\";\nconst REGISTRY = \"`TableRegistryInterface` from @rebasepro/types: `setGlobalHooks?` / `setTableHooks?` replace `getGlobalCallbacks` / `setGlobalCallbacks?`.\";\nconst SCHEMA_EDIT = \"`TablePatch` from @rebasepro/types: a schema edit is a list of `TablePatch` edits (`POST /api/admin/schema-editor/preview` and `/apply`, live schema `{ patches }`).\";\n\n/** Exports renamed (rewritten) or changed (a manual step) outside the kernel moves. */\nexport const EXPORT_CHANGES: readonly MovedSymbol[] = [\n // Renamed, same signature: rewritten.\n { symbol: \"reviewSecurityRules\", from: \"@rebasepro/plugin-review\", to: \"@rebasepro/plugin-review\", as: \"reviewRls\", guide: GUIDE.review },\n { symbol: \"reviewSecurityRules\", from: \"@rebasepro/plugin-review/config\", to: \"@rebasepro/plugin-review/config\", as: \"reviewRls\", guide: GUIDE.review },\n { symbol: \"assertUploadWithinPropertyLimits\", from: \"@rebasepro/server\", to: \"@rebasepro/server\", as: \"assertUploadWithinColumnLimits\", guide: GUIDE.serverExports },\n { symbol: \"UPLOAD_COLLECTION_FIELD\", from: \"@rebasepro/server\", to: \"@rebasepro/server\", as: \"UPLOAD_TABLE_FIELD\", guide: GUIDE.serverExports },\n { symbol: \"UPLOAD_PROPERTY_FIELD\", from: \"@rebasepro/server\", to: \"@rebasepro/server\", as: \"UPLOAD_COLUMN_FIELD\", guide: GUIDE.serverExports },\n\n // @rebasepro/types\n ...removed(\"@rebasepro/types\", [\"CollectionPatch\", \"CollectionPatchOp\", \"applyCollectionPatch\", \"collectionPatchProblems\", \"isCollectionPatch\", \"nestCollectionPatchPaths\"], SCHEMA_EDIT, GUIDE.schemaEditor),\n ...removed(\"@rebasepro/types\", [\"CollectionRegistryInterface\"], REGISTRY, GUIDE.kernel),\n ...removed(\"@rebasepro/types\", [\"ComponentLike\", \"ComponentRef\", \"LazyComponentRef\", \"isLazyComponentRef\"], COMPONENT, GUIDE.componentSlot),\n ...removed(\"@rebasepro/types\", [\"DocumentAdmin\", \"isDocumentAdmin\", \"MONGODB_CAPABILITIES\", \"MongoDBCollectionConfig\", \"MongoProperties\", \"MongoProperty\", \"isMongoDBCollectionConfig\"], MONGO, GUIDE.mongo),\n ...removed(\"@rebasepro/types\", [\"RUNTIME_ONLY_COLLECTION_KEYS\", \"runtimeOnlyKeyIn\", \"toCollectionJson\", \"diffCollections\", \"diffJsonValues\"], COLLECTION_MODEL, GUIDE.kernel),\n ...removed(\"@rebasepro/types\", [\"ListenOneTarget\"], \"`ListenOneProps` from @rebasepro/types: `ListenOneTarget` was internal, and its fields are `ListenOneProps`'s.\"),\n\n // @rebasepro/common\n ...removed(\"@rebasepro/common\", [\"IntrospectedCollection\", \"IntrospectedRelation\", \"buildCollectionFromTableMetadata\"], \"An introspected table is a `TableDescriptor`; `rebase schema introspect` writes `defineTable` files to backend/schema.\", GUIDE.serverExports),\n ...removed(\"@rebasepro/common\", [\"buildTenantSecurityRule\", \"defaultPoliciesDisabled\", \"getJunctionConfigForRelation\", \"isRelationRequired\", \"relationDeclaringProperty\", \"requireCallbackCollection\", \"restoresSoftDeletedRow\", \"softDeleteFieldOf\"], COLLECTION_MODEL, GUIDE.kernel),\n ...removed(\"@rebasepro/common\", [\"toCollectionAccessor\"], \"Nothing: a typed accessor is the table's name (`client.data.posts`), and a reserved one is `<name>Table`.\", GUIDE.sdk),\n\n // @rebasepro/server\n ...removed(\"@rebasepro/server\", [\"BundleConfigExports\", \"loadBundleConfigExports\"], \"Nothing: there is no config package, and a bundle carries `entry.tables`, `entry.resources`, `entry.storage` and `entry.hooks`.\", GUIDE.configPackage),\n ...removed(\"@rebasepro/server\", [\"CollectionConfigError\", \"ConfigProblem\", \"ValidateCollectionConfigOptions\", \"findCollectionConfigProblems\", \"assertCollectionConfigs\", \"CollectionDefaults\", \"applyCollectionDefaults\", \"UnknownKeyPolicy\", \"unknownKeyPolicyFromEnv\", \"accessModelFromCollections\", \"loadCollectionsFromDirectory\", \"loadUsersCollection\"], LOADING, GUIDE.tables),\n ...removed(\"@rebasepro/server\", [\"CollectionRegistryInterface\"], REGISTRY, GUIDE.kernel),\n ...removed(\"@rebasepro/server\", [\"DataTransformer\"], \"Nothing: the Postgres driver's codecs read the column descriptor.\"),\n ...removed(\"@rebasepro/server\", [\"composeCallbacks\"], \"`composeTableHooks` from @rebasepro/common: table hooks get `table` instead of `collection`, and `values` instead of `row`.\", GUIDE.bootOptions),\n ...removed(\"@rebasepro/server\", [\"createUserThroughAuthCollection\"], \"`createUserThroughAuthTable(adapter, served, body, caller, save)` from @rebasepro/server: it takes the served table, not a collection.\", GUIDE.serverExports),\n ...removed(\"@rebasepro/server\", [\"readUploadPropertyContext\"], \"`readUploadColumnContext` from @rebasepro/server: it returns `{ table, column }` instead of `{ collection, property }`.\", GUIDE.serverExports),\n ...removed(\"@rebasepro/server\", [\"versionProperty\"], \"`versionColumn` from @rebasepro/server: it takes a `TableDescriptor`.\", GUIDE.serverExports),\n\n // @rebasepro/server-postgres\n ...removed(\"@rebasepro/server-postgres\", [\"PostgresCollectionRegistry\"], \"`PostgresTableRegistry` (`getTable` → `getPgTable`, `registerTable` → `registerPgTable`), opened on the compiled tables (`compileSchema`).\", GUIDE.postgresExports),\n ...removed(\"@rebasepro/server-postgres\", [\"CollectionRegistryInterface\"], REGISTRY, GUIDE.kernel),\n ...removed(\"@rebasepro/server-postgres\", [\"DataTransformer\"], \"Nothing: the Postgres driver's codecs read the column descriptor.\"),\n ...removed(\"@rebasepro/server-postgres\", [\"resolveDriftCheckName\"], \"Nothing: the boot drift check reads the tables itself.\", GUIDE.kernel),\n\n // @rebasepro/cms, @rebasepro/cms-types, @rebasepro/app\n ...removed(\"@rebasepro/cms\", [\"useJsonCollectionsConfigController\", \"UseJsonCollectionsConfigControllerOptions\", \"JsonCollectionStore\"], \"Declare the tables with `defineTable` in backend/schema; how the panel shows them lives in UI preferences (`frontend/src/cms/ui-config.json`, passed as `<RebaseCMS uiConfig>`).\", GUIDE.jsonCollections),\n ...removed(\"@rebasepro/cms\", [\"ProposedCollectionChange\"], SCHEMA_EDIT, GUIDE.schemaEditor),\n ...removed(\"@rebasepro/cms-types\", [\"PartialCollectionConfig\"], \"`UiTablePreferences`: `UserConfigurationPersistence` takes `getTablePreferences` / `saveTablePreferences`.\", GUIDE.uiPreferences),\n ...removed(\"@rebasepro/cms-types\", [\"ReactComponentRef\", \"asComponentRef\", \"asReactComponent\"], COMPONENT, GUIDE.componentSlot),\n ...removed(\"@rebasepro/app\", [\"resolveComponentRef\", \"useResolvedComponent\"], COMPONENT, GUIDE.componentSlot),\n\n // Still exported, but they take something else now.\n ...removed(\"@rebasepro/codegen\", [\"generateSDK\", \"generateTypedefs\"], \"Still exported, but it takes `TableDescriptor[]` now — `compileTables(...)` or what `GET /api/schema/tables` serves — instead of collections; or run `rebase generate-sdk`.\", GUIDE.codegen),\n ...removed(\"@rebasepro/codegen\", [\"toCollectionAccessor\"], \"Nothing: a typed accessor is the table's name (`client.data.posts`), and a reserved one is `<name>Table`.\", GUIDE.sdk),\n ...removed(\"@rebasepro/plugin-review\", [\"findReviewConfigProblems\", \"assertReviewConfig\"], \"Still exported, but it takes table descriptors now: pass `services.tables()` or `compileTables(...)`.\", GUIDE.review),\n ...removed(\"@rebasepro/plugin-review/config\", [\"findReviewConfigProblems\", \"assertReviewConfig\"], \"Still exported, but it takes table descriptors now: pass `services.tables()` or `compileTables(...)`.\", GUIDE.review)\n];\n\n/** Packages that are gone: any import of them is a manual step. */\nexport const REMOVED_PACKAGES: Readonly<Record<string, { instead: string; guide: string }>> = {\n \"@rebasepro/server-mongo\": { instead: MONGO, guide: GUIDE.mongo }\n};\n\n/** A call whose options named collections: detected (object-literal arguments), never rewritten. */\nexport interface CallOptionChange {\n /** The function, as called (`openRebase`). */\n callee: string;\n /** Option keys of the collection model. */\n keys: readonly string[];\n instead: string;\n guide: string;\n}\n\n/** Calls whose options named the collection model. */\nexport const CALL_OPTION_CHANGES: readonly CallOptionChange[] = [\n { callee: \"openRebase\", keys: [\"collections\", \"callbacks\"], instead: \"`openRebase({ tables, hooks })` with `tables` from `compileSchema([...])`; the result's `.collections` is `.tables`.\", guide: GUIDE.bootOptions },\n { callee: \"openPostgresDriver\", keys: [\"collections\"], instead: \"`openPostgresDriver(config, { tables })` with `tables` from `compileSchema([...])`; the `collection` props of driver calls are ignored.\", guide: GUIDE.postgresExports },\n { callee: \"createHistoryRoutes\", keys: [\"collections\"], instead: \"`createHistoryRoutes({ tables })`.\", guide: GUIDE.serverExports }\n];\n\n/** A spelling found anywhere in a source file (not only in an import): detected, never rewritten. */\nexport interface CodeSpelling {\n /** What the step calls it. */\n spelling: string;\n /** Where it is: each match is one line of the step. */\n pattern: RegExp;\n /** Only files whose text also matches this are read (a cheap guard against a common word). */\n onlyIf?: RegExp;\n instead: string;\n guide: string;\n}\n\n/** Spellings a project's own code can hold whose meaning changed: each is a manual step. */\nexport const CODE_SPELLINGS: readonly CodeSpelling[] = [\n { spelling: \"REBASE_LIVE_SCHEMA_COLLECTIONS_PATH\", pattern: /\\bREBASE_LIVE_SCHEMA_COLLECTIONS_PATH\\b/g, instead: \"`REBASE_LIVE_SCHEMA_PATH` (default `backend/schema`); the old variable refuses the boot. Rename it in your .env files and deployment variables too.\", guide: GUIDE.schemaEditor },\n { spelling: \"liveSchema.repository.collectionsPath\", pattern: /\\bcollectionsPath\\s*:/g, onlyIf: /\\brepository\\b/, instead: \"`schemaPath` — the directory of the tables (`backend/schema`), not of the collections.\", guide: GUIDE.schemaEditor },\n { spelling: \"REBASE_STRICT_COLLECTION_CONFIG\", pattern: /\\bREBASE_STRICT_COLLECTION_CONFIG\\b/g, instead: \"Nothing: it is no longer read; a schema that does not compile always refuses the boot.\", guide: GUIDE.cliFlags },\n { spelling: \"the schema-editor collection / property routes\", pattern: /\\/schema-editor\\/(?:collection|property)\\/(?:save|delete)\\b/g, instead: \"`GET /api/admin/schema-editor/tables`, `POST /preview` and `POST /apply` with `{ patches: TablePatch[] }`.\", guide: GUIDE.schemaEditor },\n { spelling: \"SCHEMA_EDIT_REFUSED\", pattern: /[\"'`]SCHEMA_EDIT_REFUSED[\"'`]/g, instead: \"A file that changed on disk after the edit was prepared now answers 409 `SCHEMA_EDIT_STALE_FILE` (reload and retry); `SCHEMA_EDIT_REFUSED` is still the code of every other refusal.\", guide: GUIDE.schemaEditor },\n { spelling: \"an MCP tool named for collections\", pattern: /[\"'`](?:list_collections|describe_collection|query_collection|show_collection|count_documents|aggregate_documents|list_documents|get_document|create_document|update_document|delete_document)[\"'`]/g, onlyIf: /mcp/i, instead: \"`list_tables`, `describe_table`, `query_table`, `show_table`, `count_rows`, `aggregate_rows`, `get_row`, `create_row`, `update_row`, `delete_row` (`list_documents` → `query_table`); their `collection` argument is `table`.\", guide: GUIDE.mcp },\n { spelling: \"remediation.rebase.securityRules\", pattern: /\\brebase\\s*\\??\\.\\s*securityRules\\b/g, onlyIf: /remediation/, instead: \"`remediation.rebase.rls` (rls-check agent format version 2).\", guide: GUIDE.rlsCheck },\n { spelling: \"UserConfigurationPersistence.getCollectionConfig / onCollectionModified\", pattern: /\\b(?:getCollectionConfig|onCollectionModified)\\b/g, instead: \"`getTablePreferences` / `saveTablePreferences`, which read and write a `UiTablePreferences` delta.\", guide: GUIDE.uiPreferences },\n { spelling: \"StudioSchemaEditing.updateCollection\", pattern: /\\bupdateCollection\\b/g, onlyIf: /\\bStudioSchemaEditing\\b/, instead: \"`applyTablePatches(slug, patches)`.\", guide: GUIDE.uiPreferences },\n { spelling: \"<CollectionsProvider collections>\", pattern: /<CollectionsProvider\\b[^>]*?\\bcollections\\s*=/g, instead: \"`CollectionsProvider` takes `tableCustomizations`, `externalCollections` and `tables`.\", guide: GUIDE.adminPanel },\n { spelling: \"getGlobalCallbacks / setGlobalCallbacks\", pattern: /\\b(?:getGlobalCallbacks|setGlobalCallbacks)\\b/g, instead: \"A driver's registry is a `TableRegistryInterface`: `setGlobalHooks?` / `setTableHooks?`.\", guide: GUIDE.kernel },\n { spelling: \"a custom DataDriver\", pattern: /\\bimplements\\s+(?:[\\w.]+\\s*,\\s*)*DataDriver\\b/g, instead: \"Implement `serveStoredRows(path, rows)` to serve history: without it the history routes answer 501.\", guide: GUIDE.history }\n];\n\n/** A `package.json` script spelling of the old CLI: detected, never rewritten. */\nexport const SCRIPT_SPELLINGS: readonly CodeSpelling[] = [\n { spelling: \"--collections\", pattern: /\\brebase\\b[^&|;]*\\s(?:--collections\\b|-c\\s)/g, instead: \"`--schema-dir <dir>` (only when the tables are not in backend/schema); `--collections` / `-c` are refused.\", guide: GUIDE.cliFlags },\n { spelling: \"schema introspect --output\", pattern: /\\bschema\\s+introspect\\b[^&|;]*\\s--output\\b/g, instead: \"`rebase schema introspect` writes `defineTable` files to backend/schema: drop `--output`.\", guide: GUIDE.cliFlags }\n];\n","/**\n * GENERATED by tooling/scripts/codemod/moved-symbols-table.mjs from\n * tooling/scripts/headless-guard/moved-symbols.json and\n * tooling/scripts/headless-guard/cms-only-symbols.json — do not edit by hand: change\n * the JSON and run the script again. `moved-imports.test.ts` fails while they disagree.\n *\n * Every symbol that left a package's root in 0.31: `to` is the package to import it from now\n * (`as`: under that name), or null when it is gone and `instead` says what to write.\n */\nimport type { MovedSymbol } from \"./types\";\n\n/** The symbols that moved or were removed, by the package they left. */\nexport const MOVED_SYMBOLS: readonly MovedSymbol[] = [\n { symbol: \"FindResponse\", from: \"@rebasepro/client\", to: null, instead: \"FindResult from @rebasepro/types: what client.data.<table>.find() resolves to.\" },\n { symbol: \"defineCollection\", from: \"@rebasepro/cms-types\", to: null, instead: \"defineTable (backend/schema) + customizeTable for the panel's presentation; defineFirestoreCollection (@rebasepro/firebase) for Firestore; defineLegacyCollection (@rebasepro/common/migrate) for 0.30 fixtures.\" },\n { symbol: \"apiHiddenFieldNames\", from: \"@rebasepro/common\", to: null, instead: \"apiHiddenKeys(descriptor) from @rebasepro/common.\" },\n { symbol: \"applyDefaultValuesOnCreate\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"assertBeforeQueryIsPostgresOnly\", from: \"@rebasepro/common\", to: null, instead: \"Nothing: Postgres is the only server engine.\" },\n { symbol: \"AuthContext\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"buildConditionContext\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"buildPropertyCallbacks\", from: \"@rebasepro/common\", to: null, instead: \"Column transforms: col.*().transform(...) on the table definition.\" },\n { symbol: \"buildRebaseData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"buildRoutedRebaseData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canCreateEntity\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canDeleteEntity\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canEditEntity\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canReadCollection\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canReadField\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"canWriteField\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"checkOperation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CheckOperationOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"COLLECTION_PATH_SEPARATOR\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionRegistry\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"collectionsToTableDefs\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"collectionToTableDef\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"compileRulePolicies\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"composeCallbacks\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"copyCarriesRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"createRelationRef\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"createRelationRefWithData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DEFAULT_ONE_OF_TYPE\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DEFAULT_ONE_OF_VALUE\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DEFAULT_STRING_COLUMN_LENGTH\", from: \"@rebasepro/common\", to: null, instead: \"col.varchar({ length }) states the length on the column.\" },\n { symbol: \"defaultUsersCollection\", from: \"@rebasepro/common\", to: null, instead: \"defineAuthTable for the user store; AUTH_SECRET_NAMES lists its secrets.\" },\n { symbol: \"defineCollection\", from: \"@rebasepro/common\", to: null, instead: \"defineTable (backend/schema); the CMS customizes a table with customizeTable; Firestore uses defineFirestoreCollection; legacy fixtures defineLegacyCollection from @rebasepro/common/migrate.\" },\n { symbol: \"effectiveAccess\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityCallbackContext\", from: \"@rebasepro/common\", to: null, instead: \"TableHookProps[\\\"context\\\"] from @rebasepro/types.\" },\n { symbol: \"EntityDataOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"enumToObjectEntries\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"evaluateCondition\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"fieldKeyForColumn\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"findRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"fullPathToCollectionSegments\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getArrayResolvedProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getChildViewDeclaringProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getChildViewRelationPropertyKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getCopyValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDeclaredPrimaryKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDefaultValueFor\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDefaultValueFortype\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDefaultValuesFor\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getEffectiveSecurityRules\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getEffectiveSecurityRulesOnce\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getEntityChildViews\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getGeneratedPolicyNames\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getGeneratedPolicyNamesOnce\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getInjectedSecurityRules\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getJunctionCollectionConfig\", from: \"@rebasepro/common\", to: null, instead: \"junctionPolicyTable(junction) from @rebasepro/common.\" },\n { symbol: \"getJunctionSecurityRules\", from: \"@rebasepro/common\", to: null, instead: \"tableJunctionRules(junction) from @rebasepro/common.\" },\n { symbol: \"getLabelOrConfigFrom\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getPrimaryKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getReferenceFrom\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getRelationFrom\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getRelationTargetPath\", from: \"@rebasepro/common\", to: \"@rebasepro/cms\" },\n { symbol: \"getSubcollections\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getTableName\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getTenantConfig\", from: \"@rebasepro/common\", to: null, instead: \"tenantOf(descriptor) from @rebasepro/common reads a table's tenancy.\" },\n { symbol: \"hasEntityId\", from: \"@rebasepro/common\", to: \"@rebasepro/cms\" },\n { symbol: \"hasFieldAccessRules\", from: \"@rebasepro/common\", to: null, instead: \"hasColumnAccessRules(descriptor) from @rebasepro/common.\" },\n { symbol: \"includableRelationNames\", from: \"@rebasepro/common\", to: null, instead: \"includableRelations(descriptor) from @rebasepro/common.\" },\n { symbol: \"isJunctionBackedRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isPropertyBuilder\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"JunctionDeclaringSide\", from: \"@rebasepro/common\", to: null, instead: \"TableJunctionSide from @rebasepro/common.\" },\n { symbol: \"JunctionEndpoint\", from: \"@rebasepro/common\", to: null, instead: \"TableJunctionEndpoint from @rebasepro/common.\" },\n { symbol: \"JunctionSpec\", from: \"@rebasepro/common\", to: null, instead: \"TableJunction from @rebasepro/common.\" },\n { symbol: \"LegacyPolicyCompileOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"LegacyRulePolicyCompileOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"legacyTableResolver\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"LiftNote\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"LiftNoteKind\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"LiftOptions\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"LiftResult\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"liftRuleSpelling\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"liftTenantSourceSpelling\", from: \"@rebasepro/common\", to: \"@rebasepro/common/migrate\" },\n { symbol: \"normalizeToEntityRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PolicyClauses\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"policyTableFromCollection\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"policyToPostgres\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"queryableFieldNames\", from: \"@rebasepro/common\", to: null, instead: \"queryableColumnKeys(descriptor) from @rebasepro/common.\" },\n { symbol: \"QueryBuilder\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"registerConditionOperations\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationRef\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationRefWithData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveArrayProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveCollectionRelations\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveEnumValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolveFilenameStringParams\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveJunctionSpecs\", from: \"@rebasepro/common\", to: null, instead: \"resolveTableJunctions(descriptors) from @rebasepro/common.\" },\n { symbol: \"resolvePrimaryKeys\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveProperty\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolvePropertyEnum\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvePropertyProps\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveRelation\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveRelationProperty\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStorageFilenameString\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStoragePathString\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolveStoragePathStringParams\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStorageSource\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"resolveStringColumnLength\", from: \"@rebasepro/common\", to: null, instead: \"col.varchar({ length }) states the length on the column.\" },\n { symbol: \"restrictedFieldNames\", from: \"@rebasepro/common\", to: null, instead: \"restrictedKeys(descriptor, viewer, kind) from @rebasepro/common.\" },\n { symbol: \"RoutableData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RoutedRebaseDataParams\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"rowToViewModel\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"sanitizeData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"segmentsToStrippedPath\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"sortProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"stripCollectionPath\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"traverseValueProperty\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"traverseValuesProperties\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"unavailableStorageSource\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"UnknownResolution\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"updateDateAutoValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"updateUserAutoValues\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"vectorPropertyNames\", from: \"@rebasepro/common\", to: null, instead: \"vectorColumnKeys(descriptor) from @rebasepro/common.\" },\n { symbol: \"withDeprecatedAlias\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"withRelationReferencesOnly\", from: \"@rebasepro/common\", to: null, instead: \"History entries hold the stored (wire) row, which embeds no related row; the history routes serve an older entry's relation refs as keys. Nothing replaces it.\" },\n { symbol: \"wrapAsEntityData\", from: \"@rebasepro/common\", to: \"@rebasepro/cms-types\" },\n { symbol: \"wrapAsSdkData\", from: \"@rebasepro/common\", to: null, instead: \"buildSdkData(driver) from @rebasepro/common: the SDK is built on the driver's rows; there is no Entity accessor to flatten.\" },\n { symbol: \"composeCallbacks\", from: \"@rebasepro/server\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ListenCollectionRequest\", from: \"@rebasepro/server\", to: null, instead: \"ListenCollectionProps from @rebasepro/types (a subscription's rows are plain rows).\" },\n { symbol: \"ListenEntityRequest\", from: \"@rebasepro/server\", to: null, instead: \"ListenOneProps from @rebasepro/types.\" },\n { symbol: \"ADMIN_COLLECTION_KEYS\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ADMIN_PROPERTY_KEYS\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AdminCollectionKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AdminPropertyKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterDeleteProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterReadProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterSaveErrorProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AfterSaveProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AnyCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ArrayProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ArrayPropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AuthCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"AuthState\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BaseCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BaseProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BeforeDeleteProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BeforeQueryProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BeforeSaveProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BelongsToRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BinaryProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BooleanProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BrinIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"BtreeIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ChildViewSource\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionCallbacks\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionRegistryController\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"CollectionView\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorHue\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorScheme\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ColorTone\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ConditionContext\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ConditionRule\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DataTransformer\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: the Postgres driver's codecs read the column descriptor.\" },\n { symbol: \"DataType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DateProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"DatePropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"deserializeCollections\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"EffectiveRoleController\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EngineProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Entity\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityChildView\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityReference\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityReferenceProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EntityValues\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EnumValueConditions\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EnumValueConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"EnumValues\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FieldAccess\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FileType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FilterPreset\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FindResponse\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FirebaseCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FirebaseProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"FirebaseProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"GeoPoint\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"GeopointProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getCollectionDataPath\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"getDeclaredSubcollections\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"GinIndex\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"hasForeignKeyOnTarget\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind (hasOne | hasMany).\" },\n { symbol: \"HasManyRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"HasOneRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ImageResize\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"IndexKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"IndexPredicate\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"InferCollectionConfigType\", from: \"@rebasepro/types\", to: null, instead: \"Infer a table's row with InferRow<typeof table>.\" },\n { symbol: \"InferEntityType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"InferPropertyType\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"initTextSearch\", from: \"@rebasepro/types\", to: null, instead: \"DataDriver no longer declares it; the Firestore driver (FirestoreDataDriver) declares its own.\" },\n { symbol: \"isFirebaseCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isManyToMany\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind === \\\"manyToMany\\\".\" },\n { symbol: \"isPostgresCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isRelationalCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"isSerializedCollectionRef\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"isToMany\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind (hasMany | manyToMany | via).\" },\n { symbol: \"JsonLogicRule\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ManyToManyRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"MapProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"McpAppModuleExport\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"nestAdminCollectionKeys\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"nestAdminKeysOf\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"nestAdminPropertyKeys\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"NoSuchKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"NumberProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"NumberPropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PostgresCollectionConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PostgresProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PostgresProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Properties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Property\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyBuilderProps\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyCallbacks\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyConditions\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyTypeNotOnThisEngine\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"PropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"QueryBuilderInterface\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RebaseData\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ReferenceProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Relation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationBase\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"RelationProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedBelongsTo\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedForeignKeyOnTarget\", from: \"@rebasepro/types\", to: null, instead: \"Read RelationDescriptor.kind (hasOne | hasMany).\" },\n { symbol: \"ResolvedHasMany\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedHasOne\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedManyToMany\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedRelationBase\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ResolvedVia\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"serializeCollections\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"SerializedCollectionRef\", from: \"@rebasepro/types\", to: null, instead: \"Nothing: GET /api/schema/tables serves table descriptors; collections are not serialized.\" },\n { symbol: \"SqlExpression\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StorageConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StrictProperties\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StringProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"StringPropertyValidationSchema\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"TableAccessor\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"TableTrashAccessor\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"UnorderedIndexKey\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"UploadedFileContext\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"Vector\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"VectorDistance\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"VectorIndexConfig\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"VectorProperty\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" },\n { symbol: \"ViaRelation\", from: \"@rebasepro/types\", to: \"@rebasepro/cms-types\" }\n];\n","/**\n * Rewriting a project's imports of names that moved, were renamed or were\n * removed in 0.31 — the third pass of `rebase migrate sdk-calls`, run on the\n * text the SDK-call passes wrote.\n *\n * The table is {@link MOVED_SYMBOLS} (generated from the headless guard's JSON:\n * the CMS view model and helpers that left `@rebasepro/types` /\n * `@rebasepro/common`) and {@link EXPORT_CHANGES} (the renames and removals\n * elsewhere). For every `import { … } from` / `export { … } from` whose module\n * is a package a name left:\n *\n * - a name with a destination moves to an import from that package — merged\n * into an import of it the file already has, `import type` / inline `type`\n * and `as` aliases kept, the rest of the declaration left where it is, a\n * declaration left empty deleted. A rename renames the file's references\n * to it too (an aliased import keeps its alias; a re-export keeps its public\n * name). `import(\"pkg\").Name` in a type is repointed the same way.\n * - a name without one (removed, or still exported with another meaning) is\n * left as written and becomes a manual step with what to write instead.\n * - a namespace import (`import * as T`), `export *`, a dynamic `import()` or\n * a `require()` of such a package that uses a moved name is not guessed at:\n * a manual step names the file, the line and the names.\n *\n * Running it again on its own output changes nothing.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ExportDeclaration, ExportSpecifier, ImportDeclaration, ImportSpecifier, Node, SourceFile } from \"ts-morph\";\n\nimport type { AstContext } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport { CALL_OPTION_CHANGES, CODE_SPELLINGS, EXPORT_CHANGES, REMOVED_PACKAGES, SCRIPT_SPELLINGS, UPGRADE_GUIDE, type CodeSpelling } from \"./export-changes\";\nimport { MOVED_SYMBOLS } from \"./moved-symbols.generated\";\nimport { own } from \"./own\";\nimport type { ManualStep, MovedSymbol, Note } from \"./types\";\n\n/** A replacement of `[start, end)` in a file's text. */\nexport interface TextEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** One name an import or re-export of the file now takes from another package or under another name. */\nexport interface MovedName {\n symbol: string;\n from: string;\n to: string;\n as?: string;\n}\n\n/** What the pass found in one file. */\nexport interface MovedImportsResult {\n edits: TextEdit[];\n moved: MovedName[];\n manualSteps: ManualStep[];\n}\n\nconst key = (from: string, symbol: string): string => `${from}\\0${symbol}`;\n\n/** The table, generated rows over hand-written ones. */\nconst TABLE: ReadonlyMap<string, MovedSymbol> = (() => {\n const table = new Map<string, MovedSymbol>();\n for (const row of EXPORT_CHANGES) table.set(key(row.from, row.symbol), row);\n for (const row of MOVED_SYMBOLS) table.set(key(row.from, row.symbol), row);\n return table;\n})();\n\n/** The names each package lost. */\nconst BY_PACKAGE: ReadonlyMap<string, readonly MovedSymbol[]> = (() => {\n const out = new Map<string, MovedSymbol[]>();\n for (const row of TABLE.values()) out.set(row.from, [...(out.get(row.from) ?? []), row]);\n return out;\n})();\n\n/** The row for a name imported from a module, if it moved or changed. */\nexport function movedSymbol(from: string, symbol: string): MovedSymbol | undefined {\n return TABLE.get(key(from, symbol));\n}\n\n/** Every row of the table (generated rows win), for the report and the tests. */\nexport function movedSymbolTable(): readonly MovedSymbol[] {\n return [...TABLE.values()];\n}\n\n/** The package a module specifier belongs to (`@rebasepro/common/migrate` → `@rebasepro/common`). */\nexport function packageOf(specifier: string): string {\n const parts = specifier.split(\"/\");\n return specifier.startsWith(\"@\") ? parts.slice(0, 2).join(\"/\") : parts[0];\n}\n\nconst guideLink = (row: { guide?: string }): string => (row.guide ? ` See ${UPGRADE_GUIDE}${row.guide}` : \"\");\n\n/** A specifier of an import or re-export, as the model sees it. */\ninterface Spec {\n node: ImportSpecifier | ExportSpecifier;\n name: string;\n alias?: string;\n isType: boolean;\n /** Set when the name is renamed in place (same package): the specifier's new text. */\n renamed?: string;\n}\n\n/** A specifier to add to a declaration. */\ninterface Addition {\n text: string;\n isType: boolean;\n}\n\ninterface DeclarationPlan {\n keep: Spec[];\n add: Addition[];\n /** New declarations written right after this one (or in its place when it ends up empty). */\n after: string[];\n touched: boolean;\n}\n\nfunction specsOf(declaration: ImportDeclaration | ExportDeclaration): Spec[] {\n const typeOnly = declaration.isTypeOnly();\n const named = \"getNamedImports\" in declaration ? declaration.getNamedImports() : declaration.getNamedExports();\n return named.map(node => {\n const alias = node.getAliasNode()?.getText();\n return { node, name: node.getNameNode().getText(), ...(alias ? { alias } : {}), isType: typeOnly || node.isTypeOnly() };\n });\n}\n\n/** The text of a specifier written into a declaration that is (or is not) type-only. */\nfunction specText(text: string, isType: boolean, intoTypeOnly: boolean): string {\n return isType && !intoTypeOnly ? `type ${text}` : text;\n}\n\n/** A spec kept as written, its inline `type` adjusted to the declaration it ends up in. */\nfunction keptText(spec: Spec, intoTypeOnly: boolean): string {\n const bare = spec.renamed ?? (spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);\n return specText(bare, spec.isType, intoTypeOnly);\n}\n\n/** The braces of a declaration (`named`), rebuilt with `items`, in their own one-line or multi-line style. */\nfunction braces(declaration: ImportDeclaration | ExportDeclaration, named: Node, items: string[]): string {\n const original = named.getText();\n if (!original.includes(\"\\n\")) return `{ ${items.join(\", \")} }`;\n const sourceText = declaration.getSourceFile().getFullText();\n const indent = /\\{\\s*\\n([ \\t]*)/.exec(original)?.[1] ?? \" \";\n const declarationStart = declaration.getStart();\n const lineStart = sourceText.lastIndexOf(\"\\n\", declarationStart - 1) + 1;\n const closingIndent = /^[ \\t]*/.exec(sourceText.slice(lineStart, declarationStart))?.[0] ?? \"\";\n return `{\\n${items.map(item => `${indent}${item}`).join(\",\\n\")}\\n${closingIndent}}`;\n}\n\n/**\n * Names that moved to the panel's package but have a backend counterpart: in a\n * backend file the import is not moved to `@rebasepro/cms-types` (the server\n * does not run the panel's model) — the step names what the backend uses.\n */\nconst BACKEND_INSTEAD: Readonly<Record<string, string>> = {\n composeCallbacks: \"on the backend, use `composeTableHooks` from @rebasepro/common: table hooks get `table` instead of `collection`, and `values` instead of `row` in afterRead / beforeDelete / afterDelete.\"\n};\n\n/** Whether a project file is backend code (under a `backend/` directory). */\nfunction isBackendFile(relative: string): boolean {\n return /(^|\\/)backend\\//.test(relative);\n}\n\n/**\n * Plan the moves of one file.\n *\n * @param ctx the AST context\n * @param sf the file, parsed (syntax only)\n * @param relative its path from the project root, for the steps\n */\nexport function rewriteMovedImports(ctx: AstContext, sf: SourceFile, relative: string): MovedImportsResult {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const result: MovedImportsResult = { edits: [], moved: [], manualSteps: [] };\n const removedLines: string[] = [];\n const unresolved: string[] = [];\n\n const imports = sf.getImportDeclarations();\n const reexports = sf.getExportDeclarations().filter(declaration => declaration.getModuleSpecifierValue() !== undefined);\n const plans = new Map<ImportDeclaration | ExportDeclaration, DeclarationPlan>();\n const planOf = (declaration: ImportDeclaration | ExportDeclaration): DeclarationPlan => {\n let plan = plans.get(declaration);\n if (!plan) {\n plan = { keep: specsOf(declaration), add: [], after: [], touched: false };\n plans.set(declaration, plan);\n }\n return plan;\n };\n /** Local names renamed: old → new. */\n const renamedLocals = new Map<string, string>();\n\n const groups: { kind: \"import\" | \"export\"; declarations: (ImportDeclaration | ExportDeclaration)[] }[] = [\n { kind: \"import\", declarations: imports },\n { kind: \"export\", declarations: reexports }\n ];\n for (const { kind, declarations } of groups) {\n // Moves out of each declaration, gathered by destination.\n const byDestination = new Map<string, { anchor: ImportDeclaration | ExportDeclaration; quote: string; specs: { text: string; isType: boolean }[] }>();\n for (const declaration of declarations) {\n const from = declaration.getModuleSpecifierValue();\n if (from === undefined) continue;\n const removedPackage = REMOVED_PACKAGES[from];\n if (removedPackage) {\n removedLines.push(`line ${declaration.getStartLineNumber()}: \\`${from}\\` is gone. ${removedPackage.instead}${guideLink(removedPackage)}`);\n continue;\n }\n if (!BY_PACKAGE.has(from)) continue;\n if (kind === \"import\" && N.isImportDeclaration(declaration) && declaration.getNamespaceImport()) continue;\n for (const spec of specsOf(declaration)) {\n const row = movedSymbol(from, spec.name);\n if (!row) continue;\n if (row.to === null) {\n removedLines.push(`line ${declaration.getStartLineNumber()}: \\`${spec.name}\\` from ${from} — ${row.instead ?? \"it is no longer exported.\"}${guideLink(row)}`);\n continue;\n }\n const backendInstead = isBackendFile(relative) ? own(BACKEND_INSTEAD, spec.name) : undefined;\n if (backendInstead) {\n removedLines.push(`line ${declaration.getStartLineNumber()}: \\`${spec.name}\\` from ${from} — ${backendInstead}`);\n continue;\n }\n const plan = planOf(declaration);\n plan.touched = true;\n const newName = row.as ?? spec.name;\n let text: string;\n if (spec.alias) text = `${newName} as ${spec.alias}`;\n else if (newName !== spec.name && kind === \"export\") text = `${newName} as ${spec.name}`;\n else text = newName;\n if (kind === \"import\" && !spec.alias && newName !== spec.name) renamedLocals.set(spec.name, newName);\n result.moved.push({ symbol: spec.name, from, to: row.to, ...(row.as ? { as: row.as } : {}) });\n if (row.to === from) {\n // Renamed in its own package: rewritten where it stands.\n const kept = plan.keep.find(candidate => candidate.node === spec.node);\n if (kept) kept.renamed = text;\n continue;\n }\n plan.keep = plan.keep.filter(kept => kept.node !== spec.node);\n const quote = declaration.getModuleSpecifier()?.getText().charAt(0) ?? \"\\\"\";\n const group = byDestination.get(row.to) ?? { anchor: declaration, quote: quote === \"'\" ? \"'\" : \"\\\"\", specs: [] };\n if (!group.specs.some(existing => existing.text === text)) group.specs.push({ text, isType: spec.isType });\n byDestination.set(row.to, group);\n }\n }\n for (const [to, group] of byDestination) {\n const needsValue = group.specs.some(spec => !spec.isType);\n const candidates = declarations.filter(declaration => declaration.getModuleSpecifierValue() === to &&\n !(N.isImportDeclaration(declaration) && declaration.getNamespaceImport()) &&\n !(N.isExportDeclaration(declaration) && !declaration.hasNamedExports()));\n const target = needsValue\n ? candidates.find(declaration => !declaration.isTypeOnly())\n : candidates.find(declaration => declaration.isTypeOnly()) ?? candidates[0];\n if (target) {\n const plan = planOf(target);\n const existing = new Set(plan.keep.map(spec => (spec.alias ? `${spec.name} as ${spec.alias}` : spec.name)));\n for (const spec of group.specs) {\n if (existing.has(spec.text) || plan.add.some(added => added.text === spec.text)) continue;\n plan.add.push(spec);\n }\n plan.touched = true;\n continue;\n }\n const typeOnly = !needsValue;\n const items = group.specs.map(spec => specText(spec.text, spec.isType, typeOnly));\n const statement = `${kind} ${typeOnly ? \"type \" : \"\"}{ ${items.join(\", \")} } from ${group.quote}${to}${group.quote};`;\n const plan = planOf(group.anchor);\n plan.after.push(statement);\n plan.touched = true;\n }\n }\n\n // Render each touched declaration once.\n const text = sf.getFullText();\n for (const [declaration, plan] of plans) {\n if (!plan.touched) continue;\n const typeOnly = declaration.isTypeOnly();\n const items = [...plan.keep.map(spec => keptText(spec, typeOnly)), ...plan.add.map(added => specText(added.text, added.isType, typeOnly))];\n const hasDefault = N.isImportDeclaration(declaration) && declaration.getDefaultImport() !== undefined;\n const lineStart = text.lastIndexOf(\"\\n\", declaration.getStart() - 1) + 1;\n const indent = /^[ \\t]*/.exec(text.slice(lineStart, declaration.getStart()))?.[0] ?? \"\";\n const after = plan.after.map(statement => `\\n${indent}${statement}`).join(\"\");\n if (items.length === 0 && !hasDefault) {\n if (plan.after.length > 0) {\n result.edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: plan.after.join(`\\n${indent}`) });\n } else {\n // Delete the declaration and its line.\n let end = declaration.getEnd();\n if (text[end] === \"\\r\") end++;\n if (text[end] === \"\\n\") end++;\n result.edits.push({ start: lineStart, end, text: \"\" });\n }\n continue;\n }\n const named = N.isImportDeclaration(declaration) ? declaration.getImportClause()?.getNamedBindings() : declaration.getFirstChildByKind(SyntaxKind.NamedExports);\n if (named && (N.isNamedImports(named) || N.isNamedExports(named))) {\n const defaultImport = N.isImportDeclaration(declaration) ? declaration.getDefaultImport() : undefined;\n if (items.length === 0 && defaultImport) {\n // `import Default, { moved } from` → `import Default from`.\n result.edits.push({ start: defaultImport.getEnd(), end: named.getEnd(), text: \"\" });\n } else {\n result.edits.push({ start: named.getStart(), end: named.getEnd(), text: braces(declaration, named, items) });\n }\n }\n if (after) result.edits.push({ start: declaration.getEnd(), end: declaration.getEnd(), text: after });\n }\n\n // References to a renamed import.\n if (renamedLocals.size > 0) {\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n const next = renamedLocals.get(identifier.getText());\n if (!next) continue;\n const parent = identifier.getParent();\n if (!parent || N.isImportSpecifier(parent) || N.isImportClause(parent) || N.isNamespaceImport(parent) || N.isImportTypeNode(parent)) continue;\n if (N.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) continue;\n if (N.isQualifiedName(parent) && parent.getRight() === identifier) continue;\n if ((N.isPropertyAssignment(parent) || N.isPropertySignature(parent) || N.isMethodDeclaration(parent) || N.isPropertyDeclaration(parent) ||\n N.isMethodSignature(parent) || N.isGetAccessorDeclaration(parent) || N.isSetAccessorDeclaration(parent)) && parent.getNameNode() === identifier) continue;\n if (N.isShorthandPropertyAssignment(parent)) {\n result.edits.push({ start: identifier.getStart(), end: identifier.getEnd(), text: `${identifier.getText()}: ${next}` });\n continue;\n }\n if (N.isExportSpecifier(parent)) {\n if (parent.getExportDeclaration().getModuleSpecifierValue() !== undefined) continue;\n if (parent.getNameNode() === identifier) {\n result.edits.push({ start: identifier.getStart(), end: identifier.getEnd(), text: parent.getAliasNode() ? next : `${next} as ${identifier.getText()}` });\n }\n continue;\n }\n result.edits.push({ start: identifier.getStart(), end: identifier.getEnd(), text: next });\n }\n }\n\n // `import(\"pkg\").Name` in a type.\n for (const importType of sf.getDescendantsOfKind(SyntaxKind.ImportType)) {\n const argument = importType.getArgument();\n const literal = N.isLiteralTypeNode(argument) ? argument.getLiteral() : undefined;\n if (!literal || !N.isStringLiteral(literal)) continue;\n const from = literal.getLiteralValue();\n const qualifier = importType.getQualifier();\n if (!qualifier || !BY_PACKAGE.has(from)) continue;\n const first = N.isIdentifier(qualifier) ? qualifier : qualifier.getFirstDescendantByKind(SyntaxKind.Identifier);\n if (!first) continue;\n const row = movedSymbol(from, first.getText());\n if (!row) continue;\n if (row.to === null) {\n removedLines.push(`line ${importType.getStartLineNumber()}: \\`import(\"${from}\").${first.getText()}\\` — ${row.instead ?? \"it is no longer exported.\"}${guideLink(row)}`);\n continue;\n }\n const quote = literal.getText().charAt(0);\n result.edits.push({ start: literal.getStart(), end: literal.getEnd(), text: `${quote}${row.to}${quote}` });\n if (row.as) result.edits.push({ start: first.getStart(), end: first.getEnd(), text: row.as });\n result.moved.push({ symbol: first.getText(), from, to: row.to, ...(row.as ? { as: row.as } : {}) });\n }\n\n // Namespace imports, `export *`, dynamic imports and `require()`: not guessed at.\n for (const declaration of imports) {\n const from = declaration.getModuleSpecifierValue();\n const namespace = declaration.getNamespaceImport();\n if (!namespace || !BY_PACKAGE.has(from)) continue;\n const local = namespace.getText();\n const uses = new Map<string, number[]>();\n const record = (name: string, node: Node): void => {\n if (!movedSymbol(from, name)) return;\n uses.set(name, [...(uses.get(name) ?? []), node.getStartLineNumber()]);\n };\n for (const access of sf.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n if (access.getExpression().getText() === local) record(access.getName(), access);\n }\n for (const qualified of sf.getDescendantsOfKind(SyntaxKind.QualifiedName)) {\n if (qualified.getLeft().getText() === local) record(qualified.getRight().getText(), qualified);\n }\n if (uses.size > 0) unresolved.push(`line ${declaration.getStartLineNumber()}: \\`import * as ${local} from \"${from}\"\\` uses ${describeUses(from, uses, local)}`);\n }\n for (const declaration of sf.getExportDeclarations()) {\n const from = declaration.getModuleSpecifierValue();\n if (from === undefined || declaration.hasNamedExports() || !BY_PACKAGE.has(from)) continue;\n const moved = (BY_PACKAGE.get(from) ?? []).filter(row => row.to !== null);\n const destinations = [...new Set(moved.map(row => row.to))];\n if (moved.length === 0) continue;\n unresolved.push(`line ${declaration.getStartLineNumber()}: \\`${declaration.getText()}\\` no longer re-exports ${moved.length} name(s) that moved (${moved.slice(0, 6).map(row => row.symbol).join(\", \")}${moved.length > 6 ? \", …\" : \"\"}). If this module's importers read them through it, also re-export them from ${destinations.join(\", \")}.`);\n }\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression();\n const isDynamic = callee.getKind() === SyntaxKind.ImportKeyword;\n const isRequire = N.isIdentifier(callee) && callee.getText() === \"require\";\n if (!isDynamic && !isRequire) continue;\n const argument = call.getArguments()[0];\n if (!argument || !N.isStringLiteral(argument)) continue;\n const from = argument.getLiteralValue();\n if (!BY_PACKAGE.has(from)) continue;\n const uses = new Map<string, number[]>();\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n if (!movedSymbol(from, identifier.getText())) continue;\n const parent = identifier.getParent();\n if (parent && (N.isImportSpecifier(parent) || N.isExportSpecifier(parent))) continue;\n uses.set(identifier.getText(), [...(uses.get(identifier.getText()) ?? []), identifier.getStartLineNumber()]);\n }\n if (uses.size > 0) unresolved.push(`line ${call.getStartLineNumber()}: \\`${isDynamic ? \"import\" : \"require\"}(\"${from}\")\\` and ${describeUses(from, uses)}`);\n }\n\n if (removedLines.length > 0) {\n result.manualSteps.push({\n title: `Replace what 0.31 removed or changed in ${relative}`,\n detail: `The codemod leaves these imports as written; each needs a hand edit. ${removedLines.join(\"; \")}`,\n file: relative\n });\n }\n if (unresolved.length > 0) {\n result.manualSteps.push({\n title: `Repoint the moved names ${relative} reaches without a named import`,\n detail: `The codemod rewrites named imports only. ${unresolved.join(\"; \")}`,\n file: relative\n });\n }\n return result;\n}\n\nfunction describeUses(from: string, uses: ReadonlyMap<string, number[]>, local?: string): string {\n return [...uses].map(([name, lines]) => {\n const row = movedSymbol(from, name);\n const where = row?.to ? `now in ${row.to}${row.as ? ` as \\`${row.as}\\`` : \"\"}` : `gone — ${row?.instead ?? \"\"}`;\n return `\\`${local ? `${local}.` : \"\"}${name}\\` (line ${[...new Set(lines)].join(\", \")}; ${where})`;\n }).join(\", \");\n}\n\nconst SPELLING_SOURCES = new RegExp([\n \"@rebasepro/\",\n ...CALL_OPTION_CHANGES.map(change => `\\\\b${change.callee}\\\\b`),\n ...CODE_SPELLINGS.map(spelling => spelling.pattern.source)\n].join(\"|\"));\n\n/** Whether a file can hold anything this pass reads (so the rest are never parsed). */\nexport function mayNeedImportPass(text: string): boolean {\n return SPELLING_SOURCES.test(text);\n}\n\n/** The lines of `text` matching a spelling, 1-based. */\nfunction matchingLines(text: string, spelling: CodeSpelling): number[] {\n if (spelling.onlyIf && !spelling.onlyIf.test(text)) return [];\n const lines = new Set<number>();\n for (const match of text.matchAll(spelling.pattern)) lines.add(text.slice(0, match.index).split(\"\\n\").length);\n return [...lines];\n}\n\n/**\n * The spellings of a source file whose meaning changed (never rewritten):\n * {@link CODE_SPELLINGS}, and the call options of {@link CALL_OPTION_CHANGES}.\n */\nexport function detectChangedSpellings(ctx: AstContext, sf: SourceFile, relative: string): ManualStep[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const text = sf.getFullText();\n const found: string[] = [];\n for (const spelling of CODE_SPELLINGS) {\n const lines = matchingLines(text, spelling);\n if (lines.length > 0) found.push(`${spelling.spelling} (line ${lines.join(\", \")}): ${spelling.instead} See ${UPGRADE_GUIDE}${spelling.guide}`);\n }\n for (const change of CALL_OPTION_CHANGES) {\n if (!text.includes(change.callee)) continue;\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression();\n const name = N.isPropertyAccessExpression(callee) ? callee.getName() : callee.getText();\n if (name !== change.callee) continue;\n const keys = call.getArguments().flatMap(argument => (N.isObjectLiteralExpression(argument)\n ? argument.getProperties().flatMap(property => ((N.isPropertyAssignment(property) || N.isShorthandPropertyAssignment(property)) && change.keys.includes(property.getName()) ? [property.getName()] : []))\n : []));\n if (keys.length > 0) found.push(`\\`${change.callee}({ ${keys.join(\", \")} })\\` (line ${call.getStartLineNumber()}): ${change.instead} See ${UPGRADE_GUIDE}${change.guide}`);\n }\n }\n if (found.length === 0) return [];\n return [{\n title: `Update what changed meaning in ${relative}`,\n detail: `The codemod does not rewrite these: the new spelling means something different, so each is yours to adapt. ${found.join(\"; \")}`,\n file: relative\n }];\n}\n\n/** A dependency the run added to a workspace package. */\nexport interface AddedDependency {\n /** The `package.json`, relative to the project root. */\n file: string;\n name: string;\n version: string;\n}\n\ntype JsonObject = Record<string, unknown>;\nconst isObject = (value: unknown): value is JsonObject => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst DEPENDENCY_FIELDS = [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const;\n\n/** The nearest `package.json` above a file, inside the project. */\nfunction nearestPackageJson(root: string, file: string): string | undefined {\n let dir = path.dirname(file);\n for (;;) {\n const candidate = path.join(dir, \"package.json\");\n if (fs.existsSync(candidate)) return candidate;\n if (path.resolve(dir) === path.resolve(root) || path.dirname(dir) === dir) return undefined;\n dir = path.dirname(dir);\n }\n}\n\n/** The range a manifest gives its `@rebasepro/*` packages (the first one listed). */\nfunction rebaseRange(manifest: JsonObject): string | undefined {\n for (const field of DEPENDENCY_FIELDS) {\n const deps = manifest[field];\n if (!isObject(deps)) continue;\n for (const [name, range] of Object.entries(deps)) if (name.startsWith(\"@rebasepro/\") && typeof range === \"string\") return range;\n }\n return undefined;\n}\n\n/**\n * Add each package a moved import now names to the workspace package that\n * imports it, when that package does not depend on it yet: in `dependencies`,\n * with the range it gives its other `@rebasepro/*` packages (or the root's).\n * A package with no such range to copy is a manual step.\n *\n * @param root the project root\n * @param needed source file → the packages its imports now name\n * @param read a file's current text (the migration's planned content first)\n */\nexport function planDependencies(\n root: string,\n needed: ReadonlyMap<string, ReadonlySet<string>>,\n read: (file: string) => string | undefined,\n /** Versions to use for packages the config package declared (carried code moved out of config/). */\n configVersions: ReadonlyMap<string, string> = new Map()\n): { files: Map<string, string>; added: AddedDependency[]; manualSteps: ManualStep[]; notes: Note[] } {\n const out = { files: new Map<string, string>(), added: [] as AddedDependency[], manualSteps: [] as ManualStep[], notes: [] as Note[] };\n const byManifest = new Map<string, Set<string>>();\n for (const [file, packages] of needed) {\n const manifest = nearestPackageJson(root, file);\n if (!manifest) continue;\n const set = byManifest.get(manifest) ?? new Set<string>();\n for (const name of packages) set.add(packageOf(name));\n byManifest.set(manifest, set);\n }\n const parse = (file: string): { value: JsonObject; text: string } | undefined => {\n const text = read(file);\n if (text === undefined) return undefined;\n try {\n const value: unknown = JSON.parse(text);\n return isObject(value) ? { value, text } : undefined;\n } catch {\n return undefined;\n }\n };\n const rootManifest = parse(path.join(root, \"package.json\"));\n for (const [manifest, packages] of [...byManifest].sort(([a], [b]) => a.localeCompare(b))) {\n const parsed = parse(manifest);\n if (!parsed) continue;\n const relative = toPosix(path.relative(root, manifest));\n const declared = (name: string): boolean => DEPENDENCY_FIELDS.some(field => {\n const deps = parsed.value[field];\n return isObject(deps) && name in deps;\n });\n const ownName = typeof parsed.value.name === \"string\" ? parsed.value.name : undefined;\n const missing = [...packages].filter(name => name !== ownName && !declared(name)).sort();\n if (missing.length === 0) continue;\n const range = rebaseRange(parsed.value) ?? (rootManifest ? rebaseRange(rootManifest.value) : undefined);\n // A package config/ declared keeps the version config/ gave it.\n const fromConfig = missing.filter(name => configVersions.has(name) && (!name.startsWith(\"@rebasepro/\") || range === undefined));\n if (fromConfig.length > 0) {\n const dependencies = isObject(parsed.value.dependencies) ? { ...parsed.value.dependencies } : {};\n const keys = Object.keys(dependencies);\n const sorted = keys.every((name, index) => index === 0 || keys[index - 1].localeCompare(name) <= 0);\n for (const name of fromConfig) {\n const version = configVersions.get(name) ?? \"\";\n dependencies[name] = version;\n out.added.push({ file: relative, name, version });\n }\n parsed.value = { ...parsed.value, dependencies: sorted ? Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b))) : dependencies };\n const indent = /\\n([ \\t]+)\"/.exec(parsed.text)?.[1] ?? \" \";\n out.files.set(manifest, `${JSON.stringify(parsed.value, null, indent)}${parsed.text.endsWith(\"\\n\") ? \"\\n\" : \"\"}`);\n out.notes.push({ file: relative, message: `added ${fromConfig.map(name => `${name}@${configVersions.get(name) ?? \"\"}`).join(\", \")} to dependencies: code the run moved out of config/ imports ${fromConfig.length > 1 ? \"them\" : \"it\"}, and only config/package.json declared ${fromConfig.length > 1 ? \"them\" : \"it\"}. Run your package manager's install.` });\n out.manualSteps.push({\n title: `Install the packages added to ${relative}`,\n detail: `Code the run moved out of config/ (a customization, a helper) imports ${fromConfig.join(\", \")}, which only config/package.json declared; the codemod added ${fromConfig.length > 1 ? \"them\" : \"it\"} to ${relative} at the version config/ had. Run your package manager's install.`,\n file: relative\n });\n const rest = missing.filter(name => !fromConfig.includes(name));\n if (rest.length === 0) continue;\n missing.splice(0, missing.length, ...rest);\n }\n if (!range) {\n out.manualSteps.push({\n title: `Add ${missing.join(\", \")} to ${relative}`,\n detail: `Imports under ${path.posix.dirname(relative) || \"the project root\"} now name ${missing.join(\", \")}, which ${relative} does not depend on, and it lists no other @rebasepro package to copy the version from. Add ${missing.length > 1 ? \"them\" : \"it\"} at the version of your other @rebasepro packages, then install.`,\n snippet: missing.map(name => `\"${name}\": \"<the version of your other @rebasepro packages>\"`).join(\",\\n\"),\n file: relative\n });\n continue;\n }\n const dependencies = isObject(parsed.value.dependencies) ? { ...parsed.value.dependencies } : {};\n const keys = Object.keys(dependencies);\n const sorted = keys.every((name, index) => index === 0 || keys[index - 1].localeCompare(name) <= 0);\n for (const name of missing) {\n dependencies[name] = range;\n out.added.push({ file: relative, name, version: range });\n }\n const next = sorted ? Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b))) : dependencies;\n const indent = /\\n([ \\t]+)\"/.exec(parsed.text)?.[1] ?? \" \";\n out.files.set(manifest, `${JSON.stringify({ ...parsed.value, dependencies: next }, null, indent)}${parsed.text.endsWith(\"\\n\") ? \"\\n\" : \"\"}`);\n out.notes.push({ file: relative, message: `added ${missing.map(name => `${name}@${range}`).join(\", \")} to dependencies: imports moved there. Run your package manager's install.` });\n out.manualSteps.push({\n title: `Install the packages added to ${relative}`,\n detail: `Imports moved to ${missing.join(\", \")}, so the codemod added ${missing.length > 1 ? \"them\" : \"it\"} to ${relative} at ${range}, the range of your other @rebasepro packages. Run your package manager's install.`,\n file: relative\n });\n }\n return out;\n}\n\n/** The old CLI spellings in a `package.json`'s scripts: a manual step, never rewritten. */\nexport function detectScriptSpellings(manifestText: string, relative: string): ManualStep[] {\n let scripts: unknown;\n try {\n const value: unknown = JSON.parse(manifestText);\n scripts = isObject(value) ? value.scripts : undefined;\n } catch {\n return [];\n }\n if (!isObject(scripts)) return [];\n const found: string[] = [];\n for (const [name, script] of Object.entries(scripts)) {\n if (typeof script !== \"string\") continue;\n for (const spelling of SCRIPT_SPELLINGS) {\n if (matchingLines(script, spelling).length > 0) found.push(`script \"${name}\" uses ${spelling.spelling}: ${spelling.instead} See ${UPGRADE_GUIDE}${spelling.guide}`);\n }\n }\n if (found.length === 0) return [];\n return [{ title: `Update the CLI flags in ${relative}`, detail: found.join(\"; \"), file: relative }];\n}\n","/**\n * Rewriting a project's own code for the SDK and server renames that came\n * with tables (`rebase migrate sdk-calls`, and part of\n * `rebase migrate collections-to-tables` unless `--skip-sdk-calls`).\n *\n * The rules (from the SDK and server slices):\n *\n * 1. `.collection(` → `.table(` on the SDK data surface: `client.data`,\n * `rebase.data`, `rebase.dataAsAdmin`, `context.data`, `ctx.data`,\n * `openRebase().data`, `useData()` / `useSdkData()`, a `createRebaseClient()`\n * result — type arguments kept (`context.data.collection<T>(\"x\")`).\n * 2. `createRebaseClient({ … })`: `collections:` → `tables:`,\n * `collectionsDictionary` → `tablesDictionary`.\n * 3. From the generated `database.types`: `CollectionName` → `TableName`,\n * `CollectionsDictionary` → `TablesDictionary`.\n * 4. Batch operations: `{ op, collection }` → `{ op, table }`.\n * 5. `CollectionClient` → `TableClient`, `SDKCollectionClient` →\n * `SDKTableClient`, `CollectionAccessor` → `TableAccessor`,\n * `CollectionTrashAccessor` → `TableTrashAccessor`.\n * 6. Error codes: `UNKNOWN_COLLECTION` → `UNKNOWN_TABLE`,\n * `INVALID_COLLECTION_PATH` → `INVALID_TABLE_PATH`, `NO_COLLECTIONS` →\n * `NO_TABLES`, `COLLECTION_READ_ONLY` → `TABLE_READ_ONLY`.\n * 7. `maxCachedQueriesPerCollection` / `maxCachedRowsPerCollection` → `…PerTable`.\n * 8. Typed accessors on the data surface: `xCollection` → `xTable`,\n * `collectionCollection` → `collection`.\n * 9. `setCollectionCallbacks(slug, cb)` → `setTableHooks(slug, hooks)`, the\n * callbacks' props adapted as table hooks are (`collection` → `table`,\n * `row` → `values`), `CollectionCallbacks` → `TableHooks`.\n * 10. `storageAuthorize`'s data: `.collection` → `.table`.\n * 11. The rule vocabulary: an `existsIn` policy names its table with `table`\n * (`policy.existsIn({ collection: X …` → `table: X`, a literal\n * `{ kind: \"existsIn\", collection: X }` the same), and a tenant\n * membership source too (`membership: { collection: X …` →\n * `membership: { table: X …`). Wherever the rule is written: a table's\n * `rls`, a shared rule helper, a `tenant` option.\n *\n * The receiver of a `.collection(` call decides. Where a TypeScript program\n * can be built for the file (its nearest tsconfig, the workspace's sources\n * when aliases are given), a receiver whose type is the SDK's data surface\n * (it has the SDK's `table` method) is rewritten whatever its spelling.\n * Otherwise only the receivers in the list above are. Anything else — a\n * Firestore `collection(db, \"x\")`, a CMS helper, a method of the user's own\n * that happens to share the name — is left as written and reported, with\n * its file and line, so a person can check it.\n *\n * Boot options (`collections`, `collectionsDir`, `callbacks`,\n * `auth.collection`) are rewritten only in the one shape the codemod can\n * prove (`collectionsDir: path.join(__dirname, \"…/config/collections\")`);\n * anything else is a manual step with the snippet. Generated SDK files are\n * never rewritten: `rebase generate-sdk` writes them again.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { CallExpression, Node, ObjectLiteralExpression, Project, SourceFile } from \"ts-morph\";\n\nimport type { AstContext, Member, TsMorph } from \"./ast\";\nimport { createAstContext, nodeText, resolveObject, toPosix } from \"./ast\";\nimport { carryHook } from \"./hooks\";\nimport { detectChangedSpellings, detectScriptSpellings, mayNeedImportPass, packageOf, planDependencies, rewriteMovedImports, type AddedDependency } from \"./moved-imports\";\nimport { own } from \"./own\";\nimport { reindent } from \"./print-js\";\nimport type { ManualStep, Note } from \"./types\";\nimport { RULE_KEY_RENAMES } from \"./vocabulary\";\n\n/** The rules, by the name the report counts them under. */\nexport type SdkRule =\n | \"collection-call\" | \"client-options\" | \"generated-types\" | \"batch-op\" | \"type-names\" | \"error-codes\"\n | \"offline-options\" | \"typed-accessor\" | \"table-hooks\" | \"storage-authorize\" | \"boot-options\" | \"rule-vocabulary\" | \"moved-imports\";\n\n/** One `.collection(` left alone, and why. */\nexport interface LeftUnchanged {\n file: string;\n line: number;\n code: string;\n reason: string;\n}\n\n/** What one rewrite run did. */\nexport interface SdkRewriteReport {\n /** Files rewritten, relative to the root, with how many edits each. */\n files: { path: string; edits: number }[];\n /** Edits by rule. */\n counts: Partial<Record<SdkRule, number>>;\n left: LeftUnchanged[];\n manualSteps: ManualStep[];\n notes: Note[];\n /** Generated SDK files found (not rewritten). */\n generated: string[];\n /** Whether receivers were checked by type in at least one file. */\n typeAware: boolean;\n /** Packages added to a workspace package's dependencies because imports moved there. */\n dependencies: AddedDependency[];\n /**\n * `.collection(` calls rewritten by name alone — an untyped (`any`)\n * receiver that is `dataAsAdmin`, or `.data` with a literal table name —\n * printed under \"Rewritten by name — review\".\n */\n byName: { file: string; line: number; code: string }[];\n}\n\nconst RECEIVER_OWNERS = new Set([\"client\", \"rebase\", \"rebaseClient\", \"context\", \"ctx\"]);\nconst DATA_PROPERTIES = new Set([\"data\", \"dataAsAdmin\"]);\nconst DATA_HOOKS = new Set([\"useData\", \"useSdkData\"]);\nconst CLIENT_FACTORY = \"createRebaseClient\";\nconst TYPE_RENAMES: Readonly<Record<string, string>> = {\n CollectionClient: \"TableClient\",\n SDKCollectionClient: \"SDKTableClient\",\n CollectionAccessor: \"TableAccessor\",\n CollectionTrashAccessor: \"TableTrashAccessor\"\n};\nconst GENERATED_TYPE_RENAMES: Readonly<Record<string, string>> = {\n CollectionName: \"TableName\",\n CollectionsDictionary: \"TablesDictionary\"\n};\nconst ERROR_CODES: Readonly<Record<string, string>> = {\n UNKNOWN_COLLECTION: \"UNKNOWN_TABLE\",\n INVALID_COLLECTION_PATH: \"INVALID_TABLE_PATH\",\n NO_COLLECTIONS: \"NO_TABLES\",\n COLLECTION_READ_ONLY: \"TABLE_READ_ONLY\"\n};\nconst OFFLINE_OPTIONS: Readonly<Record<string, string>> = {\n maxCachedQueriesPerCollection: \"maxCachedQueriesPerTable\",\n maxCachedRowsPerCollection: \"maxCachedRowsPerTable\"\n};\n\nconst SOURCE = /\\.(ts|tsx|mts|js|mjs)$/;\nconst IGNORED_DIRS = new Set([\"node_modules\", \"dist\", \"build\", \"out\", \".git\", \"coverage\", \".turbo\", \".next\", \".rebase\", \"dist-bundle\", \"test-results\"]);\n\n/** A line longer than this is not written by a person: the file is bundled or minified output. */\nconst BUNDLE_LINE_LENGTH = 2000;\n\n/**\n * Whether a JavaScript file is bundled or minified output — a vendored build of\n * the client, say. Its identifiers are the bundle's own internals (a build of\n * `@rebasepro/client` reads `maxCachedQueriesPerCollection` from its own\n * options), so rewriting it would break it: it is replaced, not edited.\n */\nexport function isBundledFile(file: string, text: string): boolean {\n if (!/\\.(js|mjs|cjs)$/.test(file)) return false;\n let start = 0;\n while (start < text.length) {\n const newline = text.indexOf(\"\\n\", start);\n const end = newline === -1 ? text.length : newline;\n if (end - start > BUNDLE_LINE_LENGTH) return true;\n start = end + 1;\n }\n return false;\n}\n\n/**\n * A node's symbol, or undefined when the checker has none to give. The\n * checker throws on some files instead of answering (a `.js` script — not a\n * module — read under a tsconfig without `allowJs`), and one such file must\n * not end the run over every other file.\n */\nfunction symbolOf(node: Node): ReturnType<Node[\"getSymbol\"]> {\n try {\n return node.getSymbol();\n } catch {\n return undefined;\n }\n}\n\n/**\n * Whether a file is generated SDK output, which `rebase generate-sdk` rewrites:\n * the header Rebase's generators write, or a generated SDK file name. A file\n * some other generator marks \"do not edit\" (a project's own build step) is\n * the project's code, and is read like any other.\n */\nexport function isGeneratedSdkFile(file: string, text: string): boolean {\n const head = text.slice(0, 400);\n if (/auto-generated by (Rebase|`rebase generate-sdk)/i.test(head)) return true;\n return /[\\\\/]generated[\\\\/]/.test(file) && /(database\\.types|schema\\.meta|register)\\.ts$/.test(file);\n}\n\n/** Every source file of a project the rewrite reads. */\nexport function sdkSourceFiles(root: string, skipDirs: readonly string[] = []): string[] {\n const out: string[] = [];\n const skip = new Set(skipDirs.map(dir => path.resolve(dir)));\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || IGNORED_DIRS.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (!skip.has(full)) walk(full);\n } else if (SOURCE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) {\n out.push(full);\n }\n }\n };\n walk(root);\n return out.sort();\n}\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n rule: SdkRule;\n}\n\n/** A type checker for the files under one tsconfig, when one can be built. */\nclass TypeOracle {\n private readonly projects = new Map<string, Project | null>();\n used = false;\n\n constructor(private readonly tsm: TsMorph, private readonly root: string, private readonly aliases: Record<string, string>) {}\n\n private tsconfigOf(file: string): string | undefined {\n let dir = path.dirname(file);\n for (;;) {\n const candidate = path.join(dir, \"tsconfig.json\");\n if (fs.existsSync(candidate)) return candidate;\n if (dir === this.root || path.dirname(dir) === dir) return undefined;\n dir = path.dirname(dir);\n }\n }\n\n /** The file as a node of a typed program, or undefined. */\n sourceFile(file: string, text: string): SourceFile | undefined {\n const tsconfig = this.tsconfigOf(file);\n if (!tsconfig) return undefined;\n let project = this.projects.get(tsconfig);\n if (project === undefined) {\n try {\n const paths: Record<string, string[]> = {};\n for (const [specifier, target] of Object.entries(this.aliases)) paths[specifier] = [target];\n project = new this.tsm.Project({\n tsConfigFilePath: tsconfig,\n skipAddingFilesFromTsConfig: true,\n ...(Object.keys(paths).length > 0 ? { compilerOptions: { paths, noEmit: true } } : {})\n });\n } catch {\n project = null;\n }\n this.projects.set(tsconfig, project);\n }\n if (!project) return undefined;\n return project.createSourceFile(file, text, { overwrite: true });\n }\n\n /**\n * Whether a receiver's type is the SDK data surface: it has the SDK's\n * `table` method — or, typed by the 0.30 packages a project still has\n * installed when it migrates, the SDK's `collection` method. Either is\n * the SDK's only when a `@rebasepro` package declares it.\n */\n isSdkData(receiver: Node): boolean | undefined {\n try {\n const type = receiver.getType();\n if (type.isAny() || type.isUnknown()) return undefined;\n const method = type.getProperty(\"table\") ?? type.getProperty(\"collection\");\n if (!method) return false;\n this.used = true;\n return method.getDeclarations().some(declaration => /[\\\\/](packages[\\\\/](client|types|common)|@rebasepro[\\\\/])/.test(declaration.getSourceFile().getFilePath()));\n } catch {\n return undefined;\n }\n }\n}\n\n/** Whether a receiver is on the syntactic list (rule 1), following a same-scope `const` once. */\nfunction isListedReceiver(ctx: AstContext, receiver: Node, depth = 0): boolean {\n const { Node: N } = ctx.tsm;\n if (N.isNonNullExpression(receiver) || N.isParenthesizedExpression(receiver) || N.isAsExpression(receiver)) {\n return isListedReceiver(ctx, receiver.getExpression(), depth);\n }\n if (N.isPropertyAccessExpression(receiver) && DATA_PROPERTIES.has(receiver.getName())) {\n const owner = receiver.getExpression();\n if (N.isIdentifier(owner) && RECEIVER_OWNERS.has(owner.getText())) return true;\n if (N.isPropertyAccessExpression(owner) && RECEIVER_OWNERS.has(owner.getName())) return true;\n if (N.isCallExpression(owner) && owner.getExpression().getText() === \"openRebase\") return true;\n if (N.isAwaitExpression(owner)) {\n const inner = owner.getExpression();\n if (N.isCallExpression(inner) && inner.getExpression().getText() === \"openRebase\") return true;\n }\n if (N.isIdentifier(owner) && depth === 0) return isFactoryResult(ctx, owner);\n return false;\n }\n if (N.isCallExpression(receiver) && DATA_HOOKS.has(receiver.getExpression().getText())) return true;\n if (N.isIdentifier(receiver) && depth === 0) {\n if (isFactoryResult(ctx, receiver)) return true;\n const declaration = symbolOf(receiver)?.getDeclarations()[0];\n if (declaration && N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n if (initializer) return isListedReceiver(ctx, initializer, depth + 1);\n }\n }\n return false;\n}\n\n/**\n * Whether an untyped receiver is the SDK by its name: a `dataAsAdmin` property\n * (whatever owns it, a receiver cast to `any` included), reached directly, through\n * a `const`, or through a `const db = () => rebase.dataAsAdmin` call; or a\n * `.data` property, when the call names its table with a string literal.\n */\nfunction isNamedSdkReceiver(ctx: AstContext, receiver: Node, literalTable: boolean, depth = 0): boolean {\n const { Node: N } = ctx.tsm;\n if (depth > 3) return false;\n if (N.isNonNullExpression(receiver) || N.isParenthesizedExpression(receiver) || N.isAsExpression(receiver)) {\n return isNamedSdkReceiver(ctx, receiver.getExpression(), literalTable, depth);\n }\n if (N.isPropertyAccessExpression(receiver)) {\n if (receiver.getName() === \"dataAsAdmin\") return true;\n return receiver.getName() === \"data\" && literalTable;\n }\n const initializerOf = (identifier: Node): Node | undefined => {\n const declaration = symbolOf(identifier)?.getDeclarations()[0];\n if (!declaration || !N.isVariableDeclaration(declaration)) return undefined;\n const statement = declaration.getVariableStatement();\n if (statement && statement.getDeclarationKind() !== ctx.tsm.VariableDeclarationKind.Const) return undefined;\n return declaration.getInitializer();\n };\n if (N.isIdentifier(receiver)) {\n const initializer = initializerOf(receiver);\n return initializer !== undefined && isNamedSdkReceiver(ctx, initializer, literalTable, depth + 1);\n }\n if (N.isCallExpression(receiver) && receiver.getArguments().length === 0 && N.isIdentifier(receiver.getExpression())) {\n const initializer = initializerOf(receiver.getExpression());\n if (!initializer || !N.isArrowFunction(initializer) || initializer.getParameters().length > 0) return false;\n const body = initializer.getBody();\n return !N.isBlock(body) && isNamedSdkReceiver(ctx, body, literalTable, depth + 1);\n }\n return false;\n}\n\n/** The names a data-surface slot goes by: `context.data`, `rebase.dataAsAdmin`, a `data` parameter. */\nconst DATA_SLOTS = new Set([\"data\", \"dataAsAdmin\"]);\n\n/**\n * Whether a receiver IS a data-surface slot by its spelling alone, whatever its\n * type: an expression ending in `.dataAsAdmin` (or an identifier of that name),\n * or one ending in `.data` (or a `data` identifier) when the call names its table\n * with a string literal. A structural type of the project's own over the SDK\n * (`{ dataAsAdmin: { collection(…) } }`) or a `data: any` parameter has no type\n * that says \"SDK\", and a `.collection(` left on one is a TypeError on 0.31 that no\n * type checker reports — so these are rewritten, and listed for review.\n */\nfunction isDataSlot(ctx: AstContext, receiver: Node, literalTable: boolean): boolean {\n const { Node: N } = ctx.tsm;\n if (N.isNonNullExpression(receiver) || N.isParenthesizedExpression(receiver) || N.isAsExpression(receiver)) return isDataSlot(ctx, receiver.getExpression(), literalTable);\n const name = N.isPropertyAccessExpression(receiver) ? receiver.getName() : N.isIdentifier(receiver) ? receiver.getText() : undefined;\n if (name === \"dataAsAdmin\") return true;\n return name === \"data\" && literalTable;\n}\n\n/** Whether a node is the value held by a data slot: `data: { … }`, `dataAsAdmin: { … }`, `const data = { … }` (through `as`/`satisfies`). */\nfunction holdsDataSlot(ctx: AstContext, node: Node): boolean {\n const { Node: N } = ctx.tsm;\n let current: Node = node;\n let parent = current.getParent();\n while (parent && (N.isAsExpression(parent) || N.isSatisfiesExpression(parent) || N.isParenthesizedExpression(parent))) {\n current = parent;\n parent = current.getParent();\n }\n if (!parent) return false;\n if (N.isPropertyAssignment(parent) && parent.getInitializer() === current) return DATA_SLOTS.has(parent.getName());\n if (N.isPropertySignature(parent) && parent.getTypeNode() === current) return DATA_SLOTS.has(parent.getName());\n if (N.isVariableDeclaration(parent) && parent.getInitializer() === current) return DATA_SLOTS.has(parent.getName());\n return false;\n}\n\n/** Whether the receiver's type declares `collection` in an object type a data slot holds (`context: { data: { collection(…) } }`). */\nfunction memberOfSlotType(ctx: AstContext, receiver: Node): boolean {\n const { Node: N } = ctx.tsm;\n try {\n const declarations = receiver.getType().getProperty(\"collection\")?.getDeclarations() ?? [];\n return declarations.some(declaration => {\n const literal = declaration.getParent();\n return (N.isPropertySignature(declaration) || N.isMethodSignature(declaration)) && literal !== undefined && N.isTypeLiteral(literal) && holdsDataSlot(ctx, literal);\n });\n } catch {\n return false;\n }\n}\n\n/** A test file: under a test directory, or named `*.test.*` / `*.spec.*`. */\nfunction isTestFile(relative: string): boolean {\n return /(^|\\/)(test|tests|__tests__|e2e)\\//.test(relative) || /\\.(test|spec)\\.[cm]?[jt]sx?$/.test(relative);\n}\n\n/** Whether an identifier names a `createRebaseClient(...)` result declared in its file. */\nfunction isFactoryResult(ctx: AstContext, identifier: Node): boolean {\n const { Node: N } = ctx.tsm;\n const declaration = symbolOf(identifier)?.getDeclarations()[0];\n if (!declaration || !N.isVariableDeclaration(declaration)) return false;\n let initializer: Node | undefined = declaration.getInitializer();\n while (initializer && (N.isAwaitExpression(initializer) || N.isAsExpression(initializer) || N.isParenthesizedExpression(initializer))) initializer = initializer.getExpression();\n return initializer !== undefined && N.isCallExpression(initializer) && initializer.getExpression().getText() === CLIENT_FACTORY;\n}\n\n/** The object literal a hooks argument denotes: written there, or a same-scope `const`. */\nfunction hooksObject(ctx: AstContext, argument: Node): ObjectLiteralExpression | undefined {\n const { Node: N } = ctx.tsm;\n if (N.isObjectLiteralExpression(argument)) return argument;\n if (N.isIdentifier(argument)) {\n const declaration = symbolOf(argument)?.getDeclarations()[0];\n if (declaration && N.isVariableDeclaration(declaration)) {\n const initializer = declaration.getInitializer();\n return initializer ? resolveObject(ctx, initializer).node : undefined;\n }\n }\n return undefined;\n}\n\n/** Rewrite one function member in place (props renamed), returning its edit and its TODOs. */\nfunction adaptFunctionMember(ctx: AstContext, member: Member, name: string, collectionIsValue: boolean): { edit?: { start: number; end: number; text: string }; todos: string[] } {\n const target = member.method ?? member.value;\n if (!target) return { todos: [] };\n const carried = carryHook(ctx, member, name, { collectionIsValue });\n const original = member.method ? undefined : nodeText(target);\n const indent = (() => {\n const full = target.getSourceFile().getFullText();\n const lineStart = full.lastIndexOf(\"\\n\", target.getStart() - 1) + 1;\n return /^[ \\t]*/.exec(full.slice(lineStart, target.getStart()))?.[0] ?? \"\";\n })();\n if (original === carried.text) return { todos: carried.todos };\n if (member.method) {\n return { edit: { start: member.method.getStart(), end: member.method.getEnd(), text: `${member.method.getName()}: ${reindent(carried.text, indent)}` }, todos: carried.todos };\n }\n return { edit: { start: target.getStart(), end: target.getEnd(), text: reindent(carried.text, indent) }, todos: carried.todos };\n}\n\n/** The members of a hooks object that are functions, by name. */\nfunction functionMembers(ctx: AstContext, object: ObjectLiteralExpression): { name: string; member: Member }[] {\n const { Node: N } = ctx.tsm;\n const out: { name: string; member: Member }[] = [];\n for (const property of object.getProperties()) {\n if (N.isMethodDeclaration(property)) out.push({ name: property.getName(), member: { node: property, method: property } });\n else if (N.isPropertyAssignment(property)) {\n const initializer = property.getInitializerOrThrow();\n if (N.isArrowFunction(initializer) || N.isFunctionExpression(initializer)) out.push({ name: property.getName(), member: { node: property, value: initializer } });\n }\n }\n return out;\n}\n\n/**\n * Which rule source an object literal is (rule 11), and so which of\n * {@link RULE_KEY_RENAMES} apply: the argument of an `existsIn(…)` call\n * (`policy.existsIn`, or the function imported bare) or a literal\n * `{ kind: \"existsIn\", … }`; or the value of a `membership:` property (a\n * tenant's membership source). Anything else is not a rule source.\n */\nfunction ruleSourceOf(ctx: AstContext, object: ObjectLiteralExpression): keyof typeof RULE_KEY_RENAMES | undefined {\n const { Node: N } = ctx.tsm;\n const parent = object.getParent();\n if (parent && N.isCallExpression(parent) && parent.getArguments()[0] === object) {\n const callee = parent.getExpression();\n if ((N.isIdentifier(callee) && callee.getText() === \"existsIn\") ||\n (N.isPropertyAccessExpression(callee) && callee.getName() === \"existsIn\")) return \"existsIn\";\n }\n if (parent && N.isPropertyAssignment(parent) && parent.getInitializer() === object && parent.getName() === \"membership\") return \"membership\";\n const isExistsIn = object.getProperties().some(property => {\n if (!N.isPropertyAssignment(property) || property.getName() !== \"kind\") return false;\n const value = property.getInitializer();\n return value !== undefined && (N.isStringLiteral(value) || N.isNoSubstitutionTemplateLiteral(value)) && value.getLiteralValue() === \"existsIn\";\n });\n return isExistsIn ? \"existsIn\" : undefined;\n}\n\n/** Options of {@link rewriteSdkCalls}. */\nexport interface RewriteSdkOptions {\n /** Files to read instead of the ones on disk (what the migration is about to write). */\n overrides?: ReadonlyMap<string, string>;\n /** Directories not to read (the legacy `config/collections`, which is deleted after the migration). */\n skipDirs?: readonly string[];\n /** Files not to read (what the migration moves out of `config/` and removes). */\n skipFiles?: readonly string[];\n /** Module specifiers → files, for the type checker (the workspace's sources in-repo). */\n aliases?: Record<string, string>;\n /** The `backend/schema` directory a `collectionsDir` boot option becomes. */\n schemaDir?: string;\n /** The legacy collections directory, to recognise a `collectionsDir` that points at it. */\n collectionsDir?: string;\n /** The auth table's module and the collection file it came from (absolute): an `auth.collection` naming either is dropped. */\n authFiles?: readonly string[];\n /**\n * The legacy config package's `package.json`. A file the run writes (an override)\n * that imports a package only that manifest declared — a customization carrying a\n * `@rebasepro/cms-types` type, an action's icon library — gets it added to its own\n * package, at the version config/ declared.\n */\n configManifest?: string;\n}\n\n/** Every dependency a package.json declares (any dependency field), with its range. */\nfunction declaredDependencies(text: string | undefined): Map<string, string> {\n const out = new Map<string, string>();\n if (text === undefined) return out;\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return out;\n }\n if (typeof value !== \"object\" || value === null) return out;\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const deps: unknown = Reflect.get(value, field);\n if (typeof deps !== \"object\" || deps === null) continue;\n for (const [name, range] of Object.entries(deps)) if (typeof range === \"string\" && !out.has(name)) out.set(name, range);\n }\n return out;\n}\n\n/**\n * Rewrite every source file of the project at `root`. Returns the new content\n * of each file that changed, and the report.\n */\nexport async function rewriteSdkCalls(root: string, options: RewriteSdkOptions = {}): Promise<{ files: Map<string, string>; report: SdkRewriteReport }> {\n const tsm: TsMorph = await import(\"ts-morph\");\n const ctx = createAstContext(tsm);\n const oracle = new TypeOracle(tsm, root, options.aliases ?? {});\n const report: SdkRewriteReport = { files: [], counts: {}, left: [], manualSteps: [], notes: [], generated: [], typeAware: false, dependencies: [], byName: [] };\n const read = (file: string): string | undefined => options.overrides?.get(file) ?? (fs.existsSync(file) ? fs.readFileSync(file, \"utf8\") : undefined);\n /** Source file → the packages its moved imports now name. */\n const needed = new Map<string, Set<string>>();\n const out = new Map<string, string>();\n const skipped = new Set((options.skipFiles ?? []).map(file => path.resolve(file)));\n const files = new Set(sdkSourceFiles(root, options.skipDirs).filter(file => !skipped.has(file)));\n for (const file of options.overrides?.keys() ?? []) if (SOURCE.test(file)) files.add(file);\n for (const file of [...files].sort()) {\n const text = options.overrides?.get(file) ?? fs.readFileSync(file, \"utf8\");\n const relative = toPosix(path.relative(root, file));\n if (isGeneratedSdkFile(file, text)) {\n if (/collection/i.test(text)) report.generated.push(relative);\n continue;\n }\n if (isBundledFile(file, text)) {\n if (/collection/i.test(text)) {\n report.manualSteps.push({\n title: `Replace the bundled file ${relative}`,\n detail: `${relative} is bundled or minified JavaScript (a line longer than ${BUNDLE_LINE_LENGTH} characters), which the rewrite never edits: its names are the bundle's own. It mentions \\`collection\\`. If it is a build of a @rebasepro package (a vendored @rebasepro/client, say), replace it with the same package's 0.31 build; if it is a build of your own code, rebuild it after migrating the source it came from.`,\n file: relative\n });\n }\n continue;\n }\n const apply = (source: string, list: readonly { start: number; end: number; text: string }[]): string => {\n let next = source;\n for (const edit of [...list].sort((a, b) => b.start - a.start || b.end - a.end)) next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);\n return next;\n };\n let current = text;\n const fileCounts = new Map<SdkRule, number>();\n let editCount = 0;\n if (/collection|Collection|COLLECTION/.test(text)) {\n const typed = oracle.sourceFile(file, text);\n const sf = typed ?? ctx.project.createSourceFile(file, text, { overwrite: true });\n const edits = rewriteFile(ctx, sf, oracle, typed !== undefined, relative, report, options);\n if (!typed) ctx.project.removeSourceFile(sf);\n const afterFirst = apply(text, edits);\n const second = ctx.project.createSourceFile(file, afterFirst, { overwrite: true });\n const hookEdits = adaptHooks(ctx, second, relative, report);\n ctx.project.removeSourceFile(second);\n const all = [...edits, ...hookEdits];\n if (all.length > 0) {\n current = apply(afterFirst, hookEdits);\n editCount += all.length;\n for (const edit of all) fileCounts.set(edit.rule, (fileCounts.get(edit.rule) ?? 0) + 1);\n }\n }\n // The third pass, on what the first two wrote: names that moved, were renamed or removed.\n if (mayNeedImportPass(current)) {\n const third = ctx.project.createSourceFile(file, current, { overwrite: true });\n const moved = rewriteMovedImports(ctx, third, relative);\n report.manualSteps.push(...moved.manualSteps, ...detectChangedSpellings(ctx, third, relative));\n ctx.project.removeSourceFile(third);\n if (moved.edits.length > 0) {\n current = apply(current, moved.edits);\n editCount += moved.moved.length;\n fileCounts.set(\"moved-imports\", (fileCounts.get(\"moved-imports\") ?? 0) + moved.moved.length);\n const packages = needed.get(file) ?? new Set<string>();\n for (const name of moved.moved) packages.add(name.to);\n needed.set(file, packages);\n }\n }\n if (current !== text) {\n out.set(file, current);\n report.files.push({ path: relative, edits: editCount });\n for (const [rule, count] of fileCounts) report.counts[rule] = (report.counts[rule] ?? 0) + count;\n }\n }\n // Packages only config/ declared, imported by what the run writes (carried code moved out of config/).\n const configDeclared = options.configManifest ? declaredDependencies(read(options.configManifest)) : new Map<string, string>();\n {\n for (const [file, written] of options.overrides ?? []) {\n if (!SOURCE.test(file)) continue;\n const text = out.get(file) ?? written;\n for (const match of text.matchAll(/(?:\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\brequire\\s*\\(\\s*)[\"']([^\"'.\\s][^\"'\\s]*)[\"']/g)) {\n const name = packageOf(match[1]);\n // `@rebasepro/cms-types`, which a customization imports for a branded additional-field key, at the range of the others.\n if (!configDeclared.has(name) && name !== \"@rebasepro/cms-types\") continue;\n const packages = needed.get(file) ?? new Set<string>();\n packages.add(name);\n needed.set(file, packages);\n }\n }\n }\n // The workspace packages: a destination a moved import names becomes a dependency; old CLI flags in scripts are steps.\n const dependencies = planDependencies(root, needed, read, configDeclared);\n for (const [file, content] of dependencies.files) out.set(file, content);\n report.dependencies = dependencies.added;\n report.notes.push(...dependencies.notes);\n report.manualSteps.push(...dependencies.manualSteps);\n const manifests = new Set<string>([path.join(root, \"package.json\")]);\n for (const file of files) {\n let dir = path.dirname(file);\n while (dir.startsWith(root) && dir !== root) {\n const candidate = path.join(dir, \"package.json\");\n if (fs.existsSync(candidate)) {\n manifests.add(candidate);\n break;\n }\n dir = path.dirname(dir);\n }\n }\n for (const manifest of [...manifests].sort()) {\n const text = out.get(manifest) ?? read(manifest);\n if (text !== undefined) report.manualSteps.push(...detectScriptSpellings(text, toPosix(path.relative(root, manifest))));\n }\n report.typeAware = oracle.used;\n if (report.generated.length > 0) {\n report.manualSteps.push({\n title: \"Regenerate the typed SDK\",\n detail: `${report.generated.join(\", \")} ${report.generated.length > 1 ? \"are\" : \"is\"} generated SDK output from before the rename; the rewrite never edits generated files. Once the legacy files are removed (the \\`git rm\\` line this run prints — the command refuses a project that still has config/collections), run \\`rebase generate-sdk\\` (with the same output path and options as before) to write ${report.generated.length > 1 ? \"them\" : \"it\"} again.`,\n snippet: \"rebase generate-sdk\"\n });\n }\n report.byName.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line);\n report.left.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line);\n return { files: out, report };\n}\n\nfunction rewriteFile(\n ctx: AstContext,\n sf: SourceFile,\n oracle: TypeOracle,\n typed: boolean,\n relative: string,\n report: SdkRewriteReport,\n options: RewriteSdkOptions\n): Edit[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const edits: Edit[] = [];\n const taken = (start: number, end: number): boolean => edits.some(edit => start < edit.end && edit.start < end);\n const add = (node: Node, text: string, rule: SdkRule): void => {\n if (taken(node.getStart(), node.getEnd())) return;\n edits.push({ start: node.getStart(), end: node.getEnd(), text, rule });\n };\n // The type decides where there is one: a receiver typed as something else\n // (a structural interface of the project's own that only looks like the\n // SDK) is left, however it is spelled. Without a type, the list decides.\n const isSdk = (receiver: Node): boolean => {\n const byType = typed ? oracle.isSdkData(receiver) : undefined;\n if (byType !== undefined) return byType;\n return isListedReceiver(ctx, receiver);\n };\n /** No type and not on the list, but named as the SDK is: `dataAsAdmin`, or `.data` called with a literal table name. */\n const isSdkByName = (receiver: Node, call: CallExpression): boolean => {\n const literal = call.getArguments()[0];\n const literalTable = literal !== undefined && (N.isStringLiteral(literal) || N.isNoSubstitutionTemplateLiteral(literal));\n // Typed as something else (a structural type of the project's own): only the slot's own name decides —\n // or the type's `collection` member being one this pass renames (an object type a data slot holds), so\n // the call and its type stay in step.\n if (typed && oracle.isSdkData(receiver) !== undefined) return isDataSlot(ctx, receiver, literalTable) || (isDataSlot(ctx, receiver, true) && memberOfSlotType(ctx, receiver));\n return isNamedSdkReceiver(ctx, receiver, literalTable) || isDataSlot(ctx, receiver, literalTable);\n };\n const byName = (node: Node, code: Node): void => {\n report.byName.push({ file: relative, line: node.getStartLineNumber(), code: code.getText().split(\"\\n\")[0].slice(0, 120) });\n };\n\n // Imports: generated types (3), SDK type names (5), CollectionCallbacks with setTableHooks (9).\n const renamedLocals = new Map<string, string>();\n for (const declaration of sf.getImportDeclarations()) {\n const specifier = declaration.getModuleSpecifierValue();\n const generated = /database\\.types(\\.js)?$/.test(specifier);\n const rebase = specifier.startsWith(\"@rebasepro/\");\n for (const named of declaration.getNamedImports()) {\n const imported = named.getName();\n const next = (generated ? own(GENERATED_TYPE_RENAMES, imported) : undefined) ?? (rebase ? own(TYPE_RENAMES, imported) : undefined);\n if (!next) continue;\n const alias = named.getAliasNode();\n add(named.getNameNode(), next, generated ? \"generated-types\" : \"type-names\");\n if (!alias) renamedLocals.set(imported, next);\n }\n }\n\n const setTableHookFiles = sf.getText().includes(\"setCollectionCallbacks\");\n if (setTableHookFiles) {\n for (const declaration of sf.getImportDeclarations()) {\n if (!declaration.getModuleSpecifierValue().startsWith(\"@rebasepro/\")) continue;\n for (const named of declaration.getNamedImports()) {\n if (named.getName() !== \"CollectionCallbacks\") continue;\n add(named.getNameNode(), \"TableHooks\", \"table-hooks\");\n if (!named.getAliasNode()) renamedLocals.set(\"CollectionCallbacks\", \"TableHooks\");\n }\n }\n }\n\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n const next = renamedLocals.get(identifier.getText());\n if (!next) continue;\n const parent = identifier.getParent();\n if (parent && (N.isImportSpecifier(parent) || (N.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) ||\n (N.isPropertyAssignment(parent) && parent.getNameNode() === identifier))) continue;\n add(identifier, next, own(GENERATED_TYPE_RENAMES, identifier.getText()) ? \"generated-types\" : identifier.getText() === \"CollectionCallbacks\" ? \"table-hooks\" : \"type-names\");\n }\n\n // String error codes (6).\n for (const literal of [...sf.getDescendantsOfKind(SyntaxKind.StringLiteral), ...sf.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral)]) {\n const next = own(ERROR_CODES, literal.getLiteralValue());\n if (next) add(literal, literal.getText().replace(literal.getLiteralValue(), next), \"error-codes\");\n }\n\n // Offline options (7), wherever they are spelled.\n for (const identifier of sf.getDescendantsOfKind(SyntaxKind.Identifier)) {\n const next = own(OFFLINE_OPTIONS, identifier.getText());\n if (next) add(identifier, next, \"offline-options\");\n }\n\n // Object literals: createRebaseClient options (2), batch operations (4), rule sources (11).\n for (const object of sf.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression)) {\n const parent = object.getParent();\n const isClientOptions = parent !== undefined && N.isCallExpression(parent) && parent.getExpression().getText() === CLIENT_FACTORY && parent.getArguments()[0] === object;\n const hasOp = object.getProperties().some(property => (N.isPropertyAssignment(property) || N.isShorthandPropertyAssignment(property)) && property.getName() === \"op\");\n const ruleSource = ruleSourceOf(ctx, object);\n const ruleRenames = ruleSource ? RULE_KEY_RENAMES[ruleSource] : undefined;\n for (const property of object.getProperties()) {\n if (!N.isPropertyAssignment(property) && !N.isShorthandPropertyAssignment(property)) continue;\n const name = property.getName();\n let next: string | undefined;\n let rule: SdkRule = \"client-options\";\n if (isClientOptions && name === \"collections\") next = \"tables\";\n else if (isClientOptions && name === \"collectionsDictionary\") next = \"tablesDictionary\";\n else if (hasOp && name === \"collection\") {\n next = \"table\";\n rule = \"batch-op\";\n } else if (ruleRenames && own(ruleRenames, name)) {\n next = own(ruleRenames, name);\n rule = \"rule-vocabulary\";\n }\n if (!next) continue;\n if (N.isShorthandPropertyAssignment(property)) add(property, `${next}: ${name}`, rule);\n else add(property.getNameNode(), next, rule);\n }\n }\n\n // Calls: .collection( (1), typed accessors (8), setCollectionCallbacks (9), boot options.\n for (const access of sf.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n const name = access.getName();\n const receiver = access.getExpression();\n const parent = access.getParent();\n const isCall = parent !== undefined && N.isCallExpression(parent) && parent.getExpression() === access;\n if (name === \"collection\" && isCall) {\n if (isSdk(receiver)) add(access.getNameNode(), \"table\", \"collection-call\");\n else if (isSdkByName(receiver, parent)) {\n add(access.getNameNode(), \"table\", \"collection-call\");\n report.byName.push({ file: relative, line: access.getStartLineNumber(), code: parent.getText().split(\"\\n\")[0].slice(0, 120) });\n } else {\n report.left.push({\n file: relative,\n line: access.getStartLineNumber(),\n code: parent.getText().split(\"\\n\")[0].slice(0, 120),\n reason: typed ? \"left unchanged: the receiver's type is not the SDK data surface\" : \"left unchanged: receiver not recognised\"\n });\n }\n continue;\n }\n if (name === \"collection\" && !isCall && isSdk(receiver)) {\n // A reference to the method rather than a call: `typeof client.data.collection`,\n // `const open = context.data.collection`.\n add(access.getNameNode(), \"table\", \"collection-call\");\n continue;\n }\n // A test double put in the slot: `ctx.data.collection = vi.fn()`, `const open = rebase.data.collection`.\n const assignedDouble = name === \"collection\" && !isCall && parent !== undefined &&\n ((N.isBinaryExpression(parent) && parent.getLeft() === access && parent.getOperatorToken().getKind() === SyntaxKind.EqualsToken) ||\n (N.isVariableDeclaration(parent) && parent.getInitializer() === access)) &&\n isDataSlot(ctx, receiver, true);\n if (assignedDouble || (name === \"collection\" && !isCall && !(typed && oracle.isSdkData(receiver) !== undefined) && isNamedSdkReceiver(ctx, receiver, false))) {\n add(access.getNameNode(), \"table\", \"collection-call\");\n report.byName.push({ file: relative, line: access.getStartLineNumber(), code: (parent ?? access).getText().split(\"\\n\")[0].slice(0, 120) });\n continue;\n }\n if (/^[a-z]\\w*Collection$/.test(name) && !isCall && isSdk(receiver)) {\n add(access.getNameNode(), name === \"collectionCollection\" ? \"collection\" : `${name.slice(0, -\"Collection\".length)}Table`, \"typed-accessor\");\n continue;\n }\n if (name === \"setCollectionCallbacks\" && isCall) {\n add(access.getNameNode(), \"setTableHooks\", \"table-hooks\");\n continue;\n }\n }\n\n // Test doubles of the data surface: a `collection` member of the object (or\n // object type) a data slot holds — `{ dataAsAdmin: { collection: (name) => … } }`,\n // `context: { data: { collection } }`, `const data = { collection(name) { … } }`.\n const slotMembers = [\n ...sf.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression).filter(object => holdsDataSlot(ctx, object)).flatMap(object => object.getProperties()),\n ...sf.getDescendantsOfKind(SyntaxKind.TypeLiteral).filter(literal => holdsDataSlot(ctx, literal)).flatMap(literal => literal.getMembers())\n ];\n const renamedMembers = new Set<Node>();\n for (const member of slotMembers) {\n if (N.isShorthandPropertyAssignment(member) && member.getName() === \"collection\") {\n add(member, \"table: collection\", \"collection-call\");\n } else if ((N.isPropertyAssignment(member) || N.isMethodDeclaration(member) || N.isPropertySignature(member) || N.isMethodSignature(member)) && member.getName() === \"collection\") {\n add(member.getNameNode(), \"table\", \"collection-call\");\n } else {\n continue;\n }\n renamedMembers.add(member);\n byName(member, member);\n }\n if (isTestFile(relative)) {\n // A double the codemod cannot tie to a slot (`makeContext({ collection: … })`): listed, not renamed.\n for (const object of sf.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression)) {\n for (const member of object.getProperties()) {\n if (renamedMembers.has(member)) continue;\n const isFunction = N.isMethodDeclaration(member) || N.isShorthandPropertyAssignment(member) ||\n (N.isPropertyAssignment(member) && (N.isArrowFunction(member.getInitializerOrThrow()) || N.isFunctionExpression(member.getInitializerOrThrow())));\n if (!isFunction || !(N.isMethodDeclaration(member) || N.isShorthandPropertyAssignment(member) || N.isPropertyAssignment(member)) || member.getName() !== \"collection\") continue;\n report.left.push({ file: relative, line: member.getStartLineNumber(), code: member.getText().split(\"\\n\")[0].slice(0, 120), reason: \"left unchanged: a `collection` member of a test double not held by a `data` / `dataAsAdmin` slot — if it stands for the data surface, rename it `table`\" });\n }\n }\n // Assertions over source text: `'collection(\"contacts\").find'`, `/\\.collection\\(\"x\"\\)/`.\n const textual = [\n ...sf.getDescendantsOfKind(SyntaxKind.StringLiteral),\n ...sf.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral),\n ...sf.getDescendantsOfKind(SyntaxKind.RegularExpressionLiteral)\n ];\n for (const literal of textual) {\n const text = literal.getText();\n const next = text.replace(/(?<![\\w$])collection(?=\\\\?\\()/g, \"table\");\n if (next === text) continue;\n add(literal, next, \"collection-call\");\n byName(literal, literal);\n }\n }\n\n // Feature detection of the old name: `typeof x.collection === \"function\"`,\n // `\"collection\" in x`. Left as written, it now silently takes the other\n // branch (on 0.31 there is no `collection`), so each is a manual step.\n const detections: number[] = [];\n for (const typeOf of sf.getDescendantsOfKind(SyntaxKind.TypeOfExpression)) {\n const operand = typeOf.getExpression();\n const access = N.isParenthesizedExpression(operand) ? operand.getExpression() : operand;\n if (!N.isPropertyAccessExpression(access) || access.getName() !== \"collection\") continue;\n if (edits.some(edit => edit.start === access.getNameNode().getStart())) continue; // rewritten with its receiver\n detections.push(typeOf.getStartLineNumber());\n }\n for (const binary of sf.getDescendantsOfKind(SyntaxKind.BinaryExpression)) {\n const left = binary.getLeft();\n if (binary.getOperatorToken().getKind() === SyntaxKind.InKeyword && N.isStringLiteral(left) && left.getLiteralValue() === \"collection\") detections.push(binary.getStartLineNumber());\n }\n if (detections.length > 0) {\n report.manualSteps.push({\n title: `Replace the checks for \\`collection\\` in ${relative}`,\n detail: `Line ${[...new Set(detections)].sort((a, b) => a - b).join(\", \")}: code that tests whether \\`collection\\` exists (\\`typeof x.collection\\`, \\`\"collection\" in x\\`) silently takes the other branch on 0.31, where the data surface has \\`table\\` instead. Test for \\`table\\` and call \\`.table(…)\\` — or drop the check.`,\n file: relative\n });\n }\n\n // Boot options.\n for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {\n const callee = call.getExpression().getText();\n if (callee !== \"initializeRebaseBackend\" && callee !== \"createRebaseBackend\") continue;\n bootOptions(ctx, call, relative, report, edits, options);\n }\n // `typeof client.data.collection`: the method named in a type query (rule 1).\n for (const qualified of sf.getDescendantsOfKind(SyntaxKind.QualifiedName)) {\n if (qualified.getRight().getText() !== \"collection\") continue;\n const left = qualified.getLeft();\n if (!N.isQualifiedName(left) || !DATA_PROPERTIES.has(left.getRight().getText())) continue;\n const owner = left.getLeft();\n const ownerName = N.isQualifiedName(owner) ? owner.getRight().getText() : owner.getText();\n if (RECEIVER_OWNERS.has(ownerName) || (N.isIdentifier(owner) && isFactoryResult(ctx, owner))) add(qualified.getRight(), \"table\", \"collection-call\");\n }\n return edits;\n}\n\n/**\n * The second pass, over the text the first one wrote: the hooks given to\n * `setTableHooks` (rule 9) and `storageAuthorize`'s data (rule 10) get their\n * props adapted. Run after the call-site renames so a hook's body already\n * reads `.table(` and its whole text can be replaced; a hook already adapted\n * is left as it is, so a second run changes nothing.\n */\nfunction adaptHooks(ctx: AstContext, sf: SourceFile, relative: string, report: SdkRewriteReport): Edit[] {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const edits: Edit[] = [];\n const taken = (start: number, end: number): boolean => edits.some(edit => start < edit.end && edit.start < end);\n for (const access of sf.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n const parent = access.getParent();\n if (access.getName() !== \"setTableHooks\" || !parent || !N.isCallExpression(parent) || parent.getExpression() !== access) continue;\n const argument = parent.getArguments()[1];\n const object = argument ? hooksObject(ctx, argument) : undefined;\n if (!object) {\n report.manualSteps.push({\n title: `Adapt the hooks passed to setTableHooks in ${relative}`,\n detail: `Line ${access.getStartLineNumber()}: the hooks are not an object literal the codemod can read (\\`${argument?.getText() ?? \"?\"}\\`). Table hooks get \\`table\\` instead of \\`collection\\`, and afterRead / beforeDelete / afterDelete get \\`values\\` instead of \\`row\\`: adapt their parameters.`,\n file: relative\n });\n continue;\n }\n for (const { name: hook, member } of functionMembers(ctx, object)) {\n const adapted = adaptFunctionMember(ctx, member, hook, false);\n if (adapted.edit && !taken(adapted.edit.start, adapted.edit.end)) edits.push({ ...adapted.edit, rule: \"table-hooks\" });\n for (const todo of adapted.todos) {\n report.manualSteps.push({\n title: `Check the ${hook} hook in ${relative}`,\n detail: `${hook} ${todo} The line is marked \\`TODO(rebase-migrate)\\`.`,\n file: relative\n });\n }\n }\n }\n // storageAuthorize's data (10).\n for (const declaration of sf.getVariableDeclarations()) {\n if (declaration.getName() !== \"storageAuthorize\") continue;\n const initializer = declaration.getInitializer();\n if (!initializer || !(N.isArrowFunction(initializer) || N.isFunctionExpression(initializer))) continue;\n const adapted = adaptFunctionMember(ctx, { node: declaration, value: initializer }, \"storageAuthorize\", true);\n if (adapted.edit && !taken(adapted.edit.start, adapted.edit.end)) edits.push({ ...adapted.edit, rule: \"storage-authorize\" });\n }\n\n return edits;\n}\n\n/** The boot options of a backend entry: the provable shape rewritten, the rest a manual step. */\n/** The range of a node with its trailing comma and the rest of its line, when that is only whitespace. */\nfunction rangeWithTrailer(node: Node): { start: number; end: number } {\n const text = node.getSourceFile().getFullText();\n let end = node.getEnd();\n if (text[end] === \",\") end++;\n const lineEnd = text.indexOf(\"\\n\", end);\n if (lineEnd !== -1 && /^[ \\t]*$/.test(text.slice(end, lineEnd))) {\n const lineStart = text.lastIndexOf(\"\\n\", node.getStart() - 1) + 1;\n if (/^[ \\t]*$/.test(text.slice(lineStart, node.getStart()))) return { start: lineStart, end: lineEnd + 1 };\n }\n return { start: node.getStart(), end };\n}\n\n/**\n * Drop `auth: { collection: usersCollection }` from a backend entry when the\n * value is an import of the auth table (or of the collection file it came\n * from): the auth table is the one defined with `defineAuthTable`, so the\n * option goes — and the import with it when nothing else uses it. Anything\n * else stays a manual step.\n */\nfunction removeAuthCollection(ctx: AstContext, sf: SourceFile, property: Node, edits: Edit[], options: RewriteSdkOptions): boolean {\n const { Node: N, SyntaxKind } = ctx.tsm;\n const authFiles = new Set((options.authFiles ?? []).map(file => file.replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\")));\n if (authFiles.size === 0 || !N.isPropertyAssignment(property)) return false;\n const value = property.getInitializer();\n if (!value || !N.isIdentifier(value)) return false;\n const local = value.getText();\n const declaration = sf.getImportDeclarations().find(candidate =>\n candidate.getDefaultImport()?.getText() === local || candidate.getNamedImports().some(named => (named.getAliasNode()?.getText() ?? named.getName()) === local));\n if (!declaration) return false;\n const specifier = declaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\")) return false;\n const target = path.resolve(path.dirname(sf.getFilePath()), specifier).replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\");\n if (!authFiles.has(target)) return false;\n edits.push({ ...rangeWithTrailer(property), text: \"\", rule: \"boot-options\" });\n const otherUses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === local && identifier !== value && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n if (otherUses.length > 0) return true;\n const named = declaration.getNamedImports();\n const onlyThis = (declaration.getDefaultImport() ? 1 : 0) + named.length + (declaration.getNamespaceImport() ? 1 : 0) === 1;\n if (onlyThis) edits.push({ ...rangeWithTrailer(declaration), text: \"\", rule: \"boot-options\" });\n else {\n const binding = named.find(entry => (entry.getAliasNode()?.getText() ?? entry.getName()) === local);\n if (binding) edits.push({ ...rangeWithTrailer(binding), text: \"\", rule: \"boot-options\" });\n }\n return true;\n}\n\n/**\n * `collections` (the array the collections index exports) in a backend entry\n * becomes `schemaDir: path.join(__dirname, \"…/schema\")` — when the value is\n * that import, and the file has `path` and a `__dirname` to write it with —\n * and the import goes. The backend loads the same tables from their index.\n */\nfunction replaceCollectionsOption(ctx: AstContext, sf: SourceFile, property: Node, edits: Edit[], options: RewriteSdkOptions): boolean {\n const { Node: N, SyntaxKind } = ctx.tsm;\n if (!options.schemaDir || !options.collectionsDir) return false;\n const value = N.isShorthandPropertyAssignment(property) ? property.getNameNode() : N.isPropertyAssignment(property) ? property.getInitializer() : undefined;\n if (!value || !N.isIdentifier(value)) return false;\n const local = value.getText();\n const declaration = sf.getImportDeclarations().find(candidate => candidate.getNamedImports().some(named => (named.getAliasNode()?.getText() ?? named.getName()) === local));\n if (!declaration) return false;\n const specifier = declaration.getModuleSpecifierValue();\n if (!specifier.startsWith(\".\")) return false;\n const target = path.resolve(path.dirname(sf.getFilePath()), specifier).replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\").replace(/[\\\\/]index$/, \"\");\n if (target !== path.resolve(options.collectionsDir)) return false;\n const pathLocal = sf.getImportDeclarations().find(candidate => /^(node:)?path$/.test(candidate.getModuleSpecifierValue()))?.getDefaultImport()?.getText();\n const hasDirname = sf.getVariableDeclaration(\"__dirname\") !== undefined;\n if (!pathLocal || !hasDirname) return false;\n const rel = toPosix(path.relative(path.dirname(sf.getFilePath()), options.schemaDir));\n edits.push({ start: property.getStart(), end: property.getEnd(), text: `schemaDir: ${pathLocal}.join(__dirname, ${JSON.stringify(rel.startsWith(\".\") ? rel : `./${rel}`)})`, rule: \"boot-options\" });\n const otherUses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === local && identifier !== value && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n if (otherUses.length === 0) {\n const named = declaration.getNamedImports();\n if (named.length === 1 && !declaration.getDefaultImport() && !declaration.getNamespaceImport()) edits.push({ ...rangeWithTrailer(declaration), text: \"\", rule: \"boot-options\" });\n else {\n const binding = named.find(entry => (entry.getAliasNode()?.getText() ?? entry.getName()) === local);\n if (binding) edits.push({ ...rangeWithTrailer(binding), text: \"\", rule: \"boot-options\" });\n }\n }\n return true;\n}\n\nfunction bootOptions(ctx: AstContext, call: CallExpression, relative: string, report: SdkRewriteReport, edits: Edit[], options: RewriteSdkOptions): void {\n const { Node: N } = ctx.tsm;\n const object = call.getArguments()[0];\n if (!object || !N.isObjectLiteralExpression(object)) return;\n const legacy: string[] = [];\n for (const property of object.getProperties()) {\n if (!N.isPropertyAssignment(property) && !N.isShorthandPropertyAssignment(property)) continue;\n const name = property.getName();\n if (name === \"collectionsDir\" && N.isPropertyAssignment(property) && options.schemaDir && options.collectionsDir) {\n const value = property.getInitializerOrThrow();\n if (N.isCallExpression(value) && /^path\\.(join|resolve)$/.test(value.getExpression().getText())) {\n const args = value.getArguments();\n const base = args[0]?.getText();\n const rest = args.slice(1);\n if ((base === \"__dirname\" || base === \"import.meta.dirname\") && rest.length > 0 && rest.every(arg => N.isStringLiteral(arg))) {\n const from = path.dirname(path.join(path.dirname(call.getSourceFile().getFilePath()), \"x\"));\n const pointed = path.resolve(from, ...rest.map(arg => (N.isStringLiteral(arg) ? arg.getLiteralValue() : \"\")));\n if (path.resolve(pointed) === path.resolve(options.collectionsDir)) {\n const next = toPosix(path.relative(from, options.schemaDir));\n edits.push({ start: property.getStart(), end: property.getEnd(), text: `schemaDir: ${value.getExpression().getText()}(${base}, ${JSON.stringify(next)})`, rule: \"boot-options\" });\n continue;\n }\n }\n }\n legacy.push(name);\n continue;\n }\n if (name === \"collections\" && replaceCollectionsOption(ctx, call.getSourceFile(), property, edits, options)) continue;\n if (name === \"collections\" || name === \"callbacks\" || name === \"collectionsDir\") legacy.push(name);\n if (name === \"auth\" && N.isPropertyAssignment(property)) {\n const auth = property.getInitializerOrThrow();\n const collection = N.isObjectLiteralExpression(auth) ? auth.getProperty(\"collection\") : undefined;\n if (collection) {\n if (!removeAuthCollection(ctx, call.getSourceFile(), collection, edits, options)) legacy.push(\"auth.collection\");\n }\n }\n }\n if (legacy.length === 0) return;\n report.manualSteps.push({\n title: `Update the backend options in ${relative}`,\n detail: `Line ${call.getStartLineNumber()}: ${legacy.map(name => `\\`${name}\\``).join(\", \")} belong to the collection model. Pass the tables instead — \\`schemaDir\\` (the directory whose index exports them) or \\`tables\\` + \\`defaultRls\\` imported from backend/schema; \\`hooks\\` (backend/hooks.ts) for global hooks; the auth table is the one defined with \\`defineAuthTable\\`, so \\`auth.collection\\` goes.`,\n snippet: `${call.getExpression().getText()}({\\n schemaDir: path.join(__dirname, \"<relative path to backend/schema>\"),\\n // or: tables: Object.values(await import(\"<backend/schema>\")), defaultRls,\\n // hooks, (from backend/hooks.ts, if you had global callbacks)\\n // auth: { … }, (without \\`collection\\`)\\n …\\n})`,\n file: relative\n });\n}\n","/**\n * Row-shaped admin hands: custom views, entity actions, display resolvers and\n * additional fields receive `{ row, id }` on 0.31, not the `entity` view model\n * (`entity.values.x`, `entity.id`). A function that destructures `({ entity })`\n * reads `undefined` at run time — and where it is untyped (a carried\n * customization, a component on a loose prop type) no type check says so.\n *\n * Found in the project's frontend code as the run leaves it — a parameter typed\n * with one of the slot prop types, or a function written in a customization's\n * `entityActions` / `entityViews` / `display` / `additionalFields` — each is\n * rewritten when its body reads `entity` only as `entity.values.x`,\n * `entity.values` or `entity.id` (`row.x`, `row`, `id`), and listed in one\n * grouped step with its file and line otherwise.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Node, ObjectBindingPattern } from \"ts-morph\";\n\nimport type { PlanContext } from \"./plan-context\";\nimport { relativeToRoot } from \"./plan-context\";\n\n/** The prop types of the slots that take a row: a parameter typed with one is a row-shaped hand. */\nconst SLOT_TYPES = /\\b(EntityCustomViewParams|EntityActionClickProps|AdditionalFieldDelegateProps|TableDisplayResolver|EntityCustomView|EntityAction|TableEntityAction|TableEntityView|TableAdditionalField)\\b/;\n\n/** The customization keys whose functions take a row. */\nconst SLOT_KEYS = new Set([\"entityActions\", \"entityViews\", \"display\", \"additionalFields\"]);\n\nconst SOURCE = /\\.(ts|tsx|js|jsx|mts|mjs)$/;\nconst IGNORED = new Set([\"node_modules\", \"dist\", \"build\", \"generated\", \".git\", \"coverage\"]);\n\n/** Whether a function is a slot's: typed with a slot prop type, or written under a slot key of a customization. */\nfunction isSlotFunction(plan: PlanContext, fn: Node, pattern: ObjectBindingPattern): boolean {\n const { Node: N } = plan.ast.tsm;\n const parameter = pattern.getParent();\n if (N.isParameterDeclaration(parameter) && SLOT_TYPES.test(parameter.getTypeNode()?.getText() ?? \"\")) return true;\n const holder = fn.getParent();\n if (holder && N.isVariableDeclaration(holder) && SLOT_TYPES.test(holder.getTypeNode()?.getText() ?? \"\")) return true;\n for (const ancestor of fn.getAncestors()) {\n if (N.isPropertyAssignment(ancestor) && SLOT_KEYS.has(ancestor.getName())) return true;\n if (N.isCallExpression(ancestor) && /^(customizeTable|defineFirestoreCollection)$/.test(ancestor.getExpression().getText())) break;\n }\n return false;\n}\n\ninterface Found {\n file: string;\n line: number;\n rewritten: boolean;\n}\n\n/**\n * Rewrite or list the row-shaped hands in the frontend (planned contents first).\n *\n * @returns nothing; planned files are updated and one grouped step is pushed\n */\nexport function planRowShapedHands(plan: PlanContext, frontendDir: string): void {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const files = new Set<string>();\n const walk = (dir: string): void => {\n if (!fs.existsSync(dir)) return;\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || IGNORED.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) walk(full);\n else if (SOURCE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) files.add(full);\n }\n };\n walk(frontendDir);\n for (const file of plan.files.keys()) if (SOURCE.test(file) && !path.relative(frontendDir, file).startsWith(\"..\")) files.add(file);\n const found: Found[] = [];\n for (const file of [...files].sort()) {\n const planned = plan.files.get(file);\n const text = planned ? planned.content : fs.readFileSync(file, \"utf8\");\n if (!/\\bentity\\b/.test(text)) continue;\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/row-hands-${path.basename(file)}`, text, { overwrite: true });\n const edits: { start: number; end: number; text: string }[] = [];\n try {\n for (const pattern of sf.getDescendantsOfKind(SyntaxKind.ObjectBindingPattern)) {\n const parameter = pattern.getParent();\n if (!N.isParameterDeclaration(parameter)) continue;\n const fn = parameter.getParent();\n if (!fn || !(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isFunctionDeclaration(fn) || N.isMethodDeclaration(fn))) continue;\n if (fn.getParameters()[0] !== parameter) continue;\n const element = pattern.getElements().find(candidate => (candidate.getPropertyNameNode()?.getText() ?? candidate.getName()) === \"entity\");\n if (!element || !isSlotFunction(plan, fn, pattern)) continue;\n const line = parameter.getStartLineNumber();\n const body = fn.getBody();\n const others = pattern.getElements().filter(candidate => candidate !== element).map(candidate => candidate.getName());\n // Mechanical only for a plain `entity` binding read as entity.values.x / entity.values / entity.id.\n const uses = body ? body.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier => identifier.getText() === \"entity\" &&\n !(N.isPropertyAccessExpression(identifier.getParent()) && identifier.getParentOrThrow().getChildAtIndex(2) === identifier) &&\n !(N.isPropertyAssignment(identifier.getParent()) && identifier.getParentOrThrow().getChildAtIndex(0) === identifier)) : [];\n const replacements: { start: number; end: number; text: string }[] = [];\n let needsRow = false;\n let needsId = false;\n let mechanical = element.getPropertyNameNode() === undefined && element.getInitializer() === undefined && !element.getDotDotDotToken() && body !== undefined &&\n !others.includes(\"row\") && !others.includes(\"id\");\n for (const use of uses) {\n if (!mechanical) break;\n const access = use.getParent();\n if (!access || !N.isPropertyAccessExpression(access) || access.getExpression() !== use) {\n mechanical = false;\n break;\n }\n if (access.getName() === \"id\") {\n needsId = true;\n replacements.push({ start: access.getStart(), end: access.getEnd(), text: \"id\" });\n } else if (access.getName() === \"values\") {\n needsRow = true;\n replacements.push({ start: access.getStart(), end: access.getEnd(), text: \"row\" });\n } else {\n mechanical = false;\n }\n }\n // `row` / `id` already meaning something else in the body would be captured.\n if (mechanical && body) {\n const bodyText = body.getText();\n const stripped = bodyText.replace(/\\bentity\\.(values|id)\\b/g, \"\");\n if ((needsRow && /\\brow\\b/.test(stripped)) || (needsId && /\\bid\\b/.test(stripped))) mechanical = false;\n }\n if (mechanical && uses.length > 0) {\n const names = [...(needsRow ? [\"row\"] : []), ...(needsId ? [\"id\"] : [])];\n edits.push({ start: element.getStart(), end: element.getEnd(), text: names.join(\", \") }, ...replacements);\n found.push({ file, line, rewritten: true });\n } else {\n found.push({ file, line, rewritten: false });\n }\n }\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n if (edits.length > 0) {\n let next = text;\n for (const edit of edits.sort((a, b) => b.start - a.start)) next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);\n plan.files.set(file, { content: next, role: planned ? `${planned.role}, row-shaped hands` : `row-shaped hands (${relativeToRoot(plan, file)})` });\n }\n }\n const byHand = found.filter(entry => !entry.rewritten);\n const rewritten = found.filter(entry => entry.rewritten);\n if (rewritten.length > 0) {\n plan.notes.push({\n file: \"\",\n message: `${rewritten.length} custom view / entity action / display resolver / additional field function(s) destructured \\`({ entity })\\` and read only \\`entity.values.x\\` / \\`entity.id\\`: rewritten to \\`({ row, id })\\` (\\`row.x\\`, \\`id\\`) — ${rewritten.map(entry => `${relativeToRoot(plan, entry.file)}:${entry.line}`).join(\", \")}.`\n });\n }\n if (byHand.length > 0) {\n plan.manualSteps.push({\n title: \"Make the admin hands row-shaped\",\n detail: `Custom views, entity actions, display resolvers and additional fields receive \\`{ row, id }\\` on 0.31, not \\`entity\\`: \\`({ entity }) => entity.values.title\\` reads undefined (and untyped, no type check says so). Write \\`({ row, id }) => row.title\\` — \\`row\\` is the record as the server sends it (dates as ISO strings, a belongsTo as its foreign-key column), \\`id\\` its primary key as a string; a view's unsaved edits are \\`modifiedValues\\`. These read \\`entity\\` in a way the codemod does not rewrite: ${byHand.map(entry => `${relativeToRoot(plan, entry.file)}:${entry.line}`).join(\", \")}.`\n });\n }\n}\n","/**\n * The manual step that refreshes a migrated project's agent skills.\n *\n * `rebase skills install` copies the Rebase skills into each agent's own\n * directory (`.claude/skills`, `.cursor/rules`, …), where they stay frozen at\n * the release that wrote them. After the migration those copies still teach\n * `defineCollection` and `config/collections`, so the next agent session\n * writes the old layout back. The codemod does not rewrite them — the skills\n * command owns those files and knows which ones the user edited — it names\n * the command to run instead.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { AGENTS, SKILLS_MANIFEST, isAgentKey, type AgentKey } from \"../../commands/skills\";\nimport type { ManualStep } from \"./types\";\n\n/** The agents whose directory in the project holds Rebase skills: a skills manifest, or a `rebase…` entry from an older install. */\nexport function agentsWithInstalledSkills(projectRoot: string): { agent: AgentKey; dir: string }[] {\n const found: { agent: AgentKey; dir: string }[] = [];\n for (const [key, agent] of Object.entries(AGENTS)) {\n if (!isAgentKey(key)) continue;\n const dir = path.join(projectRoot, agent.targetDir);\n if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) continue;\n const entries = fs.readdirSync(dir);\n if (entries.includes(SKILLS_MANIFEST) || entries.some(entry => entry.startsWith(\"rebase\"))) {\n found.push({ agent: key, dir: agent.targetDir });\n }\n }\n return found;\n}\n\n/**\n * The step, or `undefined` when the project holds no installed Rebase skills.\n *\n * @param projectRoot the project being migrated\n */\nexport function refreshSkillsStep(projectRoot: string): ManualStep | undefined {\n const installed = agentsWithInstalledSkills(projectRoot);\n if (installed.length === 0) return undefined;\n const dirs = installed.map(entry => entry.dir);\n const command = `rebase skills install --agent ${installed.map(entry => entry.agent).join(\",\")}`;\n return {\n title: \"Refresh the project's agent skills\",\n detail: `${dirs.join(\", \")} ${dirs.length > 1 ? \"hold copies\" : \"holds a copy\"} of the Rebase agent skills from before the migration, ` +\n \"which still teach `defineCollection` and `config/collections`: an agent reading them writes the old layout back. \" +\n `Run \\`${command}\\` to replace them with the skills this release ships; it removes the skills the release no longer ships ` +\n \"(`rebase-collections` became `rebase-tables`). Files you edited are kept and listed — add `--force` to replace those too.\",\n snippet: command\n };\n}\n","/**\n * Writing the planned files so that a failed verification leaves nothing\n * behind.\n *\n * The migrated modules have to be verified where they will live: their\n * relative imports point at the project's own files, and their bare imports\n * (`@rebasepro/server/schema`) resolve through the backend workspace's\n * `node_modules`, which a temporary directory elsewhere cannot see. So the\n * files are written in place under a journal — every created file and\n * directory recorded, every replaced file's previous content kept — and\n * {@link Journal.rollback} restores the tree exactly when verification fails.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\n/** What was written, so it can be undone. */\nexport class Journal {\n private readonly created: string[] = [];\n private readonly createdDirs: string[] = [];\n private readonly replaced = new Map<string, Buffer>();\n\n /** Write one file, recording what was there before. */\n write(file: string, content: string): void {\n const dir = path.dirname(file);\n const missing: string[] = [];\n let current = dir;\n while (!fs.existsSync(current)) {\n missing.unshift(current);\n current = path.dirname(current);\n }\n for (const created of missing) {\n fs.mkdirSync(created);\n this.createdDirs.push(created);\n }\n if (fs.existsSync(file)) {\n if (!this.replaced.has(file) && !this.created.includes(file)) this.replaced.set(file, fs.readFileSync(file));\n } else if (!this.created.includes(file)) {\n this.created.push(file);\n }\n fs.writeFileSync(file, content);\n }\n\n /** Put every file and directory back as it was. */\n rollback(): void {\n for (const file of [...this.created].reverse()) fs.rmSync(file, { force: true });\n for (const [file, content] of this.replaced) fs.writeFileSync(file, content);\n for (const dir of [...this.createdDirs].reverse()) {\n try {\n fs.rmdirSync(dir);\n } catch {\n // Not empty: something else lives there now. Leave it.\n }\n }\n this.created.length = 0;\n this.createdDirs.length = 0;\n this.replaced.clear();\n }\n}\n","/**\n * The one value a 0.30 collection file imports that 0.31 no longer exports:\n * `defineCollection`, from `@rebasepro/cms-types` or `@rebasepro/common`.\n *\n * The codemod evaluates `config/collections` with the project's installed\n * packages — after an upgrade, 0.31's — so a file that starts\n * `import { defineCollection } from \"@rebasepro/cms-types\"` would fail to\n * load and the migration could not run on exactly the projects it is for.\n * For that load only, each of the two packages is aliased to a shim that\n * re-exports the package as installed and adds `defineCollection` as 0.30\n * defined it: `resolveResourceRefs(collection)` from `@rebasepro/types` (the\n * legacy loader resolves resource handles the same way afterwards, so a\n * project still on 0.30 packages loads the same values). The shims live in a\n * directory of this run's own ({@link createShimDir}), never in the project.\n */\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\n/**\n * The directory one run writes its shims into, and what it wrote there.\n *\n * Fresh per run — `mkdtemp` under the system's temporary directory, which\n * creates it with a random name and mode 0700 — because the shims are code the\n * run then evaluates: a directory any other user could have written to first\n * (the fixed, content-named path this used to be, on a shared `/tmp`) would\n * run whatever they planted there, `--dry-run` included. Every file is\n * created exclusively (`wx`), so a file the run did not write is never used.\n * {@link removeShimDir} deletes it when the run is over, failed or not.\n */\nexport interface ShimDir {\n /** The directory, absolute. */\n path: string;\n /** The files this run created in it, by name. */\n written: Map<string, string>;\n}\n\n/** A private directory for one run's shims. */\nexport function createShimDir(): ShimDir {\n const dir = fs.mkdtempSync(path.join(os.tmpdir(), \"rebase-legacy-shims-\"));\n // `mkdtemp` already creates it 0700 on POSIX; said again for an umask or\n // platform that does not.\n fs.chmodSync(dir, 0o700);\n return { path: dir, written: new Map() };\n}\n\n/** Delete a run's shim directory and everything in it. */\nexport function removeShimDir(dir: ShimDir): void {\n fs.rmSync(dir.path, { recursive: true, force: true });\n}\n\n/**\n * Write one shim into the run's directory and answer its path. A name this\n * run already wrote with the same text is answered again; anything else on\n * disk under that name is refused (`wx`), never read.\n */\nfunction writeShim(dir: ShimDir, name: string, text: string): string {\n const file = path.join(dir.path, name);\n const previous = dir.written.get(name);\n if (previous === text) return file;\n if (previous !== undefined) {\n throw new Error(`Two different shims were asked for under one name (${name}); this is a bug in the migration.`);\n }\n fs.writeFileSync(file, text, { flag: \"wx\", mode: 0o600 });\n dir.written.set(name, text);\n return file;\n}\n\n/** The packages whose 0.30 `defineCollection` the shim restores. */\nconst SHIMMED = [\"@rebasepro/cms-types\", \"@rebasepro/common\"] as const;\nconst TYPES = \"@rebasepro/types\";\n\n/** Where a specifier resolves for the project's config: an alias, or the config package's own resolution. */\nfunction resolveFrom(configDir: string, aliases: Readonly<Record<string, string>>, specifier: string): string | undefined {\n if (Object.prototype.hasOwnProperty.call(aliases, specifier)) return aliases[specifier];\n try {\n return createRequire(path.join(configDir, \"package.json\")).resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\n/** The subpath exports of an installed package (`@rebasepro/common/migrate`), resolved, so the shim's alias does not swallow them. */\nfunction subpathAliases(configDir: string, aliases: Readonly<Record<string, string>>, name: string): Record<string, string> {\n const out: Record<string, string> = {};\n let manifest: string;\n try {\n manifest = createRequire(path.join(configDir, \"package.json\")).resolve(`${name}/package.json`);\n } catch {\n return out;\n }\n let exportsField: unknown;\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(manifest, \"utf8\"));\n exportsField = typeof parsed === \"object\" && parsed !== null && \"exports\" in parsed ? parsed.exports : undefined;\n } catch {\n return out;\n }\n if (typeof exportsField !== \"object\" || exportsField === null) return out;\n for (const key of Object.keys(exportsField)) {\n if (!key.startsWith(\"./\") || key === \"./package.json\" || key.includes(\"*\")) continue;\n const specifier = `${name}/${key.slice(2)}`;\n const target = resolveFrom(configDir, aliases, specifier);\n if (target) out[specifier] = target;\n }\n return out;\n}\n\n/**\n * The module aliases to evaluate a legacy `config/` with: the given ones,\n * plus a shim for each package that lost `defineCollection`.\n *\n * @param configDir the project's `config/`, absolute\n * @param shimDir the run's private shim directory ({@link createShimDir})\n * @param aliases the run's module aliases (in-repo runs map `@rebasepro/*` to source)\n */\nexport function legacyLoadAliases(configDir: string, shimDir: ShimDir, aliases: Readonly<Record<string, string>> = {}): Record<string, string> {\n const out: Record<string, string> = { ...aliases };\n const types = resolveFrom(configDir, aliases, TYPES);\n if (!types) return out;\n // 0.30's `policy.existsIn({ collection, where })`: 0.31's builder reads `table` and would drop the name.\n const typesShim = [\n `// Written by rebase migrate collections-to-tables to load a 0.30 config/: ${TYPES} as installed, with 0.30's policy.existsIn({ collection }).`,\n `export * from ${JSON.stringify(types)};`,\n `import { policy as installedPolicy } from ${JSON.stringify(types)};`,\n \"export const policy = installedPolicy && {\",\n \" ...installedPolicy,\",\n \" existsIn: (args) => installedPolicy.existsIn({ ...args, table: args.table ?? args.collection })\",\n \"};\",\n \"\"\n ].join(\"\\n\");\n const typesFile = writeShim(shimDir, \"_rebasepro_types.ts\", typesShim);\n Object.assign(out, subpathAliases(configDir, aliases, TYPES));\n out[TYPES] = typesFile;\n for (const name of SHIMMED) {\n const real = resolveFrom(configDir, aliases, name);\n if (!real) continue;\n const text = [\n `// Written by rebase migrate collections-to-tables to load a 0.30 config/: ${name} as installed, plus 0.30's defineCollection.`,\n `export * from ${JSON.stringify(real)};`,\n `export { resolveResourceRefs as defineCollection } from ${JSON.stringify(types)};`,\n \"\"\n ].join(\"\\n\");\n const shim = writeShim(shimDir, `${name.replace(/[@/]/g, \"_\")}.ts`, text);\n Object.assign(out, subpathAliases(configDir, aliases, name));\n out[name] = shim;\n }\n return out;\n}\n\n/** A module importer (the run's jiti importer). */\ntype Importer = (file: string) => Promise<Record<string, unknown>>;\n\n/**\n * Shims for the names a 0.30 `config/` imports from a package that 0.31 moved\n * elsewhere — `import { EntityRelation } from \"@rebasepro/types\"`, now in\n * `@rebasepro/cms-types` — so the collection files load with 0.31's packages\n * installed. A name is re-exported from its new package only when the package\n * as installed no longer exports it and the new one does: a project still on\n * 0.30 packages loads exactly as before.\n *\n * @param shimDir the run's private shim directory ({@link createShimDir})\n * @param aliases the aliases the load uses so far ({@link legacyLoadAliases})\n * @param importModule an importer built with those aliases\n * @param moves the moved-symbol table\n */\nexport async function movedNameAliases(\n configDir: string,\n shimDir: ShimDir,\n aliases: Readonly<Record<string, string>>,\n importModule: Importer,\n moves: readonly { symbol: string; from: string; to: string | null; as?: string }[]\n): Promise<Record<string, string>> {\n const out: Record<string, string> = { ...aliases };\n const byPackage = new Map<string, { symbol: string; to: string; as?: string }[]>();\n for (const move of moves) {\n if (move.to === null || move.to === move.from) continue;\n byPackage.set(move.from, [...(byPackage.get(move.from) ?? []), { symbol: move.symbol, to: move.to, ...(move.as ? { as: move.as } : {}) }]);\n }\n const load = async (file: string): Promise<Record<string, unknown> | undefined> => {\n try {\n return await importModule(file);\n } catch {\n return undefined;\n }\n };\n for (const [name, rows] of byPackage) {\n const current = resolveFrom(configDir, aliases, name);\n if (!current) continue;\n const installed = await load(current);\n if (!installed) continue;\n const lines: string[] = [];\n const byDestination = new Map<string, string[]>();\n for (const row of rows) {\n if (row.symbol in installed) continue;\n const destination = resolveFrom(configDir, aliases, row.to);\n if (!destination) continue;\n const exported = row.as ?? row.symbol;\n const module = await load(destination);\n if (!module || !(exported in module)) continue;\n byDestination.set(destination, [...(byDestination.get(destination) ?? []), exported === row.symbol ? row.symbol : `${exported} as ${row.symbol}`]);\n }\n if (byDestination.size === 0) continue;\n lines.push(`// Written by rebase migrate collections-to-tables to load a 0.30 config/: ${name} as installed, plus the names 0.31 moved out of it.`);\n lines.push(`export * from ${JSON.stringify(current)};`);\n for (const [destination, names] of byDestination) lines.push(`export { ${names.join(\", \")} } from ${JSON.stringify(destination)};`);\n const text = `${lines.join(\"\\n\")}\\n`;\n const shim = writeShim(shimDir, `${name.replace(/[@/]/g, \"_\")}-moved.ts`, text);\n if (!Object.prototype.hasOwnProperty.call(out, name)) Object.assign(out, subpathAliases(configDir, aliases, name));\n out[name] = shim;\n }\n return out;\n}\n","/**\n * Evaluating a legacy project the way its loader does.\n *\n * The legacy loader (`loadCollectionsFromDirectory`) was the one definition\n * of \"the collections\": every top-level file of `<config>/collections` but the\n * index, each default-exporting one collection; the index's\n * `defaultSecurityRules` applied to every collection without rules of its own;\n * resource handles resolved to their keys; the strict parse. This reads the\n * same files in the same order with the same rules, so directory defaults,\n * spreads, shared fragments, computed keys, imported constants and\n * assignments after a declaration (`x.securityRules = [...]`) are all values\n * by the time the codemod sees them — exactly the values the server served.\n *\n * The legacy loader is gone from `@rebasepro/server` (the backend boots from\n * `backend/schema`), so its rule is restated here — the same rule the\n * plan-golden corpus reads legacy directories with. Modules are imported\n * through jiti, because a CLI run has no TypeScript loader installed and a\n * project's imports are extensionless.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { SchemaModuleImporter } from \"@rebasepro/server\";\nimport { isLegacyPostgresCollection, type LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\nimport { resolveResourceRefs, type SecurityRule } from \"@rebasepro/types\";\n\n/** A legacy collection, with the file it came from. */\nexport interface LoadedCollection {\n collection: LegacyCollectionConfig;\n /** The file, absolute. */\n file: string;\n}\n\n/** A legacy project, evaluated. */\nexport interface LegacyProject {\n /** The config directory (`config/`), absolute. */\n configDir: string;\n /** `<config>/collections`, absolute. */\n collectionsDir: string;\n /** Every collection, in the loader's order (file name order). */\n collections: LoadedCollection[];\n /** The index's `defaultSecurityRules`, when it exports any. */\n defaultSecurityRules?: SecurityRule[];\n /** The index's `collections` array, when it exports one: the panel's navigation order. */\n navigationOrder?: LegacyCollectionConfig[];\n /** Named exports of `<config>/index.ts`, when there is one (to find `callbacks`, `storageAuthorize`). */\n configIndexExports: string[];\n /**\n * Files of `<config>/collections` that export no collection at all — no\n * default export, and no named export shaped like one: helpers the\n * collection files import (`_predicates.ts`), absolute. A project that passed\n * its collections as an array never had its directory read, so these were\n * never collections; they are moved like any other module of `config/`.\n */\n helperFiles: string[];\n /**\n * Firestore collections the project builds in a module the loader never\n * read: a file under a subdirectory of `<config>/collections`, or a function\n * the index exports (`getAllFirestoreCollections()`), which the app spread\n * into the panel's collections. Empty when there are none.\n */\n builtFirestore: BuiltFirestoreCollection[];\n /** The zero-argument functions that returned Firestore collections, with what each returned. */\n firestoreBuilders: FirestoreBuilder[];\n}\n\n/** A Firestore collection reached outside the loader's top-level files. */\nexport interface BuiltFirestoreCollection {\n collection: LegacyCollectionConfig;\n /**\n * The module whose default export is this collection's object (or one with\n * its slug), absolute — absent when the collection only exists as what a\n * call returns (built per locale, say), so no literal of its own exists.\n */\n file?: string;\n}\n\n/** An exported zero-argument function that returned Firestore collections. */\nexport interface FirestoreBuilder {\n /** The module that exports it, absolute. */\n file: string;\n /** Its export name. */\n exportName: string;\n /** The slugs it returned, in order. */\n slugs: string[];\n /**\n * The slugs it returned as a different object than their file exports — a\n * copy the builder changed at run time (added a field, say), which a\n * conversion of the file alone does not carry.\n */\n changed: string[];\n}\n\n/** A module importer: the CLI's jiti importer (`createSchemaModuleImporter`), or a stand-in in tests. */\nexport type ModuleImporter = SchemaModuleImporter;\n\n/** The loader's file filter (`isCollectionFile` in `@rebasepro/server`). */\nexport function isLegacyCollectionFile(file: string): boolean {\n return (file.endsWith(\".ts\") || file.endsWith(\".js\") || file.endsWith(\".tsx\")) &&\n !file.startsWith(\".\") &&\n !file.includes(\".test.\") &&\n !file.endsWith(\".d.ts\") &&\n file !== \"index.ts\" && file !== \"index.js\" && file !== \"index.tsx\";\n}\n\nfunction isFirestoreCollection(value: unknown): value is LegacyCollectionConfig {\n return isCollection(value) && \"engine\" in value && value.engine === \"firestore\";\n}\n\n/** Every module under the subdirectories of `dir`, absolute, sorted. */\nfunction nestedModules(dir: string): string[] {\n const out: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n if (!entry.isDirectory() || entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const walk = (current: string): void => {\n for (const child of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n const full = path.join(current, child.name);\n if (child.isDirectory()) {\n if (!child.name.startsWith(\".\") && child.name !== \"node_modules\") walk(full);\n } else if (/\\.(ts|tsx|js)$/.test(child.name) && !child.name.endsWith(\".d.ts\") && !child.name.includes(\".test.\")) {\n out.push(full);\n }\n }\n };\n walk(path.join(dir, entry.name));\n }\n return out;\n}\n\n/**\n * Firestore collections the project serves from modules the loader did not\n * read: the default exports of files in subdirectories of the collections\n * directory, and what the exported zero-argument functions of those modules\n * and of the index return (`getAllFirestoreCollections()`). A module that does\n * not load is skipped: nothing proves it served a collection.\n */\nasync function findBuiltFirestore(collectionsDir: string, indexFile: string | undefined, importModule: ModuleImporter): Promise<{ built: BuiltFirestoreCollection[]; builders: FirestoreBuilder[] }> {\n const modules = [...(indexFile ? [indexFile] : []), ...nestedModules(collectionsDir)];\n const byFile = new Map<string, LegacyCollectionConfig>();\n const loaded: { file: string; mod: Record<string, unknown> }[] = [];\n for (const file of modules) {\n try {\n const mod = await importModule(file);\n loaded.push({ file, mod });\n if (file !== indexFile && isFirestoreCollection(mod.default)) byFile.set(file, mod.default);\n } catch {\n // Not loadable on its own (a React module, say): nothing it builds can be attributed to it.\n }\n }\n const builders: FirestoreBuilder[] = [];\n const reached = new Map<string, LegacyCollectionConfig>();\n const exported = new Map<string, LegacyCollectionConfig>();\n for (const collection of byFile.values()) {\n reached.set(collection.slug, collection);\n if (!exported.has(collection.slug)) exported.set(collection.slug, collection);\n }\n // A builder re-exported by an index is the same function: reported once, where it was met first.\n const called = new Set<unknown>();\n for (const { file, mod } of loaded) {\n for (const [exportName, value] of Object.entries(mod)) {\n if (called.has(value)) continue;\n // Only what names itself a collection builder is called: a module of config/ may export anything.\n if (typeof value !== \"function\" || value.length !== 0 || !/collection/i.test(exportName) || /^[A-Z]/.test(exportName)) continue;\n called.add(value);\n let returned: unknown;\n try {\n returned = value();\n } catch {\n continue;\n }\n const list = Array.isArray(returned) ? returned : [returned];\n const collections = list.filter(isFirestoreCollection);\n if (collections.length === 0) continue;\n builders.push({\n file,\n exportName,\n slugs: collections.map(collection => collection.slug),\n changed: collections.filter(collection => exported.has(collection.slug) && exported.get(collection.slug) !== collection).map(collection => collection.slug)\n });\n for (const collection of collections) if (!reached.has(collection.slug)) reached.set(collection.slug, collection);\n }\n }\n // A builder whose collections another builder returns too (`buildContent()` inside `getAll()`) is part of that one's step.\n const outer = builders.filter(builder => !builders.some(other => other !== builder && other.slugs.length > builder.slugs.length && builder.slugs.every(slug => other.slugs.includes(slug))));\n builders.splice(0, builders.length, ...outer);\n const fileOf = new Map<string, string>();\n for (const [file, collection] of byFile) if (!fileOf.has(collection.slug)) fileOf.set(collection.slug, file);\n const built = [...reached.values()].map(collection => {\n const file = fileOf.get(collection.slug);\n return { collection, ...(file ? { file } : {}) };\n });\n return { built, builders };\n}\n\nfunction isSecurityRuleList(value: unknown): value is SecurityRule[] {\n return Array.isArray(value) && value.every(rule => typeof rule === \"object\" && rule !== null);\n}\n\nfunction isCollection(value: unknown): value is LegacyCollectionConfig {\n return typeof value === \"object\" && value !== null && \"slug\" in value && typeof value.slug === \"string\";\n}\n\n/** Thrown when the legacy project cannot be evaluated: its own loader would refuse it too. */\nexport class LegacyLoadError extends Error {\n constructor(message: string, readonly file?: string) {\n super(message);\n }\n}\n\n/**\n * Evaluate `<config>/collections` of a project.\n *\n * @param configDir the config directory, absolute\n */\nexport async function loadLegacyProject(configDir: string, importModule: ModuleImporter): Promise<LegacyProject> {\n const collectionsDir = path.join(configDir, \"collections\");\n if (!fs.existsSync(collectionsDir) || !fs.statSync(collectionsDir).isDirectory()) {\n throw new LegacyLoadError(`There is no ${collectionsDir} directory: nothing to migrate.`, collectionsDir);\n }\n const files = fs.readdirSync(collectionsDir)\n .filter(file => isLegacyCollectionFile(file) && fs.statSync(path.join(collectionsDir, file)).isFile())\n .sort();\n const collections: LoadedCollection[] = [];\n const helperFiles: string[] = [];\n const failures: string[] = [];\n for (const file of files) {\n const full = path.join(collectionsDir, file);\n try {\n const mod = await importModule(full);\n const exported = mod.default;\n if (isCollection(exported)) collections.push({ collection: exported, file: full });\n // Nothing in it is a collection: a helper. A collection exported by\n // name, or a default export that is something else, may be a table\n // the project serves — dropping it would drop the table — so those\n // still refuse.\n else if (exported === undefined && !Object.values(mod).some(isCollection)) helperFiles.push(full);\n else failures.push(`${file}: no default export of a collection`);\n } catch (error) {\n failures.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n if (failures.length > 0) {\n throw new LegacyLoadError(\n `Could not load ${failures.length} collection file(s) from ${collectionsDir}:\\n` +\n failures.map(failure => ` • ${failure}`).join(\"\\n\") +\n \"\\n\\nThe codemod reads the collections exactly as the server does; fix these files first (the server refuses them too).\"\n );\n }\n\n let defaultSecurityRules: SecurityRule[] | undefined;\n let navigationOrder: LegacyCollectionConfig[] | undefined;\n const collectionsIndex = [\"index.ts\", \"index.js\", \"index.tsx\"].map(name => path.join(collectionsDir, name)).find(file => fs.existsSync(file));\n for (const name of [\"index.ts\", \"index.js\", \"index.tsx\"]) {\n const indexFile = path.join(collectionsDir, name);\n if (!fs.existsSync(indexFile)) continue;\n let mod: Record<string, unknown>;\n try {\n mod = await importModule(indexFile);\n } catch (error) {\n throw new LegacyLoadError(\n `Could not load ${indexFile}: ${error instanceof Error ? error.message : String(error)}. ` +\n \"It may declare `defaultSecurityRules`, which decide the policies of every collection without rules; the codemod will not guess them.\",\n indexFile\n );\n }\n const rules = mod.defaultSecurityRules;\n // The array itself, not a copy: an index that applies its defaults in a\n // loop put this very array on each collection, and the lift reads that\n // identity as \"inherits\".\n if (isSecurityRuleList(rules)) defaultSecurityRules = rules;\n const listed = mod.collections;\n if (Array.isArray(listed)) navigationOrder = listed.filter(isCollection);\n break;\n }\n\n // The loader's rule: references resolved, then the defaults given to every\n // Postgres collection that declares no rules of its own — the same array,\n // so the lift can tell an inherited posture from a declared one.\n for (const entry of collections) entry.collection = resolveResourceRefs(entry.collection);\n if (defaultSecurityRules && defaultSecurityRules.length > 0) {\n for (const { collection } of collections) {\n if (isLegacyPostgresCollection(collection) && !collection.securityRules?.length) {\n collection.securityRules = defaultSecurityRules;\n }\n }\n }\n\n const configIndexExports: string[] = [];\n for (const name of [\"index.ts\", \"index.js\"]) {\n const indexFile = path.join(configDir, name);\n if (!fs.existsSync(indexFile)) continue;\n try {\n configIndexExports.push(...Object.keys(await importModule(indexFile)));\n } catch {\n // The config index only re-exports; the collections were read above.\n }\n break;\n }\n\n const { built: builtFirestore, builders: firestoreBuilders } = await findBuiltFirestore(collectionsDir, collectionsIndex, importModule);\n const topLevel = new Set(collections.map(entry => entry.collection.slug));\n\n return {\n configDir,\n collectionsDir,\n collections,\n builtFirestore: builtFirestore.filter(entry => !topLevel.has(entry.collection.slug)),\n firestoreBuilders,\n ...(defaultSecurityRules ? { defaultSecurityRules } : {}),\n ...(navigationOrder ? { navigationOrder } : {}),\n configIndexExports,\n helperFiles\n };\n}\n","/**\n * Path aliases a project imports `config/` through.\n *\n * A frontend often reaches `config/` as `@config/collections/posts` — a\n * tsconfig `paths` entry for the type checker, a Vite `resolve.alias` for the\n * bundler. Such an import is an import of `config/` like a relative one, so\n * the codemod resolves both kinds of alias to the file they name and treats\n * the import as if it had been written relative.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { toPosix } from \"./ast\";\n\n/** One alias: `prefix` (with its trailing `/` for a wildcard) → an absolute path. */\nexport interface PathAlias {\n /** What a specifier starts with: `@config/` for `@config/*`, `@config` for a Vite alias, the whole key for an exact entry. */\n prefix: string;\n /** Whether the rest of the specifier is appended to `target` (`@config/*`, or a Vite alias). */\n wildcard: boolean;\n /** Exact (non-wildcard) Vite aliases also match `prefix/…`. */\n vite: boolean;\n /** The directory (wildcard) or module (exact) it names, absolute. */\n target: string;\n /** The directory whose files the alias applies to (the tsconfig's or Vite config's), absolute. */\n scope: string;\n}\n\nconst IGNORED = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\"]);\n\n/** JSON with comments and trailing commas, as tsconfig files are written. */\nfunction parseJsonc(text: string): unknown {\n let out = \"\";\n let index = 0;\n while (index < text.length) {\n const char = text[index];\n if (char === \"\\\"\") {\n const start = index++;\n while (index < text.length && text[index] !== \"\\\"\") index += text[index] === \"\\\\\" ? 2 : 1;\n out += text.slice(start, ++index);\n } else if (char === \"/\" && text[index + 1] === \"/\") {\n while (index < text.length && text[index] !== \"\\n\") index++;\n } else if (char === \"/\" && text[index + 1] === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n index = end === -1 ? text.length : end + 2;\n } else {\n out += char;\n index++;\n }\n }\n return JSON.parse(out.replace(/,(\\s*[}\\]])/g, \"$1\"));\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction tsconfigAliases(file: string): PathAlias[] {\n let json: unknown;\n try {\n json = parseJsonc(fs.readFileSync(file, \"utf8\"));\n } catch {\n return [];\n }\n const options = isRecord(json) && isRecord(json.compilerOptions) ? json.compilerOptions : undefined;\n if (!options || !isRecord(options.paths)) return [];\n const dir = path.dirname(file);\n const base = typeof options.baseUrl === \"string\" ? path.resolve(dir, options.baseUrl) : dir;\n const out: PathAlias[] = [];\n for (const [key, value] of Object.entries(options.paths)) {\n const first = Array.isArray(value) ? value.find((entry): entry is string => typeof entry === \"string\") : undefined;\n if (first === undefined) continue;\n const wildcard = key.endsWith(\"/*\") && first.endsWith(\"/*\");\n if (!wildcard && (key.includes(\"*\") || first.includes(\"*\"))) continue;\n out.push(wildcard\n ? { prefix: key.slice(0, -1), wildcard: true, vite: false, target: path.resolve(base, first.slice(0, -2)), scope: dir }\n : { prefix: key, wildcard: false, vite: false, target: path.resolve(base, first), scope: dir });\n }\n return out;\n}\n\n/** `\"@x\": path.resolve(__dirname, \"../config\")` (or `resolve(…)`, `import.meta.dirname`) in a Vite config. */\nconst VITE_ALIAS = /[\"']([^\"'\\s]+)[\"']\\s*:\\s*(?:path\\.)?resolve\\(\\s*(?:__dirname|import\\.meta\\.dirname)\\s*,\\s*[\"']([^\"']+)[\"']\\s*\\)/g;\n\nfunction viteAliases(file: string): PathAlias[] {\n const text = fs.readFileSync(file, \"utf8\");\n const dir = path.dirname(file);\n return [...text.matchAll(VITE_ALIAS)].map(match => ({ prefix: match[1], wildcard: true, vite: true, target: path.resolve(dir, match[2]), scope: dir }));\n}\n\n/**\n * Every alias the project's tsconfig files (`compilerOptions.paths`) and Vite\n * configs (`resolve.alias` written as `path.resolve(__dirname, …)`) declare,\n * in the project root and the directories below it. A tsconfig that extends\n * another is read as written: its own `paths` only.\n */\nexport function readPathAliases(root: string): PathAlias[] {\n const out: PathAlias[] = [];\n const visit = (dir: string, depth: number): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || IGNORED.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (depth < 2) visit(full, depth + 1);\n } else if (/^tsconfig.*\\.json$/.test(entry.name)) {\n out.push(...tsconfigAliases(full));\n } else if (/^vite\\.config\\.(ts|mts|js|mjs)$/.test(entry.name)) {\n out.push(...viteAliases(full));\n }\n }\n };\n visit(root, 0);\n return out;\n}\n\n/**\n * The relative specifier an aliased one stands for, from `fromFile` — or\n * undefined when no alias in scope matches it. Longer prefixes win, as both\n * TypeScript and Vite match the most specific entry.\n */\nexport function aliasToRelative(aliases: readonly PathAlias[], fromFile: string, specifier: string): string | undefined {\n const inScope = aliases\n .filter(alias => {\n const relative = path.relative(alias.scope, fromFile);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n })\n .sort((a, b) => b.prefix.length - a.prefix.length);\n for (const alias of inScope) {\n let target: string | undefined;\n if (alias.vite) {\n if (specifier === alias.prefix) target = alias.target;\n else if (specifier.startsWith(`${alias.prefix}/`)) target = path.join(alias.target, specifier.slice(alias.prefix.length + 1));\n } else if (alias.wildcard) {\n if (specifier.startsWith(alias.prefix)) target = path.join(alias.target, specifier.slice(alias.prefix.length));\n } else if (specifier === alias.prefix) {\n target = alias.target.replace(/\\.(tsx?|mts)$/, \"\");\n }\n if (target === undefined) continue;\n const relative = toPosix(path.relative(path.dirname(fromFile), target));\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n }\n return undefined;\n}\n","/**\n * Everything around the collections: `rebase.json`, the workspace, the\n * packages and tsconfigs that named the config package, the other modules of\n * `config/` (resources, storage access, the generated registration), and the\n * frontend's wiring.\n *\n * Arbitrary code is never rewritten. A file in the scaffold's known shape —\n * the `App.tsx`, `vite.config.ts` and `virtual.d.ts` `rebase init` writes — is\n * rewritten exactly; anything else is reported as a manual step with the\n * snippet to apply. The Vite config gains `rebaseBackendGuard()` either way.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { AstContext } from \"./ast\";\nimport { toPosix } from \"./ast\";\nimport { aliasToRelative, type PathAlias } from \"./path-aliases\";\nimport { resolveRelative } from \"./modules\";\nimport type { PlanContext } from \"./plan-context\";\nimport type { ManualStep } from \"./types\";\nimport { note, planFile, relativeToRoot } from \"./plan-context\";\nimport { BACKEND_GUARD_EXPORT, BACKEND_GUARD_SNIPPET } from \"../../utils/backend-guard\";\n\ntype JsonObject = Record<string, unknown>;\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readJson(file: string): { value: JsonObject; text: string } | undefined {\n if (!fs.existsSync(file)) return undefined;\n const text = fs.readFileSync(file, \"utf8\");\n try {\n const value: unknown = JSON.parse(text);\n return isObject(value) ? { value, text } : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** JSON written back with the file's own indentation and trailing newline. */\nfunction writeJson(original: string, value: JsonObject): string {\n const indent = /\\n([ \\t]+)\"/.exec(original)?.[1] ?? \" \";\n return `${JSON.stringify(value, null, indent)}${original.endsWith(\"\\n\") ? \"\\n\" : \"\"}`;\n}\n\n/** What `rebase.json` says about the layout, read raw (the CLI's parser refuses the legacy keys). */\nexport interface RawManifest {\n file: string;\n text: string;\n value: JsonObject;\n /** The backend app's key in `apps`. */\n backendName?: string;\n /** The config directory, relative to the root. */\n configDir: string;\n /** The frontend (static) app's root, relative to the root, when there is one. */\n frontendRoot?: string;\n}\n\n/** Read `rebase.json`, if there is one. */\nexport function readRawManifest(root: string): RawManifest {\n const file = path.join(root, \"rebase.json\");\n const read = readJson(file);\n const apps = read && isObject(read.value.apps) ? read.value.apps : {};\n let backendName: string | undefined;\n let configDir = \"config\";\n let frontendRoot: string | undefined;\n for (const [name, app] of Object.entries(apps)) {\n if (!isObject(app)) continue;\n if (app.type === \"backend\" && backendName === undefined) {\n backendName = name;\n if (typeof app.config === \"string\") configDir = app.config;\n }\n if (app.type === \"static\" && frontendRoot === undefined && typeof app.root === \"string\" && typeof app.cms === \"string\") {\n frontendRoot = app.root;\n }\n }\n if (frontendRoot === undefined && fs.existsSync(path.join(root, \"frontend\", \"src\"))) frontendRoot = \"frontend\";\n return { file, text: read?.text ?? \"\", value: read?.value ?? {}, ...(backendName ? { backendName } : {}), configDir, ...(frontendRoot ? { frontendRoot } : {}) };\n}\n\n/** `rebase.json` without `config` and `usersCollection` (the tables directory is the default, so no `tables` key). */\nexport function planManifest(plan: PlanContext, manifest: RawManifest): void {\n if (!manifest.text || !manifest.backendName) return;\n const apps = manifest.value.apps;\n if (!isObject(apps)) return;\n const backend = apps[manifest.backendName];\n if (!isObject(backend) || (!(\"config\" in backend) && !(\"usersCollection\" in backend))) return;\n const { config: _config, usersCollection: _users, ...rest } = backend;\n void _config;\n void _users;\n const next = { ...manifest.value, apps: { ...apps, [manifest.backendName]: rest } };\n planFile(plan, manifest.file, writeJson(manifest.text, next), \"rebase.json\");\n}\n\n/** The config package's name, from `config/package.json`. */\nfunction configPackageName(configDir: string): string | undefined {\n const read = readJson(path.join(configDir, \"package.json\"));\n return read && typeof read.value.name === \"string\" ? read.value.name : undefined;\n}\n\nconst COLLECTIONS_FLAG = /\\s+--collections(?:=|\\s+)\\S+/g;\n\n/** `--filter \"./config\"` (any quoting) in a workspace script: the package is gone. */\nfunction withoutConfigFilter(script: string, configRelative: string): string {\n const escaped = configRelative.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return script.replace(new RegExp(`\\\\s+--filter(?:=|\\\\s+)([\"']?)(?:\\\\./)?${escaped}\\\\1(?=\\\\s|$)`, \"g\"), \"\");\n}\n\n/** The workspace, the packages and the scripts that named the config package or directory. */\nexport function planWorkspace(plan: PlanContext, configDir: string, frontendRoot: string | undefined, keepConfigPackage = false): void {\n // When config/ keeps modules of the project's own, it stays a workspace\n // package, depended on as before: only the collections flags go.\n const root = plan.root;\n const configRelative = relativeToRoot(plan, configDir);\n const packageName = configPackageName(configDir);\n\n const rootPackage = readJson(path.join(root, \"package.json\"));\n if (rootPackage) {\n const value = { ...rootPackage.value };\n let changed = false;\n if (Array.isArray(value.workspaces) && !keepConfigPackage) {\n const kept = value.workspaces.filter(entry => entry !== configRelative && entry !== `./${configRelative}`);\n if (kept.length !== value.workspaces.length) {\n value.workspaces = kept;\n changed = true;\n }\n }\n if (isObject(value.scripts)) {\n const scripts: JsonObject = {};\n for (const [name, script] of Object.entries(value.scripts)) {\n const flagless = typeof script === \"string\" ? script.replace(COLLECTIONS_FLAG, \"\") : script;\n const next = typeof flagless === \"string\" && !keepConfigPackage ? withoutConfigFilter(flagless, configRelative) : flagless;\n if (next !== script) changed = true;\n scripts[name] = next;\n }\n value.scripts = scripts;\n }\n if (changed) planFile(plan, path.join(root, \"package.json\"), writeJson(rootPackage.text, value), \"package.json (workspaces, scripts)\");\n }\n\n const workspaceFile = path.join(root, \"pnpm-workspace.yaml\");\n if (fs.existsSync(workspaceFile) && !keepConfigPackage) {\n const text = fs.readFileSync(workspaceFile, \"utf8\");\n const escaped = configRelative.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const next = text.replace(new RegExp(`^[ \\\\t]*-[ \\\\t]*[\"']?(?:\\\\./)?${escaped}[\"']?[ \\\\t]*\\\\r?\\\\n`, \"m\"), \"\");\n if (next !== text) planFile(plan, workspaceFile, next, \"pnpm-workspace.yaml\");\n }\n\n const members = [\"backend\", ...(frontendRoot ? [frontendRoot] : [])];\n for (const member of members) {\n const file = path.join(root, member, \"package.json\");\n const read = readJson(file);\n if (!read) continue;\n const value = { ...read.value };\n let changed = false;\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const deps = value[field];\n if (!isObject(deps) || packageName === undefined || !(packageName in deps) || keepConfigPackage) continue;\n const { [packageName]: _removed, ...rest } = deps;\n void _removed;\n value[field] = rest;\n changed = true;\n }\n if (isObject(value.scripts)) {\n const scripts: JsonObject = {};\n for (const [name, script] of Object.entries(value.scripts)) {\n let next = script;\n if (typeof script === \"string\") {\n const flagless = script.replace(COLLECTIONS_FLAG, \"\");\n next = keepConfigPackage ? flagless : flagless.replace(/\\s+--watch=\\.\\.\\/config\\/\\S*/g, \"\");\n }\n if (next !== script) changed = true;\n scripts[name] = next;\n }\n value.scripts = scripts;\n }\n if (changed) planFile(plan, file, writeJson(read.text, value), `${member}/package.json`);\n if (member === \"backend\") {\n const deps = isObject(value.dependencies) ? value.dependencies : {};\n if (!(\"@rebasepro/server\" in deps)) {\n const sibling = Object.entries(deps).find(([name]) => name.startsWith(\"@rebasepro/\"))?.[1];\n plan.manualSteps.push({\n title: \"Add @rebasepro/server to the backend\",\n detail: \"The schema modules import their builders from `@rebasepro/server/schema`, and backend/package.json does not depend on `@rebasepro/server`. Add it beside the other @rebasepro packages, then install.\",\n snippet: `\"@rebasepro/server\": ${JSON.stringify(typeof sibling === \"string\" ? sibling : \"<the version of your other @rebasepro packages>\")}`,\n file: relativeToRoot(plan, file)\n });\n }\n }\n }\n}\n\n/** The comment the scaffold now writes above `rootDir`. */\nconst ROOT_DIR_COMMENT = [\n \" // Everything this program compiles lives under backend/, so the emit\",\n \" // mirrors it: `dist/schema/…`, `dist/functions/…`, `dist/src/…`. Saying so\",\n \" // is required from TypeScript 6, which refuses to infer it (TS5011).\"\n];\n\n/** The `//` comment lines directly above line `index`. */\nfunction commentBlockAbove(lines: readonly string[], index: number): { start: number; end: number } {\n let start = index;\n while (start > 0 && /^\\s*\\/\\//.test(lines[start - 1])) start--;\n return { start, end: index };\n}\n\n/** Drop the paragraphs of a `//` comment block that talk about the config package. */\nfunction withoutConfigParagraphs(block: readonly string[]): string[] {\n const paragraphs: string[][] = [[]];\n for (const line of block) {\n if (/^\\s*\\/\\/\\s*$/.test(line)) paragraphs.push([line]);\n else paragraphs[paragraphs.length - 1].push(line);\n }\n const kept = paragraphs.filter(paragraph => !paragraph.some(line => /\\.\\.\\/config\\b|config\\/\\*\\*|\\bconfig (package|workspace)\\b/.test(line)));\n const out = kept.flat();\n while (out.length > 0 && /^\\s*\\/\\/\\s*$/.test(out[0])) out.shift();\n return out;\n}\n\n/**\n * backend/tsconfig.json once `config/` is gone: `../config/**` out of\n * `include` and the new modules in; `rootDir \"..\"` (which existed only so the\n * program could reach ../config) back to `\".\"`, its comment and the include's\n * comment rid of the config package; a `drizzle.config.ts` include that names\n * no file dropped. With `rootDir \".\"` the emit moves from `dist/backend/src` to\n * `dist/src`, so the scripts, `entrypoint.sh` and Dockerfile that name the old\n * path follow. A tsconfig not in that shape is a manual step.\n */\nexport function planBackendTsconfig(plan: PlanContext, wanted: readonly string[], keepConfig = false): void {\n const backendDir = path.join(plan.root, \"backend\");\n const file = path.join(backendDir, \"tsconfig.json\");\n if (!fs.existsSync(file)) return;\n const original = fs.readFileSync(file, \"utf8\");\n const match = /\"include\"\\s*:\\s*\\[([^\\]]*)\\]/.exec(original);\n const entries = match ? [...match[1].matchAll(/\"((?:[^\"\\\\]|\\\\.)*)\"/g)].map(found => found[1]) : [];\n const namesConfig = entries.some(entry => entry.startsWith(\"../config\"));\n const rootUp = /\"rootDir\"\\s*:\\s*\"\\.\\.\"/.test(original);\n if (keepConfig) {\n // The backend still compiles the project's own modules of config/: only add what the migration writes.\n if (!match) return;\n const covers = (pattern: string): boolean => entries.includes(pattern) || entries.includes(\"**/*\") || entries.includes(\"**/*.ts\");\n const missing = wanted.filter(entry => !covers(entry));\n if (missing.length === 0) return;\n const next = [...entries, ...missing];\n planFile(plan, file, `${original.slice(0, match.index)}\"include\": [${next.map(entry => JSON.stringify(entry)).join(\", \")}]${original.slice(match.index + match[0].length)}`, \"backend/tsconfig.json\");\n return;\n }\n if (!namesConfig && !rootUp) return;\n if (!match) {\n plan.manualSteps.push({\n title: \"Point backend/tsconfig.json at the backend only\",\n detail: \"backend/tsconfig.json has `rootDir: \\\"..\\\"` (it compiled ../config) but no `include` the codemod can read. Set `rootDir` to `\\\".\\\"`, include `schema/**/*` and the other backend modules, and run the built entry from `dist/src/` (it was `dist/backend/src/`).\",\n file: relativeToRoot(plan, file)\n });\n return;\n }\n const kept = entries.filter(entry => !entry.startsWith(\"../config\") && !(entry === \"drizzle.config.ts\" && !fs.existsSync(path.join(backendDir, entry))));\n const covers = (pattern: string): boolean => kept.includes(pattern) || kept.includes(\"**/*\") || kept.includes(\"**/*.ts\");\n const next = [...kept, ...wanted.filter(entry => !covers(entry))];\n let text = `${original.slice(0, match.index)}\"include\": [${next.map(entry => JSON.stringify(entry)).join(\", \")}]${original.slice(match.index + match[0].length)}`;\n\n const lines = text.split(\"\\n\");\n const includeLine = lines.findIndex(line => /\"include\"\\s*:/.test(line));\n if (includeLine >= 0) {\n const block = commentBlockAbove(lines, includeLine);\n lines.splice(block.start, block.end - block.start, ...withoutConfigParagraphs(lines.slice(block.start, block.end)));\n }\n let movedEmit = false;\n const rootLine = lines.findIndex(line => /\"rootDir\"\\s*:\\s*\"\\.\\.\"/.test(line));\n if (rootLine >= 0) {\n lines[rootLine] = lines[rootLine].replace(/\"rootDir\"\\s*:\\s*\"\\.\\.\"/, `\"rootDir\": \".\"`);\n const block = commentBlockAbove(lines, rootLine);\n const comments = lines.slice(block.start, block.end);\n if (comments.length === 0 || comments.some(line => /config/.test(line))) lines.splice(block.start, block.end - block.start, ...ROOT_DIR_COMMENT);\n movedEmit = true;\n }\n // No `rootDir` at all: tsc took the common directory of the inputs, which `../config/**`\n // lifted to the project root. Without it that directory is backend/, so the emit moves the same way.\n if (namesConfig && !/\"rootDir\"\\s*:/.test(original)) movedEmit = true;\n text = lines.join(\"\\n\");\n planFile(plan, file, text, \"backend/tsconfig.json\");\n if (movedEmit) planEmitPathMove(plan);\n}\n\n/** `dist/backend/src` → `dist/src` wherever the project names the old emit path. */\nfunction planEmitPathMove(plan: PlanContext): void {\n const candidates = [\n path.join(plan.root, \"package.json\"),\n path.join(plan.root, \"backend\", \"package.json\"),\n path.join(plan.root, \"backend\", \"entrypoint.sh\"),\n path.join(plan.root, \"backend\", \"Dockerfile\"),\n path.join(plan.root, \"Dockerfile\")\n ];\n for (const candidate of candidates) {\n const planned = plan.files.get(candidate);\n const current = planned?.content ?? (fs.existsSync(candidate) ? fs.readFileSync(candidate, \"utf8\") : undefined);\n if (current === undefined || !current.includes(\"dist/backend/\")) continue;\n const next = current.split(\"dist/backend/\").join(\"dist/\");\n plan.files.set(candidate, { content: next, role: planned ? `${planned.role}, emit path` : `${relativeToRoot(plan, candidate)} (emit path dist/src)` });\n }\n}\n\n/** A legacy config module that moves to `backend/`, with its imports moved. */\nexport function planMove(plan: PlanContext, from: string, to: string, role: string): boolean {\n if (!fs.existsSync(from)) return false;\n const text = fs.readFileSync(from, \"utf8\");\n planFile(plan, to, plan.relocator.moveSpecifiersInText(text, from, to, \"backend\"), role);\n return true;\n}\n\nconst SCAFFOLD_COLLECTIONS_IMPORT = `import { collections } from \"virtual:rebase-collections\";`;\nconst SCAFFOLD_COLLECTIONS_PROP = \"collections={collections}\";\n\n/**\n * The file the collection editor writes presentation to in development, as\n * `rebase init` ships it (`templates/template/frontend/src/cms/ui-config.json`),\n * and the two lines that mount it — the import and the `<RebaseCMS>` prop.\n */\nexport const UI_CONFIG_CONTENT = \"{\\n \\\"tables\\\": {}\\n}\\n\";\nconst UI_CONFIG_IMPORT = \"// How the collection editor laid out the tables in development (labels, columns, views).\\nimport uiConfig from \\\"./cms/ui-config.json\\\";\";\nconst UI_CONFIG_PROP = \"uiConfig={uiConfig}\";\n\n/** The frontend's wiring: `App.tsx`, `vite.config.ts`, `virtual.d.ts`, `src/cms/ui-config.json`. */\nexport function planFrontendWiring(plan: PlanContext, frontendDir: string, hasExternal: boolean): void {\n const names = hasExternal ? \"tableCustomizations, externalCollections\" : \"tableCustomizations\";\n const appFile = path.join(frontendDir, \"src\", \"App.tsx\");\n\n // The collection editor's file: created empty, never overwritten. Without\n // it mounted, what the editor saves in development is gone on reload and\n // never ships.\n const uiConfigFile = path.join(frontendDir, \"src\", \"cms\", \"ui-config.json\");\n const appText = fs.existsSync(appFile) ? fs.readFileSync(appFile, \"utf8\") : \"\";\n const mountsUiConfig = /\\buiConfig\\s*=/.test(appText);\n if (!fs.existsSync(uiConfigFile) && !plan.files.has(uiConfigFile)) {\n planFile(plan, uiConfigFile, UI_CONFIG_CONTENT, \"ui-config.json (the collection editor's presentation file)\");\n }\n const wireUiConfig = !mountsUiConfig;\n const cmsSpecifier = plan.specifierStyle === \"js\" ? \"./cms/index.js\" : \"./cms\";\n const importLine = `import { ${names} } from \"${cmsSpecifier}\";${wireUiConfig ? `\\n${UI_CONFIG_IMPORT}` : \"\"}`;\n const props = [\n \"tableCustomizations={tableCustomizations}\",\n ...(hasExternal ? [\"externalCollections={externalCollections}\"] : []),\n ...(wireUiConfig ? [UI_CONFIG_PROP] : [])\n ];\n if (wireUiConfig) {\n const tsconfig = path.join(frontendDir, \"tsconfig.json\");\n const tsconfigText = fs.existsSync(tsconfig) ? fs.readFileSync(tsconfig, \"utf8\") : undefined;\n if (tsconfigText !== undefined && !tsconfigText.includes(\"resolveJsonModule\") && !tsconfigText.includes(\"\\\"extends\\\"\")) {\n note(plan, undefined, `${relativeToRoot(plan, tsconfig)} does not set \\`resolveJsonModule\\`; the type check needs it for \\`import uiConfig from \"./cms/ui-config.json\"\\` (Vite itself imports JSON as is).`);\n }\n }\n const mountStep = (file: string) => plan.manualSteps.push({\n title: \"Mount the table customizations\",\n detail: \"The admin panel no longer takes `collections`: it projects every table from the backend and layers the customizations over it. Replace the `virtual:rebase-collections` import and the `collections` prop of `<RebaseCMS>`.\" +\n (wireUiConfig ? \" Pass `uiConfig` too: in development the collection editor saves presentation to src/cms/ui-config.json, and without the prop it is lost on reload and never ships.\" : \"\"),\n snippet: `${importLine}\\n\\n<RebaseCMS\\n ${props.join(\"\\n \")}\\n {/* …the other props you pass */}\\n/>`,\n file: relativeToRoot(plan, file)\n });\n const mountsCollections = (text: string) => text.includes(\"virtual:rebase-collections\") || /<RebaseCMS[\\s\\S]*?collections=/.test(text);\n if (fs.existsSync(appFile) && (appText.includes(SCAFFOLD_COLLECTIONS_IMPORT) || mountsCollections(appText))) {\n const text = appText;\n const importCount = text.split(SCAFFOLD_COLLECTIONS_IMPORT).length - 1;\n const propCount = text.split(SCAFFOLD_COLLECTIONS_PROP).length - 1;\n // Any other `collections` in the code is a use the rewrite would break,\n // so it falls back to the printed step. A comment that says the word is\n // not one: SongBuzz's admin, `{/* … what the collections don't show */}`\n // beside <RebaseStudio/>, was left for its author to migrate by hand.\n const rest = withoutComments(text.replace(SCAFFOLD_COLLECTIONS_IMPORT, \"\").replace(SCAFFOLD_COLLECTIONS_PROP, \"\"));\n if (importCount === 1 && propCount === 1 && !/\\bcollections\\b/.test(rest)) {\n const propLine = text.split(\"\\n\").find(line => line.includes(SCAFFOLD_COLLECTIONS_PROP)) ?? \"\";\n const indent = /^[ \\t]*/.exec(propLine)?.[0] ?? \"\";\n const next = text\n .replace(SCAFFOLD_COLLECTIONS_IMPORT, importLine)\n .replace(SCAFFOLD_COLLECTIONS_PROP, props.join(`\\n${indent}`));\n planFile(plan, appFile, next, \"App.tsx (mount the customizations)\");\n } else {\n mountStep(appFile);\n }\n } else {\n // The panel is mounted somewhere other than src/App.tsx (an `AdminApp.tsx`, a\n // route module): name every source file that still imports the collections\n // module or passes `collections` to <RebaseCMS>, or nothing tells the author.\n for (const file of frontendSourceFiles(path.join(frontendDir, \"src\"))) {\n if (mountsCollections(fs.readFileSync(file, \"utf8\"))) mountStep(file);\n }\n }\n\n const viteFile = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\"].map(name => path.join(frontendDir, name)).find(candidate => fs.existsSync(candidate));\n if (viteFile) planViteConfig(plan, viteFile);\n\n const virtualFile = path.join(frontendDir, \"src\", \"virtual.d.ts\");\n if (fs.existsSync(virtualFile)) {\n const text = fs.readFileSync(virtualFile, \"utf8\");\n const block = /\\r?\\n?declare module \"virtual:rebase-collections\" \\{\\s*export const collections: [^;]+;\\s*\\}\\r?\\n?/;\n if (block.test(text)) {\n planFile(plan, virtualFile, text.replace(block, \"\\n\").replace(/\\n{3,}/g, \"\\n\\n\"), \"virtual.d.ts (drop the collections module)\");\n } else if (text.includes(\"virtual:rebase-collections\")) {\n plan.manualSteps.push({\n title: \"Drop the virtual collections module declaration\",\n detail: \"Remove the `declare module \\\"virtual:rebase-collections\\\"` block: nothing provides it any more.\",\n file: relativeToRoot(plan, virtualFile)\n });\n }\n }\n}\n\n/**\n * A TSX source with its `//` and block comments blanked out.\n *\n * For one question only — does a word still occur in the code — so it may be\n * coarse: a `//` inside a string (a URL) cuts the rest of that line, which can\n * only hide a use on a line that also holds a URL, and the rewrite it guards is\n * checked by the build that follows.\n */\nfunction withoutComments(text: string): string {\n return text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \" \").replace(/(^|[^:\"'`])\\/\\/[^\\n]*/g, \"$1\");\n}\n\n/** The frontend's own .ts/.tsx sources (no declaration files, no node_modules, not the generated cms/). */\nfunction frontendSourceFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const out: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (entry.name !== \"node_modules\" && entry.name !== \"cms\") out.push(...frontendSourceFiles(full));\n } else if (/\\.tsx?$/.test(entry.name) && !entry.name.endsWith(\".d.ts\")) {\n out.push(full);\n }\n }\n return out.sort();\n}\n\n/**\n * The frontend's Vite config: the collections plugin goes, the backend guard\n * comes.\n *\n * `rebaseCollectionsPlugin` built the panel's collections from\n * config/collections and kept their server half out of the browser bundle.\n * Tables now live in backend/ with their hooks, and the frontend references\n * them as types; `rebaseBackendGuard()` is what refuses a value import of\n * backend/ in the build (and `rebase build` refuses a frontend without it).\n * In the scaffold's shape — the plugin on a line of its own, imported from\n * `@rebasepro/app/vitePlugin` — the one becomes the other in place; any other\n * shape is a manual step with the exact lines.\n */\nfunction planViteConfig(plan: PlanContext, viteFile: string): void {\n const text = fs.readFileSync(viteFile, \"utf8\");\n const guarded = /\\brebaseBackendGuard\\s*\\(/.test(text);\n const pluginLine = /^([ \\t]*)rebaseCollectionsPlugin\\(\\{\\s*collectionsDir:\\s*[\"'][^\"']*[\"']\\s*\\}\\)(,?)[ \\t]*(\\r?\\n)/m;\n const importLine = /(import\\s*\\{[^}]*?)\\brebaseCollectionsPlugin\\b([^}]*\\}\\s*from\\s*[\"']@rebasepro\\/app\\/vitePlugin[\"'])/;\n const scaffoldShape = pluginLine.test(text) && importLine.test(text) && (text.match(/rebaseCollectionsPlugin/g) ?? []).length === 2;\n if (scaffoldShape) {\n const next = guarded\n ? text\n .replace(pluginLine, \"\")\n .replace(/(import\\s*\\{[^}]*?)\\brebaseCollectionsPlugin\\s*,\\s*/, \"$1\")\n .replace(/(import\\s*\\{[^}]*?),\\s*rebaseCollectionsPlugin\\b/, \"$1\")\n : text\n .replace(pluginLine, (_line, indent: string, comma: string, eol: string) => `${indent}${BACKEND_GUARD_EXPORT}()${comma}${eol}`)\n .replace(importLine, `$1${BACKEND_GUARD_EXPORT}$2`);\n planFile(plan, viteFile, next, guarded ? \"vite config (drop the collections plugin)\" : \"vite config (the collections plugin → rebaseBackendGuard)\");\n return;\n }\n if (text.includes(\"rebaseCollectionsPlugin\")) {\n plan.manualSteps.push({\n title: \"Remove the collections Vite plugin\",\n detail: \"`rebaseCollectionsPlugin` built the panel's collections from config/collections, which no longer exists. Remove it from the plugins (and its import); keep `rebaseMcpViewPlugin`.\",\n file: relativeToRoot(plan, viteFile)\n });\n }\n if (!guarded) {\n plan.manualSteps.push({\n title: \"Add the backend guard to the Vite config\",\n detail: \"The frontend imports the tables in backend/ as types only; a value import would ship their server hooks, and every module and secret they reach, to every visitor. \" +\n \"`rebaseBackendGuard()` fails the build and the dev server when anything in the frontend resolves to a file under backend/, and `rebase build` refuses a frontend whose Vite config does not use it.\",\n snippet: BACKEND_GUARD_SNIPPET,\n file: relativeToRoot(plan, viteFile)\n });\n }\n}\n\n/**\n * The other static apps `rebase.json` declares (a public site beside the\n * panel): `rebase build` refuses every one whose Vite config lacks\n * `rebaseBackendGuard()`, not only `frontend/`. Each without it is a manual\n * step — the codemod does not add a dependency on `@rebasepro/app` to an app\n * that may not have one.\n */\nexport function planStaticAppGuards(plan: PlanContext, frontendDir: string | undefined): void {\n // Read raw: a legacy rebase.json (a backend `config` key) does not validate against today's manifest.\n const read = readJson(path.join(plan.root, \"rebase.json\"));\n const apps = read && isObject(read.value.apps) ? Object.values(read.value.apps) : [];\n const roots = apps.flatMap(app => (isObject(app) && app.type === \"static\" && typeof app.root === \"string\" ? [path.resolve(plan.root, app.root)] : []));\n for (const root of new Set(roots)) {\n if (root === plan.root || (frontendDir && root === path.resolve(frontendDir))) continue;\n const viteFile = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\"].map(name => path.join(root, name)).find(file => fs.existsSync(file));\n if (!viteFile || /\\brebaseBackendGuard\\s*\\(/.test(fs.readFileSync(viteFile, \"utf8\"))) continue;\n const pkgFile = path.join(root, \"package.json\");\n const hasApp = fs.existsSync(pkgFile) && fs.readFileSync(pkgFile, \"utf8\").includes('\"@rebasepro/app\"');\n plan.manualSteps.push({\n title: \"Add the backend guard to the Vite config\",\n detail: `${relativeToRoot(plan, root)}/ is a static app of rebase.json, and \\`rebase build\\` refuses a static app whose Vite config does not use \\`rebaseBackendGuard()\\`` +\n (hasApp ? \".\" : `. Add \\`@rebasepro/app\\` to its devDependencies (${relativeToRoot(plan, pkgFile)}) for \\`@rebasepro/app/vitePlugin\\`.`),\n snippet: BACKEND_GUARD_SNIPPET,\n file: relativeToRoot(plan, viteFile)\n });\n }\n}\n\n/** Files of `config/` nothing the codemod moved needs, which the user should look at before deleting the directory. */\nexport function unmovedConfigFiles(plan: PlanContext, configDir: string, handled: ReadonlySet<string>): string[] {\n const out: string[] = [];\n const skip = new Set([\"node_modules\", \"dist\", \"generated\"]);\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || skip.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n continue;\n }\n if (handled.has(full)) continue;\n if (/\\.d\\.ts$/.test(entry.name) || entry.name === \"package.json\" || /^tsconfig.*\\.json$/.test(entry.name)) continue;\n if (!/\\.(ts|tsx|js|mjs|json)$/.test(entry.name)) continue;\n out.push(relativeToRoot(plan, full));\n }\n };\n if (fs.existsSync(configDir)) walk(configDir);\n return out.sort();\n}\n\n/** Where a module that imported something from `config/` should import it from now. */\nexport interface ConfigImporter {\n file: string;\n line: number;\n /** As written: relative, or through a path alias (`@config/collections/posts`). */\n specifier: string;\n /** The same import written relative to the file (equal to `specifier` when it was). */\n relativeSpecifier: string;\n target: string;\n}\n\nconst SOURCE_FILE = /\\.(ts|tsx|mts|js|jsx|mjs)$/;\nconst SPECIFIER = /(?:\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\brequire\\s*\\(\\s*)[\"']([^\"'\\s]+)[\"']/g;\n\n/**\n * Every module outside `config/` that imports something inside it — a custom\n * backend entry importing `config/collections/users`, a test importing a\n * collection — relative, or through a path alias the project's tsconfig\n * `paths` or Vite `resolve.alias` declares. After the migration those imports\n * point at nothing.\n *\n * @param skip files the run rewrites itself\n */\nexport function findConfigImporters(root: string, configDir: string, skip: ReadonlySet<string>, aliases: readonly PathAlias[] = []): ConfigImporter[] {\n return scanSources(root, configDir, skip, aliases).importers;\n}\n\n/** A use of a server API the table model renamed. */\nexport interface LegacyApiUse {\n file: string;\n line: number;\n /** The legacy name as written. */\n api: string;\n /** What it is now. */\n replacement: string;\n}\n\n/** Server APIs of the collection model, and what replaces each. */\nconst LEGACY_APIS: readonly { pattern: RegExp; api: string; replacement: string }[] = [\n { pattern: /\\bsetCollectionCallbacks\\s*\\(/g, api: \"setCollectionCallbacks\", replacement: \"`backend.setTableHooks(slug, hooks)` — table hooks get `table` for `collection`, and `values` for `row` in afterRead / beforeDelete / afterDelete\" },\n { pattern: /\\bcollectionRegistry\\b/g, api: \"collectionRegistry\", replacement: \"`backend.getTableDescriptor(slug)` / `backend.getTableDescriptors()` to read a table, and `backend.setTableHooks(slug, hooks)` to attach hooks\" },\n { pattern: /\\bcollectionsDir\\s*:/g, api: \"collectionsDir\", replacement: \"`schemaDir` (the directory whose index exports the tables) or `tables`\" }\n];\n\n/** Every use of a renamed collection-model server API in the project's own code (outside `config/`). */\nexport function findLegacyApiUses(root: string, configDir: string, skip: ReadonlySet<string>, handled: ReadonlySet<string> = new Set()): LegacyApiUse[] {\n return scanSources(root, configDir, skip).apis.filter(use => !handled.has(use.api));\n}\n\n/**\n * The text with every comment blanked to spaces, newlines kept, so offsets\n * and line numbers still point into the original. Strings and template\n * literals are skipped over (a `//` inside a URL is not a comment). The\n * scaffold's example script ships its typed-SDK import commented out\n * (`// import type { Database } from \"../config/database.types\"`): read\n * as code, every such project got a manual step for a line that is not there.\n */\nfunction blankComments(text: string): string {\n const out = text.split(\"\");\n let index = 0;\n const blank = (from: number, to: number): void => {\n for (let at = from; at < to; at++) if (out[at] !== \"\\n\") out[at] = \" \";\n };\n while (index < text.length) {\n const char = text[index];\n const next = text[index + 1];\n if (char === \"/\" && next === \"/\") {\n const end = text.indexOf(\"\\n\", index);\n const stop = end === -1 ? text.length : end;\n blank(index, stop);\n index = stop;\n } else if (char === \"/\" && next === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n const stop = end === -1 ? text.length : end + 2;\n blank(index, stop);\n index = stop;\n } else if (char === \"\\\"\" || char === \"'\" || char === \"`\") {\n index++;\n while (index < text.length && text[index] !== char) {\n if (text[index] === \"\\\\\") index++;\n else if (char !== \"`\" && text[index] === \"\\n\") break;\n index++;\n }\n index++;\n } else {\n index++;\n }\n }\n return out.join(\"\");\n}\n\nfunction scanSources(root: string, configDir: string, skip: ReadonlySet<string>, aliases: readonly PathAlias[] = []): { importers: ConfigImporter[]; apis: LegacyApiUse[] } {\n const out: ConfigImporter[] = [];\n const apis: LegacyApiUse[] = [];\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\"]);\n const inConfig = (file: string): boolean => {\n const relative = path.relative(configDir, file);\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n };\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || ignored.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (!inConfig(full)) walk(full);\n continue;\n }\n if (!SOURCE_FILE.test(entry.name) || entry.name.endsWith(\".d.ts\") || skip.has(full)) continue;\n const text = blankComments(fs.readFileSync(full, \"utf8\"));\n for (const legacy of LEGACY_APIS) {\n for (const match of text.matchAll(legacy.pattern)) {\n apis.push({ file: full, line: text.slice(0, match.index).split(\"\\n\").length, api: legacy.api, replacement: legacy.replacement });\n }\n }\n if (!text.includes(\"config\") && !aliases.some(alias => text.includes(alias.prefix))) continue;\n for (const match of text.matchAll(SPECIFIER)) {\n const specifier = match[1];\n const relativeSpecifier = /^\\.{1,2}\\//.test(specifier) ? specifier : aliasToRelative(aliases, full, specifier);\n if (relativeSpecifier === undefined) continue;\n const target = path.resolve(path.dirname(full), relativeSpecifier);\n if (!inConfig(target)) continue;\n const line = text.slice(0, match.index).split(\"\\n\").length;\n out.push({ file: full, line, specifier, relativeSpecifier, target });\n }\n }\n };\n walk(root);\n return { importers: out, apis };\n}\n\n/**\n * The modules of `config/` that are the project's own: everything but what\n * Rebase read — `config/collections`, the wiring the run moves to `backend/`\n * (`resources.ts`, `storage.ts`, `generated/register.ts`), the package's index,\n * declarations and package files. 0.31 stops reading `config/collections`, not\n * `config/`: these stay where they are, importable as before.\n *\n * @param moved the wiring files the run moves, absolute\n */\nexport function keptConfigModules(plan: PlanContext, configDir: string, collectionsDir: string, moved: readonly string[]): string[] {\n const out: string[] = [];\n const skip = new Set([\"node_modules\", \"dist\", \"generated\"]);\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || skip.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (full !== collectionsDir) walk(full);\n continue;\n }\n if (moved.includes(full) || full === path.join(configDir, \"index.ts\") || full === path.join(configDir, \"index.js\")) continue;\n if (/\\.d\\.ts$/.test(entry.name) || entry.name === \"package.json\" || /^tsconfig.*\\.json$/.test(entry.name)) continue;\n if (!/\\.(ts|tsx|mts|js|mjs|json)$/.test(entry.name)) continue;\n out.push(relativeToRoot(plan, full));\n }\n };\n if (fs.existsSync(configDir)) walk(configDir);\n return out.sort();\n}\n\n/**\n * The kept modules of `config/` nothing will import once the run is written:\n * no file outside `config/` (read as the run leaves it), no kept module that is\n * itself imported, and not the kept `config/index.ts`. A module whose only\n * importers were the collections is dead weight once they are tables — it goes\n * in the printed `git rm` line instead of staying as \"the project's own\".\n *\n * @param kept the kept modules, absolute\n * @param removed files the run removes or moves (collections, moved wiring, a dropped index), absolute\n * @param indexKept whether `config/index.ts` stays (its imports are live: the package entry)\n */\nexport function unimportedConfigModules(\n plan: PlanContext,\n configDir: string,\n kept: readonly string[],\n removed: readonly string[],\n indexKept: boolean,\n aliases: readonly PathAlias[] = []\n): string[] {\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\"]);\n const gone = (file: string): boolean => removed.some(target => file === target || !path.relative(target, file).startsWith(\"..\"));\n const inConfig = (file: string): boolean => !path.relative(configDir, file).startsWith(\"..\");\n const configPackage = readJson(path.join(configDir, \"package.json\"));\n const packageName = configPackage && typeof configPackage.value.name === \"string\" ? configPackage.value.name : undefined;\n const files = new Set<string>();\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || ignored.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (gone(full)) continue;\n if (entry.isDirectory()) walk(full);\n else if (SOURCE_FILE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) files.add(full);\n }\n };\n walk(plan.root);\n for (const file of plan.files.keys()) if (SOURCE_FILE.test(file) && !gone(file)) files.add(file);\n const indexFile = [\"index.ts\", \"index.js\"].map(name => path.join(configDir, name)).find(file => fs.existsSync(file));\n const targetsOf = (file: string): string[] => {\n const planned = plan.files.get(file);\n const text = blankComments(planned ? planned.content : fs.readFileSync(file, \"utf8\"));\n const out: string[] = [];\n for (const match of text.matchAll(SPECIFIER)) {\n const specifier = match[1];\n if (packageName && (specifier === packageName || specifier.startsWith(`${packageName}/`))) {\n const sub = specifier.slice(packageName.length + 1);\n if (sub) out.push(resolveRelative(path.join(configDir, \"index.ts\"), `./${sub}`).target);\n else if (indexFile) out.push(indexFile);\n continue;\n }\n const relative = /^\\.{1,2}\\//.test(specifier) ? specifier : aliasToRelative(aliases, file, specifier);\n if (relative !== undefined) out.push(resolveRelative(file, relative).target);\n }\n return out;\n };\n const used = new Set<string>();\n const queue: string[] = [];\n const reach = (target: string): void => {\n if (!kept.includes(target) || used.has(target)) return;\n used.add(target);\n queue.push(target);\n };\n for (const file of files) if (!inConfig(file)) targetsOf(file).forEach(reach);\n if (indexKept && indexFile) targetsOf(indexFile).forEach(reach);\n while (queue.length > 0) {\n const next = queue.pop();\n if (next !== undefined) targetsOf(next).forEach(reach);\n }\n return kept.filter(file => !used.has(file));\n}\n\n/** Files a build or a deploy reads by name: container files, shell scripts, CI and workspace YAML, JS build scripts, manifests. */\nconst DEPLOY_FILE = /^(Dockerfile.*|.*\\.dockerfile|\\.dockerignore.*|Makefile|.*\\.(sh|bash|ya?ml|toml|mjs|cjs|js)|package\\.json)$/i;\n\n/**\n * Build and deploy files that name what the migration removes: the config\n * workspace package by name (`pnpm --filter \"<name>\" run build`, a deploy\n * workspace list, an `allowBuilds` entry) when the package goes, and the\n * collections directory (`COPY config/collections`, a watcher on\n * `../config/**`). The run rewrites `pnpm-workspace.yaml` and the manifests it\n * owns; read as it leaves them, whatever still names these is a step per file\n * with its lines — the codemod does not edit a Dockerfile or a CI pipeline.\n *\n * @param packageGoes whether the config package is removed (nothing of the project's own is left in it)\n */\nexport function findDeployReferences(plan: PlanContext, configDir: string, collectionsDir: string, packageGoes: boolean): ManualStep[] {\n const steps: ManualStep[] = [];\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\", \"generated\"]);\n const configPackage = readJson(path.join(configDir, \"package.json\"));\n const packageName = configPackage && typeof configPackage.value.name === \"string\" ? configPackage.value.name : undefined;\n const escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const configRelative = toPosix(path.relative(plan.root, configDir));\n const patterns: RegExp[] = [new RegExp(`(^|[^\\\\w-])${escape(toPosix(path.relative(plan.root, collectionsDir)))}\\\\b`)];\n if (packageGoes) {\n if (packageName) patterns.push(new RegExp(`(^|[^\\\\w@/-])${escape(packageName)}(?![\\\\w-])`));\n patterns.push(new RegExp(`(\\\\.\\\\./|\\\\./|^|[\\\\s\"'=])${escape(configRelative)}/\\\\*\\\\*`));\n }\n const inConfig = (file: string): boolean => !path.relative(configDir, file).startsWith(\"..\");\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (ignored.has(entry.name) || (entry.name.startsWith(\".\") && !/^\\.(github|gitlab|circleci|dockerignore)/.test(entry.name) && !/\\.gitlab-ci\\.ya?ml$/.test(entry.name))) continue;\n const full = path.join(dir, entry.name);\n if (inConfig(full)) continue;\n if (entry.isDirectory()) {\n walk(full);\n continue;\n }\n if (!DEPLOY_FILE.test(entry.name) || entry.name === \"pnpm-lock.yaml\") continue;\n const planned = plan.files.get(full);\n const text = planned ? planned.content : fs.readFileSync(full, \"utf8\");\n if (text.length > 1_000_000 || !patterns.some(pattern => text.split(\"\\n\").some(line => pattern.test(line)))) continue;\n const lines = text.split(\"\\n\").flatMap((line, index) => (patterns.some(pattern => pattern.test(line)) ? [index + 1] : []));\n const relative = relativeToRoot(plan, full);\n steps.push({\n title: `Update the build and deploy references in ${relative}`,\n detail: `Line${lines.length > 1 ? \"s\" : \"\"} ${lines.join(\", \")}: ${relative} names ${packageGoes && packageName ? `the config workspace package (\\`${packageName}\\`) or ` : \"\"}${toPosix(path.relative(plan.root, collectionsDir))}, which the migration removes. Drop the step (the backend builds from backend/schema; there is no config package to build or copy) or point it at backend/schema.`,\n file: relative\n });\n }\n };\n walk(plan.root);\n return steps;\n}\n\n/** The names a module's text exports (`export { a, b as c }`, `export const x`); `export *` is not followed. */\nexport function exportedNamesOf(text: string): Set<string> {\n const out = new Set<string>();\n for (const match of text.matchAll(/export\\s+(?:type\\s+)?\\{([^}]*)\\}/g)) {\n for (const part of match[1].split(\",\")) {\n const name = part.trim().split(/\\s+as\\s+/).pop()?.trim();\n if (name) out.add(name);\n }\n }\n for (const match of text.matchAll(/export\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class|type|interface|enum)\\s+([A-Za-z_$][\\w$]*)/g)) out.add(match[1]);\n if (/export\\s+default\\b/.test(text)) out.add(\"default\");\n return out;\n}\n\n/**\n * The project's own code that still reads what the migration removes from\n * `config/` in a way no import rewrite can fix — each a manual step with\n * file:line, since the codemod cannot rewrite an assertion:\n *\n * - an import of a name `config/index.ts` no longer exports (`collections`,\n * `storageAuthorize`, … — the re-exports of what Rebase read), relative, through\n * a path alias, or by the config package's name;\n * - a file that reads `config/collections` as TEXT (`readFileSync`, `readdirSync`,\n * a path built with `path.join(…, \"config\", \"collections\")`): a test asserting\n * over the collection files' source, a script listing them.\n *\n * @param removedIndexNames what the index exported before the run and does not after\n * (every export when the index goes)\n */\nexport function findLegacyConfigReads(\n plan: PlanContext,\n configDir: string,\n collectionsDir: string,\n removedIndexNames: ReadonlySet<string>,\n aliases: readonly PathAlias[] = []\n): ManualStep[] {\n const steps: ManualStep[] = [];\n const ignored = new Set([\"node_modules\", \"dist\", \"build\", \".git\", \"coverage\", \".turbo\", \".next\"]);\n const inConfig = (file: string): boolean => !path.relative(configDir, file).startsWith(\"..\");\n const configPackage = readJson(path.join(configDir, \"package.json\"));\n const packageName = configPackage && typeof configPackage.value.name === \"string\" ? configPackage.value.name : undefined;\n const files = new Set<string>();\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || ignored.has(entry.name)) continue;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (!inConfig(full)) walk(full);\n } else if (SOURCE_FILE.test(entry.name) && !entry.name.endsWith(\".d.ts\")) {\n files.add(full);\n }\n }\n };\n walk(plan.root);\n for (const file of plan.files.keys()) if (SOURCE_FILE.test(file) && !inConfig(file)) files.add(file);\n const collectionsRelative = toPosix(path.relative(plan.root, collectionsDir));\n const segments = collectionsRelative.split(\"/\").map(segment => `[\"'\\`]${segment.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"'\\`]`).join(\"\\\\s*,\\\\s*\");\n const textRead = new RegExp(`[\"'\\`][^\"'\\`\\\\n]*\\\\b${collectionsRelative.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\b|${segments}`);\n for (const file of [...files].sort()) {\n const planned = plan.files.get(file);\n const text = blankComments(planned ? planned.content : fs.readFileSync(file, \"utf8\"));\n const relative = relativeToRoot(plan, file);\n const lineOf = (index: number | undefined): number => text.slice(0, index ?? 0).split(\"\\n\").length;\n // Imports of names the index lost.\n if (removedIndexNames.size > 0) {\n const lost: string[] = [];\n for (const match of text.matchAll(/import\\s+(type\\s+)?(?:([A-Za-z_$][\\w$]*)\\s*,?\\s*)?(?:\\{([^}]*)\\}|\\*\\s+as\\s+([A-Za-z_$][\\w$]*))?\\s*from\\s*[\"']([^\"']+)[\"']/g)) {\n const specifier = match[5];\n const isPackage = packageName !== undefined && specifier === packageName;\n const relativeSpecifier = /^\\.{1,2}\\//.test(specifier) ? specifier : aliasToRelative(aliases, file, specifier);\n const target = relativeSpecifier !== undefined ? resolveRelative(file, relativeSpecifier).target : undefined;\n const isIndex = isPackage || (target !== undefined && (target === configDir || (path.dirname(target) === configDir && /^index\\.(tsx?|mts|jsx?|mjs)$/.test(path.basename(target)))));\n if (!isIndex) continue;\n const named = (match[3] ?? \"\").split(\",\").map(part => part.trim().replace(/^type\\s+/, \"\").split(/\\s+as\\s+/)[0]?.trim()).filter((name): name is string => Boolean(name));\n const names = named.filter(name => removedIndexNames.has(name));\n const namespace = match[4];\n if (namespace) for (const name of removedIndexNames) if (new RegExp(`\\\\b${namespace}\\\\.${name}\\\\b`).test(text)) names.push(`${namespace}.${name}`);\n if (names.length > 0) lost.push(`line ${lineOf(match.index)}: ${names.map(name => `\\`${name}\\``).join(\", \")} from \"${specifier}\"`);\n }\n if (lost.length > 0) {\n steps.push({\n title: `Replace what ${relative} imports from config/index.ts`,\n detail: `${lost.join(\"; \")} — config/index.ts no longer exports ${lost.length > 1 ? \"these\" : \"this\"}: it re-exported what Rebase read (the collections, storageAuthorize), which is gone or moved. Read the tables from backend/schema (\\`compileTables\\` for their descriptors), presentation from frontend/src/cms, storageAuthorize from backend/storage. The codemod cannot rewrite what a test asserts about them.`,\n file: relative\n });\n }\n }\n // Reads of config/collections as files.\n const lines: number[] = [];\n let offset = 0;\n for (const line of text.split(\"\\n\")) {\n if (textRead.test(line) && !/\\bcollectionsDir\\s*:/.test(line) && !/^\\s*(import|export)\\b|\\bfrom\\s*[\"']|\\bimport\\s*\\(|\\brequire\\s*\\(/.test(line)) lines.push(lineOf(offset));\n offset += line.length + 1;\n }\n if (lines.length > 0) {\n steps.push({\n title: `Stop reading ${collectionsRelative} in ${relative}`,\n detail: `Line${lines.length > 1 ? \"s\" : \"\"} ${lines.join(\", \")}: ${relative} reads ${collectionsRelative} as files (a path to it), which the migration removes. Point it at backend/schema (the tables) or frontend/src/cms (the customizations), or assert on the compiled tables instead of their source text. The codemod cannot rewrite an assertion.`,\n file: relative\n });\n }\n }\n return steps;\n}\n\n/** Where a relative specifier written in `fromFile` points, without its extension. */\nfunction specifierStem(fromFile: string, specifier: string): string {\n return path.resolve(path.dirname(fromFile), specifier).replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\").replace(/[\\\\/]index$/, \"\");\n}\n\n/**\n * `config/index.ts` without its re-exports of what Rebase read\n * (`export { collections } from \"./collections\"`, `export { storageAuthorize }\n * from \"./storage\"`), so the package keeps exporting the project's own modules.\n * Undefined when nothing but comments would be left: the index goes too.\n */\nexport function withoutRebaseReexports(ctx: AstContext, indexFile: string, collectionsDir: string, moved: readonly string[]): string | undefined {\n const text = fs.readFileSync(indexFile, \"utf8\");\n const sf = ctx.project.createSourceFile(`/__rebase_migrate__/config-index-${path.basename(indexFile)}`, text, { overwrite: true });\n try {\n const movedStems = moved.map(file => file.replace(/\\.(tsx?|mts|jsx?|mjs)$/, \"\"));\n const isRebases = (specifier: string | undefined): boolean => {\n if (specifier === undefined || !specifier.startsWith(\".\")) return false;\n const stem = specifierStem(indexFile, specifier);\n const relative = path.relative(collectionsDir, stem);\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative)) || movedStems.includes(stem);\n };\n const drop = [...sf.getExportDeclarations(), ...sf.getImportDeclarations()].filter(declaration => isRebases(declaration.getModuleSpecifierValue()));\n if (drop.length === 0) return text;\n let out = text;\n for (const declaration of [...drop].sort((a, b) => b.getStart() - a.getStart())) {\n const end = out[declaration.getEnd()] === \"\\n\" ? declaration.getEnd() + 1 : declaration.getEnd();\n out = out.slice(0, declaration.getFullStart() === 0 ? 0 : declaration.getStart()) + out.slice(end);\n }\n const remaining = ctx.project.createSourceFile(`/__rebase_migrate__/config-index-rest-${path.basename(indexFile)}`, out, { overwrite: true });\n const empty = remaining.getStatements().length === 0;\n ctx.project.removeSourceFile(remaining);\n return empty ? undefined : out;\n } finally {\n ctx.project.removeSourceFile(sf);\n }\n}\n","/**\n * A storage property whose `storagePath` is a function.\n *\n * On 0.30 the panel called the function to choose where an upload goes, and\n * the server enforced the property's `maxSize` / `acceptedFiles` only for an\n * upload that named the property (a function path claimed no keys). On 0.31\n * the split is explicit: the panel's function is the customization's\n * `storage.path`, and the column's `path` template is where the server\n * enforces the limits for any upload landing there — in addition to an upload\n * that names the column.\n *\n * So the column needs a template that claims exactly the keys the function\n * produces. When the function returns one template literal (or string), the\n * template is its static text with each interpolation as `{path}` (any number\n * of segments — an interpolated value may hold a `/`): `` `${owner}/cv` ``\n * → `{path}/cv`, which matches every key the function can write and keys of\n * that same shape only. With no static text at all (or a function the codemod\n * cannot read), no template would be faithful: the lift refuses it, with what\n * to write.\n */\nimport type { LiftNote, LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\n\nimport { nodeAtPath, unwrap } from \"./ast\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The template a storage-path function's single returned template literal stands for, or undefined. */\nfunction templateOf(plan: PlanContext, entry: CollectionEntry, key: string): string | undefined {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const site = entry.site;\n if (!site) return undefined;\n const located = nodeAtPath(plan.ast, site.literal, [\"properties\", key, \"storage\", \"storagePath\"]);\n if (!located.node) return undefined;\n const fn = located.node.method ?? (located.node.value ? unwrap(plan.ast, located.node.value) : undefined);\n if (!fn || !(N.isArrowFunction(fn) || N.isFunctionExpression(fn) || N.isMethodDeclaration(fn))) return undefined;\n let returned;\n const body = fn.getBody();\n if (body && !N.isBlock(body)) returned = body;\n else {\n const returns = fn.getDescendantsOfKind(SyntaxKind.ReturnStatement).filter(statement =>\n statement.getFirstAncestor(ancestor => N.isArrowFunction(ancestor) || N.isFunctionExpression(ancestor) || N.isFunctionDeclaration(ancestor) || N.isMethodDeclaration(ancestor)) === fn);\n if (returns.length !== 1) return undefined;\n returned = returns[0].getExpression();\n }\n if (!returned) return undefined;\n const value = unwrap(plan.ast, returned);\n let template: string;\n if (N.isStringLiteral(value) || N.isNoSubstitutionTemplateLiteral(value)) template = value.getLiteralValue();\n else if (N.isTemplateExpression(value)) {\n template = value.getHead().getLiteralText() + value.getTemplateSpans().map(span => `{path}${span.getLiteral().getLiteralText()}`).join(\"\");\n } else return undefined;\n // Only static text decides what the template claims: none at all would claim every key.\n if (!/[^/{}]/.test(template.replace(/\\{path\\}/g, \"\"))) return undefined;\n return template;\n}\n\n/**\n * Replace each derivable function `storagePath` of the evaluated collections\n * with its template, and return the functions as lift notes (`browser`), so\n * the customization carries them as `storage.path`.\n */\nexport function deriveStoragePaths(plan: PlanContext, entries: readonly CollectionEntry[]): LiftNote[] {\n const notes: LiftNote[] = [];\n for (const entry of entries) {\n const collection: LegacyCollectionConfig = entry.collection;\n const properties: unknown = collection.properties;\n if (!isRecord(properties)) continue;\n for (const [key, property] of Object.entries(properties)) {\n if (!isRecord(property) || !isRecord(property.storage)) continue;\n const storagePath = property.storage.storagePath;\n if (typeof storagePath !== \"function\") continue;\n const template = templateOf(plan, entry, key);\n if (template === undefined) continue;\n property.storage = { ...property.storage, storagePath: template };\n notes.push({\n collection: collection.slug,\n key,\n field: \"storage.storagePath\",\n kind: \"browser\",\n valueKind: \"function\",\n value: storagePath,\n reason: `A function the panel calls to choose the upload path; the column's \\`path\\` is \"${template}\", the keys it produces, where the server enforces the limits.`\n });\n }\n }\n return notes;\n}\n","/**\n * The project's own imports of what the migration removes from `config/`.\n *\n * 0.31 stops reading `config/collections`; the project's other modules of\n * `config/` stay where they are, so an import of one of those is left alone.\n * What changes is an import of something Rebase read:\n *\n * - a collection file, in backend code: repointed to the table module\n * (`import posts from \"…/config/collections/posts\"` →\n * `import { posts } from \"…/backend/schema/posts\"`); the uses that read the\n * object are listed afterwards (see {@link tableUseSteps}), since a table\n * definition is not a collection;\n * - a collection file, in frontend code: a type-only use becomes a type import\n * of the table; a value use (reading `posts.properties.status.enum`) is a\n * manual step naming the customization module;\n * - a helper beside the collections: copied out with the code that needs it\n * (as the relocator does for carried code) and repointed;\n * - `config/resources.ts`, `config/storage.ts`, `config/generated/register.ts`:\n * repointed to their new home in `backend/`;\n * - the collections index, or a config index that is removed: a manual step.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { Node, SourceFile } from \"ts-morph\";\n\nimport { toPosix } from \"./ast\";\nimport { resolveRelative, writeSpecifier, type Side } from \"./modules\";\nimport type { PlanContext } from \"./plan-context\";\nimport { planFile, relativeToRoot } from \"./plan-context\";\nimport type { ConfigImporter } from \"./project-files\";\n\n/** A table a collection file became. */\nexport interface TableHome {\n /** The exported identifier (`posts`). */\n identifier: string;\n /** The table module, absolute. */\n file: string;\n /** The customization module and its export, when one was written. */\n cms?: { identifier: string; file: string };\n}\n\n/** What {@link repointConfigImports} needs to know about the run. */\nexport interface RepointContext {\n configDir: string;\n collectionsDir: string;\n /** Collection files (absolute) → the table each became. */\n tables: ReadonlyMap<string, TableHome>;\n /** Rebase's own modules the run moved (absolute legacy path → new path). */\n movedWiring: ReadonlyMap<string, string>;\n /** Whether `config/index.ts` is removed (it re-exported nothing but what moved). */\n indexRemoved: boolean;\n}\n\n/** An import repointed to a table module, whose uses are checked once the run's rewrites are done. */\nexport interface TableBinding {\n /** The importing file, absolute. */\n file: string;\n /** The local name. */\n local: string;\n /** The table it now names. */\n table: TableHome;\n}\n\nfunction isUnder(dir: string, file: string): boolean {\n const relative = path.relative(dir, file);\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n}\n\nfunction isIndex(file: string, dir: string): boolean {\n return path.dirname(file) === dir && /^index\\.(tsx?|mts|jsx?|mjs)$/.test(path.basename(file));\n}\n\n/**\n * Whether an import of the collections index binds names used only as the\n * `collections` option of a backend entry — which the SDK pass's boot-options\n * rewrite turns into `schemaDir` (or a step of its own).\n */\nfunction onlyBootCollections(plan: PlanContext, sf: SourceFile, declaration: Node | undefined): boolean {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n if (!declaration || !N.isImportDeclaration(declaration) || declaration.getDefaultImport() || declaration.getNamespaceImport()) return false;\n const locals = declaration.getNamedImports().map(named => named.getAliasNode()?.getText() ?? named.getName());\n if (locals.length === 0) return false;\n return locals.every(local => {\n const uses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier => identifier.getText() === local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n return uses.length > 0 && uses.every(identifier => {\n const parent = identifier.getParent();\n const isOption = parent !== undefined && ((N.isShorthandPropertyAssignment(parent) && parent.getName() === \"collections\") ||\n (N.isPropertyAssignment(parent) && parent.getName() === \"collections\" && parent.getInitializer() === identifier));\n const call = identifier.getFirstAncestorByKind(SyntaxKind.CallExpression);\n return isOption && call !== undefined && /^(initializeRebaseBackend|createRebaseBackend)$/.test(call.getExpression().getText());\n });\n });\n}\n\n/** Whether every reference to `local` in the file (but its import) is in a type position. */\nfunction usedAsTypeOnly(plan: PlanContext, sf: SourceFile, local: string): boolean {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const uses = sf.getDescendantsOfKind(SyntaxKind.Identifier).filter(identifier =>\n identifier.getText() === local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration));\n return uses.every(identifier => identifier.getAncestors().some((ancestor: Node) => N.isTypeNode(ancestor)));\n}\n\n/**\n * Rewrite the project's imports of what the migration removes from `config/`,\n * planning each rewritten file; what cannot be rewritten is a manual step per\n * file. Returns the bindings now naming a table, for {@link tableUseSteps}.\n */\nexport function repointConfigImports(plan: PlanContext, ctx: RepointContext, importers: readonly ConfigImporter[]): TableBinding[] {\n const { Node: N, SyntaxKind } = plan.ast.tsm;\n const bindings: TableBinding[] = [];\n const files = [...new Set(importers.map(importer => importer.file))].sort();\n /** Aliased specifiers (`@config/collections/posts`) → the relative one each stands for, per file. */\n const aliased = new Map<string, Map<string, string>>();\n for (const importer of importers) {\n if (importer.specifier === importer.relativeSpecifier) continue;\n const map = aliased.get(importer.file) ?? new Map<string, string>();\n map.set(importer.specifier, importer.relativeSpecifier);\n aliased.set(importer.file, map);\n }\n for (const file of files) {\n const side: Side = plan.frontendDir && isUnder(plan.frontendDir, file) ? \"frontend\" : \"backend\";\n const text = plan.files.get(file)?.content ?? fs.readFileSync(file, \"utf8\");\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/repoint-${files.indexOf(file)}-${path.basename(file)}`, text, { overwrite: true });\n const edits: { start: number; end: number; text: string }[] = [];\n const left: string[] = [];\n try {\n const literals = [\n ...sf.getImportDeclarations().map(declaration => declaration.getModuleSpecifier()),\n ...sf.getExportDeclarations().map(declaration => declaration.getModuleSpecifier()).filter(literal => literal !== undefined),\n ...sf.getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter(call => call.getExpression().getKind() === SyntaxKind.ImportKeyword || call.getExpression().getText() === \"require\")\n .map(call => call.getArguments()[0])\n .filter(argument => argument !== undefined && N.isStringLiteral(argument))\n ];\n for (const literal of literals) {\n if (!N.isStringLiteral(literal)) continue;\n const written = literal.getLiteralValue();\n // An aliased import is resolved as the relative import it stands for; the rewrite writes it relative.\n const specifier = written.startsWith(\".\") ? written : aliased.get(file)?.get(written);\n if (specifier === undefined) continue;\n const { target, style } = resolveRelative(file, specifier);\n if (!isUnder(ctx.configDir, target) && target !== ctx.configDir) continue;\n const line = literal.getStartLineNumber();\n const replaceSpecifier = (next: string): void => {\n edits.push({ start: literal.getStart() + 1, end: literal.getEnd() - 1, text: next });\n };\n const movedTo = ctx.movedWiring.get(target);\n if (movedTo) {\n replaceSpecifier(writeSpecifier(file, movedTo, style));\n continue;\n }\n if (isIndex(target, ctx.configDir) || target === ctx.configDir) {\n if (ctx.indexRemoved) left.push(`line ${line}: \"${written}\" — config/index.ts re-exported only what Rebase read (\\`collections\\`, \\`storageAuthorize\\`) and is removed: import the table from backend/schema, storageAuthorize from backend/storage`);\n continue;\n }\n if (!isUnder(ctx.collectionsDir, target)) continue; // the project's own module: it stays\n if (isIndex(target, ctx.collectionsDir) && side === \"backend\" && onlyBootCollections(plan, sf, literal.getParent())) continue; // the boot-options rewrite handles it\n if (isIndex(target, ctx.collectionsDir)) {\n left.push(side === \"backend\"\n ? `line ${line}: \"${written}\" — the collections index: the backend boots from backend/schema (\\`schemaDir\\`, or \\`tables\\` from its index)`\n : `line ${line}: \"${written}\" — the collections index: the panel projects the tables from the backend; customizations are in frontend/src/cms`);\n continue;\n }\n const table = ctx.tables.get(target);\n if (!table) {\n // A helper beside the collections: copied out, like carried code's.\n try {\n replaceSpecifier(plan.relocator.relocate(specifier, file, file, side));\n } catch (error) {\n left.push(`line ${line}: \"${written}\" — ${error instanceof Error ? error.message : String(error)}`);\n }\n continue;\n }\n const declaration = literal.getParent();\n const defaultImport = declaration && N.isImportDeclaration(declaration) ? declaration.getDefaultImport() : undefined;\n const onlyDefault = declaration && N.isImportDeclaration(declaration) && defaultImport && declaration.getNamedImports().length === 0 && !declaration.getNamespaceImport();\n if (!declaration || !N.isImportDeclaration(declaration) || !defaultImport || !onlyDefault) {\n left.push(`line ${line}: \"${written}\" — the collection is the table \\`${table.identifier}\\` now: import it from ${relativeToRoot(plan, table.file)}${side === \"frontend\" ? \" as a type (`import type`)\" : \"\"}`);\n continue;\n }\n const local = defaultImport.getText();\n const binding = table.identifier === local ? local : `${table.identifier} as ${local}`;\n const tableSpecifier = writeSpecifier(file, table.file, style);\n if (side === \"frontend\") {\n if (declaration.isTypeOnly() || usedAsTypeOnly(plan, sf, local)) {\n edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: `import type { ${binding} } from ${JSON.stringify(tableSpecifier)};` });\n } else {\n const cms = table.cms ? `the customization \\`${table.cms.identifier}\\` (${relativeToRoot(plan, table.cms.file)}) for what the panel shows, ` : \"\";\n left.push(`line ${line}: \"${written}\" — \\`${local}\\` is read as a value in the frontend; a collection object is gone and the frontend may import backend/ as types only: use ${cms}or the table descriptor the server serves (\\`GET /api/schema/tables\\`) for its columns and enum values`);\n }\n continue;\n }\n edits.push({ start: declaration.getStart(), end: declaration.getEnd(), text: `import ${declaration.isTypeOnly() ? \"type \" : \"\"}{ ${binding} } from ${JSON.stringify(tableSpecifier)};` });\n bindings.push({ file, local, table });\n }\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n if (edits.length > 0) {\n let next = text;\n for (const edit of edits.sort((a, b) => b.start - a.start)) next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);\n const planned = plan.files.get(file);\n planFile(plan, file, next, planned ? `${planned.role}, imports of config/` : `imports of config/ (${relativeToRoot(plan, file)})`);\n }\n if (left.length > 0) {\n plan.manualSteps.push({\n title: `Repoint the imports of ${relativeToRoot(plan, file)}`,\n detail: `What it imports from ${relativeToRoot(plan, ctx.collectionsDir)} is gone, and the codemod could not rewrite these: ${left.join(\"; \")}.`,\n file: relativeToRoot(plan, file)\n });\n }\n }\n return bindings;\n}\n\n/**\n * The uses of a binding repointed to a table that read it as an object, one\n * step per file, given the files as the run writes them (after the SDK\n * rewrite, which may have removed a use, as `auth.collection`). A table\n * definition is not a collection: `columns`, `hooks`, `rls` where a collection\n * had `properties`, `callbacks`, `securityRules`.\n *\n * @param read a file's content as the run writes it\n */\nexport function tableUseSteps(plan: PlanContext, bindings: readonly TableBinding[], read: (file: string) => string): void {\n const { SyntaxKind } = plan.ast.tsm;\n const byFile = new Map<string, TableBinding[]>();\n for (const binding of bindings) byFile.set(binding.file, [...(byFile.get(binding.file) ?? []), binding]);\n for (const [file, list] of byFile) {\n const text = read(file);\n const sf = plan.ast.project.createSourceFile(`/__rebase_migrate__/table-uses-${path.basename(file)}`, text, { overwrite: true });\n const lines: string[] = [];\n try {\n for (const binding of list) {\n const uses = sf.getDescendantsOfKind(SyntaxKind.Identifier)\n .filter(identifier => identifier.getText() === binding.local && !identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration))\n .map(identifier => identifier.getStartLineNumber());\n if (uses.length === 0) continue;\n lines.push(`\\`${binding.local}\\` (now the table \\`${binding.table.identifier}\\`) on line ${[...new Set(uses)].join(\", \")}`);\n }\n } finally {\n plan.ast.project.removeSourceFile(sf);\n }\n if (lines.length === 0) continue;\n plan.manualSteps.push({\n title: `Check the uses of the tables ${relativeToRoot(plan, file)} imports`,\n detail: `Its imports of collection files now import the table definitions from backend/schema: ${lines.join(\"; \")}. A table definition is not a collection — \\`columns\\`, \\`hooks\\`, \\`rls\\` where a collection had \\`properties\\`, \\`callbacks\\`, \\`securityRules\\` — so check each use.`,\n file: toPosix(path.relative(plan.root, file))\n });\n }\n}\n","/**\n * The proof that a migration is lossless: the legacy collections and the\n * migrated tables render the same SQL.\n *\n * \"Before\" is the collections exactly as the legacy loader serves them.\n * \"After\" is `backend/schema` read back through the new pipeline —\n * `loadBackendSchema` (index authority, sibling check, compile) with the CLI's\n * jiti importer, compiled by `compileLoadedSchema`, the one compile boot, the\n * runtime and the CLI share. The planner reads only compiled tables, so\n * \"before\" is the legacy collections lifted (`collectionsToTableDefs`, the\n * codemod's own core) and compiled. Both go through\n * `renderSchemaOutputs`, the renderer the plan-golden corpus is recorded\n * with: DDL under every option, policies, search, vector, triggers, views,\n * the Drizzle schema and the boot plans. A single byte of difference fails.\n */\nimport type { LegacyCollectionConfig } from \"@rebasepro/common/migrate\";\n\nimport type { ModuleImporter } from \"./load-legacy\";\nimport type { VerificationResult } from \"./types\";\n\n/** The lines around the first and last difference of two texts, as a unified-style excerpt. */\nexport function describeDifference(before: string, after: string, context = 3, limit = 80): string {\n const a = before.split(\"\\n\");\n const b = after.split(\"\\n\");\n let start = 0;\n while (start < a.length && start < b.length && a[start] === b[start]) start++;\n let endA = a.length - 1;\n let endB = b.length - 1;\n while (endA >= start && endB >= start && a[endA] === b[endB]) {\n endA--;\n endB--;\n }\n const from = Math.max(0, start - context);\n const lines: string[] = [`@@ line ${start + 1} @@`];\n for (let index = from; index < start; index++) lines.push(` ${a[index]}`);\n for (let index = start; index <= endA; index++) lines.push(`- ${a[index]}`);\n for (let index = start; index <= endB; index++) lines.push(`+ ${b[index]}`);\n for (let index = endA + 1; index < Math.min(a.length, endA + 1 + context); index++) lines.push(` ${a[index]}`);\n if (lines.length > limit) return [...lines.slice(0, limit), `… ${lines.length - limit} more lines`].join(\"\\n\");\n return lines.join(\"\\n\");\n}\n\n/**\n * Compare what the legacy collections and the migrated schema render.\n *\n * @param legacy the Postgres collections as the legacy loader serves them\n * @param schemaDir the migrated `backend/schema`, absolute\n */\nexport async function verifyMigration(\n legacy: readonly LegacyCollectionConfig[],\n schemaDir: string,\n importModule: ModuleImporter\n): Promise<VerificationResult> {\n const { renderSchemaOutputs } = await import(\"@rebasepro/server-postgres\");\n const { compileLoadedSchema, loadBackendSchema } = await import(\"@rebasepro/server\");\n const { compileSchema } = await import(\"@rebasepro/common\");\n const { collectionsToTableDefs } = await import(\"@rebasepro/common/migrate\");\n let after: Record<string, string>;\n try {\n // Exactly as the server reads it: the index is authoritative, a sibling\n // definition it does not export is refused, every definition compiles.\n // `projectRoot: false` — config/ is still there until the user deletes it.\n const loaded = await loadBackendSchema(schemaDir, { projectRoot: false, importModule });\n if (!loaded.indexFile) throw new Error(`${schemaDir} has no index module.`);\n after = renderSchemaOutputs(compileLoadedSchema(loaded).tables);\n } catch (error) {\n return { identical: false, compared: 0, differences: [], error: `The migrated schema could not be read back: ${error instanceof Error ? error.message : String(error)}` };\n }\n let before: Record<string, string>;\n try {\n const lifted = collectionsToTableDefs(legacy);\n before = renderSchemaOutputs(compileSchema(lifted.tables, lifted.defaultRls ? { defaultRls: lifted.defaultRls } : {}));\n } catch (error) {\n return { identical: false, compared: 0, differences: [], error: `The legacy collections could not be lifted into tables: ${error instanceof Error ? error.message : String(error)}` };\n }\n const differences: VerificationResult[\"differences\"] = [];\n const outputs = [...new Set([...Object.keys(before), ...Object.keys(after)])].sort();\n for (const output of outputs) {\n const a = before[output] ?? \"\";\n const b = after[output] ?? \"\";\n if (a !== b) differences.push({ output, diff: describeDifference(a, b) });\n }\n return { identical: differences.length === 0, compared: outputs.length, differences };\n}\n","/**\n * The collections-to-tables codemod: one run, from a project on the\n * `config/collections` layout to `backend/schema` + `frontend/src/cms`.\n *\n * 1. Evaluate the legacy collections as the server's loader does.\n * 2. Lift them (`collectionsToTableDefs`) and print the tables with the shared\n * printer, splicing in the source of hooks and transforms.\n * 3. Route everything that is presentation to `customizeTable` files, and\n * Firestore collections to `defineFirestoreCollection`.\n * 4. Move the rest of `config/` and rewire the workspace.\n * 5. Refuse, never guess: any construct that cannot be carried exactly blocks\n * the write, with the file, the line and what to change.\n * 6. Write under a journal, read the result back through the new pipeline\n * and require byte-identical SQL; roll back on any difference.\n *\n * `config/` itself is never deleted: the run prints the `git rm -r` line.\n */\nimport { spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { collectionsToTableDefs, isLegacyPostgresCollection, type LegacyCollectionConfig, type LiftResult } from \"@rebasepro/common/migrate\";\n\nimport { addSourceFile, createAstContext, findCollectionSite, postDeclarationAssignments, toPosix, type TsMorph } from \"./ast\";\nimport { nameTables, planBackend } from \"./backend\";\nimport { addUnattached, collectComments, placeComments, placeIndexComments } from \"./comments\";\nimport { planCustomizations, printCmsIndex } from \"./customization\";\nimport { planFirestoreCollection } from \"./firestore\";\nimport { findSplitConstants, planSplitConstants } from \"./split-constants\";\nimport { rewriteSdkCalls } from \"./sdk-calls\";\nimport { planRowShapedHands } from \"./row-hands\";\nimport { refreshSkillsStep } from \"./skills-step\";\nimport { Journal } from \"./journal\";\nimport { createSchemaModuleImporter } from \"../../utils/import-schema-module\";\nimport { createShimDir, legacyLoadAliases, movedNameAliases, removeShimDir, type ShimDir } from \"./legacy-shims\";\nimport { movedSymbolTable } from \"./moved-imports\";\nimport { LegacyLoadError, loadLegacyProject } from \"./load-legacy\";\nimport { projectSpecifierStyle, Relocator, writtenSpecifiers } from \"./modules\";\nimport type { CollectionEntry, PlanContext } from \"./plan-context\";\nimport { note, planFile, relativeToRoot } from \"./plan-context\";\nimport {\n planBackendTsconfig,\n planFrontendWiring,\n planStaticAppGuards,\n planManifest,\n planMove,\n planWorkspace,\n findConfigImporters,\n findLegacyApiUses,\n readRawManifest,\n unmovedConfigFiles,\n unimportedConfigModules,\n findLegacyConfigReads,\n findDeployReferences,\n exportedNamesOf,\n keptConfigModules,\n withoutRebaseReexports\n} from \"./project-files\";\nimport type { CollectionOutcome, MigrateOptions, MigrationReport, PlannedFile } from \"./types\";\nimport { deriveStoragePaths } from \"./storage-paths\";\nimport { readPathAliases } from \"./path-aliases\";\nimport { repointConfigImports, tableUseSteps, type TableHome } from \"./repoint\";\nimport { verifyMigration } from \"./verify\";\n\n/** The directory every table module is written to. */\nconst SCHEMA_DIR = path.join(\"backend\", \"schema\");\n\n/** Output paths that must not already hold something else (a re-run must find exactly what it would write). */\nfunction isOwnedOutput(plan: PlanContext, file: string, cmsDir: string | undefined): boolean {\n const relative = relativeToRoot(plan, file);\n return relative.startsWith(\"backend/schema/\") || relative.startsWith(\"backend/lib/\") ||\n relative === \"backend/resources.ts\" || relative === \"backend/storage.ts\" || relative.startsWith(\"backend/generated/\") ||\n (cmsDir !== undefined && !path.relative(cmsDir, file).startsWith(\"..\"));\n}\n\n/**\n * Whether the project's git tree is clean, or why it is not usable as a safety net.\n *\n * @param root the project root\n */\nexport function gitState(root: string): { clean: true } | { clean: false; reason: string } {\n const result = spawnSync(\"git\", [\"-C\", root, \"status\", \"--porcelain\", \"--untracked-files=normal\", \"--\", \".\"], { encoding: \"utf8\" });\n if (result.error || result.status !== 0) {\n return { clean: false, reason: `${root} is not inside a git repository, so a run could not be undone with git. Commit the project first, or pass --force.` };\n }\n const dirty = result.stdout.split(\"\\n\").filter(line => line.trim().length > 0);\n if (dirty.length > 0) {\n return { clean: false, reason: `the git tree has ${dirty.length} uncommitted change(s) (${dirty.slice(0, 3).map(line => line.slice(3)).join(\", \")}${dirty.length > 3 ? \", …\" : \"\"}). Commit or stash them, so the migration is one reviewable diff — or pass --force.` };\n }\n return { clean: true };\n}\n\nfunction emptyReport(root: string): MigrationReport {\n return { projectRoot: root, status: \"blocked\", collections: [], files: [], refusals: [], notes: [], manualSteps: [], ruleChanges: [] };\n}\n\n/**\n * Run the codemod on one project.\n *\n * The shims the legacy `config/` is loaded with are written into a directory\n * of this run's own, deleted when the run is over — whether it succeeded,\n * refused or threw (see `ShimDir`).\n */\nexport async function migrateCollectionsToTables(options: MigrateOptions): Promise<MigrationReport> {\n const shimDir = createShimDir();\n try {\n return await migrateWithShims(options, shimDir);\n } finally {\n removeShimDir(shimDir);\n }\n}\n\nasync function migrateWithShims(options: MigrateOptions, shimDir: ShimDir): Promise<MigrationReport> {\n const root = path.resolve(options.projectRoot);\n const report = emptyReport(root);\n const manifest = readRawManifest(root);\n const configDir = path.resolve(root, manifest.configDir);\n const writes = !options.dryRun && !options.check;\n\n // After the printed `git rm`: nothing left to read, and the tables are there.\n // That is the end state, not an error — whichever mode asks.\n const collectionsDir = path.join(configDir, \"collections\");\n if (!fs.existsSync(collectionsDir) && fs.existsSync(path.join(root, SCHEMA_DIR))) {\n report.status = \"already-migrated\";\n report.notes.push({\n file: toPosix(path.relative(root, collectionsDir)),\n message: `is gone and ${toPosix(SCHEMA_DIR)} exists: the project is already migrated. There is nothing left to compare backend/schema with (--check reads config/collections; run it before the git rm line), and nothing to remove.`\n });\n return report;\n }\n\n if (writes && !options.force) {\n const state = gitState(root);\n if (!state.clean) {\n report.refusals.push({ file: \".\", reason: state.reason });\n return report;\n }\n }\n\n // `config/` is evaluated with the packages installed now; 0.31 dropped the `defineCollection` its files import.\n // …and with the names 0.31 moved to another package re-exported where the 0.30 files import them.\n const baseAliases = legacyLoadAliases(configDir, shimDir, options.moduleAliases);\n // (Only for a project that has collections to load: it imports every package once to see what moved.)\n const loadAliases = fs.existsSync(path.join(configDir, \"collections\"))\n ? await movedNameAliases(configDir, shimDir, baseAliases, await createSchemaModuleImporter(root, baseAliases), movedSymbolTable())\n : baseAliases;\n const importModule = await createSchemaModuleImporter(root, loadAliases);\n let legacy;\n try {\n legacy = await loadLegacyProject(configDir, importModule);\n } catch (error) {\n report.refusals.push({\n file: error instanceof LegacyLoadError && error.file ? toPosix(path.relative(root, error.file)) : toPosix(path.relative(root, configDir)),\n reason: error instanceof Error ? error.message : String(error)\n });\n return report;\n }\n for (const helper of legacy.helperFiles) {\n report.notes.push({\n file: toPosix(path.relative(root, helper)),\n message: \"exports no collection: read as a module the collections import, not as a table. It is copied next to the code that imports it, since config/collections goes; when nothing imports it, a step lists it.\"\n });\n }\n\n const tsm: TsMorph = await import(\"ts-morph\");\n const ast = createAstContext(tsm);\n const frontendDir = manifest.frontendRoot ? path.resolve(root, manifest.frontendRoot) : undefined;\n const cmsDir = frontendDir ? path.join(frontendDir, \"src\", \"cms\") : undefined;\n const relocator = new Relocator(ast, root, configDir, new Set(legacy.collections.map(entry => entry.file)), {\n backend: path.join(root, \"backend\", \"lib\"),\n frontend: cmsDir ? path.join(cmsDir, \"lib\") : path.join(root, \"frontend\", \"src\", \"cms\", \"lib\")\n });\n\n // The AST of every collection file.\n const entries: CollectionEntry[] = legacy.collections.map(({ collection, file }) => {\n const sourceFile = addSourceFile(ast, file, fs.readFileSync(file, \"utf8\"));\n const site = findCollectionSite(ast, sourceFile);\n return { collection, file, sourceFile, ...(site.node ? { site: site.node } : { siteProblem: site.reason }) };\n });\n // The relative imports the run writes end as the collection files and their index write theirs:\n // `./users.js` for a project built with a plain `tsc` (NodeNext) and run on Node.\n const legacyIndexFile = [\"index.ts\", \"index.js\"].map(file => path.join(legacy.collectionsDir, file)).find(file => fs.existsSync(file));\n const specifierStyle = projectSpecifierStyle([\n ...entries.flatMap(entry => writtenSpecifiers(entry.sourceFile)),\n ...(legacyIndexFile ? writtenSpecifiers(addSourceFile(ast, legacyIndexFile, fs.readFileSync(legacyIndexFile, \"utf8\"))) : [])\n ]);\n const plan: PlanContext = {\n root,\n ast,\n relocator,\n specifierStyle,\n ...(frontendDir ? { frontendDir } : {}),\n files: new Map(),\n refusals: report.refusals,\n notes: report.notes,\n manualSteps: report.manualSteps\n };\n for (const entry of entries) {\n if (!entry.site?.binding) continue;\n for (const [assigned, { statement }] of postDeclarationAssignments(ast, entry.sourceFile, entry.site.binding)) {\n note(plan, entry, `\\`${entry.site.binding}.${assigned}\\` is assigned after the declaration; the evaluated value is what was carried.`, statement.getStartLineNumber());\n }\n }\n\n const postgres = entries.filter(entry => isLegacyPostgresCollection(entry.collection));\n const firestore = entries.filter(entry => entry.collection.engine === \"firestore\");\n for (const entry of entries) {\n if (!postgres.includes(entry) && !firestore.includes(entry)) {\n plan.refusals.push({ file: relativeToRoot(plan, entry.file), collection: entry.collection.slug, reason: `is a ${String(entry.collection.engine)} collection. Only Postgres collections become tables and Firestore ones \\`defineFirestoreCollection\\`; this engine has no home in the new layout.` });\n }\n }\n if (cmsDir) for (const entry of firestore) relocator.moved.set(entry.file, path.join(cmsDir, path.basename(entry.file)));\n\n // Enum constants of config/ the collections use: values for the schema, labels for the CMS.\n const split = await findSplitConstants(plan, postgres, importModule, cmsDir);\n plan.splitConstants = split.constants;\n\n // The tables.\n let lift: LiftResult | undefined;\n // A function storagePath whose keys a template can name: the template for the server, the function for the panel.\n const storageNotes = deriveStoragePaths(plan, postgres);\n try {\n lift = collectionsToTableDefs(postgres.map(entry => entry.collection), legacy.defaultSecurityRules ? { defaultSecurityRules: legacy.defaultSecurityRules } : {});\n } catch (error) {\n if (!isSchemaDefinitionError(error)) throw error;\n for (const problem of error.problems) {\n const entry = postgres.find(candidate => candidate.collection.slug === problem.table);\n plan.refusals.push({\n file: entry ? relativeToRoot(plan, entry.file) : relativeToRoot(plan, legacy.collectionsDir),\n collection: problem.table,\n ...(problem.key !== undefined ? { key: problem.key } : {}),\n reason: problem.message\n });\n }\n }\n\n const schemaDir = path.join(root, SCHEMA_DIR);\n const outcomes = new Map<string, CollectionOutcome>();\n for (const entry of entries) {\n outcomes.set(entry.collection.slug, { slug: entry.collection.slug, file: relativeToRoot(plan, entry.file), kind: \"refused\" });\n }\n let customizationModules: { identifier: string; file: string; slug: string }[] = [];\n /** Collection files → the table each became, for repointing the project's imports of them. */\n const tableHomes = new Map<string, TableHome>();\n /** The auth table's module and its collection file: an `auth.collection` naming either is dropped. */\n const authFiles: string[] = [];\n if (lift) {\n lift.notCarried.push(...storageNotes);\n for (const item of lift.notCarried) {\n if (item.kind !== \"meaning\") continue;\n const entry = postgres.find(candidate => candidate.collection.slug === item.collection);\n report.ruleChanges.push({\n file: entry ? relativeToRoot(plan, entry.file) : relativeToRoot(plan, legacy.collectionsDir),\n collection: item.collection,\n rule: item.field,\n message: item.reason\n });\n }\n const names = nameTables(postgres, lift.tables, schemaDir);\n const order = (legacy.navigationOrder ?? []).map(collection => collection.slug).filter(slug => names.has(slug));\n planBackend(plan, { entries: postgres, lift, schemaDir, order }, names);\n planSplitConstants(plan, split.constants, new Map(postgres.map(entry => [entry.file, names.get(entry.collection.slug)?.file ?? \"\"])));\n for (const [slug, name] of names) {\n const outcome = outcomes.get(slug);\n if (outcome) {\n outcome.kind = name.kind;\n outcome.backendFile = relativeToRoot(plan, name.file);\n }\n }\n if (cmsDir) {\n const navigation = legacy.navigationOrder ?? [];\n const ordered = [...postgres].sort((a, b) => rank(navigation, a.collection) - rank(navigation, b.collection));\n customizationModules = planCustomizations(plan, ordered, names, lift.notCarried, cmsDir).modules;\n for (const module of customizationModules) {\n const outcome = outcomes.get(module.slug);\n if (outcome) outcome.frontendFile = relativeToRoot(plan, module.file);\n }\n }\n placeCollectionComments(plan, postgres, lift, names, customizationModules);\n for (const entry of postgres) {\n const name = names.get(entry.collection.slug);\n if (!name) continue;\n const cms = customizationModules.find(module => module.slug === entry.collection.slug);\n if (name.kind === \"auth-table\") authFiles.push(name.file, entry.file);\n tableHomes.set(entry.file, { identifier: name.identifier, file: name.file, ...(cms ? { cms: { identifier: cms.identifier, file: cms.file } } : {}) });\n }\n if (!cmsDir && lift.notCarried.some(item => item.kind === \"ui\" || item.kind === \"browser\")) {\n plan.manualSteps.push({\n title: \"Presentation not carried\",\n detail: \"The project has no frontend app (rebase.json declares no static app with `cms`, and there is no frontend/src), so the collections' admin presentation — labels, icons, `admin` blocks — had nowhere to go and was not written. Add a frontend and run the codemod again from the git history if you want it.\"\n });\n }\n }\n\n // Firestore collections.\n const external: { identifier: string; file: string }[] = [];\n for (const entry of firestore) {\n if (!cmsDir) {\n plan.refusals.push({ file: relativeToRoot(plan, entry.file), collection: entry.collection.slug, reason: \"is a Firestore collection, which lives in the CMS (`defineFirestoreCollection` in frontend/src/cms), and the project has no frontend app.\" });\n continue;\n }\n const moved = planFirestoreCollection(plan, entry, cmsDir);\n if (!moved) continue;\n external.push(moved);\n const outcome = outcomes.get(entry.collection.slug);\n if (outcome) {\n outcome.kind = \"firestore\";\n outcome.frontendFile = relativeToRoot(plan, moved.file);\n }\n }\n if (firestore.length > 0 || legacy.builtFirestore.length > 0) {\n note(plan, undefined, \"Firestore collections are moved and rewritten in place; they have no SQL, so the SQL check does not cover them.\");\n }\n\n // Firestore collections the project built in modules the loader never read\n // (a subdirectory, a function the app spread into `collections`).\n const builtHomes = new Map<string, string>();\n for (const built of legacy.builtFirestore) {\n const slug = built.collection.slug;\n outcomes.set(slug, { slug, file: relativeToRoot(plan, built.file ?? legacy.collectionsDir), kind: \"firestore\" });\n if (!cmsDir || !built.file) continue;\n const sourceFile = addSourceFile(ast, built.file, fs.readFileSync(built.file, \"utf8\"));\n const entry: CollectionEntry = { collection: built.collection, file: built.file, sourceFile };\n // A literal the rewrite cannot read is left to the step below, not refused: the run never read these files before.\n const trial: PlanContext = { ...plan, files: new Map(), refusals: [], notes: [], manualSteps: [] };\n const destination = path.join(cmsDir, path.relative(legacy.collectionsDir, built.file));\n const moved = planFirestoreCollection(trial, entry, cmsDir, destination);\n if (!moved || trial.refusals.length > 0) continue;\n for (const [file, planned] of trial.files) plan.files.set(file, planned);\n plan.notes.push(...trial.notes);\n plan.manualSteps.push(...trial.manualSteps);\n external.push(moved);\n builtHomes.set(slug, moved.file);\n const outcome = outcomes.get(slug);\n if (outcome) outcome.frontendFile = relativeToRoot(plan, moved.file);\n }\n const shape = \"`defineFirestoreCollection({ slug, name, fields, … })` from `@rebasepro/firebase` in frontend/src/cms — `properties` → `fields`, a reference's `path` → `target`, no `engine`, components by value — listed in `externalCollections` and mounted as `<RebaseCMS externalCollections={externalCollections}>`\";\n const describeBuilt = (slugs: string[]): string => {\n const converted = slugs.filter(slug => builtHomes.has(slug)).map(slug => `${slug} → ${relativeToRoot(plan, builtHomes.get(slug) ?? \"\")}`);\n const byHand = slugs.filter(slug => !builtHomes.has(slug));\n return (converted.length > 0 ? ` Converted (in externalCollections): ${converted.join(\", \")}.` : \"\") +\n (byHand.length > 0 ? ` No literal of their own the codemod could rewrite (built per call, or several per file) — write each by hand in the target shape: ${byHand.join(\", \")}.` : \"\") +\n ` Target shape: ${shape}.`;\n };\n for (const builder of legacy.firestoreBuilders) {\n plan.manualSteps.push({\n title: `Mount the Firestore collections ${builder.exportName}() built`,\n detail: `\\`${builder.exportName}()\\` builds ${builder.slugs.length} Firestore collection(s) at run time; the 0.30 loader never read its module, the app spread the result into \\`collections\\`, which the panel no longer takes.` +\n describeBuilt(builder.slugs) +\n (builder.changed.length > 0 ? ` It returns changed copies of ${builder.changed.join(\", \")} (it adds to or rewrites what their files export at run time): carry that change into the converted collections by hand.` : \"\") +\n ` Replace the call with \\`externalCollections\\` from ./cms. Its module tree goes with config/collections; where other code still imports it, it was copied as written (0.30 shape) next to that code — keep only what that code reads.`,\n file: relativeToRoot(plan, builder.file)\n });\n }\n const unbuilt = legacy.builtFirestore.map(built => built.collection.slug).filter(slug => !legacy.firestoreBuilders.some(builder => builder.slugs.includes(slug)));\n if (unbuilt.length > 0) {\n plan.manualSteps.push({\n title: \"Mount the Firestore collections of the subdirectories\",\n detail: `Files under subdirectories of config/collections export Firestore collections the 0.30 loader never read (the app imported them).${describeBuilt(unbuilt)} Mount \\`externalCollections\\` from ./cms where the app passed them.`,\n file: relativeToRoot(plan, legacy.collectionsDir)\n });\n }\n\n // The CMS index and the frontend's wiring.\n if (cmsDir && frontendDir) {\n if (customizationModules.length > 0 || external.length > 0) {\n planFile(plan, path.join(cmsDir, \"index.ts\"), printCmsIndex(cmsDir, customizationModules, external, plan.specifierStyle), \"the CMS index\");\n }\n planFrontendWiring(plan, frontendDir, external.length > 0);\n }\n planStaticAppGuards(plan, frontendDir);\n\n // The legacy index's comments, onto the two indexes.\n const schemaIndex = plan.files.get(path.join(schemaDir, \"index.ts\"));\n if (legacyIndexFile && schemaIndex) {\n const cmsIndexPath = cmsDir ? path.join(cmsDir, \"index.ts\") : undefined;\n const cmsIndex = cmsIndexPath ? plan.files.get(cmsIndexPath) : undefined;\n const placed = placeIndexComments(ast, addSourceFile(ast, legacyIndexFile, fs.readFileSync(legacyIndexFile, \"utf8\")), schemaIndex.content, cmsIndex?.content, root);\n plan.files.set(path.join(schemaDir, \"index.ts\"), { ...schemaIndex, content: placed.schemaIndex });\n if (cmsIndexPath && cmsIndex && placed.cmsIndex !== undefined) plan.files.set(cmsIndexPath, { ...cmsIndex, content: placed.cmsIndex });\n }\n\n // The rest of config/.\n const handled = new Set<string>(legacy.collections.map(entry => entry.file));\n for (const name of [\"index.ts\", \"index.js\"]) handled.add(path.join(legacy.collectionsDir, name));\n handled.add(path.join(configDir, \"index.ts\"));\n const backendWanted = [\"schema/**/*\"];\n /** Rebase's own modules of config/ the run moves to backend/ (removed afterwards). */\n const movedWiring: string[] = [];\n for (const [file, target] of [[\"resources.ts\", \"resources.ts\"], [\"storage.ts\", \"storage.ts\"]] as const) {\n const from = path.join(configDir, file);\n try {\n if (planMove(plan, from, path.join(root, \"backend\", target), `backend/${target}`)) {\n handled.add(from);\n movedWiring.push(from);\n backendWanted.push(target);\n }\n } catch (error) {\n plan.refusals.push({ file: relativeToRoot(plan, from), reason: error instanceof Error ? error.message : String(error) });\n }\n }\n // `storageAuthorize` exported by config/index.ts from a module of another name\n // (`export { storageAuthorize } from \"./storage-authorize\"`): 0.30's bundle read\n // it from config/index, 0.31's reads backend/storage only. Without that file the\n // access control is silently dropped on deploy — the boot merely warns.\n const storageTarget = path.join(root, \"backend\", \"storage.ts\");\n if (legacy.configIndexExports.includes(\"storageAuthorize\") && !plan.files.has(storageTarget) && !fs.existsSync(storageTarget)) {\n const indexFile = path.join(configDir, \"index.ts\");\n const source = fs.existsSync(indexFile) ? storageAuthorizeReexport(indexFile, path.dirname(storageTarget)) : undefined;\n if (source) {\n planFile(plan, storageTarget, \"// The runtime reads `storageAuthorize` from backend/storage (0.30 read it from config/index.ts).\\n\" +\n `export { storageAuthorize } from \"${source}\";\\n`, \"backend/storage.ts (storageAuthorize, re-exported)\");\n backendWanted.push(\"storage.ts\");\n } else {\n plan.manualSteps.push({\n title: \"Move storageAuthorize to backend/storage.ts\",\n detail: \"config/index.ts exports `storageAuthorize`, which the 0.30 runtime read from there. 0.31 reads it from `backend/storage.ts` only: without that module, storage access control is gone on deploy (the boot only warns). Export it from backend/storage.ts.\",\n file: relativeToRoot(plan, indexFile)\n });\n }\n }\n const register = path.join(configDir, \"generated\", \"register.ts\");\n try {\n if (planMove(plan, register, path.join(root, \"backend\", \"generated\", \"register.ts\"), \"backend/generated/register.ts\")) {\n handled.add(register);\n movedWiring.push(register);\n backendWanted.push(\"generated/**/*\");\n }\n } catch (error) {\n plan.refusals.push({ file: relativeToRoot(plan, register), reason: error instanceof Error ? error.message : String(error) });\n }\n if (legacy.configIndexExports.includes(\"callbacks\")) {\n plan.manualSteps.push({\n title: \"Move the global collection callbacks\",\n detail: \"config/index.ts exports `callbacks`, which the runtime applied to every collection. Its home is `backend/hooks.ts`, exporting `hooks` (table hooks: `table` replaces `collection`, and `afterRead` / `beforeDelete` / `afterDelete` receive `values` instead of `row`). Move it by hand: the codemod does not rewrite a module it did not read as a collection.\",\n file: relativeToRoot(plan, path.join(configDir, \"index.ts\"))\n });\n }\n\n for (const constant of split.constants) handled.add(constant.module);\n for (const { module, reason } of split.unsplit) {\n handled.add(module);\n // Advice, not a step: the tables inline the values and the customizations the labels, so nothing breaks if the module stays as it is.\n report.notes.push({\n file: relativeToRoot(plan, module),\n message: `holds enum values the collections used; the tables inline the values and the customizations the labels (it was not split because it ${reason}). If it should stay the one source of those values, split it: the values into backend/lib (\\`export const X = [...] as const\\`), the labels into frontend/src/cms/lib (\\`Record<(typeof X)[number], string>\\`), named in the tables and customizations.`\n });\n }\n\n // Helper modules the moved code imports.\n for (const copy of relocator.helpers.values()) {\n handled.add(copy.from);\n planFile(plan, copy.to, relocator.helperContent(copy), `helper ${relativeToRoot(plan, copy.from)} (${copy.side})`);\n if (copy.side === \"backend\") backendWanted.push(\"lib/**/*\");\n const content = relocator.helperContent(copy);\n if (copy.side === \"backend\" && /from\\s+[\"'](react|@rebasepro\\/(cms|cms-types|app|ui|studio))[\"']/.test(content)) {\n plan.manualSteps.push({\n title: `Split ${relativeToRoot(plan, copy.from)}`,\n detail: `The backend uses ${relativeToRoot(plan, copy.from)}, which imports an admin-panel package. It was copied to ${relativeToRoot(plan, copy.to)} as written; the backend may not import React or the CMS (\\`pnpm check:headless\\`): keep only what the backend uses there.`,\n file: relativeToRoot(plan, copy.to)\n });\n }\n }\n\n // Modules the panel's code imports in place, edited for it (a shared dynamicProps builder's 0.31 return shape).\n for (const module of relocator.keptFrontendModules) {\n if (relocator.keptBackendModules.has(module)) continue;\n const content = relocator.editedSource(module);\n if (content !== fs.readFileSync(module, \"utf8\")) planFile(plan, module, content, `${relativeToRoot(plan, module)} (dynamicProps return shape)`);\n }\n\n // The project's own modules backend code imports in place: their collection-model types become table-model aliases.\n for (const module of relocator.keptBackendModules) {\n const content = relocator.keptBackendContent(module);\n if (content !== fs.readFileSync(module, \"utf8\")) planFile(plan, module, content, `${relativeToRoot(plan, module)} (collection-model types → table-model aliases)`);\n }\n\n for (const { file, name } of relocator.legacyTypesLeft) {\n plan.manualSteps.push({\n title: `Replace the collection-model type ${name} in ${file}`,\n detail: `A module the backend uses (copied to backend/lib, or kept in config/) \\`${name}\\` with type arguments; a table-model alias cannot stand for it. Use the table-model type from \\`@rebasepro/server/schema\\` (\\`TableHooks\\`, \\`TableBeforeSaveProps\\`, \\`TableHookProps[\"context\"]\\`, …).`\n });\n }\n\n // config/ minus what Rebase read: the project's own modules, which stay where they are.\n const configLeft = keptConfigModules(plan, configDir, legacy.collectionsDir, movedWiring);\n const configStays = configLeft.length > 0;\n const removed = [legacy.collectionsDir, ...movedWiring];\n const indexFile = path.join(configDir, \"index.ts\");\n if (configStays) {\n if (fs.existsSync(indexFile)) {\n const rewritten = withoutRebaseReexports(ast, indexFile, legacy.collectionsDir, movedWiring);\n if (rewritten === undefined) removed.push(indexFile);\n else if (rewritten !== fs.readFileSync(indexFile, \"utf8\")) planFile(plan, indexFile, rewritten, \"config/index.ts (re-exports of what moved)\");\n }\n report.notes.push({\n file: relativeToRoot(plan, configDir),\n message: `keeps ${configLeft.length} module(s) of the project's own (${configLeft.join(\", \")}): 0.31 stops reading ${relativeToRoot(plan, legacy.collectionsDir)}, not ${relativeToRoot(plan, configDir)}/. They stay where they are, importable as before; only what Rebase read is removed.`\n });\n }\n\n // The project's own imports of what config/ loses: repointed where that is mechanical (see repoint.ts).\n const wiringHomes = new Map<string, string>();\n for (const from of movedWiring) {\n const to = from === path.join(configDir, \"generated\", \"register.ts\") ? path.join(root, \"backend\", \"generated\", \"register.ts\") : path.join(root, \"backend\", path.basename(from));\n wiringHomes.set(from, to);\n }\n for (const [from, to] of relocator.moved) wiringHomes.set(from, to);\n const tableBindings = repointConfigImports(plan, {\n configDir,\n collectionsDir: legacy.collectionsDir,\n tables: tableHomes,\n movedWiring: wiringHomes,\n indexRemoved: !configStays || removed.includes(indexFile)\n }, findConfigImporters(root, configDir, new Set(plan.files.keys()), readPathAliases(root)));\n // Helpers beside the collections the project's own code imports, copied out by the repointing.\n for (const copy of relocator.helpers.values()) {\n if (plan.files.has(copy.to)) continue;\n handled.add(copy.from);\n planFile(plan, copy.to, relocator.helperContent(copy), `helper ${relativeToRoot(plan, copy.from)} (${copy.side})`);\n if (copy.side === \"backend\") backendWanted.push(\"lib/**/*\");\n }\n\n planManifest(plan, manifest);\n planWorkspace(plan, configDir, manifest.frontendRoot, configStays);\n planBackendTsconfig(plan, [...new Set(backendWanted)], configStays);\n\n // Server APIs of the collection model in the project's own code.\n const apiUses = new Map<string, { api: string; replacement: string; lines: number[] }>();\n for (const use of findLegacyApiUses(root, configDir, new Set(plan.files.keys()), options.skipSdkCalls ? new Set() : new Set([\"setCollectionCallbacks\", \"collectionsDir\"]))) {\n const key = `${use.file}\\0${use.api}`;\n const entry = apiUses.get(key) ?? { api: use.api, replacement: use.replacement, lines: [] };\n entry.lines.push(use.line);\n apiUses.set(key, entry);\n }\n for (const [key, { api, replacement, lines }] of apiUses) {\n const file = key.slice(0, key.indexOf(\"\\0\"));\n plan.manualSteps.push({\n title: `Replace ${api} in ${relativeToRoot(plan, file)}`,\n detail: `\\`${api}\\` (line${lines.length > 1 ? \"s\" : \"\"} ${lines.join(\", \")}) belongs to the collection model. Use ${replacement}.`,\n file: relativeToRoot(plan, file)\n });\n }\n\n // The project's own SDK calls and server API uses, renamed (on the files as they are about to be written).\n if (!options.skipSdkCalls) {\n const overrides = new Map([...plan.files].map(([file, { content }]) => [file, content]));\n const sdk = await rewriteSdkCalls(root, {\n overrides,\n // config/collections goes; the project's own modules of config/ are its code like any other.\n skipDirs: [legacy.collectionsDir],\n skipFiles: [...movedWiring, ...(removed.includes(indexFile) ? [indexFile] : [])],\n ...(options.moduleAliases ? { aliases: options.moduleAliases } : {}),\n schemaDir,\n collectionsDir: legacy.collectionsDir,\n authFiles,\n configManifest: path.join(configDir, \"package.json\")\n });\n for (const [file, content] of sdk.files) {\n const planned = plan.files.get(file);\n plan.files.set(file, { content, role: planned ? `${planned.role}, SDK calls` : `SDK calls (${relativeToRoot(plan, file)})` });\n }\n report.sdk = sdk.report;\n plan.manualSteps.push(...sdk.report.manualSteps);\n }\n // Views, actions, display resolvers and additional fields destructuring `({ entity })`: row-shaped on 0.31.\n if (frontendDir) planRowShapedHands(plan, frontendDir);\n tableUseSteps(plan, tableBindings, file => plan.files.get(file)?.content ?? fs.readFileSync(file, \"utf8\"));\n\n // Code that still reads what config/ loses, in a way no import rewrite fixes: names the index stopped exporting, config/collections read as files.\n {\n const indexBefore = fs.existsSync(indexFile) ? fs.readFileSync(indexFile, \"utf8\") : \"\";\n const indexAfter = !configStays || removed.includes(indexFile) ? \"\" : plan.files.get(indexFile)?.content ?? indexBefore;\n const after = exportedNamesOf(indexAfter);\n const lost = new Set([...exportedNamesOf(indexBefore)].filter(name => !after.has(name)));\n plan.manualSteps.push(...findLegacyConfigReads(plan, configDir, legacy.collectionsDir, lost, readPathAliases(root)));\n plan.manualSteps.push(...findDeployReferences(plan, configDir, legacy.collectionsDir, !configStays));\n }\n\n // Kept modules of config/ that only the collections imported: nothing needs them once the run is written.\n if (configStays) {\n const indexGoes = removed.includes(indexFile);\n const unimported = unimportedConfigModules(plan, configDir, configLeft.map(file => path.join(root, file)),\n [legacy.collectionsDir, ...movedWiring, ...(indexGoes ? [indexFile] : [])], !indexGoes && fs.existsSync(indexFile), readPathAliases(root));\n if (unimported.length > 0) {\n removed.push(...unimported);\n report.notes.push({\n file: relativeToRoot(plan, configDir),\n message: `${unimported.map(file => relativeToRoot(plan, file)).join(\", \")}: nothing imports ${unimported.length > 1 ? \"these\" : \"this\"} once the migration is written (only the collections did, and their values are in the tables now); ${unimported.length > 1 ? \"they are\" : \"it is\"} in the printed git rm line.`\n });\n }\n }\n\n const unmoved = unmovedConfigFiles(plan, configDir, handled).filter(file => relocator.isInCollections(path.join(root, file)));\n if (unmoved.length > 0) {\n // Nothing the run writes and nothing of the project imports them: only the collections did, and their values are in the tables now.\n report.notes.push({\n file: relativeToRoot(plan, legacy.collectionsDir),\n message: `${unmoved.join(\", \")}: nothing needs ${unmoved.length > 1 ? \"these\" : \"this\"} after the migration (only the collections imported ${unmoved.length > 1 ? \"them\" : \"it\"}, and their values are in the tables now); ${unmoved.length > 1 ? \"they go\" : \"it goes\"} with ${relativeToRoot(plan, legacy.collectionsDir)}.`\n });\n }\n\n const skills = refreshSkillsStep(root);\n if (skills) plan.manualSteps.push(skills);\n\n // What would be written.\n const files: PlannedFile[] = [];\n for (const [file, { content, role }] of [...plan.files].sort(([a], [b]) => a.localeCompare(b))) {\n const exists = fs.existsSync(file);\n const current = exists ? fs.readFileSync(file, \"utf8\") : undefined;\n const action: PlannedFile[\"action\"] = !exists ? \"create\" : current === content ? \"unchanged\" : \"update\";\n if (action === \"update\" && isOwnedOutput(plan, file, cmsDir) && !options.force) {\n plan.refusals.push({ file: relativeToRoot(plan, file), reason: \"already exists with other content. The codemod does not overwrite edits: move it aside (or pass --force) and run again.\" });\n }\n files.push({ path: relativeToRoot(plan, file), content, action, role });\n }\n report.files = files;\n // A collection any refusal names is refused, whatever was planned for it.\n for (const outcome of outcomes.values()) {\n if (report.refusals.some(refusal => refusal.collection === outcome.slug)) {\n outcome.kind = \"refused\";\n delete outcome.backendFile;\n delete outcome.frontendFile;\n }\n }\n report.collections = [...outcomes.values()];\n\n const legacyPostgres = postgres.map(entry => entry.collection);\n if (report.refusals.length > 0) {\n report.status = \"blocked\";\n return report;\n }\n\n if (options.check) {\n if (!fs.existsSync(schemaDir)) {\n report.refusals.push({ file: toPosix(SCHEMA_DIR), reason: \"does not exist: there is no migrated schema to check. Run without --check to migrate.\" });\n report.status = \"blocked\";\n return report;\n }\n report.verification = await verifyMigration(legacyPostgres, schemaDir, importModule);\n report.status = report.verification.identical ? \"checked\" : \"failed\";\n if (report.status === \"checked\" && report.ruleChanges.length > 0 && !options.acceptRuleChanges) {\n report.status = \"rule-changes\";\n return report;\n }\n if (report.verification.identical) report.removeCommand = removeCommand(plan, configStays ? removed : [configDir]);\n return report;\n }\n if (options.dryRun) {\n report.status = \"planned\";\n return report;\n }\n\n const pending = files.filter(file => file.action !== \"unchanged\");\n const journal = new Journal();\n for (const file of pending) journal.write(path.join(root, file.path), file.content);\n // A fresh importer: the one that read config/ cached modules by path.\n const verification = await verifyMigration(legacyPostgres, schemaDir, await createSchemaModuleImporter(root, options.moduleAliases));\n report.verification = verification;\n if (!verification.identical) {\n journal.rollback();\n report.status = \"failed\";\n return report;\n }\n report.status = pending.length === 0 ? \"already-migrated\" : \"migrated\";\n report.removeCommand = removeCommand(plan, configStays ? removed : [configDir]);\n return report;\n}\n\n/** Every collection file's comments, into the table and customization files it became (see `comments.ts`). */\nfunction placeCollectionComments(\n plan: PlanContext,\n entries: readonly CollectionEntry[],\n lift: LiftResult,\n names: ReadonlyMap<string, { file: string }>,\n customizations: readonly { file: string; slug: string }[]\n): void {\n entries.forEach((entry, index) => {\n const def = lift.tables[index];\n const name = names.get(entry.collection.slug);\n const backend = name ? plan.files.get(name.file) : undefined;\n if (!def || !name || !backend) return;\n const cmsFile = customizations.find(module => module.slug === entry.collection.slug)?.file;\n const cms = cmsFile ? plan.files.get(cmsFile) : undefined;\n const comments = collectComments(plan.ast, entry, def, new Set());\n const fresh = (text: string, content: string): boolean => !content.includes(text);\n const forBackend = comments\n .filter(comment => comment.target.side === \"backend\" || !cms)\n .map(comment => (comment.target.side === \"cms\" ? { text: comment.text, target: { side: \"backend\" as const } } : comment))\n .filter(comment => fresh(comment.text, backend.content));\n const placedBackend = placeComments(backend.content, forBackend);\n plan.files.set(name.file, { ...backend, content: addUnattached(placedBackend.text, placedBackend.leftover, entry.file, plan.root) });\n if (cms && cmsFile) {\n const forCms = comments.filter(comment => comment.target.side === \"cms\" && fresh(comment.text, cms.content));\n const placedCms = placeComments(cms.content, forCms);\n plan.files.set(cmsFile, { ...cms, content: addUnattached(placedCms.text, placedCms.leftover, entry.file, plan.root) });\n }\n });\n}\n\nfunction rank(order: readonly LegacyCollectionConfig[], collection: LegacyCollectionConfig): number {\n const index = order.findIndex(candidate => candidate.slug === collection.slug);\n return index < 0 ? order.length : index;\n}\n\n\nfunction removeCommand(plan: PlanContext, paths: readonly string[]): string {\n return `git rm -r ${paths.filter(file => fs.existsSync(file)).map(file => relativeToRoot(plan, file)).join(\" \")}`;\n}\n\n/**\n * The specifier, relative to `fromDir`, of the module `indexFile` re-exports\n * `storageAuthorize` from (`export { storageAuthorize } from \"./storage-authorize.js\"`),\n * keeping the specifier's extension style. Undefined when the index defines it\n * itself, renames it, or re-exports it from a package.\n */\nfunction storageAuthorizeReexport(indexFile: string, fromDir: string): string | undefined {\n const text = fs.readFileSync(indexFile, \"utf8\");\n for (const match of text.matchAll(/export\\s*(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*[\"']([^\"']+)[\"']/g)) {\n const names = match[1].split(\",\").map(name => name.trim());\n const specifier = match[2];\n if (!names.includes(\"storageAuthorize\") || !specifier.startsWith(\".\")) continue;\n const extension = /\\.(m?[jt]sx?)$/.exec(specifier)?.[0] ?? \"\";\n const stem = path.resolve(path.dirname(indexFile), specifier).replace(/\\.(m?[jt]sx?)$/, \"\");\n const relative = toPosix(path.relative(fromDir, stem));\n return `${relative.startsWith(\".\") ? relative : `./${relative}`}${extension}`;\n }\n return undefined;\n}\n","/**\n * `rebase migrate collections-to-tables [dir]`: the command a project on the\n * `config/collections` layout runs to move to `backend/schema` (+\n * `frontend/src/cms`). The runtime and every CLI command refuse the old layout\n * with this command in the message (`LEGACY_LAYOUT_REMEDY`).\n *\n * Prints the plan and the outcome for a person, or one JSON document\n * (`--json`) for a script or an agent. Exits 1 when the run was refused, the\n * SQL check failed, or `--check` found rules that change meaning without\n * `--accept-rule-changes`.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport chalk from \"chalk\";\n\nimport { gitState, migrateCollectionsToTables } from \"./migrate\";\nimport { rewriteSdkCalls, type SdkRewriteReport } from \"./sdk-calls\";\nimport type { ManualStep, MigrationReport, Note } from \"./types\";\n\n/** The help page. */\nexport function printCollectionsToTablesHelp(): void {\n console.log(`\n${chalk.bold(\"rebase migrate collections-to-tables\")} — move a project from config/collections to backend/schema\n\n${chalk.bold(\"Usage\")}\n rebase migrate collections-to-tables [dir] [options]\n\n ${chalk.gray(\"dir\")} The project root (where rebase.json and config/ are). Default: the current directory.\n\n${chalk.bold(\"What it writes\")}\n backend/schema/<table>.ts defineTable / defineAuthTable / defineView, one per collection\n backend/schema/index.ts every table, and defaultRls when config/collections had defaultSecurityRules\n frontend/src/cms/<table>.tsx customizeTable(...), only for a collection whose presentation was not the default\n frontend/src/cms/<name>.ts defineFirestoreCollection(...), for engine: \"firestore\" collections\n backend/resources.ts, backend/storage.ts, backend/generated/register.ts from their config/ counterparts\n rebase.json, package.json, pnpm-workspace.yaml, backend/tsconfig.json without the config package\n\n${chalk.bold(\"When to use it\")}\n Once, on a project every other command refuses with \"still on the collections layout\".\n Commit first: the run refuses a dirty git tree, so what it changes is one reviewable diff.\n\n${chalk.bold(\"Options\")}\n --dry-run Print the plan (files, refusals, manual steps) and write nothing. Start here.\n --check On a project already migrated, before deleting config/: prove backend/schema still\n renders the same SQL as config/collections. Writes nothing; exits 1 with the diff if not.\n After the git rm line (config/collections gone, backend/schema there) it reports\n \"already migrated\" and exits 0.\n --json One JSON document on stdout: files, refusals, notes, manual steps, the SQL check\n --force Run on a dirty git tree, and replace output files that hold something else\n (an earlier run's output you edited). Without it, both are refused and nothing is written.\n --skip-sdk-calls Leave the project's own code as it is; run rebase migrate sdk-calls later\n --accept-rule-changes With --check: the rules listed under \"Review before deploying\" were reviewed.\n Without it, --check exits 1 while any rule changes meaning.\n\n${chalk.bold(\"Manual steps\")}\n What the codemod cannot carry exactly is not guessed at: it is printed at the end as a numbered\n list of manual steps, each with the file it is about and, where there is one, the code to paste —\n mounting the customizations in <RebaseCMS tableCustomizations>, a module of config/ it did not\n read, an import of config/ to repoint, regenerating the SDK, refreshing the agent skills.\n The migration is done when the list is done and config/ is removed (the run prints the git rm line).\n\n${chalk.bold(\"Safety\")}\n Every run evaluates config/collections as the server did, converts it, writes the result\n and reads it back through the new pipeline: the generated SQL (DDL, policies, search, vector,\n triggers, views, the Drizzle schema) must be byte-identical, or every file is put back.\n A construct the codemod cannot carry exactly is refused with its file and line, and nothing\n is written. config/ itself is never deleted: the run prints the git rm line to run.\n\n That check compiles both sides with this release's compiler, so it proves the files were\n converted faithfully, not that a rule still MEANS what it did. Two things cover that:\n ${chalk.bold(\"Review before deploying\")} — printed last — lists every security rule whose policy now grants\n something different (e.g. a bare access: \"authenticated\", which granted nothing before and\n admits every signed-in caller now). And against the project's database, after migrating:\n rebase db push --dry-run expect \"No changes: the database already matches these tables.\"\n rebase doctor --policies expect no policy drift\n Any policy difference either lists is a change in who can access what.\n`);\n}\n\nfunction printReport(report: MigrationReport): void {\n const tables = report.collections.filter(outcome => outcome.kind === \"table\" || outcome.kind === \"auth-table\" || outcome.kind === \"view\");\n const firestore = report.collections.filter(outcome => outcome.kind === \"firestore\");\n const customized = report.collections.filter(outcome => outcome.frontendFile !== undefined && outcome.kind !== \"firestore\");\n const refused = report.collections.filter(outcome => outcome.kind === \"refused\");\n const firestoreByHand = firestore.filter(outcome => outcome.frontendFile === undefined).length;\n console.log(\"\");\n console.log(chalk.bold(`rebase migrate collections-to-tables — ${report.projectRoot}`));\n console.log(\"\");\n if (report.collections.length > 0) {\n console.log(` ${report.collections.length} collection(s): ${tables.length} table(s), ${firestore.length} Firestore${firestoreByHand > 0 ? ` (${firestoreByHand} to write by hand, see the steps)` : \"\"}, ${refused.length} refused; ${customized.length} customization file(s)`);\n }\n if (report.files.length > 0) {\n const changed = report.files.filter(file => file.action !== \"unchanged\");\n console.log(\"\");\n console.log(chalk.bold(` Files${report.status === \"planned\" || report.status === \"blocked\" ? \" (planned)\" : \"\"}: ${changed.length} to write, ${report.files.length - changed.length} unchanged`));\n for (const file of changed) console.log(` ${file.action === \"create\" ? chalk.green(\"create\") : chalk.yellow(\"update\")} ${file.path}`);\n }\n if (report.refusals.length > 0) {\n console.log(\"\");\n console.log(chalk.red.bold(` Refused (${report.refusals.length}) — nothing was written:`));\n for (const refusal of report.refusals) {\n const where = `${refusal.file}${refusal.line !== undefined ? `:${refusal.line}` : \"\"}`;\n const what = [refusal.collection, refusal.key].filter(Boolean).join(\".\");\n console.log(` ${chalk.red(\"✗\")} ${where}${what ? ` (${what})` : \"\"}`);\n console.log(` ${refusal.reason}`);\n }\n }\n if (report.notes.length > 0) {\n const notes = groupNotes(report.notes);\n console.log(\"\");\n console.log(chalk.bold(` Notes (${report.notes.length}${notes.length < report.notes.length ? `, ${notes.length} kinds` : \"\"}):`));\n for (const line of notes) console.log(` ${chalk.gray(\"·\")} ${line}`);\n }\n if (report.manualSteps.length > 0) {\n const steps = groupSteps(report.manualSteps);\n console.log(\"\");\n console.log(chalk.bold(` Manual steps (${steps.length}${steps.length < report.manualSteps.length ? `, grouped from ${report.manualSteps.length}; --json lists each` : \"\"}):`));\n steps.forEach((step, index) => {\n console.log(` ${index + 1}. ${chalk.bold(step.title)}${step.file ? chalk.gray(` (${step.file})`) : \"\"}`);\n console.log(` ${step.detail}`);\n if (step.snippet) for (const line of step.snippet.split(\"\\n\")) console.log(chalk.cyan(` ${line}`));\n });\n }\n if (report.sdk) printSdkSection(report.sdk);\n const verification = report.verification;\n if (verification) {\n console.log(\"\");\n if (verification.error) {\n console.log(chalk.red(` ✗ SQL check could not run: ${verification.error}`));\n } else if (verification.identical) {\n console.log(chalk.green(` ✓ SQL check: ${verification.compared} outputs byte-identical (DDL, policies, search, vector, triggers, views, Drizzle schema, boot plans)`));\n } else {\n console.log(chalk.red(` ✗ SQL check: ${verification.differences.length} of ${verification.compared} outputs differ${report.status === \"failed\" ? \" — every file was put back\" : \"\"}`));\n for (const difference of verification.differences) {\n console.log(chalk.bold(` ${difference.output}`));\n for (const line of difference.diff.split(\"\\n\")) console.log(` ${line}`);\n }\n }\n }\n console.log(\"\");\n switch (report.status) {\n case \"migrated\":\n console.log(chalk.green(\" Migrated. Review the diff and do the manual steps. Remove the legacy files before running generate-sdk, db push, doctor or verify (they refuse a project that still has config/collections):\"));\n break;\n case \"already-migrated\":\n console.log(chalk.green(report.verification\n ? \" Already migrated: every file holds what the codemod would write, and the SQL matches. Remove the legacy files:\"\n : \" Already migrated: config/collections is gone and backend/schema is in place. Nothing to check or remove.\"));\n break;\n case \"checked\":\n console.log(chalk.green(\" The migrated schema matches config/collections. Remove the legacy files:\"));\n break;\n case \"planned\":\n console.log(\" Dry run: nothing was written. Run without --dry-run to migrate (the SQL check runs then).\");\n break;\n default:\n break;\n }\n if (report.status === \"rule-changes\") {\n console.log(chalk.red(\" The migrated schema matches config/collections, but rules change meaning (below). Review them, then run\"));\n console.log(chalk.red(\" --check again with --accept-rule-changes.\"));\n }\n if (report.removeCommand) console.log(chalk.cyan(` ${report.removeCommand}`));\n if (report.status === \"migrated\" || report.status === \"already-migrated\" || report.status === \"checked\" || report.status === \"rule-changes\") {\n console.log(\"\");\n console.log(\" The SQL check proves the files were converted faithfully, not what the rules mean. Before deploying,\");\n console.log(\" against the project's database:\");\n console.log(chalk.cyan(\" rebase db push --dry-run\") + chalk.gray(\" expect \\\"No changes: the database already matches these tables.\\\"\"));\n console.log(chalk.cyan(\" rebase doctor --policies\") + chalk.gray(\" expect no policy drift\"));\n console.log(\" Any policy difference either lists is a change in who can access what.\");\n }\n printRuleChanges(report);\n console.log(\"\");\n}\n\n/**\n * Manual steps for a person: steps that say the same thing (the same detail,\n * no snippet) about several fields or files — \"Check fields.X.dynamicProps\"\n * once per field — printed once, listing what they are about. `--json` keeps\n * every step.\n */\n/** Kinds of step that come once per relation or file, with details of their own: printed as one step of each kind. */\nconst STEP_FAMILIES: readonly { pattern: RegExp; title: string }[] = [\n { pattern: /^Relation renamed in /, title: \"Relations renamed\" },\n { pattern: /^Update the importers of /, title: \"Exports that moved to backend/schema\" },\n { pattern: /^Check the uses of the tables /, title: \"Imports of collections that are tables now\" },\n { pattern: /^Repoint the imports of /, title: \"Imports of config/collections to repoint\" }\n];\n\nexport function groupSteps(steps: readonly ManualStep[]): ManualStep[] {\n const out: ManualStep[] = [];\n const groups = new Map<string, ManualStep[]>();\n const families = new Map<string, ManualStep[]>();\n for (const step of steps) {\n if (step.snippet) {\n out.push(step);\n continue;\n }\n const family = STEP_FAMILIES.find(candidate => candidate.pattern.test(step.title));\n if (family) {\n const members = families.get(family.title);\n if (members) members.push(step);\n else {\n families.set(family.title, [step]);\n out.push(step);\n }\n continue;\n }\n const group = groups.get(step.detail);\n if (group) group.push(step);\n else {\n const fresh = [step];\n groups.set(step.detail, fresh);\n out.push(step);\n }\n }\n return out.map(step => {\n const family = step.snippet ? undefined : STEP_FAMILIES.find(candidate => candidate.pattern.test(step.title));\n if (family) {\n const members = families.get(family.title) ?? [step];\n if (members.length === 1) return step;\n return { title: `${family.title} (${members.length})`, detail: members.map(member => `${member.file ?? member.title}: ${member.detail}`).join(\" | \") };\n }\n const group = step.snippet ? undefined : groups.get(step.detail);\n if (!group || group.length === 1) return step;\n const about = group.map(member => `${member.title}${member.file ? ` (${member.file})` : \"\"}`);\n return { title: `${group.length} steps that say the same`, detail: `${step.detail} — ${about.join(\"; \")}` };\n });\n}\n\n/** Notes for a person: the same remark about several keys (`properties.id.isId is not carried: …`) printed once with the keys. */\nexport function groupNotes(notes: readonly Note[]): string[] {\n const groups = new Map<string, string[]>();\n for (const item of notes) {\n const where = item.file ? `${item.file}${item.line !== undefined ? `:${item.line}` : \"\"}` : \"\";\n const keyed = /^([\\w$]+(?:\\.[\\w$]+|\\[\\])*\\.[\\w$]+) (.+)$/.exec(item.message);\n const key = keyed ? keyed[2] : item.message;\n const label = keyed ? `${where} ${keyed[1]}`.trim() : where;\n groups.set(key, [...(groups.get(key) ?? []), label]);\n }\n return [...groups].map(([message, labels]) => labels.length === 1\n ? `${labels[0] ? `${labels[0]} ` : \"\"}${message}`\n : `${labels.length}× ${message} — ${labels.join(\", \")}`);\n}\n\n/** The rules that change meaning: last, so they cannot scroll away. */\nfunction printRuleChanges(report: MigrationReport): void {\n if (report.ruleChanges.length === 0) return;\n console.log(\"\");\n console.log(chalk.red.bold(` ⚠ Review before deploying: these rules change meaning (${report.ruleChanges.length})`));\n console.log(chalk.red(\" Each is carried as written and keeps its policy name, but the policy now grants something different.\"));\n for (const change of report.ruleChanges) {\n console.log(` ${chalk.red(\"!\")} ${change.file} (${change.collection} ${change.rule})`);\n console.log(` ${change.message}`);\n }\n}\n\n/**\n * Run the command.\n *\n * @param flags the parsed flags\n * @param dir the project directory, as typed\n * @param moduleAliases specifiers mapped to files for evaluating the project (the in-repo entry points `@rebasepro/*` at source)\n */\nexport async function runCollectionsToTables(\n flags: { check?: boolean; dryRun?: boolean; json?: boolean; force?: boolean; skipSdkCalls?: boolean; acceptRuleChanges?: boolean },\n dir: string | undefined,\n moduleAliases?: Record<string, string>\n): Promise<MigrationReport> {\n const projectRoot = path.resolve(dir ?? process.cwd());\n const report = await migrateCollectionsToTables({\n projectRoot,\n ...(flags.check ? { check: true } : {}),\n ...(flags.dryRun ? { dryRun: true } : {}),\n ...(flags.force ? { force: true } : {}),\n ...(flags.skipSdkCalls ? { skipSdkCalls: true } : {}),\n ...(flags.acceptRuleChanges ? { acceptRuleChanges: true } : {}),\n ...(moduleAliases ? { moduleAliases } : {})\n });\n if (flags.json) console.log(JSON.stringify(report, null, 2));\n else printReport(report);\n if (report.status === \"blocked\" || report.status === \"failed\" || report.status === \"rule-changes\") process.exitCode = 1;\n return report;\n}\n\n/** The SDK-call rewrite's part of a report. */\nfunction printSdkSection(sdk: SdkRewriteReport): void {\n const total = Object.values(sdk.counts).reduce((sum, count) => sum + (count ?? 0), 0);\n console.log(\"\");\n console.log(chalk.bold(` SDK calls: ${total} rewrite(s) in ${sdk.files.length} file(s)${sdk.typeAware ? \" (receivers checked by type where a program could be built)\" : \"\"}`));\n for (const [rule, count] of Object.entries(sdk.counts)) console.log(` ${rule}: ${count}`);\n if (sdk.dependencies.length > 0) {\n console.log(chalk.bold(` Dependencies added (${sdk.dependencies.length}) — imports moved to these packages; run your package manager's install:`));\n for (const added of sdk.dependencies) console.log(` ${added.file}: ${chalk.green(`\"${added.name}\": \"${added.version}\"`)}`);\n }\n if (sdk.byName.length > 0) {\n console.log(chalk.yellow(` Rewritten by name — review (${sdk.byName.length}): no type says \"SDK\" (untyped, \\`any\\`, a structural type of your own, a test double), so the slot's name (\\`dataAsAdmin\\`, \\`data\\` with a literal table) decided. A \\`.collection(\\` left on the data surface is a TypeError on 0.31 that no type check reports:`));\n for (const entry of sdk.byName) console.log(` ${entry.file}:${entry.line} ${chalk.gray(entry.code)}`);\n }\n if (sdk.left.length > 0) {\n console.log(chalk.yellow(` Left unchanged (${sdk.left.length}) — check each:`));\n for (const left of sdk.left) console.log(` ${left.file}:${left.line} ${chalk.gray(left.code)} — ${left.reason}`);\n }\n}\n\n/** The help page of `rebase migrate sdk-calls`. */\nexport function printSdkCallsHelp(): void {\n console.log(`\n${chalk.bold(\"rebase migrate sdk-calls\")} — rewrite a project's own code for the SDK rename\n\n${chalk.bold(\"Usage\")}\n rebase migrate sdk-calls [dir] [--dry-run] [--json] [--force]\n\n Part of ${chalk.cyan(\"rebase migrate collections-to-tables\")}; run it alone on a project already migrated.\n data.collection(\"x\") → data.table(\"x\") on the SDK data surface, createRebaseClient options,\n generated type names, batch operations, error codes, offline options, typed accessors,\n setCollectionCallbacks → setTableHooks (hook props adapted), storageAuthorize data, and the\n rule keys: existsIn({ collection: X }) and membership: { collection: X } → table: X.\n A .collection( call whose receiver is not the SDK is left as written and listed. Where no type\n says \"SDK\" (untyped, any, a structural type of the project's own), a receiver ending in\n .dataAsAdmin, or in .data with a literal table name, is rewritten and listed for review — as are\n test doubles a data/dataAsAdmin slot holds ({ dataAsAdmin: { collection: … } }) and, in test\n files, source-text assertions (collection(\"x\") in a string or regex).\n Generated SDK files are not rewritten: run rebase generate-sdk.\n\n Imports of names 0.31 moved to another package (the admin-panel helpers and types that left\n @rebasepro/types and @rebasepro/common for @rebasepro/cms-types, the migration lift now in\n @rebasepro/common/migrate) are moved to it — merged into an import the file has, import type,\n inline type and as aliases kept — and renamed exports (reviewSecurityRules → reviewRls,\n assertUploadWithinPropertyLimits → assertUploadWithinColumnLimits, …) are renamed with their\n references. A package an import now names is added to that workspace package's dependencies,\n at the range of its other @rebasepro packages.\n\n${chalk.bold(\"When to use it\")}\n On a project already migrated (or migrated with --skip-sdk-calls), and again after pulling in\n code written against the old names. A second run on rewritten code changes nothing.\n\n${chalk.bold(\"Options\")}\n --dry-run Print what would change; write nothing\n --json One JSON document on stdout\n --force Run on a dirty (or absent) git tree. Without it the run refuses, so its edits stay one diff.\n\n${chalk.bold(\"Manual steps\")}\n What it cannot rewrite safely is printed after the counts as a numbered list, each with the file,\n the line and what to write instead: a boot option it cannot prove, a generated SDK file, an export\n that was removed or now means something else, a namespace import, export * or dynamic import that\n uses a moved name, an option, variable, route or MCP tool name whose meaning changed, an old CLI\n flag in a package.json script. Each points at its section of the upgrade guide.\n`);\n}\n\n/**\n * Run \\`rebase migrate sdk-calls\\`.\n *\n * @param dir the project directory, as typed\n * @param aliases specifiers mapped to files, for the type checker (in-repo runs)\n */\nexport async function runSdkCalls(flags: { dryRun?: boolean; json?: boolean; force?: boolean }, dir: string | undefined, aliases?: Record<string, string>): Promise<SdkRewriteReport | undefined> {\n const root = path.resolve(dir ?? process.cwd());\n if (!flags.dryRun && !flags.force) {\n const state = gitState(root);\n if (!state.clean) {\n if (flags.json) console.log(JSON.stringify({ error: { message: state.reason, code: \"dirty_tree\" } }, null, 2));\n else console.error(chalk.red(`✗ ${state.reason}`));\n process.exitCode = 1;\n return undefined;\n }\n }\n const legacyConfig = path.join(root, \"config\", \"collections\");\n const { files, report } = await rewriteSdkCalls(root, { skipDirs: [legacyConfig], ...(aliases ? { aliases } : {}) });\n if (!flags.dryRun) for (const [file, content] of files) fs.writeFileSync(file, content);\n if (flags.json) {\n console.log(JSON.stringify({ status: flags.dryRun ? \"planned\" : files.size > 0 ? \"rewritten\" : \"nothing-to-do\", ...report }, null, 2));\n } else {\n console.log(chalk.bold(`\\nrebase migrate sdk-calls — ${root}`));\n printSdkSection(report);\n const steps = groupSteps(report.manualSteps);\n if (steps.length > 0) console.log(chalk.bold(`\\n Manual steps (${steps.length}):`));\n steps.forEach((step, index) => {\n console.log(` ${index + 1}. ${chalk.bold(step.title)}${step.file ? chalk.gray(` (${step.file})`) : \"\"}`);\n console.log(` ${step.detail}`);\n if (step.snippet) for (const line of step.snippet.split(\"\\n\")) console.log(chalk.cyan(` ${line}`));\n });\n console.log(flags.dryRun ? \"\\n Dry run: nothing was written.\\n\" : files.size > 0 ? \"\\n Rewritten. Review the diff, then run your type check.\\n\" : \"\\n Nothing to rewrite.\\n\");\n }\n return report;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAa,YAAb,MAAuB;CACE;CAArB,YAAY,MAAuB;EAAd,KAAA,OAAA;CAAe;AACxC;AAEA,IAAM,SAAS;AACf,IAAM,aAAa;;AAGnB,SAAgB,SAAS,KAAqB;CAC1C,OAAO,WAAW,KAAK,GAAG,IAAI,MAAM,KAAK,UAAU,GAAG;AAC1D;;AAGA,SAAgB,mBAAmB,OAAuB;CACtD,OAAO,KAAK,UAAU,KAAK;AAC/B;;;;;AAMA,SAAgB,SAAS,MAAc,QAAwB;CAE3D,OADc,KAAK,MAAM,IAClB,CAAA,CAAM,KAAK,MAAM,UAAW,UAAU,KAAK,KAAK,WAAW,IAAI,OAAO,GAAG,SAAS,MAAO,CAAC,CAAC,KAAK,IAAI;AAC/G;;;;;;AAOA,SAAgB,OAAO,MAAc,YAA4B;CAC7D,IAAI,WAAW,WAAW,GAAG,OAAO;CACpC,OAAO,KACF,MAAM,IAAI,CAAC,CACX,KAAK,MAAM,UAAW,QAAQ,KAAK,KAAK,WAAW,UAAU,IAAI,KAAK,MAAM,WAAW,MAAM,IAAI,IAAK,CAAC,CACvG,KAAK,IAAI;AAClB;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CACxB;CAArB,YAAY,MAAuB,SAAiB;EAChD,MAAM,GAAG,KAAK,IAAI,SAAS;EADV,KAAA,OAAA;CAErB;AACJ;AAEA,SAAS,gBAAc,OAAkD;CACrE,IAAI,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