@prisma-next/cli 0.3.0-dev.15 → 0.3.0-dev.162

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 (236) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +381 -128
  3. package/dist/cli-errors-BDCYR5ap.mjs +4 -0
  4. package/dist/cli-errors-Dzs7Oxz7.d.mts +3 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.js +1 -2346
  7. package/dist/cli.mjs +245 -0
  8. package/dist/cli.mjs.map +1 -0
  9. package/dist/client-yYtotiSX.mjs +1063 -0
  10. package/dist/client-yYtotiSX.mjs.map +1 -0
  11. package/dist/commands/contract-emit.d.mts +7 -0
  12. package/dist/commands/contract-emit.d.mts.map +1 -0
  13. package/dist/commands/contract-emit.mjs +8 -0
  14. package/dist/commands/contract-infer.d.mts +7 -0
  15. package/dist/commands/contract-infer.d.mts.map +1 -0
  16. package/dist/commands/contract-infer.mjs +9 -0
  17. package/dist/commands/db-init.d.mts +7 -0
  18. package/dist/commands/db-init.d.mts.map +1 -0
  19. package/dist/commands/db-init.mjs +125 -0
  20. package/dist/commands/db-init.mjs.map +1 -0
  21. package/dist/commands/db-schema.d.mts +7 -0
  22. package/dist/commands/db-schema.d.mts.map +1 -0
  23. package/dist/commands/db-schema.mjs +55 -0
  24. package/dist/commands/db-schema.mjs.map +1 -0
  25. package/dist/commands/db-sign.d.mts +7 -0
  26. package/dist/commands/db-sign.d.mts.map +1 -0
  27. package/dist/commands/db-sign.mjs +136 -0
  28. package/dist/commands/db-sign.mjs.map +1 -0
  29. package/dist/commands/db-update.d.mts +7 -0
  30. package/dist/commands/db-update.d.mts.map +1 -0
  31. package/dist/commands/db-update.mjs +122 -0
  32. package/dist/commands/db-update.mjs.map +1 -0
  33. package/dist/commands/db-verify.d.mts +7 -0
  34. package/dist/commands/db-verify.d.mts.map +1 -0
  35. package/dist/commands/db-verify.mjs +322 -0
  36. package/dist/commands/db-verify.mjs.map +1 -0
  37. package/dist/commands/migration-apply.d.mts +36 -0
  38. package/dist/commands/migration-apply.d.mts.map +1 -0
  39. package/dist/commands/migration-apply.mjs +244 -0
  40. package/dist/commands/migration-apply.mjs.map +1 -0
  41. package/dist/commands/migration-new.d.mts +8 -0
  42. package/dist/commands/migration-new.d.mts.map +1 -0
  43. package/dist/commands/migration-new.mjs +151 -0
  44. package/dist/commands/migration-new.mjs.map +1 -0
  45. package/dist/commands/migration-plan.d.mts +47 -0
  46. package/dist/commands/migration-plan.d.mts.map +1 -0
  47. package/dist/commands/migration-plan.mjs +312 -0
  48. package/dist/commands/migration-plan.mjs.map +1 -0
  49. package/dist/commands/migration-ref.d.mts +43 -0
  50. package/dist/commands/migration-ref.d.mts.map +1 -0
  51. package/dist/commands/migration-ref.mjs +194 -0
  52. package/dist/commands/migration-ref.mjs.map +1 -0
  53. package/dist/commands/migration-show.d.mts +28 -0
  54. package/dist/commands/migration-show.d.mts.map +1 -0
  55. package/dist/commands/migration-show.mjs +139 -0
  56. package/dist/commands/migration-show.mjs.map +1 -0
  57. package/dist/commands/migration-status.d.mts +86 -0
  58. package/dist/commands/migration-status.d.mts.map +1 -0
  59. package/dist/commands/migration-status.mjs +8 -0
  60. package/dist/commands/migration-verify.d.mts +16 -0
  61. package/dist/commands/migration-verify.d.mts.map +1 -0
  62. package/dist/commands/migration-verify.mjs +109 -0
  63. package/dist/commands/migration-verify.mjs.map +1 -0
  64. package/dist/config-loader-C4VXKl8f.mjs +43 -0
  65. package/dist/config-loader-C4VXKl8f.mjs.map +1 -0
  66. package/dist/{config-loader.d.ts → config-loader.d.mts} +8 -3
  67. package/dist/config-loader.d.mts.map +1 -0
  68. package/dist/config-loader.mjs +3 -0
  69. package/dist/contract-emit-Bk_eEDKu.mjs +187 -0
  70. package/dist/contract-emit-Bk_eEDKu.mjs.map +1 -0
  71. package/dist/contract-infer-suMDmFSG.mjs +89 -0
  72. package/dist/contract-infer-suMDmFSG.mjs.map +1 -0
  73. package/dist/exports/config-types.d.mts +2 -0
  74. package/dist/exports/config-types.mjs +3 -0
  75. package/dist/exports/control-api.d.mts +624 -0
  76. package/dist/exports/control-api.d.mts.map +1 -0
  77. package/dist/exports/control-api.mjs +109 -0
  78. package/dist/exports/control-api.mjs.map +1 -0
  79. package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +12 -7
  80. package/dist/exports/index.d.mts.map +1 -0
  81. package/dist/exports/index.mjs +141 -0
  82. package/dist/exports/index.mjs.map +1 -0
  83. package/dist/extract-operation-statements-BVlb3jxp.mjs +13 -0
  84. package/dist/extract-operation-statements-BVlb3jxp.mjs.map +1 -0
  85. package/dist/extract-sql-ddl-6EVSOThm.mjs +26 -0
  86. package/dist/extract-sql-ddl-6EVSOThm.mjs.map +1 -0
  87. package/dist/framework-components-BAsliT4V.mjs +59 -0
  88. package/dist/framework-components-BAsliT4V.mjs.map +1 -0
  89. package/dist/inspect-live-schema-HMutsJYh.mjs +91 -0
  90. package/dist/inspect-live-schema-HMutsJYh.mjs.map +1 -0
  91. package/dist/migration-command-scaffold-Dg7CKKCg.mjs +105 -0
  92. package/dist/migration-command-scaffold-Dg7CKKCg.mjs.map +1 -0
  93. package/dist/migration-status-BqfVmC0w.mjs +1582 -0
  94. package/dist/migration-status-BqfVmC0w.mjs.map +1 -0
  95. package/dist/migrations-Bv8oeiY_.mjs +173 -0
  96. package/dist/migrations-Bv8oeiY_.mjs.map +1 -0
  97. package/dist/progress-adapter-D4x8SbJa.mjs +43 -0
  98. package/dist/progress-adapter-D4x8SbJa.mjs.map +1 -0
  99. package/dist/terminal-ui-N5tR-ob5.mjs +967 -0
  100. package/dist/terminal-ui-N5tR-ob5.mjs.map +1 -0
  101. package/dist/verify-WARh5TjK.mjs +385 -0
  102. package/dist/verify-WARh5TjK.mjs.map +1 -0
  103. package/package.json +87 -41
  104. package/src/cli.ts +113 -58
  105. package/src/commands/contract-emit.ts +237 -144
  106. package/src/commands/contract-infer-paths.ts +32 -0
  107. package/src/commands/contract-infer.ts +143 -0
  108. package/src/commands/db-init.ts +211 -426
  109. package/src/commands/db-schema.ts +77 -0
  110. package/src/commands/db-sign.ts +208 -229
  111. package/src/commands/db-update.ts +236 -0
  112. package/src/commands/db-verify.ts +504 -184
  113. package/src/commands/inspect-live-schema.ts +170 -0
  114. package/src/commands/migration-apply.ts +427 -0
  115. package/src/commands/migration-new.ts +260 -0
  116. package/src/commands/migration-plan.ts +519 -0
  117. package/src/commands/migration-ref.ts +305 -0
  118. package/src/commands/migration-show.ts +246 -0
  119. package/src/commands/migration-status.ts +864 -0
  120. package/src/commands/migration-verify.ts +180 -0
  121. package/src/config-loader.ts +13 -3
  122. package/src/control-api/client.ts +428 -46
  123. package/src/control-api/contract-enrichment.ts +119 -0
  124. package/src/control-api/errors.ts +9 -0
  125. package/src/control-api/operations/contract-emit.ts +174 -0
  126. package/src/control-api/operations/db-init.ts +144 -26
  127. package/src/control-api/operations/db-update.ts +220 -0
  128. package/src/control-api/operations/extract-operation-statements.ts +14 -0
  129. package/src/control-api/operations/extract-sql-ddl.ts +47 -0
  130. package/src/control-api/operations/migration-apply.ts +191 -0
  131. package/src/control-api/operations/migration-helpers.ts +49 -0
  132. package/src/control-api/types.ts +450 -18
  133. package/src/exports/config-types.ts +4 -3
  134. package/src/exports/control-api.ts +24 -2
  135. package/src/load-ts-contract.ts +30 -19
  136. package/src/utils/cli-errors.ts +14 -8
  137. package/src/utils/command-helpers.ts +302 -3
  138. package/src/utils/formatters/emit.ts +67 -0
  139. package/src/utils/formatters/errors.ts +82 -0
  140. package/src/utils/formatters/graph-migration-mapper.ts +240 -0
  141. package/src/utils/formatters/graph-render.ts +1323 -0
  142. package/src/utils/formatters/graph-types.ts +120 -0
  143. package/src/utils/formatters/help.ts +380 -0
  144. package/src/utils/formatters/helpers.ts +28 -0
  145. package/src/utils/formatters/migrations.ts +346 -0
  146. package/src/utils/formatters/styled.ts +212 -0
  147. package/src/utils/formatters/verify.ts +621 -0
  148. package/src/utils/framework-components.ts +13 -10
  149. package/src/utils/global-flags.ts +41 -23
  150. package/src/utils/migration-command-scaffold.ts +184 -0
  151. package/src/utils/migration-types.ts +12 -0
  152. package/src/utils/progress-adapter.ts +75 -0
  153. package/src/utils/result-handler.ts +12 -13
  154. package/src/utils/shutdown.ts +92 -0
  155. package/src/utils/suggest-command.ts +31 -0
  156. package/src/utils/terminal-ui.ts +276 -0
  157. package/dist/chunk-6EPKRATC.js +0 -91
  158. package/dist/chunk-6EPKRATC.js.map +0 -1
  159. package/dist/chunk-DIJPT5TZ.js +0 -967
  160. package/dist/chunk-DIJPT5TZ.js.map +0 -1
  161. package/dist/chunk-HWYQOCAJ.js +0 -47
  162. package/dist/chunk-HWYQOCAJ.js.map +0 -1
  163. package/dist/chunk-MG7PBERL.js +0 -131
  164. package/dist/chunk-MG7PBERL.js.map +0 -1
  165. package/dist/chunk-VI2YETW7.js +0 -38
  166. package/dist/chunk-VI2YETW7.js.map +0 -1
  167. package/dist/cli.d.ts +0 -2
  168. package/dist/cli.d.ts.map +0 -1
  169. package/dist/cli.js.map +0 -1
  170. package/dist/commands/contract-emit.d.ts +0 -3
  171. package/dist/commands/contract-emit.d.ts.map +0 -1
  172. package/dist/commands/contract-emit.js +0 -10
  173. package/dist/commands/contract-emit.js.map +0 -1
  174. package/dist/commands/db-init.d.ts +0 -3
  175. package/dist/commands/db-init.d.ts.map +0 -1
  176. package/dist/commands/db-init.js +0 -339
  177. package/dist/commands/db-init.js.map +0 -1
  178. package/dist/commands/db-introspect.d.ts +0 -3
  179. package/dist/commands/db-introspect.d.ts.map +0 -1
  180. package/dist/commands/db-introspect.js +0 -183
  181. package/dist/commands/db-introspect.js.map +0 -1
  182. package/dist/commands/db-schema-verify.d.ts +0 -3
  183. package/dist/commands/db-schema-verify.d.ts.map +0 -1
  184. package/dist/commands/db-schema-verify.js +0 -161
  185. package/dist/commands/db-schema-verify.js.map +0 -1
  186. package/dist/commands/db-sign.d.ts +0 -3
  187. package/dist/commands/db-sign.d.ts.map +0 -1
  188. package/dist/commands/db-sign.js +0 -196
  189. package/dist/commands/db-sign.js.map +0 -1
  190. package/dist/commands/db-verify.d.ts +0 -3
  191. package/dist/commands/db-verify.d.ts.map +0 -1
  192. package/dist/commands/db-verify.js +0 -170
  193. package/dist/commands/db-verify.js.map +0 -1
  194. package/dist/config-loader.d.ts.map +0 -1
  195. package/dist/config-loader.js +0 -7
  196. package/dist/config-loader.js.map +0 -1
  197. package/dist/control-api/client.d.ts +0 -13
  198. package/dist/control-api/client.d.ts.map +0 -1
  199. package/dist/control-api/operations/db-init.d.ts +0 -27
  200. package/dist/control-api/operations/db-init.d.ts.map +0 -1
  201. package/dist/control-api/types.d.ts +0 -203
  202. package/dist/control-api/types.d.ts.map +0 -1
  203. package/dist/exports/config-types.d.ts +0 -3
  204. package/dist/exports/config-types.d.ts.map +0 -1
  205. package/dist/exports/config-types.js +0 -6
  206. package/dist/exports/config-types.js.map +0 -1
  207. package/dist/exports/control-api.d.ts +0 -13
  208. package/dist/exports/control-api.d.ts.map +0 -1
  209. package/dist/exports/control-api.js +0 -240
  210. package/dist/exports/control-api.js.map +0 -1
  211. package/dist/exports/index.d.ts +0 -4
  212. package/dist/exports/index.d.ts.map +0 -1
  213. package/dist/exports/index.js +0 -176
  214. package/dist/exports/index.js.map +0 -1
  215. package/dist/load-ts-contract.d.ts.map +0 -1
  216. package/dist/utils/action.d.ts +0 -16
  217. package/dist/utils/action.d.ts.map +0 -1
  218. package/dist/utils/cli-errors.d.ts +0 -7
  219. package/dist/utils/cli-errors.d.ts.map +0 -1
  220. package/dist/utils/command-helpers.d.ts +0 -12
  221. package/dist/utils/command-helpers.d.ts.map +0 -1
  222. package/dist/utils/framework-components.d.ts +0 -70
  223. package/dist/utils/framework-components.d.ts.map +0 -1
  224. package/dist/utils/global-flags.d.ts +0 -25
  225. package/dist/utils/global-flags.d.ts.map +0 -1
  226. package/dist/utils/output.d.ts +0 -142
  227. package/dist/utils/output.d.ts.map +0 -1
  228. package/dist/utils/result-handler.d.ts +0 -15
  229. package/dist/utils/result-handler.d.ts.map +0 -1
  230. package/dist/utils/spinner.d.ts +0 -29
  231. package/dist/utils/spinner.d.ts.map +0 -1
  232. package/src/commands/db-introspect.ts +0 -254
  233. package/src/commands/db-schema-verify.ts +0 -231
  234. package/src/utils/action.ts +0 -43
  235. package/src/utils/output.ts +0 -1471
  236. package/src/utils/spinner.ts +0 -67
@@ -1,13 +0,0 @@
1
- import type { ControlClient, ControlClientOptions } from './types';
2
- /**
3
- * Creates a programmatic control client for Prisma Next operations.
4
- *
5
- * The client accepts framework component descriptors at creation time,
6
- * manages driver lifecycle via connect()/close(), and exposes domain
7
- * operations that delegate to the existing family instance methods.
8
- *
9
- * @see {@link ControlClient} for the client interface
10
- * @see README.md "Programmatic Control API" section for usage examples
11
- */
12
- export declare function createControlClient(options: ControlClientOptions): ControlClient;
13
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/control-api/client.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAOrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAEhF"}
@@ -1,27 +0,0 @@
1
- import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
2
- import type { ContractIR } from '@prisma-next/contract/ir';
3
- import type { ControlDriverInstance, ControlFamilyInstance, TargetMigrationsCapability } from '@prisma-next/core-control-plane/types';
4
- import type { DbInitResult } from '../types';
5
- /**
6
- * Options for executing dbInit operation.
7
- */
8
- export interface ExecuteDbInitOptions<TFamilyId extends string, TTargetId extends string> {
9
- readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
10
- readonly familyInstance: ControlFamilyInstance<TFamilyId>;
11
- readonly contractIR: ContractIR;
12
- readonly mode: 'plan' | 'apply';
13
- readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, ControlFamilyInstance<TFamilyId>>;
14
- readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
15
- }
16
- /**
17
- * Executes the dbInit operation.
18
- *
19
- * This is the core logic extracted from the CLI command, without any file I/O,
20
- * process.exit(), or console output. It uses the Result pattern to return
21
- * success or failure details.
22
- *
23
- * @param options - The options for executing dbInit
24
- * @returns Result with DbInitSuccess on success, DbInitFailure on failure
25
- */
26
- export declare function executeDbInit<TFamilyId extends string, TTargetId extends string>(options: ExecuteDbInitOptions<TFamilyId, TTargetId>): Promise<DbInitResult>;
27
- //# sourceMappingURL=db-init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-init.d.ts","sourceRoot":"","sources":["../../../src/control-api/operations/db-init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAIrB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM;IACtF,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC7D,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC1D,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAC7C,SAAS,EACT,SAAS,EACT,qBAAqB,CAAC,SAAS,CAAC,CACjC,CAAC;IACF,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,8BAA8B,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;CACnG;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,SAAS,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,EACpF,OAAO,EAAE,oBAAoB,CAAC,SAAS,EAAE,SAAS,CAAC,GAClD,OAAO,CAAC,YAAY,CAAC,CA6HvB"}
@@ -1,203 +0,0 @@
1
- import type { ControlAdapterDescriptor, ControlDriverDescriptor, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlTargetDescriptor, MigrationPlannerConflict, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from '@prisma-next/core-control-plane/types';
2
- import type { Result } from '@prisma-next/utils/result';
3
- /**
4
- * Options for creating a control client.
5
- *
6
- * Note: This is NOT the same as CLI config. There's no `contract` field,
7
- * no file paths. The client is config-agnostic.
8
- *
9
- * The descriptor types use permissive `any` because family-specific descriptors
10
- * (e.g., SqlFamilyDescriptor) have more specific `create` method signatures that
11
- * are not compatible with the base ControlFamilyDescriptor type due to TypeScript
12
- * variance rules. The client implementation casts these internally.
13
- */
14
- export interface ControlClientOptions {
15
- readonly family: ControlFamilyDescriptor<any, any>;
16
- readonly target: ControlTargetDescriptor<any, any, any, any>;
17
- readonly adapter: ControlAdapterDescriptor<any, any, any>;
18
- /** Optional - control client can be created without driver for offline operations */
19
- readonly driver?: ControlDriverDescriptor<any, any, any, any>;
20
- readonly extensionPacks?: ReadonlyArray<ControlExtensionDescriptor<any, any, any>>;
21
- /**
22
- * Optional default connection for auto-connect.
23
- * When provided, operations will auto-connect if not already connected.
24
- * The type is driver-specific (e.g., string URL for Postgres).
25
- */
26
- readonly connection?: unknown;
27
- }
28
- /**
29
- * Options for the verify operation.
30
- */
31
- export interface VerifyOptions {
32
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
33
- readonly contractIR: unknown;
34
- }
35
- /**
36
- * Options for the schemaVerify operation.
37
- */
38
- export interface SchemaVerifyOptions {
39
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
40
- readonly contractIR: unknown;
41
- /**
42
- * Whether to use strict mode for schema verification.
43
- * In strict mode, extra tables/columns are reported as issues.
44
- * Default: false (tolerant mode - allows superset)
45
- */
46
- readonly strict?: boolean;
47
- }
48
- /**
49
- * Options for the sign operation.
50
- */
51
- export interface SignOptions {
52
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
53
- readonly contractIR: unknown;
54
- }
55
- /**
56
- * Options for the dbInit operation.
57
- */
58
- export interface DbInitOptions {
59
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
60
- readonly contractIR: unknown;
61
- /**
62
- * Mode for the dbInit operation.
63
- * - 'plan': Returns planned operations without applying
64
- * - 'apply': Applies operations and writes marker
65
- */
66
- readonly mode: 'plan' | 'apply';
67
- }
68
- /**
69
- * Options for the introspect operation.
70
- */
71
- export interface IntrospectOptions {
72
- /**
73
- * Optional schema name to introspect.
74
- */
75
- readonly schema?: string;
76
- }
77
- /**
78
- * Successful dbInit result.
79
- */
80
- export interface DbInitSuccess {
81
- readonly mode: 'plan' | 'apply';
82
- readonly plan: {
83
- readonly operations: ReadonlyArray<{
84
- readonly id: string;
85
- readonly label: string;
86
- readonly operationClass: string;
87
- }>;
88
- };
89
- readonly execution?: {
90
- readonly operationsPlanned: number;
91
- readonly operationsExecuted: number;
92
- };
93
- readonly marker?: {
94
- readonly coreHash: string;
95
- readonly profileHash?: string;
96
- };
97
- readonly summary: string;
98
- }
99
- /**
100
- * Failure codes for dbInit operation.
101
- */
102
- export type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
103
- /**
104
- * Failure details for dbInit operation.
105
- */
106
- export interface DbInitFailure {
107
- readonly code: DbInitFailureCode;
108
- readonly summary: string;
109
- readonly conflicts?: ReadonlyArray<MigrationPlannerConflict>;
110
- readonly marker?: {
111
- readonly coreHash?: string;
112
- readonly profileHash?: string;
113
- };
114
- readonly destination?: {
115
- readonly coreHash: string;
116
- readonly profileHash?: string | undefined;
117
- };
118
- }
119
- /**
120
- * Result type for dbInit operation.
121
- * Uses Result pattern: success returns DbInitSuccess, failure returns DbInitFailure.
122
- */
123
- export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
124
- /**
125
- * Programmatic control client for Prisma Next operations.
126
- *
127
- * Lifecycle: `connect(connection)` before operations, `close()` when done.
128
- * Both `init()` and `connect()` are auto-called by operations if needed,
129
- * but `connect()` requires a connection so must be called explicitly first
130
- * unless a default connection was provided in options.
131
- *
132
- * @see README.md "Programmatic Control API" section for usage examples
133
- */
134
- export interface ControlClient {
135
- /**
136
- * Initializes the client by creating the control plane stack,
137
- * family instance, and validating framework components.
138
- *
139
- * Idempotent (safe to call multiple times).
140
- * Called automatically by `connect()` if not already initialized.
141
- */
142
- init(): void;
143
- /**
144
- * Establishes a database connection.
145
- * Auto-calls `init()` if not already initialized.
146
- * Must be called before any database operations unless a default connection
147
- * was provided in options.
148
- *
149
- * @param connection - Driver-specific connection input (e.g., URL string for Postgres).
150
- * If omitted, uses the default connection from options (if provided).
151
- * @throws If connection fails, already connected, driver is not configured,
152
- * or no connection provided and no default connection in options.
153
- */
154
- connect(connection?: unknown): Promise<void>;
155
- /**
156
- * Closes the database connection.
157
- * Idempotent (safe to call multiple times).
158
- * After close(), can call `connect()` again with same or different URL.
159
- */
160
- close(): Promise<void>;
161
- /**
162
- * Verifies database marker matches the contract.
163
- * Compares coreHash and profileHash.
164
- *
165
- * @returns Structured result (ok: false for mismatch, not throwing)
166
- * @throws If not connected or infrastructure failure
167
- */
168
- verify(options: VerifyOptions): Promise<VerifyDatabaseResult>;
169
- /**
170
- * Verifies database schema satisfies the contract requirements.
171
- *
172
- * @param options.strict - If true, extra tables/columns are issues. Default: false
173
- * @returns Structured result with schema issues
174
- * @throws If not connected or infrastructure failure
175
- */
176
- schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
177
- /**
178
- * Signs the database with a contract marker.
179
- * Writes or updates the contract marker if schema verification passes.
180
- * Idempotent (no-op if marker already matches).
181
- *
182
- * @returns Structured result
183
- * @throws If not connected or infrastructure failure
184
- */
185
- sign(options: SignOptions): Promise<SignDatabaseResult>;
186
- /**
187
- * Initializes database schema from contract.
188
- * Uses additive-only policy (no destructive changes).
189
- *
190
- * @param options.mode - 'plan' to preview, 'apply' to execute
191
- * @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
192
- * @throws If not connected, target doesn't support migrations, or infrastructure failure
193
- */
194
- dbInit(options: DbInitOptions): Promise<DbInitResult>;
195
- /**
196
- * Introspects the database schema.
197
- *
198
- * @returns Raw schema IR
199
- * @throws If not connected or infrastructure failure
200
- */
201
- introspect(options?: IntrospectOptions): Promise<unknown>;
202
- }
203
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/control-api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAMxD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,oBAAoB;IAEnC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAEnD,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE7D,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1D,q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CAAC,CAAC;IAE7C;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEhF;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAExD;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3D"}
@@ -1,3 +0,0 @@
1
- export type { ContractConfig, PrismaNextConfig, } from '@prisma-next/core-control-plane/config-types';
2
- export { defineConfig } from '@prisma-next/core-control-plane/config-types';
3
- //# sourceMappingURL=config-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../../src/exports/config-types.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC"}
@@ -1,6 +0,0 @@
1
- // src/exports/config-types.ts
2
- import { defineConfig } from "@prisma-next/core-control-plane/config-types";
3
- export {
4
- defineConfig
5
- };
6
- //# sourceMappingURL=config-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/exports/config-types.ts"],"sourcesContent":["// Re-export core-control-plane config types for convenience\nexport type {\n ContractConfig,\n PrismaNextConfig,\n} from '@prisma-next/core-control-plane/config-types';\nexport { defineConfig } from '@prisma-next/core-control-plane/config-types';\n"],"mappings":";AAKA,SAAS,oBAAoB;","names":[]}
@@ -1,13 +0,0 @@
1
- /**
2
- * Programmatic Control API for Prisma Next.
3
- *
4
- * This module exports the control client factory and types for programmatic
5
- * access to control-plane operations without using the CLI.
6
- *
7
- * @see README.md "Programmatic Control API" section for usage examples
8
- * @module
9
- */
10
- export type { ControlPlaneStack, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult, } from '@prisma-next/core-control-plane/types';
11
- export { createControlClient } from '../control-api/client';
12
- export type { ControlClient, ControlClientOptions, DbInitFailure, DbInitFailureCode, DbInitOptions, DbInitResult, DbInitSuccess, IntrospectOptions, SchemaVerifyOptions, SignOptions, VerifyOptions, } from '../control-api/types';
13
- //# sourceMappingURL=control-api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"control-api.d.ts","sourceRoot":"","sources":["../../src/exports/control-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC"}
@@ -1,240 +0,0 @@
1
- import {
2
- assertFrameworkComponentsCompatible
3
- } from "../chunk-6EPKRATC.js";
4
- import "../chunk-VI2YETW7.js";
5
-
6
- // src/control-api/client.ts
7
- import { createControlPlaneStack } from "@prisma-next/core-control-plane/stack";
8
-
9
- // src/control-api/operations/db-init.ts
10
- import { notOk, ok } from "@prisma-next/utils/result";
11
- async function executeDbInit(options) {
12
- const { driver, familyInstance, contractIR, mode, migrations, frameworkComponents } = options;
13
- const planner = migrations.createPlanner(familyInstance);
14
- const runner = migrations.createRunner(familyInstance);
15
- const schemaIR = await familyInstance.introspect({ driver });
16
- const policy = { allowedOperationClasses: ["additive"] };
17
- const plannerResult = await planner.plan({
18
- contract: contractIR,
19
- schema: schemaIR,
20
- policy,
21
- frameworkComponents
22
- });
23
- if (plannerResult.kind === "failure") {
24
- return notOk({
25
- code: "PLANNING_FAILED",
26
- summary: "Migration planning failed due to conflicts",
27
- conflicts: plannerResult.conflicts
28
- });
29
- }
30
- const migrationPlan = plannerResult.plan;
31
- const existingMarker = await familyInstance.readMarker({ driver });
32
- if (existingMarker) {
33
- const markerMatchesDestination = existingMarker.coreHash === migrationPlan.destination.coreHash && (!migrationPlan.destination.profileHash || existingMarker.profileHash === migrationPlan.destination.profileHash);
34
- if (markerMatchesDestination) {
35
- const result2 = {
36
- mode,
37
- plan: { operations: [] },
38
- ...mode === "apply" ? {
39
- execution: { operationsPlanned: 0, operationsExecuted: 0 },
40
- marker: {
41
- coreHash: existingMarker.coreHash,
42
- profileHash: existingMarker.profileHash
43
- }
44
- } : {},
45
- summary: "Database already at target contract state"
46
- };
47
- return ok(result2);
48
- }
49
- return notOk({
50
- code: "MARKER_ORIGIN_MISMATCH",
51
- summary: "Existing contract marker does not match plan destination",
52
- marker: {
53
- coreHash: existingMarker.coreHash,
54
- profileHash: existingMarker.profileHash
55
- },
56
- destination: {
57
- coreHash: migrationPlan.destination.coreHash,
58
- profileHash: migrationPlan.destination.profileHash
59
- }
60
- });
61
- }
62
- if (mode === "plan") {
63
- const result2 = {
64
- mode: "plan",
65
- plan: { operations: migrationPlan.operations },
66
- summary: `Planned ${migrationPlan.operations.length} operation(s)`
67
- };
68
- return ok(result2);
69
- }
70
- const runnerResult = await runner.execute({
71
- plan: migrationPlan,
72
- driver,
73
- destinationContract: contractIR,
74
- policy,
75
- // db init plans and applies back-to-back from a fresh introspection, so per-operation
76
- // pre/postchecks and the idempotency probe are usually redundant overhead. We still
77
- // enforce marker/origin compatibility and a full schema verification after apply.
78
- executionChecks: {
79
- prechecks: false,
80
- postchecks: false,
81
- idempotencyChecks: false
82
- },
83
- frameworkComponents
84
- });
85
- if (!runnerResult.ok) {
86
- return notOk({
87
- code: "RUNNER_FAILED",
88
- summary: runnerResult.failure.summary
89
- });
90
- }
91
- const execution = runnerResult.value;
92
- const result = {
93
- mode: "apply",
94
- plan: { operations: migrationPlan.operations },
95
- execution: {
96
- operationsPlanned: execution.operationsPlanned,
97
- operationsExecuted: execution.operationsExecuted
98
- },
99
- marker: migrationPlan.destination.profileHash ? {
100
- coreHash: migrationPlan.destination.coreHash,
101
- profileHash: migrationPlan.destination.profileHash
102
- } : { coreHash: migrationPlan.destination.coreHash },
103
- summary: `Applied ${execution.operationsExecuted} operation(s), marker written`
104
- };
105
- return ok(result);
106
- }
107
-
108
- // src/control-api/client.ts
109
- function createControlClient(options) {
110
- return new ControlClientImpl(options);
111
- }
112
- var ControlClientImpl = class {
113
- options;
114
- stack = null;
115
- driver = null;
116
- familyInstance = null;
117
- frameworkComponents = null;
118
- initialized = false;
119
- defaultConnection;
120
- constructor(options) {
121
- this.options = options;
122
- this.defaultConnection = options.connection;
123
- }
124
- init() {
125
- if (this.initialized) {
126
- return;
127
- }
128
- this.stack = createControlPlaneStack({
129
- target: this.options.target,
130
- adapter: this.options.adapter,
131
- driver: this.options.driver,
132
- extensionPacks: this.options.extensionPacks
133
- });
134
- this.familyInstance = this.options.family.create(this.stack);
135
- const rawComponents = [
136
- this.options.target,
137
- this.options.adapter,
138
- ...this.options.extensionPacks ?? []
139
- ];
140
- this.frameworkComponents = assertFrameworkComponentsCompatible(
141
- this.options.family.familyId,
142
- this.options.target.targetId,
143
- rawComponents
144
- );
145
- this.initialized = true;
146
- }
147
- async connect(connection) {
148
- this.init();
149
- if (this.driver) {
150
- throw new Error("Already connected. Call close() before reconnecting.");
151
- }
152
- const resolvedConnection = connection ?? this.defaultConnection;
153
- if (resolvedConnection === void 0) {
154
- throw new Error(
155
- "No connection provided. Pass a connection to connect() or provide a default connection when creating the client."
156
- );
157
- }
158
- if (!this.stack?.driver) {
159
- throw new Error(
160
- "Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations."
161
- );
162
- }
163
- this.driver = await this.stack?.driver.create(resolvedConnection);
164
- }
165
- async close() {
166
- if (this.driver) {
167
- await this.driver.close();
168
- this.driver = null;
169
- }
170
- }
171
- async ensureConnected() {
172
- this.init();
173
- if (!this.driver && this.defaultConnection !== void 0) {
174
- await this.connect(this.defaultConnection);
175
- }
176
- if (!this.driver || !this.familyInstance || !this.frameworkComponents) {
177
- throw new Error("Not connected. Call connect(connection) first.");
178
- }
179
- return {
180
- driver: this.driver,
181
- familyInstance: this.familyInstance,
182
- frameworkComponents: this.frameworkComponents
183
- };
184
- }
185
- async verify(options) {
186
- const { driver, familyInstance } = await this.ensureConnected();
187
- const contractIR = familyInstance.validateContractIR(options.contractIR);
188
- return familyInstance.verify({
189
- driver,
190
- contractIR,
191
- expectedTargetId: this.options.target.targetId,
192
- contractPath: ""
193
- });
194
- }
195
- async schemaVerify(options) {
196
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
197
- const contractIR = familyInstance.validateContractIR(options.contractIR);
198
- return familyInstance.schemaVerify({
199
- driver,
200
- contractIR,
201
- strict: options.strict ?? false,
202
- contractPath: "",
203
- frameworkComponents
204
- });
205
- }
206
- async sign(options) {
207
- const { driver, familyInstance } = await this.ensureConnected();
208
- const contractIR = familyInstance.validateContractIR(options.contractIR);
209
- return familyInstance.sign({
210
- driver,
211
- contractIR,
212
- contractPath: ""
213
- });
214
- }
215
- async dbInit(options) {
216
- const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
217
- if (!this.options.target.migrations) {
218
- throw new Error(`Target "${this.options.target.targetId}" does not support migrations`);
219
- }
220
- const contractIR = familyInstance.validateContractIR(options.contractIR);
221
- return executeDbInit({
222
- driver,
223
- familyInstance,
224
- contractIR,
225
- mode: options.mode,
226
- migrations: this.options.target.migrations,
227
- frameworkComponents
228
- });
229
- }
230
- async introspect(options) {
231
- const { driver, familyInstance } = await this.ensureConnected();
232
- const _schema = options?.schema;
233
- void _schema;
234
- return familyInstance.introspect({ driver });
235
- }
236
- };
237
- export {
238
- createControlClient
239
- };
240
- //# sourceMappingURL=control-api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/control-api/client.ts","../../src/control-api/operations/db-init.ts"],"sourcesContent":["import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport { createControlPlaneStack } from '@prisma-next/core-control-plane/stack';\nimport type {\n ControlDriverInstance,\n ControlFamilyInstance,\n ControlPlaneStack,\n SignDatabaseResult,\n VerifyDatabaseResult,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/core-control-plane/types';\nimport { assertFrameworkComponentsCompatible } from '../utils/framework-components';\nimport { executeDbInit } from './operations/db-init';\nimport type {\n ControlClient,\n ControlClientOptions,\n DbInitOptions,\n DbInitResult,\n IntrospectOptions,\n SchemaVerifyOptions,\n SignOptions,\n VerifyOptions,\n} from './types';\n\n/**\n * Creates a programmatic control client for Prisma Next operations.\n *\n * The client accepts framework component descriptors at creation time,\n * manages driver lifecycle via connect()/close(), and exposes domain\n * operations that delegate to the existing family instance methods.\n *\n * @see {@link ControlClient} for the client interface\n * @see README.md \"Programmatic Control API\" section for usage examples\n */\nexport function createControlClient(options: ControlClientOptions): ControlClient {\n return new ControlClientImpl(options);\n}\n\n/**\n * Implementation of ControlClient.\n * Manages initialization and connection state, delegates operations to family instance.\n */\nclass ControlClientImpl implements ControlClient {\n private readonly options: ControlClientOptions;\n private stack: ControlPlaneStack<string, string> | null = null;\n private driver: ControlDriverInstance<string, string> | null = null;\n private familyInstance: ControlFamilyInstance<string> | null = null;\n private frameworkComponents: ReadonlyArray<\n TargetBoundComponentDescriptor<string, string>\n > | null = null;\n private initialized = false;\n private readonly defaultConnection: unknown;\n\n constructor(options: ControlClientOptions) {\n this.options = options;\n this.defaultConnection = options.connection;\n }\n\n init(): void {\n if (this.initialized) {\n return; // Idempotent\n }\n\n // Create the control plane stack\n this.stack = createControlPlaneStack({\n target: this.options.target,\n adapter: this.options.adapter,\n driver: this.options.driver,\n extensionPacks: this.options.extensionPacks,\n });\n\n // Create family instance using the stack\n this.familyInstance = this.options.family.create(this.stack);\n\n // Validate and type-narrow framework components\n const rawComponents = [\n this.options.target,\n this.options.adapter,\n ...(this.options.extensionPacks ?? []),\n ];\n this.frameworkComponents = assertFrameworkComponentsCompatible(\n this.options.family.familyId,\n this.options.target.targetId,\n rawComponents,\n );\n\n this.initialized = true;\n }\n\n async connect(connection?: unknown): Promise<void> {\n // Auto-init if needed\n this.init();\n\n if (this.driver) {\n throw new Error('Already connected. Call close() before reconnecting.');\n }\n\n // Resolve connection: argument > default from options\n const resolvedConnection = connection ?? this.defaultConnection;\n if (resolvedConnection === undefined) {\n throw new Error(\n 'No connection provided. Pass a connection to connect() or provide a default connection when creating the client.',\n );\n }\n\n // Check for driver descriptor\n if (!this.stack?.driver) {\n throw new Error(\n 'Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations.',\n );\n }\n\n // Create driver instance\n // Cast through any since connection type is driver-specific at runtime.\n // The driver descriptor is typed with any for TConnection in ControlClientOptions,\n // but createControlPlaneStack defaults it to string. We bridge this at runtime.\n // biome-ignore lint/suspicious/noExplicitAny: required for runtime connection type flexibility\n this.driver = await this.stack?.driver.create(resolvedConnection as any);\n }\n\n async close(): Promise<void> {\n if (this.driver) {\n await this.driver.close();\n this.driver = null;\n }\n }\n\n private async ensureConnected(): Promise<{\n driver: ControlDriverInstance<string, string>;\n familyInstance: ControlFamilyInstance<string>;\n frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<string, string>>;\n }> {\n // Auto-init if needed\n this.init();\n\n // Auto-connect if not connected and default connection is available\n if (!this.driver && this.defaultConnection !== undefined) {\n await this.connect(this.defaultConnection);\n }\n\n if (!this.driver || !this.familyInstance || !this.frameworkComponents) {\n throw new Error('Not connected. Call connect(connection) first.');\n }\n return {\n driver: this.driver,\n familyInstance: this.familyInstance,\n frameworkComponents: this.frameworkComponents,\n };\n }\n\n async verify(options: VerifyOptions): Promise<VerifyDatabaseResult> {\n const { driver, familyInstance } = await this.ensureConnected();\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to family instance verify method\n // Note: We pass empty strings for contractPath/configPath since the programmatic\n // API doesn't deal with file paths. The family instance accepts these as optional\n // metadata for error reporting.\n return familyInstance.verify({\n driver,\n contractIR,\n expectedTargetId: this.options.target.targetId,\n contractPath: '',\n });\n }\n\n async schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult> {\n const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to family instance schemaVerify method\n return familyInstance.schemaVerify({\n driver,\n contractIR,\n strict: options.strict ?? false,\n contractPath: '',\n frameworkComponents,\n });\n }\n\n async sign(options: SignOptions): Promise<SignDatabaseResult> {\n const { driver, familyInstance } = await this.ensureConnected();\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to family instance sign method\n return familyInstance.sign({\n driver,\n contractIR,\n contractPath: '',\n });\n }\n\n async dbInit(options: DbInitOptions): Promise<DbInitResult> {\n const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();\n\n // Check target supports migrations\n if (!this.options.target.migrations) {\n throw new Error(`Target \"${this.options.target.targetId}\" does not support migrations`);\n }\n\n // Validate contract using family instance\n const contractIR = familyInstance.validateContractIR(options.contractIR);\n\n // Delegate to extracted dbInit operation\n return executeDbInit({\n driver,\n familyInstance,\n contractIR,\n mode: options.mode,\n migrations: this.options.target.migrations,\n frameworkComponents,\n });\n }\n\n async introspect(options?: IntrospectOptions): Promise<unknown> {\n const { driver, familyInstance } = await this.ensureConnected();\n\n // TODO: Pass schema option to familyInstance.introspect when schema filtering is implemented\n const _schema = options?.schema;\n void _schema;\n\n return familyInstance.introspect({ driver });\n }\n}\n","import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport type { ContractIR } from '@prisma-next/contract/ir';\nimport type {\n ControlDriverInstance,\n ControlFamilyInstance,\n MigrationPlan,\n MigrationPlannerResult,\n MigrationRunnerResult,\n TargetMigrationsCapability,\n} from '@prisma-next/core-control-plane/types';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport type { DbInitResult, DbInitSuccess } from '../types';\n\n/**\n * Options for executing dbInit operation.\n */\nexport interface ExecuteDbInitOptions<TFamilyId extends string, TTargetId extends string> {\n readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;\n readonly familyInstance: ControlFamilyInstance<TFamilyId>;\n readonly contractIR: ContractIR;\n readonly mode: 'plan' | 'apply';\n readonly migrations: TargetMigrationsCapability<\n TFamilyId,\n TTargetId,\n ControlFamilyInstance<TFamilyId>\n >;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n}\n\n/**\n * Executes the dbInit operation.\n *\n * This is the core logic extracted from the CLI command, without any file I/O,\n * process.exit(), or console output. It uses the Result pattern to return\n * success or failure details.\n *\n * @param options - The options for executing dbInit\n * @returns Result with DbInitSuccess on success, DbInitFailure on failure\n */\nexport async function executeDbInit<TFamilyId extends string, TTargetId extends string>(\n options: ExecuteDbInitOptions<TFamilyId, TTargetId>,\n): Promise<DbInitResult> {\n const { driver, familyInstance, contractIR, mode, migrations, frameworkComponents } = options;\n\n // Create planner and runner from target migrations capability\n const planner = migrations.createPlanner(familyInstance);\n const runner = migrations.createRunner(familyInstance);\n\n // Introspect live schema\n const schemaIR = await familyInstance.introspect({ driver });\n\n // Policy for init mode (additive only)\n const policy = { allowedOperationClasses: ['additive'] as const };\n\n // Plan migration\n const plannerResult: MigrationPlannerResult = await planner.plan({\n contract: contractIR,\n schema: schemaIR,\n policy,\n frameworkComponents,\n });\n\n if (plannerResult.kind === 'failure') {\n return notOk({\n code: 'PLANNING_FAILED' as const,\n summary: 'Migration planning failed due to conflicts',\n conflicts: plannerResult.conflicts,\n });\n }\n\n const migrationPlan: MigrationPlan = plannerResult.plan;\n\n // Check for existing marker - handle idempotency and mismatch errors\n const existingMarker = await familyInstance.readMarker({ driver });\n if (existingMarker) {\n const markerMatchesDestination =\n existingMarker.coreHash === migrationPlan.destination.coreHash &&\n (!migrationPlan.destination.profileHash ||\n existingMarker.profileHash === migrationPlan.destination.profileHash);\n\n if (markerMatchesDestination) {\n // Already at destination - return success with no operations\n const result: DbInitSuccess = {\n mode,\n plan: { operations: [] },\n ...(mode === 'apply'\n ? {\n execution: { operationsPlanned: 0, operationsExecuted: 0 },\n marker: {\n coreHash: existingMarker.coreHash,\n profileHash: existingMarker.profileHash,\n },\n }\n : {}),\n summary: 'Database already at target contract state',\n };\n return ok(result);\n }\n\n // Marker exists but doesn't match destination - fail\n return notOk({\n code: 'MARKER_ORIGIN_MISMATCH' as const,\n summary: 'Existing contract marker does not match plan destination',\n marker: {\n coreHash: existingMarker.coreHash,\n profileHash: existingMarker.profileHash,\n },\n destination: {\n coreHash: migrationPlan.destination.coreHash,\n profileHash: migrationPlan.destination.profileHash,\n },\n });\n }\n\n // Plan mode - don't execute\n if (mode === 'plan') {\n const result: DbInitSuccess = {\n mode: 'plan',\n plan: { operations: migrationPlan.operations },\n summary: `Planned ${migrationPlan.operations.length} operation(s)`,\n };\n return ok(result);\n }\n\n // Apply mode - execute runner\n const runnerResult: MigrationRunnerResult = await runner.execute({\n plan: migrationPlan,\n driver,\n destinationContract: contractIR,\n policy,\n // db init plans and applies back-to-back from a fresh introspection, so per-operation\n // pre/postchecks and the idempotency probe are usually redundant overhead. We still\n // enforce marker/origin compatibility and a full schema verification after apply.\n executionChecks: {\n prechecks: false,\n postchecks: false,\n idempotencyChecks: false,\n },\n frameworkComponents,\n });\n\n if (!runnerResult.ok) {\n return notOk({\n code: 'RUNNER_FAILED' as const,\n summary: runnerResult.failure.summary,\n });\n }\n\n const execution = runnerResult.value;\n\n const result: DbInitSuccess = {\n mode: 'apply',\n plan: { operations: migrationPlan.operations },\n execution: {\n operationsPlanned: execution.operationsPlanned,\n operationsExecuted: execution.operationsExecuted,\n },\n marker: migrationPlan.destination.profileHash\n ? {\n coreHash: migrationPlan.destination.coreHash,\n profileHash: migrationPlan.destination.profileHash,\n }\n : { coreHash: migrationPlan.destination.coreHash },\n summary: `Applied ${execution.operationsExecuted} operation(s), marker written`,\n };\n return ok(result);\n}\n"],"mappings":";;;;;;AACA,SAAS,+BAA+B;;;ACSxC,SAAS,OAAO,UAAU;AA6B1B,eAAsB,cACpB,SACuB;AACvB,QAAM,EAAE,QAAQ,gBAAgB,YAAY,MAAM,YAAY,oBAAoB,IAAI;AAGtF,QAAM,UAAU,WAAW,cAAc,cAAc;AACvD,QAAM,SAAS,WAAW,aAAa,cAAc;AAGrD,QAAM,WAAW,MAAM,eAAe,WAAW,EAAE,OAAO,CAAC;AAG3D,QAAM,SAAS,EAAE,yBAAyB,CAAC,UAAU,EAAW;AAGhE,QAAM,gBAAwC,MAAM,QAAQ,KAAK;AAAA,IAC/D,UAAU;AAAA,IACV,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,cAAc,SAAS,WAAW;AACpC,WAAO,MAAM;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW,cAAc;AAAA,IAC3B,CAAC;AAAA,EACH;AAEA,QAAM,gBAA+B,cAAc;AAGnD,QAAM,iBAAiB,MAAM,eAAe,WAAW,EAAE,OAAO,CAAC;AACjE,MAAI,gBAAgB;AAClB,UAAM,2BACJ,eAAe,aAAa,cAAc,YAAY,aACrD,CAAC,cAAc,YAAY,eAC1B,eAAe,gBAAgB,cAAc,YAAY;AAE7D,QAAI,0BAA0B;AAE5B,YAAMA,UAAwB;AAAA,QAC5B;AAAA,QACA,MAAM,EAAE,YAAY,CAAC,EAAE;AAAA,QACvB,GAAI,SAAS,UACT;AAAA,UACE,WAAW,EAAE,mBAAmB,GAAG,oBAAoB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mD;AAC5D,UAAM,EAAE,QAAQ,eAAe,IAAI,MAAM,KAAK,gBAAgB;AAG9D,UAAM,aAAa,eAAe,mBAAmB,QAAQ,UAAU;AAGvE,WAAO,eAAe,KAAK;AAAA,MACzB;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,SAA+C;AAC1D,UAAM,EAAE,QAAQ,gBAAgB,oBAAoB,IAAI,MAAM,KAAK,gBAAgB;AAGnF,QAAI,CAAC,KAAK,QAAQ,OAAO,YAAY;AACnC,YAAM,IAAI,MAAM,WAAW,KAAK,QAAQ,OAAO,QAAQ,+BAA+B;AAAA,IACxF;AAGA,UAAM,aAAa,eAAe,mBAAmB,QAAQ,UAAU;AAGvE,WAAO,cAAc;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,QAAQ;AAAA,MACd,YAAY,KAAK,QAAQ,OAAO;AAAA,MAChC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,WAAW,SAA+C;AAC9D,UAAM,EAAE,QAAQ,eAAe,IAAI,MAAM,KAAK,gBAAgB;AAG9D,UAAM,UAAU,SAAS;AACzB,SAAK;AAEL,WAAO,eAAe,WAAW,EAAE,OAAO,CAAC;AAAA,EAC7C;AACF;","names":["result"]}
@@ -1,4 +0,0 @@
1
- export { createContractEmitCommand } from '../commands/contract-emit';
2
- export type { LoadTsContractOptions } from '../load-ts-contract';
3
- export { loadContractFromTs } from '../load-ts-contract';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}