@prisma-next/target-postgres 0.12.0-dev.4 → 0.12.0-dev.41
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-DliyCWPY.d.mts → codec-ids-Cx7C07Y_.d.mts} +3 -2
- package/dist/codec-ids-Cx7C07Y_.d.mts.map +1 -0
- package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-DTqscwN9.mjs} +3 -2
- package/dist/codec-ids-DTqscwN9.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-BF1DXTPs.d.mts → codec-types-BoxMGJk-.d.mts} +2 -2
- package/dist/{codec-types-BF1DXTPs.d.mts.map → codec-types-BoxMGJk-.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-DuP3d9Au.d.mts → codecs-DCSyTOCb.d.mts} +2 -2
- package/dist/codecs-DCSyTOCb.d.mts.map +1 -0
- package/dist/codecs.d.mts +1 -1
- package/dist/codecs.mjs +37 -2
- package/dist/codecs.mjs.map +1 -1
- package/dist/column-type-compatibility-Dzxz_CkP.mjs +11 -0
- package/dist/column-type-compatibility-Dzxz_CkP.mjs.map +1 -0
- package/dist/column-type-compatibility.d.mts +5 -0
- package/dist/column-type-compatibility.d.mts.map +1 -0
- package/dist/column-type-compatibility.mjs +2 -0
- package/dist/contract-free.d.mts +75 -0
- package/dist/contract-free.d.mts.map +1 -0
- package/dist/contract-free.mjs +139 -0
- package/dist/contract-free.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +64 -36
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-CAPmAdxS.d.mts → data-transform-5gLOgP68.d.mts} +2 -2
- package/dist/{data-transform-CAPmAdxS.d.mts.map → data-transform-5gLOgP68.d.mts.map} +1 -1
- package/dist/{data-transform-CRkv2T_U.mjs → data-transform-DIYwbe4S.mjs} +1 -1
- package/dist/{data-transform-CRkv2T_U.mjs.map → data-transform-DIYwbe4S.mjs.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/ddl.d.mts +2 -0
- package/dist/ddl.mjs +2 -0
- package/dist/{default-normalizer-DaAhmzBV.mjs → default-normalizer-DFHtpCPH.mjs} +1 -1
- package/dist/{default-normalizer-DaAhmzBV.mjs.map → default-normalizer-DFHtpCPH.mjs.map} +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/{descriptor-meta-Uu8QaClr.mjs → descriptor-meta-BqATo5Dz.mjs} +3 -2
- package/dist/descriptor-meta-BqATo5Dz.mjs.map +1 -0
- package/dist/{descriptor-meta-runtime-DMRX39kp.mjs → descriptor-meta-runtime-BBL7VdnR.mjs} +2 -2
- package/dist/{descriptor-meta-runtime-DMRX39kp.mjs.map → descriptor-meta-runtime-BBL7VdnR.mjs.map} +1 -1
- package/dist/{enum-planning-DRA9LaMU.mjs → enum-planning-Cb-NjaH6.mjs} +0 -0
- package/dist/{enum-planning-DRA9LaMU.mjs.map → enum-planning-Cb-NjaH6.mjs.map} +1 -1
- package/dist/enum-planning.d.mts +1 -1
- package/dist/enum-planning.mjs +1 -1
- package/dist/{errors-BbnITmAD.mjs → errors-De185dnO.mjs} +1 -1
- package/dist/{errors-BbnITmAD.mjs.map → errors-De185dnO.mjs.map} +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{issue-planner-BtaL6OfW.mjs → issue-planner-NzRtXfjR.mjs} +22 -23
- package/dist/issue-planner-NzRtXfjR.mjs.map +1 -0
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +3 -3
- package/dist/migration.mjs +3 -3
- package/dist/{native-type-normalizer-BNEQ9VDs.mjs → native-type-normalizer-BUUe8USD.mjs} +1 -1
- package/dist/{native-type-normalizer-BNEQ9VDs.mjs.map → native-type-normalizer-BUUe8USD.mjs.map} +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/nodes-DCC8-DhV.mjs +42 -0
- package/dist/nodes-DCC8-DhV.mjs.map +1 -0
- package/dist/nodes-DflxwrE8.d.mts +38 -0
- package/dist/nodes-DflxwrE8.d.mts.map +1 -0
- package/dist/{op-factory-call-CDlImOF_.d.mts → op-factory-call-B-HEOf41.d.mts} +3 -3
- package/dist/{op-factory-call-CDlImOF_.d.mts.map → op-factory-call-B-HEOf41.d.mts.map} +1 -1
- package/dist/{op-factory-call-ewOd5q6L.mjs → op-factory-call-ZqeS5JxZ.mjs} +2 -2
- package/dist/{op-factory-call-ewOd5q6L.mjs.map → op-factory-call-ZqeS5JxZ.mjs.map} +1 -1
- package/dist/op-factory-call.d.mts +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +3 -2
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-BRGVWfq4.mjs +342 -0
- package/dist/planner-BRGVWfq4.mjs.map +1 -0
- package/dist/{planner-ddl-builders-BNMfSE9r.mjs → planner-ddl-builders-BfN5p8wr.mjs} +3 -3
- package/dist/{planner-ddl-builders-BNMfSE9r.mjs.map → planner-ddl-builders-BfN5p8wr.mjs.map} +1 -1
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-nhVj0hp-.mjs → planner-identity-values-DmwlJe_z.mjs} +1 -1
- package/dist/{planner-identity-values-nhVj0hp-.mjs.map → planner-identity-values-DmwlJe_z.mjs.map} +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-D02NOhVQ.d.mts → planner-produced-postgres-migration-Co71_VbU.d.mts} +3 -3
- package/dist/{planner-produced-postgres-migration-D02NOhVQ.d.mts.map → planner-produced-postgres-migration-Co71_VbU.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-D_nsXbhl.mjs → planner-produced-postgres-migration-D6KXC2DH.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-D_nsXbhl.mjs.map → planner-produced-postgres-migration-D6KXC2DH.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-schema-lookup-CGxxYfnD.mjs → planner-schema-lookup-Bm4S3LvB.mjs} +1 -1
- package/dist/{planner-schema-lookup-CGxxYfnD.mjs.map → planner-schema-lookup-Bm4S3LvB.mjs.map} +1 -1
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-CfEiTXoQ.mjs → planner-sql-checks-C43dcyOd.mjs} +39 -12
- package/dist/planner-sql-checks-C43dcyOd.mjs.map +1 -0
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-a_wuOiYf.d.mts → planner-target-details-Dv5N6x6k.d.mts} +1 -1
- package/dist/{planner-target-details-a_wuOiYf.d.mts.map → planner-target-details-Dv5N6x6k.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +3 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-BnOboPWs.mjs → postgres-contract-serializer-K_3f7YlX.mjs} +33 -24
- package/dist/postgres-contract-serializer-K_3f7YlX.mjs.map +1 -0
- package/dist/{postgres-enum-type-CSzsvXrO.d.mts → postgres-enum-type-CWwVGBNK.d.mts} +1 -1
- package/dist/{postgres-enum-type-CSzsvXrO.d.mts.map → postgres-enum-type-CWwVGBNK.d.mts.map} +1 -1
- package/dist/{postgres-enum-type-BMgyxNyy.mjs → postgres-enum-type-CaGZ2mfI.mjs} +1 -1
- package/dist/{postgres-enum-type-BMgyxNyy.mjs.map → postgres-enum-type-CaGZ2mfI.mjs.map} +1 -1
- package/dist/{postgres-migration-DRY8V-bQ.d.mts → postgres-migration-BcKS2Lqq.d.mts} +3 -3
- package/dist/{postgres-migration-DRY8V-bQ.d.mts.map → postgres-migration-BcKS2Lqq.d.mts.map} +1 -1
- package/dist/{postgres-migration-BatbEvU6.mjs → postgres-migration-BnDg_Nj0.mjs} +3 -3
- package/dist/{postgres-migration-BatbEvU6.mjs.map → postgres-migration-BnDg_Nj0.mjs.map} +1 -1
- package/dist/{postgres-schema-BxAuNFX0.mjs → postgres-schema-BQG4laaB.mjs} +29 -14
- package/dist/postgres-schema-BQG4laaB.mjs.map +1 -0
- package/dist/{render-ops-XhICjX_P.mjs → render-ops-BpU-Qv06.mjs} +1 -1
- package/dist/{render-ops-XhICjX_P.mjs.map → render-ops-BpU-Qv06.mjs.map} +1 -1
- package/dist/render-ops.d.mts +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-K125n-RZ.mjs → render-typescript-D9O7aOS_.mjs} +1 -1
- package/dist/{render-typescript-K125n-RZ.mjs.map → render-typescript-D9O7aOS_.mjs.map} +1 -1
- package/dist/render-typescript.mjs +1 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/{shared-Do_a5ymU.d.mts → shared-CMqM-2BA.d.mts} +2 -2
- package/dist/{shared-Do_a5ymU.d.mts.map → shared-CMqM-2BA.d.mts.map} +1 -1
- package/dist/{sql-utils-CggjWNij.mjs → sql-utils-DR_F9aHR.mjs} +1 -1
- package/dist/{sql-utils-CggjWNij.mjs.map → sql-utils-DR_F9aHR.mjs.map} +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/{tables-DoA39Yqo.mjs → tables-DiNZG5Ln.mjs} +3 -3
- package/dist/{tables-DoA39Yqo.mjs.map → tables-DiNZG5Ln.mjs.map} +1 -1
- package/dist/{types-O40IcFV9.d.mts → types-kggVJs6C.d.mts} +1 -1
- package/dist/types-kggVJs6C.d.mts.map +1 -0
- package/dist/types.d.mts +16 -11
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -2
- package/package.json +20 -18
- package/src/contract-free/columns.ts +49 -0
- package/src/contract-free/control-bootstrap.ts +55 -0
- package/src/contract-free/ddl.ts +32 -0
- package/src/core/ast/table-source.ts +23 -0
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codecs.ts +44 -0
- package/src/core/column-type-compatibility.ts +13 -0
- package/src/core/ddl/nodes.ts +59 -0
- package/src/core/descriptor-meta.ts +1 -0
- package/src/core/migrations/control-policy.ts +234 -0
- package/src/core/migrations/issue-planner.ts +3 -3
- package/src/core/migrations/planner-sql-checks.ts +9 -9
- package/src/core/migrations/planner-strategies.ts +16 -10
- package/src/core/migrations/planner.ts +57 -6
- package/src/core/migrations/runner.ts +78 -45
- package/src/core/postgres-contract-serializer.ts +52 -46
- package/src/core/postgres-schema.ts +43 -25
- package/src/exports/column-type-compatibility.ts +1 -0
- package/src/exports/contract-free.ts +7 -0
- package/src/exports/ddl.ts +7 -0
- package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
- package/dist/codec-ids-DliyCWPY.d.mts.map +0 -1
- package/dist/codecs-DuP3d9Au.d.mts.map +0 -1
- package/dist/descriptor-meta-Uu8QaClr.mjs.map +0 -1
- package/dist/issue-planner-BtaL6OfW.mjs.map +0 -1
- package/dist/planner-Bjz5pnLa.mjs +0 -177
- package/dist/planner-Bjz5pnLa.mjs.map +0 -1
- package/dist/planner-sql-checks-CfEiTXoQ.mjs.map +0 -1
- package/dist/postgres-contract-serializer-BnOboPWs.mjs.map +0 -1
- package/dist/postgres-schema-BxAuNFX0.mjs.map +0 -1
- package/dist/statement-builders-DVI5IVAa.mjs +0 -131
- package/dist/statement-builders-DVI5IVAa.mjs.map +0 -1
- package/dist/statement-builders.d.mts +0 -51
- package/dist/statement-builders.d.mts.map +0 -1
- package/dist/statement-builders.mjs +0 -2
- package/dist/types-O40IcFV9.d.mts.map +0 -1
- package/src/core/migrations/statement-builders.ts +0 -183
- package/src/exports/statement-builders.ts +0 -8
package/dist/{postgres-contract-serializer-BnOboPWs.mjs → postgres-contract-serializer-K_3f7YlX.mjs}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-
|
|
2
|
-
import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-
|
|
1
|
+
import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-BBL7VdnR.mjs";
|
|
2
|
+
import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-BQG4laaB.mjs";
|
|
3
3
|
import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
4
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
5
|
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
5
6
|
import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring";
|
|
6
7
|
//#region src/core/postgres-contract-serializer.ts
|
|
@@ -45,30 +46,36 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
45
46
|
}
|
|
46
47
|
hydrateSqlNamespaceEntry(nsId, raw) {
|
|
47
48
|
if (raw instanceof NamespaceBase) return raw;
|
|
48
|
-
const { id,
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
if (
|
|
49
|
+
const { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));
|
|
50
|
+
const rawEntries = raw["entries"];
|
|
51
|
+
let typeSlot;
|
|
52
|
+
if (rawEntries !== null && typeof rawEntries === "object" && !Array.isArray(rawEntries)) {
|
|
53
|
+
const rawTypeSlot = rawEntries["type"];
|
|
54
|
+
if (rawTypeSlot !== null && typeof rawTypeSlot === "object" && !Array.isArray(rawTypeSlot)) {
|
|
55
|
+
const enumFactory = this.entityTypeRegistry.get("postgres-enum");
|
|
56
|
+
typeSlot = Object.fromEntries(Object.entries(rawTypeSlot).map(([name, entry]) => [name, blindCast(enumFactory !== void 0 ? enumFactory(entry) : entry)]));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const emptyTables = Object.keys(entries.table).length === 0;
|
|
60
|
+
const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;
|
|
61
|
+
if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) return PostgresSchema.unbound;
|
|
52
62
|
return new PostgresSchema({
|
|
53
63
|
id,
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
entries: {
|
|
65
|
+
table: entries.table,
|
|
66
|
+
type: typeSlot ?? {}
|
|
67
|
+
}
|
|
56
68
|
});
|
|
57
69
|
}
|
|
58
70
|
serializeContract(contract) {
|
|
59
71
|
const { storage, ...rest } = contract;
|
|
60
72
|
const namespacesJson = {};
|
|
61
73
|
for (const [nsId, ns] of Object.entries(storage.namespaces)) if (isPostgresSchema(ns)) namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);
|
|
62
|
-
else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
|
|
68
|
-
tables: Object.fromEntries(Object.entries(ns.tables).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])),
|
|
69
|
-
enum: Object.fromEntries(Object.entries(nsEnums).map(([typeName, entry]) => [typeName, this.serializeJsonValue(entry)]))
|
|
70
|
-
};
|
|
71
|
-
}
|
|
74
|
+
else namespacesJson[nsId] = {
|
|
75
|
+
id: nsId,
|
|
76
|
+
kind: nsId === UNBOUND_NAMESPACE_ID ? "postgres-unbound-schema" : "postgres-schema",
|
|
77
|
+
entries: { table: Object.fromEntries(Object.entries(ns.entries.table).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])) }
|
|
78
|
+
};
|
|
72
79
|
const storageOut = {
|
|
73
80
|
storageHash: String(storage.storageHash),
|
|
74
81
|
namespaces: namespacesJson
|
|
@@ -85,14 +92,16 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
85
92
|
}
|
|
86
93
|
serializePostgresNamespace(ns, isUnboundSlot) {
|
|
87
94
|
const tablesOut = {};
|
|
88
|
-
for (const [tableName, table] of Object.entries(ns.
|
|
89
|
-
const
|
|
90
|
-
for (const [typeName, ty] of Object.entries(ns.
|
|
95
|
+
for (const [tableName, table] of Object.entries(ns.entries.table)) tablesOut[tableName] = this.serializeJsonValue(table);
|
|
96
|
+
const typeOut = {};
|
|
97
|
+
for (const [typeName, ty] of Object.entries(ns.entries.type)) typeOut[typeName] = this.serializeJsonValue(ty);
|
|
91
98
|
return {
|
|
92
99
|
id: ns.id,
|
|
93
100
|
kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
entries: {
|
|
102
|
+
table: tablesOut,
|
|
103
|
+
type: typeOut
|
|
104
|
+
}
|
|
96
105
|
};
|
|
97
106
|
}
|
|
98
107
|
serializeJsonValue(value) {
|
|
@@ -102,4 +111,4 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
102
111
|
//#endregion
|
|
103
112
|
export { PostgresContractSerializer as t };
|
|
104
113
|
|
|
105
|
-
//# sourceMappingURL=postgres-contract-serializer-
|
|
114
|
+
//# sourceMappingURL=postgres-contract-serializer-K_3f7YlX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-contract-serializer-K_3f7YlX.mjs","names":["rawRecord"],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport type { Type } from 'arktype';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport type { PostgresEnumType } from './postgres-enum-type';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n typeof (output as AuthoringEntityTypeFactoryOutput).factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits the maps the\n * family base consumes — hydrators and validator-schema fragments, both\n * keyed by the descriptor's `discriminator`.\n */\nfunction collectEntityRegistryContributions(namespace: AuthoringEntityTypeNamespace): {\n readonly entityTypeRegistry: ReadonlyMap<string, SqlEntityHydrationFactory>;\n readonly validatorFragments: ReadonlyMap<string, Type<unknown>>;\n} {\n const entityTypeRegistry = new Map<string, SqlEntityHydrationFactory>();\n const validatorFragments = new Map<string, Type<unknown>>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n entityTypeRegistry.set(value.discriminator, (raw) =>\n factory(raw, POSTGRES_AUTHORING_CTX),\n );\n }\n if (value.validatorSchema !== undefined) {\n validatorFragments.set(value.discriminator, value.validatorSchema);\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return { entityTypeRegistry, validatorFragments };\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n const { entityTypeRegistry, validatorFragments } = collectEntityRegistryContributions(\n postgresAuthoringEntityTypes,\n );\n super(entityTypeRegistry, validatorFragments);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const hydrated = blindCast<\n SqlNamespaceTablesInput,\n 'super.hydrateSqlNamespaceEntry returns the tables form when raw is not a NamespaceBase'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n // Extract the postgres-specific `type` slot directly from raw input.\n // The family base handles the `table` slot; the postgres target owns `type`.\n const rawRecord = raw as Record<string, unknown>;\n const rawEntries = rawRecord['entries'];\n let typeSlot: Record<string, PostgresEnumType> | undefined;\n if (rawEntries !== null && typeof rawEntries === 'object' && !Array.isArray(rawEntries)) {\n const rawTypeSlot = (rawEntries as Record<string, unknown>)['type'];\n if (rawTypeSlot !== null && typeof rawTypeSlot === 'object' && !Array.isArray(rawTypeSlot)) {\n const enumFactory = this.entityTypeRegistry.get('postgres-enum');\n typeSlot = Object.fromEntries(\n Object.entries(rawTypeSlot as Record<string, unknown>).map(([name, entry]) => [\n name,\n blindCast<PostgresEnumType, 'postgres-enum factory returns PostgresEnumType'>(\n enumFactory !== undefined ? enumFactory(entry) : entry,\n ),\n ]),\n );\n }\n }\n\n const emptyTables = Object.keys(entries.table).length === 0;\n const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;\n if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) {\n return PostgresSchema.unbound;\n }\n return new PostgresSchema({\n id,\n entries: {\n table: entries.table,\n type: typeSlot ?? {},\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table).map(([tableName, table]) => [\n tableName,\n this.serializeJsonValue(table) as JsonObject,\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonValue(entry) as JsonObject;\n }\n storageOut['types'] = typesOut;\n }\n return {\n ...rest,\n storage: storageOut,\n } as unknown as JsonObject;\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.entries.table)) {\n tablesOut[tableName] = this.serializeJsonValue(table) as JsonObject;\n }\n const typeOut: Record<string, JsonObject> = {};\n for (const [typeName, ty] of Object.entries(ns.entries.type)) {\n typeOut[typeName] = this.serializeJsonValue(ty) as JsonObject;\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n type: typeOut,\n },\n };\n }\n\n private serializeJsonValue(value: unknown): unknown {\n return JSON.parse(JSON.stringify(value)) as unknown;\n }\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAA4C,YAAY;AAEpE;;;;;;AAOA,SAAS,mCAAmC,WAG1C;CACA,MAAM,qCAAqB,IAAI,IAAuC;CACtE,MAAM,qCAAqB,IAAI,IAA2B;CAC1D,MAAM,QAAQ,SAA6C;EACzD,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GAAG;GACvC,IAAI,gCAAgC,KAAK,GAAG;IAC1C,IAAI,mCAAmC,MAAM,MAAM,GAAG;KACpD,MAAM,EAAE,YAAY,MAAM;KAC1B,mBAAmB,IAAI,MAAM,gBAAgB,QAC3C,QAAQ,KAAK,sBAAsB,CACrC;IACF;IACA,IAAI,MAAM,oBAAoB,KAAA,GAC5B,mBAAmB,IAAI,MAAM,eAAe,MAAM,eAAe;IAEnE;GACF;GACA,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,KAAK,KAAK;EAEd;CACF;CACA,KAAK,SAAS;CACd,OAAO;EAAE;EAAoB;CAAmB;AAClD;AAEA,IAAa,6BAAb,cAAgD,0BAAgD;CAC9F,cAAc;EACZ,MAAM,EAAE,oBAAoB,uBAAuB,mCACjD,4BACF;EACA,MAAM,oBAAoB,kBAAkB;CAC9C;CAEA,yBACE,MACA,KACqC;EACrC,IAAI,eAAe,eACjB,OAAO;EAMT,MAAM,EAAE,IAAI,YAJK,UAGf,MAAM,yBAAyB,MAAM,GAAG,CACX;EAK/B,MAAM,aAAaA,IAAU;EAC7B,IAAI;EACJ,IAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,CAAC,MAAM,QAAQ,UAAU,GAAG;GACvF,MAAM,cAAe,WAAuC;GAC5D,IAAI,gBAAgB,QAAQ,OAAO,gBAAgB,YAAY,CAAC,MAAM,QAAQ,WAAW,GAAG;IAC1F,MAAM,cAAc,KAAK,mBAAmB,IAAI,eAAe;IAC/D,WAAW,OAAO,YAChB,OAAO,QAAQ,WAAsC,EAAE,KAAK,CAAC,MAAM,WAAW,CAC5E,MACA,UACE,gBAAgB,KAAA,IAAY,YAAY,KAAK,IAAI,KACnD,CACF,CAAC,CACH;GACF;EACF;EAEA,MAAM,cAAc,OAAO,KAAK,QAAQ,KAAK,EAAE,WAAW;EAC1D,MAAM,aAAa,CAAC,YAAY,OAAO,KAAK,QAAQ,EAAE,WAAW;EACjE,IAAI,OAAO,wBAAwB,eAAe,YAChD,OAAO,eAAe;EAExB,OAAO,IAAI,eAAe;GACxB;GACA,SAAS;IACP,OAAO,QAAQ;IACf,MAAM,YAAY,CAAC;GACrB;EACF,CAAC;CACH;CAEA,kBAA2B,UAA4C;EACrE,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,iBAA6C,CAAC;EACpD,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,QAAQ,UAAU,GACxD,IAAI,iBAAiB,EAAE,GACrB,eAAe,QAAQ,KAAK,2BAA2B,IAAI,GAAG,OAAO,oBAAoB;OAGzF,eAAe,QAAQ;GACrB,IAAI;GACJ,MAHoB,SAAS,uBAGP,4BAA4B;GAClD,SAAS,EACP,OAAO,OAAO,YACZ,OAAO,QAAQ,GAAG,QAAQ,KAAK,EAAE,KAAK,CAAC,WAAW,WAAW,CAC3D,WACA,KAAK,mBAAmB,KAAK,CAC/B,CAAC,CACH,EACF;EACF;EAGJ,MAAM,aAAsC;GAC1C,aAAa,OAAO,QAAQ,WAAW;GACvC,YAAY;EACd;EACA,IAAI,QAAQ,UAAU,KAAA,GAAW;GAC/B,MAAM,WAAuC,CAAC;GAC9C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,QAAQ,KAAK,GACtD,SAAS,QAAQ,KAAK,mBAAmB,KAAK;GAEhD,WAAW,WAAW;EACxB;EACA,OAAO;GACL,GAAG;GACH,SAAS;EACX;CACF;CAEA,2BAAmC,IAAoB,eAAoC;EACzF,MAAM,YAAwC,CAAC;EAC/C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,GAAG,QAAQ,KAAK,GAC9D,UAAU,aAAa,KAAK,mBAAmB,KAAK;EAEtD,MAAM,UAAsC,CAAC;EAC7C,KAAK,MAAM,CAAC,UAAU,OAAO,OAAO,QAAQ,GAAG,QAAQ,IAAI,GACzD,QAAQ,YAAY,KAAK,mBAAmB,EAAE;EAEhD,OAAO;GACL,IAAI,GAAG;GACP,MAAM,gBAAgB,4BAA4B;GAClD,SAAS;IACP,OAAO;IACP,MAAM;GACR;EACF;CACF;CAEA,mBAA2B,OAAyB;EAClD,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;CACzC;AACF"}
|
|
@@ -69,4 +69,4 @@ declare class PostgresEnumType<TName extends string = string, TValues extends re
|
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
export { PostgresEnumTypeInput as n, PostgresEnumType as t };
|
|
72
|
-
//# sourceMappingURL=postgres-enum-type-
|
|
72
|
+
//# sourceMappingURL=postgres-enum-type-CWwVGBNK.d.mts.map
|
package/dist/{postgres-enum-type-CSzsvXrO.d.mts.map → postgres-enum-type-CWwVGBNK.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enum-type-
|
|
1
|
+
{"version":3,"file":"postgres-enum-type-CWwVGBNK.d.mts","names":[],"sources":["../src/core/postgres-enum-type.ts"],"mappings":";;;;UAIiB,qBAAA;;AAAjB;;;;WASW,IAAA,EAAM,KAAA;EAQI;;;;;EAAA,SAFV,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAAA,SACR,OAAA,GAAU,aAAA;AAAA;;cAIf,gBAAA;;;AAJ4B;AACjC;;;;AAGqB;AAyBtB;;;;;;;;;;;;;;;cAAa,gBAAA,+FAGH,OAAA;EAAA,SACU,IAAA;EAAA,SACT,IAAA,EAAM,KAAA;EAAA,SACN,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAFF;;;;;;;;;EAAA,SAYN,OAAA,SAAgB,gBAAA;EAAA,SACR,OAAA,GAAU,aAAA;cAEf,KAAA,EAAO,qBAAA,CAAsB,KAAA,EAAO,OAAA;EAAA,IAY5C,YAAA,CAAA;IAAA,SACO,OAAA,SAAgB,gBAAA;IAAA,SAChB,UAAA;MAAA,SAAuB,MAAA,EAAQ,OAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enum-type-
|
|
1
|
+
{"version":3,"file":"postgres-enum-type-CaGZ2mfI.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n readonly control?: ControlPolicy;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAyBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAG5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { n as DataTransformOptions } from "./data-transform-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-Dv5N6x6k.mjs";
|
|
2
|
+
import { n as DataTransformOptions } from "./data-transform-5gLOgP68.mjs";
|
|
3
3
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
5
5
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
@@ -47,4 +47,4 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
|
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
49
|
export { PostgresMigration as t };
|
|
50
|
-
//# sourceMappingURL=postgres-migration-
|
|
50
|
+
//# sourceMappingURL=postgres-migration-BcKS2Lqq.d.mts.map
|
package/dist/{postgres-migration-DRY8V-bQ.d.mts.map → postgres-migration-BcKS2Lqq.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-migration-
|
|
1
|
+
{"version":3,"file":"postgres-migration-BcKS2Lqq.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;;;;;;;qBAQU,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAgBlB;;;;;EAAA,UADQ,aAAA,mBAAgC,QAAA,CAAS,UAAA,EAAA,CACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,yBAAA,CAA0B,yBAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as errorPostgresMigrationStackMissing } from "./errors-
|
|
2
|
-
import { t as dataTransform } from "./data-transform-
|
|
1
|
+
import { t as errorPostgresMigrationStackMissing } from "./errors-De185dnO.mjs";
|
|
2
|
+
import { t as dataTransform } from "./data-transform-DIYwbe4S.mjs";
|
|
3
3
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
4
4
|
//#region src/core/migrations/postgres-migration.ts
|
|
5
5
|
/**
|
|
@@ -48,4 +48,4 @@ var PostgresMigration = class extends Migration {
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { PostgresMigration as t };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=postgres-migration-
|
|
51
|
+
//# sourceMappingURL=postgres-migration-BnDg_Nj0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-migration-
|
|
1
|
+
{"version":3,"file":"postgres-migration-BnDg_Nj0.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SACsD;EACtD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as PostgresEnumType } from "./postgres-enum-type-
|
|
2
|
-
import { n as escapeLiteral } from "./sql-utils-
|
|
1
|
+
import { t as PostgresEnumType } from "./postgres-enum-type-CaGZ2mfI.mjs";
|
|
2
|
+
import { n as escapeLiteral } from "./sql-utils-DR_F9aHR.mjs";
|
|
3
3
|
import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
|
|
4
4
|
import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
5
5
|
//#region src/core/postgres-schema.ts
|
|
@@ -9,9 +9,10 @@ import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
|
9
9
|
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
10
10
|
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* `entries` holds entity-kind slot maps (`table`, `type`). Qualifier
|
|
13
|
+
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
14
|
+
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
15
|
+
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
15
16
|
* The unbound singleton below overrides these methods to elide the
|
|
16
17
|
* prefix entirely — call sites stay polymorphic and never branch on
|
|
17
18
|
* `id === UNBOUND_NAMESPACE_ID`.
|
|
@@ -26,13 +27,14 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
26
27
|
*/
|
|
27
28
|
static unbound;
|
|
28
29
|
id;
|
|
29
|
-
|
|
30
|
-
enum;
|
|
30
|
+
entries;
|
|
31
31
|
constructor(input) {
|
|
32
32
|
super();
|
|
33
33
|
this.id = input.id;
|
|
34
|
-
this.
|
|
35
|
-
|
|
34
|
+
this.entries = Object.freeze({
|
|
35
|
+
table: Object.freeze(Object.fromEntries(Object.entries(input.entries.table).map(([k, v]) => [k, v instanceof StorageTable ? v : new StorageTable(v)]))),
|
|
36
|
+
type: Object.freeze(Object.fromEntries(Object.entries(input.entries.type).map(([k, v]) => [k, v instanceof PostgresEnumType ? v : new PostgresEnumType(v)])))
|
|
37
|
+
});
|
|
36
38
|
Object.defineProperty(this, "kind", {
|
|
37
39
|
value: "schema",
|
|
38
40
|
writable: false,
|
|
@@ -115,7 +117,13 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
115
117
|
var PostgresUnboundSchema = class PostgresUnboundSchema extends PostgresSchema {
|
|
116
118
|
static instance = new PostgresUnboundSchema();
|
|
117
119
|
constructor(input) {
|
|
118
|
-
super(input ?? {
|
|
120
|
+
super(input ?? {
|
|
121
|
+
id: UNBOUND_NAMESPACE_ID,
|
|
122
|
+
entries: {
|
|
123
|
+
table: {},
|
|
124
|
+
type: {}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
119
127
|
}
|
|
120
128
|
qualifier() {
|
|
121
129
|
return "";
|
|
@@ -151,11 +159,18 @@ function isPostgresSchema(ns) {
|
|
|
151
159
|
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
152
160
|
* be value-stable for a given input set.
|
|
153
161
|
*/
|
|
154
|
-
function postgresCreateNamespace(input) {
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
function postgresCreateNamespace(input, enumTypes) {
|
|
163
|
+
const schemaInput = {
|
|
164
|
+
id: input.id,
|
|
165
|
+
entries: {
|
|
166
|
+
table: input.entries.table,
|
|
167
|
+
type: enumTypes ?? {}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
if (input.id === UNBOUND_NAMESPACE_ID) return new PostgresUnboundSchema(schemaInput);
|
|
171
|
+
return new PostgresSchema(schemaInput);
|
|
157
172
|
}
|
|
158
173
|
//#endregion
|
|
159
174
|
export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
|
|
160
175
|
|
|
161
|
-
//# sourceMappingURL=postgres-schema-
|
|
176
|
+
//# sourceMappingURL=postgres-schema-BQG4laaB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-BQG4laaB.mjs","names":[],"sources":["../src/core/postgres-schema.ts"],"sourcesContent":["import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport {\n type PostgresEnumStorageEntry,\n type SqlNamespaceTablesInput,\n type SqlStorage,\n StorageTable,\n type StorageTableInput,\n} from '@prisma-next/sql-contract/types';\nimport { PostgresEnumType, type PostgresEnumTypeInput } from './postgres-enum-type';\nimport { escapeLiteral } from './sql-utils';\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: {\n readonly table: Record<string, StorageTable | StorageTableInput>;\n readonly type: Record<string, PostgresEnumType | PostgresEnumTypeInput>;\n };\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind slot maps (`table`, `type`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends NamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: Readonly<{\n readonly table: Readonly<Record<string, StorageTable>>;\n readonly type: Readonly<Record<string, PostgresEnumType>>;\n }>;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n this.entries = Object.freeze({\n table: Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.table).map(([k, v]) => [\n k,\n v instanceof StorageTable ? v : new StorageTable(v as StorageTableInput),\n ]),\n ),\n ),\n type: Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.type).map(([k, v]) => [\n k,\n v instanceof PostgresEnumType ? v : new PostgresEnumType(v as PostgresEnumTypeInput),\n ]),\n ),\n ),\n });\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` / `toRegclassLiteral` route through the\n * polymorphic `PostgresUnboundSchema` overrides and produce\n * unqualified (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers (`qualifyTableName`,\n * `toRegclassLiteral`) route through the polymorphic factory and\n * produce unqualified output automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {}, type: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set.\n */\nexport function postgresCreateNamespace(\n input: SqlNamespaceTablesInput,\n enumTypes?: Readonly<Record<string, PostgresEnumStorageEntry>>,\n): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n table: input.entries.table,\n type: (enumTypes ?? {}) as Record<string, PostgresEnumTypeInput>,\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAa,iBAAb,cAAoC,cAAc;;;;;;;;CAQhD,OAAO;CAGP;CACA;CAKA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAChB,KAAK,UAAU,OAAO,OAAO;GAC3B,OAAO,OAAO,OACZ,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,KAAK,EAAE,KAAK,CAAC,GAAG,OAAO,CAClD,GACA,aAAa,eAAe,IAAI,IAAI,aAAa,CAAsB,CACzE,CAAC,CACH,CACF;GACA,MAAM,OAAO,OACX,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CACjD,GACA,aAAa,mBAAmB,IAAI,IAAI,iBAAiB,CAA0B,CACrF,CAAC,CACH,CACF;EACF,CAAC;EACD,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;;;;;;CAOA,YAAoB;EAClB,OAAO,IAAI,KAAK,GAAG;CACrB;;;;;;;CAQA,aAAa,WAA2B;EACtC,OAAO,IAAI,KAAK,GAAG,KAAK,UAAU;CACpC;;;;;;;CAQA,gBAAgB,MAAsB;EACpC,OAAO,IAAI,cAAc,KAAK,aAAa,IAAI,CAAC,EAAE;CACpD;;;;;;;;;CAUA,sBAA8B;EAC5B,OAAO,IAAI,cAAc,KAAK,EAAE,EAAE;CACpC;;;;;;;;;;;;CAaA,cAAc,UAA8B;EAC1C,OAAO,KAAK;CACd;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,OAAgB,WAAkC,IAAI,sBAAsB;CAE5E,YAAY,OAA6B;EACvC,MAAM,SAAS;GAAE,IAAI;GAAsB,SAAS;IAAE,OAAO,CAAC;IAAG,MAAM,CAAC;GAAE;EAAE,CAAC;CAC/E;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;AAaA,SAAgB,wBACd,OACA,WACgB;CAChB,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,OAAO,MAAM,QAAQ;GACrB,MAAO,aAAa,CAAC;EACvB;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops-
|
|
1
|
+
{"version":3,"file":"render-ops-BpU-Qv06.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Asserts an op materialised by an `OpFactoryCall` targets postgres. The\n * extension surface lets any contributor emit calls, so this is the\n * integration boundary where a stray non-postgres op would otherwise\n * silently flow through to postgres-shaped renderers — exactly the\n * place to fail loudly with op metadata (`id` + `target.id`).\n */\nfunction assertPostgresOp(\n op: ReturnType<OpFactoryCall['toOp']>,\n callFactoryName: string,\n): asserts op is Op {\n const targetId = (op as Partial<Op>).target?.id;\n if (targetId !== 'postgres') {\n throw new Error(\n `renderOps: expected postgres op but got target.id=\"${String(targetId)}\" for op.id=\"${op.id}\" (factoryName=\"${callFactoryName}\"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`,\n );\n }\n}\n\nexport function renderOps(calls: readonly OpFactoryCall[]): Op[] {\n return calls.map((c) => {\n const op = c.toOp();\n assertPostgresOp(op, c.factoryName);\n return op;\n });\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,iBACP,IACA,iBACkB;CAClB,MAAM,WAAY,GAAmB,QAAQ;CAC7C,IAAI,aAAa,YACf,MAAM,IAAI,MACR,sDAAsD,OAAO,QAAQ,EAAE,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,0HAChI;AAEJ;AAEA,SAAgB,UAAU,OAAuC;CAC/D,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,KAAK,EAAE,KAAK;EAClB,iBAAiB,IAAI,EAAE,WAAW;EAClC,OAAO;CACT,CAAC;AACH"}
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-Dv5N6x6k.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
4
4
|
|
package/dist/render-ops.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as renderOps } from "./render-ops-
|
|
1
|
+
import { t as renderOps } from "./render-ops-BpU-Qv06.mjs";
|
|
2
2
|
export { renderOps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-typescript-
|
|
1
|
+
{"version":3,"file":"render-typescript-D9O7aOS_.mjs","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `OpFactoryCall` renders itself via `renderTypeScript()` and\n * declares its own `importRequirements()`; this file just composes the module\n * source around those contributions. The design mirrors the Mongo target's\n * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required\n * (different factory module specifiers, different base-class name) but the\n * shape is, so future consolidation to a framework-level helper is mechanical.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/postgres/migration` so an authored Postgres\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint:\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `PostgresPlanTargetDetails` and the abstract `targetId`\n * to `'postgres'`, so user-authored migrations don't need to thread\n * target-details or redeclare `targetId`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n * The migration file owns this dependency directly: pulling CLI\n * machinery in at script run time is acceptable because the script's\n * whole purpose is to be invoked from the project that owns the\n * config.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAmC,QAAQ;AAAY,GAC1E;CAAE,iBAAiB;CAAmC,QAAQ;AAAe,CAC/E;AAEA,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,KAAK;CAClC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,iBAAiB,CAAC,EAAE,KAAK,KAAK;CAExE,OAAO;EACL,eAAe,sBAAsB,CAAC;EACtC;EACA;EACA;EACA,oBAAoB,IAAI;EACxB;EACA;EACA,OAAO,gBAAgB,CAAC;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,EAAE,KAAK,IAAI;AACb;AAEA,SAAS,aAAa,OAA6C;CACjE,MAAM,eAAoC,CAAC,GAAG,YAAY;CAC1D,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,mBAAmB,GACxC,aAAa,KAAK,GAAG;CAGzB,OAAO,cAAc,YAAY;AACnC;AAEA,SAAS,oBAAoB,MAAmC;CAC9D,MAAM,QAAkB,CAAC;CACzB,MAAM,KAAK,yBAAyB;CACpC,MAAM,KAAK,cAAc;CACzB,MAAM,KAAK,eAAe,KAAK,UAAU,KAAK,IAAI,EAAE,EAAE;CACtD,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,EAAE,EAAE,EAAE;CAClD,MAAM,KAAK,QAAQ;CACnB,MAAM,KAAK,KAAK;CAChB,MAAM,KAAK,EAAE;CACb,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,MAAM;CAC7B,OAAO,KACJ,MAAM,IAAI,EACV,KAAK,SAAU,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,IAAK,EACpD,KAAK,IAAI;AACd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as renderCallsToTypeScript } from "./render-typescript-
|
|
1
|
+
import { t as renderCallsToTypeScript } from "./render-typescript-D9O7aOS_.mjs";
|
|
2
2
|
export { renderCallsToTypeScript };
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAyEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;YAQ9D,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA4CN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QAmBA,kBAAA;AAAA;;;UCjLO,6BAAA,SAAsC,qBAAqB;;;;;ADgE5E;;cCxDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-
|
|
2
|
-
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-
|
|
1
|
+
import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-BBL7VdnR.mjs";
|
|
2
|
+
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-K_3f7YlX.mjs";
|
|
3
3
|
//#region src/exports/runtime.ts
|
|
4
4
|
/**
|
|
5
5
|
* Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-Dv5N6x6k.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ReferentialAction } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
@@ -40,4 +40,4 @@ interface ForeignKeySpec {
|
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
42
|
export { ForeignKeySpec as n, Op as r, ColumnSpec as t };
|
|
43
|
-
//# sourceMappingURL=shared-
|
|
43
|
+
//# sourceMappingURL=shared-CMqM-2BA.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-CMqM-2BA.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAyB,CAAC,yBAAA;;AAA3C;;;;AAAoE;AAcpE;;;;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;AAAA;;;;;;UAQM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA"}
|
|
@@ -75,4 +75,4 @@ function validateEnumValueLength(value, enumTypeName) {
|
|
|
75
75
|
//#endregion
|
|
76
76
|
export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
|
|
77
77
|
|
|
78
|
-
//# sourceMappingURL=sql-utils-
|
|
78
|
+
//# sourceMappingURL=sql-utils-DR_F9aHR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-utils-
|
|
1
|
+
{"version":3,"file":"sql-utils-DR_F9aHR.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres target.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n *\n * They live in `target-postgres` because both the control adapter (used at\n * emit time) and the runtime adapter (used at execute time) need the same\n * escaping/validation behavior, and the target package is the natural shared\n * home that both adapters can depend on without crossing planes.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,YAAY;CAEjF,IAAI,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,KAAK,GAC/B,YACF;CAEF,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,EAAE,EAAE,4BAA4B,sBAAsB,uCAC3F;CAEF,OAAO,IAAI,WAAW,QAAQ,MAAM,MAAI,EAAE;AAC5C;;;;;;;;;;;;AAaA,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,IAAI,GACrB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,KAAK,GAC1B,SACF;CAEF,OAAO,MAAM,QAAQ,MAAM,IAAI;AACjC;;;;AAKA,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,UAAU,EAAE,GAAG,gBAAgB,UAAU;AACrE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,MAAM,SAAS,uBACjB,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,EAAE,EAAE,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,SACF;AAEJ"}
|
package/dist/sql-utils.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-
|
|
1
|
+
import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-DR_F9aHR.mjs";
|
|
2
2
|
export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as quoteIdentifier, n as escapeLiteral, r as qualifyName } from "./sql-utils-
|
|
2
|
-
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, n as columnDefaultExistsCheck, o as columnTypeCheck, r as columnExistsCheck, s as constraintExistsCheck } from "./planner-sql-checks-
|
|
1
|
+
import { i as quoteIdentifier, n as escapeLiteral, r as qualifyName } from "./sql-utils-DR_F9aHR.mjs";
|
|
2
|
+
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, n as columnDefaultExistsCheck, o as columnTypeCheck, r as columnExistsCheck, s as constraintExistsCheck } from "./planner-sql-checks-C43dcyOd.mjs";
|
|
3
3
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
4
4
|
//#region src/core/migrations/operations/shared.ts
|
|
5
5
|
function step(description, sql) {
|
|
@@ -513,4 +513,4 @@ function dropTable(schemaName, tableName) {
|
|
|
513
513
|
//#endregion
|
|
514
514
|
export { setNotNull as S, alterColumnType as _, addEnumValues as a, dropNotNull as b, renameType as c, installExtension as d, addForeignKey as f, addColumn as g, dropConstraint as h, dropIndex as i, createExtension as l, addUnique as m, dropTable as n, createEnumType as o, addPrimaryKey as p, createIndex as r, dropEnumType as s, createTable as t, createSchema as u, dropColumn as v, setDefault as x, dropDefault as y };
|
|
515
515
|
|
|
516
|
-
//# sourceMappingURL=tables-
|
|
516
|
+
//# sourceMappingURL=tables-DiNZG5Ln.mjs.map
|