@prisma-next/cli 0.3.0-dev.16 → 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 (242) 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 -2671
  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 +88 -42
  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 +97 -219
  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 +424 -72
  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 +53 -49
  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 +388 -18
  133. package/src/exports/config-types.ts +4 -3
  134. package/src/exports/control-api.ts +21 -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 +18 -29
  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-5MPKZYVI.js +0 -47
  158. package/dist/chunk-5MPKZYVI.js.map +0 -1
  159. package/dist/chunk-6EPKRATC.js +0 -91
  160. package/dist/chunk-6EPKRATC.js.map +0 -1
  161. package/dist/chunk-74IELXRA.js +0 -371
  162. package/dist/chunk-74IELXRA.js.map +0 -1
  163. package/dist/chunk-HWYQOCAJ.js +0 -47
  164. package/dist/chunk-HWYQOCAJ.js.map +0 -1
  165. package/dist/chunk-U6QI3AZ3.js +0 -133
  166. package/dist/chunk-U6QI3AZ3.js.map +0 -1
  167. package/dist/chunk-VI2YETW7.js +0 -38
  168. package/dist/chunk-VI2YETW7.js.map +0 -1
  169. package/dist/chunk-ZG5T6OB5.js +0 -923
  170. package/dist/chunk-ZG5T6OB5.js.map +0 -1
  171. package/dist/cli.d.ts +0 -2
  172. package/dist/cli.d.ts.map +0 -1
  173. package/dist/cli.js.map +0 -1
  174. package/dist/commands/contract-emit.d.ts +0 -3
  175. package/dist/commands/contract-emit.d.ts.map +0 -1
  176. package/dist/commands/contract-emit.js +0 -11
  177. package/dist/commands/contract-emit.js.map +0 -1
  178. package/dist/commands/db-init.d.ts +0 -3
  179. package/dist/commands/db-init.d.ts.map +0 -1
  180. package/dist/commands/db-init.js +0 -302
  181. package/dist/commands/db-init.js.map +0 -1
  182. package/dist/commands/db-introspect.d.ts +0 -3
  183. package/dist/commands/db-introspect.d.ts.map +0 -1
  184. package/dist/commands/db-introspect.js +0 -185
  185. package/dist/commands/db-introspect.js.map +0 -1
  186. package/dist/commands/db-schema-verify.d.ts +0 -3
  187. package/dist/commands/db-schema-verify.d.ts.map +0 -1
  188. package/dist/commands/db-schema-verify.js +0 -163
  189. package/dist/commands/db-schema-verify.js.map +0 -1
  190. package/dist/commands/db-sign.d.ts +0 -3
  191. package/dist/commands/db-sign.d.ts.map +0 -1
  192. package/dist/commands/db-sign.js +0 -198
  193. package/dist/commands/db-sign.js.map +0 -1
  194. package/dist/commands/db-verify.d.ts +0 -3
  195. package/dist/commands/db-verify.d.ts.map +0 -1
  196. package/dist/commands/db-verify.js +0 -172
  197. package/dist/commands/db-verify.js.map +0 -1
  198. package/dist/config-loader.d.ts.map +0 -1
  199. package/dist/config-loader.js +0 -7
  200. package/dist/config-loader.js.map +0 -1
  201. package/dist/control-api/client.d.ts +0 -13
  202. package/dist/control-api/client.d.ts.map +0 -1
  203. package/dist/control-api/operations/db-init.d.ts +0 -29
  204. package/dist/control-api/operations/db-init.d.ts.map +0 -1
  205. package/dist/control-api/types.d.ts +0 -256
  206. package/dist/control-api/types.d.ts.map +0 -1
  207. package/dist/exports/config-types.d.ts +0 -3
  208. package/dist/exports/config-types.d.ts.map +0 -1
  209. package/dist/exports/config-types.js +0 -6
  210. package/dist/exports/config-types.js.map +0 -1
  211. package/dist/exports/control-api.d.ts +0 -13
  212. package/dist/exports/control-api.d.ts.map +0 -1
  213. package/dist/exports/control-api.js +0 -9
  214. package/dist/exports/control-api.js.map +0 -1
  215. package/dist/exports/index.d.ts +0 -4
  216. package/dist/exports/index.d.ts.map +0 -1
  217. package/dist/exports/index.js +0 -177
  218. package/dist/exports/index.js.map +0 -1
  219. package/dist/load-ts-contract.d.ts.map +0 -1
  220. package/dist/utils/action.d.ts +0 -16
  221. package/dist/utils/action.d.ts.map +0 -1
  222. package/dist/utils/cli-errors.d.ts +0 -7
  223. package/dist/utils/cli-errors.d.ts.map +0 -1
  224. package/dist/utils/command-helpers.d.ts +0 -12
  225. package/dist/utils/command-helpers.d.ts.map +0 -1
  226. package/dist/utils/framework-components.d.ts +0 -70
  227. package/dist/utils/framework-components.d.ts.map +0 -1
  228. package/dist/utils/global-flags.d.ts +0 -25
  229. package/dist/utils/global-flags.d.ts.map +0 -1
  230. package/dist/utils/output.d.ts +0 -142
  231. package/dist/utils/output.d.ts.map +0 -1
  232. package/dist/utils/progress-adapter.d.ts +0 -26
  233. package/dist/utils/progress-adapter.d.ts.map +0 -1
  234. package/dist/utils/result-handler.d.ts +0 -15
  235. package/dist/utils/result-handler.d.ts.map +0 -1
  236. package/dist/utils/spinner.d.ts +0 -29
  237. package/dist/utils/spinner.d.ts.map +0 -1
  238. package/src/commands/db-introspect.ts +0 -254
  239. package/src/commands/db-schema-verify.ts +0 -231
  240. package/src/utils/action.ts +0 -43
  241. package/src/utils/output.ts +0 -1471
  242. package/src/utils/spinner.ts +0 -67
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -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,29 +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, OnControlProgress } 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
- /** Optional progress callback for observing operation progress */
16
- readonly onProgress?: OnControlProgress;
17
- }
18
- /**
19
- * Executes the dbInit operation.
20
- *
21
- * This is the core logic extracted from the CLI command, without any file I/O,
22
- * process.exit(), or console output. It uses the Result pattern to return
23
- * success or failure details.
24
- *
25
- * @param options - The options for executing dbInit
26
- * @returns Result with DbInitSuccess on success, DbInitFailure on failure
27
- */
28
- export declare function executeDbInit<TFamilyId extends string, TTargetId extends string>(options: ExecuteDbInitOptions<TFamilyId, TTargetId>): Promise<DbInitResult>;
29
- //# 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,EAKrB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAiB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE/E;;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;IAClG,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;CACzC;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,CA4OvB"}
@@ -1,256 +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
- * Action names for control-api operations that can emit progress events.
30
- */
31
- export type ControlActionName = 'dbInit' | 'verify' | 'schemaVerify' | 'sign' | 'introspect';
32
- /**
33
- * Progress event emitted during control-api operation execution.
34
- *
35
- * Events model operation progress using a span-based model:
36
- * - `spanStart`: Begin a timed segment (supports nesting via parentSpanId)
37
- * - `spanEnd`: Complete a timed segment
38
- *
39
- * All operation-specific progress (e.g., per-migration-operation) is modeled
40
- * as nested spans rather than special event types.
41
- *
42
- * Events are delivered via an optional `onProgress` callback to avoid polluting
43
- * return types. If the callback is absent, operations emit no events (zero overhead).
44
- */
45
- export type ControlProgressEvent = {
46
- readonly action: ControlActionName;
47
- readonly kind: 'spanStart';
48
- readonly spanId: string;
49
- readonly parentSpanId?: string;
50
- readonly label: string;
51
- } | {
52
- readonly action: ControlActionName;
53
- readonly kind: 'spanEnd';
54
- readonly spanId: string;
55
- readonly outcome: 'ok' | 'skipped' | 'error';
56
- };
57
- /**
58
- * Callback function for receiving progress events during control-api operations.
59
- *
60
- * @param event - The progress event emitted by the operation
61
- */
62
- export type OnControlProgress = (event: ControlProgressEvent) => void;
63
- /**
64
- * Options for the verify operation.
65
- */
66
- export interface VerifyOptions {
67
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
68
- readonly contractIR: unknown;
69
- /** Optional progress callback for observing operation progress */
70
- readonly onProgress?: OnControlProgress;
71
- }
72
- /**
73
- * Options for the schemaVerify operation.
74
- */
75
- export interface SchemaVerifyOptions {
76
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
77
- readonly contractIR: unknown;
78
- /**
79
- * Whether to use strict mode for schema verification.
80
- * In strict mode, extra tables/columns are reported as issues.
81
- * Default: false (tolerant mode - allows superset)
82
- */
83
- readonly strict?: boolean;
84
- /** Optional progress callback for observing operation progress */
85
- readonly onProgress?: OnControlProgress;
86
- }
87
- /**
88
- * Options for the sign operation.
89
- */
90
- export interface SignOptions {
91
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
92
- readonly contractIR: unknown;
93
- /** Optional progress callback for observing operation progress */
94
- readonly onProgress?: OnControlProgress;
95
- }
96
- /**
97
- * Options for the dbInit operation.
98
- */
99
- export interface DbInitOptions {
100
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
101
- readonly contractIR: unknown;
102
- /**
103
- * Mode for the dbInit operation.
104
- * - 'plan': Returns planned operations without applying
105
- * - 'apply': Applies operations and writes marker
106
- */
107
- readonly mode: 'plan' | 'apply';
108
- /**
109
- * Database connection. If provided, dbInit will connect before executing.
110
- * If omitted, the client must already be connected.
111
- * The type is driver-specific (e.g., string URL for Postgres).
112
- */
113
- readonly connection?: unknown;
114
- /** Optional progress callback for observing operation progress */
115
- readonly onProgress?: OnControlProgress;
116
- }
117
- /**
118
- * Options for the introspect operation.
119
- */
120
- export interface IntrospectOptions {
121
- /**
122
- * Optional schema name to introspect.
123
- */
124
- readonly schema?: string;
125
- /** Optional progress callback for observing operation progress */
126
- readonly onProgress?: OnControlProgress;
127
- }
128
- /**
129
- * Successful dbInit result.
130
- */
131
- export interface DbInitSuccess {
132
- readonly mode: 'plan' | 'apply';
133
- readonly plan: {
134
- readonly operations: ReadonlyArray<{
135
- readonly id: string;
136
- readonly label: string;
137
- readonly operationClass: string;
138
- }>;
139
- };
140
- readonly execution?: {
141
- readonly operationsPlanned: number;
142
- readonly operationsExecuted: number;
143
- };
144
- readonly marker?: {
145
- readonly coreHash: string;
146
- readonly profileHash?: string;
147
- };
148
- readonly summary: string;
149
- }
150
- /**
151
- * Failure codes for dbInit operation.
152
- */
153
- export type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
154
- /**
155
- * Failure details for dbInit operation.
156
- */
157
- export interface DbInitFailure {
158
- readonly code: DbInitFailureCode;
159
- readonly summary: string;
160
- readonly why: string | undefined;
161
- readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
162
- readonly meta: Record<string, unknown> | undefined;
163
- readonly marker?: {
164
- readonly coreHash?: string;
165
- readonly profileHash?: string;
166
- };
167
- readonly destination?: {
168
- readonly coreHash: string;
169
- readonly profileHash?: string | undefined;
170
- };
171
- }
172
- /**
173
- * Result type for dbInit operation.
174
- * Uses Result pattern: success returns DbInitSuccess, failure returns DbInitFailure.
175
- */
176
- export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
177
- /**
178
- * Programmatic control client for Prisma Next operations.
179
- *
180
- * Lifecycle: `connect(connection)` before operations, `close()` when done.
181
- * Both `init()` and `connect()` are auto-called by operations if needed,
182
- * but `connect()` requires a connection so must be called explicitly first
183
- * unless a default connection was provided in options.
184
- *
185
- * @see README.md "Programmatic Control API" section for usage examples
186
- */
187
- export interface ControlClient {
188
- /**
189
- * Initializes the client by creating the control plane stack,
190
- * family instance, and validating framework components.
191
- *
192
- * Idempotent (safe to call multiple times).
193
- * Called automatically by `connect()` if not already initialized.
194
- */
195
- init(): void;
196
- /**
197
- * Establishes a database connection.
198
- * Auto-calls `init()` if not already initialized.
199
- * Must be called before any database operations unless a default connection
200
- * was provided in options.
201
- *
202
- * @param connection - Driver-specific connection input (e.g., URL string for Postgres).
203
- * If omitted, uses the default connection from options (if provided).
204
- * @throws If connection fails, already connected, driver is not configured,
205
- * or no connection provided and no default connection in options.
206
- */
207
- connect(connection?: unknown): Promise<void>;
208
- /**
209
- * Closes the database connection.
210
- * Idempotent (safe to call multiple times).
211
- * After close(), can call `connect()` again with same or different URL.
212
- */
213
- close(): Promise<void>;
214
- /**
215
- * Verifies database marker matches the contract.
216
- * Compares coreHash and profileHash.
217
- *
218
- * @returns Structured result (ok: false for mismatch, not throwing)
219
- * @throws If not connected or infrastructure failure
220
- */
221
- verify(options: VerifyOptions): Promise<VerifyDatabaseResult>;
222
- /**
223
- * Verifies database schema satisfies the contract requirements.
224
- *
225
- * @param options.strict - If true, extra tables/columns are issues. Default: false
226
- * @returns Structured result with schema issues
227
- * @throws If not connected or infrastructure failure
228
- */
229
- schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
230
- /**
231
- * Signs the database with a contract marker.
232
- * Writes or updates the contract marker if schema verification passes.
233
- * Idempotent (no-op if marker already matches).
234
- *
235
- * @returns Structured result
236
- * @throws If not connected or infrastructure failure
237
- */
238
- sign(options: SignOptions): Promise<SignDatabaseResult>;
239
- /**
240
- * Initializes database schema from contract.
241
- * Uses additive-only policy (no destructive changes).
242
- *
243
- * @param options.mode - 'plan' to preview, 'apply' to execute
244
- * @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
245
- * @throws If not connected, target doesn't support migrations, or infrastructure failure
246
- */
247
- dbInit(options: DbInitOptions): Promise<DbInitResult>;
248
- /**
249
- * Introspects the database schema.
250
- *
251
- * @returns Raw schema IR
252
- * @throws If not connected or infrastructure failure
253
- */
254
- introspect(options?: IntrospectOptions): Promise<unknown>;
255
- }
256
- //# 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,M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AE,MAAM,GAAG,SAAS,CAAC;KAC3C,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAMhE;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,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 { ControlActionName, ControlClient, ControlClientOptions, ControlProgressEvent, DbInitFailure, DbInitFailureCode, DbInitOptions, DbInitResult, DbInitSuccess, IntrospectOptions, OnControlProgress, 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,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC"}
@@ -1,9 +0,0 @@
1
- import {
2
- createControlClient
3
- } from "../chunk-74IELXRA.js";
4
- import "../chunk-6EPKRATC.js";
5
- import "../chunk-VI2YETW7.js";
6
- export {
7
- createControlClient
8
- };
9
- //# sourceMappingURL=control-api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -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"}
@@ -1,177 +0,0 @@
1
- import {
2
- createContractEmitCommand
3
- } from "../chunk-U6QI3AZ3.js";
4
- import "../chunk-5MPKZYVI.js";
5
- import "../chunk-ZG5T6OB5.js";
6
- import "../chunk-HWYQOCAJ.js";
7
- import "../chunk-VI2YETW7.js";
8
-
9
- // src/load-ts-contract.ts
10
- import { existsSync, unlinkSync, writeFileSync } from "fs";
11
- import { tmpdir } from "os";
12
- import { join } from "path";
13
- import { build } from "esbuild";
14
- var DEFAULT_ALLOWLIST = ["@prisma-next/*"];
15
- function isAllowedImport(importPath, allowlist) {
16
- for (const pattern of allowlist) {
17
- if (pattern.endsWith("/*")) {
18
- const prefix = pattern.slice(0, -2);
19
- if (importPath === prefix || importPath.startsWith(`${prefix}/`)) {
20
- return true;
21
- }
22
- } else if (importPath === pattern) {
23
- return true;
24
- }
25
- }
26
- return false;
27
- }
28
- function validatePurity(value) {
29
- if (typeof value !== "object" || value === null) {
30
- return;
31
- }
32
- const seen = /* @__PURE__ */ new WeakSet();
33
- function check(value2) {
34
- if (value2 === null || typeof value2 !== "object") {
35
- return;
36
- }
37
- if (seen.has(value2)) {
38
- throw new Error("Contract export contains circular references");
39
- }
40
- seen.add(value2);
41
- for (const key in value2) {
42
- const descriptor = Object.getOwnPropertyDescriptor(value2, key);
43
- if (descriptor && (descriptor.get || descriptor.set)) {
44
- throw new Error(`Contract export contains getter/setter at key "${key}"`);
45
- }
46
- if (descriptor && typeof descriptor.value === "function") {
47
- throw new Error(`Contract export contains function at key "${key}"`);
48
- }
49
- check(value2[key]);
50
- }
51
- }
52
- try {
53
- check(value);
54
- JSON.stringify(value);
55
- } catch (error) {
56
- if (error instanceof Error) {
57
- if (error.message.includes("getter") || error.message.includes("circular")) {
58
- throw error;
59
- }
60
- throw new Error(`Contract export is not JSON-serializable: ${error.message}`);
61
- }
62
- throw new Error("Contract export is not JSON-serializable");
63
- }
64
- }
65
- function createImportAllowlistPlugin(allowlist, entryPath) {
66
- return {
67
- name: "import-allowlist",
68
- setup(build2) {
69
- build2.onResolve({ filter: /.*/ }, (args) => {
70
- if (args.kind === "entry-point") {
71
- return void 0;
72
- }
73
- if (args.path.startsWith(".") || args.path.startsWith("/")) {
74
- return void 0;
75
- }
76
- const isFromEntryPoint = args.importer === entryPath || args.importer === "<stdin>";
77
- if (isFromEntryPoint && !isAllowedImport(args.path, allowlist)) {
78
- return {
79
- path: args.path,
80
- external: true
81
- };
82
- }
83
- return void 0;
84
- });
85
- }
86
- };
87
- }
88
- async function loadContractFromTs(entryPath, options) {
89
- const allowlist = options?.allowlist ?? DEFAULT_ALLOWLIST;
90
- if (!existsSync(entryPath)) {
91
- throw new Error(`Contract file not found: ${entryPath}`);
92
- }
93
- const tempFile = join(
94
- tmpdir(),
95
- `prisma-next-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
96
- );
97
- try {
98
- const result = await build({
99
- entryPoints: [entryPath],
100
- bundle: true,
101
- format: "esm",
102
- platform: "node",
103
- target: "es2022",
104
- outfile: tempFile,
105
- write: false,
106
- metafile: true,
107
- plugins: [createImportAllowlistPlugin(allowlist, entryPath)],
108
- logLevel: "error"
109
- });
110
- if (result.errors.length > 0) {
111
- const errorMessages = result.errors.map((e) => e.text).join("\n");
112
- throw new Error(`Failed to bundle contract file: ${errorMessages}`);
113
- }
114
- if (!result.outputFiles || result.outputFiles.length === 0) {
115
- throw new Error("No output files generated from bundling");
116
- }
117
- const disallowedImports = [];
118
- if (result.metafile) {
119
- const inputs = result.metafile.inputs;
120
- for (const [, inputData] of Object.entries(inputs)) {
121
- const imports = inputData.imports || [];
122
- for (const imp of imports) {
123
- if (imp.external && !imp.path.startsWith(".") && !imp.path.startsWith("/") && !isAllowedImport(imp.path, allowlist)) {
124
- disallowedImports.push(imp.path);
125
- }
126
- }
127
- }
128
- }
129
- if (disallowedImports.length > 0) {
130
- throw new Error(
131
- `Disallowed imports detected. Only imports matching the allowlist are permitted:
132
- Allowlist: ${allowlist.join(", ")}
133
- Disallowed imports: ${disallowedImports.join(", ")}
134
-
135
- Only @prisma-next/* packages are allowed in contract files.`
136
- );
137
- }
138
- const bundleContent = result.outputFiles[0]?.text;
139
- if (bundleContent === void 0) {
140
- throw new Error("Bundle content is undefined");
141
- }
142
- writeFileSync(tempFile, bundleContent, "utf-8");
143
- const module = await import(`file://${tempFile}`);
144
- unlinkSync(tempFile);
145
- let contract;
146
- if (module.default !== void 0) {
147
- contract = module.default;
148
- } else if (module.contract !== void 0) {
149
- contract = module.contract;
150
- } else {
151
- throw new Error(
152
- `Contract file must export a contract as default export or named export 'contract'. Found exports: ${Object.keys(module).join(", ") || "none"}`
153
- );
154
- }
155
- if (typeof contract !== "object" || contract === null) {
156
- throw new Error(`Contract export must be an object, got ${typeof contract}`);
157
- }
158
- validatePurity(contract);
159
- return contract;
160
- } catch (error) {
161
- try {
162
- if (tempFile) {
163
- unlinkSync(tempFile);
164
- }
165
- } catch {
166
- }
167
- if (error instanceof Error) {
168
- throw error;
169
- }
170
- throw new Error(`Failed to load contract from ${entryPath}: ${String(error)}`);
171
- }
172
- }
173
- export {
174
- createContractEmitCommand,
175
- loadContractFromTs
176
- };
177
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/load-ts-contract.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport type { ContractIR } from '@prisma-next/contract/ir';\nimport type { Plugin } from 'esbuild';\nimport { build } from 'esbuild';\n\nexport interface LoadTsContractOptions {\n readonly allowlist?: ReadonlyArray<string>;\n}\n\nconst DEFAULT_ALLOWLIST = ['@prisma-next/*'];\n\nfunction isAllowedImport(importPath: string, allowlist: ReadonlyArray<string>): boolean {\n for (const pattern of allowlist) {\n if (pattern.endsWith('/*')) {\n const prefix = pattern.slice(0, -2);\n if (importPath === prefix || importPath.startsWith(`${prefix}/`)) {\n return true;\n }\n } else if (importPath === pattern) {\n return true;\n }\n }\n return false;\n}\n\nfunction validatePurity(value: unknown): void {\n if (typeof value !== 'object' || value === null) {\n return;\n }\n\n const seen = new WeakSet();\n function check(value: unknown): void {\n if (value === null || typeof value !== 'object') {\n return;\n }\n\n if (seen.has(value)) {\n throw new Error('Contract export contains circular references');\n }\n seen.add(value);\n\n for (const key in value) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor && (descriptor.get || descriptor.set)) {\n throw new Error(`Contract export contains getter/setter at key \"${key}\"`);\n }\n if (descriptor && typeof descriptor.value === 'function') {\n throw new Error(`Contract export contains function at key \"${key}\"`);\n }\n check((value as Record<string, unknown>)[key]);\n }\n }\n\n try {\n check(value);\n JSON.stringify(value);\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('getter') || error.message.includes('circular')) {\n throw error;\n }\n throw new Error(`Contract export is not JSON-serializable: ${error.message}`);\n }\n throw new Error('Contract export is not JSON-serializable');\n }\n}\n\nfunction createImportAllowlistPlugin(allowlist: ReadonlyArray<string>, entryPath: string): Plugin {\n return {\n name: 'import-allowlist',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n if (args.kind === 'entry-point') {\n return undefined;\n }\n if (args.path.startsWith('.') || args.path.startsWith('/')) {\n return undefined;\n }\n const isFromEntryPoint = args.importer === entryPath || args.importer === '<stdin>';\n if (isFromEntryPoint && !isAllowedImport(args.path, allowlist)) {\n return {\n path: args.path,\n external: true,\n };\n }\n return undefined;\n });\n },\n };\n}\n\n/**\n * Loads a contract from a TypeScript file and returns it as ContractIR.\n *\n * **Responsibility: Parsing Only**\n * This function loads and parses a TypeScript contract file. It does NOT normalize the contract.\n * The contract should already be normalized if it was built using the contract builder.\n *\n * Normalization must happen in the contract builder when the contract is created.\n * This function only validates that the contract is JSON-serializable and returns it as-is.\n *\n * @param entryPath - Path to the TypeScript contract file\n * @param options - Optional configuration (import allowlist)\n * @returns The contract as ContractIR (should already be normalized)\n * @throws Error if the contract cannot be loaded or is not JSON-serializable\n */\nexport async function loadContractFromTs(\n entryPath: string,\n options?: LoadTsContractOptions,\n): Promise<ContractIR> {\n const allowlist = options?.allowlist ?? DEFAULT_ALLOWLIST;\n\n if (!existsSync(entryPath)) {\n throw new Error(`Contract file not found: ${entryPath}`);\n }\n\n const tempFile = join(\n tmpdir(),\n `prisma-next-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`,\n );\n\n try {\n const result = await build({\n entryPoints: [entryPath],\n bundle: true,\n format: 'esm',\n platform: 'node',\n target: 'es2022',\n outfile: tempFile,\n write: false,\n metafile: true,\n plugins: [createImportAllowlistPlugin(allowlist, entryPath)],\n logLevel: 'error',\n });\n\n if (result.errors.length > 0) {\n const errorMessages = result.errors.map((e: { text: string }) => e.text).join('\\n');\n throw new Error(`Failed to bundle contract file: ${errorMessages}`);\n }\n\n if (!result.outputFiles || result.outputFiles.length === 0) {\n throw new Error('No output files generated from bundling');\n }\n\n const disallowedImports: string[] = [];\n if (result.metafile) {\n const inputs = result.metafile.inputs;\n for (const [, inputData] of Object.entries(inputs)) {\n const imports =\n (inputData as { imports?: Array<{ path: string; external?: boolean }> }).imports || [];\n for (const imp of imports) {\n if (\n imp.external &&\n !imp.path.startsWith('.') &&\n !imp.path.startsWith('/') &&\n !isAllowedImport(imp.path, allowlist)\n ) {\n disallowedImports.push(imp.path);\n }\n }\n }\n }\n\n if (disallowedImports.length > 0) {\n throw new Error(\n `Disallowed imports detected. Only imports matching the allowlist are permitted:\\n Allowlist: ${allowlist.join(', ')}\\n Disallowed imports: ${disallowedImports.join(', ')}\\n\\nOnly @prisma-next/* packages are allowed in contract files.`,\n );\n }\n\n const bundleContent = result.outputFiles[0]?.text;\n if (bundleContent === undefined) {\n throw new Error('Bundle content is undefined');\n }\n writeFileSync(tempFile, bundleContent, 'utf-8');\n\n const module = (await import(`file://${tempFile}`)) as {\n default?: unknown;\n contract?: unknown;\n };\n unlinkSync(tempFile);\n\n let contract: unknown;\n\n if (module.default !== undefined) {\n contract = module.default;\n } else if (module.contract !== undefined) {\n contract = module.contract;\n } else {\n throw new Error(\n `Contract file must export a contract as default export or named export 'contract'. Found exports: ${Object.keys(module as Record<string, unknown>).join(', ') || 'none'}`,\n );\n }\n\n if (typeof contract !== 'object' || contract === null) {\n throw new Error(`Contract export must be an object, got ${typeof contract}`);\n }\n\n validatePurity(contract);\n\n return contract as ContractIR;\n } catch (error) {\n try {\n if (tempFile) {\n unlinkSync(tempFile);\n }\n } catch {\n // Ignore cleanup errors\n }\n\n if (error instanceof Error) {\n throw error;\n }\n throw new Error(`Failed to load contract from ${entryPath}: ${String(error)}`);\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,YAAY,YAAY,qBAAqB;AACtD,SAAS,cAAc;AACvB,SAAS,YAAY;AAGrB,SAAS,aAAa;AAMtB,IAAM,oBAAoB,CAAC,gBAAgB;AAE3C,SAAS,gBAAgB,YAAoB,WAA2C;AACtF,aAAW,WAAW,WAAW;AA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YAAM,IAAI,MAAM,0CAA0C,OAAO,QAAQ,EAAE;AAAA,IAC7E;AAEA,mBAAe,QAAQ;AAEvB,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI;AACF,UAAI,UAAU;AACZ,mBAAW,QAAQ;AAAA,MACrB;AAAA,IACF,QAAQ;AAAA,IAER;AAEA,QAAI,iBAAiB,OAAO;AAC1B,YAAM;AAAA,IACR;AACA,UAAM,IAAI,MAAM,gCAAgC,SAAS,KAAK,OAAO,KAAK,CAAC,EAAE;AAAA,EAC/E;AACF;","names":["value","build"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"load-ts-contract.d.ts","sourceRoot":"","sources":["../src/load-ts-contract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAI3D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC5C;AAoFD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAyGrB"}
@@ -1,16 +0,0 @@
1
- import type { Result } from '@prisma-next/utils/result';
2
- import { CliStructuredError } from './cli-errors';
3
- export type CliResult<T> = Result<T, CliStructuredError>;
4
- /**
5
- * Performs an async action and catches structured errors, returning a Result.
6
- * Only catches CliStructuredError instances - other errors are allowed to propagate (fail fast).
7
- * If the function throws a CliStructuredError, it's caught and converted to a NotOk result.
8
- */
9
- export declare function performAction<T>(fn: () => Promise<T>): Promise<CliResult<T>>;
10
- /**
11
- * Wraps a synchronous function to catch structured errors and return a Result.
12
- * Only catches CliStructuredError instances - other errors are allowed to propagate (fail fast).
13
- * If the function throws a CliStructuredError, it's caught and converted to a NotOk result.
14
- */
15
- export declare function wrapSync<T>(fn: () => T): CliResult<T>;
16
- //# sourceMappingURL=action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/utils/action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAEzD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAYlF;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAYrD"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Re-export all domain error factories from core-control-plane for convenience.
3
- * CLI-specific errors (e.g., Commander.js argument validation) can be added here if needed.
4
- */
5
- export type { CliErrorConflict, CliErrorEnvelope } from '@prisma-next/core-control-plane/errors';
6
- export { CliStructuredError, errorConfigFileNotFound, errorConfigValidation, errorContractConfigMissing, errorContractMissingExtensionPacks, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFamilyReadMarkerSqlRequired, errorFileNotFound, errorHashMismatch, errorJsonFormatNotSupported, errorMarkerMissing, errorMigrationPlanningFailed, errorQueryRunnerFactoryRequired, errorRuntime, errorTargetMigrationNotSupported, errorTargetMismatch, errorUnexpected, } from '@prisma-next/core-control-plane/errors';
7
- //# sourceMappingURL=cli-errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-errors.d.ts","sourceRoot":"","sources":["../../src/utils/cli-errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AACjG,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,gCAAgC,EAChC,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,+BAA+B,EAC/B,YAAY,EACZ,gCAAgC,EAChC,mBAAmB,EACnB,eAAe,GAChB,MAAM,wCAAwC,CAAC"}
@@ -1,12 +0,0 @@
1
- import type { Command } from 'commander';
2
- /**
3
- * Sets both short and long descriptions for a command.
4
- * The short description is used in command trees and headers.
5
- * The long description is shown at the bottom of help output.
6
- */
7
- export declare function setCommandDescriptions(command: Command, shortDescription: string, longDescription?: string): Command;
8
- /**
9
- * Gets the long description from a command if it was set via setCommandDescriptions.
10
- */
11
- export declare function getLongDescription(command: Command): string | undefined;
12
- //# sourceMappingURL=command-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/command-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,EACxB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAOT;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEvE"}