@prisma-next/target-postgres 0.5.0-dev.9 → 0.5.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/dist/{codec-ids-CojIXVf9.mjs → codec-ids-C5qzBqus.mjs} +4 -4
- package/dist/{codec-ids-CojIXVf9.mjs.map → codec-ids-C5qzBqus.mjs.map} +1 -1
- package/dist/codec-ids-CplrEfmx.d.mts +29 -0
- package/dist/codec-ids-CplrEfmx.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -28
- package/dist/codec-ids.mjs +2 -3
- package/dist/codec-types-lrsb3N07.d.mts +79 -0
- package/dist/codec-types-lrsb3N07.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -42
- package/dist/codec-types.mjs +1 -3
- package/dist/codecs-Cue97Xqf.d.mts +558 -0
- package/dist/codecs-Cue97Xqf.d.mts.map +1 -0
- package/dist/codecs.d.mts +13 -2
- package/dist/codecs.d.mts.map +1 -0
- package/dist/codecs.mjs +738 -2
- package/dist/codecs.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +131 -94
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-VfEGzXWt.mjs → data-transform-DKWXdHuZ.mjs} +25 -7
- package/dist/data-transform-DKWXdHuZ.mjs.map +1 -0
- package/dist/data-transform-bIeAcZIJ.d.mts +38 -0
- package/dist/data-transform-bIeAcZIJ.d.mts.map +1 -0
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +2 -3
- package/dist/{default-normalizer-DNOpRoOF.mjs → default-normalizer-C8XyZj85.mjs} +2 -2
- package/dist/{default-normalizer-DNOpRoOF.mjs.map → default-normalizer-C8XyZj85.mjs.map} +1 -1
- package/dist/default-normalizer.d.mts +0 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +2 -3
- package/dist/descriptor-meta-Dde_BS3K.mjs +99 -0
- package/dist/descriptor-meta-Dde_BS3K.mjs.map +1 -0
- package/dist/{errors-AFvEPZ1R.mjs → errors-Chm2bKcS.mjs} +2 -3
- package/dist/{errors-AFvEPZ1R.mjs.map → errors-Chm2bKcS.mjs.map} +1 -1
- package/dist/errors.d.mts +0 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +2 -3
- package/dist/{issue-planner-CFjB0_oO.mjs → issue-planner-CiNmA4ls.mjs} +20 -16
- package/dist/issue-planner-CiNmA4ls.mjs.map +1 -0
- package/dist/issue-planner.d.mts +2 -4
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -3
- package/dist/migration.d.mts +8 -4
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -5
- package/dist/migration.mjs.map +1 -1
- package/dist/{native-type-normalizer-CInai_oY.mjs → native-type-normalizer-Cry4QoLf.mjs} +2 -2
- package/dist/native-type-normalizer-Cry4QoLf.mjs.map +1 -0
- package/dist/native-type-normalizer.d.mts.map +1 -1
- package/dist/native-type-normalizer.mjs +2 -3
- package/dist/{op-factory-call-C3bWXKSP.d.mts → op-factory-call-BUhxZuUA.d.mts} +9 -5
- package/dist/op-factory-call-BUhxZuUA.d.mts.map +1 -0
- package/dist/{op-factory-call-BKlruaiC.mjs → op-factory-call-Bs3HWhvG.mjs} +25 -7
- package/dist/op-factory-call-Bs3HWhvG.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +1 -2
- package/dist/op-factory-call.mjs +2 -3
- package/dist/pack.d.mts +28 -9
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -3
- package/dist/{planner-CLUvVhUN.mjs → planner-Lhacw3uU.mjs} +22 -16
- package/dist/planner-Lhacw3uU.mjs.map +1 -0
- package/dist/{planner-ddl-builders-Dxvw1LHw.mjs → planner-ddl-builders-CLB7Umhh.mjs} +4 -5
- package/dist/planner-ddl-builders-CLB7Umhh.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -3
- package/dist/{planner-identity-values-Dju-o5GF.mjs → planner-identity-values-DTx0gePL.mjs} +2 -3
- package/dist/{planner-identity-values-Dju-o5GF.mjs.map → planner-identity-values-DTx0gePL.mjs.map} +1 -1
- package/dist/planner-identity-values.d.mts +0 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -3
- package/dist/{planner-produced-postgres-migration-CRRTno6Z.d.mts → planner-produced-postgres-migration-CjxWIVgh.d.mts} +11 -7
- package/dist/planner-produced-postgres-migration-CjxWIVgh.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs → planner-produced-postgres-migration-DphktB2N.mjs} +16 -8
- package/dist/planner-produced-postgres-migration-DphktB2N.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -4
- package/dist/planner-produced-postgres-migration.mjs +2 -3
- package/dist/{planner-schema-lookup-B7lkypwn.mjs → planner-schema-lookup-B1ags8ys.mjs} +2 -2
- package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B1ags8ys.mjs.map} +1 -1
- package/dist/planner-schema-lookup.d.mts +0 -1
- package/dist/planner-schema-lookup.d.mts.map +1 -1
- package/dist/planner-schema-lookup.mjs +2 -3
- package/dist/{planner-sql-checks-7jkgm9TX.mjs → planner-sql-checks-DwZvGlV4.mjs} +3 -5
- package/dist/planner-sql-checks-DwZvGlV4.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +2 -3
- package/dist/{planner-target-details-DH-azLu-.d.mts → planner-target-details-bVVcanWh.d.mts} +1 -1
- package/dist/planner-target-details-bVVcanWh.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner-target-details.mjs +1 -1
- package/dist/planner.d.mts +21 -12
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -4
- package/dist/{postgres-migration-qtmtbONe.mjs → postgres-migration-Bkv140RW.mjs} +4 -5
- package/dist/postgres-migration-Bkv140RW.mjs.map +1 -0
- package/dist/{postgres-migration-BjA3Zmts.d.mts → postgres-migration-UkcHfZAA.d.mts} +6 -6
- package/dist/postgres-migration-UkcHfZAA.d.mts.map +1 -0
- package/dist/render-ops--1nnfNus.mjs +23 -0
- package/dist/render-ops--1nnfNus.mjs.map +1 -0
- package/dist/render-ops.d.mts +3 -4
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +2 -3
- package/dist/{render-typescript-1rF_SB4g.mjs → render-typescript-D3doH-vX.mjs} +2 -14
- package/dist/render-typescript-D3doH-vX.mjs.map +1 -0
- package/dist/render-typescript.d.mts +3 -6
- package/dist/render-typescript.d.mts.map +1 -1
- package/dist/render-typescript.mjs +2 -3
- package/dist/runtime.d.mts +5 -9
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +7 -14
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-Bxkt8pNO.d.mts → shared-MpwjwAjM.d.mts} +2 -2
- package/dist/shared-MpwjwAjM.d.mts.map +1 -0
- package/dist/{sql-utils-r-Lw535w.mjs → sql-utils-CggjWNij.mjs} +4 -2
- package/dist/sql-utils-CggjWNij.mjs.map +1 -0
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -3
- package/dist/{statement-builders-BPnmt6wx.mjs → statement-builders-BT889jV0.mjs} +28 -13
- package/dist/statement-builders-BT889jV0.mjs.map +1 -0
- package/dist/statement-builders.d.mts +31 -3
- package/dist/statement-builders.d.mts.map +1 -1
- package/dist/statement-builders.mjs +2 -3
- package/dist/{tables-BmdW_FWO.mjs → tables-r9Zk1y-Y.mjs} +18 -13
- package/dist/tables-r9Zk1y-Y.mjs.map +1 -0
- package/dist/{types-ClK03Ojd.d.mts → types-CTqpysRY.d.mts} +1 -1
- package/dist/types-CTqpysRY.d.mts.map +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +21 -19
- 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/issue-planner.ts +15 -3
- package/src/core/migrations/op-factory-call.ts +24 -2
- package/src/core/migrations/operations/data-transform.ts +86 -21
- package/src/core/migrations/operations/indexes.ts +27 -2
- package/src/core/migrations/planner-produced-postgres-migration.ts +17 -5
- package/src/core/migrations/planner.ts +62 -20
- package/src/core/migrations/postgres-migration.ts +3 -6
- package/src/core/migrations/render-ops.ts +26 -3
- package/src/core/migrations/render-typescript.ts +5 -9
- package/src/core/migrations/runner.ts +172 -151
- package/src/core/migrations/statement-builders.ts +49 -10
- 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 +2 -1
- package/dist/codec-ids.d.mts.map +0 -1
- package/dist/codec-types.d.mts.map +0 -1
- package/dist/codecs-BQEm9_oo.d.mts +0 -319
- package/dist/codecs-BQEm9_oo.d.mts.map +0 -1
- package/dist/codecs-BoahtY_Q.mjs +0 -385
- package/dist/codecs-BoahtY_Q.mjs.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 +0 -120
- package/dist/descriptor-meta-BVoVtyp-.mjs.map +0 -1
- package/dist/issue-planner-CFjB0_oO.mjs.map +0 -1
- package/dist/native-type-normalizer-CInai_oY.mjs.map +0 -1
- package/dist/op-factory-call-BKlruaiC.mjs.map +0 -1
- package/dist/op-factory-call-C3bWXKSP.d.mts.map +0 -1
- package/dist/planner-CLUvVhUN.mjs.map +0 -1
- package/dist/planner-ddl-builders-Dxvw1LHw.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs.map +0 -1
- package/dist/planner-sql-checks-7jkgm9TX.mjs.map +0 -1
- package/dist/planner-target-details-DH-azLu-.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-ops-D6_DHdOK.mjs +0 -8
- package/dist/render-ops-D6_DHdOK.mjs.map +0 -1
- package/dist/render-typescript-1rF_SB4g.mjs.map +0 -1
- package/dist/shared-Bxkt8pNO.d.mts.map +0 -1
- package/dist/sql-utils-r-Lw535w.mjs.map +0 -1
- package/dist/statement-builders-BPnmt6wx.mjs.map +0 -1
- package/dist/tables-BmdW_FWO.mjs.map +0 -1
- package/dist/types-ClK03Ojd.d.mts.map +0 -1
- package/src/core/json-schema-type-expression.ts +0 -131
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-factory-call-Bs3HWhvG.mjs","names":[],"sources":["../src/core/migrations/op-factory-call.ts"],"sourcesContent":["/**\n * Postgres migration IR: one concrete `*Call` class per pure factory under\n * `operations/`, plus a shared `PostgresOpFactoryCallNode` abstract base.\n *\n * Every call class carries the literal arguments its backing factory would\n * receive, computes a human-readable `label` in its constructor, and\n * implements two polymorphic hooks:\n *\n * - `toOp()` — converts the IR node to a runtime\n * `SqlMigrationPlanOperation` by delegating to the matching pure factory\n * under `operations/`. `DataTransformCall.toOp()` always throws\n * `PN-MIG-2001` because a planner-generated data transform is an\n * unfilled authoring stub by construction.\n * - `renderTypeScript()` / `importRequirements()` — inherited from\n * `TsExpression`. Used by `renderCallsToTypeScript` to emit the call as\n * a TypeScript expression inside the scaffolded `migration.ts`.\n *\n * The abstract base and all concrete classes are package-private. External\n * consumers see only the framework-level `OpFactoryCall` interface and the\n * `PostgresOpFactoryCall` union.\n */\n\nimport { errorUnfilledPlaceholder } from '@prisma-next/errors/migration';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type {\n OpFactoryCall as FrameworkOpFactoryCall,\n MigrationOperationClass,\n} from '@prisma-next/framework-components/control';\nimport { type ImportRequirement, jsonToTsSource, TsExpression } from '@prisma-next/ts-render';\nimport {\n addColumn,\n alterColumnType,\n dropColumn,\n dropDefault,\n dropNotNull,\n setDefault,\n setNotNull,\n} from './operations/columns';\nimport { addForeignKey, addPrimaryKey, addUnique, dropConstraint } from './operations/constraints';\nimport { createExtension, createSchema } from './operations/dependencies';\nimport { addEnumValues, createEnumType, dropEnumType, renameType } from './operations/enums';\nimport { createIndex, dropIndex } from './operations/indexes';\nimport type { ColumnSpec, ForeignKeySpec } from './operations/shared';\nimport { createTable, dropTable } from './operations/tables';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\nconst TARGET_MIGRATION_MODULE = '@prisma-next/target-postgres/migration';\n\nabstract class PostgresOpFactoryCallNode extends TsExpression implements FrameworkOpFactoryCall {\n abstract readonly factoryName: string;\n abstract readonly operationClass: MigrationOperationClass;\n abstract readonly label: string;\n abstract toOp(): Op;\n\n importRequirements(): readonly ImportRequirement[] {\n return [{ moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: this.factoryName }];\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\n// ============================================================================\n// Table\n// ============================================================================\n\nexport interface CreateTablePrimaryKey {\n readonly columns: readonly string[];\n}\n\nexport class CreateTableCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createTable' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columns: readonly ColumnSpec[];\n readonly primaryKey: CreateTablePrimaryKey | undefined;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columns: readonly ColumnSpec[],\n primaryKey?: CreateTablePrimaryKey,\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columns = columns;\n this.primaryKey = primaryKey;\n this.label = `Create table \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return createTable(this.schemaName, this.tableName, this.columns, this.primaryKey);\n }\n\n renderTypeScript(): string {\n const args = [\n jsonToTsSource(this.schemaName),\n jsonToTsSource(this.tableName),\n jsonToTsSource(this.columns),\n ];\n if (this.primaryKey) args.push(jsonToTsSource(this.primaryKey));\n return `createTable(${args.join(', ')})`;\n }\n}\n\nexport class DropTableCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropTable' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.label = `Drop table \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropTable(this.schemaName, this.tableName);\n }\n\n renderTypeScript(): string {\n return `dropTable(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;\n }\n}\n\n// ============================================================================\n// Column\n// ============================================================================\n\nexport class AddColumnCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addColumn' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly column: ColumnSpec;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, column: ColumnSpec) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.column = column;\n this.label = `Add column \"${column.name}\" to \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return addColumn(this.schemaName, this.tableName, this.column);\n }\n\n renderTypeScript(): string {\n return `addColumn(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.column)})`;\n }\n}\n\nexport class DropColumnCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropColumn' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop column \"${columnName}\" from \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropColumn(this.schemaName, this.tableName, this.columnName);\n }\n\n renderTypeScript(): string {\n return `dropColumn(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;\n }\n}\n\nexport interface AlterColumnTypeOptions {\n readonly qualifiedTargetType: string;\n readonly formatTypeExpected: string;\n readonly rawTargetTypeForLabel: string;\n readonly using?: string;\n}\n\nexport class AlterColumnTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'alterColumnType' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly options: AlterColumnTypeOptions;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columnName: string,\n options: AlterColumnTypeOptions,\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.options = options;\n this.label = `Alter type of \"${tableName}\".\"${columnName}\" to ${options.rawTargetTypeForLabel}`;\n this.freeze();\n }\n\n toOp(): Op {\n return alterColumnType(this.schemaName, this.tableName, this.columnName, this.options);\n }\n\n renderTypeScript(): string {\n return `alterColumnType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)}, ${jsonToTsSource(this.options)})`;\n }\n}\n\nexport class SetNotNullCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'setNotNull' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Set NOT NULL on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return setNotNull(this.schemaName, this.tableName, this.columnName);\n }\n\n renderTypeScript(): string {\n return `setNotNull(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;\n }\n}\n\nexport class DropNotNullCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropNotNull' as const;\n readonly operationClass = 'widening' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop NOT NULL on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropNotNull(this.schemaName, this.tableName, this.columnName);\n }\n\n renderTypeScript(): string {\n return `dropNotNull(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;\n }\n}\n\nexport class SetDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'setDefault' as const;\n readonly operationClass: 'additive' | 'widening';\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly defaultSql: string;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n operationClass: 'additive' | 'widening' = 'additive',\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.defaultSql = defaultSql;\n this.operationClass = operationClass;\n this.label = `Set default on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return setDefault(\n this.schemaName,\n this.tableName,\n this.columnName,\n this.defaultSql,\n this.operationClass,\n );\n }\n\n renderTypeScript(): string {\n const args = [\n jsonToTsSource(this.schemaName),\n jsonToTsSource(this.tableName),\n jsonToTsSource(this.columnName),\n jsonToTsSource(this.defaultSql),\n ];\n if (this.operationClass !== 'additive') {\n args.push(jsonToTsSource(this.operationClass));\n }\n return `setDefault(${args.join(', ')})`;\n }\n}\n\nexport class DropDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropDefault' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop default on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropDefault(this.schemaName, this.tableName, this.columnName);\n }\n\n renderTypeScript(): string {\n return `dropDefault(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;\n }\n}\n\n// ============================================================================\n// Constraints\n// ============================================================================\n\nexport class AddPrimaryKeyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addPrimaryKey' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.columns = columns;\n this.label = `Add primary key on \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return addPrimaryKey(this.schemaName, this.tableName, this.constraintName, this.columns);\n }\n\n renderTypeScript(): string {\n return `addPrimaryKey(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.columns)})`;\n }\n}\n\nexport class AddUniqueCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addUnique' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.columns = columns;\n this.label = `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`;\n this.freeze();\n }\n\n toOp(): Op {\n return addUnique(this.schemaName, this.tableName, this.constraintName, this.columns);\n }\n\n renderTypeScript(): string {\n return `addUnique(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.columns)})`;\n }\n}\n\nexport class AddForeignKeyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addForeignKey' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly fk: ForeignKeySpec;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, fk: ForeignKeySpec) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.fk = fk;\n this.label = `Add foreign key \"${fk.name}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return addForeignKey(this.schemaName, this.tableName, this.fk);\n }\n\n renderTypeScript(): string {\n return `addForeignKey(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.fk)})`;\n }\n}\n\nexport class DropConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropConstraint' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly kind: 'foreignKey' | 'unique' | 'primaryKey';\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.kind = kind;\n this.label = `Drop constraint \"${constraintName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropConstraint(this.schemaName, this.tableName, this.constraintName, this.kind);\n }\n\n renderTypeScript(): string {\n const args = [\n jsonToTsSource(this.schemaName),\n jsonToTsSource(this.tableName),\n jsonToTsSource(this.constraintName),\n ];\n if (this.kind !== 'unique') {\n args.push(jsonToTsSource(this.kind));\n }\n return `dropConstraint(${args.join(', ')})`;\n }\n}\n\n// ============================================================================\n// Indexes\n// ============================================================================\n\nexport class CreateIndexCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createIndex' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly indexName: string;\n readonly columns: readonly string[];\n // Named indexType (not typeName) to avoid collision with CreateEnumTypeCall.typeName,\n // which identifies a CREATE TYPE target and is read by `locationForCall` in issue-planner.ts.\n readonly indexType: string | undefined;\n readonly options: Record<string, unknown> | undefined;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n extras?: { readonly type?: string; readonly options?: Record<string, unknown> },\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.indexName = indexName;\n this.columns = columns;\n this.indexType = extras?.type;\n this.options = extras?.options;\n this.label = `Create index \"${indexName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (this.indexType !== undefined) extras.type = this.indexType;\n if (this.options !== undefined) extras.options = this.options;\n return createIndex(this.schemaName, this.tableName, this.indexName, this.columns, extras);\n }\n\n renderTypeScript(): string {\n const args = [\n jsonToTsSource(this.schemaName),\n jsonToTsSource(this.tableName),\n jsonToTsSource(this.indexName),\n jsonToTsSource(this.columns),\n ];\n if (this.indexType !== undefined || this.options !== undefined) {\n const extrasParts: string[] = [];\n if (this.indexType !== undefined) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);\n if (this.options !== undefined) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);\n args.push(`{ ${extrasParts.join(', ')} }`);\n }\n return `createIndex(${args.join(', ')})`;\n }\n}\n\nexport class DropIndexCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropIndex' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly indexName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, indexName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.indexName = indexName;\n this.label = `Drop index \"${indexName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropIndex(this.schemaName, this.tableName, this.indexName);\n }\n\n renderTypeScript(): string {\n return `dropIndex(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.indexName)})`;\n }\n}\n\n// ============================================================================\n// Enum types\n// ============================================================================\n\nexport class CreateEnumTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createEnumType' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly typeName: string;\n readonly values: readonly string[];\n readonly label: string;\n\n constructor(schemaName: string, typeName: string, values: readonly string[]) {\n super();\n this.schemaName = schemaName;\n this.typeName = typeName;\n this.values = values;\n this.label = `Create enum type \"${typeName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return createEnumType(this.schemaName, this.typeName, this.values);\n }\n\n renderTypeScript(): string {\n return `createEnumType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)}, ${jsonToTsSource(this.values)})`;\n }\n}\n\nexport class AddEnumValuesCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addEnumValues' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly typeName: string;\n readonly nativeType: string;\n readonly values: readonly string[];\n readonly label: string;\n\n constructor(schemaName: string, typeName: string, nativeType: string, values: readonly string[]) {\n super();\n this.schemaName = schemaName;\n this.typeName = typeName;\n this.nativeType = nativeType;\n this.values = values;\n this.label = `Add values to enum type \"${typeName}\": ${values.join(', ')}`;\n this.freeze();\n }\n\n toOp(): Op {\n return addEnumValues(this.schemaName, this.typeName, this.nativeType, this.values);\n }\n\n renderTypeScript(): string {\n return `addEnumValues(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)}, ${jsonToTsSource(this.nativeType)}, ${jsonToTsSource(this.values)})`;\n }\n}\n\nexport class DropEnumTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropEnumType' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly typeName: string;\n readonly label: string;\n\n constructor(schemaName: string, typeName: string) {\n super();\n this.schemaName = schemaName;\n this.typeName = typeName;\n this.label = `Drop enum type \"${typeName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return dropEnumType(this.schemaName, this.typeName);\n }\n\n renderTypeScript(): string {\n return `dropEnumType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)})`;\n }\n}\n\nexport class RenameTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'renameType' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly fromName: string;\n readonly toName: string;\n readonly label: string;\n\n constructor(schemaName: string, fromName: string, toName: string) {\n super();\n this.schemaName = schemaName;\n this.fromName = fromName;\n this.toName = toName;\n this.label = `Rename type \"${fromName}\" to \"${toName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return renameType(this.schemaName, this.fromName, this.toName);\n }\n\n renderTypeScript(): string {\n return `renameType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.fromName)}, ${jsonToTsSource(this.toName)})`;\n }\n}\n\n// ============================================================================\n// Raw SQL\n// ============================================================================\n\n/**\n * Laundered pre-built operation.\n *\n * Wraps an already-materialized `SqlMigrationPlanOperation` — typically one\n * produced by a SQL-family method, a codec control hook, or a component\n * `databaseDependencies.init` declaration — so the planner can carry it\n * alongside IR nodes without reverse-engineering it into a\n * structured call class. Doubles as the user-facing escape hatch for raw\n * migrations: authors can pass a full op shape to `rawSql({...})`.\n *\n * `toOp()` returns the stored op unchanged. `renderTypeScript()` emits\n * `rawSql({...})` with the op serialized as a JSON literal — round-tripping\n * requires every field on the op to be JSON-serializable (no closures).\n */\nexport class RawSqlCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly op: Op;\n\n constructor(op: Op) {\n super();\n this.op = op;\n this.label = op.label;\n this.operationClass = op.operationClass;\n this.freeze();\n }\n\n toOp(): Op {\n return this.op;\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource(this.op)})`;\n }\n}\n\n// ============================================================================\n// Database dependencies (structured DDL)\n// ============================================================================\n\nexport class CreateExtensionCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createExtension' as const;\n readonly operationClass = 'additive' as const;\n readonly extensionName: string;\n readonly label: string;\n\n constructor(extensionName: string) {\n super();\n this.extensionName = extensionName;\n this.label = `Create extension \"${extensionName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return createExtension(this.extensionName);\n }\n\n renderTypeScript(): string {\n return `createExtension(${jsonToTsSource(this.extensionName)})`;\n }\n}\n\nexport class CreateSchemaCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createSchema' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly label: string;\n\n constructor(schemaName: string) {\n super();\n this.schemaName = schemaName;\n this.label = `Create schema \"${schemaName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return createSchema(this.schemaName);\n }\n\n renderTypeScript(): string {\n return `createSchema(${jsonToTsSource(this.schemaName)})`;\n }\n}\n\n// ============================================================================\n// Data transform\n// ============================================================================\n\n/**\n * A planner-generated data-transform stub. `checkSlot` and `runSlot` name\n * the unfilled authoring slots that the rendered `migration.ts` will expose\n * to the user via `placeholder(\"…\")` calls. `toOp()` always throws\n * `PN-MIG-2001`: the planner cannot lower a stubbed transform to a runtime\n * op — the user must fill the rendered `migration.ts` and re-emit.\n */\nexport class DataTransformCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dataTransform' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly checkSlot: string;\n readonly runSlot: string;\n\n constructor(\n label: string,\n checkSlot: string,\n runSlot: string,\n operationClass: MigrationOperationClass = 'data',\n ) {\n super();\n this.label = label;\n this.checkSlot = checkSlot;\n this.runSlot = runSlot;\n this.operationClass = operationClass;\n this.freeze();\n }\n\n toOp(): Op {\n throw errorUnfilledPlaceholder(this.label);\n }\n\n renderTypeScript(): string {\n return [\n `this.dataTransform(endContract, ${jsonToTsSource(this.label)}, {`,\n ` check: () => placeholder(${jsonToTsSource(this.checkSlot)}),`,\n ` run: () => placeholder(${jsonToTsSource(this.runSlot)}),`,\n '})',\n ].join('\\n');\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [\n { moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: 'placeholder' },\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n ];\n }\n}\n\nexport type PostgresOpFactoryCall =\n | CreateTableCall\n | DropTableCall\n | AddColumnCall\n | DropColumnCall\n | AlterColumnTypeCall\n | SetNotNullCall\n | DropNotNullCall\n | SetDefaultCall\n | DropDefaultCall\n | AddPrimaryKeyCall\n | AddForeignKeyCall\n | AddUniqueCall\n | CreateIndexCall\n | DropIndexCall\n | DropConstraintCall\n | CreateEnumTypeCall\n | AddEnumValuesCall\n | DropEnumTypeCall\n | RenameTypeCall\n | RawSqlCall\n | CreateExtensionCall\n | CreateSchemaCall\n | DataTransformCall;\n\n/**\n * Stable identity key for reconciliation-level dedup.\n *\n * Two calls whose runtime ops would share the same `id` return the same\n * key, so a `Set<string>` can collapse them before they're emitted. The\n * current implementation delegates to `toOp().id`, which is the\n * authoritative identity; isolating dedup behind this helper lets a future\n * pass replace it with an allocation-free computation directly from the\n * call's fields without touching call sites.\n *\n * `DataTransformCall` intentionally has no sensible identity today — it\n * throws `PN-MIG-2001` on `toOp()`. Reconciliation never produces one; the\n * helper is unspecified for that variant and only meant for\n * reconciliation-emitted calls.\n */\nexport function identityKeyFor(call: PostgresOpFactoryCall): string {\n return call.toOp().id;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,0BAA0B;AAEhC,IAAe,4BAAf,cAAiD,aAA+C;CAM9F,qBAAmD;EACjD,OAAO,CAAC;GAAE,iBAAiB;GAAyB,QAAQ,KAAK;GAAa,CAAC;;CAGjF,SAAyB;EACvB,OAAO,OAAO,KAAK;;;AAYvB,IAAa,kBAAb,cAAqC,0BAA0B;CAC7D,cAAuB;CACvB,iBAA0B;CAC1B;CACA;CACA;CACA;CACA;CAEA,YACE,YACA,WACA,SACA,YACA;EACA,OAAO;EACP,KAAK,aAAa;EAClB,KAAK,YAAY;EACjB,KAAK,UAAU;EACf,KAAK,aAAa;EAClB,KAAK,QAAQ,iBAAiB,UAAU;EACxC,KAAK,QAAQ;;CAGf,OAAW;EACT,OAAO,YAAY,KAAK,YAAY,KAAK,WAAW,KAAK,SAAS,KAAK,WAAW;;CAGpF,mBAA2B;EACzB,MAAM,OAAO;GACX,eAAe,KAAK,WAAW;GAC/B,eAAe,KAAK,UAAU;GAC9B,eAAe,KAAK,QAAQ;GAC7B;EACD,IAAI,KAAK,YAAY,KAAK,KAAK,eAAe,KAAK,WAAW,CAAC;EAC/D,OAAO,eAAe,KAAK,KAAK,KAAK,CAAC;;;AAI1C,IAAa,gBAAb,cAAmC,0BAA0B;CAC3D,cAAuB;CACvB,iBAA0B;CAC1B;CACA;CACA;CAEA,YAAY,YAAoB,WAAmB;EACjD,OAAO;EACP,KAAK,aAAa;EAClB,KAAK,YAAY;EACjB,KAAK,QAAQ,eAAe,UAAU;EACtC,KAAK,QAAQ;;CAGf,OAAW;EACT,OAAO,UAAU,KAAK,YAAY,KAAK,UAAU;;CAGnD,mBAA2B;EACzB,OAAO,aAAa,eAAe,KAAK,WAAW,CAAC,IAAI,eAAe,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AAe,KAAK,UAAU,CAAC;GAC7D,4BAA4B,eAAe,KAAK,QAAQ,CAAC;GACzD;GACD,CAAC,KAAK,KAAK;;CAGd,qBAA4D;EAC1D,OAAO,CACL;GAAE,iBAAiB;GAAyB,QAAQ;GAAe,EACnE;GACE,iBAAiB;GACjB,QAAQ;GACR,MAAM;GACN,YAAY,EAAE,MAAM,QAAQ;GAC7B,CACF"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { C as SetDefaultCall, S as RenameTypeCall, _ as DropIndexCall, a as AddUniqueCall, c as CreateExtensionCall, d as CreateTableCall, f as DataTransformCall, g as DropEnumTypeCall, h as DropDefaultCall, i as AddPrimaryKeyCall, l as CreateIndexCall, m as DropConstraintCall, n as AddEnumValuesCall, o as AlterColumnTypeCall, p as DropColumnCall, r as AddForeignKeyCall, s as CreateEnumTypeCall, t as AddColumnCall, u as CreateSchemaCall, v as DropNotNullCall, w as SetNotNullCall, x as RawSqlCall, y as DropTableCall } from "./op-factory-call-C3bWXKSP.mjs";
|
|
1
|
+
import { C as SetDefaultCall, S as RenameTypeCall, _ as DropIndexCall, a as AddUniqueCall, c as CreateExtensionCall, d as CreateTableCall, f as DataTransformCall, g as DropEnumTypeCall, h as DropDefaultCall, i as AddPrimaryKeyCall, l as CreateIndexCall, m as DropConstraintCall, n as AddEnumValuesCall, o as AlterColumnTypeCall, p as DropColumnCall, r as AddForeignKeyCall, s as CreateEnumTypeCall, t as AddColumnCall, u as CreateSchemaCall, v as DropNotNullCall, w as SetNotNullCall, x as RawSqlCall, y as DropTableCall } from "./op-factory-call-BUhxZuUA.mjs";
|
|
3
2
|
export { AddColumnCall, AddEnumValuesCall, AddForeignKeyCall, AddPrimaryKeyCall, AddUniqueCall, AlterColumnTypeCall, CreateEnumTypeCall, CreateExtensionCall, CreateIndexCall, CreateSchemaCall, CreateTableCall, DataTransformCall, DropColumnCall, DropConstraintCall, DropDefaultCall, DropEnumTypeCall, DropIndexCall, DropNotNullCall, DropTableCall, RawSqlCall, RenameTypeCall, SetDefaultCall, SetNotNullCall };
|
package/dist/op-factory-call.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { C as SetNotNullCall, S as SetDefaultCall, _ as DropIndexCall, a as AddUniqueCall, b as RawSqlCall, c as CreateExtensionCall, d as CreateTableCall, f as DataTransformCall, g as DropEnumTypeCall, h as DropDefaultCall, i as AddPrimaryKeyCall, l as CreateIndexCall, m as DropConstraintCall, n as AddEnumValuesCall, o as AlterColumnTypeCall, p as DropColumnCall, r as AddForeignKeyCall, s as CreateEnumTypeCall, t as AddColumnCall, u as CreateSchemaCall, v as DropNotNullCall, x as RenameTypeCall, y as DropTableCall } from "./op-factory-call-
|
|
2
|
-
|
|
3
|
-
export { AddColumnCall, AddEnumValuesCall, AddForeignKeyCall, AddPrimaryKeyCall, AddUniqueCall, AlterColumnTypeCall, CreateEnumTypeCall, CreateExtensionCall, CreateIndexCall, CreateSchemaCall, CreateTableCall, DataTransformCall, DropColumnCall, DropConstraintCall, DropDefaultCall, DropEnumTypeCall, DropIndexCall, DropNotNullCall, DropTableCall, RawSqlCall, RenameTypeCall, SetDefaultCall, SetNotNullCall };
|
|
1
|
+
import { C as SetNotNullCall, S as SetDefaultCall, _ as DropIndexCall, a as AddUniqueCall, b as RawSqlCall, c as CreateExtensionCall, d as CreateTableCall, f as DataTransformCall, g as DropEnumTypeCall, h as DropDefaultCall, i as AddPrimaryKeyCall, l as CreateIndexCall, m as DropConstraintCall, n as AddEnumValuesCall, o as AlterColumnTypeCall, p as DropColumnCall, r as AddForeignKeyCall, s as CreateEnumTypeCall, t as AddColumnCall, u as CreateSchemaCall, v as DropNotNullCall, x as RenameTypeCall, y as DropTableCall } from "./op-factory-call-Bs3HWhvG.mjs";
|
|
2
|
+
export { AddColumnCall, AddEnumValuesCall, AddForeignKeyCall, AddPrimaryKeyCall, AddUniqueCall, AlterColumnTypeCall, CreateEnumTypeCall, CreateExtensionCall, CreateIndexCall, CreateSchemaCall, CreateTableCall, DataTransformCall, DropColumnCall, DropConstraintCall, DropDefaultCall, DropEnumTypeCall, DropIndexCall, DropNotNullCall, DropTableCall, RawSqlCall, RenameTypeCall, SetDefaultCall, SetNotNullCall };
|
package/dist/pack.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as CodecTypes } from "./codec-types-lrsb3N07.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/descriptor-meta.d.ts
|
|
4
4
|
declare const postgresTargetDescriptorMetaBase: {
|
|
@@ -96,14 +96,33 @@ declare const postgresTargetDescriptorMetaBase: {
|
|
|
96
96
|
readonly nativeType: "timestamptz";
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
|
-
readonly
|
|
100
|
-
readonly
|
|
101
|
-
|
|
102
|
-
readonly
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
readonly
|
|
106
|
-
|
|
99
|
+
readonly temporal: {
|
|
100
|
+
readonly createdAt: {
|
|
101
|
+
readonly kind: "fieldPreset";
|
|
102
|
+
readonly output: {
|
|
103
|
+
readonly codecId: "pg/timestamptz@1";
|
|
104
|
+
readonly nativeType: "timestamptz";
|
|
105
|
+
readonly default: {
|
|
106
|
+
readonly kind: "function";
|
|
107
|
+
readonly expression: "now()";
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
readonly updatedAt: {
|
|
112
|
+
readonly kind: "fieldPreset";
|
|
113
|
+
readonly output: {
|
|
114
|
+
readonly codecId: "pg/timestamptz@1";
|
|
115
|
+
readonly nativeType: "timestamptz";
|
|
116
|
+
readonly executionDefaults: {
|
|
117
|
+
readonly onCreate: {
|
|
118
|
+
readonly kind: "generator";
|
|
119
|
+
readonly id: "timestampNow";
|
|
120
|
+
};
|
|
121
|
+
readonly onUpdate: {
|
|
122
|
+
readonly kind: "generator";
|
|
123
|
+
readonly id: "timestampNow";
|
|
124
|
+
};
|
|
125
|
+
};
|
|
107
126
|
};
|
|
108
127
|
};
|
|
109
128
|
};
|
package/dist/pack.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;;cAGM,gCAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAaO,4BAAA,SAAqC,gCAAA;EAAA,SACvC,YAAA,GAAe,UAAA;AAAA"}
|
package/dist/pack.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-
|
|
2
|
-
|
|
3
|
-
export { postgresTargetDescriptorMeta as default };
|
|
1
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-Dde_BS3K.mjs";
|
|
2
|
+
export { postgresTargetDescriptorMeta as default };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { t as parsePostgresDefault } from "./default-normalizer-
|
|
2
|
-
import { t as normalizeSchemaNativeType } from "./native-type-normalizer-
|
|
3
|
-
import { n as postgresPlannerStrategies, t as planIssues } from "./issue-planner-
|
|
4
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
5
|
-
import { extractCodecControlHooks, plannerFailure } from "@prisma-next/family-sql/control";
|
|
1
|
+
import { t as parsePostgresDefault } from "./default-normalizer-C8XyZj85.mjs";
|
|
2
|
+
import { t as normalizeSchemaNativeType } from "./native-type-normalizer-Cry4QoLf.mjs";
|
|
3
|
+
import { n as postgresPlannerStrategies, t as planIssues } from "./issue-planner-CiNmA4ls.mjs";
|
|
4
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-DphktB2N.mjs";
|
|
5
|
+
import { extractCodecControlHooks, planFieldEventOperations, plannerFailure } from "@prisma-next/family-sql/control";
|
|
6
6
|
import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
|
|
7
|
-
|
|
8
7
|
//#region src/core/migrations/planner.ts
|
|
9
8
|
const DEFAULT_PLANNER_CONFIG = { defaultSchema: "public" };
|
|
10
9
|
function createPostgresMigrationPlanner(config = {}) {
|
|
@@ -30,19 +29,20 @@ function createPostgresMigrationPlanner(config = {}) {
|
|
|
30
29
|
* authoring surface.
|
|
31
30
|
*/
|
|
32
31
|
var PostgresMigrationPlanner = class {
|
|
32
|
+
config;
|
|
33
33
|
constructor(config) {
|
|
34
34
|
this.config = config;
|
|
35
35
|
}
|
|
36
36
|
plan(options) {
|
|
37
|
-
return this.planSql(options
|
|
37
|
+
return this.planSql(options);
|
|
38
38
|
}
|
|
39
|
-
emptyMigration(context) {
|
|
39
|
+
emptyMigration(context, spaceId) {
|
|
40
40
|
return new TypeScriptRenderablePostgresMigration([], {
|
|
41
41
|
from: context.fromHash,
|
|
42
42
|
to: context.toHash
|
|
43
|
-
});
|
|
43
|
+
}, spaceId);
|
|
44
44
|
}
|
|
45
|
-
planSql(options
|
|
45
|
+
planSql(options) {
|
|
46
46
|
const schemaName = options.schemaName ?? this.config.defaultSchema;
|
|
47
47
|
const policyResult = this.ensureAdditivePolicy(options.policy);
|
|
48
48
|
if (policyResult) return policyResult;
|
|
@@ -52,7 +52,7 @@ var PostgresMigrationPlanner = class {
|
|
|
52
52
|
const result = planIssues({
|
|
53
53
|
issues: schemaIssues,
|
|
54
54
|
toContract: options.contract,
|
|
55
|
-
fromContract: options.fromContract
|
|
55
|
+
fromContract: options.fromContract,
|
|
56
56
|
schemaName,
|
|
57
57
|
codecHooks,
|
|
58
58
|
storageTypes,
|
|
@@ -62,12 +62,18 @@ var PostgresMigrationPlanner = class {
|
|
|
62
62
|
strategies: postgresPlannerStrategies
|
|
63
63
|
});
|
|
64
64
|
if (!result.ok) return plannerFailure(result.failure);
|
|
65
|
+
const fieldEventOps = planFieldEventOperations({
|
|
66
|
+
priorContract: options.fromContract,
|
|
67
|
+
newContract: options.contract,
|
|
68
|
+
codecHooks
|
|
69
|
+
});
|
|
70
|
+
const calls = [...result.value.calls, ...fieldEventOps];
|
|
65
71
|
return Object.freeze({
|
|
66
72
|
kind: "success",
|
|
67
|
-
plan: new TypeScriptRenderablePostgresMigration(
|
|
68
|
-
from:
|
|
73
|
+
plan: new TypeScriptRenderablePostgresMigration(calls, {
|
|
74
|
+
from: options.fromContract?.storage.storageHash ?? null,
|
|
69
75
|
to: options.contract.storage.storageHash
|
|
70
|
-
})
|
|
76
|
+
}, options.spaceId)
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
79
|
ensureAdditivePolicy(policy) {
|
|
@@ -92,7 +98,7 @@ var PostgresMigrationPlanner = class {
|
|
|
92
98
|
}).schema.issues;
|
|
93
99
|
}
|
|
94
100
|
};
|
|
95
|
-
|
|
96
101
|
//#endregion
|
|
97
102
|
export { createPostgresMigrationPlanner as t };
|
|
98
|
-
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=planner-Lhacw3uU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-Lhacw3uU.mjs","names":[],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationPlanWithAuthoringSurface,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { parsePostgresDefault } from '../default-normalizer';\nimport { normalizeSchemaNativeType } from '../native-type-normalizer';\nimport { planIssues } from './issue-planner';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\n\ntype PlannerFrameworkComponents = SqlMigrationPlannerPlanOptions extends {\n readonly frameworkComponents: infer T;\n}\n ? T\n : ReadonlyArray<unknown>;\n\ntype PlannerOptionsWithComponents = SqlMigrationPlannerPlanOptions & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\ntype VerifySqlSchemaOptionsWithComponents = Parameters<typeof verifySqlSchema>[0] & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\ninterface PlannerConfig {\n readonly defaultSchema: string;\n}\n\nconst DEFAULT_PLANNER_CONFIG: PlannerConfig = {\n defaultSchema: 'public',\n};\n\nexport function createPostgresMigrationPlanner(\n config: Partial<PlannerConfig> = {},\n): PostgresMigrationPlanner {\n return new PostgresMigrationPlanner({\n ...DEFAULT_PLANNER_CONFIG,\n ...config,\n });\n}\n\n/**\n * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose\n * success variant carries a `TypeScriptRenderablePostgresMigration` — a\n * migration object that both the CLI (via `renderTypeScript()`) and the\n * SQL-typed callers (via `operations`, `describe()`, etc.) consume\n * uniformly.\n */\nexport type PostgresPlanResult =\n | { readonly kind: 'success'; readonly plan: TypeScriptRenderablePostgresMigration }\n | SqlPlannerFailureResult;\n\n/**\n * Postgres migration planner — a thin wrapper over `planIssues`.\n *\n * `plan()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the unified\n * `postgresPlannerStrategies` list: enum-change, NOT-NULL backfill,\n * type-change, nullable-tightening, codec-hook storage types,\n * component-declared dependency installs, and shared-temp-default /\n * empty-table-guarded NOT-NULL add-column. The same strategy list runs for\n * `migration plan`, `db update`, and `db init`; behavior diverges purely on\n * `policy.allowedOperationClasses` (the data-safe strategies short-circuit\n * when `'data'` is excluded). The issue planner applies operation-class\n * policy gates and emits a single `PostgresOpFactoryCall[]` that drives both\n * the runtime-ops view (via `renderOps`) and the `renderTypeScript()`\n * authoring surface.\n */\nexport class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {\n constructor(private readonly config: PlannerConfig) {}\n\n plan(options: {\n readonly contract: unknown;\n readonly schema: unknown;\n readonly policy: MigrationOperationPolicy;\n /**\n * The \"from\" contract (state the planner assumes the database starts\n * at), or `null` for reconciliation flows. Only `migration plan` ever\n * supplies a non-null value; `db update` / `db init` reconcile against\n * the live schema and pass `null`. When present alongside the\n * `'data'` operation class, strategies that need from/to column-shape\n * comparisons (unsafe type change, nullability tightening) activate.\n *\n * Typed as the framework `Contract | null` to satisfy the\n * `MigrationPlanner` interface contract; `planSql` narrows to the SQL\n * shape via `SqlMigrationPlannerPlanOptions`. Used to populate\n * `describe().from` on the produced plan as\n * `fromContract?.storage.storageHash ?? null`.\n */\n readonly fromContract: Contract | null;\n readonly schemaName?: string;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n /**\n * Contract space this plan applies to. Stamped onto the produced\n * {@link TypeScriptRenderablePostgresMigration.spaceId} so the runner keys\n * the marker row by the right space.\n */\n readonly spaceId: string;\n }): PostgresPlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): MigrationPlanWithAuthoringSurface {\n return new TypeScriptRenderablePostgresMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): PostgresPlanResult {\n const schemaName = options.schemaName ?? this.config.defaultSchema;\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) {\n return policyResult;\n }\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\n\n const result = planIssues({\n issues: schemaIssues,\n toContract: options.contract,\n // `fromContract` is only supplied by `migration plan`. It is `null` for\n // `db update` / `db init`, which means data-safety strategies needing\n // from/to comparisons (unsafe type change, nullable tightening) are\n // inapplicable there — reconciliation falls through to\n // `mapIssueToCall`'s direct destructive handlers.\n fromContract: options.fromContract,\n schemaName,\n codecHooks,\n storageTypes,\n schema: options.schema,\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: postgresPlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n // Inline `onFieldEvent`-emitted ops after structural DDL. The fixed\n // ordering is `structural → added → dropped → altered`, with\n // within-group sorting by `(tableName, fieldName)` so re-emits are\n // byte-stable. The hook fires only at the application emitter —\n // extension-space planning never reaches this helper.\n const fieldEventOps = planFieldEventOperations({\n priorContract: options.fromContract,\n newContract: options.contract,\n codecHooks,\n });\n // Codec-emitted calls already conform to `OpFactoryCall` — render +\n // toOp + importRequirements ride directly through the same emit path\n // as structural ops, no `RawSqlCall` wrap.\n const calls = [...result.value.calls, ...fieldEventOps];\n\n return Object.freeze({\n kind: 'success' as const,\n plan: new TypeScriptRenderablePostgresMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n ),\n });\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy) {\n if (!policy.allowedOperationClasses.includes('additive')) {\n return plannerFailure([\n {\n kind: 'unsupportedOperation',\n summary: 'Migration planner requires additive operations be allowed',\n why: 'The planner requires the \"additive\" operation class to be allowed in the policy.',\n },\n ]);\n }\n return null;\n }\n\n private collectSchemaIssues(options: PlannerOptionsWithComponents): readonly SchemaIssue[] {\n // `db init` uses additive-only policy and intentionally ignores extra\n // schema objects. Any reconciliation-capable policy (widening or\n // destructive) must inspect extras to reconcile strict equality.\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyOptions: VerifySqlSchemaOptionsWithComponents = {\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parsePostgresDefault,\n normalizeNativeType: normalizeSchemaNativeType,\n };\n const verifyResult = verifySqlSchema(verifyOptions);\n return verifyResult.schema.issues;\n }\n}\n"],"mappings":";;;;;;;AA2CA,MAAM,yBAAwC,EAC5C,eAAe,UAChB;AAED,SAAgB,+BACd,SAAiC,EAAE,EACT;CAC1B,OAAO,IAAI,yBAAyB;EAClC,GAAG;EACH,GAAG;EACJ,CAAC;;;;;;;;;;;;;;;;;;AA8BJ,IAAa,2BAAb,MAAqF;CACtD;CAA7B,YAAY,QAAwC;EAAvB,KAAA,SAAA;;CAE7B,KAAK,SA2BkB;EACrB,OAAO,KAAK,QAAQ,QAA0C;;CAGhE,eACE,SACA,SACmC;EACnC,OAAO,IAAI,sCACT,EAAE,EACF;GACE,MAAM,QAAQ;GACd,IAAI,QAAQ;GACb,EACD,QACD;;CAGH,QAAgB,SAA6D;EAC3E,MAAM,aAAa,QAAQ,cAAc,KAAK,OAAO;EACrD,MAAM,eAAe,KAAK,qBAAqB,QAAQ,OAAO;EAC9D,IAAI,cACF,OAAO;EAGT,MAAM,eAAe,KAAK,oBAAoB,QAAQ;EACtD,MAAM,aAAa,yBAAyB,QAAQ,oBAAoB;EACxE,MAAM,eAAe,QAAQ,SAAS,QAAQ,SAAS,EAAE;EAEzD,MAAM,SAAS,WAAW;GACxB,QAAQ;GACR,YAAY,QAAQ;GAMpB,cAAc,QAAQ;GACtB;GACA;GACA;GACA,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;GAChB,qBAAqB,QAAQ;GAC7B,YAAY;GACb,CAAC;EAEF,IAAI,CAAC,OAAO,IACV,OAAO,eAAe,OAAO,QAAQ;EAQvC,MAAM,gBAAgB,yBAAyB;GAC7C,eAAe,QAAQ;GACvB,aAAa,QAAQ;GACrB;GACD,CAAC;EAIF,MAAM,QAAQ,CAAC,GAAG,OAAO,MAAM,OAAO,GAAG,cAAc;EAEvD,OAAO,OAAO,OAAO;GACnB,MAAM;GACN,MAAM,IAAI,sCACR,OACA;IACE,MAAM,QAAQ,cAAc,QAAQ,eAAe;IACnD,IAAI,QAAQ,SAAS,QAAQ;IAC9B,EACD,QAAQ,QACT;GACF,CAAC;;CAGJ,qBAA6B,QAAkC;EAC7D,IAAI,CAAC,OAAO,wBAAwB,SAAS,WAAW,EACtD,OAAO,eAAe,CACpB;GACE,MAAM;GACN,SAAS;GACT,KAAK;GACN,CACF,CAAC;EAEJ,OAAO;;CAGT,oBAA4B,SAA+D;EAIzF,MAAM,UAAU,QAAQ,OAAO;EAC/B,MAAM,SAAS,QAAQ,SAAS,WAAW,IAAI,QAAQ,SAAS,cAAc;EAW9E,OADqB,gBAAgB;GARnC,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,KAAK;GAC/B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;GAE2B,CAC/B,CAAC,OAAO"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-
|
|
2
|
-
import { c as qualifyTableName, f as resolveColumnTypeMetadata } from "./planner-sql-checks-
|
|
3
|
-
|
|
1
|
+
import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-CggjWNij.mjs";
|
|
2
|
+
import { c as qualifyTableName, f as resolveColumnTypeMetadata } from "./planner-sql-checks-DwZvGlV4.mjs";
|
|
4
3
|
//#region src/core/migrations/planner-ddl-builders.ts
|
|
5
4
|
function buildCreateTableSql(qualifiedTableName, table, codecHooks, storageTypes = {}) {
|
|
6
5
|
const columnDefinitions = Object.entries(table.columns).map(([columnName, column]) => {
|
|
@@ -126,7 +125,7 @@ REFERENCES ${qualifyTableName(schemaName, foreignKey.references.table)} (${forei
|
|
|
126
125
|
}
|
|
127
126
|
return sql;
|
|
128
127
|
}
|
|
129
|
-
|
|
130
128
|
//#endregion
|
|
131
129
|
export { buildForeignKeySql as a, buildCreateTableSql as i, buildColumnDefaultSql as n, renderDefaultLiteral as o, buildColumnTypeSql as r, buildAddColumnSql as t };
|
|
132
|
-
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=planner-ddl-builders-CLB7Umhh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-ddl-builders-CLB7Umhh.mjs","names":[],"sources":["../src/core/migrations/planner-ddl-builders.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type {\n ForeignKey,\n ReferentialAction,\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport type { PostgresColumnDefault } from '../types';\nimport { qualifyTableName } from './planner-sql-checks';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\nexport function buildCreateTableSql(\n qualifiedTableName: string,\n table: StorageTable,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const columnDefinitions = Object.entries(table.columns).map(\n ([columnName, column]: [string, StorageColumn]) => {\n const parts = [\n quoteIdentifier(columnName),\n buildColumnTypeSql(column, codecHooks, storageTypes),\n buildColumnDefaultSql(column.default, column),\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n return parts.join(' ');\n },\n );\n\n const constraintDefinitions: string[] = [];\n if (table.primaryKey) {\n constraintDefinitions.push(\n `PRIMARY KEY (${table.primaryKey.columns.map(quoteIdentifier).join(', ')})`,\n );\n }\n\n const allDefinitions = [...columnDefinitions, ...constraintDefinitions];\n return `CREATE TABLE ${qualifiedTableName} (\\n ${allDefinitions.join(',\\n ')}\\n)`;\n}\n\n/**\n * Pattern for safe PostgreSQL type names.\n * Allows letters, digits, underscores, spaces (for \"double precision\", \"character varying\"),\n * and trailing [] for array types.\n */\nconst SAFE_NATIVE_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_ ]*(\\[\\])?$/;\n\nfunction assertSafeNativeType(nativeType: string): void {\n if (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) {\n throw new Error(\n `Unsafe native type name in contract: \"${nativeType}\". ` +\n 'Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*(\\\\[\\\\])?$/',\n );\n }\n}\n\n/**\n * Sanity check against accidental SQL injection from malformed contract files.\n * Rejects semicolons, SQL comment tokens, and dollar-quoting.\n * Not a comprehensive security boundary — the contract is developer-authored.\n */\nfunction assertSafeDefaultExpression(expression: string): void {\n if (expression.includes(';') || /--|\\/\\*|\\$\\$|\\bSELECT\\b/i.test(expression)) {\n throw new Error(\n `Unsafe default expression in contract: \"${expression}\". ` +\n 'Default expressions must not contain semicolons, SQL comment tokens, dollar-quoting, or subqueries.',\n );\n }\n}\n\n/**\n * Renders the SQL type for a column in DDL context.\n *\n * @param allowPseudoTypes - When true (default), autoincrement integer columns\n * produce SERIAL/BIGSERIAL/SMALLSERIAL pseudo-types. Set to false for contexts\n * like ALTER COLUMN TYPE where pseudo-types are invalid.\n */\nexport function buildColumnTypeSql(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n allowPseudoTypes = true,\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (allowPseudoTypes) {\n const columnDefault = column.default;\n if (columnDefault?.kind === 'function' && columnDefault.expression === 'autoincrement()') {\n if (resolved.nativeType === 'int4' || resolved.nativeType === 'integer') {\n return 'SERIAL';\n }\n if (resolved.nativeType === 'int8' || resolved.nativeType === 'bigint') {\n return 'BIGSERIAL';\n }\n if (resolved.nativeType === 'int2' || resolved.nativeType === 'smallint') {\n return 'SMALLSERIAL';\n }\n }\n }\n\n const expanded = expandParameterizedTypeSql(resolved, codecHooks);\n if (expanded !== null) {\n return expanded;\n }\n\n if (column.typeRef) {\n return quoteIdentifier(resolved.nativeType);\n }\n\n assertSafeNativeType(resolved.nativeType);\n return resolved.nativeType;\n}\n\nfunction expandParameterizedTypeSql(\n column: Pick<StorageColumn, 'nativeType' | 'codecId' | 'typeParams'>,\n codecHooks: Map<string, CodecControlHooks>,\n): string | null {\n if (!column.typeParams) {\n return null;\n }\n\n if (!column.codecId) {\n throw new Error(\n `Column declares typeParams for nativeType \"${column.nativeType}\" but has no codecId. ` +\n 'Ensure the column is associated with a codec.',\n );\n }\n\n const hooks = codecHooks.get(column.codecId);\n if (!hooks?.expandNativeType) {\n if (hooks?.planTypeOperations) {\n return null;\n }\n throw new Error(\n `Column declares typeParams for nativeType \"${column.nativeType}\" ` +\n `but no expandNativeType hook is registered for codecId \"${column.codecId}\". ` +\n 'Ensure the extension providing this codec is included in extensionPacks.',\n );\n }\n\n const expanded = hooks.expandNativeType({\n nativeType: column.nativeType,\n codecId: column.codecId,\n typeParams: column.typeParams,\n });\n\n return expanded !== column.nativeType ? expanded : null;\n}\n\n/** Autoincrement columns use SERIAL types, so this returns empty for them. */\nexport function buildColumnDefaultSql(\n columnDefault: PostgresColumnDefault | undefined,\n column?: StorageColumn,\n): string {\n if (!columnDefault) {\n return '';\n }\n\n switch (columnDefault.kind) {\n case 'literal':\n return `DEFAULT ${renderDefaultLiteral(columnDefault.value, column)}`;\n case 'function': {\n if (columnDefault.expression === 'autoincrement()') {\n return '';\n }\n assertSafeDefaultExpression(columnDefault.expression);\n return `DEFAULT (${columnDefault.expression})`;\n }\n case 'sequence':\n return `DEFAULT nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`;\n }\n}\n\nexport function renderDefaultLiteral(value: unknown, column?: StorageColumn): string {\n const isJsonColumn = column?.nativeType === 'json' || column?.nativeType === 'jsonb';\n\n if (value instanceof Date) {\n return `'${escapeLiteral(value.toISOString())}'`;\n }\n if (typeof value === 'string') {\n return `'${escapeLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (value === null) {\n return 'NULL';\n }\n const json = JSON.stringify(value);\n if (isJsonColumn) {\n return `'${escapeLiteral(json)}'::${column.nativeType}`;\n }\n return `'${escapeLiteral(json)}'`;\n}\n\nexport function buildAddColumnSql(\n qualifiedTableName: string,\n columnName: string,\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n temporaryDefault?: string | null,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const typeSql = buildColumnTypeSql(column, codecHooks, storageTypes);\n const defaultSql =\n buildColumnDefaultSql(column.default, column) ||\n (temporaryDefault ? `DEFAULT ${temporaryDefault}` : '');\n const parts = [\n `ALTER TABLE ${qualifiedTableName}`,\n `ADD COLUMN ${quoteIdentifier(columnName)} ${typeSql}`,\n defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n return parts.join(' ');\n}\n\nconst REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string> = {\n noAction: 'NO ACTION',\n restrict: 'RESTRICT',\n cascade: 'CASCADE',\n setNull: 'SET NULL',\n setDefault: 'SET DEFAULT',\n};\n\nexport function buildForeignKeySql(\n schemaName: string,\n tableName: string,\n fkName: string,\n foreignKey: ForeignKey,\n): string {\n let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}\nADD CONSTRAINT ${quoteIdentifier(fkName)}\nFOREIGN KEY (${foreignKey.columns.map(quoteIdentifier).join(', ')})\nREFERENCES ${qualifyTableName(schemaName, foreignKey.references.table)} (${foreignKey.references.columns\n .map(quoteIdentifier)\n .join(', ')})`;\n\n if (foreignKey.onDelete !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[foreignKey.onDelete];\n if (!action) {\n throw new Error(`Unknown referential action for onDelete: ${String(foreignKey.onDelete)}`);\n }\n sql += `\\nON DELETE ${action}`;\n }\n if (foreignKey.onUpdate !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[foreignKey.onUpdate];\n if (!action) {\n throw new Error(`Unknown referential action for onUpdate: ${String(foreignKey.onUpdate)}`);\n }\n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{ t as PostgresColumnDefault } from "./types-
|
|
1
|
+
import { t as PostgresColumnDefault } from "./types-CTqpysRY.mjs";
|
|
2
2
|
import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ForeignKey, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-ddl-builders.d.mts","names":[],"sources":["../src/core/migrations/planner-ddl-builders.ts"],"
|
|
1
|
+
{"version":3,"file":"planner-ddl-builders.d.mts","names":[],"sources":["../src/core/migrations/planner-ddl-builders.ts"],"mappings":";;;;;iBAagB,mBAAA,CACd,kBAAA,UACA,KAAA,EAAO,YAAA,EACP,UAAA,EAAY,GAAA,SAAY,iBAAA,GACxB,YAAA,GAAc,MAAA,SAAe,mBAAA;;AAJ/B;;;;;;iBAkEgB,kBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,GAAA,SAAY,iBAAA,GACxB,YAAA,GAAc,MAAA,SAAe,mBAAA,GAC7B,gBAAA;;iBAqEc,qBAAA,CACd,aAAA,EAAe,qBAAA,cACf,MAAA,GAAS,aAAA;AAAA,iBAqBK,oBAAA,CAAqB,KAAA,WAAgB,MAAA,GAAS,aAAA;AAAA,iBAsB9C,iBAAA,CACd,kBAAA,UACA,UAAA,UACA,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,GAAA,SAAY,iBAAA,GACxB,gBAAA,kBACA,YAAA,GAAc,MAAA,SAAe,mBAAA;AAAA,iBAuBf,kBAAA,CACd,UAAA,UACA,SAAA,UACA,MAAA,UACA,UAAA,EAAY,UAAA"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { a as buildForeignKeySql, i as buildCreateTableSql, n as buildColumnDefaultSql, o as renderDefaultLiteral, r as buildColumnTypeSql, t as buildAddColumnSql } from "./planner-ddl-builders-
|
|
2
|
-
|
|
3
|
-
export { buildAddColumnSql, buildColumnDefaultSql, buildColumnTypeSql, buildCreateTableSql, buildForeignKeySql, renderDefaultLiteral };
|
|
1
|
+
import { a as buildForeignKeySql, i as buildCreateTableSql, n as buildColumnDefaultSql, o as renderDefaultLiteral, r as buildColumnTypeSql, t as buildAddColumnSql } from "./planner-ddl-builders-CLB7Umhh.mjs";
|
|
2
|
+
export { buildAddColumnSql, buildColumnDefaultSql, buildColumnTypeSql, buildCreateTableSql, buildForeignKeySql, renderDefaultLiteral };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
|
-
|
|
3
2
|
//#region src/core/migrations/planner-identity-values.ts
|
|
4
3
|
/**
|
|
5
4
|
* Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.
|
|
@@ -85,7 +84,7 @@ function buildBitIdentityValue(typeParams) {
|
|
|
85
84
|
if (typeof length !== "number" || !Number.isInteger(length) || length <= 0) return null;
|
|
86
85
|
return `B'${"0".repeat(length)}'`;
|
|
87
86
|
}
|
|
88
|
-
|
|
89
87
|
//#endregion
|
|
90
88
|
export { resolveIdentityValue as n, buildBuiltinIdentityValue as t };
|
|
91
|
-
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=planner-identity-values-DTx0gePL.mjs.map
|
package/dist/{planner-identity-values-Dju-o5GF.mjs.map → planner-identity-values-DTx0gePL.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-identity-values-
|
|
1
|
+
{"version":3,"file":"planner-identity-values-DTx0gePL.mjs","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\n/**\n * Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.\n * Checks codec hooks first (extensions can provide type-specific identity values),\n * then falls back to the built-in map.\n */\nexport function resolveIdentityValue(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string | null {\n const referencedType = column.typeRef ? storageTypes[column.typeRef] : undefined;\n const codecId = referencedType?.codecId ?? column.codecId;\n const nativeType = referencedType?.nativeType ?? column.nativeType;\n const typeParams = referencedType?.typeParams ?? column.typeParams;\n\n if (codecId) {\n const hookDefault = codecHooks.get(codecId)?.resolveIdentityValue?.({\n nativeType,\n codecId,\n ...ifDefined('typeParams', typeParams),\n });\n if (hookDefault !== undefined) {\n return hookDefault;\n }\n }\n\n return buildBuiltinIdentityValue(nativeType, typeParams);\n}\n\n/**\n * Returns the built-in identity value (monoid neutral element) as a SQL literal for the given\n * PostgreSQL native type — e.g. 0 for integers, '' for text, false for booleans.\n *\n * This is the planner's fallback when no codec hook provides a type-specific identity value.\n *\n * Returns null for unrecognized types (for example enums and extension-owned types without a\n * hook), which causes the planner to fall back to the empty-table precheck.\n *\n * @internal Exported for testing only.\n */\nexport function buildBuiltinIdentityValue(\n nativeType: string,\n typeParams?: Record<string, unknown>,\n): string | null {\n const normalizedNativeType = normalizeIdentityValueNativeType(nativeType);\n\n if (normalizedNativeType.endsWith('[]')) {\n return \"'{}'\";\n }\n\n switch (normalizedNativeType) {\n case 'text':\n case 'character':\n case 'bpchar':\n case 'character varying':\n case 'varchar':\n return \"''\";\n\n case 'int2':\n case 'int4':\n case 'int8':\n case 'integer':\n case 'bigint':\n case 'smallint':\n case 'float4':\n case 'float8':\n case 'real':\n case 'double precision':\n case 'numeric':\n case 'decimal':\n return '0';\n\n case 'bool':\n case 'boolean':\n return 'false';\n\n case 'uuid':\n return \"'00000000-0000-0000-0000-000000000000'\";\n\n case 'json':\n return \"'{}'::json\";\n case 'jsonb':\n return \"'{}'::jsonb\";\n\n case 'date':\n case 'timestamp':\n case 'timestamptz':\n case 'timestamp with time zone':\n case 'timestamp without time zone':\n return \"'epoch'\";\n\n case 'time':\n case 'time without time zone':\n return \"'00:00:00'\";\n case 'timetz':\n case 'time with time zone':\n return \"'00:00:00+00'\";\n\n case 'interval':\n return \"'0'\";\n\n case 'bytea':\n return \"''::bytea\";\n case 'tsvector':\n return \"''::tsvector\";\n\n case 'bit':\n return buildBitIdentityValue(typeParams);\n case 'bit varying':\n case 'varbit':\n return \"B''\";\n\n default:\n return null;\n }\n}\n\nfunction normalizeIdentityValueNativeType(nativeType: string): string {\n return nativeType.trim().toLowerCase().replace(/\\s+/g, ' ');\n}\n\nfunction buildBitIdentityValue(typeParams?: Record<string, unknown>): string | null {\n const length = typeParams?.['length'];\n if (length === undefined) {\n return \"B'0'\";\n }\n if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {\n return null;\n }\n return `B'${'0'.repeat(length)}'`;\n}\n"],"mappings":";;;;;;;AASA,SAAgB,qBACd,QACA,YACA,eAAoD,EAAE,EACvC;CACf,MAAM,iBAAiB,OAAO,UAAU,aAAa,OAAO,WAAW,KAAA;CACvE,MAAM,UAAU,gBAAgB,WAAW,OAAO;CAClD,MAAM,aAAa,gBAAgB,cAAc,OAAO;CACxD,MAAM,aAAa,gBAAgB,cAAc,OAAO;CAExD,IAAI,SAAS;EACX,MAAM,cAAc,WAAW,IAAI,QAAQ,EAAE,uBAAuB;GAClE;GACA;GACA,GAAG,UAAU,cAAc,WAAW;GACvC,CAAC;EACF,IAAI,gBAAgB,KAAA,GAClB,OAAO;;CAIX,OAAO,0BAA0B,YAAY,WAAW;;;;;;;;;;;;;AAc1D,SAAgB,0BACd,YACA,YACe;CACf,MAAM,uBAAuB,iCAAiC,WAAW;CAEzE,IAAI,qBAAqB,SAAS,KAAK,EACrC,OAAO;CAGT,QAAQ,sBAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EAET,KAAK;EACL,KAAK,WACH,OAAO;EAET,KAAK,QACH,OAAO;EAET,KAAK,QACH,OAAO;EACT,KAAK,SACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,+BACH,OAAO;EAET,KAAK;EACL,KAAK,0BACH,OAAO;EACT,KAAK;EACL,KAAK,uBACH,OAAO;EAET,KAAK,YACH,OAAO;EAET,KAAK,SACH,OAAO;EACT,KAAK,YACH,OAAO;EAET,KAAK,OACH,OAAO,sBAAsB,WAAW;EAC1C,KAAK;EACL,KAAK,UACH,OAAO;EAET,SACE,OAAO;;;AAIb,SAAS,iCAAiC,YAA4B;CACpE,OAAO,WAAW,MAAM,CAAC,aAAa,CAAC,QAAQ,QAAQ,IAAI;;AAG7D,SAAS,sBAAsB,YAAqD;CAClF,MAAM,SAAS,aAAa;CAC5B,IAAI,WAAW,KAAA,GACb,OAAO;CAET,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,OAAO,IAAI,UAAU,GACvE,OAAO;CAET,OAAO,KAAK,IAAI,OAAO,OAAO,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { CodecControlHooks } from "@prisma-next/family-sql/control";
|
|
|
2
2
|
import { StorageColumn, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/planner-identity-values.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Returns the built-in identity value (monoid neutral element) as a SQL literal for the given
|
|
8
7
|
* PostgreSQL native type — e.g. 0 for integers, '' for text, false for booleans.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-identity-values.d.mts","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"
|
|
1
|
+
{"version":3,"file":"planner-identity-values.d.mts","names":[],"sources":["../src/core/migrations/planner-identity-values.ts"],"mappings":";;;;;;;;;;;;;;;iBA4CgB,yBAAA,CACd,UAAA,UACA,UAAA,GAAa,MAAA"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as buildBuiltinIdentityValue } from "./planner-identity-values-
|
|
2
|
-
|
|
3
|
-
export { buildBuiltinIdentityValue };
|
|
1
|
+
import { t as buildBuiltinIdentityValue } from "./planner-identity-values-DTx0gePL.mjs";
|
|
2
|
+
export { buildBuiltinIdentityValue };
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { t as PostgresPlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import {
|
|
3
|
-
import { t as PostgresMigration } from "./postgres-migration-BjA3Zmts.mjs";
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
|
|
2
|
+
import { t as PostgresMigration } from "./postgres-migration-UkcHfZAA.mjs";
|
|
4
3
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
5
|
-
import { MigrationPlanWithAuthoringSurface } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { MigrationPlanWithAuthoringSurface, OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
6
5
|
import { MigrationMeta } from "@prisma-next/migration-tools/migration";
|
|
7
6
|
|
|
8
7
|
//#region src/core/migrations/planner-produced-postgres-migration.d.ts
|
|
9
|
-
|
|
10
8
|
type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
|
|
11
9
|
declare class TypeScriptRenderablePostgresMigration extends PostgresMigration implements MigrationPlanWithAuthoringSurface {
|
|
12
10
|
#private;
|
|
13
|
-
constructor(calls: readonly
|
|
11
|
+
constructor(calls: readonly OpFactoryCall[], meta: MigrationMeta, spaceId: string);
|
|
14
12
|
get operations(): readonly Op[];
|
|
15
13
|
describe(): MigrationMeta;
|
|
14
|
+
/**
|
|
15
|
+
* Contract space this planner-produced plan applies to. Threaded
|
|
16
|
+
* from the planner options so the runner keys the marker row by
|
|
17
|
+
* the right space when executing the plan.
|
|
18
|
+
*/
|
|
19
|
+
get spaceId(): string;
|
|
16
20
|
renderTypeScript(): string;
|
|
17
21
|
}
|
|
18
22
|
//#endregion
|
|
19
23
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
20
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
24
|
+
//# sourceMappingURL=planner-produced-postgres-migration-CjxWIVgh.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-CjxWIVgh.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"mappings":";;;;;;;KAqCK,EAAA,GAAK,yBAAA,CAA0B,yBAAA;AAAA,cAEvB,qCAAA,SACH,iBAAA,YACG,iCAAA;EAAA;cAMC,KAAA,WAAgB,aAAA,IAAiB,IAAA,EAAM,aAAA,EAAe,OAAA;EAAA,IAOrD,UAAA,CAAA,YAAuB,EAAA;EAI3B,QAAA,CAAA,GAAY,aAAA;EAAA;;;;;EAAA,IASjB,OAAA,CAAA;EAIJ,gBAAA,CAAA;AAAA"}
|
|
@@ -1,16 +1,17 @@
|
|
|
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-Bkv140RW.mjs";
|
|
2
|
+
import { t as renderOps } from "./render-ops--1nnfNus.mjs";
|
|
3
|
+
import { t as renderCallsToTypeScript } from "./render-typescript-D3doH-vX.mjs";
|
|
4
4
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
5
|
-
|
|
6
5
|
//#region src/core/migrations/planner-produced-postgres-migration.ts
|
|
7
6
|
var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
8
7
|
#calls;
|
|
9
8
|
#meta;
|
|
10
|
-
|
|
9
|
+
#spaceId;
|
|
10
|
+
constructor(calls, meta, spaceId) {
|
|
11
11
|
super();
|
|
12
12
|
this.#calls = calls;
|
|
13
13
|
this.#meta = meta;
|
|
14
|
+
this.#spaceId = spaceId;
|
|
14
15
|
}
|
|
15
16
|
get operations() {
|
|
16
17
|
return renderOps(this.#calls);
|
|
@@ -18,16 +19,23 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
|
18
19
|
describe() {
|
|
19
20
|
return this.#meta;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Contract space this planner-produced plan applies to. Threaded
|
|
24
|
+
* from the planner options so the runner keys the marker row by
|
|
25
|
+
* the right space when executing the plan.
|
|
26
|
+
*/
|
|
27
|
+
get spaceId() {
|
|
28
|
+
return this.#spaceId;
|
|
29
|
+
}
|
|
21
30
|
renderTypeScript() {
|
|
22
31
|
return renderCallsToTypeScript(this.#calls, {
|
|
23
32
|
from: this.#meta.from,
|
|
24
33
|
to: this.#meta.to,
|
|
25
|
-
...ifDefined("kind", this.#meta.kind),
|
|
26
34
|
...ifDefined("labels", this.#meta.labels)
|
|
27
35
|
});
|
|
28
36
|
}
|
|
29
37
|
};
|
|
30
|
-
|
|
31
38
|
//#endregion
|
|
32
39
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
33
|
-
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=planner-produced-postgres-migration-DphktB2N.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-DphktB2N.mjs","names":["#calls","#meta","#spaceId"],"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 {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport { ifDefined } from '@prisma-next/utils/defined';\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 OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #spaceId: string;\n\n constructor(calls: readonly OpFactoryCall[], meta: MigrationMeta, spaceId: string) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\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 /**\n * Contract space this planner-produced plan applies to. Threaded\n * from the planner options so the runner keys the marker row by\n * the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\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":";;;;;AAuCA,IAAa,wCAAb,cACU,kBAEV;CACE;CACA;CACA;CAEA,YAAY,OAAiC,MAAqB,SAAiB;EACjF,OAAO;EACP,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;;CAGlB,IAAa,aAA4B;EACvC,OAAO,UAAU,KAAKF,OAAO;;CAG/B,WAAmC;EACjC,OAAO,KAAKC;;;;;;;CAQd,IAAI,UAAkB;EACpB,OAAO,KAAKC;;CAGd,mBAA2B;EACzB,OAAO,wBAAwB,KAAKF,QAAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,GAAG,UAAU,UAAU,KAAKA,MAAM,OAAO;GAC1C,CAAC"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./op-factory-call-C3bWXKSP.mjs";
|
|
3
|
-
import "./postgres-migration-BjA3Zmts.mjs";
|
|
4
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CRRTno6Z.mjs";
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CjxWIVgh.mjs";
|
|
5
2
|
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
2
|
-
|
|
3
|
-
export { TypeScriptRenderablePostgresMigration };
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-DphktB2N.mjs";
|
|
2
|
+
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -23,7 +23,7 @@ function hasIndex(lookup, columns) {
|
|
|
23
23
|
function hasForeignKey(lookup, fk) {
|
|
24
24
|
return lookup.fkKeys.has(`${fk.columns.join(",")}|${fk.references.table}|${fk.references.columns.join(",")}`);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
26
|
//#endregion
|
|
28
27
|
export { hasUniqueConstraint as i, hasForeignKey as n, hasIndex as r, buildSchemaLookupMap as t };
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=planner-schema-lookup-B1ags8ys.mjs.map
|
package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B1ags8ys.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-schema-lookup-
|
|
1
|
+
{"version":3,"file":"planner-schema-lookup-B1ags8ys.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;CAChD,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,OAAO,OAAO,EAC5D,IAAI,IAAI,WAAW,uBAAuB,MAAM,CAAC;CAEnD,OAAO;;AAGT,SAAS,uBAAuB,OAAyD;CAWvF,OAAO;EAAE,YAAA,IAVc,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CAUrD;EAAE,WAAA,IATC,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CASzC;EAAE,iBAAA,IARJ,IAC1B,MAAM,QAAQ,QAAQ,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CAOxB;EAAE,QAAA,IAL9B,IACjB,MAAM,YAAY,KACf,OAAO,GAAG,GAAG,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,gBAAgB,GAAG,GAAG,kBAAkB,KAAK,IAAI,GACxF,CAEoD;EAAE;;AAG3D,SAAgB,oBACd,QACA,SACS;CACT,MAAM,MAAM,QAAQ,KAAK,IAAI;CAC7B,OAAO,OAAO,WAAW,IAAI,IAAI,IAAI,OAAO,gBAAgB,IAAI,IAAI;;AAGtE,SAAgB,SAAS,QAA2B,SAAqC;CACvF,MAAM,MAAM,QAAQ,KAAK,IAAI;CAC7B,OAAO,OAAO,UAAU,IAAI,IAAI,IAAI,OAAO,WAAW,IAAI,IAAI;;AAGhE,SAAgB,cAAc,QAA2B,IAAyB;CAChF,OAAO,OAAO,OAAO,IACnB,GAAG,GAAG,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,WAAW,MAAM,GAAG,GAAG,WAAW,QAAQ,KAAK,IAAI,GAClF"}
|
|
@@ -2,7 +2,6 @@ import { ForeignKey } from "@prisma-next/sql-contract/types";
|
|
|
2
2
|
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/planner-schema-lookup.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Pre-computed lookup sets for a schema table's constraints.
|
|
8
7
|
* Converts O(n*m) linear scans to O(1) Set lookups per constraint check.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-schema-lookup.d.mts","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"
|
|
1
|
+
{"version":3,"file":"planner-schema-lookup.d.mts","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"mappings":";;;;;;AAOA;;UAAiB,iBAAA;EAAA,SACN,UAAA,EAAY,GAAA;EAAA,SACZ,SAAA,EAAW,GAAA;EAAA,SACX,eAAA,EAAiB,GAAA;EAAA,SACjB,MAAA,EAAQ,GAAA;AAAA;AAAA,iBAGH,oBAAA,CAAqB,MAAA,EAAQ,WAAA,GAAc,WAAA,SAAoB,iBAAA;AAAA,iBAsB/D,mBAAA,CACd,MAAA,EAAQ,iBAAA,EACR,OAAA;AAAA,iBAMc,QAAA,CAAS,MAAA,EAAQ,iBAAA,EAAmB,OAAA;AAAA,iBAKpC,aAAA,CAAc,MAAA,EAAQ,iBAAA,EAAmB,EAAA,EAAI,UAAA"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { i as hasUniqueConstraint, n as hasForeignKey, r as hasIndex, t as buildSchemaLookupMap } from "./planner-schema-lookup-
|
|
2
|
-
|
|
3
|
-
export { buildSchemaLookupMap, hasForeignKey, hasIndex, hasUniqueConstraint };
|
|
1
|
+
import { i as hasUniqueConstraint, n as hasForeignKey, r as hasIndex, t as buildSchemaLookupMap } from "./planner-schema-lookup-B1ags8ys.mjs";
|
|
2
|
+
export { buildSchemaLookupMap, hasForeignKey, hasIndex, hasUniqueConstraint };
|