@prisma-next/target-postgres 0.12.0 → 0.13.0-dev.10
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-D9fJ4HP5.d.mts → codec-ids-B1vOchLE.d.mts} +3 -2
- package/dist/codec-ids-B1vOchLE.d.mts.map +1 -0
- package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-CTikp1if.mjs} +3 -2
- package/dist/codec-ids-CTikp1if.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-CRlHq7Cz.d.mts → codec-types-CnFiNML4.d.mts} +8 -9
- package/dist/codec-types-CnFiNML4.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -2
- package/dist/{codecs-Dud5KDNk.d.mts → codecs-CBpEv4s5.d.mts} +33 -35
- package/dist/codecs-CBpEv4s5.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/contract-free.d.mts +80 -0
- package/dist/contract-free.d.mts.map +1 -0
- package/dist/contract-free.mjs +117 -0
- package/dist/contract-free.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +67 -41
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-CdtGUWp2.mjs → data-transform-D25tLeYU.mjs} +1 -1
- package/dist/{data-transform-CdtGUWp2.mjs.map → data-transform-D25tLeYU.mjs.map} +1 -1
- package/dist/{data-transform-bmOKkygi.d.mts → data-transform-DGOqcLrf.d.mts} +2 -2
- package/dist/{data-transform-bmOKkygi.d.mts.map → data-transform-DGOqcLrf.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/ddl-77SyXgFt.mjs +30 -0
- package/dist/ddl-77SyXgFt.mjs.map +1 -0
- package/dist/ddl.d.mts +2 -0
- package/dist/ddl.mjs +2 -0
- package/dist/{default-normalizer-CRscvhS5.mjs → default-normalizer-DyyCHQWs.mjs} +1 -1
- package/dist/{default-normalizer-CRscvhS5.mjs.map → default-normalizer-DyyCHQWs.mjs.map} +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/descriptor-meta-DKmj-IMN.mjs +14 -0
- package/dist/descriptor-meta-DKmj-IMN.mjs.map +1 -0
- package/dist/{descriptor-meta-DLA2xV6B.mjs → descriptor-meta-runtime-My8_s4cs.mjs} +82 -78
- package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +1 -0
- package/dist/{enum-planning-Dz0Ye3Lb.mjs → enum-planning-DTMrPLkN.mjs} +0 -0
- package/dist/enum-planning-DTMrPLkN.mjs.map +1 -0
- package/dist/enum-planning.d.mts +14 -8
- package/dist/enum-planning.d.mts.map +1 -1
- package/dist/enum-planning.mjs +2 -2
- package/dist/{errors--zafB5_n.mjs → errors-CUk87ByX.mjs} +1 -1
- package/dist/{errors--zafB5_n.mjs.map → errors-CUk87ByX.mjs.map} +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{issue-planner-ByQhUzS4.mjs → issue-planner-B0A7RFN2.mjs} +130 -28
- package/dist/issue-planner-B0A7RFN2.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 +7 -8
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +5 -4
- package/dist/migration.mjs.map +1 -1
- package/dist/{native-type-normalizer-ClNPq__-.mjs → native-type-normalizer-Bc9XJzWC.mjs} +1 -1
- package/dist/{native-type-normalizer-ClNPq__-.mjs.map → native-type-normalizer-Bc9XJzWC.mjs.map} +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/nodes-779hmCfL.d.mts +40 -0
- package/dist/nodes-779hmCfL.d.mts.map +1 -0
- package/dist/nodes-DZk2JZG3.mjs +47 -0
- package/dist/nodes-DZk2JZG3.mjs.map +1 -0
- package/dist/op-factory-call-Clp7Zr1z.mjs +1307 -0
- package/dist/op-factory-call-Clp7Zr1z.mjs.map +1 -0
- package/dist/{op-factory-call-Drccm_JD.d.mts → op-factory-call-DMA86_2D.d.mts} +39 -14
- package/dist/op-factory-call-DMA86_2D.d.mts.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 +13 -12
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-DID7RZCQ.mjs +344 -0
- package/dist/planner-DID7RZCQ.mjs.map +1 -0
- package/dist/{planner-ddl-builders-BxRCSn_b.mjs → planner-ddl-builders-Cw2n2llW.mjs} +7 -30
- package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +6 -7
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/{planner-identity-values-ojX-6cPV.mjs → planner-identity-values-BIpa5p2I.mjs} +1 -1
- package/dist/{planner-identity-values-ojX-6cPV.mjs.map → planner-identity-values-BIpa5p2I.mjs.map} +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-p-VKkCia.d.mts → planner-produced-postgres-migration-B4EDvLdz.d.mts} +5 -4
- package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-N1yqYg20.mjs → planner-produced-postgres-migration-B8gZBPOR.mjs} +8 -6
- package/dist/planner-produced-postgres-migration-B8gZBPOR.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-schema-lookup-BGyukuzG.mjs → planner-schema-lookup-CiVaAQP-.mjs} +1 -1
- package/dist/{planner-schema-lookup-BGyukuzG.mjs.map → planner-schema-lookup-CiVaAQP-.mjs.map} +1 -1
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-D3H-xOO1.mjs → planner-sql-checks-DRD5E8A1.mjs} +41 -30
- package/dist/planner-sql-checks-DRD5E8A1.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIj61DUj.d.mts → planner-target-details-CIY6tLeo.d.mts} +2 -2
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +2 -2
- package/dist/planner-type-resolution-836DExFN.mjs +20 -0
- package/dist/planner-type-resolution-836DExFN.mjs.map +1 -0
- package/dist/planner.d.mts +7 -3
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-YJvjKrmo.mjs → postgres-contract-serializer-DCg7YaP3.mjs} +40 -24
- package/dist/postgres-contract-serializer-DCg7YaP3.mjs.map +1 -0
- package/dist/{postgres-enum-type-CNhPTDhy.d.mts → postgres-enum-type-BVn63a89.d.mts} +4 -1
- package/dist/postgres-enum-type-BVn63a89.d.mts.map +1 -0
- package/dist/{postgres-enum-type-DS-KLVRH.mjs → postgres-enum-type-DPKqCBem.mjs} +2 -1
- package/dist/postgres-enum-type-DPKqCBem.mjs.map +1 -0
- package/dist/{postgres-migration-uADmx0dW.mjs → postgres-migration-BCQEjFHK.mjs} +23 -3
- package/dist/postgres-migration-BCQEjFHK.mjs.map +1 -0
- package/dist/{postgres-migration-Fd4fQkBw.d.mts → postgres-migration-DZ_gLUOW.d.mts} +25 -3
- package/dist/postgres-migration-DZ_gLUOW.d.mts.map +1 -0
- package/dist/{postgres-schema-Bm7vjlOv.mjs → postgres-schema-BVTA2QH7.mjs} +41 -15
- package/dist/postgres-schema-BVTA2QH7.mjs.map +1 -0
- package/dist/{render-ops-BC2PtCkj.mjs → render-ops-BpjstrKQ.mjs} +4 -3
- package/dist/{render-ops-BC2PtCkj.mjs.map → render-ops-BpjstrKQ.mjs.map} +1 -1
- package/dist/render-ops.d.mts +3 -2
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-CPk7hhWH.mjs → render-typescript-KMgosran.mjs} +5 -2
- package/dist/render-typescript-KMgosran.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-ByhSooBS.d.mts → shared-DarONYBZ.d.mts} +5 -5
- package/dist/{shared-ByhSooBS.d.mts.map → shared-DarONYBZ.d.mts.map} +1 -1
- package/dist/{sql-utils-B_ruBD-M.mjs → sql-utils-DcfMz4MQ.mjs} +1 -1
- package/dist/{sql-utils-B_ruBD-M.mjs.map → sql-utils-DcfMz4MQ.mjs.map} +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/{types-D-XIpzHA.d.mts → types-BDKkx8MA.d.mts} +1 -1
- package/dist/types-BDKkx8MA.d.mts.map +1 -0
- package/dist/types.d.mts +18 -11
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -2
- package/package.json +21 -20
- package/src/contract-free/columns.ts +49 -0
- package/src/contract-free/control-bootstrap.ts +55 -0
- package/src/contract-free/ddl.ts +37 -0
- package/src/core/ast/table-source.ts +23 -0
- package/src/core/authoring.ts +1 -1
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codecs.ts +44 -0
- package/src/core/ddl/nodes.ts +72 -0
- package/src/core/descriptor-meta-runtime.ts +28 -0
- package/src/core/descriptor-meta.ts +3 -6
- package/src/core/migrations/control-policy.ts +234 -0
- package/src/core/migrations/enum-planning.ts +33 -29
- package/src/core/migrations/issue-planner.ts +81 -13
- package/src/core/migrations/op-factory-call.ts +289 -46
- package/src/core/migrations/operations/constraints.ts +79 -10
- package/src/core/migrations/operations/dependencies.ts +0 -17
- package/src/core/migrations/operations/shared.ts +3 -3
- package/src/core/migrations/operations/tables.ts +1 -39
- package/src/core/migrations/planner-ddl-builders.ts +7 -48
- package/src/core/migrations/planner-produced-postgres-migration.ts +11 -6
- package/src/core/migrations/planner-sql-checks.ts +9 -9
- package/src/core/migrations/planner-strategies.ts +149 -11
- package/src/core/migrations/planner-target-details.ts +2 -1
- package/src/core/migrations/planner.ts +66 -8
- package/src/core/migrations/postgres-migration.ts +41 -0
- package/src/core/migrations/render-ops.ts +7 -2
- package/src/core/migrations/render-typescript.ts +5 -1
- package/src/core/migrations/runner.ts +78 -50
- package/src/core/postgres-contract-serializer.ts +66 -46
- package/src/core/postgres-enum-type.ts +4 -0
- package/src/core/postgres-schema.ts +56 -19
- package/src/exports/contract-free.ts +7 -0
- package/src/exports/control.ts +15 -24
- package/src/exports/ddl.ts +7 -0
- package/src/exports/enum-planning.ts +0 -1
- package/src/exports/migration.ts +11 -2
- package/src/exports/op-factory-call.ts +2 -0
- package/src/exports/planner-ddl-builders.ts +0 -1
- package/src/exports/runtime.ts +2 -2
- package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
- package/dist/codec-ids-D9fJ4HP5.d.mts.map +0 -1
- package/dist/codec-types-CRlHq7Cz.d.mts.map +0 -1
- package/dist/codecs-Dud5KDNk.d.mts.map +0 -1
- package/dist/descriptor-meta-DLA2xV6B.mjs.map +0 -1
- package/dist/enum-planning-Dz0Ye3Lb.mjs.map +0 -1
- package/dist/issue-planner-ByQhUzS4.mjs.map +0 -1
- package/dist/op-factory-call-B0WNg30h.mjs +0 -625
- package/dist/op-factory-call-B0WNg30h.mjs.map +0 -1
- package/dist/op-factory-call-Drccm_JD.d.mts.map +0 -1
- package/dist/planner-ClF0y0YR.mjs +0 -177
- package/dist/planner-ClF0y0YR.mjs.map +0 -1
- package/dist/planner-ddl-builders-BxRCSn_b.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-N1yqYg20.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-p-VKkCia.d.mts.map +0 -1
- package/dist/planner-sql-checks-D3H-xOO1.mjs.map +0 -1
- package/dist/planner-target-details-CIj61DUj.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-YJvjKrmo.mjs.map +0 -1
- package/dist/postgres-enum-type-CNhPTDhy.d.mts.map +0 -1
- package/dist/postgres-enum-type-DS-KLVRH.mjs.map +0 -1
- package/dist/postgres-migration-Fd4fQkBw.d.mts.map +0 -1
- package/dist/postgres-migration-uADmx0dW.mjs.map +0 -1
- package/dist/postgres-schema-Bm7vjlOv.mjs.map +0 -1
- package/dist/render-typescript-CPk7hhWH.mjs.map +0 -1
- package/dist/statement-builders-vImtdfmM.mjs +0 -131
- package/dist/statement-builders-vImtdfmM.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/tables-Dcb2q9zV.mjs +0 -516
- package/dist/tables-Dcb2q9zV.mjs.map +0 -1
- package/dist/types-D-XIpzHA.d.mts.map +0 -1
- package/src/core/migrations/statement-builders.ts +0 -183
- package/src/exports/statement-builders.ts +0 -8
|
@@ -1,5 +1,6 @@
|
|
|
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-CIY6tLeo.mjs";
|
|
2
|
+
import { n as DataTransformOptions } from "./data-transform-DGOqcLrf.mjs";
|
|
3
|
+
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
3
4
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
5
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
5
6
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
@@ -44,7 +45,28 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
|
|
|
44
45
|
* `get operations()`; the adapter argument is hidden from the call site.
|
|
45
46
|
*/
|
|
46
47
|
protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
48
|
+
/**
|
|
49
|
+
* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
|
|
50
|
+
* the supplied options and lowers it through the stored control adapter.
|
|
51
|
+
* Throws if no adapter is present (i.e. migration instantiated without a stack).
|
|
52
|
+
*/
|
|
53
|
+
protected createTable(options: {
|
|
54
|
+
readonly schema?: string;
|
|
55
|
+
readonly table: string;
|
|
56
|
+
readonly ifNotExists?: boolean;
|
|
57
|
+
readonly columns: readonly DdlColumn[];
|
|
58
|
+
readonly constraints?: readonly DdlTableConstraint[];
|
|
59
|
+
}): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
60
|
+
/**
|
|
61
|
+
* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
|
|
62
|
+
* the supplied options and lowers it through the stored control adapter.
|
|
63
|
+
* Throws if no adapter is present (i.e. migration instantiated without a stack).
|
|
64
|
+
*/
|
|
65
|
+
protected createSchema(options: {
|
|
66
|
+
readonly schema: string;
|
|
67
|
+
readonly ifNotExists?: boolean;
|
|
68
|
+
}): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
47
69
|
}
|
|
48
70
|
//#endregion
|
|
49
71
|
export { PostgresMigration as t };
|
|
50
|
-
//# sourceMappingURL=postgres-migration-
|
|
72
|
+
//# sourceMappingURL=postgres-migration-DZ_gLUOW.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-DZ_gLUOW.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EAJiD;;;;;;EAAA,mBAYvC,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAAR;;;;;EAAA,UAeF,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,yBAAA,CAA0B,yBAAA;EAH3B;;;;;EAAA,UAeQ,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,yBAAA,CAA0B,yBAAA;EADnB;;;;;EAAA,UAkBD,YAAA,CAAa,OAAA;IAAA,SACZ,MAAA;IAAA,SACA,WAAA;EAAA,IACP,yBAAA,CAA0B,yBAAA;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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-DPKqCBem.mjs";
|
|
2
|
+
import { n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
|
|
3
3
|
import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
|
|
4
|
-
import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
|
|
5
5
|
//#region src/core/postgres-schema.ts
|
|
6
6
|
/**
|
|
7
7
|
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
@@ -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,24 @@ 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
|
-
|
|
35
|
-
|
|
34
|
+
const table = Object.freeze(Object.fromEntries(Object.entries(input.entries.table).map(([k, v]) => [k, v instanceof StorageTable ? v : new StorageTable(v)])));
|
|
35
|
+
const type = Object.freeze(Object.fromEntries(Object.entries(input.entries.type).map(([k, v]) => [k, v instanceof PostgresEnumType ? v : new PostgresEnumType(v)])));
|
|
36
|
+
const valueSetInput = input.entries.valueSet;
|
|
37
|
+
this.entries = valueSetInput !== void 0 && Object.keys(valueSetInput).length > 0 ? Object.freeze({
|
|
38
|
+
table,
|
|
39
|
+
type,
|
|
40
|
+
valueSet: Object.freeze(Object.fromEntries(Object.entries(valueSetInput).map(([k, v]) => [k, new StorageValueSet({
|
|
41
|
+
kind: "value-set",
|
|
42
|
+
values: v.values
|
|
43
|
+
})])))
|
|
44
|
+
}) : Object.freeze({
|
|
45
|
+
table,
|
|
46
|
+
type
|
|
47
|
+
});
|
|
36
48
|
Object.defineProperty(this, "kind", {
|
|
37
49
|
value: "schema",
|
|
38
50
|
writable: false,
|
|
@@ -115,7 +127,13 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
115
127
|
var PostgresUnboundSchema = class PostgresUnboundSchema extends PostgresSchema {
|
|
116
128
|
static instance = new PostgresUnboundSchema();
|
|
117
129
|
constructor(input) {
|
|
118
|
-
super(input ?? {
|
|
130
|
+
super(input ?? {
|
|
131
|
+
id: UNBOUND_NAMESPACE_ID,
|
|
132
|
+
entries: {
|
|
133
|
+
table: {},
|
|
134
|
+
type: {}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
119
137
|
}
|
|
120
138
|
qualifier() {
|
|
121
139
|
return "";
|
|
@@ -151,11 +169,19 @@ function isPostgresSchema(ns) {
|
|
|
151
169
|
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
152
170
|
* be value-stable for a given input set.
|
|
153
171
|
*/
|
|
154
|
-
function postgresCreateNamespace(input) {
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
function postgresCreateNamespace(input, enumTypes) {
|
|
173
|
+
const schemaInput = {
|
|
174
|
+
id: input.id,
|
|
175
|
+
entries: {
|
|
176
|
+
table: input.entries.table,
|
|
177
|
+
type: enumTypes ?? {},
|
|
178
|
+
...input.entries.valueSet !== void 0 ? { valueSet: input.entries.valueSet } : {}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
if (input.id === UNBOUND_NAMESPACE_ID) return new PostgresUnboundSchema(schemaInput);
|
|
182
|
+
return new PostgresSchema(schemaInput);
|
|
157
183
|
}
|
|
158
184
|
//#endregion
|
|
159
185
|
export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
|
|
160
186
|
|
|
161
|
-
//# sourceMappingURL=postgres-schema-
|
|
187
|
+
//# sourceMappingURL=postgres-schema-BVTA2QH7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-BVTA2QH7.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 StorageValueSet,\n type StorageValueSetInput,\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 readonly valueSet?: Record<string, StorageValueSet | StorageValueSetInput>;\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 readonly valueSet?: Readonly<Record<string, StorageValueSet>>;\n }>;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n const 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 const 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 const valueSetInput = input.entries.valueSet;\n this.entries =\n valueSetInput !== undefined && Object.keys(valueSetInput).length > 0\n ? Object.freeze({\n table,\n type,\n valueSet: Object.freeze(\n Object.fromEntries(\n Object.entries(valueSetInput).map(([k, v]) => [\n k,\n new StorageValueSet({ kind: 'value-set', values: v.values }),\n ]),\n ),\n ),\n })\n : Object.freeze({ table, type });\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 ...(input.entries.valueSet !== undefined ? { valueSet: input.entries.valueSet } : {}),\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,IAAa,iBAAb,cAAoC,cAAc;;;;;;;;CAQhD,OAAO;CAGP;CACA;CAMA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAChB,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAClD,GACA,aAAa,eAAe,IAAI,IAAI,aAAa,CAAsB,CACzE,CAAC,CACH,CACF;EACA,MAAM,OAAO,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CACjD,GACA,aAAa,mBAAmB,IAAI,IAAI,iBAAiB,CAA0B,CACrF,CAAC,CACH,CACF;EACA,MAAM,gBAAgB,MAAM,QAAQ;EACpC,KAAK,UACH,kBAAkB,KAAA,KAAa,OAAO,KAAK,aAAa,CAAC,CAAC,SAAS,IAC/D,OAAO,OAAO;GACZ;GACA;GACA,UAAU,OAAO,OACf,OAAO,YACL,OAAO,QAAQ,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAC5C,GACA,IAAI,gBAAgB;IAAE,MAAM;IAAa,QAAQ,EAAE;GAAO,CAAC,CAC7D,CAAC,CACH,CACF;EACF,CAAC,IACD,OAAO,OAAO;GAAE;GAAO;EAAK,CAAC;EACnC,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;GACrB,GAAI,MAAM,QAAQ,aAAa,KAAA,IAAY,EAAE,UAAU,MAAM,QAAQ,SAAS,IAAI,CAAC;EACrF;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
1
2
|
//#region src/core/migrations/render-ops.ts
|
|
2
3
|
/**
|
|
3
4
|
* Asserts an op materialised by an `OpFactoryCall` targets postgres. The
|
|
@@ -10,9 +11,9 @@ function assertPostgresOp(op, callFactoryName) {
|
|
|
10
11
|
const targetId = op.target?.id;
|
|
11
12
|
if (targetId !== "postgres") throw new Error(`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.`);
|
|
12
13
|
}
|
|
13
|
-
function renderOps(calls) {
|
|
14
|
+
function renderOps(calls, lowerer) {
|
|
14
15
|
return calls.map((c) => {
|
|
15
|
-
const op = c.toOp();
|
|
16
|
+
const op = blindCast(c).toOp(lowerer);
|
|
16
17
|
assertPostgresOp(op, c.factoryName);
|
|
17
18
|
return op;
|
|
18
19
|
});
|
|
@@ -20,4 +21,4 @@ function renderOps(calls) {
|
|
|
20
21
|
//#endregion
|
|
21
22
|
export { renderOps as t };
|
|
22
23
|
|
|
23
|
-
//# sourceMappingURL=render-ops-
|
|
24
|
+
//# sourceMappingURL=render-ops-BpjstrKQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops-
|
|
1
|
+
{"version":3,"file":"render-ops-BpjstrKQ.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { Lowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { blindCast } from '@prisma-next/utils/casts';\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[], lowerer?: Lowerer): Op[] {\n return calls.map((c) => {\n const op = blindCast<\n { toOp(lowerer?: Lowerer): ReturnType<OpFactoryCall['toOp']> },\n 'PG OpFactoryCall.toOp accepts an optional Lowerer; the framework interface omits it because not all targets need a lowerer — the PG target overrides with this extended signature'\n >(c).toOp(lowerer);\n assertPostgresOp(op, c.factoryName);\n return op;\n });\n}\n"],"mappings":";;;;;;;;;AAeA,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,OAAiC,SAAyB;CAClF,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,KAAK,UAGT,CAAC,CAAC,CAAC,KAAK,OAAO;EACjB,iBAAiB,IAAI,EAAE,WAAW;EAClC,OAAO;CACT,CAAC;AACH"}
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { Lowerer } from "@prisma-next/family-sql/control-adapter";
|
|
4
5
|
|
|
5
6
|
//#region src/core/migrations/render-ops.d.ts
|
|
6
7
|
type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
7
|
-
declare function renderOps(calls: readonly OpFactoryCall[]): Op[];
|
|
8
|
+
declare function renderOps(calls: readonly OpFactoryCall[], lowerer?: Lowerer): Op[];
|
|
8
9
|
//#endregion
|
|
9
10
|
export { renderOps };
|
|
10
11
|
//# sourceMappingURL=render-ops.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;;KAMK,EAAA,GAAK,yBAAyB,CAAC,yBAAA;AAAA,iBAqBpB,SAAA,CAAU,KAAA,WAAgB,aAAA,IAAiB,OAAA,GAAU,OAAA,GAAU,EAAA"}
|
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-BpjstrKQ.mjs";
|
|
2
2
|
export { renderOps };
|
|
@@ -28,7 +28,7 @@ const BASE_IMPORTS = [{
|
|
|
28
28
|
}];
|
|
29
29
|
function renderCallsToTypeScript(calls, meta) {
|
|
30
30
|
const imports = buildImports(calls);
|
|
31
|
-
const operationsBody = calls.map((c) => c
|
|
31
|
+
const operationsBody = calls.map((c) => renderCall(c)).join(",\n");
|
|
32
32
|
return [
|
|
33
33
|
shebangLineFor(detectScaffoldRuntime()),
|
|
34
34
|
imports,
|
|
@@ -46,6 +46,9 @@ function renderCallsToTypeScript(calls, meta) {
|
|
|
46
46
|
""
|
|
47
47
|
].join("\n");
|
|
48
48
|
}
|
|
49
|
+
function renderCall(call) {
|
|
50
|
+
return call.renderTypeScript();
|
|
51
|
+
}
|
|
49
52
|
function buildImports(calls) {
|
|
50
53
|
const requirements = [...BASE_IMPORTS];
|
|
51
54
|
for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
|
|
@@ -69,4 +72,4 @@ function indent(text, spaces) {
|
|
|
69
72
|
//#endregion
|
|
70
73
|
export { renderCallsToTypeScript as t };
|
|
71
74
|
|
|
72
|
-
//# sourceMappingURL=render-typescript-
|
|
75
|
+
//# sourceMappingURL=render-typescript-KMgosran.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-typescript-KMgosran.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) => renderCall(c)).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 renderCall(call: OpFactoryCall): string {\n return call.renderTypeScript();\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,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;CAEjE,OAAO;EACL,eAAe,sBAAsB,CAAC;EACtC;EACA;EACA;EACA,oBAAoB,IAAI;EACxB;EACA;EACA,OAAO,gBAAgB,CAAC;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,WAAW,MAA6B;CAC/C,OAAO,KAAK,iBAAiB;AAC/B;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,CAAC,CACX,KAAK,SAAU,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,IAAK,CAAC,CACrD,KAAK,IAAI;AACd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as renderCallsToTypeScript } from "./render-typescript-
|
|
1
|
+
import { t as renderCallsToTypeScript } from "./render-typescript-KMgosran.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;EA+CN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QA8BA,kBAAA;AAAA;;;UC/LO,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
|
|
2
|
-
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-
|
|
1
|
+
import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-My8_s4cs.mjs";
|
|
2
|
+
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-DCg7YaP3.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
|
|
@@ -8,7 +8,7 @@ import { t as PostgresContractSerializer } from "./postgres-contract-serializer-
|
|
|
8
8
|
* The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
|
|
9
9
|
*/
|
|
10
10
|
const postgresRuntimeTargetDescriptor = {
|
|
11
|
-
...
|
|
11
|
+
...postgresTargetDescriptorMetaRuntime,
|
|
12
12
|
codecs: () => [],
|
|
13
13
|
create() {
|
|
14
14
|
return {
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport {
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMetaRuntime } from '../core/descriptor-meta-runtime';\n\nexport { PostgresContractSerializer } from '../core/postgres-contract-serializer';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * 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\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMetaRuntime,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;AAiBA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,CAAC;CACf,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ReferentialAction } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
5
5
|
//#region src/core/migrations/operations/shared.d.ts
|
|
6
6
|
type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
7
7
|
/**
|
|
8
|
-
* Literal-args shape for a column definition consumed by `
|
|
9
|
-
*
|
|
10
|
-
* already happened in the wrapper.
|
|
8
|
+
* Literal-args shape for a column definition consumed by `addColumn` and
|
|
9
|
+
* similar operations. Fully materialized: codec expansion and default
|
|
10
|
+
* rendering have already happened in the wrapper.
|
|
11
11
|
*
|
|
12
12
|
* - `typeSql` is the column's DDL type string (e.g. `"integer"`, `"SERIAL"`,
|
|
13
13
|
* `"varchar(100)"`), already produced by `buildColumnTypeSql` in the
|
|
@@ -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-DarONYBZ.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-DarONYBZ.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-DcfMz4MQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-utils-
|
|
1
|
+
{"version":3,"file":"sql-utils-DcfMz4MQ.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-DcfMz4MQ.mjs";
|
|
2
2
|
export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BDKkx8MA.d.mts","names":[],"sources":["../src/core/types.ts"],"mappings":";;;KAEY,qBAAA,GACR,aAAa;EAAA,SACF,IAAA;EAAA,SAA2B,IAAA;AAAA"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-
|
|
2
|
-
import { t as PostgresColumnDefault } from "./types-
|
|
1
|
+
import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-BVn63a89.mjs";
|
|
2
|
+
import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
|
|
3
3
|
import { NamespaceBase } from "@prisma-next/framework-components/ir";
|
|
4
|
-
import { SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { PostgresEnumStorageEntry, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput, StorageValueSet, StorageValueSetInput } from "@prisma-next/sql-contract/types";
|
|
5
5
|
|
|
6
6
|
//#region src/core/postgres-schema.d.ts
|
|
7
7
|
interface PostgresSchemaInput {
|
|
8
8
|
readonly id: string;
|
|
9
|
-
readonly
|
|
10
|
-
|
|
9
|
+
readonly entries: {
|
|
10
|
+
readonly table: Record<string, StorageTable | StorageTableInput>;
|
|
11
|
+
readonly type: Record<string, PostgresEnumType | PostgresEnumTypeInput>;
|
|
12
|
+
readonly valueSet?: Record<string, StorageValueSet | StorageValueSetInput>;
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
@@ -15,9 +18,10 @@ interface PostgresSchemaInput {
|
|
|
15
18
|
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
16
19
|
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
17
20
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
+
* `entries` holds entity-kind slot maps (`table`, `type`). Qualifier
|
|
22
|
+
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
23
|
+
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
24
|
+
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
21
25
|
* The unbound singleton below overrides these methods to elide the
|
|
22
26
|
* prefix entirely — call sites stay polymorphic and never branch on
|
|
23
27
|
* `id === UNBOUND_NAMESPACE_ID`.
|
|
@@ -33,8 +37,11 @@ declare class PostgresSchema extends NamespaceBase {
|
|
|
33
37
|
static unbound: PostgresUnboundSchema;
|
|
34
38
|
readonly kind: 'schema';
|
|
35
39
|
readonly id: string;
|
|
36
|
-
readonly
|
|
37
|
-
|
|
40
|
+
readonly entries: Readonly<{
|
|
41
|
+
readonly table: Readonly<Record<string, StorageTable>>;
|
|
42
|
+
readonly type: Readonly<Record<string, PostgresEnumType>>;
|
|
43
|
+
readonly valueSet?: Readonly<Record<string, StorageValueSet>>;
|
|
44
|
+
}>;
|
|
38
45
|
constructor(input: PostgresSchemaInput);
|
|
39
46
|
/**
|
|
40
47
|
* The bare schema qualifier as it would appear in a rendered SQL
|
|
@@ -115,7 +122,7 @@ declare class PostgresUnboundSchema extends PostgresSchema {
|
|
|
115
122
|
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
116
123
|
* be value-stable for a given input set.
|
|
117
124
|
*/
|
|
118
|
-
declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
|
|
125
|
+
declare function postgresCreateNamespace(input: SqlNamespaceTablesInput, enumTypes?: Readonly<Record<string, PostgresEnumStorageEntry>>): PostgresSchema;
|
|
119
126
|
//#endregion
|
|
120
127
|
export { type PostgresColumnDefault, PostgresEnumType, type PostgresEnumTypeInput, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
|
|
121
128
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;UAiBiB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA;IAAA,SACE,KAAA,EAAO,MAAA,SAAe,YAAA,GAAe,iBAAA;IAAA,SACrC,IAAA,EAAM,MAAA,SAAe,gBAAA,GAAmB,qBAAA;IAAA,SACxC,QAAA,GAAW,MAAA,SAAe,eAAA,GAAkB,oBAAA;EAAA;AAAA;;;;;;;;;;;;;;;cAkB5C,cAAA,SAAuB,aAAA;EAnBvB;;;;;;;EAAA,OA2BJ,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,QAAA;IAAA,SACP,KAAA,EAAO,QAAA,CAAS,MAAA,SAAe,YAAA;IAAA,SAC/B,IAAA,EAAM,QAAA,CAAS,MAAA,SAAe,gBAAA;IAAA,SAC9B,QAAA,GAAW,QAAA,CAAS,MAAA,SAAe,eAAA;EAAA;cAGlC,KAAA,EAAO,mBAAA;EALD;;;;;EAsDlB,SAAA;EApDsB;;;;;;EA8DtB,YAAA,CAAa,SAAA;EA7EqB;;;;;;EAuFlC,eAAA,CAAgB,IAAA;EA1EL;;;;;;;;EAsFX,mBAAA;EApFsB;;;;;;;;;;;EAmGtB,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;AAAU;AAwBpC;;;;;;;;;;;;;;;cAAa,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA;AAAA;;;;;;;AAkCM;;;;;iBAHD,uBAAA,CACd,KAAA,EAAO,uBAAA,EACP,SAAA,GAAY,QAAA,CAAS,MAAA,SAAe,wBAAA,KACnC,cAAA"}
|
package/dist/types.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as PostgresEnumType } from "./postgres-enum-type-
|
|
2
|
-
import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-
|
|
1
|
+
import { t as PostgresEnumType } from "./postgres-enum-type-DPKqCBem.mjs";
|
|
2
|
+
import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-BVTA2QH7.mjs";
|
|
3
3
|
export { PostgresEnumType, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-postgres",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-dev.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Postgres target pack for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/cli": "0.
|
|
10
|
-
"@prisma-next/contract": "0.
|
|
11
|
-
"@prisma-next/errors": "0.
|
|
12
|
-
"@prisma-next/family-sql": "0.
|
|
13
|
-
"@prisma-next/framework-components": "0.
|
|
14
|
-
"@prisma-next/migration-tools": "0.
|
|
15
|
-
"@prisma-next/ts-render": "0.
|
|
16
|
-
"@prisma-next/sql-contract": "0.
|
|
17
|
-
"@prisma-next/sql-errors": "0.
|
|
18
|
-
"@prisma-next/sql-operations": "0.
|
|
19
|
-
"@prisma-next/sql-relational-core": "0.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.
|
|
21
|
-
"@prisma-next/utils": "0.
|
|
9
|
+
"@prisma-next/cli": "0.13.0-dev.10",
|
|
10
|
+
"@prisma-next/contract": "0.13.0-dev.10",
|
|
11
|
+
"@prisma-next/errors": "0.13.0-dev.10",
|
|
12
|
+
"@prisma-next/family-sql": "0.13.0-dev.10",
|
|
13
|
+
"@prisma-next/framework-components": "0.13.0-dev.10",
|
|
14
|
+
"@prisma-next/migration-tools": "0.13.0-dev.10",
|
|
15
|
+
"@prisma-next/ts-render": "0.13.0-dev.10",
|
|
16
|
+
"@prisma-next/sql-contract": "0.13.0-dev.10",
|
|
17
|
+
"@prisma-next/sql-errors": "0.13.0-dev.10",
|
|
18
|
+
"@prisma-next/sql-operations": "0.13.0-dev.10",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.13.0-dev.10",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.13.0-dev.10",
|
|
21
|
+
"@prisma-next/utils": "0.13.0-dev.10",
|
|
22
22
|
"@standard-schema/spec": "^1.1.0",
|
|
23
23
|
"arktype": "^2.2.0",
|
|
24
24
|
"pathe": "^2.0.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@prisma-next/test-utils": "0.
|
|
28
|
-
"@prisma-next/tsconfig": "0.
|
|
29
|
-
"@prisma-next/tsdown": "0.
|
|
30
|
-
"tsdown": "0.22.
|
|
27
|
+
"@prisma-next/test-utils": "0.13.0-dev.10",
|
|
28
|
+
"@prisma-next/tsconfig": "0.13.0-dev.10",
|
|
29
|
+
"@prisma-next/tsdown": "0.13.0-dev.10",
|
|
30
|
+
"tsdown": "0.22.1",
|
|
31
31
|
"typescript": "5.9.3",
|
|
32
|
-
"vitest": "4.1.
|
|
32
|
+
"vitest": "4.1.8"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"typescript": ">=5.9"
|
|
@@ -48,8 +48,10 @@
|
|
|
48
48
|
"./codec-ids": "./dist/codec-ids.mjs",
|
|
49
49
|
"./codec-types": "./dist/codec-types.mjs",
|
|
50
50
|
"./codecs": "./dist/codecs.mjs",
|
|
51
|
+
"./contract-free": "./dist/contract-free.mjs",
|
|
51
52
|
"./control": "./dist/control.mjs",
|
|
52
53
|
"./data-transform": "./dist/data-transform.mjs",
|
|
54
|
+
"./ddl": "./dist/ddl.mjs",
|
|
53
55
|
"./default-normalizer": "./dist/default-normalizer.mjs",
|
|
54
56
|
"./enum-planning": "./dist/enum-planning.mjs",
|
|
55
57
|
"./errors": "./dist/errors.mjs",
|
|
@@ -69,7 +71,6 @@
|
|
|
69
71
|
"./render-typescript": "./dist/render-typescript.mjs",
|
|
70
72
|
"./runtime": "./dist/runtime.mjs",
|
|
71
73
|
"./sql-utils": "./dist/sql-utils.mjs",
|
|
72
|
-
"./statement-builders": "./dist/statement-builders.mjs",
|
|
73
74
|
"./types": "./dist/types.mjs",
|
|
74
75
|
"./package.json": "./package.json"
|
|
75
76
|
},
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ColumnDescriptor,
|
|
3
|
+
type ColumnSchema,
|
|
4
|
+
type TableHandle,
|
|
5
|
+
table,
|
|
6
|
+
} from '@prisma-next/sql-relational-core/contract-free';
|
|
7
|
+
import { PostgresTableSource } from '../core/ast/table-source';
|
|
8
|
+
import {
|
|
9
|
+
PG_INT4_CODEC_ID,
|
|
10
|
+
PG_INT8_CODEC_ID,
|
|
11
|
+
PG_JSONB_CODEC_ID,
|
|
12
|
+
PG_TEXT_ARRAY_CODEC_ID,
|
|
13
|
+
PG_TEXT_CODEC_ID,
|
|
14
|
+
PG_TIMESTAMPTZ_CODEC_ID,
|
|
15
|
+
} from '../core/codec-ids';
|
|
16
|
+
|
|
17
|
+
type ColOpts = { readonly nullable?: boolean };
|
|
18
|
+
|
|
19
|
+
const desc = (codecId: string, opts?: ColOpts): ColumnDescriptor => ({
|
|
20
|
+
codecId,
|
|
21
|
+
nullable: opts?.nullable ?? false,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const text = (opts?: ColOpts): ColumnDescriptor => desc(PG_TEXT_CODEC_ID, opts);
|
|
25
|
+
export const int4 = (opts?: ColOpts): ColumnDescriptor => desc(PG_INT4_CODEC_ID, opts);
|
|
26
|
+
export const int8 = (opts?: ColOpts): ColumnDescriptor => desc(PG_INT8_CODEC_ID, opts);
|
|
27
|
+
export const jsonb = (opts?: ColOpts): ColumnDescriptor => desc(PG_JSONB_CODEC_ID, opts);
|
|
28
|
+
export const textArray = (opts?: ColOpts): ColumnDescriptor => desc(PG_TEXT_ARRAY_CODEC_ID, opts);
|
|
29
|
+
export const timestamptz = (opts?: ColOpts): ColumnDescriptor =>
|
|
30
|
+
desc(PG_TIMESTAMPTZ_CODEC_ID, opts);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Declare a PostgreSQL control-plane table with a typed column schema. Wraps
|
|
34
|
+
* the generic `table()` factory with a `PostgresTableSource` so the renderer
|
|
35
|
+
* qualifies the table name with the optional schema prefix.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* const marker = pgTable(
|
|
39
|
+
* { name: 'marker', schema: 'prisma_contract' },
|
|
40
|
+
* { space: text(), core_hash: text(), updated_at: timestamptz() },
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function pgTable<Schema extends ColumnSchema>(
|
|
45
|
+
source: { readonly name: string; readonly schema?: string; readonly alias?: string },
|
|
46
|
+
columns: Schema,
|
|
47
|
+
): TableHandle<Schema> {
|
|
48
|
+
return table(new PostgresTableSource(source), columns);
|
|
49
|
+
}
|