@prisma-next/config 0.10.0 → 0.11.0-dev.1
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-BDbcSJQg.d.mts → config-types-C_icPrLk.d.mts} +8 -9
- package/dist/{config-types-BDbcSJQg.d.mts.map → config-types-C_icPrLk.d.mts.map} +1 -1
- package/dist/config-types.d.mts +2 -2
- package/dist/config-types.mjs +9 -9
- package/dist/config-types.mjs.map +1 -1
- package/dist/config-validation.d.mts +1 -1
- package/package.json +6 -6
- package/src/config-types.ts +11 -8
- package/src/exports/config-types.ts +5 -1
|
@@ -62,13 +62,11 @@ interface ContractConfig {
|
|
|
62
62
|
readonly output?: string;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* default; this constant is only reached by providers like `typescriptContract`
|
|
69
|
-
* that hold an in-memory contract with no source path to anchor on.
|
|
65
|
+
* Default *source* directory for the contract file the user authors at `init`
|
|
66
|
+
* time. Output artefacts colocate with source per the same rule path-bearing
|
|
67
|
+
* providers apply.
|
|
70
68
|
*/
|
|
71
|
-
declare const
|
|
69
|
+
declare const DEFAULT_CONTRACT_SOURCE_DIR = "src/prisma";
|
|
72
70
|
declare function normalizeContractConfig(contract: ContractConfig): ContractConfig & {
|
|
73
71
|
readonly output: string;
|
|
74
72
|
};
|
|
@@ -121,7 +119,8 @@ interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends
|
|
|
121
119
|
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
122
120
|
*
|
|
123
121
|
* Normalization:
|
|
124
|
-
* - contract.output defaults to
|
|
122
|
+
* - contract.output defaults to a path colocated with DEFAULT_CONTRACT_SOURCE_DIR
|
|
123
|
+
* when missing (in-memory-only providers)
|
|
125
124
|
*
|
|
126
125
|
* @param config - Raw config input from user
|
|
127
126
|
* @returns Normalized config IR with defaults applied
|
|
@@ -129,5 +128,5 @@ interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends
|
|
|
129
128
|
*/
|
|
130
129
|
declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
|
|
131
130
|
//#endregion
|
|
132
|
-
export { normalizeContractConfig as a, ContractSourceDiagnosticPosition as c, ContractSourceProvider as d, defineConfig as i, ContractSourceDiagnosticSpan as l,
|
|
133
|
-
//# sourceMappingURL=config-types-
|
|
131
|
+
export { normalizeContractConfig as a, ContractSourceDiagnosticPosition as c, ContractSourceProvider as d, defineConfig as i, ContractSourceDiagnosticSpan as l, DEFAULT_CONTRACT_SOURCE_DIR as n, ContractSourceContext as o, PrismaNextConfig as r, ContractSourceDiagnostic as s, ContractConfig as t, ContractSourceDiagnostics as u };
|
|
132
|
+
//# sourceMappingURL=config-types-C_icPrLk.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types-
|
|
1
|
+
{"version":3,"file":"config-types-C_icPrLk.d.mts","names":[],"sources":["../src/contract-source-types.ts","../src/config-types.ts"],"mappings":";;;;;;UAQiB,gCAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,4BAAA;EAAA,SACN,KAAA,EAAO,gCAAA;EAAA,SACP,GAAA,EAAK,gCAAA;AAAA;AAAA,UAGC,wBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,GAAO,4BAAA;;;;;;WAMP,IAAA,GAAO,QAAA,CAAS,MAAA;AAAA;AAAA,UAGV,yBAAA;EAAA,SACN,OAAA;EAAA,SACA,WAAA,WAAsB,wBAAA;EAAA,SACtB,IAAA,GAAO,MAAA;AAAA;AAAA,UAGD,qBAAA;EAAA,SACN,sBAAA;EAAA,SACA,qBAAA,EAAuB,WAAA;EAAA,SACvB,sBAAA,EAAwB,+BA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ceProvider, i as defineConfig, l as ContractSourceDiagnosticSpan, n as
|
|
2
|
-
export { type ContractConfig, type ContractSourceContext, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceProvider,
|
|
1
|
+
import { a as normalizeContractConfig, c as ContractSourceDiagnosticPosition, d as ContractSourceProvider, i as defineConfig, l as ContractSourceDiagnosticSpan, n as DEFAULT_CONTRACT_SOURCE_DIR, o as ContractSourceContext, r as PrismaNextConfig, s as ContractSourceDiagnostic, t as ContractConfig, u as ContractSourceDiagnostics } from "./config-types-C_icPrLk.mjs";
|
|
2
|
+
export { type ContractConfig, type ContractSourceContext, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceProvider, DEFAULT_CONTRACT_SOURCE_DIR, type PrismaNextConfig, defineConfig, normalizeContractConfig };
|
package/dist/config-types.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { type } from "arktype";
|
|
2
2
|
//#region src/config-types.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* default; this constant is only reached by providers like `typescriptContract`
|
|
8
|
-
* that hold an in-memory contract with no source path to anchor on.
|
|
4
|
+
* Default *source* directory for the contract file the user authors at `init`
|
|
5
|
+
* time. Output artefacts colocate with source per the same rule path-bearing
|
|
6
|
+
* providers apply.
|
|
9
7
|
*/
|
|
10
|
-
const
|
|
8
|
+
const DEFAULT_CONTRACT_SOURCE_DIR = "src/prisma";
|
|
11
9
|
function normalizeContractConfig(contract) {
|
|
10
|
+
const inMemoryFallbackOutput = `${DEFAULT_CONTRACT_SOURCE_DIR}/contract.json`;
|
|
12
11
|
return {
|
|
13
12
|
source: contract.source,
|
|
14
|
-
output: contract.output ??
|
|
13
|
+
output: contract.output ?? inMemoryFallbackOutput
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
16
|
const PrismaNextConfigSchema = type({
|
|
@@ -35,7 +34,8 @@ const PrismaNextConfigSchema = type({
|
|
|
35
34
|
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
36
35
|
*
|
|
37
36
|
* Normalization:
|
|
38
|
-
* - contract.output defaults to
|
|
37
|
+
* - contract.output defaults to a path colocated with DEFAULT_CONTRACT_SOURCE_DIR
|
|
38
|
+
* when missing (in-memory-only providers)
|
|
39
39
|
*
|
|
40
40
|
* @param config - Raw config input from user
|
|
41
41
|
* @returns Normalized config IR with defaults applied
|
|
@@ -54,6 +54,6 @@ function defineConfig(config) {
|
|
|
54
54
|
return config;
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
|
-
export {
|
|
57
|
+
export { DEFAULT_CONTRACT_SOURCE_DIR, defineConfig, normalizeContractConfig };
|
|
58
58
|
|
|
59
59
|
//# sourceMappingURL=config-types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlDriverInstance,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\nimport type { ContractSourceProvider } from './contract-source-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 a Contract or structured diagnostics.\n */\n readonly source: ContractSourceProvider;\n /**\n * Path to contract.json artifact. Providers that know an input path (PSL,\n * `typescriptContractFromPath`) derive an output colocated with that input\n * so this rarely needs to be set explicitly. The `.d.ts` types file is\n * always emitted next to the JSON (e.g., `contract.json` → `contract.d.ts`).\n */\n readonly output?: string;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlDriverInstance,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\nimport type { ContractSourceProvider } from './contract-source-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 a Contract or structured diagnostics.\n */\n readonly source: ContractSourceProvider;\n /**\n * Path to contract.json artifact. Providers that know an input path (PSL,\n * `typescriptContractFromPath`) derive an output colocated with that input\n * so this rarely needs to be set explicitly. The `.d.ts` types file is\n * always emitted next to the JSON (e.g., `contract.json` → `contract.d.ts`).\n */\n readonly output?: string;\n}\n\n/**\n * Default *source* directory for the contract file the user authors at `init`\n * time. Output artefacts colocate with source per the same rule path-bearing\n * providers apply.\n */\nexport const DEFAULT_CONTRACT_SOURCE_DIR = 'src/prisma';\n\nexport function normalizeContractConfig(\n contract: ContractConfig,\n): ContractConfig & { readonly output: string } {\n // In-memory-only fallback: `typescriptContract(contract)` has no source path\n // to anchor on, so normalization supplies a default output colocated with\n // the default source directory.\n const inMemoryFallbackOutput = `${DEFAULT_CONTRACT_SOURCE_DIR}/contract.json`;\n return {\n source: contract.source,\n output: contract.output ?? inMemoryFallbackOutput,\n };\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 * Migration configuration. Controls where on-disk migration packages are stored.\n */\n readonly migrations?: {\n /** Directory for migration packages, relative to config file. Defaults to 'migrations'. */\n readonly dir?: string;\n };\n}\n\nconst ContractSourceInputSchema = type('string');\n\nexport const ContractSourceProviderSchema = type({\n 'inputs?': ContractSourceInputSchema.array(),\n load: 'Function',\n});\n\nexport const ContractConfigSchema = type({\n source: ContractSourceProviderSchema,\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 MigrationsConfigSchema = type({\n 'dir?': 'string',\n});\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 'migrations?': MigrationsConfigSchema,\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 a path colocated with DEFAULT_CONTRACT_SOURCE_DIR\n * when missing (in-memory-only providers)\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 // Return normalized config\n return {\n ...config,\n contract: normalizeContractConfig(config.contract),\n };\n }\n\n // Return config as-is if no contract (preserve literal types)\n return config;\n}\n"],"mappings":";;;;;;;AAwCA,MAAa,8BAA8B;AAE3C,SAAgB,wBACd,UAC8C;CAI9C,MAAM,yBAAyB,GAAG,4BAA4B;CAC9D,OAAO;EACL,QAAQ,SAAS;EACjB,QAAQ,SAAS,UAAU;EAC5B;;AA8EH,MAAM,yBAAyB,KAAK;CAClC,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,mBAAmB;CACnB,WAAW;CACX,OAAO;CACP,aApBkC,KAAK;EACvC,QAN0C,KAAK;GAC/C,WAHgC,KAAK,SAG1B,CAA0B,OAAO;GAC5C,MAAM;GACP,CAGS;EACR,WAAW;EACZ,CAiBc;CACb,eAZ6B,KAAK,EAClC,QAAQ,UACT,CAUsC;CACtC,CAAC;;;;;;;;;;;;;AAcF,SAAgB,aACd,QACwC;CAExC,MAAM,YAAY,uBAAuB,OAAO;CAChD,IAAI,qBAAqB,KAAK,QAAQ;EACpC,MAAM,WAAW,UAAU,KAAK,MAA2B,EAAE,QAAQ,CAAC,KAAK,KAAK;EAChF,MAAM,IAAI,MAAM,6BAA6B,WAAW;;CAI1D,IAAI,OAAO,UAET,OAAO;EACL,GAAG;EACH,UAAU,wBAAwB,OAAO,SAAS;EACnD;CAIH,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-dev.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Prisma Next config authoring types and validation",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.
|
|
10
|
-
"@prisma-next/framework-components": "0.
|
|
11
|
-
"@prisma-next/utils": "0.
|
|
9
|
+
"@prisma-next/contract": "0.11.0-dev.1",
|
|
10
|
+
"@prisma-next/framework-components": "0.11.0-dev.1",
|
|
11
|
+
"@prisma-next/utils": "0.11.0-dev.1",
|
|
12
12
|
"arktype": "^2.2.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@prisma-next/tsconfig": "0.
|
|
16
|
-
"@prisma-next/tsdown": "0.
|
|
15
|
+
"@prisma-next/tsconfig": "0.11.0-dev.1",
|
|
16
|
+
"@prisma-next/tsdown": "0.11.0-dev.1",
|
|
17
17
|
"tsdown": "0.22.0",
|
|
18
18
|
"typescript": "5.9.3",
|
|
19
19
|
"vitest": "4.1.6"
|
package/src/config-types.ts
CHANGED
|
@@ -34,20 +34,22 @@ export interface ContractConfig {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* default; this constant is only reached by providers like `typescriptContract`
|
|
41
|
-
* that hold an in-memory contract with no source path to anchor on.
|
|
37
|
+
* Default *source* directory for the contract file the user authors at `init`
|
|
38
|
+
* time. Output artefacts colocate with source per the same rule path-bearing
|
|
39
|
+
* providers apply.
|
|
42
40
|
*/
|
|
43
|
-
export const
|
|
41
|
+
export const DEFAULT_CONTRACT_SOURCE_DIR = 'src/prisma';
|
|
44
42
|
|
|
45
43
|
export function normalizeContractConfig(
|
|
46
44
|
contract: ContractConfig,
|
|
47
45
|
): ContractConfig & { readonly output: string } {
|
|
46
|
+
// In-memory-only fallback: `typescriptContract(contract)` has no source path
|
|
47
|
+
// to anchor on, so normalization supplies a default output colocated with
|
|
48
|
+
// the default source directory.
|
|
49
|
+
const inMemoryFallbackOutput = `${DEFAULT_CONTRACT_SOURCE_DIR}/contract.json`;
|
|
48
50
|
return {
|
|
49
51
|
source: contract.source,
|
|
50
|
-
output: contract.output ??
|
|
52
|
+
output: contract.output ?? inMemoryFallbackOutput,
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -142,7 +144,8 @@ const PrismaNextConfigSchema = type({
|
|
|
142
144
|
* Validates and normalizes the config using Arktype, then returns the normalized IR.
|
|
143
145
|
*
|
|
144
146
|
* Normalization:
|
|
145
|
-
* - contract.output defaults to
|
|
147
|
+
* - contract.output defaults to a path colocated with DEFAULT_CONTRACT_SOURCE_DIR
|
|
148
|
+
* when missing (in-memory-only providers)
|
|
146
149
|
*
|
|
147
150
|
* @param config - Raw config input from user
|
|
148
151
|
* @returns Normalized config IR with defaults applied
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export type { ContractConfig, PrismaNextConfig } from '../config-types';
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
DEFAULT_CONTRACT_SOURCE_DIR,
|
|
4
|
+
defineConfig,
|
|
5
|
+
normalizeContractConfig,
|
|
6
|
+
} from '../config-types';
|
|
3
7
|
export type {
|
|
4
8
|
ContractSourceContext,
|
|
5
9
|
ContractSourceDiagnostic,
|