@prisma-next/target-postgres 0.3.0-pr.99.5 → 0.3.0
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/LICENSE +201 -0
- package/README.md +17 -8
- package/dist/control.d.mts +19 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +5382 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-CAf16lsJ.mjs +32 -0
- package/dist/descriptor-meta-CAf16lsJ.mjs.map +1 -0
- package/dist/migration-builders.d.mts +88 -0
- package/dist/migration-builders.d.mts.map +1 -0
- package/dist/migration-builders.mjs +3 -0
- package/dist/operation-descriptors-CxymFSgK.mjs +52 -0
- package/dist/operation-descriptors-CxymFSgK.mjs.map +1 -0
- package/dist/pack.d.mts +45 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +9 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +9 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +20 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +30 -28
- package/src/core/authoring.ts +15 -0
- package/src/core/descriptor-meta.ts +5 -0
- package/src/core/migrations/descriptor-planner.ts +466 -0
- package/src/core/migrations/operation-descriptors.ts +166 -0
- package/src/core/migrations/operation-resolver.ts +929 -0
- package/src/core/migrations/planner-ddl-builders.ts +256 -0
- package/src/core/migrations/planner-identity-values.ts +135 -0
- package/src/core/migrations/planner-recipes.ts +91 -0
- package/src/core/migrations/planner-reconciliation.ts +798 -0
- package/src/core/migrations/planner-schema-lookup.ts +54 -0
- package/src/core/migrations/planner-sql-checks.ts +322 -0
- package/src/core/migrations/planner-strategies.ts +262 -0
- package/src/core/migrations/planner-target-details.ts +38 -0
- package/src/core/migrations/planner-type-resolution.ts +26 -0
- package/src/core/migrations/planner.ts +410 -460
- package/src/core/migrations/runner.ts +134 -38
- package/src/core/migrations/statement-builders.ts +6 -6
- package/src/core/types.ts +5 -0
- package/src/exports/control.ts +182 -12
- package/src/exports/migration-builders.ts +56 -0
- package/src/exports/pack.ts +7 -3
- package/src/exports/runtime.ts +6 -12
- package/dist/chunk-RKEXRSSI.js +0 -14
- package/dist/chunk-RKEXRSSI.js.map +0 -1
- package/dist/core/descriptor-meta.d.ts +0 -9
- package/dist/core/descriptor-meta.d.ts.map +0 -1
- package/dist/core/migrations/planner.d.ts +0 -14
- package/dist/core/migrations/planner.d.ts.map +0 -1
- package/dist/core/migrations/runner.d.ts +0 -8
- package/dist/core/migrations/runner.d.ts.map +0 -1
- package/dist/core/migrations/statement-builders.d.ts +0 -30
- package/dist/core/migrations/statement-builders.d.ts.map +0 -1
- package/dist/exports/control.d.ts +0 -8
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -1260
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/pack.d.ts +0 -4
- package/dist/exports/pack.d.ts.map +0 -1
- package/dist/exports/pack.js +0 -11
- package/dist/exports/pack.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -12
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -19
- package/dist/exports/runtime.js.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/core/authoring.ts
|
|
2
|
+
const postgresAuthoringTypes = { enum: {
|
|
3
|
+
kind: "typeConstructor",
|
|
4
|
+
args: [{ kind: "string" }, { kind: "stringArray" }],
|
|
5
|
+
output: {
|
|
6
|
+
codecId: "pg/enum@1",
|
|
7
|
+
nativeType: {
|
|
8
|
+
kind: "arg",
|
|
9
|
+
index: 0
|
|
10
|
+
},
|
|
11
|
+
typeParams: { values: {
|
|
12
|
+
kind: "arg",
|
|
13
|
+
index: 1
|
|
14
|
+
} }
|
|
15
|
+
}
|
|
16
|
+
} };
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/core/descriptor-meta.ts
|
|
20
|
+
const postgresTargetDescriptorMeta = {
|
|
21
|
+
kind: "target",
|
|
22
|
+
familyId: "sql",
|
|
23
|
+
targetId: "postgres",
|
|
24
|
+
id: "postgres",
|
|
25
|
+
version: "0.0.1",
|
|
26
|
+
capabilities: {},
|
|
27
|
+
authoring: { type: postgresAuthoringTypes }
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { postgresTargetDescriptorMeta as t };
|
|
32
|
+
//# sourceMappingURL=descriptor-meta-CAf16lsJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-CAf16lsJ.mjs","names":[],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const postgresAuthoringTypes = {\n enum: {\n kind: 'typeConstructor',\n args: [{ kind: 'string' }, { kind: 'stringArray' }],\n output: {\n codecId: 'pg/enum@1',\n nativeType: { kind: 'arg', index: 0 },\n typeParams: {\n values: { kind: 'arg', index: 1 },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n","import { postgresAuthoringTypes } from './authoring';\n\nexport const postgresTargetDescriptorMeta = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n authoring: {\n type: postgresAuthoringTypes,\n },\n} as const;\n"],"mappings":";AAEA,MAAa,yBAAyB,EACpC,MAAM;CACJ,MAAM;CACN,MAAM,CAAC,EAAE,MAAM,UAAU,EAAE,EAAE,MAAM,eAAe,CAAC;CACnD,QAAQ;EACN,SAAS;EACT,YAAY;GAAE,MAAM;GAAO,OAAO;GAAG;EACrC,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;GAAG,EAClC;EACF;CACF,EACF;;;;ACZD,MAAa,+BAA+B;CAC1C,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EAAE;CAChB,WAAW,EACT,MAAM,wBACP;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as _prisma_next_family_sql_operation_descriptors0 from "@prisma-next/family-sql/operation-descriptors";
|
|
2
|
+
import { AddColumnDescriptor, AddEnumValuesDescriptor, AddForeignKeyDescriptor, AddPrimaryKeyDescriptor, AddUniqueDescriptor, AlterColumnTypeDescriptor, Buildable, Buildable as Buildable$1, CreateDependencyDescriptor, CreateEnumTypeDescriptor, CreateIndexDescriptor, CreateTableDescriptor, DataTransformDescriptor, DropColumnDescriptor, DropConstraintDescriptor, DropDefaultDescriptor, DropEnumTypeDescriptor, DropIndexDescriptor, DropNotNullDescriptor, DropTableDescriptor, RenameTypeDescriptor, SetDefaultDescriptor, SetNotNullDescriptor, SqlMigrationOpDescriptor, SqlMigrationOpDescriptor as SqlMigrationOpDescriptor$1, TODO, TodoMarker, TodoMarker as TodoMarker$1, addColumn, addEnumValues, addForeignKey, addPrimaryKey, addUnique, alterColumnType, createDependency, createEnumType, createIndex, createTable, dropColumn, dropConstraint, dropDefault, dropEnumType, dropIndex, dropNotNull, dropTable, renameType, setDefault, setNotNull } from "@prisma-next/family-sql/operation-descriptors";
|
|
3
|
+
import { Db, TableProxyContract } from "@prisma-next/sql-builder/types";
|
|
4
|
+
import { SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
5
|
+
|
|
6
|
+
//#region src/core/migrations/operation-descriptors.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A single query plan input — callback, pre-built plan, or TODO placeholder.
|
|
10
|
+
* @template TContract - The contract type for the Db client. Defaults to any
|
|
11
|
+
* (untyped). Use createBuilders<Contract>() to get typed callbacks.
|
|
12
|
+
*/
|
|
13
|
+
type QueryPlanInput<TContract extends TableProxyContract = any> = ((db: Db<TContract>) => Buildable$1) | SqlQueryPlan | TodoMarker$1;
|
|
14
|
+
/** Run input — a callback returning one or many buildables, or a pre-built plan/TODO. */
|
|
15
|
+
type RunInput<TContract extends TableProxyContract = any> = ((db: Db<TContract>) => Buildable$1 | readonly Buildable$1[]) | SqlQueryPlan | TodoMarker$1;
|
|
16
|
+
type PostgresMigrationOpDescriptor = SqlMigrationOpDescriptor$1 | DataTransformDescriptor;
|
|
17
|
+
declare function dataTransform<TContract extends TableProxyContract = any>(name: string, options: {
|
|
18
|
+
check: QueryPlanInput<TContract> | Buildable$1 | boolean;
|
|
19
|
+
run: RunInput<TContract> | Buildable$1;
|
|
20
|
+
}): DataTransformDescriptor;
|
|
21
|
+
/**
|
|
22
|
+
* Creates typed migration builder functions parameterized by the contract type.
|
|
23
|
+
* The dataTransform callback receives a fully typed Db<TContract> client.
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import type { Contract } from "../../src/prisma/contract.d"
|
|
28
|
+
* import { createBuilders } from "@prisma-next/target-postgres/migration-builders"
|
|
29
|
+
*
|
|
30
|
+
* const { addColumn, dataTransform, setNotNull } = createBuilders<Contract>()
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare function createBuilders<TContract extends TableProxyContract>(): {
|
|
34
|
+
dataTransform: (name: string, options: {
|
|
35
|
+
check: boolean | Buildable$1 | QueryPlanInput<TContract>;
|
|
36
|
+
run: Buildable$1 | RunInput<TContract>;
|
|
37
|
+
}) => DataTransformDescriptor;
|
|
38
|
+
TODO: symbol;
|
|
39
|
+
createTable: typeof _prisma_next_family_sql_operation_descriptors0.createTable;
|
|
40
|
+
dropTable: typeof _prisma_next_family_sql_operation_descriptors0.dropTable;
|
|
41
|
+
addColumn: typeof _prisma_next_family_sql_operation_descriptors0.addColumn;
|
|
42
|
+
dropColumn: typeof _prisma_next_family_sql_operation_descriptors0.dropColumn;
|
|
43
|
+
alterColumnType: typeof _prisma_next_family_sql_operation_descriptors0.alterColumnType;
|
|
44
|
+
setNotNull: typeof _prisma_next_family_sql_operation_descriptors0.setNotNull;
|
|
45
|
+
dropNotNull: typeof _prisma_next_family_sql_operation_descriptors0.dropNotNull;
|
|
46
|
+
setDefault: typeof _prisma_next_family_sql_operation_descriptors0.setDefault;
|
|
47
|
+
dropDefault: typeof _prisma_next_family_sql_operation_descriptors0.dropDefault;
|
|
48
|
+
addPrimaryKey: typeof _prisma_next_family_sql_operation_descriptors0.addPrimaryKey;
|
|
49
|
+
addUnique: typeof _prisma_next_family_sql_operation_descriptors0.addUnique;
|
|
50
|
+
addForeignKey: typeof _prisma_next_family_sql_operation_descriptors0.addForeignKey;
|
|
51
|
+
dropConstraint: typeof _prisma_next_family_sql_operation_descriptors0.dropConstraint;
|
|
52
|
+
createIndex: typeof _prisma_next_family_sql_operation_descriptors0.createIndex;
|
|
53
|
+
dropIndex: typeof _prisma_next_family_sql_operation_descriptors0.dropIndex;
|
|
54
|
+
createEnumType: typeof _prisma_next_family_sql_operation_descriptors0.createEnumType;
|
|
55
|
+
addEnumValues: typeof _prisma_next_family_sql_operation_descriptors0.addEnumValues;
|
|
56
|
+
dropEnumType: typeof _prisma_next_family_sql_operation_descriptors0.dropEnumType;
|
|
57
|
+
renameType: typeof _prisma_next_family_sql_operation_descriptors0.renameType;
|
|
58
|
+
createDependency: typeof _prisma_next_family_sql_operation_descriptors0.createDependency;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* All builder functions keyed by descriptor kind.
|
|
62
|
+
*/
|
|
63
|
+
declare const builders: {
|
|
64
|
+
readonly dataTransform: typeof dataTransform;
|
|
65
|
+
readonly createTable: typeof _prisma_next_family_sql_operation_descriptors0.createTable;
|
|
66
|
+
readonly dropTable: typeof _prisma_next_family_sql_operation_descriptors0.dropTable;
|
|
67
|
+
readonly addColumn: typeof _prisma_next_family_sql_operation_descriptors0.addColumn;
|
|
68
|
+
readonly dropColumn: typeof _prisma_next_family_sql_operation_descriptors0.dropColumn;
|
|
69
|
+
readonly alterColumnType: typeof _prisma_next_family_sql_operation_descriptors0.alterColumnType;
|
|
70
|
+
readonly setNotNull: typeof _prisma_next_family_sql_operation_descriptors0.setNotNull;
|
|
71
|
+
readonly dropNotNull: typeof _prisma_next_family_sql_operation_descriptors0.dropNotNull;
|
|
72
|
+
readonly setDefault: typeof _prisma_next_family_sql_operation_descriptors0.setDefault;
|
|
73
|
+
readonly dropDefault: typeof _prisma_next_family_sql_operation_descriptors0.dropDefault;
|
|
74
|
+
readonly addPrimaryKey: typeof _prisma_next_family_sql_operation_descriptors0.addPrimaryKey;
|
|
75
|
+
readonly addUnique: typeof _prisma_next_family_sql_operation_descriptors0.addUnique;
|
|
76
|
+
readonly addForeignKey: typeof _prisma_next_family_sql_operation_descriptors0.addForeignKey;
|
|
77
|
+
readonly dropConstraint: typeof _prisma_next_family_sql_operation_descriptors0.dropConstraint;
|
|
78
|
+
readonly createIndex: typeof _prisma_next_family_sql_operation_descriptors0.createIndex;
|
|
79
|
+
readonly dropIndex: typeof _prisma_next_family_sql_operation_descriptors0.dropIndex;
|
|
80
|
+
readonly createEnumType: typeof _prisma_next_family_sql_operation_descriptors0.createEnumType;
|
|
81
|
+
readonly addEnumValues: typeof _prisma_next_family_sql_operation_descriptors0.addEnumValues;
|
|
82
|
+
readonly dropEnumType: typeof _prisma_next_family_sql_operation_descriptors0.dropEnumType;
|
|
83
|
+
readonly renameType: typeof _prisma_next_family_sql_operation_descriptors0.renameType;
|
|
84
|
+
readonly createDependency: typeof _prisma_next_family_sql_operation_descriptors0.createDependency;
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { type AddColumnDescriptor, type AddEnumValuesDescriptor, type AddForeignKeyDescriptor, type AddPrimaryKeyDescriptor, type AddUniqueDescriptor, type AlterColumnTypeDescriptor, type Buildable, type CreateDependencyDescriptor, type CreateEnumTypeDescriptor, type CreateIndexDescriptor, type CreateTableDescriptor, type DataTransformDescriptor, type DropColumnDescriptor, type DropConstraintDescriptor, type DropDefaultDescriptor, type DropEnumTypeDescriptor, type DropIndexDescriptor, type DropNotNullDescriptor, type DropTableDescriptor, type PostgresMigrationOpDescriptor, type QueryPlanInput, type RenameTypeDescriptor, type RunInput, type SetDefaultDescriptor, type SetNotNullDescriptor, type SqlMigrationOpDescriptor, TODO, type TodoMarker, addColumn, addEnumValues, addForeignKey, addPrimaryKey, addUnique, alterColumnType, builders, createBuilders, createDependency, createEnumType, createIndex, createTable, dataTransform, dropColumn, dropConstraint, dropDefault, dropEnumType, dropIndex, dropNotNull, dropTable, renameType, setDefault, setNotNull };
|
|
88
|
+
//# sourceMappingURL=migration-builders.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-builders.d.mts","names":[],"sources":["../src/core/migrations/operation-descriptors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAsFA;;AACa,KARD,cAQC,CAAA,kBARgC,kBAQhC,GAAA,GAAA,CAAA,GAAA,CAAA,CAAA,EAAA,EAPH,EAOG,CAPA,SAOA,CAAA,EAAA,GAPe,WAOf,CAAA,GANT,YAMS,GALT,YAKS;;AAAe,KADhB,QACgB,CAAA,kBADW,kBACX,GAAA,GAAA,CAAA,GAAA,CAAA,CAAA,EAAA,EAAlB,EAAkB,CAAf,SAAe,CAAA,EAAA,GAAA,WAAA,GAAA,SAAqB,WAArB,EAAA,CAAA,GACxB,YADwB,GAExB,YAFwB;AAAqB,KAQrC,6BAAA,GAAgC,0BARK,GAQsB,uBARtB;AAC7C,iBAsBY,aAtBZ,CAAA,kBAsB4C,kBAtB5C,GAAA,GAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA;EACA,KAAA,EAwBO,cAxBP,CAwBsB,SAxBtB,CAAA,GAwBmC,WAxBnC,GAAA,OAAA;EAAU,GAAA,EAyBL,QAzBK,CAyBI,SAzBJ,CAAA,GAyBiB,WAzBjB;AAMd,CAAA,CAAA,EAqBG,uBArBS;AAeZ;;;;;;;;;;AAyCA;;iBAAgB,iCAAiC;;;;QAnC9C;;EAAA,WAAA,EAAA,OAAuB,8CAAA,CAAA,WAAvB;EAAuB,SAAA,EAAA,+DAAA;;;;;;;;;;;;;;;;;;;;;AA8C1B;;cAAa"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { C as setDefault, S as renameType, _ as dropDefault, a as addPrimaryKey, b as dropNotNull, c as builders, d as createEnumType, f as createIndex, g as dropConstraint, h as dropColumn, i as addForeignKey, l as createBuilders, m as dataTransform, n as addColumn, o as addUnique, p as createTable, r as addEnumValues, s as alterColumnType, t as TODO, u as createDependency, v as dropEnumType, w as setNotNull, x as dropTable, y as dropIndex } from "./operation-descriptors-CxymFSgK.mjs";
|
|
2
|
+
|
|
3
|
+
export { TODO, addColumn, addEnumValues, addForeignKey, addPrimaryKey, addUnique, alterColumnType, builders, createBuilders, createDependency, createEnumType, createIndex, createTable, dataTransform, dropColumn, dropConstraint, dropDefault, dropEnumType, dropIndex, dropNotNull, dropTable, renameType, setDefault, setNotNull };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TODO, TODO as TODO$1, addColumn, addEnumValues, addForeignKey, addPrimaryKey, addUnique, alterColumnType, builders, createDependency, createEnumType, createIndex, createTable, dropColumn, dropConstraint, dropDefault, dropEnumType, dropIndex, dropNotNull, dropTable, renameType, setDefault, setNotNull } from "@prisma-next/family-sql/operation-descriptors";
|
|
2
|
+
|
|
3
|
+
//#region src/core/migrations/operation-descriptors.ts
|
|
4
|
+
function resolveInput(input) {
|
|
5
|
+
if (typeof input === "symbol" || typeof input === "function") return input;
|
|
6
|
+
if ("build" in input && typeof input.build === "function") return input.build();
|
|
7
|
+
return input;
|
|
8
|
+
}
|
|
9
|
+
function dataTransform(name, options) {
|
|
10
|
+
const check = typeof options.check === "boolean" ? options.check : resolveInput(options.check);
|
|
11
|
+
const run = [];
|
|
12
|
+
if (typeof options.run === "function") run.push(options.run);
|
|
13
|
+
else if (typeof options.run === "symbol") run.push(options.run);
|
|
14
|
+
else run.push(resolveInput(options.run));
|
|
15
|
+
return {
|
|
16
|
+
kind: "dataTransform",
|
|
17
|
+
name,
|
|
18
|
+
source: "migration.ts",
|
|
19
|
+
check,
|
|
20
|
+
run
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates typed migration builder functions parameterized by the contract type.
|
|
25
|
+
* The dataTransform callback receives a fully typed Db<TContract> client.
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import type { Contract } from "../../src/prisma/contract.d"
|
|
30
|
+
* import { createBuilders } from "@prisma-next/target-postgres/migration-builders"
|
|
31
|
+
*
|
|
32
|
+
* const { addColumn, dataTransform, setNotNull } = createBuilders<Contract>()
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function createBuilders() {
|
|
36
|
+
return {
|
|
37
|
+
...builders,
|
|
38
|
+
dataTransform,
|
|
39
|
+
TODO
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* All builder functions keyed by descriptor kind.
|
|
44
|
+
*/
|
|
45
|
+
const builders$1 = {
|
|
46
|
+
...builders,
|
|
47
|
+
dataTransform
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { setDefault as C, renameType as S, dropDefault as _, addPrimaryKey as a, dropNotNull as b, builders$1 as c, createEnumType as d, createIndex as f, dropConstraint as g, dropColumn as h, addForeignKey as i, createBuilders as l, dataTransform as m, addColumn as n, addUnique as o, createTable as p, addEnumValues as r, alterColumnType as s, TODO$1 as t, createDependency as u, dropEnumType as v, setNotNull as w, dropTable as x, dropIndex as y };
|
|
52
|
+
//# sourceMappingURL=operation-descriptors-CxymFSgK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-descriptors-CxymFSgK.mjs","names":["run: (symbol | object | ((...args: never[]) => unknown))[]","structuralBuilders","builders"],"sources":["../src/core/migrations/operation-descriptors.ts"],"sourcesContent":["/**\n * Postgres migration operation descriptors.\n *\n * Re-exports all structural SQL descriptors from @prisma-next/family-sql\n * and adds data transform support with typed query builder callbacks.\n */\n\nimport type { Db, TableProxyContract } from '@prisma-next/sql-builder/types';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\n\n// Re-export structural descriptors from sql-family\nexport {\n type AddColumnDescriptor,\n type AddEnumValuesDescriptor,\n type AddForeignKeyDescriptor,\n type AddPrimaryKeyDescriptor,\n type AddUniqueDescriptor,\n type AlterColumnTypeDescriptor,\n addColumn,\n addEnumValues,\n addForeignKey,\n addPrimaryKey,\n addUnique,\n alterColumnType,\n type Buildable,\n type CreateDependencyDescriptor,\n type CreateEnumTypeDescriptor,\n type CreateIndexDescriptor,\n type CreateTableDescriptor,\n createDependency,\n createEnumType,\n createIndex,\n createTable,\n type DropColumnDescriptor,\n type DropConstraintDescriptor,\n type DropDefaultDescriptor,\n type DropEnumTypeDescriptor,\n type DropIndexDescriptor,\n type DropNotNullDescriptor,\n type DropTableDescriptor,\n dropColumn,\n dropConstraint,\n dropDefault,\n dropEnumType,\n dropIndex,\n dropNotNull,\n dropTable,\n type RenameTypeDescriptor,\n renameType,\n type SetDefaultDescriptor,\n type SetNotNullDescriptor,\n type SqlMigrationOpDescriptor,\n setDefault,\n setNotNull,\n TODO,\n type TodoMarker,\n} from '@prisma-next/family-sql/operation-descriptors';\n\nimport {\n type Buildable,\n type DataTransformDescriptor,\n type SqlMigrationOpDescriptor,\n builders as structuralBuilders,\n TODO,\n type TodoMarker,\n} from '@prisma-next/family-sql/operation-descriptors';\n\nexport type { DataTransformDescriptor };\n\n// ============================================================================\n// Typed data transform inputs (for createBuilders<Contract>())\n// ============================================================================\n\n/**\n * A single query plan input — callback, pre-built plan, or TODO placeholder.\n * @template TContract - The contract type for the Db client. Defaults to any\n * (untyped). Use createBuilders<Contract>() to get typed callbacks.\n */\n// biome-ignore lint/suspicious/noExplicitAny: default is untyped; createBuilders narrows this\nexport type QueryPlanInput<TContract extends TableProxyContract = any> =\n | ((db: Db<TContract>) => Buildable)\n | SqlQueryPlan\n | TodoMarker;\n\n/** Run input — a callback returning one or many buildables, or a pre-built plan/TODO. */\n// biome-ignore lint/suspicious/noExplicitAny: default is untyped; createBuilders narrows this\nexport type RunInput<TContract extends TableProxyContract = any> =\n | ((db: Db<TContract>) => Buildable | readonly Buildable[])\n | SqlQueryPlan\n | TodoMarker;\n\n// ============================================================================\n// Postgres descriptor union = SQL structural + data transforms\n// ============================================================================\n\nexport type PostgresMigrationOpDescriptor = SqlMigrationOpDescriptor | DataTransformDescriptor;\n\n// ============================================================================\n// Data transform builder\n// ============================================================================\n\nfunction resolveInput(input: QueryPlanInput): QueryPlanInput {\n if (typeof input === 'symbol' || typeof input === 'function') return input;\n if ('build' in input && typeof (input as Buildable).build === 'function') {\n return (input as Buildable).build();\n }\n return input;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: default is untyped; createBuilders narrows this\nexport function dataTransform<TContract extends TableProxyContract = any>(\n name: string,\n options: {\n check: QueryPlanInput<TContract> | Buildable | boolean;\n run: RunInput<TContract> | Buildable;\n },\n): DataTransformDescriptor {\n const check =\n typeof options.check === 'boolean'\n ? options.check\n : resolveInput(options.check as QueryPlanInput);\n\n const run: (symbol | object | ((...args: never[]) => unknown))[] = [];\n if (typeof options.run === 'function') {\n run.push(options.run);\n } else if (typeof options.run === 'symbol') {\n run.push(options.run);\n } else {\n run.push(resolveInput(options.run as QueryPlanInput));\n }\n return {\n kind: 'dataTransform' as const,\n name,\n source: 'migration.ts',\n check,\n run,\n };\n}\n\n/**\n * Creates typed migration builder functions parameterized by the contract type.\n * The dataTransform callback receives a fully typed Db<TContract> client.\n *\n * Usage:\n * ```typescript\n * import type { Contract } from \"../../src/prisma/contract.d\"\n * import { createBuilders } from \"@prisma-next/target-postgres/migration-builders\"\n *\n * const { addColumn, dataTransform, setNotNull } = createBuilders<Contract>()\n * ```\n */\nexport function createBuilders<TContract extends TableProxyContract>() {\n return {\n ...structuralBuilders,\n dataTransform: dataTransform<TContract>,\n TODO,\n };\n}\n\n/**\n * All builder functions keyed by descriptor kind.\n */\nexport const builders = {\n ...structuralBuilders,\n dataTransform,\n} as const;\n"],"mappings":";;;AAqGA,SAAS,aAAa,OAAuC;AAC3D,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAY,QAAO;AACrE,KAAI,WAAW,SAAS,OAAQ,MAAoB,UAAU,WAC5D,QAAQ,MAAoB,OAAO;AAErC,QAAO;;AAIT,SAAgB,cACd,MACA,SAIyB;CACzB,MAAM,QACJ,OAAO,QAAQ,UAAU,YACrB,QAAQ,QACR,aAAa,QAAQ,MAAwB;CAEnD,MAAMA,MAA6D,EAAE;AACrE,KAAI,OAAO,QAAQ,QAAQ,WACzB,KAAI,KAAK,QAAQ,IAAI;UACZ,OAAO,QAAQ,QAAQ,SAChC,KAAI,KAAK,QAAQ,IAAI;KAErB,KAAI,KAAK,aAAa,QAAQ,IAAsB,CAAC;AAEvD,QAAO;EACL,MAAM;EACN;EACA,QAAQ;EACR;EACA;EACD;;;;;;;;;;;;;;AAeH,SAAgB,iBAAuD;AACrE,QAAO;EACL,GAAGC;EACY;EACf;EACD;;;;;AAMH,MAAaC,aAAW;CACtB,GAAGD;CACH;CACD"}
|
package/dist/pack.d.mts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CodecTypes } from "@prisma-next/adapter-postgres/codec-types";
|
|
2
|
+
import { TargetPackRef } from "@prisma-next/framework-components/components";
|
|
3
|
+
|
|
4
|
+
//#region src/core/descriptor-meta.d.ts
|
|
5
|
+
declare const postgresTargetDescriptorMeta: {
|
|
6
|
+
readonly kind: "target";
|
|
7
|
+
readonly familyId: "sql";
|
|
8
|
+
readonly targetId: "postgres";
|
|
9
|
+
readonly id: "postgres";
|
|
10
|
+
readonly version: "0.0.1";
|
|
11
|
+
readonly capabilities: {};
|
|
12
|
+
readonly authoring: {
|
|
13
|
+
readonly type: {
|
|
14
|
+
readonly enum: {
|
|
15
|
+
readonly kind: "typeConstructor";
|
|
16
|
+
readonly args: readonly [{
|
|
17
|
+
readonly kind: "string";
|
|
18
|
+
}, {
|
|
19
|
+
readonly kind: "stringArray";
|
|
20
|
+
}];
|
|
21
|
+
readonly output: {
|
|
22
|
+
readonly codecId: "pg/enum@1";
|
|
23
|
+
readonly nativeType: {
|
|
24
|
+
readonly kind: "arg";
|
|
25
|
+
readonly index: 0;
|
|
26
|
+
};
|
|
27
|
+
readonly typeParams: {
|
|
28
|
+
readonly values: {
|
|
29
|
+
readonly kind: "arg";
|
|
30
|
+
readonly index: 1;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/exports/pack.d.ts
|
|
40
|
+
declare const _default: typeof postgresTargetDescriptorMeta & TargetPackRef<"sql", "postgres"> & {
|
|
41
|
+
readonly __codecTypes?: CodecTypes;
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { _default as default };
|
|
45
|
+
//# sourceMappingURL=pack.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts","../src/exports/pack.ts"],"sourcesContent":[],"mappings":";;;;cAEa;;;;EAAA,SAAA,EAAA,EAAA,UAAA;;;;ICA0D,SAOpE,IAAA,EAAA;MAHmC,SAAA,IAAA,EAAA;QACpC,SAAA,IAAA,EAAA,iBAAA;QAC0B,SAAA,IAAA,EAAA,SAAA,CAAA;UAAU,SAAA,IAAA,EAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;cANiC,iBAIjC,+BACpC;EDLW,SAAA,YAAA,CAAA,ECMe,UDIlB"}
|
package/dist/pack.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-CAf16lsJ.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/exports/pack.ts
|
|
4
|
+
const postgresPack = postgresTargetDescriptorMeta;
|
|
5
|
+
var pack_default = postgresPack;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { pack_default as default };
|
|
9
|
+
//# sourceMappingURL=pack.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.mjs","names":[],"sources":["../src/exports/pack.ts"],"sourcesContent":["import type { CodecTypes } from '@prisma-next/adapter-postgres/codec-types';\nimport type { TargetPackRef } from '@prisma-next/framework-components/components';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nconst postgresPack = postgresTargetDescriptorMeta;\n\nexport default postgresPack as typeof postgresTargetDescriptorMeta &\n TargetPackRef<'sql', 'postgres'> & {\n readonly __codecTypes?: CodecTypes;\n };\n"],"mappings":";;;AAIA,MAAM,eAAe;AAErB,mBAAe"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SqlRuntimeTargetDescriptor } from "@prisma-next/sql-runtime";
|
|
2
|
+
import { RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/runtime.d.ts
|
|
5
|
+
interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}
|
|
6
|
+
declare const postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<'postgres', PostgresRuntimeTargetInstance>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
|
|
9
|
+
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,6BAAA,SAAsC;AAAvD,cAEM,+BAFyC,EAER,0BAFqC,CAAA,UAAA,EAI1E,6BAJ0E,CAAA"}
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-CAf16lsJ.mjs";
|
|
2
|
+
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/runtime.ts
|
|
5
|
+
const postgresRuntimeTargetDescriptor = {
|
|
6
|
+
...postgresTargetDescriptorMeta,
|
|
7
|
+
codecs: () => createCodecRegistry(),
|
|
8
|
+
parameterizedCodecs: () => [],
|
|
9
|
+
create() {
|
|
10
|
+
return {
|
|
11
|
+
familyId: "sql",
|
|
12
|
+
targetId: "postgres"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var runtime_default = postgresRuntimeTargetDescriptor;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { runtime_default as default };
|
|
20
|
+
//# sourceMappingURL=runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'postgres',\n PostgresRuntimeTargetInstance\n>"],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\nconst postgresRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'postgres',\n PostgresRuntimeTargetInstance\n> = {\n ...postgresTargetDescriptorMeta,\n codecs: () => createCodecRegistry(),\n parameterizedCodecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;AAOA,MAAMA,kCAGF;CACF,GAAG;CACH,cAAc,qBAAqB;CACnC,2BAA2B,EAAE;CAC7B,SAAwC;AACtC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,sBAAe"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-postgres",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Postgres target pack for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.0.0",
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/sql-contract": "0.3.0
|
|
14
|
-
"@prisma-next/
|
|
15
|
-
"@prisma-next/sql-errors": "0.3.0
|
|
16
|
-
"@prisma-next/sql-schema-ir": "0.3.0
|
|
17
|
-
"@prisma-next/
|
|
9
|
+
"@prisma-next/contract": "0.3.0",
|
|
10
|
+
"@prisma-next/family-sql": "0.3.0",
|
|
11
|
+
"@prisma-next/framework-components": "0.3.0",
|
|
12
|
+
"@prisma-next/sql-builder": "0.3.0",
|
|
13
|
+
"@prisma-next/sql-contract": "0.3.0",
|
|
14
|
+
"@prisma-next/sql-operations": "0.3.0",
|
|
15
|
+
"@prisma-next/sql-errors": "0.3.0",
|
|
16
|
+
"@prisma-next/sql-schema-ir": "0.3.0",
|
|
17
|
+
"@prisma-next/sql-relational-core": "0.3.0",
|
|
18
|
+
"@prisma-next/utils": "0.3.0",
|
|
19
|
+
"@prisma-next/sql-runtime": "0.3.0"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
|
-
"
|
|
22
|
+
"tsdown": "0.18.4",
|
|
21
23
|
"typescript": "5.9.3",
|
|
22
|
-
"vitest": "4.0.
|
|
23
|
-
"@prisma-next/adapter-postgres": "0.3.0-pr.99.5",
|
|
24
|
-
"@prisma-next/driver-postgres": "0.3.0-pr.99.5",
|
|
24
|
+
"vitest": "4.0.17",
|
|
25
25
|
"@prisma-next/test-utils": "0.0.1",
|
|
26
|
-
"@prisma-next/
|
|
26
|
+
"@prisma-next/extension-pgvector": "0.3.0",
|
|
27
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
28
|
+
"@prisma-next/tsdown": "0.0.0",
|
|
29
|
+
"@prisma-next/adapter-postgres": "0.3.0",
|
|
30
|
+
"@prisma-next/driver-postgres": "0.3.0"
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
|
29
33
|
"dist",
|
|
@@ -31,21 +35,19 @@
|
|
|
31
35
|
"packs"
|
|
32
36
|
],
|
|
33
37
|
"exports": {
|
|
34
|
-
"./control":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"./
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"import": "./dist/exports/pack.js"
|
|
45
|
-
}
|
|
38
|
+
"./control": "./dist/control.mjs",
|
|
39
|
+
"./migration-builders": "./dist/migration-builders.mjs",
|
|
40
|
+
"./pack": "./dist/pack.mjs",
|
|
41
|
+
"./runtime": "./dist/runtime.mjs",
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/prisma/prisma-next.git",
|
|
47
|
+
"directory": "packages/3-targets/3-targets/postgres"
|
|
46
48
|
},
|
|
47
49
|
"scripts": {
|
|
48
|
-
"build": "
|
|
50
|
+
"build": "tsdown",
|
|
49
51
|
"test": "vitest run --passWithNoTests",
|
|
50
52
|
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
51
53
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';
|
|
2
|
+
|
|
3
|
+
export const postgresAuthoringTypes = {
|
|
4
|
+
enum: {
|
|
5
|
+
kind: 'typeConstructor',
|
|
6
|
+
args: [{ kind: 'string' }, { kind: 'stringArray' }],
|
|
7
|
+
output: {
|
|
8
|
+
codecId: 'pg/enum@1',
|
|
9
|
+
nativeType: { kind: 'arg', index: 0 },
|
|
10
|
+
typeParams: {
|
|
11
|
+
values: { kind: 'arg', index: 1 },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
} as const satisfies AuthoringTypeNamespace;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { postgresAuthoringTypes } from './authoring';
|
|
2
|
+
|
|
1
3
|
export const postgresTargetDescriptorMeta = {
|
|
2
4
|
kind: 'target',
|
|
3
5
|
familyId: 'sql',
|
|
@@ -5,4 +7,7 @@ export const postgresTargetDescriptorMeta = {
|
|
|
5
7
|
id: 'postgres',
|
|
6
8
|
version: '0.0.1',
|
|
7
9
|
capabilities: {},
|
|
10
|
+
authoring: {
|
|
11
|
+
type: postgresAuthoringTypes,
|
|
12
|
+
},
|
|
8
13
|
} as const;
|