@prisma/orm-family-sql 8.0.0-rc.21-dev.6 → 8.0.0-rc.21-dev.8
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/{attribute-specs-CM_fC-TC.d.mts → attribute-specs-DDpSUaG9.d.mts} +3 -3
- package/dist/{attribute-specs-CM_fC-TC.d.mts.map → attribute-specs-DDpSUaG9.d.mts.map} +1 -1
- package/dist/{authoring-entity-types-CgKIgWq5--Hjkn72Y.d.mts → authoring-entity-types-CgKIgWq5-BqRjoPFF.d.mts} +2 -2
- package/dist/{authoring-entity-types-CgKIgWq5--Hjkn72Y.d.mts.map → authoring-entity-types-CgKIgWq5-BqRjoPFF.d.mts.map} +1 -1
- package/dist/{config-types-BvmmK8D-.mjs → config-types-BCXwEBZH.mjs} +2 -2
- package/dist/{config-types-BvmmK8D-.mjs.map → config-types-BCXwEBZH.mjs.map} +1 -1
- package/dist/{contract-builder-Bk-Co792.mjs → contract-builder-D50r41BU.mjs} +112 -47
- package/dist/contract-builder-D50r41BU.mjs.map +1 -0
- package/dist/{contract-builder-B8oDZ4aU.d.mts → contract-builder-D6JuOGA6.d.mts} +43 -4
- package/dist/{contract-builder-B8oDZ4aU.d.mts.map → contract-builder-D6JuOGA6.d.mts.map} +1 -1
- package/dist/contract-prisma7__provider.d.mts +3 -1
- package/dist/contract-prisma7__provider.d.mts.map +1 -1
- package/dist/contract-prisma7__provider.mjs +60 -24
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__diagnostics.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +1 -1
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.d.mts +1 -1
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/contract.d.mts +2 -2
- package/dist/contract.mjs +3 -3
- package/dist/contract__data-type.d.mts +2 -2
- package/dist/contract__data-type.mjs +2 -2
- package/dist/contract__validators.mjs +1 -1
- package/dist/{control-B2CeDfVO.d.mts → control-BE7gXqZF.d.mts} +3 -3
- package/dist/{control-B2CeDfVO.d.mts.map → control-BE7gXqZF.d.mts.map} +1 -1
- package/dist/{control-C1EjGUVq.mjs → control-DPCrkpMS.mjs} +10 -11
- package/dist/control-DPCrkpMS.mjs.map +1 -0
- package/dist/{control-adapter-SlQkTEwT.mjs → control-adapter-BetaUm2y.mjs} +2 -2
- package/dist/{control-adapter-SlQkTEwT.mjs.map → control-adapter-BetaUm2y.mjs.map} +1 -1
- package/dist/{data-type-CR0gi2GQ.d.mts → data-type-B-Do6RMA.d.mts} +13 -5
- package/dist/data-type-B-Do6RMA.d.mts.map +1 -0
- package/dist/{data-type-BFSpaotu.mjs → data-type-BfA5F0Qf.mjs} +2 -2
- package/dist/{data-type-BFSpaotu.mjs.map → data-type-BfA5F0Qf.mjs.map} +1 -1
- package/dist/{default-mapping-CAOONlKQ-CIg7JCfF.d.mts → default-mapping-CEISdj2g-B50Ag_F_.d.mts} +5 -11
- package/dist/default-mapping-CEISdj2g-B50Ag_F_.d.mts.map +1 -0
- package/dist/{derived-checks-BuTkSE9l-gyx0d0dX.mjs → derived-checks-D__agoFB-Boa1MHcA.mjs} +4 -4
- package/dist/{derived-checks-BuTkSE9l-gyx0d0dX.mjs.map → derived-checks-D__agoFB-Boa1MHcA.mjs.map} +1 -1
- package/dist/{diagnostics-C7jR1Jyf.mjs → diagnostics-CoM0OFuR.mjs} +40 -30
- package/dist/diagnostics-CoM0OFuR.mjs.map +1 -0
- package/dist/{exports-CGzFaakG-4Aw50nT1.mjs → exports-CpIULsPV-Cur2Y5Dx.mjs} +8 -3
- package/dist/exports-CpIULsPV-Cur2Y5Dx.mjs.map +1 -0
- package/dist/family.d.mts +7 -7
- package/dist/family.mjs +9 -9
- package/dist/family__control-adapter.mjs +1 -1
- package/dist/family__control.d.mts +1 -1
- package/dist/family__control.mjs +3 -3
- package/dist/family__diff.mjs +1 -1
- package/dist/family__ir.mjs +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-build.d.mts +3 -3
- package/dist/family__psl-build.mjs +2 -2
- package/dist/family__psl-infer.d.mts +1 -1
- package/dist/family__runtime.d.mts +1 -1
- package/dist/family__runtime.mjs +1 -1
- package/dist/{generator-functions-Hy4pDDr9-BUHOsofo.mjs → generator-functions-Hy4pDDr9-CMfJOBtv.mjs} +2 -2
- package/dist/{generator-functions-Hy4pDDr9-BUHOsofo.mjs.map → generator-functions-Hy4pDDr9-CMfJOBtv.mjs.map} +1 -1
- package/dist/{index-BAI1gH-I.d.mts → index-hLidCcl6.d.mts} +14 -15
- package/dist/index-hLidCcl6.d.mts.map +1 -0
- package/dist/{interpreter-CrQFtK4p-CM5k_t4g.mjs → interpreter-ChvVEijY-FeJngsog.mjs} +16 -6
- package/dist/interpreter-ChvVEijY-FeJngsog.mjs.map +1 -0
- package/dist/orm-client.d.mts +1 -1
- package/dist/orm-client.mjs +1 -1
- package/dist/{pack-BPbz6RVm.d.mts → pack-DKM1hv1E.d.mts} +3 -3
- package/dist/{pack-BPbz6RVm.d.mts.map → pack-DKM1hv1E.d.mts.map} +1 -1
- package/dist/psl-build-BA0Ndi1v.mjs +268 -0
- package/dist/psl-build-BA0Ndi1v.mjs.map +1 -0
- package/dist/{psl-build-CNncjpsa.d.mts → psl-build-DCZaF5g4.d.mts} +44 -15
- package/dist/psl-build-DCZaF5g4.d.mts.map +1 -0
- package/dist/{psl-column-resolution-djGEITmJ-DfEOkjPf.d.mts → psl-column-resolution-djGEITmJ-C0LSpwl4.d.mts} +2 -2
- package/dist/{psl-column-resolution-djGEITmJ-DfEOkjPf.d.mts.map → psl-column-resolution-djGEITmJ-C0LSpwl4.d.mts.map} +1 -1
- package/dist/{psl-field-resolution-Bvhx79fP-CuyYFk8z.mjs → psl-field-resolution-BW2_FOb9-DxqR43fo.mjs} +67 -37
- package/dist/psl-field-resolution-BW2_FOb9-DxqR43fo.mjs.map +1 -0
- package/dist/{psl-infer-BkkoyXmM.d.mts → psl-infer-Cr9AeccU.d.mts} +2 -2
- package/dist/{psl-infer-BkkoyXmM.d.mts.map → psl-infer-Cr9AeccU.d.mts.map} +1 -1
- package/dist/{runtime-BrBva2ta.d.mts → runtime-CSDcwOEG.d.mts} +4 -3
- package/dist/{runtime-BrBva2ta.d.mts.map → runtime-CSDcwOEG.d.mts.map} +1 -1
- package/dist/{runtime-CCzfa1mY.mjs → runtime-DkUiQi00.mjs} +12 -4
- package/dist/runtime-DkUiQi00.mjs.map +1 -0
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/{schema-verify-C3wbdviw-mlPO4NkT.mjs → schema-verify-C3wbdviw-nQ4tG9N7.mjs} +2 -2
- package/dist/{schema-verify-C3wbdviw-mlPO4NkT.mjs.map → schema-verify-C3wbdviw-nQ4tG9N7.mjs.map} +1 -1
- package/dist/{sql-contract-serializer-sMY3prTx-aQd4v3fE.mjs → sql-contract-serializer-sMY3prTx-CBHrlt9O.mjs} +2 -2
- package/dist/{sql-contract-serializer-sMY3prTx-aQd4v3fE.mjs.map → sql-contract-serializer-sMY3prTx-CBHrlt9O.mjs.map} +1 -1
- package/dist/{sql-data-type-D7M-YTTY-D2vRqDxn.mjs → sql-data-type-LVBldu1a-Bq203xWX.mjs} +13 -7
- package/dist/sql-data-type-LVBldu1a-Bq203xWX.mjs.map +1 -0
- package/dist/{validators-CnQqLEIi.mjs → validators-qcQteqs2.mjs} +2 -2
- package/dist/{validators-CnQqLEIi.mjs.map → validators-qcQteqs2.mjs.map} +1 -1
- package/package.json +18 -18
- package/dist/contract-builder-Bk-Co792.mjs.map +0 -1
- package/dist/control-C1EjGUVq.mjs.map +0 -1
- package/dist/data-type-CR0gi2GQ.d.mts.map +0 -1
- package/dist/default-mapping-CAOONlKQ-CIg7JCfF.d.mts.map +0 -1
- package/dist/diagnostics-C7jR1Jyf.mjs.map +0 -1
- package/dist/exports-CGzFaakG-4Aw50nT1.mjs.map +0 -1
- package/dist/index-BAI1gH-I.d.mts.map +0 -1
- package/dist/interpreter-CrQFtK4p-CM5k_t4g.mjs.map +0 -1
- package/dist/psl-build-CNncjpsa.d.mts.map +0 -1
- package/dist/psl-build-DqqYhOsa.mjs +0 -426
- package/dist/psl-build-DqqYhOsa.mjs.map +0 -1
- package/dist/psl-field-resolution-Bvhx79fP-CuyYFk8z.mjs.map +0 -1
- package/dist/runtime-CCzfa1mY.mjs.map +0 -1
- package/dist/sql-data-type-D7M-YTTY-D2vRqDxn.mjs.map +0 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { n as isSqlDataType, o as resolveReportedSqlType } from "./sql-data-type-LVBldu1a-Bq203xWX.mjs";
|
|
2
|
+
import "./sql-expression-CKgKznXS.mjs";
|
|
3
|
+
import { t as sqlFamilyError } from "./errors-B5g0xWro-C8plbqga.mjs";
|
|
4
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
5
|
+
import { authoringTypeConstructorArguments, authoringTypeConstructors, findAuthoringTypeChoiceCall, getAuthoringTypeChoice, getAuthoringTypeConstructor, instantiateAuthoringTypeConstructor, isAuthoringTypeChoiceOption, printTaggedLiteral, writeDataTypeValue, writeTypedLiteral, writtenTypeArguments } from "@prisma/orm-framework/components/authoring";
|
|
6
|
+
import { dataTypeId, dataTypeParams } from "@prisma/orm-framework/components/codec";
|
|
7
|
+
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
8
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
9
|
+
import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
10
|
+
//#region ../../../2-sql-family/9-family/dist/psl-build.mjs
|
|
11
|
+
/** Every constructor of `authoringTypes` marked `inferred`, by the data type its codec represents. */
|
|
12
|
+
function inferredTypeConstructors(input) {
|
|
13
|
+
const found = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const { path, descriptor } of authoringTypeConstructors(input.authoringTypes)) {
|
|
15
|
+
if (descriptor.inferred !== true) continue;
|
|
16
|
+
const dataTypeId = input.codecLookup.descriptorFor(descriptor.output.codecId)?.dataType;
|
|
17
|
+
const dataType = dataTypeId === void 0 ? void 0 : input.dataTypeLookup.get(dataTypeId);
|
|
18
|
+
if (dataType === void 0 || !isSqlDataType(dataType)) continue;
|
|
19
|
+
found.set(dataType.id, {
|
|
20
|
+
path,
|
|
21
|
+
descriptor,
|
|
22
|
+
dataType
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return found;
|
|
26
|
+
}
|
|
27
|
+
function normalParams(marked, args) {
|
|
28
|
+
try {
|
|
29
|
+
const { typeParams } = instantiateAuthoringTypeConstructor(marked.descriptor, args);
|
|
30
|
+
const params = dataTypeParams(marked.dataType, typeParams);
|
|
31
|
+
return canonicalizeJson(marked.dataType.sql.normalize(params));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (isInternalError(error)) throw error;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The call to `marked` with the fewest arguments that produces `params`, the normal form of a
|
|
39
|
+
* column's data type parameters: arguments are dropped from the end while the normal form of what
|
|
40
|
+
* the call produces stays `params`. Undefined when the constructor cannot produce them, such as one
|
|
41
|
+
* whose argument names another entity.
|
|
42
|
+
*/
|
|
43
|
+
function fewestArgumentsCall(marked, params) {
|
|
44
|
+
const all = authoringTypeConstructorArguments(marked.descriptor, {
|
|
45
|
+
codecId: marked.descriptor.output.codecId,
|
|
46
|
+
typeParams: params
|
|
47
|
+
});
|
|
48
|
+
if (all === void 0) return void 0;
|
|
49
|
+
const wanted = canonicalizeJson(params);
|
|
50
|
+
const args = [...all];
|
|
51
|
+
while (args.length > 0 && normalParams(marked, args.slice(0, -1)) === wanted) args.pop();
|
|
52
|
+
return {
|
|
53
|
+
path: marked.path,
|
|
54
|
+
args
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether two outputs have the same codec and the same parameters in the normal form of `dataType`, which the codecs represent: how `db verify` and the planner compare a column with the database.
|
|
59
|
+
*/
|
|
60
|
+
function sameInNormalForm(dataType) {
|
|
61
|
+
const normal = (output) => canonicalizeJson(dataType.sql.normalize(dataTypeParams(dataType, output.typeParams ?? {})));
|
|
62
|
+
return (produced, wanted) => produced.codecId === wanted.codecId && normal(produced) === normal(wanted);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The type choice call that becomes the type constructor call `call`, written by name with only the arguments that differ from the defaults (ADR 279). `sameOutput` decides when it becomes the same type; by default the codec and type parameters must be exactly equal. `undefined` when no type choice call becomes it or an argument has no literal that reads back as it.
|
|
66
|
+
*/
|
|
67
|
+
function writtenTypeChoiceCall(input) {
|
|
68
|
+
const found = findAuthoringTypeChoiceCall({
|
|
69
|
+
namespace: input.authoringTypes,
|
|
70
|
+
call: input.call,
|
|
71
|
+
...ifDefined("sameOutput", input.sameOutput)
|
|
72
|
+
});
|
|
73
|
+
const choice = found && getAuthoringTypeChoice({ type: input.authoringTypes }, found.path);
|
|
74
|
+
if (found === void 0 || choice === void 0) return void 0;
|
|
75
|
+
const args = [];
|
|
76
|
+
for (const { name, value } of found.args) {
|
|
77
|
+
const argument = choice.descriptor.args.find((candidate) => candidate.name === name);
|
|
78
|
+
const text = argument === void 0 ? void 0 : isAuthoringTypeChoiceOption(argument) ? String(value) : writeDataTypeValue(blindCast(value), dataTypeId(argument.dataType), input.dataTypes);
|
|
79
|
+
if (text === void 0) return void 0;
|
|
80
|
+
args.push({
|
|
81
|
+
name,
|
|
82
|
+
text
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
path: found.path,
|
|
87
|
+
args,
|
|
88
|
+
becomes: found.becomes
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** The type the database reported for `column`, which introspection always records. */
|
|
92
|
+
function reportedTypeOf(column, tableName) {
|
|
93
|
+
if (column.reportedType === void 0) throw new InternalError(`contract infer read column "${tableName}"."${column.name}" without the type the database reported for it.`);
|
|
94
|
+
return column.reportedType;
|
|
95
|
+
}
|
|
96
|
+
/** The call to the type choice that becomes `marked` with every parameter in `params`, compared in the normal form, as `db verify` compares the column, with the explicit call it becomes. */
|
|
97
|
+
function convenienceCall(marked, params, authoringTypes, support) {
|
|
98
|
+
const values = authoringTypeConstructorArguments(marked.descriptor, {
|
|
99
|
+
codecId: marked.descriptor.output.codecId,
|
|
100
|
+
typeParams: params
|
|
101
|
+
});
|
|
102
|
+
const written = values && writtenTypeChoiceCall({
|
|
103
|
+
authoringTypes,
|
|
104
|
+
call: {
|
|
105
|
+
path: marked.path,
|
|
106
|
+
args: values
|
|
107
|
+
},
|
|
108
|
+
dataTypes: support,
|
|
109
|
+
sameOutput: sameInNormalForm(marked.dataType)
|
|
110
|
+
});
|
|
111
|
+
return written && {
|
|
112
|
+
path: written.path,
|
|
113
|
+
args: written.args,
|
|
114
|
+
explicit: {
|
|
115
|
+
path: written.becomes.path,
|
|
116
|
+
values: written.becomes.args
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The first call to a row of the type choice `written` names whose type constructor represents the same data type, with the same parameters, and whose codec reads the column default.
|
|
122
|
+
*/
|
|
123
|
+
async function rowReadingDefault(written, marked, params, authoringTypes, support, readsDefault) {
|
|
124
|
+
const choice = getAuthoringTypeChoice({ type: authoringTypes }, written.path);
|
|
125
|
+
for (const row of choice?.descriptor.choices ?? []) {
|
|
126
|
+
const path = [...written.path.slice(0, -1), row.type];
|
|
127
|
+
const descriptor = getAuthoringTypeConstructor({ type: authoringTypes }, path);
|
|
128
|
+
const call = descriptor !== void 0 && support.dataTypeOfCodec(descriptor.output.codecId) === marked.dataType.id ? convenienceCall({
|
|
129
|
+
...marked,
|
|
130
|
+
path,
|
|
131
|
+
descriptor
|
|
132
|
+
}, params, authoringTypes, support) : void 0;
|
|
133
|
+
if (call !== void 0 && await readsDefault(call)) return call;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function writtenCall(constructors, dataTypes, authoringTypes, support, reported, readsDefault) {
|
|
137
|
+
const resolved = resolveReportedSqlType(reported, dataTypes);
|
|
138
|
+
const marked = resolved && constructors.get(resolved.dataType.id);
|
|
139
|
+
if (resolved === void 0 || marked === void 0) return void 0;
|
|
140
|
+
const convenience = convenienceCall(marked, resolved.typeParams, authoringTypes, support);
|
|
141
|
+
if (convenience !== void 0) {
|
|
142
|
+
if (await readsDefault(convenience)) return convenience;
|
|
143
|
+
return await rowReadingDefault(convenience, marked, resolved.typeParams, authoringTypes, support, readsDefault) ?? convenience;
|
|
144
|
+
}
|
|
145
|
+
const call = fewestArgumentsCall(marked, resolved.typeParams);
|
|
146
|
+
const args = call && writtenTypeArguments(marked.descriptor, call.args, support);
|
|
147
|
+
return call && args && {
|
|
148
|
+
path: call.path,
|
|
149
|
+
args: args.map((text) => ({
|
|
150
|
+
name: void 0,
|
|
151
|
+
text
|
|
152
|
+
})),
|
|
153
|
+
explicit: {
|
|
154
|
+
path: call.path,
|
|
155
|
+
values: call.args
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The type of every column of `tables` that `isEnumColumn` does not claim, through the constructor marked `inferred` for the data type that claims the column's reported type: the type choice call that becomes it, with only the arguments that differ from the defaults, or else the call to it with the fewest arguments. When the codec of that type choice call cannot read the column default as a row, the first row of the same type choice whose codec can is written instead. When any column has no such call, throws `CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED` listing every one of them.
|
|
161
|
+
*/
|
|
162
|
+
async function inferColumnTypes(input) {
|
|
163
|
+
const dataTypes = [...input.constructors.values()].map((marked) => marked.dataType);
|
|
164
|
+
const types = /* @__PURE__ */ new Map();
|
|
165
|
+
const unclaimed = [];
|
|
166
|
+
for (const { schemaName, tableName, columns } of input.tables) for (const column of columns) {
|
|
167
|
+
if (input.isEnumColumn(column)) continue;
|
|
168
|
+
const reported = reportedTypeOf(column, tableName);
|
|
169
|
+
const readsDefault = input.readsDefault;
|
|
170
|
+
const call = await writtenCall(input.constructors, dataTypes, input.authoringTypes, input.dataTypes, reported, async (type) => readsDefault === void 0 ? true : readsDefault(tableName, column, type));
|
|
171
|
+
if (call === void 0) {
|
|
172
|
+
unclaimed.push(`${schemaName}.${tableName}.${column.name}: ${reported.text}${column.many === true ? "[]" : ""}`);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
types.set(JSON.stringify([tableName, column.name]), call);
|
|
176
|
+
}
|
|
177
|
+
if (unclaimed.length > 0) {
|
|
178
|
+
const columns = unclaimed.sort();
|
|
179
|
+
throw sqlFamilyError("CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED", ["contract infer: Prisma 8 cannot write these column types with the configured stack:", ...columns.map((line) => ` ${line}`)].join("\n"), {
|
|
180
|
+
why: "Prisma 8 reads a column type only through a data type that the target or an extension pack declares.",
|
|
181
|
+
fix: `No configured pack has a type for these columns. If a type comes from a database extension that has a Prisma 8 pack, add the pack to extensions in prisma.config.ts. Otherwise, to keep such a column, write the schema by hand and declare its field as Raw(sql\`<type>\`) with the type as listed, or change the column's type or remove the column from the database.`,
|
|
182
|
+
meta: { columns }
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return (tableName, columnName) => {
|
|
186
|
+
const type = types.get(JSON.stringify([tableName, columnName]));
|
|
187
|
+
if (type === void 0) throw new InternalError(`contract infer resolved no type for "${tableName}"."${columnName}".`);
|
|
188
|
+
return type;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const DEFAULT_FUNCTION_ATTRIBUTES = {
|
|
192
|
+
"autoincrement()": "@default(autoincrement())",
|
|
193
|
+
"now()": "@default(now())"
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* The attribute a stored default prints as: a named function, a literal the column takes, or any
|
|
197
|
+
* other expression as a `sql` literal. `undefined` when a literal has no written form. An expression
|
|
198
|
+
* prints even when the literal would read back as different text: default expressions are compared
|
|
199
|
+
* with case and whitespace ignored (`SqlColumnDefaultIR.isEqualTo`), and canonicalization changes only
|
|
200
|
+
* whitespace (ADR 129).
|
|
201
|
+
*/
|
|
202
|
+
function mapDefault(columnDefault, options) {
|
|
203
|
+
switch (columnDefault.kind) {
|
|
204
|
+
case "literal": {
|
|
205
|
+
const text = writeTypedLiteral(columnDefault.value, {
|
|
206
|
+
dataTypes: options?.dataTypes,
|
|
207
|
+
dataType: options?.columnCodec?.dataType,
|
|
208
|
+
typeParams: options?.typeParams,
|
|
209
|
+
...ifDefined("list", options?.list)
|
|
210
|
+
});
|
|
211
|
+
return text === void 0 ? void 0 : { attribute: `@default(${text})` };
|
|
212
|
+
}
|
|
213
|
+
case "function": return { attribute: options?.functionAttributes?.[columnDefault.expression] ?? DEFAULT_FUNCTION_ATTRIBUTES[columnDefault.expression] ?? `@default(${printTaggedLiteral("sql", columnDefault.expression)})` };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const GENERATOR_PHASES = ["onCreate", "onUpdate"];
|
|
217
|
+
/**
|
|
218
|
+
* The generator function call that writes each phase of a column's generators, as `@onCreate(...)` and `@onUpdate(...)` take it. A call must resolve back to the stored generator, so a list column, a generator no function writes for the codec, and a call that reads back differently are refused.
|
|
219
|
+
*/
|
|
220
|
+
function generatorCallsFor(input) {
|
|
221
|
+
const { executionDefault, field, list, generatorFunctions } = input;
|
|
222
|
+
const calls = [];
|
|
223
|
+
for (const phase of GENERATOR_PHASES) {
|
|
224
|
+
const generator = executionDefault[phase];
|
|
225
|
+
if (generator === void 0) continue;
|
|
226
|
+
if (list) return {
|
|
227
|
+
ok: false,
|
|
228
|
+
refusal: {
|
|
229
|
+
kind: "on-list",
|
|
230
|
+
phase,
|
|
231
|
+
generator
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const printed = generatorFunctions.callFor(generator, field);
|
|
235
|
+
if (printed === void 0) return {
|
|
236
|
+
ok: false,
|
|
237
|
+
refusal: {
|
|
238
|
+
kind: "no-function",
|
|
239
|
+
phase,
|
|
240
|
+
generator
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const readBack = generatorFunctions.resolve(printed.call, field);
|
|
244
|
+
if (!readBack.ok || canonicalizeJson(readBack.generator) !== canonicalizeJson(generator)) return {
|
|
245
|
+
ok: false,
|
|
246
|
+
refusal: {
|
|
247
|
+
kind: "reads-back-differently",
|
|
248
|
+
phase,
|
|
249
|
+
generator,
|
|
250
|
+
text: printed.text,
|
|
251
|
+
readBack: readBack.ok ? readBack.generator : void 0,
|
|
252
|
+
refusedBecause: !readBack.ok && readBack.reason === "refused" ? readBack.message : void 0
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
calls.push({
|
|
256
|
+
phase,
|
|
257
|
+
text: printed.text
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
ok: true,
|
|
262
|
+
calls
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
export { mapDefault as a, inferredTypeConstructors as i, generatorCallsFor as n, sameInNormalForm as o, inferColumnTypes as r, writtenTypeChoiceCall as s, fewestArgumentsCall as t };
|
|
267
|
+
|
|
268
|
+
//# sourceMappingURL=psl-build-BA0Ndi1v.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psl-build-BA0Ndi1v.mjs","names":[],"sources":["../../../../2-sql-family/9-family/dist/psl-build.mjs"],"sourcesContent":["import { t as sqlFamilyError } from \"./errors-B5g0xWro.mjs\";\nimport { s as toEnumMemberName } from \"./psl-names-C3cwe0rg.mjs\";\nimport { isSqlDataType, resolveReportedSqlType } from \"@internal/sql-contract/data-type\";\nimport { SQL_EXPRESSION_TAG } from \"@internal/sql-contract/sql-expression\";\nimport { authoringTypeConstructorArguments, authoringTypeConstructors, findAuthoringTypeChoiceCall, getAuthoringTypeChoice, getAuthoringTypeConstructor, instantiateAuthoringTypeConstructor, isAuthoringTypeChoiceOption, printTaggedLiteral, writeDataTypeValue, writeTypedLiteral, writtenTypeArguments } from \"@internal/framework-components/authoring\";\nimport { dataTypeId, dataTypeParams } from \"@internal/framework-components/codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError, isInternalError } from \"@internal/utils/internal-error\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\n//#region src/core/psl-build/inferred-type-constructors.ts\n/** Every constructor of `authoringTypes` marked `inferred`, by the data type its codec represents. */\nfunction inferredTypeConstructors(input) {\n\tconst found = /* @__PURE__ */ new Map();\n\tfor (const { path, descriptor } of authoringTypeConstructors(input.authoringTypes)) {\n\t\tif (descriptor.inferred !== true) continue;\n\t\tconst dataTypeId = input.codecLookup.descriptorFor(descriptor.output.codecId)?.dataType;\n\t\tconst dataType = dataTypeId === void 0 ? void 0 : input.dataTypeLookup.get(dataTypeId);\n\t\tif (dataType === void 0 || !isSqlDataType(dataType)) continue;\n\t\tfound.set(dataType.id, {\n\t\t\tpath,\n\t\t\tdescriptor,\n\t\t\tdataType\n\t\t});\n\t}\n\treturn found;\n}\nfunction normalParams(marked, args) {\n\ttry {\n\t\tconst { typeParams } = instantiateAuthoringTypeConstructor(marked.descriptor, args);\n\t\tconst params = dataTypeParams(marked.dataType, typeParams);\n\t\treturn canonicalizeJson(marked.dataType.sql.normalize(params));\n\t} catch (error) {\n\t\tif (isInternalError(error)) throw error;\n\t\treturn;\n\t}\n}\n/**\n* The call to `marked` with the fewest arguments that produces `params`, the normal form of a\n* column's data type parameters: arguments are dropped from the end while the normal form of what\n* the call produces stays `params`. Undefined when the constructor cannot produce them, such as one\n* whose argument names another entity.\n*/\nfunction fewestArgumentsCall(marked, params) {\n\tconst all = authoringTypeConstructorArguments(marked.descriptor, {\n\t\tcodecId: marked.descriptor.output.codecId,\n\t\ttypeParams: params\n\t});\n\tif (all === void 0) return void 0;\n\tconst wanted = canonicalizeJson(params);\n\tconst args = [...all];\n\twhile (args.length > 0 && normalParams(marked, args.slice(0, -1)) === wanted) args.pop();\n\treturn {\n\t\tpath: marked.path,\n\t\targs\n\t};\n}\n/**\n* Whether two outputs have the same codec and the same parameters in the normal form of `dataType`, which the codecs represent: how `db verify` and the planner compare a column with the database.\n*/\nfunction sameInNormalForm(dataType) {\n\tconst normal = (output) => canonicalizeJson(dataType.sql.normalize(dataTypeParams(dataType, output.typeParams ?? {})));\n\treturn (produced, wanted) => produced.codecId === wanted.codecId && normal(produced) === normal(wanted);\n}\n/**\n* The type choice call that becomes the type constructor call `call`, written by name with only the arguments that differ from the defaults (ADR 279). `sameOutput` decides when it becomes the same type; by default the codec and type parameters must be exactly equal. `undefined` when no type choice call becomes it or an argument has no literal that reads back as it.\n*/\nfunction writtenTypeChoiceCall(input) {\n\tconst found = findAuthoringTypeChoiceCall({\n\t\tnamespace: input.authoringTypes,\n\t\tcall: input.call,\n\t\t...ifDefined(\"sameOutput\", input.sameOutput)\n\t});\n\tconst choice = found && getAuthoringTypeChoice({ type: input.authoringTypes }, found.path);\n\tif (found === void 0 || choice === void 0) return void 0;\n\tconst args = [];\n\tfor (const { name, value } of found.args) {\n\t\tconst argument = choice.descriptor.args.find((candidate) => candidate.name === name);\n\t\tconst text = argument === void 0 ? void 0 : isAuthoringTypeChoiceOption(argument) ? String(value) : writeDataTypeValue(blindCast(value), dataTypeId(argument.dataType), input.dataTypes);\n\t\tif (text === void 0) return void 0;\n\t\targs.push({\n\t\t\tname,\n\t\t\ttext\n\t\t});\n\t}\n\treturn {\n\t\tpath: found.path,\n\t\targs,\n\t\tbecomes: found.becomes\n\t};\n}\n//#endregion\n//#region src/core/psl-build/column-types.ts\n/** The type the database reported for `column`, which introspection always records. */\nfunction reportedTypeOf(column, tableName) {\n\tif (column.reportedType === void 0) throw new InternalError(`contract infer read column \"${tableName}\".\"${column.name}\" without the type the database reported for it.`);\n\treturn column.reportedType;\n}\n/** The call to the type choice that becomes `marked` with every parameter in `params`, compared in the normal form, as `db verify` compares the column, with the explicit call it becomes. */\nfunction convenienceCall(marked, params, authoringTypes, support) {\n\tconst values = authoringTypeConstructorArguments(marked.descriptor, {\n\t\tcodecId: marked.descriptor.output.codecId,\n\t\ttypeParams: params\n\t});\n\tconst written = values && writtenTypeChoiceCall({\n\t\tauthoringTypes,\n\t\tcall: {\n\t\t\tpath: marked.path,\n\t\t\targs: values\n\t\t},\n\t\tdataTypes: support,\n\t\tsameOutput: sameInNormalForm(marked.dataType)\n\t});\n\treturn written && {\n\t\tpath: written.path,\n\t\targs: written.args,\n\t\texplicit: {\n\t\t\tpath: written.becomes.path,\n\t\t\tvalues: written.becomes.args\n\t\t}\n\t};\n}\n/**\n* The first call to a row of the type choice `written` names whose type constructor represents the same data type, with the same parameters, and whose codec reads the column default.\n*/\nasync function rowReadingDefault(written, marked, params, authoringTypes, support, readsDefault) {\n\tconst choice = getAuthoringTypeChoice({ type: authoringTypes }, written.path);\n\tfor (const row of choice?.descriptor.choices ?? []) {\n\t\tconst path = [...written.path.slice(0, -1), row.type];\n\t\tconst descriptor = getAuthoringTypeConstructor({ type: authoringTypes }, path);\n\t\tconst call = descriptor !== void 0 && support.dataTypeOfCodec(descriptor.output.codecId) === marked.dataType.id ? convenienceCall({\n\t\t\t...marked,\n\t\t\tpath,\n\t\t\tdescriptor\n\t\t}, params, authoringTypes, support) : void 0;\n\t\tif (call !== void 0 && await readsDefault(call)) return call;\n\t}\n}\nasync function writtenCall(constructors, dataTypes, authoringTypes, support, reported, readsDefault) {\n\tconst resolved = resolveReportedSqlType(reported, dataTypes);\n\tconst marked = resolved && constructors.get(resolved.dataType.id);\n\tif (resolved === void 0 || marked === void 0) return void 0;\n\tconst convenience = convenienceCall(marked, resolved.typeParams, authoringTypes, support);\n\tif (convenience !== void 0) {\n\t\tif (await readsDefault(convenience)) return convenience;\n\t\treturn await rowReadingDefault(convenience, marked, resolved.typeParams, authoringTypes, support, readsDefault) ?? convenience;\n\t}\n\tconst call = fewestArgumentsCall(marked, resolved.typeParams);\n\tconst args = call && writtenTypeArguments(marked.descriptor, call.args, support);\n\treturn call && args && {\n\t\tpath: call.path,\n\t\targs: args.map((text) => ({\n\t\t\tname: void 0,\n\t\t\ttext\n\t\t})),\n\t\texplicit: {\n\t\t\tpath: call.path,\n\t\t\tvalues: call.args\n\t\t}\n\t};\n}\n/**\n* The type of every column of `tables` that `isEnumColumn` does not claim, through the constructor marked `inferred` for the data type that claims the column's reported type: the type choice call that becomes it, with only the arguments that differ from the defaults, or else the call to it with the fewest arguments. When the codec of that type choice call cannot read the column default as a row, the first row of the same type choice whose codec can is written instead. When any column has no such call, throws `CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED` listing every one of them.\n*/\nasync function inferColumnTypes(input) {\n\tconst dataTypes = [...input.constructors.values()].map((marked) => marked.dataType);\n\tconst types = /* @__PURE__ */ new Map();\n\tconst unclaimed = [];\n\tfor (const { schemaName, tableName, columns } of input.tables) for (const column of columns) {\n\t\tif (input.isEnumColumn(column)) continue;\n\t\tconst reported = reportedTypeOf(column, tableName);\n\t\tconst readsDefault = input.readsDefault;\n\t\tconst call = await writtenCall(input.constructors, dataTypes, input.authoringTypes, input.dataTypes, reported, async (type) => readsDefault === void 0 ? true : readsDefault(tableName, column, type));\n\t\tif (call === void 0) {\n\t\t\tunclaimed.push(`${schemaName}.${tableName}.${column.name}: ${reported.text}${column.many === true ? \"[]\" : \"\"}`);\n\t\t\tcontinue;\n\t\t}\n\t\ttypes.set(JSON.stringify([tableName, column.name]), call);\n\t}\n\tif (unclaimed.length > 0) {\n\t\tconst columns = unclaimed.sort();\n\t\tthrow sqlFamilyError(\"CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED\", [\"contract infer: Prisma 8 cannot write these column types with the configured stack:\", ...columns.map((line) => ` ${line}`)].join(\"\\n\"), {\n\t\t\twhy: \"Prisma 8 reads a column type only through a data type that the target or an extension pack declares.\",\n\t\t\tfix: `No configured pack has a type for these columns. If a type comes from a database extension that has a Prisma 8 pack, add the pack to extensions in prisma.config.ts. Otherwise, to keep such a column, write the schema by hand and declare its field as Raw(sql\\`<type>\\`) with the type as listed, or change the column's type or remove the column from the database.`,\n\t\t\tmeta: { columns }\n\t\t});\n\t}\n\treturn (tableName, columnName) => {\n\t\tconst type = types.get(JSON.stringify([tableName, columnName]));\n\t\tif (type === void 0) throw new InternalError(`contract infer resolved no type for \"${tableName}\".\"${columnName}\".`);\n\t\treturn type;\n\t};\n}\n//#endregion\n//#region src/core/psl-build/default-mapping.ts\nconst DEFAULT_FUNCTION_ATTRIBUTES = {\n\t\"autoincrement()\": \"@default(autoincrement())\",\n\t\"now()\": \"@default(now())\"\n};\n/**\n* The attribute a stored default prints as: a named function, a literal the column takes, or any\n* other expression as a `sql` literal. `undefined` when a literal has no written form. An expression\n* prints even when the literal would read back as different text: default expressions are compared\n* with case and whitespace ignored (`SqlColumnDefaultIR.isEqualTo`), and canonicalization changes only\n* whitespace (ADR 129).\n*/\nfunction mapDefault(columnDefault, options) {\n\tswitch (columnDefault.kind) {\n\t\tcase \"literal\": {\n\t\t\tconst text = writeTypedLiteral(columnDefault.value, {\n\t\t\t\tdataTypes: options?.dataTypes,\n\t\t\t\tdataType: options?.columnCodec?.dataType,\n\t\t\t\ttypeParams: options?.typeParams,\n\t\t\t\t...ifDefined(\"list\", options?.list)\n\t\t\t});\n\t\t\treturn text === void 0 ? void 0 : { attribute: `@default(${text})` };\n\t\t}\n\t\tcase \"function\": return { attribute: options?.functionAttributes?.[columnDefault.expression] ?? DEFAULT_FUNCTION_ATTRIBUTES[columnDefault.expression] ?? `@default(${printTaggedLiteral(SQL_EXPRESSION_TAG, columnDefault.expression)})` };\n\t}\n}\n//#endregion\n//#region src/core/psl-build/generator-calls.ts\nconst GENERATOR_PHASES = [\"onCreate\", \"onUpdate\"];\n/**\n* The generator function call that writes each phase of a column's generators, as `@onCreate(...)` and `@onUpdate(...)` take it. A call must resolve back to the stored generator, so a list column, a generator no function writes for the codec, and a call that reads back differently are refused.\n*/\nfunction generatorCallsFor(input) {\n\tconst { executionDefault, field, list, generatorFunctions } = input;\n\tconst calls = [];\n\tfor (const phase of GENERATOR_PHASES) {\n\t\tconst generator = executionDefault[phase];\n\t\tif (generator === void 0) continue;\n\t\tif (list) return {\n\t\t\tok: false,\n\t\t\trefusal: {\n\t\t\t\tkind: \"on-list\",\n\t\t\t\tphase,\n\t\t\t\tgenerator\n\t\t\t}\n\t\t};\n\t\tconst printed = generatorFunctions.callFor(generator, field);\n\t\tif (printed === void 0) return {\n\t\t\tok: false,\n\t\t\trefusal: {\n\t\t\t\tkind: \"no-function\",\n\t\t\t\tphase,\n\t\t\t\tgenerator\n\t\t\t}\n\t\t};\n\t\tconst readBack = generatorFunctions.resolve(printed.call, field);\n\t\tif (!readBack.ok || canonicalizeJson(readBack.generator) !== canonicalizeJson(generator)) return {\n\t\t\tok: false,\n\t\t\trefusal: {\n\t\t\t\tkind: \"reads-back-differently\",\n\t\t\t\tphase,\n\t\t\t\tgenerator,\n\t\t\t\ttext: printed.text,\n\t\t\t\treadBack: readBack.ok ? readBack.generator : void 0,\n\t\t\t\trefusedBecause: !readBack.ok && readBack.reason === \"refused\" ? readBack.message : void 0\n\t\t\t}\n\t\t};\n\t\tcalls.push({\n\t\t\tphase,\n\t\t\ttext: printed.text\n\t\t});\n\t}\n\treturn {\n\t\tok: true,\n\t\tcalls\n\t};\n}\n//#endregion\nexport { fewestArgumentsCall, generatorCallsFor, inferColumnTypes, inferredTypeConstructors, mapDefault, sameInNormalForm, toEnumMemberName, writtenTypeChoiceCall };\n\n//# sourceMappingURL=psl-build.mjs.map"],"mappings":";;;;;;;;;;;AAYA,SAAS,yBAAyB,OAAO;CAC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YAAY,KAAK;IAClD,gBAAgB,CAAC,SAAS,MAAM,SAAS,WAAW,YAAY,SAAS,UAAU,KAAK;GACzF;EACD;EACA,MAAM,KAAK;GACV;GACA,MAAM,QAAQ;EACf,CAAC;CACF;CACA,OAAO;EACN,IAAI;EACJ;CACD;AACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { u as SqlColumnIR } from "./types-fmtEmvj3-B0fQaVes.mjs";
|
|
2
2
|
import "./types-B-dwfOwQ.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import "./default-mapping-
|
|
5
|
-
import { AuthoringTypeConstructorCall, AuthoringTypeConstructorDescriptor, AuthoringTypeNamespace, DataTypeSupport } from "@prisma/orm-framework/components/authoring";
|
|
3
|
+
import { a as SqlDataType, u as SqlTypeParams } from "./data-type-B-Do6RMA.mjs";
|
|
4
|
+
import "./default-mapping-CEISdj2g-B50Ag_F_.mjs";
|
|
5
|
+
import { AuthoringTypeConstructorCall, AuthoringTypeConstructorDescriptor, AuthoringTypeConstructorOutput, AuthoringTypeNamespace, DataTypeSupport } from "@prisma/orm-framework/components/authoring";
|
|
6
6
|
import { ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue } from "@prisma/orm-framework/contract/types";
|
|
7
7
|
import { CodecLookupWithDescriptors, DataTypeLookup } from "@prisma/orm-framework/components/codec";
|
|
8
8
|
import { GeneratorFunctionField, GeneratorFunctionRegistry, GeneratorPhase } from "@prisma/orm-framework/components/components";
|
|
@@ -29,20 +29,48 @@ declare function inferredTypeConstructors(input: {
|
|
|
29
29
|
* whose argument names another entity.
|
|
30
30
|
*/
|
|
31
31
|
declare function fewestArgumentsCall(marked: InferredTypeConstructor, params: SqlTypeParams): AuthoringTypeConstructorCall | undefined;
|
|
32
|
+
/** An argument of a type call as PSL writes it: by name, or by position when `name` is undefined. */
|
|
33
|
+
interface PslTypeArgument {
|
|
34
|
+
readonly name: string | undefined;
|
|
35
|
+
readonly text: string;
|
|
36
|
+
}
|
|
37
|
+
/** A call to a type constructor or type choice as PSL writes it. */
|
|
38
|
+
interface WrittenPslTypeCall {
|
|
39
|
+
readonly path: readonly string[];
|
|
40
|
+
readonly args: readonly PslTypeArgument[];
|
|
41
|
+
}
|
|
42
|
+
/** A type choice call as PSL writes it, and the type constructor call it becomes. */
|
|
43
|
+
interface WrittenTypeChoiceCall extends WrittenPslTypeCall {
|
|
44
|
+
readonly becomes: AuthoringTypeConstructorCall;
|
|
45
|
+
}
|
|
32
46
|
/**
|
|
33
|
-
*
|
|
47
|
+
* Whether two outputs have the same codec and the same parameters in the normal form of `dataType`, which the codecs represent: how `db verify` and the planner compare a column with the database.
|
|
34
48
|
*/
|
|
35
|
-
declare function
|
|
49
|
+
declare function sameInNormalForm(dataType: SqlDataType): (produced: AuthoringTypeConstructorOutput, wanted: AuthoringTypeConstructorOutput) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The type choice call that becomes the type constructor call `call`, written by name with only the arguments that differ from the defaults (ADR 279). `sameOutput` decides when it becomes the same type; by default the codec and type parameters must be exactly equal. `undefined` when no type choice call becomes it or an argument has no literal that reads back as it.
|
|
52
|
+
*/
|
|
53
|
+
declare function writtenTypeChoiceCall(input: {
|
|
54
|
+
readonly authoringTypes: AuthoringTypeNamespace;
|
|
55
|
+
readonly call: AuthoringTypeConstructorCall;
|
|
56
|
+
readonly dataTypes: DataTypeSupport;
|
|
57
|
+
readonly sameOutput: ((produced: AuthoringTypeConstructorOutput, wanted: AuthoringTypeConstructorOutput) => boolean) | undefined;
|
|
58
|
+
}): WrittenTypeChoiceCall | undefined;
|
|
36
59
|
//#endregion
|
|
37
60
|
//#region src/core/psl-build/column-types.d.ts
|
|
38
|
-
/** A
|
|
61
|
+
/** A type call as PSL writes it, and the explicit type constructor it becomes, with the value of each of its arguments. */
|
|
39
62
|
interface PslTypeCall {
|
|
40
63
|
readonly path: readonly string[];
|
|
41
|
-
readonly args: readonly
|
|
42
|
-
readonly
|
|
64
|
+
readonly args: readonly PslTypeArgument[];
|
|
65
|
+
readonly explicit: {
|
|
66
|
+
readonly path: readonly string[];
|
|
67
|
+
readonly values: readonly unknown[];
|
|
68
|
+
};
|
|
43
69
|
}
|
|
44
70
|
/** The PSL type `contract infer` writes for a column that is not an enum, by table and column name. */
|
|
45
71
|
type ColumnTypeOf = (tableName: string, columnName: string) => PslTypeCall;
|
|
72
|
+
/** Whether the codec of `type` reads the default the database reports for `column` as a row value. */
|
|
73
|
+
type ColumnTypeReadsDefault = (tableName: string, column: SqlColumnIR, type: PslTypeCall) => Promise<boolean>;
|
|
46
74
|
/** One introspected table, with the schema it was read from. */
|
|
47
75
|
interface IntrospectedTable {
|
|
48
76
|
readonly schemaName: string;
|
|
@@ -50,18 +78,19 @@ interface IntrospectedTable {
|
|
|
50
78
|
readonly columns: readonly SqlColumnIR[];
|
|
51
79
|
}
|
|
52
80
|
/**
|
|
53
|
-
* The type of every column of `tables` that `isEnumColumn` does not claim: the call, with the
|
|
54
|
-
* fewest arguments, to the constructor marked `inferred` for the data type that claims the
|
|
55
|
-
* column's reported type. When any column has no such call, throws
|
|
56
|
-
* `CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED` listing every one of them.
|
|
81
|
+
* The type of every column of `tables` that `isEnumColumn` does not claim, through the constructor marked `inferred` for the data type that claims the column's reported type: the type choice call that becomes it, with only the arguments that differ from the defaults, or else the call to it with the fewest arguments. When the codec of that type choice call cannot read the column default as a row, the first row of the same type choice whose codec can is written instead. When any column has no such call, throws `CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED` listing every one of them.
|
|
57
82
|
*/
|
|
58
83
|
declare function inferColumnTypes(input: {
|
|
59
84
|
readonly tables: readonly IntrospectedTable[];
|
|
60
85
|
readonly constructors: InferredTypeConstructors;
|
|
86
|
+
/** The stack's type namespace, whose type choices infer writes where one becomes a marked constructor. */
|
|
87
|
+
readonly authoringTypes: AuthoringTypeNamespace;
|
|
61
88
|
/** The stack's data types, whose literals write each argument. */
|
|
62
89
|
readonly dataTypes: DataTypeSupport;
|
|
63
90
|
readonly isEnumColumn: (column: SqlColumnIR) => boolean;
|
|
64
|
-
|
|
91
|
+
/** Whether a type's codec reads the column default; every type does when `undefined`. */
|
|
92
|
+
readonly readsDefault: ColumnTypeReadsDefault | undefined;
|
|
93
|
+
}): Promise<ColumnTypeOf>;
|
|
65
94
|
//#endregion
|
|
66
95
|
//#region src/core/psl-build/generator-calls.d.ts
|
|
67
96
|
/** The call text that writes one phase of a column's generators. */
|
|
@@ -108,5 +137,5 @@ declare function generatorCallsFor(input: {
|
|
|
108
137
|
*/
|
|
109
138
|
declare function toEnumMemberName(value: string): string;
|
|
110
139
|
//#endregion
|
|
111
|
-
export {
|
|
112
|
-
//# sourceMappingURL=psl-build-
|
|
140
|
+
export { sameInNormalForm as _, InferredTypeConstructor as a, PhaseCallText as c, WrittenPslTypeCall as d, WrittenTypeChoiceCall as f, inferredTypeConstructors as g, inferColumnTypes as h, GeneratorCallsResult as i, PslTypeArgument as l, generatorCallsFor as m, ColumnTypeReadsDefault as n, InferredTypeConstructors as o, fewestArgumentsCall as p, GeneratorCallRefusal as r, IntrospectedTable as s, ColumnTypeOf as t, PslTypeCall as u, toEnumMemberName as v, writtenTypeChoiceCall as y };
|
|
141
|
+
//# sourceMappingURL=psl-build-DCZaF5g4.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psl-build-DCZaF5g4.d.mts","names":[],"sources":["../../../../2-sql-family/9-family/dist/psl-build.d.mts"],"mappings":";;;;;;;;;;;UASU;WACC;WACA,YAAY;WACZ,UAAU;;;KAGhB,2BAA2B,oBAAoB;;iBAEnC,yBAAyB;WAC/B,gBAAgB;WAChB,aAAa,KAAK;WAClB,gBAAgB;IACvB;;;;;;;iBAOa,oBAAoB,QAAQ,yBAAyB,QAAQ,gBAAgB;;UAEpF;WACC;WACA;;;UAGD;WACC;WACA,eAAe;;;UAGhB,8BAA8B;WAC7B,SAAS;;;;;iBAKH,iBAAiB,UAAU,eAAe,UAAU,gCAAgC,QAAQ;;;;iBAI5F,sBAAsB;WAC5B,gBAAgB;WAChB,MAAM;WACN,WAAW;WACX,cAAc,UAAU,gCAAgC,QAAQ;IACvE;;;;UAIM;WACC;WACA,eAAe;WACf;aACE;aACA;;;;KAIR,gBAAgB,mBAAmB,uBAAuB;;KAE1D,0BAA0B,mBAAmB,QAAQ,aAAa,MAAM,gBAAgB;;UAEnF;WACC;WACA;WACA,kBAAkB;;;;;iBAKZ,iBAAiB;WACvB,iBAAiB;WACjB,cAAc;;WAEd,gBAAgB;;WAEhB,WAAW;WACX,eAAe,QAAQ;;WAEvB,cAAc;IACrB,QAAQ;;;;UAIF;WACC,OAAO;WACP;;KAEN;WACM;WACA,OAAO;WACP,WAAW;;WAEX;WACA,OAAO;WACP,WAAW;WACX;WACA,UAAU;;WAEV;;KAEN;WACM;WACA,gBAAgB;;WAEhB;WACA,SAAS;;;;;iBAKH,kBAAkB;WACxB,kBAAkB;WAClB,OAAO;WACP;WACA,oBAAoB;IAC3B;;;;;;;;;iBASa,iBAAiB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./contract-builder-
|
|
1
|
+
import "./contract-builder-D6JuOGA6.mjs";
|
|
2
2
|
import { AuthoringTypeConstructorDescriptor, DataTypeSupport } from "@prisma/orm-framework/components/authoring";
|
|
3
3
|
import { ValueSetRef } from "@prisma/orm-framework/contract/types";
|
|
4
4
|
import { CodecLookupWithDescriptors } from "@prisma/orm-framework/components/codec";
|
|
@@ -21,4 +21,4 @@ type ColumnDescriptor = {
|
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
23
|
export { ColumnDescriptor as t };
|
|
24
|
-
//# sourceMappingURL=psl-column-resolution-djGEITmJ-
|
|
24
|
+
//# sourceMappingURL=psl-column-resolution-djGEITmJ-C0LSpwl4.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"psl-column-resolution-djGEITmJ-
|
|
1
|
+
{"version":3,"file":"psl-column-resolution-djGEITmJ-C0LSpwl4.d.mts","names":[],"sources":["../../../../2-sql-family/2-authoring/contract-psl/dist/psl-column-resolution-djGEITmJ.d.mts"],"mappings":";;;;;;;;KASK;WACM;WACA,aAAa;;;;;;;;;WASb,WAAW"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { u as sqlCodecColumnLength } from "./sql-data-type-
|
|
1
|
+
import { u as sqlCodecColumnLength } from "./sql-data-type-LVBldu1a-Bq203xWX.mjs";
|
|
2
2
|
import { p as sqlTextFromStored, t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-CKgKznXS.mjs";
|
|
3
|
-
import { n as checkSqlDefaultText, o as reservedSqlDefaultText } from "./validators-
|
|
4
|
-
import { i as isValueObjectMember, o as storedAsListColumn } from "./derived-checks-
|
|
3
|
+
import { n as checkSqlDefaultText, o as reservedSqlDefaultText } from "./validators-qcQteqs2.mjs";
|
|
4
|
+
import { i as isValueObjectMember, o as storedAsListColumn } from "./derived-checks-D__agoFB-Boa1MHcA.mjs";
|
|
5
5
|
import { n as getAttribute, o as storageName, t as formatDbAttributeMigrationMessage } from "./psl-attribute-parsing-BCsFWsSp-BJ-wGlY6.mjs";
|
|
6
6
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
7
7
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -13,9 +13,9 @@ import { InternalError, isInternalError } from "@prisma/orm-framework/utils/inte
|
|
|
13
13
|
import { FunctionCallAst } from "@prisma/orm-framework/psl-parser/syntax";
|
|
14
14
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
15
15
|
import { describeTaggedLiteralFailure as describeTaggedLiteralFailure$1 } from "@prisma/orm-framework/components/control";
|
|
16
|
-
import { bool, contributedTypeCodecId, contributedTypeOf, dataTypeValue, diagnosticSource, entityRef, fieldAttribute, fieldRef, funcCall, generatorAttributeSpec, identifier, interpretAttribute, leafDiagnostic, list, mapArg, modelAttribute, nodePslSpan, nodeSourceText, numLiteral, oneOf, optional, record, referencedFieldRef, refuseRepeatedTypeAliasAttributes, str, taggedLiteral, typeAttribute, typeAttributeSpecContextOfField, typeAttributeSubjectLabel, typeGeneratorAttributeSpec, typeReferenceNode, writtenList, writtenScalar } from "@prisma/orm-framework/psl-parser";
|
|
17
|
-
import { isBareTypeConstructor, mapPslHelperArgs, reportTypeConstructorNotCalled } from "@prisma/orm-framework/psl-parser/interpret";
|
|
18
|
-
//#region ../../../2-sql-family/2-authoring/contract-psl/dist/psl-field-resolution-
|
|
16
|
+
import { bool, contributedTypeCodecId, contributedTypeOf, dataTypeValue, diagnosticSource, entityRef, fieldAttribute, fieldRef, funcCall, generatorAttributeSpec, identifier, interpretAttribute, isContributedTypeChoice, leafDiagnostic, list, mapArg, modelAttribute, nodePslSpan, nodeSourceText, numLiteral, oneOf, optional, record, referencedFieldRef, refuseRepeatedTypeAliasAttributes, str, taggedLiteral, typeAttribute, typeAttributeSpecContextOfField, typeAttributeSubjectLabel, typeGeneratorAttributeSpec, typeReferenceNode, writtenList, writtenScalar } from "@prisma/orm-framework/psl-parser";
|
|
17
|
+
import { argumentIndexOf, argumentSpan, instantiatePslTypeChoice, isBareTypeConstructor, mapPslHelperArgs, reportTypeConstructorNotCalled } from "@prisma/orm-framework/psl-parser/interpret";
|
|
18
|
+
//#region ../../../2-sql-family/2-authoring/contract-psl/dist/psl-field-resolution-BW2_FOb9.mjs
|
|
19
19
|
function contractError(code, message, options) {
|
|
20
20
|
return structuredError(code, message, options);
|
|
21
21
|
}
|
|
@@ -62,11 +62,9 @@ function storedValueReader(input) {
|
|
|
62
62
|
const suggestedTypes = [descriptor.dataType];
|
|
63
63
|
const params = dataTypeParams(codec.dataType, input.column.typeParams);
|
|
64
64
|
const read = (written, elementIndex) => {
|
|
65
|
-
let
|
|
65
|
+
let value;
|
|
66
66
|
try {
|
|
67
|
-
|
|
68
|
-
codec.fromDataTypeValue(value);
|
|
69
|
-
stored = codec.dataType.toContract(value);
|
|
67
|
+
value = codec.dataType.valueFrom(written, params);
|
|
70
68
|
} catch (error) {
|
|
71
69
|
if (isInternalError(error)) throw error;
|
|
72
70
|
return {
|
|
@@ -80,6 +78,23 @@ function storedValueReader(input) {
|
|
|
80
78
|
suggestedTypes
|
|
81
79
|
};
|
|
82
80
|
}
|
|
81
|
+
const stored = codec.dataType.toContract(value);
|
|
82
|
+
try {
|
|
83
|
+
codec.fromDataTypeValue(value);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (isInternalError(error)) throw error;
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
refusal: {
|
|
89
|
+
kind: "refused-by-codec",
|
|
90
|
+
codecId: input.column.codecId,
|
|
91
|
+
message: messageOf(error),
|
|
92
|
+
elementIndex,
|
|
93
|
+
stored
|
|
94
|
+
},
|
|
95
|
+
suggestedTypes
|
|
96
|
+
};
|
|
97
|
+
}
|
|
83
98
|
return {
|
|
84
99
|
ok: true,
|
|
85
100
|
value: stored
|
|
@@ -145,16 +160,30 @@ function readDataTypeDefault(input) {
|
|
|
145
160
|
}
|
|
146
161
|
if (input.isList) {
|
|
147
162
|
const elements = [];
|
|
163
|
+
let codecRefusal;
|
|
148
164
|
for (const [elementIndex, written] of input.written.elements.entries()) {
|
|
149
165
|
if (written.kind === "list") return nestedList(elementIndex, suggestedTypes);
|
|
150
166
|
const element = readOne(written, elementIndex);
|
|
151
|
-
if (!element.ok
|
|
167
|
+
if (!element.ok && element.refusal.kind === "refused-by-codec") {
|
|
168
|
+
codecRefusal ??= element.refusal;
|
|
169
|
+
elements.push(element.refusal.stored);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (!element.ok) return codecRefusal === void 0 ? element : refused({
|
|
173
|
+
kind: "refused-by-column",
|
|
174
|
+
codecId: codecRefusal.codecId,
|
|
175
|
+
message: codecRefusal.message,
|
|
176
|
+
elementIndex: codecRefusal.elementIndex
|
|
177
|
+
}, suggestedTypes);
|
|
152
178
|
elements.push(element.value);
|
|
153
179
|
}
|
|
154
|
-
return {
|
|
180
|
+
return codecRefusal === void 0 ? {
|
|
155
181
|
ok: true,
|
|
156
182
|
value: elements
|
|
157
|
-
}
|
|
183
|
+
} : refused({
|
|
184
|
+
...codecRefusal,
|
|
185
|
+
stored: elements
|
|
186
|
+
}, suggestedTypes);
|
|
158
187
|
}
|
|
159
188
|
return readListIntoScalar({
|
|
160
189
|
...input,
|
|
@@ -263,11 +292,7 @@ function codecRefusalMessage(refusal, subject) {
|
|
|
263
292
|
};
|
|
264
293
|
}
|
|
265
294
|
function storedRefusalMessage(refusal, subject) {
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
code: "PSL_INVALID_LITERAL",
|
|
269
|
-
message: `${location(subject, refusal.elementIndex)}: ${refusal.message}`
|
|
270
|
-
};
|
|
295
|
+
return codecRefusalMessage(refusal, subject);
|
|
271
296
|
}
|
|
272
297
|
/** A refusal worded as a PSL diagnostic's code and message; `guidance` says what to write instead. */
|
|
273
298
|
function refusalMessage(refusal, subject, dataTypes, guidance) {
|
|
@@ -277,7 +302,8 @@ function refusalMessage(refusal, subject, dataTypes, guidance) {
|
|
|
277
302
|
code: PSL_DEFAULT_LIST_EXPECTED,
|
|
278
303
|
message: `${where}: this column holds a list, so its default is a list literal, as in [1, 2]`
|
|
279
304
|
};
|
|
280
|
-
case "refused-by-column":
|
|
305
|
+
case "refused-by-column":
|
|
306
|
+
case "refused-by-codec": return codecRefusalMessage(refusal, subject);
|
|
281
307
|
case "no-list-cast": return {
|
|
282
308
|
code: PSL_VALUE_TYPE_INCOMPATIBLE,
|
|
283
309
|
message: `${where}: ${describeExpected(guidance.forms)}; got a list`
|
|
@@ -298,7 +324,8 @@ function refusalMessage(refusal, subject, dataTypes, guidance) {
|
|
|
298
324
|
function refusalSpan(refusal, spans, subject) {
|
|
299
325
|
switch (refusal.kind) {
|
|
300
326
|
case "not-a-list":
|
|
301
|
-
case "refused-by-column":
|
|
327
|
+
case "refused-by-column":
|
|
328
|
+
case "refused-by-codec": return spans.attribute;
|
|
302
329
|
default: return writtenValueSpan(spans, refusal.elementIndex, subject);
|
|
303
330
|
}
|
|
304
331
|
}
|
|
@@ -448,8 +475,8 @@ function defaultFunctionCall(name, entry, dataTypes) {
|
|
|
448
475
|
}
|
|
449
476
|
/** The data type of the column a field declares, when its type, or the named type it is declared with, is a constructor the stack knows. */
|
|
450
477
|
function receivingDataType(ctx) {
|
|
451
|
-
const
|
|
452
|
-
return
|
|
478
|
+
const codecId = ctx.contributedType === void 0 ? void 0 : contributedTypeCodecId(ctx.contributedType, ctx.dataTypes);
|
|
479
|
+
return codecId === void 0 ? void 0 : ctx.dataTypes.dataTypeOfCodec(codecId);
|
|
453
480
|
}
|
|
454
481
|
/** Whether a value of `type` can be written for a column of `receiving`: it is that type, or the column's type casts from it. An unknown column takes every type. */
|
|
455
482
|
function receives(dataTypes, receiving, type) {
|
|
@@ -797,7 +824,7 @@ function fieldSpecContext(input) {
|
|
|
797
824
|
model: input.model,
|
|
798
825
|
field: input.field,
|
|
799
826
|
typeResolution,
|
|
800
|
-
|
|
827
|
+
contributedType: contributedTypeOf(typeResolution, input.binder, input.field.typeConstructor),
|
|
801
828
|
defaultFunctionRegistry: input.defaultFunctionRegistry,
|
|
802
829
|
generatorFunctions: input.generatorFunctions,
|
|
803
830
|
dataTypes: input.dataTypes
|
|
@@ -960,13 +987,6 @@ function jsonKind(value) {
|
|
|
960
987
|
if (typeof value === "object") return "a JSON object";
|
|
961
988
|
return `a JSON ${typeof value}`;
|
|
962
989
|
}
|
|
963
|
-
function argumentSpan(call, descriptors, index) {
|
|
964
|
-
if (index === void 0) return call.span;
|
|
965
|
-
const name = descriptors?.[index]?.name;
|
|
966
|
-
const named = call.args.find((arg) => arg.kind === "named" && arg.name === name);
|
|
967
|
-
const positional = call.args.filter((arg) => arg.kind === "positional")[index];
|
|
968
|
-
return (named ?? positional)?.span ?? call.span;
|
|
969
|
-
}
|
|
970
990
|
/**
|
|
971
991
|
* Checks the type parameters a constructor produced against its codec's parameter schema,
|
|
972
992
|
* reporting a failure at the argument the failing parameter came from. Returns whether they passed.
|
|
@@ -986,12 +1006,6 @@ function checkPslTypeParams(input) {
|
|
|
986
1006
|
return false;
|
|
987
1007
|
}
|
|
988
1008
|
}
|
|
989
|
-
function argumentIndexOf(error) {
|
|
990
|
-
if (typeof error !== "object" || error === null || !("details" in error)) return void 0;
|
|
991
|
-
const { details } = error;
|
|
992
|
-
if (typeof details !== "object" || details === null || !("argumentIndex" in details)) return;
|
|
993
|
-
return typeof details.argumentIndex === "number" ? details.argumentIndex : void 0;
|
|
994
|
-
}
|
|
995
1009
|
/**
|
|
996
1010
|
* Walks `authoringContributions.entityTypes` segment-by-segment and returns
|
|
997
1011
|
* the entity type descriptor at the resolved path, or `undefined` if no
|
|
@@ -1186,6 +1200,22 @@ function resolveFieldTypeDescriptor(input) {
|
|
|
1186
1200
|
case "contributedNamespace":
|
|
1187
1201
|
case "mixin": return NOT_RESOLVED;
|
|
1188
1202
|
case "contributedType": {
|
|
1203
|
+
if (isContributedTypeChoice(resolution.symbol)) {
|
|
1204
|
+
const instantiated = instantiatePslTypeChoice({
|
|
1205
|
+
symbol: resolution.symbol,
|
|
1206
|
+
call,
|
|
1207
|
+
span: field.span,
|
|
1208
|
+
codecLookup: input.codecLookup,
|
|
1209
|
+
diagnostics,
|
|
1210
|
+
source,
|
|
1211
|
+
entityLabel,
|
|
1212
|
+
dataTypes: input.dataTypes
|
|
1213
|
+
});
|
|
1214
|
+
return instantiated === void 0 ? NOT_RESOLVED : {
|
|
1215
|
+
ok: true,
|
|
1216
|
+
descriptor: instantiated
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1189
1219
|
const { descriptor, path } = resolution.symbol;
|
|
1190
1220
|
const written = path.join(".");
|
|
1191
1221
|
if (descriptor.kind === "typeAlias") {
|
|
@@ -1870,4 +1900,4 @@ function mergeExecutionDefaults(fromAttributes, fromTypeAlias) {
|
|
|
1870
1900
|
//#endregion
|
|
1871
1901
|
export { modelSpecContext as _, describeUnsupportedSqlAttribute as a, sqlAttributeSpecs as b, instantiateFieldTypeConstructor as c, interpretModelAttribute as d, lowerEnumDefault as f, modelCoordinateKey as g, modelAttributeSpecsFrom as h, defaultFunctionCall as i, instantiatePslTypeConstructor as l, lowerTypeGenerators as m, collectResolvedFields as n, fieldSpecContext as o, lowerTypeDefault as p, contractError as r, getAuthoringEntity as s, PSL_CHECK_ON_STI_VARIANT as t, interpretFieldAttribute as u, readDataTypeDefault as v, resolveFieldTypeDescriptor as y };
|
|
1872
1902
|
|
|
1873
|
-
//# sourceMappingURL=psl-field-resolution-
|
|
1903
|
+
//# sourceMappingURL=psl-field-resolution-BW2_FOb9-DxqR43fo.mjs.map
|