@prisma/orm-family-sql 8.0.0-rc.18-dev.18 → 8.0.0-rc.18-dev.19
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/{authoring-type-constructors-0Iv2zdwS-MFIpJ4fA.mjs → authoring-type-constructors-0Iv2zdwS-BJjO5EnA.mjs} +2 -2
- package/dist/{authoring-type-constructors-0Iv2zdwS-MFIpJ4fA.mjs.map → authoring-type-constructors-0Iv2zdwS-BJjO5EnA.mjs.map} +1 -1
- package/dist/{config-types-ComQZUlA.mjs → config-types-DopEiXtk.mjs} +2 -2
- package/dist/{config-types-ComQZUlA.mjs.map → config-types-DopEiXtk.mjs.map} +1 -1
- package/dist/{contract-builder-fQ3gkIR5.mjs → contract-builder-C1X8KoEM.mjs} +3 -3
- package/dist/{contract-builder-fQ3gkIR5.mjs.map → contract-builder-C1X8KoEM.mjs.map} +1 -1
- package/dist/contract-prisma7__provider.d.mts +3 -3
- package/dist/contract-prisma7__provider.d.mts.map +1 -1
- package/dist/contract-prisma7__provider.mjs +19 -47
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.mjs +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 +1 -1
- package/dist/contract__foreign-key-materialization.d.mts +1 -1
- package/dist/contract__foreign-key-materialization.mjs +2 -2
- package/dist/contract__validators.mjs +1 -1
- package/dist/{control-mpACqp72.d.mts → control-BqS5MMDh.d.mts} +21 -12
- package/dist/control-BqS5MMDh.d.mts.map +1 -0
- package/dist/{control-ClahTAD-.mjs → control-C7MNvu5Q.mjs} +27 -13
- package/dist/control-C7MNvu5Q.mjs.map +1 -0
- package/dist/{control-adapter-BCopdpsT-DIHCWbq_.d.mts → control-adapter-BCopdpsT-Bou0wWLF.d.mts} +3 -3
- package/dist/{control-adapter-BCopdpsT-DIHCWbq_.d.mts.map → control-adapter-BCopdpsT-Bou0wWLF.d.mts.map} +1 -1
- package/dist/control-adapter-CUwBiImd.d.mts +1 -0
- package/dist/{data-type-B8N33s-_.d.mts → data-type-DuzmTpzK.d.mts} +3 -3
- package/dist/{data-type-B8N33s-_.d.mts.map → data-type-DuzmTpzK.d.mts.map} +1 -1
- package/dist/{derived-checks-CrvMQTJF-DlxFFtNM.mjs → derived-checks-sRZp_gTF-UGwFWkVX.mjs} +7 -20
- package/dist/derived-checks-sRZp_gTF-UGwFWkVX.mjs.map +1 -0
- package/dist/{diff-Bd9ILpZL.d.mts → diff-D6PbCUWL.d.mts} +5 -5
- package/dist/{diff-Bd9ILpZL.d.mts.map → diff-D6PbCUWL.d.mts.map} +1 -1
- package/dist/family.d.mts +10 -10
- package/dist/family.mjs +6 -6
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +3 -3
- package/dist/family__control.mjs +2 -2
- package/dist/family__diff.d.mts +1 -1
- package/dist/family__ir.mjs +1 -1
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-build.d.mts +2 -2
- package/dist/family__psl-build.mjs +2 -2
- package/dist/family__psl-infer.d.mts +1 -1
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/{foreign-key-materialization-DfNPQL9G.mjs → foreign-key-materialization-BIvQTfz8.mjs} +2 -2
- package/dist/{foreign-key-materialization-DfNPQL9G.mjs.map → foreign-key-materialization-BIvQTfz8.mjs.map} +1 -1
- package/dist/{foreign-key-materialization-DCaDnUs-.d.mts → foreign-key-materialization-BiWTp2vi.d.mts} +3 -3
- package/dist/{foreign-key-materialization-DCaDnUs-.d.mts.map → foreign-key-materialization-BiWTp2vi.d.mts.map} +1 -1
- package/dist/{index-equivalence-DswCiq5l-BsphajRC.mjs → index-equivalence-DswCiq5l-Cp2V5nhL.mjs} +2 -2
- package/dist/{index-equivalence-DswCiq5l-BsphajRC.mjs.map → index-equivalence-DswCiq5l-Cp2V5nhL.mjs.map} +1 -1
- package/dist/{interpreter-CFj2aTEP-BHL3TOqk.mjs → interpreter-B9wNACvu-CjrIm-Jo.mjs} +5 -5
- package/dist/{interpreter-CFj2aTEP-BHL3TOqk.mjs.map → interpreter-B9wNACvu-CjrIm-Jo.mjs.map} +1 -1
- package/dist/{migration-lg_VgP_F.d.mts → migration-CJ0xK_7n.d.mts} +2 -2
- package/dist/{migration-lg_VgP_F.d.mts.map → migration-CJ0xK_7n.d.mts.map} +1 -1
- package/dist/psl-build-ClY62mZM.d.mts +157 -0
- package/dist/psl-build-ClY62mZM.d.mts.map +1 -0
- package/dist/{psl-build-BsJ6eChh.mjs → psl-build-pU0gKdVI.mjs} +146 -7
- package/dist/psl-build-pU0gKdVI.mjs.map +1 -0
- package/dist/{psl-field-resolution-o9sXqIlE-BJnlxQ4z.mjs → psl-field-resolution-BOJPyV5I-0zJJ0fOo.mjs} +20 -14
- package/dist/{psl-field-resolution-o9sXqIlE-BJnlxQ4z.mjs.map → psl-field-resolution-BOJPyV5I-0zJJ0fOo.mjs.map} +1 -1
- package/dist/{psl-infer-B6iemK9i.d.mts → psl-infer-1C9FqGO2.d.mts} +3 -3
- package/dist/{psl-infer-B6iemK9i.d.mts.map → psl-infer-1C9FqGO2.d.mts.map} +1 -1
- package/dist/{psl-infer-HPi_YMeE.mjs → psl-infer-CvUWefHM.mjs} +2 -2
- package/dist/{psl-infer-HPi_YMeE.mjs.map → psl-infer-CvUWefHM.mjs.map} +1 -1
- package/dist/{schema-differ-DmP74bB8-BGA6fzOv.d.mts → schema-differ-DmP74bB8-GfOUaGGy.d.mts} +3 -3
- package/dist/{schema-differ-DmP74bB8-BGA6fzOv.d.mts.map → schema-differ-DmP74bB8-GfOUaGGy.d.mts.map} +1 -1
- package/dist/schema-ir.d.mts +2 -2
- package/dist/schema-ir.mjs +1 -1
- package/dist/schema-ir__types.d.mts +3 -3
- package/dist/schema-ir__types.mjs +1 -1
- package/dist/{sql-contract-serializer-sMY3prTx-C8IEwSsf.mjs → sql-contract-serializer-sMY3prTx-BKQ4Yh-n.mjs} +2 -2
- package/dist/{sql-contract-serializer-sMY3prTx-C8IEwSsf.mjs.map → sql-contract-serializer-sMY3prTx-BKQ4Yh-n.mjs.map} +1 -1
- package/dist/{types-c1iIhJep-DdMj6TNl.d.mts → types-Bqe0AXuw-xqQnkIj4.d.mts} +25 -6
- package/dist/types-Bqe0AXuw-xqQnkIj4.d.mts.map +1 -0
- package/dist/types-CTdsm45r.d.mts +1 -0
- package/dist/{types-CaVn_xxe-D9WdU3Iy.mjs → types-CfPB-Kz_-ByWDfwMj.mjs} +31 -6
- package/dist/types-CfPB-Kz_-ByWDfwMj.mjs.map +1 -0
- package/dist/{types-DaYtBAYT-B22gkh5z.d.mts → types-DaYtBAYT-DbsbDMTk.d.mts} +4 -4
- package/dist/{types-DaYtBAYT-B22gkh5z.d.mts.map → types-DaYtBAYT-DbsbDMTk.d.mts.map} +1 -1
- package/dist/{validators-Bvfk0aN7.mjs → validators-V8vN9R85.mjs} +2 -2
- package/dist/{validators-Bvfk0aN7.mjs.map → validators-V8vN9R85.mjs.map} +1 -1
- package/package.json +18 -18
- package/dist/control-ClahTAD-.mjs.map +0 -1
- package/dist/control-adapter-BsSf5pqM.d.mts +0 -1
- package/dist/control-mpACqp72.d.mts.map +0 -1
- package/dist/derived-checks-CrvMQTJF-DlxFFtNM.mjs.map +0 -1
- package/dist/psl-build-BHQfP1_C.d.mts +0 -73
- package/dist/psl-build-BHQfP1_C.d.mts.map +0 -1
- package/dist/psl-build-BsJ6eChh.mjs.map +0 -1
- package/dist/types-BLyhYk6B.d.mts +0 -1
- package/dist/types-CaVn_xxe-D9WdU3Iy.mjs.map +0 -1
- package/dist/types-c1iIhJep-DdMj6TNl.d.mts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as SqlStorage } from "./sql-storage-tZhB8nS5-8NSWT0TW.mjs";
|
|
2
2
|
import "./types-DMfBh16_.mjs";
|
|
3
|
-
import { C as SqlPlanTargetDetails, d as SqlMigrationPlanOperation } from "./types-DaYtBAYT-
|
|
3
|
+
import { C as SqlPlanTargetDetails, d as SqlMigrationPlanOperation } from "./types-DaYtBAYT-DbsbDMTk.mjs";
|
|
4
4
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
5
5
|
import { Migration } from "@prisma/orm-toolchain/migration-tools/migration";
|
|
6
6
|
//#region ../../../2-sql/9-family/dist/migration.d.mts
|
|
@@ -41,4 +41,4 @@ declare abstract class SqlMigration<TDetails extends SqlPlanTargetDetails, TTarg
|
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
43
|
export { SqlMigration as t };
|
|
44
|
-
//# sourceMappingURL=migration-
|
|
44
|
+
//# sourceMappingURL=migration-CJ0xK_7n.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-
|
|
1
|
+
{"version":3,"file":"migration-CJ0xK_7n.d.mts","names":[],"sources":["../../../../2-sql/9-family/dist/migration.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0BuB,aAAa,iBAAiB,sBAAsB,mCAAmC,cAAc,SAAS,cAAc,SAAS,aAAa,YAAY,SAAS,cAAc,SAAS,qBAAqB,UAAU,0BAA0B,kBAAkB,WAAW,OAAO;;;;;;;;;;;MAW5S"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { u as SqlColumnIR } from "./types-Bqe0AXuw-xqQnkIj4.mjs";
|
|
2
|
+
import "./types-CTdsm45r.mjs";
|
|
3
|
+
import { n as SqlDataType, s as SqlTypeParams } from "./data-type-DuzmTpzK.mjs";
|
|
4
|
+
import "./default-mapping-CEISdj2g-DF1LzGBR.mjs";
|
|
5
|
+
import { AuthoringTypeConstructorCall, AuthoringTypeConstructorDescriptor, AuthoringTypeNamespace, FieldPresetsByCodecAndGenerator, PrintableFieldPreset } from "@prisma/orm-framework/components/authoring";
|
|
6
|
+
import { CodecLookupWithDescriptors, DataTypeLookup } from "@prisma/orm-framework/components/codec";
|
|
7
|
+
import { ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue } from "@prisma/orm-framework/contract/types";
|
|
8
|
+
import { DefaultFunctionPrinter } from "@prisma/orm-framework/components/control";
|
|
9
|
+
//#region ../../../2-sql/9-family/dist/psl-build.d.mts
|
|
10
|
+
//#region src/core/psl-build/inferred-type-constructors.d.ts
|
|
11
|
+
/** The type constructor `contract infer` writes for a data type, with the data type it produces. */
|
|
12
|
+
interface InferredTypeConstructor {
|
|
13
|
+
readonly path: readonly string[];
|
|
14
|
+
readonly descriptor: AuthoringTypeConstructorDescriptor;
|
|
15
|
+
readonly dataType: SqlDataType;
|
|
16
|
+
}
|
|
17
|
+
/** The constructors marked `inferred` in a stack, keyed by the id of the data type each produces. */
|
|
18
|
+
type InferredTypeConstructors = ReadonlyMap<string, InferredTypeConstructor>;
|
|
19
|
+
/** Every constructor of `authoringTypes` marked `inferred`, by the data type its codec represents. */
|
|
20
|
+
declare function inferredTypeConstructors(input: {
|
|
21
|
+
readonly authoringTypes: AuthoringTypeNamespace;
|
|
22
|
+
readonly codecLookup: Pick<CodecLookupWithDescriptors, 'descriptorFor'>;
|
|
23
|
+
readonly dataTypeLookup: DataTypeLookup;
|
|
24
|
+
}): InferredTypeConstructors;
|
|
25
|
+
/**
|
|
26
|
+
* The call to `marked` with the fewest arguments that produces `params`, the normal form of a
|
|
27
|
+
* column's data type parameters: arguments are dropped from the end while the normal form of what
|
|
28
|
+
* the call produces stays `params`. Undefined when the constructor cannot produce them, such as one
|
|
29
|
+
* whose argument names another entity.
|
|
30
|
+
*/
|
|
31
|
+
declare function fewestArgumentsCall(marked: InferredTypeConstructor, params: SqlTypeParams): AuthoringTypeConstructorCall | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* A type constructor argument as PSL writes it: a number or boolean as written, a string between quotes.
|
|
34
|
+
* Undefined for any other value, such as an array or an object, and for a string PSL cannot carry, because a quote, backslash or line break in it would read back differently.
|
|
35
|
+
*/
|
|
36
|
+
declare function pslTypeArgumentText(value: unknown): string | undefined;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/core/psl-build/column-types.d.ts
|
|
39
|
+
/** A call to a type constructor as PSL writes it: the constructor's path and its arguments' text. */
|
|
40
|
+
interface PslTypeCall {
|
|
41
|
+
readonly path: readonly string[];
|
|
42
|
+
readonly args: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/** The PSL type `contract infer` writes for a column that is not an enum, by table and column name. */
|
|
45
|
+
type ColumnTypeOf = (tableName: string, columnName: string) => PslTypeCall;
|
|
46
|
+
/** One introspected table, with the schema it was read from. */
|
|
47
|
+
interface IntrospectedTable {
|
|
48
|
+
readonly schemaName: string;
|
|
49
|
+
readonly tableName: string;
|
|
50
|
+
readonly columns: readonly SqlColumnIR[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
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.
|
|
57
|
+
*/
|
|
58
|
+
declare function inferColumnTypes(input: {
|
|
59
|
+
readonly tables: readonly IntrospectedTable[];
|
|
60
|
+
readonly constructors: InferredTypeConstructors;
|
|
61
|
+
readonly isEnumColumn: (column: SqlColumnIR) => boolean;
|
|
62
|
+
}): ColumnTypeOf;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/core/psl-build/generated-values.d.ts
|
|
65
|
+
/** The PSL call of the default function that produces `generatorId` with `params`, or `undefined` when no default function in the stack writes it. */
|
|
66
|
+
declare function defaultFunctionCallFor(defaultFunctionPrintersByGenerator: ReadonlyMap<string, DefaultFunctionPrinter>, generatorId: string, params: Readonly<Record<string, unknown>> | undefined): string | undefined;
|
|
67
|
+
type FieldPresetArgument = {
|
|
68
|
+
readonly kind: 'positional';
|
|
69
|
+
readonly value: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'named';
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly value: string;
|
|
74
|
+
};
|
|
75
|
+
type ColumnPhase = 'onCreate' | 'onUpdate';
|
|
76
|
+
/**
|
|
77
|
+
* What a column's PSL type stands for. `dataType` is a type that stands for the column's codec and type params alone, written as a bare name such as `String` or a call such as `Timestamptz(3)`. A named type, a value object or an enum, including a native enum written `pg.enum(<Block>)`, names something more.
|
|
78
|
+
*/
|
|
79
|
+
type PslColumnTypeKind = 'dataType' | 'namedType' | 'valueObject' | 'enum';
|
|
80
|
+
/** The name a column's PSL type is written with, and what it stands for. */
|
|
81
|
+
interface PslColumnTypeRef {
|
|
82
|
+
readonly kind: PslColumnTypeKind;
|
|
83
|
+
readonly typeName: string;
|
|
84
|
+
}
|
|
85
|
+
/** Why the call of the preset that writes a column's codec with its generators cannot be written. */
|
|
86
|
+
type FieldPresetUnwritableReason = {
|
|
87
|
+
readonly kind: 'columnType';
|
|
88
|
+
readonly columnType: Exclude<PslColumnTypeKind, 'dataType'>;
|
|
89
|
+
readonly typeName: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: 'list';
|
|
92
|
+
} | {
|
|
93
|
+
readonly kind: 'phasesNotWrittenTogether';
|
|
94
|
+
} | {
|
|
95
|
+
readonly kind: 'unwritableArgument';
|
|
96
|
+
readonly argument: string;
|
|
97
|
+
readonly value: unknown;
|
|
98
|
+
} | {
|
|
99
|
+
readonly kind: 'argumentsRejected';
|
|
100
|
+
readonly message: string;
|
|
101
|
+
};
|
|
102
|
+
/** A part of the column the preset call, once written, reads back differently. */
|
|
103
|
+
type FieldPresetReadBackDifference = {
|
|
104
|
+
readonly part: 'codecId';
|
|
105
|
+
readonly column: string;
|
|
106
|
+
readonly printed: string;
|
|
107
|
+
} | {
|
|
108
|
+
readonly part: 'typeParams';
|
|
109
|
+
readonly column: Readonly<Record<string, unknown>> | undefined;
|
|
110
|
+
readonly printed: Readonly<Record<string, unknown>> | undefined;
|
|
111
|
+
} | {
|
|
112
|
+
readonly part: ColumnPhase;
|
|
113
|
+
readonly column: ExecutionMutationDefaultValue | undefined;
|
|
114
|
+
readonly printed: ExecutionMutationDefaultValue | undefined;
|
|
115
|
+
};
|
|
116
|
+
/** How a column's generators are written with a field preset, or why they cannot be. */
|
|
117
|
+
type FieldPresetCallChoice = {
|
|
118
|
+
readonly kind: 'noPreset';
|
|
119
|
+
} | {
|
|
120
|
+
readonly kind: 'call';
|
|
121
|
+
readonly preset: PrintableFieldPreset;
|
|
122
|
+
readonly arguments: readonly FieldPresetArgument[];
|
|
123
|
+
} | {
|
|
124
|
+
readonly kind: 'cannotWrite';
|
|
125
|
+
readonly preset: PrintableFieldPreset;
|
|
126
|
+
readonly reason: FieldPresetUnwritableReason;
|
|
127
|
+
} | {
|
|
128
|
+
readonly kind: 'readsBackDifferently';
|
|
129
|
+
readonly preset: PrintableFieldPreset;
|
|
130
|
+
readonly differences: readonly FieldPresetReadBackDifference[];
|
|
131
|
+
};
|
|
132
|
+
interface FieldPresetColumn {
|
|
133
|
+
readonly codecId: string;
|
|
134
|
+
readonly pslType: PslColumnTypeRef;
|
|
135
|
+
readonly list: boolean;
|
|
136
|
+
readonly typeParams: Readonly<Record<string, unknown>> | undefined;
|
|
137
|
+
readonly generators: ExecutionMutationDefaultPhases;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The call of the field preset in the stack that writes a column's codec with its generators. The call is written only for a column that is not a list and whose PSL type stands for its data type, which the preset call takes the place of, and when the preset accepts its arguments as the PSL reader checks them; it is then checked to read back with the column's codec, type params and generators with their params, where absent and empty params count as the same. Otherwise the reason it cannot be written that way.
|
|
141
|
+
*/
|
|
142
|
+
declare function fieldPresetCallFor(input: {
|
|
143
|
+
readonly fieldPresetsByCodecAndGenerator: FieldPresetsByCodecAndGenerator;
|
|
144
|
+
readonly column: FieldPresetColumn;
|
|
145
|
+
}): FieldPresetCallChoice;
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/core/psl-build/psl-names.d.ts
|
|
148
|
+
/**
|
|
149
|
+
* PSL member name for a native-enum value. The value itself always prints
|
|
150
|
+
* explicitly (`member = "value"`), so the returned name never needs a map:
|
|
151
|
+
* a value that already is a valid, non-reserved identifier is kept verbatim
|
|
152
|
+
* (case included); anything else is camelCased/escaped like a field name.
|
|
153
|
+
*/
|
|
154
|
+
declare function toEnumMemberName(value: string): string;
|
|
155
|
+
//#endregion
|
|
156
|
+
export { pslTypeArgumentText as _, FieldPresetUnwritableReason as a, IntrospectedTable as c, PslTypeCall as d, defaultFunctionCallFor as f, inferredTypeConstructors as g, inferColumnTypes as h, FieldPresetReadBackDifference as i, PslColumnTypeKind as l, fieldPresetCallFor as m, FieldPresetArgument as n, InferredTypeConstructor as o, fewestArgumentsCall as p, FieldPresetCallChoice as r, InferredTypeConstructors as s, ColumnTypeOf as t, PslColumnTypeRef as u, toEnumMemberName as v };
|
|
157
|
+
//# sourceMappingURL=psl-build-ClY62mZM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psl-build-ClY62mZM.d.mts","names":[],"sources":["../../../../2-sql/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;;;;;iBAK7E,oBAAoB;;;;UAI3B;WACC;WACA;;;KAGN,gBAAgB,mBAAmB,uBAAuB;;UAErD;WACC;WACA;WACA,kBAAkB;;;;;;;;iBAQZ,iBAAiB;WACvB,iBAAiB;WACjB,cAAc;WACd,eAAe,QAAQ;IAC9B;;;;iBAIa,uBAAuB,oCAAoC,oBAAoB,yBAAyB,qBAAqB,QAAQ,SAAS;KAC1J;WACM;WACA;;WAEA;WACA;WACA;;KAEN;;;;KAIA;;UAEK;WACC,MAAM;WACN;;;KAGN;WACM;WACA,YAAY,QAAQ;WACpB;;WAEA;;WAEA;;WAEA;WACA;WACA;;WAEA;WACA;;;KAGN;WACM;WACA;WACA;;WAEA;WACA,QAAQ,SAAS;WACjB,SAAS,SAAS;;WAElB,MAAM;WACN,QAAQ;WACR,SAAS;;;KAGf;WACM;;WAEA;WACA,QAAQ;WACR,oBAAoB;;WAEpB;WACA,QAAQ;WACR,QAAQ;;WAER;WACA,QAAQ;WACR,sBAAsB;;UAEvB;WACC;WACA,SAAS;WACT;WACA,YAAY,SAAS;WACrB,YAAY;;;;;iBAKN,mBAAmB;WACzB,iCAAiC;WACjC,QAAQ;IACf;;;;;;;;;iBASa,iBAAiB"}
|
|
@@ -3,9 +3,10 @@ import { t as numeralText } from "./data-type-DKk8Unnz.mjs";
|
|
|
3
3
|
import { r as escapePslString } from "./data-type-support-C5-XxxeB.mjs";
|
|
4
4
|
import "./sql-expression-BJCuy-WI.mjs";
|
|
5
5
|
import { t as sqlFamilyError } from "./errors-B5g0xWro-mWH2C07F.mjs";
|
|
6
|
-
import { authoringTypeConstructorArguments, authoringTypeConstructors, castTypedValue, instantiateAuthoringTypeConstructor, printTaggedLiteral, readWrittenValue } from "@prisma/orm-framework/components/authoring";
|
|
6
|
+
import { authoringTypeConstructorArguments, authoringTypeConstructors, castTypedValue, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, printTaggedLiteral, readWrittenValue, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
|
|
7
7
|
import { dataTypeId, dataTypeParams } from "@prisma/orm-framework/components/codec";
|
|
8
8
|
import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
9
|
+
import { isRuntimeError } from "@prisma/orm-framework/components/components";
|
|
9
10
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
10
11
|
//#region ../../../2-sql/9-family/dist/psl-build.mjs
|
|
11
12
|
/** Every constructor of `authoringTypes` marked `inferred`, by the data type its codec represents. */
|
|
@@ -55,12 +56,12 @@ function fewestArgumentsCall(marked, params) {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
|
-
* A type constructor argument as PSL writes it: a number as written, a string between quotes.
|
|
59
|
-
* Undefined for a string PSL cannot carry, because a quote, backslash or line break in it would read
|
|
60
|
-
* back differently.
|
|
59
|
+
* A type constructor argument as PSL writes it: a number or boolean as written, a string between quotes.
|
|
60
|
+
* Undefined for any other value, such as an array or an object, and for a string PSL cannot carry, because a quote, backslash or line break in it would read back differently.
|
|
61
61
|
*/
|
|
62
62
|
function pslTypeArgumentText(value) {
|
|
63
|
-
if (typeof value
|
|
63
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
64
|
+
if (typeof value !== "string") return void 0;
|
|
64
65
|
return escapePslString(value) === value ? `"${value}"` : void 0;
|
|
65
66
|
}
|
|
66
67
|
/** The type the database reported for `column`, which introspection always records. */
|
|
@@ -356,7 +357,145 @@ function sameForm(left, right) {
|
|
|
356
357
|
return other !== void 0 && sameForm(member, other);
|
|
357
358
|
});
|
|
358
359
|
}
|
|
360
|
+
/** The PSL call of the default function that produces `generatorId` with `params`, or `undefined` when no default function in the stack writes it. */
|
|
361
|
+
function defaultFunctionCallFor(defaultFunctionPrintersByGenerator, generatorId, params) {
|
|
362
|
+
const printer = defaultFunctionPrintersByGenerator.get(generatorId);
|
|
363
|
+
return printer === void 0 ? void 0 : `${printer.functionName}(${printer.printArguments(params)})`;
|
|
364
|
+
}
|
|
365
|
+
const PHASES = ["onCreate", "onUpdate"];
|
|
366
|
+
function sameParams(left, right) {
|
|
367
|
+
return canonicalizeJson(left ?? {}) === canonicalizeJson(right ?? {});
|
|
368
|
+
}
|
|
369
|
+
function sameGenerator(left, right) {
|
|
370
|
+
if (left === void 0 || right === void 0) return left === right;
|
|
371
|
+
return left.id === right.id && sameParams(left.params, right.params);
|
|
372
|
+
}
|
|
373
|
+
function writesEveryPhase(printForm, column) {
|
|
374
|
+
return PHASES.every((phase) => {
|
|
375
|
+
const generatorId = column.generators[phase]?.id;
|
|
376
|
+
return generatorId === void 0 || printForm[phase]?.valuesByGenerator.has(generatorId);
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function writtenArguments(printForm, column) {
|
|
380
|
+
const positional = [];
|
|
381
|
+
for (const [index, name] of printForm.typeParams.entries()) {
|
|
382
|
+
const value = column.typeParams?.[name];
|
|
383
|
+
if (value === void 0) break;
|
|
384
|
+
const text = pslTypeArgumentText(value);
|
|
385
|
+
if (text === void 0) return {
|
|
386
|
+
kind: "unwritable",
|
|
387
|
+
argument: name,
|
|
388
|
+
value
|
|
389
|
+
};
|
|
390
|
+
positional.push({
|
|
391
|
+
index,
|
|
392
|
+
value,
|
|
393
|
+
argument: {
|
|
394
|
+
kind: "positional",
|
|
395
|
+
value: text
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
const named = PHASES.flatMap((phase) => {
|
|
400
|
+
const phasePrintForm = printForm[phase];
|
|
401
|
+
const generatorId = column.generators[phase]?.id;
|
|
402
|
+
const value = generatorId === void 0 ? void 0 : phasePrintForm?.valuesByGenerator.get(generatorId);
|
|
403
|
+
if (phasePrintForm === void 0 || value === void 0) return [];
|
|
404
|
+
const { argument: name, index } = phasePrintForm;
|
|
405
|
+
return [{
|
|
406
|
+
index,
|
|
407
|
+
value,
|
|
408
|
+
argument: {
|
|
409
|
+
kind: "named",
|
|
410
|
+
name,
|
|
411
|
+
value
|
|
412
|
+
}
|
|
413
|
+
}];
|
|
414
|
+
});
|
|
415
|
+
return {
|
|
416
|
+
kind: "written",
|
|
417
|
+
arguments: [...positional, ...named]
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function rejectionOf(preset, args) {
|
|
421
|
+
try {
|
|
422
|
+
validateAuthoringHelperArguments(preset.path.join("."), preset.descriptor.args, args);
|
|
423
|
+
return;
|
|
424
|
+
} catch (error) {
|
|
425
|
+
if (isRuntimeError(error) && error.code === "CONTRACT.ARGUMENT_INVALID") return error.message;
|
|
426
|
+
throw error;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function readBackDifferences(preset, column, args) {
|
|
430
|
+
const printed = instantiateAuthoringFieldPreset(preset.descriptor, args);
|
|
431
|
+
const printedGenerators = printed.executionDefaults ?? {};
|
|
432
|
+
return [
|
|
433
|
+
...printed.descriptor.codecId === column.codecId ? [] : [{
|
|
434
|
+
part: "codecId",
|
|
435
|
+
column: column.codecId,
|
|
436
|
+
printed: printed.descriptor.codecId
|
|
437
|
+
}],
|
|
438
|
+
...sameParams(column.typeParams, printed.descriptor.typeParams) ? [] : [{
|
|
439
|
+
part: "typeParams",
|
|
440
|
+
column: column.typeParams,
|
|
441
|
+
printed: printed.descriptor.typeParams
|
|
442
|
+
}],
|
|
443
|
+
...PHASES.flatMap((phase) => sameGenerator(column.generators[phase], printedGenerators[phase]) ? [] : [{
|
|
444
|
+
part: phase,
|
|
445
|
+
column: column.generators[phase],
|
|
446
|
+
printed: printedGenerators[phase]
|
|
447
|
+
}])
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
function cannotWrite(preset, reason) {
|
|
451
|
+
return {
|
|
452
|
+
kind: "cannotWrite",
|
|
453
|
+
preset,
|
|
454
|
+
reason
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* The call of the field preset in the stack that writes a column's codec with its generators. The call is written only for a column that is not a list and whose PSL type stands for its data type, which the preset call takes the place of, and when the preset accepts its arguments as the PSL reader checks them; it is then checked to read back with the column's codec, type params and generators with their params, where absent and empty params count as the same. Otherwise the reason it cannot be written that way.
|
|
459
|
+
*/
|
|
460
|
+
function fieldPresetCallFor(input) {
|
|
461
|
+
const { column } = input;
|
|
462
|
+
const byGenerator = input.fieldPresetsByCodecAndGenerator.get(column.codecId);
|
|
463
|
+
const preset = PHASES.map((phase) => column.generators[phase]?.id).map((generatorId) => generatorId === void 0 ? void 0 : byGenerator?.get(generatorId)).find((found) => found !== void 0);
|
|
464
|
+
if (preset === void 0) return { kind: "noPreset" };
|
|
465
|
+
const { pslType } = column;
|
|
466
|
+
if (pslType.kind !== "dataType") return cannotWrite(preset, {
|
|
467
|
+
kind: "columnType",
|
|
468
|
+
columnType: pslType.kind,
|
|
469
|
+
typeName: pslType.typeName
|
|
470
|
+
});
|
|
471
|
+
if (column.list) return cannotWrite(preset, { kind: "list" });
|
|
472
|
+
if (!writesEveryPhase(preset.printForm, column)) return cannotWrite(preset, { kind: "phasesNotWrittenTogether" });
|
|
473
|
+
const written = writtenArguments(preset.printForm, column);
|
|
474
|
+
if (written.kind === "unwritable") return cannotWrite(preset, {
|
|
475
|
+
kind: "unwritableArgument",
|
|
476
|
+
argument: written.argument,
|
|
477
|
+
value: written.value
|
|
478
|
+
});
|
|
479
|
+
const args = [];
|
|
480
|
+
for (const { index, value } of written.arguments) args[index] = value;
|
|
481
|
+
const rejection = rejectionOf(preset, args);
|
|
482
|
+
if (rejection !== void 0) return cannotWrite(preset, {
|
|
483
|
+
kind: "argumentsRejected",
|
|
484
|
+
message: rejection
|
|
485
|
+
});
|
|
486
|
+
const differences = readBackDifferences(preset, column, args);
|
|
487
|
+
if (differences.length > 0) return {
|
|
488
|
+
kind: "readsBackDifferently",
|
|
489
|
+
preset,
|
|
490
|
+
differences
|
|
491
|
+
};
|
|
492
|
+
return {
|
|
493
|
+
kind: "call",
|
|
494
|
+
preset,
|
|
495
|
+
arguments: written.arguments.map(({ argument }) => argument)
|
|
496
|
+
};
|
|
497
|
+
}
|
|
359
498
|
//#endregion
|
|
360
|
-
export {
|
|
499
|
+
export { inferredTypeConstructors as a, inferColumnTypes as i, fewestArgumentsCall as n, mapDefault as o, fieldPresetCallFor as r, pslTypeArgumentText as s, defaultFunctionCallFor as t };
|
|
361
500
|
|
|
362
|
-
//# sourceMappingURL=psl-build-
|
|
501
|
+
//# sourceMappingURL=psl-build-pU0gKdVI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psl-build-pU0gKdVI.mjs","names":[],"sources":["../../../../2-sql/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 { SQL_EXPRESSION_TAG } from \"@internal/sql-contract/sql-expression\";\nimport { authoringTypeConstructorArguments, authoringTypeConstructors, castTypedValue, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, printTaggedLiteral, readWrittenValue, validateAuthoringHelperArguments } from \"@internal/framework-components/authoring\";\nimport { dataTypeId, dataTypeParams } from \"@internal/framework-components/codec\";\nimport { InternalError, isInternalError } from \"@internal/utils/internal-error\";\nimport { isRuntimeError } from \"@internal/framework-components/components\";\nimport { isSqlDataType, numeralText, resolveReportedSqlType } from \"@internal/sql-contract/data-type\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { escapePslString } from \"@internal/sql-contract/data-type-support\";\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* A type constructor argument as PSL writes it: a number or boolean as written, a string between quotes.\n* Undefined for any other value, such as an array or an object, and for a string PSL cannot carry, because a quote, backslash or line break in it would read back differently.\n*/\nfunction pslTypeArgumentText(value) {\n\tif (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n\tif (typeof value !== \"string\") return void 0;\n\treturn escapePslString(value) === value ? `\"${value}\"` : void 0;\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}\nfunction writtenCall(constructors, dataTypes, reported) {\n\tconst resolved = resolveReportedSqlType(reported, dataTypes);\n\tconst marked = resolved && constructors.get(resolved.dataType);\n\tconst call = resolved && marked && fewestArgumentsCall(marked, resolved.typeParams);\n\tif (call === void 0) return void 0;\n\tconst args = call.args.map(pslTypeArgumentText);\n\treturn args.every((arg) => arg !== void 0) ? {\n\t\tpath: call.path,\n\t\targs\n\t} : void 0;\n}\n/**\n* The type of every column of `tables` that `isEnumColumn` does not claim: the call, with the\n* fewest arguments, to the constructor marked `inferred` for the data type that claims the\n* column's reported type. When any column has no such call, throws\n* `CONTRACT.INFER_COLUMN_TYPE_UNCLAIMED` listing every one of them.\n*/\nfunction 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 call = writtenCall(input.constructors, dataTypes, reported);\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 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 = writeDefaultLiteral(columnDefault.value, options);\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}\nfunction writingSurface(support) {\n\tconst entryOf = /* @__PURE__ */ new Map();\n\tconst tagTypes = [];\n\tfor (const [key, entry] of Object.entries(support.entries)) {\n\t\tconst written = entry.written;\n\t\tif (written.kind === \"tag\") {\n\t\t\tconst type = dataTypeId(key);\n\t\t\tif (!entryOf.has(type)) entryOf.set(type, entry);\n\t\t\ttagTypes.push(type);\n\t\t\tcontinue;\n\t\t}\n\t\tif (written.syntax === \"number\") {\n\t\t\tfor (const type of written.types) entryOf.set(type, entry);\n\t\t\tcontinue;\n\t\t}\n\t\tentryOf.set(key, entry);\n\t}\n\treturn {\n\t\tsupport,\n\t\tentryOf,\n\t\ttagTypes\n\t};\n}\nfunction readValue(surface, written) {\n\tconst read = readWrittenValue(surface.support, written);\n\treturn read.ok ? read.value : void 0;\n}\n/** The value of a tag's type that a stored document is, constructed by that type. */\nfunction tagValue(surface, type, value) {\n\ttry {\n\t\treturn surface.support.lookup.get(type)?.valueFrom(value, {});\n\t} catch (error) {\n\t\tif (isInternalError(error)) throw error;\n\t\treturn;\n\t}\n}\n/**\n* Every value the stored form could be, in the order a written value would be read: a number or\n* numeral text through the number entry first, then the plain syntax that matches the shape, then\n* each tag, whose stored form is a whole document, which may itself be a number or a boolean.\n*/\nfunction classifications(value, surface) {\n\tconst found = [];\n\tif (typeof value === \"number\") found.push(readValue(surface, {\n\t\tkind: \"number\",\n\t\ttext: numeralText(value)\n\t}));\n\telse if (typeof value === \"boolean\") found.push(readValue(surface, {\n\t\tkind: \"boolean\",\n\t\tvalue\n\t}));\n\telse if (typeof value === \"string\") {\n\t\tfound.push(readValue(surface, {\n\t\t\tkind: \"number\",\n\t\t\ttext: value\n\t\t}));\n\t\tfound.push(readValue(surface, {\n\t\t\tkind: \"string\",\n\t\t\ttext: value\n\t\t}));\n\t}\n\tfor (const type of surface.tagTypes) found.push(tagValue(surface, type, value));\n\treturn found.filter((candidate) => candidate !== void 0);\n}\n/** What the column's type stores for `json` under the column's parameters, or `undefined` when it holds no such value. */\nfunction storedUnder(json, column, lookup) {\n\tconst type = lookup.get(column.id);\n\tif (type === void 0) return void 0;\n\ttry {\n\t\treturn type.toContract(type.valueFrom(json, column.params));\n\t} catch (error) {\n\t\tif (isInternalError(error)) throw error;\n\t\treturn;\n\t}\n}\n/** The stored form the column takes this value as, spelled as its parameters give it, or `undefined` when its type takes no such value. */\nfunction admitted(candidate, column, surface) {\n\tconst cast = castTypedValue(surface.support, column.id, column.params, candidate);\n\treturn cast.ok ? cast.value.value : void 0;\n}\n/** The text of the literal: what the entry prints, before the syntax that fences it. */\nfunction printedText(entry, value) {\n\ttry {\n\t\treturn entry.print(value);\n\t} catch {\n\t\treturn;\n\t}\n}\n/** The printed text as the entry's syntax writes it, for reading back. */\nfunction writtenAs(entry, text) {\n\tconst written = entry.written;\n\tif (written.kind === \"tag\") return {\n\t\tkind: \"tag\",\n\t\ttag: written.tag,\n\t\ttext\n\t};\n\tif (written.syntax !== \"boolean\") return {\n\t\tkind: written.syntax,\n\t\ttext\n\t};\n\treturn text === \"true\" || text === \"false\" ? {\n\t\tkind: \"boolean\",\n\t\tvalue: text === \"true\"\n\t} : void 0;\n}\n/** What the printed text reads back as, through the same read a written value takes. */\nfunction readBack(surface, entry, text) {\n\tconst written = writtenAs(entry, text);\n\treturn written === void 0 ? void 0 : readValue(surface, written);\n}\nfunction literalText(entry, text) {\n\tconst written = entry.written;\n\tif (written.kind === \"tag\") return printTaggedLiteral(written.tag, text);\n\treturn written.syntax === \"string\" ? `\"${escapePslString(text)}\"` : text;\n}\n/**\n* The value written as the literal of one of its types, proven by reading the text straight back:\n* the same read, the same cast, and the stored form again. A number is tried first without the\n* trailing fraction zeros the column's scale spells it with.\n*/\nfunction writeScalar(value, column, surface) {\n\tconst shortest = withoutTrailingFractionZeros(value);\n\tconst candidates = [...shortest === void 0 ? [] : classifications(shortest, surface), ...classifications(value, surface)];\n\tfor (const candidate of candidates) {\n\t\tconst entry = surface.entryOf.get(candidate.type);\n\t\tif (entry === void 0) continue;\n\t\tconst stored = admitted(candidate, column, surface);\n\t\tif (stored === void 0 || !sameForm(stored, value)) continue;\n\t\tconst text = printedText(entry, candidate.value);\n\t\tif (text === void 0) continue;\n\t\tconst reread = readBack(surface, entry, text);\n\t\tif (reread === void 0) continue;\n\t\tconst restored = admitted(reread, column, surface);\n\t\tif (restored === void 0 || !sameForm(restored, value)) continue;\n\t\treturn literalText(entry, text);\n\t}\n}\nconst DECIMAL_WITH_FRACTION = /^-?\\d+\\.\\d+$/;\nfunction withoutTrailingFractionZeros(value) {\n\tif (typeof value !== \"string\" || !DECIMAL_WITH_FRACTION.test(value)) return void 0;\n\tconst shortened = value.replace(/0+$/, \"\").replace(/\\.$/, \"\");\n\treturn shortened === value ? void 0 : shortened;\n}\n/** One written element of a list, printed as a value of any type, with no column type to admit it. */\nfunction writeElement(value, of, surface) {\n\tfor (const candidate of classifications(value, surface)) {\n\t\tif (!of.includes(candidate.type)) continue;\n\t\tconst entry = surface.entryOf.get(candidate.type);\n\t\tif (entry === void 0) continue;\n\t\tconst text = printedText(entry, candidate.value);\n\t\tif (text === void 0) continue;\n\t\tconst reread = readBack(surface, entry, text);\n\t\tif (reread === void 0 || !of.includes(reread.type)) continue;\n\t\treturn {\n\t\t\ttext: literalText(entry, text),\n\t\t\tvalue: reread.value\n\t\t};\n\t}\n}\n/**\n* A written list on a scalar column, which the column type's list cast turns into its one value,\n* constructed by the column's type. Each element is classified on its own and must be of a type the\n* cast takes.\n*/\nfunction writeListCast(value, column, surface) {\n\tconst listCast = surface.support.lookup.get(column.id)?.listCast;\n\tif (listCast === void 0) return void 0;\n\tconst parts = [];\n\tconst elements = [];\n\tfor (const element of value) {\n\t\tconst written = writeElement(element, listCast.of, surface);\n\t\tif (written === void 0) return void 0;\n\t\tparts.push(written.text);\n\t\telements.push(written.value);\n\t}\n\tlet cast;\n\ttry {\n\t\tcast = listCast.cast(elements);\n\t} catch (error) {\n\t\tif (isInternalError(error)) throw error;\n\t\treturn;\n\t}\n\tconst stored = storedUnder(cast, column, surface.support.lookup);\n\treturn stored !== void 0 && sameForm(stored, value) ? `[${parts.join(\", \")}]` : void 0;\n}\nfunction writeDefaultLiteral(value, options) {\n\tif (value instanceof Date) return void 0;\n\tconst { dataTypes, columnCodec } = options ?? {};\n\tif (dataTypes === void 0 || columnCodec === void 0) return void 0;\n\tconst { lookup } = dataTypes;\n\tconst columnDataType = columnCodec.dataType;\n\tconst columnType = lookup.get(columnDataType);\n\tconst column = {\n\t\tid: columnDataType,\n\t\tparams: columnType === void 0 ? {} : dataTypeParams(columnType, options?.typeParams)\n\t};\n\tconst surface = writingSurface(dataTypes);\n\tif (options?.list === true) {\n\t\tif (!Array.isArray(value)) return void 0;\n\t\tconst parts = [];\n\t\tfor (const element of value) {\n\t\t\tconst written = writeScalar(element, column, surface);\n\t\t\tif (written === void 0) return void 0;\n\t\t\tparts.push(written);\n\t\t}\n\t\treturn `[${parts.join(\", \")}]`;\n\t}\n\tconst written = writeScalar(value, column, surface);\n\tif (written !== void 0) return written;\n\treturn Array.isArray(value) ? writeListCast(value, column, surface) : void 0;\n}\n/** Whether two stored forms are the same JSON value, member by member and element by element. */\nfunction sameForm(left, right) {\n\tif (left === right) return true;\n\tif (Array.isArray(left) !== Array.isArray(right)) return false;\n\tif (typeof left !== \"object\" || typeof right !== \"object\" || left === null || right === null) return false;\n\tconst members = Object.entries(left);\n\tconst others = new Map(Object.entries(right));\n\treturn members.length === others.size && members.every(([key, member]) => {\n\t\tconst other = others.get(key);\n\t\treturn other !== void 0 && sameForm(member, other);\n\t});\n}\n//#endregion\n//#region src/core/psl-build/generated-values.ts\n/** The PSL call of the default function that produces `generatorId` with `params`, or `undefined` when no default function in the stack writes it. */\nfunction defaultFunctionCallFor(defaultFunctionPrintersByGenerator, generatorId, params) {\n\tconst printer = defaultFunctionPrintersByGenerator.get(generatorId);\n\treturn printer === void 0 ? void 0 : `${printer.functionName}(${printer.printArguments(params)})`;\n}\nconst PHASES = [\"onCreate\", \"onUpdate\"];\nfunction sameParams(left, right) {\n\treturn canonicalizeJson(left ?? {}) === canonicalizeJson(right ?? {});\n}\nfunction sameGenerator(left, right) {\n\tif (left === void 0 || right === void 0) return left === right;\n\treturn left.id === right.id && sameParams(left.params, right.params);\n}\nfunction writesEveryPhase(printForm, column) {\n\treturn PHASES.every((phase) => {\n\t\tconst generatorId = column.generators[phase]?.id;\n\t\treturn generatorId === void 0 || printForm[phase]?.valuesByGenerator.has(generatorId);\n\t});\n}\nfunction writtenArguments(printForm, column) {\n\tconst positional = [];\n\tfor (const [index, name] of printForm.typeParams.entries()) {\n\t\tconst value = column.typeParams?.[name];\n\t\tif (value === void 0) break;\n\t\tconst text = pslTypeArgumentText(value);\n\t\tif (text === void 0) return {\n\t\t\tkind: \"unwritable\",\n\t\t\targument: name,\n\t\t\tvalue\n\t\t};\n\t\tpositional.push({\n\t\t\tindex,\n\t\t\tvalue,\n\t\t\targument: {\n\t\t\t\tkind: \"positional\",\n\t\t\t\tvalue: text\n\t\t\t}\n\t\t});\n\t}\n\tconst named = PHASES.flatMap((phase) => {\n\t\tconst phasePrintForm = printForm[phase];\n\t\tconst generatorId = column.generators[phase]?.id;\n\t\tconst value = generatorId === void 0 ? void 0 : phasePrintForm?.valuesByGenerator.get(generatorId);\n\t\tif (phasePrintForm === void 0 || value === void 0) return [];\n\t\tconst { argument: name, index } = phasePrintForm;\n\t\treturn [{\n\t\t\tindex,\n\t\t\tvalue,\n\t\t\targument: {\n\t\t\t\tkind: \"named\",\n\t\t\t\tname,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}];\n\t});\n\treturn {\n\t\tkind: \"written\",\n\t\targuments: [...positional, ...named]\n\t};\n}\nfunction rejectionOf(preset, args) {\n\ttry {\n\t\tvalidateAuthoringHelperArguments(preset.path.join(\".\"), preset.descriptor.args, args);\n\t\treturn;\n\t} catch (error) {\n\t\tif (isRuntimeError(error) && error.code === \"CONTRACT.ARGUMENT_INVALID\") return error.message;\n\t\tthrow error;\n\t}\n}\nfunction readBackDifferences(preset, column, args) {\n\tconst printed = instantiateAuthoringFieldPreset(preset.descriptor, args);\n\tconst printedGenerators = printed.executionDefaults ?? {};\n\treturn [\n\t\t...printed.descriptor.codecId === column.codecId ? [] : [{\n\t\t\tpart: \"codecId\",\n\t\t\tcolumn: column.codecId,\n\t\t\tprinted: printed.descriptor.codecId\n\t\t}],\n\t\t...sameParams(column.typeParams, printed.descriptor.typeParams) ? [] : [{\n\t\t\tpart: \"typeParams\",\n\t\t\tcolumn: column.typeParams,\n\t\t\tprinted: printed.descriptor.typeParams\n\t\t}],\n\t\t...PHASES.flatMap((phase) => sameGenerator(column.generators[phase], printedGenerators[phase]) ? [] : [{\n\t\t\tpart: phase,\n\t\t\tcolumn: column.generators[phase],\n\t\t\tprinted: printedGenerators[phase]\n\t\t}])\n\t];\n}\nfunction cannotWrite(preset, reason) {\n\treturn {\n\t\tkind: \"cannotWrite\",\n\t\tpreset,\n\t\treason\n\t};\n}\n/**\n* The call of the field preset in the stack that writes a column's codec with its generators. The call is written only for a column that is not a list and whose PSL type stands for its data type, which the preset call takes the place of, and when the preset accepts its arguments as the PSL reader checks them; it is then checked to read back with the column's codec, type params and generators with their params, where absent and empty params count as the same. Otherwise the reason it cannot be written that way.\n*/\nfunction fieldPresetCallFor(input) {\n\tconst { column } = input;\n\tconst byGenerator = input.fieldPresetsByCodecAndGenerator.get(column.codecId);\n\tconst preset = PHASES.map((phase) => column.generators[phase]?.id).map((generatorId) => generatorId === void 0 ? void 0 : byGenerator?.get(generatorId)).find((found) => found !== void 0);\n\tif (preset === void 0) return { kind: \"noPreset\" };\n\tconst { pslType } = column;\n\tif (pslType.kind !== \"dataType\") return cannotWrite(preset, {\n\t\tkind: \"columnType\",\n\t\tcolumnType: pslType.kind,\n\t\ttypeName: pslType.typeName\n\t});\n\tif (column.list) return cannotWrite(preset, { kind: \"list\" });\n\tif (!writesEveryPhase(preset.printForm, column)) return cannotWrite(preset, { kind: \"phasesNotWrittenTogether\" });\n\tconst written = writtenArguments(preset.printForm, column);\n\tif (written.kind === \"unwritable\") return cannotWrite(preset, {\n\t\tkind: \"unwritableArgument\",\n\t\targument: written.argument,\n\t\tvalue: written.value\n\t});\n\tconst args = [];\n\tfor (const { index, value } of written.arguments) args[index] = value;\n\tconst rejection = rejectionOf(preset, args);\n\tif (rejection !== void 0) return cannotWrite(preset, {\n\t\tkind: \"argumentsRejected\",\n\t\tmessage: rejection\n\t});\n\tconst differences = readBackDifferences(preset, column, args);\n\tif (differences.length > 0) return {\n\t\tkind: \"readsBackDifferently\",\n\t\tpreset,\n\t\tdifferences\n\t};\n\treturn {\n\t\tkind: \"call\",\n\t\tpreset,\n\t\targuments: written.arguments.map(({ argument }) => argument)\n\t};\n}\n//#endregion\nexport { defaultFunctionCallFor, fewestArgumentsCall, fieldPresetCallFor, inferColumnTypes, inferredTypeConstructors, mapDefault, pslTypeArgumentText, toEnumMemberName };\n\n//# sourceMappingURL=psl-build.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,yBAAyB,OAAO;CACxC,M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,OAAO,YAAY,QAAQ;EAC7D,MAAM;EACN,UAAU,QAAQ;EAClB,OAAO,QAAQ;CAChB,CAAC;CACD,MAAM,OAAO,CAAC;CACd,KAAK,MAAM,EAAE,OAAO,WAAW,QAAQ,WAAW,KAAK,SAAS;CAChE,MAAM,YAAY,YAAY,QAAQ,IAAI;CAC1C,IAAI,cAAc,KAAK,GAAG,OAAO,YAAY,QAAQ;EACpD,MAAM;EACN,SAAS;CACV,CAAC;CACD,MAAM,cAAc,oBAAoB,QAAQ,QAAQ,IAAI;CAC5D,IAAI,YAAY,SAAS,GAAG,OAAO;EAClC,MAAM;EACN;EACA;CACD;CACA,OAAO;EACN,MAAM;EACN;EACA,WAAW,QAAQ,UAAU,KAAK,EAAE,eAAe,QAAQ;CAC5D;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { p as sqlTextFromStored, t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-BJCuy-WI.mjs";
|
|
2
2
|
import { d as resolvedTypeParams } from "./types-M_FeBD9w.mjs";
|
|
3
|
-
import { n as checkSqlDefaultText, o as reservedSqlDefaultText } from "./validators-
|
|
4
|
-
import { a as storedAsListColumn, i as isValueObjectMember } from "./derived-checks-
|
|
3
|
+
import { n as checkSqlDefaultText, o as reservedSqlDefaultText } from "./validators-V8vN9R85.mjs";
|
|
4
|
+
import { a as storedAsListColumn, i as isValueObjectMember } from "./derived-checks-sRZp_gTF-UGwFWkVX.mjs";
|
|
5
5
|
import { n as getAttribute, o as storageName, t as formatDbAttributeMigrationMessage } from "./psl-attribute-parsing-BCsFWsSp-LaNsbcrw.mjs";
|
|
6
6
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
7
7
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -15,7 +15,7 @@ import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
|
15
15
|
import { bool, contributedTypeOf, dataTypeValue, diagnosticSource, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, mapArg, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str, taggedLiteral, typeReferenceNode, writtenList, writtenScalar } from "@prisma/orm-framework/psl-parser";
|
|
16
16
|
import { describeTaggedLiteralFailure as describeTaggedLiteralFailure$1 } from "@prisma/orm-framework/components/control";
|
|
17
17
|
import { instantiatePslFieldPreset, isBareTypeConstructor, mapPslHelperArgs, reportPresetNotCalled, reportTypeConstructorNotCalled } from "@prisma/orm-framework/psl-parser/interpret";
|
|
18
|
-
//#region ../../../2-sql/2-authoring/contract-psl/dist/psl-field-resolution-
|
|
18
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/psl-field-resolution-BOJPyV5I.mjs
|
|
19
19
|
function contractError(code, message, options) {
|
|
20
20
|
return structuredError(code, message, options);
|
|
21
21
|
}
|
|
@@ -1718,19 +1718,19 @@ function collectResolvedFields(input) {
|
|
|
1718
1718
|
presetContributions = resolved.presetContributions;
|
|
1719
1719
|
}
|
|
1720
1720
|
if (!descriptor) continue;
|
|
1721
|
-
if (presetContributions && field.optional) {
|
|
1721
|
+
if (presetContributions?.id && field.optional) {
|
|
1722
1722
|
diagnostics.push({
|
|
1723
1723
|
code: "PSL_PRESET_NOT_OPTIONAL",
|
|
1724
|
-
message: `Field "${model.name}.${field.name}"
|
|
1724
|
+
message: `Field "${model.name}.${field.name}" is a primary key through its field preset, so it cannot be optional; primary key columns must be NOT NULL. Remove "?" or use a preset that does not make the field a primary key.`,
|
|
1725
1725
|
...source.at(field.span)
|
|
1726
1726
|
});
|
|
1727
1727
|
continue;
|
|
1728
1728
|
}
|
|
1729
1729
|
const defaultAttribute = getAttribute(field.attributes, "default");
|
|
1730
|
-
if (presetContributions && defaultAttribute) {
|
|
1730
|
+
if (presetContributions?.default && defaultAttribute) {
|
|
1731
1731
|
diagnostics.push({
|
|
1732
1732
|
code: "PSL_PRESET_AND_DEFAULT_CONFLICT",
|
|
1733
|
-
message: `Field "${model.name}.${field.name}" uses a field-preset call
|
|
1733
|
+
message: `Field "${model.name}.${field.name}" uses a field-preset call that already sets a database default, so it cannot also declare @default(...). Remove @default(...) or use a preset without a default.`,
|
|
1734
1734
|
...source.at(defaultAttribute.span)
|
|
1735
1735
|
});
|
|
1736
1736
|
continue;
|
|
@@ -1787,11 +1787,10 @@ function collectResolvedFields(input) {
|
|
|
1787
1787
|
});
|
|
1788
1788
|
continue;
|
|
1789
1789
|
}
|
|
1790
|
-
if (
|
|
1791
|
-
const generatorDescription = loweredOnCreate.kind === "generator" ? `"${loweredOnCreate.id}"` : "for this field";
|
|
1790
|
+
if (presetContributions?.executionDefaults?.onCreate && loweredOnCreate) {
|
|
1792
1791
|
diagnostics.push({
|
|
1793
|
-
code: "
|
|
1794
|
-
message: `Field "${model.name}.${field.name}"
|
|
1792
|
+
code: "PSL_PRESET_AND_DEFAULT_CONFLICT",
|
|
1793
|
+
message: `Field "${model.name}.${field.name}" uses a field-preset call that already generates a value on create, so @default(...) cannot generate one too. Remove @default(...), write a database default in @default(...), or use a preset without an onCreate generator.`,
|
|
1795
1794
|
...source.at(defaultAttribute?.span ?? field.span)
|
|
1796
1795
|
});
|
|
1797
1796
|
continue;
|
|
@@ -1839,13 +1838,13 @@ function collectResolvedFields(input) {
|
|
|
1839
1838
|
});
|
|
1840
1839
|
continue;
|
|
1841
1840
|
}
|
|
1842
|
-
const fieldExecutionDefaults = presetContributions?.executionDefaults
|
|
1841
|
+
const fieldExecutionDefaults = mergeExecutionDefaults(loweredDefault.executionDefaults, presetContributions?.executionDefaults);
|
|
1843
1842
|
const fieldDefaultValue = presetContributions?.default ?? loweredDefault.defaultValue;
|
|
1844
1843
|
resolvedFields.push({
|
|
1845
1844
|
field,
|
|
1846
1845
|
columnName: mappedColumnName,
|
|
1847
1846
|
descriptor,
|
|
1848
|
-
nullable: presetContributions?.nullable
|
|
1847
|
+
nullable: field.optional || Boolean(presetContributions?.nullable),
|
|
1849
1848
|
...ifDefined("defaultValue", fieldDefaultValue),
|
|
1850
1849
|
...ifDefined("executionDefaults", fieldExecutionDefaults),
|
|
1851
1850
|
isId: isIdField || Boolean(presetContributions?.id),
|
|
@@ -1860,7 +1859,14 @@ function collectResolvedFields(input) {
|
|
|
1860
1859
|
}
|
|
1861
1860
|
return resolvedFields;
|
|
1862
1861
|
}
|
|
1862
|
+
function mergeExecutionDefaults(fromDefaultAttribute, fromPreset) {
|
|
1863
|
+
if (fromDefaultAttribute === void 0 || fromPreset === void 0) return fromPreset ?? fromDefaultAttribute;
|
|
1864
|
+
return {
|
|
1865
|
+
...fromDefaultAttribute,
|
|
1866
|
+
...fromPreset
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1863
1869
|
//#endregion
|
|
1864
1870
|
export { resolveFieldTypeDescriptor as _, describeUnsupportedSqlAttribute as a, instantiateFieldTypeConstructor as c, interpretModelAttribute as d, modelAttributeSpecsFrom as f, readWrittenNumberForCodec as g, readDataTypeDefault as h, contractError as i, instantiatePslTypeConstructor as l, modelSpecContext as m, bareTypeConstructorOf as n, fieldSpecContext as o, modelCoordinateKey as p, collectResolvedFields as r, getAuthoringEntity as s, PSL_CHECK_ON_STI_VARIANT as t, interpretFieldAttribute as u, sqlAttributeSpecs as v, toNamedTypeFieldDescriptor as y };
|
|
1865
1871
|
|
|
1866
|
-
//# sourceMappingURL=psl-field-resolution-
|
|
1872
|
+
//# sourceMappingURL=psl-field-resolution-BOJPyV5I-0zJJ0fOo.mjs.map
|