@vibeorm/schema 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/ir.ts", "../src/errors.ts", "../src/prisma-literal.ts", "../src/reserved.ts", "../src/extension.ts", "../src/computed.ts", "../src/default-values.ts", "../src/capabilities.ts", "../src/validate.ts", "../src/m2m.ts"],
3
+ "sources": ["../src/ir.ts", "../src/predicate.ts", "../src/errors.ts", "../src/migration-objects.ts", "../src/prisma-literal.ts", "../src/reserved.ts", "../src/extension.ts", "../src/computed.ts", "../src/default-values.ts", "../src/capabilities.ts", "../src/validate.ts", "../src/m2m.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Canonical Schema IR for VibeORM v2.\n *\n * Both schema sources (.prisma via @vibeorm/parser, TS DSL via @vibeorm/dsl)\n * compile to this IR. Everything downstream (generator, runtime, migrate,\n * extensions) consumes ONLY this — nothing else ever parses schema text.\n */\n\n// ─── Dialects & Providers ─────────────────────────────────────────\n\n/** Datasource providers a schema may declare. */\nexport type Provider = \"postgresql\" | \"pglite\" | \"sqlite\" | \"mysql\";\n\n/**\n * SQL dialects. PGlite speaks the postgres dialect — it differs only at the\n * adapter level (single connection, bundled extension set).\n */\nexport type Dialect = \"postgres\" | \"sqlite\" | \"mysql\";\n\n/** All dialects, for matrix-style iteration in tests and tooling. */\nexport const DIALECTS: readonly Dialect[] = [\"postgres\", \"sqlite\", \"mysql\"];\n\n/** Map a datasource provider to the SQL dialect it speaks. */\nexport function providerToDialect(params: { provider: Provider }): Dialect {\n const { provider } = params;\n switch (provider) {\n case \"postgresql\":\n case \"pglite\":\n return \"postgres\";\n case \"sqlite\":\n return \"sqlite\";\n case \"mysql\":\n return \"mysql\";\n }\n}\n\n// ─── Scalar & field types ─────────────────────────────────────────\n\n/** Prisma-aligned scalar types. */\nexport type ScalarType =\n | \"String\"\n | \"Boolean\"\n | \"Int\"\n | \"BigInt\"\n | \"Float\"\n | \"Decimal\"\n | \"DateTime\"\n | \"Json\"\n | \"Bytes\";\n\n/** A field's type: a scalar, or a reference to a schema enum by name. */\nexport type FieldType = ScalarType | { readonly enum: string };\n\n/** Narrow a FieldType to an enum reference. */\nexport function isEnumType(fieldType: FieldType): fieldType is { readonly enum: string } {\n return typeof fieldType === \"object\" && \"enum\" in fieldType;\n}\n\n/** Default value declarations, normalized across schema sources. */\nexport type DefaultValueIR =\n | { readonly kind: \"autoincrement\" }\n | { readonly kind: \"now\" }\n | { readonly kind: \"uuid\" }\n | { readonly kind: \"cuid\" }\n | { readonly kind: \"nanoid\" }\n | { readonly kind: \"ulid\" }\n | { readonly kind: \"list\"; readonly values: readonly (string | number | boolean)[] }\n | { readonly kind: \"literal\"; readonly value: string | number | boolean }\n | { readonly kind: \"enumValue\"; readonly value: string }\n | { readonly kind: \"dbgenerated\"; readonly sql: string };\n\n/** A scalar/enum column on a model. */\nexport type FieldIR = {\n readonly name: string;\n /** Column name in the database when it differs from `name` (@map). */\n readonly dbName?: string;\n readonly type: FieldType;\n readonly isList: boolean;\n readonly isOptional: boolean;\n readonly isId: boolean;\n readonly isUnique: boolean;\n readonly isUpdatedAt: boolean;\n readonly default?: DefaultValueIR;\n /** Dialect-native type override (@db.*), verbatim (e.g. \"VarChar(191)\"). */\n readonly nativeType?: string;\n /**\n * Column declared as Prisma `Unsupported(\"...\")` / `dsl.unsupported(\"...\")`.\n * Kept in the IR for schema fidelity (convert, migrate DDL) but excluded from\n * the queryable surface: never projected, never writable, no generated types.\n * `nativeType` carries the raw database type; `type` is a nominal \"String\".\n */\n readonly isUnsupported?: true;\n /**\n * Field doc comment (`///`). Also carries the typed-JSON annotation\n * (`@type(Name from \"./x\")`) the generator reads on Json fields.\n */\n readonly documentation?: string;\n /**\n * Explicit column collation (`@collation(\"...\")`) — String fields. Rendered\n * as `COLLATE` on mysql and silently INERT on postgres/sqlite (the `@db.*`\n * native-type precedent — a dialect-specific annotation, not a capability,\n * so one portable schema crosses the matrix). The runtime skips LOWER()\n * wrapping for insensitive filters on `_ci` collations (board #36).\n * Absent = server/table default (LOWER() kept — conservative).\n */\n readonly collation?: string;\n};\n\n// ─── Relations ────────────────────────────────────────────────────\n\nexport type RelationType = \"oneToOne\" | \"oneToMany\" | \"manyToOne\" | \"manyToMany\";\n\nexport type CascadeAction = \"Cascade\" | \"Restrict\" | \"NoAction\" | \"SetNull\" | \"SetDefault\";\n\n/**\n * A relation field on a model. Implicit many-to-many pairing follows the v1\n * rule (LEARNINGS.md): both sides are lists AND relation names match\n * symmetrically (both unnamed, or same name), with self-exclusion.\n */\nexport type RelationIR = {\n /** Field name on the owning model (e.g. \"posts\"). */\n readonly name: string;\n /** Owning model name. */\n readonly model: string;\n readonly targetModel: string;\n readonly type: RelationType;\n /** Explicit @relation name — disambiguates multiple relations between the same pair. */\n readonly relationName?: string;\n /** FK columns on the owning model (FK side only). */\n readonly fields?: readonly string[];\n /** Referenced columns on the target model (FK side only). */\n readonly references?: readonly string[];\n readonly onDelete?: CascadeAction;\n readonly onUpdate?: CascadeAction;\n readonly isList: boolean;\n readonly isOptional: boolean;\n};\n\n// ─── Indexes ──────────────────────────────────────────────────────\n\n/**\n * Index kind. Core kinds are closed; extensions register additional kinds\n * (e.g. \"bm25\", \"hnsw\", \"fts5\") through the extension registry.\n */\nexport type IndexKind = \"btree\" | \"unique\" | \"gin\" | \"gist\" | \"hash\" | (string & {});\n\nexport type IndexFieldIR = {\n readonly name: string;\n readonly sort?: \"asc\" | \"desc\";\n};\n\nexport type IndexIR = {\n readonly name?: string;\n /**\n * CLIENT selector name for a compound unique (`@@unique(..., name:)`) —\n * names the generated `…WhereUniqueInput` property (and the runtime where\n * key) instead of the default member-fields-joined-by-`_` key. Never a\n * database identifier — that is `name` (from `map:`). Unique compounds\n * only; anywhere it cannot take effect, validation refuses it loudly.\n */\n readonly clientName?: string;\n readonly kind: IndexKind;\n readonly fields: readonly IndexFieldIR[];\n /** Partial index predicate (raw SQL), postgres/sqlite only (capability-gated). */\n readonly where?: string;\n /**\n * `UNIQUE NULLS NOT DISTINCT` — NULLs collide instead of always passing.\n * Unique indexes only; postgres 15+ (pglite included), capability-gated.\n */\n readonly nullsNotDistinct?: boolean;\n};\n\n// ─── Native row-level security ────────────────────────────────────\n\n/** Identity scalars supported by native RLS; lists, enums, Json and Bytes refuse. */\nexport type RlsContextScalar = \"String\" | \"Boolean\" | \"Int\" | \"BigInt\" | \"Float\" | \"Decimal\" | \"DateTime\";\n\n/** Every declared context key is required at binding, including nullable slots. */\nexport type RlsContextFieldIR = {\n readonly type: RlsContextScalar;\n readonly nullable: boolean;\n};\n\n/** Declaration order controls deterministic setting and predicate order. */\nexport type RlsContextIR = Readonly<Record<string, RlsContextFieldIR>>;\n\n/** Declarative reference, never an evaluated callback or raw SQL expression. */\nexport type RlsContextRefIR = { readonly context: string };\n\n/** Native PostgreSQL policy, separate from ModelIR.policy's query rewriting. */\nexport type RlsPolicyIR =\n | { readonly where: Readonly<Record<string, RlsContextRefIR>> }\n | { readonly through: string }\n | \"unprotected\"\n | \"deny\";\n\n/** Enables native RLS and requires an explicit classification on every model. */\nexport type NativeRlsIR = { readonly context: RlsContextIR };\n\n// ─── Models, enums, schema ────────────────────────────────────────\n\n/**\n * A named CHECK constraint on a model. The expression is RAW SQL, rendered\n * verbatim into DDL; the NAME keys the migration diff — engines re-serialize\n * expressions on introspection, so expression text is never compared: change\n * an expression by renaming its check.\n */\nexport type CheckIR = {\n readonly name: string;\n readonly expression: string;\n};\n\nexport type ModelIR = {\n readonly name: string;\n /** Table name in the database when it differs from `name` (@@map). */\n readonly dbName?: string;\n readonly fields: readonly FieldIR[];\n readonly relations: readonly RelationIR[];\n readonly indexes: readonly IndexIR[];\n /** Named CHECK constraints (@@check) — name-keyed in the migration diff. */\n readonly checks?: readonly CheckIR[];\n /**\n * Row-scoping policy (`@@policy([field], context: \"key\")`): the runtime\n * fails closed on policied models until a context is bound ($withPolicy).\n * `context` defaults to the field name.\n */\n readonly policy?: { readonly field: string; readonly context: string };\n /** Database-enforced row policy; cannot combine with application-level policy. */\n readonly rls?: RlsPolicyIR;\n /**\n * Composite primary key (@@id). Single-field PKs use FieldIR.isId.\n * `clientName` (`@@id(..., name:)`) names the client selector — the\n * `…WhereUniqueInput` property — instead of the default fields-joined-by-`_`\n * key; it is never a database identifier.\n */\n readonly primaryKey?: { readonly fields: readonly string[]; readonly clientName?: string };\n readonly isView: boolean;\n readonly documentation?: string;\n};\n\n/**\n * How an enum is physically stored.\n *\n * - `\"database\"` — the native projection: a PostgreSQL enum type, a MySQL\n * inline `ENUM(...)`, a SQLite TEXT column with an enum CHECK.\n * - `\"string\"` — an ordinary String column (postgres `text`, sqlite `TEXT`,\n * mysql's varchar mapping) with membership enforced by VibeORM in the codec\n * path on both input and output. Adding a member changes generated code,\n * never DDL. Sorting/equality follow string collation, not declaration order.\n *\n * The logical enum (name, members, generated constant + literal union) is the\n * same either way; only the physical projection differs.\n */\nexport type EnumStorage = \"database\" | \"string\";\n\n/** All enum storage strategies, for validation and matrix-style tests. */\nexport const ENUM_STORAGES: readonly EnumStorage[] = [\"database\", \"string\"];\n\nexport type EnumIR = {\n readonly name: string;\n readonly dbName?: string;\n readonly values: readonly string[];\n /**\n * Physical storage. ABSENT means `\"database\"` — the backwards-compatible\n * default, so IR from older schemas (and every `.prisma` enum) keeps its\n * native projection untouched. Read it through `enumStorageOf`, never\n * directly, so the default lives in one place.\n */\n readonly storage?: EnumStorage;\n};\n\n/** The effective storage of an enum (`\"database\"` when the IR omits it). */\nexport function enumStorageOf(params: { enumDef: Pick<EnumIR, \"storage\"> }): EnumStorage {\n return params.enumDef.storage ?? \"database\";\n}\n\n/** An extension declared for this schema (config and/or schema attributes). */\nexport type ExtensionDeclIR = {\n readonly name: string;\n readonly options: Readonly<Record<string, unknown>>;\n};\n\nexport type DatasourceIR = {\n readonly provider: Provider;\n /** Connection URL if the schema declares one (env-resolved at runtime, not here). */\n readonly url?: string;\n};\n\nexport type SchemaIR = {\n /** Native RLS context declaration; absent preserves existing client behavior. */\n readonly rls?: NativeRlsIR;\n readonly datasource: DatasourceIR;\n readonly models: readonly ModelIR[];\n readonly enums: readonly EnumIR[];\n readonly extensions: readonly ExtensionDeclIR[];\n};\n",
6
- "/**\n * The VibeORM v2 error contract.\n *\n * Every error thrown by any @vibeorm package is a VibeError carrying a stable\n * string code. Callers branch on `error.code` — never on message text (the v1\n * mistake this replaces). Adapters map driver errors to these codes via\n * per-driver tables.\n */\n\n// ─── Codes ────────────────────────────────────────────────────────\n\nexport const VIBE_ERROR_CODES = [\n /** findUniqueOrThrow / findFirstOrThrow / update / delete target missing. */\n \"VIBE_NOT_FOUND\",\n /** Unique constraint violation (driver-mapped). */\n \"VIBE_UNIQUE_VIOLATION\",\n /** Foreign key constraint violation (driver-mapped). */\n \"VIBE_FK_VIOLATION\",\n /** Input failed validation before reaching the database. */\n \"VIBE_VALIDATION\",\n /**\n * A STORED value violates the schema's invariant on its way out of the\n * database — e.g. a string-backed enum column holding a non-member written\n * by raw SQL or another writer. Distinct from VIBE_VALIDATION (bad input):\n * the row is what is wrong, and VibeORM refuses to return it falsely typed.\n */\n \"VIBE_DATA_INVALID\",\n /** Schema IR failed structural validation. */\n \"VIBE_SCHEMA_INVALID\",\n /** Feature requested on a dialect that does not support it. */\n \"VIBE_UNSUPPORTED_CAPABILITY\",\n /** Generated client is stale relative to config/schema — re-run generate. */\n \"VIBE_STALE_CLIENT\",\n /** Configuration problem (vibeorm.config.ts, flags, env). */\n \"VIBE_CONFIG\",\n /** Migration engine failure. */\n \"VIBE_MIGRATION\",\n /** Transaction begin/commit/rollback/serialization failure (driver-mapped). */\n \"VIBE_TRANSACTION\",\n /** A tenant-scoped handle ($scoped) refused a call it cannot make safe. */\n \"VIBE_SCOPED\",\n /** Native RLS identity is missing, invalid, expired or conflicting. */\n \"VIBE_RLS_CONTEXT\",\n /** SQLSTATE 42501: insufficient privilege, including policy WITH CHECK failure. */\n \"VIBE_PERMISSION_DENIED\",\n /** Driver/connection failure not mapped to a more specific code. */\n \"VIBE_ADAPTER\",\n /** Invariant broken inside VibeORM itself — always a bug, please report. */\n \"VIBE_INTERNAL\",\n] as const;\n\nexport type VibeErrorCode = (typeof VIBE_ERROR_CODES)[number];\n\n// ─── Error class ──────────────────────────────────────────────────\n\n/**\n * Base error for all VibeORM failures.\n *\n * @example\n * try { await db.user.findUniqueOrThrow({ where: { id } }); }\n * catch (e) {\n * if (e instanceof VibeError && e.code === \"VIBE_NOT_FOUND\") { ... }\n * }\n */\nexport class VibeError extends Error {\n readonly code: VibeErrorCode;\n readonly meta: Readonly<Record<string, unknown>>;\n\n constructor(params: {\n code: VibeErrorCode;\n message: string;\n meta?: Record<string, unknown>;\n cause?: unknown;\n }) {\n super(params.message, params.cause === undefined ? undefined : { cause: params.cause });\n this.name = \"VibeError\";\n this.code = params.code;\n this.meta = params.meta ?? {};\n }\n}\n\n// ─── Factories ────────────────────────────────────────────────────\n\n/** Standard capability error — used by sql/runtime/migrate/generator alike. */\nexport function unsupportedCapability(params: {\n dialect: string;\n feature: string;\n hint?: string;\n}): VibeError {\n const { dialect, feature, hint } = params;\n return new VibeError({\n code: \"VIBE_UNSUPPORTED_CAPABILITY\",\n message: `${feature} is not supported on ${dialect}${hint === undefined ? \"\" : ` — ${hint}`}`,\n meta: { dialect, feature },\n });\n}\n\n// ─── Stored-data invariant failures ───────────────────────────────\n\n/** Longest stored string echoed into VIBE_DATA_INVALID meta/message. */\nconst STORED_VALUE_PREVIEW_LENGTH = 80;\n\n/**\n * Describe one offending stored value for an error WITHOUT leaking anything\n * else: strings are truncated, everything else is reported by `typeof` only\n * (a stored object/array is never serialized into an error).\n */\nfunction describeStoredValue(params: { value: unknown }): string {\n const { value } = params;\n if (typeof value !== \"string\") return value === null ? \"null\" : typeof value;\n return value.length > STORED_VALUE_PREVIEW_LENGTH\n ? `${value.slice(0, STORED_VALUE_PREVIEW_LENGTH)}…`\n : value;\n}\n\n/**\n * A stored value failed the schema's invariant when a row was materialized —\n * lane 2B throws this from the codec path for a string-backed enum column\n * holding a non-member. Carries model/field/enum and a bounded description of\n * the offending value ONLY; it never accepts, and so never exposes, the rest\n * of the row.\n */\nexport function invalidStoredData(params: {\n model: string;\n field: string;\n /** The enum the column is typed with, when the invariant is enum membership. */\n enum?: string;\n /** The offending stored value — strings truncated, non-strings reduced to their type. */\n value: unknown;\n}): VibeError {\n const { model, field, enum: enumName, value } = params;\n const preview = describeStoredValue({ value });\n const invariant = enumName === undefined ? \"the schema's invariant\" : `enum ${enumName}`;\n return new VibeError({\n code: \"VIBE_DATA_INVALID\",\n message: `Stored value on ${model}.${field} violates ${invariant}: ${JSON.stringify(preview)} — clean the rows (or stop the writer) before reading them through the ORM`,\n meta: { model, field, ...(enumName === undefined ? {} : { enum: enumName }), value: preview },\n });\n}\n\n/** Internal invariant violation — always indicates a VibeORM bug. */\nexport function internalError(params: { message: string; meta?: Record<string, unknown> }): VibeError {\n return new VibeError({\n code: \"VIBE_INTERNAL\",\n message: `internal: ${params.message}`,\n meta: params.meta,\n });\n}\n\n// ─── Native RLS context refusals ──────────────────────────────────\n\n/** Stable lifecycle categories; metadata never includes identity values. */\nexport const RLS_CONTEXT_REASONS: readonly [\"missing\", \"invalid\", \"expired\", \"conflicting\"] = Object.freeze([\n \"missing\", \"invalid\", \"expired\", \"conflicting\",\n]);\n\nexport type RlsContextReason = (typeof RLS_CONTEXT_REASONS)[number];\n\n/** Native RLS binding/lifecycle failure, distinct from database permissions. */\nexport class RlsContextError extends VibeError {\n readonly reason: RlsContextReason;\n\n constructor(params: { reason: RlsContextReason; key?: string }) {\n super({\n code: \"VIBE_RLS_CONTEXT\",\n message: `Native RLS context is ${params.reason}${params.key === undefined ? \"\" : ` at key ${JSON.stringify(params.key)}`}`,\n meta: { reason: params.reason, ...(params.key === undefined ? {} : { key: params.key }) },\n });\n this.name = \"RlsContextError\";\n this.reason = params.reason;\n }\n}\n\n// ─── Scoped-handle refusals ───────────────────────────────────────\n\n/**\n * Why a `$scoped` handle refused a call — a STABLE machine-readable set.\n * Conformance vectors (and the sibling Prisma binding) match on these strings,\n * never on message text.\n */\nexport const SCOPED_REFUSAL_REASONS = [\n /** The client's schema declares @@policy — the two scoping layers do not combine. */\n \"policy_conflict\",\n /** The models map misses one or more schema models (totality is required). */\n \"unclassified_model\",\n /** The models map names a model the schema does not have. */\n \"unknown_model\",\n /** A { column } entry names an unknown field. */\n \"unknown_column\",\n /** A { column } entry names a field that cannot carry a scope (list/enum/non-scalar type). */\n \"column_not_scopeable\",\n /** A { through } entry names an unknown or to-many relation. */\n \"unknown_relation\",\n /** A { through } chain cycles or ends on a \"none\" model instead of a { column } one. */\n \"through_chain_invalid\",\n /** A models-map entry has an unknown shape or extra properties. */\n \"invalid_entry\",\n /** The scope value's runtime type does not match a scoped column's declared type. */\n \"scope_type_mismatch\",\n /** scope: null — calls on scoped models refuse until a scope is bound. */\n \"null_scope\",\n /** Raw SQL is not available on a scoped handle — use the base client. */\n \"raw_forbidden\",\n /** $scoped on an already-scoped handle — scope once, from the base client. */\n \"rescope_forbidden\",\n /** Write data names the tenant column (or through-parent) with a conflicting value. */\n \"explicit_scope_mismatch\",\n /** A bare foreign-key write would re-tenant a through-scoped row — use the relation verbs. */\n \"through_fk_write\",\n /** A nested verb on a scoped model that cannot be made safe (or nested: \"refuse\"). */\n \"nested_refused\",\n /** orderBy through a relation onto a scoped model would leak cross-tenant ordering. */\n \"relation_orderby_on_scoped\",\n /** An unfiltered relation _count of a scoped model would count foreign rows. */\n \"count_on_scoped_relation\",\n] as const;\n\nexport type ScopedRefusalReason = (typeof SCOPED_REFUSAL_REASONS)[number];\n\n/**\n * A refusal from a tenant-scoped handle (`$scoped`). Carries the model, the\n * argument path of the offending node (e.g. `\"data.legs.set\"` or a method like\n * `\"call.update\"`), and a stable `reason`. Always `code: \"VIBE_SCOPED\"`.\n */\nexport class ScopedQueryError extends VibeError {\n /** Model the refusal is about (the scoped model at the offending node). */\n readonly model: string;\n /** Argument path of the offending node (`\"where.calls.every\"`, `\"data.legs.connect\"`). */\n readonly path: string;\n readonly reason: ScopedRefusalReason;\n\n constructor(params: {\n model: string;\n path: string;\n reason: ScopedRefusalReason;\n message: string;\n meta?: Record<string, unknown>;\n }) {\n super({\n code: \"VIBE_SCOPED\",\n message: params.message,\n meta: { ...params.meta, model: params.model, path: params.path, reason: params.reason },\n });\n this.name = \"ScopedQueryError\";\n this.model = params.model;\n this.path = params.path;\n this.reason = params.reason;\n }\n}\n",
5
+ "/**\n * Canonical Schema IR for VibeORM v2.\n *\n * Both schema sources (.prisma via @vibeorm/parser, TS DSL via @vibeorm/dsl)\n * compile to this IR. Everything downstream (generator, runtime, migrate,\n * extensions) consumes ONLY this — nothing else ever parses schema text.\n */\n\nimport type { ExclusionIR } from \"./exclusion.ts\";\nimport type { MigrationObjectIR } from \"./migration-objects.ts\";\nimport type { PredicateIR } from \"./predicate.ts\";\n\n// ─── Dialects & Providers ─────────────────────────────────────────\n\n/** Datasource providers a schema may declare. */\nexport type Provider = \"postgresql\" | \"pglite\" | \"sqlite\" | \"mysql\";\n\n/**\n * SQL dialects. PGlite speaks the postgres dialect — it differs only at the\n * adapter level (single connection, bundled extension set).\n */\nexport type Dialect = \"postgres\" | \"sqlite\" | \"mysql\";\n\n/** All dialects, for matrix-style iteration in tests and tooling. */\nexport const DIALECTS: readonly Dialect[] = [\"postgres\", \"sqlite\", \"mysql\"];\n\n/** Map a datasource provider to the SQL dialect it speaks. */\nexport function providerToDialect(params: { provider: Provider }): Dialect {\n const { provider } = params;\n switch (provider) {\n case \"postgresql\":\n case \"pglite\":\n return \"postgres\";\n case \"sqlite\":\n return \"sqlite\";\n case \"mysql\":\n return \"mysql\";\n }\n}\n\n// ─── Scalar & field types ─────────────────────────────────────────\n\n/** Prisma-aligned scalar types. */\nexport type ScalarType =\n | \"String\"\n | \"Boolean\"\n | \"Int\"\n | \"BigInt\"\n | \"Float\"\n | \"Decimal\"\n | \"DateTime\"\n | \"Json\"\n | \"Bytes\";\n\n/** A field's type: a scalar, or a reference to a schema enum by name. */\nexport type FieldType = ScalarType | { readonly enum: string };\n\n/** Narrow a FieldType to an enum reference. */\nexport function isEnumType(fieldType: FieldType): fieldType is { readonly enum: string } {\n return typeof fieldType === \"object\" && \"enum\" in fieldType;\n}\n\n/**\n * A comparable spelling of a field type — `\"String\"`, `\"Int\"`, `\"enum:Status\"`.\n *\n * The ONE place a `FieldType` becomes a comparison key. Foreign-key pairing\n * (`@vibeorm/dsl`'s `fieldTypeKey`) and schema-predicate operand checking\n * (`@vibeorm/sql`'s `renderPredicate`) both ask the same question — \"are these\n * two the same scalar?\" — so they read the same answer.\n */\nexport function fieldTypeIdentity(params: { type: FieldType }): string {\n const { type } = params;\n return isEnumType(type) ? `enum:${type.enum}` : type;\n}\n\n/** Default value declarations, normalized across schema sources. */\nexport type DefaultValueIR =\n | { readonly kind: \"autoincrement\" }\n | { readonly kind: \"now\" }\n | { readonly kind: \"uuid\" }\n | { readonly kind: \"cuid\" }\n | { readonly kind: \"nanoid\" }\n | { readonly kind: \"ulid\" }\n | { readonly kind: \"list\"; readonly values: readonly (string | number | boolean)[] }\n | { readonly kind: \"literal\"; readonly value: string | number | boolean }\n | { readonly kind: \"enumValue\"; readonly value: string }\n | { readonly kind: \"dbgenerated\"; readonly sql: string };\n\n/** A scalar/enum column on a model. */\nexport type FieldIR = {\n readonly name: string;\n /** Column name in the database when it differs from `name` (@map). */\n readonly dbName?: string;\n readonly type: FieldType;\n readonly isList: boolean;\n readonly isOptional: boolean;\n readonly isId: boolean;\n readonly isUnique: boolean;\n readonly isUpdatedAt: boolean;\n readonly default?: DefaultValueIR;\n /** Dialect-native type override (@db.*), verbatim (e.g. \"VarChar(191)\"). */\n readonly nativeType?: string;\n /**\n * Column declared as Prisma `Unsupported(\"...\")` / `dsl.unsupported(\"...\")`.\n * Kept in the IR for schema fidelity (convert, migrate DDL) but excluded from\n * the queryable surface: never projected, never writable, no generated types.\n * `nativeType` carries the raw database type; `type` is a nominal \"String\".\n */\n readonly isUnsupported?: true;\n /**\n * Field doc comment (`///`). Also carries the typed-JSON annotation\n * (`@type(Name from \"./x\")`) the generator reads on Json fields.\n */\n readonly documentation?: string;\n /**\n * Explicit column collation (`@collation(\"...\")`) — String fields. Rendered\n * as `COLLATE` on mysql and silently INERT on postgres/sqlite (the `@db.*`\n * native-type precedent — a dialect-specific annotation, not a capability,\n * so one portable schema crosses the matrix). The runtime skips LOWER()\n * wrapping for insensitive filters on `_ci` collations (board #36).\n * Absent = server/table default (LOWER() kept — conservative).\n */\n readonly collation?: string;\n};\n\n// ─── Relations ────────────────────────────────────────────────────\n\nexport type RelationType = \"oneToOne\" | \"oneToMany\" | \"manyToOne\" | \"manyToMany\";\n\nexport type CascadeAction = \"Cascade\" | \"Restrict\" | \"NoAction\" | \"SetNull\" | \"SetDefault\";\n\n/**\n * A relation field on a model. Implicit many-to-many pairing follows the v1\n * rule (LEARNINGS.md): both sides are lists AND relation names match\n * symmetrically (both unnamed, or same name), with self-exclusion.\n */\nexport type RelationIR = {\n /** Field name on the owning model (e.g. \"posts\"). */\n readonly name: string;\n /** Owning model name. */\n readonly model: string;\n readonly targetModel: string;\n readonly type: RelationType;\n /** Explicit @relation name — disambiguates multiple relations between the same pair. */\n readonly relationName?: string;\n /** Physical FK identity, independent of the client relation alias. */\n readonly constraintName?: string;\n /** FK columns on the owning model (FK side only). */\n readonly fields?: readonly string[];\n /** Referenced columns on the target model (FK side only). */\n readonly references?: readonly string[];\n readonly onDelete?: CascadeAction;\n readonly onUpdate?: CascadeAction;\n readonly isList: boolean;\n readonly isOptional: boolean;\n};\n\n// ─── Indexes ──────────────────────────────────────────────────────\n\n/**\n * Index kind. Core kinds are closed; extensions register additional kinds\n * (e.g. \"bm25\", \"hnsw\", \"fts5\") through the extension registry.\n */\nexport type IndexKind = \"btree\" | \"unique\" | \"gin\" | \"gist\" | \"hash\" | (string & {});\n\nexport type IndexFieldIR = {\n readonly name: string;\n readonly sort?: \"asc\" | \"desc\";\n};\n\nexport type IndexIR = {\n readonly name?: string;\n /** Physical unique constraint owning this index, when catalog-backed. */\n readonly constraintName?: string;\n /**\n * CLIENT selector name for a compound unique (`@@unique(..., name:)`) —\n * names the generated `…WhereUniqueInput` property (and the runtime where\n * key) instead of the default member-fields-joined-by-`_` key. Never a\n * database identifier — that is `name` (from `map:`). Unique compounds\n * only; anywhere it cannot take effect, validation refuses it loudly.\n */\n readonly clientName?: string;\n readonly kind: IndexKind;\n readonly fields: readonly IndexFieldIR[];\n /** Partial index predicate (raw SQL), postgres/sqlite only (capability-gated). */\n readonly where?: string;\n /**\n * The typed expression `where` was rendered from, when the predicate was\n * authored as one. Same contract as {@link CheckIR.predicate}: `where` stays\n * the text every consumer reads, this is the structured source.\n */\n readonly wherePredicate?: PredicateIR;\n /**\n * `UNIQUE NULLS NOT DISTINCT` — NULLs collide instead of always passing.\n * Unique indexes only; postgres 15+ (pglite included), capability-gated.\n */\n readonly nullsNotDistinct?: boolean;\n};\n\n// ─── Native row-level security ────────────────────────────────────\n\n/** Identity scalars supported by native RLS; lists, enums, Json and Bytes refuse. */\nexport type RlsContextScalar = \"String\" | \"Boolean\" | \"Int\" | \"BigInt\" | \"Float\" | \"Decimal\" | \"DateTime\";\n\n/** Every declared context key is required at binding, including nullable slots. */\nexport type RlsContextFieldIR = {\n readonly type: RlsContextScalar;\n readonly nullable: boolean;\n};\n\n/** Declaration order controls deterministic setting and predicate order. */\nexport type RlsContextIR = Readonly<Record<string, RlsContextFieldIR>>;\n\n/** Declarative reference, never an evaluated callback or raw SQL expression. */\nexport type RlsContextRefIR = { readonly context: string };\n\n/** Native PostgreSQL policy, separate from ModelIR.policy's query rewriting. */\nexport type RlsPolicyIR =\n | { readonly where: Readonly<Record<string, RlsContextRefIR>> }\n | { readonly through: string }\n | \"unprotected\"\n | \"deny\";\n\n/** Enables native RLS and requires an explicit classification on every model. */\nexport type NativeRlsIR = { readonly context: RlsContextIR };\n\n// ─── Models, enums, schema ────────────────────────────────────────\n\n/**\n * A named CHECK constraint on a model. The expression is RAW SQL, rendered\n * verbatim into DDL. Authored same-name changes replace the constraint;\n * live comparisons require normalized definition evidence or an explicit\n * replacement when expression equivalence cannot be established.\n */\nexport type CheckIR = {\n /** Introspection marks raw catalog text so pure diffs cannot guess equivalence. */\n readonly catalogExpression?: true;\n readonly name: string;\n readonly expression: string;\n /**\n * The typed expression `expression` was rendered from, when the check was\n * authored as one. Serializable data, never a callback. Absent for raw\n * authored strings and for introspected catalog text — those two are carried\n * verbatim and never parsed back into a predicate.\n *\n * `expression` stays the single currency for everything downstream (diffing,\n * DDL, desired-state evidence); this field is the authoring source of truth\n * and the reference EPIC 4's exclusion constraints reuse.\n */\n readonly predicate?: PredicateIR;\n};\n\nexport type ModelIR = {\n readonly name: string;\n /** Physical primary-key constraint name, independent of the client selector. */\n readonly primaryKeyConstraintName?: string;\n /** Table name in the database when it differs from `name` (@@map). */\n readonly dbName?: string;\n readonly fields: readonly FieldIR[];\n readonly relations: readonly RelationIR[];\n readonly indexes: readonly IndexIR[];\n /** Named CHECK constraints (@@check), including authored expression changes. */\n readonly exclusions?: readonly ExclusionIR[];\n readonly checks?: readonly CheckIR[];\n /**\n * Row-scoping policy (`@@policy([field], context: \"key\")`): the runtime\n * fails closed on policied models until a context is bound ($withPolicy).\n * `context` defaults to the field name.\n */\n readonly policy?: { readonly field: string; readonly context: string };\n /** Database-enforced row policy; cannot combine with application-level policy. */\n readonly rls?: RlsPolicyIR;\n /**\n * Composite primary key (@@id). Single-field PKs use FieldIR.isId.\n * `clientName` (`@@id(..., name:)`) names the client selector — the\n * `…WhereUniqueInput` property — instead of the default fields-joined-by-`_`\n * key; it is never a database identifier.\n */\n readonly primaryKey?: { readonly fields: readonly string[]; readonly clientName?: string };\n readonly isView: boolean;\n readonly documentation?: string;\n};\n\n/**\n * How an enum is physically stored.\n *\n * - `\"database\"` — the native projection: a PostgreSQL enum type, a MySQL\n * inline `ENUM(...)`, a SQLite TEXT column with an enum CHECK.\n * - `\"string\"` — an ordinary String column (postgres `text`, sqlite `TEXT`,\n * mysql's varchar mapping) with membership enforced by VibeORM in the codec\n * path on both input and output. Adding a member changes generated code,\n * never DDL. Sorting/equality follow string collation, not declaration order.\n *\n * The logical enum (name, members, generated constant + literal union) is the\n * same either way; only the physical projection differs.\n */\nexport type EnumStorage = \"database\" | \"string\";\n\n/** All enum storage strategies, for validation and matrix-style tests. */\nexport const ENUM_STORAGES: readonly EnumStorage[] = [\"database\", \"string\"];\n\nexport type EnumIR = {\n readonly name: string;\n readonly dbName?: string;\n readonly values: readonly string[];\n /**\n * Physical storage. ABSENT means `\"database\"` — the backwards-compatible\n * default, so IR from older schemas (and every `.prisma` enum) keeps its\n * native projection untouched. Read it through `enumStorageOf`, never\n * directly, so the default lives in one place.\n */\n readonly storage?: EnumStorage;\n};\n\n/** The effective storage of an enum (`\"database\"` when the IR omits it). */\nexport function enumStorageOf(params: { enumDef: Pick<EnumIR, \"storage\"> }): EnumStorage {\n return params.enumDef.storage ?? \"database\";\n}\n\n/** An extension declared for this schema (config and/or schema attributes). */\nexport type ExtensionDeclIR = {\n readonly name: string;\n readonly options: Readonly<Record<string, unknown>>;\n};\n\nexport type DatasourceIR = {\n readonly provider: Provider;\n /** Connection URL if the schema declares one (env-resolved at runtime, not here). */\n readonly url?: string;\n};\n\nexport type SchemaIR = {\n /** Database-maintenance declarations, excluded from runtime extension registration. */\n readonly migrationObjects?: readonly MigrationObjectIR[];\n /** Native RLS context declaration; absent preserves existing client behavior. */\n readonly rls?: NativeRlsIR;\n readonly datasource: DatasourceIR;\n readonly models: readonly ModelIR[];\n readonly enums: readonly EnumIR[];\n readonly extensions: readonly ExtensionDeclIR[];\n};\n",
6
+ "/**\n * Typed schema predicates — the serializable expression a CHECK constraint or a\n * partial-index `WHERE` is authored as.\n *\n * This module holds the DATA only. It contains no SQL text and no dialect\n * knowledge: rendering a predicate is `renderPredicate` in @vibeorm/sql (rule 4\n * — every SQL-text decision lives in one place), and authoring one is the `c`\n * builder in @vibeorm/dsl.\n *\n * Three properties are load-bearing:\n *\n * 1. **It is data, never a callback.** Nothing downstream carries an executable\n * JavaScript function, so a predicate survives JSON (`desired-state.json`,\n * migration metadata) unchanged.\n * 2. **Fields are LOGICAL names.** `@map`ped physical column names are resolved\n * at render time against the model, so renaming a mapped column cannot leave\n * a CHECK pointing at a column that no longer exists.\n * 3. **Numeric literals keep every digit.** BigInt and Decimal values ride as\n * exact decimal TEXT — `Number(9007199254740993n)` is a different number, the\n * same trap column defaults already guard against.\n *\n * A raw SQL string stays the documented escape hatch for anything this cannot\n * express; raw text is carried verbatim and never parsed back into a predicate.\n */\n\n// ─── Operands ─────────────────────────────────────────────────────\n\n/** Comparison operators a schema predicate may use. Deliberately closed. */\nexport type PredicateComparisonOp = \"eq\" | \"ne\" | \"gt\" | \"gte\" | \"lt\" | \"lte\";\n\n/** All comparison operators, for matrix-style iteration in tests and tooling. */\nexport const PREDICATE_COMPARISON_OPS: readonly PredicateComparisonOp[] = [\n \"eq\",\n \"ne\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n];\n\n/**\n * A reference to one of the model's own fields, by LOGICAL name. The mapped\n * physical column is resolved when the predicate is rendered.\n */\nexport type PredicateFieldRef = {\n readonly kind: \"field\";\n readonly name: string;\n};\n\n/**\n * A literal operand in JSON-safe carrier form. BigInt and Decimal values are\n * carried as exact decimal text; Int/Float as numbers; String/enum as strings.\n */\nexport type PredicateValue = {\n readonly kind: \"value\";\n readonly value: string | number | boolean;\n};\n\n/** Either side of a comparison: another field, or a literal. */\nexport type PredicateOperand = PredicateFieldRef | PredicateValue;\n\n// ─── The predicate ────────────────────────────────────────────────\n\n/**\n * A boolean expression over one model's fields.\n *\n * SQL three-valued logic applies unchanged: a comparison against NULL is\n * UNKNOWN, and a CHECK constraint passes on TRUE **or** UNKNOWN. Nothing here\n * adds an implicit null guard — where all-or-none is the invariant, the author\n * writes it out with `isNull`/`isNotNull`.\n */\nexport type PredicateIR =\n | {\n readonly kind: \"compare\";\n readonly op: PredicateComparisonOp;\n readonly left: PredicateFieldRef;\n readonly right: PredicateOperand;\n }\n | {\n readonly kind: \"inList\";\n readonly field: PredicateFieldRef;\n readonly values: readonly PredicateValue[];\n readonly negate?: true;\n }\n | { readonly kind: \"isNull\"; readonly field: PredicateFieldRef; readonly negate?: true }\n | { readonly kind: \"and\"; readonly operands: readonly PredicateIR[] }\n | { readonly kind: \"or\"; readonly operands: readonly PredicateIR[] }\n | { readonly kind: \"not\"; readonly operand: PredicateIR };\n\n// ─── Structural helpers ───────────────────────────────────────────\n\n/** Narrow a predicate operand to a field reference. */\nexport function isPredicateFieldRef(operand: PredicateOperand): operand is PredicateFieldRef {\n return operand.kind === \"field\";\n}\n\n/**\n * Every LOGICAL field name the predicate reads, in first-seen order.\n *\n * Used by validation (\"does the model declare these?\") and by any consumer that\n * needs to know which columns an expression depends on without rendering it.\n */\nexport function predicateFieldNames(params: { predicate: PredicateIR }): readonly string[] {\n const seen = new Set<string>();\n const walk = (node: PredicateIR): void => {\n switch (node.kind) {\n case \"compare\":\n seen.add(node.left.name);\n if (isPredicateFieldRef(node.right)) seen.add(node.right.name);\n return;\n case \"inList\":\n case \"isNull\":\n seen.add(node.field.name);\n return;\n case \"and\":\n case \"or\":\n for (const operand of node.operands) walk(operand);\n return;\n case \"not\":\n walk(node.operand);\n return;\n }\n };\n walk(params.predicate);\n return [...seen];\n}\n\n/**\n * A stable, DIALECT-FREE key for a predicate.\n *\n * Two predicates share a key exactly when they are structurally identical. The\n * DSL uses it to tell a partial index from a total one over the same columns —\n * which are different database objects — without rendering SQL, because index\n * planning happens before a provider is known.\n *\n * It is NOT a semantic equivalence test: `a AND b` and `b AND a` get different\n * keys, deliberately. Guessing SQL equivalence is what constitution rule 4\n * forbids and what EPIC 1's live normalization exists for.\n */\nexport function predicateKey(params: { predicate: PredicateIR }): string {\n const encode = (node: PredicateIR): string => {\n switch (node.kind) {\n case \"compare\":\n return `cmp(${node.op},${node.left.name},${\n isPredicateFieldRef(node.right)\n ? `f:${node.right.name}`\n : `v:${typeof node.right.value}:${String(node.right.value)}`\n })`;\n case \"inList\":\n return `in${node.negate === true ? \"!\" : \"\"}(${node.field.name},[${node.values\n .map((entry) => `${typeof entry.value}:${String(entry.value)}`)\n .join(\"|\")}])`;\n case \"isNull\":\n return `null${node.negate === true ? \"!\" : \"\"}(${node.field.name})`;\n case \"and\":\n case \"or\":\n return `${node.kind}(${node.operands.map(encode).join(\",\")})`;\n case \"not\":\n return `not(${encode(node.operand)})`;\n }\n };\n return encode(params.predicate);\n}\n",
7
+ "/**\n * The VibeORM v2 error contract.\n *\n * Every error thrown by any @vibeorm package is a VibeError carrying a stable\n * string code. Callers branch on `error.code` — never on message text (the v1\n * mistake this replaces). Adapters map driver errors to these codes via\n * per-driver tables.\n */\n\n// ─── Codes ────────────────────────────────────────────────────────\n\nexport const VIBE_ERROR_CODES = [\n /** findUniqueOrThrow / findFirstOrThrow / update / delete target missing. */\n \"VIBE_NOT_FOUND\",\n /** Unique constraint violation (driver-mapped). */\n \"VIBE_UNIQUE_VIOLATION\",\n /** Exclusion constraint violation (PostgreSQL SQLSTATE 23P01). */\n \"VIBE_EXCLUSION_VIOLATION\",\n /** Foreign key constraint violation (driver-mapped). */\n \"VIBE_FK_VIOLATION\",\n /** Input failed validation before reaching the database. */\n \"VIBE_VALIDATION\",\n /**\n * A STORED value violates the schema's invariant on its way out of the\n * database — e.g. a string-backed enum column holding a non-member written\n * by raw SQL or another writer. Distinct from VIBE_VALIDATION (bad input):\n * the row is what is wrong, and VibeORM refuses to return it falsely typed.\n */\n \"VIBE_DATA_INVALID\",\n /** Schema IR failed structural validation. */\n \"VIBE_SCHEMA_INVALID\",\n /** Feature requested on a dialect that does not support it. */\n \"VIBE_UNSUPPORTED_CAPABILITY\",\n /** Generated client is stale relative to config/schema — re-run generate. */\n \"VIBE_STALE_CLIENT\",\n /** Configuration problem (vibeorm.config.ts, flags, env). */\n \"VIBE_CONFIG\",\n /** Migration engine failure. */\n \"VIBE_MIGRATION\",\n /** Transaction begin/commit/rollback/serialization failure (driver-mapped). */\n \"VIBE_TRANSACTION\",\n /**\n * A lock could not be obtained (driver-mapped): a `nowait` locking read whose\n * rows were already locked, or a bounded lock wait that expired. PostgreSQL\n * reports both as SQLSTATE 55P03 and MySQL as errno 3572 / 1205. Distinct\n * from VIBE_TRANSACTION: nothing was rolled back by the ENGINE's own conflict\n * detection — another transaction simply holds the row right now. Never\n * retried automatically; whether to wait, skip or fail is the caller's policy.\n */\n \"VIBE_LOCK_NOT_AVAILABLE\",\n /** A tenant-scoped handle ($scoped) refused a call it cannot make safe. */\n \"VIBE_SCOPED\",\n /**\n * A read-only client ($readOnly) refused a call. The facade forwards an\n * ALLOWLIST of read methods and refuses everything else, so this code covers\n * a classified write, a raw-SQL door, connection/lock control, and any\n * surface nobody classified — including one added by a later ORM version.\n */\n \"VIBE_READ_ONLY\",\n /** Native RLS identity is missing, invalid, expired or conflicting. */\n \"VIBE_RLS_CONTEXT\",\n /** SQLSTATE 42501: insufficient privilege, including policy WITH CHECK failure. */\n \"VIBE_PERMISSION_DENIED\",\n /** Driver/connection failure not mapped to a more specific code. */\n \"VIBE_ADAPTER\",\n /** Invariant broken inside VibeORM itself — always a bug, please report. */\n \"VIBE_INTERNAL\",\n] as const;\n\nexport type VibeErrorCode = (typeof VIBE_ERROR_CODES)[number];\n\n// ─── Error class ──────────────────────────────────────────────────\n\n/**\n * Base error for all VibeORM failures.\n *\n * @example\n * try { await db.user.findUniqueOrThrow({ where: { id } }); }\n * catch (e) {\n * if (e instanceof VibeError && e.code === \"VIBE_NOT_FOUND\") { ... }\n * }\n */\nexport class VibeError extends Error {\n readonly code: VibeErrorCode;\n readonly meta: Readonly<Record<string, unknown>>;\n\n constructor(params: {\n code: VibeErrorCode;\n message: string;\n meta?: Record<string, unknown>;\n cause?: unknown;\n }) {\n super(params.message, params.cause === undefined ? undefined : { cause: params.cause });\n this.name = \"VibeError\";\n this.code = params.code;\n this.meta = params.meta ?? {};\n }\n}\n\n// ─── Factories ────────────────────────────────────────────────────\n\n/** Standard capability error — used by sql/runtime/migrate/generator alike. */\nexport function unsupportedCapability(params: {\n dialect: string;\n feature: string;\n hint?: string;\n}): VibeError {\n const { dialect, feature, hint } = params;\n return new VibeError({\n code: \"VIBE_UNSUPPORTED_CAPABILITY\",\n message: `${feature} is not supported on ${dialect}${hint === undefined ? \"\" : ` — ${hint}`}`,\n meta: { dialect, feature },\n });\n}\n\n// ─── Stored-data invariant failures ───────────────────────────────\n\n/** Longest stored string echoed into VIBE_DATA_INVALID meta/message. */\nconst STORED_VALUE_PREVIEW_LENGTH = 80;\n\n/**\n * Describe one offending stored value for an error WITHOUT leaking anything\n * else: strings are truncated, everything else is reported by `typeof` only\n * (a stored object/array is never serialized into an error).\n */\nfunction describeStoredValue(params: { value: unknown }): string {\n const { value } = params;\n if (typeof value !== \"string\") return value === null ? \"null\" : typeof value;\n return value.length > STORED_VALUE_PREVIEW_LENGTH\n ? `${value.slice(0, STORED_VALUE_PREVIEW_LENGTH)}…`\n : value;\n}\n\n/**\n * A stored value failed the schema's invariant when a row was materialized —\n * lane 2B throws this from the codec path for a string-backed enum column\n * holding a non-member. Carries model/field/enum and a bounded description of\n * the offending value ONLY; it never accepts, and so never exposes, the rest\n * of the row.\n */\nexport function invalidStoredData(params: {\n model: string;\n field: string;\n /** The enum the column is typed with, when the invariant is enum membership. */\n enum?: string;\n /** The offending stored value — strings truncated, non-strings reduced to their type. */\n value: unknown;\n}): VibeError {\n const { model, field, enum: enumName, value } = params;\n const preview = describeStoredValue({ value });\n const invariant = enumName === undefined ? \"the schema's invariant\" : `enum ${enumName}`;\n return new VibeError({\n code: \"VIBE_DATA_INVALID\",\n message: `Stored value on ${model}.${field} violates ${invariant}: ${JSON.stringify(preview)} — clean the rows (or stop the writer) before reading them through the ORM`,\n meta: { model, field, ...(enumName === undefined ? {} : { enum: enumName }), value: preview },\n });\n}\n\n/** Internal invariant violation — always indicates a VibeORM bug. */\nexport function internalError(params: { message: string; meta?: Record<string, unknown> }): VibeError {\n return new VibeError({\n code: \"VIBE_INTERNAL\",\n message: `internal: ${params.message}`,\n meta: params.meta,\n });\n}\n\n// ─── Native RLS context refusals ──────────────────────────────────\n\n/** Stable lifecycle categories; metadata never includes identity values. */\nexport const RLS_CONTEXT_REASONS: readonly [\"missing\", \"invalid\", \"expired\", \"conflicting\"] = Object.freeze([\n \"missing\", \"invalid\", \"expired\", \"conflicting\",\n]);\n\nexport type RlsContextReason = (typeof RLS_CONTEXT_REASONS)[number];\n\n/** Native RLS binding/lifecycle failure, distinct from database permissions. */\nexport class RlsContextError extends VibeError {\n readonly reason: RlsContextReason;\n\n constructor(params: { reason: RlsContextReason; key?: string }) {\n super({\n code: \"VIBE_RLS_CONTEXT\",\n message: `Native RLS context is ${params.reason}${params.key === undefined ? \"\" : ` at key ${JSON.stringify(params.key)}`}`,\n meta: { reason: params.reason, ...(params.key === undefined ? {} : { key: params.key }) },\n });\n this.name = \"RlsContextError\";\n this.reason = params.reason;\n }\n}\n\n// ─── Scoped-handle refusals ───────────────────────────────────────\n\n/**\n * Why a `$scoped` handle refused a call — a STABLE machine-readable set.\n * Conformance vectors (and the sibling Prisma binding) match on these strings,\n * never on message text.\n */\nexport const SCOPED_REFUSAL_REASONS = [\n /** The client's schema declares @@policy — the two scoping layers do not combine. */\n \"policy_conflict\",\n /** The models map misses one or more schema models (totality is required). */\n \"unclassified_model\",\n /** The models map names a model the schema does not have. */\n \"unknown_model\",\n /** A { column } entry names an unknown field. */\n \"unknown_column\",\n /** A { column } entry names a field that cannot carry a scope (list/enum/non-scalar type). */\n \"column_not_scopeable\",\n /** A { through } entry names an unknown or to-many relation. */\n \"unknown_relation\",\n /** A { through } chain cycles or ends on a \"none\" model instead of a { column } one. */\n \"through_chain_invalid\",\n /** A models-map entry has an unknown shape or extra properties. */\n \"invalid_entry\",\n /** The scope value's runtime type does not match a scoped column's declared type. */\n \"scope_type_mismatch\",\n /** scope: null — calls on scoped models refuse until a scope is bound. */\n \"null_scope\",\n /** Raw SQL is not available on a scoped handle — use the base client. */\n \"raw_forbidden\",\n /** $scoped on an already-scoped handle — scope once, from the base client. */\n \"rescope_forbidden\",\n /** Write data names the tenant column (or through-parent) with a conflicting value. */\n \"explicit_scope_mismatch\",\n /** A bare foreign-key write would re-tenant a through-scoped row — use the relation verbs. */\n \"through_fk_write\",\n /** A nested verb on a scoped model that cannot be made safe (or nested: \"refuse\"). */\n \"nested_refused\",\n /** orderBy through a relation onto a scoped model would leak cross-tenant ordering. */\n \"relation_orderby_on_scoped\",\n /** An unfiltered relation _count of a scoped model would count foreign rows. */\n \"count_on_scoped_relation\",\n] as const;\n\nexport type ScopedRefusalReason = (typeof SCOPED_REFUSAL_REASONS)[number];\n\n/**\n * A refusal from a tenant-scoped handle (`$scoped`). Carries the model, the\n * argument path of the offending node (e.g. `\"data.legs.set\"` or a method like\n * `\"call.update\"`), and a stable `reason`. Always `code: \"VIBE_SCOPED\"`.\n */\nexport class ScopedQueryError extends VibeError {\n /** Model the refusal is about (the scoped model at the offending node). */\n readonly model: string;\n /** Argument path of the offending node (`\"where.calls.every\"`, `\"data.legs.connect\"`). */\n readonly path: string;\n readonly reason: ScopedRefusalReason;\n\n constructor(params: {\n model: string;\n path: string;\n reason: ScopedRefusalReason;\n message: string;\n meta?: Record<string, unknown>;\n }) {\n super({\n code: \"VIBE_SCOPED\",\n message: params.message,\n meta: { ...params.meta, model: params.model, path: params.path, reason: params.reason },\n });\n this.name = \"ScopedQueryError\";\n this.model = params.model;\n this.path = params.path;\n this.reason = params.reason;\n }\n}\n\n// ─── Read-only-handle refusals ────────────────────────────────────\n\n/**\n * Why a `$readOnly` handle refused a call — a STABLE machine-readable set, so\n * a caller mapping the refusal onto its own domain error never matches message\n * text (constitution rule 5).\n */\nexport const READ_ONLY_REFUSAL_REASONS = [\n /** A delegate method that writes rows (`create`, `upsertMany`, `delete`, …). */\n \"write\",\n /**\n * A raw-SQL door. A SELECT-shaped statement is not proof of a read, and\n * VibeORM will not inspect SQL text to guess: the door is closed instead. A\n * genuinely read-only raw path needs a database-enforced guarantee (a read-only\n * transaction or a read-only role), which is a separate, explicit feature.\n */\n \"raw\",\n /** Connection lifecycle, advisory locks, identity binding — control, not reading. */\n \"control\",\n /**\n * A surface nobody classified as a read: an extension mount, or a method a\n * later ORM version adds. Deny-by-default is the whole point of the facade.\n */\n \"unclassified\",\n /** An array-`$transaction` member whose operation is not a classified read. */\n \"foreign_operation\",\n] as const;\n\nexport type ReadOnlyRefusalReason = (typeof READ_ONLY_REFUSAL_REASONS)[number];\n\n/**\n * A refusal from a read-only handle (`$readOnly`). Carries the offending\n * member's path (`\"user.upsertMany\"`, `\"$executeRaw\"`, `\"post.search\"`) and a\n * stable `reason`. Always `code: \"VIBE_READ_ONLY\"`.\n */\nexport class ReadOnlyClientError extends VibeError {\n /** The member as the caller spelled it: `\"<model>.<method>\"` or `\"$method\"`. */\n readonly path: string;\n readonly reason: ReadOnlyRefusalReason;\n\n constructor(params: {\n path: string;\n reason: ReadOnlyRefusalReason;\n message: string;\n meta?: Record<string, unknown>;\n }) {\n super({\n code: \"VIBE_READ_ONLY\",\n message: params.message,\n meta: { ...params.meta, path: params.path, reason: params.reason },\n });\n this.name = \"ReadOnlyClientError\";\n this.path = params.path;\n this.reason = params.reason;\n }\n}\n",
8
+ "import type { Dialect } from \"./ir.ts\";\nimport { VibeError } from \"./errors.ts\";\n\n/** Physical namespace and name, never a search_path-dependent SQL string. */\nexport type QualifiedSqlName = {\n readonly namespace: string;\n readonly name: string;\n};\n\n/** Portable catalog identity. PostgreSQL object identifiers must not be persisted. */\nexport type SqlObjectIdentity =\n | { readonly kind: \"table\" | \"view\" | \"sequence\" | \"postgresExtension\"; readonly name: QualifiedSqlName }\n | { readonly kind: \"function\"; readonly name: QualifiedSqlName; readonly argumentTypes: readonly QualifiedSqlName[] }\n | { readonly kind: \"index\" | \"trigger\"; readonly table: QualifiedSqlName; readonly name: string }\n | { readonly kind: \"constraint\"; readonly table: QualifiedSqlName; readonly name: string; readonly constraintType: \"check\" | \"foreignKey\" | \"exclusion\" | \"unique\" | \"primaryKey\" }\n | { readonly kind: \"column\" | \"columnDefault\" | \"generatedColumn\"; readonly table: QualifiedSqlName; readonly column: string };\n\n/** Catalog facts are serialized, not executable verification callbacks. */\nexport type SqlObjectFacts = Readonly<Record<string, string | number | boolean | null | readonly string[]>>;\n\n/** An independently authored expectation, or one deparsed from an independent reference. */\nexport type SqlObjectDefinition = {\n readonly identity: SqlObjectIdentity;\n readonly facts: SqlObjectFacts;\n readonly dependencies: readonly SqlObjectIdentity[];\n readonly format: \"catalog-v1\";\n};\n\n/** Migration-only declaration. It contributes no generated runtime extension manifest. */\nexport type MigrationObjectIR = {\n readonly id: string;\n readonly dialect: Dialect;\n readonly identity: SqlObjectIdentity;\n readonly create: readonly string[];\n readonly drop: readonly string[];\n readonly dependsOn: readonly SqlObjectIdentity[];\n /** Absence preserves ownership but must be reported as inspection unavailable. */\n readonly expected?: SqlObjectDefinition;\n};\n\n/** Stable, unambiguous identifier also accepted by named removal authorization. */\nexport function sqlObjectKey(params: { identity: SqlObjectIdentity }): string {\n const object = params.identity;\n switch (object.kind) {\n case \"table\": case \"view\": case \"sequence\": case \"postgresExtension\":\n return JSON.stringify([object.kind, object.name.namespace, object.name.name]);\n case \"function\":\n return JSON.stringify([object.kind, object.name.namespace, object.name.name, object.argumentTypes.map((type) => [type.namespace, type.name])]);\n case \"index\": case \"trigger\":\n return JSON.stringify([object.kind, object.table.namespace, object.table.name, object.name]);\n case \"constraint\":\n return JSON.stringify([object.kind, object.table.namespace, object.table.name, object.name, object.constraintType]);\n case \"column\": case \"columnDefault\": case \"generatedColumn\":\n return JSON.stringify([object.kind, object.table.namespace, object.table.name, object.column]);\n }\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\nfunction name(value: unknown): value is QualifiedSqlName {\n return record(value) && typeof value.namespace === \"string\" && value.namespace.length > 0\n && typeof value.name === \"string\" && value.name.length > 0;\n}\n\n/** Validate identities read from JSON or untyped config before any database access. */\nexport function isSqlObjectIdentity(value: unknown): value is SqlObjectIdentity {\n if (!record(value)) return false;\n switch (value.kind) {\n case \"table\": case \"view\": case \"sequence\": case \"postgresExtension\": return name(value.name);\n case \"function\": return name(value.name) && Array.isArray(value.argumentTypes) && value.argumentTypes.every(name);\n case \"index\": case \"trigger\": return name(value.table) && typeof value.name === \"string\" && value.name.length > 0;\n case \"constraint\": return name(value.table) && typeof value.name === \"string\" && value.name.length > 0\n && [\"check\", \"foreignKey\", \"exclusion\", \"unique\", \"primaryKey\"].includes(String(value.constraintType));\n case \"column\": case \"columnDefault\": case \"generatedColumn\": return name(value.table) && typeof value.column === \"string\" && value.column.length > 0;\n default: return false;\n }\n}\n\n/** Reject malformed expected catalog facts rather than degrading to presence-only verification. */\nexport function isSqlObjectDefinition(value: unknown): value is SqlObjectDefinition {\n return record(value) && value.format === \"catalog-v1\" && isSqlObjectIdentity(value.identity)\n && record(value.facts) && Object.keys(value.facts).length > 0\n && Object.values(value.facts).every((fact) => fact === null || typeof fact === \"string\" || typeof fact === \"boolean\"\n || (typeof fact === \"number\" && Number.isFinite(fact)) || (Array.isArray(fact) && fact.every((entry) => typeof entry === \"string\")))\n && Array.isArray(value.dependencies) && value.dependencies.every(isSqlObjectIdentity);\n}\n\n/** Runtime validation for serializable migration-only schema contributions. */\nexport function assertMigrationObjects(params: { objects: unknown }): asserts params is { objects: readonly MigrationObjectIR[] } {\n if (!Array.isArray(params.objects)) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"migrationObjects must be an array\" });\n const ids = new Set<string>();\n const owners = new Set<string>();\n for (const object of params.objects) {\n if (!record(object) || typeof object.id !== \"string\" || object.id.length === 0\n || ![\"postgres\", \"sqlite\", \"mysql\"].includes(String(object.dialect)) || !isSqlObjectIdentity(object.identity)\n || !Array.isArray(object.create) || !object.create.every((sql) => typeof sql === \"string\")\n || !Array.isArray(object.drop) || !object.drop.every((sql) => typeof sql === \"string\")\n || !Array.isArray(object.dependsOn) || !object.dependsOn.every(isSqlObjectIdentity)\n || (object.expected !== undefined && (!isSqlObjectDefinition(object.expected)\n || sqlObjectKey({ identity: object.expected.identity }) !== sqlObjectKey({ identity: object.identity })))) {\n throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"Invalid migration-only object declaration\" });\n }\n const key = sqlObjectKey({ identity: object.identity });\n if (ids.has(object.id) || owners.has(key)) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"Duplicate migration object identity or id\", meta: { id: object.id, key } });\n ids.add(object.id);\n owners.add(key);\n }\n}\n",
7
9
  "/**\n * The Prisma literal grammar, in ONE place.\n *\n * Two defects the review found were the same defect seen from both sides:\n * reading a `.prisma` string token by stripping its quotes keeps the escape\n * BYTES (`\\n` stayed a backslash and an `n`), and writing one by interpolating\n * a value between two quotes emits text that cannot be read back (an embedded\n * `\"` ends the token early). Both directions therefore live here, so the\n * decoder and the encoder can never drift apart:\n *\n * - {@link decodePrismaString} — token text (quotes included) → the bytes it denotes.\n * - {@link encodePrismaString} — a value → a token that decodes back to it.\n * - {@link exactIntegerLiteral} — an integer literal's digits, never rounded\n * through a JavaScript number.\n *\n * ROUND-TRIP CONTRACT (unit-tested):\n * `decodePrismaString({ raw: encodePrismaString({ value }) }) === value` for\n * every string, and the parser reads back what the printers write.\n */\n\nimport { VibeError } from \"./errors.ts\";\n\n// ─── Strings ──────────────────────────────────────────────────────\n\n/**\n * Escape sequences a `.prisma` string literal may carry, mapped to the byte\n * each one denotes. `\\uXXXX` is handled separately (it consumes four more\n * characters); anything else is refused rather than guessed at.\n */\nconst STRING_ESCAPES: Readonly<Record<string, string>> = {\n '\"': '\"',\n \"'\": \"'\",\n \"\\\\\": \"\\\\\",\n \"/\": \"/\",\n n: \"\\n\",\n r: \"\\r\",\n t: \"\\t\",\n b: \"\\b\",\n f: \"\\f\",\n};\n\nfunction malformed(params: { raw: string; detail: string }): VibeError {\n return new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `Malformed string literal ${JSON.stringify(params.raw)}: ${params.detail}`,\n meta: { issues: [{ rule: \"malformed-string-literal\", message: params.detail }], literal: params.raw },\n });\n}\n\n/**\n * Decode a `.prisma` string token into the bytes it denotes.\n *\n * The surrounding double quotes are optional: a token that is not quoted (a\n * bare identifier the CST handed over as a string) is returned unchanged, which\n * is what every call site relied on before escapes were decoded at all.\n *\n * @throws VibeError `VIBE_SCHEMA_INVALID` on an unknown escape, a malformed\n * `\\uXXXX`, or a trailing backslash — never a silently mangled value.\n */\nexport function decodePrismaString(params: { raw: string }): string {\n const { raw } = params;\n const quoted = raw.length >= 2 && raw.startsWith('\"') && raw.endsWith('\"');\n const body = quoted ? raw.slice(1, -1) : raw;\n if (!body.includes(\"\\\\\")) return body;\n\n let out = \"\";\n for (let index = 0; index < body.length; index += 1) {\n const char = body[index]!;\n if (char !== \"\\\\\") {\n out += char;\n continue;\n }\n const next = body[index + 1];\n if (next === undefined) throw malformed({ raw, detail: \"it ends with a lone backslash\" });\n if (next === \"u\") {\n const digits = body.slice(index + 2, index + 6);\n if (!/^[0-9a-fA-F]{4}$/.test(digits)) {\n throw malformed({ raw, detail: `\\\\u must be followed by four hex digits, found \"${digits}\"` });\n }\n out += String.fromCharCode(Number.parseInt(digits, 16));\n index += 5;\n continue;\n }\n const decoded = STRING_ESCAPES[next];\n if (decoded === undefined) throw malformed({ raw, detail: `unknown escape \"\\\\${next}\"` });\n out += decoded;\n index += 1;\n }\n return out;\n}\n\n/** Control characters have no readable escape of their own — emit `\\uXXXX`. */\nfunction unicodeEscape(params: { char: string }): string {\n return `\\\\u${params.char.charCodeAt(0).toString(16).padStart(4, \"0\")}`;\n}\n\n/**\n * Encode a value as a complete `.prisma` string token, quotes included.\n *\n * Every printer that writes a string into schema text goes through this, so\n * embedded quotes, backslashes, newlines and control characters survive a\n * re-parse instead of truncating the token or changing its bytes.\n */\nexport function encodePrismaString(params: { value: string }): string {\n const { value } = params;\n let out = '\"';\n for (const char of value) {\n if (char === \"\\\\\") out += \"\\\\\\\\\";\n else if (char === '\"') out += '\\\\\"';\n else if (char === \"\\n\") out += \"\\\\n\";\n else if (char === \"\\r\") out += \"\\\\r\";\n else if (char === \"\\t\") out += \"\\\\t\";\n else if (char < \" \" || char === \"\\u007f\") out += unicodeEscape({ char });\n else out += char;\n }\n return `${out}\"`;\n}\n\n// ─── Integers ─────────────────────────────────────────────────────\n\nconst INTEGER_LITERAL = /^-?\\d+$/;\n\n/**\n * The IR value for an integer literal default, exactly as written.\n *\n * A JavaScript `number` holds integers exactly only up to 2^53 − 1, so\n * `@default(9007199254740993)` used to become `9007199254740992` before any\n * SQL was rendered. Digits that do not survive that conversion are carried in\n * the `literal` variant's EXISTING string slot instead — the same shape a\n * numeric string default (`Decimal @default(\"0\")`) already has, which every\n * consumer already compiles against and renders. Safe integers keep their\n * `number` form, so nothing that works today changes shape.\n *\n * @throws VibeError `VIBE_SCHEMA_INVALID` when the text is not an integer literal.\n */\nexport function exactIntegerLiteral(params: { text: string }): number | string {\n const { text } = params;\n if (!INTEGER_LITERAL.test(text)) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `Not an integer literal: ${JSON.stringify(text)}`,\n meta: { issues: [{ rule: \"malformed-integer-literal\", message: text }], literal: text },\n });\n }\n const asNumber = Number(text);\n if (Number.isSafeInteger(asNumber)) return asNumber;\n return BigInt(text).toString();\n}\n",
8
- "/**\n * Reserved names on the generated client surface.\n *\n * Extensions claim exactly one identifier per scope (plan D9): a method or\n * namespace on opted-in model delegates, and/or a root `$name` namespace.\n * The generator rejects any extension whose name collides with these lists.\n * Snapshot-tested so the core can never silently grow into an extension's name.\n */\n\n// ─── Model delegate methods ───────────────────────────────────────\n\nexport const RESERVED_DELEGATE_NAMES: readonly string[] = [\n \"findMany\",\n \"findFirst\",\n \"findUnique\",\n \"findFirstOrThrow\",\n \"findUniqueOrThrow\",\n \"create\",\n \"createMany\",\n \"createManyAndReturn\",\n \"update\",\n \"updateMany\",\n \"updateManyAndReturn\",\n \"upsert\",\n \"delete\",\n \"deleteMany\",\n \"count\",\n \"aggregate\",\n \"groupBy\",\n \"fields\",\n];\n\n// ─── Client $-methods ─────────────────────────────────────────────\n\nexport const RESERVED_CLIENT_NAMES: readonly string[] = [\n \"$connect\",\n \"$disconnect\",\n \"$transaction\",\n \"$queryRaw\",\n \"$queryRawUnsafe\",\n \"$executeRaw\",\n \"$executeRawUnsafe\",\n \"$on\",\n \"$extends\",\n \"$defineView\",\n \"$withPolicy\",\n \"$bypassPolicy\",\n \"$scoped\",\n];\n\n// ─── Reserved column-name prefix ─────────────────────────────────\n\n/**\n * Column-name prefix reserved for VibeORM's own result projections — the M2M\n * join loader's `__vibe_parent` stitch key today, hidden order/stitch fields\n * generally. A user column with this prefix would collide with a projection\n * alias and be silently misgrouped or stripped, so schema validation refuses\n * it (`reserved-column-prefix`). Unreachable from `.prisma` field-name\n * grammar, reachable via `@map` or hand-built IR. Wave-C sqlite review,\n * finding 3.\n */\nexport const RESERVED_COLUMN_PREFIX: string = \"__vibe_\";\n\n// ─── Guards ───────────────────────────────────────────────────────\n\nexport function isReservedDelegateName(params: { name: string }): boolean {\n return RESERVED_DELEGATE_NAMES.includes(params.name);\n}\n\n/** Checks the `$`-prefixed form an extension's root namespace would occupy. */\nexport function isReservedClientName(params: { name: string }): boolean {\n const withPrefix = params.name.startsWith(\"$\") ? params.name : `$${params.name}`;\n return RESERVED_CLIENT_NAMES.includes(withPrefix);\n}\n",
9
- "/**\n * Extension framework contract (plan §10, extensions.md).\n *\n * Hook types live HERE so every package can consume them without cycles:\n * extensions implement them (tier 1 in @vibeorm/extensions), parser/dsl route\n * schema attributes through the registry, migrate applies artifact DDL,\n * the generator bakes client surfaces (D9), and the runtime mounts them.\n *\n * All hook signatures are dependency-free on purpose: DDL is dialect-correct\n * SQL text (never migrate step objects), SQL fragments are neutral part lists\n * (@vibeorm/sql renders them), and client contributions are JS/d.ts text.\n */\n\nimport { VibeError } from \"./errors.ts\";\nimport type { Dialect, ModelIR, Provider, SchemaIR } from \"./ir.ts\";\nimport { RESERVED_CLIENT_NAMES, RESERVED_DELEGATE_NAMES } from \"./reserved.ts\";\n\n// ─── Attribute parsing (schema plane) ─────────────────────────────\n\n/** Scalar-ish values an extension attribute argument may carry. */\nexport type ExtensionAttributeValue =\n | string\n | number\n | boolean\n | readonly string[]\n | readonly number[];\n\n/**\n * One occurrence of an extension attribute, normalized identically by the\n * .prisma parser and the TS DSL (source equivalence is tested — LEARNINGS F2).\n */\nexport type ExtensionAttributeArgs = {\n /** The positional field-list argument (`[title, body]`), when present. */\n readonly fields?: readonly string[];\n /** Named arguments (`name: \"x\"`, `weights: [2, 1]`, `dims: 1536`). */\n readonly named: Readonly<Record<string, ExtensionAttributeValue>>;\n};\n\n/** A model-level attribute the extension registers (`@@search(...)`). */\nexport type ExtensionModelAttribute = {\n /** Attribute name without the `@@` prefix. */\n readonly name: string;\n /**\n * Validate and normalize one occurrence into declaration data. Returning\n * `{ error }` rejects the schema with VIBE_SCHEMA_INVALID at parse time.\n */\n readonly parse: (ctx: {\n readonly model: string;\n readonly args: ExtensionAttributeArgs;\n /** Scalar/enum field names on the model, for validation. */\n readonly fieldNames: readonly string[];\n }) =>\n | { readonly declaration: Readonly<Record<string, unknown>> }\n | { readonly error: string };\n};\n\n/** A column type the extension registers (`embedding Vector(1536)`). */\nexport type ExtensionFieldType = {\n /** Type name as written in the schema — e.g. \"Vector\". */\n readonly name: string;\n /**\n * Lower one field to a database-native column type. The field lands in the\n * IR exactly like `Unsupported(\"<nativeType>\")` (kept for DDL, excluded from\n * the core queryable surface); the declaration is merged into the\n * extension's ExtensionDeclIR for downstream planes.\n */\n readonly lower: (ctx: {\n readonly model: string;\n readonly field: string;\n /** Positional type arguments (`Vector(1536)` → [1536]). */\n readonly args: readonly (string | number)[];\n }) =>\n | {\n readonly nativeType: string;\n readonly declaration?: Readonly<Record<string, unknown>>;\n }\n | { readonly error: string };\n};\n\n// ─── Migrate plane ────────────────────────────────────────────────\n\n/**\n * The database object an artifact owns. Migrate uses this identity to\n * (a) hide extension-owned objects from the introspected IR before diffing —\n * so the core differ never schedules their drop — and (b) decide whether the\n * artifact is missing and must be created.\n */\nexport type ExtensionArtifactOwner =\n | { readonly kind: \"postgresExtension\"; readonly name: string }\n | { readonly kind: \"column\"; readonly table: string; readonly column: string }\n | { readonly kind: \"index\"; readonly table: string; readonly name: string }\n | {\n readonly kind: \"table\";\n readonly name: string;\n /** Auxiliary tables created alongside (FTS5's `_data`, `_idx`, …). */\n readonly auxiliaryPrefixes?: readonly string[];\n }\n | { readonly kind: \"trigger\"; readonly table: string; readonly name: string };\n\n/**\n * One extension-owned database object with dialect-correct DDL. `create`\n * statements must be idempotent wherever the dialect allows (IF NOT EXISTS),\n * so replays and partial applies converge.\n */\nexport type ExtensionArtifact = {\n /** Stable identity, e.g. \"search:Post:index\". Used in logs and errors. */\n readonly id: string;\n readonly owns: ExtensionArtifactOwner;\n readonly create: readonly string[];\n readonly drop: readonly string[];\n};\n\n/** Context handed to schema-scoped extension hooks. */\nexport type ExtensionSchemaContext = {\n readonly schema: SchemaIR;\n readonly dialect: Dialect;\n readonly provider: Provider;\n /** The extension factory's own options (from config / VibeClient). */\n readonly options: Readonly<Record<string, unknown>>;\n /** Normalized per-model declarations gathered from schema attributes. */\n readonly declarations: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n};\n\nexport type ExtensionMigratePlane = {\n /**\n * Every database object this extension needs for the given schema on the\n * given dialect/provider. Called by `db push` and `migrate generate`.\n * Must throw VIBE_UNSUPPORTED_CAPABILITY for a dialect that cannot ever\n * satisfy the declaration (earliest knowable moment).\n */\n readonly artifacts: (ctx: ExtensionSchemaContext) => readonly ExtensionArtifact[];\n};\n\n// ─── SQL plane ────────────────────────────────────────────────────\n\n/**\n * A neutral bound SQL fragment: literal text, bound parameters and quoted\n * identifiers, in order. @vibeorm/sql renders it (placeholders through\n * ParamCollector, identifiers through dialect.quoteIdent) — extensions never\n * hand-write `$1`/`?` or quotes.\n */\nexport type SqlFragmentPart =\n | string\n | { readonly param: unknown }\n | { readonly ident: readonly string[] };\n\nexport type SqlFragmentSpec = {\n readonly parts: readonly SqlFragmentPart[];\n};\n\n/** A where-operator the extension contributes (`{ name: { similarTo: \"x\" } }`). */\nexport type ExtensionWhereOperator = {\n /** Operator key as written in `where` objects. */\n readonly name: string;\n /**\n * Compile one use to a fragment. `column` is the already-resolved column\n * reference (alias-qualified by the caller via `ident`).\n */\n readonly compile: (ctx: {\n /** Identifier path for the column, e.g. [\"t0\", \"name\"] or [\"name\"]. */\n readonly column: readonly string[];\n readonly operand: unknown;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n }) => { readonly fragment: SqlFragmentSpec } | { readonly error: string };\n};\n\nexport type ExtensionSqlPlane = {\n readonly whereOperators?: readonly ExtensionWhereOperator[];\n};\n\n// ─── Client plane (D9 — baked at generate time) ───────────────────\n\nexport type ExtensionImportSpec = {\n readonly from: string;\n readonly names: readonly string[];\n};\n\n/**\n * What the generator bakes for one scope. `runtimeGlue` is a JS expression\n * (may reference identifiers from `imports`) evaluating to the mount factory\n * the runtime calls with a MountContext; `dts` lines land inside the delegate\n * (model scope) or client (root scope) type body; `dtsTypes` are module-scope\n * declarations emitted once per contribution.\n */\nexport type ExtensionClientContribution = {\n readonly kind: \"method\" | \"namespace\";\n readonly runtimeGlue: string;\n readonly dts: readonly string[];\n readonly dtsTypes?: readonly string[];\n readonly imports?: readonly ExtensionImportSpec[];\n readonly dtsImports?: readonly ExtensionImportSpec[];\n};\n\n/** Generated type names the extension may reference in its d.ts text. */\nexport type ExtensionModelTypeNames = {\n /** The model payload type (e.g. \"Post\"). */\n readonly payload: string;\n readonly whereInput: string;\n};\n\nexport type ExtensionClientPlane = {\n readonly model?: (ctx: {\n readonly model: ModelIR;\n readonly schema: SchemaIR;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n readonly declaration: Readonly<Record<string, unknown>>;\n readonly typeNames: ExtensionModelTypeNames;\n }) => ExtensionClientContribution | null;\n readonly root?: (ctx: {\n readonly schema: SchemaIR;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n readonly declarations: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n }) => ExtensionClientContribution | null;\n};\n\n// ─── Runtime & doctor planes ──────────────────────────────────────\n\n/** Minimal SQL execution surface handed to runtime/doctor hooks. */\nexport type ExtensionSqlExecutor = (params: {\n readonly text: string;\n readonly values?: readonly unknown[];\n}) => Promise<readonly Record<string, unknown>[]>;\n\nexport type ExtensionRuntimePlane = {\n /** Session setup after connect (e.g. SET pg_trgm.similarity_threshold). */\n readonly onConnect?: (ctx: {\n readonly execute: ExtensionSqlExecutor;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n }) => Promise<void>;\n};\n\nexport type ExtensionDoctorCheck = {\n readonly name: string;\n readonly ok: boolean;\n readonly note?: string;\n};\n\nexport type ExtensionDoctorReport = {\n readonly checks: readonly ExtensionDoctorCheck[];\n};\n\nexport type ExtensionDoctorHook = (ctx: {\n readonly execute: ExtensionSqlExecutor;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n}) => Promise<ExtensionDoctorReport>;\n\n// ─── The extension ────────────────────────────────────────────────\n\n/**\n * A VibeORM extension instance — what an extension factory (`search()`,\n * `vector({ dims })`) returns and what config/VibeClient carry.\n */\nexport type VibeExtension = {\n /** Unique name; the ONLY identifier the extension may claim (D9). */\n readonly name: string;\n /** Embedded in the generated-client manifest for staleness checks. */\n readonly version: string;\n /** The factory's raw options — hashed into the manifest. */\n readonly options: Readonly<Record<string, unknown>>;\n /** Database extension requirements per provider (null = built in). */\n readonly requires?: Partial<\n Record<Provider, { readonly extension: string; readonly min?: string } | null>\n >;\n readonly schema?: {\n readonly modelAttributes?: readonly ExtensionModelAttribute[];\n readonly fieldTypes?: readonly ExtensionFieldType[];\n /** Index kinds this extension registers (informational). */\n readonly indexKinds?: readonly string[];\n /** Replication-class: valid with zero schema attributes. */\n readonly configOnly?: boolean;\n };\n readonly migrate?: ExtensionMigratePlane;\n readonly sql?: ExtensionSqlPlane;\n readonly client?: ExtensionClientPlane;\n readonly runtime?: ExtensionRuntimePlane;\n readonly doctor?: ExtensionDoctorHook;\n};\n\n/** Manifest entry embedded in the generated client (extensions.md §3.2). */\nexport type ExtensionManifestEntry = {\n readonly name: string;\n readonly version: string;\n readonly optionsHash: string;\n};\n\n// ─── Stable hashing (manifest) ────────────────────────────────────\n\nfunction stableSerialize(value: unknown): string {\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"undefined\";\n if (Array.isArray(value)) return `[${value.map(stableSerialize).join(\",\")}]`;\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entryValue]) => `${JSON.stringify(key)}:${stableSerialize(entryValue)}`);\n return `{${entries.join(\",\")}}`;\n}\n\n/**\n * Deterministic hash of an extension's options for the client manifest.\n * FNV-1a 32-bit over a key-sorted serialization — stable across processes.\n */\nexport function extensionOptionsHash(params: {\n options: Readonly<Record<string, unknown>>;\n}): string {\n const text = stableSerialize(params.options);\n let hash = 0x811c9dc5;\n for (let index = 0; index < text.length; index += 1) {\n hash ^= text.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(16).padStart(8, \"0\");\n}\n\n/** Build the manifest entry for one extension instance. */\nexport function extensionManifestEntry(params: { extension: VibeExtension }): ExtensionManifestEntry {\n const { extension } = params;\n return {\n name: extension.name,\n version: extension.version,\n optionsHash: extensionOptionsHash({ options: extension.options }),\n };\n}\n\n// ─── defineExtension ──────────────────────────────────────────────\n\nconst EXTENSION_NAME_PATTERN = /^[a-z][a-zA-Z0-9]*$/;\n\n/**\n * Validate and freeze an extension definition. Userland extensions use this\n * exactly like tier 1 — nothing in @vibeorm/extensions is privileged.\n *\n * @example\n * export function trgm(options: TrgmOptions = {}): VibeExtension {\n * return defineExtension({ name: \"trgm\", version: VERSION, options, ... });\n * }\n */\nexport function defineExtension(extension: VibeExtension): VibeExtension {\n const { name } = extension;\n if (!EXTENSION_NAME_PATTERN.test(name)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension name \"${name}\" is invalid — must match ${EXTENSION_NAME_PATTERN} (it becomes a client identifier)`,\n meta: { name },\n });\n }\n if (RESERVED_DELEGATE_NAMES.includes(name)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension name \"${name}\" collides with a core delegate method`,\n meta: { name },\n });\n }\n if (RESERVED_CLIENT_NAMES.includes(`$${name}`)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension name \"${name}\" collides with the core client method \"$${name}\"`,\n meta: { name },\n });\n }\n return Object.freeze(extension);\n}\n\n// ─── Registry ─────────────────────────────────────────────────────\n\n/** Configured extensions, indexed for the parser/dsl/generator/migrate. */\nexport type ExtensionRegistry = {\n readonly extensions: readonly VibeExtension[];\n readonly byName: ReadonlyMap<string, VibeExtension>;\n /** Model-attribute name (without @@) → owning extension + spec. */\n readonly modelAttributes: ReadonlyMap<\n string,\n { readonly extension: VibeExtension; readonly attribute: ExtensionModelAttribute }\n >;\n /** Field-type name → owning extension + spec. */\n readonly fieldTypes: ReadonlyMap<\n string,\n { readonly extension: VibeExtension; readonly fieldType: ExtensionFieldType }\n >;\n};\n\n/**\n * Index a configured extension list. Throws VIBE_CONFIG on duplicate\n * extension names and on attribute/type claims that collide across extensions.\n */\nexport function buildExtensionRegistry(params: {\n extensions: readonly VibeExtension[];\n}): ExtensionRegistry {\n const byName = new Map<string, VibeExtension>();\n const modelAttributes = new Map<\n string,\n { extension: VibeExtension; attribute: ExtensionModelAttribute }\n >();\n const fieldTypes = new Map<string, { extension: VibeExtension; fieldType: ExtensionFieldType }>();\n\n for (const extension of params.extensions) {\n if (byName.has(extension.name)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `duplicate extension name \"${extension.name}\" in the configured extension list`,\n meta: { name: extension.name },\n });\n }\n byName.set(extension.name, extension);\n\n for (const attribute of extension.schema?.modelAttributes ?? []) {\n const existing = modelAttributes.get(attribute.name);\n if (existing !== undefined) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `model attribute \"@@${attribute.name}\" is claimed by both \"${existing.extension.name}\" and \"${extension.name}\"`,\n meta: { attribute: attribute.name },\n });\n }\n modelAttributes.set(attribute.name, { extension, attribute });\n }\n\n for (const fieldType of extension.schema?.fieldTypes ?? []) {\n const existing = fieldTypes.get(fieldType.name);\n if (existing !== undefined) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `field type \"${fieldType.name}\" is claimed by both \"${existing.extension.name}\" and \"${extension.name}\"`,\n meta: { fieldType: fieldType.name },\n });\n }\n fieldTypes.set(fieldType.name, { extension, fieldType });\n }\n }\n\n return { extensions: params.extensions, byName, modelAttributes, fieldTypes };\n}\n\n/** An empty registry — the default when no extensions are configured. */\nexport const EMPTY_EXTENSION_REGISTRY: ExtensionRegistry = buildExtensionRegistry({\n extensions: [],\n});\n\n// ─── IR access helpers ────────────────────────────────────────────\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Merge two declaration fragments for the same (extension, model) — e.g. a\n * field-type lowering plus a model attribute. One level deep: object values\n * merge shallowly, everything else is last-wins. Used identically by the\n * .prisma parser and the TS DSL so both sources produce byte-identical IR.\n */\nexport function mergeExtensionDeclarations(params: {\n base: Readonly<Record<string, unknown>>;\n next: Readonly<Record<string, unknown>>;\n}): Record<string, unknown> {\n const out: Record<string, unknown> = { ...params.base };\n for (const [key, value] of Object.entries(params.next)) {\n const existing = out[key];\n out[key] = isPlainObject(existing) && isPlainObject(value) ? { ...existing, ...value } : value;\n }\n return out;\n}\n\n/**\n * Per-model declarations one extension gathered from schema attributes,\n * read back out of SchemaIR.extensions. Parser and DSL both store them as\n * `{ models: { [modelName]: declaration } }` in ExtensionDeclIR.options.\n */\nexport function extensionDeclarations(params: {\n schema: SchemaIR;\n name: string;\n}): Readonly<Record<string, Readonly<Record<string, unknown>>>> {\n const decl = params.schema.extensions.find((entry) => entry.name === params.name);\n if (decl === undefined) return {};\n const models = decl.options[\"models\"];\n if (models === null || typeof models !== \"object\" || Array.isArray(models)) return {};\n return models as Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n",
10
+ "/**\n * Reserved names on the generated client surface.\n *\n * Extensions claim exactly one identifier per scope (plan D9): a method or\n * namespace on opted-in model delegates, and/or a root `$name` namespace.\n * The generator rejects any extension whose name collides with these lists.\n * Snapshot-tested so the core can never silently grow into an extension's name.\n */\n\n// ─── Model delegate methods ───────────────────────────────────────\n\nexport const RESERVED_DELEGATE_NAMES: readonly string[] = [\n \"findMany\",\n \"findFirst\",\n \"findUnique\",\n \"findFirstOrThrow\",\n \"findUniqueOrThrow\",\n \"create\",\n \"createMany\",\n \"createManyAndReturn\",\n \"update\",\n \"updateMany\",\n \"updateManyAndReturn\",\n \"upsert\",\n \"delete\",\n \"deleteMany\",\n \"count\",\n \"aggregate\",\n \"groupBy\",\n \"fields\",\n];\n\n// ─── Client $-methods ─────────────────────────────────────────────\n\nexport const RESERVED_CLIENT_NAMES: readonly string[] = [\n \"$connect\",\n \"$disconnect\",\n \"$transaction\",\n \"$querySql\",\n \"$executeSql\",\n \"$queryRaw\",\n \"$queryRawUnsafe\",\n \"$executeRaw\",\n \"$executeRawUnsafe\",\n \"$on\",\n \"$extends\",\n \"$defineView\",\n \"$withPolicy\",\n \"$bypassPolicy\",\n \"$scoped\",\n \"$readOnly\",\n];\n\n// ─── Reserved column-name prefix ─────────────────────────────────\n\n/**\n * Column-name prefix reserved for VibeORM's own result projections — the M2M\n * join loader's `__vibe_parent` stitch key today, hidden order/stitch fields\n * generally. A user column with this prefix would collide with a projection\n * alias and be silently misgrouped or stripped, so schema validation refuses\n * it (`reserved-column-prefix`). Unreachable from `.prisma` field-name\n * grammar, reachable via `@map` or hand-built IR. Wave-C sqlite review,\n * finding 3.\n */\nexport const RESERVED_COLUMN_PREFIX: string = \"__vibe_\";\n\n// ─── Guards ───────────────────────────────────────────────────────\n\nexport function isReservedDelegateName(params: { name: string }): boolean {\n return RESERVED_DELEGATE_NAMES.includes(params.name);\n}\n\n/** Checks the `$`-prefixed form an extension's root namespace would occupy. */\nexport function isReservedClientName(params: { name: string }): boolean {\n const withPrefix = params.name.startsWith(\"$\") ? params.name : `$${params.name}`;\n return RESERVED_CLIENT_NAMES.includes(withPrefix);\n}\n",
11
+ "/**\n * Extension framework contract (plan §10, extensions.md).\n *\n * Hook types live HERE so every package can consume them without cycles:\n * extensions implement them (tier 1 in @vibeorm/extensions), parser/dsl route\n * schema attributes through the registry, migrate applies artifact DDL,\n * the generator bakes client surfaces (D9), and the runtime mounts them.\n *\n * All hook signatures are dependency-free on purpose: DDL is dialect-correct\n * SQL text (never migrate step objects), SQL fragments are neutral part lists\n * (@vibeorm/sql renders them), and client contributions are JS/d.ts text.\n */\n\nimport { VibeError } from \"./errors.ts\";\nimport type { SqlObjectDefinition } from \"./migration-objects.ts\";\nimport type { Dialect, ModelIR, Provider, SchemaIR } from \"./ir.ts\";\nimport { RESERVED_CLIENT_NAMES, RESERVED_DELEGATE_NAMES } from \"./reserved.ts\";\n\n// ─── Attribute parsing (schema plane) ─────────────────────────────\n\n/** Scalar-ish values an extension attribute argument may carry. */\nexport type ExtensionAttributeValue =\n | string\n | number\n | boolean\n | readonly string[]\n | readonly number[];\n\n/**\n * One occurrence of an extension attribute, normalized identically by the\n * .prisma parser and the TS DSL (source equivalence is tested — LEARNINGS F2).\n */\nexport type ExtensionAttributeArgs = {\n /** The positional field-list argument (`[title, body]`), when present. */\n readonly fields?: readonly string[];\n /** Named arguments (`name: \"x\"`, `weights: [2, 1]`, `dims: 1536`). */\n readonly named: Readonly<Record<string, ExtensionAttributeValue>>;\n};\n\n/** A model-level attribute the extension registers (`@@search(...)`). */\nexport type ExtensionModelAttribute = {\n /** Attribute name without the `@@` prefix. */\n readonly name: string;\n /**\n * Validate and normalize one occurrence into declaration data. Returning\n * `{ error }` rejects the schema with VIBE_SCHEMA_INVALID at parse time.\n */\n readonly parse: (ctx: {\n readonly model: string;\n readonly args: ExtensionAttributeArgs;\n /** Scalar/enum field names on the model, for validation. */\n readonly fieldNames: readonly string[];\n }) =>\n | { readonly declaration: Readonly<Record<string, unknown>> }\n | { readonly error: string };\n};\n\n/** A column type the extension registers (`embedding Vector(1536)`). */\nexport type ExtensionFieldType = {\n /** Type name as written in the schema — e.g. \"Vector\". */\n readonly name: string;\n /**\n * Lower one field to a database-native column type. The field lands in the\n * IR exactly like `Unsupported(\"<nativeType>\")` (kept for DDL, excluded from\n * the core queryable surface); the declaration is merged into the\n * extension's ExtensionDeclIR for downstream planes.\n */\n readonly lower: (ctx: {\n readonly model: string;\n readonly field: string;\n /** Positional type arguments (`Vector(1536)` → [1536]). */\n readonly args: readonly (string | number)[];\n }) =>\n | {\n readonly nativeType: string;\n readonly declaration?: Readonly<Record<string, unknown>>;\n }\n | { readonly error: string };\n};\n\n// ─── Migrate plane ────────────────────────────────────────────────\n\n/**\n * The database object an artifact owns. Migrate uses this identity to\n * (a) hide extension-owned objects from the introspected IR before diffing —\n * so the core differ never schedules their drop — and (b) decide whether the\n * artifact is missing and must be created.\n */\nexport type ExtensionArtifactOwner =\n | { readonly kind: \"postgresExtension\"; readonly name: string }\n | { readonly kind: \"column\"; readonly table: string; readonly column: string }\n | { readonly kind: \"index\"; readonly table: string; readonly name: string }\n | {\n readonly kind: \"table\";\n readonly name: string;\n /** Auxiliary tables created alongside (FTS5's `_data`, `_idx`, …). */\n readonly auxiliaryPrefixes?: readonly string[];\n }\n | { readonly kind: \"trigger\"; readonly table: string; readonly name: string };\n\n/**\n * One extension-owned database object with dialect-correct DDL. `create`\n * statements must be idempotent wherever the dialect allows (IF NOT EXISTS),\n * so replays and partial applies converge.\n */\nexport type ExtensionArtifact = {\n /** Stable identity, e.g. \"search:Post:index\". Used in logs and errors. */\n readonly id: string;\n readonly owns: ExtensionArtifactOwner;\n /** Independent definition enables verification through the legacy compatibility path. */\n readonly expected?: SqlObjectDefinition;\n readonly create: readonly string[];\n readonly drop: readonly string[];\n};\n\n/** Context handed to schema-scoped extension hooks. */\nexport type ExtensionSchemaContext = {\n readonly schema: SchemaIR;\n readonly dialect: Dialect;\n readonly provider: Provider;\n /** The extension factory's own options (from config / VibeClient). */\n readonly options: Readonly<Record<string, unknown>>;\n /** Normalized per-model declarations gathered from schema attributes. */\n readonly declarations: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n};\n\nexport type ExtensionMigratePlane = {\n /**\n * Every database object this extension needs for the given schema on the\n * given dialect/provider. Called by `db push` and `migrate generate`.\n * Must throw VIBE_UNSUPPORTED_CAPABILITY for a dialect that cannot ever\n * satisfy the declaration (earliest knowable moment).\n */\n readonly artifacts: (ctx: ExtensionSchemaContext) => readonly ExtensionArtifact[];\n};\n\n// ─── SQL plane ────────────────────────────────────────────────────\n\n/**\n * A neutral bound SQL fragment: literal text, bound parameters and quoted\n * identifiers, in order. @vibeorm/sql renders it (placeholders through\n * ParamCollector, identifiers through dialect.quoteIdent) — extensions never\n * hand-write `$1`/`?` or quotes.\n */\nexport type SqlFragmentPart =\n | string\n | { readonly param: unknown }\n | { readonly ident: readonly string[] };\n\nexport type SqlFragmentSpec = {\n readonly parts: readonly SqlFragmentPart[];\n};\n\n/** A where-operator the extension contributes (`{ name: { similarTo: \"x\" } }`). */\nexport type ExtensionWhereOperator = {\n /** Operator key as written in `where` objects. */\n readonly name: string;\n /**\n * Compile one use to a fragment. `column` is the already-resolved column\n * reference (alias-qualified by the caller via `ident`).\n */\n readonly compile: (ctx: {\n /** Identifier path for the column, e.g. [\"t0\", \"name\"] or [\"name\"]. */\n readonly column: readonly string[];\n readonly operand: unknown;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n }) => { readonly fragment: SqlFragmentSpec } | { readonly error: string };\n};\n\nexport type ExtensionSqlPlane = {\n readonly whereOperators?: readonly ExtensionWhereOperator[];\n};\n\n// ─── Client plane (D9 — baked at generate time) ───────────────────\n\nexport type ExtensionImportSpec = {\n readonly from: string;\n readonly names: readonly string[];\n};\n\n/**\n * What the generator bakes for one scope. `runtimeGlue` is a JS expression\n * (may reference identifiers from `imports`) evaluating to the mount factory\n * the runtime calls with a MountContext; `dts` lines land inside the delegate\n * (model scope) or client (root scope) type body; `dtsTypes` are module-scope\n * declarations emitted once per contribution.\n */\nexport type ExtensionClientContribution = {\n readonly kind: \"method\" | \"namespace\";\n /**\n * What a READ-ONLY client (`$readOnly`) may call on this surface. `true`\n * classifies a `kind: \"method\"` contribution as reading nothing but rows; a\n * list names the members of a `kind: \"namespace\"` contribution that only\n * read (`[\"nearest\"]` — `set` writes). ABSENT means denied: an unclassified\n * extension surface never appears on a read-only client, in the generated\n * type or at runtime.\n */\n readonly readOnly?: true | readonly string[];\n readonly runtimeGlue: string;\n readonly dts: readonly string[];\n readonly dtsTypes?: readonly string[];\n readonly imports?: readonly ExtensionImportSpec[];\n readonly dtsImports?: readonly ExtensionImportSpec[];\n};\n\n/** Generated type names the extension may reference in its d.ts text. */\nexport type ExtensionModelTypeNames = {\n /** The model payload type (e.g. \"Post\"). */\n readonly payload: string;\n readonly whereInput: string;\n};\n\nexport type ExtensionClientPlane = {\n readonly model?: (ctx: {\n readonly model: ModelIR;\n readonly schema: SchemaIR;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n readonly declaration: Readonly<Record<string, unknown>>;\n readonly typeNames: ExtensionModelTypeNames;\n }) => ExtensionClientContribution | null;\n readonly root?: (ctx: {\n readonly schema: SchemaIR;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n readonly declarations: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n }) => ExtensionClientContribution | null;\n};\n\n// ─── Runtime & doctor planes ──────────────────────────────────────\n\n/** Minimal SQL execution surface handed to runtime/doctor hooks. */\nexport type ExtensionSqlExecutor = (params: {\n readonly text: string;\n readonly values?: readonly unknown[];\n}) => Promise<readonly Record<string, unknown>[]>;\n\nexport type ExtensionRuntimePlane = {\n /** Session setup after connect (e.g. SET pg_trgm.similarity_threshold). */\n readonly onConnect?: (ctx: {\n readonly execute: ExtensionSqlExecutor;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n }) => Promise<void>;\n};\n\nexport type ExtensionDoctorCheck = {\n readonly name: string;\n readonly ok: boolean;\n readonly note?: string;\n};\n\nexport type ExtensionDoctorReport = {\n readonly checks: readonly ExtensionDoctorCheck[];\n};\n\nexport type ExtensionDoctorHook = (ctx: {\n readonly execute: ExtensionSqlExecutor;\n readonly dialect: Dialect;\n readonly provider: Provider;\n readonly options: Readonly<Record<string, unknown>>;\n}) => Promise<ExtensionDoctorReport>;\n\n// ─── The extension ────────────────────────────────────────────────\n\n/**\n * A VibeORM extension instance — what an extension factory (`search()`,\n * `vector({ dims })`) returns and what config/VibeClient carry.\n */\nexport type VibeExtension = {\n /** Unique name; the ONLY identifier the extension may claim (D9). */\n readonly name: string;\n /** Embedded in the generated-client manifest for staleness checks. */\n readonly version: string;\n /** The factory's raw options — hashed into the manifest. */\n readonly options: Readonly<Record<string, unknown>>;\n /** Database extension requirements per provider (null = built in). */\n readonly requires?: Partial<\n Record<Provider, { readonly extension: string; readonly min?: string } | null>\n >;\n readonly schema?: {\n readonly modelAttributes?: readonly ExtensionModelAttribute[];\n readonly fieldTypes?: readonly ExtensionFieldType[];\n /** Index kinds this extension registers (informational). */\n readonly indexKinds?: readonly string[];\n /** Replication-class: valid with zero schema attributes. */\n readonly configOnly?: boolean;\n };\n readonly migrate?: ExtensionMigratePlane;\n readonly sql?: ExtensionSqlPlane;\n readonly client?: ExtensionClientPlane;\n readonly runtime?: ExtensionRuntimePlane;\n readonly doctor?: ExtensionDoctorHook;\n};\n\n/** Manifest entry embedded in the generated client (extensions.md §3.2). */\nexport type ExtensionManifestEntry = {\n readonly name: string;\n readonly version: string;\n readonly optionsHash: string;\n};\n\n// ─── Stable hashing (manifest) ────────────────────────────────────\n\nfunction stableSerialize(value: unknown): string {\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"undefined\";\n if (Array.isArray(value)) return `[${value.map(stableSerialize).join(\",\")}]`;\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entryValue]) => `${JSON.stringify(key)}:${stableSerialize(entryValue)}`);\n return `{${entries.join(\",\")}}`;\n}\n\n/**\n * Deterministic hash of an extension's options for the client manifest.\n * FNV-1a 32-bit over a key-sorted serialization — stable across processes.\n */\nexport function extensionOptionsHash(params: {\n options: Readonly<Record<string, unknown>>;\n}): string {\n const text = stableSerialize(params.options);\n let hash = 0x811c9dc5;\n for (let index = 0; index < text.length; index += 1) {\n hash ^= text.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(16).padStart(8, \"0\");\n}\n\n/** Build the manifest entry for one extension instance. */\nexport function extensionManifestEntry(params: { extension: VibeExtension }): ExtensionManifestEntry {\n const { extension } = params;\n return {\n name: extension.name,\n version: extension.version,\n optionsHash: extensionOptionsHash({ options: extension.options }),\n };\n}\n\n// ─── defineExtension ──────────────────────────────────────────────\n\nconst EXTENSION_NAME_PATTERN = /^[a-z][a-zA-Z0-9]*$/;\n\n/**\n * Validate and freeze an extension definition. Userland extensions use this\n * exactly like tier 1 — nothing in @vibeorm/extensions is privileged.\n *\n * @example\n * export function trgm(options: TrgmOptions = {}): VibeExtension {\n * return defineExtension({ name: \"trgm\", version: VERSION, options, ... });\n * }\n */\nexport function defineExtension(extension: VibeExtension): VibeExtension {\n const { name } = extension;\n if (!EXTENSION_NAME_PATTERN.test(name)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension name \"${name}\" is invalid — must match ${EXTENSION_NAME_PATTERN} (it becomes a client identifier)`,\n meta: { name },\n });\n }\n if (RESERVED_DELEGATE_NAMES.includes(name)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension name \"${name}\" collides with a core delegate method`,\n meta: { name },\n });\n }\n if (RESERVED_CLIENT_NAMES.includes(`$${name}`)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `extension name \"${name}\" collides with the core client method \"$${name}\"`,\n meta: { name },\n });\n }\n return Object.freeze(extension);\n}\n\n// ─── Registry ─────────────────────────────────────────────────────\n\n/** Configured extensions, indexed for the parser/dsl/generator/migrate. */\nexport type ExtensionRegistry = {\n readonly extensions: readonly VibeExtension[];\n readonly byName: ReadonlyMap<string, VibeExtension>;\n /** Model-attribute name (without @@) → owning extension + spec. */\n readonly modelAttributes: ReadonlyMap<\n string,\n { readonly extension: VibeExtension; readonly attribute: ExtensionModelAttribute }\n >;\n /** Field-type name → owning extension + spec. */\n readonly fieldTypes: ReadonlyMap<\n string,\n { readonly extension: VibeExtension; readonly fieldType: ExtensionFieldType }\n >;\n};\n\n/**\n * Index a configured extension list. Throws VIBE_CONFIG on duplicate\n * extension names and on attribute/type claims that collide across extensions.\n */\nexport function buildExtensionRegistry(params: {\n extensions: readonly VibeExtension[];\n}): ExtensionRegistry {\n const byName = new Map<string, VibeExtension>();\n const modelAttributes = new Map<\n string,\n { extension: VibeExtension; attribute: ExtensionModelAttribute }\n >();\n const fieldTypes = new Map<string, { extension: VibeExtension; fieldType: ExtensionFieldType }>();\n\n for (const extension of params.extensions) {\n if (byName.has(extension.name)) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `duplicate extension name \"${extension.name}\" in the configured extension list`,\n meta: { name: extension.name },\n });\n }\n byName.set(extension.name, extension);\n\n for (const attribute of extension.schema?.modelAttributes ?? []) {\n const existing = modelAttributes.get(attribute.name);\n if (existing !== undefined) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `model attribute \"@@${attribute.name}\" is claimed by both \"${existing.extension.name}\" and \"${extension.name}\"`,\n meta: { attribute: attribute.name },\n });\n }\n modelAttributes.set(attribute.name, { extension, attribute });\n }\n\n for (const fieldType of extension.schema?.fieldTypes ?? []) {\n const existing = fieldTypes.get(fieldType.name);\n if (existing !== undefined) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `field type \"${fieldType.name}\" is claimed by both \"${existing.extension.name}\" and \"${extension.name}\"`,\n meta: { fieldType: fieldType.name },\n });\n }\n fieldTypes.set(fieldType.name, { extension, fieldType });\n }\n }\n\n return { extensions: params.extensions, byName, modelAttributes, fieldTypes };\n}\n\n/** An empty registry — the default when no extensions are configured. */\nexport const EMPTY_EXTENSION_REGISTRY: ExtensionRegistry = buildExtensionRegistry({\n extensions: [],\n});\n\n// ─── IR access helpers ────────────────────────────────────────────\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Merge two declaration fragments for the same (extension, model) — e.g. a\n * field-type lowering plus a model attribute. One level deep: object values\n * merge shallowly, everything else is last-wins. Used identically by the\n * .prisma parser and the TS DSL so both sources produce byte-identical IR.\n */\nexport function mergeExtensionDeclarations(params: {\n base: Readonly<Record<string, unknown>>;\n next: Readonly<Record<string, unknown>>;\n}): Record<string, unknown> {\n const out: Record<string, unknown> = { ...params.base };\n for (const [key, value] of Object.entries(params.next)) {\n const existing = out[key];\n out[key] = isPlainObject(existing) && isPlainObject(value) ? { ...existing, ...value } : value;\n }\n return out;\n}\n\n/**\n * Per-model declarations one extension gathered from schema attributes,\n * read back out of SchemaIR.extensions. Parser and DSL both store them as\n * `{ models: { [modelName]: declaration } }` in ExtensionDeclIR.options.\n */\nexport function extensionDeclarations(params: {\n schema: SchemaIR;\n name: string;\n}): Readonly<Record<string, Readonly<Record<string, unknown>>>> {\n const decl = params.schema.extensions.find((entry) => entry.name === params.name);\n if (decl === undefined) return {};\n const models = decl.options[\"models\"];\n if (models === null || typeof models !== \"object\" || Array.isArray(models)) return {};\n return models as Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n",
10
12
  "/**\n * Computed fields — config-declared derived properties on query results.\n *\n * The declaration lives in `vibeorm.config.ts` (so the generator can write the\n * field's TYPE into the payload `.d.ts` verbatim — rules 1/2: no inference),\n * and the SAME spec object is passed to `VibeClient({ computed })`, which runs\n * the `compute` functions at row materialization. The generated client bakes a\n * manifest of `{ model, field, type, needs }`; drift between that manifest and\n * the live config throws `VIBE_STALE_CLIENT` at construction.\n *\n * Deliberately NOT part of the Schema IR: the IR is the only schema currency\n * (rule 9) and migrate/introspection/db-push must never see a presentation-only\n * field — and compute functions would not survive IR serialization anyway.\n */\n\nimport { VibeError } from \"./errors.ts\";\nimport type { SchemaIR } from \"./ir.ts\";\nimport { RESERVED_COLUMN_PREFIX } from \"./reserved.ts\";\n\n// ─── Types ────────────────────────────────────────────────────────\n\n/** One computed field: an explicit result type, the scalars it reads, and the derivation. */\nexport type ComputedFieldSpec = {\n /** TypeScript type written VERBATIM into the generated payload (`\"string\"`, `\"number | null\"`). */\n readonly type: string;\n /**\n * Scalar fields of the model the compute reads. They are fetched whenever\n * the computed field is selected — even when not selected themselves — and\n * stripped from the result afterwards (the stitch-key pattern).\n */\n readonly needs: readonly string[];\n /**\n * Synchronous derivation. Receives the row with every `needs` scalar\n * decoded; the return value is attached under the computed field's name.\n */\n readonly compute: (row: Record<string, unknown>) => unknown;\n};\n\n/** Computed-field config: IR model name (`\"User\"`) → field name → spec. */\nexport type ComputedConfig = Readonly<Record<string, Readonly<Record<string, ComputedFieldSpec>>>>;\n\n/** What the generator bakes per computed field for the staleness gate. */\nexport type ComputedManifestEntry = {\n readonly model: string;\n readonly field: string;\n readonly type: string;\n readonly needs: readonly string[];\n};\n\n// ─── Manifest ─────────────────────────────────────────────────────\n\n/** The baked manifest for a config — model/field sorted, so output is deterministic. */\nexport function buildComputedManifest(params: { computed: ComputedConfig }): readonly ComputedManifestEntry[] {\n const { computed } = params;\n const entries: ComputedManifestEntry[] = [];\n for (const modelName of Object.keys(computed).sort()) {\n const fields = computed[modelName] ?? {};\n for (const fieldName of Object.keys(fields).sort()) {\n const spec = fields[fieldName] as ComputedFieldSpec;\n entries.push({ model: modelName, field: fieldName, type: spec.type, needs: [...spec.needs] });\n }\n }\n return entries;\n}\n\n// ─── Validation ───────────────────────────────────────────────────\n\nconst IDENTIFIER_PATTERN: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/**\n * Validate a computed-field config against a schema: models exist (by IR\n * name), field names are collision-free identifiers, `needs` name queryable\n * scalar fields, and each spec is structurally complete. Every problem is\n * reported at once in ONE `VIBE_CONFIG` error.\n */\nexport function validateComputedConfig(params: { schema: SchemaIR; computed: ComputedConfig }): void {\n const { schema, computed } = params;\n const problems: string[] = [];\n const modelByName = new Map(schema.models.map((model) => [model.name, model]));\n\n for (const [modelName, fields] of Object.entries(computed)) {\n const model = modelByName.get(modelName);\n if (model === undefined) {\n const byClientName = schema.models.find(\n (candidate) => candidate.name.charAt(0).toLowerCase() + candidate.name.slice(1) === modelName,\n );\n problems.push(\n byClientName === undefined\n ? `unknown model \"${modelName}\"`\n : `unknown model \"${modelName}\" — computed is keyed by MODEL name (\"${byClientName.name}\"), not client name`,\n );\n continue;\n }\n if (fields === null || typeof fields !== \"object\" || Array.isArray(fields)) {\n problems.push(`computed.${modelName} must be an object of field specs`);\n continue;\n }\n for (const [fieldName, spec] of Object.entries(fields)) {\n const at = `${modelName}.${fieldName}`;\n if (!IDENTIFIER_PATTERN.test(fieldName)) {\n problems.push(`\"${at}\" is not a valid identifier`);\n } else if (fieldName.startsWith(RESERVED_COLUMN_PREFIX)) {\n problems.push(`\"${at}\" uses the reserved \"${RESERVED_COLUMN_PREFIX}\" prefix`);\n }\n if (fieldName === \"_count\") problems.push(`\"${at}\" collides with the _count projection`);\n if (model.fields.some((field) => field.name === fieldName)) {\n problems.push(`\"${at}\" collides with a schema field of the same name`);\n }\n if (model.relations.some((relation) => relation.name === fieldName)) {\n problems.push(`\"${at}\" collides with a relation of the same name`);\n }\n if (spec === null || typeof spec !== \"object\") {\n problems.push(`\"${at}\" must be a spec object ({ type, needs, compute })`);\n continue;\n }\n if (typeof spec.type !== \"string\" || spec.type.trim().length === 0) {\n problems.push(`\"${at}\".type must be a non-empty TypeScript type string`);\n }\n if (typeof spec.compute !== \"function\") {\n problems.push(`\"${at}\".compute must be a function`);\n }\n if (!Array.isArray(spec.needs)) {\n problems.push(`\"${at}\".needs must be an array of scalar field names`);\n continue;\n }\n for (const need of spec.needs) {\n if (typeof need !== \"string\") {\n problems.push(`\"${at}\".needs entries must be strings`);\n continue;\n }\n const target = model.fields.find((field) => field.name === need);\n if (target === undefined) {\n problems.push(\n model.relations.some((relation) => relation.name === need)\n ? `\"${at}\".needs names the relation \"${need}\" — needs are scalar fields only`\n : `\"${at}\".needs names \"${need}\", which is not a field of ${modelName}`,\n );\n } else if (target.isUnsupported === true) {\n problems.push(`\"${at}\".needs names \"${need}\", an Unsupported(...) column — those are never queryable`);\n }\n }\n }\n }\n\n if (problems.length > 0) {\n throw new VibeError({\n code: \"VIBE_CONFIG\",\n message: `invalid computed-field config — ${problems.join(\"; \")}`,\n meta: { problems },\n });\n }\n}\n",
11
13
  "import { VibeError } from \"./errors.ts\";\nimport { isEnumType } from \"./ir.ts\";\nimport type { FieldType } from \"./ir.ts\";\nimport { exactIntegerLiteral } from \"./prisma-literal.ts\";\n\n/** JSON text with deterministic object keys; refuses values JSON would silently drop. */\nexport function serializeJsonDefault(params: { value: unknown }): string {\n const ancestors = new Set<object>();\n const visit = (value: unknown): string => {\n if (value === null) return \"null\";\n if (typeof value === \"string\" || typeof value === \"boolean\") return JSON.stringify(value);\n if (typeof value === \"number\" && Number.isFinite(value)) return JSON.stringify(value);\n if (typeof value !== \"object\" || value === null || ancestors.has(value)) {\n throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"JSON defaults require finite, acyclic JSON values\" });\n }\n ancestors.add(value);\n let text: string;\n if (Array.isArray(value)) {\n text = `[${Array.from(value, visit).join(\",\")}]`;\n } else {\n if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {\n throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"JSON defaults require plain objects, not class instances\" });\n }\n if (Reflect.ownKeys(value).some((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)!;\n return typeof key !== \"string\" || !descriptor.enumerable || !(\"value\" in descriptor);\n })) {\n throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"JSON defaults require enumerable data properties, without symbols or accessors\" });\n }\n text = `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${visit(Object.getOwnPropertyDescriptor(value, key)!.value)}`).join(\",\")}}`;\n }\n ancestors.delete(value);\n return text;\n };\n return visit(params.value);\n}\n\n/** Normalize and validate a scalar-list default without converting wide integers to doubles. */\nexport function scalarListDefault(params: { type: FieldType; values: readonly unknown[] }): readonly (string | number | boolean)[] {\n const { type } = params;\n return Array.from(params.values, (value) => {\n if (type === \"BigInt\" && typeof value === \"bigint\") return exactIntegerLiteral({ text: value.toString() });\n if (type === \"BigInt\" && typeof value === \"string\" && /^-?\\d+$/.test(value)) return exactIntegerLiteral({ text: value });\n if ((type === \"Int\" || type === \"BigInt\") && typeof value === \"number\" && Number.isSafeInteger(value) &&\n (type !== \"Int\" || (value >= -2147483648 && value <= 2147483647))) return value;\n if (type === \"Float\" && typeof value === \"number\" && Number.isFinite(value)) return value;\n if (type === \"Boolean\" && typeof value === \"boolean\") return value;\n if ((type === \"String\" || isEnumType(type)) && typeof value === \"string\") return value;\n if (type === \"Decimal\" && (typeof value === \"string\" || typeof value === \"number\") && /^-?\\d+(\\.\\d+)?$/.test(String(value))) {\n const text = String(value);\n const [integer, fraction = \"\"] = text.replace(/^-/, \"\").split(\".\");\n const whole = BigInt(integer!).toString();\n const tail = fraction.replace(/0+$/, \"\");\n const sign = text.startsWith(\"-\") && (whole !== \"0\" || tail !== \"\") ? \"-\" : \"\";\n return `${sign}${whole}${tail === \"\" ? \"\" : `.${tail}`}`;\n }\n if (type === \"Json\" && typeof value === \"string\") return value;\n if (type === \"DateTime\") {\n const text = value instanceof Date && Number.isFinite(value.getTime()) ? value.toISOString() : value;\n if (typeof text === \"string\") {\n // PostgreSQL re-serializes dates with spaces and short offsets. Preserve\n // microseconds instead of passing the fractional value through Date.\n const match = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(?:\\.(\\d{1,6}))?(Z|[+-]\\d{2}(?::?\\d{2})?)?$/.exec(text);\n const timestamp = match === null ? NaN : Date.parse(match[2] === undefined ? `${text}Z` : text);\n if (Number.isFinite(timestamp)) return new Date(timestamp).toISOString().replace(/\\.\\d{3}Z$/, `.${(match?.[1] ?? \"\").padEnd(6, \"0\")}Z`);\n }\n }\n if (type === \"Bytes\" && value instanceof Uint8Array) return `\\\\x${Array.from(value, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\")}`;\n if (type === \"Bytes\" && typeof value === \"string\" && /^\\\\x(?:[0-9a-f]{2})*$/i.test(value)) return value.toLowerCase();\n throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `Invalid scalar-list default element for ${isEnumType(type) ? type.enum : type}` });\n });\n}\n",
12
- "/**\n * Dialect capability shape.\n *\n * Tables live here so structural validation can refuse unsupported features\n * without depending on SQL. @vibeorm/sql re-exports these SAME frozen objects;\n * runtime, migrate, generator and tooling share their identity.\n */\n\nimport type { Dialect } from \"./ir.ts\";\n\n// ─── Full-text engines ────────────────────────────────────────────\n\n/** Full-text engines the `search` extension can target. */\nexport type FullTextEngine = \"bm25\" | \"tsvector\" | \"fts5\" | \"fulltext\";\n\n// ─── Capability table ─────────────────────────────────────────────\n\nexport type DialectCapabilities = {\n /** Native database row policies; PGlite additionally needs a verified restricted role. */\n readonly nativeRowLevelSecurity: boolean;\n /** INSERT/UPDATE/DELETE ... RETURNING. False ⇒ insertId + re-select fallback. */\n readonly returning: boolean;\n /** Native scalar array columns (String[], Int[], ...). */\n readonly scalarArrays: boolean;\n /** Native enum column types (CREATE TYPE / inline ENUM). */\n readonly nativeEnums: boolean;\n /** Native ILIKE operator. False ⇒ LOWER() LIKE LOWER() strategy. */\n readonly ilike: boolean;\n /** LATERAL JOIN relation strategy (\"join\") availability. */\n readonly lateralJoin: boolean;\n /** Native DISTINCT ON. */\n readonly distinctOn: boolean;\n /** Partial (predicate) indexes. */\n readonly partialIndexes: boolean;\n /** Named-constraint conflict targets (`ON CONFLICT ON CONSTRAINT …`). */\n readonly conflictTargetConstraint: boolean;\n /** DDL participates in transactions (mysql auto-commits DDL). */\n readonly transactionalDdl: boolean;\n /** createManyAndReturn support (requires multi-row RETURNING). */\n readonly createManyAndReturn: boolean;\n /** A real JSON column type (vs TEXT storage). */\n readonly jsonColumnType: boolean;\n /** Native NULLS FIRST/LAST in ORDER BY. False ⇒ IS NULL emulation term. */\n readonly orderByNulls: boolean;\n /** Full-text engines available on this dialect (first = preferred). */\n readonly fullTextEngines: readonly FullTextEngine[];\n};\n\n// ─── Frozen per-dialect tables ────────────────────────────────────\n\nexport const POSTGRES_CAPABILITIES: DialectCapabilities = Object.freeze({\n nativeRowLevelSecurity: true,\n returning: true,\n scalarArrays: true,\n nativeEnums: true,\n ilike: true,\n lateralJoin: true,\n distinctOn: true,\n partialIndexes: true,\n conflictTargetConstraint: true,\n transactionalDdl: true,\n createManyAndReturn: true,\n jsonColumnType: true,\n orderByNulls: true,\n fullTextEngines: Object.freeze<FullTextEngine[]>([\"bm25\", \"tsvector\"]),\n});\n\nexport const SQLITE_CAPABILITIES: DialectCapabilities = Object.freeze({\n nativeRowLevelSecurity: false,\n returning: true,\n scalarArrays: false,\n nativeEnums: false,\n ilike: false,\n lateralJoin: false,\n distinctOn: false,\n partialIndexes: true,\n conflictTargetConstraint: false,\n transactionalDdl: true,\n createManyAndReturn: true,\n jsonColumnType: false,\n orderByNulls: true,\n fullTextEngines: Object.freeze<FullTextEngine[]>([\"fts5\"]),\n});\n\nexport const MYSQL_CAPABILITIES: DialectCapabilities = Object.freeze({\n nativeRowLevelSecurity: false,\n returning: false,\n scalarArrays: false,\n nativeEnums: true,\n ilike: false,\n lateralJoin: false,\n distinctOn: false,\n partialIndexes: false,\n conflictTargetConstraint: false,\n transactionalDdl: false,\n createManyAndReturn: false,\n jsonColumnType: true,\n orderByNulls: false,\n fullTextEngines: Object.freeze<FullTextEngine[]>([\"fulltext\"]),\n});\n\nexport const DIALECT_CAPABILITIES: Readonly<Record<Dialect, DialectCapabilities>> = Object.freeze({\n postgres: POSTGRES_CAPABILITIES,\n sqlite: SQLITE_CAPABILITIES,\n mysql: MYSQL_CAPABILITIES,\n});\n",
13
- "/**\n * Structural validation of a SchemaIR.\n *\n * Shared by both schema sources (parser + dsl), so a schema that validates here\n * validates everywhere. Source-specific rules (e.g. Prisma AMBIGUOUS_RELATION\n * candidate detection) live in the source packages and land in P1.\n */\n\nimport { scalarListDefault } from \"./default-values.ts\";\n\nimport { ENUM_STORAGES, isEnumType, providerToDialect } from \"./ir.ts\";\nimport type { EnumIR, ModelIR, RelationIR, SchemaIR } from \"./ir.ts\";\nimport { VibeError, unsupportedCapability } from \"./errors.ts\";\nimport { DIALECT_CAPABILITIES } from \"./capabilities.ts\";\nimport { RESERVED_COLUMN_PREFIX } from \"./reserved.ts\";\n\n// ─── Issue shape ──────────────────────────────────────────────────\n\nexport type ValidationIssue = {\n /** Stable rule id, e.g. \"duplicate-model\", \"unknown-relation-target\". */\n readonly rule: string;\n readonly message: string;\n readonly model?: string;\n readonly field?: string;\n};\n\n// ─── Validation ───────────────────────────────────────────────────\n\n// ─── Reserved enum names ───────────────────────────────────────────\n\n/**\n * Enum names that would collide with a name the generated client already\n * exports, imports or uses internally (`index.js` / `index.d.ts` / `enums.js` / `enums.d.ts`).\n * An enum `X` emits `X` (constant + literal union), `XFilter`,\n * `XNullableFilter`, `XListFilter` and `XValidator`, so the shared scalar\n * filter prefixes are reserved too: an enum named `String` would redefine\n * `StringFilter`. Mirrored by a generator test against the emitted output so\n * this list cannot silently fall behind the emitters.\n */\nexport const RESERVED_ENUM_NAMES: readonly string[] = [\n // Module-level names and helpers of the generated entries.\n \"enumValidators\",\n \"enumValidator\",\n \"OmittedKeys\",\n \"ExactKeys\",\n \"PossibleKeys\",\n \"UncertainKeys\",\n \"HasSelectedField\",\n \"Provided\",\n \"ViewDelegateMap\",\n \"extensionManifest\",\n \"extensionMounts\",\n \"computedManifest\",\n // Globals referenced by generated values and declarations must not be shadowed.\n \"Object\", \"Set\", \"JSON\", \"Record\", \"Readonly\", \"ReadonlyArray\", \"Partial\",\n \"Omit\", \"NonNullable\", \"Promise\", \"PromiseLike\", \"Awaited\", \"TemplateStringsArray\",\n \"Date\", \"Uint8Array\",\n \"schema\",\n \"VibeClient\",\n \"VibeClientInstance\",\n \"VibeClientOptions\",\n \"VibeError\",\n \"VibeErrorCode\",\n \"BatchPayload\",\n \"UpsertManyPayload\",\n \"QueryMode\",\n \"RelationStrategy\",\n \"SortOrder\",\n \"SortOrderWithNulls\",\n \"KeysetToken\",\n \"KeysetOptions\",\n \"JsonValue\",\n \"InputJsonValue\",\n \"InputJsonArray\",\n \"InputJsonObject\",\n \"VibeTelemetryOptions\",\n \"VibeTelemetryExporter\",\n \"VibeTelemetryOperationEvent\",\n \"VibeTelemetryStatementEvent\",\n \"VibeTelemetryHandle\",\n \"ScopedClientInstance\",\n \"ScopedModelsConfig\",\n \"ScopedNestedMode\",\n \"ViewClient\",\n \"ViewDefinitionInput\",\n \"ViewRow\",\n // Names the generated entries import.\n \"createClient\",\n \"DatabaseAdapter\",\n \"DbNow\",\n \"QueryEvent\",\n \"Skip\",\n \"TransactionOptions\",\n \"SchemaIR\",\n \"VibeExtension\",\n \"ComputedConfig\",\n \"WriteValidators\",\n // Scalar filter / update-operation prefixes.\n \"String\",\n \"Bool\",\n \"Int\",\n \"BigInt\",\n \"Float\",\n \"Decimal\",\n \"DateTime\",\n \"Json\",\n \"Bytes\",\n ...[\"String\", \"Bool\", \"Int\", \"BigInt\", \"Float\", \"Decimal\", \"DateTime\", \"Json\", \"Bytes\"].flatMap((prefix) =>\n [\"Filter\", \"NullableFilter\", \"ListFilter\"].map((suffix) => `${prefix}${suffix}`),\n ),\n ...[\"Int\", \"Float\", \"BigInt\", \"Decimal\"].flatMap((prefix) =>\n [`${prefix}FieldUpdateOperationsInput`, `Nullable${prefix}FieldUpdateOperationsInput`],\n ),\n];\n\n// Reserve complete generated type families, including private payload helpers.\n// The generator's namespace mirror feeds EVERY emitted name back through this\n// validation; it must not exclude enum/model-prefixed or unexported names.\nconst GENERATED_TYPE_NAMES: {\n readonly enumSuffixes: readonly string[];\n readonly modelSuffixes: readonly string[];\n readonly nestedPrefixes: readonly string[];\n} = {\n enumSuffixes: [\"\", \"Filter\", \"NullableFilter\", \"ListFilter\", \"Validator\"],\n modelSuffixes: [\n \"\", \"ScalarFieldEnum\", \"SelectableFieldEnum\", \"Relations\", \"CountSelect\", \"Select\", \"Include\", \"OmitInput\", \"Args\",\n \"ListRelationFilter\", \"RelationFilter\", \"WhereInput\", \"WhereUniqueInput\", \"OrderByInput\",\n \"CreateInput\", \"UncheckedCreateInput\", \"CreateManyInput\", \"UpdateInput\", \"UncheckedUpdateInput\", \"UpdateManyInput\",\n \"CountAggregateInput\", \"AvgAggregateInput\", \"SumAggregateInput\", \"MinAggregateInput\", \"MaxAggregateInput\",\n \"FindManyArgs\", \"FindFirstArgs\", \"FindUniqueArgs\", \"CreateArgs\", \"ConflictTarget\", \"CreateOnConflictInput\",\n \"CreateOrSkipArgs\", \"CreateManyArgs\", \"CreateManyAndReturnArgs\", \"UpdateArgs\", \"UpdateManyArgs\",\n // EPIC 2 — conditional update + updateManyAndReturn derived names.\n \"UpdateWhereInput\", \"UpdateManyAndReturnArgs\", \"UpsertArgs\",\n // EPIC 10 — batched upsert.\n \"UpsertManyArgs\",\n \"DeleteArgs\", \"DeleteManyArgs\", \"CountArgs\", \"AggregateArgs\", \"GroupByArgs\", \"OmitBase\", \"CountResult\", \"CountPayload\",\n \"AggregateValues\", \"AggregateSelection\", \"CountOutput\",\n \"RelationPayload\", \"IncludePayload\", \"GetPayload\", \"AggregateResult\", \"GroupByResult\", \"Delegate\",\n \"ViewFields\", \"ViewSelect\", \"ViewInclude\", \"ViewNestedArgs\", \"ViewFindManyArgs\", \"ViewFindUniqueArgs\",\n \"ViewScalars\", \"ViewSelectScalars\", \"ViewReveal\", \"ViewRelationResult\", \"ViewIncludeResult\", \"ViewResult\", \"ViewDelegate\",\n ],\n nestedPrefixes: [\n \"Create\", \"UncheckedCreate\", \"Update\", \"UncheckedUpdate\", \"ConnectOrCreate\",\n \"CreateNestedMany\", \"UpdateNestedMany\", \"CreateNestedOne\", \"UpdateNestedOne\",\n \"UpdateWithWhereUnique\", \"UpdateManyWithWhere\", \"UpsertWithWhereUnique\",\n ],\n};\n\nfunction validateGeneratedNames(params: { schema: SchemaIR; issues: ValidationIssue[] }): void {\n const { schema, issues } = params;\n const owners = new Map(RESERVED_ENUM_NAMES.map((name) => [name, \"generated client\"]));\n if (schema.rls !== undefined) {\n owners.set(\"RlsContext\", \"native RLS client\");\n owners.set(\"BoundVibeClientInstance\", \"native RLS client\");\n }\n const register = (params: { name: string; owner: string }): void => {\n const previous = owners.get(params.name);\n if (previous !== undefined && previous !== params.owner) {\n issues.push({ rule: \"generated-name-collision\", message: `Generated name \"${params.name}\" from ${params.owner} conflicts with ${previous}` });\n } else {\n owners.set(params.name, params.owner);\n }\n };\n for (const model of schema.models) {\n const owner = `model \"${model.name}\"`;\n for (const suffix of GENERATED_TYPE_NAMES.modelSuffixes) register({ name: `${model.name}${suffix}`, owner });\n const withouts = [\"\", ...model.relations.map((relation) => `Without${relation.name.charAt(0).toUpperCase()}${relation.name.slice(1)}`)];\n for (const without of withouts) {\n for (const prefix of GENERATED_TYPE_NAMES.nestedPrefixes) register({ name: `${model.name}${prefix}${without}Input`, owner });\n }\n }\n for (const declared of schema.enums) {\n for (const suffix of GENERATED_TYPE_NAMES.enumSuffixes) register({ name: `${declared.name}${suffix}`, owner: `enum \"${declared.name}\"` });\n }\n}\n\n/** Validate a SchemaIR structurally; returns all issues found (empty = valid). */\nexport function validateSchemaIR(params: { schema: SchemaIR }): ValidationIssue[] {\n const { schema } = params;\n const issues: ValidationIssue[] = [];\n\n const modelByName = new Map<string, ModelIR>();\n for (const model of schema.models) {\n if (modelByName.has(model.name)) {\n issues.push({\n rule: \"duplicate-model\",\n message: `Duplicate model name \"${model.name}\"`,\n model: model.name,\n });\n } else {\n modelByName.set(model.name, model);\n }\n }\n\n const enumByName = new Map<string, EnumIR>();\n for (const enumDef of schema.enums) {\n if (enumByName.has(enumDef.name)) {\n issues.push({\n rule: \"duplicate-enum\",\n message: `Duplicate enum name \"${enumDef.name}\"`,\n });\n } else {\n enumByName.set(enumDef.name, enumDef);\n }\n if (enumDef.values.length === 0) {\n issues.push({\n rule: \"empty-enum\",\n message: `Enum \"${enumDef.name}\" has no values`,\n });\n }\n // Members are a set: the generated constant object and the membership\n // lookup both key on the value, so a repeat would silently collapse.\n const seenValues = new Set<string>();\n for (const value of enumDef.values) {\n if (seenValues.has(value)) {\n issues.push({\n rule: \"duplicate-enum-value\",\n message: `Enum \"${enumDef.name}\" lists value \"${value}\" more than once`,\n });\n }\n seenValues.add(value);\n }\n if (enumDef.storage !== undefined && !ENUM_STORAGES.includes(enumDef.storage)) {\n issues.push({\n rule: \"invalid-enum-storage\",\n message: `Enum \"${enumDef.name}\" has storage ${JSON.stringify(enumDef.storage)} — expected one of ${ENUM_STORAGES.join(\", \")}`,\n });\n }\n // Generated-name collisions: the client module exports one value AND one\n // type per enum, so an enum cannot share a model's name or a name the\n // module already exports/imports.\n if (modelByName.has(enumDef.name)) {\n issues.push({\n rule: \"enum-model-name-collision\",\n message: `Enum \"${enumDef.name}\" shares its name with a model — the generated client exports one type per name`,\n model: enumDef.name,\n });\n }\n if (RESERVED_ENUM_NAMES.includes(enumDef.name)) {\n issues.push({\n rule: \"enum-reserved-name\",\n message: `Enum \"${enumDef.name}\" collides with a name the generated client already exports or imports`,\n });\n }\n }\n\n for (const model of schema.models) {\n validateModel({ model, modelByName, enumByName, issues });\n }\n\n // Implicit SELF many-to-many: refused on every dialect, at the earliest\n // knowable moment (validation is shared by the parser, the DSL, generate,\n // db push and migrate, so no authoring path can slip past it).\n //\n // `implicitJoinTable` gives join column \"A\" to the lexicographically first\n // MODEL name. A self relation has one name on both sides, so both relation\n // fields claim \"A\" and traverse the join table in the same direction: the\n // inverse field returns the forward edge set. Rows already written through\n // either field carry that single orientation, so no corrected rule can\n // re-read them without silently changing what deployed data means. VibeORM\n // refuses the shape instead of answering wrongly; a directed self relation\n // is modelled with an explicit junction model.\n //\n // Detection is the ONE shared structural rule and never `relation.type`:\n // `db pull` represents a physical self join table as two unnamed `oneToMany`\n // list sides, and that shape has to refuse identically.\n for (const model of schema.models) {\n for (const relation of model.relations) {\n if (relation.targetModel !== model.name) continue;\n if (!isImplicitManyToManyRelation({ model, relation, models: schema.models })) continue;\n issues.push({\n rule: \"implicit-self-many-to-many\",\n message:\n `Relation \"${model.name}.${relation.name}\" is an implicit self many-to-many. Both sides of a self ` +\n `relation own the same join-table column, so this field and its inverse read the same rows. Replace ` +\n `it with an explicit junction model carrying one foreign key per direction, each under its own ` +\n `@relation name, and point \"${relation.name}\" at that model. Worked example, and the row copy for a ` +\n `join table that already exists: docs/queries.md, \"Directed self relations\".`,\n model: model.name,\n field: relation.name,\n });\n }\n }\n\n // Capability-gated index features, refused at validation — the earliest\n // knowable moment — instead of failing later at DDL time:\n // - partial predicates (where): postgres/pglite/sqlite only;\n // - UNIQUE NULLS NOT DISTINCT: postgres/pglite only (pg 15+), unique only.\n const provider = schema.datasource.provider;\n for (const model of schema.models) {\n for (const index of model.indexes) {\n if (index.where !== undefined && provider === \"mysql\") {\n issues.push({\n rule: \"partial-index-unsupported\",\n message: `Partial index (where) on \"${model.name}\" — mysql has no partial indexes; predicates are postgres/pglite/sqlite only`,\n model: model.name,\n });\n }\n if (index.nullsNotDistinct === true) {\n if (index.kind !== \"unique\") {\n issues.push({\n rule: \"nulls-not-distinct-non-unique\",\n message: `nullsNotDistinct on a non-unique index of \"${model.name}\" — the flag changes UNIQUE null semantics and means nothing elsewhere`,\n model: model.name,\n });\n }\n if (provider === \"sqlite\" || provider === \"mysql\") {\n issues.push({\n rule: \"nulls-not-distinct-unsupported\",\n message: `UNIQUE NULLS NOT DISTINCT on \"${model.name}\" — ${provider} treats NULLs as distinct and has no switch; the flag is postgres/pglite (15+) only`,\n model: model.name,\n });\n }\n }\n }\n }\n\n // `name:` on `@@unique` / `@@id` — the CLIENT selector name (the generated\n // `…WhereUniqueInput` property and the runtime where key). Everywhere it\n // cannot take effect it is refused loudly — never silently dropped (the\n // exact papercut this rule exists to prevent).\n for (const model of schema.models) {\n const fieldNames = new Set(model.fields.map((field) => field.name));\n const defaultKeys = new Set<string>();\n if (\n model.primaryKey !== undefined &&\n model.primaryKey.fields.length > 1 &&\n model.primaryKey.clientName === undefined\n ) {\n defaultKeys.add(model.primaryKey.fields.join(\"_\"));\n }\n for (const index of model.indexes) {\n if (\n index.kind === \"unique\" &&\n index.where === undefined &&\n index.fields.length > 1 &&\n index.clientName === undefined\n ) {\n defaultKeys.add(index.fields.map((field) => field.name).join(\"_\"));\n }\n }\n const seenSelectorNames = new Set<string>();\n const checkSelectorName = (params: {\n clientName: string;\n fieldCount: number;\n where?: string;\n isUnique: boolean;\n site: string;\n }): void => {\n const { clientName, fieldCount, where, isUnique, site } = params;\n if (!isUnique) {\n issues.push({\n rule: \"client-name-non-unique\",\n message: `name: (\"${clientName}\") on a non-unique index of \"${model.name}\" — a client selector names a UNIQUE group; use map: for the index's database name`,\n model: model.name,\n });\n return;\n }\n if (where !== undefined) {\n issues.push({\n rule: \"client-name-partial-unique\",\n message: `name: (\"${clientName}\") on a partial unique of \"${model.name}\" — a partial unique cannot address a row and never joins WhereUniqueInput`,\n model: model.name,\n });\n return;\n }\n if (fieldCount < 2) {\n issues.push({\n rule: \"client-name-single-field\",\n message: `name: (\"${clientName}\") on a single-field ${site} of \"${model.name}\" — the field itself is the selector; name: applies to compound groups only`,\n model: model.name,\n });\n return;\n }\n if (fieldNames.has(clientName) || defaultKeys.has(clientName) || seenSelectorNames.has(clientName)) {\n issues.push({\n rule: \"client-name-collision\",\n message: `name: (\"${clientName}\") on \"${model.name}\" collides with a field or another unique selector — WhereUniqueInput keys must be unambiguous`,\n model: model.name,\n });\n return;\n }\n seenSelectorNames.add(clientName);\n };\n if (model.primaryKey !== undefined && model.primaryKey.clientName !== undefined) {\n checkSelectorName({\n clientName: model.primaryKey.clientName,\n fieldCount: model.primaryKey.fields.length,\n isUnique: true,\n site: \"@@id\",\n });\n }\n for (const index of model.indexes) {\n if (index.clientName === undefined) continue;\n checkSelectorName({\n clientName: index.clientName,\n fieldCount: index.fields.length,\n ...(index.where === undefined ? {} : { where: index.where }),\n isUnique: index.kind === \"unique\",\n site: \"@@unique\",\n });\n }\n }\n\n validateGeneratedNames({ schema, issues });\n validateNativeRls({ schema, issues });\n return issues;\n}\n\nfunction validateModel(params: {\n model: ModelIR;\n modelByName: Map<string, ModelIR>;\n enumByName: Map<string, EnumIR>;\n issues: ValidationIssue[];\n}): void {\n const { model, modelByName, enumByName, issues } = params;\n\n // Field + relation names share one namespace on the model.\n const memberNames = new Set<string>();\n for (const field of model.fields) {\n if (memberNames.has(field.name)) {\n issues.push({\n rule: \"duplicate-field\",\n message: `Duplicate field \"${field.name}\" on model \"${model.name}\"`,\n model: model.name,\n field: field.name,\n });\n }\n memberNames.add(field.name);\n\n if (isEnumType(field.type)) {\n const enumDef = enumByName.get(field.type.enum);\n if (enumDef === undefined) {\n issues.push({\n rule: \"unknown-enum\",\n message: `Field \"${model.name}.${field.name}\" references unknown enum \"${field.type.enum}\"`,\n model: model.name,\n field: field.name,\n });\n } else {\n // A default must be a member — `@default(FOO)` (enumValue) and the\n // quoted `@default(\"FOO\")` (literal) spellings alike. Checked here,\n // once, for both schema sources.\n const defaultValue = field.default;\n const candidate =\n defaultValue === undefined\n ? undefined\n : defaultValue.kind === \"enumValue\"\n ? defaultValue.value\n : defaultValue.kind === \"literal\" && typeof defaultValue.value === \"string\"\n ? defaultValue.value\n : undefined;\n if (candidate !== undefined && !enumDef.values.includes(candidate)) {\n issues.push({\n rule: \"enum-default-not-member\",\n message: `Default \"${candidate}\" on \"${model.name}.${field.name}\" is not a member of enum \"${enumDef.name}\" (${enumDef.values.join(\", \")})`,\n model: model.name,\n field: field.name,\n });\n }\n }\n }\n\n // The runtime aliases its own projections (M2M stitch key `__vibe_parent`,\n // hidden order fields) under this prefix; a user column there would\n // collide and be silently misgrouped/stripped. `.prisma` field names\n // cannot start with `_`, but `@map` and hand-built IR can.\n const columnName = field.dbName ?? field.name;\n if (columnName.startsWith(RESERVED_COLUMN_PREFIX)) {\n issues.push({\n rule: \"reserved-column-prefix\",\n message:\n `Field \"${model.name}.${field.name}\" maps to column \"${columnName}\" — the \"${RESERVED_COLUMN_PREFIX}\" ` +\n `prefix is reserved for VibeORM's own projection aliases`,\n model: model.name,\n field: field.name,\n });\n }\n }\n\n for (const relation of model.relations) {\n if (memberNames.has(relation.name)) {\n issues.push({\n rule: \"duplicate-field\",\n message: `Relation \"${relation.name}\" collides with another member on model \"${model.name}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n memberNames.add(relation.name);\n }\n\n // Primary key presence (views are exempt).\n const fieldNames = new Set(model.fields.map((f) => f.name));\n const hasIdField = model.fields.some((f) => f.isId);\n if (!model.isView && !hasIdField && model.primaryKey === undefined) {\n issues.push({\n rule: \"missing-id\",\n message: `Model \"${model.name}\" has no @id field and no composite primary key`,\n model: model.name,\n });\n }\n if (model.primaryKey !== undefined) {\n for (const pkField of model.primaryKey.fields) {\n if (!fieldNames.has(pkField)) {\n issues.push({\n rule: \"unknown-pk-field\",\n message: `Composite primary key on \"${model.name}\" references unknown field \"${pkField}\"`,\n model: model.name,\n field: pkField,\n });\n }\n }\n }\n\n // Relations: target exists, FK columns exist both sides, arities match.\n for (const relation of model.relations) {\n const target = modelByName.get(relation.targetModel);\n if (target === undefined) {\n issues.push({\n rule: \"unknown-relation-target\",\n message: `Relation \"${model.name}.${relation.name}\" targets unknown model \"${relation.targetModel}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n\n const hasFields = relation.fields !== undefined && relation.fields.length > 0;\n const hasReferences = relation.references !== undefined && relation.references.length > 0;\n if (hasFields !== hasReferences) {\n issues.push({\n rule: \"relation-fields-mismatch\",\n message: `Relation \"${model.name}.${relation.name}\" must declare fields and references together`,\n model: model.name,\n field: relation.name,\n });\n }\n if (hasFields && hasReferences && relation.fields !== undefined && relation.references !== undefined) {\n if (relation.fields.length !== relation.references.length) {\n issues.push({\n rule: \"relation-fields-mismatch\",\n message: `Relation \"${model.name}.${relation.name}\" has ${relation.fields.length} fields but ${relation.references.length} references`,\n model: model.name,\n field: relation.name,\n });\n }\n for (const fkField of relation.fields) {\n if (!fieldNames.has(fkField)) {\n issues.push({\n rule: \"unknown-relation-field\",\n message: `Relation \"${model.name}.${relation.name}\" uses unknown field \"${fkField}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n }\n if (target !== undefined) {\n const targetFieldNames = new Set(target.fields.map((f) => f.name));\n for (const refField of relation.references) {\n if (!targetFieldNames.has(refField)) {\n issues.push({\n rule: \"unknown-relation-reference\",\n message: `Relation \"${model.name}.${relation.name}\" references unknown field \"${relation.targetModel}.${refField}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n }\n }\n }\n }\n\n // @collation: String fields only — collation has no meaning off text.\n for (const field of model.fields) {\n if (field.collation !== undefined && field.type !== \"String\") {\n issues.push({\n rule: \"collation-non-string\",\n message: `@collation on \"${model.name}.${field.name}\" — collation is only valid on String fields`,\n model: model.name,\n field: field.name,\n });\n }\n }\n\n // @@policy: the field must exist and be a required, non-list scalar — an\n // optional scoping column cannot fail closed.\n if (model.policy !== undefined) {\n const policyField = model.fields.find((field) => field.name === model.policy?.field);\n if (policyField === undefined) {\n issues.push({\n rule: \"policy-unknown-field\",\n message: `@@policy on \"${model.name}\" references unknown field \"${model.policy.field}\"`,\n model: model.name,\n });\n } else if (policyField.isList) {\n issues.push({\n rule: \"policy-list-field\",\n message: `@@policy field \"${model.name}.${policyField.name}\" must be a non-list scalar`,\n model: model.name,\n field: policyField.name,\n });\n } else if (policyField.isOptional) {\n issues.push({\n rule: \"policy-optional-field\",\n message: `@@policy field \"${model.name}.${policyField.name}\" must be required — an optional scoping column cannot fail closed`,\n model: model.name,\n field: policyField.name,\n });\n }\n }\n\n // Checks: non-empty, and NAME-unique (names key the migration diff).\n const checkNames = new Set<string>();\n for (const check of model.checks ?? []) {\n if (check.name.trim() === \"\" || check.expression.trim() === \"\") {\n issues.push({\n rule: \"invalid-check\",\n message: `CHECK on \"${model.name}\" needs a non-empty name and expression`,\n model: model.name,\n });\n }\n if (checkNames.has(check.name)) {\n issues.push({\n rule: \"duplicate-check\",\n message: `Duplicate CHECK name \"${check.name}\" on \"${model.name}\" — names key the migration diff`,\n model: model.name,\n });\n }\n checkNames.add(check.name);\n }\n\n // Indexes reference real fields.\n for (const index of model.indexes) {\n for (const indexField of index.fields) {\n if (!fieldNames.has(indexField.name)) {\n issues.push({\n rule: \"unknown-index-field\",\n message: `Index on \"${model.name}\" references unknown field \"${indexField.name}\"`,\n model: model.name,\n field: indexField.name,\n });\n }\n }\n }\n}\n\n// ─── Assertion form ───────────────────────────────────────────────\n\n/** Throw VIBE_SCHEMA_INVALID (with all issues in meta) if the schema is invalid. */\nexport function assertValidSchemaIR(params: { schema: SchemaIR }): void {\n const dialect = providerToDialect({ provider: params.schema.datasource.provider });\n if (params.schema.rls !== undefined && !DIALECT_CAPABILITIES[dialect].nativeRowLevelSecurity) {\n throw unsupportedCapability({ dialect, feature: \"nativeRowLevelSecurity\" });\n }\n for (const model of params.schema.models) {\n const counters = model.fields.filter((field) => field.default?.kind === \"autoincrement\");\n if (dialect === \"mysql\" && counters.length > 1) throw unsupportedCapability({ dialect, feature: \"multiple auto-increment columns\" });\n for (const field of model.fields) {\n if (field.default?.kind === \"list\") {\n if (dialect !== \"postgres\") throw unsupportedCapability({ dialect, feature: \"scalar-list defaults\" });\n if (!field.isList) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `List default on non-list field ${model.name}.${field.name}` });\n scalarListDefault({ type: field.type, values: field.default.values });\n if (isEnumType(field.type)) {\n const name = field.type.enum;\n const members = params.schema.enums.find((entry) => entry.name === name)?.values ?? [];\n if (field.default.values.some((value) => typeof value !== \"string\" || !members.includes(value))) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `Invalid enum-list default on ${model.name}.${field.name}` });\n }\n }\n if (field.default?.kind !== \"autoincrement\") continue;\n if (field.isList || field.isOptional || (field.type !== \"Int\" && field.type !== \"BigInt\")) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `autoincrement requires a required scalar Int or BigInt: ${model.name}.${field.name}` });\n const pk = model.primaryKey?.fields ?? model.fields.filter((entry) => entry.isId).map((entry) => entry.name);\n if (dialect === \"sqlite\" && (pk.length !== 1 || pk[0] !== field.name)) throw unsupportedCapability({ dialect, feature: `non-primary auto-increment column ${model.name}.${field.name}` });\n if (dialect === \"mysql\" && pk[0] !== field.name && !field.isUnique && !model.indexes.some((index) => index.fields[0]?.name === field.name)) throw unsupportedCapability({ dialect, feature: `unindexed auto-increment column ${model.name}.${field.name}` });\n }\n }\n const issues = validateSchemaIR(params);\n if (issues.length > 0) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `Schema validation failed with ${issues.length} issue(s): ${issues\n .map((issue) => issue.message)\n .join(\"; \")}`,\n meta: { issues },\n });\n }\n}\n\n// ─── Native RLS structure ─────────────────────────────────────────\n\nfunction rlsRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null) &&\n Reflect.ownKeys(value).every((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n return typeof key === \"string\" && descriptor?.enumerable === true && \"value\" in descriptor;\n });\n}\n\nfunction rlsKeys(params: { value: Record<string, unknown>; keys: readonly string[] }): boolean {\n const own = Reflect.ownKeys(params.value);\n return own.length === params.keys.length && params.keys.every((key) => Object.hasOwn(params.value, key));\n}\n\n/** Validate context declarations independently (also used by settings rendering). */\nexport function validateRlsContextIR(params: { context: unknown }): ValidationIssue[] {\n const { context } = params;\n const issues: ValidationIssue[] = [];\n if (!rlsRecord(context)) return [{ rule: \"rls-invalid-context\", message: \"Native RLS context must be a named scalar-slot map\" }];\n const seen = new Set<string>();\n for (const key of Reflect.ownKeys(context)) {\n const slot: unknown = typeof key === \"string\" ? context[key] : undefined;\n if (typeof key !== \"string\" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(key) || seen.has(key.toLowerCase()) ||\n !rlsRecord(slot) || !rlsKeys({ value: slot, keys: [\"type\", \"nullable\"] }) || typeof slot.nullable !== \"boolean\" ||\n (typeof slot.type !== \"string\" || ![\"String\", \"Boolean\", \"Int\", \"BigInt\", \"Float\", \"Decimal\", \"DateTime\"].includes(slot.type))) {\n issues.push({ rule: \"rls-invalid-context\", message: `Invalid native RLS context slot ${String(key)}; use distinct setting keys and supported scalar slots with explicit nullable` });\n }\n if (typeof key === \"string\") seen.add(key.toLowerCase());\n }\n return issues;\n}\n\n/**\n * Shared structural implicit-M2M rule, including introspection's unnamed lists.\n * Each fieldless list must be the other's sole counterpart under the same\n * relation-name key, counting FK-owning candidates too. Never trust `type`:\n * ordinary mutual FKs also synthesize unnamed lists during introspection.\n */\nexport function isImplicitManyToManyRelation(params: {\n model: ModelIR;\n relation: RelationIR;\n models: readonly ModelIR[];\n}): boolean {\n const { model, relation, models } = params;\n if (model.isView || !relation.isList || (relation.fields?.length ?? 0) !== 0) return false;\n const target = models.find((candidate) => candidate.name === relation.targetModel);\n if (target === undefined || target.isView) return false;\n const counterpart = soleRelationCounterpart({ relation, ownModel: model.name, target });\n if (counterpart === undefined || !counterpart.isList || (counterpart.fields?.length ?? 0) !== 0) return false;\n return soleRelationCounterpart({ relation: counterpart, ownModel: target.name, target: model }) === relation;\n}\n\nfunction soleRelationCounterpart(params: { relation: RelationIR; ownModel: string; target: ModelIR }): RelationIR | undefined {\n const { relation, ownModel, target } = params;\n const candidates = target.relations.filter((candidate) =>\n candidate !== relation && candidate.targetModel === ownModel && candidate.relationName === relation.relationName,\n );\n return candidates.length === 1 ? candidates[0] : undefined;\n}\n\nfunction validateNativeRls(params: { schema: SchemaIR; issues: ValidationIssue[] }): void {\n const { schema, issues } = params;\n if (schema.rls === undefined) {\n if (schema.models.some((model) => model.rls !== undefined)) {\n issues.push({ rule: \"rls-missing-context\", message: \"Model RLS rules require a schema-level rls.context declaration\" });\n }\n return;\n }\n const dialect = providerToDialect({ provider: schema.datasource.provider });\n if (!DIALECT_CAPABILITIES[dialect].nativeRowLevelSecurity) {\n issues.push({ rule: \"rls-unsupported-capability\", message: `nativeRowLevelSecurity is not supported on ${dialect}` });\n }\n if (!rlsRecord(schema.rls) || !rlsKeys({ value: schema.rls, keys: [\"context\"] })) {\n issues.push({ rule: \"rls-invalid-context\", message: \"Native RLS supports only a schema-level context declaration\" });\n return;\n }\n const contextIssues = validateRlsContextIR({ context: schema.rls.context });\n issues.push(...contextIssues);\n const context = contextIssues.length === 0 ? schema.rls.context : undefined;\n const byName = new Map(schema.models.map((model) => [model.name, model]));\n const tables = new Set<string>();\n const throughTargets = new Map<string, string>();\n for (const model of schema.models) {\n const add = (params: { rule: string; message: string; field?: string }): void => {\n issues.push({ ...params, model: model.name });\n };\n const table = model.dbName ?? model.name;\n if (tables.has(table)) add({ rule: \"rls-duplicate-table\", message: `RLS models share physical table ${table}` });\n tables.add(table);\n const columns = new Set<string>();\n for (const field of model.fields) {\n const name = field.dbName ?? field.name;\n if (columns.has(name)) add({ rule: \"rls-duplicate-column\", message: `RLS model ${model.name} repeats physical column ${name}`, field: field.name });\n columns.add(name);\n }\n if (model.policy !== undefined) add({ rule: \"rls-policy-conflict\", message: \"Native RLS cannot combine with application-level ModelIR.policy\" });\n if (model.isView) add({ rule: \"rls-view-unsupported\", message: \"Database views are not supported on native RLS clients; remove the view declaration\" });\n if (model.rls === undefined) {\n add({ rule: \"rls-unclassified-model\", message: `Classify ${model.name} as where, through, unprotected or deny` });\n continue;\n }\n if (model.rls !== \"unprotected\") {\n for (const relation of model.relations) {\n if (isImplicitManyToManyRelation({ model, relation, models: schema.models })) {\n add({ rule: \"rls-implicit-many-to-many\", message: \"Protected implicit many-to-many relations need an explicit junction model with its own rule\", field: relation.name });\n }\n }\n }\n const rule: unknown = model.rls;\n if (rule === \"unprotected\" || rule === \"deny\") continue;\n if (!rlsRecord(rule)) {\n add({ rule: \"rls-invalid-rule\", message: \"Native RLS accepts where, through, unprotected or deny only\" });\n continue;\n }\n if (rlsKeys({ value: rule, keys: [\"where\"] }) && rlsRecord(rule.where) && Reflect.ownKeys(rule.where).length > 0) {\n for (const fieldName of Reflect.ownKeys(rule.where)) {\n const ref: unknown = typeof fieldName === \"string\" ? rule.where[fieldName] : undefined;\n if (!rlsRecord(ref) || !rlsKeys({ value: ref, keys: [\"context\"] }) || typeof ref.context !== \"string\") {\n add({ rule: \"rls-invalid-rule\", message: \"Ownership equality accepts a context reference only\" });\n continue;\n }\n const field = model.fields.find((f) => f.name === fieldName);\n if (field === undefined) {\n add({ rule: \"rls-unknown-field\", message: `Native RLS requires a direct scalar field, not path ${String(fieldName)}` });\n } else if (field.isList || field.isUnsupported || isEnumType(field.type) || field.type === \"Json\" || field.type === \"Bytes\") {\n add({ rule: \"rls-unsupported-field\", message: \"Native RLS ownership requires a supported non-list scalar\", field: field.name });\n } else if (context !== undefined) {\n const slot = Object.hasOwn(context, ref.context) ? context[ref.context] : undefined;\n if (slot === undefined) add({ rule: \"rls-unknown-context\", message: `Unknown native RLS context key ${ref.context}`, field: field.name });\n else if (slot.type !== field.type) add({ rule: \"rls-context-type-mismatch\", message: `Context ${ref.context} does not match ${model.name}.${field.name}`, field: field.name });\n }\n }\n continue;\n }\n if (rlsKeys({ value: rule, keys: [\"through\"] }) && typeof rule.through === \"string\") {\n const relation = model.relations.find((r) => r.name === rule.through);\n const target = relation === undefined ? undefined : byName.get(relation.targetModel);\n if (relation === undefined || target === undefined || relation.model !== model.name || relation.isList ||\n (relation.type !== \"oneToOne\" && relation.type !== \"manyToOne\") ||\n !validRlsForeignKey({ model, target, relation })) {\n add({ rule: \"rls-invalid-through\", message: \"Native RLS through requires a to-one relation with an actual, complete foreign key on this model\" });\n continue;\n }\n if (relation.isOptional || relation.fields?.some((name) => model.fields.find((field) => field.name === name)?.isOptional)) {\n add({ rule: \"rls-nullable-through\", message: \"Native RLS through requires a non-nullable parent relation and foreign key; NULL parent links cannot satisfy WITH CHECK. Make the link required or use a direct ownership rule\", field: relation.name });\n continue;\n }\n if (table === \"parent\") add({ rule: \"rls-through-alias-conflict\", message: \"A through table mapped to parent would shadow the fixed policy parent alias; use another table name\" });\n throughTargets.set(model.name, target.name);\n continue;\n }\n add({ rule: \"rls-invalid-rule\", message: \"Native RLS accepts a nonempty equality map or a single through relation; extra properties and operation-specific rules refuse\" });\n }\n for (const [origin, first] of throughTargets) {\n const seen = new Set([origin]);\n let current: string | undefined = first;\n while (current !== undefined && !seen.has(current)) {\n seen.add(current);\n const rule = byName.get(current)?.rls;\n if (rlsRecord(rule) && rlsKeys({ value: rule, keys: [\"where\"] })) break;\n current = throughTargets.get(current);\n }\n if (current === undefined || current === origin || (throughTargets.has(current) && seen.has(current))) {\n issues.push({ rule: \"rls-through-chain-invalid\", message: `Through chain from ${origin} must be acyclic and end in a direct where rule`, model: origin });\n }\n }\n}\n\nfunction validRlsForeignKey(params: { model: ModelIR; target: ModelIR; relation: RelationIR }): boolean {\n const { model, target, relation } = params;\n const fields = relation.fields;\n const refs = relation.references;\n if (fields === undefined || refs === undefined || fields.length === 0 || fields.length !== refs.length ||\n new Set(fields).size !== fields.length || new Set(refs).size !== refs.length) return false;\n const validFields = fields.every((name, index) => {\n const field = model.fields.find((f) => f.name === name);\n const ref = target.fields.find((f) => f.name === refs[index]);\n return field !== undefined && ref !== undefined && !field.isList && !ref.isList && !field.isUnsupported && !ref.isUnsupported &&\n (field.type === ref.type || (isEnumType(field.type) && isEnumType(ref.type) && field.type.enum === ref.type.enum));\n });\n const uniqueSets = [\n ...target.fields.filter((f) => f.isId || f.isUnique).map((f) => [f.name]),\n ...(target.primaryKey === undefined ? [] : [target.primaryKey.fields]),\n ...target.indexes.filter((index) => index.kind === \"unique\" && index.where === undefined).map((index) => index.fields.map((f) => f.name)),\n ];\n return validFields && uniqueSets.some((set) => set.length === refs.length && set.every((name) => refs.includes(name)));\n}\n",
14
+ "/**\n * Dialect capability shape.\n *\n * Tables live here so structural validation can refuse unsupported features\n * without depending on SQL. @vibeorm/sql re-exports these SAME frozen objects;\n * runtime, migrate, generator and tooling share their identity.\n */\n\nimport type { Dialect } from \"./ir.ts\";\n\n// ─── Full-text engines ────────────────────────────────────────────\n\n/** Full-text engines the `search` extension can target. */\nexport type FullTextEngine = \"bm25\" | \"tsvector\" | \"fts5\" | \"fulltext\";\n\n// ─── Locking ──────────────────────────────────────────────────────\n\n/**\n * How strongly a locking read holds the rows it returns.\n *\n * - `\"update\"` — the exclusive row lock (`FOR UPDATE`): nobody else may update,\n * delete or lock the row until this transaction ends.\n * - `\"noKeyUpdate\"` — PostgreSQL's weaker exclusive lock (`FOR NO KEY UPDATE`):\n * it still blocks other writers of the same row, but does NOT block a child\n * row's foreign-key reference to it.\n * - `\"share\"` — the shared lock (`FOR SHARE`): several readers may hold it at\n * once, and every writer waits.\n * - `\"keyShare\"` — PostgreSQL's weakest lock (`FOR KEY SHARE`): it only blocks\n * changes to the row's key columns, which is what a foreign-key check needs.\n */\nexport type RowLockStrength = \"update\" | \"noKeyUpdate\" | \"share\" | \"keyShare\";\n\n/**\n * What a locking read does when another transaction already holds a\n * conflicting lock on a row it matched.\n *\n * - `\"wait\"` — block until the holder commits or rolls back (SQL's default).\n * - `\"nowait\"` — fail immediately with `VIBE_LOCK_NOT_AVAILABLE`.\n * - `\"skipLocked\"` — leave the locked rows out of the result, which is how a\n * queue hands disjoint work to concurrent workers.\n */\nexport type RowLockWaitPolicy = \"wait\" | \"nowait\" | \"skipLocked\";\n\n/** Advisory locks are exclusive (one holder) or shared (many readers, no writer). */\nexport type AdvisoryLockMode = \"exclusive\" | \"shared\";\n\n// ─── Capability table ─────────────────────────────────────────────\n\nexport type DialectCapabilities = {\n /** Explicit database-normalized CHECK inspection; text-only engines never guess equivalence. */\n /** PostgreSQL GiST exclusion constraints and their shared extension requirement. */\n readonly exclusionConstraints: boolean;\n readonly exclusionExtensions: readonly string[];\n readonly checkNormalization: \"rollback\" | \"temporary\" | \"sourceText\";\n /** Native database row policies; PGlite additionally needs a verified restricted role. */\n readonly nativeRowLevelSecurity: boolean;\n /** INSERT/UPDATE/DELETE ... RETURNING. False ⇒ insertId + re-select fallback. */\n readonly returning: boolean;\n /** Native scalar array columns (String[], Int[], ...). */\n readonly scalarArrays: boolean;\n /** Native enum column types (CREATE TYPE / inline ENUM). */\n readonly nativeEnums: boolean;\n /** Native ILIKE operator. False ⇒ LOWER() LIKE LOWER() strategy. */\n readonly ilike: boolean;\n /** LATERAL JOIN relation strategy (\"join\") availability. */\n readonly lateralJoin: boolean;\n /** Native DISTINCT ON. */\n readonly distinctOn: boolean;\n /** Partial (predicate) indexes. */\n readonly partialIndexes: boolean;\n /** Named-constraint conflict targets (`ON CONFLICT ON CONSTRAINT …`). */\n readonly conflictTargetConstraint: boolean;\n /** DDL participates in transactions (mysql auto-commits DDL). */\n readonly transactionalDdl: boolean;\n /** createManyAndReturn support (requires multi-row RETURNING). */\n readonly createManyAndReturn: boolean;\n /** A real JSON column type (vs TEXT storage). */\n readonly jsonColumnType: boolean;\n /** Native NULLS FIRST/LAST in ORDER BY. False ⇒ IS NULL emulation term. */\n readonly orderByNulls: boolean;\n /** Full-text engines available on this dialect (first = preferred). */\n readonly fullTextEngines: readonly FullTextEngine[];\n /**\n * Row-lock strengths this dialect can express in a locking read. EMPTY means\n * the dialect has no locking-read clause at all (sqlite), not that locking is\n * unnecessary — the runtime refuses every strength it cannot render.\n */\n readonly rowLockStrengths: readonly RowLockStrength[];\n /**\n * Wait policies this dialect can express. Empty exactly when\n * {@link DialectCapabilities.rowLockStrengths} is empty.\n */\n readonly rowLockWaitPolicies: readonly RowLockWaitPolicy[];\n /**\n * Transaction-scoped advisory locks on application-defined keys\n * (`pg_advisory_xact_lock`). MySQL's `GET_LOCK` is SESSION-scoped — it\n * survives a rollback — so it does not satisfy this capability.\n */\n readonly advisoryLocks: boolean;\n};\n\n// ─── Frozen per-dialect tables ────────────────────────────────────\n\nexport const POSTGRES_CAPABILITIES: DialectCapabilities = Object.freeze({\n exclusionConstraints: true,\n exclusionExtensions: Object.freeze([\"btree_gist\"]),\n checkNormalization: \"rollback\",\n nativeRowLevelSecurity: true,\n returning: true,\n scalarArrays: true,\n nativeEnums: true,\n ilike: true,\n lateralJoin: true,\n distinctOn: true,\n partialIndexes: true,\n conflictTargetConstraint: true,\n transactionalDdl: true,\n createManyAndReturn: true,\n jsonColumnType: true,\n orderByNulls: true,\n fullTextEngines: Object.freeze<FullTextEngine[]>([\"bm25\", \"tsvector\"]),\n // Verified on PostgreSQL 18.6 and PGlite 0.5.4 (PostgreSQL 18.3): all four\n // strengths and all three wait policies parse and behave.\n rowLockStrengths: Object.freeze<RowLockStrength[]>([\"update\", \"noKeyUpdate\", \"share\", \"keyShare\"]),\n rowLockWaitPolicies: Object.freeze<RowLockWaitPolicy[]>([\"wait\", \"nowait\", \"skipLocked\"]),\n advisoryLocks: true,\n});\n\nexport const SQLITE_CAPABILITIES: DialectCapabilities = Object.freeze({\n exclusionConstraints: false,\n exclusionExtensions: Object.freeze([]),\n checkNormalization: \"sourceText\",\n nativeRowLevelSecurity: false,\n returning: true,\n scalarArrays: false,\n nativeEnums: false,\n ilike: false,\n lateralJoin: false,\n distinctOn: false,\n partialIndexes: true,\n conflictTargetConstraint: false,\n transactionalDdl: true,\n createManyAndReturn: true,\n jsonColumnType: false,\n orderByNulls: true,\n fullTextEngines: Object.freeze<FullTextEngine[]>([\"fts5\"]),\n // sqlite has NO locking-read clause: `SELECT … FOR UPDATE` is a syntax error\n // (verified on sqlite 3.51.0). Its write transactions are mutually exclusive,\n // so the legacy `lock: \"update\"` request stays a documented no-op; every\n // other request is refused rather than silently downgraded.\n rowLockStrengths: Object.freeze<RowLockStrength[]>([]),\n rowLockWaitPolicies: Object.freeze<RowLockWaitPolicy[]>([]),\n advisoryLocks: false,\n});\n\nexport const MYSQL_CAPABILITIES: DialectCapabilities = Object.freeze({\n exclusionConstraints: false,\n exclusionExtensions: Object.freeze([]),\n checkNormalization: \"temporary\",\n nativeRowLevelSecurity: false,\n returning: false,\n scalarArrays: false,\n nativeEnums: true,\n ilike: false,\n lateralJoin: false,\n distinctOn: false,\n partialIndexes: false,\n conflictTargetConstraint: false,\n transactionalDdl: false,\n createManyAndReturn: false,\n jsonColumnType: true,\n orderByNulls: false,\n fullTextEngines: Object.freeze<FullTextEngine[]>([\"fulltext\"]),\n // Verified on MySQL 26.7.0: FOR UPDATE / FOR SHARE with NOWAIT and SKIP\n // LOCKED all parse; FOR NO KEY UPDATE and FOR KEY SHARE are parse errors\n // (errno 1064). GET_LOCK is session-scoped, so there are no advisory locks.\n rowLockStrengths: Object.freeze<RowLockStrength[]>([\"update\", \"share\"]),\n rowLockWaitPolicies: Object.freeze<RowLockWaitPolicy[]>([\"wait\", \"nowait\", \"skipLocked\"]),\n advisoryLocks: false,\n});\n\nexport const DIALECT_CAPABILITIES: Readonly<Record<Dialect, DialectCapabilities>> = Object.freeze({\n postgres: POSTGRES_CAPABILITIES,\n sqlite: SQLITE_CAPABILITIES,\n mysql: MYSQL_CAPABILITIES,\n});\n",
15
+ "/**\n * Structural validation of a SchemaIR.\n *\n * Shared by both schema sources (parser + dsl), so a schema that validates here\n * validates everywhere. Source-specific rules (e.g. Prisma AMBIGUOUS_RELATION\n * candidate detection) live in the source packages and land in P1.\n */\n\nimport type { ExclusionIR } from \"./exclusion.ts\";\nimport { scalarListDefault } from \"./default-values.ts\";\n\nimport { ENUM_STORAGES, isEnumType, providerToDialect } from \"./ir.ts\";\nimport type { EnumIR, ModelIR, RelationIR, SchemaIR } from \"./ir.ts\";\nimport { predicateFieldNames } from \"./predicate.ts\";\nimport type { PredicateIR } from \"./predicate.ts\";\nimport { VibeError, unsupportedCapability } from \"./errors.ts\";\nimport { DIALECT_CAPABILITIES } from \"./capabilities.ts\";\nimport { RESERVED_COLUMN_PREFIX } from \"./reserved.ts\";\n\n// ─── Issue shape ──────────────────────────────────────────────────\n\nexport type ValidationIssue = {\n /** Stable rule id, e.g. \"duplicate-model\", \"unknown-relation-target\". */\n readonly rule: string;\n readonly message: string;\n readonly model?: string;\n readonly field?: string;\n};\n\n// ─── Validation ───────────────────────────────────────────────────\n\n// ─── Reserved enum names ───────────────────────────────────────────\n\n/**\n * Enum names that would collide with a name the generated client already\n * exports, imports or uses internally (`index.js` / `index.d.ts` / `enums.js` / `enums.d.ts`).\n * An enum `X` emits `X` (constant + literal union), `XFilter`,\n * `XNullableFilter`, `XListFilter` and `XValidator`, so the shared scalar\n * filter prefixes are reserved too: an enum named `String` would redefine\n * `StringFilter`. Mirrored by a generator test against the emitted output so\n * this list cannot silently fall behind the emitters.\n */\nexport const RESERVED_ENUM_NAMES: readonly string[] = [\n // Module-level names and helpers of the generated entries.\n \"sql\", \"decode\", \"sqlProjection\", \"sqlModels\", \"createSqlModel\", \"SqlColumn\", \"SqlFragment\", \"ResultDecoder\", \"ExtendedDateTime\",\n \"enumValidators\",\n \"enumValidator\",\n \"OmittedKeys\",\n \"ExactKeys\",\n \"PossibleKeys\",\n \"UncertainKeys\",\n \"HasSelectedField\",\n \"Provided\",\n \"ViewDelegateMap\",\n \"extensionManifest\",\n \"extensionMounts\",\n \"computedManifest\",\n // Globals referenced by generated values and declarations must not be shadowed.\n \"Object\", \"Set\", \"JSON\", \"Record\", \"Readonly\", \"ReadonlyArray\", \"Partial\",\n \"Omit\", \"NonNullable\", \"Promise\", \"PromiseLike\", \"Awaited\", \"TemplateStringsArray\",\n \"Date\", \"Uint8Array\",\n \"schema\",\n \"VibeClient\",\n \"VibeClientInstance\",\n \"VibeClientOptions\",\n \"VibeError\",\n \"VibeErrorCode\",\n \"BatchPayload\",\n \"UpsertManyPayload\",\n \"QueryMode\",\n \"RelationStrategy\",\n \"SortOrder\",\n \"SortOrderWithNulls\",\n \"KeysetToken\",\n \"KeysetOptions\",\n \"RowLockRequest\",\n \"JsonValue\",\n \"InputJsonValue\",\n \"InputJsonArray\",\n \"InputJsonObject\",\n \"VibeTelemetryOptions\",\n \"VibeTelemetryExporter\",\n \"VibeTelemetryOperationEvent\",\n \"VibeTelemetryStatementEvent\",\n \"VibeTelemetryHandle\",\n \"ScopedClientInstance\",\n \"ScopedModelsConfig\",\n \"ScopedNestedMode\",\n // EPIC 6 — the transaction and read-only client surfaces.\n \"VibeTransactionClientInstance\",\n \"ScopedTransactionClientInstance\",\n \"ReadOnlyClientInstance\",\n \"ViewClient\",\n \"ViewDefinitionInput\",\n \"ViewRow\",\n // Names the generated entries import.\n \"createClient\",\n \"DatabaseAdapter\",\n \"DbNow\",\n \"QueryEvent\",\n \"Skip\",\n \"TransactionOptions\",\n \"AdvisoryLockOptions\",\n \"StatementDiagnosticsOptions\",\n \"SchemaIR\",\n \"VibeExtension\",\n \"ComputedConfig\",\n \"WriteValidators\",\n // Scalar filter / update-operation prefixes.\n \"String\",\n \"Bool\",\n \"Int\",\n \"BigInt\",\n \"Float\",\n \"Decimal\",\n \"DateTime\",\n \"Json\",\n \"Bytes\",\n ...[\"String\", \"Bool\", \"Int\", \"BigInt\", \"Float\", \"Decimal\", \"DateTime\", \"Json\", \"Bytes\"].flatMap((prefix) =>\n [\"Filter\", \"NullableFilter\", \"ListFilter\"].map((suffix) => `${prefix}${suffix}`),\n ),\n ...[\"Int\", \"Float\", \"BigInt\", \"Decimal\"].flatMap((prefix) =>\n [`${prefix}FieldUpdateOperationsInput`, `Nullable${prefix}FieldUpdateOperationsInput`],\n ),\n];\n\n// Reserve complete generated type families, including private payload helpers.\n// The generator's namespace mirror feeds EVERY emitted name back through this\n// validation; it must not exclude enum/model-prefixed or unexported names.\nconst GENERATED_TYPE_NAMES: {\n readonly enumSuffixes: readonly string[];\n readonly modelSuffixes: readonly string[];\n readonly nestedPrefixes: readonly string[];\n} = {\n enumSuffixes: [\"\", \"Filter\", \"NullableFilter\", \"ListFilter\", \"Validator\"],\n modelSuffixes: [\n \"\", \"ScalarFieldEnum\", \"SelectableFieldEnum\", \"Relations\", \"CountSelect\", \"Select\", \"Include\", \"OmitInput\", \"Args\",\n \"ListRelationFilter\", \"RelationFilter\", \"WhereInput\", \"WhereUniqueInput\", \"OrderByInput\",\n \"ScalarOrderByInput\", \"RelationOrderByInput\", \"RelationFindManyArgs\",\n \"CreateInput\", \"UncheckedCreateInput\", \"CreateManyInput\", \"UpdateInput\", \"UncheckedUpdateInput\", \"UpdateManyInput\",\n \"CountAggregateInput\", \"AvgAggregateInput\", \"SumAggregateInput\", \"MinAggregateInput\", \"MaxAggregateInput\",\n \"FindManyArgs\", \"FindFirstArgs\", \"FindUniqueArgs\", \"CreateArgs\", \"ConflictTarget\", \"CreateOnConflictInput\",\n \"CreateOrSkipArgs\", \"CreateManyArgs\", \"CreateManyAndReturnArgs\", \"UpdateArgs\", \"UpdateManyArgs\",\n // EPIC 2 — conditional update + updateManyAndReturn derived names.\n \"UpdateWhereInput\", \"UpdateManyAndReturnArgs\", \"UpsertArgs\",\n // EPIC 10 — batched upsert.\n \"UpsertManyArgs\",\n \"DeleteArgs\", \"DeleteManyArgs\", \"CountArgs\", \"AggregateArgs\", \"GroupByArgs\", \"OmitBase\", \"CountResult\", \"CountPayload\",\n \"AggregateValues\", \"AggregateSelection\", \"CountOutput\",\n \"RelationPayload\", \"IncludePayload\", \"GetPayload\", \"AggregateResult\", \"GroupByResult\", \"Delegate\",\n \"ViewFields\", \"ViewSelect\", \"ViewInclude\", \"ViewNestedArgs\", \"ViewFindManyArgs\", \"ViewFindUniqueArgs\",\n \"ViewScalars\", \"ViewSelectScalars\", \"ViewReveal\", \"ViewRelationResult\", \"ViewIncludeResult\", \"ViewResult\", \"ViewDelegate\",\n // EPIC 6 — the read-only delegate is a SUFFIX form so this mirror covers it.\n \"ReadOnlyDelegate\",\n ],\n nestedPrefixes: [\n \"Create\", \"UncheckedCreate\", \"Update\", \"UncheckedUpdate\", \"ConnectOrCreate\",\n \"CreateNestedMany\", \"UpdateNestedMany\", \"CreateNestedOne\", \"UpdateNestedOne\",\n \"UpdateWithWhereUnique\", \"UpdateManyWithWhere\", \"UpsertWithWhereUnique\",\n ],\n};\n\nfunction validateGeneratedNames(params: { schema: SchemaIR; issues: ValidationIssue[] }): void {\n const { schema, issues } = params;\n const owners = new Map(RESERVED_ENUM_NAMES.map((name) => [name, \"generated client\"]));\n if (schema.rls !== undefined) {\n owners.set(\"RlsContext\", \"native RLS client\");\n owners.set(\"BoundVibeClientInstance\", \"native RLS client\");\n owners.set(\"BoundVibeTransactionClientInstance\", \"native RLS client\");\n }\n const register = (params: { name: string; owner: string }): void => {\n const previous = owners.get(params.name);\n if (previous !== undefined && previous !== params.owner) {\n issues.push({ rule: \"generated-name-collision\", message: `Generated name \"${params.name}\" from ${params.owner} conflicts with ${previous}` });\n } else {\n owners.set(params.name, params.owner);\n }\n };\n for (const model of schema.models) {\n const owner = `model \"${model.name}\"`;\n for (const suffix of GENERATED_TYPE_NAMES.modelSuffixes) register({ name: `${model.name}${suffix}`, owner });\n const withouts = [\"\", ...model.relations.map((relation) => `Without${relation.name.charAt(0).toUpperCase()}${relation.name.slice(1)}`)];\n for (const without of withouts) {\n for (const prefix of GENERATED_TYPE_NAMES.nestedPrefixes) register({ name: `${model.name}${prefix}${without}Input`, owner });\n }\n }\n for (const declared of schema.enums) {\n for (const suffix of GENERATED_TYPE_NAMES.enumSuffixes) register({ name: `${declared.name}${suffix}`, owner: `enum \"${declared.name}\"` });\n }\n}\n\n/** Validate a SchemaIR structurally; returns all issues found (empty = valid). */\nexport function validateSchemaIR(params: { schema: SchemaIR }): ValidationIssue[] {\n const { schema } = params;\n const issues: ValidationIssue[] = [];\n\n const modelByName = new Map<string, ModelIR>();\n for (const model of schema.models) {\n if (modelByName.has(model.name)) {\n issues.push({\n rule: \"duplicate-model\",\n message: `Duplicate model name \"${model.name}\"`,\n model: model.name,\n });\n } else {\n modelByName.set(model.name, model);\n }\n }\n\n const enumByName = new Map<string, EnumIR>();\n for (const enumDef of schema.enums) {\n if (enumByName.has(enumDef.name)) {\n issues.push({\n rule: \"duplicate-enum\",\n message: `Duplicate enum name \"${enumDef.name}\"`,\n });\n } else {\n enumByName.set(enumDef.name, enumDef);\n }\n if (enumDef.values.length === 0) {\n issues.push({\n rule: \"empty-enum\",\n message: `Enum \"${enumDef.name}\" has no values`,\n });\n }\n // Members are a set: the generated constant object and the membership\n // lookup both key on the value, so a repeat would silently collapse.\n const seenValues = new Set<string>();\n for (const value of enumDef.values) {\n if (seenValues.has(value)) {\n issues.push({\n rule: \"duplicate-enum-value\",\n message: `Enum \"${enumDef.name}\" lists value \"${value}\" more than once`,\n });\n }\n seenValues.add(value);\n }\n if (enumDef.storage !== undefined && !ENUM_STORAGES.includes(enumDef.storage)) {\n issues.push({\n rule: \"invalid-enum-storage\",\n message: `Enum \"${enumDef.name}\" has storage ${JSON.stringify(enumDef.storage)} — expected one of ${ENUM_STORAGES.join(\", \")}`,\n });\n }\n // Generated-name collisions: the client module exports one value AND one\n // type per enum, so an enum cannot share a model's name or a name the\n // module already exports/imports.\n if (modelByName.has(enumDef.name)) {\n issues.push({\n rule: \"enum-model-name-collision\",\n message: `Enum \"${enumDef.name}\" shares its name with a model — the generated client exports one type per name`,\n model: enumDef.name,\n });\n }\n if (RESERVED_ENUM_NAMES.includes(enumDef.name)) {\n issues.push({\n rule: \"enum-reserved-name\",\n message: `Enum \"${enumDef.name}\" collides with a name the generated client already exports or imports`,\n });\n }\n }\n\n for (const model of schema.models) {\n validateModel({ model, modelByName, enumByName, issues });\n }\n\n // Implicit SELF many-to-many: refused on every dialect, at the earliest\n // knowable moment (validation is shared by the parser, the DSL, generate,\n // db push and migrate, so no authoring path can slip past it).\n //\n // `implicitJoinTable` gives join column \"A\" to the lexicographically first\n // MODEL name. A self relation has one name on both sides, so both relation\n // fields claim \"A\" and traverse the join table in the same direction: the\n // inverse field returns the forward edge set. Rows already written through\n // either field carry that single orientation, so no corrected rule can\n // re-read them without silently changing what deployed data means. VibeORM\n // refuses the shape instead of answering wrongly; a directed self relation\n // is modelled with an explicit junction model.\n //\n // Detection is the ONE shared structural rule and never `relation.type`:\n // `db pull` represents a physical self join table as two unnamed `oneToMany`\n // list sides, and that shape has to refuse identically.\n for (const model of schema.models) {\n for (const relation of model.relations) {\n if (relation.targetModel !== model.name) continue;\n if (!isImplicitManyToManyRelation({ model, relation, models: schema.models })) continue;\n issues.push({\n rule: \"implicit-self-many-to-many\",\n message:\n `Relation \"${model.name}.${relation.name}\" is an implicit self many-to-many. Both sides of a self ` +\n `relation own the same join-table column, so this field and its inverse read the same rows. Replace ` +\n `it with an explicit junction model carrying one foreign key per direction, each under its own ` +\n `@relation name, and point \"${relation.name}\" at that model. Worked example, and the row copy for a ` +\n `join table that already exists: docs/queries.md, \"Directed self relations\".`,\n model: model.name,\n field: relation.name,\n });\n }\n }\n\n // Capability-gated index features, refused at validation — the earliest\n // knowable moment — instead of failing later at DDL time:\n // - partial predicates (where): postgres/pglite/sqlite only;\n // - UNIQUE NULLS NOT DISTINCT: postgres/pglite only (pg 15+), unique only.\n const provider = schema.datasource.provider;\n for (const model of schema.models) {\n for (const index of model.indexes) {\n if (index.where !== undefined && provider === \"mysql\") {\n issues.push({\n rule: \"partial-index-unsupported\",\n message: `Partial index (where) on \"${model.name}\" — mysql has no partial indexes; predicates are postgres/pglite/sqlite only`,\n model: model.name,\n });\n }\n if (index.nullsNotDistinct === true) {\n if (index.kind !== \"unique\") {\n issues.push({\n rule: \"nulls-not-distinct-non-unique\",\n message: `nullsNotDistinct on a non-unique index of \"${model.name}\" — the flag changes UNIQUE null semantics and means nothing elsewhere`,\n model: model.name,\n });\n }\n if (provider === \"sqlite\" || provider === \"mysql\") {\n issues.push({\n rule: \"nulls-not-distinct-unsupported\",\n message: `UNIQUE NULLS NOT DISTINCT on \"${model.name}\" — ${provider} treats NULLs as distinct and has no switch; the flag is postgres/pglite (15+) only`,\n model: model.name,\n });\n }\n }\n }\n }\n\n // `name:` on `@@unique` / `@@id` — the CLIENT selector name (the generated\n // `…WhereUniqueInput` property and the runtime where key). Everywhere it\n // cannot take effect it is refused loudly — never silently dropped (the\n // exact papercut this rule exists to prevent).\n for (const model of schema.models) {\n const fieldNames = new Set(model.fields.map((field) => field.name));\n const defaultKeys = new Set<string>();\n if (\n model.primaryKey !== undefined &&\n model.primaryKey.fields.length > 1 &&\n model.primaryKey.clientName === undefined\n ) {\n defaultKeys.add(model.primaryKey.fields.join(\"_\"));\n }\n for (const index of model.indexes) {\n if (\n index.kind === \"unique\" &&\n index.where === undefined &&\n index.fields.length > 1 &&\n index.clientName === undefined\n ) {\n defaultKeys.add(index.fields.map((field) => field.name).join(\"_\"));\n }\n }\n const seenSelectorNames = new Set<string>();\n const checkSelectorName = (params: {\n clientName: string;\n fieldCount: number;\n where?: string;\n isUnique: boolean;\n site: string;\n }): void => {\n const { clientName, fieldCount, where, isUnique, site } = params;\n if (!isUnique) {\n issues.push({\n rule: \"client-name-non-unique\",\n message: `name: (\"${clientName}\") on a non-unique index of \"${model.name}\" — a client selector names a UNIQUE group; use map: for the index's database name`,\n model: model.name,\n });\n return;\n }\n if (where !== undefined) {\n issues.push({\n rule: \"client-name-partial-unique\",\n message: `name: (\"${clientName}\") on a partial unique of \"${model.name}\" — a partial unique cannot address a row and never joins WhereUniqueInput`,\n model: model.name,\n });\n return;\n }\n if (fieldCount < 2) {\n issues.push({\n rule: \"client-name-single-field\",\n message: `name: (\"${clientName}\") on a single-field ${site} of \"${model.name}\" — the field itself is the selector; name: applies to compound groups only`,\n model: model.name,\n });\n return;\n }\n if (fieldNames.has(clientName) || defaultKeys.has(clientName) || seenSelectorNames.has(clientName)) {\n issues.push({\n rule: \"client-name-collision\",\n message: `name: (\"${clientName}\") on \"${model.name}\" collides with a field or another unique selector — WhereUniqueInput keys must be unambiguous`,\n model: model.name,\n });\n return;\n }\n seenSelectorNames.add(clientName);\n };\n if (model.primaryKey !== undefined && model.primaryKey.clientName !== undefined) {\n checkSelectorName({\n clientName: model.primaryKey.clientName,\n fieldCount: model.primaryKey.fields.length,\n isUnique: true,\n site: \"@@id\",\n });\n }\n for (const index of model.indexes) {\n if (index.clientName === undefined) continue;\n checkSelectorName({\n clientName: index.clientName,\n fieldCount: index.fields.length,\n ...(index.where === undefined ? {} : { where: index.where }),\n isUnique: index.kind === \"unique\",\n site: \"@@unique\",\n });\n }\n }\n\n validateGeneratedNames({ schema, issues });\n validateNativeRls({ schema, issues });\n return issues;\n}\n\nfunction validateModel(params: {\n model: ModelIR;\n modelByName: Map<string, ModelIR>;\n enumByName: Map<string, EnumIR>;\n issues: ValidationIssue[];\n}): void {\n const { model, modelByName, enumByName, issues } = params;\n\n // Field + relation names share one namespace on the model.\n const memberNames = new Set<string>();\n for (const field of model.fields) {\n if (memberNames.has(field.name)) {\n issues.push({\n rule: \"duplicate-field\",\n message: `Duplicate field \"${field.name}\" on model \"${model.name}\"`,\n model: model.name,\n field: field.name,\n });\n }\n memberNames.add(field.name);\n\n if (isEnumType(field.type)) {\n const enumDef = enumByName.get(field.type.enum);\n if (enumDef === undefined) {\n issues.push({\n rule: \"unknown-enum\",\n message: `Field \"${model.name}.${field.name}\" references unknown enum \"${field.type.enum}\"`,\n model: model.name,\n field: field.name,\n });\n } else {\n // A default must be a member — `@default(FOO)` (enumValue) and the\n // quoted `@default(\"FOO\")` (literal) spellings alike. Checked here,\n // once, for both schema sources.\n const defaultValue = field.default;\n const candidate =\n defaultValue === undefined\n ? undefined\n : defaultValue.kind === \"enumValue\"\n ? defaultValue.value\n : defaultValue.kind === \"literal\" && typeof defaultValue.value === \"string\"\n ? defaultValue.value\n : undefined;\n if (candidate !== undefined && !enumDef.values.includes(candidate)) {\n issues.push({\n rule: \"enum-default-not-member\",\n message: `Default \"${candidate}\" on \"${model.name}.${field.name}\" is not a member of enum \"${enumDef.name}\" (${enumDef.values.join(\", \")})`,\n model: model.name,\n field: field.name,\n });\n }\n }\n }\n\n // The runtime aliases its own projections (M2M stitch key `__vibe_parent`,\n // hidden order fields) under this prefix; a user column there would\n // collide and be silently misgrouped/stripped. `.prisma` field names\n // cannot start with `_`, but `@map` and hand-built IR can.\n const columnName = field.dbName ?? field.name;\n if (columnName.startsWith(RESERVED_COLUMN_PREFIX)) {\n issues.push({\n rule: \"reserved-column-prefix\",\n message:\n `Field \"${model.name}.${field.name}\" maps to column \"${columnName}\" — the \"${RESERVED_COLUMN_PREFIX}\" ` +\n `prefix is reserved for VibeORM's own projection aliases`,\n model: model.name,\n field: field.name,\n });\n }\n }\n\n for (const relation of model.relations) {\n if (memberNames.has(relation.name)) {\n issues.push({\n rule: \"duplicate-field\",\n message: `Relation \"${relation.name}\" collides with another member on model \"${model.name}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n memberNames.add(relation.name);\n }\n\n // Primary key presence (views are exempt).\n const fieldNames = new Set(model.fields.map((f) => f.name));\n const hasIdField = model.fields.some((f) => f.isId);\n if (!model.isView && !hasIdField && model.primaryKey === undefined) {\n issues.push({\n rule: \"missing-id\",\n message: `Model \"${model.name}\" has no @id field and no composite primary key`,\n model: model.name,\n });\n }\n if (model.primaryKey !== undefined) {\n for (const pkField of model.primaryKey.fields) {\n if (!fieldNames.has(pkField)) {\n issues.push({\n rule: \"unknown-pk-field\",\n message: `Composite primary key on \"${model.name}\" references unknown field \"${pkField}\"`,\n model: model.name,\n field: pkField,\n });\n }\n }\n }\n\n // Relations: target exists, FK columns exist both sides, arities match.\n for (const relation of model.relations) {\n const target = modelByName.get(relation.targetModel);\n if (target === undefined) {\n issues.push({\n rule: \"unknown-relation-target\",\n message: `Relation \"${model.name}.${relation.name}\" targets unknown model \"${relation.targetModel}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n\n const hasFields = relation.fields !== undefined && relation.fields.length > 0;\n const hasReferences = relation.references !== undefined && relation.references.length > 0;\n if (hasFields !== hasReferences) {\n issues.push({\n rule: \"relation-fields-mismatch\",\n message: `Relation \"${model.name}.${relation.name}\" must declare fields and references together`,\n model: model.name,\n field: relation.name,\n });\n }\n if (hasFields && hasReferences && relation.fields !== undefined && relation.references !== undefined) {\n if (relation.fields.length !== relation.references.length) {\n issues.push({\n rule: \"relation-fields-mismatch\",\n message: `Relation \"${model.name}.${relation.name}\" has ${relation.fields.length} fields but ${relation.references.length} references`,\n model: model.name,\n field: relation.name,\n });\n }\n for (const fkField of relation.fields) {\n if (!fieldNames.has(fkField)) {\n issues.push({\n rule: \"unknown-relation-field\",\n message: `Relation \"${model.name}.${relation.name}\" uses unknown field \"${fkField}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n }\n if (target !== undefined) {\n const targetFieldNames = new Set(target.fields.map((f) => f.name));\n for (const refField of relation.references) {\n if (!targetFieldNames.has(refField)) {\n issues.push({\n rule: \"unknown-relation-reference\",\n message: `Relation \"${model.name}.${relation.name}\" references unknown field \"${relation.targetModel}.${refField}\"`,\n model: model.name,\n field: relation.name,\n });\n }\n }\n }\n }\n }\n\n // @collation: String fields only — collation has no meaning off text.\n for (const field of model.fields) {\n if (field.collation !== undefined && field.type !== \"String\") {\n issues.push({\n rule: \"collation-non-string\",\n message: `@collation on \"${model.name}.${field.name}\" — collation is only valid on String fields`,\n model: model.name,\n field: field.name,\n });\n }\n }\n\n // @@policy: the field must exist and be a required, non-list scalar — an\n // optional scoping column cannot fail closed.\n if (model.policy !== undefined) {\n const policyField = model.fields.find((field) => field.name === model.policy?.field);\n if (policyField === undefined) {\n issues.push({\n rule: \"policy-unknown-field\",\n message: `@@policy on \"${model.name}\" references unknown field \"${model.policy.field}\"`,\n model: model.name,\n });\n } else if (policyField.isList) {\n issues.push({\n rule: \"policy-list-field\",\n message: `@@policy field \"${model.name}.${policyField.name}\" must be a non-list scalar`,\n model: model.name,\n field: policyField.name,\n });\n } else if (policyField.isOptional) {\n issues.push({\n rule: \"policy-optional-field\",\n message: `@@policy field \"${model.name}.${policyField.name}\" must be required — an optional scoping column cannot fail closed`,\n model: model.name,\n field: policyField.name,\n });\n }\n }\n\n // Checks: non-empty, and NAME-unique (names key the migration diff).\n const checkNames = new Set<string>();\n for (const check of model.checks ?? []) {\n if (check.name.trim() === \"\" || check.expression.trim() === \"\") {\n issues.push({\n rule: \"invalid-check\",\n message: `CHECK on \"${model.name}\" needs a non-empty name and expression`,\n model: model.name,\n });\n }\n if (checkNames.has(check.name)) {\n issues.push({\n rule: \"duplicate-check\",\n message: `Duplicate CHECK name \"${check.name}\" on \"${model.name}\" — names key the migration diff`,\n model: model.name,\n });\n }\n checkNames.add(check.name);\n if (check.predicate !== undefined) {\n validatePredicateFields({\n predicate: check.predicate,\n model,\n fieldNames,\n site: `CHECK \"${check.name}\"`,\n issues,\n });\n }\n }\n\n // Indexes reference real fields.\n for (const index of model.indexes) {\n for (const indexField of index.fields) {\n if (!fieldNames.has(indexField.name)) {\n issues.push({\n rule: \"unknown-index-field\",\n message: `Index on \"${model.name}\" references unknown field \"${indexField.name}\"`,\n model: model.name,\n field: indexField.name,\n });\n }\n }\n if (index.wherePredicate !== undefined) {\n validatePredicateFields({\n predicate: index.wherePredicate,\n model,\n fieldNames,\n site: `partial index on [${index.fields.map((entry) => entry.name).join(\", \")}]`,\n issues,\n });\n }\n }\n}\n\n/**\n * A typed predicate may only read fields its own model declares, and never a\n * scalar list — no dialect here compares an array column usefully in a CHECK or\n * an index predicate. Rendering refuses the same cases with the exact scalar in\n * hand; this is the IR-level floor that holds for hand-built IR too.\n */\nfunction validatePredicateFields(params: {\n predicate: PredicateIR;\n model: ModelIR;\n fieldNames: ReadonlySet<string>;\n site: string;\n issues: ValidationIssue[];\n}): void {\n const { predicate, model, fieldNames, site, issues } = params;\n for (const name of predicateFieldNames({ predicate })) {\n if (!fieldNames.has(name)) {\n issues.push({\n rule: \"predicate-unknown-field\",\n message: `${site} on \"${model.name}\" references unknown field \"${name}\"`,\n model: model.name,\n field: name,\n });\n continue;\n }\n if (model.fields.find((field) => field.name === name)?.isList === true) {\n issues.push({\n rule: \"predicate-list-field\",\n message: `${site} on \"${model.name}\" compares scalar list \"${name}\" — use a raw expression for array operators`,\n model: model.name,\n field: name,\n });\n }\n }\n}\n\nimport { assertMigrationObjects } from \"./migration-objects.ts\";\n\n// ─── Assertion form ───────────────────────────────────────────────\n\n/** Throw VIBE_SCHEMA_INVALID (with all issues in meta) if the schema is invalid. */\nexport function assertValidSchemaIR(params: { schema: SchemaIR }): void {\n const dialect = providerToDialect({ provider: params.schema.datasource.provider });\n for (const model of params.schema.models) {\n if (model.exclusions !== undefined && !Array.isArray(model.exclusions)) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"Exclusions must be an array\", meta: { rule: \"exclusion-definition\" } });\n if ((model.exclusions?.length ?? 0) === 0) continue;\n if (!DIALECT_CAPABILITIES[dialect].exclusionConstraints) throw unsupportedCapability({ dialect, feature: \"exclusionConstraints\" });\n const names = new Set<string>();\n const exclusions: readonly ExclusionIR[] = model.exclusions ?? [];\n for (const exclusion of exclusions) {\n if (exclusion === null || typeof exclusion !== \"object\") throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"Invalid exclusion declaration\", meta: { rule: \"exclusion-definition\" } });\n const source = exclusion.source;\n if (source !== undefined) {\n const references = [...source.keys.flatMap((key) => \"field\" in key ? [key.field] : key.fields), ...[source.range.lower, source.range.upper].flatMap((endpoint) => \"field\" in endpoint ? [endpoint.field] : []), ...(source.where === undefined ? [] : predicateFieldNames({ predicate: source.where }))];\n if (references.some((name) => !model.fields.some((field) => field.name === name && !field.isList))) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"Exclusion references an unknown or list field\", meta: { rule: \"exclusion-field\", model: model.name } });\n }\n if (!exclusion.name || names.has(exclusion.name) || typeof exclusion.definition !== \"string\" || !exclusion.definition.startsWith(\"EXCLUDE USING \") || !Array.isArray(exclusion.requiredExtensions) || exclusion.requiredExtensions.some((name) => name !== \"btree_gist\")) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: \"Invalid exclusion declaration\", meta: { rule: \"exclusion-definition\", model: model.name } });\n names.add(exclusion.name);\n }\n }\n if (params.schema.migrationObjects !== undefined) assertMigrationObjects({ objects: params.schema.migrationObjects });\n if (params.schema.rls !== undefined && !DIALECT_CAPABILITIES[dialect].nativeRowLevelSecurity) {\n throw unsupportedCapability({ dialect, feature: \"nativeRowLevelSecurity\" });\n }\n for (const model of params.schema.models) {\n const counters = model.fields.filter((field) => field.default?.kind === \"autoincrement\");\n if (dialect === \"mysql\" && counters.length > 1) throw unsupportedCapability({ dialect, feature: \"multiple auto-increment columns\" });\n for (const field of model.fields) {\n if (field.default?.kind === \"list\") {\n if (dialect !== \"postgres\") throw unsupportedCapability({ dialect, feature: \"scalar-list defaults\" });\n if (!field.isList) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `List default on non-list field ${model.name}.${field.name}` });\n scalarListDefault({ type: field.type, values: field.default.values });\n if (isEnumType(field.type)) {\n const name = field.type.enum;\n const members = params.schema.enums.find((entry) => entry.name === name)?.values ?? [];\n if (field.default.values.some((value) => typeof value !== \"string\" || !members.includes(value))) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `Invalid enum-list default on ${model.name}.${field.name}` });\n }\n }\n if (field.default?.kind !== \"autoincrement\") continue;\n if (field.isList || field.isOptional || (field.type !== \"Int\" && field.type !== \"BigInt\")) throw new VibeError({ code: \"VIBE_SCHEMA_INVALID\", message: `autoincrement requires a required scalar Int or BigInt: ${model.name}.${field.name}` });\n const pk = model.primaryKey?.fields ?? model.fields.filter((entry) => entry.isId).map((entry) => entry.name);\n if (dialect === \"sqlite\" && (pk.length !== 1 || pk[0] !== field.name)) throw unsupportedCapability({ dialect, feature: `non-primary auto-increment column ${model.name}.${field.name}` });\n if (dialect === \"mysql\" && pk[0] !== field.name && !field.isUnique && !model.indexes.some((index) => index.fields[0]?.name === field.name)) throw unsupportedCapability({ dialect, feature: `unindexed auto-increment column ${model.name}.${field.name}` });\n }\n }\n const issues = validateSchemaIR(params);\n if (issues.length > 0) {\n throw new VibeError({\n code: \"VIBE_SCHEMA_INVALID\",\n message: `Schema validation failed with ${issues.length} issue(s): ${issues\n .map((issue) => issue.message)\n .join(\"; \")}`,\n meta: { issues },\n });\n }\n}\n\n// ─── Native RLS structure ─────────────────────────────────────────\n\nfunction rlsRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null) &&\n Reflect.ownKeys(value).every((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n return typeof key === \"string\" && descriptor?.enumerable === true && \"value\" in descriptor;\n });\n}\n\nfunction rlsKeys(params: { value: Record<string, unknown>; keys: readonly string[] }): boolean {\n const own = Reflect.ownKeys(params.value);\n return own.length === params.keys.length && params.keys.every((key) => Object.hasOwn(params.value, key));\n}\n\n/** Validate context declarations independently (also used by settings rendering). */\nexport function validateRlsContextIR(params: { context: unknown }): ValidationIssue[] {\n const { context } = params;\n const issues: ValidationIssue[] = [];\n if (!rlsRecord(context)) return [{ rule: \"rls-invalid-context\", message: \"Native RLS context must be a named scalar-slot map\" }];\n const seen = new Set<string>();\n for (const key of Reflect.ownKeys(context)) {\n const slot: unknown = typeof key === \"string\" ? context[key] : undefined;\n if (typeof key !== \"string\" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(key) || seen.has(key.toLowerCase()) ||\n !rlsRecord(slot) || !rlsKeys({ value: slot, keys: [\"type\", \"nullable\"] }) || typeof slot.nullable !== \"boolean\" ||\n (typeof slot.type !== \"string\" || ![\"String\", \"Boolean\", \"Int\", \"BigInt\", \"Float\", \"Decimal\", \"DateTime\"].includes(slot.type))) {\n issues.push({ rule: \"rls-invalid-context\", message: `Invalid native RLS context slot ${String(key)}; use distinct setting keys and supported scalar slots with explicit nullable` });\n }\n if (typeof key === \"string\") seen.add(key.toLowerCase());\n }\n return issues;\n}\n\n/**\n * Shared structural implicit-M2M rule, including introspection's unnamed lists.\n * Each fieldless list must be the other's sole counterpart under the same\n * relation-name key, counting FK-owning candidates too. Never trust `type`:\n * ordinary mutual FKs also synthesize unnamed lists during introspection.\n */\nexport function isImplicitManyToManyRelation(params: {\n model: ModelIR;\n relation: RelationIR;\n models: readonly ModelIR[];\n}): boolean {\n const { model, relation, models } = params;\n if (model.isView || !relation.isList || (relation.fields?.length ?? 0) !== 0) return false;\n const target = models.find((candidate) => candidate.name === relation.targetModel);\n if (target === undefined || target.isView) return false;\n const counterpart = soleRelationCounterpart({ relation, ownModel: model.name, target });\n if (counterpart === undefined || !counterpart.isList || (counterpart.fields?.length ?? 0) !== 0) return false;\n return soleRelationCounterpart({ relation: counterpart, ownModel: target.name, target: model }) === relation;\n}\n\nfunction soleRelationCounterpart(params: { relation: RelationIR; ownModel: string; target: ModelIR }): RelationIR | undefined {\n const { relation, ownModel, target } = params;\n const candidates = target.relations.filter((candidate) =>\n candidate !== relation && candidate.targetModel === ownModel && candidate.relationName === relation.relationName,\n );\n return candidates.length === 1 ? candidates[0] : undefined;\n}\n\nfunction validateNativeRls(params: { schema: SchemaIR; issues: ValidationIssue[] }): void {\n const { schema, issues } = params;\n if (schema.rls === undefined) {\n if (schema.models.some((model) => model.rls !== undefined)) {\n issues.push({ rule: \"rls-missing-context\", message: \"Model RLS rules require a schema-level rls.context declaration\" });\n }\n return;\n }\n const dialect = providerToDialect({ provider: schema.datasource.provider });\n if (!DIALECT_CAPABILITIES[dialect].nativeRowLevelSecurity) {\n issues.push({ rule: \"rls-unsupported-capability\", message: `nativeRowLevelSecurity is not supported on ${dialect}` });\n }\n if (!rlsRecord(schema.rls) || !rlsKeys({ value: schema.rls, keys: [\"context\"] })) {\n issues.push({ rule: \"rls-invalid-context\", message: \"Native RLS supports only a schema-level context declaration\" });\n return;\n }\n const contextIssues = validateRlsContextIR({ context: schema.rls.context });\n issues.push(...contextIssues);\n const context = contextIssues.length === 0 ? schema.rls.context : undefined;\n const byName = new Map(schema.models.map((model) => [model.name, model]));\n const tables = new Set<string>();\n const throughTargets = new Map<string, string>();\n for (const model of schema.models) {\n const add = (params: { rule: string; message: string; field?: string }): void => {\n issues.push({ ...params, model: model.name });\n };\n const table = model.dbName ?? model.name;\n if (tables.has(table)) add({ rule: \"rls-duplicate-table\", message: `RLS models share physical table ${table}` });\n tables.add(table);\n const columns = new Set<string>();\n for (const field of model.fields) {\n const name = field.dbName ?? field.name;\n if (columns.has(name)) add({ rule: \"rls-duplicate-column\", message: `RLS model ${model.name} repeats physical column ${name}`, field: field.name });\n columns.add(name);\n }\n if (model.policy !== undefined) add({ rule: \"rls-policy-conflict\", message: \"Native RLS cannot combine with application-level ModelIR.policy\" });\n if (model.isView) add({ rule: \"rls-view-unsupported\", message: \"Database views are not supported on native RLS clients; remove the view declaration\" });\n if (model.rls === undefined) {\n add({ rule: \"rls-unclassified-model\", message: `Classify ${model.name} as where, through, unprotected or deny` });\n continue;\n }\n if (model.rls !== \"unprotected\") {\n for (const relation of model.relations) {\n if (isImplicitManyToManyRelation({ model, relation, models: schema.models })) {\n add({ rule: \"rls-implicit-many-to-many\", message: \"Protected implicit many-to-many relations need an explicit junction model with its own rule\", field: relation.name });\n }\n }\n }\n const rule: unknown = model.rls;\n if (rule === \"unprotected\" || rule === \"deny\") continue;\n if (!rlsRecord(rule)) {\n add({ rule: \"rls-invalid-rule\", message: \"Native RLS accepts where, through, unprotected or deny only\" });\n continue;\n }\n if (rlsKeys({ value: rule, keys: [\"where\"] }) && rlsRecord(rule.where) && Reflect.ownKeys(rule.where).length > 0) {\n for (const fieldName of Reflect.ownKeys(rule.where)) {\n const ref: unknown = typeof fieldName === \"string\" ? rule.where[fieldName] : undefined;\n if (!rlsRecord(ref) || !rlsKeys({ value: ref, keys: [\"context\"] }) || typeof ref.context !== \"string\") {\n add({ rule: \"rls-invalid-rule\", message: \"Ownership equality accepts a context reference only\" });\n continue;\n }\n const field = model.fields.find((f) => f.name === fieldName);\n if (field === undefined) {\n add({ rule: \"rls-unknown-field\", message: `Native RLS requires a direct scalar field, not path ${String(fieldName)}` });\n } else if (field.isList || field.isUnsupported || isEnumType(field.type) || field.type === \"Json\" || field.type === \"Bytes\") {\n add({ rule: \"rls-unsupported-field\", message: \"Native RLS ownership requires a supported non-list scalar\", field: field.name });\n } else if (context !== undefined) {\n const slot = Object.hasOwn(context, ref.context) ? context[ref.context] : undefined;\n if (slot === undefined) add({ rule: \"rls-unknown-context\", message: `Unknown native RLS context key ${ref.context}`, field: field.name });\n else if (slot.type !== field.type) add({ rule: \"rls-context-type-mismatch\", message: `Context ${ref.context} does not match ${model.name}.${field.name}`, field: field.name });\n }\n }\n continue;\n }\n if (rlsKeys({ value: rule, keys: [\"through\"] }) && typeof rule.through === \"string\") {\n const relation = model.relations.find((r) => r.name === rule.through);\n const target = relation === undefined ? undefined : byName.get(relation.targetModel);\n if (relation === undefined || target === undefined || relation.model !== model.name || relation.isList ||\n (relation.type !== \"oneToOne\" && relation.type !== \"manyToOne\") ||\n !validRlsForeignKey({ model, target, relation })) {\n add({ rule: \"rls-invalid-through\", message: \"Native RLS through requires a to-one relation with an actual, complete foreign key on this model\" });\n continue;\n }\n if (relation.isOptional || relation.fields?.some((name) => model.fields.find((field) => field.name === name)?.isOptional)) {\n add({ rule: \"rls-nullable-through\", message: \"Native RLS through requires a non-nullable parent relation and foreign key; NULL parent links cannot satisfy WITH CHECK. Make the link required or use a direct ownership rule\", field: relation.name });\n continue;\n }\n if (table === \"parent\") add({ rule: \"rls-through-alias-conflict\", message: \"A through table mapped to parent would shadow the fixed policy parent alias; use another table name\" });\n throughTargets.set(model.name, target.name);\n continue;\n }\n add({ rule: \"rls-invalid-rule\", message: \"Native RLS accepts a nonempty equality map or a single through relation; extra properties and operation-specific rules refuse\" });\n }\n for (const [origin, first] of throughTargets) {\n const seen = new Set([origin]);\n let current: string | undefined = first;\n while (current !== undefined && !seen.has(current)) {\n seen.add(current);\n const rule = byName.get(current)?.rls;\n if (rlsRecord(rule) && rlsKeys({ value: rule, keys: [\"where\"] })) break;\n current = throughTargets.get(current);\n }\n if (current === undefined || current === origin || (throughTargets.has(current) && seen.has(current))) {\n issues.push({ rule: \"rls-through-chain-invalid\", message: `Through chain from ${origin} must be acyclic and end in a direct where rule`, model: origin });\n }\n }\n}\n\nfunction validRlsForeignKey(params: { model: ModelIR; target: ModelIR; relation: RelationIR }): boolean {\n const { model, target, relation } = params;\n const fields = relation.fields;\n const refs = relation.references;\n if (fields === undefined || refs === undefined || fields.length === 0 || fields.length !== refs.length ||\n new Set(fields).size !== fields.length || new Set(refs).size !== refs.length) return false;\n const validFields = fields.every((name, index) => {\n const field = model.fields.find((f) => f.name === name);\n const ref = target.fields.find((f) => f.name === refs[index]);\n return field !== undefined && ref !== undefined && !field.isList && !ref.isList && !field.isUnsupported && !ref.isUnsupported &&\n (field.type === ref.type || (isEnumType(field.type) && isEnumType(ref.type) && field.type.enum === ref.type.enum));\n });\n const uniqueSets = [\n ...target.fields.filter((f) => f.isId || f.isUnique).map((f) => [f.name]),\n ...(target.primaryKey === undefined ? [] : [target.primaryKey.fields]),\n ...target.indexes.filter((index) => index.kind === \"unique\" && index.where === undefined).map((index) => index.fields.map((f) => f.name)),\n ];\n return validFields && uniqueSets.some((set) => set.length === refs.length && set.every((name) => refs.includes(name)));\n}\n",
14
16
  "/**\n * Implicit many-to-many join-table convention (Prisma-compatible).\n *\n * ONE shared rule for every consumer — runtime query building, migrate DDL,\n * introspection round-trip — per LEARNINGS: implicit-M2M conventions must never\n * be re-implemented per consumer.\n *\n * Convention (matches Prisma and v1):\n * - Relation key: the explicit relation name when both sides declare one,\n * else `${A}To${B}` with A, B the two model names sorted lexicographically.\n * - Table name: `_` + relation key (`_PostToTag`, `_tags`).\n * - Columns: `\"A\"` references the lexicographically-first model's primary key,\n * `\"B\"` the other.\n *\n * SELF relations are a degenerate case of that last rule and are REFUSED, not\n * supported: both sides carry the same model name, so the sort decides nothing\n * and both relation fields would own column `\"A\"` and read the join table in\n * the same direction. `validateSchemaIR` rejects the shape with\n * `implicit-self-many-to-many`, and the runtime relation planner carries a\n * backstop for IRs that never passed validation. This function still DERIVES a\n * self join table's name (`_XToX`) because introspection and the migration\n * differ have to recognise one that already exists in a database.\n */\n\nexport type ImplicitJoinTable = {\n /** Join table name, including the leading underscore. */\n readonly tableName: string;\n /** Model whose primary key column `\"A\"` references (sorts first). */\n readonly modelA: string;\n /** Model whose primary key column `\"B\"` references. */\n readonly modelB: string;\n /** Column names, fixed by the convention. */\n readonly columnA: \"A\";\n readonly columnB: \"B\";\n};\n\n/**\n * Resolve the join table for an implicit many-to-many relation between two\n * models. Argument order does not matter; the convention sorts internally.\n */\nexport function implicitJoinTable(params: {\n modelA: string;\n modelB: string;\n /** Explicit @relation name shared by both sides, when present. */\n relationName?: string;\n}): ImplicitJoinTable {\n const sorted = [params.modelA, params.modelB].sort();\n const first = sorted[0] as string;\n const second = sorted[1] as string;\n const key = params.relationName ?? `${first}To${second}`;\n return {\n tableName: `_${key}`,\n modelA: first,\n modelB: second,\n columnA: \"A\",\n columnB: \"B\",\n };\n}\n"
15
17
  ],
16
- "mappings": ";;AAoBO,IAAM,WAA+B,CAAC,YAAY,UAAU,OAAO;AAGnE,SAAS,iBAAiB,CAAC,QAAyC;AAAA,EACzE,QAAQ,aAAa;AAAA,EACrB,QAAQ;AAAA,SACD;AAAA,SACA;AAAA,MACH,OAAO;AAAA,SACJ;AAAA,MACH,OAAO;AAAA,SACJ;AAAA,MACH,OAAO;AAAA;AAAA;AAsBN,SAAS,UAAU,CAAC,WAA8D;AAAA,EACvF,OAAO,OAAO,cAAc,YAAY,UAAU;AAAA;AAyM7C,IAAM,gBAAwC,CAAC,YAAY,QAAQ;AAgBnE,SAAS,aAAa,CAAC,QAA2D;AAAA,EACvF,OAAO,OAAO,QAAQ,WAAW;AAAA;;ACtQ5B,IAAM,mBAAmB;AAAA,EAE9B;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAOA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AACF;AAAA;AAeO,MAAM,kBAAkB,MAAM;AAAA,EAC1B;AAAA,EACA;AAAA,EAET,WAAW,CAAC,QAKT;AAAA,IACD,MAAM,OAAO,SAAS,OAAO,UAAU,YAAY,YAAY,EAAE,OAAO,OAAO,MAAM,CAAC;AAAA,IACtF,KAAK,OAAO;AAAA,IACZ,KAAK,OAAO,OAAO;AAAA,IACnB,KAAK,OAAO,OAAO,QAAQ,CAAC;AAAA;AAEhC;AAKO,SAAS,qBAAqB,CAAC,QAIxB;AAAA,EACZ,QAAQ,SAAS,SAAS,SAAS;AAAA,EACnC,OAAO,IAAI,UAAU;AAAA,IACnB,MAAM;AA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