@prisma-next/cli 0.3.0-dev.2 → 0.3.0-dev.20

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 (101) hide show
  1. package/README.md +111 -27
  2. package/dist/{chunk-BZMBKEEQ.js → chunk-AGOTG4L3.js} +44 -76
  3. package/dist/chunk-AGOTG4L3.js.map +1 -0
  4. package/dist/chunk-HLLI4YL7.js +180 -0
  5. package/dist/chunk-HLLI4YL7.js.map +1 -0
  6. package/dist/chunk-VG2R7DGF.js +735 -0
  7. package/dist/chunk-VG2R7DGF.js.map +1 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +1502 -968
  11. package/dist/cli.js.map +1 -1
  12. package/dist/commands/contract-emit.d.ts +2 -4
  13. package/dist/commands/contract-emit.d.ts.map +1 -0
  14. package/dist/commands/contract-emit.js +3 -2
  15. package/dist/commands/db-init.d.ts +2 -4
  16. package/dist/commands/db-init.d.ts.map +1 -0
  17. package/dist/commands/db-init.js +205 -289
  18. package/dist/commands/db-init.js.map +1 -1
  19. package/dist/commands/db-introspect.d.ts +2 -4
  20. package/dist/commands/db-introspect.d.ts.map +1 -0
  21. package/dist/commands/db-introspect.js +108 -143
  22. package/dist/commands/db-introspect.js.map +1 -1
  23. package/dist/commands/db-schema-verify.d.ts +2 -4
  24. package/dist/commands/db-schema-verify.d.ts.map +1 -0
  25. package/dist/commands/db-schema-verify.js +120 -113
  26. package/dist/commands/db-schema-verify.js.map +1 -1
  27. package/dist/commands/db-sign.d.ts +2 -4
  28. package/dist/commands/db-sign.d.ts.map +1 -0
  29. package/dist/commands/db-sign.js +152 -156
  30. package/dist/commands/db-sign.js.map +1 -1
  31. package/dist/commands/db-verify.d.ts +2 -4
  32. package/dist/commands/db-verify.d.ts.map +1 -0
  33. package/dist/commands/db-verify.js +142 -122
  34. package/dist/commands/db-verify.js.map +1 -1
  35. package/dist/config-loader.d.ts +3 -5
  36. package/dist/config-loader.d.ts.map +1 -0
  37. package/dist/control-api/client.d.ts +13 -0
  38. package/dist/control-api/client.d.ts.map +1 -0
  39. package/dist/control-api/operations/db-init.d.ts +29 -0
  40. package/dist/control-api/operations/db-init.d.ts.map +1 -0
  41. package/dist/control-api/types.d.ts +387 -0
  42. package/dist/control-api/types.d.ts.map +1 -0
  43. package/dist/exports/config-types.d.ts +3 -0
  44. package/dist/exports/config-types.d.ts.map +1 -0
  45. package/dist/exports/config-types.js.map +1 -0
  46. package/dist/exports/control-api.d.ts +13 -0
  47. package/dist/exports/control-api.d.ts.map +1 -0
  48. package/dist/exports/control-api.js +7 -0
  49. package/dist/exports/control-api.js.map +1 -0
  50. package/dist/exports/index.d.ts +4 -0
  51. package/dist/exports/index.d.ts.map +1 -0
  52. package/dist/{index.js → exports/index.js} +4 -3
  53. package/dist/exports/index.js.map +1 -0
  54. package/dist/{index.d.ts → load-ts-contract.d.ts} +4 -8
  55. package/dist/load-ts-contract.d.ts.map +1 -0
  56. package/dist/utils/cli-errors.d.ts +7 -0
  57. package/dist/utils/cli-errors.d.ts.map +1 -0
  58. package/dist/utils/command-helpers.d.ts +12 -0
  59. package/dist/utils/command-helpers.d.ts.map +1 -0
  60. package/dist/utils/framework-components.d.ts +70 -0
  61. package/dist/utils/framework-components.d.ts.map +1 -0
  62. package/dist/utils/global-flags.d.ts +25 -0
  63. package/dist/utils/global-flags.d.ts.map +1 -0
  64. package/dist/utils/output.d.ts +142 -0
  65. package/dist/utils/output.d.ts.map +1 -0
  66. package/dist/utils/progress-adapter.d.ts +26 -0
  67. package/dist/utils/progress-adapter.d.ts.map +1 -0
  68. package/dist/utils/result-handler.d.ts +15 -0
  69. package/dist/utils/result-handler.d.ts.map +1 -0
  70. package/package.json +28 -25
  71. package/src/cli.ts +260 -0
  72. package/src/commands/contract-emit.ts +259 -0
  73. package/src/commands/db-init.ts +360 -0
  74. package/src/commands/db-introspect.ts +227 -0
  75. package/src/commands/db-schema-verify.ts +238 -0
  76. package/src/commands/db-sign.ts +279 -0
  77. package/src/commands/db-verify.ts +258 -0
  78. package/src/config-loader.ts +76 -0
  79. package/src/control-api/client.ts +589 -0
  80. package/src/control-api/operations/db-init.ts +281 -0
  81. package/src/control-api/types.ts +461 -0
  82. package/src/exports/config-types.ts +6 -0
  83. package/src/exports/control-api.ts +46 -0
  84. package/src/exports/index.ts +4 -0
  85. package/src/load-ts-contract.ts +217 -0
  86. package/src/utils/cli-errors.ts +26 -0
  87. package/src/utils/command-helpers.ts +26 -0
  88. package/src/utils/framework-components.ts +177 -0
  89. package/src/utils/global-flags.ts +75 -0
  90. package/src/utils/output.ts +1471 -0
  91. package/src/utils/progress-adapter.ts +86 -0
  92. package/src/utils/result-handler.ts +44 -0
  93. package/dist/chunk-464LNZCE.js +0 -134
  94. package/dist/chunk-464LNZCE.js.map +0 -1
  95. package/dist/chunk-BZMBKEEQ.js.map +0 -1
  96. package/dist/chunk-ZKYEJROM.js +0 -94
  97. package/dist/chunk-ZKYEJROM.js.map +0 -1
  98. package/dist/config-types.d.ts +0 -1
  99. package/dist/config-types.js.map +0 -1
  100. package/dist/index.js.map +0 -1
  101. /package/dist/{config-types.js → exports/config-types.js} +0 -0
@@ -0,0 +1,387 @@
1
+ import type { CoreSchemaView } from '@prisma-next/core-control-plane/schema-view';
2
+ import type { ControlAdapterDescriptor, ControlDriverDescriptor, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlTargetDescriptor, MigrationPlannerConflict, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from '@prisma-next/core-control-plane/types';
3
+ import type { Result } from '@prisma-next/utils/result';
4
+ /**
5
+ * Options for creating a control client.
6
+ *
7
+ * Note: This is NOT the same as CLI config. There's no `contract` field,
8
+ * no file paths. The client is config-agnostic.
9
+ *
10
+ * The descriptor types use permissive `any` because family-specific descriptors
11
+ * (e.g., SqlFamilyDescriptor) have more specific `create` method signatures that
12
+ * are not compatible with the base ControlFamilyDescriptor type due to TypeScript
13
+ * variance rules. The client implementation casts these internally.
14
+ */
15
+ export interface ControlClientOptions {
16
+ readonly family: ControlFamilyDescriptor<any, any>;
17
+ readonly target: ControlTargetDescriptor<any, any, any, any>;
18
+ readonly adapter: ControlAdapterDescriptor<any, any, any>;
19
+ /** Optional - control client can be created without driver for offline operations */
20
+ readonly driver?: ControlDriverDescriptor<any, any, any, any>;
21
+ readonly extensionPacks?: ReadonlyArray<ControlExtensionDescriptor<any, any, any>>;
22
+ /**
23
+ * Optional default connection for auto-connect.
24
+ * When provided, operations will auto-connect if not already connected.
25
+ * The type is driver-specific (e.g., string URL for Postgres).
26
+ */
27
+ readonly connection?: unknown;
28
+ }
29
+ /**
30
+ * Action names for control-api operations that can emit progress events.
31
+ */
32
+ export type ControlActionName = 'dbInit' | 'verify' | 'schemaVerify' | 'sign' | 'introspect' | 'emit';
33
+ /**
34
+ * Progress event emitted during control-api operation execution.
35
+ *
36
+ * Events model operation progress using a span-based model:
37
+ * - `spanStart`: Begin a timed segment (supports nesting via parentSpanId)
38
+ * - `spanEnd`: Complete a timed segment
39
+ *
40
+ * All operation-specific progress (e.g., per-migration-operation) is modeled
41
+ * as nested spans rather than special event types.
42
+ *
43
+ * Events are delivered via an optional `onProgress` callback to avoid polluting
44
+ * return types. If the callback is absent, operations emit no events (zero overhead).
45
+ */
46
+ export type ControlProgressEvent = {
47
+ readonly action: ControlActionName;
48
+ readonly kind: 'spanStart';
49
+ readonly spanId: string;
50
+ readonly parentSpanId?: string;
51
+ readonly label: string;
52
+ } | {
53
+ readonly action: ControlActionName;
54
+ readonly kind: 'spanEnd';
55
+ readonly spanId: string;
56
+ readonly outcome: 'ok' | 'skipped' | 'error';
57
+ };
58
+ /**
59
+ * Callback function for receiving progress events during control-api operations.
60
+ *
61
+ * @param event - The progress event emitted by the operation
62
+ */
63
+ export type OnControlProgress = (event: ControlProgressEvent) => void;
64
+ /**
65
+ * Options for the verify operation.
66
+ */
67
+ export interface VerifyOptions {
68
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
69
+ readonly contractIR: unknown;
70
+ /**
71
+ * Database connection. If provided, verify will connect before executing.
72
+ * If omitted, the client must already be connected.
73
+ * The type is driver-specific (e.g., string URL for Postgres).
74
+ */
75
+ readonly connection?: unknown;
76
+ /** Optional progress callback for observing operation progress */
77
+ readonly onProgress?: OnControlProgress;
78
+ }
79
+ /**
80
+ * Options for the schemaVerify operation.
81
+ */
82
+ export interface SchemaVerifyOptions {
83
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
84
+ readonly contractIR: unknown;
85
+ /**
86
+ * Whether to use strict mode for schema verification.
87
+ * In strict mode, extra tables/columns are reported as issues.
88
+ * Default: false (tolerant mode - allows superset)
89
+ */
90
+ readonly strict?: boolean;
91
+ /**
92
+ * Database connection. If provided, schemaVerify will connect before executing.
93
+ * If omitted, the client must already be connected.
94
+ * The type is driver-specific (e.g., string URL for Postgres).
95
+ */
96
+ readonly connection?: unknown;
97
+ /** Optional progress callback for observing operation progress */
98
+ readonly onProgress?: OnControlProgress;
99
+ }
100
+ /**
101
+ * Options for the sign operation.
102
+ */
103
+ export interface SignOptions {
104
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
105
+ readonly contractIR: unknown;
106
+ /**
107
+ * Path to the contract file (for metadata in the result).
108
+ */
109
+ readonly contractPath?: string;
110
+ /**
111
+ * Path to the config file (for metadata in the result).
112
+ */
113
+ readonly configPath?: string;
114
+ /**
115
+ * Database connection. If provided, sign will connect before executing.
116
+ * If omitted, the client must already be connected.
117
+ * The type is driver-specific (e.g., string URL for Postgres).
118
+ */
119
+ readonly connection?: unknown;
120
+ /** Optional progress callback for observing operation progress */
121
+ readonly onProgress?: OnControlProgress;
122
+ }
123
+ /**
124
+ * Options for the dbInit operation.
125
+ */
126
+ export interface DbInitOptions {
127
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
128
+ readonly contractIR: unknown;
129
+ /**
130
+ * Mode for the dbInit operation.
131
+ * - 'plan': Returns planned operations without applying
132
+ * - 'apply': Applies operations and writes marker
133
+ */
134
+ readonly mode: 'plan' | 'apply';
135
+ /**
136
+ * Database connection. If provided, dbInit will connect before executing.
137
+ * If omitted, the client must already be connected.
138
+ * The type is driver-specific (e.g., string URL for Postgres).
139
+ */
140
+ readonly connection?: unknown;
141
+ /** Optional progress callback for observing operation progress */
142
+ readonly onProgress?: OnControlProgress;
143
+ }
144
+ /**
145
+ * Options for the introspect operation.
146
+ */
147
+ export interface IntrospectOptions {
148
+ /**
149
+ * Optional schema name to introspect.
150
+ */
151
+ readonly schema?: string;
152
+ /**
153
+ * Database connection. If provided, introspect will connect before executing.
154
+ * If omitted, the client must already be connected.
155
+ * The type is driver-specific (e.g., string URL for Postgres).
156
+ */
157
+ readonly connection?: unknown;
158
+ /** Optional progress callback for observing operation progress */
159
+ readonly onProgress?: OnControlProgress;
160
+ }
161
+ /**
162
+ * Contract source as a raw value (any JSON-serializable value).
163
+ */
164
+ export interface ContractSourceValue {
165
+ readonly kind: 'value';
166
+ readonly value: unknown;
167
+ }
168
+ /**
169
+ * Contract source as a lazy loader function.
170
+ */
171
+ export interface ContractSourceLoader {
172
+ readonly kind: 'loader';
173
+ readonly load: () => unknown | Promise<unknown>;
174
+ }
175
+ /**
176
+ * Discriminated union for contract source.
177
+ * Use `kind` to determine how to resolve the contract.
178
+ */
179
+ export type EmitContractSource = ContractSourceValue | ContractSourceLoader;
180
+ /**
181
+ * Contract configuration for emit operation.
182
+ */
183
+ export interface EmitContractConfig {
184
+ /**
185
+ * Contract source - either a raw value or a loader function.
186
+ * Switch on `source.kind` to determine how to resolve.
187
+ */
188
+ readonly source: EmitContractSource;
189
+ /**
190
+ * Output path for contract.json.
191
+ * Should be an absolute or relative path.
192
+ */
193
+ readonly output: string;
194
+ /**
195
+ * Output path for contract.d.ts.
196
+ * Should be an absolute or relative path.
197
+ */
198
+ readonly types: string;
199
+ }
200
+ /**
201
+ * Options for the emit operation.
202
+ */
203
+ export interface EmitOptions {
204
+ /**
205
+ * Contract configuration containing source, output, and types paths.
206
+ */
207
+ readonly contractConfig: EmitContractConfig;
208
+ /** Optional progress callback for observing operation progress */
209
+ readonly onProgress?: OnControlProgress;
210
+ }
211
+ /**
212
+ * Successful dbInit result.
213
+ */
214
+ export interface DbInitSuccess {
215
+ readonly mode: 'plan' | 'apply';
216
+ readonly plan: {
217
+ readonly operations: ReadonlyArray<{
218
+ readonly id: string;
219
+ readonly label: string;
220
+ readonly operationClass: string;
221
+ }>;
222
+ };
223
+ readonly execution?: {
224
+ readonly operationsPlanned: number;
225
+ readonly operationsExecuted: number;
226
+ };
227
+ readonly marker?: {
228
+ readonly coreHash: string;
229
+ readonly profileHash?: string;
230
+ };
231
+ readonly summary: string;
232
+ }
233
+ /**
234
+ * Failure codes for dbInit operation.
235
+ */
236
+ export type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
237
+ /**
238
+ * Failure details for dbInit operation.
239
+ */
240
+ export interface DbInitFailure {
241
+ readonly code: DbInitFailureCode;
242
+ readonly summary: string;
243
+ readonly why: string | undefined;
244
+ readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
245
+ readonly meta: Record<string, unknown> | undefined;
246
+ readonly marker?: {
247
+ readonly coreHash?: string;
248
+ readonly profileHash?: string;
249
+ };
250
+ readonly destination?: {
251
+ readonly coreHash: string;
252
+ readonly profileHash?: string | undefined;
253
+ };
254
+ }
255
+ /**
256
+ * Result type for dbInit operation.
257
+ * Uses Result pattern: success returns DbInitSuccess, failure returns DbInitFailure.
258
+ */
259
+ export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
260
+ /**
261
+ * Successful emit result.
262
+ * Contains the hashes and paths of emitted files.
263
+ */
264
+ export interface EmitSuccess {
265
+ /** Core hash of the emitted contract */
266
+ readonly coreHash: string;
267
+ /** Profile hash of the emitted contract (target-specific) */
268
+ readonly profileHash: string;
269
+ /** The emitted contract as JSON string */
270
+ readonly contractJson: string;
271
+ /** The emitted contract TypeScript declarations */
272
+ readonly contractDts: string;
273
+ }
274
+ /**
275
+ * Failure codes for emit operation.
276
+ */
277
+ export type EmitFailureCode = 'CONTRACT_SOURCE_INVALID' | 'EMIT_FAILED';
278
+ /**
279
+ * Failure details for emit operation.
280
+ */
281
+ export interface EmitFailure {
282
+ readonly code: EmitFailureCode;
283
+ readonly summary: string;
284
+ readonly why: string | undefined;
285
+ readonly meta: Record<string, unknown> | undefined;
286
+ }
287
+ /**
288
+ * Result type for emit operation.
289
+ * Uses Result pattern: success returns EmitSuccess, failure returns EmitFailure.
290
+ */
291
+ export type EmitResult = Result<EmitSuccess, EmitFailure>;
292
+ /**
293
+ * Programmatic control client for Prisma Next operations.
294
+ *
295
+ * Lifecycle: `connect(connection)` before operations, `close()` when done.
296
+ * Both `init()` and `connect()` are auto-called by operations if needed,
297
+ * but `connect()` requires a connection so must be called explicitly first
298
+ * unless a default connection was provided in options.
299
+ *
300
+ * @see README.md "Programmatic Control API" section for usage examples
301
+ */
302
+ export interface ControlClient {
303
+ /**
304
+ * Initializes the client by creating the control plane stack,
305
+ * family instance, and validating framework components.
306
+ *
307
+ * Idempotent (safe to call multiple times).
308
+ * Called automatically by `connect()` if not already initialized.
309
+ */
310
+ init(): void;
311
+ /**
312
+ * Establishes a database connection.
313
+ * Auto-calls `init()` if not already initialized.
314
+ * Must be called before any database operations unless a default connection
315
+ * was provided in options.
316
+ *
317
+ * @param connection - Driver-specific connection input (e.g., URL string for Postgres).
318
+ * If omitted, uses the default connection from options (if provided).
319
+ * @throws If connection fails, already connected, driver is not configured,
320
+ * or no connection provided and no default connection in options.
321
+ */
322
+ connect(connection?: unknown): Promise<void>;
323
+ /**
324
+ * Closes the database connection.
325
+ * Idempotent (safe to call multiple times).
326
+ * After close(), can call `connect()` again with same or different URL.
327
+ */
328
+ close(): Promise<void>;
329
+ /**
330
+ * Verifies database marker matches the contract.
331
+ * Compares coreHash and profileHash.
332
+ *
333
+ * @returns Structured result (ok: false for mismatch, not throwing)
334
+ * @throws If not connected or infrastructure failure
335
+ */
336
+ verify(options: VerifyOptions): Promise<VerifyDatabaseResult>;
337
+ /**
338
+ * Verifies database schema satisfies the contract requirements.
339
+ *
340
+ * @param options.strict - If true, extra tables/columns are issues. Default: false
341
+ * @returns Structured result with schema issues
342
+ * @throws If not connected or infrastructure failure
343
+ */
344
+ schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
345
+ /**
346
+ * Signs the database with a contract marker.
347
+ * Writes or updates the contract marker if schema verification passes.
348
+ * Idempotent (no-op if marker already matches).
349
+ *
350
+ * @returns Structured result
351
+ * @throws If not connected or infrastructure failure
352
+ */
353
+ sign(options: SignOptions): Promise<SignDatabaseResult>;
354
+ /**
355
+ * Initializes database schema from contract.
356
+ * Uses additive-only policy (no destructive changes).
357
+ *
358
+ * @param options.mode - 'plan' to preview, 'apply' to execute
359
+ * @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
360
+ * @throws If not connected, target doesn't support migrations, or infrastructure failure
361
+ */
362
+ dbInit(options: DbInitOptions): Promise<DbInitResult>;
363
+ /**
364
+ * Introspects the database schema.
365
+ *
366
+ * @returns Raw schema IR
367
+ * @throws If not connected or infrastructure failure
368
+ */
369
+ introspect(options?: IntrospectOptions): Promise<unknown>;
370
+ /**
371
+ * Converts a schema IR to a schema view for CLI tree rendering.
372
+ * Delegates to the family instance's toSchemaView method.
373
+ *
374
+ * @param schemaIR - The schema IR from introspect()
375
+ * @returns CoreSchemaView if the family supports it, undefined otherwise
376
+ */
377
+ toSchemaView(schemaIR: unknown): CoreSchemaView | undefined;
378
+ /**
379
+ * Emits the contract to JSON and TypeScript declarations.
380
+ * This is an offline operation that does NOT require a database connection.
381
+ * Uses `init()` to create the stack but does NOT call `connect()`.
382
+ *
383
+ * @returns Result pattern: Ok with emit details, NotOk with failure details
384
+ */
385
+ emit(options: EmitOptions): Promise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H,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;IAE1D;;;;;;OAMG;IACH,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;IAE5D;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjD"}
@@ -0,0 +1,3 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,13 @@
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 { ContractSourceLoader, ContractSourceValue, ControlActionName, ControlClient, ControlClientOptions, ControlProgressEvent, DbInitFailure, DbInitFailureCode, DbInitOptions, DbInitResult, DbInitSuccess, EmitContractConfig, EmitContractSource, EmitFailure, EmitFailureCode, EmitOptions, EmitResult, EmitSuccess, IntrospectOptions, OnControlProgress, SchemaVerifyOptions, SignOptions, VerifyOptions, } from '../control-api/types';
13
+ //# sourceMappingURL=control-api.d.ts.map
@@ -0,0 +1 @@
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,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import {
2
+ createControlClient
3
+ } from "../chunk-VG2R7DGF.js";
4
+ export {
5
+ createControlClient
6
+ };
7
+ //# sourceMappingURL=control-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
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,8 +1,9 @@
1
1
  import {
2
2
  createContractEmitCommand
3
- } from "./chunk-464LNZCE.js";
4
- import "./chunk-BZMBKEEQ.js";
5
- import "./chunk-HWYQOCAJ.js";
3
+ } from "../chunk-HLLI4YL7.js";
4
+ import "../chunk-AGOTG4L3.js";
5
+ import "../chunk-HWYQOCAJ.js";
6
+ import "../chunk-VG2R7DGF.js";
6
7
 
7
8
  // src/load-ts-contract.ts
8
9
  import { existsSync, unlinkSync, writeFileSync } from "fs";
@@ -0,0 +1 @@
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;AAC/B,QAAI,QAAQ,SAAS,IAAI,GAAG;AAC1B,YAAM,SAAS,QAAQ,MAAM,GAAG,EAAE;AAClC,UAAI,eAAe,UAAU,WAAW,WAAW,GAAG,MAAM,GAAG,GAAG;AAChE,eAAO;AAAA,MACT;AAAA,IACF,WAAW,eAAe,SAAS;AACjC,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,eAAe,OAAsB;AAC5C,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C;AAAA,EACF;AAEA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E;AACF;","names":["value","build"]}
@@ -1,8 +1,5 @@
1
- export { createContractEmitCommand } from './commands/contract-emit.js';
2
- import { ContractIR } from '@prisma-next/contract/ir';
3
- import 'commander';
4
-
5
- interface LoadTsContractOptions {
1
+ import type { ContractIR } from '@prisma-next/contract/ir';
2
+ export interface LoadTsContractOptions {
6
3
  readonly allowlist?: ReadonlyArray<string>;
7
4
  }
8
5
  /**
@@ -20,6 +17,5 @@ interface LoadTsContractOptions {
20
17
  * @returns The contract as ContractIR (should already be normalized)
21
18
  * @throws Error if the contract cannot be loaded or is not JSON-serializable
22
19
  */
23
- declare function loadContractFromTs(entryPath: string, options?: LoadTsContractOptions): Promise<ContractIR>;
24
-
25
- export { type LoadTsContractOptions, loadContractFromTs };
20
+ export declare function loadContractFromTs(entryPath: string, options?: LoadTsContractOptions): Promise<ContractIR>;
21
+ //# sourceMappingURL=load-ts-contract.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,70 @@
1
+ import { type TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
2
+ import type { ContractIR } from '@prisma-next/contract/ir';
3
+ import type { ControlPlaneStack } from '@prisma-next/core-control-plane/types';
4
+ /**
5
+ * Asserts that all framework components are compatible with the expected family and target.
6
+ *
7
+ * This function validates that each component in the framework components array:
8
+ * - Has kind 'target', 'adapter', 'extension', or 'driver'
9
+ * - Has familyId matching expectedFamilyId
10
+ * - Has targetId matching expectedTargetId
11
+ *
12
+ * This validation happens at the CLI composition boundary, before passing components
13
+ * to typed planner/runner instances. It fills the gap between runtime validation
14
+ * (via `validateConfig()`) and compile-time type enforcement.
15
+ *
16
+ * @param expectedFamilyId - The expected family ID (e.g., 'sql')
17
+ * @param expectedTargetId - The expected target ID (e.g., 'postgres')
18
+ * @param frameworkComponents - Array of framework components to validate
19
+ * @returns The same array typed as TargetBoundComponentDescriptor
20
+ * @throws CliStructuredError if any component is incompatible
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const config = await loadConfig();
25
+ * const frameworkComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];
26
+ *
27
+ * // Validate and type-narrow components before passing to planner
28
+ * const typedComponents = assertFrameworkComponentsCompatible(
29
+ * config.family.familyId,
30
+ * config.target.targetId,
31
+ * frameworkComponents
32
+ * );
33
+ *
34
+ * const planner = target.migrations.createPlanner(familyInstance);
35
+ * planner.plan({ contract, schema, policy, frameworkComponents: typedComponents });
36
+ * ```
37
+ */
38
+ export declare function assertFrameworkComponentsCompatible<TFamilyId extends string, TTargetId extends string>(expectedFamilyId: TFamilyId, expectedTargetId: TTargetId, frameworkComponents: ReadonlyArray<unknown>): ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
39
+ /**
40
+ * Validates that a contract is compatible with the configured target, adapter,
41
+ * and extension packs. Throws on family/target mismatches or missing extension packs.
42
+ *
43
+ * This check ensures the emitted contract matches the CLI config before running
44
+ * commands that depend on the contract (e.g., db verify, db sign).
45
+ *
46
+ * @param contract - The contract IR to validate (must include targetFamily, target, extensionPacks).
47
+ * @param stack - The control plane stack (target, adapter, driver, extensionPacks).
48
+ *
49
+ * @throws {CliStructuredError} errorConfigValidation when contract.targetFamily or contract.target
50
+ * doesn't match the configured family/target.
51
+ * @throws {CliStructuredError} errorContractMissingExtensionPacks when the contract requires
52
+ * extension packs that are not provided in the config (includes all missing packs in error.meta).
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { assertContractRequirementsSatisfied } from './framework-components';
57
+ *
58
+ * const config = await loadConfig();
59
+ * const contractIR = await loadContractJson(config.contract.output);
60
+ * const stack = createControlPlaneStack({ target: config.target, adapter: config.adapter, ... });
61
+ *
62
+ * // Throws if contract is incompatible with config
63
+ * assertContractRequirementsSatisfied({ contract: contractIR, stack });
64
+ * ```
65
+ */
66
+ export declare function assertContractRequirementsSatisfied<TFamilyId extends string, TTargetId extends string>({ contract, stack, }: {
67
+ readonly contract: Pick<ContractIR, 'targetFamily' | 'target' | 'extensionPacks'>;
68
+ readonly stack: ControlPlaneStack<TFamilyId, TTargetId>;
69
+ }): void;
70
+ //# sourceMappingURL=framework-components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-components.d.ts","sourceRoot":"","sources":["../../src/utils/framework-components.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mCAAmC,CACjD,SAAS,SAAS,MAAM,EACxB,SAAS,SAAS,MAAM,EAExB,gBAAgB,EAAE,SAAS,EAC3B,gBAAgB,EAAE,SAAS,EAC3B,mBAAmB,EAAE,aAAa,CAAC,OAAO,CAAC,GAC1C,aAAa,CAAC,8BAA8B,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CA0DrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mCAAmC,CACjD,SAAS,SAAS,MAAM,EACxB,SAAS,SAAS,MAAM,EACxB,EACA,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,cAAc,GAAG,QAAQ,GAAG,gBAAgB,CAAC,CAAC;IAClF,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;CACzD,GAAG,IAAI,CA+BP"}
@@ -0,0 +1,25 @@
1
+ export interface GlobalFlags {
2
+ readonly json?: 'object' | 'ndjson';
3
+ readonly quiet?: boolean;
4
+ readonly verbose?: number;
5
+ readonly timestamps?: boolean;
6
+ readonly color?: boolean;
7
+ }
8
+ export interface CliOptions {
9
+ readonly json?: string | boolean;
10
+ readonly quiet?: boolean;
11
+ readonly q?: boolean;
12
+ readonly verbose?: boolean;
13
+ readonly v?: boolean;
14
+ readonly vv?: boolean;
15
+ readonly trace?: boolean;
16
+ readonly timestamps?: boolean;
17
+ readonly color?: boolean;
18
+ readonly 'no-color'?: boolean;
19
+ }
20
+ /**
21
+ * Parses global flags from CLI options.
22
+ * Handles verbosity flags (-v, -vv, --trace), JSON output, quiet mode, timestamps, and color.
23
+ */
24
+ export declare function parseGlobalFlags(options: CliOptions): GlobalFlags;
25
+ //# sourceMappingURL=global-flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-flags.d.ts","sourceRoot":"","sources":["../../src/utils/global-flags.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,CAiDjE"}