@prisma-next/config 0.5.0-dev.8 → 0.5.0-dev.80
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-CK4a_UHR.d.mts → config-types-CrHPZdb2.d.mts} +2 -3
- package/dist/config-types-CrHPZdb2.d.mts.map +1 -0
- package/dist/config-types.d.mts +1 -1
- package/dist/config-types.mjs +10 -19
- package/dist/config-types.mjs.map +1 -1
- package/dist/config-validation.d.mts +1 -2
- package/dist/config-validation.d.mts.map +1 -1
- package/dist/config-validation.mjs +1 -2
- package/dist/config-validation.mjs.map +1 -1
- package/package.json +8 -7
- package/dist/config-types-CK4a_UHR.d.mts.map +0 -1
|
@@ -104,8 +104,7 @@ interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends
|
|
|
104
104
|
* Migration configuration. Controls where on-disk migration packages are stored.
|
|
105
105
|
*/
|
|
106
106
|
readonly migrations?: {
|
|
107
|
-
/** Directory for migration packages, relative to config file. Defaults to 'migrations'. */
|
|
108
|
-
readonly dir?: string;
|
|
107
|
+
/** Directory for migration packages, relative to config file. Defaults to 'migrations'. */readonly dir?: string;
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
110
|
/**
|
|
@@ -122,4 +121,4 @@ interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends
|
|
|
122
121
|
declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
|
|
123
122
|
//#endregion
|
|
124
123
|
export { normalizeContractConfig as a, ContractSourceDiagnosticPosition as c, ContractSourceProvider as d, defineConfig as i, ContractSourceDiagnosticSpan as l, DEFAULT_CONTRACT_OUTPUT as n, ContractSourceContext as o, PrismaNextConfig as r, ContractSourceDiagnostic as s, ContractConfig as t, ContractSourceDiagnostics as u };
|
|
125
|
-
//# sourceMappingURL=config-types-
|
|
124
|
+
//# sourceMappingURL=config-types-CrHP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AAA,EAAS,wBAAA,CAAyB,SAAA,EAAW,SAAA;EAAA,SAC7C,cAAA,YAA0B,0BAAA,CAA2B,SAAA,EAAW,SAAA;ED/BhE;;;;;AAGX;EAHW,SCsCA,MAAA,GAAS,uBAAA,CAChB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA,EAAW,SAAA,GACjC,WAAA;;;;;WAMO,EAAA;ID1CA;;;;AAGX;IAHW,SCgDE,UAAA,GAAa,WAAA;EAAA;ED3CQ;;;;EAAA,SCiDvB,QAAA,GAAW,cAAA;ED9CqC;;;EAAA,SCkDhD,UAAA;IDpDA,oGCsDE,GAAA;EAAA;AAAA;;;;;;;;;;;;iBA8CG,YAAA,sEAAA,CACd,MAAA,EAAQ,gBAAA,CAAiB,SAAA,EAAW,SAAA,IACnC,gBAAA,CAAiB,SAAA,EAAW,SAAA"}
|
package/dist/config-types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as normalizeContractConfig, c as ContractSourceDiagnosticPosition, d as ContractSourceProvider, i as defineConfig, l as ContractSourceDiagnosticSpan, n as DEFAULT_CONTRACT_OUTPUT, o as ContractSourceContext, r as PrismaNextConfig, s as ContractSourceDiagnostic, t as ContractConfig, u as ContractSourceDiagnostics } from "./config-types-
|
|
1
|
+
import { a as normalizeContractConfig, c as ContractSourceDiagnosticPosition, d as ContractSourceProvider, i as defineConfig, l as ContractSourceDiagnosticSpan, n as DEFAULT_CONTRACT_OUTPUT, o as ContractSourceContext, r as PrismaNextConfig, s as ContractSourceDiagnostic, t as ContractConfig, u as ContractSourceDiagnostics } from "./config-types-CrHPZdb2.mjs";
|
|
2
2
|
export { type ContractConfig, type ContractSourceContext, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceProvider, DEFAULT_CONTRACT_OUTPUT, type PrismaNextConfig, defineConfig, normalizeContractConfig };
|
package/dist/config-types.mjs
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
import { type } from "arktype";
|
|
2
|
-
|
|
3
2
|
//#region src/config-types.ts
|
|
4
3
|
const DEFAULT_CONTRACT_OUTPUT = "src/prisma/contract.json";
|
|
5
4
|
function normalizeContractConfig(contract) {
|
|
6
5
|
return {
|
|
7
6
|
source: contract.source,
|
|
8
|
-
output: contract.output ??
|
|
7
|
+
output: contract.output ?? "src/prisma/contract.json"
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
|
-
const ContractSourceInputSchema = type("string");
|
|
12
|
-
const ContractSourceProviderSchema = type({
|
|
13
|
-
"inputs?": ContractSourceInputSchema.array(),
|
|
14
|
-
load: "Function"
|
|
15
|
-
});
|
|
16
|
-
const ContractConfigSchema = type({
|
|
17
|
-
source: ContractSourceProviderSchema,
|
|
18
|
-
"output?": "string"
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Arktype schema for PrismaNextConfig validation.
|
|
22
|
-
* Note: This validates structure only. Descriptor objects (family, target, adapter) are validated separately.
|
|
23
|
-
*/
|
|
24
|
-
const MigrationsConfigSchema = type({ "dir?": "string" });
|
|
25
10
|
const PrismaNextConfigSchema = type({
|
|
26
11
|
family: "unknown",
|
|
27
12
|
target: "unknown",
|
|
@@ -29,8 +14,14 @@ const PrismaNextConfigSchema = type({
|
|
|
29
14
|
"extensionPacks?": "unknown[]",
|
|
30
15
|
"driver?": "unknown",
|
|
31
16
|
"db?": "unknown",
|
|
32
|
-
"contract?":
|
|
33
|
-
|
|
17
|
+
"contract?": type({
|
|
18
|
+
source: type({
|
|
19
|
+
"inputs?": type("string").array(),
|
|
20
|
+
load: "Function"
|
|
21
|
+
}),
|
|
22
|
+
"output?": "string"
|
|
23
|
+
}),
|
|
24
|
+
"migrations?": type({ "dir?": "string" })
|
|
34
25
|
});
|
|
35
26
|
/**
|
|
36
27
|
* Helper function to define a Prisma Next config.
|
|
@@ -55,7 +46,7 @@ function defineConfig(config) {
|
|
|
55
46
|
};
|
|
56
47
|
return config;
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
//#endregion
|
|
60
50
|
export { DEFAULT_CONTRACT_OUTPUT, defineConfig, normalizeContractConfig };
|
|
51
|
+
|
|
61
52
|
//# 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. Defaults to 'src/prisma/contract.json'.\n * The .d.ts types file will be colocated (e.g., contract.json -> contract.d.ts).\n */\n readonly output?: string;\n}\n\nexport const DEFAULT_CONTRACT_OUTPUT = 'src/prisma/contract.json';\n\nexport function normalizeContractConfig(\n contract: ContractConfig,\n): ContractConfig & { readonly output: string } {\n return {\n source: contract.source,\n output: contract.output ?? DEFAULT_CONTRACT_OUTPUT,\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 DEFAULT_CONTRACT_OUTPUT if missing\n *\n * @param config - Raw config input from user\n * @returns Normalized config IR with defaults applied\n * @throws Error if config structure is invalid\n */\nexport function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(\n config: PrismaNextConfig<TFamilyId, TTargetId>,\n): PrismaNextConfig<TFamilyId, TTargetId> {\n // Validate structure using Arktype\n const validated = PrismaNextConfigSchema(config);\n if (validated instanceof type.errors) {\n const messages = validated.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Config validation failed: ${messages}`);\n }\n\n // Normalize contract config if present\n if (config.contract) {\n // 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":"
|
|
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. Defaults to 'src/prisma/contract.json'.\n * The .d.ts types file will be colocated (e.g., contract.json -> contract.d.ts).\n */\n readonly output?: string;\n}\n\nexport const DEFAULT_CONTRACT_OUTPUT = 'src/prisma/contract.json';\n\nexport function normalizeContractConfig(\n contract: ContractConfig,\n): ContractConfig & { readonly output: string } {\n return {\n source: contract.source,\n output: contract.output ?? DEFAULT_CONTRACT_OUTPUT,\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 DEFAULT_CONTRACT_OUTPUT if missing\n *\n * @param config - Raw config input from user\n * @returns Normalized config IR with defaults applied\n * @throws Error if config structure is invalid\n */\nexport function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(\n config: PrismaNextConfig<TFamilyId, TTargetId>,\n): PrismaNextConfig<TFamilyId, TTargetId> {\n // Validate structure using Arktype\n const validated = PrismaNextConfigSchema(config);\n if (validated instanceof type.errors) {\n const messages = validated.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Config validation failed: ${messages}`);\n }\n\n // Normalize contract config if present\n if (config.contract) {\n // 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":";;AAiCA,MAAa,0BAA0B;AAEvC,SAAgB,wBACd,UAC8C;CAC9C,OAAO;EACL,QAAQ,SAAS;EACjB,QAAQ,SAAS,UAAA;EAClB;;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;;;;;;;;;;;;AAaF,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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { r as PrismaNextConfig } from "./config-types-
|
|
1
|
+
import { r as PrismaNextConfig } from "./config-types-CrHPZdb2.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/config-validation.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Validates that the config has the required structure.
|
|
7
6
|
* This is pure validation logic with no file I/O or CLI awareness.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validation.d.mts","names":[],"sources":["../src/config-validation.ts","../src/errors.ts"],"
|
|
1
|
+
{"version":3,"file":"config-validation.d.mts","names":[],"sources":["../src/config-validation.ts","../src/errors.ts"],"mappings":";;;;;AA0DA;;;;;iBAAgB,cAAA,CAAe,MAAA,oBAA0B,MAAA,IAAU,gBAAA;;;cC1DtD,qBAAA,SAA8B,KAAA;EAAA,SAChC,KAAA;EAAA,SACA,GAAA;cAEG,KAAA,UAAe,GAAA;AAAA"}
|
|
@@ -9,7 +9,6 @@ var ConfigValidationError = class extends Error {
|
|
|
9
9
|
this.why = why ?? `Config must have a "${field}" field`;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
|
|
13
12
|
//#endregion
|
|
14
13
|
//#region src/config-validation.ts
|
|
15
14
|
function throwValidation(field, why) {
|
|
@@ -101,7 +100,7 @@ function validateConfig(config) {
|
|
|
101
100
|
validateContractConfig(contract);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
|
-
|
|
105
103
|
//#endregion
|
|
106
104
|
export { ConfigValidationError, validateConfig };
|
|
105
|
+
|
|
107
106
|
//# sourceMappingURL=config-validation.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validation.mjs","names":[],"sources":["../src/errors.ts","../src/config-validation.ts"],"sourcesContent":["export class ConfigValidationError extends Error {\n readonly field: string;\n readonly why: string;\n\n constructor(field: string, why?: string) {\n super(why ?? `Config must have a \"${field}\" field`);\n this.name = 'ConfigValidationError';\n this.field = field;\n this.why = why ?? `Config must have a \"${field}\" field`;\n }\n}\n","import type { PrismaNextConfig } from './config-types';\nimport { ConfigValidationError } from './errors';\n\nfunction throwValidation(field: string, why?: string): never {\n throw new ConfigValidationError(field, why);\n}\n\nfunction validateContractConfig(contract: Record<string, unknown>): void {\n if (!Object.hasOwn(contract, 'source')) {\n throwValidation(\n 'contract.source',\n 'Config.contract.source is required when contract is provided',\n );\n }\n\n const source = contract['source'];\n if (!source || typeof source !== 'object') {\n throwValidation('contract.source', 'Config.contract.source must be a provider object');\n }\n\n const sourceConfig = source as Record<string, unknown>;\n const inputs = Object.hasOwn(sourceConfig, 'inputs') ? sourceConfig['inputs'] : undefined;\n\n if (inputs !== undefined) {\n if (!Array.isArray(inputs)) {\n throwValidation(\n 'contract.source.inputs',\n 'Config.contract.source.inputs must be an array of strings when provided',\n );\n }\n\n for (const input of inputs) {\n if (typeof input !== 'string') {\n throwValidation(\n 'contract.source.inputs[]',\n 'Config.contract.source.inputs must contain only strings',\n );\n }\n }\n }\n\n if (!Object.hasOwn(sourceConfig, 'load') || typeof sourceConfig['load'] !== 'function') {\n throwValidation('contract.source.load', 'Config.contract.source.load must be a function');\n }\n\n const output = Object.hasOwn(contract, 'output') ? contract['output'] : undefined;\n if (output !== undefined && typeof output !== 'string') {\n throwValidation('contract.output', 'Config.contract.output must be a string when provided');\n }\n}\n\n/**\n * Validates that the config has the required structure.\n * This is pure validation logic with no file I/O or CLI awareness.\n *\n * @param config - Config object to validate\n * @throws ConfigValidationError if config structure is invalid\n */\nexport function validateConfig(config: unknown): asserts config is PrismaNextConfig {\n if (!config || typeof config !== 'object') {\n throwValidation('object', 'Config must be an object');\n }\n\n const configObj = config as Record<string, unknown>;\n\n if (!configObj['family']) {\n throwValidation('family');\n }\n\n if (!configObj['target']) {\n throwValidation('target');\n }\n\n if (!configObj['adapter']) {\n throwValidation('adapter');\n }\n\n // Validate family descriptor\n const family = configObj['family'] as Record<string, unknown>;\n if (family['kind'] !== 'family') {\n throwValidation('family.kind', 'Config.family must have kind: \"family\"');\n }\n if (typeof family['id'] !== 'string') {\n throwValidation('family.id', 'Config.family must have id: string');\n }\n if (typeof family['familyId'] !== 'string') {\n throwValidation('family.familyId', 'Config.family must have familyId: string');\n }\n if (typeof family['version'] !== 'string') {\n throwValidation('family.version', 'Config.family must have version: string');\n }\n if (!family['emission'] || typeof family['emission'] !== 'object') {\n throwValidation('family.emission', 'Config.family must have emission: EmissionSpi');\n }\n if (typeof family['create'] !== 'function') {\n throwValidation('family.create', 'Config.family must have create: function');\n }\n\n const familyId = family['familyId'] as string;\n\n // Validate target descriptor\n const target = configObj['target'] as Record<string, unknown>;\n if (target['kind'] !== 'target') {\n throwValidation('target.kind', 'Config.target must have kind: \"target\"');\n }\n if (typeof target['id'] !== 'string') {\n throwValidation('target.id', 'Config.target must have id: string');\n }\n if (typeof target['familyId'] !== 'string') {\n throwValidation('target.familyId', 'Config.target must have familyId: string');\n }\n if (typeof target['version'] !== 'string') {\n throwValidation('target.version', 'Config.target must have version: string');\n }\n if (target['familyId'] !== familyId) {\n throwValidation(\n 'target.familyId',\n `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,\n );\n }\n if (typeof target['targetId'] !== 'string') {\n throwValidation('target.targetId', 'Config.target must have targetId: string');\n }\n if (typeof target['create'] !== 'function') {\n throwValidation('target.create', 'Config.target must have create: function');\n }\n const expectedTargetId = target['targetId'] as string;\n\n // Validate adapter descriptor\n const adapter = configObj['adapter'] as Record<string, unknown>;\n if (adapter['kind'] !== 'adapter') {\n throwValidation('adapter.kind', 'Config.adapter must have kind: \"adapter\"');\n }\n if (typeof adapter['id'] !== 'string') {\n throwValidation('adapter.id', 'Config.adapter must have id: string');\n }\n if (typeof adapter['familyId'] !== 'string') {\n throwValidation('adapter.familyId', 'Config.adapter must have familyId: string');\n }\n if (typeof adapter['version'] !== 'string') {\n throwValidation('adapter.version', 'Config.adapter must have version: string');\n }\n if (adapter['familyId'] !== familyId) {\n throwValidation(\n 'adapter.familyId',\n `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,\n );\n }\n if (typeof adapter['targetId'] !== 'string') {\n throwValidation('adapter.targetId', 'Config.adapter must have targetId: string');\n }\n if (adapter['targetId'] !== expectedTargetId) {\n throwValidation(\n 'adapter.targetId',\n `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,\n );\n }\n if (typeof adapter['create'] !== 'function') {\n throwValidation('adapter.create', 'Config.adapter must have create: function');\n }\n\n if (configObj['extensions'] !== undefined) {\n throwValidation('extensions', 'Config.extensions is not supported; use Config.extensionPacks');\n }\n\n // Validate extensionPacks array if present\n if (configObj['extensionPacks'] !== undefined) {\n if (!Array.isArray(configObj['extensionPacks'])) {\n throwValidation('extensionPacks', 'Config.extensionPacks must be an array');\n }\n for (const ext of configObj['extensionPacks']) {\n if (!ext || typeof ext !== 'object') {\n throwValidation(\n 'extensionPacks[]',\n 'Config.extensionPacks must contain ControlExtensionDescriptor objects',\n );\n }\n const extObj = ext as Record<string, unknown>;\n if (extObj['kind'] !== 'extension') {\n throwValidation(\n 'extensionPacks[].kind',\n 'Config.extensionPacks items must have kind: \"extension\"',\n );\n }\n if (typeof extObj['id'] !== 'string') {\n throwValidation('extensionPacks[].id', 'Config.extensionPacks items must have id: string');\n }\n if (typeof extObj['familyId'] !== 'string') {\n throwValidation(\n 'extensionPacks[].familyId',\n 'Config.extensionPacks items must have familyId: string',\n );\n }\n if (typeof extObj['version'] !== 'string') {\n throwValidation(\n 'extensionPacks[].version',\n 'Config.extensionPacks items must have version: string',\n );\n }\n if (extObj['familyId'] !== familyId) {\n throwValidation(\n 'extensionPacks[].familyId',\n `Config.extensionPacks[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,\n );\n }\n if (typeof extObj['targetId'] !== 'string') {\n throwValidation(\n 'extensionPacks[].targetId',\n 'Config.extensionPacks items must have targetId: string',\n );\n }\n if (extObj['targetId'] !== expectedTargetId) {\n throwValidation(\n 'extensionPacks[].targetId',\n `Config.extensionPacks[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,\n );\n }\n if (typeof extObj['create'] !== 'function') {\n throwValidation(\n 'extensionPacks[].create',\n 'Config.extensionPacks items must have create: function',\n );\n }\n }\n }\n\n // Validate driver descriptor if present\n if (configObj['driver'] !== undefined) {\n const driver = configObj['driver'] as Record<string, unknown>;\n if (driver['kind'] !== 'driver') {\n throwValidation('driver.kind', 'Config.driver must have kind: \"driver\"');\n }\n if (typeof driver['id'] !== 'string') {\n throwValidation('driver.id', 'Config.driver must have id: string');\n }\n if (typeof driver['version'] !== 'string') {\n throwValidation('driver.version', 'Config.driver must have version: string');\n }\n if (typeof driver['familyId'] !== 'string') {\n throwValidation('driver.familyId', 'Config.driver must have familyId: string');\n }\n if (driver['familyId'] !== familyId) {\n throwValidation(\n 'driver.familyId',\n `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,\n );\n }\n if (typeof driver['targetId'] !== 'string') {\n throwValidation('driver.targetId', 'Config.driver must have targetId: string');\n }\n if (driver['targetId'] !== expectedTargetId) {\n throwValidation(\n 'driver.targetId',\n `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,\n );\n }\n if (typeof driver['create'] !== 'function') {\n throwValidation('driver.create', 'Config.driver must have create: function');\n }\n }\n\n // Validate contract config if present (structure validation - defineConfig() handles normalization)\n if (configObj['contract'] !== undefined) {\n const contract = configObj['contract'] as Record<string, unknown>;\n if (!contract || typeof contract !== 'object') {\n throwValidation('contract', 'Config.contract must be an object');\n }\n validateContractConfig(contract);\n }\n}\n"],"mappings":";AAAA,IAAa,wBAAb,cAA2C,MAAM;CAC/C,AAAS;CACT,AAAS;CAET,YAAY,OAAe,KAAc;AACvC,QAAM,OAAO,uBAAuB,MAAM,SAAS;AACnD,OAAK,OAAO;AACZ,OAAK,QAAQ;AACb,OAAK,MAAM,OAAO,uBAAuB,MAAM;;;;;;ACLnD,SAAS,gBAAgB,OAAe,KAAqB;AAC3D,OAAM,IAAI,sBAAsB,OAAO,IAAI;;AAG7C,SAAS,uBAAuB,UAAyC;AACvE,KAAI,CAAC,OAAO,OAAO,UAAU,SAAS,CACpC,iBACE,mBACA,+DACD;CAGH,MAAM,SAAS,SAAS;AACxB,KAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,iBAAgB,mBAAmB,mDAAmD;CAGxF,MAAM,eAAe;CACrB,MAAM,SAAS,OAAO,OAAO,cAAc,SAAS,GAAG,aAAa,YAAY;AAEhF,KAAI,WAAW,QAAW;AACxB,MAAI,CAAC,MAAM,QAAQ,OAAO,CACxB,iBACE,0BACA,0EACD;AAGH,OAAK,MAAM,SAAS,OAClB,KAAI,OAAO,UAAU,SACnB,iBACE,4BACA,0DACD;;AAKP,KAAI,CAAC,OAAO,OAAO,cAAc,OAAO,IAAI,OAAO,aAAa,YAAY,WAC1E,iBAAgB,wBAAwB,iDAAiD;CAG3F,MAAM,SAAS,OAAO,OAAO,UAAU,SAAS,GAAG,SAAS,YAAY;AACxE,KAAI,WAAW,UAAa,OAAO,WAAW,SAC5C,iBAAgB,mBAAmB,wDAAwD;;;;;;;;;AAW/F,SAAgB,eAAe,QAAqD;AAClF,KAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,iBAAgB,UAAU,2BAA2B;C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,2BACA,yDACD;;;AAMP,KAAI,UAAU,cAAc,QAAW;EACrC,MAAM,SAAS,UAAU;AACzB,MAAI,OAAO,YAAY,SACrB,iBAAgB,eAAe,2CAAyC;AAE1E,MAAI,OAAO,OAAO,UAAU,SAC1B,iBAAgB,aAAa,qCAAqC;AAEpE,MAAI,OAAO,OAAO,eAAe,SAC/B,iBAAgB,kBAAkB,0CAA0C;AAE9E,MAAI,OAAO,OAAO,gBAAgB,SAChC,iBAAgB,mBAAmB,2CAA2C;AAEhF,MAAI,OAAO,gBAAgB,SACzB,iBACE,mBACA,uEAAuE,SAAS,SAAS,OAAO,YAAY,GAC7G;AAEH,MAAI,OAAO,OAAO,gBAAgB,SAChC,iBAAgB,mBAAmB,2CAA2C;AAEhF,MAAI,OAAO,gBAAgB,iBACzB,iBACE,mBACA,uEAAuE,iBAAiB,SAAS,OAAO,YAAY,GACrH;AAEH,MAAI,OAAO,OAAO,cAAc,WAC9B,iBAAgB,iBAAiB,2CAA2C;;AAKhF,KAAI,UAAU,gBAAgB,QAAW;EACvC,MAAM,WAAW,UAAU;AAC3B,MAAI,CAAC,YAAY,OAAO,aAAa,SACnC,iBAAgB,YAAY,oCAAoC;AAElE,yBAAuB,SAAS"}
|
|
1
|
+
{"version":3,"file":"config-validation.mjs","names":[],"sources":["../src/errors.ts","../src/config-validation.ts"],"sourcesContent":["export class ConfigValidationError extends Error {\n readonly field: string;\n readonly why: string;\n\n constructor(field: string, why?: string) {\n super(why ?? `Config must have a \"${field}\" field`);\n this.name = 'ConfigValidationError';\n this.field = field;\n this.why = why ?? `Config must have a \"${field}\" field`;\n }\n}\n","import type { PrismaNextConfig } from './config-types';\nimport { ConfigValidationError } from './errors';\n\nfunction throwValidation(field: string, why?: string): never {\n throw new ConfigValidationError(field, why);\n}\n\nfunction validateContractConfig(contract: Record<string, unknown>): void {\n if (!Object.hasOwn(contract, 'source')) {\n throwValidation(\n 'contract.source',\n 'Config.contract.source is required when contract is provided',\n );\n }\n\n const source = contract['source'];\n if (!source || typeof source !== 'object') {\n throwValidation('contract.source', 'Config.contract.source must be a provider object');\n }\n\n const sourceConfig = source as Record<string, unknown>;\n const inputs = Object.hasOwn(sourceConfig, 'inputs') ? sourceConfig['inputs'] : undefined;\n\n if (inputs !== undefined) {\n if (!Array.isArray(inputs)) {\n throwValidation(\n 'contract.source.inputs',\n 'Config.contract.source.inputs must be an array of strings when provided',\n );\n }\n\n for (const input of inputs) {\n if (typeof input !== 'string') {\n throwValidation(\n 'contract.source.inputs[]',\n 'Config.contract.source.inputs must contain only strings',\n );\n }\n }\n }\n\n if (!Object.hasOwn(sourceConfig, 'load') || typeof sourceConfig['load'] !== 'function') {\n throwValidation('contract.source.load', 'Config.contract.source.load must be a function');\n }\n\n const output = Object.hasOwn(contract, 'output') ? contract['output'] : undefined;\n if (output !== undefined && typeof output !== 'string') {\n throwValidation('contract.output', 'Config.contract.output must be a string when provided');\n }\n}\n\n/**\n * Validates that the config has the required structure.\n * This is pure validation logic with no file I/O or CLI awareness.\n *\n * @param config - Config object to validate\n * @throws ConfigValidationError if config structure is invalid\n */\nexport function validateConfig(config: unknown): asserts config is PrismaNextConfig {\n if (!config || typeof config !== 'object') {\n throwValidation('object', 'Config must be an object');\n }\n\n const configObj = config as Record<string, unknown>;\n\n if (!configObj['family']) {\n throwValidation('family');\n }\n\n if (!configObj['target']) {\n throwValidation('target');\n }\n\n if (!configObj['adapter']) {\n throwValidation('adapter');\n }\n\n // Validate family descriptor\n const family = configObj['family'] as Record<string, unknown>;\n if (family['kind'] !== 'family') {\n throwValidation('family.kind', 'Config.family must have kind: \"family\"');\n }\n if (typeof family['id'] !== 'string') {\n throwValidation('family.id', 'Config.family must have id: string');\n }\n if (typeof family['familyId'] !== 'string') {\n throwValidation('family.familyId', 'Config.family must have familyId: string');\n }\n if (typeof family['version'] !== 'string') {\n throwValidation('family.version', 'Config.family must have version: string');\n }\n if (!family['emission'] || typeof family['emission'] !== 'object') {\n throwValidation('family.emission', 'Config.family must have emission: EmissionSpi');\n }\n if (typeof family['create'] !== 'function') {\n throwValidation('family.create', 'Config.family must have create: function');\n }\n\n const familyId = family['familyId'] as string;\n\n // Validate target descriptor\n const target = configObj['target'] as Record<string, unknown>;\n if (target['kind'] !== 'target') {\n throwValidation('target.kind', 'Config.target must have kind: \"target\"');\n }\n if (typeof target['id'] !== 'string') {\n throwValidation('target.id', 'Config.target must have id: string');\n }\n if (typeof target['familyId'] !== 'string') {\n throwValidation('target.familyId', 'Config.target must have familyId: string');\n }\n if (typeof target['version'] !== 'string') {\n throwValidation('target.version', 'Config.target must have version: string');\n }\n if (target['familyId'] !== familyId) {\n throwValidation(\n 'target.familyId',\n `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,\n );\n }\n if (typeof target['targetId'] !== 'string') {\n throwValidation('target.targetId', 'Config.target must have targetId: string');\n }\n if (typeof target['create'] !== 'function') {\n throwValidation('target.create', 'Config.target must have create: function');\n }\n const expectedTargetId = target['targetId'] as string;\n\n // Validate adapter descriptor\n const adapter = configObj['adapter'] as Record<string, unknown>;\n if (adapter['kind'] !== 'adapter') {\n throwValidation('adapter.kind', 'Config.adapter must have kind: \"adapter\"');\n }\n if (typeof adapter['id'] !== 'string') {\n throwValidation('adapter.id', 'Config.adapter must have id: string');\n }\n if (typeof adapter['familyId'] !== 'string') {\n throwValidation('adapter.familyId', 'Config.adapter must have familyId: string');\n }\n if (typeof adapter['version'] !== 'string') {\n throwValidation('adapter.version', 'Config.adapter must have version: string');\n }\n if (adapter['familyId'] !== familyId) {\n throwValidation(\n 'adapter.familyId',\n `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,\n );\n }\n if (typeof adapter['targetId'] !== 'string') {\n throwValidation('adapter.targetId', 'Config.adapter must have targetId: string');\n }\n if (adapter['targetId'] !== expectedTargetId) {\n throwValidation(\n 'adapter.targetId',\n `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,\n );\n }\n if (typeof adapter['create'] !== 'function') {\n throwValidation('adapter.create', 'Config.adapter must have create: function');\n }\n\n if (configObj['extensions'] !== undefined) {\n throwValidation('extensions', 'Config.extensions is not supported; use Config.extensionPacks');\n }\n\n // Validate extensionPacks array if present\n if (configObj['extensionPacks'] !== undefined) {\n if (!Array.isArray(configObj['extensionPacks'])) {\n throwValidation('extensionPacks', 'Config.extensionPacks must be an array');\n }\n for (const ext of configObj['extensionPacks']) {\n if (!ext || typeof ext !== 'object') {\n throwValidation(\n 'extensionPacks[]',\n 'Config.extensionPacks must contain ControlExtensionDescriptor objects',\n );\n }\n const extObj = ext as Record<string, unknown>;\n if (extObj['kind'] !== 'extension') {\n throwValidation(\n 'extensionPacks[].kind',\n 'Config.extensionPacks items must have kind: \"extension\"',\n );\n }\n if (typeof extObj['id'] !== 'string') {\n throwValidation('extensionPacks[].id', 'Config.extensionPacks items must have id: string');\n }\n if (typeof extObj['familyId'] !== 'string') {\n throwValidation(\n 'extensionPacks[].familyId',\n 'Config.extensionPacks items must have familyId: string',\n );\n }\n if (typeof extObj['version'] !== 'string') {\n throwValidation(\n 'extensionPacks[].version',\n 'Config.extensionPacks items must have version: string',\n );\n }\n if (extObj['familyId'] !== familyId) {\n throwValidation(\n 'extensionPacks[].familyId',\n `Config.extensionPacks[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,\n );\n }\n if (typeof extObj['targetId'] !== 'string') {\n throwValidation(\n 'extensionPacks[].targetId',\n 'Config.extensionPacks items must have targetId: string',\n );\n }\n if (extObj['targetId'] !== expectedTargetId) {\n throwValidation(\n 'extensionPacks[].targetId',\n `Config.extensionPacks[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,\n );\n }\n if (typeof extObj['create'] !== 'function') {\n throwValidation(\n 'extensionPacks[].create',\n 'Config.extensionPacks items must have create: function',\n );\n }\n }\n }\n\n // Validate driver descriptor if present\n if (configObj['driver'] !== undefined) {\n const driver = configObj['driver'] as Record<string, unknown>;\n if (driver['kind'] !== 'driver') {\n throwValidation('driver.kind', 'Config.driver must have kind: \"driver\"');\n }\n if (typeof driver['id'] !== 'string') {\n throwValidation('driver.id', 'Config.driver must have id: string');\n }\n if (typeof driver['version'] !== 'string') {\n throwValidation('driver.version', 'Config.driver must have version: string');\n }\n if (typeof driver['familyId'] !== 'string') {\n throwValidation('driver.familyId', 'Config.driver must have familyId: string');\n }\n if (driver['familyId'] !== familyId) {\n throwValidation(\n 'driver.familyId',\n `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,\n );\n }\n if (typeof driver['targetId'] !== 'string') {\n throwValidation('driver.targetId', 'Config.driver must have targetId: string');\n }\n if (driver['targetId'] !== expectedTargetId) {\n throwValidation(\n 'driver.targetId',\n `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,\n );\n }\n if (typeof driver['create'] !== 'function') {\n throwValidation('driver.create', 'Config.driver must have create: function');\n }\n }\n\n // Validate contract config if present (structure validation - defineConfig() handles normalization)\n if (configObj['contract'] !== undefined) {\n const contract = configObj['contract'] as Record<string, unknown>;\n if (!contract || typeof contract !== 'object') {\n throwValidation('contract', 'Config.contract must be an object');\n }\n validateContractConfig(contract);\n }\n}\n"],"mappings":";AAAA,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CACA;CAEA,YAAY,OAAe,KAAc;EACvC,MAAM,OAAO,uBAAuB,MAAM,SAAS;EACnD,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,MAAM,OAAO,uBAAuB,MAAM;;;;;ACLnD,SAAS,gBAAgB,OAAe,KAAqB;CAC3D,MAAM,IAAI,sBAAsB,OAAO,IAAI;;AAG7C,SAAS,uBAAuB,UAAyC;CACvE,IAAI,CAAC,OAAO,OAAO,UAAU,SAAS,EACpC,gBACE,mBACA,+DACD;CAGH,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,UAAU,OAAO,WAAW,UAC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BAAgB,iBAAiB,2CAA2C;;CAKhF,IAAI,UAAU,gBAAgB,KAAA,GAAW;EACvC,MAAM,WAAW,UAAU;EAC3B,IAAI,CAAC,YAAY,OAAO,aAAa,UACnC,gBAAgB,YAAY,oCAAoC;EAElE,uBAAuB,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/config",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.80",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"description": "Prisma Next config authoring types and validation",
|
|
7
8
|
"dependencies": {
|
|
8
|
-
"arktype": "^2.1.
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/contract": "0.5.0-dev.
|
|
11
|
-
"@prisma-next/
|
|
9
|
+
"arktype": "^2.1.29",
|
|
10
|
+
"@prisma-next/framework-components": "0.5.0-dev.80",
|
|
11
|
+
"@prisma-next/contract": "0.5.0-dev.80",
|
|
12
|
+
"@prisma-next/utils": "0.5.0-dev.80"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
|
-
"tsdown": "0.
|
|
15
|
+
"tsdown": "0.22.0",
|
|
15
16
|
"typescript": "5.9.3",
|
|
16
|
-
"vitest": "4.
|
|
17
|
+
"vitest": "4.1.5",
|
|
17
18
|
"@prisma-next/tsdown": "0.0.0",
|
|
18
19
|
"@prisma-next/tsconfig": "0.0.0"
|
|
19
20
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-types-CK4a_UHR.d.mts","names":[],"sources":["../src/contract-source-types.ts","../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;;;UAQiB,gCAAA;;EAAA,SAAA,IAAA,EAAA,MAAA;EAMA,SAAA,MAAA,EAAA,MAAA;AAKjB;AAIkB,UATD,4BAAA,CASC;EAMS,SAAA,KA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