@prisma-next/core-control-plane 0.3.0-dev.4 → 0.3.0-dev.5
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/dist/config-types.d.ts +68 -0
- package/dist/config-types.d.ts.map +1 -0
- package/dist/config-validation.d.ts +10 -0
- package/dist/config-validation.d.ts.map +1 -0
- package/dist/emission/canonicalization.d.ts +6 -0
- package/dist/emission/canonicalization.d.ts.map +1 -0
- package/dist/emission/emit.d.ts +5 -0
- package/dist/emission/emit.d.ts.map +1 -0
- package/dist/emission/hashing.d.ts +17 -0
- package/dist/emission/hashing.d.ts.map +1 -0
- package/dist/emission/types.d.ts +16 -0
- package/dist/emission/types.d.ts.map +1 -0
- package/dist/errors.d.ts +183 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/exports/config-types.d.ts +3 -70
- package/dist/exports/config-types.d.ts.map +1 -0
- package/dist/exports/config-validation.d.ts +2 -18
- package/dist/exports/config-validation.d.ts.map +1 -0
- package/dist/exports/emission.d.ts +5 -42
- package/dist/exports/emission.d.ts.map +1 -0
- package/dist/exports/errors.d.ts +3 -184
- package/dist/exports/errors.d.ts.map +1 -0
- package/dist/exports/schema-view.d.ts +2 -87
- package/dist/exports/schema-view.d.ts.map +1 -0
- package/dist/exports/types.d.ts +2 -589
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/migrations.d.ts +190 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/schema-view.d.ts +86 -0
- package/dist/schema-view.d.ts.map +1 -0
- package/dist/types.d.ts +400 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/config-types.ts +157 -0
- package/src/config-validation.ts +270 -0
- package/src/emission/canonicalization.ts +253 -0
- package/src/emission/emit.ts +118 -0
- package/src/emission/hashing.ts +57 -0
- package/src/emission/types.ts +17 -0
- package/src/errors.ts +426 -0
- package/src/exports/config-types.ts +5 -0
- package/src/exports/config-validation.ts +1 -0
- package/src/exports/emission.ts +6 -0
- package/src/exports/errors.ts +22 -0
- package/src/exports/schema-view.ts +1 -0
- package/src/exports/types.ts +37 -0
- package/src/migrations.ts +247 -0
- package/src/schema-view.ts +95 -0
- package/src/types.ts +512 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ControlAdapterDescriptor, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlTargetDescriptor } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Type alias for CLI driver instances.
|
|
4
|
+
* Uses string for both family and target IDs for maximum flexibility.
|
|
5
|
+
*/
|
|
6
|
+
export type CliDriver = ControlDriverInstance<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Contract configuration specifying source and artifact locations.
|
|
9
|
+
*/
|
|
10
|
+
export interface ContractConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Contract source. Can be a value or a function that returns a value (sync or async).
|
|
13
|
+
* If a function, it will be called to resolve the contract.
|
|
14
|
+
*/
|
|
15
|
+
readonly source: unknown | (() => unknown | Promise<unknown>);
|
|
16
|
+
/**
|
|
17
|
+
* Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.
|
|
18
|
+
* This is the canonical location where other CLI commands can find the contract JSON.
|
|
19
|
+
*/
|
|
20
|
+
readonly output?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Path to contract.d.ts artifact. Defaults to output with .d.ts extension.
|
|
23
|
+
* If output ends with .json, replaces .json with .d.ts.
|
|
24
|
+
* Otherwise, appends .d.ts to the directory containing output.
|
|
25
|
+
*/
|
|
26
|
+
readonly types?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Configuration for Prisma Next CLI.
|
|
30
|
+
* Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
|
|
31
|
+
*
|
|
32
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
33
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
34
|
+
*/
|
|
35
|
+
export interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
36
|
+
readonly family: ControlFamilyDescriptor<TFamilyId>;
|
|
37
|
+
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
38
|
+
readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
|
|
39
|
+
readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
|
|
40
|
+
/**
|
|
41
|
+
* Driver descriptor for DB-connected CLI commands.
|
|
42
|
+
* Required for DB-connected commands (e.g., db verify).
|
|
43
|
+
* Optional for commands that don't need database access (e.g., emit).
|
|
44
|
+
*/
|
|
45
|
+
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId>;
|
|
46
|
+
readonly db?: {
|
|
47
|
+
readonly url?: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Contract configuration. Specifies source and artifact locations.
|
|
51
|
+
* Required for emit command; optional for other commands that only read artifacts.
|
|
52
|
+
*/
|
|
53
|
+
readonly contract?: ContractConfig;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Helper function to define a Prisma Next config.
|
|
57
|
+
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
58
|
+
*
|
|
59
|
+
* Normalization:
|
|
60
|
+
* - contract.output defaults to 'src/prisma/contract.json' if missing
|
|
61
|
+
* - contract.types defaults to output with .d.ts extension if missing
|
|
62
|
+
*
|
|
63
|
+
* @param config - Raw config input from user
|
|
64
|
+
* @returns Normalized config IR with defaults applied
|
|
65
|
+
* @throws Error if config structure is invalid
|
|
66
|
+
*/
|
|
67
|
+
export declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
|
|
68
|
+
//# sourceMappingURL=config-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.d.ts","sourceRoot":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A0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,SAAS,MAAM,GAAG,MAAM,EAC/F,MAAM,EAAE,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,GAC7C,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAgDxC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PrismaNextConfig } from './config-types';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that the config has the required structure.
|
|
4
|
+
* This is pure validation logic with no file I/O or CLI awareness.
|
|
5
|
+
*
|
|
6
|
+
* @param config - Config object to validate
|
|
7
|
+
* @throws CliStructuredError if config structure is invalid
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateConfig(config: unknown): asserts config is PrismaNextConfig;
|
|
10
|
+
//# sourceMappingURL=config-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../src/config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,gBAAgB,CAmQlF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalization.d.ts","sourceRoot":"","sources":["../../src/emission/canonicalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA6N3D,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3D,MAAM,CA6BR"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContractIR } from '@prisma-next/contract/ir';
|
|
2
|
+
import type { TargetFamilyHook } from '@prisma-next/contract/types';
|
|
3
|
+
import type { EmitOptions, EmitResult } from './types';
|
|
4
|
+
export declare function emit(ir: ContractIR, options: EmitOptions, targetFamily: TargetFamilyHook): Promise<EmitResult>;
|
|
5
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/emission/emit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,6BAA6B,CAAC;AAIvF,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmCvD,wBAAsB,IAAI,CACxB,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,gBAAgB,GAC7B,OAAO,CAAC,UAAU,CAAC,CAyErB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type ContractInput = {
|
|
2
|
+
schemaVersion: string;
|
|
3
|
+
targetFamily: string;
|
|
4
|
+
target: string;
|
|
5
|
+
models: Record<string, unknown>;
|
|
6
|
+
relations: Record<string, unknown>;
|
|
7
|
+
storage: Record<string, unknown>;
|
|
8
|
+
extensionPacks: Record<string, unknown>;
|
|
9
|
+
sources: Record<string, unknown>;
|
|
10
|
+
capabilities: Record<string, Record<string, boolean>>;
|
|
11
|
+
meta: Record<string, unknown>;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export declare function computeCoreHash(contract: ContractInput): string;
|
|
15
|
+
export declare function computeProfileHash(contract: ContractInput): string;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=hashing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashing.d.ts","sourceRoot":"","sources":["../../src/emission/hashing.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAQF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAe/D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAelE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TypesImportSpec } from '@prisma-next/contract/types';
|
|
2
|
+
import type { OperationRegistry } from '@prisma-next/operations';
|
|
3
|
+
export interface EmitOptions {
|
|
4
|
+
readonly outputDir: string;
|
|
5
|
+
readonly operationRegistry?: OperationRegistry;
|
|
6
|
+
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
7
|
+
readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
8
|
+
readonly extensionIds?: ReadonlyArray<string>;
|
|
9
|
+
}
|
|
10
|
+
export interface EmitResult {
|
|
11
|
+
readonly contractJson: string;
|
|
12
|
+
readonly contractDts: string;
|
|
13
|
+
readonly coreHash: string;
|
|
14
|
+
readonly profileHash: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/emission/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAC/C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC3D,QAAQ,CAAC,oBAAoB,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC/D,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI error envelope for output formatting.
|
|
3
|
+
* This is the serialized form of a CliStructuredError.
|
|
4
|
+
*/
|
|
5
|
+
export interface CliErrorEnvelope {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly domain: string;
|
|
8
|
+
readonly severity: 'error' | 'warn' | 'info';
|
|
9
|
+
readonly summary: string;
|
|
10
|
+
readonly why: string | undefined;
|
|
11
|
+
readonly fix: string | undefined;
|
|
12
|
+
readonly where: {
|
|
13
|
+
readonly path: string | undefined;
|
|
14
|
+
readonly line: number | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
17
|
+
readonly docsUrl: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Minimal conflict data structure expected by CLI output.
|
|
21
|
+
*/
|
|
22
|
+
export interface CliErrorConflict {
|
|
23
|
+
readonly kind: string;
|
|
24
|
+
readonly summary: string;
|
|
25
|
+
readonly why?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Structured CLI error that contains all information needed for error envelopes.
|
|
29
|
+
* Call sites throw these errors with full context.
|
|
30
|
+
*/
|
|
31
|
+
export declare class CliStructuredError extends Error {
|
|
32
|
+
readonly code: string;
|
|
33
|
+
readonly domain: 'CLI' | 'RTM';
|
|
34
|
+
readonly severity: 'error' | 'warn' | 'info';
|
|
35
|
+
readonly why: string | undefined;
|
|
36
|
+
readonly fix: string | undefined;
|
|
37
|
+
readonly where: {
|
|
38
|
+
readonly path: string | undefined;
|
|
39
|
+
readonly line: number | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
42
|
+
readonly docsUrl: string | undefined;
|
|
43
|
+
constructor(code: string, summary: string, options?: {
|
|
44
|
+
readonly domain?: 'CLI' | 'RTM';
|
|
45
|
+
readonly severity?: 'error' | 'warn' | 'info';
|
|
46
|
+
readonly why?: string;
|
|
47
|
+
readonly fix?: string;
|
|
48
|
+
readonly where?: {
|
|
49
|
+
readonly path?: string;
|
|
50
|
+
readonly line?: number;
|
|
51
|
+
};
|
|
52
|
+
readonly meta?: Record<string, unknown>;
|
|
53
|
+
readonly docsUrl?: string;
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Converts this error to a CLI error envelope for output formatting.
|
|
57
|
+
*/
|
|
58
|
+
toEnvelope(): CliErrorEnvelope;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Config file not found or missing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function errorConfigFileNotFound(configPath?: string, options?: {
|
|
64
|
+
readonly why?: string;
|
|
65
|
+
}): CliStructuredError;
|
|
66
|
+
/**
|
|
67
|
+
* Contract configuration missing from config.
|
|
68
|
+
*/
|
|
69
|
+
export declare function errorContractConfigMissing(options?: {
|
|
70
|
+
readonly why?: string;
|
|
71
|
+
}): CliStructuredError;
|
|
72
|
+
/**
|
|
73
|
+
* Contract validation failed.
|
|
74
|
+
*/
|
|
75
|
+
export declare function errorContractValidationFailed(reason: string, options?: {
|
|
76
|
+
readonly where?: {
|
|
77
|
+
readonly path?: string;
|
|
78
|
+
readonly line?: number;
|
|
79
|
+
};
|
|
80
|
+
}): CliStructuredError;
|
|
81
|
+
/**
|
|
82
|
+
* File not found.
|
|
83
|
+
*/
|
|
84
|
+
export declare function errorFileNotFound(filePath: string, options?: {
|
|
85
|
+
readonly why?: string;
|
|
86
|
+
readonly fix?: string;
|
|
87
|
+
readonly docsUrl?: string;
|
|
88
|
+
}): CliStructuredError;
|
|
89
|
+
/**
|
|
90
|
+
* Database URL is required but not provided.
|
|
91
|
+
*/
|
|
92
|
+
export declare function errorDatabaseUrlRequired(options?: {
|
|
93
|
+
readonly why?: string;
|
|
94
|
+
}): CliStructuredError;
|
|
95
|
+
/**
|
|
96
|
+
* Query runner factory is required but not provided in config.
|
|
97
|
+
*/
|
|
98
|
+
export declare function errorQueryRunnerFactoryRequired(options?: {
|
|
99
|
+
readonly why?: string;
|
|
100
|
+
}): CliStructuredError;
|
|
101
|
+
/**
|
|
102
|
+
* Family verify.readMarker is required but not provided.
|
|
103
|
+
*/
|
|
104
|
+
export declare function errorFamilyReadMarkerSqlRequired(options?: {
|
|
105
|
+
readonly why?: string;
|
|
106
|
+
}): CliStructuredError;
|
|
107
|
+
/**
|
|
108
|
+
* JSON output format not supported.
|
|
109
|
+
*/
|
|
110
|
+
export declare function errorJsonFormatNotSupported(options: {
|
|
111
|
+
readonly command: string;
|
|
112
|
+
readonly format: string;
|
|
113
|
+
readonly supportedFormats: readonly string[];
|
|
114
|
+
}): CliStructuredError;
|
|
115
|
+
/**
|
|
116
|
+
* Driver is required for DB-connected commands but not provided.
|
|
117
|
+
*/
|
|
118
|
+
export declare function errorDriverRequired(options?: {
|
|
119
|
+
readonly why?: string;
|
|
120
|
+
}): CliStructuredError;
|
|
121
|
+
/**
|
|
122
|
+
* Contract requires extension packs that are not provided by config descriptors.
|
|
123
|
+
*/
|
|
124
|
+
export declare function errorContractMissingExtensionPacks(options: {
|
|
125
|
+
readonly missingExtensionPacks: readonly string[];
|
|
126
|
+
readonly providedComponentIds: readonly string[];
|
|
127
|
+
}): CliStructuredError;
|
|
128
|
+
/**
|
|
129
|
+
* Migration planning failed due to conflicts.
|
|
130
|
+
*/
|
|
131
|
+
export declare function errorMigrationPlanningFailed(options: {
|
|
132
|
+
readonly conflicts: readonly CliErrorConflict[];
|
|
133
|
+
readonly why?: string;
|
|
134
|
+
}): CliStructuredError;
|
|
135
|
+
/**
|
|
136
|
+
* Target does not support migrations (missing createPlanner/createRunner).
|
|
137
|
+
*/
|
|
138
|
+
export declare function errorTargetMigrationNotSupported(options?: {
|
|
139
|
+
readonly why?: string;
|
|
140
|
+
}): CliStructuredError;
|
|
141
|
+
/**
|
|
142
|
+
* Config validation error (missing required fields).
|
|
143
|
+
*/
|
|
144
|
+
export declare function errorConfigValidation(field: string, options?: {
|
|
145
|
+
readonly why?: string;
|
|
146
|
+
}): CliStructuredError;
|
|
147
|
+
/**
|
|
148
|
+
* Contract marker not found in database.
|
|
149
|
+
*/
|
|
150
|
+
export declare function errorMarkerMissing(options?: {
|
|
151
|
+
readonly why?: string;
|
|
152
|
+
readonly dbUrl?: string;
|
|
153
|
+
}): CliStructuredError;
|
|
154
|
+
/**
|
|
155
|
+
* Contract hash does not match database marker.
|
|
156
|
+
*/
|
|
157
|
+
export declare function errorHashMismatch(options?: {
|
|
158
|
+
readonly why?: string;
|
|
159
|
+
readonly expected?: string;
|
|
160
|
+
readonly actual?: string;
|
|
161
|
+
}): CliStructuredError;
|
|
162
|
+
/**
|
|
163
|
+
* Contract target does not match config target.
|
|
164
|
+
*/
|
|
165
|
+
export declare function errorTargetMismatch(expected: string, actual: string, options?: {
|
|
166
|
+
readonly why?: string;
|
|
167
|
+
}): CliStructuredError;
|
|
168
|
+
/**
|
|
169
|
+
* Generic runtime error.
|
|
170
|
+
*/
|
|
171
|
+
export declare function errorRuntime(summary: string, options?: {
|
|
172
|
+
readonly why?: string;
|
|
173
|
+
readonly fix?: string;
|
|
174
|
+
readonly meta?: Record<string, unknown>;
|
|
175
|
+
}): CliStructuredError;
|
|
176
|
+
/**
|
|
177
|
+
* Generic unexpected error.
|
|
178
|
+
*/
|
|
179
|
+
export declare function errorUnexpected(message: string, options?: {
|
|
180
|
+
readonly why?: string;
|
|
181
|
+
readonly fix?: string;
|
|
182
|
+
}): CliStructuredError;
|
|
183
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,KAAK,EACV;QACE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;KACnC,GACD,SAAS,CAAC;IACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '@prisma-next/contract/types';
|
|
5
|
-
import '@prisma-next/utils/result';
|
|
6
|
-
import './schema-view.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Contract configuration specifying source and artifact locations.
|
|
10
|
-
*/
|
|
11
|
-
interface ContractConfig {
|
|
12
|
-
/**
|
|
13
|
-
* Contract source. Can be a value or a function that returns a value (sync or async).
|
|
14
|
-
* If a function, it will be called to resolve the contract.
|
|
15
|
-
*/
|
|
16
|
-
readonly source: unknown | (() => unknown | Promise<unknown>);
|
|
17
|
-
/**
|
|
18
|
-
* Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.
|
|
19
|
-
* This is the canonical location where other CLI commands can find the contract JSON.
|
|
20
|
-
*/
|
|
21
|
-
readonly output?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Path to contract.d.ts artifact. Defaults to output with .d.ts extension.
|
|
24
|
-
* If output ends with .json, replaces .json with .d.ts.
|
|
25
|
-
* Otherwise, appends .d.ts to the directory containing output.
|
|
26
|
-
*/
|
|
27
|
-
readonly types?: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Configuration for Prisma Next CLI.
|
|
31
|
-
* Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
|
|
32
|
-
*
|
|
33
|
-
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
34
|
-
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
35
|
-
*/
|
|
36
|
-
interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
37
|
-
readonly family: ControlFamilyDescriptor<TFamilyId>;
|
|
38
|
-
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
39
|
-
readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
|
|
40
|
-
readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
|
|
41
|
-
/**
|
|
42
|
-
* Driver descriptor for DB-connected CLI commands.
|
|
43
|
-
* Required for DB-connected commands (e.g., db verify).
|
|
44
|
-
* Optional for commands that don't need database access (e.g., emit).
|
|
45
|
-
*/
|
|
46
|
-
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId>;
|
|
47
|
-
readonly db?: {
|
|
48
|
-
readonly url?: string;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Contract configuration. Specifies source and artifact locations.
|
|
52
|
-
* Required for emit command; optional for other commands that only read artifacts.
|
|
53
|
-
*/
|
|
54
|
-
readonly contract?: ContractConfig;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Helper function to define a Prisma Next config.
|
|
58
|
-
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
59
|
-
*
|
|
60
|
-
* Normalization:
|
|
61
|
-
* - contract.output defaults to 'src/prisma/contract.json' if missing
|
|
62
|
-
* - contract.types defaults to output with .d.ts extension if missing
|
|
63
|
-
*
|
|
64
|
-
* @param config - Raw config input from user
|
|
65
|
-
* @returns Normalized config IR with defaults applied
|
|
66
|
-
* @throws Error if config structure is invalid
|
|
67
|
-
*/
|
|
68
|
-
declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
|
|
69
|
-
|
|
70
|
-
export { type ContractConfig, type PrismaNextConfig, defineConfig };
|
|
1
|
+
export type { ContractConfig, PrismaNextConfig, } from '../config-types';
|
|
2
|
+
export { defineConfig } from '../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":"AAAA,YAAY,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '@prisma-next/contract/framework-components';
|
|
4
|
-
import '@prisma-next/contract/ir';
|
|
5
|
-
import '@prisma-next/contract/types';
|
|
6
|
-
import '@prisma-next/utils/result';
|
|
7
|
-
import './schema-view.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Validates that the config has the required structure.
|
|
11
|
-
* This is pure validation logic with no file I/O or CLI awareness.
|
|
12
|
-
*
|
|
13
|
-
* @param config - Config object to validate
|
|
14
|
-
* @throws CliStructuredError if config structure is invalid
|
|
15
|
-
*/
|
|
16
|
-
declare function validateConfig(config: unknown): asserts config is PrismaNextConfig;
|
|
17
|
-
|
|
18
|
-
export { validateConfig };
|
|
1
|
+
export { validateConfig } from '../config-validation';
|
|
2
|
+
//# sourceMappingURL=config-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../../src/exports/config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
coreHash?: string;
|
|
7
|
-
profileHash?: string;
|
|
8
|
-
}): string;
|
|
9
|
-
|
|
10
|
-
interface EmitOptions {
|
|
11
|
-
readonly outputDir: string;
|
|
12
|
-
readonly operationRegistry?: OperationRegistry;
|
|
13
|
-
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
14
|
-
readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
15
|
-
readonly extensionIds?: ReadonlyArray<string>;
|
|
16
|
-
}
|
|
17
|
-
interface EmitResult {
|
|
18
|
-
readonly contractJson: string;
|
|
19
|
-
readonly contractDts: string;
|
|
20
|
-
readonly coreHash: string;
|
|
21
|
-
readonly profileHash: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare function emit(ir: ContractIR, options: EmitOptions, targetFamily: TargetFamilyHook): Promise<EmitResult>;
|
|
25
|
-
|
|
26
|
-
type ContractInput = {
|
|
27
|
-
schemaVersion: string;
|
|
28
|
-
targetFamily: string;
|
|
29
|
-
target: string;
|
|
30
|
-
models: Record<string, unknown>;
|
|
31
|
-
relations: Record<string, unknown>;
|
|
32
|
-
storage: Record<string, unknown>;
|
|
33
|
-
extensionPacks: Record<string, unknown>;
|
|
34
|
-
sources: Record<string, unknown>;
|
|
35
|
-
capabilities: Record<string, Record<string, boolean>>;
|
|
36
|
-
meta: Record<string, unknown>;
|
|
37
|
-
[key: string]: unknown;
|
|
38
|
-
};
|
|
39
|
-
declare function computeCoreHash(contract: ContractInput): string;
|
|
40
|
-
declare function computeProfileHash(contract: ContractInput): string;
|
|
41
|
-
|
|
42
|
-
export { type EmitOptions, type EmitResult, canonicalizeContract, computeCoreHash, computeProfileHash, emit };
|
|
1
|
+
export { canonicalizeContract } from '../emission/canonicalization';
|
|
2
|
+
export { emit } from '../emission/emit';
|
|
3
|
+
export { computeCoreHash, computeProfileHash } from '../emission/hashing';
|
|
4
|
+
export type { EmitOptions, EmitResult } from '../emission/types';
|
|
5
|
+
//# sourceMappingURL=emission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emission.d.ts","sourceRoot":"","sources":["../../src/exports/emission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|