@vibeorm/generator 1.3.1 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/generate.ts", "../src/emit-dts.ts", "../src/extension-bake.ts", "../src/type-names.ts", "../src/util.ts", "../src/emit-js.ts", "../src/schema-view.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The generator's public entry point: SchemaIR → a consumable client module\n * directory (index.js + directly-written index.d.ts + README.md).\n *\n * Output is byte-identical for structurally identical IR: models, enums and\n * extensions are sorted by name, object keys are serialized sorted, and every\n * emitter iterates deterministically.\n */\n\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { buildComputedManifest, validateComputedConfig } from \"@vibeorm/schema\";\nimport type { ComputedConfig, ComputedManifestEntry, SchemaIR, VibeExtension } from \"@vibeorm/schema\";\nimport { emitDts } from \"./emit-dts.ts\";\nimport { emitJs } from \"./emit-js.ts\";\nimport { bakeExtensions } from \"./extension-bake.ts\";\nimport { buildSchemaView } from \"./schema-view.ts\";\n\n/** What `generateClient` wrote. */\nexport type GenerateResult = {\n /** Paths of the written files (outDir-joined, in emission order). */\n files: string[];\n};\n\nconst README: string = `# Generated VibeORM client\n\nThis directory was generated by \\`@vibeorm/generator\\` from your VibeORM schema — do not edit it by hand, any change is overwritten on the next generate. After every schema change, regenerate with \\`vibeorm generate\\` (or programmatically via \\`generateClient({ schema, outDir })\\` from \\`@vibeorm/generator\\`).\n`;\n\n/**\n * Generate the client module for a schema into `outDir` (created if missing).\n *\n * @throws VibeError `VIBE_SCHEMA_INVALID` when the IR fails validation.\n */\nexport async function generateClient(params: {\n schema: SchemaIR;\n outDir: string;\n /** Configured extension instances — their surfaces bake into the client (D9). */\n extensions?: readonly VibeExtension[];\n /** Computed-field config — types bake into the .d.ts, the manifest into index.js. */\n computed?: ComputedConfig;\n}): Promise<GenerateResult> {\n const { schema, outDir } = params;\n const view = buildSchemaView({ schema });\n const baked = bakeExtensions({ schema: view.schema, extensions: params.extensions ?? [] });\n\n let computed: readonly ComputedManifestEntry[] = [];\n if (params.computed !== undefined && Object.keys(params.computed).length > 0) {\n validateComputedConfig({ schema, computed: params.computed });\n computed = buildComputedManifest({ computed: params.computed });\n }\n\n const outputs: ReadonlyArray<{ name: string; content: string }> = [\n { name: \"index.js\", content: emitJs({ view, baked, computed }) },\n { name: \"index.d.ts\", content: emitDts({ view, baked, computed }) },\n { name: \"README.md\", content: README },\n ];\n\n await mkdir(outDir, { recursive: true });\n const files: string[] = [];\n for (const output of outputs) {\n const path = join(outDir, output.name);\n await writeFile(path, output.content, \"utf-8\");\n files.push(path);\n }\n return { files };\n}\n",
6
+ "/**\n * Emits the generated client's index.d.ts as text (decision D3): the entire\n * typed surface, written directly — no tsc run, no inference for the consumer's\n * tsserver to pay for.\n *\n * Type-budget rules this file is built around (plan §6, constitution rule 2):\n * - concrete per-model base types; narrowing via mapped lookups over them;\n * - no conditional type deeper than a single level per key — recursion exists\n * only where the API is recursive (nested select/include), and each hop is\n * one shallow conditional + one mapped lookup;\n * - no distributive conditionals over model unions — every model's types are\n * spelled out flat;\n * - no Zod, no `as const` inference trees, no mega-unions.\n */\n\nimport { VibeError } from \"@vibeorm/schema\";\nimport type { ComputedManifestEntry } from \"@vibeorm/schema\";\nimport { EMPTY_BAKED_EXTENSIONS } from \"./extension-bake.ts\";\nimport type { BakedExtensions } from \"./extension-bake.ts\";\nimport type { EnumView, FieldView, ModelView, RelationView, SchemaView } from \"./schema-view.ts\";\nimport {\n MINMAX_SCALARS,\n NUMERIC_SCALARS,\n filterName,\n inputBaseType,\n payloadBaseType,\n updateOpsName,\n} from \"./type-names.ts\";\nimport { maybeParens, pascal, propKey, tsString } from \"./util.ts\";\n\n// ─── Small helpers ────────────────────────────────────────────────\n\nfunction banner(params: { title: string }): string {\n return `// ─── ${params.title} ───`;\n}\n\n/** An `export type Name = { …lines }` alias; empty bodies become Record<string, never>. */\nfunction objectAlias(params: { name: string; lines: readonly string[] }): string {\n const { name, lines } = params;\n if (lines.length === 0) return `export type ${name} = Record<string, never>;`;\n return `export type ${name} = {\\n${lines.join(\"\\n\")}\\n};`;\n}\n\n/** `T | readonly T[]` for single-or-many input positions. */\nfunction orMany(params: { type: string }): string {\n const { type } = params;\n return `${type} | readonly ${maybeParens({ type })}[]`;\n}\n\nfunction payloadFieldType(params: { field: FieldView }): string {\n const { field } = params;\n const base = payloadBaseType({ field });\n if (field.isList) return `${maybeParens({ type: base })}[]`;\n return field.isOptional ? `${base} | null` : base;\n}\n\nfunction relationPayloadType(params: { relation: RelationView }): string {\n const { relation } = params;\n if (relation.isList) return `${relation.target}[]`;\n return relation.isOptional ? `${relation.target} | null` : relation.target;\n}\n\n// ─── Static preamble ──────────────────────────────────────────────\n\nconst PREAMBLE: string = `${banner({ title: \"Shared scalar & helper types\" })}\n\n/** JSON as stored/returned by Json columns (decoded payload shape). */\nexport type JsonValue = string | number | boolean | null | { [key: string]: JsonValue } | JsonValue[];\n\n/** Object form accepted as Json INPUT — readonly, and undefined-valued keys are dropped on serialize. */\nexport type InputJsonObject = { readonly [key: string]: InputJsonValue | null | undefined };\n\n/** Array form accepted as Json INPUT — readonly arrays are welcome (v1 lesson, LEARNINGS bug 7). */\nexport type InputJsonArray = ReadonlyArray<InputJsonValue | null>;\n\n/**\n * JSON as ACCEPTED for Json input positions — deliberately wider than\n * JsonValue: readonly containers and toJSON-bearing values (Date) serialize\n * fine, the runtime stringifies with JSON.stringify (v1 lessons, bugs 7+8).\n */\nexport type InputJsonValue = string | number | boolean | InputJsonObject | InputJsonArray | { toJSON(): unknown };\n\n/** \\`strict\\` (board #20) forces case-SENSITIVE matching where the engine folds (sqlite/mysql); a no-op on postgres. */\nexport type QueryMode = \"default\" | \"insensitive\" | \"strict\";\n\nexport type SortOrder = \"asc\" | \"desc\";\n\nexport type SortOrderWithNulls = SortOrder | { readonly sort: SortOrder; readonly nulls?: \"first\" | \"last\" };\n\n/** How relations are loaded: batched WHERE-IN queries, or a single JOIN (pg/pglite). */\nexport type RelationStrategy = \"query\" | \"join\";\n\n/** Result of createMany/updateMany/deleteMany. */\nexport type BatchPayload = { readonly count: number };\n\n/** Keys of an omit object whose value is exactly true — the scalars the result drops. */\ntype OmittedKeys<O> = keyof { [K in keyof O as O[K] extends true ? K : never]: 0 };`;\n\ntype ScalarFilterConfig = {\n readonly prefix: string;\n readonly value: string;\n readonly comparable: boolean;\n readonly text: boolean;\n};\n\nconst SCALAR_FILTER_CONFIGS: readonly ScalarFilterConfig[] = [\n { prefix: \"String\", value: \"string\", comparable: true, text: true },\n { prefix: \"Int\", value: \"number\", comparable: true, text: false },\n { prefix: \"Float\", value: \"number\", comparable: true, text: false },\n { prefix: \"BigInt\", value: \"bigint | number\", comparable: true, text: false },\n { prefix: \"Decimal\", value: \"string | number\", comparable: true, text: false },\n { prefix: \"DateTime\", value: \"Date | string\", comparable: true, text: false },\n { prefix: \"Bool\", value: \"boolean\", comparable: false, text: false },\n { prefix: \"Bytes\", value: \"Uint8Array\", comparable: false, text: false },\n];\n\nfunction scalarFilterAlias(params: { config: ScalarFilterConfig; nullable: boolean }): string {\n const { config, nullable } = params;\n const name = nullable ? `${config.prefix}NullableFilter` : `${config.prefix}Filter`;\n const value = config.value;\n const valueOrNull = nullable ? `${value} | null` : value;\n const array = `readonly ${maybeParens({ type: value })}[]`;\n const lines: string[] = [];\n lines.push(` readonly equals?: ${valueOrNull};`);\n lines.push(` readonly in?: ${array};`);\n lines.push(` readonly notIn?: ${array};`);\n if (config.comparable) {\n lines.push(` readonly lt?: ${value};`);\n lines.push(` readonly lte?: ${value};`);\n lines.push(` readonly gt?: ${value};`);\n lines.push(` readonly gte?: ${value};`);\n }\n if (config.text) {\n lines.push(` readonly contains?: ${value};`);\n lines.push(` readonly startsWith?: ${value};`);\n lines.push(` readonly endsWith?: ${value};`);\n lines.push(` readonly mode?: QueryMode;`);\n }\n lines.push(` readonly not?: ${value} | ${name}${nullable ? \" | null\" : \"\"};`);\n return objectAlias({ name, lines });\n}\n\nfunction scalarListFilterAlias(params: { config: ScalarFilterConfig }): string {\n const { config } = params;\n const value = config.value;\n const array = `readonly ${maybeParens({ type: value })}[]`;\n return objectAlias({\n name: `${config.prefix}ListFilter`,\n lines: [\n ` readonly equals?: ${array} | null;`,\n ` readonly has?: ${value} | null;`,\n ` readonly hasEvery?: ${array};`,\n ` readonly hasSome?: ${array};`,\n ` readonly isEmpty?: boolean;`,\n ],\n });\n}\n\nconst UPDATE_OPS_CONFIGS: ReadonlyArray<{ readonly prefix: string; readonly value: string }> = [\n { prefix: \"Int\", value: \"number\" },\n { prefix: \"Float\", value: \"number\" },\n { prefix: \"BigInt\", value: \"bigint | number\" },\n { prefix: \"Decimal\", value: \"string | number\" },\n];\n\nfunction updateOpsAlias(params: { prefix: string; value: string; nullable: boolean }): string {\n const { prefix, value, nullable } = params;\n const name = nullable ? `Nullable${prefix}FieldUpdateOperationsInput` : `${prefix}FieldUpdateOperationsInput`;\n return objectAlias({\n name,\n lines: [\n ` readonly set?: ${nullable ? `${value} | null` : value};`,\n ` readonly increment?: ${value};`,\n ` readonly decrement?: ${value};`,\n ` readonly multiply?: ${value};`,\n ` readonly divide?: ${value};`,\n ],\n });\n}\n\nfunction filterSection(): string[] {\n const parts: string[] = [banner({ title: \"Scalar filters\" })];\n for (const config of SCALAR_FILTER_CONFIGS) {\n parts.push(scalarFilterAlias({ config, nullable: false }));\n parts.push(scalarFilterAlias({ config, nullable: true }));\n parts.push(scalarListFilterAlias({ config }));\n }\n parts.push(\n objectAlias({\n name: \"JsonFilter\",\n lines: [` readonly equals?: InputJsonValue;`, ` readonly not?: InputJsonValue;`],\n }),\n );\n parts.push(\n objectAlias({\n name: \"JsonNullableFilter\",\n lines: [` readonly equals?: InputJsonValue | null;`, ` readonly not?: InputJsonValue | null;`],\n }),\n );\n parts.push(\n objectAlias({\n name: \"JsonListFilter\",\n lines: [\n ` readonly equals?: readonly InputJsonValue[] | null;`,\n ` readonly has?: InputJsonValue | null;`,\n ` readonly hasEvery?: readonly InputJsonValue[];`,\n ` readonly hasSome?: readonly InputJsonValue[];`,\n ` readonly isEmpty?: boolean;`,\n ],\n }),\n );\n parts.push(banner({ title: \"Atomic update operations\" }));\n for (const config of UPDATE_OPS_CONFIGS) {\n parts.push(updateOpsAlias({ ...config, nullable: false }));\n parts.push(updateOpsAlias({ ...config, nullable: true }));\n }\n return parts;\n}\n\n// ─── Enums ────────────────────────────────────────────────────────\n\nfunction emitEnum(params: { declared: EnumView }): string {\n const { declared } = params;\n const name = declared.name;\n const parts: string[] = [banner({ title: `Enum ${name}` })];\n\n const valueLines = declared.values.map(\n (value) => ` readonly ${propKey({ name: value })}: ${tsString({ value })};`,\n );\n parts.push(`export declare const ${name}: {\\n${valueLines.join(\"\\n\")}\\n};`);\n parts.push(`export type ${name} = ${declared.values.map((value) => tsString({ value })).join(\" | \")};`);\n\n const array = `readonly ${name}[]`;\n parts.push(\n objectAlias({\n name: `${name}Filter`,\n lines: [\n ` readonly equals?: ${name};`,\n ` readonly in?: ${array};`,\n ` readonly notIn?: ${array};`,\n ` readonly not?: ${name} | ${name}Filter;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${name}NullableFilter`,\n lines: [\n ` readonly equals?: ${name} | null;`,\n ` readonly in?: ${array};`,\n ` readonly notIn?: ${array};`,\n ` readonly not?: ${name} | ${name}NullableFilter | null;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${name}ListFilter`,\n lines: [\n ` readonly equals?: ${array} | null;`,\n ` readonly has?: ${name} | null;`,\n ` readonly hasEvery?: ${array};`,\n ` readonly hasSome?: ${array};`,\n ` readonly isEmpty?: boolean;`,\n ],\n }),\n );\n return parts.join(\"\\n\\n\");\n}\n\n// ─── Create / update input bodies ─────────────────────────────────\n\nfunction createFieldProp(params: { field: FieldView }): string {\n const { field } = params;\n const optional = field.isOptional || field.hasDefault || field.isUpdatedAt || field.isList;\n const base = inputBaseType({ field });\n const value = field.isList\n ? `readonly ${maybeParens({ type: base })}[]`\n : field.isOptional\n ? `${base} | null`\n : base;\n return ` readonly ${propKey({ name: field.name })}${optional ? \"?\" : \"\"}: ${value};`;\n}\n\nfunction updateFieldProp(params: { field: FieldView }): string {\n const { field } = params;\n const base = inputBaseType({ field });\n const key = propKey({ name: field.name });\n if (field.isList) {\n const element = maybeParens({ type: base });\n return ` readonly ${key}?: readonly ${element}[] | { readonly set?: readonly ${element}[]; readonly push?: ${base} | readonly ${element}[] };`;\n }\n const ops = updateOpsName({ field });\n const withNull = field.isOptional ? `${base} | null` : base;\n if (ops !== null) return ` readonly ${key}?: ${withNull} | ${ops};`;\n return ` readonly ${key}?: ${withNull} | { readonly set: ${withNull} };`;\n}\n\nfunction nestedRefName(params: { relation: RelationView; verb: \"Create\" | \"Update\" }): string {\n const { relation, verb } = params;\n const suffix = relation.inverseName === null ? \"\" : `Without${pascal({ name: relation.inverseName })}`;\n return `${relation.target}${verb}Nested${relation.isList ? \"Many\" : \"One\"}${suffix}Input`;\n}\n\n/** Checked input: relation fields present, ALL FK scalar columns excluded. */\nfunction checkedCreateLines(params: { model: ModelView; omitRelation?: string }): string[] {\n const { model, omitRelation } = params;\n const lines: string[] = [];\n for (const field of model.fields) {\n if (model.fkFieldNames.has(field.name)) continue;\n lines.push(createFieldProp({ field }));\n }\n for (const relation of model.relations) {\n if (relation.name === omitRelation) continue;\n const required = !relation.isList && !relation.isOptional;\n lines.push(\n ` readonly ${propKey({ name: relation.name })}${required ? \"\" : \"?\"}: ${nestedRefName({ relation, verb: \"Create\" })};`,\n );\n }\n return lines;\n}\n\n/** Unchecked input: scalar columns only (FKs included), no relation fields. */\nfunction uncheckedCreateLines(params: { model: ModelView; omitRelation?: string }): string[] {\n const { model, omitRelation } = params;\n const omitted = new Set(\n omitRelation === undefined\n ? []\n : (model.relations.find((relation) => relation.name === omitRelation)?.fkFields ?? []),\n );\n return model.fields.filter((field) => !omitted.has(field.name)).map((field) => createFieldProp({ field }));\n}\n\nfunction checkedUpdateLines(params: { model: ModelView; omitRelation?: string }): string[] {\n const { model, omitRelation } = params;\n const lines: string[] = [];\n for (const field of model.fields) {\n if (model.fkFieldNames.has(field.name)) continue;\n lines.push(updateFieldProp({ field }));\n }\n for (const relation of model.relations) {\n if (relation.name === omitRelation) continue;\n lines.push(\n ` readonly ${propKey({ name: relation.name })}?: ${nestedRefName({ relation, verb: \"Update\" })};`,\n );\n }\n return lines;\n}\n\nfunction uncheckedUpdateLines(params: { model: ModelView; omitRelation?: string }): string[] {\n const { model, omitRelation } = params;\n const omitted = new Set(\n omitRelation === undefined\n ? []\n : (model.relations.find((relation) => relation.name === omitRelation)?.fkFields ?? []),\n );\n return model.fields.filter((field) => !omitted.has(field.name)).map((field) => updateFieldProp({ field }));\n}\n\n// ─── Nested input registry ────────────────────────────────────────\n\n/**\n * Nested write wrappers, deduplicated by alias name. A context is one relation\n * seen from its parent: nested inputs for the TARGET model, \"without\" the\n * inverse field pointing back at the parent.\n */\ntype NestedRegistry = Map<string, string>;\n\nfunction register(params: { registry: NestedRegistry; name: string; text: string }): void {\n const { registry, name, text } = params;\n const existing = registry.get(name);\n if (existing !== undefined) {\n if (existing !== text) {\n throw new VibeError({\n code: \"VIBE_INTERNAL\",\n message: `internal: nested input type \"${name}\" generated with two different bodies`,\n meta: { name },\n });\n }\n return;\n }\n registry.set(name, text);\n}\n\nfunction registerNestedContext(params: {\n registry: NestedRegistry;\n view: SchemaView;\n relation: RelationView;\n}): void {\n const { registry, view, relation } = params;\n const target = view.modelByName.get(relation.target);\n if (target === undefined) return; // validation would have thrown already\n const t = target.name;\n const inverse = relation.inverseName;\n const suffix = inverse === null ? \"\" : `Without${pascal({ name: inverse })}`;\n const many = relation.isList;\n const m2m = relation.type === \"manyToMany\";\n\n let createUnion: string;\n let updateUnion: string;\n if (inverse === null) {\n createUnion = `${t}CreateInput | ${t}UncheckedCreateInput`;\n updateUnion = `${t}UpdateInput | ${t}UncheckedUpdateInput`;\n } else {\n createUnion = `${t}Create${suffix}Input | ${t}UncheckedCreate${suffix}Input`;\n updateUnion = `${t}Update${suffix}Input | ${t}UncheckedUpdate${suffix}Input`;\n register({\n registry,\n name: `${t}Create${suffix}Input`,\n text: objectAlias({\n name: `${t}Create${suffix}Input`,\n lines: checkedCreateLines({ model: target, omitRelation: inverse }),\n }),\n });\n register({\n registry,\n name: `${t}UncheckedCreate${suffix}Input`,\n text: objectAlias({\n name: `${t}UncheckedCreate${suffix}Input`,\n lines: uncheckedCreateLines({ model: target, omitRelation: inverse }),\n }),\n });\n register({\n registry,\n name: `${t}Update${suffix}Input`,\n text: objectAlias({\n name: `${t}Update${suffix}Input`,\n lines: checkedUpdateLines({ model: target, omitRelation: inverse }),\n }),\n });\n register({\n registry,\n name: `${t}UncheckedUpdate${suffix}Input`,\n text: objectAlias({\n name: `${t}UncheckedUpdate${suffix}Input`,\n lines: uncheckedUpdateLines({ model: target, omitRelation: inverse }),\n }),\n });\n }\n\n const connectOrCreateName = `${t}ConnectOrCreate${suffix}Input`;\n register({\n registry,\n name: connectOrCreateName,\n text: objectAlias({\n name: connectOrCreateName,\n lines: [` readonly where: ${t}WhereUniqueInput;`, ` readonly create: ${createUnion};`],\n }),\n });\n\n const createManyData =\n inverse === null ? `readonly ${t}CreateManyInput[]` : `readonly ${t}UncheckedCreate${suffix}Input[]`;\n\n if (many) {\n register({\n registry,\n name: `${t}CreateNestedMany${suffix}Input`,\n text: objectAlias({\n name: `${t}CreateNestedMany${suffix}Input`,\n lines: [\n ` readonly create?: ${orMany({ type: createUnion })};`,\n ` readonly connect?: ${orMany({ type: `${t}WhereUniqueInput` })};`,\n ` readonly connectOrCreate?: ${orMany({ type: connectOrCreateName })};`,\n ...(m2m\n ? []\n : [` readonly createMany?: { readonly data: ${createManyData}; readonly skipDuplicates?: boolean };`]),\n ],\n }),\n });\n\n const updateWithWhere = `${t}UpdateWithWhereUnique${suffix}Input`;\n register({\n registry,\n name: updateWithWhere,\n text: objectAlias({\n name: updateWithWhere,\n lines: [` readonly where: ${t}WhereUniqueInput;`, ` readonly data: ${updateUnion};`],\n }),\n });\n const updateManyWithWhere = `${t}UpdateManyWithWhere${suffix}Input`;\n register({\n registry,\n name: updateManyWithWhere,\n text: objectAlias({\n name: updateManyWithWhere,\n lines: [` readonly where: ${t}WhereInput;`, ` readonly data: ${t}UpdateManyInput;`],\n }),\n });\n const upsertWithWhere = `${t}UpsertWithWhereUnique${suffix}Input`;\n register({\n registry,\n name: upsertWithWhere,\n text: objectAlias({\n name: upsertWithWhere,\n lines: [\n ` readonly where: ${t}WhereUniqueInput;`,\n ` readonly create: ${createUnion};`,\n ` readonly update: ${updateUnion};`,\n ],\n }),\n });\n register({\n registry,\n name: `${t}UpdateNestedMany${suffix}Input`,\n text: objectAlias({\n name: `${t}UpdateNestedMany${suffix}Input`,\n lines: [\n ` readonly create?: ${orMany({ type: createUnion })};`,\n ` readonly connect?: ${orMany({ type: `${t}WhereUniqueInput` })};`,\n ` readonly connectOrCreate?: ${orMany({ type: connectOrCreateName })};`,\n ...(m2m\n ? []\n : [` readonly createMany?: { readonly data: ${createManyData}; readonly skipDuplicates?: boolean };`]),\n ` readonly set?: ${orMany({ type: `${t}WhereUniqueInput` })};`,\n ` readonly disconnect?: ${orMany({ type: `${t}WhereUniqueInput` })};`,\n ` readonly delete?: ${orMany({ type: `${t}WhereUniqueInput` })};`,\n ` readonly update?: ${orMany({ type: updateWithWhere })};`,\n ` readonly updateMany?: ${orMany({ type: updateManyWithWhere })};`,\n ` readonly deleteMany?: ${orMany({ type: `${t}WhereInput` })};`,\n ` readonly upsert?: ${orMany({ type: upsertWithWhere })};`,\n ],\n }),\n });\n } else {\n // The rare fallback (no resolvable inverse) always offers disconnect/delete;\n // the precise Without-variant gates them on the forward relation's optionality.\n const allowDetach = inverse === null || relation.isOptional;\n register({\n registry,\n name: `${t}CreateNestedOne${suffix}Input`,\n text: objectAlias({\n name: `${t}CreateNestedOne${suffix}Input`,\n lines: [\n ` readonly create?: ${createUnion};`,\n ` readonly connect?: ${t}WhereUniqueInput;`,\n ` readonly connectOrCreate?: ${connectOrCreateName};`,\n ],\n }),\n });\n register({\n registry,\n name: `${t}UpdateNestedOne${suffix}Input`,\n text: objectAlias({\n name: `${t}UpdateNestedOne${suffix}Input`,\n lines: [\n ` readonly create?: ${createUnion};`,\n ` readonly connect?: ${t}WhereUniqueInput;`,\n ` readonly connectOrCreate?: ${connectOrCreateName};`,\n ` readonly update?: ${updateUnion};`,\n ` readonly upsert?: { readonly create: ${createUnion}; readonly update: ${updateUnion} };`,\n ...(allowDetach ? [` readonly disconnect?: boolean;`, ` readonly delete?: boolean;`] : []),\n ],\n }),\n });\n }\n}\n\n// ─── Per-model emission ───────────────────────────────────────────\n\nconst AGGREGATE_OPS_UNION: string = `\"_count\" | \"_avg\" | \"_sum\" | \"_min\" | \"_max\"`;\n\nfunction emitModel(params: {\n model: ModelView;\n view: SchemaView;\n registry: NestedRegistry;\n /** Extension delegate-body lines (already indented) — baked surfaces (D9). */\n extensionLines?: readonly string[];\n /** Computed-field manifest entries for THIS model (config-declared, pre-resolved types). */\n computed?: readonly ComputedManifestEntry[];\n}): string {\n const { model, view, registry } = params;\n const computedEntries = params.computed ?? [];\n const n = model.name;\n const hasRelations = model.relations.length > 0;\n const parts: string[] = [banner({ title: `Model ${n}` })];\n\n for (const relation of model.relations) {\n registerNestedContext({ registry, view, relation });\n }\n\n // Payload (scalars + computed fields — relations are opt-in via include/select).\n parts.push(\n `export type ${n} = {\\n${[\n ...model.fields.map((field) => ` ${propKey({ name: field.name })}: ${payloadFieldType({ field })};`),\n ...computedEntries.map((entry) => ` ${propKey({ name: entry.field })}: ${entry.type};`),\n ].join(\"\\n\")}\\n};`,\n );\n\n parts.push(\n `export type ${n}ScalarFieldEnum = ${model.fields.map((field) => tsString({ value: field.name })).join(\" | \")};`,\n );\n\n // Computed fields are selectable/omittable but never SQL-addressable, so the\n // scalar enum (distinct, groupBy.by) stays scalar-only and the payload\n // narrowing maps over this wider union instead.\n if (computedEntries.length > 0) {\n parts.push(\n `export type ${n}SelectableFieldEnum = ${n}ScalarFieldEnum | ${computedEntries\n .map((entry) => tsString({ value: entry.field }))\n .join(\" | \")};`,\n );\n }\n const selectableEnum = computedEntries.length > 0 ? `${n}SelectableFieldEnum` : `${n}ScalarFieldEnum`;\n\n if (hasRelations) {\n parts.push(\n `export type ${n}Relations = {\\n${model.relations\n .map((relation) => ` ${propKey({ name: relation.name })}: ${relationPayloadType({ relation })};`)\n .join(\"\\n\")}\\n};`,\n );\n }\n\n // Select / Include / omit / nested-args. `_count` exists only where the\n // runtime can count something: models with at least one list relation.\n const listRelations = model.relations.filter((relation) => relation.isList);\n const hasCounts = listRelations.length > 0;\n const countLine = ` readonly _count?: boolean | { readonly select: ${n}CountSelect };`;\n const relationSelectValue = (relation: RelationView): string =>\n `boolean | ${relation.target}${relation.isList ? \"FindManyArgs\" : \"Args\"}`;\n if (hasCounts) {\n parts.push(\n objectAlias({\n name: `${n}CountSelect`,\n lines: listRelations.map((relation) => ` readonly ${propKey({ name: relation.name })}?: boolean;`),\n }),\n );\n }\n parts.push(\n objectAlias({\n name: `${n}Select`,\n lines: [\n ...model.fields.map((field) => ` readonly ${propKey({ name: field.name })}?: boolean;`),\n ...computedEntries.map((entry) => ` readonly ${propKey({ name: entry.field })}?: boolean;`),\n ...model.relations.map(\n (relation) => ` readonly ${propKey({ name: relation.name })}?: ${relationSelectValue(relation)};`,\n ),\n ...(hasCounts ? [countLine] : []),\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}Include`,\n lines: [\n ...model.relations.map(\n (relation) => ` readonly ${propKey({ name: relation.name })}?: ${relationSelectValue(relation)};`,\n ),\n ...(hasCounts ? [countLine] : []),\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}OmitInput`,\n lines: [\n ...model.fields.map((field) => ` readonly ${propKey({ name: field.name })}?: boolean;`),\n ...computedEntries.map((entry) => ` readonly ${propKey({ name: entry.field })}?: boolean;`),\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}Args`,\n lines: [\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ` readonly relationStrategy?: RelationStrategy;`,\n ],\n }),\n );\n\n // Relation filters (referenced by OTHER models' WhereInput).\n parts.push(\n objectAlias({\n name: `${n}ListRelationFilter`,\n lines: [\n ` readonly some?: ${n}WhereInput;`,\n ` readonly every?: ${n}WhereInput;`,\n ` readonly none?: ${n}WhereInput;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}RelationFilter`,\n lines: [` readonly is?: ${n}WhereInput | null;`, ` readonly isNot?: ${n}WhereInput | null;`],\n }),\n );\n\n // Where.\n const whereLines: string[] = [\n ` readonly AND?: ${orMany({ type: `${n}WhereInput` })};`,\n ` readonly OR?: readonly ${n}WhereInput[];`,\n ` readonly NOT?: ${orMany({ type: `${n}WhereInput` })};`,\n ];\n for (const field of model.fields) {\n const key = propKey({ name: field.name });\n if (field.isList || field.scalar === \"Json\") {\n whereLines.push(` readonly ${key}?: ${filterName({ field })};`);\n continue;\n }\n const nullable = field.isOptional ? \" | null\" : \"\";\n whereLines.push(` readonly ${key}?: ${inputBaseType({ field })} | ${filterName({ field })}${nullable};`);\n }\n for (const relation of model.relations) {\n const key = propKey({ name: relation.name });\n if (relation.isList) {\n whereLines.push(` readonly ${key}?: ${relation.target}ListRelationFilter;`);\n } else {\n whereLines.push(\n ` readonly ${key}?: ${relation.target}RelationFilter | ${relation.target}WhereInput${relation.isOptional ? \" | null\" : \"\"};`,\n );\n }\n }\n parts.push(objectAlias({ name: `${n}WhereInput`, lines: whereLines }));\n\n // WhereUnique — one union member per way to address a single row.\n if (model.uniques.length === 0) {\n parts.push(`export type ${n}WhereUniqueInput = never;`);\n } else {\n const members = model.uniques.map((member) => {\n const first = member.fields[0];\n if (member.fields.length === 1 && first !== undefined) {\n return `{ readonly ${propKey({ name: first.name })}: ${inputBaseType({ field: first })} }`;\n }\n const inner = member.fields\n .map((field) => `readonly ${propKey({ name: field.name })}: ${inputBaseType({ field })}`)\n .join(\"; \");\n return `{ readonly ${propKey({ name: member.key })}: { ${inner} } }`;\n });\n parts.push(`export type ${n}WhereUniqueInput =\\n | ${members.join(\"\\n | \")};`);\n }\n\n // OrderBy (scalars; nullable fields take the nulls-position form).\n parts.push(\n objectAlias({\n name: `${n}OrderByInput`,\n lines: model.fields.map(\n (field) =>\n ` readonly ${propKey({ name: field.name })}?: ${field.isOptional ? \"SortOrderWithNulls\" : \"SortOrder\"};`,\n ),\n }),\n );\n\n // Create / update inputs.\n parts.push(objectAlias({ name: `${n}CreateInput`, lines: checkedCreateLines({ model }) }));\n parts.push(objectAlias({ name: `${n}UncheckedCreateInput`, lines: uncheckedCreateLines({ model }) }));\n parts.push(`export type ${n}CreateManyInput = ${n}UncheckedCreateInput;`);\n parts.push(objectAlias({ name: `${n}UpdateInput`, lines: checkedUpdateLines({ model }) }));\n parts.push(objectAlias({ name: `${n}UncheckedUpdateInput`, lines: uncheckedUpdateLines({ model }) }));\n parts.push(`export type ${n}UpdateManyInput = ${n}UncheckedUpdateInput;`);\n\n // Aggregate inputs.\n const numericFields = model.fields.filter(\n (field) => !field.isList && field.scalar !== null && NUMERIC_SCALARS.has(field.scalar),\n );\n const minmaxFields = model.fields.filter(\n (field) => !field.isList && field.scalar !== null && MINMAX_SCALARS.has(field.scalar),\n );\n parts.push(\n objectAlias({\n name: `${n}CountAggregateInput`,\n lines: [\n ...model.fields.map((field) => ` readonly ${propKey({ name: field.name })}?: true;`),\n ` readonly _all?: true;`,\n ],\n }),\n );\n const aggregateOpProps: string[] = [` readonly _count?: true | ${n}CountAggregateInput;`];\n if (numericFields.length > 0) {\n parts.push(\n objectAlias({\n name: `${n}AvgAggregateInput`,\n lines: numericFields.map((field) => ` readonly ${propKey({ name: field.name })}?: true;`),\n }),\n );\n parts.push(`export type ${n}SumAggregateInput = ${n}AvgAggregateInput;`);\n aggregateOpProps.push(` readonly _avg?: ${n}AvgAggregateInput;`);\n aggregateOpProps.push(` readonly _sum?: ${n}SumAggregateInput;`);\n }\n if (minmaxFields.length > 0) {\n parts.push(\n objectAlias({\n name: `${n}MinAggregateInput`,\n lines: minmaxFields.map((field) => ` readonly ${propKey({ name: field.name })}?: true;`),\n }),\n );\n parts.push(`export type ${n}MaxAggregateInput = ${n}MinAggregateInput;`);\n aggregateOpProps.push(` readonly _min?: ${n}MinAggregateInput;`);\n aggregateOpProps.push(` readonly _max?: ${n}MaxAggregateInput;`);\n }\n\n // Method args.\n parts.push(\n objectAlias({\n name: `${n}FindManyArgs`,\n lines: [\n ` readonly where?: ${n}WhereInput;`,\n ` readonly orderBy?: ${orMany({ type: `${n}OrderByInput` })};`,\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ` readonly cursor?: ${n}WhereUniqueInput;`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ` readonly distinct?: ${orMany({ type: `${n}ScalarFieldEnum` })};`,\n ` readonly relationStrategy?: RelationStrategy;`,\n ],\n }),\n );\n parts.push(`export type ${n}FindFirstArgs = ${n}FindManyArgs;`);\n parts.push(\n objectAlias({\n name: `${n}FindUniqueArgs`,\n lines: [\n ` readonly where: ${n}WhereUniqueInput;`,\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ` readonly relationStrategy?: RelationStrategy;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}CreateArgs`,\n lines: [\n ` readonly data: ${n}CreateInput | ${n}UncheckedCreateInput;`,\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}CreateManyArgs`,\n lines: [\n ` readonly data: ${orMany({ type: `${n}CreateManyInput` })};`,\n ` readonly skipDuplicates?: boolean;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}CreateManyAndReturnArgs`,\n lines: [\n ` readonly data: ${orMany({ type: `${n}CreateManyInput` })};`,\n ` readonly skipDuplicates?: boolean;`,\n ` readonly select?: ${n}Select;`,\n ` readonly omit?: ${n}OmitInput;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}UpdateArgs`,\n lines: [\n ` readonly where: ${n}WhereUniqueInput;`,\n ` readonly data: ${n}UpdateInput | ${n}UncheckedUpdateInput;`,\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}UpdateManyArgs`,\n lines: [` readonly where?: ${n}WhereInput;`, ` readonly data: ${n}UpdateManyInput;`],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}UpsertArgs`,\n lines: [\n ` readonly where: ${n}WhereUniqueInput;`,\n ` readonly create: ${n}CreateInput | ${n}UncheckedCreateInput;`,\n ` readonly update: ${n}UpdateInput | ${n}UncheckedUpdateInput;`,\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}DeleteArgs`,\n lines: [\n ` readonly where: ${n}WhereUniqueInput;`,\n ` readonly select?: ${n}Select;`,\n ` readonly include?: ${n}Include;`,\n ` readonly omit?: ${n}OmitInput;`,\n ],\n }),\n );\n parts.push(objectAlias({ name: `${n}DeleteManyArgs`, lines: [` readonly where?: ${n}WhereInput;`] }));\n parts.push(\n objectAlias({\n name: `${n}CountArgs`,\n lines: [\n ` readonly where?: ${n}WhereInput;`,\n ` readonly orderBy?: ${orMany({ type: `${n}OrderByInput` })};`,\n ` readonly cursor?: ${n}WhereUniqueInput;`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}AggregateArgs`,\n lines: [\n ` readonly where?: ${n}WhereInput;`,\n ` readonly orderBy?: ${orMany({ type: `${n}OrderByInput` })};`,\n ` readonly cursor?: ${n}WhereUniqueInput;`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ...aggregateOpProps,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}GroupByArgs`,\n lines: [\n ` readonly by: readonly ${n}ScalarFieldEnum[];`,\n ` readonly where?: ${n}WhereInput;`,\n ` readonly orderBy?: ${orMany({ type: `${n}OrderByInput` })};`,\n ` readonly having?: ${n}WhereInput;`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ...aggregateOpProps,\n ],\n }),\n );\n\n // Result narrowing: one shallow conditional per key + mapped lookups.\n // `omit`/`include`/`_count` each resolve through their own single-conditional\n // helper and combine by intersection (`unknown` is the identity), so no\n // branch nests deeper than one conditional (constitution rule 2).\n const falseFilter = (source: string): string => `${source}[K] extends false | undefined ? never : K`;\n parts.push(\n `type ${n}OmitBase<A> = A extends { readonly omit: infer O extends object } ? Omit<${n}, OmittedKeys<O>> : ${n};`,\n );\n if (hasCounts) {\n const listUnion = listRelations.map((relation) => tsString({ value: relation.name })).join(\" | \");\n const allCounts = listRelations\n .map((relation) => `${propKey({ name: relation.name })}: number`)\n .join(\"; \");\n parts.push(\n `type ${n}CountResult<C> = C extends { readonly select: infer CS extends object }\\n` +\n ` ? { [K in keyof CS & (${listUnion}) as ${falseFilter(\"CS\")}]: number }\\n` +\n ` : { ${allCounts} };`,\n );\n parts.push(\n `type ${n}CountPayload<S> = S extends { readonly _count: infer C extends true | object } ? { _count: ${n}CountResult<C> } : unknown;`,\n );\n }\n if (hasRelations) {\n const relationCases = model.relations\n .map((relation) => {\n const nested = `${relation.target}GetPayload<A>`;\n const guard = `A extends { readonly select: unknown } | { readonly include: unknown } | { readonly omit: unknown }`;\n let expression: string;\n if (relation.isList) {\n expression = `${guard} ? ${nested}[] : ${relation.target}[]`;\n } else if (relation.isOptional) {\n expression = `(${guard} ? ${nested} : ${relation.target}) | null`;\n } else {\n expression = `${guard} ? ${nested} : ${relation.target}`;\n }\n return ` ${propKey({ name: relation.name })}: ${expression};`;\n })\n .join(\"\\n\");\n parts.push(`type ${n}RelationPayload<K extends keyof ${n}Relations, A> = {\\n${relationCases}\\n}[K];`);\n parts.push(\n `type ${n}IncludePayload<A> = A extends { readonly include: infer I extends object }\\n` +\n ` ? { [K in keyof I & keyof ${n}Relations as ${falseFilter(\"I\")}]: ${n}RelationPayload<K, I[K]> }${hasCounts ? ` & ${n}CountPayload<I>` : \"\"}\\n` +\n ` : unknown;`,\n );\n parts.push(\n `export type ${n}GetPayload<A> = A extends { readonly select: infer S extends object }\\n` +\n ` ? { [K in keyof S & ${selectableEnum} as ${falseFilter(\"S\")}]: ${n}[K & keyof ${n}] } &\\n` +\n ` { [K in keyof S & keyof ${n}Relations as ${falseFilter(\"S\")}]: ${n}RelationPayload<K, S[K]> }${hasCounts ? ` &\\n ${n}CountPayload<S>` : \"\"}\\n` +\n ` : ${n}OmitBase<A> & ${n}IncludePayload<A>;`,\n );\n } else {\n parts.push(\n `export type ${n}GetPayload<A> = A extends { readonly select: infer S extends object }\\n` +\n ` ? { [K in keyof S & ${selectableEnum} as ${falseFilter(\"S\")}]: ${n}[K & keyof ${n}] }\\n` +\n ` : ${n}OmitBase<A>;`,\n );\n }\n\n parts.push(\n `export type ${n}AggregateResult<A> = {\\n` +\n ` [K in keyof A & (${AGGREGATE_OPS_UNION})]:\\n` +\n ` K extends \"_count\" ? (A[K] extends true ? number : { [F in keyof A[K]]: number })\\n` +\n ` : K extends \"_avg\" ? { [F in keyof A[K]]: number | null }\\n` +\n ` : { [F in keyof A[K] & keyof ${n}]: ${n}[F & keyof ${n}] | null };\\n` +\n `};`,\n );\n parts.push(\n `export type ${n}GroupByResult<A extends ${n}GroupByArgs> =\\n` +\n ` { [K in A[\"by\"][number]]: ${n}[K & keyof ${n}] } & ${n}AggregateResult<A>;`,\n );\n\n // Delegate. A view carries the read half only: `migrate` never creates a\n // table for it, so a typed write would be a promise the system cannot keep.\n const readMethods: string[] = [\n ` findMany<A extends ${n}FindManyArgs = ${n}FindManyArgs>(args?: A): Promise<${n}GetPayload<A>[]>;`,\n ` findFirst<A extends ${n}FindFirstArgs = ${n}FindFirstArgs>(args?: A): Promise<${n}GetPayload<A> | null>;`,\n ` findFirstOrThrow<A extends ${n}FindFirstArgs = ${n}FindFirstArgs>(args?: A): Promise<${n}GetPayload<A>>;`,\n ` findUnique<A extends ${n}FindUniqueArgs>(args: A): Promise<${n}GetPayload<A> | null>;`,\n ` findUniqueOrThrow<A extends ${n}FindUniqueArgs>(args: A): Promise<${n}GetPayload<A>>;`,\n ];\n const writeMethods: string[] = [\n ` create<A extends ${n}CreateArgs>(args: A): Promise<${n}GetPayload<A>>;`,\n ` createMany(args: ${n}CreateManyArgs): Promise<BatchPayload>;`,\n ` createManyAndReturn<A extends ${n}CreateManyAndReturnArgs>(args: A): Promise<${n}GetPayload<A>[]>;`,\n ` update<A extends ${n}UpdateArgs>(args: A): Promise<${n}GetPayload<A>>;`,\n ` updateMany(args: ${n}UpdateManyArgs): Promise<BatchPayload>;`,\n ` upsert<A extends ${n}UpsertArgs>(args: A): Promise<${n}GetPayload<A>>;`,\n ` delete<A extends ${n}DeleteArgs>(args: A): Promise<${n}GetPayload<A>>;`,\n ` deleteMany(args?: ${n}DeleteManyArgs): Promise<BatchPayload>;`,\n ];\n const aggregateMethods: string[] = [\n ` count(args?: ${n}CountArgs): Promise<number>;`,\n ` aggregate<A extends ${n}AggregateArgs>(args: A): Promise<${n}AggregateResult<A>>;`,\n ` groupBy<A extends ${n}GroupByArgs>(args: A): Promise<${n}GroupByResult<A>[]>;`,\n ];\n const delegateMethods: string[] = model.isView\n ? [...readMethods, ...aggregateMethods]\n : [...readMethods, ...writeMethods, ...aggregateMethods];\n delegateMethods.push(...(params.extensionLines ?? []));\n parts.push(`export type ${n}Delegate = {\\n${delegateMethods.join(\"\\n\")}\\n};`);\n\n return parts.join(\"\\n\\n\");\n}\n\n// ─── Field-masking views ($defineView) ──────────────────────────\n\n/**\n * The typed `$defineView` surface (board #11 — v1 `defineView` parity).\n * Budget shape (rule 2): every helper is one shallow conditional or one mapped\n * lookup; relation masking resolves ONE include level against the definition\n * (the runtime masks recursively — deeper levels are typed as their masked\n * target's scalars, matching v1's depth).\n */\nfunction emitViewTypesForModel(params: { model: ModelView; view: SchemaView }): string {\n const { model, view } = params;\n const n = model.name;\n const hasRelations = model.relations.length > 0;\n const parts: string[] = [];\n\n parts.push(\n objectAlias({\n name: `${n}ViewFields`,\n lines: model.fields.map((field) => ` readonly ${propKey({ name: field.name })}?: true;`),\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}ViewSelect`,\n lines: model.fields.map((field) => ` readonly ${propKey({ name: field.name })}?: boolean;`),\n }),\n );\n parts.push(\n `type ${n}ViewScalars<F> = { [K in keyof F & ${n}ScalarFieldEnum]: ${n}[K & keyof ${n}] };`,\n );\n\n if (hasRelations) {\n parts.push(\n objectAlias({\n name: `${n}ViewInclude`,\n lines: model.relations.map(\n (relation) =>\n ` readonly ${propKey({ name: relation.name })}?: boolean | ${relation.target}ViewNestedArgs;`,\n ),\n }),\n );\n }\n parts.push(\n objectAlias({\n name: `${n}ViewNestedArgs`,\n lines: [\n ` readonly where?: ${n}WhereInput;`,\n ` readonly orderBy?: ${orMany({ type: `${n}OrderByInput` })};`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ` readonly select?: ${n}ViewSelect;`,\n ` readonly reveal?: ${n}ViewSelect;`,\n ...(hasRelations ? [` readonly include?: ${n}ViewInclude;`] : []),\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}ViewFindManyArgs`,\n lines: [\n ` readonly where?: ${n}WhereInput;`,\n ` readonly orderBy?: ${orMany({ type: `${n}OrderByInput` })};`,\n ` readonly select?: ${n}ViewSelect;`,\n ` readonly reveal?: ${n}ViewSelect;`,\n ...(hasRelations ? [` readonly include?: ${n}ViewInclude;`] : []),\n ` readonly cursor?: ${n}WhereUniqueInput;`,\n ` readonly take?: number;`,\n ` readonly skip?: number;`,\n ` readonly distinct?: ${orMany({ type: `${n}ScalarFieldEnum` })};`,\n ` readonly relationStrategy?: RelationStrategy;`,\n ],\n }),\n );\n parts.push(\n objectAlias({\n name: `${n}ViewFindUniqueArgs`,\n lines: [\n ` readonly where: ${n}WhereUniqueInput;`,\n ` readonly select?: ${n}ViewSelect;`,\n ` readonly reveal?: ${n}ViewSelect;`,\n ...(hasRelations ? [` readonly include?: ${n}ViewInclude;`] : []),\n ` readonly relationStrategy?: RelationStrategy;`,\n ],\n }),\n );\n\n // Result narrowing — same one-conditional-per-key discipline as GetPayload.\n const falseFilter = (source: string): string => `${source}[K] extends false | undefined ? never : K`;\n parts.push(\n `type ${n}ViewSelectScalars<F, A> = A extends { readonly select: infer S extends object }\\n` +\n ` ? { [K in keyof S & keyof F & ${n}ScalarFieldEnum as ${falseFilter(\"S\")}]: ${n}[K & keyof ${n}] }\\n` +\n ` : ${n}ViewScalars<F>;`,\n );\n parts.push(\n `type ${n}ViewReveal<A> = A extends { readonly reveal: infer R extends object }\\n` +\n ` ? { [K in keyof R & ${n}ScalarFieldEnum as ${falseFilter(\"R\")}]: ${n}[K & keyof ${n}] }\\n` +\n ` : unknown;`,\n );\n if (hasRelations) {\n const relationCases = model.relations\n .map((relation) => {\n const target = relation.target;\n const targetClientKey = view.modelByName.get(target)?.clientName ?? target;\n const guard = `D extends { readonly ${propKey({ name: targetClientKey })}: infer RF extends object }`;\n const masked = `ViewRow<${target}ViewScalars<RF>>`;\n let expression: string;\n if (relation.isList) {\n expression = `${guard} ? ${masked}[] : ${target}[]`;\n } else if (relation.isOptional) {\n expression = `(${guard} ? ${masked} : ${target}) | null`;\n } else {\n expression = `${guard} ? ${masked} : ${target}`;\n }\n return ` ${propKey({ name: relation.name })}: ${expression};`;\n })\n .join(\"\\n\");\n parts.push(`type ${n}ViewRelationResult<K extends keyof ${n}Relations, D> = {\\n${relationCases}\\n}[K];`);\n parts.push(\n `type ${n}ViewIncludeResult<A, D> = A extends { readonly include: infer I extends object }\\n` +\n ` ? { [K in keyof I & keyof ${n}Relations as ${falseFilter(\"I\")}]: ${n}ViewRelationResult<K, D> }\\n` +\n ` : unknown;`,\n );\n parts.push(\n `export type ${n}ViewResult<F, A, D> = ViewRow<${n}ViewSelectScalars<F, A> & ${n}ViewReveal<A> & ${n}ViewIncludeResult<A, D>>;`,\n );\n } else {\n parts.push(\n `export type ${n}ViewResult<F, A, D> = ViewRow<${n}ViewSelectScalars<F, A> & ${n}ViewReveal<A>>;`,\n );\n }\n\n parts.push(\n `export type ${n}ViewDelegate<F, D extends ViewDefinitionInput = ViewDefinitionInput> = {\\n` +\n ` findMany<A extends ${n}ViewFindManyArgs = ${n}ViewFindManyArgs>(args?: A): Promise<${n}ViewResult<F, A, D>[]>;\\n` +\n ` findFirst<A extends ${n}ViewFindManyArgs = ${n}ViewFindManyArgs>(args?: A): Promise<${n}ViewResult<F, A, D> | null>;\\n` +\n ` findFirstOrThrow<A extends ${n}ViewFindManyArgs = ${n}ViewFindManyArgs>(args?: A): Promise<${n}ViewResult<F, A, D>>;\\n` +\n ` findUnique<A extends ${n}ViewFindUniqueArgs>(args: A): Promise<${n}ViewResult<F, A, D> | null>;\\n` +\n ` findUniqueOrThrow<A extends ${n}ViewFindUniqueArgs>(args: A): Promise<${n}ViewResult<F, A, D>>;\\n` +\n ` count(args?: ${n}CountArgs): Promise<number>;\\n` +\n ` aggregate<A extends ${n}AggregateArgs>(args: A): Promise<${n}AggregateResult<A>>;\\n` +\n ` groupBy<A extends ${n}GroupByArgs>(args: A): Promise<${n}GroupByResult<A>[]>;\\n` +\n `};`,\n );\n\n return parts.join(\"\\n\\n\");\n}\n\nfunction emitViewSection(params: { view: SchemaView }): string[] {\n const { view } = params;\n const parts: string[] = [banner({ title: \"Field-masking views ($defineView)\" })];\n parts.push(\n `/**\\n` +\n ` * A masked row: definition fields are properties, JSON.stringify drops\\n` +\n ` * revealed fields (toJSON), $unsafe() returns everything as a plain object.\\n` +\n ` */\\n` +\n `export type ViewRow<T> = T & {\\n` +\n ` toJSON(): Partial<T>;\\n` +\n ` $unsafe(): Record<string, unknown>;\\n` +\n `};`,\n );\n parts.push(\n objectAlias({\n name: \"ViewDefinitionInput\",\n lines: view.models.map(\n (model) => ` readonly ${propKey({ name: model.clientName })}?: ${model.name}ViewFields;`,\n ),\n }),\n );\n parts.push(\n `type ViewDelegateMap<D extends ViewDefinitionInput> = {\\n${view.models\n .map(\n (model) =>\n ` ${propKey({ name: model.clientName })}: ${model.name}ViewDelegate<NonNullable<D[${tsString({ value: model.clientName })}]>, D>;`,\n )\n .join(\"\\n\")}\\n};`,\n );\n parts.push(\n `/** A read-only scoped client over the definition's models — what $defineView returns. */\\n` +\n `export type ViewClient<D extends ViewDefinitionInput> = {\\n` +\n ` readonly [K in keyof D & keyof ViewDelegateMap<D>]: ViewDelegateMap<D>[K];\\n` +\n `};`,\n );\n for (const model of view.models) {\n parts.push(emitViewTypesForModel({ model, view }));\n }\n return parts;\n}\n\n// ─── Client ───────────────────────────────────────────────────────\n\nfunction emitClient(params: { view: SchemaView; baked: BakedExtensions; hasComputed: boolean }): string {\n const { view, baked, hasComputed } = params;\n const parts: string[] = [banner({ title: \"Client\" })];\n parts.push(\n objectAlias({\n name: \"VibeClientOptions\",\n lines: [\n ` readonly adapter: DatabaseAdapter;`,\n ` readonly onQuery?: (event: QueryEvent) => void;`,\n ` readonly relationStrategy?: RelationStrategy;`,\n ...(baked.empty\n ? []\n : [\n ` /** The live extension instances — verified against the baked manifest. */`,\n ` readonly extensions?: readonly VibeExtension[];`,\n ]),\n ...(hasComputed\n ? [\n ` /** The live computed-field config — verified against the baked manifest (VIBE_STALE_CLIENT). */`,\n ` readonly computed: ComputedConfig;`,\n ]\n : []),\n ],\n }),\n );\n const delegateProps = view.models.map(\n (model) => ` readonly ${propKey({ name: model.clientName })}: ${model.name}Delegate;`,\n );\n const clientExtensionLines = baked.clientDts.length === 0 ? \"\" : `${baked.clientDts.join(\"\\n\")}\\n`;\n parts.push(\n `export type VibeClientInstance = {\\n` +\n `${delegateProps.join(\"\\n\")}\\n` +\n ` readonly $transaction: <T>(fn: (tx: VibeClientInstance) => Promise<T>, options?: TransactionOptions) => Promise<T>;\\n` +\n ` readonly $queryRaw: <T = Record<string, unknown>>(strings: TemplateStringsArray, ...values: unknown[]) => Promise<T[]>;\\n` +\n ` readonly $executeRaw: (strings: TemplateStringsArray, ...values: unknown[]) => Promise<number>;\\n` +\n ` readonly $queryRawUnsafe: <T = Record<string, unknown>>(text: string, ...values: unknown[]) => Promise<T[]>;\\n` +\n ` readonly $executeRawUnsafe: (text: string, ...values: unknown[]) => Promise<number>;\\n` +\n ` readonly $connect: () => Promise<void>;\\n` +\n ` readonly $disconnect: () => Promise<void>;\\n` +\n ` /** Field-masking views (v1 defineView parity): a read-only masked projection of models. */\\n` +\n ` readonly $defineView: <D extends ViewDefinitionInput>(options: { readonly name: string; readonly definition: D }) => ViewClient<D>;\\n` +\n clientExtensionLines +\n `};`,\n );\n parts.push(`/** Build a typed client over a database adapter. */\\nexport declare function VibeClient(options: VibeClientOptions): VibeClientInstance;`);\n parts.push(\n `/** The normalized Schema IR this client was generated from (plain data). */\\nexport declare const schema: SchemaIR;`,\n );\n return parts.join(\"\\n\\n\");\n}\n\n// ─── Entry ────────────────────────────────────────────────────────\n\n/** Emit the full index.d.ts for a resolved schema view. */\nexport function emitDts(params: {\n view: SchemaView;\n baked?: BakedExtensions;\n computed?: readonly ComputedManifestEntry[];\n}): string {\n const { view } = params;\n const baked = params.baked ?? EMPTY_BAKED_EXTENSIONS;\n const computed = params.computed ?? [];\n const hasComputed = computed.length > 0;\n const computedByModel = new Map<string, ComputedManifestEntry[]>();\n for (const entry of computed) {\n const list = computedByModel.get(entry.model) ?? [];\n list.push(entry);\n computedByModel.set(entry.model, list);\n }\n const parts: string[] = [];\n parts.push(\n `// Generated by VibeORM (@vibeorm/generator) — DO NOT EDIT.\\n// Regenerate with \\`vibeorm generate\\` after every schema change.`,\n );\n const schemaTypeImports = [\n \"SchemaIR\",\n ...(baked.empty ? [] : [\"VibeExtension\"]),\n ...(hasComputed ? [\"ComputedConfig\"] : []),\n ].sort();\n const importLines = [\n `import type { DatabaseAdapter, QueryEvent, TransactionOptions } from \"@vibeorm/runtime\";`,\n `import type { ${schemaTypeImports.join(\", \")} } from \"@vibeorm/schema\";`,\n ...baked.dtsImports,\n ];\n parts.push(\n `${importLines.join(\"\\n\")}\\n\\n` +\n `export { VibeError } from \"@vibeorm/schema\";\\nexport type { VibeErrorCode } from \"@vibeorm/schema\";`,\n );\n parts.push(PREAMBLE);\n parts.push(...filterSection());\n for (const declared of view.enums) parts.push(emitEnum({ declared }));\n\n const registry: NestedRegistry = new Map();\n const modelParts: string[] = [];\n for (const model of view.models) {\n const extensionLines = baked.delegateDts.get(model.name);\n const modelComputed = computedByModel.get(model.name);\n modelParts.push(\n emitModel({\n model,\n view,\n registry,\n ...(extensionLines === undefined ? {} : { extensionLines }),\n ...(modelComputed === undefined ? {} : { computed: modelComputed }),\n }),\n );\n }\n parts.push(...modelParts);\n\n if (registry.size > 0) {\n parts.push(banner({ title: \"Nested write inputs\" }));\n for (const name of [...registry.keys()].sort()) {\n parts.push(registry.get(name) as string);\n }\n }\n\n if (baked.moduleDts.length > 0) {\n parts.push(banner({ title: \"Extensions\" }));\n parts.push(...baked.moduleDts);\n }\n\n parts.push(...emitViewSection({ view }));\n\n parts.push(emitClient({ view, baked, hasComputed }));\n return `${parts.join(\"\\n\\n\")}\\n`;\n}\n",
7
+ "/**\n * Generate-time extension baking (plan D9).\n *\n * Each configured extension's client plane contributes runtime glue (JS\n * expressions over its own module's exports) and d.ts text per opted-in model\n * / per client. This module collects those contributions once, validates the\n * one-identifier rule against the exported reserved-name lists, and hands the\n * emitters plain string blocks — the emitted types stay fully pre-resolved\n * (no inference), keeping the tsserver budget flat.\n */\n\nimport {\n VibeError,\n buildExtensionRegistry,\n extensionDeclarations,\n extensionManifestEntry,\n providerToDialect,\n} from \"@vibeorm/schema\";\nimport type {\n ExtensionClientContribution,\n ExtensionImportSpec,\n ExtensionManifestEntry,\n SchemaIR,\n VibeExtension,\n} from \"@vibeorm/schema\";\n\n// ─── Result ───────────────────────────────────────────────────────\n\n/** Everything the js/d.ts emitters need, pre-stringified. */\nexport type BakedExtensions = {\n /** `import { x } from \"…\";` lines for index.js. */\n readonly jsImports: readonly string[];\n /** JS object-literal expressions — one ClientExtensionMount each. */\n readonly mounts: readonly string[];\n /** Manifest entries (name-sorted) for the staleness gate. */\n readonly manifest: readonly ExtensionManifestEntry[];\n /** `import type { x } from \"…\";` lines for index.d.ts. */\n readonly dtsImports: readonly string[];\n /** Model name → delegate-body lines (already 2-space indented). */\n readonly delegateDts: ReadonlyMap<string, readonly string[]>;\n /** Module-scope type declaration blocks. */\n readonly moduleDts: readonly string[];\n /** VibeClientInstance-body lines for root `$name` namespaces. */\n readonly clientDts: readonly string[];\n /** True when nothing was configured — emitters keep their baseline output. */\n readonly empty: boolean;\n};\n\nexport const EMPTY_BAKED_EXTENSIONS: BakedExtensions = {\n jsImports: [],\n mounts: [],\n manifest: [],\n dtsImports: [],\n delegateDts: new Map(),\n moduleDts: [],\n clientDts: [],\n empty: true,\n};\n\n// ─── Import collection ────────────────────────────────────────────\n\nclass ImportCollector {\n private readonly byModule = new Map<string, Set<string>>();\n\n add(specs: readonly ExtensionImportSpec[] | undefined): void {\n for (const spec of specs ?? []) {\n const names = this.byModule.get(spec.from) ?? new Set<string>();\n for (const name of spec.names) names.add(name);\n this.byModule.set(spec.from, names);\n }\n }\n\n lines(params: { typeOnly: boolean }): string[] {\n return [...this.byModule.entries()]\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(\n ([from, names]) =>\n `import ${params.typeOnly ? \"type \" : \"\"}{ ${[...names].sort().join(\", \")} } from ${JSON.stringify(from)};`,\n );\n }\n}\n\n// ─── Baking ───────────────────────────────────────────────────────\n\nfunction indent(lines: readonly string[]): string[] {\n return lines.map((line) => (line.length === 0 ? line : ` ${line}`));\n}\n\n/**\n * Collect every configured extension's baked surface for this schema.\n *\n * @throws VibeError VIBE_CONFIG on duplicate names/claims (registry) and on\n * contributions that break the one-identifier rule (D9).\n */\nexport function bakeExtensions(params: {\n schema: SchemaIR;\n extensions: readonly VibeExtension[];\n}): BakedExtensions {\n const { schema } = params;\n if (params.extensions.length === 0) return EMPTY_BAKED_EXTENSIONS;\n\n // Validates duplicate names and cross-extension attribute claims.\n buildExtensionRegistry({ extensions: params.extensions });\n\n const dialect = providerToDialect({ provider: schema.datasource.provider });\n const provider = schema.datasource.provider;\n const sorted = [...params.extensions].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n const jsImports = new ImportCollector();\n const dtsImports = new ImportCollector();\n const mounts: string[] = [];\n const delegateDts = new Map<string, string[]>();\n const moduleDts: string[] = [];\n const clientDts: string[] = [];\n\n const useContribution = (paramsInner: {\n extension: VibeExtension;\n contribution: ExtensionClientContribution;\n scope: \"model\" | \"client\";\n model?: string;\n }): void => {\n const { extension, contribution, scope, model } = paramsInner;\n const property = scope === \"model\" ? extension.name : `$${extension.name}`;\n jsImports.add(contribution.imports);\n dtsImports.add(contribution.dtsImports);\n moduleDts.push(...(contribution.dtsTypes ?? []));\n mounts.push(\n `{ extension: ${JSON.stringify(extension.name)}, scope: ${JSON.stringify(scope)}, ${\n model === undefined ? \"\" : `model: ${JSON.stringify(model)}, `\n }property: ${JSON.stringify(property)}, create: ${contribution.runtimeGlue} }`,\n );\n if (scope === \"model\" && model !== undefined) {\n const lines = delegateDts.get(model) ?? [];\n lines.push(...indent(contribution.dts));\n delegateDts.set(model, lines);\n } else {\n // Root contributions write their own `readonly $name: …;` lines.\n clientDts.push(...indent(contribution.dts));\n }\n };\n\n for (const extension of sorted) {\n const declarations = extensionDeclarations({ schema, name: extension.name });\n\n const modelHook = extension.client?.model;\n if (modelHook !== undefined) {\n for (const model of schema.models) {\n const declaration = declarations[model.name];\n if (declaration === undefined) continue;\n const contribution = modelHook({\n model,\n schema,\n dialect,\n provider,\n options: extension.options,\n declaration,\n typeNames: { payload: model.name, whereInput: `${model.name}WhereInput` },\n });\n if (contribution === null) continue;\n // One-identifier rule (D9): the mounted name must not shadow a field\n // or relation of the model.\n const clash =\n model.fields.some((field) => field.name === extension.name) ||\n model.relations.some((relation) => relation.name === extension.name);\n if (clash) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension \"${extension.name}\" collides with a field/relation named \"${extension.name}\" on model \"${model.name}\" — rename one of them`,\n meta: { extension: extension.name, model: model.name },\n });\n }\n useContribution({ extension, contribution, scope: \"model\", model: model.name });\n }\n }\n\n const rootHook = extension.client?.root;\n if (rootHook !== undefined) {\n const contribution = rootHook({\n schema,\n dialect,\n provider,\n options: extension.options,\n declarations,\n });\n if (contribution !== null) {\n useContribution({ extension, contribution, scope: \"client\" });\n }\n }\n }\n\n return {\n jsImports: jsImports.lines({ typeOnly: false }),\n mounts,\n manifest: sorted.map((extension) => extensionManifestEntry({ extension })),\n dtsImports: dtsImports.lines({ typeOnly: true }),\n delegateDts,\n moduleDts,\n clientDts,\n empty: false,\n };\n}\n",
8
+ "/**\n * Scalar → TypeScript type mapping and the shared filter/update-operation type\n * names referenced by the emitted d.ts. Payload types mirror the runtime codec\n * table exactly (BigInt → bigint, Decimal → string, DateTime → Date, Json →\n * JsonValue, Bytes → Uint8Array); input types are wider where every dialect\n * coerces (`Date | string`, `bigint | number`, `string | number` for Decimal).\n */\n\nimport type { ScalarType } from \"@vibeorm/schema\";\nimport type { FieldView } from \"./schema-view.ts\";\n\n// ─── Tables ───────────────────────────────────────────────────────\n\n/** Decoded payload type per scalar (what rows contain after the codec table ran). */\nconst PAYLOAD_TYPES: Readonly<Record<ScalarType, string>> = {\n String: \"string\",\n Boolean: \"boolean\",\n Int: \"number\",\n BigInt: \"bigint\",\n Float: \"number\",\n Decimal: \"string\",\n DateTime: \"Date\",\n Json: \"JsonValue\",\n Bytes: \"Uint8Array\",\n};\n\n/** Accepted input type per scalar (what create/update/filter values accept). */\nconst INPUT_TYPES: Readonly<Record<ScalarType, string>> = {\n String: \"string\",\n Boolean: \"boolean\",\n Int: \"number\",\n BigInt: \"bigint | number\",\n Float: \"number\",\n Decimal: \"string | number\",\n DateTime: \"Date | string\",\n Json: \"InputJsonValue\",\n Bytes: \"Uint8Array\",\n};\n\n/** Prefix of the shared filter/update-ops type names per scalar. */\nconst FILTER_PREFIX: Readonly<Record<ScalarType, string>> = {\n String: \"String\",\n Boolean: \"Bool\",\n Int: \"Int\",\n BigInt: \"BigInt\",\n Float: \"Float\",\n Decimal: \"Decimal\",\n DateTime: \"DateTime\",\n Json: \"Json\",\n Bytes: \"Bytes\",\n};\n\n/** Scalars that take atomic update operations (increment/decrement/multiply/divide). */\nexport const NUMERIC_SCALARS: ReadonlySet<ScalarType> = new Set([\"Int\", \"BigInt\", \"Float\", \"Decimal\"]);\n\n/** Scalars aggregable with `_min`/`_max` (orderable on every dialect). */\nexport const MINMAX_SCALARS: ReadonlySet<ScalarType> = new Set([\n \"String\",\n \"Int\",\n \"BigInt\",\n \"Float\",\n \"Decimal\",\n \"DateTime\",\n]);\n\n// ─── Lookups ──────────────────────────────────────────────────────\n\n/** The payload type of a field WITHOUT list/null decoration (`string`, `Role`, …). */\nexport function payloadBaseType(params: { field: FieldView }): string {\n const { field } = params;\n return field.enumName ?? PAYLOAD_TYPES[field.scalar as ScalarType];\n}\n\n/** The accepted input value type of a field WITHOUT list/null decoration. */\nexport function inputBaseType(params: { field: FieldView }): string {\n const { field } = params;\n return field.enumName ?? INPUT_TYPES[field.scalar as ScalarType];\n}\n\n/** The filter type name for a field (`StringFilter`, `RoleNullableFilter`, `IntListFilter`, …). */\nexport function filterName(params: { field: FieldView }): string {\n const { field } = params;\n const prefix = field.enumName ?? FILTER_PREFIX[field.scalar as ScalarType];\n if (field.isList) return `${prefix}ListFilter`;\n return field.isOptional ? `${prefix}NullableFilter` : `${prefix}Filter`;\n}\n\n/** The atomic update-operations type name for a numeric field, else `null`. */\nexport function updateOpsName(params: { field: FieldView }): string | null {\n const { field } = params;\n if (field.isList || field.scalar === null || !NUMERIC_SCALARS.has(field.scalar)) return null;\n const prefix = FILTER_PREFIX[field.scalar];\n return field.isOptional ? `Nullable${prefix}FieldUpdateOperationsInput` : `${prefix}FieldUpdateOperationsInput`;\n}\n",
9
+ "/**\n * Shared helpers for the generator: naming, TS property keys, and the stable\n * JSON serializer that keeps emitted output byte-identical for structurally\n * identical IR (object-key insertion order never leaks into the output).\n */\n\nimport { VibeError } from \"@vibeorm/schema\";\n\n// ─── Naming ───────────────────────────────────────────────────────\n\n/** First character uppercased, rest untouched (`posts` → `Posts`). */\nexport function pascal(params: { name: string }): string {\n const { name } = params;\n if (name.length === 0) return name;\n return name.charAt(0).toUpperCase() + name.slice(1);\n}\n\n/**\n * Delegate key for a model name: first character lowercased, rest untouched\n * (the Prisma convention — mirrors @vibeorm/runtime's `toClientName`, which the\n * generator must never drift from: the emitted d.ts declares exactly the\n * properties the runtime attaches).\n */\nexport function clientNameOf(params: { name: string }): string {\n const { name } = params;\n if (name.length === 0) return name;\n return name.charAt(0).toLowerCase() + name.slice(1);\n}\n\nconst IDENTIFIER_RE: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/** A field name as a TS property key — bare when it is a valid identifier, quoted otherwise. */\nexport function propKey(params: { name: string }): string {\n const { name } = params;\n return IDENTIFIER_RE.test(name) ? name : JSON.stringify(name);\n}\n\n/** A TS/JS double-quoted string literal, escaped. */\nexport function tsString(params: { value: string }): string {\n return JSON.stringify(params.value);\n}\n\n/** Wrap a type expression in parens when it is a union (for `[]` suffixing). */\nexport function maybeParens(params: { type: string }): string {\n const { type } = params;\n return type.includes(\"|\") ? `(${type})` : type;\n}\n\n// ─── Stable JSON ──────────────────────────────────────────────────\n\n/**\n * JSON.stringify with recursively sorted object keys and 2-space indentation.\n * Arrays keep their order (array order is semantic in the IR); `undefined`\n * object values are omitted exactly like JSON.stringify does.\n */\nexport function stableStringify(params: { value: unknown }): string {\n return renderValue({ value: params.value, indent: \"\" });\n}\n\nfunction renderValue(params: { value: unknown; indent: string }): string {\n const { value, indent } = params;\n if (value === null) return \"null\";\n const kind = typeof value;\n if (kind === \"string\" || kind === \"number\" || kind === \"boolean\") return JSON.stringify(value);\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n const inner = `${indent} `;\n const items = value.map((item) => inner + renderValue({ value: item, indent: inner }));\n return `[\\n${items.join(\",\\n\")}\\n${indent}]`;\n }\n if (kind === \"object\") {\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record)\n .filter((key) => record[key] !== undefined)\n .sort();\n if (keys.length === 0) return \"{}\";\n const inner = `${indent} `;\n const items = keys.map(\n (key) => `${inner}${JSON.stringify(key)}: ${renderValue({ value: record[key], indent: inner })}`,\n );\n return `{\\n${items.join(\",\\n\")}\\n${indent}}`;\n }\n throw new VibeError({\n code: \"VIBE_INTERNAL\",\n message: `internal: cannot serialize a ${kind} value into the generated client`,\n meta: { kind },\n });\n}\n",
10
+ "/**\n * Emits the generated client's index.js — runtime glue ONLY. All typing lives\n * in the directly-written index.d.ts (see emit-dts.ts); this file embeds the\n * normalized Schema IR as plain data (no `as const` inference trees), exports\n * enums as frozen plain objects and wires `VibeClient()` to the dynamic client\n * in @vibeorm/runtime. Import specifiers stay bare — the consumer resolves\n * @vibeorm/runtime and @vibeorm/schema from its own node_modules.\n */\n\nimport type { ComputedManifestEntry } from \"@vibeorm/schema\";\nimport type { BakedExtensions } from \"./extension-bake.ts\";\nimport { EMPTY_BAKED_EXTENSIONS } from \"./extension-bake.ts\";\nimport type { SchemaView } from \"./schema-view.ts\";\nimport { stableStringify, tsString } from \"./util.ts\";\n\n/** Emit the full index.js for a resolved schema view. */\nexport function emitJs(params: {\n view: SchemaView;\n baked?: BakedExtensions;\n computed?: readonly ComputedManifestEntry[];\n}): string {\n const { view } = params;\n const baked = params.baked ?? EMPTY_BAKED_EXTENSIONS;\n const computed = params.computed ?? [];\n const hasComputed = computed.length > 0;\n const parts: string[] = [];\n\n parts.push(\n `// Generated by VibeORM (@vibeorm/generator) — DO NOT EDIT.\\n// Regenerate with \\`vibeorm generate\\` after every schema change.`,\n );\n parts.push(`import { createClient } from \"@vibeorm/runtime\";`);\n if (baked.jsImports.length > 0) parts.push(baked.jsImports.join(\"\\n\"));\n parts.push(`export { VibeError } from \"@vibeorm/schema\";`);\n parts.push(\n `/** The normalized Schema IR this client was generated from (plain data). */\\nexport const schema = ${stableStringify(\n { value: view.schema },\n )};`,\n );\n\n for (const declared of view.enums) {\n const entries = declared.values\n .map((value) => ` ${tsString({ value })}: ${tsString({ value })},`)\n .join(\"\\n\");\n parts.push(`export const ${declared.name} = Object.freeze({\\n${entries}\\n});`);\n }\n\n if (baked.empty && !hasComputed) {\n parts.push(\n `/** Build a typed client over a database adapter. */\\n` +\n `export function VibeClient(options) {\\n` +\n ` const { adapter, ...clientOptions } = options;\\n` +\n ` return createClient({ schema, adapter, options: clientOptions });\\n` +\n `}`,\n );\n return `${parts.join(\"\\n\\n\")}\\n`;\n }\n\n if (!baked.empty) {\n parts.push(\n `/** Extension manifest — verified against the live extension list (VIBE_STALE_CLIENT). */\\n` +\n `const extensionManifest = ${stableStringify({ value: baked.manifest })};`,\n );\n parts.push(\n `/** Baked extension surfaces (extensions.md D9). */\\n` +\n `const extensionMounts = [\\n${baked.mounts.map((mount) => ` ${mount},`).join(\"\\n\")}\\n];`,\n );\n }\n if (hasComputed) {\n parts.push(\n `/** Computed-field manifest — verified against the live computed config (VIBE_STALE_CLIENT). */\\n` +\n `const computedManifest = ${stableStringify({ value: computed })};`,\n );\n }\n\n const destructured = [\n \"adapter\",\n ...(baked.empty ? [] : [\"extensions\"]),\n ...(hasComputed ? [\"computed\"] : []),\n \"...clientOptions\",\n ].join(\", \");\n const createLines = [\n ` schema,`,\n ` adapter,`,\n ` options: clientOptions,`,\n ...(baked.empty\n ? []\n : [` extensions: { manifest: extensionManifest, mounts: extensionMounts, instances: extensions ?? [] },`]),\n ...(hasComputed ? [` computed: { manifest: computedManifest, specs: computed },`] : []),\n ];\n parts.push(\n `/** Build a typed client over a database adapter. */\\n` +\n `export function VibeClient(options) {\\n` +\n ` const { ${destructured} } = options;\\n` +\n ` return createClient({\\n${createLines.join(\"\\n\")}\\n });\\n` +\n `}`,\n );\n\n return `${parts.join(\"\\n\\n\")}\\n`;\n}\n",
11
+ "/**\n * The generator's resolved view of a SchemaIR: models and enums sorted by name\n * (deterministic emission), `Unsupported(...)` columns dropped from the typed\n * surface (ruling F3 — kept in the embedded IR for schema fidelity), unique\n * lookup members precomputed, and every relation resolved to its inverse field\n * on the target model using the v1 pairing rule: same model pair, symmetric\n * relation name (both unnamed or same name), self-pair excluded by field name.\n */\n\nimport { assertValidSchemaIR, isEnumType } from \"@vibeorm/schema\";\nimport type { FieldIR, ModelIR, RelationIR, RelationType, ScalarType, SchemaIR } from \"@vibeorm/schema\";\nimport { clientNameOf } from \"./util.ts\";\n\n// ─── Types ────────────────────────────────────────────────────────\n\nexport type EnumView = {\n readonly name: string;\n readonly values: readonly string[];\n};\n\n/** A scalar/enum column, resolved for type emission. */\nexport type FieldView = {\n readonly name: string;\n /** The scalar type, or `null` when the field is an enum reference. */\n readonly scalar: ScalarType | null;\n /** The enum name, or `null` when the field is a scalar. */\n readonly enumName: string | null;\n readonly isList: boolean;\n readonly isOptional: boolean;\n readonly isId: boolean;\n readonly isUnique: boolean;\n readonly hasDefault: boolean;\n readonly isUpdatedAt: boolean;\n};\n\n/** A relation field, resolved to its inverse on the target model. */\nexport type RelationView = {\n readonly name: string;\n /** Target model name. */\n readonly target: string;\n readonly type: RelationType;\n readonly isList: boolean;\n readonly isOptional: boolean;\n /** FK scalar field names on the owning model (FK side only, else empty). */\n readonly fkFields: readonly string[];\n /**\n * The back-relation field name on the target model, or `null` when pairing\n * is ambiguous/absent — nested input types then fall back to the target's\n * plain create/update inputs instead of `Without…` variants.\n */\n readonly inverseName: string | null;\n};\n\n/** One way to identify a single row: a unique field, or a composite unique/PK. */\nexport type UniqueMemberView = {\n /** Property key in WhereUniqueInput — the field name, or fields joined by `_`. */\n readonly key: string;\n readonly fields: readonly FieldView[];\n};\n\nexport type ModelView = {\n readonly name: string;\n /** Delegate key on the client (`user` for `User`). */\n readonly clientName: string;\n readonly fields: readonly FieldView[];\n readonly relations: readonly RelationView[];\n readonly uniques: readonly UniqueMemberView[];\n /** Every scalar field name that backs some relation's FK. */\n readonly fkFieldNames: ReadonlySet<string>;\n readonly isView: boolean;\n};\n\nexport type SchemaView = {\n /** The normalized IR (models/enums/extensions sorted by name) — embedded as data in index.js. */\n readonly schema: SchemaIR;\n readonly enums: readonly EnumView[];\n readonly models: readonly ModelView[];\n readonly modelByName: ReadonlyMap<string, ModelView>;\n};\n\n// ─── Building ─────────────────────────────────────────────────────\n\nfunction byName(left: { readonly name: string }, right: { readonly name: string }): number {\n return left.name < right.name ? -1 : left.name > right.name ? 1 : 0;\n}\n\nfunction buildFieldView(params: { field: FieldIR }): FieldView {\n const { field } = params;\n const enumRef = isEnumType(field.type);\n return {\n name: field.name,\n scalar: enumRef ? null : (field.type as ScalarType),\n enumName: enumRef ? (field.type as { readonly enum: string }).enum : null,\n isList: field.isList,\n isOptional: field.isOptional,\n isId: field.isId,\n isUnique: field.isUnique,\n hasDefault: field.default !== undefined,\n isUpdatedAt: field.isUpdatedAt,\n };\n}\n\n/**\n * Resolve the inverse field of a relation on its target model. Exactly one\n * candidate must match (same model pair, symmetric relation name, not the\n * relation itself on self-relations) — anything else returns `null` and the\n * nested input types degrade to the plain create/update inputs.\n */\nfunction resolveInverse(params: { relation: RelationIR; target: ModelIR }): string | null {\n const { relation, target } = params;\n const candidates = target.relations.filter(\n (candidate) =>\n candidate.targetModel === relation.model &&\n (candidate.relationName ?? null) === (relation.relationName ?? null) &&\n !(candidate.model === relation.model && candidate.name === relation.name),\n );\n const first = candidates[0];\n return candidates.length === 1 && first !== undefined ? first.name : null;\n}\n\nfunction buildUniques(params: {\n model: ModelIR;\n fields: readonly FieldView[];\n}): UniqueMemberView[] {\n const { model, fields } = params;\n const fieldByName = new Map(fields.map((field) => [field.name, field]));\n const members: UniqueMemberView[] = [];\n const seen = new Set<string>();\n\n const add = (names: readonly string[]): void => {\n const key = names.join(\"_\");\n if (seen.has(key)) return;\n const resolved: FieldView[] = [];\n for (const name of names) {\n const field = fieldByName.get(name);\n if (field === undefined) return; // Unsupported column inside a unique — not addressable.\n resolved.push(field);\n }\n seen.add(key);\n members.push({ key, fields: resolved });\n };\n\n for (const field of fields) {\n if (field.isId || field.isUnique) add([field.name]);\n }\n if (model.primaryKey !== undefined && model.primaryKey.fields.length > 1) {\n add(model.primaryKey.fields);\n }\n for (const index of model.indexes) {\n if (index.kind === \"unique\") add(index.fields.map((field) => field.name));\n }\n return members;\n}\n\nfunction buildModelView(params: { model: ModelIR; modelIRByName: ReadonlyMap<string, ModelIR> }): ModelView {\n const { model, modelIRByName } = params;\n const fields = model.fields\n .filter((field) => field.isUnsupported !== true)\n .map((field) => buildFieldView({ field }));\n\n const fkFieldNames = new Set<string>();\n const relations: RelationView[] = model.relations.map((relation) => {\n for (const fk of relation.fields ?? []) fkFieldNames.add(fk);\n const target = modelIRByName.get(relation.targetModel);\n return {\n name: relation.name,\n target: relation.targetModel,\n type: relation.type,\n isList: relation.isList,\n isOptional: relation.isOptional,\n fkFields: relation.fields ?? [],\n inverseName: target === undefined ? null : resolveInverse({ relation, target }),\n };\n });\n\n return {\n name: model.name,\n clientName: clientNameOf({ name: model.name }),\n fields,\n relations,\n uniques: buildUniques({ model, fields }),\n fkFieldNames,\n isView: model.isView,\n };\n}\n\n/**\n * Validate and resolve a SchemaIR for emission. The returned view's `schema`\n * is the normalized IR (sorted models/enums/extensions) that gets embedded in\n * the generated index.js — byte-identical for structurally identical input.\n */\nexport function buildSchemaView(params: { schema: SchemaIR }): SchemaView {\n const { schema } = params;\n assertValidSchemaIR({ schema });\n\n const normalized: SchemaIR = {\n datasource: schema.datasource,\n models: [...schema.models].sort(byName),\n enums: [...schema.enums].sort(byName),\n extensions: [...schema.extensions].sort(byName),\n };\n\n const modelIRByName = new Map(normalized.models.map((model) => [model.name, model]));\n const models = normalized.models.map((model) => buildModelView({ model, modelIRByName }));\n\n return {\n schema: normalized,\n enums: normalized.enums.map((declared) => ({ name: declared.name, values: declared.values })),\n models,\n modelByName: new Map(models.map((model) => [model.name, model])),\n };\n}\n"
12
+ ],
13
+ "mappings": ";;AASA;AACA;AACA;;;ACIA,sBAAS;;;ACJT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCO,IAAM,yBAA0C;AAAA,EACrD,WAAW,CAAC;AAAA,EACZ,QAAQ,CAAC;AAAA,EACT,UAAU,CAAC;AAAA,EACX,YAAY,CAAC;AAAA,EACb,aAAa,IAAI;AAAA,EACjB,WAAW,CAAC;AAAA,EACZ,WAAW,CAAC;AAAA,EACZ,OAAO;AACT;AAAA;AAIA,MAAM,gBAAgB;AAAA,EACH,WAAW,IAAI;AAAA,EAEhC,GAAG,CAAC,OAAyD;AAAA,IAC3D,WAAW,QAAQ,SAAS,CAAC,GAAG;AAAA,MAC9B,MAAM,QAAQ,KAAK,SAAS,IAAI,KAAK,IAAI,KAAK,IAAI;AAAA,MAClD,WAAW,QAAQ,KAAK;AAAA,QAAO,MAAM,IAAI,IAAI;AAAA,MAC7C,KAAK,SAAS,IAAI,KAAK,MAAM,KAAK;AAAA,IACpC;AAAA;AAAA,EAGF,KAAK,CAAC,QAAyC;AAAA,IAC7C,OAAO,CAAC,GAAG,KAAK,SAAS,QAAQ,CAAC,EAC/B,KAAK,EAAE,KAAK,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAE,EAC/C,IACC,EAAE,MAAM,WACN,UAAU,OAAO,WAAW,UAAU,OAAO,CAA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K,QAAQ,YAAY,OAAO,cAAc,CAAC,EAAE,CAAC;AAAA,EAEzF,IAAI,WAA6C,CAAC;AAAA,EAClD,IAAI,OAAO,aAAa,aAAa,OAAO,KAAK,OAAO,QAAQ,EAAE,SAAS,GAAG;AAAA,IAC5E,uBAAuB,EAAE,QAAQ,UAAU,OAAO,SAAS,CAAC;AAAA,IAC5D,WAAW,sBAAsB,EAAE,UAAU,OAAO,SAAS,CAAC;AAAA,EAChE;AAAA,EAEA,MAAM,UAA4D;AAAA,IAChE,EAAE,MAAM,YAAY,SAAS,OAAO,EAAE,MAAM,OAAO,SAAS,CAAC,EAAE;AAAA,IAC/D,EAAE,MAAM,cAAc,SAAS,QAAQ,EAAE,MAAM,OAAO,SAAS,CAAC,EAAE;AAAA,IAClE,EAAE,MAAM,aAAa,SAAS,OAAO;AAAA,EACvC;AAAA,EAEA,MAAM,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC,MAAM,QAAkB,CAAC;AAAA,EACzB,WAAW,UAAU,SAAS;AAAA,IAC5B,MAAM,OAAO,KAAK,QAAQ,OAAO,IAAI;AAAA,IACrC,MAAM,UAAU,MAAM,OAAO,SAAS,OAAO;AAAA,IAC7C,MAAM,KAAK,IAAI;AAAA,EACjB;AAAA,EACA,OAAO,EAAE,MAAM;AAAA;",
14
+ "debugId": "793CBF3FCF2EA78F64756E2164756E21",
15
+ "names": []
16
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The generator's resolved view of a SchemaIR: models and enums sorted by name
3
+ * (deterministic emission), `Unsupported(...)` columns dropped from the typed
4
+ * surface (ruling F3 — kept in the embedded IR for schema fidelity), unique
5
+ * lookup members precomputed, and every relation resolved to its inverse field
6
+ * on the target model using the v1 pairing rule: same model pair, symmetric
7
+ * relation name (both unnamed or same name), self-pair excluded by field name.
8
+ */
9
+ import type { RelationType, ScalarType, SchemaIR } from "@vibeorm/schema";
10
+ export type EnumView = {
11
+ readonly name: string;
12
+ readonly values: readonly string[];
13
+ };
14
+ /** A scalar/enum column, resolved for type emission. */
15
+ export type FieldView = {
16
+ readonly name: string;
17
+ /** The scalar type, or `null` when the field is an enum reference. */
18
+ readonly scalar: ScalarType | null;
19
+ /** The enum name, or `null` when the field is a scalar. */
20
+ readonly enumName: string | null;
21
+ readonly isList: boolean;
22
+ readonly isOptional: boolean;
23
+ readonly isId: boolean;
24
+ readonly isUnique: boolean;
25
+ readonly hasDefault: boolean;
26
+ readonly isUpdatedAt: boolean;
27
+ };
28
+ /** A relation field, resolved to its inverse on the target model. */
29
+ export type RelationView = {
30
+ readonly name: string;
31
+ /** Target model name. */
32
+ readonly target: string;
33
+ readonly type: RelationType;
34
+ readonly isList: boolean;
35
+ readonly isOptional: boolean;
36
+ /** FK scalar field names on the owning model (FK side only, else empty). */
37
+ readonly fkFields: readonly string[];
38
+ /**
39
+ * The back-relation field name on the target model, or `null` when pairing
40
+ * is ambiguous/absent — nested input types then fall back to the target's
41
+ * plain create/update inputs instead of `Without…` variants.
42
+ */
43
+ readonly inverseName: string | null;
44
+ };
45
+ /** One way to identify a single row: a unique field, or a composite unique/PK. */
46
+ export type UniqueMemberView = {
47
+ /** Property key in WhereUniqueInput — the field name, or fields joined by `_`. */
48
+ readonly key: string;
49
+ readonly fields: readonly FieldView[];
50
+ };
51
+ export type ModelView = {
52
+ readonly name: string;
53
+ /** Delegate key on the client (`user` for `User`). */
54
+ readonly clientName: string;
55
+ readonly fields: readonly FieldView[];
56
+ readonly relations: readonly RelationView[];
57
+ readonly uniques: readonly UniqueMemberView[];
58
+ /** Every scalar field name that backs some relation's FK. */
59
+ readonly fkFieldNames: ReadonlySet<string>;
60
+ readonly isView: boolean;
61
+ };
62
+ export type SchemaView = {
63
+ /** The normalized IR (models/enums/extensions sorted by name) — embedded as data in index.js. */
64
+ readonly schema: SchemaIR;
65
+ readonly enums: readonly EnumView[];
66
+ readonly models: readonly ModelView[];
67
+ readonly modelByName: ReadonlyMap<string, ModelView>;
68
+ };
69
+ /**
70
+ * Validate and resolve a SchemaIR for emission. The returned view's `schema`
71
+ * is the normalized IR (sorted models/enums/extensions) that gets embedded in
72
+ * the generated index.js — byte-identical for structurally identical input.
73
+ */
74
+ export declare function buildSchemaView(params: {
75
+ schema: SchemaIR;
76
+ }): SchemaView;
77
+ //# sourceMappingURL=schema-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-view.d.ts","sourceRoot":"","sources":["../src/schema-view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAgC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKxG,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,YAAY,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;CAAE,GAAG,UAAU,CAoBxE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Scalar → TypeScript type mapping and the shared filter/update-operation type
3
+ * names referenced by the emitted d.ts. Payload types mirror the runtime codec
4
+ * table exactly (BigInt → bigint, Decimal → string, DateTime → Date, Json →
5
+ * JsonValue, Bytes → Uint8Array); input types are wider where every dialect
6
+ * coerces (`Date | string`, `bigint | number`, `string | number` for Decimal).
7
+ */
8
+ import type { ScalarType } from "@vibeorm/schema";
9
+ import type { FieldView } from "./schema-view.ts";
10
+ /** Scalars that take atomic update operations (increment/decrement/multiply/divide). */
11
+ export declare const NUMERIC_SCALARS: ReadonlySet<ScalarType>;
12
+ /** Scalars aggregable with `_min`/`_max` (orderable on every dialect). */
13
+ export declare const MINMAX_SCALARS: ReadonlySet<ScalarType>;
14
+ /** The payload type of a field WITHOUT list/null decoration (`string`, `Role`, …). */
15
+ export declare function payloadBaseType(params: {
16
+ field: FieldView;
17
+ }): string;
18
+ /** The accepted input value type of a field WITHOUT list/null decoration. */
19
+ export declare function inputBaseType(params: {
20
+ field: FieldView;
21
+ }): string;
22
+ /** The filter type name for a field (`StringFilter`, `RoleNullableFilter`, `IntListFilter`, …). */
23
+ export declare function filterName(params: {
24
+ field: FieldView;
25
+ }): string;
26
+ /** The atomic update-operations type name for a numeric field, else `null`. */
27
+ export declare function updateOpsName(params: {
28
+ field: FieldView;
29
+ }): string | null;
30
+ //# sourceMappingURL=type-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-names.d.ts","sourceRoot":"","sources":["../src/type-names.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA2ClD,wFAAwF;AACxF,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,UAAU,CAAkD,CAAC;AAEvG,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,UAAU,CAOjD,CAAC;AAIH,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,MAAM,CAGpE;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,MAAM,CAGlE;AAED,mGAAmG;AACnG,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,MAAM,CAK/D;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAKzE"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Shared helpers for the generator: naming, TS property keys, and the stable
3
+ * JSON serializer that keeps emitted output byte-identical for structurally
4
+ * identical IR (object-key insertion order never leaks into the output).
5
+ */
6
+ /** First character uppercased, rest untouched (`posts` → `Posts`). */
7
+ export declare function pascal(params: {
8
+ name: string;
9
+ }): string;
10
+ /**
11
+ * Delegate key for a model name: first character lowercased, rest untouched
12
+ * (the Prisma convention — mirrors @vibeorm/runtime's `toClientName`, which the
13
+ * generator must never drift from: the emitted d.ts declares exactly the
14
+ * properties the runtime attaches).
15
+ */
16
+ export declare function clientNameOf(params: {
17
+ name: string;
18
+ }): string;
19
+ /** A field name as a TS property key — bare when it is a valid identifier, quoted otherwise. */
20
+ export declare function propKey(params: {
21
+ name: string;
22
+ }): string;
23
+ /** A TS/JS double-quoted string literal, escaped. */
24
+ export declare function tsString(params: {
25
+ value: string;
26
+ }): string;
27
+ /** Wrap a type expression in parens when it is a union (for `[]` suffixing). */
28
+ export declare function maybeParens(params: {
29
+ type: string;
30
+ }): string;
31
+ /**
32
+ * JSON.stringify with recursively sorted object keys and 2-space indentation.
33
+ * Arrays keep their order (array order is semantic in the IR); `undefined`
34
+ * object values are omitted exactly like JSON.stringify does.
35
+ */
36
+ export declare function stableStringify(params: {
37
+ value: unknown;
38
+ }): string;
39
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,sEAAsE;AACtE,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAIvD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAI7D;AAID,gGAAgG;AAChG,wBAAgB,OAAO,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGxD;AAED,qDAAqD;AACrD,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE1D;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAG5D;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAElE"}
package/package.json CHANGED
@@ -1,42 +1,48 @@
1
1
  {
2
2
  "name": "@vibeorm/generator",
3
- "version": "1.3.1",
4
- "description": "TypeScript client generator for VibeORM — produces typed delegates, inputs, and Zod schemas from a Prisma schema",
5
- "license": "MIT",
3
+ "version": "2.0.0-alpha.2",
4
+ "description": "Client generator for VibeORM v2 — emits .js + directly-written .d.ts from the Schema IR",
6
5
  "keywords": [
7
6
  "orm",
8
- "codegen",
9
- "prisma",
10
- "bun",
11
7
  "typescript",
12
- "postgresql"
8
+ "sql",
9
+ "database",
10
+ "bun",
11
+ "type-safe",
12
+ "codegen",
13
+ "client",
14
+ "typescript-codegen",
15
+ "declaration-files"
13
16
  ],
17
+ "homepage": "https://github.com/vibeorm/vibeorm/tree/master/packages/generator#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/vibeorm/vibeorm/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/vibeorm/vibeorm.git",
24
+ "directory": "packages/generator"
25
+ },
26
+ "license": "MIT",
27
+ "author": "VibeORM contributors",
14
28
  "type": "module",
15
29
  "exports": {
16
30
  ".": {
17
- "default": "./src/index.ts",
18
- "types": "./src/index.ts"
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
19
33
  }
20
34
  },
21
35
  "files": [
22
- "src"
36
+ "dist",
37
+ "README.md"
23
38
  ],
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/vibeorm/vibeorm.git",
27
- "directory": "packages/generator"
39
+ "engines": {
40
+ "bun": ">=1.2.0"
28
41
  },
29
- "homepage": "https://github.com/vibeorm/vibeorm/tree/master/packages/generator",
30
- "bugs": {
31
- "url": "https://github.com/vibeorm/vibeorm/issues"
42
+ "dependencies": {
43
+ "@vibeorm/schema": "2.0.0-alpha.2"
32
44
  },
33
45
  "publishConfig": {
34
46
  "access": "public"
35
- },
36
- "engines": {
37
- "bun": ">=1.1.0"
38
- },
39
- "dependencies": {
40
- "@vibeorm/parser": "1.3.1"
41
47
  }
42
48
  }
package/src/generate.ts DELETED
@@ -1,70 +0,0 @@
1
- import type { Schema } from "@vibeorm/parser";
2
- import { generateEnums } from "./generators/generate-enums.ts";
3
- import { generateModels } from "./generators/generate-models.ts";
4
- import {
5
- generateInputs,
6
- generateFilterTypes,
7
- generateRelationFilterTypes,
8
- } from "./generators/generate-inputs.ts";
9
- import { generateArgs } from "./generators/generate-args.ts";
10
- import { generateResult } from "./generators/generate-result.ts";
11
- import { generateDelegates } from "./generators/generate-delegates.ts";
12
- import { generateClient } from "./generators/generate-client.ts";
13
- import { generateSchemas } from "./generators/generate-schemas.ts";
14
- import { generateViewTypes } from "./generators/generate-view-types.ts";
15
-
16
- export type GeneratedFile = {
17
- filename: string;
18
- content: string;
19
- };
20
-
21
- /**
22
- * Takes a parsed schema IR and produces all the generated TypeScript files.
23
- */
24
- export function generate(params: { schema: Schema }): GeneratedFile[] {
25
- const { schema } = params;
26
-
27
- const files: GeneratedFile[] = [
28
- {
29
- filename: "enums.ts",
30
- content: generateEnums({ enums: schema.enums }),
31
- },
32
- {
33
- filename: "models.ts",
34
- content: generateModels({ schema }),
35
- },
36
- {
37
- filename: "inputs.ts",
38
- content:
39
- generateInputs({ schema }) +
40
- generateFilterTypes() +
41
- generateRelationFilterTypes({ schema }),
42
- },
43
- {
44
- filename: "args.ts",
45
- content: generateArgs({ schema }),
46
- },
47
- {
48
- filename: "result.ts",
49
- content: generateResult({ schema }),
50
- },
51
- {
52
- filename: "delegates.ts",
53
- content: generateDelegates({ schema }),
54
- },
55
- {
56
- filename: "index.ts",
57
- content: generateClient({ schema }),
58
- },
59
- {
60
- filename: "schemas.ts",
61
- content: generateSchemas({ schema }),
62
- },
63
- {
64
- filename: "view-types.ts",
65
- content: generateViewTypes({ schema }),
66
- },
67
- ];
68
-
69
- return files;
70
- }