@prisma-next/target-sqlite 0.5.0-dev.9 → 0.6.0-dev.1

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.
Files changed (134) hide show
  1. package/dist/codec-ids-CYwMu3-4.d.mts +13 -0
  2. package/dist/codec-ids-CYwMu3-4.d.mts.map +1 -0
  3. package/dist/codec-ids-CuUxYcd0.mjs +13 -0
  4. package/dist/codec-ids-CuUxYcd0.mjs.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -0
  6. package/dist/codec-ids.mjs +2 -0
  7. package/dist/codec-types-xLeyb_u4.d.mts +23 -0
  8. package/dist/codec-types-xLeyb_u4.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +3 -0
  10. package/dist/codec-types.mjs +2 -0
  11. package/dist/codecs-DEjc7dem.d.mts +203 -0
  12. package/dist/codecs-DEjc7dem.d.mts.map +1 -0
  13. package/dist/codecs-DVnHtVWW.mjs +220 -0
  14. package/dist/codecs-DVnHtVWW.mjs.map +1 -0
  15. package/dist/codecs.d.mts +2 -0
  16. package/dist/codecs.mjs +13 -0
  17. package/dist/codecs.mjs.map +1 -0
  18. package/dist/control.d.mts +4 -3
  19. package/dist/control.d.mts.map +1 -1
  20. package/dist/control.mjs +427 -5
  21. package/dist/control.mjs.map +1 -1
  22. package/dist/default-normalizer-3Fccw7yw.mjs +69 -0
  23. package/dist/default-normalizer-3Fccw7yw.mjs.map +1 -0
  24. package/dist/default-normalizer.d.mts +7 -0
  25. package/dist/default-normalizer.d.mts.map +1 -0
  26. package/dist/default-normalizer.mjs +2 -0
  27. package/dist/descriptor-meta-CE2Kbn9b.mjs +17 -0
  28. package/dist/descriptor-meta-CE2Kbn9b.mjs.map +1 -0
  29. package/dist/migration.d.mts +85 -0
  30. package/dist/migration.d.mts.map +1 -0
  31. package/dist/migration.mjs +49 -0
  32. package/dist/migration.mjs.map +1 -0
  33. package/dist/native-type-normalizer-BlN5XfD-.mjs +14 -0
  34. package/dist/native-type-normalizer-BlN5XfD-.mjs.map +1 -0
  35. package/dist/native-type-normalizer.d.mts +11 -0
  36. package/dist/native-type-normalizer.d.mts.map +1 -0
  37. package/dist/native-type-normalizer.mjs +2 -0
  38. package/dist/op-factory-call-DRKKURAO.mjs +279 -0
  39. package/dist/op-factory-call-DRKKURAO.mjs.map +1 -0
  40. package/dist/op-factory-call.d.mts +151 -0
  41. package/dist/op-factory-call.d.mts.map +1 -0
  42. package/dist/op-factory-call.mjs +2 -0
  43. package/dist/pack.d.mts +35 -1
  44. package/dist/pack.d.mts.map +1 -1
  45. package/dist/pack.mjs +2 -3
  46. package/dist/planner-A7dqS0u6.mjs +522 -0
  47. package/dist/planner-A7dqS0u6.mjs.map +1 -0
  48. package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts +29 -0
  49. package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts.map +1 -0
  50. package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs +110 -0
  51. package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs.map +1 -0
  52. package/dist/planner-produced-sqlite-migration.d.mts +2 -0
  53. package/dist/planner-produced-sqlite-migration.mjs +2 -0
  54. package/dist/planner-target-details-Bm71XPKb.mjs +15 -0
  55. package/dist/planner-target-details-Bm71XPKb.mjs.map +1 -0
  56. package/dist/planner-target-details-vhvZDWK1.d.mts +12 -0
  57. package/dist/planner-target-details-vhvZDWK1.d.mts.map +1 -0
  58. package/dist/planner-target-details.d.mts +2 -0
  59. package/dist/planner-target-details.mjs +2 -0
  60. package/dist/planner.d.mts +59 -0
  61. package/dist/planner.d.mts.map +1 -0
  62. package/dist/planner.mjs +2 -0
  63. package/dist/render-ops-CSRDT4YL.mjs +8 -0
  64. package/dist/render-ops-CSRDT4YL.mjs.map +1 -0
  65. package/dist/render-ops.d.mts +10 -0
  66. package/dist/render-ops.d.mts.map +1 -0
  67. package/dist/render-ops.mjs +2 -0
  68. package/dist/runtime.d.mts.map +1 -1
  69. package/dist/runtime.mjs +4 -8
  70. package/dist/runtime.mjs.map +1 -1
  71. package/dist/shared-qLsgTOZs.d.mts +69 -0
  72. package/dist/shared-qLsgTOZs.d.mts.map +1 -0
  73. package/dist/sql-utils-DhevMgef.mjs +35 -0
  74. package/dist/sql-utils-DhevMgef.mjs.map +1 -0
  75. package/dist/sql-utils.d.mts +22 -0
  76. package/dist/sql-utils.d.mts.map +1 -0
  77. package/dist/sql-utils.mjs +2 -0
  78. package/dist/sqlite-migration-BBJktVVw.mjs +16 -0
  79. package/dist/sqlite-migration-BBJktVVw.mjs.map +1 -0
  80. package/dist/sqlite-migration-DAb2NEX6.d.mts +17 -0
  81. package/dist/sqlite-migration-DAb2NEX6.d.mts.map +1 -0
  82. package/dist/statement-builders-Dne-LkAV.mjs +158 -0
  83. package/dist/statement-builders-Dne-LkAV.mjs.map +1 -0
  84. package/dist/statement-builders.d.mts +68 -0
  85. package/dist/statement-builders.d.mts.map +1 -0
  86. package/dist/statement-builders.mjs +2 -0
  87. package/dist/tables-D84zfPZI.mjs +403 -0
  88. package/dist/tables-D84zfPZI.mjs.map +1 -0
  89. package/package.json +33 -11
  90. package/src/core/authoring.ts +9 -0
  91. package/src/core/codec-helpers.ts +11 -0
  92. package/src/core/codec-ids.ts +13 -0
  93. package/src/core/codecs.ts +337 -0
  94. package/src/core/control-target.ts +53 -11
  95. package/src/core/default-normalizer.ts +92 -0
  96. package/src/core/descriptor-meta.ts +5 -1
  97. package/src/core/migrations/issue-planner.ts +586 -0
  98. package/src/core/migrations/op-factory-call.ts +369 -0
  99. package/src/core/migrations/operations/columns.ts +62 -0
  100. package/src/core/migrations/operations/data-transform.ts +51 -0
  101. package/src/core/migrations/operations/indexes.ts +52 -0
  102. package/src/core/migrations/operations/raw.ts +12 -0
  103. package/src/core/migrations/operations/shared.ts +120 -0
  104. package/src/core/migrations/operations/tables.ts +388 -0
  105. package/src/core/migrations/planner-ddl-builders.ts +142 -0
  106. package/src/core/migrations/planner-produced-sqlite-migration.ts +70 -0
  107. package/src/core/migrations/planner-strategies.ts +231 -0
  108. package/src/core/migrations/planner-target-details.ts +33 -0
  109. package/src/core/migrations/planner.ts +183 -0
  110. package/src/core/migrations/render-ops.ts +15 -0
  111. package/src/core/migrations/render-typescript.ts +91 -0
  112. package/src/core/migrations/runner.ts +724 -0
  113. package/src/core/migrations/sqlite-migration.ts +13 -0
  114. package/src/core/migrations/statement-builders.ts +212 -0
  115. package/src/core/native-type-normalizer.ts +9 -0
  116. package/src/core/registry.ts +11 -0
  117. package/src/core/runtime-target.ts +1 -3
  118. package/src/core/sql-utils.ts +47 -0
  119. package/src/exports/codec-ids.ts +13 -0
  120. package/src/exports/codec-types.ts +43 -0
  121. package/src/exports/codecs.ts +20 -0
  122. package/src/exports/control.ts +1 -0
  123. package/src/exports/default-normalizer.ts +1 -0
  124. package/src/exports/migration.ts +24 -0
  125. package/src/exports/native-type-normalizer.ts +1 -0
  126. package/src/exports/op-factory-call.ts +12 -0
  127. package/src/exports/planner-produced-sqlite-migration.ts +4 -0
  128. package/src/exports/planner-target-details.ts +2 -0
  129. package/src/exports/planner.ts +2 -0
  130. package/src/exports/render-ops.ts +1 -0
  131. package/src/exports/sql-utils.ts +1 -0
  132. package/src/exports/statement-builders.ts +12 -0
  133. package/dist/descriptor-meta-DbuuziYA.mjs +0 -14
  134. package/dist/descriptor-meta-DbuuziYA.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-A7dqS0u6.mjs","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts","../src/core/migrations/planner.ts"],"sourcesContent":["/**\n * SQLite migration strategies.\n *\n * Each strategy examines the issue list, consumes issues it handles, and\n * returns the `SqliteOpFactoryCall[]` to address them. The issue planner\n * runs each strategy in order and routes whatever's left through\n * `mapIssueToCall`.\n *\n * SQLite has no enums, no data-safe backfill, and no component-declared\n * database dependencies. The only recipe that needs strategy-level\n * multi-issue consumption is `recreateTable` (added in a later phase), which\n * absorbs type/nullability/default/constraint mismatches for a given table\n * into a single recreate operation.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationClass,\n MigrationOperationPolicy,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type { SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { toTableSpec } from './issue-planner';\nimport { DataTransformCall, RecreateTableCall, type SqliteOpFactoryCall } from './op-factory-call';\nimport type { SqliteIndexSpec } from './operations/shared';\nimport { buildRecreatePostchecks, buildRecreateSummary } from './operations/tables';\n\nexport interface StrategyContext {\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema: SqlSchemaIR;\n readonly policy: MigrationOperationPolicy;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\nexport type CallMigrationStrategy = (\n issues: readonly SchemaIssue[],\n context: StrategyContext,\n) =>\n | {\n kind: 'match';\n issues: readonly SchemaIssue[];\n calls: readonly SqliteOpFactoryCall[];\n recipe?: boolean;\n }\n | { kind: 'no_match' };\n\n// ============================================================================\n// Recreate-table strategy\n// ============================================================================\n\nconst WIDENING_ISSUE_KINDS = new Set<SchemaIssue['kind']>(['default_mismatch', 'default_missing']);\n\nconst DESTRUCTIVE_ISSUE_KINDS = new Set<SchemaIssue['kind']>([\n 'extra_default',\n 'type_mismatch',\n 'primary_key_mismatch',\n 'foreign_key_mismatch',\n 'unique_constraint_mismatch',\n 'extra_foreign_key',\n 'extra_unique_constraint',\n 'extra_primary_key',\n]);\n\nfunction classifyIssue(issue: SchemaIssue): 'widening' | 'destructive' | null {\n if (issue.kind === 'enum_values_changed') return null;\n if (!issue.table) return null;\n if (issue.kind === 'nullability_mismatch') {\n // Relaxing (NOT NULL → nullable) is widening; tightening is destructive.\n return issue.expected === 'true' ? 'widening' : 'destructive';\n }\n if (WIDENING_ISSUE_KINDS.has(issue.kind)) return 'widening';\n if (DESTRUCTIVE_ISSUE_KINDS.has(issue.kind)) return 'destructive';\n return null;\n}\n\n/**\n * Groups recreate-eligible issues by table, decides per-table operation class\n * (destructive wins over widening), and emits one `RecreateTableCall` per\n * table. Returns unchanged-or-smaller issue list — issues the strategy\n * consumed are removed so `mapIssueToCall` doesn't double-handle them.\n */\nexport const recreateTableStrategy: CallMigrationStrategy = (issues, ctx) => {\n const byTable = new Map<string, { issues: SchemaIssue[]; hasDestructive: boolean }>();\n const consumed = new Set<SchemaIssue>();\n\n for (const issue of issues) {\n const cls = classifyIssue(issue);\n if (!cls) continue;\n if (issue.kind === 'enum_values_changed') continue;\n if (!issue.table) continue;\n const table = issue.table;\n const entry = byTable.get(table);\n if (entry) {\n entry.issues.push(issue);\n if (cls === 'destructive') entry.hasDestructive = true;\n } else {\n byTable.set(table, { issues: [issue], hasDestructive: cls === 'destructive' });\n }\n consumed.add(issue);\n }\n\n if (byTable.size === 0) return { kind: 'no_match' };\n\n const calls: SqliteOpFactoryCall[] = [];\n for (const [tableName, entry] of byTable) {\n const contractTable = ctx.toContract.storage.tables[tableName];\n const schemaTable = ctx.schema.tables[tableName];\n if (!contractTable || !schemaTable) continue;\n const operationClass: MigrationOperationClass = entry.hasDestructive\n ? 'destructive'\n : 'widening';\n\n // Flatten the contract table to a self-contained spec — the Call holds\n // pre-rendered SQL fragments only, no `StorageColumn` or `storageTypes`.\n const tableSpec = toTableSpec(contractTable, ctx.storageTypes);\n\n const seenIndexColumnKeys = new Set<string>();\n const indexes: SqliteIndexSpec[] = [];\n for (const idx of contractTable.indexes) {\n const key = idx.columns.join(',');\n if (seenIndexColumnKeys.has(key)) continue;\n seenIndexColumnKeys.add(key);\n indexes.push({\n name: idx.name ?? defaultIndexName(tableName, idx.columns),\n columns: idx.columns,\n });\n }\n for (const fk of contractTable.foreignKeys) {\n if (fk.index === false) continue;\n const key = fk.columns.join(',');\n if (seenIndexColumnKeys.has(key)) continue;\n seenIndexColumnKeys.add(key);\n indexes.push({\n name: defaultIndexName(tableName, fk.columns),\n columns: fk.columns,\n });\n }\n\n calls.push(\n new RecreateTableCall({\n tableName,\n contractTable: tableSpec,\n schemaColumnNames: Object.keys(schemaTable.columns),\n indexes,\n summary: buildRecreateSummary(tableName, entry.issues),\n postchecks: buildRecreatePostchecks(tableName, entry.issues, tableSpec),\n operationClass,\n }),\n );\n }\n\n return {\n kind: 'match',\n issues: issues.filter((i) => !consumed.has(i)),\n calls,\n recipe: true,\n };\n};\n\n// ============================================================================\n// Nullability-tightening backfill strategy\n// ============================================================================\n\n/**\n * When the policy allows `'data'` and the contract tightens one or more\n * columns from nullable to NOT NULL, emit a `DataTransformCall` stub per\n * tightened column. The user fills the backfill `UPDATE` in the rendered\n * `migration.ts` before the subsequent `RecreateTableCall` copies data into\n * the tightened schema (whose `INSERT INTO temp SELECT … FROM old` would\n * otherwise fail at runtime if any `NULL`s remain).\n *\n * Does NOT consume the tightening issue — `recreateTableStrategy` still\n * needs it to produce the actual recreate that enforces the NOT NULL at\n * the schema level. The backfill op and the recreate op end up in the\n * recipe slot in strategy order (backfill first, recreate second), which\n * matches the required execution order.\n *\n * Mirrors Postgres's `nullableTighteningCallStrategy` / `'data'`-class\n * gating. When `'data'` is not in the policy (the default `db update` /\n * `db init` path), the strategy short-circuits and the recreate alone\n * runs with its current destructive-class gating — preserving today's\n * behavior where a tightening blows up at runtime if NULLs are present.\n */\nexport const nullabilityTighteningBackfillStrategy: CallMigrationStrategy = (issues, ctx) => {\n if (!ctx.policy.allowedOperationClasses.includes('data')) {\n return { kind: 'no_match' };\n }\n\n const calls: SqliteOpFactoryCall[] = [];\n for (const issue of issues) {\n if (issue.kind !== 'nullability_mismatch') continue;\n if (!issue.table || !issue.column) continue;\n // Tightening only: `expected === 'true'` means the contract wants the\n // column nullable (relaxing from NOT NULL → nullable), which is safe and\n // needs no backfill.\n if (issue.expected === 'true') continue;\n\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column || column.nullable === true) continue;\n\n calls.push(\n new DataTransformCall(\n `data_migration.backfill-${issue.table}-${issue.column}`,\n `Backfill NULLs in \"${issue.table}\".\"${issue.column}\" before NOT NULL tightening`,\n issue.table,\n issue.column,\n ),\n );\n }\n\n if (calls.length === 0) return { kind: 'no_match' };\n\n return {\n kind: 'match',\n issues,\n calls,\n recipe: true,\n };\n};\n\nexport const sqlitePlannerStrategies: readonly CallMigrationStrategy[] = [\n nullabilityTighteningBackfillStrategy,\n recreateTableStrategy,\n];\n","/**\n * SQLite migration issue planner.\n *\n * Takes schema issues (from `verifySqlSchema`) and emits migration IR\n * (`SqliteOpFactoryCall[]`). Strategies consume issues they recognize and\n * produce specialized call sequences (e.g. recreateTableStrategy absorbs\n * type/nullability/default/constraint mismatches into a single recreate op);\n * remaining issues flow through `mapIssueToCall` for the default case.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlPlannerConflict,\n SqlPlannerConflictLocation,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type {\n SqlStorage,\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n type SqliteOpFactoryCall,\n} from './op-factory-call';\nimport type {\n SqliteColumnSpec,\n SqliteForeignKeySpec,\n SqliteTableSpec,\n SqliteUniqueSpec,\n} from './operations/shared';\nimport {\n buildColumnDefaultSql,\n buildColumnTypeSql,\n isInlineAutoincrementPrimaryKey,\n} from './planner-ddl-builders';\nimport {\n type CallMigrationStrategy,\n type StrategyContext,\n sqlitePlannerStrategies,\n} from './planner-strategies';\nimport { CONTROL_TABLE_NAMES } from './statement-builders';\n\nexport type { CallMigrationStrategy, StrategyContext };\n\n// ============================================================================\n// Issue kind ordering (dependency order)\n// ============================================================================\n\nconst ISSUE_KIND_ORDER: Record<string, number> = {\n // Drops (reconciliation — clear the way for creates)\n extra_foreign_key: 10,\n extra_unique_constraint: 11,\n extra_primary_key: 12,\n extra_index: 13,\n extra_default: 14,\n extra_column: 15,\n extra_table: 16,\n\n // Tables before columns\n missing_table: 20,\n\n // Columns before constraints\n missing_column: 30,\n\n // Reconciliation alters (on existing objects)\n type_mismatch: 40,\n nullability_mismatch: 41,\n default_missing: 42,\n default_mismatch: 43,\n\n // Constraints after columns exist\n primary_key_mismatch: 50,\n unique_constraint_mismatch: 51,\n index_mismatch: 52,\n foreign_key_mismatch: 60,\n};\n\nfunction issueOrder(issue: SchemaIssue): number {\n return ISSUE_KIND_ORDER[issue.kind] ?? 99;\n}\n\nfunction issueKey(issue: SchemaIssue): string {\n const table = 'table' in issue && typeof issue.table === 'string' ? issue.table : '';\n const column = 'column' in issue && typeof issue.column === 'string' ? issue.column : '';\n const name =\n 'indexOrConstraint' in issue && typeof issue.indexOrConstraint === 'string'\n ? issue.indexOrConstraint\n : '';\n return `${table}\\u0000${column}\\u0000${name}`;\n}\n\n// ============================================================================\n// Conflict helpers\n// ============================================================================\n\nfunction issueConflict(\n kind: SqlPlannerConflict['kind'],\n summary: string,\n location?: SqlPlannerConflict['location'],\n): SqlPlannerConflict {\n return {\n kind,\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction conflictKindForIssue(issue: SchemaIssue): SqlPlannerConflict['kind'] {\n switch (issue.kind) {\n case 'type_mismatch':\n return 'typeMismatch';\n case 'nullability_mismatch':\n return 'nullabilityConflict';\n case 'primary_key_mismatch':\n case 'unique_constraint_mismatch':\n case 'index_mismatch':\n case 'extra_primary_key':\n case 'extra_unique_constraint':\n return 'indexIncompatible';\n case 'foreign_key_mismatch':\n case 'extra_foreign_key':\n return 'foreignKeyConflict';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction issueLocation(issue: SchemaIssue): SqlPlannerConflictLocation | undefined {\n if (issue.kind === 'enum_values_changed') return undefined;\n const location: {\n table?: string;\n column?: string;\n constraint?: string;\n } = {};\n if (issue.table) location.table = issue.table;\n if (issue.column) location.column = issue.column;\n if (issue.indexOrConstraint) location.constraint = issue.indexOrConstraint;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n\nfunction conflictForDisallowedCall(\n call: SqliteOpFactoryCall,\n allowed: readonly string[],\n): SqlPlannerConflict {\n const summary = `Operation \"${call.label}\" requires class \"${call.operationClass}\", but policy allows only: ${allowed.join(', ')}`;\n const location = locationForCall(call);\n return {\n kind: conflictKindForCall(call),\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction conflictKindForCall(call: SqliteOpFactoryCall): SqlPlannerConflict['kind'] {\n switch (call.factoryName) {\n case 'createIndex':\n case 'dropIndex':\n return 'indexIncompatible';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction locationForCall(call: SqliteOpFactoryCall): SqlPlannerConflictLocation | undefined {\n const location: { table?: string; column?: string; index?: string } = {};\n if ('tableName' in call) location.table = call.tableName;\n if ('columnName' in call) location.column = call.columnName;\n if ('indexName' in call) location.index = call.indexName;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n\nfunction isMissing(issue: SchemaIssue): boolean {\n if (issue.kind === 'enum_values_changed') return false;\n return issue.actual === undefined;\n}\n\n// ============================================================================\n// StorageTable / StorageColumn → flat SqliteTableSpec\n// ============================================================================\n\n/**\n * Resolves codec / `typeRef` / default rendering into a flat\n * `SqliteColumnSpec`. Mirrors Postgres's `toColumnSpec`. Once a column is\n * flattened, downstream Calls and operation factories never see\n * `StorageColumn` again — they deal in pre-rendered SQL fragments.\n */\nexport function toColumnSpec(\n name: string,\n column: StorageColumn,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n inlineAutoincrementPrimaryKey = false,\n): SqliteColumnSpec {\n const typeSql = buildColumnTypeSql(column, storageTypes as Record<string, StorageTypeInstance>);\n const defaultSql = buildColumnDefaultSql(column.default);\n return {\n name,\n typeSql,\n defaultSql,\n nullable: column.nullable,\n ...(inlineAutoincrementPrimaryKey ? { inlineAutoincrementPrimaryKey: true } : {}),\n };\n}\n\n/**\n * Flattens a `StorageTable` into a `SqliteTableSpec` ready for\n * `CreateTableCall` / `RecreateTableCall`. Sole-column AUTOINCREMENT\n * primary keys are detected here and marked on the column spec so the\n * renderer emits `INTEGER PRIMARY KEY AUTOINCREMENT` inline.\n */\nexport function toTableSpec(\n table: StorageTable,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n): SqliteTableSpec {\n const columns: SqliteColumnSpec[] = Object.entries(table.columns).map(([name, column]) =>\n toColumnSpec(name, column, storageTypes, isInlineAutoincrementPrimaryKey(table, name)),\n );\n const uniques: SqliteUniqueSpec[] = table.uniques.map((u) => ({\n columns: u.columns,\n ...(u.name !== undefined ? { name: u.name } : {}),\n }));\n const foreignKeys: SqliteForeignKeySpec[] = table.foreignKeys.map((fk) => ({\n columns: fk.columns,\n references: { table: fk.references.table, columns: fk.references.columns },\n constraint: fk.constraint !== false,\n ...(fk.name !== undefined ? { name: fk.name } : {}),\n ...(fk.onDelete !== undefined ? { onDelete: fk.onDelete } : {}),\n ...(fk.onUpdate !== undefined ? { onUpdate: fk.onUpdate } : {}),\n }));\n return {\n columns,\n ...(table.primaryKey ? { primaryKey: { columns: table.primaryKey.columns } } : {}),\n uniques,\n foreignKeys,\n };\n}\n\n// ============================================================================\n// Issue planner\n// ============================================================================\n\nexport interface IssuePlannerOptions {\n readonly issues: readonly SchemaIssue[];\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema?: SqlSchemaIR;\n readonly policy?: MigrationOperationPolicy;\n readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n readonly strategies?: readonly CallMigrationStrategy[];\n}\n\nexport interface IssuePlannerValue {\n readonly calls: readonly SqliteOpFactoryCall[];\n}\n\nconst DEFAULT_POLICY: MigrationOperationPolicy = {\n allowedOperationClasses: ['additive', 'widening', 'destructive', 'data'],\n};\n\nfunction emptySchemaIR(): SqlSchemaIR {\n return { tables: {} };\n}\n\n// ============================================================================\n// Issue → Call mapping (per-issue default path)\n// ============================================================================\n\nfunction mapIssueToCall(\n issue: SchemaIssue,\n ctx: StrategyContext,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n switch (issue.kind) {\n case 'missing_table': {\n if (!issue.table) {\n return notOk(\n issueConflict('unsupportedOperation', 'Missing table issue has no table name'),\n );\n }\n const contractTable = ctx.toContract.storage.tables[issue.table];\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" reported missing but not found in destination contract`,\n ),\n );\n }\n const tableSpec = toTableSpec(contractTable, ctx.storageTypes);\n const calls: SqliteOpFactoryCall[] = [new CreateTableCall(issue.table, tableSpec)];\n const declaredIndexColumnKeys = new Set<string>();\n for (const index of contractTable.indexes) {\n const indexName = index.name ?? defaultIndexName(issue.table, index.columns);\n declaredIndexColumnKeys.add(index.columns.join(','));\n calls.push(new CreateIndexCall(issue.table, indexName, index.columns));\n }\n for (const fk of contractTable.foreignKeys) {\n if (fk.index === false) continue;\n if (declaredIndexColumnKeys.has(fk.columns.join(','))) continue;\n const indexName = defaultIndexName(issue.table, fk.columns);\n calls.push(new CreateIndexCall(issue.table, indexName, fk.columns));\n }\n return ok(calls);\n }\n\n case 'missing_column': {\n if (!issue.table || !issue.column) {\n return notOk(\n issueConflict('unsupportedOperation', 'Missing column issue has no table/column name'),\n );\n }\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n }\n const contractTable = ctx.toContract.storage.tables[issue.table];\n const columnSpec = toColumnSpec(\n issue.column,\n column,\n ctx.storageTypes,\n contractTable ? isInlineAutoincrementPrimaryKey(contractTable, issue.column) : false,\n );\n return ok([new AddColumnCall(issue.table, columnSpec)]);\n }\n\n case 'index_mismatch': {\n if (!issue.table) {\n return notOk(issueConflict('indexIncompatible', 'Index issue has no table name'));\n }\n if (!isMissing(issue) || !issue.expected) {\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Index on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n }\n const columns = issue.expected.split(', ');\n const contractTable = ctx.toContract.storage.tables[issue.table];\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" not found in destination contract`,\n ),\n );\n }\n // Use the explicit-index name if one is declared for these columns;\n // otherwise fall back to `defaultIndexName` (which is also what\n // `verifySqlSchema` synthesizes for FK-backing indexes). Whether the\n // missing index originates from `contractTable.indexes` or from an FK\n // with `index: true` doesn't change the emitted DDL.\n const explicitIndex = contractTable.indexes.find(\n (idx) => idx.columns.join(',') === columns.join(','),\n );\n const indexName = explicitIndex?.name ?? defaultIndexName(issue.table, columns);\n return ok([new CreateIndexCall(issue.table, indexName, columns)]);\n }\n\n case 'extra_table': {\n if (!issue.table) {\n return notOk(issueConflict('unsupportedOperation', 'Extra table issue has no table name'));\n }\n // Runner-owned control tables must never be dropped.\n if (CONTROL_TABLE_NAMES.has(issue.table)) return ok([]);\n return ok([new DropTableCall(issue.table)]);\n }\n\n case 'extra_column': {\n if (!issue.table || !issue.column) {\n return notOk(\n issueConflict('unsupportedOperation', 'Extra column issue has no table/column name'),\n );\n }\n return ok([new DropColumnCall(issue.table, issue.column)]);\n }\n\n case 'extra_index': {\n if (!issue.table || !issue.indexOrConstraint) {\n return notOk(\n issueConflict('unsupportedOperation', 'Extra index issue has no table/index name'),\n );\n }\n return ok([new DropIndexCall(issue.table, issue.indexOrConstraint)]);\n }\n\n // SQLite has no enum types (capability `sql.enums: false`). The verifier\n // should never emit `enum_values_changed` against a SQLite schema, so if\n // we receive one it is a verifier bug — surface it as an explicit\n // conflict rather than silently dropping it.\n case 'enum_values_changed':\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Received enum_values_changed against a SQLite schema (sql.enums: false) — verifier bug',\n ),\n );\n\n // Everything below is absorbed by recreateTableStrategy. If it falls\n // through here, policy or context didn't allow the recreate — surface as\n // a conflict.\n case 'type_mismatch':\n case 'nullability_mismatch':\n case 'default_mismatch':\n case 'default_missing':\n case 'extra_default':\n case 'primary_key_mismatch':\n case 'unique_constraint_mismatch':\n case 'foreign_key_mismatch':\n case 'extra_foreign_key':\n case 'extra_unique_constraint':\n case 'extra_primary_key':\n return notOk(issueConflict(conflictKindForIssue(issue), issue.message, issueLocation(issue)));\n\n default:\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Unhandled issue kind: ${(issue as SchemaIssue).kind}`,\n ),\n );\n }\n}\n\n// ============================================================================\n// Call categorization for final emission order\n// ============================================================================\n\ntype CallCategory =\n | 'drop-column'\n | 'drop-index'\n | 'drop-table'\n | 'create-table'\n | 'add-column'\n | 'create-index';\n\nfunction classifyCall(call: SqliteOpFactoryCall): CallCategory | null {\n switch (call.factoryName) {\n case 'createTable':\n return 'create-table';\n case 'addColumn':\n return 'add-column';\n case 'createIndex':\n return 'create-index';\n case 'dropColumn':\n return 'drop-column';\n case 'dropIndex':\n return 'drop-index';\n case 'dropTable':\n return 'drop-table';\n // recreateTable goes into the recipe slot; return null for bucketable.\n case 'recreateTable':\n return null;\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Top-level planIssues\n// ============================================================================\n\nexport function planIssues(\n options: IssuePlannerOptions,\n): Result<IssuePlannerValue, readonly SqlPlannerConflict[]> {\n const policyProvided = options.policy !== undefined;\n const policy = options.policy ?? DEFAULT_POLICY;\n const schema = options.schema ?? emptySchemaIR();\n const frameworkComponents = options.frameworkComponents ?? [];\n\n const context: StrategyContext = {\n toContract: options.toContract,\n fromContract: options.fromContract,\n codecHooks: options.codecHooks,\n storageTypes: options.storageTypes,\n schema,\n policy,\n frameworkComponents,\n };\n\n const strategies = options.strategies ?? sqlitePlannerStrategies;\n\n let remaining = options.issues;\n const recipeCalls: SqliteOpFactoryCall[] = [];\n const bucketableCalls: SqliteOpFactoryCall[] = [];\n\n for (const strategy of strategies) {\n const result = strategy(remaining, context);\n if (result.kind === 'match') {\n remaining = result.issues;\n if (result.recipe) {\n recipeCalls.push(...result.calls);\n } else {\n bucketableCalls.push(...result.calls);\n }\n }\n }\n\n const sorted = [...remaining].sort((a, b) => {\n const kindDelta = issueOrder(a) - issueOrder(b);\n if (kindDelta !== 0) return kindDelta;\n const keyA = issueKey(a);\n const keyB = issueKey(b);\n return keyA < keyB ? -1 : keyA > keyB ? 1 : 0;\n });\n\n const defaultCalls: SqliteOpFactoryCall[] = [];\n const conflicts: SqlPlannerConflict[] = [];\n\n for (const issue of sorted) {\n const result = mapIssueToCall(issue, context);\n if (result.ok) {\n defaultCalls.push(...result.value);\n } else {\n conflicts.push(result.failure);\n }\n }\n\n // Policy gating for recipe + bucketable. Default-mapped calls for disallowed\n // classes never get here (they're surfaced as per-issue conflicts above).\n const allowed = policy.allowedOperationClasses;\n let gatedRecipe = recipeCalls;\n let gatedBucketable = bucketableCalls;\n let gatedDefault = defaultCalls;\n if (policyProvided) {\n const sink = (acc: SqliteOpFactoryCall[]) => (call: SqliteOpFactoryCall) => {\n if (allowed.includes(call.operationClass)) {\n acc.push(call);\n return;\n }\n conflicts.push(conflictForDisallowedCall(call, allowed));\n };\n const gatedRecipeBucket: SqliteOpFactoryCall[] = [];\n const gatedBucketableBucket: SqliteOpFactoryCall[] = [];\n const gatedDefaultBucket: SqliteOpFactoryCall[] = [];\n recipeCalls.forEach(sink(gatedRecipeBucket));\n bucketableCalls.forEach(sink(gatedBucketableBucket));\n defaultCalls.forEach(sink(gatedDefaultBucket));\n gatedRecipe = gatedRecipeBucket;\n gatedBucketable = gatedBucketableBucket;\n gatedDefault = gatedDefaultBucket;\n }\n\n if (conflicts.length > 0) {\n return notOk(conflicts);\n }\n\n // Final emission order matches the current monolithic planner:\n // create-table → add-column → create-index → recreate → drop-column → drop-index → drop-table\n const combined = [...gatedDefault, ...gatedBucketable];\n const byCategory = (cat: CallCategory) => combined.filter((c) => classifyCall(c) === cat);\n\n const calls: SqliteOpFactoryCall[] = [\n ...byCategory('create-table'),\n ...byCategory('add-column'),\n ...byCategory('create-index'),\n ...gatedRecipe,\n ...byCategory('drop-column'),\n ...byCategory('drop-index'),\n ...byCategory('drop-table'),\n ];\n\n return ok({ calls });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlanner,\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 MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport { planIssues } from './issue-planner';\nimport {\n type SqliteMigrationDestinationInfo,\n TypeScriptRenderableSqliteMigration,\n} from './planner-produced-sqlite-migration';\nimport { sqlitePlannerStrategies } from './planner-strategies';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\nexport function createSqliteMigrationPlanner(): SqliteMigrationPlanner {\n return new SqliteMigrationPlanner();\n}\n\nexport type SqlitePlanResult =\n | { readonly kind: 'success'; readonly plan: TypeScriptRenderableSqliteMigration }\n | SqlPlannerFailureResult;\n\n/**\n * SQLite 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 registered\n * strategies. Strategies absorb groups of related issues into composite\n * recipes (e.g. recreating a table to apply type/nullability/default/\n * constraint changes at once); anything not absorbed by a strategy flows\n * through `mapIssueToCall` in the issue planner as a one-off call.\n *\n * FK-backing indexes are surfaced by `verifySqlSchema`'s index expansion\n * (see `verify-sql-schema.ts:459-469`), so `mapIssueToCall` handles them\n * uniformly alongside user-declared indexes.\n */\nexport class SqliteMigrationPlanner\n implements SqlMigrationPlanner<SqlitePlanTargetDetails>, MigrationPlanner<'sql', 'sqlite'>\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 at),\n * or `null` for reconciliation flows.\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 frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n /**\n * Contract space this plan applies to. Stamped onto the produced\n * {@link TypeScriptRenderableSqliteMigration.spaceId} so the runner keys\n * the marker row by the right space.\n */\n readonly spaceId: string;\n }): SqlitePlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): TypeScriptRenderableSqliteMigration {\n return new TypeScriptRenderableSqliteMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): SqlitePlanResult {\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) return policyResult;\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: options.fromContract,\n codecHooks,\n storageTypes,\n schema: options.schema,\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: sqlitePlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n // Codec lifecycle hook (T2.2): inline `onFieldEvent`-emitted ops after\n // structural DDL. Sub-spec § 5 fixes the ordering as\n // `structural → added → dropped → altered`, with within-group sorting by\n // `(tableName, fieldName)` deterministic for byte-stable re-emits.\n // Hook fires only at the application emitter — extension-space planning\n // (M2 R2) 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 const destination: SqliteMigrationDestinationInfo = {\n storageHash: options.contract.storage.storageHash,\n ...(options.contract.profileHash !== undefined\n ? { profileHash: options.contract.profileHash }\n : {}),\n };\n\n return {\n kind: 'success' as const,\n plan: new TypeScriptRenderableSqliteMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n destination,\n ),\n };\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy): SqlPlannerFailureResult | null {\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: SqlMigrationPlannerPlanOptions): readonly SchemaIssue[] {\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyResult = verifySqlSchema({\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n return verifyResult.schema.issues;\n }\n}\n"],"mappings":";;;;;;;;;;;AAyDA,MAAM,uBAAuB,IAAI,IAAyB,CAAC,oBAAoB,kBAAkB,CAAC;AAElG,MAAM,0BAA0B,IAAI,IAAyB;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,cAAc,OAAuD;CAC5E,IAAI,MAAM,SAAS,uBAAuB,OAAO;CACjD,IAAI,CAAC,MAAM,OAAO,OAAO;CACzB,IAAI,MAAM,SAAS,wBAEjB,OAAO,MAAM,aAAa,SAAS,aAAa;CAElD,IAAI,qBAAqB,IAAI,MAAM,KAAK,EAAE,OAAO;CACjD,IAAI,wBAAwB,IAAI,MAAM,KAAK,EAAE,OAAO;CACpD,OAAO;;;;;;;;AAST,MAAa,yBAAgD,QAAQ,QAAQ;CAC3E,MAAM,0BAAU,IAAI,KAAiE;CACrF,MAAM,2BAAW,IAAI,KAAkB;CAEvC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,MAAM,cAAc,MAAM;EAChC,IAAI,CAAC,KAAK;EACV,IAAI,MAAM,SAAS,uBAAuB;EAC1C,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,QAAQ,MAAM;EACpB,MAAM,QA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a,QAAQ;GACrB;GACD,CAAC;EAIF,MAAM,QAAQ,CAAC,GAAG,OAAO,MAAM,OAAO,GAAG,cAAc;EAEvD,MAAM,cAA8C;GAClD,aAAa,QAAQ,SAAS,QAAQ;GACtC,GAAI,QAAQ,SAAS,gBAAgB,KAAA,IACjC,EAAE,aAAa,QAAQ,SAAS,aAAa,GAC7C,EAAE;GACP;EAED,OAAO;GACL,MAAM;GACN,MAAM,IAAI,oCACR,OACA;IACE,MAAM,QAAQ,cAAc,QAAQ,eAAe;IACnD,IAAI,QAAQ,SAAS,QAAQ;IAC9B,EACD,QAAQ,SACR,YACD;GACF;;CAGH,qBAA6B,QAAkE;EAC7F,IAAI,CAAC,OAAO,wBAAwB,SAAS,WAAW,EACtD,OAAO,eAAe,CACpB;GACE,MAAM;GACN,SAAS;GACT,KAAK;GACN,CACF,CAAC;EAEJ,OAAO;;CAGT,oBAA4B,SAAiE;EAC3F,MAAM,UAAU,QAAQ,OAAO;EAC/B,MAAM,SAAS,QAAQ,SAAS,WAAW,IAAI,QAAQ,SAAS,cAAc;EAU9E,OATqB,gBAAgB;GACnC,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,KAAK;GAC/B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;GACtB,CACkB,CAAC,OAAO"}
@@ -0,0 +1,29 @@
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
+ import { t as SqliteMigration } from "./sqlite-migration-DAb2NEX6.mjs";
3
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
4
+ import { MigrationPlanWithAuthoringSurface, OpFactoryCall } from "@prisma-next/framework-components/control";
5
+ import { MigrationMeta } from "@prisma-next/migration-tools/migration";
6
+
7
+ //#region src/core/migrations/planner-produced-sqlite-migration.d.ts
8
+ type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
9
+ interface SqliteMigrationDestinationInfo {
10
+ readonly storageHash: string;
11
+ readonly profileHash?: string;
12
+ }
13
+ declare class TypeScriptRenderableSqliteMigration extends SqliteMigration implements MigrationPlanWithAuthoringSurface {
14
+ #private;
15
+ constructor(calls: readonly OpFactoryCall[], meta: MigrationMeta, spaceId: string, destination?: SqliteMigrationDestinationInfo);
16
+ get operations(): readonly Op[];
17
+ describe(): MigrationMeta;
18
+ get destination(): SqliteMigrationDestinationInfo;
19
+ /**
20
+ * Contract space this planner-produced plan applies to. Threaded
21
+ * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner
22
+ * keys the marker row by the right space when executing the plan.
23
+ */
24
+ get spaceId(): string;
25
+ renderTypeScript(): string;
26
+ }
27
+ //#endregion
28
+ export { TypeScriptRenderableSqliteMigration as n, SqliteMigrationDestinationInfo as t };
29
+ //# sourceMappingURL=planner-produced-sqlite-migration-CI9LdXPr.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-produced-sqlite-migration-CI9LdXPr.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-sqlite-migration.ts"],"mappings":";;;;;;;KAYK,EAAA,GAAK,yBAAA,CAA0B,uBAAA;AAAA,UAEnB,8BAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA;AAAA;AAAA,cAGE,mCAAA,SACH,eAAA,YACG,iCAAA;EAAA;cAQT,KAAA,WAAgB,aAAA,IAChB,IAAA,EAAM,aAAA,EACN,OAAA,UACA,WAAA,GAAc,8BAAA;EAAA,IASH,UAAA,CAAA,YAAuB,EAAA;EAI3B,QAAA,CAAA,GAAY,aAAA;EAAA,IAIR,WAAA,CAAA,GAAe,8BAAA;EAjCR;AAGtB;;;;EAHsB,IA0ChB,OAAA,CAAA;EAIJ,gBAAA,CAAA;AAAA"}
@@ -0,0 +1,110 @@
1
+ import { t as renderOps } from "./render-ops-CSRDT4YL.mjs";
2
+ import { t as SqliteMigration } from "./sqlite-migration-BBJktVVw.mjs";
3
+ import { jsonToTsSource, renderImports } from "@prisma-next/ts-render";
4
+ import { ifDefined } from "@prisma-next/utils/defined";
5
+ import { detectScaffoldRuntime, shebangLineFor } from "@prisma-next/migration-tools/migration-ts";
6
+ //#region src/core/migrations/render-typescript.ts
7
+ /**
8
+ * Always-present base imports for the rendered scaffold. Both come from
9
+ * `@prisma-next/target-sqlite/migration` so an authored SQLite
10
+ * `migration.ts` only needs a single dependency for its base class and
11
+ * its CLI entrypoint. Mirrors Postgres's `BASE_IMPORTS`.
12
+ *
13
+ * - `Migration` — the target-owned re-export fixes the `SqlMigration`
14
+ * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to
15
+ * `'sqlite'`.
16
+ * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from
17
+ * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,
18
+ * assembles a `ControlStack`, and instantiates the migration class.
19
+ */
20
+ const BASE_IMPORTS = [{
21
+ moduleSpecifier: "@prisma-next/target-sqlite/migration",
22
+ symbol: "Migration"
23
+ }, {
24
+ moduleSpecifier: "@prisma-next/target-sqlite/migration",
25
+ symbol: "MigrationCLI"
26
+ }];
27
+ function renderCallsToTypeScript(calls, meta) {
28
+ const imports = buildImports(calls);
29
+ const operationsBody = calls.map((c) => c.renderTypeScript()).join(",\n");
30
+ return [
31
+ shebangLineFor(detectScaffoldRuntime()),
32
+ imports,
33
+ "",
34
+ "export default class M extends Migration {",
35
+ buildDescribeMethod(meta),
36
+ " override get operations() {",
37
+ " return [",
38
+ indent(operationsBody, 6),
39
+ " ];",
40
+ " }",
41
+ "}",
42
+ "",
43
+ "MigrationCLI.run(import.meta.url, M);",
44
+ ""
45
+ ].join("\n");
46
+ }
47
+ function buildImports(calls) {
48
+ const requirements = [...BASE_IMPORTS];
49
+ for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
50
+ return renderImports(requirements);
51
+ }
52
+ function buildDescribeMethod(meta) {
53
+ const lines = [];
54
+ lines.push(" override describe() {");
55
+ lines.push(" return {");
56
+ lines.push(` from: ${JSON.stringify(meta.from)},`);
57
+ lines.push(` to: ${JSON.stringify(meta.to)},`);
58
+ if (meta.labels && meta.labels.length > 0) lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
59
+ lines.push(" };");
60
+ lines.push(" }");
61
+ lines.push("");
62
+ return lines.join("\n");
63
+ }
64
+ function indent(text, spaces) {
65
+ const pad = " ".repeat(spaces);
66
+ return text.split("\n").map((line) => line.trim() ? `${pad}${line}` : line).join("\n");
67
+ }
68
+ //#endregion
69
+ //#region src/core/migrations/planner-produced-sqlite-migration.ts
70
+ var TypeScriptRenderableSqliteMigration = class extends SqliteMigration {
71
+ #calls;
72
+ #meta;
73
+ #destination;
74
+ #spaceId;
75
+ constructor(calls, meta, spaceId, destination) {
76
+ super();
77
+ this.#calls = calls;
78
+ this.#meta = meta;
79
+ this.#spaceId = spaceId;
80
+ this.#destination = destination ?? { storageHash: meta.to };
81
+ }
82
+ get operations() {
83
+ return renderOps(this.#calls);
84
+ }
85
+ describe() {
86
+ return this.#meta;
87
+ }
88
+ get destination() {
89
+ return this.#destination;
90
+ }
91
+ /**
92
+ * Contract space this planner-produced plan applies to. Threaded
93
+ * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner
94
+ * keys the marker row by the right space when executing the plan.
95
+ */
96
+ get spaceId() {
97
+ return this.#spaceId;
98
+ }
99
+ renderTypeScript() {
100
+ return renderCallsToTypeScript(this.#calls, {
101
+ from: this.#meta.from,
102
+ to: this.#meta.to,
103
+ ...ifDefined("labels", this.#meta.labels)
104
+ });
105
+ }
106
+ };
107
+ //#endregion
108
+ export { TypeScriptRenderableSqliteMigration as t };
109
+
110
+ //# sourceMappingURL=planner-produced-sqlite-migration-C_TzWbT0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-produced-sqlite-migration-C_TzWbT0.mjs","names":["#calls","#meta","#destination","#spaceId"],"sources":["../src/core/migrations/render-typescript.ts","../src/core/migrations/planner-produced-sqlite-migration.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the SQLite migration IR. Mirrors the\n * Postgres `render-typescript.ts` — different base-class + factory module\n * specifier, same overall shape.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\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-sqlite/migration` so an authored SQLite\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint. Mirrors Postgres's `BASE_IMPORTS`.\n *\n * - `Migration` — the target-owned re-export fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to\n * `'sqlite'`.\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 */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/target-sqlite/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/target-sqlite/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n 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","import 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 { SqlitePlanTargetDetails } from './planner-target-details';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\nimport { SqliteMigration } from './sqlite-migration';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport interface SqliteMigrationDestinationInfo {\n readonly storageHash: string;\n readonly profileHash?: string;\n}\n\nexport class TypeScriptRenderableSqliteMigration\n extends SqliteMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #destination: SqliteMigrationDestinationInfo;\n readonly #spaceId: string;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n destination?: SqliteMigrationDestinationInfo,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#destination = destination ?? { storageHash: meta.to };\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 override get destination(): SqliteMigrationDestinationInfo {\n return this.#destination;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner\n * keys the marker row by 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":";;;;;;;;;;;;;;;;;;;AA6BA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAwC,QAAQ;CAAa,EAChF;CAAE,iBAAiB;CAAwC,QAAQ;CAAgB,CACpF;AAED,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,MAAM;CACnC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,kBAAkB,CAAC,CAAC,KAAK,MAAM;CAEzE,OAAO;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,OAA6C;CACjE,MAAM,eAAoC,CAAC,GAAG,aAAa;CAC3D,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,oBAAoB,EACzC,aAAa,KAAK,IAAI;CAG1B,OAAO,cAAc,aAAa;;AAGpC,SAAS,oBAAoB,MAAmC;CAC9D,MAAM,QAAkB,EAAE;CAC1B,MAAM,KAAK,0BAA0B;CACrC,MAAM,KAAK,eAAe;CAC1B,MAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;CACvD,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,GAAG,CAAC,GAAG;CACnD,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,GACtC,MAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO,CAAC,GAAG;CAE7D,MAAM,KAAK,SAAS;CACpB,MAAM,KAAK,MAAM;CACjB,MAAM,KAAK,GAAG;CACd,OAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,OAAO;CAC9B,OAAO,KACJ,MAAM,KAAK,CACX,KAAK,SAAU,KAAK,MAAM,GAAG,GAAG,MAAM,SAAS,KAAM,CACrD,KAAK,KAAK;;;;ACtEf,IAAa,sCAAb,cACU,gBAEV;CACE;CACA;CACA;CACA;CAEA,YACE,OACA,MACA,SACA,aACA;EACA,OAAO;EACP,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKE,WAAW;EAChB,KAAKD,eAAe,eAAe,EAAE,aAAa,KAAK,IAAI;;CAG7D,IAAa,aAA4B;EACvC,OAAO,UAAU,KAAKF,OAAO;;CAG/B,WAAmC;EACjC,OAAO,KAAKC;;CAGd,IAAa,cAA8C;EACzD,OAAO,KAAKC;;;;;;;CAQd,IAAI,UAAkB;EACpB,OAAO,KAAKC;;CAGd,mBAA2B;EACzB,OAAO,wBAAwB,KAAKH,QAAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,GAAG,UAAU,UAAU,KAAKA,MAAM,OAAO;GAC1C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-CI9LdXPr.mjs";
2
+ export { type SqliteMigrationDestinationInfo, TypeScriptRenderableSqliteMigration };
@@ -0,0 +1,2 @@
1
+ import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-C_TzWbT0.mjs";
2
+ export { TypeScriptRenderableSqliteMigration };
@@ -0,0 +1,15 @@
1
+ import { ifDefined } from "@prisma-next/utils/defined";
2
+ //#region src/core/migrations/planner-target-details.ts
3
+ const DEFAULT_SCHEMA = "main";
4
+ function buildTargetDetails(objectType, name, table) {
5
+ return {
6
+ schema: DEFAULT_SCHEMA,
7
+ objectType,
8
+ name,
9
+ ...ifDefined("table", table)
10
+ };
11
+ }
12
+ //#endregion
13
+ export { buildTargetDetails as t };
14
+
15
+ //# sourceMappingURL=planner-target-details-Bm71XPKb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-target-details-Bm71XPKb.mjs","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\n\nexport type OperationClass = 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey';\n\n// SQLite's default (and only) schema name; keeps `SqlitePlanTargetDetails`\n// conformant with `SqlPlanTargetDetails`, which mandates a `schema` field.\nconst DEFAULT_SCHEMA = 'main';\n\nexport interface SqlitePlanTargetDetails {\n readonly schema: string;\n readonly objectType: OperationClass;\n readonly name: string;\n readonly table?: string;\n}\n\nexport interface PlanningMode {\n readonly includeExtraObjects: boolean;\n readonly allowWidening: boolean;\n readonly allowDestructive: boolean;\n}\n\nexport function buildTargetDetails(\n objectType: OperationClass,\n name: string,\n table?: string,\n): SqlitePlanTargetDetails {\n return {\n schema: DEFAULT_SCHEMA,\n objectType,\n name,\n ...ifDefined('table', table),\n };\n}\n"],"mappings":";;AAMA,MAAM,iBAAiB;AAevB,SAAgB,mBACd,YACA,MACA,OACyB;CACzB,OAAO;EACL,QAAQ;EACR;EACA;EACA,GAAG,UAAU,SAAS,MAAM;EAC7B"}
@@ -0,0 +1,12 @@
1
+ //#region src/core/migrations/planner-target-details.d.ts
2
+ type OperationClass = 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey';
3
+ interface SqlitePlanTargetDetails {
4
+ readonly schema: string;
5
+ readonly objectType: OperationClass;
6
+ readonly name: string;
7
+ readonly table?: string;
8
+ }
9
+ declare function buildTargetDetails(objectType: OperationClass, name: string, table?: string): SqlitePlanTargetDetails;
10
+ //#endregion
11
+ export { buildTargetDetails as n, SqlitePlanTargetDetails as t };
12
+ //# sourceMappingURL=planner-target-details-vhvZDWK1.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-target-details-vhvZDWK1.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAMK,uBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAA;EAAA,SACZ,IAAA;EAAA,SACA,KAAA;AAAA;AAAA,iBASK,kBAAA,CACd,UAAA,EAAY,cAAA,EACZ,IAAA,UACA,KAAA,YACC,uBAAA"}
@@ -0,0 +1,2 @@
1
+ import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
+ export { type SqlitePlanTargetDetails, buildTargetDetails };
@@ -0,0 +1,2 @@
1
+ import { t as buildTargetDetails } from "./planner-target-details-Bm71XPKb.mjs";
2
+ export { buildTargetDetails };
@@ -0,0 +1,59 @@
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
+ import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-CI9LdXPr.mjs";
3
+ import { MigrationOperationPolicy, SqlMigrationPlanner, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
4
+ import { MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
5
+ import { Contract } from "@prisma-next/contract/types";
6
+ import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
7
+
8
+ //#region src/core/migrations/planner.d.ts
9
+ declare function createSqliteMigrationPlanner(): SqliteMigrationPlanner;
10
+ type SqlitePlanResult = {
11
+ readonly kind: 'success';
12
+ readonly plan: TypeScriptRenderableSqliteMigration;
13
+ } | SqlPlannerFailureResult;
14
+ /**
15
+ * SQLite migration planner — a thin wrapper over `planIssues`.
16
+ *
17
+ * `plan()` verifies the live schema against the target contract (producing
18
+ * `SchemaIssue[]`) and delegates to `planIssues` with the registered
19
+ * strategies. Strategies absorb groups of related issues into composite
20
+ * recipes (e.g. recreating a table to apply type/nullability/default/
21
+ * constraint changes at once); anything not absorbed by a strategy flows
22
+ * through `mapIssueToCall` in the issue planner as a one-off call.
23
+ *
24
+ * FK-backing indexes are surfaced by `verifySqlSchema`'s index expansion
25
+ * (see `verify-sql-schema.ts:459-469`), so `mapIssueToCall` handles them
26
+ * uniformly alongside user-declared indexes.
27
+ */
28
+ declare class SqliteMigrationPlanner implements SqlMigrationPlanner<SqlitePlanTargetDetails>, MigrationPlanner<'sql', 'sqlite'> {
29
+ plan(options: {
30
+ readonly contract: unknown;
31
+ readonly schema: unknown;
32
+ readonly policy: MigrationOperationPolicy;
33
+ /**
34
+ * The "from" contract (state the planner assumes the database starts at),
35
+ * or `null` for reconciliation flows.
36
+ *
37
+ * Typed as the framework `Contract | null` to satisfy the
38
+ * `MigrationPlanner` interface contract; `planSql` narrows to the SQL
39
+ * shape via `SqlMigrationPlannerPlanOptions`. Used to populate
40
+ * `describe().from` on the produced plan as
41
+ * `fromContract?.storage.storageHash ?? null`.
42
+ */
43
+ readonly fromContract: Contract | null;
44
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
45
+ /**
46
+ * Contract space this plan applies to. Stamped onto the produced
47
+ * {@link TypeScriptRenderableSqliteMigration.spaceId} so the runner keys
48
+ * the marker row by the right space.
49
+ */
50
+ readonly spaceId: string;
51
+ }): SqlitePlanResult;
52
+ emptyMigration(context: MigrationScaffoldContext, spaceId: string): TypeScriptRenderableSqliteMigration;
53
+ private planSql;
54
+ private ensureAdditivePolicy;
55
+ private collectSchemaIssues;
56
+ }
57
+ //#endregion
58
+ export { SqliteMigrationPlanner, type SqlitePlanResult, createSqliteMigrationPlanner };
59
+ //# sourceMappingURL=planner.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;iBA6BgB,4BAAA,CAAA,GAAgC,sBAAA;AAAA,KAIpC,gBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,IAAA,EAAM,mCAAA;AAAA,IAC3C,uBAAA;;;AAFJ;;;;;;;;;;AAkBA;;cAAa,sBAAA,YACA,mBAAA,CAAoB,uBAAA,GAA0B,gBAAA;EAEzD,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IAYa;;;;;;;;;;IAAA,SADrB,YAAA,EAAc,QAAA;IAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAdnC;;;;;IAAA,SAoBA,OAAA;EAAA,IACP,gBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,mCAAA;EAAA,QAWK,OAAA;EAAA,QA6DA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-A7dqS0u6.mjs";
2
+ export { SqliteMigrationPlanner, createSqliteMigrationPlanner };
@@ -0,0 +1,8 @@
1
+ //#region src/core/migrations/render-ops.ts
2
+ function renderOps(calls) {
3
+ return calls.map((c) => c.toOp());
4
+ }
5
+ //#endregion
6
+ export { renderOps as t };
7
+
8
+ //# sourceMappingURL=render-ops-CSRDT4YL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ops-CSRDT4YL.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport function renderOps(calls: readonly OpFactoryCall[]): Op[] {\n // Each call's `toOp()` is typed as the framework `MigrationPlanOperation`;\n // every concrete Call class on the sqlite planner path produces an op\n // whose `target.details` is `SqlitePlanTargetDetails`-shaped (or whose\n // `target.details` is absent, which is structurally compatible). The\n // narrowing cast happens at this single integration boundary instead of\n // poisoning every caller's type.\n return calls.map((c) => c.toOp() as Op);\n}\n"],"mappings":";AAMA,SAAgB,UAAU,OAAuC;CAO/D,OAAO,MAAM,KAAK,MAAM,EAAE,MAAM,CAAO"}
@@ -0,0 +1,10 @@
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
+ import { OpFactoryCall } from "@prisma-next/framework-components/control";
4
+
5
+ //#region src/core/migrations/render-ops.d.ts
6
+ type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
7
+ declare function renderOps(calls: readonly OpFactoryCall[]): Op[];
8
+ //#endregion
9
+ export { renderOps };
10
+ //# sourceMappingURL=render-ops.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;KAIK,EAAA,GAAK,yBAAA,CAA0B,uBAAA;AAAA,iBAEpB,SAAA,CAAU,KAAA,WAAgB,aAAA,KAAkB,EAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as renderOps } from "./render-ops-CSRDT4YL.mjs";
2
+ export { renderOps };
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,2BAAA,SAAoC;AAArD,cAEM,6BAFuC,EAER,0BAFqC,CAAA,QAAA,EAIxE,2BAJwE,CAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts"],"mappings":";;;;UAIiB,2BAAA,SAAoC,qBAAA;AAAA,cAE/C,6BAAA,EAA+B,0BAAA,WAEnC,2BAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,11 +1,8 @@
1
- import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-DbuuziYA.mjs";
2
- import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
3
-
1
+ import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-CE2Kbn9b.mjs";
4
2
  //#region src/core/runtime-target.ts
5
3
  const sqliteRuntimeTargetDescriptor = {
6
4
  ...sqliteTargetDescriptorMeta,
7
- codecs: () => createCodecRegistry(),
8
- parameterizedCodecs: () => [],
5
+ codecs: () => [],
9
6
  create() {
10
7
  return {
11
8
  familyId: "sql",
@@ -13,8 +10,7 @@ const sqliteRuntimeTargetDescriptor = {
13
10
  };
14
11
  }
15
12
  };
16
- var runtime_target_default = sqliteRuntimeTargetDescriptor;
17
-
18
13
  //#endregion
19
- export { runtime_target_default as default };
14
+ export { sqliteRuntimeTargetDescriptor as default };
15
+
20
16
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":["sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n>"],"sources":["../src/core/runtime-target.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\n\nexport interface SqliteRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'sqlite'> {}\n\nconst sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n> = {\n ...sqliteTargetDescriptorMeta,\n codecs: () => createCodecRegistry(),\n parameterizedCodecs: () => [],\n create(): SqliteRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n};\n\nexport default sqliteRuntimeTargetDescriptor;\n"],"mappings":";;;;AAOA,MAAMA,gCAGF;CACF,GAAG;CACH,cAAc,qBAAqB;CACnC,2BAA2B,EAAE;CAC7B,SAAsC;AACpC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,6BAAe"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/core/runtime-target.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\n\nexport interface SqliteRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'sqlite'> {}\n\nconst sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n> = {\n ...sqliteTargetDescriptorMeta,\n codecs: () => [],\n create(): SqliteRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n};\n\nexport default sqliteRuntimeTargetDescriptor;\n"],"mappings":";;AAMA,MAAM,gCAGF;CACF,GAAG;CACH,cAAc,EAAE;CAChB,SAAsC;EACpC,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
@@ -0,0 +1,69 @@
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
+ import { ReferentialAction } from "@prisma-next/sql-contract/types";
4
+
5
+ //#region src/core/migrations/operations/shared.d.ts
6
+ type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
7
+ /**
8
+ * Flat, fully-resolved column shape consumed by `createTable`, `addColumn`,
9
+ * and `recreateTable`. Codec / `typeRef` / default expansion happens at the
10
+ * call-construction site (in the issue-planner / strategies) so the
11
+ * operation factories deal only in pre-rendered SQL fragments — mirrors the
12
+ * Postgres `ColumnSpec` pattern.
13
+ *
14
+ * - `typeSql` is the column's DDL type token (e.g. `"INTEGER"`, `"TEXT"`).
15
+ * - `defaultSql` is the full `DEFAULT …` clause (or empty when there is no
16
+ * default and when the column is rendered as `INTEGER PRIMARY KEY
17
+ * AUTOINCREMENT`, since SQLite forbids a default on an autoincrement PK).
18
+ * - `inlineAutoincrementPrimaryKey` directs the renderer to emit
19
+ * `INTEGER PRIMARY KEY AUTOINCREMENT` inline and to skip the table-level
20
+ * primary-key constraint for this column. SQLite-specific: the column
21
+ * becomes an alias for `rowid` only when this exact form is used.
22
+ */
23
+ interface SqliteColumnSpec {
24
+ readonly name: string;
25
+ readonly typeSql: string;
26
+ readonly defaultSql: string;
27
+ readonly nullable: boolean;
28
+ readonly inlineAutoincrementPrimaryKey?: boolean;
29
+ }
30
+ interface SqlitePrimaryKeySpec {
31
+ readonly columns: readonly string[];
32
+ }
33
+ interface SqliteUniqueSpec {
34
+ readonly columns: readonly string[];
35
+ readonly name?: string;
36
+ }
37
+ interface SqliteForeignKeySpec {
38
+ readonly columns: readonly string[];
39
+ readonly references: {
40
+ readonly table: string;
41
+ readonly columns: readonly string[];
42
+ };
43
+ readonly name?: string;
44
+ readonly onDelete?: ReferentialAction;
45
+ readonly onUpdate?: ReferentialAction;
46
+ readonly constraint: boolean;
47
+ }
48
+ /**
49
+ * Flat shape of a contract table for DDL emission. Used by both
50
+ * `createTable` (additive) and `recreateTable` (widening/destructive).
51
+ */
52
+ interface SqliteTableSpec {
53
+ readonly columns: readonly SqliteColumnSpec[];
54
+ readonly primaryKey?: SqlitePrimaryKeySpec;
55
+ readonly uniques?: readonly SqliteUniqueSpec[];
56
+ readonly foreignKeys?: readonly SqliteForeignKeySpec[];
57
+ }
58
+ /**
59
+ * Index recreation spec for `recreateTable`. Both declared indexes and
60
+ * FK-backing indexes flatten to the same shape; the planner dedupes by
61
+ * column-set before constructing the call.
62
+ */
63
+ interface SqliteIndexSpec {
64
+ readonly name: string;
65
+ readonly columns: readonly string[];
66
+ }
67
+ //#endregion
68
+ export { SqliteTableSpec as i, SqliteColumnSpec as n, SqliteIndexSpec as r, Op as t };
69
+ //# sourceMappingURL=shared-qLsgTOZs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-qLsgTOZs.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAKY,EAAA,GAAK,yBAAA,CAA0B,uBAAA;;;AAsB3C;;;;;;;;;;;AAQA;;;UARiB,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;EAAA,SACA,6BAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAA;AAAA;AAAA,UAGM,gBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA;IAAA,SACE,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;EAAA,SACX,UAAA;AAAA;;;;;UAOM,eAAA;EAAA,SACN,OAAA,WAAkB,gBAAA;EAAA,SAClB,UAAA,GAAa,oBAAA;EAAA,SACb,OAAA,YAAmB,gBAAA;EAAA,SACnB,WAAA,YAAuB,oBAAA;AAAA;;;;;;UAQjB,eAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;AAAA"}
@@ -0,0 +1,35 @@
1
+ //#region src/core/sql-utils.ts
2
+ /**
3
+ * Shared SQL utility functions for the SQLite target.
4
+ *
5
+ * These functions handle safe SQL identifier and literal escaping. They
6
+ * live in `target-sqlite` (mirroring `target-postgres/src/core/sql-utils.ts`)
7
+ * so both the control adapter (used at emit time) and the runtime adapter
8
+ * (used at execute time) can depend on them through a single one-way edge:
9
+ * `adapter-sqlite → target-sqlite`. Hosting them target-side avoids the
10
+ * cyclic workspace dependency that would arise if `target-sqlite` reached
11
+ * back into `adapter-sqlite` for these primitives.
12
+ */
13
+ var SqlEscapeError = class extends Error {
14
+ value;
15
+ kind;
16
+ constructor(message, value, kind) {
17
+ super(message);
18
+ this.value = value;
19
+ this.kind = kind;
20
+ this.name = "SqlEscapeError";
21
+ }
22
+ };
23
+ function quoteIdentifier(identifier) {
24
+ if (identifier.length === 0) throw new SqlEscapeError("Identifier cannot be empty", identifier, "identifier");
25
+ if (identifier.includes("\0")) throw new SqlEscapeError("Identifier cannot contain null bytes", identifier.replace(/\0/g, "\\0"), "identifier");
26
+ return `"${identifier.replace(/"/g, "\"\"")}"`;
27
+ }
28
+ function escapeLiteral(value) {
29
+ if (value.includes("\0")) throw new SqlEscapeError("Literal value cannot contain null bytes", value.replace(/\0/g, "\\0"), "literal");
30
+ return value.replace(/'/g, "''");
31
+ }
32
+ //#endregion
33
+ export { escapeLiteral as n, quoteIdentifier as r, SqlEscapeError as t };
34
+
35
+ //# sourceMappingURL=sql-utils-DhevMgef.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-utils-DhevMgef.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the SQLite target.\n *\n * These functions handle safe SQL identifier and literal escaping. They\n * live in `target-sqlite` (mirroring `target-postgres/src/core/sql-utils.ts`)\n * so both the control adapter (used at emit time) and the runtime adapter\n * (used at execute time) can depend on them through a single one-way edge:\n * `adapter-sqlite → target-sqlite`. Hosting them target-side avoids the\n * cyclic workspace dependency that would arise if `target-sqlite` reached\n * back into `adapter-sqlite` for these primitives.\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\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 return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\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"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,QAAQ;EAHE,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;;;AAIhB,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;CAElF,IAAI,WAAW,SAAS,KAAK,EAC3B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;CAEH,OAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;AAG5C,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,KAAK,EACtB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;CAEH,OAAO,MAAM,QAAQ,MAAM,KAAK"}
@@ -0,0 +1,22 @@
1
+ //#region src/core/sql-utils.d.ts
2
+ /**
3
+ * Shared SQL utility functions for the SQLite target.
4
+ *
5
+ * These functions handle safe SQL identifier and literal escaping. They
6
+ * live in `target-sqlite` (mirroring `target-postgres/src/core/sql-utils.ts`)
7
+ * so both the control adapter (used at emit time) and the runtime adapter
8
+ * (used at execute time) can depend on them through a single one-way edge:
9
+ * `adapter-sqlite → target-sqlite`. Hosting them target-side avoids the
10
+ * cyclic workspace dependency that would arise if `target-sqlite` reached
11
+ * back into `adapter-sqlite` for these primitives.
12
+ */
13
+ declare class SqlEscapeError extends Error {
14
+ readonly value: string;
15
+ readonly kind: 'identifier' | 'literal';
16
+ constructor(message: string, value: string, kind: 'identifier' | 'literal');
17
+ }
18
+ declare function quoteIdentifier(identifier: string): string;
19
+ declare function escapeLiteral(value: string): string;
20
+ //#endregion
21
+ export { SqlEscapeError, escapeLiteral, quoteIdentifier };
22
+ //# sourceMappingURL=sql-utils.d.mts.map