@prisma-next/cli 0.3.0-dev.16 → 0.3.0-dev.163
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.
- package/LICENSE +201 -0
- package/README.md +381 -128
- package/dist/cli-errors-BDCYR5ap.mjs +4 -0
- package/dist/cli-errors-Dzs7Oxz7.d.mts +3 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.js +1 -2671
- package/dist/cli.mjs +238 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client-yYtotiSX.mjs +1063 -0
- package/dist/client-yYtotiSX.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts +7 -0
- package/dist/commands/contract-emit.d.mts.map +1 -0
- package/dist/commands/contract-emit.mjs +4 -0
- package/dist/commands/contract-infer.d.mts +7 -0
- package/dist/commands/contract-infer.d.mts.map +1 -0
- package/dist/commands/contract-infer.mjs +4 -0
- package/dist/commands/db-init.d.mts +7 -0
- package/dist/commands/db-init.d.mts.map +1 -0
- package/dist/commands/db-init.mjs +124 -0
- package/dist/commands/db-init.mjs.map +1 -0
- package/dist/commands/db-schema.d.mts +7 -0
- package/dist/commands/db-schema.d.mts.map +1 -0
- package/dist/commands/db-schema.mjs +52 -0
- package/dist/commands/db-schema.mjs.map +1 -0
- package/dist/commands/db-sign.d.mts +7 -0
- package/dist/commands/db-sign.d.mts.map +1 -0
- package/dist/commands/db-sign.mjs +135 -0
- package/dist/commands/db-sign.mjs.map +1 -0
- package/dist/commands/db-update.d.mts +7 -0
- package/dist/commands/db-update.d.mts.map +1 -0
- package/dist/commands/db-update.mjs +121 -0
- package/dist/commands/db-update.mjs.map +1 -0
- package/dist/commands/db-verify.d.mts +7 -0
- package/dist/commands/db-verify.d.mts.map +1 -0
- package/dist/commands/db-verify.mjs +321 -0
- package/dist/commands/db-verify.mjs.map +1 -0
- package/dist/commands/migration-apply.d.mts +36 -0
- package/dist/commands/migration-apply.d.mts.map +1 -0
- package/dist/commands/migration-apply.mjs +243 -0
- package/dist/commands/migration-apply.mjs.map +1 -0
- package/dist/commands/migration-new.d.mts +8 -0
- package/dist/commands/migration-new.d.mts.map +1 -0
- package/dist/commands/migration-new.mjs +151 -0
- package/dist/commands/migration-new.mjs.map +1 -0
- package/dist/commands/migration-plan.d.mts +47 -0
- package/dist/commands/migration-plan.d.mts.map +1 -0
- package/dist/commands/migration-plan.mjs +312 -0
- package/dist/commands/migration-plan.mjs.map +1 -0
- package/dist/commands/migration-ref.d.mts +43 -0
- package/dist/commands/migration-ref.d.mts.map +1 -0
- package/dist/commands/migration-ref.mjs +194 -0
- package/dist/commands/migration-ref.mjs.map +1 -0
- package/dist/commands/migration-show.d.mts +28 -0
- package/dist/commands/migration-show.d.mts.map +1 -0
- package/dist/commands/migration-show.mjs +139 -0
- package/dist/commands/migration-show.mjs.map +1 -0
- package/dist/commands/migration-status.d.mts +86 -0
- package/dist/commands/migration-status.d.mts.map +1 -0
- package/dist/commands/migration-status.mjs +4 -0
- package/dist/commands/migration-verify.d.mts +16 -0
- package/dist/commands/migration-verify.d.mts.map +1 -0
- package/dist/commands/migration-verify.mjs +109 -0
- package/dist/commands/migration-verify.mjs.map +1 -0
- package/dist/config-loader-C4VXKl8f.mjs +43 -0
- package/dist/config-loader-C4VXKl8f.mjs.map +1 -0
- package/dist/{config-loader.d.ts → config-loader.d.mts} +8 -3
- package/dist/config-loader.d.mts.map +1 -0
- package/dist/config-loader.mjs +3 -0
- package/dist/contract-emit-Bk_eEDKu.mjs +187 -0
- package/dist/contract-emit-Bk_eEDKu.mjs.map +1 -0
- package/dist/contract-infer-suMDmFSG.mjs +89 -0
- package/dist/contract-infer-suMDmFSG.mjs.map +1 -0
- package/dist/exports/config-types.d.mts +2 -0
- package/dist/exports/config-types.mjs +3 -0
- package/dist/exports/control-api.d.mts +624 -0
- package/dist/exports/control-api.d.mts.map +1 -0
- package/dist/exports/control-api.mjs +109 -0
- package/dist/exports/control-api.mjs.map +1 -0
- package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +12 -7
- package/dist/exports/index.d.mts.map +1 -0
- package/dist/exports/index.mjs +137 -0
- package/dist/exports/index.mjs.map +1 -0
- package/dist/extract-operation-statements-BVlb3jxp.mjs +13 -0
- package/dist/extract-operation-statements-BVlb3jxp.mjs.map +1 -0
- package/dist/extract-sql-ddl-6EVSOThm.mjs +26 -0
- package/dist/extract-sql-ddl-6EVSOThm.mjs.map +1 -0
- package/dist/framework-components-BAsliT4V.mjs +59 -0
- package/dist/framework-components-BAsliT4V.mjs.map +1 -0
- package/dist/inspect-live-schema-HMutsJYh.mjs +91 -0
- package/dist/inspect-live-schema-HMutsJYh.mjs.map +1 -0
- package/dist/migration-command-scaffold-Dg7CKKCg.mjs +105 -0
- package/dist/migration-command-scaffold-Dg7CKKCg.mjs.map +1 -0
- package/dist/migration-status-BqfVmC0w.mjs +1582 -0
- package/dist/migration-status-BqfVmC0w.mjs.map +1 -0
- package/dist/migrations-Bv8oeiY_.mjs +173 -0
- package/dist/migrations-Bv8oeiY_.mjs.map +1 -0
- package/dist/progress-adapter-D4x8SbJa.mjs +43 -0
- package/dist/progress-adapter-D4x8SbJa.mjs.map +1 -0
- package/dist/terminal-ui-N5tR-ob5.mjs +967 -0
- package/dist/terminal-ui-N5tR-ob5.mjs.map +1 -0
- package/dist/verify-WARh5TjK.mjs +385 -0
- package/dist/verify-WARh5TjK.mjs.map +1 -0
- package/package.json +88 -42
- package/src/cli.ts +113 -58
- package/src/commands/contract-emit.ts +237 -144
- package/src/commands/contract-infer-paths.ts +32 -0
- package/src/commands/contract-infer.ts +143 -0
- package/src/commands/db-init.ts +97 -219
- package/src/commands/db-schema.ts +77 -0
- package/src/commands/db-sign.ts +208 -229
- package/src/commands/db-update.ts +236 -0
- package/src/commands/db-verify.ts +504 -184
- package/src/commands/inspect-live-schema.ts +170 -0
- package/src/commands/migration-apply.ts +427 -0
- package/src/commands/migration-new.ts +260 -0
- package/src/commands/migration-plan.ts +519 -0
- package/src/commands/migration-ref.ts +305 -0
- package/src/commands/migration-show.ts +246 -0
- package/src/commands/migration-status.ts +864 -0
- package/src/commands/migration-verify.ts +180 -0
- package/src/config-loader.ts +13 -3
- package/src/control-api/client.ts +424 -72
- package/src/control-api/contract-enrichment.ts +119 -0
- package/src/control-api/errors.ts +9 -0
- package/src/control-api/operations/contract-emit.ts +174 -0
- package/src/control-api/operations/db-init.ts +53 -49
- package/src/control-api/operations/db-update.ts +220 -0
- package/src/control-api/operations/extract-operation-statements.ts +14 -0
- package/src/control-api/operations/extract-sql-ddl.ts +47 -0
- package/src/control-api/operations/migration-apply.ts +191 -0
- package/src/control-api/operations/migration-helpers.ts +49 -0
- package/src/control-api/types.ts +388 -18
- package/src/exports/config-types.ts +4 -3
- package/src/exports/control-api.ts +21 -2
- package/src/load-ts-contract.ts +30 -19
- package/src/utils/cli-errors.ts +14 -8
- package/src/utils/command-helpers.ts +302 -3
- package/src/utils/formatters/emit.ts +67 -0
- package/src/utils/formatters/errors.ts +82 -0
- package/src/utils/formatters/graph-migration-mapper.ts +240 -0
- package/src/utils/formatters/graph-render.ts +1323 -0
- package/src/utils/formatters/graph-types.ts +120 -0
- package/src/utils/formatters/help.ts +380 -0
- package/src/utils/formatters/helpers.ts +28 -0
- package/src/utils/formatters/migrations.ts +346 -0
- package/src/utils/formatters/styled.ts +212 -0
- package/src/utils/formatters/verify.ts +621 -0
- package/src/utils/framework-components.ts +13 -10
- package/src/utils/global-flags.ts +41 -23
- package/src/utils/migration-command-scaffold.ts +184 -0
- package/src/utils/migration-types.ts +12 -0
- package/src/utils/progress-adapter.ts +18 -29
- package/src/utils/result-handler.ts +12 -13
- package/src/utils/shutdown.ts +92 -0
- package/src/utils/suggest-command.ts +31 -0
- package/src/utils/terminal-ui.ts +276 -0
- package/dist/chunk-5MPKZYVI.js +0 -47
- package/dist/chunk-5MPKZYVI.js.map +0 -1
- package/dist/chunk-6EPKRATC.js +0 -91
- package/dist/chunk-6EPKRATC.js.map +0 -1
- package/dist/chunk-74IELXRA.js +0 -371
- package/dist/chunk-74IELXRA.js.map +0 -1
- package/dist/chunk-HWYQOCAJ.js +0 -47
- package/dist/chunk-HWYQOCAJ.js.map +0 -1
- package/dist/chunk-U6QI3AZ3.js +0 -133
- package/dist/chunk-U6QI3AZ3.js.map +0 -1
- package/dist/chunk-VI2YETW7.js +0 -38
- package/dist/chunk-VI2YETW7.js.map +0 -1
- package/dist/chunk-ZG5T6OB5.js +0 -923
- package/dist/chunk-ZG5T6OB5.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/contract-emit.d.ts +0 -3
- package/dist/commands/contract-emit.d.ts.map +0 -1
- package/dist/commands/contract-emit.js +0 -11
- package/dist/commands/contract-emit.js.map +0 -1
- package/dist/commands/db-init.d.ts +0 -3
- package/dist/commands/db-init.d.ts.map +0 -1
- package/dist/commands/db-init.js +0 -302
- package/dist/commands/db-init.js.map +0 -1
- package/dist/commands/db-introspect.d.ts +0 -3
- package/dist/commands/db-introspect.d.ts.map +0 -1
- package/dist/commands/db-introspect.js +0 -185
- package/dist/commands/db-introspect.js.map +0 -1
- package/dist/commands/db-schema-verify.d.ts +0 -3
- package/dist/commands/db-schema-verify.d.ts.map +0 -1
- package/dist/commands/db-schema-verify.js +0 -163
- package/dist/commands/db-schema-verify.js.map +0 -1
- package/dist/commands/db-sign.d.ts +0 -3
- package/dist/commands/db-sign.d.ts.map +0 -1
- package/dist/commands/db-sign.js +0 -198
- package/dist/commands/db-sign.js.map +0 -1
- package/dist/commands/db-verify.d.ts +0 -3
- package/dist/commands/db-verify.d.ts.map +0 -1
- package/dist/commands/db-verify.js +0 -172
- package/dist/commands/db-verify.js.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -7
- package/dist/config-loader.js.map +0 -1
- package/dist/control-api/client.d.ts +0 -13
- package/dist/control-api/client.d.ts.map +0 -1
- package/dist/control-api/operations/db-init.d.ts +0 -29
- package/dist/control-api/operations/db-init.d.ts.map +0 -1
- package/dist/control-api/types.d.ts +0 -256
- package/dist/control-api/types.d.ts.map +0 -1
- package/dist/exports/config-types.d.ts +0 -3
- package/dist/exports/config-types.d.ts.map +0 -1
- package/dist/exports/config-types.js +0 -6
- package/dist/exports/config-types.js.map +0 -1
- package/dist/exports/control-api.d.ts +0 -13
- package/dist/exports/control-api.d.ts.map +0 -1
- package/dist/exports/control-api.js +0 -9
- package/dist/exports/control-api.js.map +0 -1
- package/dist/exports/index.d.ts +0 -4
- package/dist/exports/index.d.ts.map +0 -1
- package/dist/exports/index.js +0 -177
- package/dist/exports/index.js.map +0 -1
- package/dist/load-ts-contract.d.ts.map +0 -1
- package/dist/utils/action.d.ts +0 -16
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/cli-errors.d.ts +0 -7
- package/dist/utils/cli-errors.d.ts.map +0 -1
- package/dist/utils/command-helpers.d.ts +0 -12
- package/dist/utils/command-helpers.d.ts.map +0 -1
- package/dist/utils/framework-components.d.ts +0 -70
- package/dist/utils/framework-components.d.ts.map +0 -1
- package/dist/utils/global-flags.d.ts +0 -25
- package/dist/utils/global-flags.d.ts.map +0 -1
- package/dist/utils/output.d.ts +0 -142
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/progress-adapter.d.ts +0 -26
- package/dist/utils/progress-adapter.d.ts.map +0 -1
- package/dist/utils/result-handler.d.ts +0 -15
- package/dist/utils/result-handler.d.ts.map +0 -1
- package/dist/utils/spinner.d.ts +0 -29
- package/dist/utils/spinner.d.ts.map +0 -1
- package/src/commands/db-introspect.ts +0 -254
- package/src/commands/db-schema-verify.ts +0 -231
- package/src/utils/action.ts +0 -43
- package/src/utils/output.ts +0 -1471
- package/src/utils/spinner.ts +0 -67
|
@@ -1,70 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/utils/output.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
export interface EmitContractResult {
|
|
3
|
-
readonly coreHash: string;
|
|
4
|
-
readonly profileHash: string;
|
|
5
|
-
readonly outDir: string;
|
|
6
|
-
readonly files: {
|
|
7
|
-
readonly json: string;
|
|
8
|
-
readonly dts: string;
|
|
9
|
-
};
|
|
10
|
-
readonly timings: {
|
|
11
|
-
readonly total: number;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
import type { CoreSchemaView } from '@prisma-next/core-control-plane/schema-view';
|
|
15
|
-
import type { IntrospectSchemaResult, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from '@prisma-next/core-control-plane/types';
|
|
16
|
-
import type { CliErrorEnvelope } from './cli-errors';
|
|
17
|
-
import type { GlobalFlags } from './global-flags';
|
|
18
|
-
/**
|
|
19
|
-
* Formats human-readable output for contract emit.
|
|
20
|
-
*/
|
|
21
|
-
export declare function formatEmitOutput(result: EmitContractResult, flags: GlobalFlags): string;
|
|
22
|
-
/**
|
|
23
|
-
* Formats JSON output for contract emit.
|
|
24
|
-
*/
|
|
25
|
-
export declare function formatEmitJson(result: EmitContractResult): string;
|
|
26
|
-
/**
|
|
27
|
-
* Formats error output for human-readable display.
|
|
28
|
-
*/
|
|
29
|
-
export declare function formatErrorOutput(error: CliErrorEnvelope, flags: GlobalFlags): string;
|
|
30
|
-
/**
|
|
31
|
-
* Formats error output as JSON.
|
|
32
|
-
*/
|
|
33
|
-
export declare function formatErrorJson(error: CliErrorEnvelope): string;
|
|
34
|
-
/**
|
|
35
|
-
* Formats human-readable output for database verify.
|
|
36
|
-
*/
|
|
37
|
-
export declare function formatVerifyOutput(result: VerifyDatabaseResult, flags: GlobalFlags): string;
|
|
38
|
-
/**
|
|
39
|
-
* Formats JSON output for database verify.
|
|
40
|
-
*/
|
|
41
|
-
export declare function formatVerifyJson(result: VerifyDatabaseResult): string;
|
|
42
|
-
/**
|
|
43
|
-
* Formats JSON output for database introspection.
|
|
44
|
-
*/
|
|
45
|
-
export declare function formatIntrospectJson(result: IntrospectSchemaResult<unknown>): string;
|
|
46
|
-
/**
|
|
47
|
-
* Formats human-readable output for database introspection.
|
|
48
|
-
*/
|
|
49
|
-
export declare function formatIntrospectOutput(result: IntrospectSchemaResult<unknown>, schemaView: CoreSchemaView | undefined, flags: GlobalFlags): string;
|
|
50
|
-
/**
|
|
51
|
-
* Formats human-readable output for database schema verification.
|
|
52
|
-
*/
|
|
53
|
-
export declare function formatSchemaVerifyOutput(result: VerifyDatabaseSchemaResult, flags: GlobalFlags): string;
|
|
54
|
-
/**
|
|
55
|
-
* Formats JSON output for database schema verification.
|
|
56
|
-
*/
|
|
57
|
-
export declare function formatSchemaVerifyJson(result: VerifyDatabaseSchemaResult): string;
|
|
58
|
-
/**
|
|
59
|
-
* Formats human-readable output for database sign.
|
|
60
|
-
*/
|
|
61
|
-
export declare function formatSignOutput(result: SignDatabaseResult, flags: GlobalFlags): string;
|
|
62
|
-
/**
|
|
63
|
-
* Formats JSON output for database sign.
|
|
64
|
-
*/
|
|
65
|
-
export declare function formatSignJson(result: SignDatabaseResult): string;
|
|
66
|
-
/**
|
|
67
|
-
* Result type for db init command.
|
|
68
|
-
*/
|
|
69
|
-
export interface DbInitResult {
|
|
70
|
-
readonly ok: boolean;
|
|
71
|
-
readonly mode: 'plan' | 'apply';
|
|
72
|
-
readonly plan?: {
|
|
73
|
-
readonly targetId: string;
|
|
74
|
-
readonly destination: {
|
|
75
|
-
readonly coreHash: string;
|
|
76
|
-
readonly profileHash?: string;
|
|
77
|
-
};
|
|
78
|
-
readonly operations: readonly {
|
|
79
|
-
readonly id: string;
|
|
80
|
-
readonly label: string;
|
|
81
|
-
readonly operationClass: string;
|
|
82
|
-
}[];
|
|
83
|
-
};
|
|
84
|
-
readonly execution?: {
|
|
85
|
-
readonly operationsPlanned: number;
|
|
86
|
-
readonly operationsExecuted: number;
|
|
87
|
-
};
|
|
88
|
-
readonly marker?: {
|
|
89
|
-
readonly coreHash: string;
|
|
90
|
-
readonly profileHash?: string;
|
|
91
|
-
};
|
|
92
|
-
readonly summary: string;
|
|
93
|
-
readonly timings: {
|
|
94
|
-
readonly total: number;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Formats human-readable output for db init plan mode.
|
|
99
|
-
*/
|
|
100
|
-
export declare function formatDbInitPlanOutput(result: DbInitResult, flags: GlobalFlags): string;
|
|
101
|
-
/**
|
|
102
|
-
* Formats human-readable output for db init apply mode.
|
|
103
|
-
*/
|
|
104
|
-
export declare function formatDbInitApplyOutput(result: DbInitResult, flags: GlobalFlags): string;
|
|
105
|
-
/**
|
|
106
|
-
* Formats JSON output for db init command.
|
|
107
|
-
*/
|
|
108
|
-
export declare function formatDbInitJson(result: DbInitResult): string;
|
|
109
|
-
/**
|
|
110
|
-
* Formats the header in the new experimental visual style.
|
|
111
|
-
* This header appears at the start of command output, showing the operation,
|
|
112
|
-
* intent, documentation link, and parameters.
|
|
113
|
-
*/
|
|
114
|
-
export declare function formatStyledHeader(options: {
|
|
115
|
-
readonly command: string;
|
|
116
|
-
readonly description: string;
|
|
117
|
-
readonly url?: string;
|
|
118
|
-
readonly details: ReadonlyArray<{
|
|
119
|
-
readonly label: string;
|
|
120
|
-
readonly value: string;
|
|
121
|
-
}>;
|
|
122
|
-
readonly flags: GlobalFlags;
|
|
123
|
-
}): string;
|
|
124
|
-
/**
|
|
125
|
-
* Formats a success message in the styled output format.
|
|
126
|
-
*/
|
|
127
|
-
export declare function formatSuccessMessage(flags: GlobalFlags): string;
|
|
128
|
-
/**
|
|
129
|
-
* Formats help output for a command using the styled format.
|
|
130
|
-
*/
|
|
131
|
-
export declare function formatCommandHelp(options: {
|
|
132
|
-
readonly command: Command;
|
|
133
|
-
readonly flags: GlobalFlags;
|
|
134
|
-
}): string;
|
|
135
|
-
/**
|
|
136
|
-
* Formats help output for the root program using the styled format.
|
|
137
|
-
*/
|
|
138
|
-
export declare function formatRootHelp(options: {
|
|
139
|
-
readonly program: Command;
|
|
140
|
-
readonly flags: GlobalFlags;
|
|
141
|
-
}): string;
|
|
142
|
-
//# sourceMappingURL=output.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { OnControlProgress } from '../control-api/types';
|
|
2
|
-
import type { GlobalFlags } from './global-flags';
|
|
3
|
-
/**
|
|
4
|
-
* Options for creating a progress adapter.
|
|
5
|
-
*/
|
|
6
|
-
interface ProgressAdapterOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Global flags that control progress output behavior (quiet, json, color).
|
|
9
|
-
*/
|
|
10
|
-
readonly flags: GlobalFlags;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Creates a progress adapter that converts control-api progress events
|
|
14
|
-
* into CLI spinner/progress output.
|
|
15
|
-
*
|
|
16
|
-
* The adapter:
|
|
17
|
-
* - Starts/succeeds spinners for top-level span boundaries
|
|
18
|
-
* - Prints per-operation lines for nested spans (e.g., migration operations under 'apply')
|
|
19
|
-
* - Respects quiet/json/non-TTY flags (no-op in those cases)
|
|
20
|
-
*
|
|
21
|
-
* @param options - Progress adapter configuration
|
|
22
|
-
* @returns An onProgress callback compatible with control-api operations
|
|
23
|
-
*/
|
|
24
|
-
export declare function createProgressAdapter(options: ProgressAdapterOptions): OnControlProgress;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=progress-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress-adapter.d.ts","sourceRoot":"","sources":["../../src/utils/progress-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,sBAAsB;IAC9B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAUD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,CAmDxF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Result } from '@prisma-next/utils/result';
|
|
2
|
-
import type { CliStructuredError } from './cli-errors';
|
|
3
|
-
import type { GlobalFlags } from './global-flags';
|
|
4
|
-
/**
|
|
5
|
-
* Processes a CLI command result, handling both success and error cases.
|
|
6
|
-
* Formats output appropriately and returns the exit code.
|
|
7
|
-
* Never throws - returns exit code for commands to use with process.exit().
|
|
8
|
-
*
|
|
9
|
-
* @param result - The result from a CLI command
|
|
10
|
-
* @param flags - Global flags for output formatting
|
|
11
|
-
* @param onSuccess - Optional callback for successful results (for custom success output)
|
|
12
|
-
* @returns The exit code that should be used (0 for success, non-zero for errors)
|
|
13
|
-
*/
|
|
14
|
-
export declare function handleResult<T>(result: Result<T, CliStructuredError>, flags: GlobalFlags, onSuccess?: (value: T) => void): number;
|
|
15
|
-
//# sourceMappingURL=result-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-handler.d.ts","sourceRoot":"","sources":["../../src/utils/result-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,EACrC,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAC7B,MAAM,CAwBR"}
|
package/dist/utils/spinner.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { GlobalFlags } from './global-flags';
|
|
2
|
-
/**
|
|
3
|
-
* Options for the withSpinner helper function.
|
|
4
|
-
*/
|
|
5
|
-
interface WithSpinnerOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The message to display in the spinner.
|
|
8
|
-
*/
|
|
9
|
-
readonly message: string;
|
|
10
|
-
/**
|
|
11
|
-
* Global flags that control spinner behavior (quiet, json, color).
|
|
12
|
-
*/
|
|
13
|
-
readonly flags: GlobalFlags;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Wraps an async operation with a spinner.
|
|
17
|
-
*
|
|
18
|
-
* The spinner respects:
|
|
19
|
-
* - `flags.quiet`: No spinner if quiet mode is enabled
|
|
20
|
-
* - `flags.json === 'object'`: No spinner if JSON output is enabled
|
|
21
|
-
* - Non-TTY environments: No spinner if stdout is not a TTY
|
|
22
|
-
*
|
|
23
|
-
* @param operation - The async operation to execute
|
|
24
|
-
* @param options - Spinner configuration options
|
|
25
|
-
* @returns The result of the operation
|
|
26
|
-
*/
|
|
27
|
-
export declare function withSpinner<T>(operation: () => Promise<T>, options: WithSpinnerOptions): Promise<T>;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/utils/spinner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,kBAAkB;IAC1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAkCZ"}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { relative, resolve } from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
errorDatabaseConnectionRequired,
|
|
5
|
-
errorDriverRequired,
|
|
6
|
-
errorRuntime,
|
|
7
|
-
errorUnexpected,
|
|
8
|
-
} from '@prisma-next/core-control-plane/errors';
|
|
9
|
-
import type { CoreSchemaView } from '@prisma-next/core-control-plane/schema-view';
|
|
10
|
-
import type { IntrospectSchemaResult } from '@prisma-next/core-control-plane/types';
|
|
11
|
-
import { createControlPlaneStack } from '@prisma-next/core-control-plane/types';
|
|
12
|
-
import { Command } from 'commander';
|
|
13
|
-
import { loadConfig } from '../config-loader';
|
|
14
|
-
import { performAction } from '../utils/action';
|
|
15
|
-
import { setCommandDescriptions } from '../utils/command-helpers';
|
|
16
|
-
import { assertContractRequirementsSatisfied } from '../utils/framework-components';
|
|
17
|
-
import { parseGlobalFlags } from '../utils/global-flags';
|
|
18
|
-
import {
|
|
19
|
-
formatCommandHelp,
|
|
20
|
-
formatIntrospectJson,
|
|
21
|
-
formatIntrospectOutput,
|
|
22
|
-
formatStyledHeader,
|
|
23
|
-
} from '../utils/output';
|
|
24
|
-
import { handleResult } from '../utils/result-handler';
|
|
25
|
-
import { withSpinner } from '../utils/spinner';
|
|
26
|
-
|
|
27
|
-
interface DbIntrospectOptions {
|
|
28
|
-
readonly db?: string;
|
|
29
|
-
readonly config?: string;
|
|
30
|
-
readonly json?: string | boolean;
|
|
31
|
-
readonly quiet?: boolean;
|
|
32
|
-
readonly q?: boolean;
|
|
33
|
-
readonly verbose?: boolean;
|
|
34
|
-
readonly v?: boolean;
|
|
35
|
-
readonly vv?: boolean;
|
|
36
|
-
readonly trace?: boolean;
|
|
37
|
-
readonly timestamps?: boolean;
|
|
38
|
-
readonly color?: boolean;
|
|
39
|
-
readonly 'no-color'?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function createDbIntrospectCommand(): Command {
|
|
43
|
-
const command = new Command('introspect');
|
|
44
|
-
setCommandDescriptions(
|
|
45
|
-
command,
|
|
46
|
-
'Inspect the database schema',
|
|
47
|
-
'Reads the live database schema and displays it as a tree structure. This command\n' +
|
|
48
|
-
'does not check the schema against your contract - it only shows what exists in\n' +
|
|
49
|
-
'the database. Use `db verify` or `db schema-verify` to compare against your contract.',
|
|
50
|
-
);
|
|
51
|
-
command
|
|
52
|
-
.configureHelp({
|
|
53
|
-
formatHelp: (cmd) => {
|
|
54
|
-
const flags = parseGlobalFlags({});
|
|
55
|
-
return formatCommandHelp({ command: cmd, flags });
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
.option('--db <url>', 'Database connection string')
|
|
59
|
-
.option('--config <path>', 'Path to prisma-next.config.ts')
|
|
60
|
-
.option('--json [format]', 'Output as JSON (object or ndjson)', false)
|
|
61
|
-
.option('-q, --quiet', 'Quiet mode: errors only')
|
|
62
|
-
.option('-v, --verbose', 'Verbose output: debug info, timings')
|
|
63
|
-
.option('-vv, --trace', 'Trace output: deep internals, stack traces')
|
|
64
|
-
.option('--timestamps', 'Add timestamps to output')
|
|
65
|
-
.option('--color', 'Force color output')
|
|
66
|
-
.option('--no-color', 'Disable color output')
|
|
67
|
-
.action(async (options: DbIntrospectOptions) => {
|
|
68
|
-
const flags = parseGlobalFlags(options);
|
|
69
|
-
|
|
70
|
-
const result = await performAction(async () => {
|
|
71
|
-
const startTime = Date.now();
|
|
72
|
-
|
|
73
|
-
// Load config (file I/O)
|
|
74
|
-
const config = await loadConfig(options.config);
|
|
75
|
-
// Normalize config path for display (match contract path format - no ./ prefix)
|
|
76
|
-
const configPath = options.config
|
|
77
|
-
? relative(process.cwd(), resolve(options.config))
|
|
78
|
-
: 'prisma-next.config.ts';
|
|
79
|
-
|
|
80
|
-
// Optionally load contract if contract config exists
|
|
81
|
-
let contractIR: unknown | undefined;
|
|
82
|
-
if (config.contract?.output) {
|
|
83
|
-
const contractPath = resolve(config.contract.output);
|
|
84
|
-
try {
|
|
85
|
-
const contractJsonContent = await readFile(contractPath, 'utf-8');
|
|
86
|
-
contractIR = JSON.parse(contractJsonContent);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
// Contract file is optional for introspection - don't fail if it doesn't exist
|
|
89
|
-
if (error instanceof Error && (error as { code?: string }).code !== 'ENOENT') {
|
|
90
|
-
throw errorUnexpected(error.message, {
|
|
91
|
-
why: `Failed to read contract file: ${error.message}`,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Output header (only for human-readable output)
|
|
98
|
-
if (flags.json !== 'object' && !flags.quiet) {
|
|
99
|
-
const details: Array<{ label: string; value: string }> = [
|
|
100
|
-
{ label: 'config', value: configPath },
|
|
101
|
-
];
|
|
102
|
-
if (options.db) {
|
|
103
|
-
// Mask password in URL for security
|
|
104
|
-
const maskedUrl = options.db.replace(/:([^:@]+)@/, ':****@');
|
|
105
|
-
details.push({ label: 'database', value: maskedUrl });
|
|
106
|
-
} else if (config.db?.connection && typeof config.db.connection === 'string') {
|
|
107
|
-
// Mask password in URL for security
|
|
108
|
-
const maskedUrl = config.db.connection.replace(/:([^:@]+)@/, ':****@');
|
|
109
|
-
details.push({ label: 'database', value: maskedUrl });
|
|
110
|
-
}
|
|
111
|
-
const header = formatStyledHeader({
|
|
112
|
-
command: 'db introspect',
|
|
113
|
-
description: 'Inspect the database schema',
|
|
114
|
-
url: 'https://pris.ly/db-introspect',
|
|
115
|
-
details,
|
|
116
|
-
flags,
|
|
117
|
-
});
|
|
118
|
-
console.log(header);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Resolve database connection (--db flag or config.db.connection)
|
|
122
|
-
const dbConnection = options.db ?? config.db?.connection;
|
|
123
|
-
if (!dbConnection) {
|
|
124
|
-
throw errorDatabaseConnectionRequired();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Check for driver
|
|
128
|
-
if (!config.driver) {
|
|
129
|
-
throw errorDriverRequired();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Store driver descriptor after null check
|
|
133
|
-
const driverDescriptor = config.driver;
|
|
134
|
-
|
|
135
|
-
const driver = await withSpinner(() => driverDescriptor.create(dbConnection), {
|
|
136
|
-
message: 'Connecting to database...',
|
|
137
|
-
flags,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
// Create family instance
|
|
142
|
-
const stack = createControlPlaneStack({
|
|
143
|
-
target: config.target,
|
|
144
|
-
adapter: config.adapter,
|
|
145
|
-
driver: driverDescriptor,
|
|
146
|
-
extensionPacks: config.extensionPacks,
|
|
147
|
-
});
|
|
148
|
-
const familyInstance = config.family.create(stack);
|
|
149
|
-
|
|
150
|
-
// Validate contract IR if we loaded it
|
|
151
|
-
if (contractIR) {
|
|
152
|
-
const validatedContract = familyInstance.validateContractIR(contractIR);
|
|
153
|
-
assertContractRequirementsSatisfied({ contract: validatedContract, stack });
|
|
154
|
-
contractIR = validatedContract;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Call family instance introspect method
|
|
158
|
-
let schemaIR: unknown;
|
|
159
|
-
try {
|
|
160
|
-
schemaIR = await withSpinner(
|
|
161
|
-
() =>
|
|
162
|
-
familyInstance.introspect({
|
|
163
|
-
driver,
|
|
164
|
-
contractIR,
|
|
165
|
-
}),
|
|
166
|
-
{
|
|
167
|
-
message: 'Introspecting database schema...',
|
|
168
|
-
flags,
|
|
169
|
-
},
|
|
170
|
-
);
|
|
171
|
-
} catch (error) {
|
|
172
|
-
// Wrap errors from introspect() in structured error
|
|
173
|
-
throw errorRuntime(error instanceof Error ? error.message : String(error), {
|
|
174
|
-
why: `Failed to introspect database: ${error instanceof Error ? error.message : String(error)}`,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Optionally call toSchemaView if available
|
|
179
|
-
let schemaView: CoreSchemaView | undefined;
|
|
180
|
-
if (familyInstance.toSchemaView) {
|
|
181
|
-
try {
|
|
182
|
-
schemaView = familyInstance.toSchemaView(schemaIR);
|
|
183
|
-
} catch (error) {
|
|
184
|
-
// Schema view projection is optional - log but don't fail
|
|
185
|
-
if (flags.verbose) {
|
|
186
|
-
console.error(
|
|
187
|
-
`Warning: Failed to project schema to view: ${error instanceof Error ? error.message : String(error)}`,
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const totalTime = Date.now() - startTime;
|
|
194
|
-
|
|
195
|
-
// Add blank line after all async operations if spinners were shown
|
|
196
|
-
if (!flags.quiet && flags.json !== 'object' && process.stdout.isTTY) {
|
|
197
|
-
console.log('');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Build result envelope
|
|
201
|
-
// Get masked connection URL for meta (only for string connections)
|
|
202
|
-
const connectionForMeta =
|
|
203
|
-
typeof dbConnection === 'string'
|
|
204
|
-
? dbConnection.replace(/:([^:@]+)@/, ':****@')
|
|
205
|
-
: undefined;
|
|
206
|
-
|
|
207
|
-
const introspectResult: IntrospectSchemaResult<unknown> = {
|
|
208
|
-
ok: true,
|
|
209
|
-
summary: 'Schema introspected successfully',
|
|
210
|
-
target: {
|
|
211
|
-
familyId: config.family.familyId,
|
|
212
|
-
id: config.target.targetId,
|
|
213
|
-
},
|
|
214
|
-
schema: schemaIR,
|
|
215
|
-
...(configPath || connectionForMeta
|
|
216
|
-
? {
|
|
217
|
-
meta: {
|
|
218
|
-
...(configPath ? { configPath } : {}),
|
|
219
|
-
...(connectionForMeta ? { dbUrl: connectionForMeta } : {}),
|
|
220
|
-
},
|
|
221
|
-
}
|
|
222
|
-
: {}),
|
|
223
|
-
timings: {
|
|
224
|
-
total: totalTime,
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
return { introspectResult, schemaView };
|
|
229
|
-
} finally {
|
|
230
|
-
// Ensure driver connection is closed
|
|
231
|
-
await driver.close();
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
// Handle result - formats output and returns exit code
|
|
236
|
-
const exitCode = handleResult(result, flags, (value) => {
|
|
237
|
-
const { introspectResult, schemaView } = value;
|
|
238
|
-
// Output based on flags
|
|
239
|
-
if (flags.json === 'object') {
|
|
240
|
-
// JSON output to stdout
|
|
241
|
-
console.log(formatIntrospectJson(introspectResult));
|
|
242
|
-
} else {
|
|
243
|
-
// Human-readable output to stdout
|
|
244
|
-
const output = formatIntrospectOutput(introspectResult, schemaView, flags);
|
|
245
|
-
if (output) {
|
|
246
|
-
console.log(output);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
process.exit(exitCode);
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
return command;
|
|
254
|
-
}
|