@prisma/orm-family-sql 8.0.0-rc.11-dev.42 → 8.0.0-rc.11-dev.44

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 (168) hide show
  1. package/dist/{ast-BHZ0g4iL.d.mts → ast-d2-iNoEs.d.mts} +72 -10
  2. package/dist/ast-d2-iNoEs.d.mts.map +1 -0
  3. package/dist/{ast-C8jX7HNs.mjs → ast-um6jG7BL.mjs} +129 -8
  4. package/dist/ast-um6jG7BL.mjs.map +1 -0
  5. package/dist/{authoring-type-constructors-C1ogrr_x-BeSS93gc.mjs → authoring-type-constructors-C1ogrr_x-VWDkCaSq.mjs} +2 -2
  6. package/dist/{authoring-type-constructors-C1ogrr_x-BeSS93gc.mjs.map → authoring-type-constructors-C1ogrr_x-VWDkCaSq.mjs.map} +1 -1
  7. package/dist/builder.d.mts +2 -2
  8. package/dist/builder__runtime.d.mts +8 -8
  9. package/dist/builder__types.d.mts +2 -2
  10. package/dist/{config-types-C-rrJ_8P.d.mts → config-types-Bd3ud-mX.d.mts} +3 -3
  11. package/dist/{config-types-C-rrJ_8P.d.mts.map → config-types-Bd3ud-mX.d.mts.map} +1 -1
  12. package/dist/{config-types-B98UYjF0.mjs → config-types-fwqTEhK6.mjs} +2 -2
  13. package/dist/{config-types-B98UYjF0.mjs.map → config-types-fwqTEhK6.mjs.map} +1 -1
  14. package/dist/{contract-builder-DV-DZX4h.d.mts → contract-builder-BHCjHphC.d.mts} +12 -5
  15. package/dist/{contract-builder-DV-DZX4h.d.mts.map → contract-builder-BHCjHphC.d.mts.map} +1 -1
  16. package/dist/{contract-builder-BCqPVNbs.mjs → contract-builder-BgWPuVYv.mjs} +2 -2
  17. package/dist/{contract-builder-BCqPVNbs.mjs.map → contract-builder-BgWPuVYv.mjs.map} +1 -1
  18. package/dist/contract-prisma7__provider.d.mts +1 -1
  19. package/dist/contract-prisma7__provider.mjs +118 -48
  20. package/dist/contract-prisma7__provider.mjs.map +1 -1
  21. package/dist/contract-psl.d.mts +10 -6
  22. package/dist/contract-psl.d.mts.map +1 -1
  23. package/dist/contract-psl.mjs +1 -1
  24. package/dist/contract-psl__attribute-specs.d.mts +9 -7
  25. package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
  26. package/dist/contract-psl__attribute-specs.mjs +1 -1
  27. package/dist/contract-psl__provider.d.mts +1 -1
  28. package/dist/contract-psl__provider.mjs +3 -2
  29. package/dist/contract-psl__provider.mjs.map +1 -1
  30. package/dist/contract-ts.d.mts +3 -3
  31. package/dist/contract-ts.mjs +3 -3
  32. package/dist/contract-ts__config-types.d.mts +1 -1
  33. package/dist/contract-ts__config-types.mjs +1 -1
  34. package/dist/contract-ts__contract-builder.d.mts +2 -2
  35. package/dist/contract-ts__contract-builder.mjs +2 -2
  36. package/dist/contract.d.mts +5 -5
  37. package/dist/contract__factories.d.mts +1 -1
  38. package/dist/contract__index-type-validation.d.mts +1 -1
  39. package/dist/contract__types.d.mts +2 -2
  40. package/dist/contract__validators.d.mts +1 -1
  41. package/dist/{control-C9oCqe39.d.mts → control-D7O180pB.d.mts} +21 -18
  42. package/dist/control-D7O180pB.d.mts.map +1 -0
  43. package/dist/{control-Cijy1SHG.mjs → control-FOipY3kl.mjs} +11 -6
  44. package/dist/{control-Cijy1SHG.mjs.map → control-FOipY3kl.mjs.map} +1 -1
  45. package/dist/{control-adapter-C99J7aEF-B2G4GA5s.d.mts → control-adapter-C99J7aEF-DwFChl8n.d.mts} +8 -8
  46. package/dist/{control-adapter-C99J7aEF-B2G4GA5s.d.mts.map → control-adapter-C99J7aEF-DwFChl8n.d.mts.map} +1 -1
  47. package/dist/control-adapter-DPWKLNdH.d.mts +1 -0
  48. package/dist/{db-BhQdL6Za-Dod07quT.d.mts → db-BhQdL6Za-BBgu_awF.d.mts} +8 -8
  49. package/dist/{db-BhQdL6Za-Dod07quT.d.mts.map → db-BhQdL6Za-BBgu_awF.d.mts.map} +1 -1
  50. package/dist/{ddl-types-BGdnAbXo-DKPHPUGx.mjs → ddl-types-DOgOmDOh-Cs_MY05h.mjs} +2 -2
  51. package/dist/{ddl-types-BGdnAbXo-DKPHPUGx.mjs.map → ddl-types-DOgOmDOh-Cs_MY05h.mjs.map} +1 -1
  52. package/dist/{ddl-types-Biy7miT--CSyPnOHq.d.mts → ddl-types-DrK8E0jL-ClX_UkVh.d.mts} +4 -4
  53. package/dist/{ddl-types-Biy7miT--CSyPnOHq.d.mts.map → ddl-types-DrK8E0jL-ClX_UkVh.d.mts.map} +1 -1
  54. package/dist/{derived-checks-C4BPtrnO-B9MQRh6W.mjs → derived-checks-6WZKIUxH-B3Pd6QA5.mjs} +30 -12
  55. package/dist/derived-checks-6WZKIUxH-B3Pd6QA5.mjs.map +1 -0
  56. package/dist/{derived-checks-DPdD01O0-DCKdvxNK.d.mts → derived-checks-DPdD01O0-DNBs1ZDA.d.mts} +2 -2
  57. package/dist/{derived-checks-DPdD01O0-DCKdvxNK.d.mts.map → derived-checks-DPdD01O0-DNBs1ZDA.d.mts.map} +1 -1
  58. package/dist/{diff-CwozLSiO.d.mts → diff-C9tzE_nE.d.mts} +7 -7
  59. package/dist/{diff-CwozLSiO.d.mts.map → diff-C9tzE_nE.d.mts.map} +1 -1
  60. package/dist/{expression-CTADTPZW.d.mts → expression-CAJjmssr.d.mts} +6 -6
  61. package/dist/{expression-CTADTPZW.d.mts.map → expression-CAJjmssr.d.mts.map} +1 -1
  62. package/dist/{factories-B9PfKd5k.d.mts → factories-P3qBQhO-.d.mts} +2 -2
  63. package/dist/{factories-B9PfKd5k.d.mts.map → factories-P3qBQhO-.d.mts.map} +1 -1
  64. package/dist/family.d.mts +11 -11
  65. package/dist/family.mjs +2 -2
  66. package/dist/family__control-adapter.d.mts +2 -2
  67. package/dist/family__control.d.mts +4 -4
  68. package/dist/family__control.mjs +1 -1
  69. package/dist/family__diff.d.mts +2 -2
  70. package/dist/family__ir.d.mts +1 -1
  71. package/dist/family__migration.d.mts +1 -1
  72. package/dist/family__pack.d.mts +2 -2
  73. package/dist/family__pack.d.mts.map +1 -1
  74. package/dist/family__pack.mjs +2 -2
  75. package/dist/family__psl-infer.d.mts +1 -1
  76. package/dist/family__psl-infer.mjs +1 -1
  77. package/dist/family__runtime.d.mts +1 -1
  78. package/dist/{index-C6_--MKi.d.mts → index-CLAshwKN.d.mts} +3 -3
  79. package/dist/{index-C6_--MKi.d.mts.map → index-CLAshwKN.d.mts.map} +1 -1
  80. package/dist/{index-CA_WLNy1.d.mts → index-DI6YpxCw.d.mts} +10 -10
  81. package/dist/{index-CA_WLNy1.d.mts.map → index-DI6YpxCw.d.mts.map} +1 -1
  82. package/dist/{index-type-validation-BFiTwZub.d.mts → index-type-validation-CZ5L2lli.d.mts} +2 -2
  83. package/dist/{index-type-validation-BFiTwZub.d.mts.map → index-type-validation-CZ5L2lli.d.mts.map} +1 -1
  84. package/dist/{interpreter-Bf7Um__3-DC_thY44.mjs → interpreter-BIBwrA2w-DAiNN30m.mjs} +568 -181
  85. package/dist/interpreter-BIBwrA2w-DAiNN30m.mjs.map +1 -0
  86. package/dist/{ir-CodnAisu.d.mts → ir-BJ-dsbe-.d.mts} +2 -2
  87. package/dist/{ir-CodnAisu.d.mts.map → ir-BJ-dsbe-.d.mts.map} +1 -1
  88. package/dist/{middleware-0yjzaoBT-BqmCD6Dt.d.mts → middleware-CHg6zJkn-DJAKnDpd.d.mts} +3 -3
  89. package/dist/{middleware-0yjzaoBT-BqmCD6Dt.d.mts.map → middleware-CHg6zJkn-DJAKnDpd.d.mts.map} +1 -1
  90. package/dist/middleware-wyJe8dVq.d.mts +1 -0
  91. package/dist/{migration-CniGZoFt.d.mts → migration-BQWwBE8Q.d.mts} +3 -3
  92. package/dist/{migration-CniGZoFt.d.mts.map → migration-BQWwBE8Q.d.mts.map} +1 -1
  93. package/dist/operations.d.mts +1 -1
  94. package/dist/orm-client.d.mts +13 -13
  95. package/dist/orm-client.mjs +1 -1
  96. package/dist/{plan-Bs-Pdirc-BCy94--G.d.mts → plan-DVkrl9Pq-DOf_eQ84.d.mts} +4 -4
  97. package/dist/plan-DVkrl9Pq-DOf_eQ84.d.mts.map +1 -0
  98. package/dist/plan-Dzq6Nwb4.d.mts +2 -0
  99. package/dist/{prepared-statement-DZtymlzd-DFIuG_WK.d.mts → prepared-statement-DZtymlzd-DmbP44p0.d.mts} +15 -15
  100. package/dist/{prepared-statement-DZtymlzd-DFIuG_WK.d.mts.map → prepared-statement-DZtymlzd-DmbP44p0.d.mts.map} +1 -1
  101. package/dist/{psl-infer-6p4x9ebN.mjs → psl-infer-BAbdN_ZR.mjs} +195 -13
  102. package/dist/psl-infer-BAbdN_ZR.mjs.map +1 -0
  103. package/dist/{psl-infer-CLZsT2Hz.d.mts → psl-infer-DQCWvJtk.d.mts} +16 -3
  104. package/dist/psl-infer-DQCWvJtk.d.mts.map +1 -0
  105. package/dist/{query-lane-context-QIUURgPP-CvQ9jQRm.d.mts → query-lane-context-BUNC86DS-C_hIrqaW.d.mts} +6 -6
  106. package/dist/{query-lane-context-QIUURgPP-CvQ9jQRm.d.mts.map → query-lane-context-BUNC86DS-C_hIrqaW.d.mts.map} +1 -1
  107. package/dist/query-lane-context-CeOxBL6I.d.mts +1 -0
  108. package/dist/relational-core.d.mts +12 -12
  109. package/dist/relational-core.mjs +3 -3
  110. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  111. package/dist/relational-core__ast.d.mts +4 -4
  112. package/dist/relational-core__ast.mjs +3 -3
  113. package/dist/relational-core__codec-descriptor-registry.d.mts +3 -3
  114. package/dist/relational-core__contract-free.d.mts +3 -3
  115. package/dist/relational-core__contract-free.mjs +1 -1
  116. package/dist/relational-core__contract-free.mjs.map +1 -1
  117. package/dist/relational-core__expression.d.mts +1 -1
  118. package/dist/relational-core__middleware.d.mts +2 -2
  119. package/dist/relational-core__plan.d.mts +3 -3
  120. package/dist/relational-core__query-lane-context.d.mts +2 -2
  121. package/dist/relational-core__types.d.mts +2 -2
  122. package/dist/{runtime-gCSNgykk.d.mts → runtime-BqAUXvAl.d.mts} +3 -3
  123. package/dist/{runtime-gCSNgykk.d.mts.map → runtime-BqAUXvAl.d.mts.map} +1 -1
  124. package/dist/runtime.d.mts +4 -4
  125. package/dist/runtime.mjs +1 -1
  126. package/dist/runtime__internal__prepared-query.d.mts +1 -1
  127. package/dist/{schema-differ-DpG_gnur-DrAcUO68.d.mts → schema-differ-DpG_gnur-CXVM1Oed.d.mts} +4 -4
  128. package/dist/{schema-differ-DpG_gnur-DrAcUO68.d.mts.map → schema-differ-DpG_gnur-CXVM1Oed.d.mts.map} +1 -1
  129. package/dist/schema-ir.d.mts +1 -1
  130. package/dist/schema-ir__types.d.mts +2 -2
  131. package/dist/{sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs → sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs} +37 -23
  132. package/dist/sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs.map +1 -0
  133. package/dist/{sql-execution-plan-S3HvDKIP-8KF1nBHu.d.mts → sql-execution-plan-DBvAsaOB-LUMcfRpN.d.mts} +3 -3
  134. package/dist/sql-execution-plan-DBvAsaOB-LUMcfRpN.d.mts.map +1 -0
  135. package/dist/{types-BDUG29Df-DRoC4zw1.d.mts → types-BDUG29Df-LE85dIXP.d.mts} +2 -2
  136. package/dist/{types-BDUG29Df-DRoC4zw1.d.mts.map → types-BDUG29Df-LE85dIXP.d.mts.map} +1 -1
  137. package/dist/{types-BFPRCYGW-CvvVz-AC.d.mts → types-BFPRCYGW-CBv60DKI.d.mts} +7 -7
  138. package/dist/{types-BFPRCYGW-CvvVz-AC.d.mts.map → types-BFPRCYGW-CBv60DKI.d.mts.map} +1 -1
  139. package/dist/{types-CRU1CBUk-CR2_opbw.d.mts → types-BLVS175T-DmpY58Nx.d.mts} +9 -9
  140. package/dist/{types-CRU1CBUk-CR2_opbw.d.mts.map → types-BLVS175T-DmpY58Nx.d.mts.map} +1 -1
  141. package/dist/types-BijNazlM.d.mts +1 -0
  142. package/dist/{types-BmgtemBx.d.mts → types-C36_3E6_.d.mts} +2 -2
  143. package/dist/{types-BmgtemBx.d.mts.map → types-C36_3E6_.d.mts.map} +1 -1
  144. package/dist/{types-CHOgKgHg-DMlDrQz6.d.mts → types-CHOgKgHg-BxgkL3GS.d.mts} +2 -2
  145. package/dist/{types-CHOgKgHg-DMlDrQz6.d.mts.map → types-CHOgKgHg-BxgkL3GS.d.mts.map} +1 -1
  146. package/dist/types-CQ8FfvRk.d.mts +1 -0
  147. package/dist/{types-BXSw7th1-pL1Iggyd.d.mts → types-YGX78yVc-BBy1pp_1.d.mts} +7 -5
  148. package/dist/types-YGX78yVc-BBy1pp_1.d.mts.map +1 -0
  149. package/dist/{validators-DvtOcB04.d.mts → validators-CJSyNFS4.d.mts} +2 -2
  150. package/dist/{validators-DvtOcB04.d.mts.map → validators-CJSyNFS4.d.mts.map} +1 -1
  151. package/package.json +18 -18
  152. package/dist/ast-BHZ0g4iL.d.mts.map +0 -1
  153. package/dist/ast-C8jX7HNs.mjs.map +0 -1
  154. package/dist/control-C9oCqe39.d.mts.map +0 -1
  155. package/dist/control-adapter-Bx5ZQKj-.d.mts +0 -1
  156. package/dist/derived-checks-C4BPtrnO-B9MQRh6W.mjs.map +0 -1
  157. package/dist/interpreter-Bf7Um__3-DC_thY44.mjs.map +0 -1
  158. package/dist/middleware-Di3_d2T5.d.mts +0 -1
  159. package/dist/plan-BEJGOQ-l.d.mts +0 -2
  160. package/dist/plan-Bs-Pdirc-BCy94--G.d.mts.map +0 -1
  161. package/dist/psl-infer-6p4x9ebN.mjs.map +0 -1
  162. package/dist/psl-infer-CLZsT2Hz.d.mts.map +0 -1
  163. package/dist/query-lane-context-yy5kDAlG.d.mts +0 -1
  164. package/dist/sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs.map +0 -1
  165. package/dist/sql-execution-plan-S3HvDKIP-8KF1nBHu.d.mts.map +0 -1
  166. package/dist/types-BXSw7th1-pL1Iggyd.d.mts.map +0 -1
  167. package/dist/types-D3XRY_cO.d.mts +0 -1
  168. package/dist/types-RPn42d0t.d.mts +0 -1
@@ -1,5 +1,5 @@
1
1
  import { i as SqlNamespaceBase, s as SqlNamespaceInput } from "./sql-storage-8LqxeLAY-DH4DdUXx.mjs";
2
- import "./types-BmgtemBx.mjs";
2
+ import "./types-C36_3E6_.mjs";
3
3
  import { ControlPolicy } from "@prisma/orm-framework/contract/types";
4
4
  import { TargetPackRef } from "@prisma/orm-framework/components/components";
5
5
  import { ContractConfig } from "@prisma/orm-framework/config/config-types";
@@ -1,7 +1,7 @@
1
1
  import { d as validateSqlStorageConsistency, l as validateModelStorageReferences } from "./validators-y6eLjhcb.mjs";
2
2
  import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
3
- import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-C4BPtrnO-B9MQRh6W.mjs";
4
- import { a as normalizeReferentialAction, n as buildEntityTypesByDiscriminator, o as numberLiteralDefault, r as indexFkRelations, s as resolveFieldTypeDescriptor, t as applyBackrelationCandidates } from "./interpreter-Bf7Um__3-DC_thY44.mjs";
3
+ import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-6WZKIUxH-B3Pd6QA5.mjs";
4
+ import { c as resolveFieldTypeDescriptor, i as indexFkRelations, n as buildEntityTypesByDiscriminator, o as normalizeReferentialAction, r as entryForTag, s as readDataTypeDefault, t as applyBackrelationCandidates } from "./interpreter-BIBwrA2w-DAiNN30m.mjs";
5
5
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
6
6
  import { collectScalarTypeConstructors, instantiateAuthoringEntityType } from "@prisma/orm-framework/components/authoring";
7
7
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -93,35 +93,84 @@ function lowerPrisma7Default(input) {
93
93
  return {
94
94
  storage: {
95
95
  kind: "literal",
96
- value: scalar
96
+ value: scalar,
97
+ canonical: true
97
98
  },
98
99
  onCreate: void 0
99
100
  };
100
101
  }
102
+ /**
103
+ * The stored value of a written default: an enum member resolves through the enum's members, and
104
+ * every other value is read by the authoring entry for its syntax, cast into the column's data type
105
+ * and validated by the column's codec — the same path the current schema language takes.
106
+ */
101
107
  function scalarValue$1(expression, input, unknown) {
102
108
  const span = input.attribute.span;
103
- const isJson = input.literalForm?.kind === "json";
104
- const jsonNull = (holds) => {
105
- input.diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_JSON_NULL_DEFAULT_UNSUPPORTED", `Field "${input.modelName}.${input.field.name}": @default(${printSyntax(expression.syntax).trim()}) ${holds} the JSON value null, which the contract cannot tell apart from SQL NULL. Remove the @default or give it another JSON value; either changes the column default on Prisma 7's next migration.`, input.sourceId, span));
106
- };
109
+ const enumValue = enumMemberValue(expression, input);
110
+ if (enumValue !== void 0) return enumValue;
107
111
  const array = ArrayLiteralAst.cast(expression.syntax);
108
- if (array !== void 0) {
112
+ const elements = array === void 0 ? void 0 : [...array.elements()];
113
+ if (elements?.some((element) => enumMemberValue(element, input) !== void 0) === true) {
109
114
  const values = [];
110
- for (const element of array.elements()) {
111
- const value = elementValue(element, input);
112
- if (value === void 0) return unknown(rejectedNumberReason(element, input) ?? "lists may only hold literals or enum members.", span);
115
+ for (const element of elements) {
116
+ const value = enumMemberValue(element, input);
117
+ if (value === void 0) return unknown("lists may only hold literals or enum members.", span);
113
118
  values.push(value);
114
119
  }
115
- if (isJson && values.includes(null)) return jsonNull("holds");
116
120
  return values;
117
121
  }
118
- const value = elementValue(expression, input);
119
- if (isJson && value === null) return jsonNull("is");
120
- if (value !== void 0) return value;
121
- const numberReason = rejectedNumberReason(expression, input);
122
- if (numberReason !== void 0) return unknown(numberReason, span);
122
+ const written = writtenLiteralFor(expression, elements, input);
123
+ if (written === void 0) return unreadableValue(expression, input, unknown);
124
+ const jsonNull = jsonNullDefault(written, expression, input);
125
+ if (jsonNull !== void 0) return jsonNull;
126
+ const read = readDataTypeDefault({
127
+ written,
128
+ isList: input.field.list,
129
+ column: {
130
+ codecId: input.codecId,
131
+ typeParams: input.typeParams
132
+ },
133
+ codecLookup: input.codecLookup,
134
+ support: input.dataTypeSupport,
135
+ fieldPath: `${input.modelName}.${input.field.name}`
136
+ });
137
+ return read.ok ? read.value : unknown(refusalReason(read.refusal), span);
138
+ }
139
+ /** The storage value of an enum member name, when the field is typed by a Prisma 7 enum. */
140
+ function enumMemberValue(expression, input) {
141
+ const member = IdentifierAst.cast(expression.syntax)?.name();
142
+ return member === void 0 ? void 0 : input.enumMembers?.get(member);
143
+ }
144
+ function writtenLiteralFor(expression, elements, input) {
145
+ if (elements === void 0) return writtenLiteral(expression, input);
146
+ const written = [];
147
+ for (const element of elements) {
148
+ const elementLiteral = writtenLiteral(element, input);
149
+ if (elementLiteral === void 0) return void 0;
150
+ written.push(elementLiteral);
151
+ }
152
+ return {
153
+ kind: "list",
154
+ elements: written
155
+ };
156
+ }
157
+ /**
158
+ * The JSON value null, which the contract cannot tell apart from SQL NULL, reported before the
159
+ * column's codec sees the literal.
160
+ */
161
+ function jsonNullDefault(written, expression, input) {
162
+ if (input.literalForm?.kind !== "json") return void 0;
163
+ const value = jsonDocumentOf(written, input);
164
+ if (value === void 0) return void 0;
165
+ if (!(Array.isArray(value) ? value.includes(null) : value === null)) return void 0;
166
+ input.diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_JSON_NULL_DEFAULT_UNSUPPORTED", `Field "${input.modelName}.${input.field.name}": @default(${printSyntax(expression.syntax).trim()}) ${written.kind === "list" ? "holds" : "is"} the JSON value null, which the contract cannot tell apart from SQL NULL. Remove the @default or give it another JSON value; either changes the column default on Prisma 7's next migration.`, input.sourceId, input.attribute.span));
167
+ }
168
+ /** A `@default(...)` this contract source cannot read as a literal at all. */
169
+ function unreadableValue(expression, input, unknown) {
170
+ const span = input.attribute.span;
123
171
  const identifier = IdentifierAst.cast(expression.syntax)?.name();
124
172
  if (identifier !== void 0) return unknown(input.enumMembers === void 0 ? `refers to "${identifier}", but the field is not an enum.` : `refers to "${identifier}", which is not a member of the field's enum.`, span);
173
+ if (ArrayLiteralAst.cast(expression.syntax) !== void 0) return unknown("lists may only hold literals or enum members.", span);
125
174
  return unknown("holds a value this contract source does not read.", span);
126
175
  }
127
176
  function sqlExpressionDefault(expression, form, isList) {
@@ -141,40 +190,55 @@ function sqlExpressionDefault(expression, form, isList) {
141
190
  }
142
191
  return { expression: form.list(literals) };
143
192
  }
144
- /** The Prisma 7 scalars whose number defaults must be whole numbers, as each is named in a message. */
145
- const WHOLE_NUMBER_SCALARS = {
146
- Int: "an Int",
147
- BigInt: "a BigInt"
148
- };
149
- const WHOLE_NUMBER_TEXT = /^-?\d+$/;
150
- /** The number literal the column codec reads neither as a number nor as text, such as `1.5` for a `BigInt`, which Prisma 7 rejects too. */
151
- function rejectedNumberReason(expression, input) {
152
- const text = NumberLiteralExprAst.cast(expression.syntax)?.token()?.text;
153
- if (text === void 0 || numberValue(text, input) !== void 0) return void 0;
154
- const { typeName } = input.field;
155
- const wholeNumberScalar = Object.hasOwn(WHOLE_NUMBER_SCALARS, typeName) ? WHOLE_NUMBER_SCALARS[typeName] : void 0;
156
- return wholeNumberScalar === void 0 ? `holds ${text}, which is not a valid ${typeName} value.` : `holds ${text}, which is not an integer; ${wholeNumberScalar} default must be a whole number.`;
193
+ /** The written literal a Prisma 7 expression is, or `undefined` when it is not a literal at all. */
194
+ function writtenLiteral(expression, input) {
195
+ const text = StringLiteralExprAst.cast(expression.syntax)?.value();
196
+ if (text !== void 0) return input.literalForm?.kind === "json" ? {
197
+ kind: "tag",
198
+ tag: "json",
199
+ body: text
200
+ } : {
201
+ kind: "string",
202
+ text
203
+ };
204
+ const number = NumberLiteralExprAst.cast(expression.syntax)?.token()?.text;
205
+ if (number !== void 0) return {
206
+ kind: "number",
207
+ text: number
208
+ };
209
+ const boolean = BooleanLiteralExprAst.cast(expression.syntax)?.value();
210
+ return boolean === void 0 ? void 0 : {
211
+ kind: "boolean",
212
+ value: boolean
213
+ };
157
214
  }
158
- /** A number default for the field: Prisma 7 accepts only whole numbers for `Int` and `BigInt`. */
159
- function numberValue(text, input) {
160
- if (Object.hasOwn(WHOLE_NUMBER_SCALARS, input.field.typeName) && !WHOLE_NUMBER_TEXT.test(text)) return;
161
- return numberLiteralDefault(text, input.codecId, input.codecLookup);
215
+ /**
216
+ * The document a written JSON value holds, read through the same entry the interpreter uses, or
217
+ * `undefined` when the body is not a document.
218
+ */
219
+ function jsonDocumentOf(written, input) {
220
+ const entry = entryForTag(input.dataTypeSupport, "json");
221
+ if (entry === void 0 || entry.entry.written.kind !== "tag") return void 0;
222
+ const bodies = written.kind === "list" ? written.elements.flatMap((element) => element.kind === "tag" ? [element.body] : []) : written.kind === "tag" ? [written.body] : [];
223
+ const parse = entry.entry.written.parse;
224
+ try {
225
+ const documents = bodies.map((body) => parse(body));
226
+ return written.kind === "list" ? documents : documents[0];
227
+ } catch {
228
+ return;
229
+ }
162
230
  }
163
- function elementValue(expression, input) {
164
- const member = IdentifierAst.cast(expression.syntax)?.name();
165
- if (member !== void 0) return input.enumMembers?.get(member);
166
- const number = NumberLiteralExprAst.cast(expression.syntax)?.token()?.text;
167
- if (number !== void 0) return numberValue(number, input);
168
- const text = StringLiteralExprAst.cast(expression.syntax)?.value();
169
- if (text !== void 0) {
170
- if (input.literalForm?.kind === "json") try {
171
- return blindCast(JSON.parse(text));
172
- } catch {
173
- return;
174
- }
175
- return text;
231
+ /** Why the column refused the value, as a phrase following `@default `. */
232
+ function refusalReason(refusal) {
233
+ const at = refusal.elementIndex === void 0 ? "" : ` at element ${refusal.elementIndex + 1}`;
234
+ switch (refusal.kind) {
235
+ case "unreadable": return `holds text${at} that this contract source does not read: ${refusal.message}`;
236
+ case "unknown-tag": return `holds a ${refusal.tag} literal${at}, which this stack does not register.`;
237
+ case "unwritable": return `holds a ${refusal.syntax} value${at}, which this target has no data type for.`;
238
+ case "not-a-list": return "holds a single value on a list column, which takes a list literal.";
239
+ case "no-cast": return `holds a ${refusal.valueType} value${at}, which ${refusal.columnType} has no cast from; ${refusal.casts.length === 0 ? "it casts from nothing" : `it casts from ${refusal.casts.join(", ")}`}.`;
240
+ case "undecodable": return `holds a value${at} that ${refusal.codecId} does not read: ${refusal.message}`;
176
241
  }
177
- return BooleanLiteralExprAst.cast(expression.syntax)?.value();
178
242
  }
179
243
  function lowerFunction(call, input, label, unknown) {
180
244
  const fn = call.path().join(".");
@@ -1485,7 +1549,12 @@ function readField(args) {
1485
1549
  field,
1486
1550
  modelName: model.symbol.name,
1487
1551
  codecId: resolved.descriptor.codecId,
1552
+ typeParams: resolved.descriptor.typeParams,
1488
1553
  codecLookup: input.codecLookup,
1554
+ dataTypeSupport: {
1555
+ entries: input.authoringContributions?.dataTypes ?? {},
1556
+ lookup: input.dataTypeLookup
1557
+ },
1489
1558
  literalForm: binding.literalDefaultForm(resolved.descriptor),
1490
1559
  enumMembers: enumDeclaration === void 0 ? void 0 : new Map(enumDeclaration.members.map((member) => [member.name, member.value])),
1491
1560
  controlMutationDefaults: input.controlMutationDefaults,
@@ -1634,6 +1703,7 @@ function prisma7Contract(schemaPath, options) {
1634
1703
  controlMutationDefaults: context.controlMutationDefaults,
1635
1704
  authoringContributions: context.authoringContributions,
1636
1705
  codecLookup: context.codecLookup,
1706
+ dataTypeLookup: context.dataTypeLookup,
1637
1707
  composedExtensions: context.composedExtensions
1638
1708
  });
1639
1709
  if (!interpreted.ok) return interpreted;