🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/config

Package Overview
Dependencies
Maintainers
4
Versions
536
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/config - npm Package Compare versions

Comparing version
0.14.0-dev.55
to
0.14.0-dev.57
+159
dist/config-types-O5PKSIYe.d.mts
import { AssembledAuthoringContributions, ControlAdapterDescriptor, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlMutationDefaults, ControlTargetDescriptor } from "@prisma-next/framework-components/control";
import { Contract } from "@prisma-next/contract/types";
import { CodecLookup } from "@prisma-next/framework-components/codec";
import { CapabilityMatrix } from "@prisma-next/framework-components/components";
import { Result } from "@prisma-next/utils/result";
//#region src/contract-source-types.d.ts
interface ContractSourceDiagnosticPosition {
readonly offset: number;
readonly line: number;
readonly column: number;
}
interface ContractSourceDiagnosticSpan {
readonly start: ContractSourceDiagnosticPosition;
readonly end: ContractSourceDiagnosticPosition;
}
interface ContractSourceDiagnostic {
readonly code: string;
readonly message: string;
readonly sourceId?: string;
readonly span?: ContractSourceDiagnosticSpan;
/**
* Optional structured payload for machine-readable consumers (agents,
* IDE extensions, CLI auto-fix). Human-readable prose lives in `message`;
* `data` carries the extracted facts (e.g. `{ namespace: 'pgvector' }`).
*/
readonly data?: Readonly<Record<string, unknown>>;
}
interface ContractSourceDiagnostics {
readonly summary: string;
readonly diagnostics: readonly ContractSourceDiagnostic[];
readonly meta?: Record<string, unknown>;
}
interface ContractSourceContext {
readonly composedExtensionPacks: readonly string[];
/** Extension contracts keyed by space ID, required for cross-space FK resolution. */
readonly composedExtensionContracts: ReadonlyMap<string, Contract>;
readonly scalarTypeDescriptors: ReadonlyMap<string, string>;
readonly authoringContributions: AssembledAuthoringContributions;
readonly codecLookup: CodecLookup;
readonly controlMutationDefaults: ControlMutationDefaults;
readonly resolvedInputs: readonly string[];
readonly capabilities: CapabilityMatrix;
}
/** Lets format-aware tooling avoid file-extension sniffing and opaque loader introspection. */
type ContractSourceFormat = 'psl' | 'typescript';
interface ContractSourceProviderBase {
readonly inputs?: readonly string[];
readonly load: (context: ContractSourceContext) => Promise<Result<Contract, ContractSourceDiagnostics>>;
}
interface PslContractSourceProvider extends ContractSourceProviderBase {
readonly sourceFormat: 'psl';
}
interface TypeScriptContractSourceProvider extends ContractSourceProviderBase {
readonly sourceFormat: 'typescript';
}
/**
* Third-party or unspecified source formats. Absent (or unrecognized)
* `sourceFormat` means format-aware tooling must leave the source untouched.
* Narrowing to a known format flows only through capability guards owned by
* the authoring layer.
*/
interface OpaqueContractSourceProvider extends ContractSourceProviderBase {
readonly sourceFormat?: string;
}
type ContractSourceProvider = PslContractSourceProvider | TypeScriptContractSourceProvider | OpaqueContractSourceProvider;
//#endregion
//#region src/config-types.d.ts
/**
* Contract configuration specifying source and artifact locations.
*/
interface ContractConfig {
/**
* Contract source provider. The provider is always async and must return
* a Result containing either a Contract or structured diagnostics.
*/
readonly source: ContractSourceProvider;
/**
* Path to contract.json artifact. Providers that know an input path (PSL,
* `typescriptContractFromPath`) derive an output colocated with that input
* so this rarely needs to be set explicitly. The `.d.ts` types file is
* always emitted next to the JSON (e.g., `contract.json` → `contract.d.ts`).
*/
readonly output?: string;
}
interface FormatterConfig {
readonly indent?: number | 'tab';
readonly newline?: 'LF' | 'CRLF';
}
/**
* Default *source* directory for the contract file the user authors at `init`
* time. Output artefacts colocate with source per the same rule path-bearing
* providers apply.
*/
declare const DEFAULT_CONTRACT_SOURCE_DIR = "src/prisma";
declare function normalizeContractConfig(contract: ContractConfig): ContractConfig & {
readonly output: string;
};
/**
* Configuration for Prisma Next CLI.
* Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
*
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
* @template TConnection - The driver connection input type (defaults to `unknown` for config flexibility)
*/
interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string, TConnection = unknown> {
readonly family: ControlFamilyDescriptor<TFamilyId>;
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
/**
* Driver descriptor for DB-connected CLI commands.
* Required for DB-connected commands (e.g., db verify).
* Optional for commands that don't need database access (e.g., emit).
* The driver's connection type matches the TConnection config parameter.
*/
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId, ControlDriverInstance<TFamilyId, TTargetId>, TConnection>;
/**
* Database connection configuration.
* The connection type is driver-specific (e.g., URL string for Postgres).
*/
readonly db?: {
/**
* Driver-specific connection input.
* For Postgres: a connection string (URL).
* For other drivers: may be a structured object.
*/
readonly connection?: TConnection;
};
/**
* Contract configuration. Specifies source and artifact locations.
* Required for emit command; optional for other commands that only read artifacts.
*/
readonly contract?: ContractConfig;
/**
* Migration configuration. Controls where on-disk migration packages are stored.
*/
readonly migrations?: {
/** Directory for migration packages, relative to config file. Defaults to 'migrations'. */readonly dir?: string;
};
readonly formatter?: FormatterConfig;
}
/**
* Helper function to define a Prisma Next config.
* Validates and normalizes the config using Arktype, then returns the normalized IR.
*
* Normalization:
* - contract.output defaults to a path colocated with DEFAULT_CONTRACT_SOURCE_DIR
* when missing (in-memory-only providers)
*
* @param config - Raw config input from user
* @returns Normalized config IR with defaults applied
* @throws Error if config structure is invalid
*/
declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
//#endregion
export { TypeScriptContractSourceProvider as _, defineConfig as a, ContractSourceDiagnostic as c, ContractSourceDiagnostics as d, ContractSourceFormat as f, PslContractSourceProvider as g, OpaqueContractSourceProvider as h, PrismaNextConfig as i, ContractSourceDiagnosticPosition as l, ContractSourceProviderBase as m, DEFAULT_CONTRACT_SOURCE_DIR as n, normalizeContractConfig as o, ContractSourceProvider as p, FormatterConfig as r, ContractSourceContext as s, ContractConfig as t, ContractSourceDiagnosticSpan as u };
//# sourceMappingURL=config-types-O5PKSIYe.d.mts.map
{"version":3,"file":"config-types-O5PKSIYe.d.mts","names":[],"sources":["../src/contract-source-types.ts","../src/config-types.ts"],"mappings":";;;;;;;UASiB,gCAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,4BAAA;EAAA,SACN,KAAA,EAAO,gCAAA;EAAA,SACP,GAAA,EAAK,gCAAgC;AAAA;AAAA,UAG/B,wBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,GAAO,4BAAA;EAP8B;;;;;EAAA,SAarC,IAAA,GAAO,QAAA,CAAS,MAAA;AAAA;AAAA,UAGV,yBAAA;EAAA,SACN,OAAA;EAAA,SACA,WAAA,WAAsB,wBAAA;EAAA,SACtB,IAAA,GAAO,MAAM;AAAA;AAAA,UAGP,qBAAA;EAAA,SACN,sBAAA;EAVe;EAAA,SAYf,0BAAA,EAA4B,WAAA,SAAoB,QAAA;EAAA,SAChD,qBAAA,EAAuB,WAAA;EAAA,SACvB,sBAAA,EAAwB,+BAAA;EAAA,SACxB,WAAA,EAAa,WAAA;EAAA,SACb,uBAAA,EAAyB,uBAAA;EAAA,SACzB,cAAA;EAAA,SACA,YAAA,EAAc,gBAAA;AAAA;;KAIb,oBAAA;AAAA,UAEK,0BAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA,GACP,OAAA,EAAS,qBAAA,KACN,OAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,yBAAA;AAAA;AAAA,UAGf,yBAAA,SAAkC,0BAA0B;EAAA,SAClE,YAAY;AAAA;AAAA,UAGN,gCAAA,SAAyC,0BAA0B;EAAA,SACzE,YAAY;AAAA;AA9BC;AAGxB;;;;;AAHwB,UAuCP,4BAAA,SAAqC,0BAA0B;EAAA,SACrE,YAAY;AAAA;AAAA,KAGX,sBAAA,GACR,yBAAA,GACA,gCAAA,GACA,4BAAA;;;AAzEJ;;;AAAA,UCWiB,cAAA;EDVN;;;;EAAA,SCeA,MAAA,EAAQ,sBAAsB;EDVxB;;;;;;EAAA,SCiBN,MAAA;AAAA;AAAA,UAGM,eAAA;EAAA,SACN,MAAA;EAAA,SACA,OAAO;AAAA;;;;;;cAQL,2BAAA;AAAA,iBAEG,uBAAA,CACd,QAAA,EAAU,cAAA,GACT,cAAc;EAAA,SAAc,MAAA;AAAA;;;;;;;ADnBE;AAGjC;UCmCiB,gBAAA;EAAA,SAKN,MAAA,EAAQ,uBAAA,CAAwB,SAAA;EAAA,SAChC,MAAA,EAAQ,uBAAA,CAAwB,SAAA,EAAW,SAAA;EAAA,SAC3C,OAAA,EAAS,wBAAA,CAAyB,SAAA,EAAW,SAAA;EAAA,SAC7C,cAAA,YAA0B,0BAAA,CAA2B,SAAA,EAAW,SAAA;EDzC1C;;;;AACT;AAGxB;EAJiC,SCgDtB,MAAA,GAAS,uBAAA,CAChB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA,EAAW,SAAA,GACjC,WAAA;;;;;WAMO,EAAA;IDhDa;;;;;IAAA,SCsDX,UAAA,GAAa,WAAA;EAAA;EDzDa;;;;EAAA,SC+D5B,QAAA,GAAW,cAAA;ED7Da;;;EAAA,SCiExB,UAAA;ID/DyB,oGCiEvB,GAAA;EAAA;EAAA,SAEF,SAAA,GAAY,eAAA;AAAA;;;;;;;;;ADvDkC;AAGzD;;;iBC2GgB,YAAA,uEACd,MAAA,EAAQ,gBAAA,CAAiB,SAAA,EAAW,SAAA,IACnC,gBAAA,CAAiB,SAAA,EAAW,SAAA"}
+2
-2

@@ -1,2 +0,2 @@

import { a as defineConfig, c as ContractSourceDiagnostic, d as ContractSourceDiagnostics, f as ContractSourceFormat, i as PrismaNextConfig, l as ContractSourceDiagnosticPosition, n as DEFAULT_CONTRACT_SOURCE_DIR, o as normalizeContractConfig, p as ContractSourceProvider, r as FormatterConfig, s as ContractSourceContext, t as ContractConfig, u as ContractSourceDiagnosticSpan } from "./config-types-DYfiKSrh.mjs";
export { type ContractConfig, type ContractSourceContext, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceFormat, type ContractSourceProvider, DEFAULT_CONTRACT_SOURCE_DIR, type FormatterConfig, type PrismaNextConfig, defineConfig, normalizeContractConfig };
import { _ as TypeScriptContractSourceProvider, a as defineConfig, c as ContractSourceDiagnostic, d as ContractSourceDiagnostics, f as ContractSourceFormat, g as PslContractSourceProvider, h as OpaqueContractSourceProvider, i as PrismaNextConfig, l as ContractSourceDiagnosticPosition, m as ContractSourceProviderBase, n as DEFAULT_CONTRACT_SOURCE_DIR, o as normalizeContractConfig, p as ContractSourceProvider, r as FormatterConfig, s as ContractSourceContext, t as ContractConfig, u as ContractSourceDiagnosticSpan } from "./config-types-O5PKSIYe.mjs";
export { type ContractConfig, type ContractSourceContext, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceFormat, type ContractSourceProvider, type ContractSourceProviderBase, DEFAULT_CONTRACT_SOURCE_DIR, type FormatterConfig, type OpaqueContractSourceProvider, type PrismaNextConfig, type PslContractSourceProvider, type TypeScriptContractSourceProvider, defineConfig, normalizeContractConfig };

@@ -25,3 +25,3 @@ import { type } from "arktype";

source: type({
"sourceFormat?": "'psl' | 'typescript'",
"sourceFormat?": "string",
"inputs?": type("string").array(),

@@ -28,0 +28,0 @@ load: "Function"

@@ -1,1 +0,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\nexport interface FormatterConfig {\n readonly indent?: number | 'tab';\n readonly newline?: 'LF' | 'CRLF';\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 readonly formatter?: FormatterConfig;\n}\n\nconst ContractSourceInputSchema = type('string');\n\nexport const ContractSourceProviderSchema = type({\n 'sourceFormat?': \"'psl' | 'typescript'\",\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 FormatterIndentSchema = type('number.integer >= 1').or(\"'tab'\");\n\nexport const FormatterConfigSchema = type({\n 'indent?': FormatterIndentSchema,\n 'newline?': \"'LF' | 'CRLF'\",\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 'formatter?': FormatterConfigSchema,\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":";;;;;;;AA6CA,MAAa,8BAA8B;AAE3C,SAAgB,wBACd,UAC8C;CAI9C,MAAM,yBAAyB,GAAG,4BAA4B;CAC9D,OAAO;EACL,QAAQ,SAAS;EACjB,QAAQ,SAAS,UAAU;CAC7B;AACF;AAsFA,MAAM,yBAAyB,KAAK;CAClC,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,mBAAmB;CACnB,WAAW;CACX,OAAO;CACP,aA3BkC,KAAK;EACvC,QAP0C,KAAK;GAC/C,iBAAiB;GACjB,WAJgC,KAAK,QAI1B,CAAA,CAA0B,MAAM;GAC3C,MAAM;EACR,CAGU;EACR,WAAW;CACb,CAwBe;CACb,eAnB6B,KAAK,EAClC,QAAQ,SACV,CAiBiB;CACf,cAdmC,KAAK;EACxC,WAH4B,KAAK,qBAAqB,CAAC,CAAC,GAAG,OAGhD;EACX,YAAY;CACd,CAWgB;AAChB,CAAC;;;;;;;;;;;;;AAcD,SAAgB,aACd,QACwC;CAExC,MAAM,YAAY,uBAAuB,MAAM;CAC/C,IAAI,qBAAqB,KAAK,QAAQ;EACpC,MAAM,WAAW,UAAU,KAAK,MAA2B,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI;EAC/E,MAAM,IAAI,MAAM,6BAA6B,UAAU;CACzD;CAGA,IAAI,OAAO,UAET,OAAO;EACL,GAAG;EACH,UAAU,wBAAwB,OAAO,QAAQ;CACnD;CAIF,OAAO;AACT"}
{"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\nexport interface FormatterConfig {\n readonly indent?: number | 'tab';\n readonly newline?: 'LF' | 'CRLF';\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 readonly formatter?: FormatterConfig;\n}\n\nconst ContractSourceInputSchema = type('string');\n\nexport const ContractSourceProviderSchema = type({\n 'sourceFormat?': 'string',\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 FormatterIndentSchema = type('number.integer >= 1').or(\"'tab'\");\n\nexport const FormatterConfigSchema = type({\n 'indent?': FormatterIndentSchema,\n 'newline?': \"'LF' | 'CRLF'\",\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 'formatter?': FormatterConfigSchema,\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":";;;;;;;AA6CA,MAAa,8BAA8B;AAE3C,SAAgB,wBACd,UAC8C;CAI9C,MAAM,yBAAyB,GAAG,4BAA4B;CAC9D,OAAO;EACL,QAAQ,SAAS;EACjB,QAAQ,SAAS,UAAU;CAC7B;AACF;AAsFA,MAAM,yBAAyB,KAAK;CAClC,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,mBAAmB;CACnB,WAAW;CACX,OAAO;CACP,aA3BkC,KAAK;EACvC,QAP0C,KAAK;GAC/C,iBAAiB;GACjB,WAJgC,KAAK,QAI1B,CAAA,CAA0B,MAAM;GAC3C,MAAM;EACR,CAGU;EACR,WAAW;CACb,CAwBe;CACb,eAnB6B,KAAK,EAClC,QAAQ,SACV,CAiBiB;CACf,cAdmC,KAAK;EACxC,WAH4B,KAAK,qBAAqB,CAAC,CAAC,GAAG,OAGhD;EACX,YAAY;CACd,CAWgB;AAChB,CAAC;;;;;;;;;;;;;AAcD,SAAgB,aACd,QACwC;CAExC,MAAM,YAAY,uBAAuB,MAAM;CAC/C,IAAI,qBAAqB,KAAK,QAAQ;EACpC,MAAM,WAAW,UAAU,KAAK,MAA2B,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI;EAC/E,MAAM,IAAI,MAAM,6BAA6B,UAAU;CACzD;CAGA,IAAI,OAAO,UAET,OAAO;EACL,GAAG;EACH,UAAU,wBAAwB,OAAO,QAAQ;CACnD;CAIF,OAAO;AACT"}

@@ -1,2 +0,2 @@

import { i as PrismaNextConfig } from "./config-types-DYfiKSrh.mjs";
import { i as PrismaNextConfig } from "./config-types-O5PKSIYe.mjs";

@@ -3,0 +3,0 @@ //#region src/config-validation.d.ts

{
"name": "@prisma-next/config",
"version": "0.14.0-dev.55",
"version": "0.14.0-dev.57",
"license": "Apache-2.0",

@@ -9,5 +9,5 @@ "type": "module",

"dependencies": {
"@prisma-next/contract": "0.14.0-dev.55",
"@prisma-next/framework-components": "0.14.0-dev.55",
"@prisma-next/utils": "0.14.0-dev.55",
"@prisma-next/contract": "0.14.0-dev.57",
"@prisma-next/framework-components": "0.14.0-dev.57",
"@prisma-next/utils": "0.14.0-dev.57",
"arktype": "^2.2.0",

@@ -17,4 +17,4 @@ "pathe": "^2.0.3"

"devDependencies": {
"@prisma-next/tsconfig": "0.14.0-dev.55",
"@prisma-next/tsdown": "0.14.0-dev.55",
"@prisma-next/tsconfig": "0.14.0-dev.57",
"@prisma-next/tsdown": "0.14.0-dev.57",
"tsdown": "0.22.1",

@@ -21,0 +21,0 @@ "typescript": "5.9.3",

@@ -120,3 +120,3 @@ import type {

export const ContractSourceProviderSchema = type({
'sourceFormat?': "'psl' | 'typescript'",
'sourceFormat?': 'string',
'inputs?': ContractSourceInputSchema.array(),

@@ -123,0 +123,0 @@ load: 'Function',

@@ -55,5 +55,3 @@ import type { Contract } from '@prisma-next/contract/types';

export interface ContractSourceProvider {
/** Absent means format-aware tooling must leave the source untouched. */
readonly sourceFormat?: ContractSourceFormat;
export interface ContractSourceProviderBase {
readonly inputs?: readonly string[];

@@ -64,1 +62,24 @@ readonly load: (

}
export interface PslContractSourceProvider extends ContractSourceProviderBase {
readonly sourceFormat: 'psl';
}
export interface TypeScriptContractSourceProvider extends ContractSourceProviderBase {
readonly sourceFormat: 'typescript';
}
/**
* Third-party or unspecified source formats. Absent (or unrecognized)
* `sourceFormat` means format-aware tooling must leave the source untouched.
* Narrowing to a known format flows only through capability guards owned by
* the authoring layer.
*/
export interface OpaqueContractSourceProvider extends ContractSourceProviderBase {
readonly sourceFormat?: string;
}
export type ContractSourceProvider =
| PslContractSourceProvider
| TypeScriptContractSourceProvider
| OpaqueContractSourceProvider;

@@ -15,2 +15,6 @@ export type { ContractConfig, FormatterConfig, PrismaNextConfig } from '../config-types';

ContractSourceProvider,
ContractSourceProviderBase,
OpaqueContractSourceProvider,
PslContractSourceProvider,
TypeScriptContractSourceProvider,
} from '../contract-source-types';
import { AssembledAuthoringContributions, ControlAdapterDescriptor, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlMutationDefaults, ControlTargetDescriptor } from "@prisma-next/framework-components/control";
import { Contract } from "@prisma-next/contract/types";
import { CodecLookup } from "@prisma-next/framework-components/codec";
import { CapabilityMatrix } from "@prisma-next/framework-components/components";
import { Result } from "@prisma-next/utils/result";
//#region src/contract-source-types.d.ts
interface ContractSourceDiagnosticPosition {
readonly offset: number;
readonly line: number;
readonly column: number;
}
interface ContractSourceDiagnosticSpan {
readonly start: ContractSourceDiagnosticPosition;
readonly end: ContractSourceDiagnosticPosition;
}
interface ContractSourceDiagnostic {
readonly code: string;
readonly message: string;
readonly sourceId?: string;
readonly span?: ContractSourceDiagnosticSpan;
/**
* Optional structured payload for machine-readable consumers (agents,
* IDE extensions, CLI auto-fix). Human-readable prose lives in `message`;
* `data` carries the extracted facts (e.g. `{ namespace: 'pgvector' }`).
*/
readonly data?: Readonly<Record<string, unknown>>;
}
interface ContractSourceDiagnostics {
readonly summary: string;
readonly diagnostics: readonly ContractSourceDiagnostic[];
readonly meta?: Record<string, unknown>;
}
interface ContractSourceContext {
readonly composedExtensionPacks: readonly string[];
/** Extension contracts keyed by space ID, required for cross-space FK resolution. */
readonly composedExtensionContracts: ReadonlyMap<string, Contract>;
readonly scalarTypeDescriptors: ReadonlyMap<string, string>;
readonly authoringContributions: AssembledAuthoringContributions;
readonly codecLookup: CodecLookup;
readonly controlMutationDefaults: ControlMutationDefaults;
readonly resolvedInputs: readonly string[];
readonly capabilities: CapabilityMatrix;
}
/** Lets format-aware tooling avoid file-extension sniffing and opaque loader introspection. */
type ContractSourceFormat = 'psl' | 'typescript';
interface ContractSourceProvider {
/** Absent means format-aware tooling must leave the source untouched. */
readonly sourceFormat?: ContractSourceFormat;
readonly inputs?: readonly string[];
readonly load: (context: ContractSourceContext) => Promise<Result<Contract, ContractSourceDiagnostics>>;
}
//#endregion
//#region src/config-types.d.ts
/**
* Contract configuration specifying source and artifact locations.
*/
interface ContractConfig {
/**
* Contract source provider. The provider is always async and must return
* a Result containing either a Contract or structured diagnostics.
*/
readonly source: ContractSourceProvider;
/**
* Path to contract.json artifact. Providers that know an input path (PSL,
* `typescriptContractFromPath`) derive an output colocated with that input
* so this rarely needs to be set explicitly. The `.d.ts` types file is
* always emitted next to the JSON (e.g., `contract.json` → `contract.d.ts`).
*/
readonly output?: string;
}
interface FormatterConfig {
readonly indent?: number | 'tab';
readonly newline?: 'LF' | 'CRLF';
}
/**
* Default *source* directory for the contract file the user authors at `init`
* time. Output artefacts colocate with source per the same rule path-bearing
* providers apply.
*/
declare const DEFAULT_CONTRACT_SOURCE_DIR = "src/prisma";
declare function normalizeContractConfig(contract: ContractConfig): ContractConfig & {
readonly output: string;
};
/**
* Configuration for Prisma Next CLI.
* Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
*
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
* @template TConnection - The driver connection input type (defaults to `unknown` for config flexibility)
*/
interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string, TConnection = unknown> {
readonly family: ControlFamilyDescriptor<TFamilyId>;
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
/**
* Driver descriptor for DB-connected CLI commands.
* Required for DB-connected commands (e.g., db verify).
* Optional for commands that don't need database access (e.g., emit).
* The driver's connection type matches the TConnection config parameter.
*/
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId, ControlDriverInstance<TFamilyId, TTargetId>, TConnection>;
/**
* Database connection configuration.
* The connection type is driver-specific (e.g., URL string for Postgres).
*/
readonly db?: {
/**
* Driver-specific connection input.
* For Postgres: a connection string (URL).
* For other drivers: may be a structured object.
*/
readonly connection?: TConnection;
};
/**
* Contract configuration. Specifies source and artifact locations.
* Required for emit command; optional for other commands that only read artifacts.
*/
readonly contract?: ContractConfig;
/**
* Migration configuration. Controls where on-disk migration packages are stored.
*/
readonly migrations?: {
/** Directory for migration packages, relative to config file. Defaults to 'migrations'. */readonly dir?: string;
};
readonly formatter?: FormatterConfig;
}
/**
* Helper function to define a Prisma Next config.
* Validates and normalizes the config using Arktype, then returns the normalized IR.
*
* Normalization:
* - contract.output defaults to a path colocated with DEFAULT_CONTRACT_SOURCE_DIR
* when missing (in-memory-only providers)
*
* @param config - Raw config input from user
* @returns Normalized config IR with defaults applied
* @throws Error if config structure is invalid
*/
declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
//#endregion
export { defineConfig as a, ContractSourceDiagnostic as c, ContractSourceDiagnostics as d, ContractSourceFormat as f, PrismaNextConfig as i, ContractSourceDiagnosticPosition as l, DEFAULT_CONTRACT_SOURCE_DIR as n, normalizeContractConfig as o, ContractSourceProvider as p, FormatterConfig as r, ContractSourceContext as s, ContractConfig as t, ContractSourceDiagnosticSpan as u };
//# sourceMappingURL=config-types-DYfiKSrh.d.mts.map
{"version":3,"file":"config-types-DYfiKSrh.d.mts","names":[],"sources":["../src/contract-source-types.ts","../src/config-types.ts"],"mappings":";;;;;;;UASiB,gCAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,4BAAA;EAAA,SACN,KAAA,EAAO,gCAAA;EAAA,SACP,GAAA,EAAK,gCAAgC;AAAA;AAAA,UAG/B,wBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,GAAO,4BAAA;EAP8B;;;;;EAAA,SAarC,IAAA,GAAO,QAAA,CAAS,MAAA;AAAA;AAAA,UAGV,yBAAA;EAAA,SACN,OAAA;EAAA,SACA,WAAA,WAAsB,wBAAA;EAAA,SACtB,IAAA,GAAO,MAAM;AAAA;AAAA,UAGP,qBAAA;EAAA,SACN,sBAAA;EAVe;EAAA,SAYf,0BAAA,EAA4B,WAAA,SAAoB,QAAA;EAAA,SAChD,qBAAA,EAAuB,WAAA;EAAA,SACvB,sBAAA,EAAwB,+BAAA;EAAA,SACxB,WAAA,EAAa,WAAA;EAAA,SACb,uBAAA,EAAyB,uBAAA;EAAA,SACzB,cAAA;EAAA,SACA,YAAA,EAAc,gBAAA;AAAA;;KAIb,oBAAA;AAAA,UAEK,sBAAA;EArByB;EAAA,SAuB/B,YAAA,GAAe,oBAAA;EAAA,SACf,MAAA;EAAA,SACA,IAAA,GACP,OAAA,EAAS,qBAAA,KACN,OAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,yBAAA;AAAA;;;AAnDhC;;;AAAA,UCWiB,cAAA;EDVN;;;;EAAA,SCeA,MAAA,EAAQ,sBAAsB;EDVxB;;;;;;EAAA,SCiBN,MAAA;AAAA;AAAA,UAGM,eAAA;EAAA,SACN,MAAA;EAAA,SACA,OAAO;AAAA;;;;;;cAQL,2BAAA;AAAA,iBAEG,uBAAA,CACd,QAAA,EAAU,cAAA,GACT,cAAc;EAAA,SAAc,MAAA;AAAA;;;;;;;ADnBE;AAGjC;UCmCiB,gBAAA;EAAA,SAKN,MAAA,EAAQ,uBAAA,CAAwB,SAAA;EAAA,SAChC,MAAA,EAAQ,uBAAA,CAAwB,SAAA,EAAW,SAAA;EAAA,SAC3C,OAAA,EAAS,wBAAA,CAAyB,SAAA,EAAW,SAAA;EAAA,SAC7C,cAAA,YAA0B,0BAAA,CAA2B,SAAA,EAAW,SAAA;EDzC1C;;;;AACT;AAGxB;EAJiC,SCgDtB,MAAA,GAAS,uBAAA,CAChB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA,EAAW,SAAA,GACjC,WAAA;;;;;WAMO,EAAA;IDhDa;;;;;IAAA,SCsDX,UAAA,GAAa,WAAA;EAAA;EDzDa;;;;EAAA,SC+D5B,QAAA,GAAW,cAAA;ED7Da;;;EAAA,SCiExB,UAAA;ID/DyB,oGCiEvB,GAAA;EAAA;EAAA,SAEF,SAAA,GAAY,eAAA;AAAA;;;;;;;;;;;;ADrDkC;iBC4GzC,YAAA,uEACd,MAAA,EAAQ,gBAAA,CAAiB,SAAA,EAAW,SAAA,IACnC,gBAAA,CAAiB,SAAA,EAAW,SAAA"}