@prisma/orm-better-auth 8.0.0-rc.25-dev.7 → 8.0.0-rc.25-dev.9
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/README.md +49 -19
- package/dist/contract-check-Cw4rCQvX.mjs +799 -0
- package/dist/contract-check-Cw4rCQvX.mjs.map +1 -0
- package/dist/edited-contract-source-uFJmCt41.mjs +487 -0
- package/dist/edited-contract-source-uFJmCt41.mjs.map +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -774
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edited-contract-source-uFJmCt41.mjs","names":[],"sources":["../src/generate/refusal.ts","../src/generate/contract-source-files.ts","../src/generate/check-edited-source.ts","../src/generate/edit-contract-source.ts","../src/generate/edited-contract-source.ts"],"sourcesContent":["import type { BetterAuthError } from '@better-auth/core/error';\nimport type { ContractComparison } from '../contract/compare';\nimport { contractMismatchError } from '../contract/contract-check';\nimport { contractMessage } from '../contract/message';\n\nconst additionKinds: ReadonlySet<string> = new Set(['missing-model', 'missing-field']);\n\n/** The error `auth generate` throws when it writes nothing: the contract message, then why the contract was not changed. */\nexport function notChanged(comparison: ContractComparison, reason?: string): BetterAuthError {\n const message = contractMessage(comparison) ?? '';\n return contractMismatchError(\n reason === undefined\n ? message\n : `${message}\\n\\n\\`auth generate\\` did not change your contract, because ${reason}`,\n );\n}\n\n/** Throws the contract message when the comparison found something other than a missing model or field, which `auth generate` does not fix. */\nexport function assertOnlyAdditions(comparison: ContractComparison): void {\n if (comparison.problems.some((problem) => !additionKinds.has(problem.kind))) {\n throw notChanged(comparison);\n }\n}\n\nexport function listOf(items: readonly string[]): string {\n const last = items.at(-1);\n return items.length < 2 || last === undefined\n ? items.join('')\n : `${items.slice(0, -1).join(', ')} and ${last}`;\n}\n","import { isPrisma8Schema } from '@prisma/orm-framework/psl-parser';\nimport type { ContractComparison } from '../contract/compare';\nimport type { ContractSourceFile } from './edit-contract-source';\nimport { notChanged } from './refusal';\n\nexport interface ReadContractSourceFile extends ContractSourceFile {\n /** The file's absolute path, which Better Auth writes to whatever its `--cwd`. */\n readonly absolutePath: string;\n}\n\nconst passOutput = 'Pass your contract file with `--output`.';\nconst typeScriptContract =\n 'it is written in TypeScript. Add the equivalent models and fields in TypeScript.';\nconst typeScriptFile = /\\.[cm]?tsx?$/;\nconst betterAuthDirectoryFile = 'auth-schema.ts';\n\n/** A caught error's code, as the operating system and the module loader give one, in parentheses; nothing when it has none. Their messages are left out: they differ between systems and hold absolute paths. */\nfunction errorCode(error: unknown): string {\n const code: unknown = error instanceof Error ? Reflect.get(error, 'code') : undefined;\n return typeof code === 'string' ? ` (${code})` : '';\n}\n\n/** A caught error's code, or else the first line of its message. Used where an error without a code comes from the developer's own `prisma.config.ts` or file, whose text is what they need. */\nfunction errorDetail(error: unknown): string {\n const code = errorCode(error);\n if (code !== '') return code;\n const message = error instanceof Error ? error.message : String(error);\n return `: ${message.split('\\n')[0]}`;\n}\n\nfunction isMissingFile(error: unknown): boolean {\n return error instanceof Error && Reflect.get(error, 'code') === 'ENOENT';\n}\n\nasync function configLoader(comparison: ContractComparison) {\n try {\n return await import('@prisma/orm-toolchain/config-loader');\n } catch (error) {\n throw notChanged(\n comparison,\n `Prisma's config loader could not be loaded${errorCode(error)}. ${passOutput}`,\n );\n }\n}\n\n/** The absolute paths of the contract's inputs in `prisma.config.ts` in the working directory. Better Auth does not tell the adapter its `--cwd`. */\nasync function contractInputs(\n comparison: ContractComparison,\n shown: (path: string) => string,\n): Promise<readonly string[]> {\n const loader = await configLoader(comparison);\n const didNotLoad = (reason: string) =>\n notChanged(comparison, `prisma.config.ts did not load${reason}. ${passOutput}`);\n let loaded: Awaited<ReturnType<typeof loader.loadConfigForSections>>;\n try {\n loaded = await loader.loadConfigForSections(undefined, ['contract']);\n } catch (error) {\n throw didNotLoad(errorDetail(error));\n }\n if (!loaded.ok) {\n if (loaded.failure.code === 'CONFIG.FILE_NOT_FOUND') {\n throw notChanged(\n comparison,\n `it found no prisma.config.ts in the working directory. ${passOutput}`,\n );\n }\n throw didNotLoad(`: ${loaded.failure.message}`);\n }\n const source = loaded.value.contract?.source;\n if (source === undefined) {\n throw notChanged(comparison, `prisma.config.ts names no contract. ${passOutput}`);\n }\n if (source.format !== 'psl') throw notChanged(comparison, typeScriptContract);\n if (source.parserOptions?.grammar === 'prisma-7') {\n throw notChanged(\n comparison,\n 'it is a Prisma 7 schema, and the lines above are Prisma 8 syntax. Add the equivalent lines by hand.',\n );\n }\n const inputs = await loader.expandContractInputs(source.inputs);\n if (inputs.length === 0) {\n throw notChanged(\n comparison,\n `the contract inputs prisma.config.ts names match no file: ${(source.inputs ?? []).map(shown).join(', ')}. ${passOutput}`,\n );\n }\n return inputs;\n}\n\n/**\n * The contract's source files: the file `--output` names when Better Auth passes one, otherwise the files of the contract in `prisma.config.ts` in the working directory that start with `// use prisma-8`, as emitting reads them. Each file's `path` is relative to the working directory when the file is inside it. Throws the contract message, with the reason, when no PSL source can be read.\n */\nexport async function contractSourceFiles(\n file: string | undefined,\n comparison: ContractComparison,\n): Promise<readonly ReadContractSourceFile[]> {\n const { readFile } = await import('node:fs/promises');\n const { basename, isAbsolute, relative, resolve } = await import('node:path');\n const shown = (path: string): string => {\n const fromCwd = relative(process.cwd(), path);\n return fromCwd.startsWith('..') || isAbsolute(fromCwd) ? path : fromCwd;\n };\n if (file !== undefined && typeScriptFile.test(file)) {\n throw notChanged(\n comparison,\n basename(file) === betterAuthDirectoryFile\n ? `\\`--output\\` names a directory, so Better Auth passed ${shown(resolve(file))}. Pass your contract's PSL file itself with \\`--output\\`.`\n : typeScriptContract,\n );\n }\n const paths = file === undefined ? await contractInputs(comparison, shown) : [resolve(file)];\n const files: ReadContractSourceFile[] = [];\n for (const absolutePath of paths) {\n const path = shown(absolutePath);\n let text: string;\n try {\n text = await readFile(absolutePath, 'utf8');\n } catch (error) {\n throw notChanged(\n comparison,\n isMissingFile(error)\n ? `${path} was not found. ${passOutput}`\n : `${path} could not be read${errorDetail(error)}. ${passOutput}`,\n );\n }\n if (file === undefined && !isPrisma8Schema(text)) continue;\n files.push({ path, text, absolutePath });\n }\n if (files.length === 0) {\n throw notChanged(\n comparison,\n `none of the files prisma.config.ts names starts with \\`// use prisma-8\\`. ${passOutput}`,\n );\n }\n return files;\n}\n","import { buildSymbolTable } from '@prisma/orm-framework/psl-parser';\nimport { parse } from '@prisma/orm-framework/psl-parser/syntax';\nimport type { ContractSourceFile } from './edit-contract-source';\n\nexport interface NewDiagnostic {\n readonly path: string;\n readonly message: string;\n /** One-based. */\n readonly line: number;\n}\n\n/** Text the edit inserted into a file: `length` characters at `offset` of the original text. */\nexport interface InsertedText {\n readonly path: string;\n readonly offset: number;\n readonly length: number;\n}\n\ninterface LocatedDiagnostic extends NewDiagnostic {\n readonly offset: number;\n}\n\nfunction offsetOf(text: string, line: number, character: number): number {\n let offset = 0;\n for (let current = 0; current < line; current += 1) {\n const newline = text.indexOf('\\n', offset);\n if (newline === -1) return text.length;\n offset = newline + 1;\n }\n return offset + character;\n}\n\n/** What Prisma's published parser and symbol table report for a contract's source files: parse errors and duplicate declarations. */\nfunction diagnosticsOf(\n files: readonly ContractSourceFile[],\n defaultNamespaceId: string,\n): LocatedDiagnostic[] {\n const parsed = files.map((file) => parse(file.text, file.path));\n const [first, ...rest] = parsed.map(({ sources }) => sources);\n if (first === undefined) return [];\n const { diagnostics } = buildSymbolTable({\n documents: parsed.map(({ document }) => document),\n sources: first.merge(...rest),\n defaultNamespaceId,\n });\n const textOf = new Map(files.map((file) => [file.path, file.text]));\n return [...parsed.flatMap((result) => result.diagnostics), ...diagnostics].map(\n ({ filename, message, range }) => ({\n path: filename,\n message,\n line: range.start.line + 1,\n offset: offsetOf(textOf.get(filename) ?? '', range.start.line, range.start.character),\n }),\n );\n}\n\nfunction keyOf({ path, message, offset }: LocatedDiagnostic): string {\n return `${path}\\u0000${message}\\u0000${offset}`;\n}\n\n/**\n * The first diagnostic the edited files have and the original files do not. Each original diagnostic is moved by the text the edit inserted before it, so a diagnostic the original already had is matched where it now is, and the one returned is where the edit put it. The check is what a published entrypoint offers without the target's descriptors: parsing and the symbol table, not the binder or interpreter.\n */\nexport function firstNewDiagnostic(\n original: readonly ContractSourceFile[],\n edited: readonly ContractSourceFile[],\n defaultNamespaceId: string,\n inserted: readonly InsertedText[],\n): NewDiagnostic | undefined {\n const remaining = new Map<string, number>();\n for (const diagnostic of diagnosticsOf(original, defaultNamespaceId)) {\n const shift = inserted\n .filter(({ path, offset }) => path === diagnostic.path && offset <= diagnostic.offset)\n .reduce((total, { length }) => total + length, 0);\n const key = keyOf({ ...diagnostic, offset: diagnostic.offset + shift });\n remaining.set(key, (remaining.get(key) ?? 0) + 1);\n }\n for (const diagnostic of diagnosticsOf(edited, defaultNamespaceId)) {\n const key = keyOf(diagnostic);\n const left = remaining.get(key) ?? 0;\n if (left === 0)\n return { path: diagnostic.path, message: diagnostic.message, line: diagnostic.line };\n remaining.set(key, left - 1);\n }\n return undefined;\n}\n","import { isPrisma8Schema } from '@prisma/orm-framework/psl-parser';\nimport {\n CompositeTypeDeclarationAst,\n type DocumentAst,\n type FieldAttributeAst,\n type FieldDeclarationAst,\n GenericBlockDeclarationAst,\n MixinDeclarationAst,\n type ModelAttributeAst,\n ModelDeclarationAst,\n NamespaceDeclarationAst,\n parse,\n StringLiteralExprAst,\n TypesBlockAst,\n} from '@prisma/orm-framework/psl-parser/syntax';\nimport type { ContractComparison } from '../contract/compare';\nimport { type PrintedBlock, printPsl, renderBlocks } from '../contract/print-psl';\nimport { isSearchedNamespace, modelNameCandidates } from '../models/model-lookup';\nimport { firstNewDiagnostic } from './check-edited-source';\nimport { assertOnlyAdditions, listOf, notChanged } from './refusal';\n\nexport interface ContractSourceFile {\n /** The path `auth generate` shows and writes to. */\n readonly path: string;\n readonly text: string;\n}\n\nexport interface ContractEdit<F extends ContractSourceFile = ContractSourceFile> {\n /** The source file the edit changes. */\n readonly file: F;\n /** The whole edited file. */\n readonly code: string;\n /** What is added where and what to do after the file is written, then a line for each note the printed PSL carries. */\n readonly summary: string;\n}\n\ninterface DeclaredModel<F extends ContractSourceFile = ContractSourceFile> {\n readonly file: F;\n readonly namespaceId: string;\n readonly declaration: ModelDeclarationAst;\n}\n\ninterface Insertion {\n readonly offset: number;\n readonly text: string;\n}\n\nfunction modelKey(namespaceId: string, name: string): string {\n return `${namespaceId}.${name}`;\n}\n\n/** A declaration other than a model that takes a name a model could take, as Prisma's symbol table claims names. */\ninterface OtherDeclaration {\n readonly path: string;\n readonly namespaceId: string;\n readonly name: string;\n readonly kind: string;\n}\n\ninterface DeclaredField {\n readonly name: string;\n /** The column the field is stored in: its `@map` name, or its own. */\n readonly column: string;\n}\n\ninterface DeclaredMixin {\n readonly name: string;\n readonly path: string;\n readonly fields: readonly DeclaredField[];\n}\n\ninterface Declarations<F extends ContractSourceFile> {\n readonly models: Map<string, DeclaredModel<F>[]>;\n readonly others: OtherDeclaration[];\n readonly mixins: DeclaredMixin[];\n}\n\n/** The kind of a declaration that shares the name slot of models, or `undefined` for a model or a declaration that does not. Read from `buildSymbolTable` in `psl-parser/src/symbol-table.ts`. */\nfunction otherKind(declaration: unknown): string | undefined {\n if (declaration instanceof CompositeTypeDeclarationAst) return 'composite type';\n if (declaration instanceof MixinDeclarationAst) return 'mixin';\n if (declaration instanceof GenericBlockDeclarationAst) {\n return declaration.keyword()?.text ?? 'block';\n }\n return undefined;\n}\n\nfunction declaredFields(fields: Iterable<FieldDeclarationAst>): DeclaredField[] {\n return [...fields].flatMap((field) => {\n const name = field.name()?.name();\n return name === undefined ? [] : [{ name, column: mappedName(field.attributes()) ?? name }];\n });\n}\n\n/** A field of a model as the contract will have it, and where it is written. */\ninterface ModelField extends DeclaredField {\n /** The mixin it comes from; `undefined` for the model's own field. */\n readonly mixin: string | undefined;\n /** The file the field is written in: the model's, or the mixin's. */\n readonly path: string;\n}\n\n/** The model's fields as the contract will have them: its own, then those of every mixin it includes. */\nfunction modelFields(\n { file, declaration }: DeclaredModel,\n mixins: readonly DeclaredMixin[],\n): ModelField[] {\n const own = declaredFields(declaration.fields()).map((field) => ({\n ...field,\n mixin: undefined,\n path: file.path,\n }));\n const included = [...declaration.inclusions()].flatMap((inclusion) => {\n const mixinName = inclusion.name()?.path().at(-1);\n return mixins\n .filter(({ name }) => name === mixinName)\n .flatMap((mixin) =>\n mixin.fields.map((field) => ({ ...field, mixin: mixin.name, path: mixin.path })),\n );\n });\n return [...own, ...included];\n}\n\nfunction collectDeclarations<F extends ContractSourceFile>(\n file: F,\n document: DocumentAst,\n defaultNamespace: string,\n into: Declarations<F>,\n): void {\n const add = (\n namespaceId: string,\n declaration:\n | ModelDeclarationAst\n | CompositeTypeDeclarationAst\n | GenericBlockDeclarationAst\n | MixinDeclarationAst,\n ) => {\n const name = declaration.name()?.name();\n if (name === undefined) return;\n if (declaration instanceof ModelDeclarationAst) {\n const key = modelKey(namespaceId, name);\n into.models.set(key, [...(into.models.get(key) ?? []), { file, namespaceId, declaration }]);\n return;\n }\n if (declaration instanceof MixinDeclarationAst) {\n into.mixins.push({ name, path: file.path, fields: declaredFields(declaration.fields()) });\n }\n const kind = otherKind(declaration);\n if (kind !== undefined) into.others.push({ path: file.path, namespaceId, name, kind });\n };\n for (const declaration of document.declarations()) {\n if (\n declaration instanceof ModelDeclarationAst ||\n declaration instanceof CompositeTypeDeclarationAst ||\n declaration instanceof GenericBlockDeclarationAst ||\n declaration instanceof MixinDeclarationAst\n ) {\n add(defaultNamespace, declaration);\n continue;\n }\n if (declaration instanceof TypesBlockAst) {\n for (const binding of declaration.declarations()) {\n const name = binding.name()?.name();\n if (name !== undefined) {\n into.others.push({\n path: file.path,\n namespaceId: defaultNamespace,\n name,\n kind: 'named type',\n });\n }\n }\n continue;\n }\n if (!(declaration instanceof NamespaceDeclarationAst)) continue;\n const namespaceName = declaration.name()?.name();\n if (namespaceName !== undefined) {\n into.others.push({\n path: file.path,\n namespaceId: defaultNamespace,\n name: namespaceName,\n kind: 'namespace',\n });\n }\n const namespaceId = namespaceName ?? defaultNamespace;\n for (const member of declaration.declarations()) {\n if (\n member instanceof ModelDeclarationAst ||\n member instanceof CompositeTypeDeclarationAst ||\n member instanceof GenericBlockDeclarationAst ||\n member instanceof MixinDeclarationAst\n ) {\n add(namespaceId, member);\n }\n }\n }\n}\n\nfunction parsedDeclarations<F extends ContractSourceFile>(\n files: readonly F[],\n comparison: ContractComparison,\n): Declarations<F> {\n const declarations: Declarations<F> = { models: new Map(), others: [], mixins: [] };\n for (const file of files) {\n if (!isPrisma8Schema(file.text)) {\n throw notChanged(comparison, `${file.path} does not start with \\`// use prisma-8\\`.`);\n }\n const { document, diagnostics } = parse(file.text, file.path);\n const [first] = diagnostics;\n if (first !== undefined) {\n throw notChanged(\n comparison,\n `${file.path} does not parse: ${first.message} (line ${first.range.start.line + 1}).`,\n );\n }\n collectDeclarations(file, document, comparison.defaultNamespace, declarations);\n }\n return declarations;\n}\n\n/** The name `@map(\"x\")` or `@@map(\"x\")` gives, read as the contract emitter reads it: the first `map` attribute, and its first positional argument when that is a string. */\nfunction mappedName(\n attributes: Iterable<FieldAttributeAst | ModelAttributeAst>,\n): string | undefined {\n for (const attribute of attributes) {\n const path = attribute.name()?.path() ?? [];\n if (path.length !== 1 || path[0] !== 'map') continue;\n const [first] = [...(attribute.argList()?.args() ?? [])].filter(\n (argument) => argument.name() === undefined,\n );\n const value = first?.value();\n return value instanceof StringLiteralExprAst ? value.value() : undefined;\n }\n return undefined;\n}\n\n/** A declaration the adapter will find, which the emitted contract does not have yet. */\ninterface AheadOfEmit {\n readonly name: string;\n /** The namespace of a model, which the list names when two models have the same name. */\n readonly namespaceId: string | undefined;\n readonly path: string;\n}\n\n/** A declaration stored where Better Auth's model or field is stored, under a name the adapter does not look up. */\ninterface StoredUnderAnotherName {\n readonly path: string;\n /** The declaration as the developer wrote it: the model's name, or the field's name after its model's. */\n readonly declared: string;\n readonly storage: string;\n /** What Better Auth looks for, as the edit would have written it. */\n readonly lookedFor: string;\n readonly renameTo: string;\n}\n\ninterface Conflicts {\n readonly aheadOfEmit: AheadOfEmit[];\n readonly storedUnderAnotherName: StoredUnderAnotherName[];\n}\n\n/** The name with only the ASCII letters A to Z lower-cased, the case SQLite ignores in table and column names. */\nfunction foldAsciiCase(name: string): string {\n return name.replace(/[A-Z]/g, (letter) => letter.toLowerCase());\n}\n\nfunction sameStorageName(a: string, b: string, comparison: ContractComparison): boolean {\n return comparison.storageNamesIgnoreCase ? foldAsciiCase(a) === foldAsciiCase(b) : a === b;\n}\n\n/** What the model already declares that conflicts with the fields the block would add. A Better Auth field is found by its exact name. */\nfunction fieldConflicts(\n block: PrintedBlock,\n model: DeclaredModel,\n mixins: readonly DeclaredMixin[],\n comparison: ContractComparison,\n into: Conflicts,\n): void {\n const additions = new Set(block.fieldNames);\n for (const { name, column, mixin, path } of modelFields(model, mixins)) {\n const declared = `${block.modelName}.${name}${mixin === undefined ? '' : ` (from the mixin ${mixin})`}`;\n if (additions.has(name)) {\n into.aheadOfEmit.push({ name: declared, namespaceId: undefined, path });\n continue;\n }\n const needed = block.columns.find((candidate) =>\n sameStorageName(candidate, column, comparison),\n );\n if (needed === undefined) continue;\n into.storedUnderAnotherName.push({\n path,\n declared,\n storage: `the column \"${column}\"`,\n lookedFor: `a field named ${needed} in ${block.modelName}`,\n renameTo: needed,\n });\n }\n}\n\n/**\n * The declared models that conflict with a model the block would add: one with a name the adapter looks the model up by, in a namespace the adapter searches; or one stored in its table, in the namespace the model goes into.\n */\nfunction modelConflicts(\n block: PrintedBlock,\n models: readonly DeclaredModel[],\n comparison: ContractComparison,\n into: Conflicts,\n): void {\n const { physicalName, table } = block;\n if (physicalName === undefined || table === undefined) return;\n const lookedUp = new Set(modelNameCandidates(physicalName));\n const newNamespace = comparison.namespace ?? comparison.defaultNamespace;\n for (const { file, namespaceId, declaration } of models) {\n const name = declaration.name()?.name();\n if (name === undefined) continue;\n if (lookedUp.has(name) && isSearchedNamespace(namespaceId, comparison.namespace)) {\n into.aheadOfEmit.push({ name, namespaceId, path: file.path });\n continue;\n }\n if (namespaceId !== newNamespace) continue;\n const stored = mappedName(declaration.attributes()) ?? name;\n if (!sameStorageName(stored, table, comparison)) continue;\n into.storedUnderAnotherName.push({\n path: file.path,\n declared: name,\n storage: `the table \"${stored}\"`,\n lookedFor: `a model named ${block.modelName}`,\n renameTo: block.modelName,\n });\n }\n}\n\n/** The listed names, each prefixed with its namespace when another listed name is the same. */\nfunction aheadOfEmitNames(declarations: readonly AheadOfEmit[]): string[] {\n return declarations.map(({ name, namespaceId }) =>\n namespaceId !== undefined && declarations.filter((other) => other.name === name).length > 1\n ? `${namespaceId}.${name}`\n : name,\n );\n}\n\nfunction storedUnderAnotherNameReason({\n path,\n declared,\n storage,\n lookedFor,\n renameTo,\n}: StoredUnderAnotherName): string {\n return `${path} stores ${declared} in ${storage}, but Better Auth looks for ${lookedFor}. Rename ${declared} to ${renameTo}, then run \\`prisma contract emit\\`, and \\`auth generate\\` again.`;\n}\n\nfunction uniquePaths(models: readonly DeclaredModel[]): string[] {\n return [...new Set(models.map(({ file }) => file.path))];\n}\n\nfunction lineStart(text: string, offset: number): number {\n return text.lastIndexOf('\\n', offset - 1) + 1;\n}\n\n/** The offset of the line break that ends the line holding `offset`, before `\\r\\n` or `\\n`, or the end of the text. */\nfunction lineEnd(text: string, offset: number): number {\n const newline = text.indexOf('\\n', offset);\n if (newline === -1) return text.length;\n return text[newline - 1] === '\\r' ? newline - 1 : newline;\n}\n\nfunction indentationAt(text: string, offset: number): string {\n return /^[ \\t]*/.exec(text.slice(lineStart(text, offset)))?.[0] ?? '';\n}\n\n/** The indentation of a field relative to its model, from the first model of the file that has a field; two spaces when none has. */\nfunction indentUnit(text: string, models: readonly DeclaredModel[]): string {\n for (const { declaration } of [...models].sort(\n (a, b) => a.declaration.syntax.offset - b.declaration.syntax.offset,\n )) {\n const [field] = declaration.fields();\n if (field === undefined) continue;\n const modelIndent = indentationAt(text, declaration.syntax.offset);\n const fieldIndent = indentationAt(text, field.syntax.offset);\n if (fieldIndent.length > modelIndent.length && fieldIndent.startsWith(modelIndent)) {\n return fieldIndent.slice(modelIndent.length);\n }\n }\n return ' ';\n}\n\n/** Printed PSL, indented two spaces a level, with each level indented by `unit` instead. */\nfunction reindented(printed: string, unit: string): string {\n return printed.replace(/^(?: {2})+/gm, (spaces) => unit.repeat(spaces.length / 2));\n}\n\n/** Where the block's fields go: after the line of the model's last field, or after the `{` line of a model without fields. `undefined` when the model's `}` is on that line. */\nfunction fieldInsertion(\n text: string,\n declaration: ModelDeclarationAst,\n block: PrintedBlock,\n eol: string,\n unit: string,\n): Insertion | undefined {\n const last = [...declaration.fields()].at(-1);\n const anchorEnd = last?.syntax.endOffset ?? declaration.lbrace()?.endOffset;\n const rbrace = declaration.rbrace();\n if (anchorEnd === undefined || rbrace === undefined) return undefined;\n const offset = lineEnd(text, anchorEnd);\n if (rbrace.offset < offset) return undefined;\n const indent =\n last === undefined\n ? `${indentationAt(text, declaration.syntax.offset)}${unit}`\n : indentationAt(text, last.syntax.offset);\n return { offset, text: block.fieldLines.map((line) => `${eol}${indent}${line}`).join('') };\n}\n\nfunction separatorBefore(text: string, eol: string): string {\n if (text.endsWith(`${eol}${eol}`)) return '';\n return text.endsWith(eol) ? eol : `${eol}${eol}`;\n}\n\nfunction countOf(count: number, noun: string): string {\n return `${count} ${noun}${count === 1 ? '' : 's'}`;\n}\n\nfunction summaryOf(\n path: string,\n extended: readonly PrintedBlock[],\n added: readonly PrintedBlock[],\n notes: readonly string[],\n): string {\n const parts = extended.map(\n (block) => `${countOf(block.fieldNames.length, 'field')} added to ${block.modelName}`,\n );\n if (added.length > 0) {\n parts.push(\n `model${added.length === 1 ? '' : 's'} ${listOf(added.map((block) => block.modelName))} added`,\n );\n }\n return [\n `Changes to ${path}: ${parts.join(', ')}. After the file is written, run \\`prisma contract emit\\` and update your database.`,\n ...notes.map((note) => `Note: ${note}`),\n ].join('\\n');\n}\n\n/**\n * Adds what the comparison found missing to the PSL source files, as text inserted at positions from the syntax tree: missing fields after the last field of their model, missing models at the end of the file that holds the first model the edit extends. Every original line is kept as written. Throws the contract message, with the reason, when the edit cannot be made.\n */\nexport function editContractSource<F extends ContractSourceFile>(\n files: readonly F[],\n comparison: ContractComparison,\n): ContractEdit<F> {\n assertOnlyAdditions(comparison);\n const withoutId = comparison.models.find(\n (model) => model.status === 'found' && model.missingFields.includes('id'),\n );\n if (withoutId?.status === 'found') {\n throw notChanged(\n comparison,\n `model ${withoutId.found.name} has no field named \\`id\\`. Add the \\`id\\` field above by hand, with \\`@unique\\` in place of \\`@id\\`.`,\n );\n }\n\n const { models: declared, others, mixins } = parsedDeclarations(files, comparison);\n const printed = printPsl(comparison);\n const extended = printed.blocks.filter((block) => block.existing);\n const added = printed.blocks.filter((block) => !block.existing);\n\n const targets = extended.map((block) => {\n const matches = declared.get(modelKey(block.namespaceId, block.modelName)) ?? [];\n const [match] = matches;\n if (match === undefined) {\n throw notChanged(\n comparison,\n `no model ${block.modelName} is declared in ${listOf(files.map((file) => file.path))}.`,\n );\n }\n if (matches.length > 1) {\n throw notChanged(\n comparison,\n `model ${block.modelName} is declared more than once in ${listOf(uniquePaths(matches))}.`,\n );\n }\n return { block, ...match };\n });\n\n const allDeclared = [...declared.values()].flat();\n const conflicts: Conflicts = { aheadOfEmit: [], storedUnderAnotherName: [] };\n for (const { block, ...model } of targets) {\n fieldConflicts(block, model, mixins, comparison, conflicts);\n }\n for (const block of added) modelConflicts(block, allDeclared, comparison, conflicts);\n const { aheadOfEmit, storedUnderAnotherName } = conflicts;\n if (aheadOfEmit.length > 0) {\n throw notChanged(\n comparison,\n `${listOf([...new Set(aheadOfEmit.map(({ path }) => path))])} already declares ${listOf(aheadOfEmitNames(aheadOfEmit))}, which the emitted contract does not have. Run \\`prisma contract emit\\`, then update your database.`,\n );\n }\n if (storedUnderAnotherName.length > 0) {\n throw notChanged(\n comparison,\n storedUnderAnotherName.map(storedUnderAnotherNameReason).join(' '),\n );\n }\n const newNamespace = comparison.namespace ?? comparison.defaultNamespace;\n for (const block of added) {\n const other = others.find(\n ({ namespaceId, name }) => namespaceId === newNamespace && name === block.modelName,\n );\n if (other === undefined) continue;\n throw notChanged(\n comparison,\n `${other.path} declares the ${other.kind} ${other.name}, and Better Auth's model ${block.physicalName ?? block.modelName} needs that name. Rename the ${other.kind}, then run \\`auth generate\\` again.`,\n );\n }\n\n const touched = uniquePaths(targets);\n if (touched.length > 1) {\n throw notChanged(\n comparison,\n `the additions belong in ${listOf(touched)}, and Better Auth writes one file. Add them by hand.`,\n );\n }\n const file = targets[0]?.file ?? files[0];\n if (file === undefined) throw notChanged(comparison, 'no contract file was found.');\n const eol = file.text.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const unit = indentUnit(\n file.text,\n [...declared.values()].flat().filter((model) => model.file === file),\n );\n\n const insertions = targets.map(({ block, declaration }) => {\n const insertion = fieldInsertion(file.text, declaration, block, eol, unit);\n if (insertion === undefined) {\n throw notChanged(\n comparison,\n `model ${block.modelName} is written on one line. Put its \\`}\\` on a line of its own and run \\`auth generate\\` again.`,\n );\n }\n return insertion;\n });\n if (added.length > 0) {\n const models = reindented(renderBlocks(added, comparison.namespace), unit)\n .split('\\n')\n .join(eol);\n insertions.push({\n offset: file.text.length,\n text: `${separatorBefore(file.text, eol)}${models}${eol}`,\n });\n }\n\n let code = file.text;\n for (const { offset, text } of [...insertions].sort((a, b) => b.offset - a.offset)) {\n code = `${code.slice(0, offset)}${text}${code.slice(offset)}`;\n }\n const rejected = firstNewDiagnostic(\n files,\n files.map((candidate) => (candidate === file ? { path: file.path, text: code } : candidate)),\n comparison.defaultNamespace,\n insertions.map(({ offset, text }) => ({ path: file.path, offset, length: text.length })),\n );\n if (rejected !== undefined) {\n throw notChanged(\n comparison,\n `Prisma would not accept the edited ${rejected.path}: ${rejected.message} (line ${rejected.line}).`,\n );\n }\n return { file, code, summary: summaryOf(file.path, extended, added, printed.notes) };\n}\n","import type { DBAdapterSchemaCreation } from '@better-auth/core/db/adapter';\nimport type { ContractComparison } from '../contract/compare';\nimport { contractSourceFiles } from './contract-source-files';\nimport { editContractSource } from './edit-contract-source';\nimport { assertOnlyAdditions } from './refusal';\n\n/**\n * What `auth generate` writes when the contract lacks models or fields: the whole edited contract file at its absolute path, for Better Auth to overwrite after it asks. Prints what is added. Throws the contract message when the contract cannot be edited.\n */\nexport async function editedContractSource(\n file: string | undefined,\n comparison: ContractComparison,\n): Promise<DBAdapterSchemaCreation> {\n assertOnlyAdditions(comparison);\n const edit = editContractSource(await contractSourceFiles(file, comparison), comparison);\n console.log(edit.summary);\n return { code: edit.code, path: edit.file.absolutePath, overwrite: true };\n}\n"],"mappings":";;;;AAKA,MAAM,gCAAqC,IAAI,IAAI,CAAC,iBAAiB,eAAe,CAAC;;AAGrF,SAAgB,WAAW,YAAgC,QAAkC;CAC3F,MAAM,UAAU,gBAAgB,UAAU,KAAK;CAC/C,OAAO,sBACL,WAAW,KAAA,IACP,UACA,GAAG,QAAQ,8DAA8D,QAC/E;AACF;;AAGA,SAAgB,oBAAoB,YAAsC;CACxE,IAAI,WAAW,SAAS,MAAM,YAAY,CAAC,cAAc,IAAI,QAAQ,IAAI,CAAC,GACxE,MAAM,WAAW,UAAU;AAE/B;AAEA,SAAgB,OAAO,OAAkC;CACvD,MAAM,OAAO,MAAM,GAAG,EAAE;CACxB,OAAO,MAAM,SAAS,KAAK,SAAS,KAAA,IAChC,MAAM,KAAK,EAAE,IACb,GAAG,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO;AAC9C;;;ACnBA,MAAM,aAAa;AACnB,MAAM,qBACJ;AACF,MAAM,iBAAiB;AACvB,MAAM,0BAA0B;;AAGhC,SAAS,UAAU,OAAwB;CACzC,MAAM,OAAgB,iBAAiB,QAAQ,QAAQ,IAAI,OAAO,MAAM,IAAI,KAAA;CAC5E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AAQ,KAAK;CAAE;AACrF;;;;;;AC3iBA,eAAsB,qBACpB,MACA,YACkC;CAClC,oBAAoB,UAAU;CAC9B,MAAM,OAAO,mBAAmB,MAAM,oBAAoB,MAAM,UAAU,GAAG,UAAU;CACvF,QAAQ,IAAI,KAAK,OAAO;CACxB,OAAO;EAAE,MAAM,KAAK;EAAM,MAAM,KAAK,KAAK;EAAc,WAAW;CAAK;AAC1E"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/models/model-lookup.ts","../src/options.ts","../src/adapter.ts"],"mappings":";;;;;KAIY,cAAc,SAAS;;;UCFlB;WACN;WACA;WACA;WACA,YAAY;;;;;;;UC0BN;WACN,UAAU;WACV;EACT,YAAY,GAAG,KAAK;aAAe;QAAkB,YAAY,KAAK,QAAQ;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/models/model-lookup.ts","../src/options.ts","../src/adapter.ts"],"mappings":";;;;;KAIY,cAAc,SAAS;;;UCFlB;WACN;WACA;WACA;WACA,YAAY;;;;;;;UC0BN;WACN,UAAU;WACV;EACT,YAAY,GAAG,KAAK;aAAe;QAAkB,YAAY,KAAK,QAAQ;;;;;;;;;;iBAoRhE,cACd,IAAI,kBACJ,iBAAgB,wBACd,mBAAmB,sBAAsB,UAAU"}
|