@prisma/orm-family-sql 8.0.0-rc.11-dev.41 → 8.0.0-rc.11-dev.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ast-BHZ0g4iL.d.mts → ast-d2-iNoEs.d.mts} +72 -10
- package/dist/ast-d2-iNoEs.d.mts.map +1 -0
- package/dist/{ast-C8jX7HNs.mjs → ast-um6jG7BL.mjs} +129 -8
- package/dist/ast-um6jG7BL.mjs.map +1 -0
- package/dist/{authoring-type-constructors-C1ogrr_x-BeSS93gc.mjs → authoring-type-constructors-C1ogrr_x-VWDkCaSq.mjs} +2 -2
- package/dist/{authoring-type-constructors-C1ogrr_x-BeSS93gc.mjs.map → authoring-type-constructors-C1ogrr_x-VWDkCaSq.mjs.map} +1 -1
- package/dist/builder.d.mts +2 -2
- package/dist/builder__runtime.d.mts +8 -8
- package/dist/builder__types.d.mts +2 -2
- package/dist/{config-types-C-rrJ_8P.d.mts → config-types-Bd3ud-mX.d.mts} +3 -3
- package/dist/{config-types-C-rrJ_8P.d.mts.map → config-types-Bd3ud-mX.d.mts.map} +1 -1
- package/dist/{config-types-B98UYjF0.mjs → config-types-fwqTEhK6.mjs} +2 -2
- package/dist/{config-types-B98UYjF0.mjs.map → config-types-fwqTEhK6.mjs.map} +1 -1
- package/dist/{contract-builder-DV-DZX4h.d.mts → contract-builder-BHCjHphC.d.mts} +12 -5
- package/dist/{contract-builder-DV-DZX4h.d.mts.map → contract-builder-BHCjHphC.d.mts.map} +1 -1
- package/dist/{contract-builder-BCqPVNbs.mjs → contract-builder-BgWPuVYv.mjs} +2 -2
- package/dist/{contract-builder-BCqPVNbs.mjs.map → contract-builder-BgWPuVYv.mjs.map} +1 -1
- package/dist/contract-prisma7__provider.d.mts +1 -1
- package/dist/contract-prisma7__provider.mjs +118 -48
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +10 -6
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +3 -2
- package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.d.mts +1 -1
- package/dist/contract-psl__provider.mjs +3 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +3 -3
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.d.mts +1 -1
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.d.mts +2 -2
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/contract.d.mts +5 -5
- package/dist/contract__factories.d.mts +1 -1
- package/dist/contract__index-type-validation.d.mts +1 -1
- package/dist/contract__types.d.mts +2 -2
- package/dist/contract__validators.d.mts +1 -1
- package/dist/{control-Cijy1SHG.mjs → control-Ber3kz3q.mjs} +11 -6
- package/dist/{control-Cijy1SHG.mjs.map → control-Ber3kz3q.mjs.map} +1 -1
- package/dist/{control-C9oCqe39.d.mts → control-CkJbZTUB.d.mts} +20 -17
- package/dist/control-CkJbZTUB.d.mts.map +1 -0
- package/dist/{control-adapter-C99J7aEF-B2G4GA5s.d.mts → control-adapter-C99J7aEF-DwFChl8n.d.mts} +8 -8
- package/dist/{control-adapter-C99J7aEF-B2G4GA5s.d.mts.map → control-adapter-C99J7aEF-DwFChl8n.d.mts.map} +1 -1
- package/dist/control-adapter-DPWKLNdH.d.mts +1 -0
- package/dist/{db-BhQdL6Za-Dod07quT.d.mts → db-BhQdL6Za-BBgu_awF.d.mts} +8 -8
- package/dist/{db-BhQdL6Za-Dod07quT.d.mts.map → db-BhQdL6Za-BBgu_awF.d.mts.map} +1 -1
- package/dist/{ddl-types-BGdnAbXo-DKPHPUGx.mjs → ddl-types-DOgOmDOh-Cs_MY05h.mjs} +2 -2
- package/dist/{ddl-types-BGdnAbXo-DKPHPUGx.mjs.map → ddl-types-DOgOmDOh-Cs_MY05h.mjs.map} +1 -1
- package/dist/{ddl-types-Biy7miT--CSyPnOHq.d.mts → ddl-types-DrK8E0jL-ClX_UkVh.d.mts} +4 -4
- package/dist/{ddl-types-Biy7miT--CSyPnOHq.d.mts.map → ddl-types-DrK8E0jL-ClX_UkVh.d.mts.map} +1 -1
- package/dist/{derived-checks-C4BPtrnO-B9MQRh6W.mjs → derived-checks-6WZKIUxH-B3Pd6QA5.mjs} +30 -12
- package/dist/derived-checks-6WZKIUxH-B3Pd6QA5.mjs.map +1 -0
- package/dist/{derived-checks-DPdD01O0-DCKdvxNK.d.mts → derived-checks-DPdD01O0-DNBs1ZDA.d.mts} +2 -2
- package/dist/{derived-checks-DPdD01O0-DCKdvxNK.d.mts.map → derived-checks-DPdD01O0-DNBs1ZDA.d.mts.map} +1 -1
- package/dist/{diff-CwozLSiO.d.mts → diff-C9tzE_nE.d.mts} +7 -7
- package/dist/{diff-CwozLSiO.d.mts.map → diff-C9tzE_nE.d.mts.map} +1 -1
- package/dist/{expression-CTADTPZW.d.mts → expression-CAJjmssr.d.mts} +6 -6
- package/dist/{expression-CTADTPZW.d.mts.map → expression-CAJjmssr.d.mts.map} +1 -1
- package/dist/{factories-B9PfKd5k.d.mts → factories-P3qBQhO-.d.mts} +2 -2
- package/dist/{factories-B9PfKd5k.d.mts.map → factories-P3qBQhO-.d.mts.map} +1 -1
- package/dist/family.d.mts +11 -11
- package/dist/family.mjs +2 -2
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +4 -4
- package/dist/family__control.mjs +1 -1
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__ir.d.mts +1 -1
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.d.mts.map +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-infer.d.mts +1 -1
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/family__runtime.d.mts +1 -1
- package/dist/{index-C6_--MKi.d.mts → index-CLAshwKN.d.mts} +3 -3
- package/dist/{index-C6_--MKi.d.mts.map → index-CLAshwKN.d.mts.map} +1 -1
- package/dist/{index-CA_WLNy1.d.mts → index-DI6YpxCw.d.mts} +10 -10
- package/dist/{index-CA_WLNy1.d.mts.map → index-DI6YpxCw.d.mts.map} +1 -1
- package/dist/{index-type-validation-BFiTwZub.d.mts → index-type-validation-CZ5L2lli.d.mts} +2 -2
- package/dist/{index-type-validation-BFiTwZub.d.mts.map → index-type-validation-CZ5L2lli.d.mts.map} +1 -1
- package/dist/{interpreter-Bf7Um__3-DC_thY44.mjs → interpreter-DvKii7Bl-D8Ipte3f.mjs} +463 -104
- package/dist/interpreter-DvKii7Bl-D8Ipte3f.mjs.map +1 -0
- package/dist/{ir-CodnAisu.d.mts → ir-BJ-dsbe-.d.mts} +2 -2
- package/dist/{ir-CodnAisu.d.mts.map → ir-BJ-dsbe-.d.mts.map} +1 -1
- package/dist/{middleware-0yjzaoBT-BqmCD6Dt.d.mts → middleware-CHg6zJkn-DJAKnDpd.d.mts} +3 -3
- package/dist/{middleware-0yjzaoBT-BqmCD6Dt.d.mts.map → middleware-CHg6zJkn-DJAKnDpd.d.mts.map} +1 -1
- package/dist/middleware-wyJe8dVq.d.mts +1 -0
- package/dist/{migration-CniGZoFt.d.mts → migration-BQWwBE8Q.d.mts} +3 -3
- package/dist/{migration-CniGZoFt.d.mts.map → migration-BQWwBE8Q.d.mts.map} +1 -1
- package/dist/operations.d.mts +1 -1
- package/dist/orm-client.d.mts +13 -13
- package/dist/orm-client.mjs +1 -1
- package/dist/{plan-Bs-Pdirc-BCy94--G.d.mts → plan-DVkrl9Pq-DOf_eQ84.d.mts} +4 -4
- package/dist/plan-DVkrl9Pq-DOf_eQ84.d.mts.map +1 -0
- package/dist/plan-Dzq6Nwb4.d.mts +2 -0
- package/dist/{prepared-statement-DZtymlzd-DFIuG_WK.d.mts → prepared-statement-DZtymlzd-DmbP44p0.d.mts} +15 -15
- package/dist/{prepared-statement-DZtymlzd-DFIuG_WK.d.mts.map → prepared-statement-DZtymlzd-DmbP44p0.d.mts.map} +1 -1
- package/dist/{psl-infer-6p4x9ebN.mjs → psl-infer-BAbdN_ZR.mjs} +195 -13
- package/dist/psl-infer-BAbdN_ZR.mjs.map +1 -0
- package/dist/{psl-infer-CLZsT2Hz.d.mts → psl-infer-DQCWvJtk.d.mts} +16 -3
- package/dist/psl-infer-DQCWvJtk.d.mts.map +1 -0
- package/dist/{query-lane-context-QIUURgPP-CvQ9jQRm.d.mts → query-lane-context-BUNC86DS-C_hIrqaW.d.mts} +6 -6
- package/dist/{query-lane-context-QIUURgPP-CvQ9jQRm.d.mts.map → query-lane-context-BUNC86DS-C_hIrqaW.d.mts.map} +1 -1
- package/dist/query-lane-context-CeOxBL6I.d.mts +1 -0
- package/dist/relational-core.d.mts +12 -12
- package/dist/relational-core.mjs +3 -3
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
- package/dist/relational-core__ast.d.mts +4 -4
- package/dist/relational-core__ast.mjs +3 -3
- package/dist/relational-core__codec-descriptor-registry.d.mts +3 -3
- package/dist/relational-core__contract-free.d.mts +3 -3
- package/dist/relational-core__contract-free.mjs +1 -1
- package/dist/relational-core__contract-free.mjs.map +1 -1
- package/dist/relational-core__expression.d.mts +1 -1
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__plan.d.mts +3 -3
- package/dist/relational-core__query-lane-context.d.mts +2 -2
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/{runtime-gCSNgykk.d.mts → runtime-BqAUXvAl.d.mts} +3 -3
- package/dist/{runtime-gCSNgykk.d.mts.map → runtime-BqAUXvAl.d.mts.map} +1 -1
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +1 -1
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{schema-differ-DpG_gnur-DrAcUO68.d.mts → schema-differ-DpG_gnur-CXVM1Oed.d.mts} +4 -4
- package/dist/{schema-differ-DpG_gnur-DrAcUO68.d.mts.map → schema-differ-DpG_gnur-CXVM1Oed.d.mts.map} +1 -1
- package/dist/schema-ir.d.mts +1 -1
- package/dist/schema-ir__types.d.mts +2 -2
- package/dist/{sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs → sql-attribute-specs-CQoOV2MU-DLD9uxC6.mjs} +16 -8
- package/dist/sql-attribute-specs-CQoOV2MU-DLD9uxC6.mjs.map +1 -0
- package/dist/{sql-execution-plan-S3HvDKIP-8KF1nBHu.d.mts → sql-execution-plan-DBvAsaOB-LUMcfRpN.d.mts} +3 -3
- package/dist/sql-execution-plan-DBvAsaOB-LUMcfRpN.d.mts.map +1 -0
- package/dist/{types-BDUG29Df-DRoC4zw1.d.mts → types-BDUG29Df-LE85dIXP.d.mts} +2 -2
- package/dist/{types-BDUG29Df-DRoC4zw1.d.mts.map → types-BDUG29Df-LE85dIXP.d.mts.map} +1 -1
- package/dist/{types-BFPRCYGW-CvvVz-AC.d.mts → types-BFPRCYGW-CBv60DKI.d.mts} +7 -7
- package/dist/{types-BFPRCYGW-CvvVz-AC.d.mts.map → types-BFPRCYGW-CBv60DKI.d.mts.map} +1 -1
- package/dist/{types-CRU1CBUk-CR2_opbw.d.mts → types-BLVS175T-DmpY58Nx.d.mts} +9 -9
- package/dist/{types-CRU1CBUk-CR2_opbw.d.mts.map → types-BLVS175T-DmpY58Nx.d.mts.map} +1 -1
- package/dist/types-BijNazlM.d.mts +1 -0
- package/dist/{types-BmgtemBx.d.mts → types-C36_3E6_.d.mts} +2 -2
- package/dist/{types-BmgtemBx.d.mts.map → types-C36_3E6_.d.mts.map} +1 -1
- package/dist/{types-CHOgKgHg-DMlDrQz6.d.mts → types-CHOgKgHg-BxgkL3GS.d.mts} +2 -2
- package/dist/{types-CHOgKgHg-DMlDrQz6.d.mts.map → types-CHOgKgHg-BxgkL3GS.d.mts.map} +1 -1
- package/dist/types-CQ8FfvRk.d.mts +1 -0
- package/dist/{types-BXSw7th1-pL1Iggyd.d.mts → types-YGX78yVc-BBy1pp_1.d.mts} +7 -5
- package/dist/types-YGX78yVc-BBy1pp_1.d.mts.map +1 -0
- package/dist/{validators-DvtOcB04.d.mts → validators-CJSyNFS4.d.mts} +2 -2
- package/dist/{validators-DvtOcB04.d.mts.map → validators-CJSyNFS4.d.mts.map} +1 -1
- package/package.json +18 -18
- package/dist/ast-BHZ0g4iL.d.mts.map +0 -1
- package/dist/ast-C8jX7HNs.mjs.map +0 -1
- package/dist/control-C9oCqe39.d.mts.map +0 -1
- package/dist/control-adapter-Bx5ZQKj-.d.mts +0 -1
- package/dist/derived-checks-C4BPtrnO-B9MQRh6W.mjs.map +0 -1
- package/dist/interpreter-Bf7Um__3-DC_thY44.mjs.map +0 -1
- package/dist/middleware-Di3_d2T5.d.mts +0 -1
- package/dist/plan-BEJGOQ-l.d.mts +0 -2
- package/dist/plan-Bs-Pdirc-BCy94--G.d.mts.map +0 -1
- package/dist/psl-infer-6p4x9ebN.mjs.map +0 -1
- package/dist/psl-infer-CLZsT2Hz.d.mts.map +0 -1
- package/dist/query-lane-context-yy5kDAlG.d.mts +0 -1
- package/dist/sql-attribute-specs-DAEpjrWl-C0kmaUJt.mjs.map +0 -1
- package/dist/sql-execution-plan-S3HvDKIP-8KF1nBHu.d.mts.map +0 -1
- package/dist/types-BXSw7th1-pL1Iggyd.d.mts.map +0 -1
- package/dist/types-D3XRY_cO.d.mts +0 -1
- package/dist/types-RPn42d0t.d.mts +0 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { n as isAuthoredIndexInput } from "./index-naming-Cj1Anq-T-w1JL7-EM.mjs";
|
|
2
2
|
import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
|
|
3
|
-
import { n as buildSqlContractFromDefinition } from "./derived-checks-
|
|
4
|
-
import { a as interpretFieldAttribute, i as findModelAttributeNode, n as fieldSpecContext, o as interpretModelAttribute, r as findFieldAttributeNode, s as sqlAttributeSpecs, t as PSL_CHECK_ON_STI_VARIANT } from "./sql-attribute-specs-
|
|
3
|
+
import { n as buildSqlContractFromDefinition } from "./derived-checks-6WZKIUxH-B3Pd6QA5.mjs";
|
|
4
|
+
import { a as interpretFieldAttribute, i as findModelAttributeNode, n as fieldSpecContext, o as interpretModelAttribute, r as findFieldAttributeNode, s as sqlAttributeSpecs, t as PSL_CHECK_ON_STI_VARIANT } from "./sql-attribute-specs-CQoOV2MU-DLD9uxC6.mjs";
|
|
5
5
|
import { t as defaultTableName } from "./default-table-name-BfFY8qYR-lHNcVmY5.mjs";
|
|
6
|
-
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
7
|
-
import { hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
|
|
6
|
+
import { isStructuredError, structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
7
|
+
import { hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, isDataTypeLoweringEntry, loweringEntryKey, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
|
|
8
8
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
9
9
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
10
10
|
import { crossRef } from "@prisma/orm-framework/contract/types";
|
|
11
11
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
12
12
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
13
13
|
import { resolveToOneRelationNullable } from "@prisma/orm-framework/contract-authoring";
|
|
14
|
+
import { materializeCodec } from "@prisma/orm-framework/components/codec";
|
|
14
15
|
import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
|
|
15
16
|
import { describeTaggedLiteralFailure } from "@prisma/orm-framework/components/control";
|
|
16
17
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
17
18
|
import { createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, keywordPslSpan, nodePslSpan } from "@prisma/orm-framework/psl-parser";
|
|
18
19
|
import { consumeInvalidFkPairing, fkRelationPairKey, requiredOneToOneBackrelationDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
|
|
19
|
-
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-
|
|
20
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-DvKii7Bl.mjs
|
|
20
21
|
function contractError(code, message, options) {
|
|
21
22
|
return structuredError(code, message, options);
|
|
22
23
|
}
|
|
@@ -56,6 +57,316 @@ function mapFieldNamesToColumns(input) {
|
|
|
56
57
|
}
|
|
57
58
|
return columns;
|
|
58
59
|
}
|
|
60
|
+
/** A `` json`...` `` body that is not a JSON document. */
|
|
61
|
+
const PSL_INVALID_JSON_LITERAL = "PSL_INVALID_JSON_LITERAL";
|
|
62
|
+
/** A written value the entry, a cast, or the column's codec refuses. */
|
|
63
|
+
const PSL_INVALID_DEFAULT_LITERAL = "PSL_INVALID_DEFAULT_LITERAL";
|
|
64
|
+
/** A written value whose data type the column's type neither is nor casts from. */
|
|
65
|
+
const PSL_DEFAULT_TYPE_INCOMPATIBLE = "PSL_DEFAULT_TYPE_INCOMPATIBLE";
|
|
66
|
+
/** The code the JSON reader raises, so the PSL diagnostic for a bad document is its own. */
|
|
67
|
+
const INVALID_JSON_CODE = "CONTRACT.INVALID_JSON_LITERAL";
|
|
68
|
+
/** The value entries of a stack, by data type id. */
|
|
69
|
+
function valueEntries(support) {
|
|
70
|
+
return Object.entries(support.entries).flatMap(([key, entry]) => isDataTypeLoweringEntry(entry) ? [] : [[key, entry]]);
|
|
71
|
+
}
|
|
72
|
+
/** The entry a tag names, or `undefined` when no pack registered that tag. */
|
|
73
|
+
function entryForTag(support, tag) {
|
|
74
|
+
for (const [key, entry] of valueEntries(support)) if (entry.written.kind === "tag" && entry.written.tag === tag) return {
|
|
75
|
+
key,
|
|
76
|
+
entry
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Every tag a stack registers, in the order the entries were merged, for a diagnostic. */
|
|
80
|
+
function knownTags(support) {
|
|
81
|
+
return Object.values(support.entries).flatMap((entry) => entry.written.kind === "tag" ? [entry.written.tag] : []);
|
|
82
|
+
}
|
|
83
|
+
function entryForPlain(support, syntax) {
|
|
84
|
+
for (const [key, entry] of valueEntries(support)) if (entry.written.kind === "plain" && entry.written.syntax === syntax) return {
|
|
85
|
+
key,
|
|
86
|
+
entry
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** The text an entry reads: a tag's body, a string's value, or the word a boolean is written as. */
|
|
90
|
+
function plainText(written) {
|
|
91
|
+
switch (written.kind) {
|
|
92
|
+
case "tag": return written.body;
|
|
93
|
+
case "string": return written.text;
|
|
94
|
+
case "boolean": return String(written.value);
|
|
95
|
+
case "number": return written.text;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function messageOf(error) {
|
|
99
|
+
return error instanceof Error ? error.message : String(error);
|
|
100
|
+
}
|
|
101
|
+
function isJsonRefusal(error) {
|
|
102
|
+
return isStructuredError(error) && error.code === INVALID_JSON_CODE;
|
|
103
|
+
}
|
|
104
|
+
/** Read one written value through the entry for its syntax. */
|
|
105
|
+
function readValue(support, written, elementIndex) {
|
|
106
|
+
const refuse = (refusal) => ({
|
|
107
|
+
ok: false,
|
|
108
|
+
refusal: blindCast({
|
|
109
|
+
...refusal,
|
|
110
|
+
elementIndex
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
const found = written.kind === "tag" ? entryForTag(support, written.tag) : entryForPlain(support, written.kind);
|
|
114
|
+
if (found === void 0) return written.kind === "tag" ? refuse({
|
|
115
|
+
kind: "unknown-tag",
|
|
116
|
+
tag: written.tag,
|
|
117
|
+
known: knownTags(support)
|
|
118
|
+
}) : refuse({
|
|
119
|
+
kind: "unwritable",
|
|
120
|
+
syntax: written.kind
|
|
121
|
+
});
|
|
122
|
+
const form = found.entry.written;
|
|
123
|
+
if (form.kind === "plain" && form.syntax === "number") {
|
|
124
|
+
const text = plainText(written);
|
|
125
|
+
const classified = form.classify(text);
|
|
126
|
+
if (classified === void 0) return refuse({
|
|
127
|
+
kind: "unreadable",
|
|
128
|
+
json: false,
|
|
129
|
+
message: `no data type of this target holds the number ${text}`
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
ok: true,
|
|
133
|
+
typed: classified
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const text = plainText(written);
|
|
137
|
+
try {
|
|
138
|
+
return {
|
|
139
|
+
ok: true,
|
|
140
|
+
typed: {
|
|
141
|
+
type: blindCast(found.key),
|
|
142
|
+
value: form.parse(text)
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return refuse({
|
|
147
|
+
kind: "unreadable",
|
|
148
|
+
json: isJsonRefusal(error),
|
|
149
|
+
message: messageOf(error)
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** Convert a value of one data type into the form another stores, when that type takes it. */
|
|
154
|
+
function castInto(support, columnType, typed, elementIndex) {
|
|
155
|
+
if (typed.type === columnType) return {
|
|
156
|
+
ok: true,
|
|
157
|
+
value: typed.value
|
|
158
|
+
};
|
|
159
|
+
const declaration = support.lookup.get(columnType);
|
|
160
|
+
const cast = declaration?.casts[typed.type];
|
|
161
|
+
if (cast === void 0) return {
|
|
162
|
+
ok: false,
|
|
163
|
+
refusal: {
|
|
164
|
+
kind: "no-cast",
|
|
165
|
+
columnType,
|
|
166
|
+
valueType: typed.type,
|
|
167
|
+
casts: Object.keys(declaration?.casts ?? {}),
|
|
168
|
+
elementIndex
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
try {
|
|
172
|
+
return {
|
|
173
|
+
ok: true,
|
|
174
|
+
value: cast(typed.value)
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
ok: false,
|
|
179
|
+
refusal: {
|
|
180
|
+
kind: "unreadable",
|
|
181
|
+
json: isJsonRefusal(error),
|
|
182
|
+
message: messageOf(error),
|
|
183
|
+
elementIndex
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** The column's `typeParams` as the codec reference carries them, so `vector(3)` checks its length. */
|
|
189
|
+
function codecRefTypeParams(typeParams) {
|
|
190
|
+
return typeParams === void 0 ? void 0 : blindCast(typeParams);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Read one `@default(...)` value for a column, refusing in parts so each contract source words its
|
|
194
|
+
* own diagnostic. `isList` selects the check: a list column's elements are each read and cast
|
|
195
|
+
* against the element codec's data type, while a scalar column takes a written list only through
|
|
196
|
+
* its type's list cast — which is how `pgvector.Vector(3) @default([0.1, 0.2])` is read.
|
|
197
|
+
*/
|
|
198
|
+
function readDataTypeDefault(input) {
|
|
199
|
+
const descriptorFor = input.codecLookup?.descriptorFor;
|
|
200
|
+
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.`);
|
|
201
|
+
const descriptor = descriptorFor(input.column.codecId);
|
|
202
|
+
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.`);
|
|
203
|
+
const columnType = descriptor.dataType;
|
|
204
|
+
const codec = materializeCodec(descriptor, {
|
|
205
|
+
codecId: input.column.codecId,
|
|
206
|
+
...ifDefined("typeParams", codecRefTypeParams(input.column.typeParams))
|
|
207
|
+
}, { name: input.fieldPath });
|
|
208
|
+
const validate = (value, elementIndex) => {
|
|
209
|
+
try {
|
|
210
|
+
codec.decodeJson(value);
|
|
211
|
+
return {
|
|
212
|
+
ok: true,
|
|
213
|
+
value
|
|
214
|
+
};
|
|
215
|
+
} catch (error) {
|
|
216
|
+
return {
|
|
217
|
+
ok: false,
|
|
218
|
+
refusal: {
|
|
219
|
+
kind: "undecodable",
|
|
220
|
+
codecId: input.column.codecId,
|
|
221
|
+
message: messageOf(error),
|
|
222
|
+
elementIndex
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const readOne = (written, elementIndex) => {
|
|
228
|
+
const read = readValue(input.support, written, elementIndex);
|
|
229
|
+
if (!read.ok) return read;
|
|
230
|
+
const cast = castInto(input.support, columnType, read.typed, elementIndex);
|
|
231
|
+
if (!cast.ok) return cast;
|
|
232
|
+
return validate(cast.value, elementIndex);
|
|
233
|
+
};
|
|
234
|
+
if (input.written.kind !== "list") {
|
|
235
|
+
if (input.isList) return {
|
|
236
|
+
ok: false,
|
|
237
|
+
refusal: {
|
|
238
|
+
kind: "not-a-list",
|
|
239
|
+
elementIndex: void 0
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
return readOne(input.written, void 0);
|
|
243
|
+
}
|
|
244
|
+
if (input.isList) {
|
|
245
|
+
const elements = [];
|
|
246
|
+
for (const [elementIndex, written] of input.written.elements.entries()) {
|
|
247
|
+
if (written.kind === "list") return {
|
|
248
|
+
ok: false,
|
|
249
|
+
refusal: {
|
|
250
|
+
kind: "unreadable",
|
|
251
|
+
json: false,
|
|
252
|
+
message: "a list holds values, not other lists",
|
|
253
|
+
elementIndex
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const element = readOne(written, elementIndex);
|
|
257
|
+
if (!element.ok) return element;
|
|
258
|
+
elements.push(element.value);
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
ok: true,
|
|
262
|
+
value: elements
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return readListIntoScalar({
|
|
266
|
+
...input,
|
|
267
|
+
written: input.written,
|
|
268
|
+
columnType,
|
|
269
|
+
validate
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/** A written list on a column that is not a list: the column's type takes it through its list cast. */
|
|
273
|
+
function readListIntoScalar(input) {
|
|
274
|
+
const listCast = input.support.lookup.get(input.columnType)?.listCast;
|
|
275
|
+
if (listCast === void 0) return {
|
|
276
|
+
ok: false,
|
|
277
|
+
refusal: {
|
|
278
|
+
kind: "no-cast",
|
|
279
|
+
columnType: input.columnType,
|
|
280
|
+
valueType: "a list",
|
|
281
|
+
casts: Object.keys(input.support.lookup.get(input.columnType)?.casts ?? {}),
|
|
282
|
+
elementIndex: void 0
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const elements = [];
|
|
286
|
+
for (const [elementIndex, written] of input.written.elements.entries()) {
|
|
287
|
+
if (written.kind === "list") return {
|
|
288
|
+
ok: false,
|
|
289
|
+
refusal: {
|
|
290
|
+
kind: "unreadable",
|
|
291
|
+
json: false,
|
|
292
|
+
message: "a list holds values, not other lists",
|
|
293
|
+
elementIndex
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const read = readValue(input.support, written, elementIndex);
|
|
297
|
+
if (!read.ok) return read;
|
|
298
|
+
if (!listCast.of.includes(read.typed.type)) return {
|
|
299
|
+
ok: false,
|
|
300
|
+
refusal: {
|
|
301
|
+
kind: "no-cast",
|
|
302
|
+
columnType: input.columnType,
|
|
303
|
+
valueType: read.typed.type,
|
|
304
|
+
casts: [...listCast.of],
|
|
305
|
+
elementIndex
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
elements.push(read.typed.value);
|
|
309
|
+
}
|
|
310
|
+
try {
|
|
311
|
+
return input.validate(listCast.cast(elements), void 0);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return {
|
|
314
|
+
ok: false,
|
|
315
|
+
refusal: {
|
|
316
|
+
kind: "unreadable",
|
|
317
|
+
json: isJsonRefusal(error),
|
|
318
|
+
message: messageOf(error),
|
|
319
|
+
elementIndex: void 0
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/** Where in a written list a diagnostic is about, for a message: ` at element 2`. */
|
|
325
|
+
function at(elementIndex) {
|
|
326
|
+
return elementIndex === void 0 ? "" : ` at element ${elementIndex + 1}`;
|
|
327
|
+
}
|
|
328
|
+
/** {@link readDataTypeDefault} worded as a PSL diagnostic's code and message. */
|
|
329
|
+
function lowerDataTypeDefault(input) {
|
|
330
|
+
const read = readDataTypeDefault(input);
|
|
331
|
+
if (read.ok) return read;
|
|
332
|
+
const { refusal } = read;
|
|
333
|
+
const where = `Field "${input.fieldPath}"${at(refusal.elementIndex)}`;
|
|
334
|
+
switch (refusal.kind) {
|
|
335
|
+
case "unreadable": return {
|
|
336
|
+
ok: false,
|
|
337
|
+
code: refusal.json ? PSL_INVALID_JSON_LITERAL : PSL_INVALID_DEFAULT_LITERAL,
|
|
338
|
+
message: `${where}: ${refusal.message}`
|
|
339
|
+
};
|
|
340
|
+
case "unknown-tag": return {
|
|
341
|
+
ok: false,
|
|
342
|
+
code: "PSL_UNKNOWN_DEFAULT_LITERAL_TAG",
|
|
343
|
+
message: `Unknown literal tag "${refusal.tag}". Known tags: ${refusal.known.join(", ")}.`
|
|
344
|
+
};
|
|
345
|
+
case "unwritable": return {
|
|
346
|
+
ok: false,
|
|
347
|
+
code: PSL_DEFAULT_TYPE_INCOMPATIBLE,
|
|
348
|
+
message: `${where}: this target has no data type for a ${refusal.syntax} value`
|
|
349
|
+
};
|
|
350
|
+
case "not-a-list": return {
|
|
351
|
+
ok: false,
|
|
352
|
+
code: PSL_DEFAULT_TYPE_INCOMPATIBLE,
|
|
353
|
+
message: `${where}: this column holds a list, so its default is a list literal, as in [1, 2]`
|
|
354
|
+
};
|
|
355
|
+
case "no-cast": return {
|
|
356
|
+
ok: false,
|
|
357
|
+
code: PSL_DEFAULT_TYPE_INCOMPATIBLE,
|
|
358
|
+
message: `${where}: ${refusal.columnType} has no cast from ${refusal.valueType}; ${describeCasts(refusal.casts)}`
|
|
359
|
+
};
|
|
360
|
+
case "undecodable": return {
|
|
361
|
+
ok: false,
|
|
362
|
+
code: PSL_INVALID_DEFAULT_LITERAL,
|
|
363
|
+
message: `${where}: ${refusal.message}`
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function describeCasts(casts) {
|
|
368
|
+
return casts.length === 0 ? "it casts from nothing" : `it casts from ${casts.join(", ")}`;
|
|
369
|
+
}
|
|
59
370
|
function formatSupportedFunctionList(registry) {
|
|
60
371
|
const signatures = Array.from(registry.entries()).sort(([a], [b]) => a.localeCompare(b)).flatMap(([functionName, entry]) => {
|
|
61
372
|
const usageSignatures = entry.usageSignatures?.filter((signature) => signature.length > 0);
|
|
@@ -86,44 +397,6 @@ function lowerDefaultFunctionWithRegistry(input) {
|
|
|
86
397
|
}
|
|
87
398
|
};
|
|
88
399
|
}
|
|
89
|
-
/**
|
|
90
|
-
* The default value a number literal gives a column whose codec holds numbers. Returns `undefined`
|
|
91
|
-
* when the codec does not hold numbers, or reads the literal neither as a JSON number nor as
|
|
92
|
-
* decimal text.
|
|
93
|
-
*/
|
|
94
|
-
function numberLiteralDefault(text, codecId, codecLookup) {
|
|
95
|
-
const codec = numberHoldingCodec(codecLookup, codecId);
|
|
96
|
-
if (codec === void 0) return void 0;
|
|
97
|
-
const number = Number(text);
|
|
98
|
-
if (tryDecodeJson(codec, number) !== void 0) return number;
|
|
99
|
-
const decoded = tryDecodeJson(codec, canonicalDecimalText(text));
|
|
100
|
-
return decoded !== void 0 && isNumberValue(decoded.value) ? decoded.value : void 0;
|
|
101
|
-
}
|
|
102
|
-
function numberHoldingCodec(codecLookup, codecId) {
|
|
103
|
-
return codecLookup?.descriptorFor?.(codecId)?.traits.includes("numeric") === true ? codecLookup?.get(codecId) : void 0;
|
|
104
|
-
}
|
|
105
|
-
const DECIMAL_NUMERAL = /^(-?)0*(\d+)(\.\d+)?$/;
|
|
106
|
-
/**
|
|
107
|
-
* Leading zeros and the sign of zero never change a decimal. Trailing zeros are kept, because a
|
|
108
|
-
* column without a scale keeps them.
|
|
109
|
-
*/
|
|
110
|
-
function canonicalDecimalText(text) {
|
|
111
|
-
const numeral = DECIMAL_NUMERAL.exec(text);
|
|
112
|
-
if (numeral === null) return text;
|
|
113
|
-
const [, sign = "", whole = "", fraction = ""] = numeral;
|
|
114
|
-
const digits = `${whole}${fraction}`;
|
|
115
|
-
return /^[0.]+$/.test(digits) ? digits : `${sign}${digits}`;
|
|
116
|
-
}
|
|
117
|
-
function isNumberValue(value) {
|
|
118
|
-
return typeof value === "string" || typeof value === "number" || typeof value === "bigint";
|
|
119
|
-
}
|
|
120
|
-
function tryDecodeJson(codec, json) {
|
|
121
|
-
try {
|
|
122
|
-
return { value: codec.decodeJson(json) };
|
|
123
|
-
} catch {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
400
|
const INVALID_AUTHORING_ARGUMENT = Symbol("invalidAuthoringArgument");
|
|
128
401
|
function isIdentifierStartCharacter(character) {
|
|
129
402
|
return character !== void 0 && /[A-Za-z_$]/.test(character);
|
|
@@ -797,7 +1070,7 @@ const TAGGED_LITERAL_CANONICALIZATION_CODES = {
|
|
|
797
1070
|
nul: "PSL_TAGGED_LITERAL_NUL",
|
|
798
1071
|
"too-large": "PSL_TAGGED_LITERAL_TOO_LARGE"
|
|
799
1072
|
};
|
|
800
|
-
function lowerTaggedLiteral(literal,
|
|
1073
|
+
function lowerTaggedLiteral(literal, support, context, source) {
|
|
801
1074
|
const reject = (code, message) => ({
|
|
802
1075
|
ok: false,
|
|
803
1076
|
kind: "owned",
|
|
@@ -807,10 +1080,18 @@ function lowerTaggedLiteral(literal, registry, context, source) {
|
|
|
807
1080
|
...source.at(literal.span)
|
|
808
1081
|
}
|
|
809
1082
|
});
|
|
810
|
-
const entry =
|
|
811
|
-
if (entry === void 0) return reject("PSL_UNKNOWN_DEFAULT_LITERAL_TAG", `Unknown literal tag "${literal.tag}". Known tags: ${
|
|
1083
|
+
const entry = support.entries[loweringEntryKey(literal.tag)] ?? entryForTag(support, literal.tag)?.entry;
|
|
1084
|
+
if (entry === void 0) return reject("PSL_UNKNOWN_DEFAULT_LITERAL_TAG", `Unknown literal tag "${literal.tag}". Known tags: ${knownTags(support).join(", ")}.`);
|
|
812
1085
|
const { canonicalization } = literal;
|
|
813
1086
|
if (!canonicalization.ok) return reject(TAGGED_LITERAL_CANONICALIZATION_CODES[canonicalization.reason], describeTaggedLiteralFailure(canonicalization.reason));
|
|
1087
|
+
if (!isDataTypeLoweringEntry(entry)) return {
|
|
1088
|
+
ok: true,
|
|
1089
|
+
written: {
|
|
1090
|
+
kind: "tag",
|
|
1091
|
+
tag: literal.tag,
|
|
1092
|
+
body: canonicalization.body
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
814
1095
|
const result = entry.lower({
|
|
815
1096
|
literal: {
|
|
816
1097
|
tag: literal.tag,
|
|
@@ -836,7 +1117,7 @@ function lowerDefaultForField(input) {
|
|
|
836
1117
|
field: input.field,
|
|
837
1118
|
controlMutationDefaults: {
|
|
838
1119
|
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
839
|
-
|
|
1120
|
+
dataTypeEntries: input.dataTypeSupport.entries
|
|
840
1121
|
}
|
|
841
1122
|
})),
|
|
842
1123
|
model: input.model,
|
|
@@ -846,65 +1127,140 @@ function lowerDefaultForField(input) {
|
|
|
846
1127
|
});
|
|
847
1128
|
if (interpreted === void 0) return {};
|
|
848
1129
|
const value = interpreted.value;
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
columnCodecId: input.columnDescriptor.codecId
|
|
864
|
-
};
|
|
865
|
-
const lowered = "tag" in value ? lowerTaggedLiteral(value, input.defaultLiteralTagRegistry, context, source) : lowerDefaultFunctionWithRegistry({
|
|
866
|
-
call: value,
|
|
867
|
-
registry: input.defaultFunctionRegistry,
|
|
868
|
-
context,
|
|
869
|
-
source
|
|
1130
|
+
const context = {
|
|
1131
|
+
sourceId: input.sources.sourceFileFor(node.syntax).filename,
|
|
1132
|
+
modelName: input.modelName,
|
|
1133
|
+
fieldName: input.fieldName,
|
|
1134
|
+
columnCodecId: input.columnDescriptor.codecId
|
|
1135
|
+
};
|
|
1136
|
+
const readAsLiteral = (written) => {
|
|
1137
|
+
const lowered = lowerDataTypeDefault({
|
|
1138
|
+
written,
|
|
1139
|
+
isList: input.field.list,
|
|
1140
|
+
column: input.columnDescriptor,
|
|
1141
|
+
codecLookup: input.codecLookup,
|
|
1142
|
+
support: input.dataTypeSupport,
|
|
1143
|
+
fieldPath: `${input.modelName}.${input.fieldName}`
|
|
870
1144
|
});
|
|
871
1145
|
if (!lowered.ok) {
|
|
872
|
-
if (lowered.kind === "owned") input.diagnostics.push(lowered.diagnostic);
|
|
873
|
-
else input.diagnostics.pushExternal(lowered.diagnostic);
|
|
874
|
-
return {};
|
|
875
|
-
}
|
|
876
|
-
if (lowered.value.kind === "storage") return { defaultValue: lowered.value.defaultValue };
|
|
877
|
-
const generatorDescriptor = input.generatorDescriptorById.get(lowered.value.generated.id);
|
|
878
|
-
if (!generatorDescriptor) {
|
|
879
1146
|
input.diagnostics.push({
|
|
880
|
-
code:
|
|
881
|
-
message:
|
|
882
|
-
...source.at(
|
|
1147
|
+
code: lowered.code,
|
|
1148
|
+
message: lowered.message,
|
|
1149
|
+
...source.at()
|
|
883
1150
|
});
|
|
884
1151
|
return {};
|
|
885
1152
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1153
|
+
return { defaultValue: {
|
|
1154
|
+
kind: "literal",
|
|
1155
|
+
value: lowered.value,
|
|
1156
|
+
canonical: true
|
|
1157
|
+
} };
|
|
1158
|
+
};
|
|
1159
|
+
const writtenElement = (element) => {
|
|
1160
|
+
if (typeof element === "string") return {
|
|
1161
|
+
kind: "string",
|
|
1162
|
+
text: element
|
|
1163
|
+
};
|
|
1164
|
+
if (typeof element === "boolean") return {
|
|
1165
|
+
kind: "boolean",
|
|
1166
|
+
value: element
|
|
1167
|
+
};
|
|
1168
|
+
if ("text" in element) return {
|
|
1169
|
+
kind: "number",
|
|
1170
|
+
text: element.text
|
|
1171
|
+
};
|
|
1172
|
+
const lowered = lowerTaggedLiteral(element, input.dataTypeSupport, context, source);
|
|
1173
|
+
if (!lowered.ok) {
|
|
1174
|
+
if (lowered.kind === "owned") input.diagnostics.push(lowered.diagnostic);
|
|
1175
|
+
else input.diagnostics.pushExternal(lowered.diagnostic);
|
|
1176
|
+
return { ok: false };
|
|
893
1177
|
}
|
|
894
|
-
if (!
|
|
1178
|
+
if (!("written" in lowered)) {
|
|
895
1179
|
input.diagnostics.push({
|
|
896
|
-
code:
|
|
897
|
-
message: `
|
|
898
|
-
...source.at(
|
|
1180
|
+
code: PSL_INVALID_DEFAULT_LITERAL,
|
|
1181
|
+
message: `Literal tag "${element.tag}" produces a default of its own and cannot be an element of a list literal.`,
|
|
1182
|
+
...source.at(element.span)
|
|
899
1183
|
});
|
|
900
|
-
return {};
|
|
1184
|
+
return { ok: false };
|
|
901
1185
|
}
|
|
902
|
-
return
|
|
1186
|
+
return lowered.written;
|
|
1187
|
+
};
|
|
1188
|
+
if (input.columnDescriptor.valueSet !== void 0) {
|
|
1189
|
+
if (typeof value === "string") return { defaultValue: {
|
|
1190
|
+
kind: "literal",
|
|
1191
|
+
value
|
|
1192
|
+
} };
|
|
1193
|
+
if (Array.isArray(value)) {
|
|
1194
|
+
const members = value.filter((element) => typeof element === "string");
|
|
1195
|
+
if (members.length === value.length) return { defaultValue: {
|
|
1196
|
+
kind: "literal",
|
|
1197
|
+
value: members
|
|
1198
|
+
} };
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
if (Array.isArray(value)) {
|
|
1202
|
+
const elements = [];
|
|
1203
|
+
for (const element of value) {
|
|
1204
|
+
const written = writtenElement(element);
|
|
1205
|
+
if ("ok" in written) return {};
|
|
1206
|
+
elements.push(written);
|
|
1207
|
+
}
|
|
1208
|
+
return readAsLiteral({
|
|
1209
|
+
kind: "list",
|
|
1210
|
+
elements
|
|
1211
|
+
});
|
|
903
1212
|
}
|
|
904
|
-
|
|
905
|
-
kind: "
|
|
1213
|
+
if (typeof value === "string") return readAsLiteral({
|
|
1214
|
+
kind: "string",
|
|
1215
|
+
text: value
|
|
1216
|
+
});
|
|
1217
|
+
if (typeof value === "boolean") return readAsLiteral({
|
|
1218
|
+
kind: "boolean",
|
|
906
1219
|
value
|
|
907
|
-
}
|
|
1220
|
+
});
|
|
1221
|
+
if ("text" in value) return readAsLiteral({
|
|
1222
|
+
kind: "number",
|
|
1223
|
+
text: value.text
|
|
1224
|
+
});
|
|
1225
|
+
const lowered = "tag" in value ? lowerTaggedLiteral(value, input.dataTypeSupport, context, source) : lowerDefaultFunctionWithRegistry({
|
|
1226
|
+
call: value,
|
|
1227
|
+
registry: input.defaultFunctionRegistry,
|
|
1228
|
+
context,
|
|
1229
|
+
source
|
|
1230
|
+
});
|
|
1231
|
+
if (!lowered.ok) {
|
|
1232
|
+
if (lowered.kind === "owned") input.diagnostics.push(lowered.diagnostic);
|
|
1233
|
+
else input.diagnostics.pushExternal(lowered.diagnostic);
|
|
1234
|
+
return {};
|
|
1235
|
+
}
|
|
1236
|
+
if ("written" in lowered) return readAsLiteral(lowered.written);
|
|
1237
|
+
if (lowered.value.kind === "storage") return { defaultValue: lowered.value.defaultValue };
|
|
1238
|
+
const generatorDescriptor = input.generatorDescriptorById.get(lowered.value.generated.id);
|
|
1239
|
+
if (!generatorDescriptor) {
|
|
1240
|
+
input.diagnostics.push({
|
|
1241
|
+
code: "PSL_INVALID_DEFAULT_APPLICABILITY",
|
|
1242
|
+
message: `Default generator "${lowered.value.generated.id}" is not available in the composed mutation default registry.`,
|
|
1243
|
+
...source.at(value.span)
|
|
1244
|
+
});
|
|
1245
|
+
return {};
|
|
1246
|
+
}
|
|
1247
|
+
if (generatorDescriptor.applicableCodecIds === void 0) {
|
|
1248
|
+
input.diagnostics.push({
|
|
1249
|
+
code: "PSL_INVALID_DEFAULT_APPLICABILITY",
|
|
1250
|
+
message: `Default generator "${generatorDescriptor.id}" is not applicable to "@default(...)" lowering. Use the corresponding field preset (e.g. \`temporal.${generatorDescriptor.id === "timestampNow" ? "updatedAt" : generatorDescriptor.id}()\`) instead.`,
|
|
1251
|
+
...source.at(value.span)
|
|
1252
|
+
});
|
|
1253
|
+
return {};
|
|
1254
|
+
}
|
|
1255
|
+
if (!generatorDescriptor.applicableCodecIds.includes(input.columnDescriptor.codecId)) {
|
|
1256
|
+
input.diagnostics.push({
|
|
1257
|
+
code: "PSL_INVALID_DEFAULT_APPLICABILITY",
|
|
1258
|
+
message: `Default generator "${generatorDescriptor.id}" is not applicable to "${input.modelName}.${input.fieldName}" with codecId "${input.columnDescriptor.codecId}".`,
|
|
1259
|
+
...source.at(value.span)
|
|
1260
|
+
});
|
|
1261
|
+
return {};
|
|
1262
|
+
}
|
|
1263
|
+
return { executionDefaults: { onCreate: lowered.value.generated } };
|
|
908
1264
|
}
|
|
909
1265
|
function resolveColumnDescriptor(field, enumTypeDescriptors, namedTypeDescriptors, scalarColumnDescriptors) {
|
|
910
1266
|
if (namedTypeDescriptors.has(field.typeName)) return namedTypeDescriptors.get(field.typeName);
|
|
@@ -924,7 +1280,7 @@ function lowerEnumDefaultForField(input) {
|
|
|
924
1280
|
field,
|
|
925
1281
|
controlMutationDefaults: {
|
|
926
1282
|
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
927
|
-
|
|
1283
|
+
dataTypeEntries: input.dataTypeSupport.entries
|
|
928
1284
|
}
|
|
929
1285
|
})),
|
|
930
1286
|
model,
|
|
@@ -1065,7 +1421,7 @@ function lowerNoCheckForField(input) {
|
|
|
1065
1421
|
return [...authored].sort();
|
|
1066
1422
|
}
|
|
1067
1423
|
function collectResolvedFields(input) {
|
|
1068
|
-
const { model, symbolTable, mapping, enumTypeDescriptors, namedTypeDescriptors, modelNames, compositeTypeNames, composedExtensions, authoringContributions, familyId, targetId, defaultFunctionRegistry,
|
|
1424
|
+
const { model, symbolTable, mapping, enumTypeDescriptors, namedTypeDescriptors, modelNames, compositeTypeNames, composedExtensions, authoringContributions, familyId, targetId, defaultFunctionRegistry, dataTypeSupport, generatorDescriptorById, diagnostics, sources, scalarColumnDescriptors, enumHandles, capabilities, namespaceId, namespaceExtensionEntities, codecLookup } = input;
|
|
1069
1425
|
const resolvedFields = [];
|
|
1070
1426
|
const valueObjectStorageTypeName = authoringContributions?.valueObjectStorageType;
|
|
1071
1427
|
const declaredControlPolicy = getAttribute(model.attributes, "control")?.args.find((arg) => arg.kind === "positional")?.value.trim();
|
|
@@ -1179,7 +1535,7 @@ function collectResolvedFields(input) {
|
|
|
1179
1535
|
sources: input.sources,
|
|
1180
1536
|
enumHandle,
|
|
1181
1537
|
defaultFunctionRegistry,
|
|
1182
|
-
|
|
1538
|
+
dataTypeSupport,
|
|
1183
1539
|
diagnostics
|
|
1184
1540
|
}) : lowerDefaultForField({
|
|
1185
1541
|
modelName: model.name,
|
|
@@ -1191,7 +1547,7 @@ function collectResolvedFields(input) {
|
|
|
1191
1547
|
columnDescriptor: descriptor,
|
|
1192
1548
|
generatorDescriptorById,
|
|
1193
1549
|
defaultFunctionRegistry,
|
|
1194
|
-
|
|
1550
|
+
dataTypeSupport,
|
|
1195
1551
|
codecLookup,
|
|
1196
1552
|
diagnostics
|
|
1197
1553
|
}) : {};
|
|
@@ -2150,7 +2506,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2150
2506
|
familyId: input.familyId,
|
|
2151
2507
|
targetId: input.targetId,
|
|
2152
2508
|
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
2153
|
-
|
|
2509
|
+
dataTypeSupport: input.dataTypeSupport,
|
|
2154
2510
|
generatorDescriptorById: input.generatorDescriptorById,
|
|
2155
2511
|
diagnostics,
|
|
2156
2512
|
sources: input.sources,
|
|
@@ -2459,7 +2815,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
2459
2815
|
model,
|
|
2460
2816
|
controlMutationDefaults: {
|
|
2461
2817
|
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
2462
|
-
|
|
2818
|
+
dataTypeEntries: input.dataTypeSupport.entries
|
|
2463
2819
|
}
|
|
2464
2820
|
}),
|
|
2465
2821
|
model,
|
|
@@ -3211,7 +3567,10 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3211
3567
|
const composedExtensions = new Set(input.composedExtensions ?? []);
|
|
3212
3568
|
const composedExtensionContracts = input.composedExtensionContracts;
|
|
3213
3569
|
const defaultFunctionRegistry = input.controlMutationDefaults?.defaultFunctionRegistry ?? /* @__PURE__ */ new Map();
|
|
3214
|
-
const
|
|
3570
|
+
const dataTypeSupport = {
|
|
3571
|
+
entries: input.authoringContributions?.dataTypes ?? {},
|
|
3572
|
+
lookup: input.dataTypeLookup
|
|
3573
|
+
};
|
|
3215
3574
|
const generatorDescriptors = input.controlMutationDefaults?.generatorDescriptors ?? [];
|
|
3216
3575
|
const generatorDescriptorById = /* @__PURE__ */ new Map();
|
|
3217
3576
|
for (const descriptor of generatorDescriptors) generatorDescriptorById.set(descriptor.id, descriptor);
|
|
@@ -3380,7 +3739,7 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3380
3739
|
targetId: input.target.targetId,
|
|
3381
3740
|
authoringContributions: input.authoringContributions,
|
|
3382
3741
|
defaultFunctionRegistry,
|
|
3383
|
-
|
|
3742
|
+
dataTypeSupport,
|
|
3384
3743
|
generatorDescriptorById,
|
|
3385
3744
|
scalarColumnDescriptors: input.scalarColumnDescriptors,
|
|
3386
3745
|
sources: input.sources,
|
|
@@ -3543,6 +3902,6 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3543
3902
|
});
|
|
3544
3903
|
}
|
|
3545
3904
|
//#endregion
|
|
3546
|
-
export {
|
|
3905
|
+
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 };
|
|
3547
3906
|
|
|
3548
|
-
//# sourceMappingURL=interpreter-
|
|
3907
|
+
//# sourceMappingURL=interpreter-DvKii7Bl-D8Ipte3f.mjs.map
|