@prisma-next/target-postgres 0.5.0-dev.6 → 0.5.0-dev.61
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-B-wNPs-9.d.mts +29 -0
- package/dist/codec-ids-B-wNPs-9.d.mts.map +1 -0
- package/dist/{codec-ids-CojIXVf9.mjs → codec-ids-ckQX9Kcg.mjs} +3 -2
- package/dist/{codec-ids-CojIXVf9.mjs.map → codec-ids-ckQX9Kcg.mjs.map} +1 -1
- package/dist/codec-ids.d.mts +2 -28
- package/dist/codec-ids.mjs +2 -2
- package/dist/codec-types-Br-rrBBQ.d.mts +80 -0
- package/dist/codec-types-Br-rrBBQ.d.mts.map +1 -0
- package/dist/codec-types.d.mts +4 -42
- package/dist/codec-types.mjs +1 -3
- package/dist/codecs-DZUnQrrl.d.mts +559 -0
- package/dist/codecs-DZUnQrrl.d.mts.map +1 -0
- package/dist/codecs.d.mts +15 -2
- package/dist/codecs.d.mts.map +1 -0
- package/dist/codecs.mjs +742 -2
- package/dist/codecs.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +26 -68
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-VfEGzXWt.mjs → data-transform-CR_9PvW9.mjs} +24 -5
- package/dist/data-transform-CR_9PvW9.mjs.map +1 -0
- package/dist/data-transform-T71mQkVW.d.mts +39 -0
- package/dist/data-transform-T71mQkVW.d.mts.map +1 -0
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/{default-normalizer-DNOpRoOF.mjs → default-normalizer-D4RoM0i6.mjs} +1 -1
- package/dist/{default-normalizer-DNOpRoOF.mjs.map → default-normalizer-D4RoM0i6.mjs.map} +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/{descriptor-meta-BVoVtyp-.mjs → descriptor-meta-B9JFfKCb.mjs} +7 -12
- package/dist/descriptor-meta-B9JFfKCb.mjs.map +1 -0
- package/dist/{errors-AFvEPZ1R.mjs → errors-BT_Duyj-.mjs} +1 -1
- package/dist/{errors-AFvEPZ1R.mjs.map → errors-BT_Duyj-.mjs.map} +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{issue-planner-CFjB0_oO.mjs → issue-planner-DooWabc2.mjs} +8 -8
- package/dist/{issue-planner-CFjB0_oO.mjs.map → issue-planner-DooWabc2.mjs.map} +1 -1
- package/dist/issue-planner.d.mts +3 -3
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +3 -3
- package/dist/migration.mjs +3 -3
- package/dist/{native-type-normalizer-CInai_oY.mjs → native-type-normalizer-i4IFPL5F.mjs} +1 -1
- package/dist/{native-type-normalizer-CInai_oY.mjs.map → native-type-normalizer-i4IFPL5F.mjs.map} +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/{op-factory-call-BKlruaiC.mjs → op-factory-call-Bvw39XKU.mjs} +2 -2
- package/dist/{op-factory-call-BKlruaiC.mjs.map → op-factory-call-Bvw39XKU.mjs.map} +1 -1
- package/dist/{op-factory-call-C3bWXKSP.d.mts → op-factory-call-SFMIf-Cz.d.mts} +3 -3
- package/dist/{op-factory-call-C3bWXKSP.d.mts.map → op-factory-call-SFMIf-Cz.d.mts.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +30 -9
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CLUvVhUN.mjs → planner-BMtFbKfn.mjs} +9 -9
- package/dist/planner-BMtFbKfn.mjs.map +1 -0
- package/dist/{planner-ddl-builders-Dxvw1LHw.mjs → planner-ddl-builders-B6VK92UF.mjs} +3 -3
- package/dist/{planner-ddl-builders-Dxvw1LHw.mjs.map → planner-ddl-builders-B6VK92UF.mjs.map} +1 -1
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-Dju-o5GF.mjs → planner-identity-values-CC5fa5D9.mjs} +1 -1
- package/dist/{planner-identity-values-Dju-o5GF.mjs.map → planner-identity-values-CC5fa5D9.mjs.map} +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs → planner-produced-postgres-migration-C0vaAvA8.mjs} +4 -5
- package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs.map → planner-produced-postgres-migration-C0vaAvA8.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-CRRTno6Z.d.mts → planner-produced-postgres-migration-CyzRgqsq.d.mts} +4 -4
- package/dist/planner-produced-postgres-migration-CyzRgqsq.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +5 -4
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-schema-lookup-B7lkypwn.mjs → planner-schema-lookup-B3talum5.mjs} +1 -1
- package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B3talum5.mjs.map} +1 -1
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-7jkgm9TX.mjs → planner-sql-checks-uDnwA68k.mjs} +2 -2
- package/dist/{planner-sql-checks-7jkgm9TX.mjs.map → planner-sql-checks-uDnwA68k.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-DH-azLu-.d.mts → planner-target-details-COAiKZjW.d.mts} +1 -1
- package/dist/{planner-target-details-DH-azLu-.d.mts.map → planner-target-details-COAiKZjW.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +19 -12
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-migration-qtmtbONe.mjs → postgres-migration-BAgHXrjO.mjs} +3 -3
- package/dist/postgres-migration-BAgHXrjO.mjs.map +1 -0
- package/dist/{postgres-migration-BjA3Zmts.d.mts → postgres-migration-Dzxr5BCy.d.mts} +5 -4
- package/dist/postgres-migration-Dzxr5BCy.d.mts.map +1 -0
- package/dist/{render-ops-D6_DHdOK.mjs → render-ops-DddkYOIB.mjs} +1 -1
- package/dist/{render-ops-D6_DHdOK.mjs.map → render-ops-DddkYOIB.mjs.map} +1 -1
- package/dist/render-ops.d.mts +3 -3
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-1rF_SB4g.mjs → render-typescript-0EtwW-Ip.mjs} +1 -2
- package/dist/render-typescript-0EtwW-Ip.mjs.map +1 -0
- package/dist/render-typescript.d.mts +3 -4
- package/dist/render-typescript.d.mts.map +1 -1
- package/dist/render-typescript.mjs +1 -1
- package/dist/runtime.d.mts +5 -9
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +5 -10
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-Bxkt8pNO.d.mts → shared-DSVRy4AX.d.mts} +2 -2
- package/dist/{shared-Bxkt8pNO.d.mts.map → shared-DSVRy4AX.d.mts.map} +1 -1
- package/dist/{sql-utils-r-Lw535w.mjs → sql-utils-C9dyHV0x.mjs} +1 -1
- package/dist/{sql-utils-r-Lw535w.mjs.map → sql-utils-C9dyHV0x.mjs.map} +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/{statement-builders-BPnmt6wx.mjs → statement-builders-Ckkq4ryf.mjs} +13 -8
- package/dist/statement-builders-Ckkq4ryf.mjs.map +1 -0
- package/dist/statement-builders.d.mts +10 -3
- package/dist/statement-builders.d.mts.map +1 -1
- package/dist/statement-builders.mjs +2 -2
- package/dist/{tables-BmdW_FWO.mjs → tables-CnvPb0Iz.mjs} +3 -3
- package/dist/{tables-BmdW_FWO.mjs.map → tables-CnvPb0Iz.mjs.map} +1 -1
- package/dist/{types-ClK03Ojd.d.mts → types-DWZq_XTl.d.mts} +1 -1
- package/dist/types-DWZq_XTl.d.mts.map +1 -0
- package/dist/types.d.mts +1 -1
- package/package.json +17 -15
- package/src/core/authoring.ts +5 -11
- package/src/core/codec-helpers.ts +135 -0
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +81 -0
- package/src/core/codecs.ts +941 -547
- package/src/core/descriptor-meta.ts +1 -1
- package/src/core/migrations/operations/data-transform.ts +86 -21
- package/src/core/migrations/planner-produced-postgres-migration.ts +0 -1
- package/src/core/migrations/planner.ts +17 -11
- package/src/core/migrations/postgres-migration.ts +3 -6
- package/src/core/migrations/render-typescript.ts +1 -5
- package/src/core/migrations/runner.ts +43 -112
- package/src/core/migrations/statement-builders.ts +22 -6
- package/src/core/registry.ts +11 -0
- package/src/exports/codec-types.ts +4 -13
- package/src/exports/codecs.ts +49 -2
- package/src/exports/runtime.ts +6 -11
- package/src/exports/statement-builders.ts +1 -1
- package/dist/codec-ids.d.mts.map +0 -1
- package/dist/codec-types.d.mts.map +0 -1
- package/dist/codecs-BoahtY_Q.mjs +0 -385
- package/dist/codecs-BoahtY_Q.mjs.map +0 -1
- package/dist/codecs-D-F2KJqt.d.mts +0 -299
- package/dist/codecs-D-F2KJqt.d.mts.map +0 -1
- package/dist/data-transform-CxFRBIUp.d.mts +0 -32
- package/dist/data-transform-CxFRBIUp.d.mts.map +0 -1
- package/dist/data-transform-VfEGzXWt.mjs.map +0 -1
- package/dist/descriptor-meta-BVoVtyp-.mjs.map +0 -1
- package/dist/planner-CLUvVhUN.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +0 -1
- package/dist/postgres-migration-BjA3Zmts.d.mts.map +0 -1
- package/dist/postgres-migration-qtmtbONe.mjs.map +0 -1
- package/dist/render-typescript-1rF_SB4g.mjs.map +0 -1
- package/dist/statement-builders-BPnmt6wx.mjs.map +0 -1
- package/dist/types-ClK03Ojd.d.mts.map +0 -1
- package/src/core/json-schema-type-expression.ts +0 -131
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
2
|
-
import { t as renderOps } from "./render-ops-
|
|
3
|
-
import { t as renderCallsToTypeScript } from "./render-typescript-
|
|
1
|
+
import { t as PostgresMigration } from "./postgres-migration-BAgHXrjO.mjs";
|
|
2
|
+
import { t as renderOps } from "./render-ops-DddkYOIB.mjs";
|
|
3
|
+
import { t as renderCallsToTypeScript } from "./render-typescript-0EtwW-Ip.mjs";
|
|
4
4
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
5
5
|
|
|
6
6
|
//#region src/core/migrations/planner-produced-postgres-migration.ts
|
|
@@ -22,7 +22,6 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
|
22
22
|
return renderCallsToTypeScript(this.#calls, {
|
|
23
23
|
from: this.#meta.from,
|
|
24
24
|
to: this.#meta.to,
|
|
25
|
-
...ifDefined("kind", this.#meta.kind),
|
|
26
25
|
...ifDefined("labels", this.#meta.labels)
|
|
27
26
|
});
|
|
28
27
|
}
|
|
@@ -30,4 +29,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
|
30
29
|
|
|
31
30
|
//#endregion
|
|
32
31
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
33
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
32
|
+
//# sourceMappingURL=planner-produced-postgres-migration-C0vaAvA8.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-postgres-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-C0vaAvA8.mjs","names":["#calls","#meta"],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":["/**\n * Planner-produced Postgres migration.\n *\n * Returned by `PostgresMigrationPlanner.plan(...)` and `emptyMigration(...)`.\n * Holds the migration IR (`PostgresOpFactoryCall[]`) alongside\n * `MigrationMeta` and exposes both the runtime-ops view (`get operations`)\n * and the TypeScript authoring view (`renderTypeScript()`). Satisfies\n * `MigrationPlanWithAuthoringSurface` so the CLI can uniformly serialize any\n * planner result back to `migration.ts`.\n *\n * Extends the family-level `SqlMigration` alias rather than the target-local\n * migration base directly — mirrors Mongo's `PlannerProducedMongoMigration`\n * shape and keeps CLI wiring one step removed from target internals.\n *\n * Placeholder-bearing plans: `renderTypeScript()` always succeeds and embeds\n * `() => placeholder(\"slot\")` at each stub. `operations`, in contrast, is\n * _not safe to enumerate_ on a stub-bearing plan — `DataTransformCall.toOp()`\n * throws `PN-MIG-2001` because a planner-stubbed closure cannot be lowered\n * to a runtime op. Callers that know a plan may carry stubs must render to\n * `migration.ts`, let the user fill the slots, and re-load the edited\n * migration before enumerating ops. The walk-schema planner does not emit\n * `DataTransformCall`s today, so this asymmetry is invisible until the\n * issue-planner integration lands in Phase 2.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { MigrationPlanWithAuthoringSurface } from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\nimport { PostgresMigration } from './postgres-migration';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\nexport class TypeScriptRenderablePostgresMigration\n extends PostgresMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly PostgresOpFactoryCall[];\n readonly #meta: MigrationMeta;\n\n constructor(calls: readonly PostgresOpFactoryCall[], meta: MigrationMeta) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n }\n\n override get operations(): readonly Op[] {\n return renderOps(this.#calls);\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, {\n from: this.#meta.from,\n to: this.#meta.to,\n ...ifDefined('labels', this.#meta.labels),\n });\n }\n}\n"],"mappings":";;;;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE,CAASA;CACT,CAASC;CAET,YAAY,OAAyC,MAAqB;AACxE,SAAO;AACP,QAAKD,QAAS;AACd,QAAKC,OAAQ;;CAGf,IAAa,aAA4B;AACvC,SAAO,UAAU,MAAKD,MAAO;;CAG/B,AAAS,WAA0B;AACjC,SAAO,MAAKC;;CAGd,mBAA2B;AACzB,SAAO,wBAAwB,MAAKD,OAAQ;GAC1C,MAAM,MAAKC,KAAM;GACjB,IAAI,MAAKA,KAAM;GACf,GAAG,UAAU,UAAU,MAAKA,KAAM,OAAO;GAC1C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { b as PostgresOpFactoryCall } from "./op-factory-call-
|
|
3
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-COAiKZjW.mjs";
|
|
2
|
+
import { b as PostgresOpFactoryCall } from "./op-factory-call-SFMIf-Cz.mjs";
|
|
3
|
+
import { t as PostgresMigration } from "./postgres-migration-Dzxr5BCy.mjs";
|
|
4
4
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
5
5
|
import { MigrationPlanWithAuthoringSurface } from "@prisma-next/framework-components/control";
|
|
6
6
|
import { MigrationMeta } from "@prisma-next/migration-tools/migration";
|
|
@@ -17,4 +17,4 @@ declare class TypeScriptRenderablePostgresMigration extends PostgresMigration im
|
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
20
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
20
|
+
//# sourceMappingURL=planner-produced-postgres-migration-CyzRgqsq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-CyzRgqsq.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAmCK,EAAA,GAAK,0BAA0B;cAEvB,qCAAA,SACH,iBAAA,YACG;;8BAKiB,+BAA+B;6BAMvB;cAIf"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import
|
|
1
|
+
import "./data-transform-T71mQkVW.mjs";
|
|
2
|
+
import "./shared-DSVRy4AX.mjs";
|
|
3
|
+
import "./op-factory-call-SFMIf-Cz.mjs";
|
|
4
|
+
import "./postgres-migration-Dzxr5BCy.mjs";
|
|
5
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CyzRgqsq.mjs";
|
|
5
6
|
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-C0vaAvA8.mjs";
|
|
2
2
|
|
|
3
3
|
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -26,4 +26,4 @@ function hasForeignKey(lookup, fk) {
|
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { hasUniqueConstraint as i, hasForeignKey as n, hasIndex as r, buildSchemaLookupMap as t };
|
|
29
|
-
//# sourceMappingURL=planner-schema-lookup-
|
|
29
|
+
//# sourceMappingURL=planner-schema-lookup-B3talum5.mjs.map
|
package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B3talum5.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-schema-lookup-
|
|
1
|
+
{"version":3,"file":"planner-schema-lookup-B3talum5.mjs","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"sourcesContent":["import type { ForeignKey } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * Pre-computed lookup sets for a schema table's constraints.\n * Converts O(n*m) linear scans to O(1) Set lookups per constraint check.\n */\nexport interface SchemaTableLookup {\n readonly uniqueKeys: Set<string>;\n readonly indexKeys: Set<string>;\n readonly uniqueIndexKeys: Set<string>;\n readonly fkKeys: Set<string>;\n}\n\nexport function buildSchemaLookupMap(schema: SqlSchemaIR): ReadonlyMap<string, SchemaTableLookup> {\n const map = new Map<string, SchemaTableLookup>();\n for (const [tableName, table] of Object.entries(schema.tables)) {\n map.set(tableName, buildSchemaTableLookup(table));\n }\n return map;\n}\n\nfunction buildSchemaTableLookup(table: SqlSchemaIR['tables'][string]): SchemaTableLookup {\n const uniqueKeys = new Set(table.uniques.map((u) => u.columns.join(',')));\n const indexKeys = new Set(table.indexes.map((i) => i.columns.join(',')));\n const uniqueIndexKeys = new Set(\n table.indexes.filter((i) => i.unique).map((i) => i.columns.join(',')),\n );\n const fkKeys = new Set(\n table.foreignKeys.map(\n (fk) => `${fk.columns.join(',')}|${fk.referencedTable}|${fk.referencedColumns.join(',')}`,\n ),\n );\n return { uniqueKeys, indexKeys, uniqueIndexKeys, fkKeys };\n}\n\nexport function hasUniqueConstraint(\n lookup: SchemaTableLookup,\n columns: readonly string[],\n): boolean {\n const key = columns.join(',');\n return lookup.uniqueKeys.has(key) || lookup.uniqueIndexKeys.has(key);\n}\n\nexport function hasIndex(lookup: SchemaTableLookup, columns: readonly string[]): boolean {\n const key = columns.join(',');\n return lookup.indexKeys.has(key) || lookup.uniqueKeys.has(key);\n}\n\nexport function hasForeignKey(lookup: SchemaTableLookup, fk: ForeignKey): boolean {\n return lookup.fkKeys.has(\n `${fk.columns.join(',')}|${fk.references.table}|${fk.references.columns.join(',')}`,\n );\n}\n"],"mappings":";AAcA,SAAgB,qBAAqB,QAA6D;CAChG,MAAM,sBAAM,IAAI,KAAgC;AAChD,MAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,OAAO,OAAO,CAC5D,KAAI,IAAI,WAAW,uBAAuB,MAAM,CAAC;AAEnD,QAAO;;AAGT,SAAS,uBAAuB,OAAyD;AAWvF,QAAO;EAAE,YAVU,IAAI,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC;EAUpD,WATH,IAAI,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC;EASxC,iBARR,IAAI,IAC1B,MAAM,QAAQ,QAAQ,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CACtE;EAMgD,QALlC,IAAI,IACjB,MAAM,YAAY,KACf,OAAO,GAAG,GAAG,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,gBAAgB,GAAG,GAAG,kBAAkB,KAAK,IAAI,GACxF,CACF;EACwD;;AAG3D,SAAgB,oBACd,QACA,SACS;CACT,MAAM,MAAM,QAAQ,KAAK,IAAI;AAC7B,QAAO,OAAO,WAAW,IAAI,IAAI,IAAI,OAAO,gBAAgB,IAAI,IAAI;;AAGtE,SAAgB,SAAS,QAA2B,SAAqC;CACvF,MAAM,MAAM,QAAQ,KAAK,IAAI;AAC7B,QAAO,OAAO,UAAU,IAAI,IAAI,IAAI,OAAO,WAAW,IAAI,IAAI;;AAGhE,SAAgB,cAAc,QAA2B,IAAyB;AAChF,QAAO,OAAO,OAAO,IACnB,GAAG,GAAG,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,WAAW,MAAM,GAAG,GAAG,WAAW,QAAQ,KAAK,IAAI,GAClF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as hasUniqueConstraint, n as hasForeignKey, r as hasIndex, t as buildSchemaLookupMap } from "./planner-schema-lookup-
|
|
1
|
+
import { i as hasUniqueConstraint, n as hasForeignKey, r as hasIndex, t as buildSchemaLookupMap } from "./planner-schema-lookup-B3talum5.mjs";
|
|
2
2
|
|
|
3
3
|
export { buildSchemaLookupMap, hasForeignKey, hasIndex, hasUniqueConstraint };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-
|
|
1
|
+
import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-C9dyHV0x.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/migrations/planner-type-resolution.ts
|
|
4
4
|
function resolveColumnTypeMetadata(column, storageTypes) {
|
|
@@ -238,4 +238,4 @@ function tableHasPrimaryKeyCheck(schema, table, exists, constraintName) {
|
|
|
238
238
|
|
|
239
239
|
//#endregion
|
|
240
240
|
export { columnNullabilityCheck as a, qualifyTableName as c, toRegclassLiteral as d, resolveColumnTypeMetadata as f, columnHasNoDefaultCheck as i, tableHasPrimaryKeyCheck as l, columnDefaultExistsCheck as n, columnTypeCheck as o, columnExistsCheck as r, constraintExistsCheck as s, buildExpectedFormatType as t, tableIsEmptyCheck as u };
|
|
241
|
-
//# sourceMappingURL=planner-sql-checks-
|
|
241
|
+
//# sourceMappingURL=planner-sql-checks-uDnwA68k.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks-7jkgm9TX.mjs","names":["FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string>"],"sources":["../src/core/migrations/planner-type-resolution.ts","../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\n\nexport type ResolvedColumnTypeMetadata = Pick<\n StorageColumn,\n 'nativeType' | 'codecId' | 'typeParams'\n>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n return column;\n }\n\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n","import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\nexport function qualifyTableName(schema: string, table: string): string {\n return `${quoteIdentifier(schema)}.${quoteIdentifier(table)}`;\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n const regclass = `${quoteIdentifier(schema)}.${quoteIdentifier(name)}`;\n return `'${escapeLiteral(regclass)}'`;\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${toRegclassLiteral(schema, table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = '${escapeLiteral(schema)}'\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(opts.schema)}'\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"planner-sql-checks-uDnwA68k.mjs","names":["FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string>"],"sources":["../src/core/migrations/planner-type-resolution.ts","../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\n\nexport type ResolvedColumnTypeMetadata = Pick<\n StorageColumn,\n 'nativeType' | 'codecId' | 'typeParams'\n>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n return column;\n }\n\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n","import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\nexport function qualifyTableName(schema: string, table: string): string {\n return `${quoteIdentifier(schema)}.${quoteIdentifier(table)}`;\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n const regclass = `${quoteIdentifier(schema)}.${quoteIdentifier(name)}`;\n return `'${escapeLiteral(regclass)}'`;\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${toRegclassLiteral(schema, table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = '${escapeLiteral(schema)}'\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(opts.schema)}'\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":"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"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-
|
|
1
|
+
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-uDnwA68k.mjs";
|
|
2
2
|
|
|
3
3
|
export { buildExpectedFormatType, columnExistsCheck, columnHasNoDefaultCheck, columnNullabilityCheck, constraintExistsCheck, qualifyTableName, tableHasPrimaryKeyCheck, tableIsEmptyCheck, toRegclassLiteral };
|
package/dist/{planner-target-details-DH-azLu-.d.mts.map → planner-target-details-COAiKZjW.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-target-details-
|
|
1
|
+
{"version":3,"file":"planner-target-details-COAiKZjW.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"sourcesContent":[],"mappings":";KAEY,cAAA;AAAA,UAUK,yBAAA,CAVS;EAUT,SAAA,MAAA,EAAA,MAAA;uBAEM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-COAiKZjW.mjs";
|
|
2
2
|
export { type PostgresPlanTargetDetails };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import
|
|
1
|
+
import "./data-transform-T71mQkVW.mjs";
|
|
2
|
+
import "./shared-DSVRy4AX.mjs";
|
|
3
|
+
import "./op-factory-call-SFMIf-Cz.mjs";
|
|
4
|
+
import "./postgres-migration-Dzxr5BCy.mjs";
|
|
5
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CyzRgqsq.mjs";
|
|
5
6
|
import { MigrationOperationPolicy, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
6
|
-
import {
|
|
7
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
7
8
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
9
|
+
import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
|
|
8
10
|
|
|
9
11
|
//#region src/core/migrations/planner.d.ts
|
|
10
12
|
interface PlannerConfig {
|
|
@@ -45,16 +47,21 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
|
|
|
45
47
|
readonly contract: unknown;
|
|
46
48
|
readonly schema: unknown;
|
|
47
49
|
readonly policy: MigrationOperationPolicy;
|
|
48
|
-
readonly fromHash?: string;
|
|
49
50
|
/**
|
|
50
51
|
* The "from" contract (state the planner assumes the database starts
|
|
51
|
-
* at)
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* activate.
|
|
52
|
+
* at), or `null` for reconciliation flows. Only `migration plan` ever
|
|
53
|
+
* supplies a non-null value; `db update` / `db init` reconcile against
|
|
54
|
+
* the live schema and pass `null`. When present alongside the
|
|
55
|
+
* `'data'` operation class, strategies that need from/to column-shape
|
|
56
|
+
* comparisons (unsafe type change, nullability tightening) activate.
|
|
57
|
+
*
|
|
58
|
+
* Typed as the framework `Contract | null` to satisfy the
|
|
59
|
+
* `MigrationPlanner` interface contract; `planSql` narrows to the SQL
|
|
60
|
+
* shape via `SqlMigrationPlannerPlanOptions`. Used to populate
|
|
61
|
+
* `describe().from` on the produced plan as
|
|
62
|
+
* `fromContract?.storage.storageHash ?? null`.
|
|
56
63
|
*/
|
|
57
|
-
readonly fromContract
|
|
64
|
+
readonly fromContract: Contract | null;
|
|
58
65
|
readonly schemaName?: string;
|
|
59
66
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
60
67
|
}): PostgresPlanResult;
|
package/dist/planner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;UAmCU,aAAA;;;iBAQM,8BAAA,UACN,QAAQ,iBACf;;;AA3B2F;AAyB9F;;;;AAE2B,KAcf,kBAAA,GAde;EAcf,SAAA,IAAA,EAAA,SAAkB;EAoBjB,SAAA,IAAA,EAnBkC,qCAmBT;CACC,GAnBnC,uBAmBmC;;;;;;;;;;;;;;;;;cAD1B,wBAAA,YAAoC;;sBACV;;;;qBAKlB;;;;;;;;;;;;;;;2BAeM;;kCAEO,cAAc;MAC1C;0BAIoB,2BAA2B"}
|
package/dist/planner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./issue-planner-
|
|
2
|
-
import { t as createPostgresMigrationPlanner } from "./planner-
|
|
1
|
+
import "./issue-planner-DooWabc2.mjs";
|
|
2
|
+
import { t as createPostgresMigrationPlanner } from "./planner-BMtFbKfn.mjs";
|
|
3
3
|
|
|
4
4
|
export { createPostgresMigrationPlanner };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as errorPostgresMigrationStackMissing } from "./errors-
|
|
2
|
-
import { t as dataTransform } from "./data-transform-
|
|
1
|
+
import { t as errorPostgresMigrationStackMissing } from "./errors-BT_Duyj-.mjs";
|
|
2
|
+
import { t as dataTransform } from "./data-transform-CR_9PvW9.mjs";
|
|
3
3
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
4
4
|
|
|
5
5
|
//#region src/core/migrations/postgres-migration.ts
|
|
@@ -49,4 +49,4 @@ var PostgresMigration = class extends Migration {
|
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { PostgresMigration as t };
|
|
52
|
-
//# sourceMappingURL=postgres-migration-
|
|
52
|
+
//# sourceMappingURL=postgres-migration-BAgHXrjO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-BAgHXrjO.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a target-specific re-export of this\n * class from `@prisma-next/target-postgres/migration`, keeping the\n * authoring surface target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,AAAS,WAAW;;;;;;;CAQpB,AAAmB;CAEnB,YAAY,OAAyC;AACnD,QAAM,MAAM;AAIZ,OAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,MAAM,GAC5B;;;;;;;CAQN,AAAU,cACR,UACA,MACA,SACsD;AACtD,MAAI,CAAC,KAAK,eACR,OAAM,oCAAoC;AAE5C,SAAO,cAAc,UAAU,MAAM,SAAS,KAAK,eAAe"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { n as DataTransformOptions
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-COAiKZjW.mjs";
|
|
2
|
+
import { n as DataTransformOptions } from "./data-transform-T71mQkVW.mjs";
|
|
3
|
+
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
4
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
4
5
|
import { Contract } from "@prisma-next/contract/types";
|
|
5
6
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -43,8 +44,8 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
|
|
|
43
44
|
* supplies the stored control adapter. Authors call this from inside
|
|
44
45
|
* `get operations()`; the adapter argument is hidden from the call site.
|
|
45
46
|
*/
|
|
46
|
-
protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions):
|
|
47
|
+
protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
47
48
|
}
|
|
48
49
|
//#endregion
|
|
49
50
|
export { PostgresMigration as t };
|
|
50
|
-
//# sourceMappingURL=postgres-migration-
|
|
51
|
+
//# sourceMappingURL=postgres-migration-Dzxr5BCy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-Dzxr5BCy.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,UAC9C;;;;;;;;qCAWmC;sBAEf;;;;;;4CAesB,SAAS,uBACvC,kCAED,uBACR,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops-
|
|
1
|
+
{"version":3,"file":"render-ops-DddkYOIB.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\nexport function renderOps(calls: readonly PostgresOpFactoryCall[]): Op[] {\n return calls.map((c) => c.toOp());\n}\n"],"mappings":";AAMA,SAAgB,UAAU,OAA+C;AACvE,QAAO,MAAM,KAAK,MAAM,EAAE,MAAM,CAAC"}
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import "./shared-
|
|
3
|
-
import { b as PostgresOpFactoryCall } from "./op-factory-call-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-COAiKZjW.mjs";
|
|
2
|
+
import "./shared-DSVRy4AX.mjs";
|
|
3
|
+
import { b as PostgresOpFactoryCall } from "./op-factory-call-SFMIf-Cz.mjs";
|
|
4
4
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
5
5
|
|
|
6
6
|
//#region src/core/migrations/render-ops.d.ts
|
package/dist/render-ops.mjs
CHANGED
|
@@ -68,7 +68,6 @@ function buildDescribeMethod(meta) {
|
|
|
68
68
|
lines.push(" return {");
|
|
69
69
|
lines.push(` from: ${JSON.stringify(meta.from)},`);
|
|
70
70
|
lines.push(` to: ${JSON.stringify(meta.to)},`);
|
|
71
|
-
if (meta.kind) lines.push(` kind: ${JSON.stringify(meta.kind)},`);
|
|
72
71
|
if (meta.labels && meta.labels.length > 0) lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
|
|
73
72
|
lines.push(" };");
|
|
74
73
|
lines.push(" }");
|
|
@@ -82,4 +81,4 @@ function indent(text, spaces) {
|
|
|
82
81
|
|
|
83
82
|
//#endregion
|
|
84
83
|
export { renderCallsToTypeScript as t };
|
|
85
|
-
//# sourceMappingURL=render-typescript-
|
|
84
|
+
//# sourceMappingURL=render-typescript-0EtwW-Ip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-typescript-0EtwW-Ip.mjs","names":["BASE_IMPORTS: readonly ImportRequirement[]","requirements: ImportRequirement[]","lines: string[]"],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `PostgresOpFactoryCall` 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 { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/target-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 target-owned 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/target-postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/target-postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<PostgresOpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<PostgresOpFactoryCall>): 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 if (meta.labels && meta.labels.length > 0) {\n lines.push(` labels: ${jsonToTsSource(meta.labels)},`);\n }\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAMA,eAA6C,CACjD;CAAE,iBAAiB;CAA0C,QAAQ;CAAa,EAClF;CAAE,iBAAiB;CAA0C,QAAQ;CAAgB,CACtF;AAED,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,MAAM;CACnC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,kBAAkB,CAAC,CAAC,KAAK,MAAM;AAEzE,QAAO;EACL,eAAe,uBAAuB,CAAC;EACvC;EACA;EACA;EACA,oBAAoB,KAAK;EACzB;EACA;EACA,OAAO,gBAAgB,EAAE;EACzB;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,aAAa,OAAqD;CACzE,MAAMC,eAAoC,CAAC,GAAG,aAAa;AAC3D,MAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,OAAO,KAAK,oBAAoB,CACzC,cAAa,KAAK,IAAI;AAG1B,QAAO,cAAc,aAAa;;AAGpC,SAAS,oBAAoB,MAAmC;CAC9D,MAAMC,QAAkB,EAAE;AAC1B,OAAM,KAAK,0BAA0B;AACrC,OAAM,KAAK,eAAe;AAC1B,OAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;AACvD,OAAM,KAAK,aAAa,KAAK,UAAU,KAAK,GAAG,CAAC,GAAG;AACnD,KAAI,KAAK,UAAU,KAAK,OAAO,SAAS,EACtC,OAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO,CAAC,GAAG;AAE7D,OAAM,KAAK,SAAS;AACpB,OAAM,KAAK,MAAM;AACjB,OAAM,KAAK,GAAG;AACd,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,OAAO;AAC9B,QAAO,KACJ,MAAM,KAAK,CACX,KAAK,SAAU,KAAK,MAAM,GAAG,GAAG,MAAM,SAAS,KAAM,CACrD,KAAK,KAAK"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import "./shared-
|
|
2
|
-
import { b as PostgresOpFactoryCall } from "./op-factory-call-
|
|
1
|
+
import "./shared-DSVRy4AX.mjs";
|
|
2
|
+
import { b as PostgresOpFactoryCall } from "./op-factory-call-SFMIf-Cz.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/render-typescript.d.ts
|
|
5
5
|
|
|
6
6
|
interface RenderMigrationMeta {
|
|
7
|
-
readonly from: string;
|
|
7
|
+
readonly from: string | null;
|
|
8
8
|
readonly to: string;
|
|
9
|
-
readonly kind?: string;
|
|
10
9
|
readonly labels?: readonly string[];
|
|
11
10
|
}
|
|
12
11
|
declare function renderCallsToTypeScript(calls: ReadonlyArray<PostgresOpFactoryCall>, meta: RenderMigrationMeta): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":[],"mappings":";;;;;UAeiB,mBAAA
|
|
1
|
+
{"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":[],"mappings":";;;;;UAeiB,mBAAA;;;;;iBA6BD,uBAAA,QACP,cAAc,8BACf"}
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
|
|
2
2
|
import { RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
|
|
3
3
|
|
|
4
4
|
//#region src/exports/runtime.d.ts
|
|
5
5
|
interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}
|
|
6
6
|
/**
|
|
7
|
-
* Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`
|
|
8
|
-
* from `@prisma-next/sql-runtime`. The target package is a control-plane
|
|
9
|
-
* residence and must not pull the SQL execution-plane package into its
|
|
10
|
-
* dependency closure. The runtime descriptor here is shaped to satisfy the
|
|
11
|
-
* framework's `RuntimeTargetDescriptor` plus the structural
|
|
12
|
-
* `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that
|
|
7
|
+
* 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
|
|
13
8
|
* `@prisma-next/sql-runtime` consumers narrow to at composition time.
|
|
9
|
+
*
|
|
10
|
+
* The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
|
|
14
11
|
*/
|
|
15
12
|
declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'postgres', PostgresRuntimeTargetInstance> & {
|
|
16
|
-
readonly codecs: () =>
|
|
17
|
-
readonly parameterizedCodecs: () => readonly never[];
|
|
13
|
+
readonly codecs: () => readonly AnyCodecDescriptor[];
|
|
18
14
|
};
|
|
19
15
|
//#endregion
|
|
20
16
|
export { PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAOiB,6BAAA,SAAsC;AAAvD;AAAkG
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAOiB,6BAAA,SAAsC;AAAvD;AAAkG;;;;;cAQ5F,iCAAiC,2CAGrC;kCAEgC"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-
|
|
2
|
-
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
1
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-B9JFfKCb.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/exports/runtime.ts
|
|
5
4
|
/**
|
|
6
|
-
* Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`
|
|
7
|
-
* from `@prisma-next/sql-runtime`. The target package is a control-plane
|
|
8
|
-
* residence and must not pull the SQL execution-plane package into its
|
|
9
|
-
* dependency closure. The runtime descriptor here is shaped to satisfy the
|
|
10
|
-
* framework's `RuntimeTargetDescriptor` plus the structural
|
|
11
|
-
* `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that
|
|
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
|
|
12
6
|
* `@prisma-next/sql-runtime` consumers narrow to at composition time.
|
|
7
|
+
*
|
|
8
|
+
* The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
|
|
13
9
|
*/
|
|
14
10
|
const postgresRuntimeTargetDescriptor = {
|
|
15
11
|
...postgresTargetDescriptorMeta,
|
|
16
|
-
codecs: () =>
|
|
17
|
-
parameterizedCodecs: () => [],
|
|
12
|
+
codecs: () => [],
|
|
18
13
|
create() {
|
|
19
14
|
return {
|
|
20
15
|
familyId: "sql",
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () =>
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n}"],"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 { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\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 ...postgresTargetDescriptorMeta,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;AAeA,MAAMA,kCAMF;CACF,GAAG;CACH,cAAc,EAAE;CAChB,SAAwC;AACtC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,sBAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-COAiKZjW.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ReferentialAction } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
@@ -38,4 +38,4 @@ interface ForeignKeySpec {
|
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
export { ForeignKeySpec as n, Op as r, ColumnSpec as t };
|
|
41
|
-
//# sourceMappingURL=shared-
|
|
41
|
+
//# sourceMappingURL=shared-DSVRy4AX.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-DSVRy4AX.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"sourcesContent":[],"mappings":";;;;;KAMY,EAAA,GAAK,0BAA0B;;AAA3C;AAcA;AAWA;;;;;;;;;UAXiB,UAAA;;;;;;;;;;UAWA,cAAA;;;;;;;sBAOK;sBACA"}
|
|
@@ -73,4 +73,4 @@ function validateEnumValueLength(value, enumTypeName) {
|
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
|
|
76
|
-
//# sourceMappingURL=sql-utils-
|
|
76
|
+
//# sourceMappingURL=sql-utils-C9dyHV0x.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-utils-
|
|
1
|
+
{"version":3,"file":"sql-utils-C9dyHV0x.mjs","names":["value: string","kind: 'identifier' | 'literal'"],"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;CACxC,YACE,SACA,AAAgBA,OAChB,AAAgBC,MAChB;AACA,QAAM,QAAQ;EAHE;EACA;AAGhB,OAAK,OAAO;;;AAIhB,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;AAC1D,KAAI,WAAW,WAAW,EACxB,OAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;AAElF,KAAI,WAAW,SAAS,KAAK,CAC3B,OAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;AAEH,KAAI,WAAW,SAAS,sBACtB,SAAQ,KACN,eAAe,WAAW,MAAM,GAAG,GAAG,CAAC,4BAA4B,sBAAsB,wCAC1F;AAEH,QAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,cAAc,OAAuB;AACnD,KAAI,MAAM,SAAS,KAAK,CACtB,OAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;AAEH,QAAO,MAAM,QAAQ,MAAM,KAAK;;;;;AAMlC,SAAgB,YAAY,YAAoB,YAA4B;AAC1E,QAAO,GAAG,gBAAgB,WAAW,CAAC,GAAG,gBAAgB,WAAW;;;;;;;;;;;;;AActE,SAAgB,wBAAwB,OAAe,cAA4B;AACjF,KAAI,MAAM,SAAS,sBACjB,OAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,UACD"}
|
package/dist/sql-utils.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-C9dyHV0x.mjs";
|
|
2
2
|
|
|
3
3
|
export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
|