@prisma-next/target-sqlite 0.15.0 → 0.16.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/{codec-ids-BfPkjMmk.d.mts → codec-ids-Dof8fZfe.d.mts} +1 -2
  2. package/dist/codec-ids-Dof8fZfe.d.mts.map +1 -0
  3. package/dist/codec-ids.d.mts +1 -1
  4. package/dist/{codec-types-izdPhp_9.d.mts → codec-types-CcFkbJ3o.d.mts} +3 -4
  5. package/dist/codec-types-CcFkbJ3o.d.mts.map +1 -0
  6. package/dist/codec-types.d.mts +2 -2
  7. package/dist/{codecs-BGeJavlQ.d.mts → codecs-DGgo--O0.d.mts} +2 -3
  8. package/dist/codecs-DGgo--O0.d.mts.map +1 -0
  9. package/dist/codecs.d.mts +1 -1
  10. package/dist/contract-free.d.mts +1 -2
  11. package/dist/contract-free.d.mts.map +1 -1
  12. package/dist/control-tables.d.mts.map +1 -1
  13. package/dist/control.d.mts +0 -1
  14. package/dist/control.d.mts.map +1 -1
  15. package/dist/control.mjs +14 -14
  16. package/dist/control.mjs.map +1 -1
  17. package/dist/ddl.d.mts +1 -1
  18. package/dist/default-normalizer.d.mts +0 -1
  19. package/dist/default-normalizer.d.mts.map +1 -1
  20. package/dist/{descriptor-meta-D1fap-5t.mjs → descriptor-meta-BPrgV878.mjs} +12 -6
  21. package/dist/descriptor-meta-BPrgV878.mjs.map +1 -0
  22. package/dist/migration.d.mts +2 -3
  23. package/dist/migration.d.mts.map +1 -1
  24. package/dist/migration.mjs +2 -2
  25. package/dist/native-type-normalizer.d.mts.map +1 -1
  26. package/dist/{nodes-VzaaeUTb.d.mts → nodes-COZjF41I.d.mts} +1 -2
  27. package/dist/nodes-COZjF41I.d.mts.map +1 -0
  28. package/dist/{op-factory-call-Do03QgD9.mjs → op-factory-call-8pTnIHhR.mjs} +8 -8
  29. package/dist/op-factory-call-8pTnIHhR.mjs.map +1 -0
  30. package/dist/op-factory-call.d.mts +2 -3
  31. package/dist/op-factory-call.d.mts.map +1 -1
  32. package/dist/op-factory-call.mjs +1 -1
  33. package/dist/pack.d.mts +41 -2
  34. package/dist/pack.d.mts.map +1 -1
  35. package/dist/pack.mjs +1 -1
  36. package/dist/{planner-produced-sqlite-migration-CeGjNfd2.mjs → planner-produced-sqlite-migration-CWmvnJi4.mjs} +21 -11
  37. package/dist/planner-produced-sqlite-migration-CWmvnJi4.mjs.map +1 -0
  38. package/dist/{planner-produced-sqlite-migration-o1qUzwLk.d.mts → planner-produced-sqlite-migration-fd_Jw-mL.d.mts} +3 -4
  39. package/dist/planner-produced-sqlite-migration-fd_Jw-mL.d.mts.map +1 -0
  40. package/dist/planner-produced-sqlite-migration.d.mts +1 -1
  41. package/dist/planner-produced-sqlite-migration.mjs +1 -1
  42. package/dist/{planner-D2hMk3oC.mjs → planner-sc4nqpzL.mjs} +19 -59
  43. package/dist/planner-sc4nqpzL.mjs.map +1 -0
  44. package/dist/planner-target-details-xR6UfIcz.d.mts.map +1 -1
  45. package/dist/planner.d.mts +7 -2
  46. package/dist/planner.d.mts.map +1 -1
  47. package/dist/planner.mjs +1 -1
  48. package/dist/render-ops.d.mts +0 -1
  49. package/dist/render-ops.d.mts.map +1 -1
  50. package/dist/runtime.d.mts +1 -2
  51. package/dist/runtime.d.mts.map +1 -1
  52. package/dist/{shared-C6sM-wel.d.mts → shared-DLUM4Ae2.d.mts} +1 -3
  53. package/dist/shared-DLUM4Ae2.d.mts.map +1 -0
  54. package/dist/sql-utils.d.mts.map +1 -1
  55. package/dist/{sqlite-contract-view-J32K82Gi.d.mts → sqlite-contract-view-CMgE0L4W.d.mts} +4 -3
  56. package/dist/sqlite-contract-view-CMgE0L4W.d.mts.map +1 -0
  57. package/dist/{sqlite-migration-BYbzskpE.d.mts → sqlite-migration-CBXynqeE.d.mts} +8 -8
  58. package/dist/sqlite-migration-CBXynqeE.d.mts.map +1 -0
  59. package/dist/{sqlite-migration-C9bD6XDl.mjs → sqlite-migration-CLXPhPxF.mjs} +11 -10
  60. package/dist/sqlite-migration-CLXPhPxF.mjs.map +1 -0
  61. package/package.json +19 -19
  62. package/src/core/authoring.ts +11 -5
  63. package/src/core/errors.ts +12 -8
  64. package/src/core/migrations/issue-planner.ts +18 -62
  65. package/src/core/migrations/op-factory-call.ts +1 -1
  66. package/src/core/migrations/operations/shared.ts +3 -5
  67. package/src/core/migrations/operations/tables.ts +3 -2
  68. package/src/core/migrations/planner-produced-sqlite-migration.ts +4 -0
  69. package/src/core/migrations/planner-strategies.ts +4 -3
  70. package/src/core/migrations/planner.ts +11 -2
  71. package/src/core/migrations/render-typescript.ts +20 -8
  72. package/src/core/migrations/runner.ts +13 -12
  73. package/src/core/migrations/sqlite-migration.ts +5 -4
  74. package/dist/codec-ids-BfPkjMmk.d.mts.map +0 -1
  75. package/dist/codec-types-izdPhp_9.d.mts.map +0 -1
  76. package/dist/codecs-BGeJavlQ.d.mts.map +0 -1
  77. package/dist/descriptor-meta-D1fap-5t.mjs.map +0 -1
  78. package/dist/nodes-VzaaeUTb.d.mts.map +0 -1
  79. package/dist/op-factory-call-Do03QgD9.mjs.map +0 -1
  80. package/dist/planner-D2hMk3oC.mjs.map +0 -1
  81. package/dist/planner-produced-sqlite-migration-CeGjNfd2.mjs.map +0 -1
  82. package/dist/planner-produced-sqlite-migration-o1qUzwLk.d.mts.map +0 -1
  83. package/dist/shared-C6sM-wel.d.mts.map +0 -1
  84. package/dist/sqlite-contract-view-J32K82Gi.d.mts.map +0 -1
  85. package/dist/sqlite-migration-BYbzskpE.d.mts.map +0 -1
  86. package/dist/sqlite-migration-C9bD6XDl.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqlite-migration-C9bD6XDl.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/errors.ts","../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import { CliStructuredError } from '@prisma-next/errors/control';\n\n/**\n * A `SqliteMigration` operation that needs the materialized control adapter\n * — named by `operation` (e.g. `createTable`, `dropColumn`, `recreateTable`) —\n * was invoked, but the migration was constructed without a `ControlStack`.\n * Concrete authoring usage always goes through the migration CLI entrypoint,\n * which assembles a stack from the loaded `prisma-next.config.ts`; reaching this\n * error means a test fixture or ad-hoc consumer instantiated `SqliteMigration`\n * with the no-arg form (legal for `operations` / `describe` introspection only).\n *\n * The `operation` argument is required so every throw site names the operation\n * that actually failed; a new operation cannot inherit a misattributed message.\n *\n * Distinct from `PN-MIG-2001` (placeholder not filled) because the missing\n * input is the stack itself, not the per-operation contract.\n *\n * Lives in `@prisma-next/target-sqlite/errors` rather than the shared\n * framework migration errors module because the failure is target-specific:\n * the contract it talks about (`SqliteMigration`, the SQLite control\n * adapter, the SQLite-target stack) only exists in this package.\n */\nexport function errorSqliteMigrationStackMissing(operation: string): CliStructuredError {\n return new CliStructuredError('2008', `SqliteMigration.${operation} requires a control adapter`, {\n domain: 'MIG',\n why: `SqliteMigration.${operation} was invoked on an instance constructed without a ControlStack, so the stored controlAdapter is undefined and the operation cannot lower its DDL node.`,\n fix: 'Construct the migration via the migration CLI entrypoint (which assembles a ControlStack from the loaded prisma-next.config.ts), or pass a ControlStack containing a SQLite adapter to the migration constructor in test fixtures.',\n meta: { operation },\n });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { errorSqliteMigrationStackMissing } from '../errors';\nimport { SqliteContractView } from '../sqlite-contract-view';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n RecreateTableCall,\n} from './op-factory-call';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n *\n * The constructor materializes a single SQLite `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected instance methods\n * forward to the corresponding `*Call` with that stored adapter, so user\n * migrations can write `this.createTable({...})` without threading the adapter\n * through every call.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its `start-contract.json` / `end-contract.json` imports gets\n * fully-typed view accessors: `this.endContract` is a `SqliteContractView<End>`\n * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),\n * built lazily from the JSON fields via the shared `MigrationContractViews`\n * helper. Mirrors `MongoMigration`'s view getters; the framework base derives\n * `describe()` from the same JSON.\n */\nexport abstract class SqliteMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<SqlitePlanTargetDetails, 'sqlite', Start, End> {\n readonly targetId = 'sqlite' as const;\n\n /**\n * Materialized SQLite control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a PN-MIG-2008 in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;\n\n #endView = new MigrationContractViews<SqliteContractView<End>>(this, 'SqliteMigration', (json) =>\n SqliteContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<SqliteContractView<Start>>(\n this,\n 'SqliteMigration',\n (json) => SqliteContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'sqlite'>) {\n super(stack);\n this.controlAdapter = stack?.adapter\n ? blindCast<\n SqlControlAdapter<'sqlite'>,\n 'The SQLite descriptor create() returns SqlControlAdapter<sqlite>; typed as wider ControlAdapterInstance at the framework boundary'\n >(stack.adapter.create(stack))\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a PN-MIG-2008 naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'sqlite'> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed SQLite view over this migration's end-state contract — sole\n * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.\n * Throws if no `endContractJson` was provided.\n */\n get endContract(): SqliteContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed SQLite view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): SqliteContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n protected createTable(options: {\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<Op> {\n return new CreateTableCall(options.table, options.columns, options.constraints).toOp(\n this.controlAdapterFor('createTable'),\n );\n }\n\n protected dropTable(options: { readonly table: string }): Promise<Op> {\n return new DropTableCall(options.table).toOp(this.controlAdapterFor('dropTable'));\n }\n\n protected addColumn(options: {\n readonly table: string;\n readonly column: SqliteColumnSpec;\n }): Promise<Op> {\n return new AddColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {\n return new DropColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected createIndex(options: {\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n }): Promise<Op> {\n return new CreateIndexCall(options.table, options.index, options.columns).toOp(\n this.controlAdapterFor('createIndex'),\n );\n }\n\n protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {\n return new DropIndexCall(options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected recreateTable(options: {\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n }): Promise<Op> {\n return new RecreateTableCall(options).toOp(this.controlAdapterFor('recreateTable'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iCAAiC,WAAuC;CACtF,OAAO,IAAI,mBAAmB,QAAQ,mBAAmB,UAAU,8BAA8B;EAC/F,QAAQ;EACR,KAAK,mBAAmB,UAAU;EAClC,KAAK;EACL,MAAM,EAAE,UAAU;CACpB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;ACoBA,IAAsB,kBAAtB,cAGUA,UAA4D;CACpE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBAAgD,MAAM,oBAAoB,SACvF,mBAAmB,SAAc,IAAI,CACvC;CACA,aAAa,IAAI,uBACf,MACA,oBACC,SAAS,mBAAmB,SAAgB,IAAI,CACnD;CAEA,YAAY,OAAuC;EACjD,MAAM,KAAK;EACX,KAAK,iBAAiB,OAAO,UACzB,UAGE,MAAM,QAAQ,OAAO,KAAK,CAAC,IAC7B,KAAA;CACN;;;;;;CAOA,kBAA0B,WAAgD;EACxE,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC,SAAS;EAElD,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,cAAuC;EACzC,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAkD;EACpD,OAAO,KAAKC,WAAW;CACzB;CAEA,YAAsB,SAKN;EACd,OAAO,IAAI,gBAAgB,QAAQ,OAAO,QAAQ,SAAS,QAAQ,WAAW,CAAC,CAAC,KAC9E,KAAK,kBAAkB,aAAa,CACtC;CACF;CAEA,UAAoB,SAAkD;EACpE,OAAO,IAAI,cAAc,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,kBAAkB,WAAW,CAAC;CAClF;CAEA,UAAoB,SAGJ;EACd,OAAO,IAAI,cAAc,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACtD,KAAK,kBAAkB,WAAW,CACpC;CACF;CAEA,WAAqB,SAA2E;EAC9F,OAAO,IAAI,eAAe,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACvD,KAAK,kBAAkB,YAAY,CACrC;CACF;CAEA,YAAsB,SAIN;EACd,OAAO,IAAI,gBAAgB,QAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,CAAC,CAAC,KACxE,KAAK,kBAAkB,aAAa,CACtC;CACF;CAEA,UAAoB,SAA0E;EAC5F,OAAO,IAAI,cAAc,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrD,KAAK,kBAAkB,WAAW,CACpC;CACF;CAEA,cAAwB,SAQR;EACd,OAAO,IAAI,kBAAkB,OAAO,CAAC,CAAC,KAAK,KAAK,kBAAkB,eAAe,CAAC;CACpF;AACF"}