/** * Public, typed configuration surface for `manifest.config.ts`. * * This module is the import target for end users authoring a TypeScript * Manifest config: * * ```ts * // manifest.config.ts * import { defineConfig } from "@angriff36/manifest/config"; * * export default defineConfig({ * stores: { Order: { implementation: PrismaOrderStore } }, * resolveUser: async (auth) => ({ id: auth.userId! }), * build: { src: "modules/**\/*.manifest", output: "ir/" }, * }); * ``` * * `defineConfig` is an identity function: it returns its argument unchanged at * runtime and exists purely so authors get autocomplete and compile-time * checking for the config shape. * * Scope note: these types describe the config surface that ACTUALLY ships today * (see docs/spec/config/manifest.config.md). Config G5 (`projections.enabled` / * `projections.defaults`), Config G2 (`validation.failOn` + `rules`), Config G3 * (`mergeIntegrity`), Config G4 (`provenance`), Config G7 (`runtime` including * concurrency.maxParallelCommands), Config G8 (`hooks.lifecycle`), * Config G9 (`plugins.order`/`capabilities`), and Config G10 (`driftGates`) * are modelled. Still proposed only: G2 `requireDescriptions` (no IR description * field). The JSON * schema at docs/spec/config/manifest.config.schema.json remains the executable * contract that `manifest config validate` enforces for the YAML/build config. */ import type { NamingConventionInput } from './projections/shared/naming.js'; import { type ManifestNamingInput, type ResolvedNamingConfig } from './naming-config.js'; import type { ManifestMergeIntegrityConfig } from './merge-integrity.js'; import type { ManifestProvenanceConfig } from './provenance-config.js'; import type { ManifestRuntimeBuildConfig } from './runtime-config.js'; export type { NamingConventionInput }; export type { ManifestMergeIntegrityConfig, MergeDuplicatePolicy, ResolvedMergeIntegrity, } from './merge-integrity.js'; export { resolveMergeIntegrity, dedupeLastByKey } from './merge-integrity.js'; export type { ManifestProvenanceConfig, ProvenanceFieldToken, ProvenanceLockfile, ResolvedProvenanceConfig, } from './provenance-config.js'; export { DETERMINISTIC_COMPILED_AT, buildProvenanceLockfile, checkProvenanceLockfileStale, resolveCompiledAt, resolveProvenanceConfig, } from './provenance-config.js'; export type { ManifestRuntimeBuildConfig, ManifestRuntimeConcurrencyConfig, ManifestRuntimeDeterminismConfig, ResolvedRuntimeConfig, RuntimeExecutionMode, } from './runtime-config.js'; export { MANIFEST_RUNTIME_BAG_KEY, applyRuntimeConfigToProjectionOptions, readManifestRuntimeMeta, resolveRuntimeConfig, } from './runtime-config.js'; export type { ValidationRuleDiagnostic, ValidationRuleId, ValidationRuleSeverity, ValidationRulesConfig, } from './validation-rules.js'; export { VALIDATION_RULE_IDS, resolveValidationRules, runValidationRules, } from './validation-rules.js'; export { resolveNamingConfig, extractNamingConvention, validateNamingConfig, type ManifestNamingInput, type ResolvedNamingConfig, type NamingRuleSeverity, type NamingCasing, type NamingNormalizationConfig, } from './naming-config.js'; export { detectStorageNameChanges, type PriorStorageSnapshot, type ProposedStorageNames, } from './naming-storage-guard.js'; export { nameKey, canonicalEntityName, canonicalFieldName, canonicalTableName, relationshipIdField, CanonicalNameRegistry, } from './canonical-names.js'; /** A single environment-variable declaration used by `manifest preflight`. */ export interface ManifestEnvVarDefinition { name: string; description?: string; required?: boolean; default?: string; example?: string; } /** Grouped environment-variable declarations. */ export interface ManifestEnvMapping { stores?: Record; auth?: Record; adapters?: Record; custom?: Record; } /** Config G8 — build lifecycle scripts around compile / generate. */ export interface ManifestLifecycleHooksConfig { /** Scripts (paths relative to cwd) run before `manifest compile`. */ beforeCompile?: string[]; /** Scripts run after a successful `manifest generate` / `generate --all`. */ afterGenerate?: string[]; } /** * Hook settings: git pre-commit (`manifest install-hooks`) plus optional * Config G8 build lifecycle scripts. */ export interface ManifestHooksConfig { /** Skip running the generated hook in CI environments. Default: true. */ skipInCi?: boolean; /** Git hook manager the pre-commit hook is installed into. Default: 'husky'. */ provider?: 'husky' | 'simple-git-hooks'; /** Run `manifest fmt` from the generated pre-commit hook. Default: true. */ runFmt?: boolean; /** Run `manifest validate` from the generated pre-commit hook. Default: true. */ runValidate?: boolean; /** Config G8 — build lifecycle hooks (not git hooks). */ lifecycle?: ManifestLifecycleHooksConfig; } /** Declares a Manifest plugin for the CLI to load. */ export interface ManifestPluginDeclaration { /** npm package name or relative file path to the plugin module. */ module: string; /** Plugin-specific options passed at load time. */ options?: Record; /** Whether the plugin is active. Default: true. */ enabled?: boolean; /** * Config G9 — load priority (lower first). Omitted entries sort after ordered ones. */ order?: number; /** * Config G9 — capability tags (`storeAdapter`, `auditSink`, `builtin`, * `cliCommand`, `projection`, or host-defined tags). */ capabilities?: string[]; } /** Config G2 — CI exit policy (does not alter language severities). */ export type ManifestValidationFailOn = 'block' | 'warn' | 'never'; export interface ManifestValidationConfig { /** * When compile/validate should exit non-zero after reporting diagnostics. * - `block` (default): errors only * - `warn`: errors or warnings * - `never`: always exit 0 (report-only) */ failOn?: ManifestValidationFailOn; /** * Config G2 — optional additive lint rules (`off` | `warn` | `error`). * Does not change language severities. `requireDescriptions` is not shipped * (entities/commands have no IR description field yet). */ rules?: import('./validation-rules.js').ValidationRulesConfig; } /** Config G10 — declarative CI drift gates (`manifest ci-gate`). */ export interface ManifestDriftGatesConfig { /** Committed effective-config snapshot path (`manifest config inspect --json`). */ effectiveConfigSnapshot?: string; /** Compare live effective config to the snapshot. Default true when path set. */ failOnConfigDrift?: boolean; /** Fail when `generate --all --check` reports artifact drift. Default false. */ failOnGeneratedDrift?: boolean; /** Require every IR file's `version` to equal this string. */ pinIrSchemaVersion?: string; } /** Per-projection config block (e.g. nextjs, routes, prisma). */ export interface ManifestProjectionConfig { /** Directory where this projection's artifacts are written. */ output?: string; /** Surface-specific options. See the projection's option reference. */ options?: Record; } /** * Meta keys under `projections` that are not projection targets (Config G5). * `manifest generate --all` must skip these when iterating configured names. */ export declare const PROJECTION_META_KEYS: readonly ["enabled", "defaults"]; export type ProjectionMetaKey = (typeof PROJECTION_META_KEYS)[number]; /** True for `projections.enabled` / `projections.defaults` (not a target name). */ export declare function isProjectionMetaKey(name: string): name is ProjectionMetaKey; /** * Projection map plus Config G5 controls: * - `enabled` — when set, `manifest generate --all` runs only these names (order preserved) * - `defaults` — shared options merged under each projection's own `options` * * Named projection blocks remain `{ output?, options? }`. */ export type ManifestProjectionsConfig = { /** Explicit opt-in list for `manifest generate --all`. Absent = all declared targets. */ enabled?: string[]; /** Shared options merged under each projection's `options` (per-projection wins). */ defaults?: Record; } & { [projectionName: string]: ManifestProjectionConfig | string[] | Record | undefined; }; /** * Names `manifest generate --all` should run for this projections map. * When `enabled` is set, returns that list (order preserved); otherwise every * non-meta key. Does not require each name to have an `output` block — the * generate driver still skips missing outputs with a warning. */ export declare function listConfiguredProjectionNames(projections: ManifestProjectionsConfig | Record | undefined | null): string[]; /** Read a named projection block, or undefined for meta keys / missing / wrong shape. */ export declare function getProjectionBlock(projections: ManifestProjectionsConfig | Record | undefined | null, name: string): ManifestProjectionConfig | undefined; /** * Foreign-key override for a `belongsTo`/`ref` relation in the Prisma * projection. Mirrors `PrismaProjectionOptions.foreignKeys` in the JSON schema. */ export interface ManifestPrismaForeignKeyConfig { fields: string[]; references?: string[]; onDelete?: string; onUpdate?: string; } /** * Multi-schema layout for the Prisma projection. Mirrors `multiSchema` in * `docs/spec/config/manifest.config.schema.json`. PostgreSQL / CockroachDB / * SQL Server only. Per-model resolution: `entitySchema[name]` → IR module → * `defaultSchema`. */ export interface ManifestPrismaMultiSchemaConfig { /** Master switch. Default false (flat layout). */ enabled?: boolean; /** Explicit datasource schema list; missing-but-used schemas are appended. */ schemas?: string[]; /** Per-entity schema override (entity name → schema). Wins over IR module. */ entitySchema?: Record; /** Schema for entities with neither an override nor a module. Default 'public'. */ defaultSchema?: string; } /** * Typed surface for `projections.prisma.options`. Mirrors * `definitions.PrismaProjectionOptions` in the JSON schema (the executable * contract `manifest config validate` enforces). Authors may annotate a * `manifest.config.ts` projection's `options` with this for autocomplete; * `ManifestProjectionConfig.options` stays `Record` so the * surface remains permissive and back-compatible. */ export interface ManifestPrismaProjectionOptions { provider?: 'postgresql' | 'mysql' | 'sqlite' | 'sqlserver' | 'mongodb' | 'cockroachdb'; /** Path hint for the emitted schema.prisma artifact. Default 'schema.prisma'. */ output?: string; /** Env var for the DB URL in the emitted prisma.config.ts companion. Default 'DATABASE_URL'. */ urlEnvVar?: string; /** Datasource `relationMode`. */ relationMode?: 'prisma' | 'foreignKeys'; /** `generator client { ... }` fields, emitted verbatim as `key = "value"`. */ generator?: Record; /** Preserve module layout as DB schemas via `@@schema(...)`. */ multiSchema?: ManifestPrismaMultiSchemaConfig; /** Auto-emit inverse relation fields for one-sided belongsTo/ref. Default false. */ autoBackRelations?: boolean; /** Automatic identifier-casing convention (adds @map/@@map only). */ naming?: NamingConventionInput; tableMappings?: Record; columnMappings?: Record>; precision?: Record>; indexes?: Record>; typeMappings?: Record>; foreignKeys?: Record>; dbAttributes?: Record>; fieldAttributes?: Record>; } /** * Typed surface for `projections.prisma-store.options`. Inherits every Prisma * projection option (provider, naming, multiSchema, …) and adds the * store-metadata/registry-owned keys. Mirrors `PrismaStoreProjectionOptions` * in the JSON schema. */ export interface ManifestPrismaStoreProjectionOptions extends ManifestPrismaProjectionOptions { accessorNames?: Record; metadataOutput?: string; registryOutput?: string; storeImportPath?: string; metadataImportPath?: string; softDelete?: Record; } /** * Build-level configuration — the YAML-equivalent surface, also expressible as * the `build` block of a TypeScript config. Validated by the JSON schema. */ export interface ManifestBuildConfig { /** Optional pointer to the config JSON schema for editor IntelliSense. Prefer a local path; Manifest publishes no resolvable schema URL. */ $schema?: string; /** Glob for source `.manifest` files. Default: '**\/*.manifest'. */ src?: string; /** Directory for compiled IR JSON. Default: 'ir/'. */ output?: string; /** Optional path to a Prisma schema for property-alignment scans. */ prismaSchema?: string; /** * Config G2 — CI exit policy for compile/validate. * Does not change language diagnostic severities. */ validation?: ManifestValidationConfig; /** * Config G3 — cross-file name collision policy for multi-module compile. * Default: `error` (unchanged from historical strict merge). */ mergeIntegrity?: ManifestMergeIntegrityConfig; /** * Config G4 — IR provenance stamps (deterministic compiledAt, lockfile, * failIfStale). IR always includes required provenance fields. */ provenance?: ManifestProvenanceConfig; /** * Config G7 — central runtime knobs for generate (executionMode → nextjs * dispatcher; determinism.deterministicMode → factory RuntimeOptions). */ runtime?: ManifestRuntimeBuildConfig; /** Config G10 — declarative drift gates for `manifest ci-gate`. */ driftGates?: ManifestDriftGatesConfig; /** * Per-projection config blocks, keyed by projection name, plus optional * Config G5 `enabled` / `defaults` meta keys. */ projections?: ManifestProjectionsConfig; /** Environment-variable declarations for `manifest preflight`. */ env?: ManifestEnvMapping; /** Git pre-commit hook settings for `manifest install-hooks`. */ hooks?: ManifestHooksConfig; /** Third-party plugin declarations loaded by the CLI. */ plugins?: ManifestPluginDeclaration[]; /** * Identifier naming policy. * * Legacy (still supported): `'snake_case'` or `{ table, column, pluralizeTables }` * — physical projection convention only; normalization stays off. * * Expanded: `{ normalization: true, entities: { casing: 'pascal', mismatch: 'fix' }, … }` * — see `docs/spec/config/manifest.config.md` § naming. */ naming?: ManifestNamingInput; } /** User context resolved from authentication. */ export interface ManifestUserContext { id: string; role?: string; tenantId?: string; [key: string]: unknown; } /** Authentication context passed to `resolveUser`. */ export interface ManifestAuthContext { userId?: string; claims?: Record; headers?: Record; [key: string]: unknown; } /** Store binding for an entity (runtime config). */ export interface ManifestStoreBinding { /** Store implementation: class, factory function, or instance. */ implementation: unknown; /** Optional Prisma model name for property-alignment checks. */ prismaModel?: string; /** Optional manifest-property → database-column mapping. */ propertyMapping?: Record; } /** * Runtime-level configuration — the shape of a `manifest.config.ts` default * export. Carries store bindings, user resolution, and an optional `build` * block that is merged over `manifest.config.yaml`. */ export interface ManifestRuntimeConfig { /** Per-entity store implementation bindings. */ stores?: Record; /** Resolve user context from authentication for generated routes. */ resolveUser?: (auth: ManifestAuthContext) => Promise; /** Build-level settings, merged over manifest.config.yaml and validated identically. */ build?: ManifestBuildConfig; } /** * Identity helper that types a `manifest.config.ts` default export. * * Returns its argument unchanged; exists only to provide editor autocomplete * and compile-time checking. Use it for the runtime config authored in * TypeScript: * * ```ts * export default defineConfig({ build: { src: "**\/*.manifest" } }); * ``` */ export declare function defineConfig(config: ManifestRuntimeConfig): ManifestRuntimeConfig; /** * Build a fail-soft user resolver from `ManifestRuntimeConfig.resolveUser`. * Missing/throwing resolvers yield `null` (caller decides fail-closed vs anonymous). */ export declare function createUserResolver(config: ManifestRuntimeConfig | null | undefined): (auth: ManifestAuthContext) => Promise; /** True when config provides a `resolveUser` function. */ export declare function hasUserResolver(config: ManifestRuntimeConfig | null | undefined): boolean; /** * Resolve the option bag a projection receives, layering the build-level global * physical `naming` convention UNDER the projection's own `options` when the * projection did not set `options.naming`. When app-wide `naming.normalization` * is enabled, the resolved policy is also injected as internal * `__manifestNaming`; Convex ignores local `options.naming` in that case so * one projection cannot silently invent a second spelling. * * This is the single inheritance contract for the global `naming` default: * dispatchers should build `request.options` from this helper so the projection * sees one merged bag and its `normalizeOptions` remains the only defaults * source for everything else. * * Returns a shallow copy; the input config is never mutated. All non-`naming` * keys pass through untouched. */ export declare function resolveProjectionOptions(build: ManifestBuildConfig | undefined, projectionName: string): Record; /** Public helper for Builder / `manifest config inspect`. */ export declare function resolveBuildNaming(build: ManifestBuildConfig | undefined): ResolvedNamingConfig; //# sourceMappingURL=config.d.ts.map