@prisma-next/family-sql 0.13.0-dev.28 → 0.13.0-dev.29
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-CN60DEWb.mjs → authoring-type-constructors-CjFfO6LM.mjs} +20 -20
- package/dist/authoring-type-constructors-CjFfO6LM.mjs.map +1 -0
- package/dist/{control-adapter-B_s-UMXg.d.mts → control-adapter-Cmw9LvEP.d.mts} +4 -20
- package/dist/control-adapter-Cmw9LvEP.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +1 -1
- package/dist/control.d.mts +4 -4
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +17 -73
- package/dist/control.mjs.map +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/pack.d.mts +3 -3
- package/dist/pack.mjs +1 -1
- package/dist/schema-verify.d.mts +1 -1
- package/dist/schema-verify.mjs +1 -1
- package/dist/{types-BR5vHjvX.d.mts → types-kgstZ_Zd.d.mts} +2 -2
- package/dist/{types-BR5vHjvX.d.mts.map → types-kgstZ_Zd.d.mts.map} +1 -1
- package/dist/{verify-sql-schema-DcMaT5Zj.d.mts → verify-sql-schema-thU-jKpf.d.mts} +2 -14
- package/dist/verify-sql-schema-thU-jKpf.d.mts.map +1 -0
- package/dist/{verify-sql-schema-CC7EOR2x.mjs → verify-sql-schema-xT4udQLQ.mjs} +10 -117
- package/dist/verify-sql-schema-xT4udQLQ.mjs.map +1 -0
- package/package.json +21 -21
- package/src/core/authoring-entity-types.ts +20 -20
- package/src/core/control-adapter.ts +2 -37
- package/src/core/control-instance.ts +0 -4
- package/src/core/migrations/contract-to-schema-ir.ts +4 -83
- package/src/core/psl-contract-infer/postgres-type-map.ts +5 -22
- package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +17 -70
- package/src/core/schema-verify/verify-sql-schema.ts +8 -144
- package/dist/authoring-type-constructors-CN60DEWb.mjs.map +0 -1
- package/dist/control-adapter-B_s-UMXg.d.mts.map +0 -1
- package/dist/verify-sql-schema-CC7EOR2x.mjs.map +0 -1
- package/dist/verify-sql-schema-DcMaT5Zj.d.mts.map +0 -1
package/dist/{authoring-type-constructors-CN60DEWb.mjs → authoring-type-constructors-CjFfO6LM.mjs}
RENAMED
|
@@ -4,17 +4,17 @@ import { blindCast } from "@prisma-next/utils/casts";
|
|
|
4
4
|
function parseQuotedString(raw) {
|
|
5
5
|
if (raw.startsWith("\"") && raw.endsWith("\"") && raw.length >= 2) return raw.slice(1, -1);
|
|
6
6
|
}
|
|
7
|
-
const sqlFamilyEntityTypes = {
|
|
7
|
+
const sqlFamilyEntityTypes = { enum: {
|
|
8
8
|
kind: "entity",
|
|
9
|
-
discriminator: "
|
|
9
|
+
discriminator: "enum",
|
|
10
10
|
output: { factory: (block, ctx) => {
|
|
11
11
|
const sourceId = ctx.sourceId ?? "unknown";
|
|
12
12
|
const diagnostics = ctx.diagnostics;
|
|
13
13
|
const typeAttr = block.blockAttributes.find((a) => a.name === "type");
|
|
14
14
|
if (!typeAttr) {
|
|
15
15
|
diagnostics?.push({
|
|
16
|
-
code: "
|
|
17
|
-
message: `
|
|
16
|
+
code: "PSL_ENUM_MISSING_TYPE",
|
|
17
|
+
message: `enum "${block.name}" is missing a @@type("codecId") attribute`,
|
|
18
18
|
sourceId,
|
|
19
19
|
span: block.span
|
|
20
20
|
});
|
|
@@ -24,8 +24,8 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
24
24
|
const codecId = rawCodecArg !== void 0 ? parseQuotedString(rawCodecArg) : void 0;
|
|
25
25
|
if (!codecId) {
|
|
26
26
|
diagnostics?.push({
|
|
27
|
-
code: "
|
|
28
|
-
message: `
|
|
27
|
+
code: "PSL_ENUM_MISSING_TYPE",
|
|
28
|
+
message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`,
|
|
29
29
|
sourceId,
|
|
30
30
|
span: typeAttr.span
|
|
31
31
|
});
|
|
@@ -36,7 +36,7 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
36
36
|
const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;
|
|
37
37
|
diagnostics?.push({
|
|
38
38
|
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
39
|
-
message: `
|
|
39
|
+
message: `enum "${block.name}" @@type references unknown codec "${codecId}"`,
|
|
40
40
|
sourceId,
|
|
41
41
|
span: typeArgSpan
|
|
42
42
|
});
|
|
@@ -47,7 +47,7 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
47
47
|
const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;
|
|
48
48
|
diagnostics?.push({
|
|
49
49
|
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
50
|
-
message: `
|
|
50
|
+
message: `enum "${block.name}" @@type codec "${codecId}" resolves in targetTypesFor but is absent from codecLookup.get`,
|
|
51
51
|
sourceId,
|
|
52
52
|
span: typeArgSpan
|
|
53
53
|
});
|
|
@@ -62,8 +62,8 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
62
62
|
value = codec.decodeJson(memberName);
|
|
63
63
|
} catch {
|
|
64
64
|
diagnostics?.push({
|
|
65
|
-
code: "
|
|
66
|
-
message: `
|
|
65
|
+
code: "PSL_ENUM_BARE_MEMBER_NON_STRING_CODEC",
|
|
66
|
+
message: `enum "${block.name}" member "${memberName}" has no value and codec "${codecId}" does not accept a bare name as input`,
|
|
67
67
|
sourceId,
|
|
68
68
|
span: paramValue.span
|
|
69
69
|
});
|
|
@@ -77,7 +77,7 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
77
77
|
} catch {
|
|
78
78
|
diagnostics?.push({
|
|
79
79
|
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
80
|
-
message: `
|
|
80
|
+
message: `enum "${block.name}" member "${memberName}" value "${paramValue.raw}" is not valid JSON`,
|
|
81
81
|
sourceId,
|
|
82
82
|
span: paramValue.span
|
|
83
83
|
});
|
|
@@ -90,7 +90,7 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
90
90
|
const reason = err instanceof Error ? err.message : String(err);
|
|
91
91
|
diagnostics?.push({
|
|
92
92
|
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
93
|
-
message: `
|
|
93
|
+
message: `enum "${block.name}" member "${memberName}" was rejected by codec "${codecId}": ${reason}`,
|
|
94
94
|
sourceId,
|
|
95
95
|
span: paramValue.span
|
|
96
96
|
});
|
|
@@ -101,8 +101,8 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
101
101
|
const valueKey = String(value);
|
|
102
102
|
if (seenValues.has(valueKey)) {
|
|
103
103
|
diagnostics?.push({
|
|
104
|
-
code: "
|
|
105
|
-
message: `
|
|
104
|
+
code: "PSL_ENUM_DUPLICATE_MEMBER_VALUE",
|
|
105
|
+
message: `enum "${block.name}": duplicate member value "${valueKey}"`,
|
|
106
106
|
sourceId,
|
|
107
107
|
span: paramValue.span
|
|
108
108
|
});
|
|
@@ -118,8 +118,8 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
118
118
|
if (memberError) return void 0;
|
|
119
119
|
if (members.length === 0) {
|
|
120
120
|
diagnostics?.push({
|
|
121
|
-
code: "
|
|
122
|
-
message: `
|
|
121
|
+
code: "PSL_ENUM_MISSING_TYPE",
|
|
122
|
+
message: `enum "${block.name}" must have at least one member`,
|
|
123
123
|
sourceId,
|
|
124
124
|
span: block.span
|
|
125
125
|
});
|
|
@@ -134,10 +134,10 @@ const sqlFamilyEntityTypes = { enum2: {
|
|
|
134
134
|
})));
|
|
135
135
|
} }
|
|
136
136
|
} };
|
|
137
|
-
const sqlFamilyPslBlockDescriptors = {
|
|
137
|
+
const sqlFamilyPslBlockDescriptors = { enum: {
|
|
138
138
|
kind: "pslBlock",
|
|
139
|
-
keyword: "
|
|
140
|
-
discriminator: "
|
|
139
|
+
keyword: "enum",
|
|
140
|
+
discriminator: "enum",
|
|
141
141
|
name: { required: true },
|
|
142
142
|
parameters: {},
|
|
143
143
|
variadicParameters: true
|
|
@@ -339,4 +339,4 @@ const sqlFamilyAuthoringTypes = { sql: { String: {
|
|
|
339
339
|
//#endregion
|
|
340
340
|
export { sqlFamilyPslBlockDescriptors as i, sqlFamilyAuthoringFieldPresets as n, sqlFamilyEntityTypes as r, sqlFamilyAuthoringTypes as t };
|
|
341
341
|
|
|
342
|
-
//# sourceMappingURL=authoring-type-constructors-
|
|
342
|
+
//# sourceMappingURL=authoring-type-constructors-CjFfO6LM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-type-constructors-CjFfO6LM.mjs","names":[],"sources":["../src/core/authoring-entity-types.ts","../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { JsonValue } from '@prisma-next/contract/types';\nimport type {\n AuthoringEntityContext,\n AuthoringEntityTypeDescriptor,\n AuthoringEntityTypeNamespace,\n AuthoringPslBlockDescriptorNamespace,\n PslExtensionBlock,\n} from '@prisma-next/framework-components/authoring';\nimport { type EnumTypeHandle, enumType } from '@prisma-next/sql-contract-ts/contract-builder';\nimport { blindCast } from '@prisma-next/utils/casts';\n\nfunction parseQuotedString(raw: string): string | undefined {\n if (raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2) {\n return raw.slice(1, -1);\n }\n return undefined;\n}\n\nexport const sqlFamilyEnumEntityDescriptor = {\n kind: 'entity' as const,\n discriminator: 'enum',\n output: {\n factory: (\n block: PslExtensionBlock,\n ctx: AuthoringEntityContext,\n ): EnumTypeHandle | undefined => {\n const sourceId = ctx.sourceId ?? 'unknown';\n const diagnostics = ctx.diagnostics;\n\n const typeAttr = block.blockAttributes.find((a) => a.name === 'type');\n if (!typeAttr) {\n diagnostics?.push({\n code: 'PSL_ENUM_MISSING_TYPE',\n message: `enum \"${block.name}\" is missing a @@type(\"codecId\") attribute`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n const rawCodecArg = typeAttr.args[0]?.value;\n const codecId = rawCodecArg !== undefined ? parseQuotedString(rawCodecArg) : undefined;\n if (!codecId) {\n diagnostics?.push({\n code: 'PSL_ENUM_MISSING_TYPE',\n message: `enum \"${block.name}\" @@type attribute must have a quoted codec id argument`,\n sourceId,\n span: typeAttr.span,\n });\n return undefined;\n }\n\n const nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];\n if (nativeType === undefined) {\n const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum \"${block.name}\" @@type references unknown codec \"${codecId}\"`,\n sourceId,\n span: typeArgSpan,\n });\n return undefined;\n }\n\n const codec = ctx.codecLookup?.get(codecId);\n if (codec === undefined) {\n const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum \"${block.name}\" @@type codec \"${codecId}\" resolves in targetTypesFor but is absent from codecLookup.get`,\n sourceId,\n span: typeArgSpan,\n });\n return undefined;\n }\n\n const seenValues = new Set<string>();\n const members: { name: string; value: unknown }[] = [];\n let memberError = false;\n\n for (const [memberName, paramValue] of Object.entries(block.parameters)) {\n let value: unknown;\n if (paramValue.kind === 'bare') {\n try {\n value = codec.decodeJson(memberName);\n } catch {\n diagnostics?.push({\n code: 'PSL_ENUM_BARE_MEMBER_NON_STRING_CODEC',\n message: `enum \"${block.name}\" member \"${memberName}\" has no value and codec \"${codecId}\" does not accept a bare name as input`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n } else if (paramValue.kind === 'value') {\n let jsonValue: unknown;\n try {\n jsonValue = JSON.parse(paramValue.raw);\n } catch {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n try {\n value = codec.decodeJson(\n blindCast<JsonValue, 'JSON.parse returns a JsonValue-compatible value'>(jsonValue),\n );\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum \"${block.name}\" member \"${memberName}\" was rejected by codec \"${codecId}\": ${reason}`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n } else {\n continue;\n }\n\n const valueKey = String(value);\n if (seenValues.has(valueKey)) {\n diagnostics?.push({\n code: 'PSL_ENUM_DUPLICATE_MEMBER_VALUE',\n message: `enum \"${block.name}\": duplicate member value \"${valueKey}\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n seenValues.add(valueKey);\n members.push({ name: memberName, value });\n }\n\n if (memberError) return undefined;\n\n if (members.length === 0) {\n diagnostics?.push({\n code: 'PSL_ENUM_MISSING_TYPE',\n message: `enum \"${block.name}\" must have at least one member`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n return enumType(\n block.name,\n { codecId, nativeType },\n ...members.map((m) => ({ name: m.name, value: m.value })),\n );\n },\n },\n} satisfies AuthoringEntityTypeDescriptor;\n\nexport const sqlFamilyEntityTypes: AuthoringEntityTypeNamespace = {\n enum: sqlFamilyEnumEntityDescriptor,\n};\n\nexport const sqlFamilyPslBlockDescriptors = {\n enum: {\n kind: 'pslBlock',\n keyword: 'enum',\n discriminator: 'enum',\n name: { required: true },\n parameters: {},\n variadicParameters: true,\n },\n} as const satisfies AuthoringPslBlockDescriptorNamespace;\n","import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\n/**\n * Family-level SQL authoring field presets.\n *\n * Only presets whose codec IDs align with the ID generator metadata live here\n * (see `@prisma-next/ids`). These presets are target-agnostic because the\n * generator metadata fixes their codec/native-type to `sql/char@1`\n * (`character`) regardless of target, and the PSL interpreter lets the\n * generator override the scalar descriptor.\n *\n * The `uuidString` / `id.uuidv4String` / `id.uuidv7String` presets store UUID\n * values as `character(36)` — portable across all SQL targets. For a native\n * Postgres `uuid` column use `uuidNative` / `id.uuidv4Native` /\n * `id.uuidv7Native` from `@prisma-next/target-postgres`.\n *\n * Scalar presets that map to target-specific codecs (e.g. `text`, `int`,\n * `boolean`, `dateTime`) are contributed by the target pack (see\n * `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the\n * TS callback surface and the PSL scalar surface lower to byte-identical\n * contracts for the active target.\n */\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n uuidString: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4String: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7String: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ulid',\n },\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'cuid2',\n },\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ksuid',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";;;AAWA,SAAS,kBAAkB,KAAiC;CAC1D,IAAI,IAAI,WAAW,IAAG,KAAK,IAAI,SAAS,IAAG,KAAK,IAAI,UAAU,GAC5D,OAAO,IAAI,MAAM,GAAG,EAAE;AAG1B;AAoJA,MAAa,uBAAqD,EAChE,MAAM;CAlJN,MAAM;CACN,eAAe;CACf,QAAQ,EACN,UACE,OACA,QAC+B;EAC/B,MAAM,WAAW,IAAI,YAAY;EACjC,MAAM,cAAc,IAAI;EAExB,MAAM,WAAW,MAAM,gBAAgB,MAAM,MAAM,EAAE,SAAS,MAAM;EACpE,IAAI,CAAC,UAAU;GACb,aAAa,KAAK;IAChB,MAAM;IACN,SAAS,SAAS,MAAM,KAAK;IAC7B;IACA,MAAM,MAAM;GACd,CAAC;GACD;EACF;EAEA,MAAM,cAAc,SAAS,KAAK,EAAE,EAAE;EACtC,MAAM,UAAU,gBAAgB,KAAA,IAAY,kBAAkB,WAAW,IAAI,KAAA;EAC7E,IAAI,CAAC,SAAS;GACZ,aAAa,KAAK;IAChB,MAAM;IACN,SAAS,SAAS,MAAM,KAAK;IAC7B;IACA,MAAM,SAAS;GACjB,CAAC;GACD;EACF;EAEA,MAAM,aAAa,IAAI,aAAa,eAAe,OAAO,CAAC,GAAG;EAC9D,IAAI,eAAe,KAAA,GAAW;GAC5B,MAAM,cAAc,SAAS,KAAK,EAAE,EAAE,QAAQ,SAAS;GACvD,aAAa,KAAK;IAChB,MAAM;IACN,SAAS,SAAS,MAAM,KAAK,qCAAqC,QAAQ;IAC1E;IACA,MAAM;GACR,CAAC;GACD;EACF;EAEA,MAAM,QAAQ,IAAI,aAAa,IAAI,OAAO;EAC1C,IAAI,UAAU,KAAA,GAAW;GACvB,MAAM,cAAc,SAAS,KAAK,EAAE,EAAE,QAAQ,SA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CACF;AACF;;;ACpNA,MAAa,0BAA0B,EACrC,KAAK,EACH,QAAQ;CACN,MAAM;CACN,MAAM,CAAC;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;CAAS,CAAC;CACvF,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;EAAE,EAClC;CACF;AACF,EACF,EACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-
|
|
1
|
+
import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-schema-thU-jKpf.mjs";
|
|
2
2
|
import { ControlAdapterInstance, ControlStack } from "@prisma-next/framework-components/control";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { SqlControlDriverInstance } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { ContractMarkerRecord, LedgerEntryRecord } from "@prisma-next/contract/types";
|
|
5
5
|
import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext, SqlExecuteRequest } from "@prisma-next/sql-relational-core/ast";
|
|
6
6
|
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
7
7
|
|
|
@@ -134,22 +134,6 @@ interface SqlControlAdapter<TTarget extends string = string> extends ControlAdap
|
|
|
134
134
|
* before comparison with contract native types during schema verification.
|
|
135
135
|
*/
|
|
136
136
|
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
137
|
-
/**
|
|
138
|
-
* Optional bridging adapter for resolving the existing values of a
|
|
139
|
-
* native enum type from the introspected schema IR. Targets supply
|
|
140
|
-
* this so the family-level schema verifier can walk
|
|
141
|
-
* `PostgresEnumStorageEntry` entries natively without needing to
|
|
142
|
-
* know the target-specific `schema.annotations` shape
|
|
143
|
-
* (e.g. `schema.annotations.pg.storageTypes`).
|
|
144
|
-
*/
|
|
145
|
-
readonly resolveExistingEnumValues?: (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
146
|
-
/**
|
|
147
|
-
* Optional contract-scoped factory for {@link resolveExistingEnumValues}.
|
|
148
|
-
* Targets that need the contract storage to resolve namespace → DDL schema
|
|
149
|
-
* supply this; the family control instance prefers it over the bare adapter
|
|
150
|
-
* hook when present.
|
|
151
|
-
*/
|
|
152
|
-
readonly resolveExistingEnumValuesForContract?: (contract: Contract<SqlStorage>) => (schema: SqlSchemaIR, enumType: PostgresEnumStorageEntry, namespaceId: string) => readonly string[] | null;
|
|
153
137
|
/**
|
|
154
138
|
* Ordered DDL queries that bootstrap marker/ledger control tables for migration
|
|
155
139
|
* runners. Postgres includes `CREATE SCHEMA`; SQLite does not.
|
|
@@ -178,4 +162,4 @@ interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
|
178
162
|
}
|
|
179
163
|
//#endregion
|
|
180
164
|
export { SqlControlAdapterDescriptor as i, Lowerer as n, SqlControlAdapter as r, ExecuteRequestLowerer as t };
|
|
181
|
-
//# sourceMappingURL=control-adapter-
|
|
165
|
+
//# sourceMappingURL=control-adapter-Cmw9LvEP.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter-Cmw9LvEP.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"mappings":";;;;;;;;;;AAuBA;;;;;UAAiB,OAAA;EACf,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,OAAA,EAAS,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;;;;;;;UAStD,qBAAA,SAA8B,OAAA;EAC7C,qBAAA,CACE,GAAA,EAAK,WAAA,GAAc,OAAA,EACnB,OAAA,GAAU,cAAA,YACT,OAAA,CAAQ,iBAAA;AAAA;AAb0E;AASvF;;;;;AATuF,UAsBtE,iBAAA,0CACP,sBAAA,QAA8B,OAAA,GACpC,qBAAA;EAXS;;;;;;;;;;;;;;;EA2BX,UAAA,CACE,MAAA,EAA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0BAAA,aAAuC,OAAA;AAAA;;;;;;;UASxB,2BAAA;EA1DF;;;;;;EAiEb,MAAA,CAAO,KAAA,EAAO,YAAA,QAAoB,OAAA,IAAW,iBAAA,CAAkB,OAAA;AAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as SqlControlAdapterDescriptor, n as Lowerer, r as SqlControlAdapter, t as ExecuteRequestLowerer } from "./control-adapter-
|
|
1
|
+
import { i as SqlControlAdapterDescriptor, n as Lowerer, r as SqlControlAdapter, t as ExecuteRequestLowerer } from "./control-adapter-Cmw9LvEP.mjs";
|
|
2
2
|
export type { ExecuteRequestLowerer, Lowerer, SqlControlAdapter, SqlControlAdapterDescriptor };
|
package/dist/control.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-
|
|
1
|
+
import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-kgstZ_Zd.mjs";
|
|
2
2
|
import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
3
3
|
import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { ColumnDefault, Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
@@ -240,10 +240,10 @@ declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlC
|
|
|
240
240
|
};
|
|
241
241
|
readonly entityTypes: import("@prisma-next/framework-components/authoring").AuthoringEntityTypeNamespace;
|
|
242
242
|
readonly pslBlockDescriptors: {
|
|
243
|
-
readonly
|
|
243
|
+
readonly enum: {
|
|
244
244
|
readonly kind: "pslBlock";
|
|
245
|
-
readonly keyword: "
|
|
246
|
-
readonly discriminator: "
|
|
245
|
+
readonly keyword: "enum";
|
|
246
|
+
readonly discriminator: "enum";
|
|
247
247
|
readonly name: {
|
|
248
248
|
readonly required: true;
|
|
249
249
|
};
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAWa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOT,MAAA,2BACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCNW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA;;;;;;;;;ADbf;;;;
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control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A;;;;;;;;;;WAUtB,UAAA,EAAY,WAAA,SAAoB,iBAAA;AAAA;AAAA,iBAa3B,wBAAA,CACd,OAAA,EAAS,+BAAA,YACC,aAAa;;;iBCgCT,mBAAA,iBACd,OAAA,EAAS,6BAAA,CAA8B,cAAA,IACtC,gBAAA,CAAiB,cAAA;AAAA,iBAcJ,cAAA,iBACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,GACvB,QAAA,YAAoB,kBAAA,KACnB,uBAAA,CAAwB,cAAA;AAAA,iBAsBX,cAAA,CAAe,SAAA,WAAoB,kBAAA,KAAuB,uBAAuB;;;;iBAoBjF,aAAA,CAAc,KAAA;EAC5B,iBAAA;EACA,kBAAA;AAAA,IACE,EAAE,CAAC,8BAAA;;;;iBAYS,aAAA,CACd,IAAA,EAAM,2BAAA,EACN,OAAA,UACA,OAAA;EAAY,GAAA;EAAc,IAAA,GAAO,SAAA;AAAA,IAChC,KAAA,CAAM,yBAAA;;;;;;cC1KI,oBAAA,EAAsB,0BAEjC;;;;;;;;;;;;;;iBCoBc,6BAAA,IAAiC,kCAAkC;;;;;;;;;;;iBAqBnE,wBAAA,gEAGd,KAAA;EAAA,SAAkB,OAAA,EAAS,OAAA;EAAA,SAAkB,UAAA,EAAY,UAAA;AAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC6BlB,QAAA"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringFieldPresets, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-
|
|
1
|
+
import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringFieldPresets, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-CjFfO6LM.mjs";
|
|
2
2
|
import { t as SqlContractSerializer } from "./sql-contract-serializer-D6-28zKd.mjs";
|
|
3
|
-
import { a as contractToSchemaIR, c as extractCodecControlHooks, o as detectDestructiveChanges, s as resolveValueSetValues, t as verifySqlSchema } from "./verify-sql-schema-
|
|
3
|
+
import { a as contractToSchemaIR, c as extractCodecControlHooks, o as detectDestructiveChanges, s as resolveValueSetValues, t as verifySqlSchema } from "./verify-sql-schema-xT4udQLQ.mjs";
|
|
4
4
|
import { t as collectSupportedCodecTypeIds } from "./verify-C-G0obRm.mjs";
|
|
5
5
|
import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-CloimujU.mjs";
|
|
6
6
|
import { sqlEmission } from "@prisma-next/sql-contract-emitter";
|
|
@@ -155,20 +155,6 @@ function toFieldName(columnName) {
|
|
|
155
155
|
};
|
|
156
156
|
return { name };
|
|
157
157
|
}
|
|
158
|
-
function toEnumName(pgTypeName) {
|
|
159
|
-
let name;
|
|
160
|
-
if (hasSeparators(pgTypeName)) name = snakeToPascalCase(pgTypeName);
|
|
161
|
-
else name = pgTypeName.charAt(0).toUpperCase() + pgTypeName.slice(1);
|
|
162
|
-
if (needsEscaping(name)) return {
|
|
163
|
-
name: escapeName(name),
|
|
164
|
-
map: pgTypeName
|
|
165
|
-
};
|
|
166
|
-
if (name !== pgTypeName) return {
|
|
167
|
-
name,
|
|
168
|
-
map: pgTypeName
|
|
169
|
-
};
|
|
170
|
-
return { name };
|
|
171
|
-
}
|
|
172
158
|
function pluralize(word) {
|
|
173
159
|
if (word.endsWith("s") || word.endsWith("x") || word.endsWith("z") || word.endsWith("ch") || word.endsWith("sh")) return `${word}es`;
|
|
174
160
|
if (word.endsWith("y") && !/[aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;
|
|
@@ -333,7 +319,6 @@ const PARAMETERIZED_NATIVE_TYPES = {
|
|
|
333
319
|
}
|
|
334
320
|
};
|
|
335
321
|
const PARAMETERIZED_TYPE_PATTERN = /^(.+?)\((.+)\)$/;
|
|
336
|
-
const ENUM_CODEC_ID = "pg/enum@1";
|
|
337
322
|
function getOwnMappingValue(map, key) {
|
|
338
323
|
return Object.hasOwn(map, key) ? map[key] : void 0;
|
|
339
324
|
}
|
|
@@ -387,16 +372,11 @@ function createPostgresTypeMap(enumTypeNames) {
|
|
|
387
372
|
} };
|
|
388
373
|
}
|
|
389
374
|
function extractEnumInfo(annotations) {
|
|
390
|
-
const
|
|
375
|
+
const nativeEnumTypeNames = (annotations?.["pg"])?.["nativeEnumTypeNames"];
|
|
391
376
|
const typeNames = /* @__PURE__ */ new Set();
|
|
392
377
|
const definitions = /* @__PURE__ */ new Map();
|
|
393
|
-
if (
|
|
394
|
-
for (const
|
|
395
|
-
const nativeType = typeInstance.nativeType;
|
|
396
|
-
typeNames.add(nativeType);
|
|
397
|
-
const values = typeInstance.typeParams?.["values"];
|
|
398
|
-
if (Array.isArray(values) && values.every((v) => typeof v === "string")) definitions.set(nativeType, values);
|
|
399
|
-
}
|
|
378
|
+
if (Array.isArray(nativeEnumTypeNames)) {
|
|
379
|
+
for (const name of nativeEnumTypeNames) if (typeof name === "string") typeNames.add(name);
|
|
400
380
|
}
|
|
401
381
|
return {
|
|
402
382
|
typeNames,
|
|
@@ -620,37 +600,27 @@ const PSL_SCALAR_TYPE_NAMES = new Set([
|
|
|
620
600
|
*/
|
|
621
601
|
function sqlSchemaIrToPslAst(schemaIR) {
|
|
622
602
|
const enumInfo = extractEnumInfo(schemaIR.annotations);
|
|
603
|
+
if (enumInfo.typeNames.size > 0) {
|
|
604
|
+
const names = [...enumInfo.typeNames].join(", ");
|
|
605
|
+
throw new Error(`contract infer: the database contains native Postgres enum type(s): ${names}. Native Postgres enums (CREATE TYPE … AS ENUM) are not adoptable by contract infer. Drop the native type and replace each column with a text column carrying a CHECK constraint, then re-run contract infer. The domain enum (enum Name { @@type("pg/text@1") … }) authoring surface generates the required check automatically.`);
|
|
606
|
+
}
|
|
623
607
|
return buildPslDocumentAst(schemaIR, {
|
|
624
|
-
typeMap: createPostgresTypeMap(
|
|
608
|
+
typeMap: createPostgresTypeMap(/* @__PURE__ */ new Set()),
|
|
625
609
|
defaultMapping: createPostgresDefaultMapping(),
|
|
626
|
-
enumInfo,
|
|
627
610
|
parseRawDefault
|
|
628
611
|
});
|
|
629
612
|
}
|
|
630
613
|
function buildPslDocumentAst(schemaIR, options) {
|
|
631
|
-
const { typeMap, defaultMapping,
|
|
632
|
-
const { typeNames: enumTypeNames, definitions: enumDefinitions } = enumInfo ?? {
|
|
633
|
-
typeNames: /* @__PURE__ */ new Set(),
|
|
634
|
-
definitions: /* @__PURE__ */ new Map()
|
|
635
|
-
};
|
|
614
|
+
const { typeMap, defaultMapping, parseRawDefault: rawDefaultParser } = options;
|
|
636
615
|
const modelNames = buildTopLevelNameMap(Object.keys(schemaIR.tables), toModelName, "model", "table");
|
|
637
|
-
const enumNames = buildTopLevelNameMap(enumTypeNames, toEnumName, "enum", "enum type");
|
|
638
|
-
assertNoCrossKindNameCollisions(modelNames, enumNames);
|
|
639
616
|
const modelNameMap = new Map([...modelNames].map(([tableName, result]) => [tableName, result.name]));
|
|
640
|
-
const
|
|
641
|
-
const reservedNamedTypeNames = createReservedNamedTypeNames(modelNames, enumNames);
|
|
617
|
+
const reservedNamedTypeNames = createReservedNamedTypeNames(modelNames);
|
|
642
618
|
const fieldNamesByTable = buildFieldNamesByTable(schemaIR.tables);
|
|
643
619
|
const { relationsByTable } = inferRelations(schemaIR.tables, modelNameMap);
|
|
644
|
-
const namedTypes = seedNamedTypeRegistry(schemaIR, typeMap,
|
|
620
|
+
const namedTypes = seedNamedTypeRegistry(schemaIR, typeMap, /* @__PURE__ */ new Map(), reservedNamedTypeNames);
|
|
645
621
|
const models = [];
|
|
646
|
-
for (const table of Object.values(schemaIR.tables)) models.push(buildModel(table, typeMap,
|
|
622
|
+
for (const table of Object.values(schemaIR.tables)) models.push(buildModel(table, typeMap, /* @__PURE__ */ new Map(), fieldNamesByTable, namedTypes, defaultMapping, rawDefaultParser, relationsByTable.get(table.name) ?? []));
|
|
647
623
|
const sortedModels = topologicalSort(models, schemaIR.tables, modelNameMap);
|
|
648
|
-
const enums = [];
|
|
649
|
-
for (const [pgTypeName, values] of enumDefinitions) {
|
|
650
|
-
const enumName = enumNames.get(pgTypeName);
|
|
651
|
-
enums.push(buildEnum(enumName, values));
|
|
652
|
-
}
|
|
653
|
-
enums.sort((a, b) => a.name.localeCompare(b.name));
|
|
654
624
|
const namedTypeEntries = [...namedTypes.entriesByKey.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
655
625
|
const types = namedTypeEntries.length > 0 ? {
|
|
656
626
|
kind: "types",
|
|
@@ -663,7 +633,7 @@ function buildPslDocumentAst(schemaIR, options) {
|
|
|
663
633
|
namespaces: [makePslNamespace({
|
|
664
634
|
kind: "namespace",
|
|
665
635
|
name: UNSPECIFIED_PSL_NAMESPACE_ID,
|
|
666
|
-
entries: makePslNamespaceEntries(sortedModels,
|
|
636
|
+
entries: makePslNamespaceEntries(sortedModels, [], []),
|
|
667
637
|
span: SYNTHETIC_SPAN
|
|
668
638
|
})],
|
|
669
639
|
...types ? { types } : {},
|
|
@@ -819,21 +789,6 @@ function namedArg(name, value) {
|
|
|
819
789
|
span: SYNTHETIC_SPAN
|
|
820
790
|
};
|
|
821
791
|
}
|
|
822
|
-
function buildEnum(name, values) {
|
|
823
|
-
const attrs = [];
|
|
824
|
-
if (name.map) attrs.push(buildMapAttribute("enum", name.map));
|
|
825
|
-
return {
|
|
826
|
-
kind: "enum",
|
|
827
|
-
name: name.name,
|
|
828
|
-
values: values.map((value) => ({
|
|
829
|
-
kind: "enumValue",
|
|
830
|
-
name: value,
|
|
831
|
-
span: SYNTHETIC_SPAN
|
|
832
|
-
})),
|
|
833
|
-
attributes: attrs,
|
|
834
|
-
span: SYNTHETIC_SPAN
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
792
|
function buildNamedTypeDeclaration(entry) {
|
|
838
793
|
const attribute = buildAttribute("namedType", entry.nativeTypeAttribute.name, (entry.nativeTypeAttribute.args ?? []).map(positionalArg));
|
|
839
794
|
return {
|
|
@@ -913,18 +868,9 @@ function buildTopLevelNameMap(sources, normalize, kind, sourceKind) {
|
|
|
913
868
|
}
|
|
914
869
|
return results;
|
|
915
870
|
}
|
|
916
|
-
function
|
|
917
|
-
const enumSourceByName = new Map([...enumNames].map(([source, result]) => [result.name, source]));
|
|
918
|
-
const collisions = [...modelNames.entries()].map(([tableName, result]) => {
|
|
919
|
-
const enumSource = enumSourceByName.get(result.name);
|
|
920
|
-
return enumSource ? `- identifier "${result.name}" from table "${tableName}" collides with enum type "${enumSource}"` : void 0;
|
|
921
|
-
}).filter((detail) => detail !== void 0);
|
|
922
|
-
if (collisions.length > 0) throw new Error(`PSL top-level name collisions detected:\n${collisions.join("\n")}`);
|
|
923
|
-
}
|
|
924
|
-
function createReservedNamedTypeNames(modelNames, enumNames) {
|
|
871
|
+
function createReservedNamedTypeNames(modelNames) {
|
|
925
872
|
const reservedNames = new Set(PSL_SCALAR_TYPE_NAMES);
|
|
926
873
|
for (const result of modelNames.values()) reservedNames.add(result.name);
|
|
927
|
-
for (const result of enumNames.values()) reservedNames.add(result.name);
|
|
928
874
|
return reservedNames;
|
|
929
875
|
}
|
|
930
876
|
function seedNamedTypeRegistry(schemaIR, typeMap, enumNameMap, reservedNames) {
|
|
@@ -1282,7 +1228,6 @@ function createSqlFamilyInstance(stack) {
|
|
|
1282
1228
|
verifySchema(options) {
|
|
1283
1229
|
const contract = deserializeWithTargetSerializer(options.contract);
|
|
1284
1230
|
const controlAdapter = getControlAdapter();
|
|
1285
|
-
const resolveExistingEnumValues = controlAdapter.resolveExistingEnumValuesForContract?.(contract) ?? controlAdapter.resolveExistingEnumValues;
|
|
1286
1231
|
return verifySqlSchema({
|
|
1287
1232
|
contract,
|
|
1288
1233
|
schema: options.schema,
|
|
@@ -1290,8 +1235,7 @@ function createSqlFamilyInstance(stack) {
|
|
|
1290
1235
|
typeMetadataRegistry,
|
|
1291
1236
|
frameworkComponents: options.frameworkComponents,
|
|
1292
1237
|
...ifDefined("normalizeDefault", controlAdapter.normalizeDefault),
|
|
1293
|
-
...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType)
|
|
1294
|
-
...ifDefined("resolveExistingEnumValues", resolveExistingEnumValues)
|
|
1238
|
+
...ifDefined("normalizeNativeType", controlAdapter.normalizeNativeType)
|
|
1295
1239
|
});
|
|
1296
1240
|
},
|
|
1297
1241
|
async sign(options) {
|