@prisma/orm-family-sql 8.0.0-rc.14-dev.6 → 8.0.0-rc.14-dev.7

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 (195) hide show
  1. package/dist/{ast-CJd4157-.mjs → ast-5hifzBHC.mjs} +84 -35
  2. package/dist/ast-5hifzBHC.mjs.map +1 -0
  3. package/dist/{ast-B53rACdv.d.mts → ast-BQOF33Tw.d.mts} +40 -16
  4. package/dist/ast-BQOF33Tw.d.mts.map +1 -0
  5. package/dist/{authoring-entity-types-CZ-vdwYS-D6R9QovE.d.mts → authoring-entity-types-CZ-vdwYS-BCsVtN8A.d.mts} +2 -2
  6. package/dist/{authoring-entity-types-CZ-vdwYS-D6R9QovE.d.mts.map → authoring-entity-types-CZ-vdwYS-BCsVtN8A.d.mts.map} +1 -1
  7. package/dist/{authoring-type-constructors-DQZEX4Sb-D6uFhwhG.mjs → authoring-type-constructors-kt60uJ3j-BpulZfmt.mjs} +7 -4
  8. package/dist/authoring-type-constructors-kt60uJ3j-BpulZfmt.mjs.map +1 -0
  9. package/dist/builder.d.mts +2 -2
  10. package/dist/builder__runtime.d.mts +9 -9
  11. package/dist/builder__runtime.mjs +1 -1
  12. package/dist/builder__types.d.mts +2 -2
  13. package/dist/{codec-descriptor-registry-Cj-tqpFL.mjs → codec-descriptor-registry-B1v3GEdK.mjs} +13 -22
  14. package/dist/codec-descriptor-registry-B1v3GEdK.mjs.map +1 -0
  15. package/dist/{config-types-CEXpi8FV.mjs → config-types-BrBS_jH9.mjs} +2 -2
  16. package/dist/{config-types-CEXpi8FV.mjs.map → config-types-BrBS_jH9.mjs.map} +1 -1
  17. package/dist/{config-types-Bd3ud-mX.d.mts → config-types-VJ5O9Ert.d.mts} +4 -4
  18. package/dist/{config-types-Bd3ud-mX.d.mts.map → config-types-VJ5O9Ert.d.mts.map} +1 -1
  19. package/dist/{contract-builder-vmb0E3SP.mjs → contract-builder-39dhpN_w.mjs} +3 -3
  20. package/dist/contract-builder-39dhpN_w.mjs.map +1 -0
  21. package/dist/{contract-builder-6ujqQuj-.d.mts → contract-builder-ezejmfrY.d.mts} +48 -22
  22. package/dist/contract-builder-ezejmfrY.d.mts.map +1 -0
  23. package/dist/contract-emitter.d.mts +0 -1
  24. package/dist/contract-emitter.d.mts.map +1 -1
  25. package/dist/contract-emitter.mjs +1 -1
  26. package/dist/contract-prisma7__provider.d.mts +2 -2
  27. package/dist/contract-prisma7__provider.mjs +3 -3
  28. package/dist/contract-prisma7__provider.mjs.map +1 -1
  29. package/dist/contract-psl.d.mts +6 -6
  30. package/dist/contract-psl.d.mts.map +1 -1
  31. package/dist/contract-psl.mjs +1 -1
  32. package/dist/contract-psl__provider.d.mts +2 -2
  33. package/dist/contract-psl__provider.mjs +2 -2
  34. package/dist/contract-psl__provider.mjs.map +1 -1
  35. package/dist/contract-ts.d.mts +4 -4
  36. package/dist/contract-ts.mjs +4 -4
  37. package/dist/contract-ts__config-types.d.mts +1 -1
  38. package/dist/contract-ts__config-types.mjs +1 -1
  39. package/dist/contract-ts__contract-builder.d.mts +3 -3
  40. package/dist/contract-ts__contract-builder.mjs +3 -3
  41. package/dist/{contract-view-CPHxoAEX.d.mts → contract-view-BTFdP8wh.d.mts} +2 -2
  42. package/dist/{contract-view-CPHxoAEX.d.mts.map → contract-view-BTFdP8wh.d.mts.map} +1 -1
  43. package/dist/contract.d.mts +9 -9
  44. package/dist/contract.mjs +2 -2
  45. package/dist/contract__contract-view.d.mts +1 -1
  46. package/dist/contract__factories.d.mts +1 -1
  47. package/dist/contract__index-type-validation.d.mts +1 -1
  48. package/dist/contract__resolve-storage-table.d.mts +1 -1
  49. package/dist/contract__types.d.mts +4 -4
  50. package/dist/contract__types.mjs +2 -2
  51. package/dist/contract__validators.d.mts +1 -1
  52. package/dist/{control-2-eFP31F.mjs → control-BEikPMFg.mjs} +15 -14
  53. package/dist/control-BEikPMFg.mjs.map +1 -0
  54. package/dist/{control-adapter-C99J7aEF-B3_IhgH6.d.mts → control-adapter-C4_cgvzB-BwZx3_VD.d.mts} +11 -7
  55. package/dist/control-adapter-C4_cgvzB-BwZx3_VD.d.mts.map +1 -0
  56. package/dist/control-adapter-CDDbpxyt.d.mts +1 -0
  57. package/dist/{control-DmVQjyZd.d.mts → control-k5_z0qcA.d.mts} +22 -20
  58. package/dist/{control-DmVQjyZd.d.mts.map → control-k5_z0qcA.d.mts.map} +1 -1
  59. package/dist/{db-DLjWu9-f-COdzEg7b.d.mts → db-DLjWu9-f-BWg-lrGV.d.mts} +8 -8
  60. package/dist/{db-DLjWu9-f-COdzEg7b.d.mts.map → db-DLjWu9-f-BWg-lrGV.d.mts.map} +1 -1
  61. package/dist/{ddl-types-DD-i-Uj9-BRqLNUDm.d.mts → ddl-types-B23QEzDx-ridB7leA.d.mts} +5 -5
  62. package/dist/{ddl-types-DD-i-Uj9-BRqLNUDm.d.mts.map → ddl-types-B23QEzDx-ridB7leA.d.mts.map} +1 -1
  63. package/dist/{ddl-types-DOgOmDOh-Cs_MY05h.mjs → ddl-types-B700dqv--DOnQueWA.mjs} +3 -3
  64. package/dist/ddl-types-B700dqv--DOnQueWA.mjs.map +1 -0
  65. package/dist/{derived-checks-C6psACIj-BSBDa2_9.mjs → derived-checks-D8_YCVs5-CfBVLnya.mjs} +112 -109
  66. package/dist/derived-checks-D8_YCVs5-CfBVLnya.mjs.map +1 -0
  67. package/dist/{derived-checks-DPdD01O0-DNBs1ZDA.d.mts → derived-checks-DPdD01O0-zXZEuy5P.d.mts} +3 -3
  68. package/dist/{derived-checks-DPdD01O0-DNBs1ZDA.d.mts.map → derived-checks-DPdD01O0-zXZEuy5P.d.mts.map} +1 -1
  69. package/dist/{diff-DFOiwUHg.d.mts → diff-C_zQQTgw.d.mts} +6 -6
  70. package/dist/{diff-DFOiwUHg.d.mts.map → diff-C_zQQTgw.d.mts.map} +1 -1
  71. package/dist/{dist-ChyuAdtP.mjs → dist-DeiKZwAD.mjs} +4 -35
  72. package/dist/dist-DeiKZwAD.mjs.map +1 -0
  73. package/dist/{expression-Dl5WvxCA.d.mts → expression-B95FOcDX.d.mts} +7 -7
  74. package/dist/{expression-Dl5WvxCA.d.mts.map → expression-B95FOcDX.d.mts.map} +1 -1
  75. package/dist/{factories-P3qBQhO-.d.mts → factories-TIM9dI6S.d.mts} +2 -2
  76. package/dist/{factories-P3qBQhO-.d.mts.map → factories-TIM9dI6S.d.mts.map} +1 -1
  77. package/dist/family.d.mts +12 -12
  78. package/dist/family.mjs +4 -4
  79. package/dist/family__control-adapter.d.mts +2 -2
  80. package/dist/family__control.d.mts +4 -4
  81. package/dist/family__control.mjs +2 -2
  82. package/dist/family__diff.d.mts +2 -2
  83. package/dist/family__diff.mjs +1 -1
  84. package/dist/family__ir.d.mts +1 -1
  85. package/dist/family__ir.mjs +1 -1
  86. package/dist/family__migration.d.mts +1 -1
  87. package/dist/family__pack.d.mts +1 -1
  88. package/dist/family__pack.mjs +1 -1
  89. package/dist/family__pack.mjs.map +1 -1
  90. package/dist/family__psl-build.mjs +1 -1
  91. package/dist/family__runtime.d.mts +2 -2
  92. package/dist/{index-Cef8iy1o.d.mts → index-DrUd8HwS.d.mts} +3 -3
  93. package/dist/{index-Cef8iy1o.d.mts.map → index-DrUd8HwS.d.mts.map} +1 -1
  94. package/dist/{index-BNL2_qQY.d.mts → index-DrWMh8L0.d.mts} +11 -11
  95. package/dist/{index-BNL2_qQY.d.mts.map → index-DrWMh8L0.d.mts.map} +1 -1
  96. package/dist/{index-type-validation-CZ5L2lli.d.mts → index-type-validation-BAQWs-c_.d.mts} +3 -3
  97. package/dist/{index-type-validation-CZ5L2lli.d.mts.map → index-type-validation-BAQWs-c_.d.mts.map} +1 -1
  98. package/dist/{interpreter-Bcc3MIC5-C4dZrobt.mjs → interpreter-j1ewAXPb-BwieIKeF.mjs} +299 -157
  99. package/dist/interpreter-j1ewAXPb-BwieIKeF.mjs.map +1 -0
  100. package/dist/{ir-BJ-dsbe-.d.mts → ir-DI4cwMsy.d.mts} +3 -3
  101. package/dist/{ir-BJ-dsbe-.d.mts.map → ir-DI4cwMsy.d.mts.map} +1 -1
  102. package/dist/middleware-C6T9FExV.d.mts +1 -0
  103. package/dist/{middleware-CuGBptK0-UwVChCr2.d.mts → middleware-CuGBptK0-CGDI6sQU.d.mts} +2 -2
  104. package/dist/{middleware-CuGBptK0-UwVChCr2.d.mts.map → middleware-CuGBptK0-CGDI6sQU.d.mts.map} +1 -1
  105. package/dist/{migration-Csmr6bd8.d.mts → migration-CRsGI-9f.d.mts} +4 -4
  106. package/dist/{migration-Csmr6bd8.d.mts.map → migration-CRsGI-9f.d.mts.map} +1 -1
  107. package/dist/operations.d.mts +1 -1
  108. package/dist/orm-client.d.mts +14 -14
  109. package/dist/orm-client.mjs +4 -3
  110. package/dist/orm-client.mjs.map +1 -1
  111. package/dist/{pack-BUv79Jrr.d.mts → pack-DcSVDz7M.d.mts} +2 -2
  112. package/dist/{pack-BUv79Jrr.d.mts.map → pack-DcSVDz7M.d.mts.map} +1 -1
  113. package/dist/{plan-B7g2kDfQ-ZD3BfWYx.d.mts → plan-B7g2kDfQ-Do1iWC4q.d.mts} +4 -4
  114. package/dist/{plan-B7g2kDfQ-ZD3BfWYx.d.mts.map → plan-B7g2kDfQ-Do1iWC4q.d.mts.map} +1 -1
  115. package/dist/plan-BBBYfvlz.d.mts +2 -0
  116. package/dist/{prepared-statement-BHSj2pDk-D9a_Vwr-.d.mts → prepared-statement-BdsTSY7Y-ICyuLB7c.d.mts} +17 -17
  117. package/dist/{prepared-statement-BHSj2pDk-D9a_Vwr-.d.mts.map → prepared-statement-BdsTSY7Y-ICyuLB7c.d.mts.map} +1 -1
  118. package/dist/{psl-build-ph4eUJSB.mjs → psl-build-139T3MMA.mjs} +3 -3
  119. package/dist/{psl-build-ph4eUJSB.mjs.map → psl-build-139T3MMA.mjs.map} +1 -1
  120. package/dist/query-lane-context-B0R8L6W-.d.mts +1 -0
  121. package/dist/{query-lane-context-D6o9YrEV-BxW3-5e8.d.mts → query-lane-context-BSmWfohZ-QAWw_dXQ.d.mts} +6 -6
  122. package/dist/{query-lane-context-D6o9YrEV-BxW3-5e8.d.mts.map → query-lane-context-BSmWfohZ-QAWw_dXQ.d.mts.map} +1 -1
  123. package/dist/relational-core.d.mts +12 -12
  124. package/dist/relational-core.mjs +3 -3
  125. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  126. package/dist/relational-core__ast.d.mts +4 -4
  127. package/dist/relational-core__ast.mjs +3 -3
  128. package/dist/relational-core__codec-descriptor-registry.d.mts +4 -4
  129. package/dist/relational-core__codec-descriptor-registry.mjs +1 -1
  130. package/dist/relational-core__contract-free.d.mts +3 -3
  131. package/dist/relational-core__contract-free.mjs +1 -1
  132. package/dist/relational-core__contract-free.mjs.map +1 -1
  133. package/dist/relational-core__expression.d.mts +1 -1
  134. package/dist/relational-core__middleware.d.mts +2 -2
  135. package/dist/relational-core__plan.d.mts +3 -3
  136. package/dist/relational-core__query-lane-context.d.mts +2 -2
  137. package/dist/relational-core__types.d.mts +2 -2
  138. package/dist/{resolve-storage-table-Nyrgk4h8.d.mts → resolve-storage-table-DhgzQjow.d.mts} +2 -2
  139. package/dist/{resolve-storage-table-Nyrgk4h8.d.mts.map → resolve-storage-table-DhgzQjow.d.mts.map} +1 -1
  140. package/dist/{runtime-DgOeosYa.d.mts → runtime-I-W0bhvd.d.mts} +2 -2
  141. package/dist/{runtime-DgOeosYa.d.mts.map → runtime-I-W0bhvd.d.mts.map} +1 -1
  142. package/dist/runtime.d.mts +4 -4
  143. package/dist/runtime.mjs +6 -4
  144. package/dist/runtime.mjs.map +1 -1
  145. package/dist/runtime__internal__prepared-query.d.mts +1 -1
  146. package/dist/{schema-differ-DpG_gnur-3ciAcy28.d.mts → schema-differ-DpG_gnur-gLIPLPVI.d.mts} +3 -3
  147. package/dist/{schema-differ-DpG_gnur-3ciAcy28.d.mts.map → schema-differ-DpG_gnur-gLIPLPVI.d.mts.map} +1 -1
  148. package/dist/schema-ir.mjs +1 -1
  149. package/dist/schema-ir__types.mjs +1 -1
  150. package/dist/{schema-verify-DI0aJQ9d-Bgbmen10.mjs → schema-verify-DI0aJQ9d-DL-C6on7.mjs} +2 -2
  151. package/dist/{schema-verify-DI0aJQ9d-Bgbmen10.mjs.map → schema-verify-DI0aJQ9d-DL-C6on7.mjs.map} +1 -1
  152. package/dist/{sql-contract-serializer-C90xg7_q-DERDzTD5.mjs → sql-contract-serializer-C90xg7_q-DBJSt3MT.mjs} +2 -2
  153. package/dist/{sql-contract-serializer-C90xg7_q-DERDzTD5.mjs.map → sql-contract-serializer-C90xg7_q-DBJSt3MT.mjs.map} +1 -1
  154. package/dist/{sql-execution-plan-Db0j752I-faODNLY9.d.mts → sql-execution-plan-Db0j752I-uGUWy8sD.d.mts} +2 -2
  155. package/dist/{sql-execution-plan-Db0j752I-faODNLY9.d.mts.map → sql-execution-plan-Db0j752I-uGUWy8sD.d.mts.map} +1 -1
  156. package/dist/{sql-storage-8LqxeLAY-DH4DdUXx.d.mts → sql-storage-BSxD7_vv-C4ugLH39.d.mts} +10 -3
  157. package/dist/sql-storage-BSxD7_vv-C4ugLH39.d.mts.map +1 -0
  158. package/dist/{types-BFPRCYGW-CZrZyp1E.d.mts → types-BKJWoQ40-BzViF_9K.d.mts} +7 -7
  159. package/dist/{types-BFPRCYGW-CZrZyp1E.d.mts.map → types-BKJWoQ40-BzViF_9K.d.mts.map} +1 -1
  160. package/dist/{types-D8Se4rnB.mjs → types-BmXzMDQL.mjs} +9 -2
  161. package/dist/types-BmXzMDQL.mjs.map +1 -0
  162. package/dist/{types-C36_3E6_.d.mts → types-BoMDdzjD.d.mts} +3 -3
  163. package/dist/{types-C36_3E6_.d.mts.map → types-BoMDdzjD.d.mts.map} +1 -1
  164. package/dist/types-BsUJ1jWE.d.mts +1 -0
  165. package/dist/{types-DFJNPLXY-DyYKIhXA.d.mts → types-C0VMsES6-BLOPdA8Y.d.mts} +10 -10
  166. package/dist/{types-DFJNPLXY-DyYKIhXA.d.mts.map → types-C0VMsES6-BLOPdA8Y.d.mts.map} +1 -1
  167. package/dist/{types-yyhkYQNT-Dmoq-giA.mjs → types-C5QzgUrH-B7IJM6qN.mjs} +8 -14
  168. package/dist/types-C5QzgUrH-B7IJM6qN.mjs.map +1 -0
  169. package/dist/{types-BDUG29Df-LE85dIXP.d.mts → types-DTUyRqZv-DLh98w8w.d.mts} +3 -3
  170. package/dist/{types-BDUG29Df-LE85dIXP.d.mts.map → types-DTUyRqZv-DLh98w8w.d.mts.map} +1 -1
  171. package/dist/{types-Yui2yFf6-Dnc7RNUD.d.mts → types-Yui2yFf6-DQkiEr9B.d.mts} +2 -2
  172. package/dist/{types-Yui2yFf6-Dnc7RNUD.d.mts.map → types-Yui2yFf6-DQkiEr9B.d.mts.map} +1 -1
  173. package/dist/{validators-CJSyNFS4.d.mts → validators-CZNulH-_.d.mts} +3 -3
  174. package/dist/{validators-CJSyNFS4.d.mts.map → validators-CZNulH-_.d.mts.map} +1 -1
  175. package/package.json +18 -18
  176. package/dist/ast-B53rACdv.d.mts.map +0 -1
  177. package/dist/ast-CJd4157-.mjs.map +0 -1
  178. package/dist/authoring-type-constructors-DQZEX4Sb-D6uFhwhG.mjs.map +0 -1
  179. package/dist/codec-descriptor-registry-Cj-tqpFL.mjs.map +0 -1
  180. package/dist/contract-builder-6ujqQuj-.d.mts.map +0 -1
  181. package/dist/contract-builder-vmb0E3SP.mjs.map +0 -1
  182. package/dist/control-2-eFP31F.mjs.map +0 -1
  183. package/dist/control-adapter-C99J7aEF-B3_IhgH6.d.mts.map +0 -1
  184. package/dist/control-adapter-kl-cOML5.d.mts +0 -1
  185. package/dist/ddl-types-DOgOmDOh-Cs_MY05h.mjs.map +0 -1
  186. package/dist/derived-checks-C6psACIj-BSBDa2_9.mjs.map +0 -1
  187. package/dist/dist-ChyuAdtP.mjs.map +0 -1
  188. package/dist/interpreter-Bcc3MIC5-C4dZrobt.mjs.map +0 -1
  189. package/dist/middleware-RUh4qBBg.d.mts +0 -1
  190. package/dist/plan-CVje8E5I.d.mts +0 -2
  191. package/dist/query-lane-context-D54z0tof.d.mts +0 -1
  192. package/dist/sql-storage-8LqxeLAY-DH4DdUXx.d.mts.map +0 -1
  193. package/dist/types-D8Se4rnB.mjs.map +0 -1
  194. package/dist/types-Dul4Za_W.d.mts +0 -1
  195. package/dist/types-yyhkYQNT-Dmoq-giA.mjs.map +0 -1
@@ -1,18 +1,19 @@
1
1
  import { n as isAuthoredIndexInput } from "./index-naming-Cj1Anq-T-C9TevpPR.mjs";
2
2
  import { n as providesPslEntityPlacement } from "./entity-handle-lowering-hook-B3atrRKX.mjs";
3
3
  import { s as sqlTextFromCanonical, t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-BXx0Ilj-.mjs";
4
+ import { d as resolvedTypeParams } from "./types-BmXzMDQL.mjs";
4
5
  import { n as checkSqlDefaultBody, o as reservedSqlDefaultBody } from "./validators-BlqrBU7I.mjs";
5
6
  import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
6
- import { n as buildSqlContractFromDefinition } from "./derived-checks-C6psACIj-BSBDa2_9.mjs";
7
+ import { a as storedAsListColumn, i as isValueObjectMember, n as buildSqlContractFromDefinition } from "./derived-checks-D8_YCVs5-CfBVLnya.mjs";
7
8
  import { a as getAttribute, c as interpretModelAttribute, d as modelAttributeSpecsFrom, f as sqlAttributeSpecs, i as formatDbAttributeMigrationMessage, l as lowerDefaultFunctionWithRegistry, n as createSqlBinder, o as getNamedArgument, p as storageName, r as fieldSpecContext, s as interpretFieldAttribute, t as PSL_CHECK_ON_STI_VARIANT, u as mapFieldNamesToColumns } from "./sql-attribute-specs-Bs9QDuS7-DmIRJUz9.mjs";
8
9
  import { t as defaultTableName } from "./default-table-name-BfFY8qYR-lHNcVmY5.mjs";
9
10
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
10
- import { checkUncomposedNamespace, getAuthoringFieldPreset, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringTypeConstructorDescriptor, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
11
+ import { checkUncomposedNamespace, getAuthoringFieldPreset, getAuthoringTypeConstructor, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringModelAttributeDescriptor, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
11
12
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
12
- import { InternalError } from "@prisma/orm-framework/utils/internal-error";
13
+ import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
13
14
  import { crossRef } from "@prisma/orm-framework/contract/types";
14
15
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
15
- import { materializeCodec } from "@prisma/orm-framework/components/codec";
16
+ import { codecForRef } from "@prisma/orm-framework/components/codec";
16
17
  import { blindCast } from "@prisma/orm-framework/utils/casts";
17
18
  import { NamespaceDeclarationAst } from "@prisma/orm-framework/psl-parser/syntax";
18
19
  import { resolveToOneRelationNullable } from "@prisma/orm-framework/contract-authoring";
@@ -22,12 +23,14 @@ import { notOk, ok } from "@prisma/orm-framework/utils/result";
22
23
  import { createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, interpretExtensionBlocks, nodePslSpan, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
23
24
  import { UNBOUND_PSL_NAMESPACE_NAME, UNSPECIFIED_PSL_NAMESPACE_ID } from "@prisma/orm-framework/components/psl-ast";
24
25
  import { claimedBlockKeywords, enumMemberAttributeDiagnostics, fkRelationPairKey, instantiatePslFieldPreset, mapPslHelperArgs, reportUncomposedNamespace, reportUnknownFieldPreset, requiredOneToOneBackrelationDiagnostic, uncomposedNamespaceDiagnostic, unsupportedBlockDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
25
- //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-Bcc3MIC5.mjs
26
+ //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-j1ewAXPb.mjs
26
27
  function contractError(code, message, options) {
27
28
  return structuredError(code, message, options);
28
29
  }
29
30
  /** A written value the column's codec refuses. */
30
31
  const PSL_INVALID_DEFAULT_LITERAL = "PSL_INVALID_DEFAULT_LITERAL";
32
+ /** A written value whose data type the receiving type neither is nor casts from. */
33
+ const PSL_VALUE_TYPE_INCOMPATIBLE = "PSL_VALUE_TYPE_INCOMPATIBLE";
31
34
  /** A single value written as the default of a column that holds a list. */
32
35
  const PSL_DEFAULT_LIST_EXPECTED = "PSL_DEFAULT_LIST_EXPECTED";
33
36
  /** The entry a tag names, or `undefined` when no pack registered that tag. */
@@ -100,6 +103,7 @@ function readValue(support, written, elementIndex) {
100
103
  }
101
104
  };
102
105
  } catch (error) {
106
+ if (isInternalError(error)) throw error;
103
107
  return refuse({
104
108
  kind: "unreadable",
105
109
  message: messageOf(error)
@@ -130,6 +134,7 @@ function castInto(support, columnType, typed, elementIndex) {
130
134
  value: cast(typed.value)
131
135
  };
132
136
  } catch (error) {
137
+ if (isInternalError(error)) throw error;
133
138
  return {
134
139
  ok: false,
135
140
  refusal: {
@@ -145,22 +150,17 @@ function codecRefTypeParams(typeParams) {
145
150
  return typeParams === void 0 ? void 0 : blindCast(typeParams);
146
151
  }
147
152
  /**
148
- * Read one `@default(...)` value for a column, refusing in parts so each contract source words its
149
- * own diagnostic. `isList` selects the check: a list column's elements are each read and cast
150
- * against the element codec's data type, while a scalar column takes a written list only through
151
- * its type's list cast — which is how `pgvector.Vector(3) @default([0.1, 0.2])` is read.
153
+ * The column's codec descriptor, and `read`, which reads a value in its stored JSON form with the column's codec, built with the column's type parameters.
152
154
  */
153
- function readDataTypeDefault(input) {
154
- const descriptorFor = input.codecLookup?.descriptorFor;
155
- if (descriptorFor === void 0) throw new InternalError(`Field "${input.fieldPath}": the codec lookup resolving column codecs exposes no descriptorFor, but the column was resolved from a codec descriptor.`);
156
- const descriptor = descriptorFor(input.column.codecId);
157
- if (descriptor === void 0) throw new InternalError(`Field "${input.fieldPath}": no codec descriptor is registered for "${input.column.codecId}", but the column was resolved from one.`);
158
- const columnType = descriptor.dataType;
159
- const codec = materializeCodec(descriptor, {
155
+ function storedValueReader(input) {
156
+ if (input.codecLookup === void 0) throw new InternalError(`Field "${input.fieldPath}": no codec lookup was given, but the column was resolved from a codec descriptor.`);
157
+ const descriptor = input.codecLookup.descriptorFor(input.column.codecId);
158
+ const codec = codecForRef(input.codecLookup, {
160
159
  codecId: input.column.codecId,
161
160
  ...ifDefined("typeParams", codecRefTypeParams(input.column.typeParams))
162
- }, { name: input.fieldPath });
163
- const validate = (value, elementIndex) => {
161
+ });
162
+ if (codec === void 0 || descriptor === void 0) throw new InternalError(`Field "${input.fieldPath}": no codec descriptor is registered for "${input.column.codecId}", but the column was resolved from one.`);
163
+ const read = (value, elementIndex) => {
164
164
  try {
165
165
  codec.decodeJson(value);
166
166
  return {
@@ -168,10 +168,11 @@ function readDataTypeDefault(input) {
168
168
  value
169
169
  };
170
170
  } catch (error) {
171
+ if (isInternalError(error)) throw error;
171
172
  return {
172
173
  ok: false,
173
174
  refusal: {
174
- kind: "undecodable",
175
+ kind: "refused-by-codec",
175
176
  codecId: input.column.codecId,
176
177
  message: messageOf(error),
177
178
  elementIndex
@@ -179,12 +180,33 @@ function readDataTypeDefault(input) {
179
180
  };
180
181
  }
181
182
  };
183
+ return {
184
+ descriptor,
185
+ read
186
+ };
187
+ }
188
+ /**
189
+ * Reads a value already in its stored JSON form, such as one member of a JSON document default, with the column's codec. Worded as {@link lowerDataTypeDefault} words a codec refusal.
190
+ */
191
+ function readStoredValue(input) {
192
+ const reading = storedValueReader(input).read(input.value, void 0);
193
+ return reading.ok ? reading : refusalDiagnostic(reading.refusal, input.fieldPath);
194
+ }
195
+ /**
196
+ * Read one `@default(...)` value for a column, refusing in parts so each contract source words its
197
+ * own diagnostic. `isList` selects the check: a list column's elements are each read and cast
198
+ * against the element codec's data type, while a scalar column takes a written list only through
199
+ * its type's list cast — which is how `pgvector.Vector(3) @default([0.1, 0.2])` is read.
200
+ */
201
+ function readDataTypeDefault(input) {
202
+ const { descriptor, read: readStored } = storedValueReader(input);
203
+ const columnType = descriptor.dataType;
182
204
  const readOne = (written, elementIndex) => {
183
205
  const read = readValue(input.support, written, elementIndex);
184
206
  if (!read.ok) return read;
185
207
  const cast = castInto(input.support, columnType, read.typed, elementIndex);
186
208
  if (!cast.ok) return cast;
187
- return validate(cast.value, elementIndex);
209
+ return readStored(cast.value, elementIndex);
188
210
  };
189
211
  if (input.written.kind !== "list") {
190
212
  if (input.isList) return {
@@ -220,7 +242,7 @@ function readDataTypeDefault(input) {
220
242
  ...input,
221
243
  written: input.written,
222
244
  columnType,
223
- validate
245
+ readStored
224
246
  });
225
247
  }
226
248
  /** A written list on a column that is not a list: the column's type takes it through its list cast. */
@@ -261,8 +283,9 @@ function readListIntoScalar(input) {
261
283
  elements.push(read.typed.value);
262
284
  }
263
285
  try {
264
- return input.validate(listCast.cast(elements), void 0);
286
+ return input.readStored(listCast.cast(elements), void 0);
265
287
  } catch (error) {
288
+ if (isInternalError(error)) throw error;
266
289
  return {
267
290
  ok: false,
268
291
  refusal: {
@@ -280,9 +303,11 @@ function at(elementIndex) {
280
303
  /** {@link readDataTypeDefault} worded as a PSL diagnostic's code and message. */
281
304
  function lowerDataTypeDefault(input) {
282
305
  const read = readDataTypeDefault(input);
283
- if (read.ok) return read;
284
- const { refusal } = read;
285
- const where = `Field "${input.fieldPath}"${at(refusal.elementIndex)}`;
306
+ return read.ok ? read : refusalDiagnostic(read.refusal, input.fieldPath);
307
+ }
308
+ /** A refusal worded as a PSL diagnostic's code and message. */
309
+ function refusalDiagnostic(refusal, fieldPath) {
310
+ const where = `Field "${fieldPath}"${at(refusal.elementIndex)}`;
286
311
  switch (refusal.kind) {
287
312
  case "unreadable": return {
288
313
  ok: false,
@@ -296,7 +321,7 @@ function lowerDataTypeDefault(input) {
296
321
  };
297
322
  case "unwritable": return {
298
323
  ok: false,
299
- code: "PSL_VALUE_TYPE_INCOMPATIBLE",
324
+ code: PSL_VALUE_TYPE_INCOMPATIBLE,
300
325
  message: `${where}: this target has no data type for a ${refusal.syntax} value`
301
326
  };
302
327
  case "not-a-list": return {
@@ -306,10 +331,10 @@ function lowerDataTypeDefault(input) {
306
331
  };
307
332
  case "no-cast": return {
308
333
  ok: false,
309
- code: "PSL_VALUE_TYPE_INCOMPATIBLE",
334
+ code: PSL_VALUE_TYPE_INCOMPATIBLE,
310
335
  message: `${where}: ${refusal.columnType} has no cast from ${refusal.valueType}; ${describeCasts(refusal.casts)}`
311
336
  };
312
- case "undecodable": return {
337
+ case "refused-by-codec": return {
313
338
  ok: false,
314
339
  code: PSL_INVALID_DEFAULT_LITERAL,
315
340
  message: `${where}: ${refusal.message}`
@@ -319,6 +344,106 @@ function lowerDataTypeDefault(input) {
319
344
  function describeCasts(casts) {
320
345
  return casts.length === 0 ? "it casts from nothing" : `it casts from ${casts.join(", ")}`;
321
346
  }
347
+ /** Each way the default does not match the composite type. */
348
+ function valueObjectDefaultMismatches(input) {
349
+ const mismatches = [];
350
+ const shape = (path, message) => mismatches.push({
351
+ code: PSL_VALUE_TYPE_INCOMPATIBLE,
352
+ message: `Field "${path}": ${message}`
353
+ });
354
+ const checkObject = (value, valueObjectName, path) => {
355
+ const valueObject = input.types.nodes.get(valueObjectName);
356
+ const declared = input.types.declaredMembers.get(valueObjectName);
357
+ if (valueObject === void 0 || declared === void 0) throw new InternalError(`Field "${path}" is typed by the value object "${valueObjectName}", which the contract does not declare.`);
358
+ if (!isJsonObject(value)) {
359
+ shape(path, `a value of "${valueObjectName}" is a JSON object, not ${jsonKind(value)}`);
360
+ return;
361
+ }
362
+ for (const key of Object.keys(value)) if (!declared.has(key)) shape(path, `"${key}" is not a member of "${valueObjectName}"`);
363
+ for (const member of valueObject.fields) checkMember(value[member.fieldName], member, `${path}.${member.fieldName}`);
364
+ };
365
+ const checkMember = (value, member, path) => {
366
+ if (value === void 0) {
367
+ if (!member.nullable) shape(path, "the member is required, and the default has no value for it");
368
+ return;
369
+ }
370
+ if (value === null && member.nullable) return;
371
+ if (member.many === true) {
372
+ if (!Array.isArray(value)) {
373
+ shape(path, `the member is a list, so its value is a JSON array, not ${jsonKind(value)}`);
374
+ return;
375
+ }
376
+ for (const [index, element] of value.entries()) checkOne(element, member, `${path}[${index}]`, "an element of the member is not null");
377
+ return;
378
+ }
379
+ checkOne(value, member, path, "the member is not optional, so its value is not null");
380
+ };
381
+ const checkOne = (value, member, path, notNull) => {
382
+ if (isValueObjectMember(member)) {
383
+ if (value === null) shape(path, notNull);
384
+ else checkObject(value, member.valueObjectName, path);
385
+ return;
386
+ }
387
+ const reading = readStoredValue({
388
+ value,
389
+ column: member.descriptor,
390
+ codecLookup: input.codecLookup,
391
+ fieldPath: path
392
+ });
393
+ if (!reading.ok) {
394
+ if (value === null) shape(path, notNull);
395
+ else mismatches.push({
396
+ code: reading.code,
397
+ message: reading.message
398
+ });
399
+ return;
400
+ }
401
+ const enumMismatch = enumValueMismatch(value, member, path, input.codecLookup);
402
+ if (enumMismatch !== void 0) mismatches.push(enumMismatch);
403
+ };
404
+ if (input.value === null) {
405
+ if (input.nullable) return mismatches;
406
+ shape(input.fieldPath, input.list ? "the default of a list of value objects is a JSON array, not null" : "the default of a value object is a JSON object, not null");
407
+ return mismatches;
408
+ }
409
+ if (input.list) {
410
+ if (!Array.isArray(input.value)) {
411
+ shape(input.fieldPath, `the default of a list of value objects is a JSON array, not ${jsonKind(input.value)}`);
412
+ return mismatches;
413
+ }
414
+ for (const [index, element] of input.value.entries()) checkObject(element, input.valueObjectName, `${input.fieldPath}[${index}]`);
415
+ return mismatches;
416
+ }
417
+ if (!isJsonObject(input.value)) {
418
+ shape(input.fieldPath, `the default of a value object is a JSON object, not ${jsonKind(input.value)}`);
419
+ return mismatches;
420
+ }
421
+ checkObject(input.value, input.valueObjectName, input.fieldPath);
422
+ return mismatches;
423
+ }
424
+ /**
425
+ * A member typed by an enum takes only the enum's values, in the form its codec stores them, as a model field of that enum takes only its members.
426
+ */
427
+ function enumValueMismatch(value, member, path, codecLookup) {
428
+ const handle = member.enumTypeHandle;
429
+ if (handle === void 0) return void 0;
430
+ const codec = codecLookup?.get(handle.codecId);
431
+ const stored = handle.values.map((enumValue) => codec === void 0 ? enumValue : codec.encodeJson(enumValue));
432
+ if (stored.some((storedValue) => storedValue === value)) return void 0;
433
+ return {
434
+ code: PSL_INVALID_DEFAULT_LITERAL,
435
+ message: `Field "${path}": Expected one of: ${stored.map((storedValue) => JSON.stringify(storedValue)).join(" | ")}`
436
+ };
437
+ }
438
+ function isJsonObject(value) {
439
+ return typeof value === "object" && value !== null && !Array.isArray(value);
440
+ }
441
+ function jsonKind(value) {
442
+ if (value === null) return "null";
443
+ if (Array.isArray(value)) return "a JSON array";
444
+ if (typeof value === "object") return "a JSON object";
445
+ return `a JSON ${typeof value}`;
446
+ }
322
447
  function toNamedTypeFieldDescriptor(typeRef, descriptor) {
323
448
  return {
324
449
  codecId: descriptor.codecId,
@@ -326,14 +451,6 @@ function toNamedTypeFieldDescriptor(typeRef, descriptor) {
326
451
  typeRef
327
452
  };
328
453
  }
329
- function getAuthoringTypeConstructor(contributions, path) {
330
- let current = contributions?.type;
331
- for (const segment of path) {
332
- if (typeof current !== "object" || current === null || "kind" in current) return;
333
- current = current[segment];
334
- }
335
- return current !== void 0 && isAuthoringTypeConstructorDescriptor(current) ? current : void 0;
336
- }
337
454
  /**
338
455
  * Walks `authoringContributions.entityTypes` segment-by-segment and returns
339
456
  * the entity type descriptor at the resolved path, or `undefined` if no
@@ -375,6 +492,7 @@ function instantiatePslTypeConstructor(input) {
375
492
  validateAuthoringHelperArguments(helperPath, input.descriptor.args, args);
376
493
  return instantiateAuthoringTypeConstructor(input.descriptor, args);
377
494
  } catch (error) {
495
+ if (isInternalError(error)) throw error;
378
496
  const message = error instanceof Error ? error.message : String(error);
379
497
  input.diagnostics.push({
380
498
  code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
@@ -471,7 +589,7 @@ function resolveEntityRefTypeConstructorCall(input) {
471
589
  const entity = input.namespaceExtensionEntities?.[entityRefArg.entityKind]?.[ref];
472
590
  if (entity === void 0) return reportUnknownRef();
473
591
  const codecId = input.descriptor.output.codecId;
474
- const codecDescriptor = input.codecLookup?.descriptorFor?.(codecId);
592
+ const codecDescriptor = input.codecLookup?.descriptorFor(codecId);
475
593
  if (codecDescriptor === void 0 || !hasColumnFromEntityHook(codecDescriptor)) throw contractError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Type constructor "${helperPath}" registers codecId "${codecId}" with an entity-ref argument, but its codec descriptor has no "columnFromEntity" authoring hook. This is a contributor bug in the pack registering "${helperPath}", not a user-schema error.`, { meta: {
476
594
  helperPath,
477
595
  codecId
@@ -659,10 +777,11 @@ function lowerDefaultForField(input) {
659
777
  });
660
778
  if (interpreted === void 0) return {};
661
779
  const value = interpreted.value;
780
+ const readsListElements = (written) => input.isListColumn || input.field.list && written.kind === "list";
662
781
  const readAsLiteral = (written) => {
663
782
  const lowered = lowerDataTypeDefault({
664
783
  written,
665
- isList: input.field.list,
784
+ isList: readsListElements(written),
666
785
  column: input.columnDescriptor,
667
786
  codecLookup: input.codecLookup,
668
787
  support: input.dataTypeSupport,
@@ -676,6 +795,22 @@ function lowerDefaultForField(input) {
676
795
  });
677
796
  return {};
678
797
  }
798
+ if (input.valueObjectDefault !== void 0) {
799
+ const mismatches = valueObjectDefaultMismatches({
800
+ fieldPath: `${input.modelName}.${input.fieldName}`,
801
+ value: lowered.value,
802
+ list: input.field.list,
803
+ nullable: input.field.optional,
804
+ ...input.valueObjectDefault,
805
+ codecLookup: input.codecLookup
806
+ });
807
+ for (const { code, message } of mismatches) input.diagnostics.push({
808
+ code,
809
+ message,
810
+ ...source.at()
811
+ });
812
+ if (mismatches.length > 0) return {};
813
+ }
679
814
  return { defaultValue: {
680
815
  kind: "literal",
681
816
  value: lowered.value,
@@ -870,6 +1005,7 @@ function describeUnsupportedSqlAttribute(input) {
870
1005
  authoringContributions: input.authoringContributions
871
1006
  };
872
1007
  return ({ attribute, level, owner, field }) => {
1008
+ if (owner.kind === "compositeType") return void 0;
873
1009
  if (level === "model") {
874
1010
  const source = diagnosticSource(input.sources, owner.node.syntax);
875
1011
  const uncomposedNamespace = checkUncomposedNamespace(attribute.name, input.composedExtensions, namespaceContext);
@@ -963,7 +1099,7 @@ function lowerNoCheckForField(input) {
963
1099
  const span = getAttribute(input.field.attributes, "noCheck")?.span ?? input.field.span;
964
1100
  const subject = `Field "${input.model.name}.${input.field.name}"`;
965
1101
  const derivable = [];
966
- if (input.isListField) derivable.push("elementNotNull");
1102
+ if (input.isListColumn) derivable.push("elementNotNull");
967
1103
  if (input.isDomainEnum) derivable.push("membership");
968
1104
  const authored = [interpreted.first, interpreted.second].filter((kind) => kind === "membership" || kind === "elementNotNull");
969
1105
  if (authored.length === 0) {
@@ -989,7 +1125,7 @@ function lowerNoCheckForField(input) {
989
1125
  return [...authored].sort();
990
1126
  }
991
1127
  function collectResolvedFields(input) {
992
- const { model, symbolTable, enumTypeDescriptors, namedTypeDescriptors, composedExtensions, authoringContributions, binder, familyId, targetId, defaultFunctionRegistry, dataTypeSupport, generatorDescriptorById, diagnostics, sources, scalarColumnDescriptors, enumHandles, capabilities, namespaceId, namespaceExtensionEntities, codecLookup } = input;
1128
+ const { model, symbolTable, enumTypeDescriptors, namedTypeDescriptors, valueObjectTypes, composedExtensions, authoringContributions, binder, familyId, targetId, defaultFunctionRegistry, dataTypeSupport, generatorDescriptorById, diagnostics, sources, scalarColumnDescriptors, enumHandles, capabilities, namespaceId, namespaceExtensionEntities, codecLookup } = input;
993
1129
  const resolvedFields = [];
994
1130
  const valueObjectStorageTypeName = authoringContributions?.valueObjectStorageType;
995
1131
  const declaredControlPolicy = getAttribute(model.attributes, "control")?.args.find((arg) => arg.kind === "positional")?.value.trim();
@@ -1004,10 +1140,14 @@ function collectResolvedFields(input) {
1004
1140
  if (isModelField && relationAttribute) continue;
1005
1141
  if (field.typeContractSpaceId !== void 0 && relationAttribute) continue;
1006
1142
  if (isModelField) continue;
1007
- const isValueObjectField = fieldTypeResolution?.kind === "compositeType";
1143
+ const valueObjectName = fieldTypeResolution?.kind === "compositeType" ? fieldTypeResolution.symbol.name : void 0;
1144
+ const isValueObjectField = valueObjectName !== void 0;
1008
1145
  const isListField = field.list;
1146
+ const isListColumn = storedAsListColumn({
1147
+ list: isListField,
1148
+ typedByValueObject: isValueObjectField
1149
+ });
1009
1150
  let descriptor;
1010
- let scalarCodecId;
1011
1151
  let presetContributions;
1012
1152
  const resolveInput = {
1013
1153
  field,
@@ -1026,8 +1166,18 @@ function collectResolvedFields(input) {
1026
1166
  ...ifDefined("namespaceExtensionEntities", namespaceExtensionEntities),
1027
1167
  ...ifDefined("codecLookup", codecLookup)
1028
1168
  };
1029
- if (isValueObjectField) descriptor = valueObjectStorageTypeName !== void 0 ? scalarColumnDescriptors.get(valueObjectStorageTypeName) : void 0;
1030
- else if (isListField) {
1169
+ if (isValueObjectField) {
1170
+ if (valueObjectStorageTypeName === void 0) {
1171
+ diagnostics.push({
1172
+ code: "PSL_UNSUPPORTED_FIELD_TYPE",
1173
+ message: `Field "${model.name}.${field.name}" is typed by the composite type "${field.typeName}", but the adapter of the stack declares no storage type for value objects, so the field has no column to be stored in.`,
1174
+ ...source.at(field.span)
1175
+ });
1176
+ continue;
1177
+ }
1178
+ descriptor = scalarColumnDescriptors.get(valueObjectStorageTypeName);
1179
+ if (descriptor === void 0) throw new InternalError(`The stack declares "${valueObjectStorageTypeName}" as its value-object storage type, but it is not one of the stack's scalar types; the control stack checks this when it is assembled.`);
1180
+ } else if (isListField) {
1031
1181
  if (capabilities["sql"]?.["scalarList"] !== true) {
1032
1182
  diagnostics.push({
1033
1183
  code: "PSL_SCALAR_LIST_UNSUPPORTED_TARGET",
@@ -1053,7 +1203,6 @@ function collectResolvedFields(input) {
1053
1203
  });
1054
1204
  continue;
1055
1205
  }
1056
- scalarCodecId = resolved.descriptor.codecId;
1057
1206
  descriptor = resolved.descriptor;
1058
1207
  } else {
1059
1208
  const resolved = resolveFieldTypeDescriptor(resolveInput);
@@ -1108,6 +1257,11 @@ function collectResolvedFields(input) {
1108
1257
  sources: input.sources,
1109
1258
  binder: input.binder,
1110
1259
  columnDescriptor: descriptor,
1260
+ isListColumn,
1261
+ valueObjectDefault: valueObjectName === void 0 ? void 0 : {
1262
+ valueObjectName,
1263
+ types: valueObjectTypes
1264
+ },
1111
1265
  generatorDescriptorById,
1112
1266
  defaultFunctionRegistry,
1113
1267
  dataTypeSupport,
@@ -1183,7 +1337,7 @@ function collectResolvedFields(input) {
1183
1337
  field,
1184
1338
  sources: input.sources,
1185
1339
  binder: input.binder,
1186
- isListField: isListField && !isValueObjectField,
1340
+ isListColumn,
1187
1341
  isDomainEnum: enumHandle !== void 0,
1188
1342
  diagnostics
1189
1343
  }) : void 0;
@@ -1200,8 +1354,7 @@ function collectResolvedFields(input) {
1200
1354
  ...ifDefined("uniqueName", uniqueName),
1201
1355
  ...ifDefined("many", isListField ? true : void 0),
1202
1356
  ...ifDefined("noCheck", noCheckKinds),
1203
- ...ifDefined("valueObjectTypeName", isValueObjectField ? field.typeName : void 0),
1204
- ...ifDefined("scalarCodecId", scalarCodecId)
1357
+ ...ifDefined("valueObjectTypeName", valueObjectName)
1205
1358
  });
1206
1359
  }
1207
1360
  return resolvedFields;
@@ -1972,6 +2125,7 @@ function buildModelNodeFromPsl(input) {
1972
2125
  symbolTable: input.symbolTable,
1973
2126
  enumTypeDescriptors: input.enumTypeDescriptors,
1974
2127
  namedTypeDescriptors: input.namedTypeDescriptors,
2128
+ valueObjectTypes: input.valueObjectTypes,
1975
2129
  composedExtensions: input.composedExtensions,
1976
2130
  authoringContributions: input.authoringContributions,
1977
2131
  familyId: input.familyId,
@@ -2548,17 +2702,23 @@ function buildModelNodeFromPsl(input) {
2548
2702
  modelName: model.name,
2549
2703
  tableName,
2550
2704
  fields: resolvedFields.map((resolvedField) => {
2551
- const enumHandle = input.enumHandles?.get(resolvedField.field.typeName);
2552
- return {
2705
+ const common = {
2553
2706
  fieldName: resolvedField.field.name,
2554
2707
  columnName: resolvedField.columnName,
2555
2708
  descriptor: resolvedField.descriptor,
2556
2709
  nullable: resolvedField.nullable,
2557
- ...resolvedField.many && resolvedField.valueObjectTypeName === void 0 ? { many: true } : {},
2710
+ ...ifDefined("many", resolvedField.many),
2558
2711
  ...ifDefined("default", resolvedField.defaultValue),
2559
- ...ifDefined("executionDefaults", resolvedField.executionDefaults),
2712
+ ...ifDefined("executionDefaults", resolvedField.executionDefaults)
2713
+ };
2714
+ if (resolvedField.valueObjectTypeName !== void 0) return {
2715
+ ...common,
2716
+ valueObjectName: resolvedField.valueObjectTypeName
2717
+ };
2718
+ return {
2719
+ ...common,
2560
2720
  ...ifDefined("noCheck", resolvedField.noCheck),
2561
- ...ifDefined("enumTypeHandle", enumHandle)
2721
+ ...ifDefined("enumTypeHandle", input.enumHandles?.get(resolvedField.field.typeName))
2562
2722
  };
2563
2723
  }),
2564
2724
  ...ifDefined("id", primaryKey),
@@ -2572,44 +2732,53 @@ function buildModelNodeFromPsl(input) {
2572
2732
  invalidFkPairings: resultInvalidFkPairings,
2573
2733
  crossSpaceRelations: resultCrossSpaceRelations,
2574
2734
  backrelationCandidates: resultBackrelationCandidates,
2575
- resolvedFields,
2576
2735
  modelAttributeEntities
2577
2736
  };
2578
2737
  }
2579
- function buildValueObjects(input) {
2580
- const { compositeTypes, enumTypeDescriptors, namedTypeDescriptors, scalarColumnDescriptors, composedExtensions, familyId, targetId, authoringContributions, diagnostics, sources, binder } = input;
2581
- const valueObjects = {};
2582
- for (const compositeType of compositeTypes) {
2583
- const fields = {};
2738
+ function buildValueObjectNodes(input) {
2739
+ const { compositeTypes, enumHandles, diagnostics, sources, binder } = input;
2740
+ return compositeTypes.map((compositeType) => {
2741
+ for (const attribute of compositeType.attributes) diagnostics.push({
2742
+ code: "PSL_UNSUPPORTED_COMPOSITE_TYPE_ATTRIBUTE",
2743
+ message: `Composite type "${compositeType.name}" uses attribute "@@${attribute.name}", which a composite type does not take`,
2744
+ ...diagnosticSource(sources, compositeType.node.syntax).at(attribute.span)
2745
+ });
2746
+ const fields = [];
2584
2747
  for (const field of Object.values(compositeType.fields)) {
2748
+ for (const attribute of field.attributes) diagnostics.push({
2749
+ code: "PSL_UNSUPPORTED_FIELD_ATTRIBUTE",
2750
+ message: `Member "${field.name}" of composite type "${compositeType.name}" uses attribute "@${attribute.name}", which a composite type member does not take`,
2751
+ ...diagnosticSource(sources, field.node.syntax).at(attribute.span)
2752
+ });
2753
+ const common = {
2754
+ fieldName: field.name,
2755
+ nullable: field.optional,
2756
+ ...ifDefined("many", field.list ? true : void 0)
2757
+ };
2585
2758
  const fieldTypeReference = typeReferenceNode(field);
2586
2759
  const fieldTypeResolution = fieldTypeReference === void 0 ? void 0 : binder.symbolForNode(fieldTypeReference);
2587
2760
  if (fieldTypeResolution?.kind === "compositeType") {
2588
- const result = {
2589
- type: {
2590
- kind: "valueObject",
2591
- name: fieldTypeResolution.symbol.name
2592
- },
2593
- nullable: field.optional
2594
- };
2595
- fields[field.name] = field.list ? {
2596
- ...result,
2597
- many: true
2598
- } : result;
2761
+ fields.push({
2762
+ ...common,
2763
+ valueObjectName: fieldTypeResolution.symbol.name
2764
+ });
2599
2765
  continue;
2600
2766
  }
2601
2767
  const resolved = resolveFieldTypeDescriptor({
2602
2768
  field,
2603
- enumTypeDescriptors,
2604
- namedTypeDescriptors,
2605
- scalarColumnDescriptors,
2606
- authoringContributions,
2607
- composedExtensions,
2608
- familyId,
2609
- targetId,
2769
+ enumTypeDescriptors: input.enumTypeDescriptors,
2770
+ namedTypeDescriptors: input.namedTypeDescriptors,
2771
+ scalarColumnDescriptors: input.scalarColumnDescriptors,
2772
+ authoringContributions: input.authoringContributions,
2773
+ composedExtensions: input.composedExtensions,
2774
+ familyId: input.familyId,
2775
+ targetId: input.targetId,
2610
2776
  diagnostics,
2611
2777
  sources,
2612
- entityLabel: `Field "${compositeType.name}.${field.name}"`
2778
+ entityLabel: `Field "${compositeType.name}.${field.name}"`,
2779
+ namespaceId: input.defaultNamespaceId,
2780
+ ...ifDefined("namespaceExtensionEntities", input.defaultNamespaceExtensionEntities),
2781
+ ...ifDefined("codecLookup", input.codecLookup)
2613
2782
  });
2614
2783
  if (!resolved.ok) {
2615
2784
  if (!resolved.alreadyReported && fieldTypeResolution?.kind !== "unresolved") diagnostics.push({
@@ -2619,62 +2788,29 @@ function buildValueObjects(input) {
2619
2788
  });
2620
2789
  continue;
2621
2790
  }
2622
- const scalarField = {
2623
- nullable: field.optional,
2624
- type: {
2625
- kind: "scalar",
2626
- codecId: resolved.descriptor.codecId
2627
- }
2628
- };
2629
- fields[field.name] = field.list ? {
2630
- ...scalarField,
2631
- many: true
2632
- } : scalarField;
2633
- }
2634
- valueObjects[compositeType.name] = { fields };
2635
- }
2636
- return valueObjects;
2637
- }
2638
- function patchModelDomainFields(models, modelResolvedFields) {
2639
- let patched = models;
2640
- for (const [modelName, resolvedFields] of modelResolvedFields) {
2641
- const model = patched[modelName];
2642
- if (!model) continue;
2643
- let needsPatch = false;
2644
- const patchedFields = { ...model.fields };
2645
- for (const rf of resolvedFields) if (rf.valueObjectTypeName) {
2646
- needsPatch = true;
2647
- patchedFields[rf.field.name] = {
2648
- nullable: rf.field.optional,
2649
- type: {
2650
- kind: "valueObject",
2651
- name: rf.valueObjectTypeName
2652
- },
2653
- ...rf.many ? { many: true } : {}
2654
- };
2655
- } else if (rf.many && rf.scalarCodecId) {
2656
- needsPatch = true;
2657
- const builtType = model.fields[rf.field.name]?.type;
2658
- const typeParams = builtType?.kind === "scalar" ? builtType.typeParams : void 0;
2659
- patchedFields[rf.field.name] = {
2660
- nullable: rf.field.optional,
2661
- type: {
2662
- kind: "scalar",
2663
- codecId: rf.scalarCodecId,
2664
- ...ifDefined("typeParams", typeParams)
2791
+ const { descriptor } = resolved;
2792
+ if (descriptor.valueSet !== void 0) {
2793
+ diagnostics.push({
2794
+ code: "PSL_UNSUPPORTED_FIELD_TYPE",
2795
+ message: `Field "${compositeType.name}.${field.name}" is typed by the storage enum "${descriptor.valueSet.entityName}", which a composite type member cannot use: a member has no column to store it in. Use a PSL enum instead.`,
2796
+ ...diagnosticSource(sources, field.node.syntax).at(field.span)
2797
+ });
2798
+ continue;
2799
+ }
2800
+ fields.push({
2801
+ ...common,
2802
+ descriptor: {
2803
+ codecId: descriptor.codecId,
2804
+ ...ifDefined("typeParams", resolvedTypeParams(descriptor, input.namedTypes))
2665
2805
  },
2666
- many: true
2667
- };
2806
+ ...ifDefined("enumTypeHandle", enumHandles.get(field.typeName))
2807
+ });
2668
2808
  }
2669
- if (needsPatch) patched = {
2670
- ...patched,
2671
- [modelName]: {
2672
- ...model,
2673
- fields: patchedFields
2674
- }
2809
+ return {
2810
+ name: compositeType.name,
2811
+ fields
2675
2812
  };
2676
- }
2677
- return patched;
2813
+ });
2678
2814
  }
2679
2815
  function collectPolymorphismDeclarations(identities, symbols, sources, binder, diagnostics) {
2680
2816
  const discriminatorDeclarations = /* @__PURE__ */ new Map();
@@ -2855,7 +2991,7 @@ function materializeMtiVariantStorageLinks(modelNodes, baseDeclarations, stiVari
2855
2991
  const linkFields = [];
2856
2992
  for (const pkColumn of basePrimaryKey.columns) {
2857
2993
  if (existingColumns.has(pkColumn)) continue;
2858
- const baseField = baseNode.fields.find((field) => "descriptor" in field && field.columnName === pkColumn);
2994
+ const baseField = baseNode.fields.find((field) => field.columnName === pkColumn);
2859
2995
  if (!baseField) continue;
2860
2996
  linkFields.push({
2861
2997
  fieldName: baseField.fieldName,
@@ -3248,15 +3384,36 @@ function interpretPslDocumentToSqlContract(input) {
3248
3384
  const fkRelationMetadata = [];
3249
3385
  const invalidFkPairings = [];
3250
3386
  const backrelationCandidates = [];
3251
- const modelResolvedFields = /* @__PURE__ */ new Map();
3252
3387
  const crossSpaceRelationsByModel = /* @__PURE__ */ new Map();
3253
3388
  const modelAttributeEntitiesByNamespace = /* @__PURE__ */ new Map();
3389
+ const valueObjects = buildValueObjectNodes({
3390
+ compositeTypes,
3391
+ enumTypeDescriptors: allEnumTypeDescriptors,
3392
+ enumHandles: enumHandlesByName,
3393
+ namedTypeDescriptors: namedTypeResult.namedTypeDescriptors,
3394
+ namedTypes: namedTypeResult.storageTypes,
3395
+ scalarColumnDescriptors: input.scalarColumnDescriptors,
3396
+ composedExtensions,
3397
+ familyId: input.target.familyId,
3398
+ targetId: input.target.targetId,
3399
+ authoringContributions: input.authoringContributions,
3400
+ diagnostics,
3401
+ sources: input.sources,
3402
+ defaultNamespaceId,
3403
+ defaultNamespaceExtensionEntities: namespaceExtensionEntities.get(defaultNamespaceId),
3404
+ codecLookup: input.codecLookup,
3405
+ binder
3406
+ });
3407
+ const valueObjectTypes = {
3408
+ nodes: new Map(valueObjects.map((valueObject) => [valueObject.name, valueObject])),
3409
+ declaredMembers: new Map(compositeTypes.map((compositeType) => [compositeType.name, new Set(Object.keys(compositeType.fields))]))
3410
+ };
3254
3411
  for (const { model, namespaceId } of modelEntries) {
3255
- const coordinate = modelCoordinateKey(namespaceId ?? defaultNamespaceId, model.name);
3256
3412
  const result = buildModelNodeFromPsl({
3257
3413
  model,
3258
3414
  physicalNames,
3259
3415
  namespaceId,
3416
+ valueObjectTypes,
3260
3417
  enumTypeDescriptors: allEnumTypeDescriptors,
3261
3418
  namedTypeDescriptors: namedTypeResult.namedTypeDescriptors,
3262
3419
  composedExtensions,
@@ -3288,7 +3445,6 @@ function interpretPslDocumentToSqlContract(input) {
3288
3445
  fkRelationMetadata.push(...result.fkRelationMetadata);
3289
3446
  invalidFkPairings.push(...result.invalidFkPairings);
3290
3447
  backrelationCandidates.push(...result.backrelationCandidates);
3291
- modelResolvedFields.set(coordinate, result.resolvedFields);
3292
3448
  if (result.crossSpaceRelations.length > 0) {
3293
3449
  const existing = crossSpaceRelationsByModel.get(model) ?? [];
3294
3450
  crossSpaceRelationsByModel.set(model, [...existing, ...result.crossSpaceRelations]);
@@ -3358,19 +3514,6 @@ function interpretPslDocumentToSqlContract(input) {
3358
3514
  ...modelRelations.has(symbol) ? { relations: [...modelRelations.get(symbol) ?? []].sort((left, right) => compareStrings(left.fieldName, right.fieldName)) } : {}
3359
3515
  })), baseDeclarations, stiVariantKeys, defaultNamespaceId);
3360
3516
  const { modelNodes: stiColumnModelNodes, stiBaseFieldsByBase } = materializeStiVariantStorageColumns(mtiLinkedModelNodes, baseDeclarations, stiVariantKeys, defaultNamespaceId);
3361
- const valueObjects = buildValueObjects({
3362
- compositeTypes,
3363
- enumTypeDescriptors: allEnumTypeDescriptors,
3364
- namedTypeDescriptors: namedTypeResult.namedTypeDescriptors,
3365
- scalarColumnDescriptors: input.scalarColumnDescriptors,
3366
- composedExtensions,
3367
- familyId: input.target.familyId,
3368
- targetId: input.target.targetId,
3369
- authoringContributions: input.authoringContributions,
3370
- diagnostics,
3371
- sources: input.sources,
3372
- binder
3373
- });
3374
3517
  if (diagnostics.length > 0 || (input.seedDiagnostics?.length ?? 0) > 0) return notOk({
3375
3518
  summary: "PSL to SQL contract interpretation failed",
3376
3519
  diagnostics: [...input.seedDiagnostics ?? [], ...diagnostics.toExternal()]
@@ -3409,17 +3552,17 @@ function interpretPslDocumentToSqlContract(input) {
3409
3552
  ...Object.keys(validEnumHandles).length > 0 ? { enums: validEnumHandles } : {},
3410
3553
  ...namespaceExtensionEntities.size > 0 ? { namespaces: [...namespaceExtensionEntities.keys()] } : {},
3411
3554
  createNamespace: createNamespaceWithExtensions,
3555
+ ...ifDefined("valueObjects", valueObjects.length > 0 ? valueObjects : void 0),
3412
3556
  models: stiColumnModelNodes
3413
3557
  }, input.codecLookup);
3414
- const modelsForPatch = {};
3558
+ const modelsByCoordinate = {};
3415
3559
  for (const [namespaceId, namespaceSlice] of Object.entries(contract.domain.namespaces)) for (const [modelName, model] of Object.entries(namespaceSlice.models)) {
3416
3560
  const coordinate = modelCoordinateKey(namespaceId, modelName);
3417
- invariant(!Object.hasOwn(modelsForPatch, coordinate), `symbol table guarantees coordinate uniqueness; duplicate model "${namespaceId}.${modelName}" reached interpretation`);
3418
- modelsForPatch[coordinate] = model;
3561
+ invariant(!Object.hasOwn(modelsByCoordinate, coordinate), `symbol table guarantees coordinate uniqueness; duplicate model "${namespaceId}.${modelName}" reached interpretation`);
3562
+ modelsByCoordinate[coordinate] = model;
3419
3563
  }
3420
- let patchedModels = patchModelDomainFields(modelsForPatch, modelResolvedFields);
3421
3564
  const polyDiagnostics = createPslDiagnosticCollector(input.sources);
3422
- patchedModels = resolvePolymorphism(patchedModels, physicalNames, discriminatorDeclarations, baseDeclarations, syntheticPkFieldsByVariant, stiBaseFieldsByBase, polyDiagnostics);
3565
+ const polymorphicModels = resolvePolymorphism(modelsByCoordinate, physicalNames, discriminatorDeclarations, baseDeclarations, syntheticPkFieldsByVariant, stiBaseFieldsByBase, polyDiagnostics);
3423
3566
  if (polyDiagnostics.length > 0) return notOk({
3424
3567
  summary: "PSL to SQL contract interpretation failed",
3425
3568
  diagnostics: polyDiagnostics.toExternal()
@@ -3429,14 +3572,13 @@ function interpretPslDocumentToSqlContract(input) {
3429
3572
  ...contract,
3430
3573
  roots: filteredRoots,
3431
3574
  domain: { namespaces: Object.fromEntries(Object.entries(contract.domain.namespaces).map(([namespaceId, namespaceSlice]) => [namespaceId, {
3432
- models: Object.fromEntries(Object.entries(namespaceSlice.models).map(([modelName, model]) => [modelName, patchedModels[modelCoordinateKey(namespaceId, modelName)] ?? model])),
3575
+ models: Object.fromEntries(Object.entries(namespaceSlice.models).map(([modelName, model]) => [modelName, polymorphicModels[modelCoordinateKey(namespaceId, modelName)] ?? model])),
3433
3576
  ...ifDefined("enum", namespaceSlice.enum),
3434
- ...ifDefined("valueObjects", namespaceSlice.valueObjects),
3435
- ...namespaceId === input.target.defaultNamespaceId && Object.keys(valueObjects).length > 0 ? { valueObjects } : {}
3577
+ ...ifDefined("valueObjects", namespaceSlice.valueObjects)
3436
3578
  }])) }
3437
3579
  });
3438
3580
  }
3439
3581
  //#endregion
3440
3582
  export { interpretPslDocumentToSqlContract as a, resolveFieldTypeDescriptor as c, indexFkRelations as i, buildEntityTypesByDiscriminator as n, normalizeReferentialAction as o, entryForTag as r, readDataTypeDefault as s, applyBackrelationCandidates as t };
3441
3583
 
3442
- //# sourceMappingURL=interpreter-Bcc3MIC5-C4dZrobt.mjs.map
3584
+ //# sourceMappingURL=interpreter-j1ewAXPb-BwieIKeF.mjs.map