@prisma-next/config
Advanced tools
| 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 { 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[]; | ||
| } | ||
| /** 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-BxURjD5t.d.mts.map |
| {"version":3,"file":"config-types-BxURjD5t.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,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;AAAA;;KAIC,oBAAA;AAAA,UAEK,sBAAA;EApBA;EAAA,SAsBN,YAAA,GAAe,oBAAA;EAAA,SACf,MAAA;EAAA,SACA,IAAA,GACP,OAAA,EAAS,qBAAA,KACN,OAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,yBAAA;AAAA;;;;;;UCtCf,cAAA;EDVN;;;AACM;EADN,SCeA,MAAA,EAAQ,sBAAsB;EDXI;;;;;;EAAA,SCkBlC,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;;;;;;ADpBE;AAGjC;;UCoCiB,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;EDzChE;;;AAAa;AAGxB;;EAHW,SCgDA,MAAA,GAAS,uBAAA,CAChB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA,EAAW,SAAA,GACjC,WAAA;ED9CuD;;;;EAAA,SCoDhD,EAAA;IDhDyB;;;;;IAAA,SCsDvB,UAAA,GAAa,WAAA;EAAA;EDzDf;;;;EAAA,SC+DA,QAAA,GAAW,cAAA;ED7DE;;;EAAA,SCiEb,UAAA;ID/Dc,oGCiEZ,GAAA;EAAA;EAAA,SAEF,SAAA,GAAY,eAAA;AAAA;;;;;;;;ADvDkC;;;;ACtCzD;iBAoJgB,YAAA,uEACd,MAAA,EAAQ,gBAAA,CAAiB,SAAA,EAAW,SAAA,IACnC,gBAAA,CAAiB,SAAA,EAAW,SAAA"} |
@@ -1,2 +0,2 @@ | ||
| 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-6ihajZrZ.mjs"; | ||
| export { type ContractConfig, type ContractSourceContext, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceProvider, DEFAULT_CONTRACT_SOURCE_DIR, type PrismaNextConfig, defineConfig, normalizeContractConfig }; | ||
| 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-BxURjD5t.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 }; |
@@ -25,2 +25,3 @@ import { type } from "arktype"; | ||
| source: type({ | ||
| "sourceFormat?": "'psl' | 'typescript'", | ||
| "inputs?": type("string").array(), | ||
@@ -31,3 +32,7 @@ load: "Function" | ||
| }), | ||
| "migrations?": type({ "dir?": "string" }) | ||
| "migrations?": type({ "dir?": "string" }), | ||
| "formatter?": type({ | ||
| "indent?": type("number.integer >= 1").or("'tab'"), | ||
| "newline?": "'LF' | 'CRLF'" | ||
| }) | ||
| }); | ||
@@ -34,0 +39,0 @@ /** |
@@ -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\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;CAC7B;AACF;AA6EA,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,QAG1B,CAAA,CAA0B,MAAM;GAC3C,MAAM;EACR,CAGU;EACR,WAAW;CACb,CAiBe;CACb,eAZ6B,KAAK,EAClC,QAAQ,SACV,CAUsC;AACtC,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?': \"'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"} |
@@ -1,2 +0,2 @@ | ||
| import { r as PrismaNextConfig } from "./config-types-6ihajZrZ.mjs"; | ||
| import { i as PrismaNextConfig } from "./config-types-BxURjD5t.mjs"; | ||
@@ -3,0 +3,0 @@ //#region src/config-validation.d.ts |
+6
-6
| { | ||
| "name": "@prisma-next/config", | ||
| "version": "0.14.0-dev.3", | ||
| "version": "0.14.0-dev.4", | ||
| "license": "Apache-2.0", | ||
@@ -9,10 +9,10 @@ "type": "module", | ||
| "dependencies": { | ||
| "@prisma-next/contract": "0.14.0-dev.3", | ||
| "@prisma-next/framework-components": "0.14.0-dev.3", | ||
| "@prisma-next/utils": "0.14.0-dev.3", | ||
| "@prisma-next/contract": "0.14.0-dev.4", | ||
| "@prisma-next/framework-components": "0.14.0-dev.4", | ||
| "@prisma-next/utils": "0.14.0-dev.4", | ||
| "arktype": "^2.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@prisma-next/tsconfig": "0.14.0-dev.3", | ||
| "@prisma-next/tsdown": "0.14.0-dev.3", | ||
| "@prisma-next/tsconfig": "0.14.0-dev.4", | ||
| "@prisma-next/tsdown": "0.14.0-dev.4", | ||
| "tsdown": "0.22.1", | ||
@@ -19,0 +19,0 @@ "typescript": "5.9.3", |
+15
-0
@@ -36,2 +36,7 @@ import type { | ||
| export interface FormatterConfig { | ||
| readonly indent?: number | 'tab'; | ||
| readonly newline?: 'LF' | 'CRLF'; | ||
| } | ||
| /** | ||
@@ -110,2 +115,3 @@ * Default *source* directory for the contract file the user authors at `init` | ||
| }; | ||
| readonly formatter?: FormatterConfig; | ||
| } | ||
@@ -116,2 +122,3 @@ | ||
| export const ContractSourceProviderSchema = type({ | ||
| 'sourceFormat?': "'psl' | 'typescript'", | ||
| 'inputs?': ContractSourceInputSchema.array(), | ||
@@ -134,2 +141,9 @@ load: 'Function', | ||
| const FormatterIndentSchema = type('number.integer >= 1').or("'tab'"); | ||
| export const FormatterConfigSchema = type({ | ||
| 'indent?': FormatterIndentSchema, | ||
| 'newline?': "'LF' | 'CRLF'", | ||
| }); | ||
| const PrismaNextConfigSchema = type({ | ||
@@ -144,2 +158,3 @@ family: 'unknown', // ControlFamilyDescriptor - validated separately | ||
| 'migrations?': MigrationsConfigSchema, | ||
| 'formatter?': FormatterConfigSchema, | ||
| }); | ||
@@ -146,0 +161,0 @@ |
@@ -50,3 +50,8 @@ import type { Contract } from '@prisma-next/contract/types'; | ||
| /** Lets format-aware tooling avoid file-extension sniffing and opaque loader introspection. */ | ||
| export type ContractSourceFormat = 'psl' | 'typescript'; | ||
| export interface ContractSourceProvider { | ||
| /** Absent means format-aware tooling must leave the source untouched. */ | ||
| readonly sourceFormat?: ContractSourceFormat; | ||
| readonly inputs?: readonly string[]; | ||
@@ -53,0 +58,0 @@ readonly load: ( |
@@ -1,2 +0,2 @@ | ||
| export type { ContractConfig, PrismaNextConfig } from '../config-types'; | ||
| export type { ContractConfig, FormatterConfig, PrismaNextConfig } from '../config-types'; | ||
| export { | ||
@@ -13,3 +13,4 @@ DEFAULT_CONTRACT_SOURCE_DIR, | ||
| ContractSourceDiagnostics, | ||
| ContractSourceFormat, | ||
| ContractSourceProvider, | ||
| } 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 { 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[]; | ||
| } | ||
| interface ContractSourceProvider { | ||
| 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; | ||
| } | ||
| /** | ||
| * 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; | ||
| }; | ||
| } | ||
| /** | ||
| * 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 { 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 }; | ||
| //# sourceMappingURL=config-types-6ihajZrZ.d.mts.map |
| {"version":3,"file":"config-types-6ihajZrZ.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,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;AAAA;AAAA,UAGM,sBAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA,GACP,OAAA,EAAS,qBAAA,KACN,OAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,yBAAA;AAAA;;;;;;UCjCf,cAAA;EDVN;;;AACM;EADN,SCeA,MAAA,EAAQ,sBAAsB;EDXI;;;;;;EAAA,SCkBlC,MAAA;AAAA;ADhBqC;AAGhD;;;;AAHgD,cCwBnC,2BAAA;AAAA,iBAEG,uBAAA,CACd,QAAA,EAAU,cAAA,GACT,cAAc;EAAA,SAAc,MAAA;AAAA;;;;;;;;;UAmBd,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;EDpCnD;;;;;;EAAA,SC2Cb,MAAA,GAAS,uBAAA,CAChB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA,EAAW,SAAA,GACjC,WAAA;ED/CoB;AAGxB;;;EAHwB,SCqDb,EAAA;ID/C4B;;;;;IAAA,SCqD1B,UAAA,GAAa,WAAA;EAAA;EDvDf;;;;EAAA,SC6DA,QAAA,GAAW,cAAA;ED1DY;;;EAAA,SC8DvB,UAAA;ID5Da,oGC8DX,GAAA;EAAA;AAAA;;;;;;;;;;;ADrD4C;;iBCoGzC,YAAA,uEACd,MAAA,EAAQ,gBAAA,CAAiB,SAAA,EAAW,SAAA,IACnC,gBAAA,CAAiB,SAAA,EAAW,SAAA"} |
77962
2.78%669
3.4%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed