@prisma/orm-family-sql 8.0.0-rc.18-dev.36 → 8.0.0-rc.18-dev.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/{attribute-specs-CKPSK8oZ.d.mts → attribute-specs-D_fUYNiw.d.mts} +15 -8
  2. package/dist/attribute-specs-D_fUYNiw.d.mts.map +1 -0
  3. package/dist/{authoring-entity-types-DUQLeBf_-DmXuN7I3.d.mts → authoring-entity-types-DUQLeBf_-BZ1zRWGY.d.mts} +2 -2
  4. package/dist/{authoring-entity-types-DUQLeBf_-DmXuN7I3.d.mts.map → authoring-entity-types-DUQLeBf_-BZ1zRWGY.d.mts.map} +1 -1
  5. package/dist/{config-types-Dc7u9onO.mjs → config-types-CUWdUm6B.mjs} +2 -2
  6. package/dist/{config-types-Dc7u9onO.mjs.map → config-types-CUWdUm6B.mjs.map} +1 -1
  7. package/dist/{contract-builder-C7X80029.d.mts → contract-builder-Di-2-fFO.d.mts} +2 -2
  8. package/dist/{contract-builder-C7X80029.d.mts.map → contract-builder-Di-2-fFO.d.mts.map} +1 -1
  9. package/dist/{contract-builder-CKfnPa4C.mjs → contract-builder-DzzgwCZd.mjs} +20 -9
  10. package/dist/contract-builder-DzzgwCZd.mjs.map +1 -0
  11. package/dist/contract-prisma7__provider.mjs +69 -44
  12. package/dist/contract-prisma7__provider.mjs.map +1 -1
  13. package/dist/contract-psl.d.mts +2 -2
  14. package/dist/contract-psl.mjs +1 -1
  15. package/dist/contract-psl__attribute-specs.d.mts +2 -2
  16. package/dist/contract-psl__attribute-specs.mjs +2 -2
  17. package/dist/contract-psl__provider.mjs +2 -2
  18. package/dist/contract-psl__provider.mjs.map +1 -1
  19. package/dist/contract-ts.d.mts +1 -1
  20. package/dist/contract-ts.mjs +3 -3
  21. package/dist/contract-ts__config-types.mjs +1 -1
  22. package/dist/contract-ts__contract-builder.d.mts +1 -1
  23. package/dist/contract-ts__contract-builder.mjs +2 -2
  24. package/dist/contract.d.mts +2 -2
  25. package/dist/contract.mjs +4 -4
  26. package/dist/contract__data-type.d.mts +2 -2
  27. package/dist/contract__data-type.mjs +3 -3
  28. package/dist/contract__validators.mjs +1 -1
  29. package/dist/{control-B1Nyqky-.d.mts → control-LkQLqHHL.d.mts} +14 -31
  30. package/dist/control-LkQLqHHL.d.mts.map +1 -0
  31. package/dist/{control-adapter-BX5COBWO.mjs → control-adapter-DRlEXxsv.mjs} +2 -2
  32. package/dist/{control-adapter-BX5COBWO.mjs.map → control-adapter-DRlEXxsv.mjs.map} +1 -1
  33. package/dist/{control-jtTYvP_4.mjs → control-d-Dlrhh4.mjs} +38 -9
  34. package/dist/control-d-Dlrhh4.mjs.map +1 -0
  35. package/dist/{data-type-DMk-fLAZ.d.mts → data-type-BacIoCfv.d.mts} +11 -2
  36. package/dist/data-type-BacIoCfv.d.mts.map +1 -0
  37. package/dist/{data-type-HNhSslwG.mjs → data-type-CUJMZOHo.mjs} +2 -2
  38. package/dist/data-type-CUJMZOHo.mjs.map +1 -0
  39. package/dist/{derived-checks-CwbSfZ8d-B3-zWGv_.mjs → derived-checks-CwbSfZ8d-B91zqK6B.mjs} +3 -3
  40. package/dist/{derived-checks-CwbSfZ8d-B3-zWGv_.mjs.map → derived-checks-CwbSfZ8d-B91zqK6B.mjs.map} +1 -1
  41. package/dist/{diff-DDjcnhgw.d.mts → diff-CzUyZmJi.d.mts} +2 -2
  42. package/dist/{diff-DDjcnhgw.d.mts.map → diff-CzUyZmJi.d.mts.map} +1 -1
  43. package/dist/family.d.mts +7 -7
  44. package/dist/family.mjs +8 -8
  45. package/dist/family__control-adapter.mjs +1 -1
  46. package/dist/family__control.d.mts +3 -3
  47. package/dist/family__control.mjs +4 -4
  48. package/dist/family__diff.d.mts +1 -1
  49. package/dist/family__diff.mjs +1 -1
  50. package/dist/family__ir.mjs +1 -1
  51. package/dist/family__migration.d.mts +1 -1
  52. package/dist/family__pack.d.mts +2 -2
  53. package/dist/family__pack.mjs +3 -3
  54. package/dist/family__pack.mjs.map +1 -1
  55. package/dist/family__psl-build.d.mts +1 -1
  56. package/dist/family__psl-build.mjs +1 -1
  57. package/dist/{generator-functions-DIXj2u8w-B_EpEY8t.mjs → generator-functions-DErXcNG5-nKYm5qLY.mjs} +124 -67
  58. package/dist/generator-functions-DErXcNG5-nKYm5qLY.mjs.map +1 -0
  59. package/dist/{interpreter-Dq32sxoS-BcLhPY0_.mjs → interpreter-MPFufRkd-D0QvlLTq.mjs} +72 -18
  60. package/dist/interpreter-MPFufRkd-D0QvlLTq.mjs.map +1 -0
  61. package/dist/{migration-BZJFz90J.d.mts → migration-tfMTDejH.d.mts} +2 -2
  62. package/dist/{migration-BZJFz90J.d.mts.map → migration-tfMTDejH.d.mts.map} +1 -1
  63. package/dist/{pack-C4yN9ooT.d.mts → pack-74uFuOgh.d.mts} +48 -30
  64. package/dist/{pack-C4yN9ooT.d.mts.map → pack-74uFuOgh.d.mts.map} +1 -1
  65. package/dist/{psl-build-DzdzY3o1.mjs → psl-build-BSZQ8lC1.mjs} +5 -4
  66. package/dist/{psl-build-DzdzY3o1.mjs.map → psl-build-BSZQ8lC1.mjs.map} +1 -1
  67. package/dist/{psl-build-DETsH_kq.d.mts → psl-build-BkNvqSMz.d.mts} +4 -2
  68. package/dist/{psl-build-DETsH_kq.d.mts.map → psl-build-BkNvqSMz.d.mts.map} +1 -1
  69. package/dist/{psl-column-resolution-DNdqpUxt-CL8m5aC4.d.mts → psl-column-resolution-DNdqpUxt-DlQwgbqn.d.mts} +3 -3
  70. package/dist/{psl-column-resolution-DNdqpUxt-CL8m5aC4.d.mts.map → psl-column-resolution-DNdqpUxt-DlQwgbqn.d.mts.map} +1 -1
  71. package/dist/{psl-field-resolution-C8s57hFC-Bv6NiK8J.mjs → psl-field-resolution-BLtSah2i-BuuJ5H70.mjs} +21 -15
  72. package/dist/psl-field-resolution-BLtSah2i-BuuJ5H70.mjs.map +1 -0
  73. package/dist/{schema-verify-BwRdzbHb-BzdgK4xv.mjs → schema-verify-BwRdzbHb-DfFAS0EC.mjs} +2 -2
  74. package/dist/{schema-verify-BwRdzbHb-BzdgK4xv.mjs.map → schema-verify-BwRdzbHb-DfFAS0EC.mjs.map} +1 -1
  75. package/dist/{sql-contract-serializer-sMY3prTx-D-xfnqyD.mjs → sql-contract-serializer-sMY3prTx-CpZa5Nlt.mjs} +2 -2
  76. package/dist/{sql-contract-serializer-sMY3prTx-D-xfnqyD.mjs.map → sql-contract-serializer-sMY3prTx-CpZa5Nlt.mjs.map} +1 -1
  77. package/dist/{sql-data-type-D5cI3M07-DIcPP8s1.mjs → sql-data-type-D7M-YTTY-C9oWGZ3z.mjs} +16 -3
  78. package/dist/sql-data-type-D7M-YTTY-C9oWGZ3z.mjs.map +1 -0
  79. package/dist/{types-DKSRuPhK-DuxW_ceI.d.mts → types-CI5lled6-CDV4aYNB.d.mts} +2 -2
  80. package/dist/{types-DKSRuPhK-DuxW_ceI.d.mts.map → types-CI5lled6-CDV4aYNB.d.mts.map} +1 -1
  81. package/dist/{validators-BlONfdFH.mjs → validators-Cfy0jmZ2.mjs} +2 -2
  82. package/dist/{validators-BlONfdFH.mjs.map → validators-Cfy0jmZ2.mjs.map} +1 -1
  83. package/package.json +18 -18
  84. package/dist/attribute-specs-CKPSK8oZ.d.mts.map +0 -1
  85. package/dist/contract-builder-CKfnPa4C.mjs.map +0 -1
  86. package/dist/control-B1Nyqky-.d.mts.map +0 -1
  87. package/dist/control-jtTYvP_4.mjs.map +0 -1
  88. package/dist/data-type-DMk-fLAZ.d.mts.map +0 -1
  89. package/dist/data-type-HNhSslwG.mjs.map +0 -1
  90. package/dist/generator-functions-DIXj2u8w-B_EpEY8t.mjs.map +0 -1
  91. package/dist/interpreter-Dq32sxoS-BcLhPY0_.mjs.map +0 -1
  92. package/dist/psl-field-resolution-C8s57hFC-Bv6NiK8J.mjs.map +0 -1
  93. package/dist/sql-data-type-D5cI3M07-DIcPP8s1.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-builder-DzzgwCZd.mjs","names":["#handle"],"sources":["../../../../2-sql/2-authoring/contract-ts/dist/contract-builder.mjs"],"sourcesContent":["import { a as storedAsListColumn, i as isValueObjectMember, n as buildSqlContractFromDefinition, o as contractError, r as toOneNullabilityContradictionMessage, t as applySqlSpecifierControlPolicy } from \"./derived-checks-CwbSfZ8d.mjs\";\nimport { SqlExpression, isSqlExpression, readSqlExpression, requireSqlExpression, sql } from \"@internal/sql-contract/sql-expression\";\nimport { assertSafeAuthoringHelperKey, bindEnumType, composePackAuthoringNamespace, createEntityHelpersFromNamespace, createFieldHelpersFromNamespace, enumType, isEnumTypeHandle, member, resolveToOneRelationNullable } from \"@internal/contract-authoring\";\nimport { assertNoCrossRegistryCollisions, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringTypeConstructorDescriptor, validateAuthoringHelperArguments, validateAuthoringTypeParams } from \"@internal/framework-components/authoring\";\nimport { assembleGeneratorFunctions, createGeneratorHelpers } from \"@internal/framework-components/components\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { CODEC_INSTANCE_KIND } from \"@internal/sql-contract/types\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { isColumnDefault } from \"@internal/contract/types\";\nimport { checkSqlDefaultText, reservedSqlDefaultText } from \"@internal/sql-contract/validators\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { sqlColumnLength } from \"@internal/sql-contract/data-type\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { providesEntityHandleLowering } from \"@internal/sql-contract/entity-handle-lowering-hook\";\n//#region src/authoring-helper-runtime.ts\nfunction isNamedConstraintOptionsLike(value) {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\tif (Object.keys(value).some((key) => key !== \"name\")) return false;\n\tconst name = value.name;\n\treturn name === void 0 || typeof name === \"string\";\n}\nfunction createTypeHelpersFromNamespace(namespace, lookups, path = []) {\n\tconst helpers = {};\n\tfor (const [key, value] of Object.entries(namespace)) {\n\t\tassertSafeAuthoringHelperKey(key, path);\n\t\tconst currentPath = [...path, key];\n\t\tif (isAuthoringTypeConstructorDescriptor(value)) {\n\t\t\tconst helperPath = currentPath.join(\".\");\n\t\t\thelpers[key] = (...args) => {\n\t\t\t\tvalidateAuthoringHelperArguments(helperPath, value.args, args);\n\t\t\t\tconst output = instantiateAuthoringTypeConstructor(value, args);\n\t\t\t\tvalidateAuthoringTypeParams(helperPath, value.output, output.typeParams, lookups.codecLookup.descriptorFor(output.codecId)?.paramsSchema);\n\t\t\t\treturn {\n\t\t\t\t\tkind: CODEC_INSTANCE_KIND,\n\t\t\t\t\tcodecId: output.codecId,\n\t\t\t\t\ttypeParams: output.typeParams ?? {}\n\t\t\t\t};\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\t\thelpers[key] = createTypeHelpersFromNamespace(value, lookups, currentPath);\n\t}\n\treturn helpers;\n}\nfunction createFieldPresetHelper(options) {\n\treturn (...rawArgs) => {\n\t\tconst acceptsNamedConstraintOptions = options.descriptor.output.id === true || options.descriptor.output.unique === true;\n\t\tconst declaredArguments = options.descriptor.args ?? [];\n\t\tif (acceptsNamedConstraintOptions && rawArgs.length > declaredArguments.length + 1) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `${options.helperPath} expects at most ${declaredArguments.length + 1} argument(s), received ${rawArgs.length}`, { meta: {\n\t\t\thelperPath: options.helperPath,\n\t\t\texpected: declaredArguments.length + 1,\n\t\t\treceived: rawArgs.length\n\t\t} });\n\t\tlet args = rawArgs;\n\t\tlet namedConstraintOptions;\n\t\tif (acceptsNamedConstraintOptions && rawArgs.length === declaredArguments.length + 1) {\n\t\t\tconst maybeNamedConstraintOptions = rawArgs.at(-1);\n\t\t\tif (!isNamedConstraintOptionsLike(maybeNamedConstraintOptions)) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", `${options.helperPath} accepts an optional trailing { name?: string } constraint options object`, { meta: { helperPath: options.helperPath } });\n\t\t\tnamedConstraintOptions = maybeNamedConstraintOptions;\n\t\t\targs = rawArgs.slice(0, -1);\n\t\t}\n\t\tvalidateAuthoringHelperArguments(options.helperPath, options.descriptor.args, args);\n\t\tconst output = options.descriptor.output;\n\t\tvalidateAuthoringTypeParams(options.helperPath, output, instantiateAuthoringFieldPreset(options.descriptor, args).descriptor.typeParams, options.codecLookup.descriptorFor(output.codecId)?.paramsSchema);\n\t\treturn options.build({\n\t\t\targs,\n\t\t\t...namedConstraintOptions ? { namedConstraintOptions } : {}\n\t\t});\n\t};\n}\n//#endregion\n//#region src/contract-dsl.ts\nfunction withGeneratorCall(state, phase, call) {\n\tif (state.generatorCalls?.[phase] !== void 0 || state.executionDefaults?.[phase] !== void 0) throw contractError(\"CONTRACT.DEFAULT_INVALID\", `.${phase}() is called on a field that already generates a value ${phase === \"onCreate\" ? \"on create\" : \"on update\"}. Set each phase once, and do not combine .${phase}() with a field preset that sets it.`, { meta: {\n\t\treason: \"generator-phase-set-twice\",\n\t\tphase\n\t} });\n\treturn {\n\t\t...state,\n\t\tgeneratorCalls: {\n\t\t\t...state.generatorCalls,\n\t\t\t[phase]: call\n\t\t}\n\t};\n}\nfunction toColumnDefault(value) {\n\tconst expression = readSqlExpression(value);\n\tif (expression !== void 0) return sqlExpressionDefault(expression);\n\tif (isColumnDefault(value)) return value;\n\treturn {\n\t\tkind: \"literal\",\n\t\tvalue\n\t};\n}\nfunction sqlExpressionDefault(value) {\n\tconst reserved = reservedSqlDefaultText(value.text);\n\tif (reserved !== void 0) throw contractError(\"CONTRACT.DEFAULT_INVALID\", `Write .default(${reserved}()) instead of sql\\`${reserved}()\\`; ${reserved}() is a Prisma default function, not raw SQL.`, { meta: {\n\t\treason: \"reserved-function\",\n\t\texpression: value.text\n\t} });\n\tconst unsafe = checkSqlDefaultText(value.text);\n\tif (unsafe !== void 0) throw contractError(\"CONTRACT.DEFAULT_INVALID\", unsafe, { meta: {\n\t\treason: \"unsafe-sql\",\n\t\texpression: value.text\n\t} });\n\treturn {\n\t\tkind: \"function\",\n\t\texpression: value.text\n\t};\n}\nvar ScalarFieldBuilder = class ScalarFieldBuilder {\n\tstate;\n\tconstructor(state) {\n\t\tthis.state = state;\n\t}\n\t/**\n\t* Returns the physical column name when `.column(name)` was called, or\n\t* `undefined` when the field uses the default (logical field name) mapping.\n\t* Used by cross-space FK lowering to stamp the physical column name onto\n\t* `TargetFieldRef.columnName` so FK target columns are resolved correctly.\n\t*/\n\tget physicalColumnName() {\n\t\treturn this.state.columnName;\n\t}\n\toptional() {\n\t\treturn new ScalarFieldBuilder(blindCast({\n\t\t\t...this.state,\n\t\t\tnullable: true\n\t\t}));\n\t}\n\tcolumn(name) {\n\t\treturn new ScalarFieldBuilder(blindCast({\n\t\t\t...this.state,\n\t\t\tcolumnName: name\n\t\t}));\n\t}\n\tmany(options) {\n\t\treturn new ScalarFieldBuilder(blindCast({\n\t\t\t...this.state,\n\t\t\tmany: { elementNullable: options?.elementsNullable === true }\n\t\t}));\n\t}\n\tdefault(value) {\n\t\treturn blindCast(new ScalarFieldBuilder({\n\t\t\t...this.state,\n\t\t\tdefault: toColumnDefault(value)\n\t\t}));\n\t}\n\t/** Generates the field's value in the client when a row is created without one, with a call from `gen`, such as `gen.uuid()`. */\n\tonCreate(call) {\n\t\treturn blindCast(new ScalarFieldBuilder(withGeneratorCall(this.state, \"onCreate\", call)));\n\t}\n\t/** Generates the field's value in the client every time a row is updated, with a call from `gen`, such as `gen.now()`. */\n\tonUpdate(call) {\n\t\treturn new ScalarFieldBuilder(withGeneratorCall(this.state, \"onUpdate\", call));\n\t}\n\t/**\n\t* @deprecated Write `.default(now())` or `.default(autoincrement())`, or `` .default(sql`...`) `` for any other SQL. Removed in 8.0.0.\n\t*/\n\tdefaultSql(expression) {\n\t\treturn blindCast(new ScalarFieldBuilder({\n\t\t\t...this.state,\n\t\t\tdefault: {\n\t\t\t\tkind: \"function\",\n\t\t\t\texpression\n\t\t\t}\n\t\t}));\n\t}\n\tid(options) {\n\t\treturn new ScalarFieldBuilder(blindCast({\n\t\t\t...this.state,\n\t\t\tid: options?.name ? { name: options.name } : {}\n\t\t}));\n\t}\n\tunique(options) {\n\t\treturn new ScalarFieldBuilder(blindCast({\n\t\t\t...this.state,\n\t\t\tunique: options?.name ? { name: options.name } : {}\n\t\t}));\n\t}\n\tsql(spec) {\n\t\tconst idSpec = \"id\" in spec ? spec.id : void 0;\n\t\tconst uniqueSpec = \"unique\" in spec ? spec.unique : void 0;\n\t\tif (idSpec && !this.state.id) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"field.sql({ id }) requires an existing inline .id(...) declaration.\");\n\t\tif (uniqueSpec && !this.state.unique) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"field.sql({ unique }) requires an existing inline .unique(...) declaration.\");\n\t\treturn new ScalarFieldBuilder(blindCast({\n\t\t\t...this.state,\n\t\t\t...spec.column ? { columnName: spec.column } : {},\n\t\t\t...idSpec ? { id: { name: idSpec.name } } : {},\n\t\t\t...uniqueSpec ? { unique: { name: uniqueSpec.name } } : {}\n\t\t}));\n\t}\n\tbuild() {\n\t\treturn this.state;\n\t}\n};\nvar EnumScalarFieldBuilder = class EnumScalarFieldBuilder extends ScalarFieldBuilder {\n\t#handle;\n\tconstructor(state, handle) {\n\t\tsuper(state);\n\t\tthis.#handle = handle;\n\t}\n\tdefault(value) {\n\t\treturn blindCast(new EnumScalarFieldBuilder({\n\t\t\t...this.build(),\n\t\t\tdefault: {\n\t\t\t\tkind: \"literal\",\n\t\t\t\tvalue\n\t\t\t}\n\t\t}, this.#handle));\n\t}\n\tdefaultSql(_expression) {\n\t\tthrow contractError(\"CONTRACT.DEFAULT_INVALID\", \"defaultSql is not available on an enum field; use .default(members.X) instead\", { meta: { reason: \"defaultSql-on-enum-field\" } });\n\t}\n};\nconst columnField = (descriptor) => new ScalarFieldBuilder({\n\tkind: \"scalar\",\n\tdescriptor,\n\tnullable: false,\n\tmany: false\n});\nfunction generatedField(spec) {\n\treturn new ScalarFieldBuilder({\n\t\tkind: \"scalar\",\n\t\tdescriptor: blindCast({\n\t\t\t...spec.type,\n\t\t\t...spec.typeParams ? { typeParams: spec.typeParams } : {}\n\t\t}),\n\t\tnullable: false,\n\t\tmany: false,\n\t\texecutionDefaults: { onCreate: spec.generated }\n\t});\n}\nfunction untypedNamedTypeField(typeRef) {\n\tif (isEnumTypeHandle(typeRef)) return new EnumScalarFieldBuilder(blindCast({\n\t\tkind: \"scalar\",\n\t\ttypeRef,\n\t\tnullable: false,\n\t\tmany: false\n\t}), typeRef);\n\treturn new ScalarFieldBuilder({\n\t\tkind: \"scalar\",\n\t\ttypeRef,\n\t\tnullable: false,\n\t\tmany: false\n\t});\n}\nconst namedTypeField = blindCast(untypedNamedTypeField);\nfunction buildFieldPreset(descriptor, args, namedConstraintOptions) {\n\tconst preset = instantiateAuthoringFieldPreset(descriptor, args);\n\treturn new ScalarFieldBuilder({\n\t\tkind: \"scalar\",\n\t\tdescriptor: preset.descriptor,\n\t\tnullable: preset.nullable,\n\t\tmany: false,\n\t\t...ifDefined(\"default\", preset.default),\n\t\t...ifDefined(\"executionDefaults\", preset.executionDefaults),\n\t\t...preset.id ? { id: namedConstraintOptions?.name ? { name: namedConstraintOptions.name } : {} } : {},\n\t\t...preset.unique ? { unique: namedConstraintOptions?.name ? { name: namedConstraintOptions.name } : {} } : {}\n\t});\n}\nvar RelationBuilder = class RelationBuilder {\n\tstate;\n\tconstructor(state) {\n\t\tthis.state = state;\n\t}\n\tsql(spec) {\n\t\tif (this.state.kind !== \"belongsTo\") throw contractError(\"CONTRACT.RELATION_INVALID\", \"relation.sql(...) is only supported for belongsTo relations.\", { meta: { relationKind: this.state.kind } });\n\t\treturn new RelationBuilder({\n\t\t\t...this.state,\n\t\t\tsql: spec\n\t\t});\n\t}\n\tbuild() {\n\t\treturn this.state;\n\t}\n};\nfunction normalizeFieldRefInput(input) {\n\treturn (Array.isArray(input) ? input : [input]).map((ref) => ref.fieldName);\n}\nfunction normalizeTargetFieldRefInput(input) {\n\tconst refs = Array.isArray(input) ? input : [input];\n\tconst [first] = refs;\n\tif (!first) throw contractError(\"CONTRACT.FOREIGN_KEY_INVALID\", \"Expected at least one target ref\", { meta: { reason: \"empty-target-refs\" } });\n\tif (refs.some((ref) => ref.modelName !== first.modelName)) throw contractError(\"CONTRACT.FOREIGN_KEY_INVALID\", \"All target refs in a foreign key must point to the same model\", { meta: {\n\t\tmismatch: \"modelName\",\n\t\tmodels: refs.map((ref) => ref.modelName)\n\t} });\n\tif (refs.some((ref) => ref.spaceId !== first.spaceId)) throw contractError(\"CONTRACT.FOREIGN_KEY_INVALID\", `All target refs in a compound foreign key must share the same spaceId (found mismatch: \"${first.spaceId ?? \"<local>\"}\" vs \"${refs.find((r) => r.spaceId !== first.spaceId)?.spaceId ?? \"<local>\"}\")`, { meta: {\n\t\tmismatch: \"spaceId\",\n\t\tfirst: first.spaceId,\n\t\tsecond: refs.find((r) => r.spaceId !== first.spaceId)?.spaceId\n\t} });\n\tif (refs.some((ref) => ref.namespaceId !== first.namespaceId)) throw contractError(\"CONTRACT.FOREIGN_KEY_INVALID\", \"All target refs in a compound foreign key must share the same namespaceId (found mismatch)\", { meta: { mismatch: \"namespaceId\" } });\n\tif (refs.some((ref) => ref.tableName !== first.tableName)) throw contractError(\"CONTRACT.FOREIGN_KEY_INVALID\", \"All target refs in a compound foreign key must share the same tableName (found mismatch)\", { meta: { mismatch: \"tableName\" } });\n\treturn {\n\t\tmodelName: first.modelName,\n\t\tfieldNames: refs.map((ref) => ref.columnName ?? ref.fieldName),\n\t\tsource: refs.some((ref) => ref.source === \"string\") ? \"string\" : \"token\",\n\t\tspaceId: first.spaceId,\n\t\tnamespaceId: first.namespaceId,\n\t\ttableName: first.tableName\n\t};\n}\nfunction createConstraintsDsl() {\n\tfunction ref(modelName, fieldName) {\n\t\treturn {\n\t\t\tkind: \"targetFieldRef\",\n\t\t\tsource: \"string\",\n\t\t\tmodelName,\n\t\t\tfieldName\n\t\t};\n\t}\n\tfunction id(fieldOrFields, options) {\n\t\treturn {\n\t\t\tkind: \"id\",\n\t\t\tfields: normalizeFieldRefInput(fieldOrFields),\n\t\t\t...options?.name ? { name: options.name } : {}\n\t\t};\n\t}\n\tfunction unique(fieldOrFields, options) {\n\t\treturn {\n\t\t\tkind: \"unique\",\n\t\t\tfields: normalizeFieldRefInput(fieldOrFields),\n\t\t\t...options?.name ? { name: options.name } : {}\n\t\t};\n\t}\n\tfunction index(fieldsOrOptions, options) {\n\t\tconst isExpressionForm = !Array.isArray(fieldsOrOptions) && typeof fieldsOrOptions === \"object\" && \"expression\" in fieldsOrOptions;\n\t\tconst opts = isExpressionForm ? fieldsOrOptions : options;\n\t\tconst carried = {\n\t\t\tkind: \"index\",\n\t\t\t...opts?.name !== void 0 ? { name: opts.name } : {},\n\t\t\t...opts?.map !== void 0 ? { map: opts.map } : {},\n\t\t\t...opts?.where !== void 0 ? { where: opts.where } : {},\n\t\t\t...opts?.unique !== void 0 ? { unique: opts.unique } : {},\n\t\t\t...opts?.type !== void 0 ? { type: opts.type } : {},\n\t\t\t...opts?.options !== void 0 ? { options: blindCast(opts.options) } : {}\n\t\t};\n\t\treturn isExpressionForm ? {\n\t\t\t...carried,\n\t\t\texpression: fieldsOrOptions.expression\n\t\t} : {\n\t\t\t...carried,\n\t\t\tfields: normalizeFieldRefInput(fieldsOrOptions)\n\t\t};\n\t}\n\tfunction foreignKey(fieldOrFields, target, options) {\n\t\tconst normalizedTarget = normalizeTargetFieldRefInput(target);\n\t\treturn {\n\t\t\tkind: \"fk\",\n\t\t\tfields: normalizeFieldRefInput(fieldOrFields),\n\t\t\ttargetModel: normalizedTarget.modelName,\n\t\t\ttargetFields: normalizedTarget.fieldNames,\n\t\t\ttargetSource: normalizedTarget.source,\n\t\t\t...normalizedTarget.spaceId !== void 0 ? { targetSpaceId: normalizedTarget.spaceId } : {},\n\t\t\t...normalizedTarget.namespaceId !== void 0 ? { targetNamespaceId: normalizedTarget.namespaceId } : {},\n\t\t\t...normalizedTarget.tableName !== void 0 ? { targetTableName: normalizedTarget.tableName } : {},\n\t\t\t...options?.name ? { name: options.name } : {},\n\t\t\t...options?.onDelete ? { onDelete: options.onDelete } : {},\n\t\t\t...options?.onUpdate ? { onUpdate: options.onUpdate } : {},\n\t\t\t...options?.constraint !== void 0 ? { constraint: options.constraint } : {},\n\t\t\t...options?.index !== void 0 ? { index: options.index } : {}\n\t\t};\n\t}\n\treturn {\n\t\tref,\n\t\tid,\n\t\tunique,\n\t\tindex,\n\t\tforeignKey\n\t};\n}\n/**\n* Declares an authored CHECK constraint for a model's `.sql({ checks: [...] })`.\n* Unlike `index()`, `check()` names no column tuple — the predicate is opaque\n* SQL — so it needs no field-ref context and is a plain top-level function\n* rather than a method on `constraints`.\n*/\nfunction check(input) {\n\treturn {\n\t\tkind: \"check\",\n\t\texpression: input.expression,\n\t\t...input.name !== void 0 ? { name: input.name } : {},\n\t\t...input.map !== void 0 ? { map: input.map } : {}\n\t};\n}\nfunction createFieldRefs(fields) {\n\tconst refs = {};\n\tfor (const fieldName of Object.keys(fields)) refs[fieldName] = {\n\t\tkind: \"columnRef\",\n\t\tfieldName\n\t};\n\treturn refs;\n}\nfunction createModelTokenRefs(modelName, fields, crossSpaceCoordinate) {\n\tconst refs = {};\n\tfor (const [fieldName, fieldBuilder] of Object.entries(fields)) {\n\t\tconst physicalColumn = crossSpaceCoordinate !== void 0 ? fieldBuilder.physicalColumnName : void 0;\n\t\trefs[fieldName] = {\n\t\t\tkind: \"targetFieldRef\",\n\t\t\tsource: \"token\",\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\t...crossSpaceCoordinate !== void 0 ? {\n\t\t\t\tspaceId: crossSpaceCoordinate.spaceId,\n\t\t\t\t...crossSpaceCoordinate.namespaceId !== void 0 ? { namespaceId: crossSpaceCoordinate.namespaceId } : {},\n\t\t\t\t...crossSpaceCoordinate.tableName !== void 0 ? { tableName: crossSpaceCoordinate.tableName } : {},\n\t\t\t\t...physicalColumn !== void 0 ? { columnName: physicalColumn } : {}\n\t\t\t} : {}\n\t\t};\n\t}\n\treturn refs;\n}\nfunction buildStageSpec(stageInput, context) {\n\tif (typeof stageInput === \"function\") return stageInput(context);\n\treturn stageInput;\n}\nfunction createAttributeConstraintsDsl() {\n\tconst constraints = createConstraintsDsl();\n\treturn {\n\t\tid: constraints.id,\n\t\tunique: constraints.unique\n\t};\n}\nfunction createSqlConstraintsDsl() {\n\tconst constraints = createConstraintsDsl();\n\treturn {\n\t\tindex: constraints.index,\n\t\tforeignKey: constraints.foreignKey,\n\t\tref: constraints.ref\n\t};\n}\nfunction createColumnRefs(fields) {\n\treturn createFieldRefs(fields);\n}\nfunction findDuplicateRelationName(existingRelations, nextRelations) {\n\treturn Object.keys(nextRelations).find((relationName) => Object.hasOwn(existingRelations, relationName));\n}\nvar ContractModelBuilder = class ContractModelBuilder {\n\tstageOne;\n\tattributesFactory;\n\tsqlFactory;\n\tspaceId;\n\ttableName;\n\trefs;\n\tconstructor(stageOne, attributesFactory, sqlFactory, spaceId, tableName) {\n\t\tthis.stageOne = stageOne;\n\t\tthis.attributesFactory = attributesFactory;\n\t\tthis.sqlFactory = sqlFactory;\n\t\tthis.spaceId = spaceId;\n\t\tthis.tableName = tableName;\n\t\tconst crossSpaceCoordinate = spaceId !== void 0 ? {\n\t\t\tspaceId,\n\t\t\t...stageOne.namespace !== void 0 ? { namespaceId: stageOne.namespace } : {},\n\t\t\t...tableName !== void 0 ? { tableName } : {}\n\t\t} : void 0;\n\t\tthis.refs = blindCast(stageOne.modelName ? createModelTokenRefs(stageOne.modelName, stageOne.fields, crossSpaceCoordinate) : void 0);\n\t}\n\tref(fieldName) {\n\t\tconst modelName = this.stageOne.modelName;\n\t\tif (!modelName) throw contractError(\"CONTRACT.MODEL_TOKEN_INVALID\", \"Model tokens require model(\\\"ModelName\\\", ...) before calling .ref(...)\");\n\t\treturn {\n\t\t\tkind: \"targetFieldRef\",\n\t\t\tsource: \"token\",\n\t\t\tmodelName,\n\t\t\tfieldName\n\t\t};\n\t}\n\trelations(relations) {\n\t\tconst duplicateRelationName = findDuplicateRelationName(this.stageOne.relations, relations);\n\t\tif (duplicateRelationName) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Model \"${this.stageOne.modelName ?? \"<anonymous>\"}\" already defines relation \"${duplicateRelationName}\".`, { meta: {\n\t\t\tkind: \"relation\",\n\t\t\tname: duplicateRelationName,\n\t\t\tmodelName: this.stageOne.modelName\n\t\t} });\n\t\treturn new ContractModelBuilder({\n\t\t\t...this.stageOne,\n\t\t\trelations: {\n\t\t\t\t...this.stageOne.relations,\n\t\t\t\t...relations\n\t\t\t}\n\t\t}, this.attributesFactory, this.sqlFactory, this.spaceId, this.tableName);\n\t}\n\tattributes(specOrFactory) {\n\t\treturn blindCast(new ContractModelBuilder(this.stageOne, specOrFactory, this.sqlFactory, this.spaceId, this.tableName));\n\t}\n\tsql(specOrFactory) {\n\t\tconst nextTableName = typeof specOrFactory !== \"function\" ? specOrFactory.table : this.tableName;\n\t\treturn blindCast(new ContractModelBuilder(this.stageOne, this.attributesFactory, specOrFactory, this.spaceId, nextTableName));\n\t}\n\tbuildAttributesSpec() {\n\t\tif (!this.attributesFactory) return;\n\t\treturn buildStageSpec(this.attributesFactory, {\n\t\t\tfields: createFieldRefs(this.stageOne.fields),\n\t\t\tconstraints: createAttributeConstraintsDsl()\n\t\t});\n\t}\n\tbuildSqlSpec() {\n\t\tif (!this.sqlFactory) return;\n\t\treturn buildStageSpec(this.sqlFactory, {\n\t\t\tcols: createColumnRefs(this.stageOne.fields),\n\t\t\tconstraints: createSqlConstraintsDsl()\n\t\t});\n\t}\n};\nfunction isLazyRelationModelName(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value && value.kind === \"lazyRelationModelName\" && \"resolve\" in value && typeof value.resolve === \"function\";\n}\nfunction resolveNamedModelTokenName(token) {\n\tconst modelName = token.stageOne.modelName;\n\tif (!modelName) throw contractError(\"CONTRACT.MODEL_TOKEN_INVALID\", \"Relation targets require named model tokens. Use model(\\\"ModelName\\\", ...) before passing a token to rel.*(...).\");\n\treturn modelName;\n}\nfunction normalizeRelationModelSource(target) {\n\tif (typeof target === \"string\") return {\n\t\tkind: \"relationModelName\",\n\t\tsource: \"string\",\n\t\tmodelName: target\n\t};\n\tif (typeof target === \"function\") return {\n\t\tkind: \"lazyRelationModelName\",\n\t\tsource: \"lazyToken\",\n\t\tresolve: () => resolveNamedModelTokenName(target())\n\t};\n\treturn {\n\t\tkind: \"relationModelName\",\n\t\tsource: \"token\",\n\t\tmodelName: resolveNamedModelTokenName(target)\n\t};\n}\nfunction model(modelNameOrInput, maybeInput) {\n\tconst input = typeof modelNameOrInput === \"string\" ? maybeInput : modelNameOrInput;\n\tif (!input) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"model(\\\"ModelName\\\", ...) requires a model definition.\");\n\treturn new ContractModelBuilder({\n\t\t...typeof modelNameOrInput === \"string\" ? { modelName: modelNameOrInput } : {},\n\t\t...input.namespace !== void 0 ? { namespace: input.namespace } : {},\n\t\tfields: input.fields,\n\t\trelations: input.relations ?? {}\n\t});\n}\n/**\n* Factory for building a standalone branded extension model handle.\n*\n* Use this instead of `new ContractModelBuilder(…)` when constructing handles\n* for models that live in a foreign contract space (e.g. a Supabase extension\n* model referenced by a user's contract). The `spaceId` brands the returned\n* handle so `refs.<field>.spaceId` carries the foreign space identifier.\n*\n* @param name - The domain model name as declared in the foreign contract\n* (e.g. `'AuthUser'`, not a bare table alias like `'User'`).\n* @param input.namespace - The namespace within the foreign space (e.g. `'auth'`).\n* @param input.fields - Field definitions (use `field.column(…)`).\n* @param input.table - The physical table name in the foreign schema.\n* @param spaceId - The extension space identifier (e.g. `'supabase'`).\n*/\nfunction extensionModel(name, input, spaceId) {\n\treturn new ContractModelBuilder({\n\t\tmodelName: name,\n\t\tnamespace: input.namespace,\n\t\tfields: input.fields,\n\t\trelations: {}\n\t}, void 0, void 0, spaceId, input.table);\n}\nfunction isCrossSpaceHandle(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst rec = blindCast(value);\n\treturn typeof rec[\"spaceId\"] === \"string\" && typeof rec[\"stageOne\"] === \"object\" && rec[\"stageOne\"] !== null;\n}\nfunction belongsTo(toModel, options) {\n\tconst resolvedModel = typeof toModel === \"function\" ? toModel() : toModel;\n\tconst crossSpaceCoordinate = isCrossSpaceHandle(resolvedModel) ? {\n\t\tspaceId: resolvedModel.spaceId,\n\t\t...resolvedModel.tableName !== void 0 ? { tableName: resolvedModel.tableName } : {},\n\t\t...resolvedModel.stageOne.namespace !== void 0 ? { namespaceId: resolvedModel.stageOne.namespace } : {}\n\t} : void 0;\n\treturn new RelationBuilder({\n\t\tkind: \"belongsTo\",\n\t\ttoModel: normalizeRelationModelSource(toModel),\n\t\tfrom: options.from,\n\t\tto: options.to,\n\t\t...ifDefined(\"optional\", options.optional),\n\t\t...crossSpaceCoordinate !== void 0 ? crossSpaceCoordinate : {}\n\t});\n}\nfunction hasMany(toModel, options) {\n\treturn new RelationBuilder({\n\t\tkind: \"hasMany\",\n\t\ttoModel: normalizeRelationModelSource(toModel),\n\t\tby: options.by\n\t});\n}\nfunction hasOne(toModel, options) {\n\treturn new RelationBuilder({\n\t\tkind: \"hasOne\",\n\t\ttoModel: normalizeRelationModelSource(toModel),\n\t\tby: options.by\n\t});\n}\nfunction manyToMany(toModel, options) {\n\treturn new RelationBuilder({\n\t\tkind: \"manyToMany\",\n\t\ttoModel: normalizeRelationModelSource(toModel),\n\t\tthrough: normalizeRelationModelSource(options.through),\n\t\tfrom: options.from,\n\t\tto: options.to\n\t});\n}\nconst rel = {\n\tbelongsTo,\n\thasMany,\n\thasOne,\n\tmanyToMany\n};\nconst field = {\n\tcolumn: columnField,\n\tgenerated: generatedField,\n\tnamedType: namedTypeField\n};\nfunction isContractInput(value) {\n\tif (typeof value !== \"object\" || value === null || !(\"target\" in value) || !(\"family\" in value)) return false;\n\tconst target = value.target;\n\tconst family = value.family;\n\treturn typeof target === \"object\" && target !== null && \"kind\" in target && target.kind === \"target\" && typeof family === \"object\" && family !== null && \"kind\" in family && family.kind === \"family\";\n}\nfunction isRelationFieldArray(value) {\n\treturn Array.isArray(value);\n}\nfunction normalizeRelationFieldNames(value) {\n\tif (isRelationFieldArray(value)) return value;\n\treturn [value];\n}\nfunction resolveRelationModelName(value) {\n\tif (isLazyRelationModelName(value)) return value.resolve();\n\treturn value.modelName;\n}\nfunction applyNaming(name, strategy) {\n\tif (!strategy || strategy === \"identity\") return name;\n\tlet result = \"\";\n\tfor (let index = 0; index < name.length; index += 1) {\n\t\tconst char = name[index];\n\t\tif (!char) continue;\n\t\tconst lower = char.toLowerCase();\n\t\tif (char !== lower && index > 0) {\n\t\t\tconst prev = name[index - 1];\n\t\t\tconst next = name[index + 1];\n\t\t\tconst prevIsLower = !!prev && prev === prev.toLowerCase();\n\t\t\tconst nextIsLower = !!next && next === next.toLowerCase();\n\t\t\tif (prevIsLower || nextIsLower) result += \"_\";\n\t\t}\n\t\tresult += lower;\n\t}\n\treturn result;\n}\n//#endregion\n//#region src/composed-authoring-helpers.ts\nfunction composeTypeNamespace(components) {\n\treturn composePackAuthoringNamespace(components, \"type\");\n}\nfunction composeFieldNamespace(components) {\n\treturn composePackAuthoringNamespace(components, \"field\");\n}\nfunction composeEntityNamespace(components) {\n\treturn composePackAuthoringNamespace(components, \"entityTypes\");\n}\n/**\n* Reserved top-level keys on the composed helpers surface — the\n* built-in `model` / `rel` helpers, the `field` / `type` / `gen` namespace\n* objects. Pack-contributed entity types are flattened to the same\n* top-level shape (e.g. `helpers.enum({...})`), so a pack cannot\n* contribute an entity type whose name collides with one of these\n* reserved keys without silently overwriting at runtime. Detect the\n* collision at compose time and fail loudly with a guidance message.\n*/\nconst RESERVED_HELPER_KEYS = [\n\t\"field\",\n\t\"model\",\n\t\"rel\",\n\t\"type\",\n\t\"gen\"\n];\nfunction assertNoBuiltInEntityCollisions(namespace) {\n\tconst collisions = Object.keys(namespace).filter((name) => RESERVED_HELPER_KEYS.includes(name));\n\tif (collisions.length > 0) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Pack-contributed entity type(s) ${collisions.map((c) => `\"${c}\"`).join(\", \")} collide with the reserved built-in helper key(s) on the composed helpers surface. Reserved keys: ${RESERVED_HELPER_KEYS.map((k) => `\"${k}\"`).join(\", \")}.`, { meta: {\n\t\tcollisions,\n\t\treservedKeys: RESERVED_HELPER_KEYS\n\t} });\n}\nfunction createComposedFieldHelpers(fieldNamespace, lookups) {\n\tconst helperNamespace = createFieldHelpersFromNamespace(fieldNamespace, ({ helperPath, descriptor }) => createFieldPresetHelper({\n\t\thelperPath,\n\t\tdescriptor,\n\t\tcodecLookup: lookups.codecLookup,\n\t\tbuild: ({ args, namedConstraintOptions }) => buildFieldPreset(descriptor, args, namedConstraintOptions)\n\t}));\n\tconst coreFieldHelpers = {\n\t\tcolumn: field.column,\n\t\tgenerated: field.generated,\n\t\tnamedType: field.namedType\n\t};\n\tconst coreHelperNames = new Set(Object.keys(coreFieldHelpers));\n\tfor (const helperName of Object.keys(helperNamespace)) if (coreHelperNames.has(helperName)) throw contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Duplicate authoring field helper \"${helperName}\". Core field helpers reserve that name.`, { meta: { helperName } });\n\treturn {\n\t\t...coreFieldHelpers,\n\t\t...helperNamespace\n\t};\n}\nfunction createComposedAuthoringHelpers(options) {\n\tconst extensionValues = Object.values(options.extensions ?? {});\n\tconst components = [\n\t\toptions.family,\n\t\toptions.target,\n\t\t...extensionValues\n\t];\n\tconst typeNamespace = composeTypeNamespace(components);\n\tconst fieldNamespace = composeFieldNamespace(components);\n\tconst entityNamespace = composeEntityNamespace(components);\n\tassertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityNamespace);\n\tassertNoBuiltInEntityCollisions(entityNamespace);\n\treturn blindCast({\n\t\t...createEntityHelpersFromNamespace(entityNamespace, { ctx: {\n\t\t\tfamily: options.family.familyId,\n\t\t\ttarget: options.target.targetId,\n\t\t\tcodecLookup: options.codecLookup,\n\t\t\tdataTypeLookup: options.dataTypeLookup\n\t\t} }),\n\t\tfield: createComposedFieldHelpers(fieldNamespace, options),\n\t\tmodel,\n\t\trel,\n\t\ttype: createTypeHelpersFromNamespace(typeNamespace, options),\n\t\tgen: createGeneratorHelpers([\n\t\t\toptions.family,\n\t\t\toptions.target,\n\t\t\t...extensionValues\n\t\t])\n\t});\n}\n//#endregion\n//#region src/contract-warnings.ts\nfunction hasNamedModelToken(models, modelName) {\n\treturn models[modelName]?.stageOne.modelName === modelName;\n}\nfunction formatFieldSelection(fieldNames) {\n\tif (fieldNames.length === 1) return `'${fieldNames[0]}'`;\n\treturn `[${fieldNames.map((fieldName) => `'${fieldName}'`).join(\", \")}]`;\n}\nfunction formatTokenFieldSelection(modelName, fieldNames) {\n\tif (fieldNames.length === 1) return `${modelName}.refs.${fieldNames[0]}`;\n\treturn `[${fieldNames.map((fieldName) => `${modelName}.refs.${fieldName}`).join(\", \")}]`;\n}\nfunction formatConstraintsRefCall(modelName, fieldNames) {\n\tif (fieldNames.length === 1) return `constraints.ref('${modelName}', '${fieldNames[0]}')`;\n\treturn `[${fieldNames.map((fieldName) => `constraints.ref('${modelName}', '${fieldName}')`).join(\", \")}]`;\n}\nfunction formatRelationModelDisplay(relationModel) {\n\tif (relationModel.kind === \"lazyRelationModelName\") return `() => ${relationModel.resolve()}`;\n\treturn relationModel.source === \"string\" ? `'${relationModel.modelName}'` : relationModel.modelName;\n}\nfunction formatRelationCall(relation, targetModelDisplay) {\n\tif (relation.kind === \"belongsTo\") return `rel.belongsTo(${targetModelDisplay}, { from: ${formatFieldSelection(normalizeRelationFieldNames(relation.from))}, to: ${formatFieldSelection(normalizeRelationFieldNames(relation.to))} })`;\n\tif (relation.kind === \"hasMany\" || relation.kind === \"hasOne\") {\n\t\tconst by = formatFieldSelection(normalizeRelationFieldNames(relation.by));\n\t\treturn `rel.${relation.kind}(${targetModelDisplay}, { by: ${by} })`;\n\t}\n\treturn `rel.manyToMany(${targetModelDisplay}, { through: ${formatRelationModelDisplay(relation.through)}, from: ${formatFieldSelection(normalizeRelationFieldNames(relation.from))}, to: ${formatFieldSelection(normalizeRelationFieldNames(relation.to))} })`;\n}\nfunction formatManyToManyCallWithThrough(relation, throughDisplay) {\n\treturn `rel.manyToMany(${formatRelationModelDisplay(relation.toModel)}, { through: ${throughDisplay}, from: ${formatFieldSelection(normalizeRelationFieldNames(relation.from))}, to: ${formatFieldSelection(normalizeRelationFieldNames(relation.to))} })`;\n}\nconst WARNING_BATCH_THRESHOLD = 5;\nfunction flushWarnings(warnings) {\n\tif (warnings.length === 0) return;\n\tif (warnings.length <= WARNING_BATCH_THRESHOLD) {\n\t\tfor (const message of warnings) process.emitWarning(message, { code: \"PN_CONTRACT_TYPED_FALLBACK_AVAILABLE\" });\n\t\treturn;\n\t}\n\tprocess.emitWarning(`${warnings.length} contract references use string fallbacks where typed alternatives are available. Use named model tokens and typed storage type refs for autocomplete and type safety.\n` + warnings.map((w) => ` - ${w}`).join(\"\\n\"), { code: \"PN_CONTRACT_TYPED_FALLBACK_AVAILABLE\" });\n}\nfunction formatFallbackWarning(location, current, suggested) {\n\treturn `Contract ${location} uses ${current}. Use ${suggested} when the named model token is available in the same contract to keep typed relation targets and model refs.`;\n}\nfunction emitTypedNamedTypeFallbackWarnings(models, storageTypes) {\n\tconst warnings = [];\n\tconst warnedFields = /* @__PURE__ */ new Set();\n\tfor (const [modelName, modelDefinition] of Object.entries(models)) for (const [fieldName, fieldBuilder] of Object.entries(modelDefinition.stageOne.fields)) {\n\t\tconst fieldState = fieldBuilder.build();\n\t\tif (typeof fieldState.typeRef !== \"string\" || !(fieldState.typeRef in storageTypes)) continue;\n\t\tconst warningKey = `${modelName}.${fieldName}`;\n\t\tif (warnedFields.has(warningKey)) continue;\n\t\twarnedFields.add(warningKey);\n\t\twarnings.push(`Contract field \"${modelName}.${fieldName}\" uses field.namedType('${fieldState.typeRef}'). Use field.namedType(types.${fieldState.typeRef}) when the storage type is declared in the same contract to keep autocomplete and typed local refs.`);\n\t}\n\tflushWarnings(warnings);\n}\nfunction emitTypedCrossModelFallbackWarnings(collection) {\n\tconst warnings = [];\n\tconst warnedKeys = /* @__PURE__ */ new Set();\n\tfor (const spec of collection.modelSpecs.values()) {\n\t\tfor (const [relationName, relationBuilder] of Object.entries(spec.relations)) {\n\t\t\tconst relation = relationBuilder.build();\n\t\t\tif (relation.toModel.kind === \"relationModelName\" && relation.toModel.source === \"string\" && hasNamedModelToken(collection.models, relation.toModel.modelName)) {\n\t\t\t\tconst warningKey = `${spec.modelName}.${relationName}.toModel`;\n\t\t\t\tif (!warnedKeys.has(warningKey)) {\n\t\t\t\t\twarnedKeys.add(warningKey);\n\t\t\t\t\tconst current = formatRelationCall(relation, `'${relation.toModel.modelName}'`);\n\t\t\t\t\tconst suggested = formatRelationCall(relation, relation.toModel.modelName);\n\t\t\t\t\twarnings.push(formatFallbackWarning(`relation \"${spec.modelName}.${relationName}\"`, current, suggested));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (relation.kind === \"manyToMany\" && relation.through.kind === \"relationModelName\" && relation.through.source === \"string\" && hasNamedModelToken(collection.models, relation.through.modelName)) {\n\t\t\t\tconst warningKey = `${spec.modelName}.${relationName}.through`;\n\t\t\t\tif (!warnedKeys.has(warningKey)) {\n\t\t\t\t\twarnedKeys.add(warningKey);\n\t\t\t\t\tconst current = formatManyToManyCallWithThrough(relation, `'${relation.through.modelName}'`);\n\t\t\t\t\tconst suggested = formatManyToManyCallWithThrough(relation, relation.through.modelName);\n\t\t\t\t\twarnings.push(formatFallbackWarning(`relation \"${spec.modelName}.${relationName}\"`, current, suggested));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const [foreignKeyIndex, foreignKey] of (spec.sqlSpec?.foreignKeys ?? []).entries()) {\n\t\t\tif (foreignKey.targetSource !== \"string\" || !hasNamedModelToken(collection.models, foreignKey.targetModel)) continue;\n\t\t\tconst warningKey = `${spec.modelName}.sql.foreignKeys.${foreignKeyIndex}`;\n\t\t\tif (warnedKeys.has(warningKey)) continue;\n\t\t\twarnedKeys.add(warningKey);\n\t\t\tconst current = formatConstraintsRefCall(foreignKey.targetModel, foreignKey.targetFields);\n\t\t\tconst suggested = formatTokenFieldSelection(foreignKey.targetModel, foreignKey.targetFields);\n\t\t\twarnings.push(formatFallbackWarning(`model \"${spec.modelName}\"`, `${current} in .sql(...)`, suggested));\n\t\t}\n\t}\n\tflushWarnings(warnings);\n}\n//#endregion\n//#region src/contract-lowering.ts\nfunction buildStorageTypeReverseLookup(storageTypes) {\n\tconst lookup = /* @__PURE__ */ new Map();\n\tfor (const [key, instance] of Object.entries(storageTypes)) lookup.set(instance, key);\n\treturn lookup;\n}\nfunction resolveFieldDescriptor(modelName, fieldName, fieldState, storageTypes, storageTypeReverseLookup) {\n\tif (\"descriptor\" in fieldState && fieldState.descriptor) return fieldState.descriptor;\n\tif (\"typeRef\" in fieldState && fieldState.typeRef) {\n\t\tif (isEnumTypeHandle(fieldState.typeRef)) return { codecId: fieldState.typeRef.codecId };\n\t\tconst typeRef = typeof fieldState.typeRef === \"string\" ? fieldState.typeRef : storageTypeReverseLookup.get(fieldState.typeRef);\n\t\tif (!typeRef) throw contractError(\"CONTRACT.TYPE_UNKNOWN\", `Field \"${modelName}.${fieldName}\" references a storage type instance that is not present in definition.types`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\treason: \"instance-not-in-definition-types\"\n\t\t} });\n\t\tconst referencedType = storageTypes[typeRef];\n\t\tif (!referencedType) throw contractError(\"CONTRACT.TYPE_UNKNOWN\", `Field \"${modelName}.${fieldName}\" references unknown storage type \"${typeRef}\"`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\ttypeRef\n\t\t} });\n\t\treturn {\n\t\t\tcodecId: referencedType.codecId,\n\t\t\ttypeRef\n\t\t};\n\t}\n\tthrow contractError(\"CONTRACT.TYPE_UNKNOWN\", `Field \"${modelName}.${fieldName}\" does not resolve to a storage descriptor`, { meta: {\n\t\tmodelName,\n\t\tfieldName,\n\t\treason: \"unresolved-storage-descriptor\"\n\t} });\n}\nfunction mapFieldNamesToColumnNames(modelName, fieldNames, fieldToColumn) {\n\treturn fieldNames.map((fieldName) => {\n\t\tconst columnName = fieldToColumn[fieldName];\n\t\tif (!columnName) throw contractError(\"CONTRACT.FIELD_UNKNOWN\", `Unknown field \"${modelName}.${fieldName}\" in contract definition`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName\n\t\t} });\n\t\treturn columnName;\n\t});\n}\nfunction assertRelationFieldArity(params) {\n\tif (params.leftFields.length === params.rightFields.length) return;\n\tthrow contractError(\"CONTRACT.RELATION_INVALID\", `Relation \"${params.modelName}.${params.relationName}\" maps ${params.leftFields.length} ${params.leftLabel} field(s) to ${params.rightFields.length} ${params.rightLabel} field(s).`, { meta: {\n\t\tmodelName: params.modelName,\n\t\trelationName: params.relationName,\n\t\treason: \"field-count-mismatch\"\n\t} });\n}\nfunction resolveInlineIdConstraint(spec) {\n\tconst inlineIdFields = [];\n\tlet idName;\n\tfor (const [fieldName, fieldBuilder] of Object.entries(spec.fieldBuilders)) {\n\t\tconst fieldState = fieldBuilder.build();\n\t\tif (!fieldState.id) continue;\n\t\tinlineIdFields.push(fieldName);\n\t\tif (fieldState.id.name) idName = fieldState.id.name;\n\t}\n\tif (inlineIdFields.length === 0) return;\n\tif (inlineIdFields.length > 1) throw contractError(\"CONTRACT.IDENTITY_INVALID\", `Model \"${spec.modelName}\" marks multiple fields with .id(). Use .attributes(...) for compound identities.`, { meta: {\n\t\tmodelName: spec.modelName,\n\t\treason: \"multiple-inline-ids\",\n\t\tfields: inlineIdFields\n\t} });\n\tconst [inlineIdField] = inlineIdFields;\n\tif (!inlineIdField) return;\n\treturn {\n\t\tkind: \"id\",\n\t\tfields: [inlineIdField],\n\t\t...idName ? { name: idName } : {}\n\t};\n}\nfunction collectInlineUniqueConstraints(spec) {\n\tconst constraints = [];\n\tfor (const [fieldName, fieldBuilder] of Object.entries(spec.fieldBuilders)) {\n\t\tconst fieldState = fieldBuilder.build();\n\t\tif (!fieldState.unique) continue;\n\t\tconstraints.push({\n\t\t\tkind: \"unique\",\n\t\t\tfields: [fieldName],\n\t\t\t...fieldState.unique.name ? { name: fieldState.unique.name } : {}\n\t\t});\n\t}\n\treturn constraints;\n}\nfunction resolveModelIdConstraint(spec) {\n\tconst inlineId = resolveInlineIdConstraint(spec);\n\tconst attributeId = spec.attributesSpec?.id;\n\tif (inlineId && attributeId) throw contractError(\"CONTRACT.IDENTITY_INVALID\", `Model \"${spec.modelName}\" defines identity both inline and in .attributes(...). Pick one identity style.`, { meta: {\n\t\tmodelName: spec.modelName,\n\t\treason: \"inline-and-attributes\"\n\t} });\n\tconst resolvedId = attributeId ?? inlineId;\n\tif (resolvedId && resolvedId.fields.length === 0) throw contractError(\"CONTRACT.IDENTITY_INVALID\", `Model \"${spec.modelName}\" defines an empty identity. Add at least one field.`, { meta: {\n\t\tmodelName: spec.modelName,\n\t\treason: \"empty-identity\"\n\t} });\n\treturn resolvedId;\n}\nfunction resolveModelUniqueConstraints(spec) {\n\tconst attributeUniques = spec.attributesSpec?.uniques ?? [];\n\tfor (const unique of attributeUniques) if (unique.fields.length === 0) throw contractError(\"CONTRACT.CONSTRAINT_INVALID\", `Model \"${spec.modelName}\" defines an empty unique constraint. Add at least one field.`, { meta: { modelName: spec.modelName } });\n\treturn [...collectInlineUniqueConstraints(spec), ...attributeUniques];\n}\nfunction resolveRelationForeignKeys(spec, allSpecs) {\n\tconst foreignKeys = [];\n\tfor (const [relationName, relationBuilder] of Object.entries(spec.relations)) {\n\t\tconst relation = relationBuilder.build();\n\t\tif (relation.kind !== \"belongsTo\" || !relation.sql?.fk) continue;\n\t\tconst targetModelName = resolveRelationModelName(relation.toModel);\n\t\tif (relation.spaceId !== void 0) {\n\t\t\tconst fields = normalizeRelationFieldNames(relation.from);\n\t\t\tconst targetFields = normalizeRelationFieldNames(relation.to);\n\t\t\tassertRelationFieldArity({\n\t\t\t\tmodelName: spec.modelName,\n\t\t\t\trelationName,\n\t\t\t\tleftLabel: \"source\",\n\t\t\t\tleftFields: fields,\n\t\t\t\trightLabel: \"target\",\n\t\t\t\trightFields: targetFields\n\t\t\t});\n\t\t\tforeignKeys.push({\n\t\t\t\tkind: \"fk\",\n\t\t\t\tfields,\n\t\t\t\ttargetModel: targetModelName,\n\t\t\t\ttargetFields,\n\t\t\t\ttargetSpaceId: relation.spaceId,\n\t\t\t\t...relation.namespaceId !== void 0 ? { targetNamespaceId: relation.namespaceId } : {},\n\t\t\t\t...relation.tableName !== void 0 ? { targetTableName: relation.tableName } : {},\n\t\t\t\t...relation.sql.fk.name ? { name: relation.sql.fk.name } : {},\n\t\t\t\t...relation.sql.fk.onDelete ? { onDelete: relation.sql.fk.onDelete } : {},\n\t\t\t\t...relation.sql.fk.onUpdate ? { onUpdate: relation.sql.fk.onUpdate } : {},\n\t\t\t\t...relation.sql.fk.constraint !== void 0 ? { constraint: relation.sql.fk.constraint } : {},\n\t\t\t\t...relation.sql.fk.index !== void 0 ? { index: relation.sql.fk.index } : {}\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (!allSpecs.has(targetModelName)) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Relation \"${spec.modelName}.${relationName}\" references unknown model \"${targetModelName}\"`, { meta: {\n\t\t\tsourceModel: spec.modelName,\n\t\t\trelationName,\n\t\t\ttargetModel: targetModelName\n\t\t} });\n\t\tconst fields = normalizeRelationFieldNames(relation.from);\n\t\tconst targetFields = normalizeRelationFieldNames(relation.to);\n\t\tassertRelationFieldArity({\n\t\t\tmodelName: spec.modelName,\n\t\t\trelationName,\n\t\t\tleftLabel: \"source\",\n\t\t\tleftFields: fields,\n\t\t\trightLabel: \"target\",\n\t\t\trightFields: targetFields\n\t\t});\n\t\tforeignKeys.push({\n\t\t\tkind: \"fk\",\n\t\t\tfields,\n\t\t\ttargetModel: targetModelName,\n\t\t\ttargetFields,\n\t\t\t...relation.sql.fk.name ? { name: relation.sql.fk.name } : {},\n\t\t\t...relation.sql.fk.onDelete ? { onDelete: relation.sql.fk.onDelete } : {},\n\t\t\t...relation.sql.fk.onUpdate ? { onUpdate: relation.sql.fk.onUpdate } : {},\n\t\t\t...relation.sql.fk.constraint !== void 0 ? { constraint: relation.sql.fk.constraint } : {},\n\t\t\t...relation.sql.fk.index !== void 0 ? { index: relation.sql.fk.index } : {}\n\t\t});\n\t}\n\treturn foreignKeys;\n}\nfunction resolveRelationAnchorFields(spec) {\n\tconst idFields = spec.idConstraint?.fields;\n\tif (idFields && idFields.length > 0) return idFields;\n\tif (\"id\" in spec.fieldToColumn) return [\"id\"];\n\tthrow contractError(\"CONTRACT.IDENTITY_INVALID\", `Model \"${spec.modelName}\" needs an explicit id or an \"id\" field to anchor non-owning relations`, { meta: {\n\t\tmodelName: spec.modelName,\n\t\treason: \"missing-anchor-id\"\n\t} });\n}\nfunction belongsToNullable(relationName, declaredNullable, spec, fieldNames) {\n\tconst { nullable, contradiction } = resolveToOneRelationNullable({\n\t\tdeclaredNullable,\n\t\tlocalFieldNullability: fieldNames.map((fieldName) => spec.fieldBuilders[fieldName]?.build().nullable === true),\n\t\townsReference: true\n\t});\n\tif (contradiction !== void 0) throw contractError(\"CONTRACT.RELATION_INVALID\", toOneNullabilityContradictionMessage(`Relation \"${spec.modelName}.${relationName}\"`, contradiction), { meta: {\n\t\tmodelName: spec.modelName,\n\t\trelationName,\n\t\treason: \"to-one-nullability-mismatch\"\n\t} });\n\treturn nullable;\n}\nfunction lowerBelongsToRelation(relationName, relation, currentSpec, allSpecs, extensions) {\n\tconst targetModelName = resolveRelationModelName(relation.toModel);\n\tconst fromFields = normalizeRelationFieldNames(relation.from);\n\tconst toFields = normalizeRelationFieldNames(relation.to);\n\tassertRelationFieldArity({\n\t\tmodelName: currentSpec.modelName,\n\t\trelationName,\n\t\tleftLabel: \"source\",\n\t\tleftFields: fromFields,\n\t\trightLabel: \"target\",\n\t\trightFields: toFields\n\t});\n\tif (relation.spaceId !== void 0) {\n\t\tassertKnownExtensionPack(extensions, relation.spaceId, `Relation \"${currentSpec.modelName}.${relationName}\"`);\n\t\tconst parentColumns = mapFieldNamesToColumnNames(currentSpec.modelName, fromFields, currentSpec.fieldToColumn);\n\t\treturn {\n\t\t\tfieldName: relationName,\n\t\t\ttoModel: targetModelName,\n\t\t\ttoTable: relation.tableName,\n\t\t\tcardinality: \"N:1\",\n\t\t\tnullable: belongsToNullable(relationName, relation.optional, currentSpec, fromFields),\n\t\t\tspaceId: relation.spaceId,\n\t\t\t...relation.namespaceId !== void 0 ? { namespaceId: relation.namespaceId } : {},\n\t\t\ton: {\n\t\t\t\tparentTable: currentSpec.tableName,\n\t\t\t\tparentColumns,\n\t\t\t\tchildTable: relation.tableName,\n\t\t\t\tchildColumns: toFields\n\t\t\t}\n\t\t};\n\t}\n\tconst targetSpec = allSpecs.get(targetModelName);\n\tif (!targetSpec) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Relation \"${currentSpec.modelName}.${relationName}\" references unknown model \"${targetModelName}\"`, { meta: {\n\t\tsourceModel: currentSpec.modelName,\n\t\trelationName,\n\t\ttargetModel: targetModelName\n\t} });\n\treturn {\n\t\tfieldName: relationName,\n\t\ttoModel: targetModelName,\n\t\ttoTable: targetSpec.tableName,\n\t\tcardinality: \"N:1\",\n\t\tnullable: belongsToNullable(relationName, relation.optional, currentSpec, fromFields),\n\t\ton: {\n\t\t\tparentTable: currentSpec.tableName,\n\t\t\tparentColumns: mapFieldNamesToColumnNames(currentSpec.modelName, fromFields, currentSpec.fieldToColumn),\n\t\t\tchildTable: targetSpec.tableName,\n\t\t\tchildColumns: mapFieldNamesToColumnNames(targetSpec.modelName, toFields, targetSpec.fieldToColumn)\n\t\t}\n\t};\n}\nfunction lowerHasOwnershipRelation(relationName, relation, currentSpec, allSpecs) {\n\tconst targetModelName = resolveRelationModelName(relation.toModel);\n\tconst targetSpec = allSpecs.get(targetModelName);\n\tif (!targetSpec) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Relation \"${currentSpec.modelName}.${relationName}\" references unknown model \"${targetModelName}\"`, { meta: {\n\t\tsourceModel: currentSpec.modelName,\n\t\trelationName,\n\t\ttargetModel: targetModelName\n\t} });\n\tconst parentFields = resolveRelationAnchorFields(currentSpec);\n\tconst childFields = normalizeRelationFieldNames(relation.by);\n\tassertRelationFieldArity({\n\t\tmodelName: currentSpec.modelName,\n\t\trelationName,\n\t\tleftLabel: \"anchor\",\n\t\tleftFields: parentFields,\n\t\trightLabel: \"child\",\n\t\trightFields: childFields\n\t});\n\treturn {\n\t\tfieldName: relationName,\n\t\ttoModel: targetModelName,\n\t\ttoTable: targetSpec.tableName,\n\t\t...relation.kind === \"hasMany\" ? { cardinality: \"1:N\" } : {\n\t\t\tcardinality: \"1:1\",\n\t\t\tnullable: true\n\t\t},\n\t\ton: {\n\t\t\tparentTable: currentSpec.tableName,\n\t\t\tparentColumns: mapFieldNamesToColumnNames(currentSpec.modelName, parentFields, currentSpec.fieldToColumn),\n\t\t\tchildTable: targetSpec.tableName,\n\t\t\tchildColumns: mapFieldNamesToColumnNames(targetSpec.modelName, childFields, targetSpec.fieldToColumn)\n\t\t}\n\t};\n}\nfunction lowerManyToManyRelation(relationName, relation, currentSpec, allSpecs) {\n\tconst targetModelName = resolveRelationModelName(relation.toModel);\n\tconst targetSpec = allSpecs.get(targetModelName);\n\tif (!targetSpec) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Relation \"${currentSpec.modelName}.${relationName}\" references unknown model \"${targetModelName}\"`, { meta: {\n\t\tsourceModel: currentSpec.modelName,\n\t\trelationName,\n\t\ttargetModel: targetModelName\n\t} });\n\tconst throughModelName = resolveRelationModelName(relation.through);\n\tconst throughSpec = allSpecs.get(throughModelName);\n\tif (!throughSpec) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Relation \"${currentSpec.modelName}.${relationName}\" references unknown through model \"${throughModelName}\"`, { meta: {\n\t\tsourceModel: currentSpec.modelName,\n\t\trelationName,\n\t\ttargetModel: throughModelName\n\t} });\n\tconst currentAnchorFields = resolveRelationAnchorFields(currentSpec);\n\tconst targetAnchorFields = resolveRelationAnchorFields(targetSpec);\n\tconst throughFromFields = normalizeRelationFieldNames(relation.from);\n\tconst throughToFields = normalizeRelationFieldNames(relation.to);\n\tif (currentAnchorFields.length !== throughFromFields.length || targetAnchorFields.length !== throughToFields.length) throw contractError(\"CONTRACT.RELATION_INVALID\", `Relation \"${currentSpec.modelName}.${relationName}\" has mismatched many-to-many field counts.`, { meta: {\n\t\tmodelName: currentSpec.modelName,\n\t\trelationName,\n\t\treason: \"many-to-many-field-count-mismatch\"\n\t} });\n\treturn {\n\t\tfieldName: relationName,\n\t\ttoModel: targetModelName,\n\t\ttoTable: targetSpec.tableName,\n\t\tcardinality: \"N:M\",\n\t\tthrough: {\n\t\t\ttable: throughSpec.tableName,\n\t\t\t...ifDefined(\"namespaceId\", throughSpec.namespace),\n\t\t\tparentColumns: mapFieldNamesToColumnNames(throughSpec.modelName, throughFromFields, throughSpec.fieldToColumn),\n\t\t\tchildColumns: mapFieldNamesToColumnNames(throughSpec.modelName, throughToFields, throughSpec.fieldToColumn)\n\t\t},\n\t\ton: {\n\t\t\tparentTable: currentSpec.tableName,\n\t\t\tparentColumns: mapFieldNamesToColumnNames(currentSpec.modelName, currentAnchorFields, currentSpec.fieldToColumn),\n\t\t\tchildTable: throughSpec.tableName,\n\t\t\tchildColumns: mapFieldNamesToColumnNames(throughSpec.modelName, throughFromFields, throughSpec.fieldToColumn)\n\t\t}\n\t};\n}\nfunction resolveRelationNode(relationName, relation, currentSpec, allSpecs, extensions) {\n\tif (relation.kind === \"belongsTo\") return lowerBelongsToRelation(relationName, relation, currentSpec, allSpecs, extensions);\n\tif (relation.kind === \"hasMany\" || relation.kind === \"hasOne\") return lowerHasOwnershipRelation(relationName, relation, currentSpec, allSpecs);\n\treturn lowerManyToManyRelation(relationName, relation, currentSpec, allSpecs);\n}\nfunction lowerLocalForeignKeyNode(spec, targetSpec, foreignKey) {\n\treturn {\n\t\tcolumns: mapFieldNamesToColumnNames(spec.modelName, foreignKey.fields, spec.fieldToColumn),\n\t\treferences: {\n\t\t\tmodel: targetSpec.modelName,\n\t\t\ttable: targetSpec.tableName,\n\t\t\tcolumns: mapFieldNamesToColumnNames(targetSpec.modelName, foreignKey.targetFields, targetSpec.fieldToColumn)\n\t\t},\n\t\t...foreignKey.name ? { name: foreignKey.name } : {},\n\t\t...foreignKey.onDelete ? { onDelete: foreignKey.onDelete } : {},\n\t\t...foreignKey.onUpdate ? { onUpdate: foreignKey.onUpdate } : {},\n\t\t...foreignKey.constraint !== void 0 ? { constraint: foreignKey.constraint } : {},\n\t\t...foreignKey.index !== void 0 ? { index: foreignKey.index } : {}\n\t};\n}\nfunction lowerCrossSpaceForeignKeyNode(spec, foreignKey) {\n\tif (foreignKey.targetTableName === void 0) throw contractError(\"CONTRACT.FOREIGN_KEY_INVALID\", `Foreign key on \"${spec.modelName}\" references model \"${foreignKey.targetModel}\" in contract space \"${foreignKey.targetSpaceId}\" but the target table name is unknown: the handle's .sql() stage is a factory function, so its table cannot be read statically. Declare the target model's .sql() stage with a static object carrying \\`table\\`.`, { meta: {\n\t\tsourceModel: spec.modelName,\n\t\ttargetModel: foreignKey.targetModel,\n\t\tspaceId: foreignKey.targetSpaceId\n\t} });\n\treturn {\n\t\tcolumns: mapFieldNamesToColumnNames(spec.modelName, foreignKey.fields, spec.fieldToColumn),\n\t\treferences: {\n\t\t\tmodel: foreignKey.targetModel,\n\t\t\ttable: foreignKey.targetTableName,\n\t\t\tcolumns: foreignKey.targetFields,\n\t\t\t...foreignKey.targetNamespaceId !== void 0 ? { namespaceId: foreignKey.targetNamespaceId } : {},\n\t\t\tspaceId: foreignKey.targetSpaceId\n\t\t},\n\t\t...foreignKey.name ? { name: foreignKey.name } : {},\n\t\t...foreignKey.onDelete ? { onDelete: foreignKey.onDelete } : {},\n\t\t...foreignKey.onUpdate ? { onUpdate: foreignKey.onUpdate } : {},\n\t\t...foreignKey.constraint !== void 0 ? { constraint: foreignKey.constraint } : {},\n\t\t...foreignKey.index !== void 0 ? { index: foreignKey.index } : {}\n\t};\n}\nfunction assertKnownExtensionPack(extensions, spaceId, context) {\n\tif (extensions !== void 0 && Object.hasOwn(extensions, spaceId)) return;\n\tthrow contractError(\"CONTRACT.PACK_MISSING\", `${context} references contract space \"${spaceId}\" but \"${spaceId}\" is not declared in extensions. Add the pack to extensions.`, { meta: {\n\t\tspaceId,\n\t\tcontext\n\t} });\n}\nfunction resolveForeignKeyNodes(spec, allSpecs, extensions) {\n\tconst relationForeignKeys = resolveRelationForeignKeys(spec, allSpecs).map((foreignKey) => {\n\t\tif (foreignKey.targetSpaceId !== void 0) {\n\t\t\tassertKnownExtensionPack(extensions, foreignKey.targetSpaceId, `Relation-derived foreign key on \"${spec.modelName}\"`);\n\t\t\treturn lowerCrossSpaceForeignKeyNode(spec, {\n\t\t\t\t...foreignKey,\n\t\t\t\ttargetSpaceId: foreignKey.targetSpaceId\n\t\t\t});\n\t\t}\n\t\tconst targetSpec = allSpecs.get(foreignKey.targetModel);\n\t\tif (!targetSpec) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Foreign key on \"${spec.modelName}\" references unknown model \"${foreignKey.targetModel}\"`, { meta: {\n\t\t\tsourceModel: spec.modelName,\n\t\t\ttargetModel: foreignKey.targetModel\n\t\t} });\n\t\treturn lowerLocalForeignKeyNode(spec, targetSpec, foreignKey);\n\t});\n\tconst sqlForeignKeys = (spec.sqlSpec?.foreignKeys ?? []).map((foreignKey) => {\n\t\tif (foreignKey.targetSpaceId !== void 0) {\n\t\t\tassertKnownExtensionPack(extensions, foreignKey.targetSpaceId, `Foreign key on \"${spec.modelName}\"`);\n\t\t\treturn lowerCrossSpaceForeignKeyNode(spec, {\n\t\t\t\t...foreignKey,\n\t\t\t\ttargetSpaceId: foreignKey.targetSpaceId\n\t\t\t});\n\t\t}\n\t\tconst targetSpec = allSpecs.get(foreignKey.targetModel);\n\t\tif (!targetSpec) throw contractError(\"CONTRACT.MODEL_UNKNOWN\", `Foreign key on \"${spec.modelName}\" references unknown model \"${foreignKey.targetModel}\"`, { meta: {\n\t\t\tsourceModel: spec.modelName,\n\t\t\ttargetModel: foreignKey.targetModel\n\t\t} });\n\t\treturn lowerLocalForeignKeyNode(spec, targetSpec, foreignKey);\n\t});\n\treturn [...relationForeignKeys, ...sqlForeignKeys];\n}\n/**\n* Resolves a deferred index expression's field refs the way the field-tuple form\n* resolves its columns, and pairs each with the codec the column stores through\n* so a renderer can refuse a column it cannot express.\n*/\nfunction resolveDeferredColumns(spec, fieldNames, fieldCodecIds) {\n\tconst columnNames = mapFieldNamesToColumnNames(spec.modelName, fieldNames, spec.fieldToColumn);\n\treturn fieldNames.map((fieldName, position) => {\n\t\tconst name = columnNames[position];\n\t\tconst codecId = fieldCodecIds[fieldName];\n\t\tif (name === void 0 || codecId === void 0) throw new InternalError(`Deferred index expression on \"${spec.modelName}\" resolved no column for field \"${fieldName}\"`);\n\t\treturn {\n\t\t\tname,\n\t\t\tcodecId\n\t\t};\n\t});\n}\n/**\n* The text of an index expression. A string has no `render`, and `'render' in` a string throws a\n* `TypeError`, so the `sql` value is recognized first and anything else is refused last.\n*/\nfunction indexExpressionText(spec, expression, fieldCodecIds, owner) {\n\tconst sqlExpression = readSqlExpression(expression);\n\tif (sqlExpression !== void 0) return sqlExpression.text;\n\tif (typeof expression === \"object\" && expression !== null && \"render\" in expression) return renderedSqlText(expression.render(resolveDeferredColumns(spec, expression.fields.map((ref) => ref.fieldName), fieldCodecIds)), `${owner} expression`);\n\treturn requireSqlExpression(expression, `${owner} expression`).text;\n}\nfunction renderedSqlText(rendered, what) {\n\ttry {\n\t\treturn new SqlExpression(rendered).text;\n\t} catch (cause) {\n\t\tif (!isStructuredError(cause) || cause.code !== \"CONTRACT.SQL_EXPRESSION_INVALID\") throw cause;\n\t\tthrow contractError(\"CONTRACT.SQL_EXPRESSION_INVALID\", `${what}: ${cause.message}`, {\n\t\t\tmeta: {\n\t\t\t\twhat,\n\t\t\t\t...cause.meta\n\t\t\t},\n\t\t\tcause\n\t\t});\n\t}\n}\nfunction constraintOwner(kind, modelName, constraint) {\n\tconst name = constraint.name ?? constraint.map;\n\treturn name === void 0 ? `${kind} on \"${modelName}\"` : `${kind} \"${name}\"`;\n}\n/** The fields an index covers, in order: its own, or those of its deferred expression. */\nfunction coveredFieldNames(index) {\n\tif (index.fields !== void 0) return index.fields;\n\tconst { expression } = index;\n\tif (expression === void 0 || isSqlExpression(expression) || typeof expression !== \"object\") return [];\n\treturn expression.fields.map((ref) => ref.fieldName);\n}\n/**\n* The generators a field's `.onCreate(...)` and `.onUpdate(...)` calls resolve to for its column, merged over the phases a field preset or `field.generated(...)` sets.\n*/\nfunction resolveGeneratorCalls(input) {\n\tconst { modelName, fieldName, fieldState, descriptor, generatorFunctions } = input;\n\tconst calls = fieldState.generatorCalls;\n\tif (calls === void 0) return fieldState.executionDefaults;\n\tconst typeParams = descriptor.typeParams ?? (descriptor.typeRef === void 0 ? void 0 : input.storageTypes[descriptor.typeRef]?.typeParams);\n\tconst column = {\n\t\tcodecId: descriptor.codecId,\n\t\ttypeParams,\n\t\tlength: input.columnLength(descriptor.codecId, typeParams)\n\t};\n\tconst phases = { ...fieldState.executionDefaults };\n\tfor (const phase of [\"onCreate\", \"onUpdate\"]) {\n\t\tconst call = calls[phase];\n\t\tif (call === void 0) continue;\n\t\tif (fieldState.many !== false) throw contractError(\"CONTRACT.DEFAULT_INVALID\", `Field \"${modelName}.${fieldName}\" is a list and cannot use .${phase}(${call.name}()). Lists have no per-element generated values; remove .${phase}(...).`, { meta: {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\tcodecId: column.codecId,\n\t\t\tfunction: call.name,\n\t\t\treason: \"generator-on-list\"\n\t\t} });\n\t\tconst resolution = generatorFunctions.resolve(call, column);\n\t\tif (resolution.ok) {\n\t\t\tphases[phase] = resolution.generator;\n\t\t\tcontinue;\n\t\t}\n\t\tconst meta = {\n\t\t\tmodelName,\n\t\t\tfieldName,\n\t\t\tcodecId: column.codecId,\n\t\t\tfunction: call.name\n\t\t};\n\t\tif (resolution.reason === \"unknown-function\") throw contractError(\"CONTRACT.DEFAULT_INVALID\", `Field \"${modelName}.${fieldName}\": no pack in the contract declares the generator function \"${call.name}\".`, { meta: {\n\t\t\t...meta,\n\t\t\treason: \"generator-unknown\"\n\t\t} });\n\t\tconst applying = generatorFunctions.functionsFor(column.codecId).map(({ name }) => `${name}()`);\n\t\tthrow contractError(\"CONTRACT.DEFAULT_INVALID\", resolution.reason === \"refused\" ? `Field \"${modelName}.${fieldName}\": ${resolution.message}` : `Field \"${modelName}.${fieldName}\": ${call.name}() does not apply to codec \"${column.codecId}\". ${applying.length === 0 ? \"No generator function applies to this codec.\" : `Functions that apply: ${applying.join(\", \")}.`}`, { meta: {\n\t\t\t...meta,\n\t\t\treason: \"generator-not-applicable\"\n\t\t} });\n\t}\n\treturn phases;\n}\nfunction resolveModelNode(spec, allSpecs, storageTypes, storageTypeReverseLookup, generatorFunctions, columnLength, extensions) {\n\tconst fields = [];\n\t/** Filled by the field loop below, read by a deferred index expression. */\n\tconst fieldCodecIds = {};\n\tfor (const [fieldName, fieldBuilder] of Object.entries(spec.fieldBuilders)) {\n\t\tconst fieldState = fieldBuilder.build();\n\t\tconst descriptor = resolveFieldDescriptor(spec.modelName, fieldName, fieldState, storageTypes, storageTypeReverseLookup);\n\t\tconst columnName = spec.fieldToColumn[fieldName];\n\t\tif (!columnName) throw new InternalError(`Column name resolution failed for \"${spec.modelName}.${fieldName}\"`);\n\t\tfieldCodecIds[fieldName] = descriptor.codecId;\n\t\tconst enumHandle = \"typeRef\" in fieldState && isEnumTypeHandle(fieldState.typeRef) ? fieldState.typeRef : void 0;\n\t\tconst executionDefaults = resolveGeneratorCalls({\n\t\t\tmodelName: spec.modelName,\n\t\t\tfieldName,\n\t\t\tfieldState,\n\t\t\tdescriptor,\n\t\t\tstorageTypes,\n\t\t\tgeneratorFunctions,\n\t\t\tcolumnLength\n\t\t});\n\t\tfields.push({\n\t\t\tfieldName,\n\t\t\tcolumnName,\n\t\t\tdescriptor,\n\t\t\tnullable: fieldState.nullable,\n\t\t\tmany: fieldState.many !== false,\n\t\t\t...fieldState.many !== false ? { elementNullable: fieldState.many.elementNullable } : {},\n\t\t\t...fieldState.default ? { default: fieldState.default } : {},\n\t\t\t...ifDefined(\"executionDefaults\", executionDefaults),\n\t\t\t...enumHandle !== void 0 ? { enumTypeHandle: enumHandle } : {}\n\t\t});\n\t}\n\tconst { idConstraint } = spec;\n\tconst uniques = resolveModelUniqueConstraints(spec).map((unique) => ({\n\t\tcolumns: mapFieldNamesToColumnNames(spec.modelName, unique.fields, spec.fieldToColumn),\n\t\t...unique.name ? { name: unique.name } : {}\n\t}));\n\tconst indexes = (spec.sqlSpec?.indexes ?? []).map((index) => {\n\t\tconst options = typeof index.options === \"function\" ? index.options(resolveDeferredColumns(spec, coveredFieldNames(index), fieldCodecIds)) : index.options;\n\t\tconst method = blindCast({\n\t\t\ttype: index.type,\n\t\t\toptions\n\t\t});\n\t\tconst owner = constraintOwner(\"Index\", spec.modelName, index);\n\t\tconst carried = {\n\t\t\twhere: index.where === void 0 ? void 0 : requireSqlExpression(index.where, `${owner} where`).text,\n\t\t\tunique: index.unique,\n\t\t\tname: index.name,\n\t\t\tmap: index.map,\n\t\t\t...method\n\t\t};\n\t\treturn index.expression !== void 0 ? {\n\t\t\t...carried,\n\t\t\texpression: indexExpressionText(spec, index.expression, fieldCodecIds, owner)\n\t\t} : {\n\t\t\t...carried,\n\t\t\tcolumns: mapFieldNamesToColumnNames(spec.modelName, index.fields ?? [], spec.fieldToColumn)\n\t\t};\n\t});\n\tconst checks = (spec.sqlSpec?.checks ?? []).map((authoredCheck) => ({\n\t\texpression: requireSqlExpression(authoredCheck.expression, `${constraintOwner(\"Check\", spec.modelName, authoredCheck)} expression`).text,\n\t\tname: authoredCheck.name,\n\t\tmap: authoredCheck.map\n\t}));\n\tconst foreignKeys = resolveForeignKeyNodes(spec, allSpecs, extensions);\n\tconst relations = Object.entries(spec.relations).map(([relationName, relationBuilder]) => resolveRelationNode(relationName, relationBuilder.build(), spec, allSpecs, extensions));\n\treturn {\n\t\tmodelName: spec.modelName,\n\t\ttableName: spec.tableName,\n\t\t...spec.namespace !== void 0 ? { namespaceId: spec.namespace } : {},\n\t\tfields,\n\t\t...idConstraint ? { id: {\n\t\t\tcolumns: mapFieldNamesToColumnNames(spec.modelName, idConstraint.fields, spec.fieldToColumn),\n\t\t\t...idConstraint.name ? { name: idConstraint.name } : {}\n\t\t} } : {},\n\t\t...uniques.length > 0 ? { uniques } : {},\n\t\t...indexes.length > 0 ? { indexes } : {},\n\t\t...checks.length > 0 ? { checks } : {},\n\t\t...foreignKeys.length > 0 ? { foreignKeys } : {},\n\t\t...relations.length > 0 ? { relations } : {},\n\t\t...ifDefined(\"control\", spec.sqlSpec?.control)\n\t};\n}\nfunction columnLengthOf(definition) {\n\tconst { codecLookup, dataTypeLookup } = definition;\n\treturn (codecId, typeParams) => {\n\t\tconst dataTypeId = codecLookup.descriptorFor(codecId)?.dataType;\n\t\treturn sqlColumnLength(dataTypeId === void 0 ? void 0 : dataTypeLookup.get(dataTypeId), typeParams);\n\t};\n}\nfunction collectRuntimeModelSpecs(definition) {\n\tconst storageTypes = { ...definition.types ?? {} };\n\tconst models = { ...definition.models ?? {} };\n\temitTypedNamedTypeFallbackWarnings(models, storageTypes);\n\tconst modelSpecs = /* @__PURE__ */ new Map();\n\tconst tableOwners = /* @__PURE__ */ new Map();\n\tfor (const [modelName, modelDefinition] of Object.entries(models)) {\n\t\tconst tokenModelName = modelDefinition.stageOne.modelName;\n\t\tif (tokenModelName && tokenModelName !== modelName) throw contractError(\"CONTRACT.MODEL_TOKEN_INVALID\", `Model token \"${tokenModelName}\" must be assigned to models.${tokenModelName}. Received models.${modelName}.`, { meta: {\n\t\t\ttokenModelName,\n\t\t\tassignedKey: modelName\n\t\t} });\n\t\tconst attributesSpec = modelDefinition.buildAttributesSpec();\n\t\tconst sqlSpec = modelDefinition.buildSqlSpec();\n\t\tconst tableName = sqlSpec?.table ?? applyNaming(modelName, definition.naming?.tables);\n\t\tconst namespaceId = modelDefinition.stageOne.namespace ?? definition.target.defaultNamespaceId;\n\t\tconst tableKey = JSON.stringify([namespaceId, tableName]);\n\t\tconst existingModel = tableOwners.get(tableKey);\n\t\tif (existingModel) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Models \"${existingModel}\" and \"${modelName}\" both map to table \"${tableName}\".`, { meta: {\n\t\t\tkind: \"table\",\n\t\t\tname: tableName,\n\t\t\tfirst: existingModel,\n\t\t\tsecond: modelName\n\t\t} });\n\t\ttableOwners.set(tableKey, modelName);\n\t\tconst fieldToColumn = {};\n\t\tconst columnOwners = /* @__PURE__ */ new Map();\n\t\tfor (const [fieldName, fieldBuilder] of Object.entries(modelDefinition.stageOne.fields)) {\n\t\t\tconst columnName = fieldBuilder.build().columnName ?? applyNaming(fieldName, definition.naming?.columns);\n\t\t\tconst existingField = columnOwners.get(columnName);\n\t\t\tif (existingField) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `Model \"${modelName}\" maps both \"${existingField}\" and \"${fieldName}\" to column \"${columnName}\".`, { meta: {\n\t\t\t\tkind: \"column\",\n\t\t\t\tname: columnName,\n\t\t\t\tfirst: existingField,\n\t\t\t\tsecond: fieldName\n\t\t\t} });\n\t\t\tcolumnOwners.set(columnName, fieldName);\n\t\t\tfieldToColumn[fieldName] = columnName;\n\t\t}\n\t\tconst fieldBuilders = modelDefinition.stageOne.fields;\n\t\tconst idConstraint = resolveModelIdConstraint({\n\t\t\tmodelName,\n\t\t\tfieldBuilders,\n\t\t\tattributesSpec\n\t\t});\n\t\tmodelSpecs.set(modelName, {\n\t\t\tmodelName,\n\t\t\ttableName,\n\t\t\tnamespace: modelDefinition.stageOne.namespace,\n\t\t\tfieldBuilders,\n\t\t\tfieldToColumn,\n\t\t\trelations: modelDefinition.stageOne.relations,\n\t\t\tattributesSpec,\n\t\t\tsqlSpec,\n\t\t\tidConstraint\n\t\t});\n\t}\n\treturn {\n\t\tstorageTypes,\n\t\tmodels,\n\t\tmodelSpecs\n\t};\n}\nfunction lowerModels(collection, generatorFunctions, columnLength, extensions) {\n\temitTypedCrossModelFallbackWarnings(collection);\n\tconst storageTypeReverseLookup = buildStorageTypeReverseLookup(collection.storageTypes);\n\treturn Array.from(collection.modelSpecs.values()).map((spec) => resolveModelNode(spec, collection.modelSpecs, collection.storageTypes, storageTypeReverseLookup, generatorFunctions, columnLength, extensions));\n}\n/**\n* Kind-agnostic walk over the author-declared `entities` handle list:\n*\n* 1. Index the bound packs' `entityTypes` contributions by discriminator so\n* each handle's `entityKind` maps to the pack that registered it; a\n* handle whose kind no composed pack registers is an error naming the\n* kind.\n* 2. Resolve each handle's declared model refs (`handle.refs`, actual\n* model-handle objects) to storage table coordinates — identity against\n* the contract's `models` record first, then the handle's declared model\n* name against the build's model specs; never by re-deriving a table\n* name. A cross-space (extensionModel) handle resolves to its own\n* coordinate annotated with `spaceId`.\n* 3. Call each owning pack's batch lowering hook once with all of its\n* claimed handles, and fold the returned rows into the namespace-scoped\n* attachments (namespace → kind → key), rejecting two different entities\n* in one slot. The result becomes `ContractDefinition.attachedEntities`.\n*\n* No entity kind is named anywhere in this walk.\n*/\nfunction lowerPackEntityHandles(definition, modelSpecs) {\n\tconst entities = definition.entities;\n\tif (entities === void 0 || entities.length === 0) return void 0;\n\tconst components = [definition.target, ...Object.values(definition.extensions ?? {})];\n\tconst owningComponent = /* @__PURE__ */ new Map();\n\tconst walkEntityTypes = (namespace, component) => {\n\t\tfor (const value of Object.values(namespace)) if (isAuthoringEntityTypeDescriptor(value)) owningComponent.set(value.discriminator, component);\n\t\telse walkEntityTypes(value, component);\n\t};\n\tfor (const component of components) {\n\t\tconst entityTypes = component.authoring?.entityTypes;\n\t\tif (entityTypes !== void 0) walkEntityTypes(entityTypes, component);\n\t}\n\tconst defaultNamespaceId = definition.target.defaultNamespaceId;\n\tconst modelNamesByIdentity = /* @__PURE__ */ new Map();\n\tfor (const [modelName, modelBuilder] of Object.entries(definition.models ?? {})) modelNamesByIdentity.set(modelBuilder, modelName);\n\tconst coordinateOf = (modelName) => {\n\t\tconst spec = modelSpecs.get(modelName);\n\t\tif (spec === void 0) return void 0;\n\t\treturn {\n\t\t\tkind: \"resolved\",\n\t\t\tnamespaceId: spec.namespace ?? defaultNamespaceId,\n\t\t\ttableName: spec.tableName,\n\t\t\tmodelName\n\t\t};\n\t};\n\tconst declaredModelName = (value) => {\n\t\tif (typeof value !== \"object\" || value === null || !(\"stageOne\" in value)) return void 0;\n\t\tconst stageOne = value.stageOne;\n\t\tif (typeof stageOne !== \"object\" || stageOne === null || !(\"modelName\" in stageOne)) return;\n\t\treturn typeof stageOne.modelName === \"string\" ? stageOne.modelName : void 0;\n\t};\n\tconst resolveRef = (value) => {\n\t\tconst modelName = declaredModelName(value);\n\t\tif (isCrossSpaceHandle(value)) {\n\t\t\tconst tableName = value.tableName;\n\t\t\tconst namespaceId = value.stageOne.namespace;\n\t\t\tif (tableName !== void 0 && namespaceId !== void 0) return {\n\t\t\t\tkind: \"cross-space\",\n\t\t\t\tspaceId: value.spaceId,\n\t\t\t\tnamespaceId,\n\t\t\t\ttableName,\n\t\t\t\t...ifDefined(\"modelName\", modelName)\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tkind: \"unresolved\",\n\t\t\t\t...ifDefined(\"modelName\", modelName)\n\t\t\t};\n\t\t}\n\t\tconst identityName = modelNamesByIdentity.get(value);\n\t\treturn (identityName !== void 0 ? coordinateOf(identityName) : void 0) ?? (modelName !== void 0 ? coordinateOf(modelName) : void 0) ?? {\n\t\t\tkind: \"unresolved\",\n\t\t\t...ifDefined(\"modelName\", modelName)\n\t\t};\n\t};\n\tconst claimed = /* @__PURE__ */ new Map();\n\tfor (const handle of entities) {\n\t\tconst component = owningComponent.get(handle.entityKind);\n\t\tif (component === void 0) throw contractError(\"CONTRACT.ENTITY_KIND_UNKNOWN\", `defineContract: entities contains a handle with entityKind \"${handle.entityKind}\", which no composed pack registers. Compose a pack whose entityTypes contribution claims \"${handle.entityKind}\", or remove the handle.`, { meta: { entityKind: handle.entityKind } });\n\t\tconst refs = {};\n\t\tfor (const [refName, refValue] of Object.entries(handle.refs ?? {})) refs[refName] = resolveRef(refValue);\n\t\tconst forComponent = claimed.get(component) ?? [];\n\t\tforComponent.push({\n\t\t\thandle,\n\t\t\trefs\n\t\t});\n\t\tclaimed.set(component, forComponent);\n\t}\n\tconst pack = {};\n\tfor (const [component, handles] of claimed) {\n\t\tconst authoring = component.authoring;\n\t\tif (!providesEntityHandleLowering(authoring)) {\n\t\t\tconst kinds = [...new Set(handles.map((entry) => entry.handle.entityKind))].sort();\n\t\t\tthrow contractError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `defineContract: entityKind(s) ${kinds.map((kind) => `\"${kind}\"`).join(\", \")} are registered by a pack that does not implement entity-handle lowering (no lowerEntityHandles on its authoring contributions).`, { meta: {\n\t\t\t\tentityKinds: kinds,\n\t\t\t\treason: \"missing-lowerEntityHandles\"\n\t\t\t} });\n\t\t}\n\t\tfor (const row of authoring.lowerEntityHandles({\n\t\t\thandles,\n\t\t\tdefaultNamespaceId\n\t\t})) {\n\t\t\tconst forNamespace = pack[row.namespaceId] ?? {};\n\t\t\tpack[row.namespaceId] = forNamespace;\n\t\t\tconst forKind = forNamespace[row.entityKind] ?? {};\n\t\t\tforNamespace[row.entityKind] = forKind;\n\t\t\tconst existing = forKind[row.key];\n\t\t\tif (existing !== void 0 && existing !== row.entity) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `defineContract: two different \"${row.entityKind}\" entities named \"${row.key}\" in namespace \"${row.namespaceId}\" — pack-entity names must be unique per namespace.`, { meta: {\n\t\t\t\tkind: row.entityKind,\n\t\t\t\tname: row.key,\n\t\t\t\tnamespaceId: row.namespaceId\n\t\t\t} });\n\t\t\tforKind[row.key] = row.entity;\n\t\t}\n\t}\n\treturn pack;\n}\nfunction buildContractDefinition(definition) {\n\tconst collection = collectRuntimeModelSpecs(definition);\n\tconst models = lowerModels(collection, assembleGeneratorFunctions([\n\t\tdefinition.family,\n\t\tdefinition.target,\n\t\t...Object.values(definition.extensions ?? {})\n\t]), columnLengthOf(definition), definition.extensions);\n\tconst attachedEntities = lowerPackEntityHandles(definition, collection.modelSpecs);\n\treturn {\n\t\ttarget: definition.target,\n\t\t...ifDefined(\"defaultControlPolicy\", definition.defaultControlPolicy),\n\t\t...definition.extensions ? { extensions: definition.extensions } : {},\n\t\t...ifDefined(\"capabilities\", definition.adapter?.capabilities),\n\t\t...definition.storageHash ? { storageHash: definition.storageHash } : {},\n\t\t...definition.foreignKeyDefaults ? { foreignKeyDefaults: definition.foreignKeyDefaults } : {},\n\t\t...Object.keys(collection.storageTypes).length > 0 ? { storageTypes: collection.storageTypes } : {},\n\t\t...definition.namespaces ? { namespaces: definition.namespaces } : {},\n\t\twarnings: void 0,\n\t\tcreateNamespace: definition.createNamespace,\n\t\t...definition.enums && Object.keys(definition.enums).length > 0 ? { enums: definition.enums } : {},\n\t\t...attachedEntities && Object.keys(attachedEntities).length > 0 ? { attachedEntities } : {},\n\t\tmodels\n\t};\n}\n//#endregion\n//#region src/contract-builder.ts\nfunction validateTargetPackRef(family, target) {\n\tif (family.familyId !== \"sql\") throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `defineContract only accepts SQL family packs. Received family \"${family.familyId}\".`, { meta: {\n\t\tpackId: family.id,\n\t\tpackFamilyId: family.familyId,\n\t\tcontractFamilyId: \"sql\"\n\t} });\n\tif (target.familyId !== family.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `target pack \"${target.id}\" targets family \"${target.familyId}\" but contract family is \"${family.familyId}\".`, { meta: {\n\t\tpackId: target.id,\n\t\tpackFamilyId: target.familyId,\n\t\tcontractFamilyId: family.familyId\n\t} });\n}\n/**\n* Per-target reserved namespace names enforced by `defineContract` for\n* SQL family contracts. Two categories:\n*\n* 1. **IR sentinels** (`__unbound__`, `__unspecified__`) — reserved on\n* every SQL target. The double-underscore decoration marks them as\n* framework-reserved coordinates; user code must not declare them\n* explicitly.\n* 2. **Target-specific PSL keywords** — Postgres reserves the bare\n* `unbound` identifier for the late-binding opt-in\n* (`namespace unbound { … }`) so the TS surface must reject it from\n* `defineContract({ namespaces })` lists. SQLite has no schema\n* concept and rejects every non-empty namespaces list outright;\n* callers should declare `namespaces: []` or omit the field.\n*/\nfunction validateNamespaceDeclarations(target, namespaces) {\n\tif (!namespaces) return;\n\tif (target.targetId === \"sqlite\" && namespaces.length > 0) throw contractError(\"CONTRACT.NAMESPACE_UNSUPPORTED\", `defineContract: SQLite contracts cannot declare namespaces (SQLite has no schema concept; emitted DDL is always unqualified). Received namespaces: [${namespaces.map((name) => `\"${name}\"`).join(\", \")}].`, { meta: {\n\t\tnamespaces,\n\t\ttargetId: target.targetId\n\t} });\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (const namespace of namespaces) {\n\t\tif (namespace.length === 0) throw contractError(\"CONTRACT.NAMESPACE_INVALID\", \"defineContract: namespace names cannot be empty.\", { meta: {\n\t\t\tnamespace,\n\t\t\treason: \"empty\"\n\t\t} });\n\t\tif (namespace.trim().length === 0) throw contractError(\"CONTRACT.NAMESPACE_INVALID\", `defineContract: namespace name \"${namespace}\" cannot be whitespace-only.`, { meta: {\n\t\t\tnamespace,\n\t\t\treason: \"whitespace-only\"\n\t\t} });\n\t\tif (namespace === \"__unbound__\" || namespace === \"__unspecified__\") throw contractError(\"CONTRACT.NAMESPACE_INVALID\", `defineContract: namespace name \"${namespace}\" is a reserved IR sentinel and cannot appear in the declared namespaces list.`, { meta: {\n\t\t\tnamespace,\n\t\t\treason: \"reserved-ir-sentinel\"\n\t\t} });\n\t\tif (target.targetId === \"postgres\" && namespace === \"unbound\") throw contractError(\"CONTRACT.NAMESPACE_INVALID\", `defineContract: namespace name \"unbound\" is reserved by Postgres for the late-binding opt-in (use \\`namespace unbound { … }\\` in PSL instead of declaring it as a regular schema).`, { meta: {\n\t\t\tnamespace,\n\t\t\treason: \"reserved-by-postgres\"\n\t\t} });\n\t\tif (seen.has(namespace)) throw contractError(\"CONTRACT.NAME_DUPLICATE\", `defineContract: namespaces list contains duplicate entry \"${namespace}\".`, { meta: {\n\t\t\tkind: \"namespace\",\n\t\t\tname: namespace\n\t\t} });\n\t\tseen.add(namespace);\n\t}\n}\n/**\n* Per-model `namespace` validation paired with\n* {@link validateNamespaceDeclarations}. Mirrors the reserved-name\n* rules so the per-model surface stays consistent with the contract-\n* level surface:\n*\n* - `__unbound__` / `__unspecified__` — reserved IR sentinels on\n* every SQL target.\n* - `unbound` on Postgres — reserved for the PSL\n* `namespace unbound { … }` opt-in.\n*\n* Additionally enforces that each per-model `namespace` either\n* references an entry in the contract's declared `namespaces` list or\n* names the Postgres late-binding keyword (`unbound`) — the latter is\n* not a \"declared namespace\" but is a legal opt-in only via PSL today,\n* so the TS surface also rejects it on the per-model side and points\n* authors at the PSL `namespace unbound { … }` block.\n*\n* The SQLite per-model `namespace` field is rejected outright (SQLite\n* has no schema concept).\n*/\nfunction validatePerModelNamespaces(target, namespaces, models) {\n\tconst declaredNamespaces = new Set(namespaces ?? []);\n\tfor (const [modelKey, modelBuilder] of Object.entries(models)) {\n\t\tconst perModelNamespace = modelBuilder.stageOne.namespace;\n\t\tif (perModelNamespace === void 0) continue;\n\t\tif (target.targetId === \"sqlite\") throw contractError(\"CONTRACT.NAMESPACE_UNSUPPORTED\", `defineContract: model \"${modelKey}\" sets \\`namespace: \"${perModelNamespace}\"\\` but the target is SQLite (SQLite has no schema concept; remove the per-model \\`namespace\\` field).`, { meta: {\n\t\t\tmodelKey,\n\t\t\tnamespace: perModelNamespace,\n\t\t\ttargetId: target.targetId\n\t\t} });\n\t\tif (perModelNamespace === \"__unbound__\" || perModelNamespace === \"__unspecified__\") throw contractError(\"CONTRACT.NAMESPACE_INVALID\", `defineContract: model \"${modelKey}\" sets \\`namespace: \"${perModelNamespace}\"\\` but that name is a reserved IR sentinel and cannot appear in user code.`, { meta: {\n\t\t\tmodelKey,\n\t\t\tnamespace: perModelNamespace,\n\t\t\treason: \"reserved-ir-sentinel\"\n\t\t} });\n\t\tif (target.targetId === \"postgres\" && perModelNamespace === \"unbound\") throw contractError(\"CONTRACT.NAMESPACE_INVALID\", `defineContract: model \"${modelKey}\" sets \\`namespace: \"unbound\"\\` but that name is reserved by Postgres for the late-binding opt-in (use \\`namespace unbound { … }\\` in PSL instead — there is no equivalent surface in the TS builder today).`, { meta: {\n\t\t\tmodelKey,\n\t\t\tnamespace: perModelNamespace,\n\t\t\treason: \"reserved-by-postgres\"\n\t\t} });\n\t\tif (!declaredNamespaces.has(perModelNamespace)) throw contractError(\"CONTRACT.NAMESPACE_UNKNOWN\", `defineContract: model \"${modelKey}\" references namespace \"${perModelNamespace}\" but that name does not appear in the contract's declared \\`namespaces\\` list.${declaredNamespaces.size > 0 ? ` Declared namespaces: [${[...declaredNamespaces].map((name) => `\"${name}\"`).join(\", \")}].` : \" The contract does not declare any namespaces; add `namespaces: [\\\"…\\\"]` to `defineContract` first.\"}`, { meta: {\n\t\t\tmodelKey,\n\t\t\tnamespace: perModelNamespace,\n\t\t\tdeclared: [...declaredNamespaces]\n\t\t} });\n\t}\n}\nfunction validateExtensionPackRefs(target, extensions) {\n\tif (!extensions) return;\n\tfor (const packRef of Object.values(extensions)) {\n\t\tif (packRef.kind !== \"extension\") throw contractError(\"CONTRACT.PACK_REF_INVALID\", `defineContract only accepts extension pack refs in extensions. Received kind \"${packRef.kind}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tkind: packRef.kind\n\t\t} });\n\t\tif (packRef.familyId !== target.familyId) throw contractError(\"CONTRACT.PACK_FAMILY_MISMATCH\", `extension pack \"${packRef.id}\" targets family \"${packRef.familyId}\" but contract target family is \"${target.familyId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackFamilyId: packRef.familyId,\n\t\t\tcontractFamilyId: target.familyId\n\t\t} });\n\t\tif (packRef.targetId && packRef.targetId !== target.targetId) throw contractError(\"CONTRACT.PACK_TARGET_MISMATCH\", `extension pack \"${packRef.id}\" targets \"${packRef.targetId}\" but contract target is \"${target.targetId}\".`, { meta: {\n\t\t\tpackId: packRef.id,\n\t\t\tpackTargetId: packRef.targetId,\n\t\t\tcontractTargetId: target.targetId\n\t\t} });\n\t}\n}\nfunction buildContractFromDsl(definition) {\n\tvalidateTargetPackRef(definition.family, definition.target);\n\tvalidateExtensionPackRefs(definition.target, definition.extensions);\n\tvalidateNamespaceDeclarations(definition.target, definition.namespaces);\n\tvalidatePerModelNamespaces(definition.target, definition.namespaces, definition.models ?? {});\n\treturn blindCast(buildSqlContractFromDefinition(buildContractDefinition(definition), definition.codecLookup, definition.dataTypeLookup));\n}\n/** Implementation. */\nfunction buildBoundContract(family, target, definition, factory) {\n\tconst full = {\n\t\t...definition,\n\t\tfamily,\n\t\ttarget\n\t};\n\tif (factory !== void 0) {\n\t\tconst built = factory(createComposedAuthoringHelpers({\n\t\t\tfamily,\n\t\t\ttarget,\n\t\t\textensions: definition.extensions,\n\t\t\tcodecLookup: definition.codecLookup,\n\t\t\tdataTypeLookup: definition.dataTypeLookup\n\t\t}));\n\t\tconst mergedEnums = {\n\t\t\t...definition.enums ?? {},\n\t\t\t...built.enums\n\t\t};\n\t\tconst mergedEntities = [...definition.entities ?? [], ...built.entities ?? []];\n\t\treturn buildContractFromDsl({\n\t\t\t...full,\n\t\t\t...ifDefined(\"types\", built.types),\n\t\t\t...ifDefined(\"models\", built.models),\n\t\t\t...ifDefined(\"enums\", Object.keys(mergedEnums).length > 0 ? mergedEnums : void 0),\n\t\t\t...ifDefined(\"entities\", mergedEntities.length > 0 ? mergedEntities : void 0)\n\t\t});\n\t}\n\treturn buildContractFromDsl(full);\n}\nfunction defineContract(definition, factory) {\n\tif (!isContractInput(definition)) throw contractError(\"CONTRACT.ARGUMENT_INVALID\", \"defineContract expects a contract definition object. Define your contract with defineContract({ family, target, models, ... }).\");\n\tif (factory !== void 0) return buildBoundContract(definition.family, definition.target, definition, factory);\n\treturn buildBoundContract(definition.family, definition.target, definition);\n}\n//#endregion\n//#region src/default-functions.ts\n/** The database's current time, the same default PSL writes as `@default(now())`. */\nfunction now() {\n\treturn {\n\t\tkind: \"function\",\n\t\texpression: \"now()\"\n\t};\n}\n/** A database-assigned sequence value, the same default PSL writes as `@default(autoincrement())`. */\nfunction autoincrement() {\n\treturn {\n\t\tkind: \"function\",\n\t\texpression: \"autoincrement()\"\n\t};\n}\n//#endregion\nexport { applySqlSpecifierControlPolicy, autoincrement, bindEnumType, buildBoundContract, buildContractDefinition, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, defineContract, enumType, extensionModel, field, isValueObjectMember, member, model, now, rel, sql, storedAsListColumn };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,6BAA6B,OAAO;CAC5C,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,QAAQ,QAAQ,MAAM,GAAG,OAAO;CAC7D,MAAM,OAAO,MAAM;CACnB,OAAO,SAAS,KAAK,KAAK,OAAO,SAAS;AAC3C;AACA,SAAS,+BAA+B,WAAW,SAAS,OAAO,CAAC,GAAG;CACtE,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,GAAG;EACrD,6BAA6B,KAAK,IAAI;EACtC,MAAM,cAAc,CAAC,GAAG,MAAM,GAAG;EACjC,IAAI,qCAAqC,KAAK,GAAG;GAChD,MAAM,aAAa,YAAY,KAAK,GAAG;G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MAAM,iBAAiB,CAAC,GAAG,WAAW,YAAY,CAAC,GAAG,GAAG,MAAM,YAAY,CAAC,CAAC;EAC7E,OAAO,qBAAqB;GAC3B,GAAG;GACH,GAAG,UAAU,SAAS,MAAM,KAAK;GACjC,GAAG,UAAU,UAAU,MAAM,MAAM;GACnC,GAAG,UAAU,SAAS,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,IAAI,cAAc,KAAK,CAAC;GAChF,GAAG,UAAU,YAAY,eAAe,SAAS,IAAI,iBAAiB,KAAK,CAAC;EAC7E,CAAC;CACF;CACA,OAAO,qBAAqB,IAAI;AACjC;AACA,SAAS,eAAe,YAAY,SAAS;CAC5C,IAAI,CAAC,gBAAgB,UAAU,GAAG,MAAM,cAAc,6BAA6B,iIAAiI;CACpN,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,YAAY,OAAO;CAC3G,OAAO,mBAAmB,WAAW,QAAQ,WAAW,QAAQ,UAAU;AAC3E;;AAIA,SAAS,MAAM;CACd,OAAO;EACN,MAAM;EACN,YAAY;CACb;AACD;;AAEA,SAAS,gBAAgB;CACxB,OAAO;EACN,MAAM;EACN,YAAY;CACb;AACD"}
@@ -1,24 +1,27 @@
1
1
  import { r as lowerAuthoredIndex } from "./index-naming-BOcJT1B3-18gQUduD.mjs";
2
- import { d as sqlDataTypeOfCodec } from "./sql-data-type-D5cI3M07-DIcPP8s1.mjs";
2
+ import { p as sqlDataTypeOfCodec, u as sqlCodecColumnLength } from "./sql-data-type-D7M-YTTY-C9oWGZ3z.mjs";
3
3
  import { n as declaredBackingObjectName, r as declaredIndexesServeForeignKey } from "./foreign-key-materialization-BPQqd0qF.mjs";
4
- import { p as validateSqlStorageConsistency, u as validateModelStorageReferences } from "./validators-BlONfdFH.mjs";
4
+ import { p as validateSqlStorageConsistency, u as validateModelStorageReferences } from "./validators-Cfy0jmZ2.mjs";
5
5
  import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
6
- import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-CwbSfZ8d-B3-zWGv_.mjs";
7
- import { c as instantiateFieldTypeConstructor, h as readDataTypeDefault } from "./psl-field-resolution-C8s57hFC-Bv6NiK8J.mjs";
8
- import { a as normalizeReferentialAction, n as buildEntityTypesByDiscriminator, r as indexFkRelations, t as applyBackrelationCandidates } from "./interpreter-Dq32sxoS-BcLhPY0_.mjs";
6
+ import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-CwbSfZ8d-B91zqK6B.mjs";
7
+ import { _ as readDataTypeDefault, a as defaultFunctionCall, l as instantiateFieldTypeConstructor } from "./psl-field-resolution-BLtSah2i-BuuJ5H70.mjs";
8
+ import { a as normalizeReferentialAction, n as buildEntityTypesByDiscriminator, r as indexFkRelations, t as applyBackrelationCandidates } from "./interpreter-MPFufRkd-D0QvlLTq.mjs";
9
9
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
10
10
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
11
11
  import { entryForTag, getAuthoringTypeConstructor, instantiateAuthoringEntityType, instantiateAuthoringTypeConstructor } from "@prisma/orm-framework/components/authoring";
12
12
  import { clipToUtf8Bytes, utf8ByteLength } from "@prisma/orm-framework/utils/text";
13
13
  import { blindCast } from "@prisma/orm-framework/utils/casts";
14
14
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
15
+ import { EMPTY_GENERATOR_FUNCTIONS } from "@prisma/orm-framework/components/components";
15
16
  import { validateContractDomain } from "@prisma/orm-framework/contract/validate-domain";
16
17
  import { readFile, readdir, stat } from "node:fs/promises";
17
18
  import { ArrayLiteralAst, BooleanLiteralExprAst, FunctionCallAst, IdentifierAst, ModelAttributeAst, NumberLiteralExprAst, PathExprAst, StringLiteralExprAst, dottedPathsIn, parse, printSyntax } from "@prisma/orm-framework/psl-parser/syntax";
18
19
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
19
20
  import { basename, dirname, extname, join, normalize } from "pathe";
20
- import { buildSymbolTable, createPslDiagnosticCollector, diagnosticSource, keywordPslSpan, nodePslSpan, readResolvedAttribute } from "@prisma/orm-framework/psl-parser";
21
+ import { assembleAuthoringContributions } from "@prisma/orm-framework/components/control";
22
+ import { EMPTY_DATA_TYPES, buildSymbolTable, createBinder, createPslDiagnosticCollector, diagnosticSource, generatorFunctionCall, keywordPslSpan, mapPslDiagnostics, nodePslSpan, readResolvedAttribute } from "@prisma/orm-framework/psl-parser";
21
23
  import { fkRelationPairKey } from "@prisma/orm-framework/psl-parser/interpret";
24
+ import { CUID_VERSION } from "@prisma/orm-framework/ids";
22
25
  //#region ../../../2-sql/2-authoring/contract-prisma7/dist/provider.mjs
23
26
  function prisma7Diagnostic(code, message, sourceId, span) {
24
27
  return {
@@ -177,22 +180,15 @@ function checkStatedConstraintNameLength(input) {
177
180
  const spelling = `${attribute.node instanceof ModelAttributeAst ? "@@" : "@"}${attribute.name}`;
178
181
  input.diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_CONSTRAINT_NAME_TOO_LONG", `${input.owner}: the name "${name}" in the map argument of ${spelling} is ${bytes} bytes, longer than the ${maxBytes} bytes the database keeps. Shorten the map to ${maxBytes} bytes or fewer; Prisma 7 refuses this name too.`, input.sourceId, mapArgument.span));
179
182
  }
180
- /** Positional argument keys per Prisma 7 default function, matching the target registry's signatures. */
181
- const FUNCTION_ARGUMENT_KEYS = {
182
- uuid: ["version"],
183
- cuid: ["version"],
184
- nanoid: ["size"],
185
- now: [],
186
- autoincrement: [],
187
- ulid: []
188
- };
189
- function literalArgument(expression) {
190
- const text = StringLiteralExprAst.cast(expression.syntax)?.value();
191
- if (text !== void 0) return text;
192
- const number = NumberLiteralExprAst.cast(expression.syntax)?.value();
193
- if (number !== void 0) return number;
194
- return BooleanLiteralExprAst.cast(expression.syntax)?.value();
195
- }
183
+ /** The default functions of Prisma 7's schema language. */
184
+ const PRISMA7_DEFAULT_FUNCTIONS = /* @__PURE__ */ new Set([
185
+ "autoincrement",
186
+ "now",
187
+ "uuid",
188
+ "cuid",
189
+ "nanoid",
190
+ "ulid"
191
+ ]);
196
192
  function lowerPrisma7Default(input) {
197
193
  const { attribute, field, sourceId, diagnostics } = input;
198
194
  const label = `Field "${input.modelName}.${field.name}"`;
@@ -204,7 +200,7 @@ function lowerPrisma7Default(input) {
204
200
  if (argument === void 0 || expression === void 0) return unknown("needs one value.", attribute.span);
205
201
  const call = FunctionCallAst.cast(expression.syntax);
206
202
  if (input.onlyDbgenerated && call?.path().join(".") !== "dbgenerated") return unknown("on a field of type Unsupported(...) must be dbgenerated(\"...\"). Prisma 7 refuses this schema too: \"Only @default(dbgenerated(\"...\")) can be used for Unsupported types.\" Write the default as @default(dbgenerated(\"<sql expression>\")), or remove it.", attribute.span);
207
- if (call !== void 0) return lowerFunction(call, input, label, unknown);
203
+ if (call !== void 0) return lowerFunction(call, expression, input, label, unknown);
208
204
  const scalar = scalarValue$1(expression, input, unknown);
209
205
  if (scalar === void 0) return void 0;
210
206
  return {
@@ -376,32 +372,25 @@ function refusalReason(refusal) {
376
372
  function describeCasts(casts) {
377
373
  return casts.length === 0 ? "it casts from nothing" : `it casts from ${casts.join(", ")}`;
378
374
  }
379
- function lowerFunction(call, input, label, unknown) {
375
+ function lowerFunction(call, expression, input, label, unknown) {
380
376
  const fn = call.path().join(".");
381
377
  const span = input.attribute.span;
382
378
  const callArgs = [...call.args()];
383
379
  if (fn === "dbgenerated") return dbgeneratedDefault(callArgs, unknown, span);
384
- const keys = FUNCTION_ARGUMENT_KEYS[fn];
385
380
  const entry = input.controlMutationDefaults.defaultFunctionRegistry.get(fn);
386
- if (keys === void 0 || entry === void 0 && !input.generatorFunctions.has(fn)) return unknown(`function "${fn}()" is not a Prisma 7 default function this target supports.`, span);
387
- const args = {};
388
- let index = 0;
389
- for (const arg of callArgs) {
390
- const key = arg.name()?.name() ?? keys[index];
391
- const value = arg.value();
392
- const literal = value === void 0 ? void 0 : literalArgument(value);
393
- if (key === void 0 || literal === void 0) return unknown(`function "${fn}()" has an argument this contract source does not read.`, span);
394
- args[key] = literal;
395
- index += 1;
396
- }
397
- if (fn === "cuid") args["version"] = 2;
381
+ const generator = entry === void 0 ? input.generatorFunctions.functionsFor(input.codecId).find(({ name }) => name === fn) : void 0;
382
+ if (!PRISMA7_DEFAULT_FUNCTIONS.has(fn) || entry === void 0 && !input.generatorFunctions.has(fn)) return unknown(`function "${fn}()" is not a Prisma 7 default function this target supports.`, span);
398
383
  if (entry === void 0) {
384
+ if (generator === void 0) return unknown(`function "${fn}()" cannot fill a column of codec "${input.codecId}".`, span);
385
+ const args = fn === "cuid" && callArgs.length === 0 ? { version: CUID_VERSION } : boundArguments(generatorFunctionCall(fn, generator.signature, input.dataTypes), expression, input, label);
386
+ if (args === void 0) return void 0;
399
387
  const resolution = input.generatorFunctions.resolve({
400
388
  name: fn,
401
389
  args
402
390
  }, {
403
391
  codecId: input.codecId,
404
- typeParams: input.typeParams
392
+ typeParams: input.typeParams,
393
+ length: sqlCodecColumnLength(input.dataTypes, input.codecId, input.typeParams)
405
394
  });
406
395
  if (resolution.ok) return {
407
396
  storage: void 0,
@@ -414,6 +403,8 @@ function lowerFunction(call, input, label, unknown) {
414
403
  }
415
404
  return unknown(`function "${fn}()" cannot fill a column of codec "${input.codecId}".`, span);
416
405
  }
406
+ const args = boundArguments(defaultFunctionCall(fn, entry, input.dataTypes), expression, input, label);
407
+ if (args === void 0) return void 0;
417
408
  const lowered = entry.lower({
418
409
  call: {
419
410
  fn,
@@ -437,6 +428,15 @@ function lowerFunction(call, input, label, unknown) {
437
428
  };
438
429
  }
439
430
  /**
431
+ * The arguments of a call, bound and checked through its function's signature as Prisma 8 PSL binds them, or `undefined` after reporting each refusal at its argument.
432
+ */
433
+ function boundArguments(arm, expression, input, label) {
434
+ const ctx = input.argumentContext();
435
+ const bound = arm.parse(expression, ctx);
436
+ if (bound.ok) return bound.value.args;
437
+ for (const diagnostic of mapPslDiagnostics(bound.failure, ctx.sources)) input.diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_UNKNOWN_DEFAULT", `${label}: ${diagnostic.message}`, input.sourceId, diagnostic.span));
438
+ }
439
+ /**
440
440
  * Prisma 7's `dbgenerated("<sql>")` is a raw SQL default, carried as written; the empty form
441
441
  * `dbgenerated()` means the column has no default. Prisma 7 refuses a blank string, so this
442
442
  * source does too.
@@ -1034,17 +1034,27 @@ function synthesizeJunction(requester, partner, naming, diagnostics) {
1034
1034
  };
1035
1035
  }
1036
1036
  /** The generator `now()` resolves to for a column, which `@updatedAt` writes on create and on update; `undefined` when no generator function binds `now` to its codec. */
1037
- function nowGeneratorFor(generatorFunctions, column) {
1037
+ function nowGeneratorFor(generatorFunctions, dataTypes, column) {
1038
1038
  const resolution = generatorFunctions.resolve({
1039
1039
  name: "now",
1040
1040
  args: {}
1041
1041
  }, {
1042
1042
  codecId: column.codecId,
1043
- typeParams: column.typeParams
1043
+ typeParams: column.typeParams,
1044
+ length: sqlCodecColumnLength(dataTypes, column.codecId, column.typeParams)
1044
1045
  });
1045
1046
  return resolution.ok ? resolution.generator : void 0;
1046
1047
  }
1047
1048
  const SUMMARY = "Prisma 7 schema interpretation failed";
1049
+ /**
1050
+ * The binder context of a Prisma 7 document's argument context. A default function's arguments are literals, so the binder needs no Prisma 8 attribute specs, functions or data types.
1051
+ */
1052
+ const ARGUMENT_BINDER_CONTEXT = {
1053
+ authoringContributions: assembleAuthoringContributions([]),
1054
+ controlMutationDefaults: { defaultFunctionRegistry: /* @__PURE__ */ new Map() },
1055
+ generatorFunctions: EMPTY_GENERATOR_FUNCTIONS,
1056
+ dataTypes: EMPTY_DATA_TYPES
1057
+ };
1048
1058
  function stringArgument(attribute) {
1049
1059
  const expression = (attribute.args.find((arg) => arg.kind === "positional") ?? attribute.args.find((arg) => arg.name === "name"))?.expression;
1050
1060
  if (expression === void 0) return void 0;
@@ -1174,9 +1184,22 @@ function interpretPrisma7Documents(input) {
1174
1184
  for (const mixin of Object.values(symbolTable.defaultNamespace.mixins)) unsupported(`${mixin.keyword} mixin`, mixin.span);
1175
1185
  unsupportedInclusions("PSL_INVALID_MODEL_MEMBER", symbolTable.defaultNamespace.models);
1176
1186
  unsupportedInclusions("PSL_INVALID_EXTENSION_BLOCK_MEMBER", symbolTable.defaultNamespace.blocks);
1187
+ let argumentContext;
1188
+ const argumentContextOf = () => {
1189
+ argumentContext ??= {
1190
+ sources,
1191
+ symbols: symbolTable,
1192
+ binder: createBinder({
1193
+ sources,
1194
+ symbolTable,
1195
+ context: ARGUMENT_BINDER_CONTEXT
1196
+ }).binder
1197
+ };
1198
+ return argumentContext;
1199
+ };
1177
1200
  for (const symbol of Object.values(symbolTable.defaultNamespace.models)) {
1178
1201
  if (!claimName("model", symbol.name, sourceId, symbol.span)) continue;
1179
- models.push(readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, binding, diagnostics));
1202
+ models.push(readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, binding, diagnostics, argumentContextOf));
1180
1203
  }
1181
1204
  }
1182
1205
  checkDatasource(datasources, input.documents[0]?.sourceId ?? "schema.prisma", binding, diagnostics);
@@ -1411,7 +1434,7 @@ function keyColumns(model, fieldNames) {
1411
1434
  }
1412
1435
  return columns;
1413
1436
  }
1414
- function readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, binding, diagnostics) {
1437
+ function readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, binding, diagnostics, argumentContext) {
1415
1438
  const { indexTypes } = binding;
1416
1439
  let ignored = false;
1417
1440
  let tableName = symbol.name;
@@ -1468,7 +1491,8 @@ function readModelDeclaration(symbol, sourceId, sources, defaultNamespaceId, bin
1468
1491
  ignored,
1469
1492
  id,
1470
1493
  uniqueIndexes,
1471
- indexes
1494
+ indexes,
1495
+ argumentContext
1472
1496
  };
1473
1497
  }
1474
1498
  function requireStringArgument(attribute, owner, sourceId, diagnostics) {
@@ -1780,7 +1804,7 @@ function readField(args) {
1780
1804
  codecLookup: input.codecLookup,
1781
1805
  dataTypeLookup: input.dataTypes.lookup
1782
1806
  };
1783
- const updatedAtGenerator = updatedAt === void 0 || ignored ? void 0 : nowGeneratorFor(input.generatorFunctions, resolved.descriptor);
1807
+ const updatedAtGenerator = updatedAt === void 0 || ignored ? void 0 : nowGeneratorFor(input.generatorFunctions, input.dataTypes, resolved.descriptor);
1784
1808
  if (updatedAt !== void 0 && !ignored && updatedAtGenerator === void 0) {
1785
1809
  if (nativeType === void 0) throw new InternalError(`The Prisma 7 target binding has no "now" generator for codec "${resolved.descriptor.codecId}", which the DateTime scalar maps to.`);
1786
1810
  diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_UPDATED_AT_FIELD_INVALID", `${label} has @updatedAt, but "@db.${nativeType.name}" makes it a column that is not a date or time, so @updatedAt cannot set it. Prisma 7 refuses this schema too: "Native type ${nativeType.name} is not compatible with declared field type DateTime". Remove @updatedAt, or use a date or time native type such as @db.Timestamp.`, sourceId, nativeType.attribute.span));
@@ -1802,6 +1826,7 @@ function readField(args) {
1802
1826
  }),
1803
1827
  enumMembers: enumDeclaration === void 0 ? void 0 : new Map(enumDeclaration.members.map((member) => [member.name, member.value])),
1804
1828
  controlMutationDefaults: input.controlMutationDefaults,
1829
+ argumentContext: model.argumentContext,
1805
1830
  generatorFunctions: input.generatorFunctions,
1806
1831
  sourceId,
1807
1832
  diagnostics