@prisma-next/target-postgres 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/{codec-ids-C_-Hj6bL.mjs → codec-ids-BvytN2P8.mjs} +2 -3
- package/dist/codec-ids-BvytN2P8.mjs.map +1 -0
- package/dist/{codec-ids-BzrFF-I4.d.mts → codec-ids-CnXu9Qy3.d.mts} +2 -3
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-B0WT0obB.d.mts → codec-types-DHCkwPKE.d.mts} +2 -3
- package/dist/codec-types-DHCkwPKE.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-CX56Smsj.d.mts → codecs--0A5_4Bq.d.mts} +3 -23
- package/dist/codecs--0A5_4Bq.d.mts.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +2 -38
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.mjs +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +7 -10
- package/dist/control.mjs.map +1 -1
- package/dist/{descriptor-meta-C7O6XHfh.mjs → descriptor-meta-BKma_hQ5.mjs} +2 -2
- package/dist/{descriptor-meta-C7O6XHfh.mjs.map → descriptor-meta-BKma_hQ5.mjs.map} +1 -1
- package/dist/{descriptor-meta-runtime-BToWdas9.mjs → descriptor-meta-runtime-e5f2tscJ.mjs} +2 -39
- package/dist/descriptor-meta-runtime-e5f2tscJ.mjs.map +1 -0
- package/dist/{issue-planner-CK-XWGB0.mjs → issue-planner-DsjB7xDj.mjs} +17 -227
- package/dist/issue-planner-DsjB7xDj.mjs.map +1 -0
- package/dist/issue-planner.d.mts +8 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +1 -11
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +3 -3
- package/dist/{op-factory-call-DxjpXw-A.d.mts → op-factory-call-CdtMyrlU.d.mts} +3 -48
- package/dist/{op-factory-call-DxjpXw-A.d.mts.map → op-factory-call-CdtMyrlU.d.mts.map} +1 -1
- package/dist/{op-factory-call-CHvtj70z.mjs → op-factory-call-CjR846f7.mjs} +4 -159
- package/dist/op-factory-call-CjR846f7.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +2 -18
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-4FbY_95H.mjs → planner-_FOL4I21.mjs} +9 -41
- package/dist/planner-_FOL4I21.mjs.map +1 -0
- package/dist/{planner-ddl-builders-Cw2n2llW.mjs → planner-ddl-builders-B2wOwLqI.mjs} +2 -2
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -4
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-BIpa5p2I.mjs → planner-identity-values-CJPha2Sz.mjs} +3 -9
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -0
- package/dist/planner-identity-values.d.mts +1 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-qfkCkGVe.mjs → planner-produced-postgres-migration-BmCpyWLJ.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-qfkCkGVe.mjs.map → planner-produced-postgres-migration-BmCpyWLJ.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-BLgdXLsA.mjs → planner-sql-checks-CJJtPfDH.mjs} +3 -3
- package/dist/planner-sql-checks-CJJtPfDH.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts +2 -2
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-type-resolution-836DExFN.mjs → planner-type-resolution-Bt2f_q-F.mjs} +1 -6
- package/dist/planner-type-resolution-Bt2f_q-F.mjs.map +1 -0
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-CTxVcCVW.mjs → postgres-contract-serializer-CyAe8ZFv.mjs} +12 -29
- package/dist/postgres-contract-serializer-CyAe8ZFv.mjs.map +1 -0
- package/dist/{postgres-migration-DF5ApLqQ.mjs → postgres-migration-dG-J0aI8.mjs} +2 -2
- package/dist/{postgres-migration-DF5ApLqQ.mjs.map → postgres-migration-dG-J0aI8.mjs.map} +1 -1
- package/dist/{postgres-schema-C7c9rhGk.mjs → postgres-schema-CTKYiTHu.mjs} +7 -21
- package/dist/postgres-schema-CTKYiTHu.mjs.map +1 -0
- package/dist/runtime.d.mts +0 -2
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/types.d.mts +5 -25
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -4
- package/package.json +17 -18
- package/src/core/authoring.ts +1 -44
- package/src/core/codec-helpers.ts +0 -17
- package/src/core/codec-ids.ts +0 -1
- package/src/core/codec-type-map.ts +0 -2
- package/src/core/codecs.ts +0 -49
- package/src/core/migrations/control-policy.ts +3 -45
- package/src/core/migrations/issue-planner.ts +9 -52
- package/src/core/migrations/op-factory-call.ts +2 -124
- package/src/core/migrations/planner-ddl-builders.ts +3 -4
- package/src/core/migrations/planner-identity-values.ts +4 -28
- package/src/core/migrations/planner-recipes.ts +2 -6
- package/src/core/migrations/planner-sql-checks.ts +2 -6
- package/src/core/migrations/planner-strategies.ts +13 -353
- package/src/core/migrations/planner-type-resolution.ts +2 -20
- package/src/core/migrations/planner.ts +0 -2
- package/src/core/migrations/runner.ts +0 -4
- package/src/core/postgres-contract-serializer.ts +9 -67
- package/src/core/postgres-schema.ts +6 -37
- package/src/exports/codecs.ts +0 -2
- package/src/exports/control.ts +0 -15
- package/src/exports/migration.ts +0 -6
- package/src/exports/op-factory-call.ts +0 -4
- package/src/exports/types.ts +0 -2
- package/dist/codec-ids-BzrFF-I4.d.mts.map +0 -1
- package/dist/codec-ids-C_-Hj6bL.mjs.map +0 -1
- package/dist/codec-types-B0WT0obB.d.mts.map +0 -1
- package/dist/codecs-CX56Smsj.d.mts.map +0 -1
- package/dist/descriptor-meta-runtime-BToWdas9.mjs.map +0 -1
- package/dist/enum-planning-D8z4FH7y.mjs +0 -129
- package/dist/enum-planning-D8z4FH7y.mjs.map +0 -1
- package/dist/enum-planning.d.mts +0 -92
- package/dist/enum-planning.d.mts.map +0 -1
- package/dist/enum-planning.mjs +0 -2
- package/dist/issue-planner-CK-XWGB0.mjs.map +0 -1
- package/dist/op-factory-call-CHvtj70z.mjs.map +0 -1
- package/dist/planner-4FbY_95H.mjs.map +0 -1
- package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +0 -1
- package/dist/planner-identity-values-BIpa5p2I.mjs.map +0 -1
- package/dist/planner-sql-checks-BLgdXLsA.mjs.map +0 -1
- package/dist/planner-type-resolution-836DExFN.mjs.map +0 -1
- package/dist/postgres-contract-serializer-CTxVcCVW.mjs.map +0 -1
- package/dist/postgres-enum-type-BVn63a89.d.mts +0 -72
- package/dist/postgres-enum-type-BVn63a89.d.mts.map +0 -1
- package/dist/postgres-enum-type-DPKqCBem.mjs +0 -62
- package/dist/postgres-enum-type-DPKqCBem.mjs.map +0 -1
- package/dist/postgres-enum-type-schema-DZBTtvBF.mjs +0 -20
- package/dist/postgres-enum-type-schema-DZBTtvBF.mjs.map +0 -1
- package/dist/postgres-schema-C7c9rhGk.mjs.map +0 -1
- package/src/core/migrations/enum-planning.ts +0 -217
- package/src/core/migrations/operations/enums.ts +0 -114
- package/src/core/postgres-enum-type.ts +0 -89
- package/src/exports/enum-planning.ts +0 -10
|
@@ -15,12 +15,9 @@ import {
|
|
|
15
15
|
UNBOUND_NAMESPACE_ID,
|
|
16
16
|
} from '@prisma-next/framework-components/ir';
|
|
17
17
|
import type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
18
|
-
import { blindCast
|
|
18
|
+
import { blindCast } from '@prisma-next/utils/casts';
|
|
19
19
|
import type { JsonObject } from '@prisma-next/utils/json';
|
|
20
|
-
import type { Type } from 'arktype';
|
|
21
20
|
import { postgresAuthoringEntityTypes } from './authoring';
|
|
22
|
-
import type { PostgresEnumType } from './postgres-enum-type';
|
|
23
|
-
import { PostgresEnumTypeSchema } from './postgres-enum-type-schema';
|
|
24
21
|
import { isPostgresSchema, PostgresSchema } from './postgres-schema';
|
|
25
22
|
|
|
26
23
|
const POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {
|
|
@@ -66,44 +63,10 @@ function collectStorageTypesHydrators(
|
|
|
66
63
|
return registry;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
// Pack-contributed validator schemas keyed by entries key: postgres registers
|
|
70
|
-
// 'type' → the inner name→entry map schema. The family base composes these
|
|
71
|
-
// into the single registry alongside SQL core's 'table'/'valueSet' via
|
|
72
|
-
// createSqlEntrySchemaRegistry.
|
|
73
|
-
const POSTGRES_VALIDATOR_REGISTRY: ReadonlyMap<string, Type<unknown>> = new Map<
|
|
74
|
-
string,
|
|
75
|
-
Type<unknown>
|
|
76
|
-
>([['type', castAs<Type<unknown>>(PostgresEnumTypeSchema)]]);
|
|
77
|
-
|
|
78
66
|
export class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
|
|
79
|
-
private readonly enumFactory: SqlEntityHydrationFactory | undefined;
|
|
80
|
-
|
|
81
67
|
constructor() {
|
|
82
68
|
const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);
|
|
83
|
-
super(storageTypesHydrators
|
|
84
|
-
this.enumFactory = storageTypesHydrators.get('postgres-enum');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected override hydrateEntriesKind(
|
|
88
|
-
key: string,
|
|
89
|
-
innerMap: unknown,
|
|
90
|
-
): Record<string, unknown> | undefined {
|
|
91
|
-
if (key === 'type') {
|
|
92
|
-
if (innerMap === null || typeof innerMap !== 'object' || Array.isArray(innerMap)) {
|
|
93
|
-
return {};
|
|
94
|
-
}
|
|
95
|
-
return Object.fromEntries(
|
|
96
|
-
Object.entries(
|
|
97
|
-
blindCast<Record<string, unknown>, 'checked object, non-null, non-array above'>(innerMap),
|
|
98
|
-
).map(([name, entry]) => [
|
|
99
|
-
name,
|
|
100
|
-
blindCast<PostgresEnumType, 'postgres-enum factory returns PostgresEnumType'>(
|
|
101
|
-
this.enumFactory !== undefined ? this.enumFactory(entry) : entry,
|
|
102
|
-
),
|
|
103
|
-
]),
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
return super.hydrateEntriesKind(key, innerMap);
|
|
69
|
+
super(storageTypesHydrators);
|
|
107
70
|
}
|
|
108
71
|
|
|
109
72
|
protected override hydrateSqlNamespaceEntry(
|
|
@@ -119,34 +82,18 @@ export class PostgresContractSerializer extends SqlContractSerializerBase<Contra
|
|
|
119
82
|
>(super.hydrateSqlNamespaceEntry(nsId, raw));
|
|
120
83
|
const { id, entries } = hydrated;
|
|
121
84
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const valueSetEntries = entries['valueSet'];
|
|
127
|
-
const hasValueSets = valueSetEntries !== undefined && Object.keys(valueSetEntries).length > 0;
|
|
128
|
-
const tableEntries = entries['table'] ?? {};
|
|
129
|
-
const emptyTables = Object.keys(tableEntries).length === 0;
|
|
130
|
-
const emptyTypes = !typeEntries || Object.keys(typeEntries).length === 0;
|
|
131
|
-
if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes && !hasValueSets) {
|
|
85
|
+
const valueSetSlot = entries['valueSet'];
|
|
86
|
+
const hasValueSets = valueSetSlot !== undefined && Object.keys(valueSetSlot).length > 0;
|
|
87
|
+
const emptyTables = Object.keys(entries['table'] ?? {}).length === 0;
|
|
88
|
+
if (id === UNBOUND_NAMESPACE_ID && emptyTables && !hasValueSets) {
|
|
132
89
|
return PostgresSchema.unbound;
|
|
133
90
|
}
|
|
134
91
|
return new PostgresSchema({
|
|
135
92
|
id,
|
|
136
93
|
entries: {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
>(tableEntries),
|
|
141
|
-
type: typeEntries ?? {},
|
|
142
|
-
...(hasValueSets
|
|
143
|
-
? {
|
|
144
|
-
valueSet: blindCast<
|
|
145
|
-
Record<string, unknown>,
|
|
146
|
-
'valueSet entries are StorageValueSet instances after base hydration'
|
|
147
|
-
>(valueSetEntries),
|
|
148
|
-
}
|
|
149
|
-
: {}),
|
|
94
|
+
...entries,
|
|
95
|
+
table: entries['table'] ?? {},
|
|
96
|
+
...(hasValueSets ? { valueSet: valueSetSlot } : {}),
|
|
150
97
|
},
|
|
151
98
|
});
|
|
152
99
|
}
|
|
@@ -195,10 +142,6 @@ export class PostgresContractSerializer extends SqlContractSerializerBase<Contra
|
|
|
195
142
|
for (const [tableName, table] of Object.entries(ns.table)) {
|
|
196
143
|
tablesOut[tableName] = this.serializeJsonValue(table) as JsonObject;
|
|
197
144
|
}
|
|
198
|
-
const typeOut: Record<string, JsonObject> = {};
|
|
199
|
-
for (const [typeName, ty] of Object.entries(ns.type)) {
|
|
200
|
-
typeOut[typeName] = this.serializeJsonValue(ty) as JsonObject;
|
|
201
|
-
}
|
|
202
145
|
const valueSetEntries = ns.valueSet;
|
|
203
146
|
const valueSetOut: Record<string, JsonObject> = {};
|
|
204
147
|
if (valueSetEntries !== undefined) {
|
|
@@ -214,7 +157,6 @@ export class PostgresContractSerializer extends SqlContractSerializerBase<Contra
|
|
|
214
157
|
kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',
|
|
215
158
|
entries: {
|
|
216
159
|
table: tablesOut,
|
|
217
|
-
type: typeOut,
|
|
218
160
|
...(Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}),
|
|
219
161
|
},
|
|
220
162
|
};
|
|
@@ -4,8 +4,6 @@ import {
|
|
|
4
4
|
UNBOUND_NAMESPACE_ID,
|
|
5
5
|
} from '@prisma-next/framework-components/ir';
|
|
6
6
|
import {
|
|
7
|
-
type PostgresEnumStorageEntry,
|
|
8
|
-
type SqlNamespaceEntries,
|
|
9
7
|
type SqlNamespaceTablesInput,
|
|
10
8
|
type SqlStorage,
|
|
11
9
|
StorageTable,
|
|
@@ -15,13 +13,8 @@ import {
|
|
|
15
13
|
} from '@prisma-next/sql-contract/types';
|
|
16
14
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
17
15
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
18
|
-
import { PostgresEnumType, type PostgresEnumTypeInput } from './postgres-enum-type';
|
|
19
16
|
import { escapeLiteral } from './sql-utils';
|
|
20
17
|
|
|
21
|
-
export type PostgresNamespaceEntries = SqlNamespaceEntries & {
|
|
22
|
-
readonly type?: Readonly<Record<string, PostgresEnumType>>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
18
|
export interface PostgresSchemaInput {
|
|
26
19
|
readonly id: string;
|
|
27
20
|
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
@@ -33,7 +26,7 @@ export interface PostgresSchemaInput {
|
|
|
33
26
|
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
34
27
|
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
35
28
|
*
|
|
36
|
-
* `entries` holds entity-kind maps (`table`, `
|
|
29
|
+
* `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
|
|
37
30
|
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
38
31
|
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
39
32
|
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
@@ -53,7 +46,7 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
53
46
|
|
|
54
47
|
declare readonly kind: 'schema';
|
|
55
48
|
readonly id: string;
|
|
56
|
-
readonly entries:
|
|
49
|
+
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
57
50
|
|
|
58
51
|
constructor(input: PostgresSchemaInput) {
|
|
59
52
|
super();
|
|
@@ -61,7 +54,6 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
61
54
|
|
|
62
55
|
const carried: Record<string, Readonly<Record<string, unknown>>> = {};
|
|
63
56
|
let table: Readonly<Record<string, StorageTable>> = Object.freeze({});
|
|
64
|
-
let type: Readonly<Record<string, PostgresEnumType>> = Object.freeze({});
|
|
65
57
|
let valueSet: Readonly<Record<string, StorageValueSet>> | undefined;
|
|
66
58
|
for (const [kind, rawMap] of Object.entries(input.entries)) {
|
|
67
59
|
if (kind === 'table') {
|
|
@@ -75,17 +67,6 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
75
67
|
tableMap[name] = new StorageTable(v);
|
|
76
68
|
}
|
|
77
69
|
table = Object.freeze(tableMap);
|
|
78
|
-
} else if (kind === 'type') {
|
|
79
|
-
const typeMap: Record<string, PostgresEnumType> = {};
|
|
80
|
-
for (const [name, v] of Object.entries(
|
|
81
|
-
blindCast<
|
|
82
|
-
Record<string, PostgresEnumTypeInput>,
|
|
83
|
-
'entries[type] holds PostgresEnumTypeInput by construction'
|
|
84
|
-
>(rawMap),
|
|
85
|
-
)) {
|
|
86
|
-
typeMap[name] = new PostgresEnumType(v);
|
|
87
|
-
}
|
|
88
|
-
type = Object.freeze(typeMap);
|
|
89
70
|
} else if (kind === 'valueSet') {
|
|
90
71
|
const vsMap: Record<string, StorageValueSet> = {};
|
|
91
72
|
for (const [name, v] of Object.entries(
|
|
@@ -107,7 +88,6 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
107
88
|
this.entries = Object.freeze({
|
|
108
89
|
...carried,
|
|
109
90
|
table,
|
|
110
|
-
type,
|
|
111
91
|
...ifDefined('valueSet', valueSet),
|
|
112
92
|
});
|
|
113
93
|
Object.defineProperty(this, 'kind', {
|
|
@@ -120,15 +100,11 @@ export class PostgresSchema extends NamespaceBase {
|
|
|
120
100
|
}
|
|
121
101
|
|
|
122
102
|
get table(): Readonly<Record<string, StorageTable>> {
|
|
123
|
-
return this.entries
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
get type(): Readonly<Record<string, PostgresEnumType>> {
|
|
127
|
-
return this.entries.type ?? Object.freeze({});
|
|
103
|
+
return this.entries['table'] ?? Object.freeze({});
|
|
128
104
|
}
|
|
129
105
|
|
|
130
106
|
get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined {
|
|
131
|
-
return this.entries
|
|
107
|
+
return this.entries['valueSet'] as Readonly<Record<string, StorageValueSet>> | undefined;
|
|
132
108
|
}
|
|
133
109
|
|
|
134
110
|
/**
|
|
@@ -211,7 +187,7 @@ export class PostgresUnboundSchema extends PostgresSchema {
|
|
|
211
187
|
static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();
|
|
212
188
|
|
|
213
189
|
constructor(input?: PostgresSchemaInput) {
|
|
214
|
-
super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {}
|
|
190
|
+
super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });
|
|
215
191
|
}
|
|
216
192
|
|
|
217
193
|
override qualifier(): string {
|
|
@@ -253,19 +229,12 @@ export function isPostgresSchema(ns: unknown): ns is PostgresSchema {
|
|
|
253
229
|
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
254
230
|
* be value-stable for a given input set.
|
|
255
231
|
*/
|
|
256
|
-
export function postgresCreateNamespace(
|
|
257
|
-
input: SqlNamespaceTablesInput,
|
|
258
|
-
enumTypes?: Readonly<Record<string, PostgresEnumStorageEntry>>,
|
|
259
|
-
): PostgresSchema {
|
|
232
|
+
export function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema {
|
|
260
233
|
const schemaInput: PostgresSchemaInput = {
|
|
261
234
|
id: input.id,
|
|
262
235
|
entries: {
|
|
263
236
|
...input.entries,
|
|
264
237
|
table: input.entries['table'] ?? {},
|
|
265
|
-
type: blindCast<
|
|
266
|
-
Record<string, PostgresEnumTypeInput>,
|
|
267
|
-
'enumTypes values are PostgresEnumTypeInput by construction'
|
|
268
|
-
>(enumTypes ?? {}),
|
|
269
238
|
},
|
|
270
239
|
};
|
|
271
240
|
if (input.id === UNBOUND_NAMESPACE_ID) {
|
package/src/exports/codecs.ts
CHANGED
|
@@ -2,7 +2,6 @@ export type {
|
|
|
2
2
|
PgBitDescriptor,
|
|
3
3
|
PgBoolDescriptor,
|
|
4
4
|
PgCharDescriptor,
|
|
5
|
-
PgEnumDescriptor,
|
|
6
5
|
PgFloat4Descriptor,
|
|
7
6
|
PgFloat8Descriptor,
|
|
8
7
|
PgFloatDescriptor,
|
|
@@ -27,7 +26,6 @@ export {
|
|
|
27
26
|
pgBitColumn,
|
|
28
27
|
pgBoolColumn,
|
|
29
28
|
pgCharColumn,
|
|
30
|
-
pgEnumColumn,
|
|
31
29
|
pgFloat4Column,
|
|
32
30
|
pgFloat8Column,
|
|
33
31
|
pgFloatColumn,
|
package/src/exports/control.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type {
|
|
|
10
10
|
import type { SqlStorage, StorageColumn } from '@prisma-next/sql-contract/types';
|
|
11
11
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
12
12
|
import { postgresTargetDescriptorMeta } from '../core/descriptor-meta';
|
|
13
|
-
import { resolveDdlSchemaForNamespaceStorage } from '../core/migrations/enum-planning';
|
|
14
13
|
import { createPostgresMigrationPlanner } from '../core/migrations/planner';
|
|
15
14
|
import { renderDefaultLiteral } from '../core/migrations/planner-ddl-builders';
|
|
16
15
|
import type { PostgresPlanTargetDetails } from '../core/migrations/planner-target-details';
|
|
@@ -31,12 +30,6 @@ function buildNativeTypeExpander(
|
|
|
31
30
|
readonly typeParams?: Record<string, unknown>;
|
|
32
31
|
}) => {
|
|
33
32
|
if (!input.typeParams) return input.nativeType;
|
|
34
|
-
// Mirror `renderExpectedNativeType` in verify-sql-schema: when a codec
|
|
35
|
-
// has no `expandNativeType` hook (e.g. `pg/enum@1`, whose typeParams
|
|
36
|
-
// describe the value set rather than a DDL suffix), fall back to the
|
|
37
|
-
// bare native type rather than throwing. Throwing here would reject
|
|
38
|
-
// every plan involving an enum-/values-typed column as soon as its
|
|
39
|
-
// `typeRef` resolved to a `StorageTypeInstance` carrying typeParams.
|
|
40
33
|
if (!input.codecId) return input.nativeType;
|
|
41
34
|
const hooks = codecHooks.get(input.codecId);
|
|
42
35
|
if (!hooks?.expandNativeType) return input.nativeType;
|
|
@@ -77,14 +70,6 @@ const postgresTargetDescriptor: SqlControlTargetDescriptor<'postgres', PostgresP
|
|
|
77
70
|
annotationNamespace: 'pg',
|
|
78
71
|
...ifDefined('expandNativeType', expander),
|
|
79
72
|
renderDefault: postgresRenderDefault,
|
|
80
|
-
// Map each namespace to the live DDL schema its enums are stored
|
|
81
|
-
// under, so the projected "from" IR nests enums by the same schema
|
|
82
|
-
// `readExistingEnumValues` reads (the contract-to-contract `migration
|
|
83
|
-
// plan` path). `undefined` schema IR ⇒ the unbound coordinate
|
|
84
|
-
// resolves to the default `public` landing schema, matching the
|
|
85
|
-
// read-side fallback.
|
|
86
|
-
resolveEnumNamespaceSchema: (storage, namespaceId) =>
|
|
87
|
-
resolveDdlSchemaForNamespaceStorage(storage, namespaceId, undefined),
|
|
88
73
|
});
|
|
89
74
|
},
|
|
90
75
|
},
|
package/src/exports/migration.ts
CHANGED
|
@@ -42,12 +42,6 @@ export {
|
|
|
42
42
|
createExtension,
|
|
43
43
|
installExtension,
|
|
44
44
|
} from '../core/migrations/operations/dependencies';
|
|
45
|
-
export {
|
|
46
|
-
addEnumValues,
|
|
47
|
-
createEnumType,
|
|
48
|
-
dropEnumType,
|
|
49
|
-
renameType,
|
|
50
|
-
} from '../core/migrations/operations/enums';
|
|
51
45
|
export { createIndex, dropIndex } from '../core/migrations/operations/indexes';
|
|
52
46
|
export { rawSql } from '../core/migrations/operations/raw';
|
|
53
47
|
export { dropTable } from '../core/migrations/operations/tables';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
export {
|
|
2
2
|
AddCheckConstraintCall,
|
|
3
3
|
AddColumnCall,
|
|
4
|
-
AddEnumValuesCall,
|
|
5
4
|
AddForeignKeyCall,
|
|
6
5
|
AddPrimaryKeyCall,
|
|
7
6
|
AddUniqueCall,
|
|
8
7
|
AlterColumnTypeCall,
|
|
9
|
-
CreateEnumTypeCall,
|
|
10
8
|
CreateExtensionCall,
|
|
11
9
|
CreateIndexCall,
|
|
12
10
|
CreateSchemaCall,
|
|
@@ -16,12 +14,10 @@ export {
|
|
|
16
14
|
DropColumnCall,
|
|
17
15
|
DropConstraintCall,
|
|
18
16
|
DropDefaultCall,
|
|
19
|
-
DropEnumTypeCall,
|
|
20
17
|
DropIndexCall,
|
|
21
18
|
DropNotNullCall,
|
|
22
19
|
DropTableCall,
|
|
23
20
|
RawSqlCall,
|
|
24
|
-
RenameTypeCall,
|
|
25
21
|
SetDefaultCall,
|
|
26
22
|
SetNotNullCall,
|
|
27
23
|
} from '../core/migrations/op-factory-call';
|
package/src/exports/types.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-ids-BzrFF-I4.d.mts","names":[],"sources":["../src/core/codec-ids.ts"],"mappings":";;;cAQa,gBAAA;AAAA,cACA,sBAAA;AAAA,cACA,gBAAA;AAAA,cACA,gBAAA;AAAA,cACA,mBAAA;AAAA,cACA,eAAA;AAAA,cACA,gBAAA;AAAA,cACA,gBAAA;AAAA,cACA,gBAAA;AAAA,cACA,iBAAA;AAAA,cACA,kBAAA;AAAA,cACA,kBAAA;AAAA,cACA,mBAAA;AAAA,cACA,gBAAA;AAAA,cACA,eAAA;AAAA,cACA,kBAAA;AAAA,cACA,qBAAA;AAAA,cACA,uBAAA;AAAA,cACA,gBAAA;AAAA,cACA,kBAAA;AAAA,cACA,oBAAA;AAAA,cACA,gBAAA;AAAA,cACA,iBAAA;AAAA,cACA,iBAAA;AAAA,cACA,gBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-ids-C_-Hj6bL.mjs","names":[],"sources":["../src/core/codec-ids.ts"],"sourcesContent":["export {\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/sql-relational-core/ast';\nexport const PG_TEXT_CODEC_ID = 'pg/text@1' as const;\nexport const PG_TEXT_ARRAY_CODEC_ID = 'pg/text-array@1' as const;\nexport const PG_ENUM_CODEC_ID = 'pg/enum@1' as const;\nexport const PG_CHAR_CODEC_ID = 'pg/char@1' as const;\nexport const PG_VARCHAR_CODEC_ID = 'pg/varchar@1' as const;\nexport const PG_INT_CODEC_ID = 'pg/int@1' as const;\nexport const PG_INT2_CODEC_ID = 'pg/int2@1' as const;\nexport const PG_INT4_CODEC_ID = 'pg/int4@1' as const;\nexport const PG_INT8_CODEC_ID = 'pg/int8@1' as const;\nexport const PG_FLOAT_CODEC_ID = 'pg/float@1' as const;\nexport const PG_FLOAT4_CODEC_ID = 'pg/float4@1' as const;\nexport const PG_FLOAT8_CODEC_ID = 'pg/float8@1' as const;\nexport const PG_NUMERIC_CODEC_ID = 'pg/numeric@1' as const;\nexport const PG_BOOL_CODEC_ID = 'pg/bool@1' as const;\nexport const PG_BIT_CODEC_ID = 'pg/bit@1' as const;\nexport const PG_VARBIT_CODEC_ID = 'pg/varbit@1' as const;\nexport const PG_TIMESTAMP_CODEC_ID = 'pg/timestamp@1' as const;\nexport const PG_TIMESTAMPTZ_CODEC_ID = 'pg/timestamptz@1' as const;\nexport const PG_TIME_CODEC_ID = 'pg/time@1' as const;\nexport const PG_TIMETZ_CODEC_ID = 'pg/timetz@1' as const;\nexport const PG_INTERVAL_CODEC_ID = 'pg/interval@1' as const;\nexport const PG_JSON_CODEC_ID = 'pg/json@1' as const;\nexport const PG_JSONB_CODEC_ID = 'pg/jsonb@1' as const;\nexport const PG_BYTEA_CODEC_ID = 'pg/bytea@1' as const;\nexport const PG_UUID_CODEC_ID = 'pg/uuid@1' as const;\n"],"mappings":";;AAQA,MAAa,mBAAmB;AAChC,MAAa,yBAAyB;AACtC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AACvC,MAAa,mBAAmB;AAChC,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;AACjC,MAAa,mBAAmB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-B0WT0obB.d.mts","names":[],"sources":["../src/core/codec-type-map.ts","../src/exports/codec-types.ts"],"mappings":";;;;;cA6Ca,kBAAA;EAAA;;;;;;iBA+BH,gBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;KAEE,OAAA,6BAAoC,CAAA,0BAA2B,CAAA,CAAE,CAAA,IAAK,CAAA,CAAE,CAAA,EAAG,CAAA;AAAA,KAE3E,kBAAA,UAA4B,kBAAkB;AAAA,KAE9C,mBAAA,GAAsB,iBAAiB,CAAC,kBAAA;;;KCvExC,UAAA,GAAa,OAAO,CAAC,mBAAA;AAAA,KAI5B,OAAA,kBAAyB,MAAA,qBAA2B,CAAA,0BAClC,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AAA,SACnB,OAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;;;;;;;;WACA,MAAA;EAAA,SACA,YAAA,EAAY,gBAAA;EACrB,OAAA,KAAY,GAAA,EAAK,oBAAA,KAAyB,aAAA;AAAA;AAAA,cAOxC,aAAA,0DAAa,UAAA,CAAA,aAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-runtime-BToWdas9.mjs","names":[],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta-runtime.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type {\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringTypeNamespace,\n} from '@prisma-next/framework-components/authoring';\nimport type { PostgresEnumStorageEntry } from '@prisma-next/sql-contract/types';\nimport { PostgresEnumType, type PostgresEnumTypeInput } from './postgres-enum-type';\nimport { PostgresEnumTypeSchema } from './postgres-enum-type-schema';\n\nexport const postgresAuthoringTypes = {} as const satisfies AuthoringTypeNamespace;\n\n/**\n * Entity type contributions surface as top-level helpers on the\n * composed-helpers shape (e.g. `helpers.enum({...})`), flattened\n * alongside the built-in `model` / `rel` helpers. Pack contributions\n * still ship via the contribution data structure\n * `authoring.entityTypes.<name>`; the composed-helpers template\n * performs the rename in the type system.\n *\n * `enum` is the first real consumer of the entities-namespace mechanism:\n * the factory constructs a `PostgresEnumType` IR-class instance from\n * the user-supplied input. Both authoring runtimes (TS DSL and PSL)\n * dispatch through this single contribution — PSL `enum Status { … }`\n * declarations are lowered by the interpreter into a factory call\n * with the parsed name + value list; TS DSL `helpers.enum({...})`\n * resolves through the same path. Removing this contribution makes\n * both surfaces fail with a \"no entity helper named `enum`\" type\n * error at the contract-definition site.\n */\n/**\n * The factory constructs a `PostgresEnumType` instance natively — the\n * `SqlStorage.types` slot accepts polymorphic IR (the framework\n * `StorageType` alphabet), so no cast is needed at the contribution\n * surface. The declared return type is the structural\n * `PostgresEnumStorageEntry` so the inferred contract type stays\n * portable (it names a type exported from\n * `@prisma-next/sql-contract/types`, a public surface every consumer\n * already imports). Sharpening the inferred contract type to surface\n * enum-specific narrowing through `EntityHelperFunction` is a\n * separable refinement and lives outside this PR.\n */\nexport const postgresAuthoringEntityTypes = {\n enum: {\n kind: 'entity',\n discriminator: 'postgres-enum',\n validatorSchema: PostgresEnumTypeSchema,\n output: {\n factory: (input: PostgresEnumTypeInput): PostgresEnumStorageEntry =>\n new PostgresEnumType(input),\n },\n },\n} as const satisfies AuthoringEntityTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n *\n * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n * the family pack instead.\n */\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n }),\n uuidNative: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n },\n },\n id: {\n uuidv4Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","// Runtime-safe slice of the postgres target descriptor metadata.\n//\n// This file exists separately from ./descriptor-meta on purpose: the runtime\n// plane reads only `kind/familyId/targetId/id/version/capabilities` (plus the\n// `__codecTypes` phantom). The `authoring` slot lives on the pack/control\n// descriptor only, because authoring contributions are consumed at\n// contract-construction time by `assembleAuthoringContributions` (control\n// plane) and the PSL interpreter — never at runtime.\n//\n// Keeping the runtime closure free of the `./authoring` import is what lets\n// the bundler tree-shake `@prisma-next/family-sql/control` (and its\n// transitive `verify-sql-schema` chunk) out of the runtime entry. Do not\n// add an `authoring` field here — if you need to, the pack/control meta in\n// `./descriptor-meta` is the right place. See TML-2766 for context.\nimport type { CodecTypes } from '../exports/codec-types';\n\nconst postgresTargetDescriptorMetaRuntimeBase = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n} as const;\n\nexport const postgresTargetDescriptorMetaRuntime: typeof postgresTargetDescriptorMetaRuntimeBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaRuntimeBase;\n"],"mappings":";;;;AAUA,MAAa,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCvC,MAAa,+BAA+B,EAC1C,MAAM;CACJ,MAAM;CACN,eAAe;CACf,iBAAiB;CACjB,QAAQ,EACN,UAAU,UACR,IAAI,iBAAiB,KAAK,EAC9B;AACF,EACF;;;;;;;;;;;;;;AAeA,MAAa,gCAAgC;CAC3C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,KAAK;EACH,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,QAAQ;EACN,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAAU;EACR,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAA0B,yCAAyB;EACjD,SAAS;EACT,YAAY;CACd,CAAC;CACD,YAAY;EACV,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,IAAI;EACF,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;EACA,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;CACF;AACF;ACnJA,MAAa,sCAET;CAVF,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;AAKb"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import "./codec-ids-C_-Hj6bL.mjs";
|
|
2
|
-
import { r as isPostgresSchema } from "./postgres-schema-C7c9rhGk.mjs";
|
|
3
|
-
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
4
|
-
import { arraysEqual } from "@prisma-next/family-sql/schema-verify";
|
|
5
|
-
//#region src/core/migrations/enum-planning.ts
|
|
6
|
-
/**
|
|
7
|
-
* Pure planning helpers for Postgres enum types: the diff/rebuild logic
|
|
8
|
-
* that the verifier and planner use to walk `PostgresEnumType` instances
|
|
9
|
-
* natively. Op builders live in `./operations/enums.ts`.
|
|
10
|
-
*/
|
|
11
|
-
function readOptionalString(value) {
|
|
12
|
-
return typeof value === "string" ? value : void 0;
|
|
13
|
-
}
|
|
14
|
-
function readPgStorageTypeEntry(value) {
|
|
15
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return;
|
|
16
|
-
const codecId = Reflect.get(value, "codecId");
|
|
17
|
-
const typeParamsRaw = Reflect.get(value, "typeParams");
|
|
18
|
-
const typeParams = typeParamsRaw !== void 0 && typeParamsRaw !== null && typeof typeParamsRaw === "object" && !Array.isArray(typeParamsRaw) ? { values: Reflect.get(typeParamsRaw, "values") } : void 0;
|
|
19
|
-
return {
|
|
20
|
-
...typeof codecId === "string" ? { codecId } : {},
|
|
21
|
-
...typeParams !== void 0 ? { typeParams } : {}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function readPgEnumTypesMap(value) {
|
|
25
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return;
|
|
26
|
-
const bySchema = {};
|
|
27
|
-
for (const [schemaName, byTypeRaw] of Object.entries(value)) {
|
|
28
|
-
if (byTypeRaw === null || typeof byTypeRaw !== "object" || Array.isArray(byTypeRaw)) continue;
|
|
29
|
-
const byType = {};
|
|
30
|
-
for (const [nativeType, entryValue] of Object.entries(byTypeRaw)) {
|
|
31
|
-
const entry = readPgStorageTypeEntry(entryValue);
|
|
32
|
-
if (entry !== void 0) byType[nativeType] = entry;
|
|
33
|
-
}
|
|
34
|
-
if (Object.keys(byType).length > 0) bySchema[schemaName] = byType;
|
|
35
|
-
}
|
|
36
|
-
return Object.keys(bySchema).length > 0 ? bySchema : void 0;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Reads the Postgres annotation envelope (`schema.annotations.pg`) from
|
|
40
|
-
* family Schema IR. `SqlAnnotations` is an open target-pack extensibility
|
|
41
|
-
* map (`Record<string, unknown>`); this accessor narrows the `pg` slot at
|
|
42
|
-
* runtime so Postgres code can read introspection fields without casts.
|
|
43
|
-
*/
|
|
44
|
-
function readPostgresSchemaIrAnnotations(schema) {
|
|
45
|
-
const raw = schema.annotations?.["pg"];
|
|
46
|
-
if (raw === void 0 || raw === null || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
47
|
-
const schemaField = readOptionalString(Reflect.get(raw, "schema"));
|
|
48
|
-
const enumTypes = readPgEnumTypesMap(Reflect.get(raw, "enumTypes"));
|
|
49
|
-
return {
|
|
50
|
-
...schemaField !== void 0 ? { schema: schemaField } : {},
|
|
51
|
-
...enumTypes !== void 0 ? { enumTypes } : {}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Resolves the live-schema name a namespace's enums are introspected under,
|
|
56
|
-
* for keying `readExistingEnumValues` lookups. The unbound namespace's
|
|
57
|
-
* `ddlSchemaName` is a planner-emit sentinel (`__unbound__`) that never names a
|
|
58
|
-
* real schema, so for the unbound coordinate we read the *introspected* schema
|
|
59
|
-
* recorded on `annotations.pg.schema` (the live `current_schema()` the adapter
|
|
60
|
-
* walked) — that is the schema the enum's `storageTypes` entry is keyed under.
|
|
61
|
-
* Named namespaces resolve to their own DDL schema, which matches the
|
|
62
|
-
* per-schema introspection key directly.
|
|
63
|
-
*/
|
|
64
|
-
function resolveDdlSchemaForNamespaceStorage(storage, namespaceId, schemaIr) {
|
|
65
|
-
if (namespaceId === UNBOUND_NAMESPACE_ID) return (schemaIr ? readPostgresSchemaIrAnnotations(schemaIr).schema : void 0) ?? "public";
|
|
66
|
-
const namespace = storage.namespaces[namespaceId];
|
|
67
|
-
if (namespace && isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);
|
|
68
|
-
return namespaceId;
|
|
69
|
-
}
|
|
70
|
-
/** Contract-scoped bridge for the family verifier's enum value resolver. */
|
|
71
|
-
function createResolveExistingEnumValues(storage) {
|
|
72
|
-
return (schema, enumType, namespaceId) => readExistingEnumValues(schema, resolveDdlSchemaForNamespaceStorage(storage, namespaceId, schema), enumType.nativeType);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Reads existing enum values for `(schemaName, nativeType)` from the
|
|
76
|
-
* Postgres-introspected `schema.annotations.pg.enumTypes` map, addressed by
|
|
77
|
-
* the `(schema, nativeType)` coordinate.
|
|
78
|
-
*
|
|
79
|
-
* Schema IR's enum entries are always codec-typed
|
|
80
|
-
* (`{codecId: PG_ENUM_CODEC_ID, typeParams.values}`): the introspector
|
|
81
|
-
* writes that shape, and the Contract→Schema IR projector resolves
|
|
82
|
-
* `PostgresEnumType` instances down to the same codec-typed triple before
|
|
83
|
-
* they ever land in Schema IR. There is no second on-disk shape to
|
|
84
|
-
* accept here.
|
|
85
|
-
*
|
|
86
|
-
* Returns `null` when no enum entry exists for the given native type.
|
|
87
|
-
*/
|
|
88
|
-
function readExistingEnumValues(schema, schemaName, nativeType) {
|
|
89
|
-
const existing = readPostgresSchemaIrAnnotations(schema).enumTypes?.[schemaName]?.[nativeType];
|
|
90
|
-
if (!existing || existing.codecId !== "pg/enum@1") return null;
|
|
91
|
-
const enumValues = existing.typeParams?.values;
|
|
92
|
-
if (!Array.isArray(enumValues) || !enumValues.every((v) => typeof v === "string")) return null;
|
|
93
|
-
return enumValues;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Determines what changes are needed to transform existing enum values to
|
|
97
|
-
* desired values.
|
|
98
|
-
*
|
|
99
|
-
* Postgres enums can only have values added (not removed or reordered)
|
|
100
|
-
* without a full type rebuild involving temp type creation and column
|
|
101
|
-
* migration; `'rebuild'` covers the value-removal and reorder cases.
|
|
102
|
-
*/
|
|
103
|
-
function determineEnumDiff(existing, desired) {
|
|
104
|
-
if (arraysEqual(existing, desired)) return { kind: "unchanged" };
|
|
105
|
-
const existingSet = new Set(existing);
|
|
106
|
-
const desiredSet = new Set(desired);
|
|
107
|
-
const missingValues = desired.filter((value) => !existingSet.has(value));
|
|
108
|
-
const removedValues = existing.filter((value) => !desiredSet.has(value));
|
|
109
|
-
const orderMismatch = missingValues.length === 0 && removedValues.length === 0 && !arraysEqual(existing, desired);
|
|
110
|
-
if (removedValues.length > 0 || orderMismatch) return {
|
|
111
|
-
kind: "rebuild",
|
|
112
|
-
removedValues
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
kind: "add_values",
|
|
116
|
-
values: missingValues
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Convenience accessor — returns the enum's desired values from a
|
|
121
|
-
* `PostgresEnumType` IR instance.
|
|
122
|
-
*/
|
|
123
|
-
function getDesiredEnumValues(typeInstance) {
|
|
124
|
-
return typeInstance.values;
|
|
125
|
-
}
|
|
126
|
-
//#endregion
|
|
127
|
-
export { readPostgresSchemaIrAnnotations as a, readExistingEnumValues as i, determineEnumDiff as n, resolveDdlSchemaForNamespaceStorage as o, getDesiredEnumValues as r, createResolveExistingEnumValues as t };
|
|
128
|
-
|
|
129
|
-
//# sourceMappingURL=enum-planning-D8z4FH7y.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enum-planning-D8z4FH7y.mjs","names":[],"sources":["../src/core/migrations/enum-planning.ts"],"sourcesContent":["/**\n * Pure planning helpers for Postgres enum types: the diff/rebuild logic\n * that the verifier and planner use to walk `PostgresEnumType` instances\n * natively. Op builders live in `./operations/enums.ts`.\n */\n\nimport { arraysEqual } from '@prisma-next/family-sql/schema-verify';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { PostgresEnumStorageEntry, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { PG_ENUM_CODEC_ID } from '../codec-ids';\nimport type { PostgresEnumType } from '../postgres-enum-type';\nimport { isPostgresSchema } from '../postgres-schema';\n\n/**\n * Codec-typed enum entry shape stored under\n * `schema.annotations.pg.enumTypes[schemaName][nativeType]`.\n */\ninterface PgStorageTypeEntry {\n readonly codecId?: string;\n readonly typeParams?: { readonly values?: unknown };\n}\n\n/**\n * Live enum types keyed by `(schemaName, nativeType)` as a nested map, so two\n * schemas sharing a native enum name stay distinct without packing the pair\n * into a string. This is the same `(namespace, entityName)` coordinate the\n * contract side addresses entities by.\n */\ntype PgEnumTypesMap = Readonly<Record<string, Readonly<Record<string, PgStorageTypeEntry>>>>;\n\n/** Postgres-specific subtree on family `SqlSchemaIR.annotations`. */\nexport interface PostgresSchemaIrAnnotations {\n readonly schema?: string;\n readonly enumTypes?: PgEnumTypesMap;\n}\n\nfunction readOptionalString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction readPgStorageTypeEntry(value: unknown): PgStorageTypeEntry | undefined {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n return undefined;\n }\n const codecId = Reflect.get(value, 'codecId');\n const typeParamsRaw = Reflect.get(value, 'typeParams');\n const typeParams =\n typeParamsRaw !== undefined &&\n typeParamsRaw !== null &&\n typeof typeParamsRaw === 'object' &&\n !Array.isArray(typeParamsRaw)\n ? { values: Reflect.get(typeParamsRaw, 'values') }\n : undefined;\n return {\n ...(typeof codecId === 'string' ? { codecId } : {}),\n ...(typeParams !== undefined ? { typeParams } : {}),\n };\n}\n\nfunction readPgEnumTypesMap(value: unknown): PgEnumTypesMap | undefined {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n return undefined;\n }\n const bySchema: Record<string, Record<string, PgStorageTypeEntry>> = {};\n for (const [schemaName, byTypeRaw] of Object.entries(value)) {\n if (byTypeRaw === null || typeof byTypeRaw !== 'object' || Array.isArray(byTypeRaw)) {\n continue;\n }\n const byType: Record<string, PgStorageTypeEntry> = {};\n for (const [nativeType, entryValue] of Object.entries(byTypeRaw)) {\n const entry = readPgStorageTypeEntry(entryValue);\n if (entry !== undefined) {\n byType[nativeType] = entry;\n }\n }\n if (Object.keys(byType).length > 0) {\n bySchema[schemaName] = byType;\n }\n }\n return Object.keys(bySchema).length > 0 ? bySchema : undefined;\n}\n\n/**\n * Reads the Postgres annotation envelope (`schema.annotations.pg`) from\n * family Schema IR. `SqlAnnotations` is an open target-pack extensibility\n * map (`Record<string, unknown>`); this accessor narrows the `pg` slot at\n * runtime so Postgres code can read introspection fields without casts.\n */\nexport function readPostgresSchemaIrAnnotations(schema: SqlSchemaIR): PostgresSchemaIrAnnotations {\n const raw = schema.annotations?.['pg'];\n if (raw === undefined || raw === null || typeof raw !== 'object' || Array.isArray(raw)) {\n return {};\n }\n const schemaField = readOptionalString(Reflect.get(raw, 'schema'));\n const enumTypes = readPgEnumTypesMap(Reflect.get(raw, 'enumTypes'));\n return {\n ...(schemaField !== undefined ? { schema: schemaField } : {}),\n ...(enumTypes !== undefined ? { enumTypes } : {}),\n };\n}\n\n/**\n * Resolves the live-schema name a namespace's enums are introspected under,\n * for keying `readExistingEnumValues` lookups. The unbound namespace's\n * `ddlSchemaName` is a planner-emit sentinel (`__unbound__`) that never names a\n * real schema, so for the unbound coordinate we read the *introspected* schema\n * recorded on `annotations.pg.schema` (the live `current_schema()` the adapter\n * walked) — that is the schema the enum's `storageTypes` entry is keyed under.\n * Named namespaces resolve to their own DDL schema, which matches the\n * per-schema introspection key directly.\n */\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n schemaIr?: SqlSchemaIR,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return (schemaIr ? readPostgresSchemaIrAnnotations(schemaIr).schema : undefined) ?? 'public';\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n\n/** Contract-scoped bridge for the family verifier's enum value resolver. */\nexport function createResolveExistingEnumValues(\n storage: SqlStorage,\n): (\n schema: SqlSchemaIR,\n enumType: PostgresEnumStorageEntry,\n namespaceId: string,\n) => readonly string[] | null {\n return (schema, enumType, namespaceId) =>\n readExistingEnumValues(\n schema,\n resolveDdlSchemaForNamespaceStorage(storage, namespaceId, schema),\n enumType.nativeType,\n );\n}\n\n/**\n * Categorisation of how an existing enum type's values relate to the\n * desired set in the contract.\n */\nexport type EnumDiff =\n | { readonly kind: 'unchanged' }\n | { readonly kind: 'add_values'; readonly values: readonly string[] }\n | { readonly kind: 'rebuild'; readonly removedValues: readonly string[] };\n\n/**\n * Reads existing enum values for `(schemaName, nativeType)` from the\n * Postgres-introspected `schema.annotations.pg.enumTypes` map, addressed by\n * the `(schema, nativeType)` coordinate.\n *\n * Schema IR's enum entries are always codec-typed\n * (`{codecId: PG_ENUM_CODEC_ID, typeParams.values}`): the introspector\n * writes that shape, and the Contract→Schema IR projector resolves\n * `PostgresEnumType` instances down to the same codec-typed triple before\n * they ever land in Schema IR. There is no second on-disk shape to\n * accept here.\n *\n * Returns `null` when no enum entry exists for the given native type.\n */\nexport function readExistingEnumValues(\n schema: SqlSchemaIR,\n schemaName: string,\n nativeType: string,\n): readonly string[] | null {\n const enumTypes = readPostgresSchemaIrAnnotations(schema).enumTypes;\n const existing = enumTypes?.[schemaName]?.[nativeType];\n if (!existing || existing.codecId !== PG_ENUM_CODEC_ID) {\n return null;\n }\n const enumValues = existing.typeParams?.values;\n if (!Array.isArray(enumValues) || !enumValues.every((v) => typeof v === 'string')) {\n return null;\n }\n return enumValues;\n}\n\n/**\n * Determines what changes are needed to transform existing enum values to\n * desired values.\n *\n * Postgres enums can only have values added (not removed or reordered)\n * without a full type rebuild involving temp type creation and column\n * migration; `'rebuild'` covers the value-removal and reorder cases.\n */\nexport function determineEnumDiff(\n existing: readonly string[],\n desired: readonly string[],\n): EnumDiff {\n if (arraysEqual(existing, desired)) {\n return { kind: 'unchanged' };\n }\n const existingSet = new Set(existing);\n const desiredSet = new Set(desired);\n const missingValues = desired.filter((value) => !existingSet.has(value));\n const removedValues = existing.filter((value) => !desiredSet.has(value));\n const orderMismatch =\n missingValues.length === 0 && removedValues.length === 0 && !arraysEqual(existing, desired);\n if (removedValues.length > 0 || orderMismatch) {\n return { kind: 'rebuild', removedValues };\n }\n return { kind: 'add_values', values: missingValues };\n}\n\n/**\n * Convenience accessor — returns the enum's desired values from a\n * `PostgresEnumType` IR instance.\n */\nexport function getDesiredEnumValues(typeInstance: PostgresEnumType): readonly string[] {\n return typeInstance.values;\n}\n"],"mappings":";;;;;;;;;;AAqCA,SAAS,mBAAmB,OAAoC;CAC9D,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;AAEA,SAAS,uBAAuB,OAAgD;CAC9E,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GACpE;CAEF,MAAM,UAAU,QAAQ,IAAI,OAAO,SAAS;CAC5C,MAAM,gBAAgB,QAAQ,IAAI,OAAO,YAAY;CACrD,MAAM,aACJ,kBAAkB,KAAA,KAClB,kBAAkB,QAClB,OAAO,kBAAkB,YACzB,CAAC,MAAM,QAAQ,aAAa,IACxB,EAAE,QAAQ,QAAQ,IAAI,eAAe,QAAQ,EAAE,IAC/C,KAAA;CACN,OAAO;EACL,GAAI,OAAO,YAAY,WAAW,EAAE,QAAQ,IAAI,CAAC;EACjD,G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