@prisma-next/core-control-plane 0.3.0-dev.5 → 0.3.0-dev.51
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/README.md +35 -1
- package/dist/config-types-Ci0VxOEC.d.mts +96 -0
- package/dist/config-types-Ci0VxOEC.d.mts.map +1 -0
- package/dist/config-types.d.mts +3 -0
- package/dist/config-types.mjs +60 -0
- package/dist/config-types.mjs.map +1 -0
- package/dist/config-validation.d.mts +16 -0
- package/dist/config-validation.d.mts.map +1 -0
- package/dist/config-validation.mjs +79 -0
- package/dist/config-validation.mjs.map +1 -0
- package/dist/emission.d.mts +58 -0
- package/dist/emission.d.mts.map +1 -0
- package/dist/emission.mjs +315 -0
- package/dist/emission.mjs.map +1 -0
- package/dist/errors-Qlh0sdcb.mjs +276 -0
- package/dist/errors-Qlh0sdcb.mjs.map +1 -0
- package/dist/errors.d.mts +191 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +3 -0
- package/dist/{schema-view.d.ts → schema-view-D9u47nc8.d.mts} +13 -10
- package/dist/schema-view-D9u47nc8.d.mts.map +1 -0
- package/dist/schema-view.d.mts +2 -0
- package/dist/schema-view.mjs +1 -0
- package/dist/stack.d.mts +30 -0
- package/dist/stack.d.mts.map +1 -0
- package/dist/stack.mjs +30 -0
- package/dist/stack.mjs.map +1 -0
- package/dist/types-CuAauVCJ.d.mts +597 -0
- package/dist/types-CuAauVCJ.d.mts.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +31 -38
- package/src/config-types.ts +30 -35
- package/src/config-validation.ts +7 -5
- package/src/contract-source-types.ts +28 -0
- package/src/emission/canonicalization.ts +68 -21
- package/src/emission/emit.ts +82 -21
- package/src/emission/hashing.ts +29 -27
- package/src/emission/types.ts +13 -2
- package/src/errors.ts +24 -5
- package/src/exports/config-types.ts +7 -0
- package/src/exports/emission.ts +1 -1
- package/src/exports/errors.ts +1 -1
- package/src/exports/stack.ts +1 -0
- package/src/exports/types.ts +1 -0
- package/src/migrations.ts +1 -1
- package/src/stack.ts +38 -0
- package/src/types.ts +41 -17
- package/dist/chunk-U5RYT6PT.js +0 -229
- package/dist/chunk-U5RYT6PT.js.map +0 -1
- package/dist/config-types.d.ts +0 -68
- package/dist/config-types.d.ts.map +0 -1
- package/dist/config-validation.d.ts +0 -10
- package/dist/config-validation.d.ts.map +0 -1
- package/dist/emission/canonicalization.d.ts +0 -6
- package/dist/emission/canonicalization.d.ts.map +0 -1
- package/dist/emission/emit.d.ts +0 -5
- package/dist/emission/emit.d.ts.map +0 -1
- package/dist/emission/hashing.d.ts +0 -17
- package/dist/emission/hashing.d.ts.map +0 -1
- package/dist/emission/types.d.ts +0 -16
- package/dist/emission/types.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -183
- package/dist/errors.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 -53
- package/dist/exports/config-types.js.map +0 -1
- package/dist/exports/config-validation.d.ts +0 -2
- package/dist/exports/config-validation.d.ts.map +0 -1
- package/dist/exports/config-validation.js +0 -252
- package/dist/exports/config-validation.js.map +0 -1
- package/dist/exports/emission.d.ts +0 -5
- package/dist/exports/emission.d.ts.map +0 -1
- package/dist/exports/emission.js +0 -310
- package/dist/exports/emission.js.map +0 -1
- package/dist/exports/errors.d.ts +0 -3
- package/dist/exports/errors.d.ts.map +0 -1
- package/dist/exports/errors.js +0 -43
- package/dist/exports/errors.js.map +0 -1
- package/dist/exports/schema-view.d.ts +0 -2
- package/dist/exports/schema-view.d.ts.map +0 -1
- package/dist/exports/schema-view.js +0 -1
- package/dist/exports/schema-view.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -1
- package/dist/exports/types.js.map +0 -1
- package/dist/migrations.d.ts +0 -190
- package/dist/migrations.d.ts.map +0 -1
- package/dist/schema-view.d.ts.map +0 -1
- package/dist/types.d.ts +0 -400
- package/dist/types.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ This package provides the core domain logic for control plane operations (contra
|
|
|
9
9
|
## Responsibilities
|
|
10
10
|
|
|
11
11
|
- **Config Types**: Type definitions for Prisma Next configuration (`PrismaNextConfig`, `ControlFamilyDescriptor`, `ControlTargetDescriptor`, `ControlAdapterDescriptor`, `ControlDriverDescriptor`, `ControlExtensionDescriptor`)
|
|
12
|
+
- **ControlPlaneStack**: A struct bundling `target`, `adapter`, `driver`, and `extensionPacks` for control plane operations. Use `createControlPlaneStack()` to construct with sensible defaults.
|
|
12
13
|
- **Config Validation**: Pure validation logic for config structure (no file I/O)
|
|
13
14
|
- **Config Normalization**: `defineConfig()` function for normalizing config with defaults
|
|
14
15
|
- **Domain Actions**:
|
|
@@ -60,7 +61,8 @@ const config = defineConfig({
|
|
|
60
61
|
target: postgresTargetDescriptor,
|
|
61
62
|
adapter: postgresAdapterDescriptor,
|
|
62
63
|
contract: {
|
|
63
|
-
source: contractBuilder,
|
|
64
|
+
source: contractBuilder, // TS-first value/loader
|
|
65
|
+
// source: { kind: 'psl', schemaPath: './schema.prisma' }, // PSL-first
|
|
64
66
|
output: 'src/prisma/contract.json',
|
|
65
67
|
},
|
|
66
68
|
});
|
|
@@ -69,6 +71,38 @@ const config = defineConfig({
|
|
|
69
71
|
validateConfig(config);
|
|
70
72
|
```
|
|
71
73
|
|
|
74
|
+
`contract.source` supports:
|
|
75
|
+
- direct values and sync/async loader functions (TS-first)
|
|
76
|
+
- `{ kind: 'psl', schemaPath: string }` (PSL-first, requires non-empty `schemaPath`)
|
|
77
|
+
|
|
78
|
+
### ControlPlaneStack
|
|
79
|
+
|
|
80
|
+
The `ControlPlaneStack` bundles component descriptors for control plane operations (creating family instances, running CLI commands, connecting to databases):
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { createControlPlaneStack } from '@prisma-next/core-control-plane/stack';
|
|
84
|
+
import type { ControlPlaneStack } from '@prisma-next/core-control-plane/types';
|
|
85
|
+
|
|
86
|
+
// Create a stack with sensible defaults
|
|
87
|
+
const stack = createControlPlaneStack({
|
|
88
|
+
target: postgresTarget,
|
|
89
|
+
adapter: postgresAdapter,
|
|
90
|
+
driver: postgresDriver, // optional, defaults to undefined
|
|
91
|
+
extensionPacks: [pgvector], // optional, defaults to []
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Use stack for family instance creation
|
|
95
|
+
const familyInstance = config.family.create(stack);
|
|
96
|
+
|
|
97
|
+
// Stack is also used internally by ControlClient and CLI commands
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Stack shape after construction:**
|
|
101
|
+
- `target`: Required target descriptor
|
|
102
|
+
- `adapter`: Required adapter descriptor
|
|
103
|
+
- `driver`: `ControlDriverDescriptor | undefined` (always present, may be `undefined`)
|
|
104
|
+
- `extensionPacks`: `readonly ControlExtensionDescriptor[]` (always an array, possibly empty)
|
|
105
|
+
|
|
72
106
|
### Verify Database
|
|
73
107
|
|
|
74
108
|
```typescript
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { a as ControlExtensionDescriptor, i as ControlDriverInstance, r as ControlDriverDescriptor, s as ControlFamilyDescriptor, t as ControlAdapterDescriptor, u as ControlTargetDescriptor } from "./types-CuAauVCJ.mjs";
|
|
2
|
+
import { ContractIR } from "@prisma-next/contract/ir";
|
|
3
|
+
import { Result } from "@prisma-next/utils/result";
|
|
4
|
+
|
|
5
|
+
//#region src/contract-source-types.d.ts
|
|
6
|
+
interface ContractSourceDiagnosticPosition {
|
|
7
|
+
readonly offset: number;
|
|
8
|
+
readonly line: number;
|
|
9
|
+
readonly column: number;
|
|
10
|
+
}
|
|
11
|
+
interface ContractSourceDiagnosticSpan {
|
|
12
|
+
readonly start: ContractSourceDiagnosticPosition;
|
|
13
|
+
readonly end: ContractSourceDiagnosticPosition;
|
|
14
|
+
}
|
|
15
|
+
interface ContractSourceDiagnostic {
|
|
16
|
+
readonly code: string;
|
|
17
|
+
readonly message: string;
|
|
18
|
+
readonly sourceId?: string;
|
|
19
|
+
readonly span?: ContractSourceDiagnosticSpan;
|
|
20
|
+
}
|
|
21
|
+
interface ContractSourceDiagnostics {
|
|
22
|
+
readonly summary: string;
|
|
23
|
+
readonly diagnostics: readonly ContractSourceDiagnostic[];
|
|
24
|
+
readonly meta?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
type ContractSourceProvider = () => Promise<Result<ContractIR, ContractSourceDiagnostics>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/config-types.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Contract configuration specifying source and artifact locations.
|
|
31
|
+
*/
|
|
32
|
+
interface ContractConfig {
|
|
33
|
+
/**
|
|
34
|
+
* Contract source provider. The provider is always async and must return
|
|
35
|
+
* a Result containing either ContractIR or structured diagnostics.
|
|
36
|
+
*/
|
|
37
|
+
readonly source: ContractSourceProvider;
|
|
38
|
+
/**
|
|
39
|
+
* Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.
|
|
40
|
+
* The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
|
|
41
|
+
*/
|
|
42
|
+
readonly output?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for Prisma Next CLI.
|
|
46
|
+
* Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
|
|
47
|
+
*
|
|
48
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
49
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
50
|
+
* @template TConnection - The driver connection input type (defaults to `unknown` for config flexibility)
|
|
51
|
+
*/
|
|
52
|
+
interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string, TConnection = unknown> {
|
|
53
|
+
readonly family: ControlFamilyDescriptor<TFamilyId>;
|
|
54
|
+
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
55
|
+
readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
|
|
56
|
+
readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
|
|
57
|
+
/**
|
|
58
|
+
* Driver descriptor for DB-connected CLI commands.
|
|
59
|
+
* Required for DB-connected commands (e.g., db verify).
|
|
60
|
+
* Optional for commands that don't need database access (e.g., emit).
|
|
61
|
+
* The driver's connection type matches the TConnection config parameter.
|
|
62
|
+
*/
|
|
63
|
+
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId, ControlDriverInstance<TFamilyId, TTargetId>, TConnection>;
|
|
64
|
+
/**
|
|
65
|
+
* Database connection configuration.
|
|
66
|
+
* The connection type is driver-specific (e.g., URL string for Postgres).
|
|
67
|
+
*/
|
|
68
|
+
readonly db?: {
|
|
69
|
+
/**
|
|
70
|
+
* Driver-specific connection input.
|
|
71
|
+
* For Postgres: a connection string (URL).
|
|
72
|
+
* For other drivers: may be a structured object.
|
|
73
|
+
*/
|
|
74
|
+
readonly connection?: TConnection;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Contract configuration. Specifies source and artifact locations.
|
|
78
|
+
* Required for emit command; optional for other commands that only read artifacts.
|
|
79
|
+
*/
|
|
80
|
+
readonly contract?: ContractConfig;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Helper function to define a Prisma Next config.
|
|
84
|
+
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
85
|
+
*
|
|
86
|
+
* Normalization:
|
|
87
|
+
* - contract.output defaults to 'src/prisma/contract.json' if missing
|
|
88
|
+
*
|
|
89
|
+
* @param config - Raw config input from user
|
|
90
|
+
* @returns Normalized config IR with defaults applied
|
|
91
|
+
* @throws Error if config structure is invalid
|
|
92
|
+
*/
|
|
93
|
+
declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { ContractSourceDiagnosticPosition as a, ContractSourceProvider as c, ContractSourceDiagnostic as i, PrismaNextConfig as n, ContractSourceDiagnosticSpan as o, defineConfig as r, ContractSourceDiagnostics as s, ContractConfig as t };
|
|
96
|
+
//# sourceMappingURL=config-types-Ci0VxOEC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types-Ci0VxOEC.d.mts","names":[],"sources":["../src/contract-source-types.ts","../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;;UAGiB,gCAAA;;;EAAA,SAAA,MAAA,EAAA,MAAA;AAMjB;AAKiB,UALA,4BAAA,CASC;EAGD,SAAA,KAAA,EAXC,gCAae;EAIrB,SAAA,GAAA,EAhBI,gCAgBkB;;AAAoC,UAbrD,wBAAA,CAaqD;EAAnB,SAAA,IAAA,EAAA,MAAA;EAAR,SAAA,OAAA,EAAA,MAAA;EAAO,SAAA,QAAA,CAAA,EAAA,MAAA;kBAThC;;UAGD,yBAAA;ECDA,SAAA,OAAA,EAAc,MAAA;EAqBd,SAAA,WAAgB,EAAA,SDlBA,wBCkBA,EAAA;EAKU,SAAA,IAAA,CAAA,EDtBzB,MCsByB,CAAA,MAAA,EAAA,OAAA,CAAA;;AACA,KDpB/B,sBAAA,GCoB+B,GAAA,GDpBA,OCoBA,CDpBQ,MCoBR,CDpBe,UCoBf,EDpB2B,yBCoB3B,CAAA,CAAA;;;ADjC3C;AAOA;AAMA;AAA0D,UCPzC,cAAA,CDOyC;EAAY;;;;mBCFnD;;;AALnB;AAqBA;EAK2C,SAAA,MAAA,CAAA,EAAA,MAAA;;;;;;;;;;AAGN,UARpB,gBAQoB,CAAA,kBAAA,MAAA,GAAA,MAAA,EAAA,kBAAA,MAAA,GAAA,MAAA,EAAA,cAAA,OAAA,CAAA,CAAA;EAQjC,SAAA,MAAA,EAXe,uBAWf,CAXuC,SAWvC,CAAA;EACA,SAAA,MAAA,EAXe,uBAWf,CAXuC,SAWvC,EAXkD,SAWlD,CAAA;EACsB,SAAA,OAAA,EAXN,wBAWM,CAXmB,SAWnB,EAX8B,SAW9B,CAAA;EAAW,SAAA,cAAA,CAAA,EAAA,SAVA,0BAUA,CAV2B,SAU3B,EAVsC,SAUtC,CAAA,EAAA;EAAjC;;;;;;EAyDY,SAAA,MAAY,CAAA,EA5DR,uBA4DQ,CA3DxB,SA2DwB,EA1DxB,SA0DwB,EAzDxB,qBAyDwB,CAzDF,SAyDE,EAzDS,SAyDT,CAAA,EAxDxB,WAwDwB,CAAA;EACD;;;;EACI,SAAA,EAAA,CAAA,EAAA;IAA5B;;;;;0BA9CuB;;;;;;sBAMJ;;;;;;;;;;;;;iBAsCN,2FACN,iBAAiB,WAAW,aACnC,iBAAiB,WAAW"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as ContractSourceDiagnosticPosition, c as ContractSourceProvider, i as ContractSourceDiagnostic, n as PrismaNextConfig, o as ContractSourceDiagnosticSpan, r as defineConfig, s as ContractSourceDiagnostics, t as ContractConfig } from "./config-types-Ci0VxOEC.mjs";
|
|
2
|
+
import "./types-CuAauVCJ.mjs";
|
|
3
|
+
export { type ContractConfig, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceProvider, type PrismaNextConfig, defineConfig };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type } from "arktype";
|
|
2
|
+
|
|
3
|
+
//#region src/config-types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Arktype schema for ContractConfig validation.
|
|
6
|
+
* Validates presence/shape only.
|
|
7
|
+
* contract.source is validated as a provider function at runtime in defineConfig().
|
|
8
|
+
*/
|
|
9
|
+
const ContractConfigSchema = type({
|
|
10
|
+
source: "unknown",
|
|
11
|
+
"output?": "string"
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Arktype schema for PrismaNextConfig validation.
|
|
15
|
+
* Note: This validates structure only. Descriptor objects (family, target, adapter) are validated separately.
|
|
16
|
+
*/
|
|
17
|
+
const PrismaNextConfigSchema = type({
|
|
18
|
+
family: "unknown",
|
|
19
|
+
target: "unknown",
|
|
20
|
+
adapter: "unknown",
|
|
21
|
+
"extensionPacks?": "unknown[]",
|
|
22
|
+
"driver?": "unknown",
|
|
23
|
+
"db?": "unknown",
|
|
24
|
+
"contract?": ContractConfigSchema
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Helper function to define a Prisma Next config.
|
|
28
|
+
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
29
|
+
*
|
|
30
|
+
* Normalization:
|
|
31
|
+
* - contract.output defaults to 'src/prisma/contract.json' if missing
|
|
32
|
+
*
|
|
33
|
+
* @param config - Raw config input from user
|
|
34
|
+
* @returns Normalized config IR with defaults applied
|
|
35
|
+
* @throws Error if config structure is invalid
|
|
36
|
+
*/
|
|
37
|
+
function defineConfig(config) {
|
|
38
|
+
const validated = PrismaNextConfigSchema(config);
|
|
39
|
+
if (validated instanceof type.errors) {
|
|
40
|
+
const messages = validated.map((p) => p.message).join("; ");
|
|
41
|
+
throw new Error(`Config validation failed: ${messages}`);
|
|
42
|
+
}
|
|
43
|
+
if (config.contract) {
|
|
44
|
+
if (typeof config.contract.source !== "function") throw new Error("Config.contract.source must be a provider function");
|
|
45
|
+
const output = config.contract.output ?? "src/prisma/contract.json";
|
|
46
|
+
const normalizedContract = {
|
|
47
|
+
source: config.contract.source,
|
|
48
|
+
output
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
...config,
|
|
52
|
+
contract: normalizedContract
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { defineConfig };
|
|
60
|
+
//# sourceMappingURL=config-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-types.mjs","names":["normalizedContract: ContractConfig"],"sources":["../src/config-types.ts"],"sourcesContent":["import { type } from 'arktype';\nimport type { ContractSourceProvider } from './contract-source-types';\nimport type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlDriverInstance,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from './types';\n\n/**\n * Type alias for CLI driver instances.\n * Uses string for both family and target IDs for maximum flexibility.\n */\nexport type CliDriver = ControlDriverInstance<string, string>;\n\n/**\n * Contract configuration specifying source and artifact locations.\n */\nexport interface ContractConfig {\n /**\n * Contract source provider. The provider is always async and must return\n * a Result containing either ContractIR or structured diagnostics.\n */\n readonly source: ContractSourceProvider;\n /**\n * Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.\n * The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).\n */\n readonly output?: string;\n}\n\n/**\n * Configuration for Prisma Next CLI.\n * Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.\n *\n * @template TFamilyId - The family ID (e.g., 'sql', 'document')\n * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')\n * @template TConnection - The driver connection input type (defaults to `unknown` for config flexibility)\n */\nexport interface PrismaNextConfig<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n TConnection = unknown,\n> {\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;\n readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];\n /**\n * Driver descriptor for DB-connected CLI commands.\n * Required for DB-connected commands (e.g., db verify).\n * Optional for commands that don't need database access (e.g., emit).\n * The driver's connection type matches the TConnection config parameter.\n */\n readonly driver?: ControlDriverDescriptor<\n TFamilyId,\n TTargetId,\n ControlDriverInstance<TFamilyId, TTargetId>,\n TConnection\n >;\n /**\n * Database connection configuration.\n * The connection type is driver-specific (e.g., URL string for Postgres).\n */\n readonly db?: {\n /**\n * Driver-specific connection input.\n * For Postgres: a connection string (URL).\n * For other drivers: may be a structured object.\n */\n readonly connection?: TConnection;\n };\n /**\n * Contract configuration. Specifies source and artifact locations.\n * Required for emit command; optional for other commands that only read artifacts.\n */\n readonly contract?: ContractConfig;\n}\n\n/**\n * Arktype schema for ContractConfig validation.\n * Validates presence/shape only.\n * contract.source is validated as a provider function at runtime in defineConfig().\n */\nconst ContractConfigSchema = type({\n source: 'unknown', // Runtime check enforces provider function shape\n 'output?': 'string',\n});\n\n/**\n * Arktype schema for PrismaNextConfig validation.\n * Note: This validates structure only. Descriptor objects (family, target, adapter) are validated separately.\n */\nconst PrismaNextConfigSchema = type({\n family: 'unknown', // ControlFamilyDescriptor - validated separately\n target: 'unknown', // ControlTargetDescriptor - validated separately\n adapter: 'unknown', // ControlAdapterDescriptor - validated separately\n 'extensionPacks?': 'unknown[]',\n 'driver?': 'unknown', // ControlDriverDescriptor - validated separately (optional)\n 'db?': 'unknown',\n 'contract?': ContractConfigSchema,\n});\n\n/**\n * Helper function to define a Prisma Next config.\n * Validates and normalizes the config using Arktype, then returns the normalized IR.\n *\n * Normalization:\n * - contract.output defaults to 'src/prisma/contract.json' if missing\n *\n * @param config - Raw config input from user\n * @returns Normalized config IR with defaults applied\n * @throws Error if config structure is invalid\n */\nexport function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(\n config: PrismaNextConfig<TFamilyId, TTargetId>,\n): PrismaNextConfig<TFamilyId, TTargetId> {\n // Validate structure using Arktype\n const validated = PrismaNextConfigSchema(config);\n if (validated instanceof type.errors) {\n const messages = validated.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Config validation failed: ${messages}`);\n }\n\n // Normalize contract config if present\n if (config.contract) {\n // Validate contract.source provider function shape at runtime.\n const source = config.contract.source;\n if (typeof source !== 'function') {\n throw new Error('Config.contract.source must be a provider function');\n }\n\n // Apply defaults\n const output = config.contract.output ?? 'src/prisma/contract.json';\n\n const normalizedContract: ContractConfig = {\n source: config.contract.source,\n output,\n };\n\n // Return normalized config\n return {\n ...config,\n contract: normalizedContract,\n };\n }\n\n // Return config as-is if no contract (preserve literal types)\n return config;\n}\n"],"mappings":";;;;;;;;AAsFA,MAAM,uBAAuB,KAAK;CAChC,QAAQ;CACR,WAAW;CACZ,CAAC;;;;;AAMF,MAAM,yBAAyB,KAAK;CAClC,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,mBAAmB;CACnB,WAAW;CACX,OAAO;CACP,aAAa;CACd,CAAC;;;;;;;;;;;;AAaF,SAAgB,aACd,QACwC;CAExC,MAAM,YAAY,uBAAuB,OAAO;AAChD,KAAI,qBAAqB,KAAK,QAAQ;EACpC,MAAM,WAAW,UAAU,KAAK,MAA2B,EAAE,QAAQ,CAAC,KAAK,KAAK;AAChF,QAAM,IAAI,MAAM,6BAA6B,WAAW;;AAI1D,KAAI,OAAO,UAAU;AAGnB,MAAI,OADW,OAAO,SAAS,WACT,WACpB,OAAM,IAAI,MAAM,qDAAqD;EAIvE,MAAM,SAAS,OAAO,SAAS,UAAU;EAEzC,MAAMA,qBAAqC;GACzC,QAAQ,OAAO,SAAS;GACxB;GACD;AAGD,SAAO;GACL,GAAG;GACH,UAAU;GACX;;AAIH,QAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { n as PrismaNextConfig } from "./config-types-Ci0VxOEC.mjs";
|
|
2
|
+
import "./types-CuAauVCJ.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/config-validation.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validates that the config has the required structure.
|
|
8
|
+
* This is pure validation logic with no file I/O or CLI awareness.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Config object to validate
|
|
11
|
+
* @throws CliStructuredError if config structure is invalid
|
|
12
|
+
*/
|
|
13
|
+
declare function validateConfig(config: unknown): asserts config is PrismaNextConfig;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { validateConfig };
|
|
16
|
+
//# sourceMappingURL=config-validation.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-validation.d.mts","names":[],"sources":["../src/config-validation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;;;;iBAAgB,cAAA,qCAAmD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { r as errorConfigValidation } from "./errors-Qlh0sdcb.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/config-validation.ts
|
|
4
|
+
/**
|
|
5
|
+
* Validates that the config has the required structure.
|
|
6
|
+
* This is pure validation logic with no file I/O or CLI awareness.
|
|
7
|
+
*
|
|
8
|
+
* @param config - Config object to validate
|
|
9
|
+
* @throws CliStructuredError if config structure is invalid
|
|
10
|
+
*/
|
|
11
|
+
function validateConfig(config) {
|
|
12
|
+
if (!config || typeof config !== "object") throw errorConfigValidation("object", { why: "Config must be an object" });
|
|
13
|
+
const configObj = config;
|
|
14
|
+
if (!configObj["family"]) throw errorConfigValidation("family");
|
|
15
|
+
if (!configObj["target"]) throw errorConfigValidation("target");
|
|
16
|
+
if (!configObj["adapter"]) throw errorConfigValidation("adapter");
|
|
17
|
+
const family = configObj["family"];
|
|
18
|
+
if (family["kind"] !== "family") throw errorConfigValidation("family.kind", { why: "Config.family must have kind: \"family\"" });
|
|
19
|
+
if (typeof family["familyId"] !== "string") throw errorConfigValidation("family.familyId", { why: "Config.family must have familyId: string" });
|
|
20
|
+
if (typeof family["version"] !== "string") throw errorConfigValidation("family.version", { why: "Config.family must have version: string" });
|
|
21
|
+
if (!family["hook"] || typeof family["hook"] !== "object") throw errorConfigValidation("family.hook", { why: "Config.family must have hook: TargetFamilyHook" });
|
|
22
|
+
if (typeof family["create"] !== "function") throw errorConfigValidation("family.create", { why: "Config.family must have create: function" });
|
|
23
|
+
const familyId = family["familyId"];
|
|
24
|
+
const target = configObj["target"];
|
|
25
|
+
if (target["kind"] !== "target") throw errorConfigValidation("target.kind", { why: "Config.target must have kind: \"target\"" });
|
|
26
|
+
if (typeof target["id"] !== "string") throw errorConfigValidation("target.id", { why: "Config.target must have id: string" });
|
|
27
|
+
if (typeof target["familyId"] !== "string") throw errorConfigValidation("target.familyId", { why: "Config.target must have familyId: string" });
|
|
28
|
+
if (typeof target["version"] !== "string") throw errorConfigValidation("target.version", { why: "Config.target must have version: string" });
|
|
29
|
+
if (target["familyId"] !== familyId) throw errorConfigValidation("target.familyId", { why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target["familyId"]})` });
|
|
30
|
+
if (typeof target["targetId"] !== "string") throw errorConfigValidation("target.targetId", { why: "Config.target must have targetId: string" });
|
|
31
|
+
if (typeof target["create"] !== "function") throw errorConfigValidation("target.create", { why: "Config.target must have create: function" });
|
|
32
|
+
const expectedTargetId = target["targetId"];
|
|
33
|
+
const adapter = configObj["adapter"];
|
|
34
|
+
if (adapter["kind"] !== "adapter") throw errorConfigValidation("adapter.kind", { why: "Config.adapter must have kind: \"adapter\"" });
|
|
35
|
+
if (typeof adapter["id"] !== "string") throw errorConfigValidation("adapter.id", { why: "Config.adapter must have id: string" });
|
|
36
|
+
if (typeof adapter["familyId"] !== "string") throw errorConfigValidation("adapter.familyId", { why: "Config.adapter must have familyId: string" });
|
|
37
|
+
if (typeof adapter["version"] !== "string") throw errorConfigValidation("adapter.version", { why: "Config.adapter must have version: string" });
|
|
38
|
+
if (adapter["familyId"] !== familyId) throw errorConfigValidation("adapter.familyId", { why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter["familyId"]})` });
|
|
39
|
+
if (typeof adapter["targetId"] !== "string") throw errorConfigValidation("adapter.targetId", { why: "Config.adapter must have targetId: string" });
|
|
40
|
+
if (adapter["targetId"] !== expectedTargetId) throw errorConfigValidation("adapter.targetId", { why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter["targetId"]})` });
|
|
41
|
+
if (typeof adapter["create"] !== "function") throw errorConfigValidation("adapter.create", { why: "Config.adapter must have create: function" });
|
|
42
|
+
if (configObj["extensions"] !== void 0) {
|
|
43
|
+
if (!Array.isArray(configObj["extensions"])) throw errorConfigValidation("extensions", { why: "Config.extensions must be an array" });
|
|
44
|
+
for (const ext of configObj["extensions"]) {
|
|
45
|
+
if (!ext || typeof ext !== "object") throw errorConfigValidation("extensions[]", { why: "Config.extensions must contain ExtensionDescriptor objects" });
|
|
46
|
+
const extObj = ext;
|
|
47
|
+
if (extObj["kind"] !== "extension") throw errorConfigValidation("extensions[].kind", { why: "Config.extensions items must have kind: \"extension\"" });
|
|
48
|
+
if (typeof extObj["id"] !== "string") throw errorConfigValidation("extensions[].id", { why: "Config.extensions items must have id: string" });
|
|
49
|
+
if (typeof extObj["familyId"] !== "string") throw errorConfigValidation("extensions[].familyId", { why: "Config.extensions items must have familyId: string" });
|
|
50
|
+
if (typeof extObj["version"] !== "string") throw errorConfigValidation("extensions[].version", { why: "Config.extensions items must have version: string" });
|
|
51
|
+
if (extObj["familyId"] !== familyId) throw errorConfigValidation("extensions[].familyId", { why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj["familyId"]})` });
|
|
52
|
+
if (typeof extObj["targetId"] !== "string") throw errorConfigValidation("extensions[].targetId", { why: "Config.extensions items must have targetId: string" });
|
|
53
|
+
if (extObj["targetId"] !== expectedTargetId) throw errorConfigValidation("extensions[].targetId", { why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj["targetId"]})` });
|
|
54
|
+
if (typeof extObj["create"] !== "function") throw errorConfigValidation("extensions[].create", { why: "Config.extensions items must have create: function" });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (configObj["driver"] !== void 0) {
|
|
58
|
+
const driver = configObj["driver"];
|
|
59
|
+
if (driver["kind"] !== "driver") throw errorConfigValidation("driver.kind", { why: "Config.driver must have kind: \"driver\"" });
|
|
60
|
+
if (typeof driver["id"] !== "string") throw errorConfigValidation("driver.id", { why: "Config.driver must have id: string" });
|
|
61
|
+
if (typeof driver["version"] !== "string") throw errorConfigValidation("driver.version", { why: "Config.driver must have version: string" });
|
|
62
|
+
if (typeof driver["familyId"] !== "string") throw errorConfigValidation("driver.familyId", { why: "Config.driver must have familyId: string" });
|
|
63
|
+
if (driver["familyId"] !== familyId) throw errorConfigValidation("driver.familyId", { why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver["familyId"]})` });
|
|
64
|
+
if (typeof driver["targetId"] !== "string") throw errorConfigValidation("driver.targetId", { why: "Config.driver must have targetId: string" });
|
|
65
|
+
if (driver["targetId"] !== expectedTargetId) throw errorConfigValidation("driver.targetId", { why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver["targetId"]})` });
|
|
66
|
+
if (typeof driver["create"] !== "function") throw errorConfigValidation("driver.create", { why: "Config.driver must have create: function" });
|
|
67
|
+
}
|
|
68
|
+
if (configObj["contract"] !== void 0) {
|
|
69
|
+
const contract = configObj["contract"];
|
|
70
|
+
if (!contract || typeof contract !== "object") throw errorConfigValidation("contract", { why: "Config.contract must be an object" });
|
|
71
|
+
if (!("source" in contract)) throw errorConfigValidation("contract.source", { why: "Config.contract.source is required when contract is provided" });
|
|
72
|
+
if (typeof contract["source"] !== "function") throw errorConfigValidation("contract.source", { why: "Config.contract.source must be a provider function" });
|
|
73
|
+
if (contract["output"] !== void 0 && typeof contract["output"] !== "string") throw errorConfigValidation("contract.output", { why: "Config.contract.output must be a string when provided" });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { validateConfig };
|
|
79
|
+
//# sourceMappingURL=config-validation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-validation.mjs","names":[],"sources":["../src/config-validation.ts"],"sourcesContent":["import type { PrismaNextConfig } from './config-types';\nimport { errorConfigValidation } from './errors';\n\n/**\n * Validates that the config has the required structure.\n * This is pure validation logic with no file I/O or CLI awareness.\n *\n * @param config - Config object to validate\n * @throws CliStructuredError if config structure is invalid\n */\nexport function validateConfig(config: unknown): asserts config is PrismaNextConfig {\n if (!config || typeof config !== 'object') {\n throw errorConfigValidation('object', {\n why: 'Config must be an object',\n });\n }\n\n const configObj = config as Record<string, unknown>;\n\n if (!configObj['family']) {\n throw errorConfigValidation('family');\n }\n\n if (!configObj['target']) {\n throw errorConfigValidation('target');\n }\n\n if (!configObj['adapter']) {\n throw errorConfigValidation('adapter');\n }\n\n // Validate family descriptor\n const family = configObj['family'] as Record<string, unknown>;\n if (family['kind'] !== 'family') {\n throw errorConfigValidation('family.kind', {\n why: 'Config.family must have kind: \"family\"',\n });\n }\n if (typeof family['familyId'] !== 'string') {\n throw errorConfigValidation('family.familyId', {\n why: 'Config.family must have familyId: string',\n });\n }\n if (typeof family['version'] !== 'string') {\n throw errorConfigValidation('family.version', {\n why: 'Config.family must have version: string',\n });\n }\n if (!family['hook'] || typeof family['hook'] !== 'object') {\n throw errorConfigValidation('family.hook', {\n why: 'Config.family must have hook: TargetFamilyHook',\n });\n }\n if (typeof family['create'] !== 'function') {\n throw errorConfigValidation('family.create', {\n why: 'Config.family must have create: function',\n });\n }\n\n const familyId = family['familyId'] as string;\n\n // Validate target descriptor\n const target = configObj['target'] as Record<string, unknown>;\n if (target['kind'] !== 'target') {\n throw errorConfigValidation('target.kind', {\n why: 'Config.target must have kind: \"target\"',\n });\n }\n if (typeof target['id'] !== 'string') {\n throw errorConfigValidation('target.id', {\n why: 'Config.target must have id: string',\n });\n }\n if (typeof target['familyId'] !== 'string') {\n throw errorConfigValidation('target.familyId', {\n why: 'Config.target must have familyId: string',\n });\n }\n if (typeof target['version'] !== 'string') {\n throw errorConfigValidation('target.version', {\n why: 'Config.target must have version: string',\n });\n }\n if (target['familyId'] !== familyId) {\n throw errorConfigValidation('target.familyId', {\n why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,\n });\n }\n if (typeof target['targetId'] !== 'string') {\n throw errorConfigValidation('target.targetId', {\n why: 'Config.target must have targetId: string',\n });\n }\n if (typeof target['create'] !== 'function') {\n throw errorConfigValidation('target.create', {\n why: 'Config.target must have create: function',\n });\n }\n const expectedTargetId = target['targetId'] as string;\n\n // Validate adapter descriptor\n const adapter = configObj['adapter'] as Record<string, unknown>;\n if (adapter['kind'] !== 'adapter') {\n throw errorConfigValidation('adapter.kind', {\n why: 'Config.adapter must have kind: \"adapter\"',\n });\n }\n if (typeof adapter['id'] !== 'string') {\n throw errorConfigValidation('adapter.id', {\n why: 'Config.adapter must have id: string',\n });\n }\n if (typeof adapter['familyId'] !== 'string') {\n throw errorConfigValidation('adapter.familyId', {\n why: 'Config.adapter must have familyId: string',\n });\n }\n if (typeof adapter['version'] !== 'string') {\n throw errorConfigValidation('adapter.version', {\n why: 'Config.adapter must have version: string',\n });\n }\n if (adapter['familyId'] !== familyId) {\n throw errorConfigValidation('adapter.familyId', {\n why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,\n });\n }\n if (typeof adapter['targetId'] !== 'string') {\n throw errorConfigValidation('adapter.targetId', {\n why: 'Config.adapter must have targetId: string',\n });\n }\n if (adapter['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('adapter.targetId', {\n why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,\n });\n }\n if (typeof adapter['create'] !== 'function') {\n throw errorConfigValidation('adapter.create', {\n why: 'Config.adapter must have create: function',\n });\n }\n\n // Validate extensions array if present\n if (configObj['extensions'] !== undefined) {\n if (!Array.isArray(configObj['extensions'])) {\n throw errorConfigValidation('extensions', {\n why: 'Config.extensions must be an array',\n });\n }\n for (const ext of configObj['extensions']) {\n if (!ext || typeof ext !== 'object') {\n throw errorConfigValidation('extensions[]', {\n why: 'Config.extensions must contain ExtensionDescriptor objects',\n });\n }\n const extObj = ext as Record<string, unknown>;\n if (extObj['kind'] !== 'extension') {\n throw errorConfigValidation('extensions[].kind', {\n why: 'Config.extensions items must have kind: \"extension\"',\n });\n }\n if (typeof extObj['id'] !== 'string') {\n throw errorConfigValidation('extensions[].id', {\n why: 'Config.extensions items must have id: string',\n });\n }\n if (typeof extObj['familyId'] !== 'string') {\n throw errorConfigValidation('extensions[].familyId', {\n why: 'Config.extensions items must have familyId: string',\n });\n }\n if (typeof extObj['version'] !== 'string') {\n throw errorConfigValidation('extensions[].version', {\n why: 'Config.extensions items must have version: string',\n });\n }\n if (extObj['familyId'] !== familyId) {\n throw errorConfigValidation('extensions[].familyId', {\n why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,\n });\n }\n if (typeof extObj['targetId'] !== 'string') {\n throw errorConfigValidation('extensions[].targetId', {\n why: 'Config.extensions items must have targetId: string',\n });\n }\n if (extObj['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('extensions[].targetId', {\n why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,\n });\n }\n if (typeof extObj['create'] !== 'function') {\n throw errorConfigValidation('extensions[].create', {\n why: 'Config.extensions items must have create: function',\n });\n }\n }\n }\n\n // Validate driver descriptor if present\n if (configObj['driver'] !== undefined) {\n const driver = configObj['driver'] as Record<string, unknown>;\n if (driver['kind'] !== 'driver') {\n throw errorConfigValidation('driver.kind', {\n why: 'Config.driver must have kind: \"driver\"',\n });\n }\n if (typeof driver['id'] !== 'string') {\n throw errorConfigValidation('driver.id', {\n why: 'Config.driver must have id: string',\n });\n }\n if (typeof driver['version'] !== 'string') {\n throw errorConfigValidation('driver.version', {\n why: 'Config.driver must have version: string',\n });\n }\n if (typeof driver['familyId'] !== 'string') {\n throw errorConfigValidation('driver.familyId', {\n why: 'Config.driver must have familyId: string',\n });\n }\n if (driver['familyId'] !== familyId) {\n throw errorConfigValidation('driver.familyId', {\n why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,\n });\n }\n if (typeof driver['targetId'] !== 'string') {\n throw errorConfigValidation('driver.targetId', {\n why: 'Config.driver must have targetId: string',\n });\n }\n if (driver['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('driver.targetId', {\n why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,\n });\n }\n if (typeof driver['create'] !== 'function') {\n throw errorConfigValidation('driver.create', {\n why: 'Config.driver must have create: function',\n });\n }\n }\n\n // Validate contract config if present (structure validation - defineConfig() handles normalization)\n if (configObj['contract'] !== undefined) {\n const contract = configObj['contract'] as Record<string, unknown>;\n if (!contract || typeof contract !== 'object') {\n throw errorConfigValidation('contract', {\n why: 'Config.contract must be an object',\n });\n }\n if (!('source' in contract)) {\n throw errorConfigValidation('contract.source', {\n why: 'Config.contract.source is required when contract is provided',\n });\n }\n\n if (typeof contract['source'] !== 'function') {\n throw errorConfigValidation('contract.source', {\n why: 'Config.contract.source must be a provider function',\n });\n }\n\n if (contract['output'] !== undefined && typeof contract['output'] !== 'string') {\n throw errorConfigValidation('contract.output', {\n why: 'Config.contract.output must be a string when provided',\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,eAAe,QAAqD;AAClF,KAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,OAAM,sBAAsB,UAAU,EACpC,KAAK,4BACN,CAAC;CAGJ,MAAM,YAAY;AAElB,KAAI,CAAC,UAAU,UACb,OAAM,sBAAsB,SAAS;AAGvC,KAAI,CAAC,UAAU,UACb,OAAM,sBAAsB,SAAS;AAGvC,KAAI,CAAC,UAAU,WACb,OAAM,sBAAsB,UAAU;CAIxC,MAAM,SAAS,UAAU;AACzB,KAAI,OAAO,YAAY,SACrB,OAAM,sBAAsB,eAAe,EACzC,KAAK,4CACN,CAAC;AAEJ,KAAI,OAAO,OAAO,gBAAgB,SAChC,OAAM,sBAAsB,mBAAmB,EAC7C,KAAK,4CACN,CAAC;AAEJ,KAAI,OAAO,OAAO,eAAe,SAC/B,OAAM,sBAAsB,kB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AAsB,mBAAmB,EAC7C,KAAK,gEACN,CAAC;AAGJ,MAAI,OAAO,SAAS,cAAc,WAChC,OAAM,sBAAsB,mBAAmB,EAC7C,KAAK,sDACN,CAAC;AAGJ,MAAI,SAAS,cAAc,UAAa,OAAO,SAAS,cAAc,SACpE,OAAM,sBAAsB,mBAAmB,EAC7C,KAAK,yDACN,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { TargetFamilyHook, TypeRenderEntry, TypesImportSpec } from "@prisma-next/contract/types";
|
|
2
|
+
import { ContractIR } from "@prisma-next/contract/ir";
|
|
3
|
+
import { OperationRegistry } from "@prisma-next/operations";
|
|
4
|
+
|
|
5
|
+
//#region src/emission/canonicalization.d.ts
|
|
6
|
+
type CanonicalContractInput = {
|
|
7
|
+
schemaVersion: string;
|
|
8
|
+
targetFamily: string;
|
|
9
|
+
target: string;
|
|
10
|
+
models: Record<string, unknown>;
|
|
11
|
+
relations: Record<string, unknown>;
|
|
12
|
+
storage: Record<string, unknown>;
|
|
13
|
+
execution?: Record<string, unknown>;
|
|
14
|
+
extensionPacks: Record<string, unknown>;
|
|
15
|
+
capabilities: Record<string, Record<string, boolean>>;
|
|
16
|
+
meta: Record<string, unknown>;
|
|
17
|
+
storageHash?: string;
|
|
18
|
+
executionHash?: string;
|
|
19
|
+
profileHash?: string;
|
|
20
|
+
};
|
|
21
|
+
declare function canonicalizeContract(ir: CanonicalContractInput): string;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/emission/types.d.ts
|
|
24
|
+
interface EmitOptions {
|
|
25
|
+
readonly outputDir: string;
|
|
26
|
+
readonly operationRegistry?: OperationRegistry;
|
|
27
|
+
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
28
|
+
readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
29
|
+
readonly extensionIds?: ReadonlyArray<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Normalized parameterized type renderers, keyed by codecId.
|
|
32
|
+
* These are extracted from descriptors and normalized during assembly.
|
|
33
|
+
*/
|
|
34
|
+
readonly parameterizedRenderers?: Map<string, TypeRenderEntry>;
|
|
35
|
+
/**
|
|
36
|
+
* Type imports for parameterized codecs.
|
|
37
|
+
* These are added to contract.d.ts alongside codec and operation type imports.
|
|
38
|
+
*/
|
|
39
|
+
readonly parameterizedTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
40
|
+
}
|
|
41
|
+
interface EmitResult {
|
|
42
|
+
readonly contractJson: string;
|
|
43
|
+
readonly contractDts: string;
|
|
44
|
+
readonly storageHash: string;
|
|
45
|
+
readonly executionHash?: string;
|
|
46
|
+
readonly profileHash: string;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/emission/emit.d.ts
|
|
50
|
+
declare function emit(ir: ContractIR, options: EmitOptions, targetFamily: TargetFamilyHook): Promise<EmitResult>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/emission/hashing.d.ts
|
|
53
|
+
declare function computeStorageHash(contract: CanonicalContractInput): string;
|
|
54
|
+
declare function computeProfileHash(contract: CanonicalContractInput): string;
|
|
55
|
+
declare function computeExecutionHash(contract: CanonicalContractInput): string;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { type EmitOptions, type EmitResult, canonicalizeContract, computeExecutionHash, computeProfileHash, computeStorageHash, emit };
|
|
58
|
+
//# sourceMappingURL=emission.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emission.d.mts","names":[],"sources":["../src/emission/canonicalization.ts","../src/emission/types.ts","../src/emission/emit.ts","../src/emission/hashing.ts"],"sourcesContent":[],"mappings":";;;;;KAoBY,sBAAA;;;;UAIF;EAJE,SAAA,EAKC,MALD,CAAA,MAAA,EAAsB,OAAA,CAAA;EAIxB,OAAA,EAEC,MAFD,CAAA,MAAA,EAAA,OAAA,CAAA;EACG,SAAA,CAAA,EAEC,MAFD,CAAA,MAAA,EAAA,OAAA,CAAA;EACF,cAAA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