@showwhat/core 2.0.0 → 2.1.0
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/README.md +6 -2
- package/dist/index.d.ts +83 -34
- package/dist/index.js +379 -290
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/conditions/types.ts","../src/conditions/string.ts","../src/conditions/number.ts","../src/conditions/utils.ts","../src/conditions/datetime.ts","../src/conditions/bool.ts","../src/conditions/env.ts","../src/conditions/start-at.ts","../src/conditions/end-at.ts","../src/schemas/condition.ts","../src/logger.ts","../src/conditions/composite.ts","../src/conditions/index.ts","../src/resolver.ts","../src/parsers.ts","../src/schemas/context.ts","../src/schemas/variation.ts","../src/schemas/definition.ts","../src/schemas/preset.ts","../src/schemas/resolution.ts","../src/data.ts","../src/presets.ts"],"sourcesContent":["import type { ZodError } from \"zod\";\n\nexport class ShowwhatError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"ShowwhatError\";\n }\n}\n\nexport class ParseError extends ShowwhatError {\n constructor(\n message: string,\n public readonly line?: number,\n ) {\n super(message);\n this.name = \"ParseError\";\n }\n}\n\nfunction formatHeader(context?: string): string {\n return `Validation failed${context ? ` in ${context}` : \"\"}:`;\n}\n\nexport class ValidationError extends ShowwhatError {\n public readonly issues: ZodError[\"issues\"];\n\n constructor(message: string, context?: string) {\n super(`${formatHeader(context)}\\n ${message}`);\n this.name = \"ValidationError\";\n this.issues = [{ code: \"custom\" as const, message, path: [] }];\n }\n}\n\nexport class SchemaValidationError extends ValidationError {\n constructor(zodError: ZodError, context?: string) {\n const lines = zodError.issues.map((i) => `[${i.path.join(\".\")}] ${i.message}`);\n super(lines.join(\"\\n \"), context);\n this.name = \"SchemaValidationError\";\n // Overwrite the generic issue created by ValidationError with the real Zod issues\n (this as { issues: ZodError[\"issues\"] }).issues = zodError.issues;\n }\n}\n\nexport class DefinitionNotFoundError extends ShowwhatError {\n constructor(public readonly key: string) {\n super(`Definition \"${key}\" not found`);\n this.name = \"DefinitionNotFoundError\";\n }\n}\n\nexport class DefinitionInactiveError extends ShowwhatError {\n constructor(public readonly key: string) {\n super(`Definition \"${key}\" is inactive`);\n this.name = \"DefinitionInactiveError\";\n }\n}\n\nexport class VariationNotFoundError extends ShowwhatError {\n constructor(public readonly key: string) {\n super(`No matching variation for \"${key}\"`);\n this.name = \"VariationNotFoundError\";\n }\n}\n\nexport class InvalidContextError extends ShowwhatError {\n constructor(\n public readonly key: string,\n public readonly value: string | number | boolean,\n ) {\n super(`Invalid context value for \"${key}\": \"${value}\"`);\n this.name = \"InvalidContextError\";\n }\n}\n\nexport class DataError extends ShowwhatError {\n constructor(message: string, cause?: unknown) {\n super(message, cause !== undefined ? { cause } : undefined);\n this.name = \"DataError\";\n }\n}\n\nexport class ConditionError extends ShowwhatError {\n constructor(\n public readonly conditionType: string,\n message: string,\n cause?: unknown,\n ) {\n super(message, cause !== undefined ? { cause } : undefined);\n this.name = \"ConditionError\";\n }\n}\n","import type { Context } from \"../schemas/context.js\";\n\nexport type Annotations<T extends Record<string, unknown> = Record<string, unknown>> = T;\nexport type Dependencies<T extends Record<string, unknown> = Record<string, unknown>> = T;\n\nexport type RegexFactory = (pattern: string) => { test: (input: string) => boolean };\n\nexport const defaultCreateRegex: RegexFactory = (pattern) => new RegExp(pattern);\n\nexport type ConditionEvaluatorArgs = {\n condition: unknown;\n context: Readonly<Context>;\n annotations: Annotations;\n deps: Readonly<Dependencies>;\n depth: string;\n createRegex: RegexFactory;\n};\n\nexport type ConditionEvaluator = (args: ConditionEvaluatorArgs) => Promise<boolean>;\n\nexport type ConditionEvaluators<T extends string = string> = Record<T, ConditionEvaluator>;\n\nexport const noConditionEvaluator: ConditionEvaluator = async () => false;\n","import type { Context } from \"../schemas/context.js\";\nimport type { StringCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator, RegexFactory } from \"./types.js\";\nimport { defaultCreateRegex } from \"./types.js\";\nimport { ConditionError } from \"../errors.js\";\n\nexport async function evaluateString(\n condition: StringCondition,\n ctx: Readonly<Context>,\n createRegex: RegexFactory = defaultCreateRegex,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) return false;\n const raw = ctx[condition.key];\n if (typeof raw !== \"string\") return false;\n const actual = raw;\n\n switch (condition.op) {\n case \"eq\":\n return actual === condition.value;\n case \"neq\":\n return actual !== condition.value;\n case \"in\":\n return (condition.value as string[]).includes(actual);\n case \"nin\":\n return !(condition.value as string[]).includes(actual);\n case \"regex\": {\n const pattern = condition.value as string;\n let regex: { test: (input: string) => boolean };\n try {\n regex = createRegex(pattern);\n } catch (e) {\n throw new ConditionError(\n \"string\",\n `Invalid regex pattern \"${pattern}\": ${(e as Error).message}`,\n e,\n );\n }\n return regex.test(actual);\n }\n }\n}\n\nexport const stringEvaluator: ConditionEvaluator = ({ condition, context, createRegex }) =>\n evaluateString(condition as StringCondition, context, createRegex);\n","import type { Context } from \"../schemas/context.js\";\nimport type { NumberCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateNumber(\n condition: NumberCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) return false;\n const raw = ctx[condition.key];\n if (typeof raw !== \"number\" && typeof raw !== \"string\") return false;\n const actual = Number(raw);\n if (Number.isNaN(actual)) return false;\n\n switch (condition.op) {\n case \"eq\":\n return actual === (condition.value as number);\n case \"neq\":\n return actual !== (condition.value as number);\n case \"gt\":\n return actual > (condition.value as number);\n case \"gte\":\n return actual >= (condition.value as number);\n case \"lt\":\n return actual < (condition.value as number);\n case \"lte\":\n return actual <= (condition.value as number);\n case \"in\":\n return (condition.value as number[]).includes(actual);\n case \"nin\":\n return !(condition.value as number[]).includes(actual);\n }\n}\n\nexport const numberEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateNumber(condition as NumberCondition, context);\n","import { z } from \"zod\";\nimport { InvalidContextError } from \"../errors.js\";\n\nconst IsoUtcDatetime = z.iso.datetime();\n\nexport function parseDate(key: string, raw: string): Date {\n if (!IsoUtcDatetime.safeParse(raw).success) {\n throw new InvalidContextError(key, raw);\n }\n return new Date(raw);\n}\n","import type { Context } from \"../schemas/context.js\";\nimport type { DatetimeCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\nimport { parseDate } from \"./utils.js\";\n\nexport async function evaluateDatetime(\n condition: DatetimeCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) return false;\n const raw = ctx[condition.key];\n if (typeof raw !== \"string\") return false;\n const actual = parseDate(condition.key, raw);\n\n const expected = new Date(condition.value);\n\n switch (condition.op) {\n case \"eq\":\n return actual.getTime() === expected.getTime();\n case \"gt\":\n return actual > expected;\n case \"gte\":\n return actual >= expected;\n case \"lt\":\n return actual < expected;\n case \"lte\":\n return actual <= expected;\n }\n}\n\nexport const datetimeEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateDatetime(condition as DatetimeCondition, context);\n","import type { Context } from \"../schemas/context.js\";\nimport type { BoolCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateBool(\n condition: BoolCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) return false;\n const raw = ctx[condition.key];\n\n if (typeof raw === \"boolean\") {\n return raw === condition.value;\n }\n\n if (typeof raw === \"string\") {\n if (raw === \"true\") return condition.value === true;\n if (raw === \"false\") return condition.value === false;\n }\n\n return false;\n}\n\nexport const boolEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateBool(condition as BoolCondition, context);\n","import type { Context } from \"../schemas/context.js\";\nimport type { EnvCondition } from \"../schemas/condition.js\";\nimport { evaluateString } from \"./string.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateEnv(\n condition: EnvCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (Array.isArray(condition.value)) {\n return evaluateString({ type: \"string\", key: \"env\", op: \"in\", value: condition.value }, ctx);\n }\n return evaluateString({ type: \"string\", key: \"env\", op: \"eq\", value: condition.value }, ctx);\n}\n\nexport const envEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateEnv(condition as EnvCondition, context);\n","import type { ConditionEvaluator } from \"./types.js\";\nimport type { Context } from \"../schemas/context.js\";\nimport type { StartAtCondition } from \"../schemas/condition.js\";\nimport { evaluateDatetime } from \"./datetime.js\";\n\nexport async function evaluateStartAt(\n condition: StartAtCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n return evaluateDatetime(\n {\n type: \"datetime\",\n key: \"at\",\n op: \"gte\",\n value: condition.value,\n },\n ctx,\n );\n}\n\nexport const startAtEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateStartAt(condition as StartAtCondition, context);\n","import type { ConditionEvaluator } from \"./types.js\";\nimport type { Context } from \"../schemas/context.js\";\nimport type { EndAtCondition } from \"../schemas/condition.js\";\nimport { evaluateDatetime } from \"./datetime.js\";\n\nexport async function evaluateEndAt(\n condition: EndAtCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n return evaluateDatetime(\n {\n type: \"datetime\",\n key: \"at\",\n op: \"lt\",\n value: condition.value,\n },\n ctx,\n );\n}\n\nexport const endAtEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateEndAt(condition as EndAtCondition, context);\n","import { z } from \"zod\";\n\n// ── Constants ─────────────────────────────────────────────────────────────────\n\nexport const PRIMITIVE_CONDITION_TYPES = {\n string: \"string\",\n number: \"number\",\n bool: \"bool\",\n datetime: \"datetime\",\n} as const;\n\nexport type PrimitiveConditionType =\n (typeof PRIMITIVE_CONDITION_TYPES)[keyof typeof PRIMITIVE_CONDITION_TYPES];\n\nexport const CONDITION_TYPES = {\n ...PRIMITIVE_CONDITION_TYPES,\n env: \"env\",\n startAt: \"startAt\",\n endAt: \"endAt\",\n and: \"and\",\n or: \"or\",\n} as const;\n\nexport const CONTEXT_KEYS = {\n env: \"env\",\n at: \"at\",\n} as const;\n\n// ── Primitive condition schemas ──────────────────────────────────────────────\n\nexport const StringConditionSchema = z\n .object({\n id: z.string().optional(),\n type: z.literal(\"string\"),\n key: z.string().min(1),\n op: z.enum([\"eq\", \"neq\", \"in\", \"nin\", \"regex\"]),\n value: z.union([z.string(), z.array(z.string())]),\n })\n .superRefine((val, ctx) => {\n const isArrayOp = val.op === \"in\" || val.op === \"nin\";\n const isArray = Array.isArray(val.value);\n if (isArrayOp && !isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires an array value`,\n path: [\"value\"],\n });\n }\n if (!isArrayOp && isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires a string value`,\n path: [\"value\"],\n });\n }\n });\nexport type StringCondition = z.infer<typeof StringConditionSchema>;\n\nexport const NumberConditionSchema = z\n .object({\n id: z.string().optional(),\n type: z.literal(\"number\"),\n key: z.string().min(1),\n op: z.enum([\"eq\", \"neq\", \"gt\", \"gte\", \"lt\", \"lte\", \"in\", \"nin\"]),\n value: z.union([z.number(), z.array(z.number())]),\n })\n .superRefine((val, ctx) => {\n const isArrayOp = val.op === \"in\" || val.op === \"nin\";\n const isArray = Array.isArray(val.value);\n if (isArrayOp && !isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires an array value`,\n path: [\"value\"],\n });\n }\n if (!isArrayOp && isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires a number value`,\n path: [\"value\"],\n });\n }\n });\nexport type NumberCondition = z.infer<typeof NumberConditionSchema>;\n\nexport const DatetimeConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"datetime\"),\n key: z.string().min(1),\n op: z.enum([\"eq\", \"gt\", \"gte\", \"lt\", \"lte\"]),\n value: z.iso.datetime({ message: '\"datetime\" must be a valid ISO 8601 datetime' }),\n});\nexport type DatetimeCondition = z.infer<typeof DatetimeConditionSchema>;\n\nexport const BoolConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"bool\"),\n key: z.string().min(1),\n op: z.literal(\"eq\").optional(),\n value: z.boolean(),\n});\nexport type BoolCondition = z.infer<typeof BoolConditionSchema>;\n\n// ── Sugar condition schemas ──────────────────────────────────────────────────\n\nexport const EnvConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"env\"),\n op: z.literal(\"eq\").optional(),\n value: z.union([z.string(), z.array(z.string())]),\n});\nexport type EnvCondition = z.infer<typeof EnvConditionSchema>;\n\nexport const StartAtConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"startAt\"),\n value: z.iso.datetime({ message: '\"startAt\" must be a valid ISO 8601 datetime' }),\n});\nexport type StartAtCondition = z.infer<typeof StartAtConditionSchema>;\n\nexport const EndAtConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"endAt\"),\n value: z.iso.datetime({ message: '\"endAt\" must be a valid ISO 8601 datetime' }),\n});\nexport type EndAtCondition = z.infer<typeof EndAtConditionSchema>;\n\n// ── Built-in union ────────────────────────────────────────────────────────────\n\nexport const BuiltinConditionSchema = z.discriminatedUnion(\"type\", [\n StringConditionSchema,\n NumberConditionSchema,\n DatetimeConditionSchema,\n BoolConditionSchema,\n EnvConditionSchema,\n StartAtConditionSchema,\n EndAtConditionSchema,\n]);\nexport type BuiltinCondition = z.infer<typeof BuiltinConditionSchema>;\n\n// ── Condition (explicit recursive type) ──────────────────────────────────────\n\nexport type Condition =\n | BuiltinCondition\n | { id?: string; type: \"and\"; conditions: Condition[] }\n | { id?: string; type: \"or\"; conditions: Condition[] }\n | { type: string; [key: string]: unknown };\n\n// ── Composite schemas ─────────────────────────────────────────────────────────\n// z.lazy is safe here: all schemas are in this file, so ConditionSchema\n// is defined before any .parse() call occurs.\n\nconst AndConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"and\"),\n conditions: z.array(z.lazy(() => ConditionSchema)).min(1),\n});\nconst OrConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"or\"),\n conditions: z.array(z.lazy(() => ConditionSchema)).min(1),\n});\n\n// All built-in and composite types must not pass through the open-union custom-condition arm.\nconst BLOCKED_OPEN_UNION_TYPES = new Set<string>(Object.values(CONDITION_TYPES));\n\n// ── ConditionSchema ───────────────────────────────────────────────────────────\n// z.ZodType<Condition> annotation is required for the recursive schema.\n\n// Regex pattern validation is deferred to resolve time via the configured\n// createRegex factory (see ResolverOptions). This avoids divergence between\n// the parse-time engine (always native RegExp) and the runtime engine\n// (which may be RE2 or another safe-regex implementation).\nexport const ConditionSchema: z.ZodType<Condition> = z.union([\n BuiltinConditionSchema,\n AndConditionSchema,\n OrConditionSchema,\n z.looseObject({ type: z.string() }).refine((val) => !BLOCKED_OPEN_UNION_TYPES.has(val.type), {\n message: \"Reserved condition type\",\n }),\n]);\n\n// ── Composite types (inferred after schema is defined) ────────────────────────\n\nexport type AndCondition = z.infer<typeof AndConditionSchema>;\nexport type OrCondition = z.infer<typeof OrConditionSchema>;\nexport type CompositeCondition = AndCondition | OrCondition;\n\n// ── Type guards ───────────────────────────────────────────────────────────────\n\nexport function isAndCondition(c: Condition): c is AndCondition {\n return c.type === CONDITION_TYPES.and;\n}\nexport function isOrCondition(c: Condition): c is OrCondition {\n return c.type === CONDITION_TYPES.or;\n}\n","export interface Logger {\n debug(message: string, data?: Record<string, unknown>): void;\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n error(message: string, data?: Record<string, unknown>): void;\n}\n\nexport const noopLogger: Logger = {\n debug() {},\n info() {},\n warn() {},\n error() {},\n};\n","import type { Condition } from \"../schemas/condition.js\";\nimport { isAndCondition, isOrCondition } from \"../schemas/condition.js\";\nimport type { Context } from \"../schemas/context.js\";\nimport type {\n Annotations,\n ConditionEvaluator,\n ConditionEvaluators,\n Dependencies,\n RegexFactory,\n} from \"./types.js\";\nimport { defaultCreateRegex } from \"./types.js\";\nimport type { Logger } from \"../logger.js\";\nimport { noopLogger } from \"../logger.js\";\nimport { ShowwhatError } from \"../errors.js\";\n\nexport type EvaluateConditionArgs = {\n condition: Condition;\n context: Readonly<Context>;\n evaluators: ConditionEvaluators;\n annotations: Annotations;\n deps?: Readonly<Dependencies>;\n depth?: string;\n logger?: Logger;\n fallback?: ConditionEvaluator;\n createRegex?: RegexFactory;\n};\n\nexport async function evaluateCondition({\n condition,\n context,\n evaluators,\n annotations,\n deps = {},\n depth = \"\",\n logger = noopLogger,\n fallback,\n createRegex = defaultCreateRegex,\n}: EvaluateConditionArgs): Promise<boolean> {\n if (isAndCondition(condition)) {\n for (let i = 0; i < condition.conditions.length; i++) {\n const childDepth = depth === \"\" ? `${i}` : `${depth}.${i}`;\n const result = await evaluateCondition({\n condition: condition.conditions[i],\n context,\n evaluators,\n annotations,\n deps,\n depth: childDepth,\n logger,\n fallback,\n createRegex,\n });\n\n if (!result) {\n logger.debug(\"and condition short-circuited (child returned false)\", {\n childType: condition.conditions[i].type,\n depth: childDepth,\n });\n return false;\n }\n }\n return true;\n }\n\n if (isOrCondition(condition)) {\n for (let i = 0; i < condition.conditions.length; i++) {\n const childDepth = depth === \"\" ? `${i}` : `${depth}.${i}`;\n const result = await evaluateCondition({\n condition: condition.conditions[i],\n context,\n evaluators,\n annotations,\n deps,\n depth: childDepth,\n logger,\n fallback,\n createRegex,\n });\n\n if (result) {\n logger.debug(\"or condition short-circuited (child returned true)\", {\n childType: condition.conditions[i].type,\n depth: childDepth,\n });\n return true;\n }\n }\n return false;\n }\n\n const evaluator = evaluators[condition.type];\n\n if (!evaluator) {\n if (fallback) {\n const result = await fallback({ condition, context, annotations, deps, depth, createRegex });\n logger.debug(\"condition evaluated (fallback)\", {\n type: condition.type,\n depth,\n result,\n });\n return result;\n }\n\n throw new ShowwhatError(`Unknown condition type \"${condition.type}\".`);\n }\n\n const result = await evaluator({ condition, context, annotations, deps, depth, createRegex });\n logger.debug(\"condition evaluated\", {\n type: condition.type,\n depth,\n result,\n });\n return result;\n}\n","import { stringEvaluator } from \"./string.js\";\nimport { numberEvaluator } from \"./number.js\";\nimport { datetimeEvaluator } from \"./datetime.js\";\nimport { boolEvaluator } from \"./bool.js\";\nimport { envEvaluator } from \"./env.js\";\nimport { startAtEvaluator } from \"./start-at.js\";\nimport { endAtEvaluator } from \"./end-at.js\";\nimport type { BuiltinCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluators } from \"./types.js\";\nexport { noConditionEvaluator } from \"./types.js\";\nexport type {\n Annotations,\n ConditionEvaluator,\n ConditionEvaluatorArgs,\n ConditionEvaluators,\n Dependencies,\n RegexFactory,\n} from \"./types.js\";\nexport { defaultCreateRegex } from \"./types.js\";\nexport { evaluateCondition } from \"./composite.js\";\nexport type { EvaluateConditionArgs } from \"./composite.js\";\n\nexport const builtinEvaluators: ConditionEvaluators<BuiltinCondition[\"type\"]> = {\n string: stringEvaluator,\n number: numberEvaluator,\n datetime: datetimeEvaluator,\n bool: boolEvaluator,\n env: envEvaluator,\n startAt: startAtEvaluator,\n endAt: endAtEvaluator,\n};\n","import type {\n Definitions,\n Resolution,\n ResolutionError,\n Variation,\n Context,\n ContextValue,\n} from \"./schemas/index.js\";\nimport { evaluateCondition } from \"./conditions/index.js\";\nimport type {\n Annotations,\n ConditionEvaluator,\n ConditionEvaluators,\n Dependencies,\n RegexFactory,\n} from \"./conditions/index.js\";\nimport {\n DefinitionInactiveError,\n DefinitionNotFoundError,\n ShowwhatError,\n VariationNotFoundError,\n} from \"./errors.js\";\nimport type { Logger } from \"./logger.js\";\nimport { noopLogger } from \"./logger.js\";\n\nexport type ResolverOptions = {\n evaluators?: ConditionEvaluators;\n fallback?: ConditionEvaluator;\n logger?: Logger;\n createRegex?: RegexFactory;\n};\n\nfunction getEvaluators(options?: ResolverOptions): ConditionEvaluators {\n if (!options?.evaluators) {\n throw new ShowwhatError(\"No evaluators registered. Pass evaluators via options.\");\n }\n return options.evaluators;\n}\n\nfunction getLogger(options?: ResolverOptions): Logger {\n return options?.logger ?? noopLogger;\n}\n\nexport async function resolveVariation<\n T extends Record<string, ContextValue> = Record<string, ContextValue>,\n D extends Record<string, unknown> = Record<string, unknown>,\n>({\n variations,\n context,\n deps,\n options,\n}: {\n variations: Variation[];\n context: Readonly<Context<T>>;\n deps?: Dependencies<D>;\n options?: ResolverOptions;\n}): Promise<{ variation: Variation; variationIndex: number; annotations: Annotations } | null> {\n const evaluators = getEvaluators(options);\n const logger = getLogger(options);\n\n for (let i = 0; i < variations.length; i++) {\n const variation = variations[i];\n const conditionList = Array.isArray(variation.conditions) ? variation.conditions : [];\n\n if (conditionList.length === 0) {\n logger.debug(\"variation matched (no conditions)\", { variationIndex: i });\n return { variation, variationIndex: i, annotations: {} };\n }\n\n const annotations: Annotations = {};\n const rulesMatch = await evaluateCondition({\n condition: { type: \"and\", conditions: conditionList },\n context,\n evaluators,\n annotations,\n deps: deps ?? {},\n logger,\n fallback: options?.fallback,\n createRegex: options?.createRegex,\n });\n\n if (!rulesMatch) {\n logger.debug(\"variation did not match\", {\n variationIndex: i,\n conditionCount: conditionList.length,\n });\n continue;\n }\n\n logger.debug(\"variation matched\", {\n variationIndex: i,\n conditionCount: conditionList.length,\n });\n return { variation, variationIndex: i, annotations };\n }\n\n logger.debug(\"no variation matched\", { variationCount: variations.length });\n return null;\n}\n\nfunction toResolution(\n key: string,\n result: { variation: Variation; variationIndex: number; annotations: Annotations },\n): Resolution {\n const conditionCount = Array.isArray(result.variation.conditions)\n ? result.variation.conditions.length\n : 0;\n\n return {\n success: true,\n key,\n value: result.variation.value,\n meta: {\n variation: {\n index: result.variationIndex,\n id: result.variation.id,\n description: result.variation.description,\n conditionCount,\n },\n annotations: result.annotations,\n },\n };\n}\n\nasync function resolveKey<T extends Record<string, ContextValue> = Record<string, ContextValue>>(\n key: string,\n definitions: Definitions,\n context: Readonly<Context<T>>,\n deps?: Dependencies,\n options?: ResolverOptions,\n): Promise<Resolution> {\n const logger = getLogger(options);\n const definition = definitions[key];\n\n if (!definition) {\n logger.warn(\"definition not found\", { key });\n throw new DefinitionNotFoundError(key);\n }\n\n if (definition.active !== undefined && definition.active !== true) {\n logger.warn(\"definition inactive\", { key });\n throw new DefinitionInactiveError(key);\n }\n\n logger.debug(\"resolving definition\", {\n key,\n variationCount: definition.variations.length,\n });\n\n const result = await resolveVariation({\n variations: definition.variations,\n context,\n deps,\n options,\n });\n\n if (!result) {\n logger.warn(\"no matching variation\", { key });\n throw new VariationNotFoundError(key);\n }\n\n logger.debug(\"resolved\", {\n key,\n variationIndex: result.variationIndex,\n value: result.variation.value,\n });\n\n return toResolution(key, result);\n}\n\n/**\n * Resolve all definitions against the given context.\n *\n * Each key is resolved independently — a failure for one key does not\n * affect others. Failed keys are returned as `ResolutionError` entries.\n */\nexport async function resolve<\n T extends Record<string, ContextValue> = Record<string, ContextValue>,\n D extends Record<string, unknown> = Record<string, unknown>,\n>({\n definitions,\n context,\n deps,\n options,\n}: {\n definitions: Definitions;\n context: Readonly<Context<T>>;\n deps?: Dependencies<D>;\n options?: ResolverOptions;\n}): Promise<Record<string, Resolution | ResolutionError>> {\n const keys = Object.keys(definitions);\n const entries = await Promise.all(\n keys.map((key) =>\n resolveKey<T>(key, definitions, context, deps, options).catch(\n (reason): ResolutionError => ({\n success: false,\n key,\n error:\n reason instanceof ShowwhatError\n ? reason\n : new ShowwhatError(String(reason), { cause: reason }),\n }),\n ),\n ),\n );\n\n return Object.fromEntries(keys.map((key, i) => [key, entries[i]]));\n}\n","import yaml from \"js-yaml\";\nimport { FileFormatSchema } from \"./schemas/index.js\";\nimport { ParseError, SchemaValidationError } from \"./errors.js\";\nimport type { FileFormat } from \"./schemas/index.js\";\nimport { PresetsSchema } from \"./schemas/index.js\";\nimport type { Presets } from \"./schemas/index.js\";\n\nfunction loadYaml(input: string): unknown {\n try {\n return yaml.load(input);\n } catch (e: unknown) {\n const err = e as Error;\n const line = (e as yaml.YAMLException)?.mark?.line;\n throw new ParseError(`YAML: ${err.message}`, line);\n }\n}\n\nfunction assertPlainObject(raw: unknown, label: string): asserts raw is Record<string, unknown> {\n if (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) {\n throw new ParseError(label);\n }\n}\n\nexport async function parseYaml(input: string): Promise<FileFormat> {\n const raw = loadYaml(input);\n assertPlainObject(raw, \"YAML: Unknown structure at the root level\");\n return await parseObject(raw);\n}\n\nexport async function parseObject(raw: unknown): Promise<FileFormat> {\n const result = FileFormatSchema.safeParse(raw);\n if (!result.success) {\n throw new SchemaValidationError(result.error, \"flags\");\n }\n\n return result.data;\n}\n\nexport async function parsePresetsObject(raw: unknown): Promise<Presets> {\n assertPlainObject(raw, \"Expected object with presets key\");\n const result = PresetsSchema.safeParse(raw.presets ?? {});\n if (!result.success) {\n throw new SchemaValidationError(result.error, \"presets\");\n }\n return result.data;\n}\n\nexport async function parsePresetsYaml(input: string): Promise<Presets> {\n return parsePresetsObject(loadYaml(input));\n}\n","import { z } from \"zod\";\n\nconst ContextPrimitiveSchema = z.union([z.string(), z.number(), z.boolean()]);\n\nconst ContextValueSchema: z.ZodType<ContextValue> = z.union([\n ContextPrimitiveSchema,\n z.array(ContextPrimitiveSchema),\n z.lazy(() => z.record(z.string(), ContextValueSchema)),\n]);\n\nexport const ContextSchema = z.record(z.string(), ContextValueSchema);\n\ntype ContextPrimitive = string | number | boolean;\nexport type ContextValue = ContextPrimitive | ContextPrimitive[] | { [key: string]: ContextValue };\nexport type Context<T extends Record<string, ContextValue> = Record<string, ContextValue>> = T;\n","import { z } from \"zod\";\nimport { ConditionSchema } from \"./condition.js\";\n\nexport type VariationValue = unknown;\nexport const VariationValueSchema: z.ZodType<VariationValue> = z.unknown();\n\nexport const VariationSchema = z.object({\n id: z.string().optional(),\n value: VariationValueSchema,\n conditions: z.array(ConditionSchema).optional(),\n description: z.string().optional(),\n});\nexport type Variation = z.infer<typeof VariationSchema>;\n","import { z } from \"zod\";\nimport { VariationSchema } from \"./variation.js\";\nimport { PresetsSchema } from \"./preset.js\";\n\nexport const DefinitionSchema = z.object({\n id: z.string().optional(),\n active: z.boolean().optional(),\n description: z.string().optional(),\n variations: z.array(VariationSchema).min(1),\n});\nexport type Definition = z.infer<typeof DefinitionSchema>;\n\nexport const DefinitionsSchema = z.record(z.string().min(1), DefinitionSchema);\nexport type Definitions = z.infer<typeof DefinitionsSchema>;\n\nexport const FileFormatSchema = z\n .object({\n definitions: DefinitionsSchema,\n presets: PresetsSchema.optional(),\n })\n .strict();\n\nexport type FileFormat = z.infer<typeof FileFormatSchema>;\n","import { z } from \"zod\";\nimport { PRIMITIVE_CONDITION_TYPES } from \"./condition.js\";\n\nexport type PresetDefinition = {\n type: string;\n key?: string;\n overrides?: Record<string, unknown>;\n};\n\nexport type Presets = Record<string, PresetDefinition>;\n\nexport const PRIMITIVE_TYPES = new Set<string>(Object.values(PRIMITIVE_CONDITION_TYPES));\n\nconst PresetDefinitionSchema = z\n .object({\n type: z.string().min(1),\n key: z.string().min(1).optional(),\n overrides: z.record(z.string(), z.unknown()).optional(),\n })\n .superRefine((val, ctx) => {\n if (PRIMITIVE_TYPES.has(val.type) && !val.key) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"key\" is required when type is a built-in preset type (\"${val.type}\")`,\n path: [\"key\"],\n });\n }\n });\n\nexport const PresetsSchema = z.record(z.string(), PresetDefinitionSchema);\n","import { z } from \"zod\";\nimport { VariationValueSchema } from \"./variation.js\";\nimport type { ShowwhatError } from \"../errors.js\";\n\nexport const ResolutionSchema = z.object({\n key: z.string(),\n value: VariationValueSchema,\n meta: z.object({\n variation: z.object({\n index: z.number().int().nonnegative(),\n id: z.string().optional(),\n description: z.string().optional(),\n conditionCount: z.number().int().nonnegative(),\n }),\n annotations: z.record(z.string(), z.unknown()),\n }),\n});\n\ntype BaseResolution = z.infer<typeof ResolutionSchema>;\n\nexport type Resolution = Omit<BaseResolution, \"value\"> & {\n success: true;\n value: unknown;\n};\n\nexport type ResolutionError = {\n success: false;\n key: string;\n error: ShowwhatError;\n};\n","import { parseObject, parseYaml } from \"./parsers.js\";\nimport type { Definitions, Definition } from \"./schemas/index.js\";\nimport type { Presets } from \"./schemas/index.js\";\n\nexport interface DefinitionReader {\n get(key: string): Promise<Definition | null>;\n getAll(): Promise<Definitions>;\n listKeys(): Promise<string[]>;\n load?(): Promise<void>;\n close?(): Promise<void>;\n ping?(): Promise<void>;\n}\n\nexport interface DefinitionWriter {\n put(key: string, definition: Definition): Promise<void>;\n delete(key: string): Promise<void>;\n putMany(flags: Definitions, options?: { replace?: boolean }): Promise<void>;\n load?(): Promise<void>;\n close?(): Promise<void>;\n ping?(): Promise<void>;\n}\n\nexport interface DefinitionData extends DefinitionReader, DefinitionWriter {}\n\nexport interface PresetReader {\n getPresets(): Promise<Presets>;\n getPresets(key: string): Promise<Presets>;\n}\n\nfunction hasMethod(obj: object, key: string): boolean {\n return key in obj && typeof (obj as Record<string, unknown>)[key] === \"function\";\n}\n\nexport function isWritable(reader: DefinitionReader): reader is DefinitionData {\n return hasMethod(reader, \"put\") && hasMethod(reader, \"delete\") && hasMethod(reader, \"putMany\");\n}\n\nexport class MemoryData implements DefinitionReader, PresetReader {\n #flags: Definitions;\n #presets: Presets;\n\n private constructor(flags: Definitions, presets: Presets) {\n this.#flags = flags;\n this.#presets = presets;\n }\n\n static async fromObject(raw: unknown): Promise<MemoryData> {\n const fileFormat = await parseObject(raw);\n return new MemoryData(fileFormat.definitions, fileFormat.presets ?? {});\n }\n\n static async fromYaml(yaml: string): Promise<MemoryData> {\n const fileFormat = await parseYaml(yaml);\n return new MemoryData(fileFormat.definitions, fileFormat.presets ?? {});\n }\n\n async get(key: string): Promise<Definition | null> {\n const def = this.#flags[key];\n if (def === undefined) {\n return null;\n }\n return structuredClone(def);\n }\n\n async getAll(): Promise<Definitions> {\n return structuredClone(this.#flags);\n }\n\n async listKeys(): Promise<string[]> {\n return Object.keys(this.#flags);\n }\n\n async getPresets(): Promise<Presets> {\n return structuredClone(this.#presets);\n }\n}\n","import { stringEvaluator } from \"./conditions/string.js\";\nimport { numberEvaluator } from \"./conditions/number.js\";\nimport { boolEvaluator } from \"./conditions/bool.js\";\nimport { datetimeEvaluator } from \"./conditions/datetime.js\";\nimport type { ConditionEvaluator, ConditionEvaluators } from \"./conditions/types.js\";\nimport { CONDITION_TYPES, type PrimitiveConditionType } from \"./schemas/condition.js\";\nimport { PRIMITIVE_TYPES } from \"./schemas/preset.js\";\nimport type { Presets } from \"./schemas/preset.js\";\n\n// ── Reserved names ───────────────────────────────────────────────────────────\n\nconst RESERVED_CONDITION_TYPES = new Set([...Object.values(CONDITION_TYPES), \"__custom\"]);\n\nconst BUILTIN_EVALUATORS: Record<PrimitiveConditionType, ConditionEvaluator> = {\n string: stringEvaluator,\n number: numberEvaluator,\n bool: boolEvaluator,\n datetime: datetimeEvaluator,\n};\n\n// ── Factory ──────────────────────────────────────────────────────────────────\n\nexport function createPresetConditions(presets: Presets): ConditionEvaluators {\n const result: ConditionEvaluators = {};\n\n for (const [name, preset] of Object.entries(presets)) {\n if (RESERVED_CONDITION_TYPES.has(name)) {\n throw new Error(`Preset name \"${name}\" collides with a built-in or reserved condition type`);\n }\n\n if (!PRIMITIVE_TYPES.has(preset.type)) {\n continue;\n }\n\n const primitiveType = preset.type as PrimitiveConditionType;\n const delegateEvaluator = BUILTIN_EVALUATORS[primitiveType];\n const presetKey = preset.key!;\n\n const overrides = preset.overrides ?? {};\n\n const evaluator: ConditionEvaluator = ({\n condition,\n context,\n annotations,\n deps,\n depth,\n createRegex,\n }) => {\n const rec = condition as Record<string, unknown>;\n return delegateEvaluator({\n condition: { ...rec, ...overrides, type: primitiveType, key: presetKey },\n context,\n annotations,\n deps,\n depth,\n createRegex,\n });\n };\n\n result[name] = evaluator;\n }\n\n return result;\n}\n"],"mappings":";AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB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A,EACpC;AAAA,EAEA,MAAM,WAA8B;AAClC,WAAO,OAAO,KAAK,KAAK,MAAM;AAAA,EAChC;AAAA,EAEA,MAAM,aAA+B;AACnC,WAAO,gBAAgB,KAAK,QAAQ;AAAA,EACtC;AACF;;;AChEA,IAAM,2BAA2B,oBAAI,IAAI,CAAC,GAAG,OAAO,OAAO,eAAe,GAAG,UAAU,CAAC;AAExF,IAAM,qBAAyE;AAAA,EAC7E,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AACZ;AAIO,SAAS,uBAAuB,SAAuC;AAC5E,QAAM,SAA8B,CAAC;AAErC,aAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,OAAO,GAAG;AACpD,QAAI,yBAAyB,IAAI,IAAI,GAAG;AACtC,YAAM,IAAI,MAAM,gBAAgB,IAAI,uDAAuD;AAAA,IAC7F;AAEA,QAAI,CAAC,gBAAgB,IAAI,OAAO,IAAI,GAAG;AACrC;AAAA,IACF;AAEA,UAAM,gBAAgB,OAAO;AAC7B,UAAM,oBAAoB,mBAAmB,aAAa;AAC1D,UAAM,YAAY,OAAO;AAEzB,UAAM,YAAY,OAAO,aAAa,CAAC;AAEvC,UAAM,YAAgC,CAAC;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAAM;AACJ,YAAM,MAAM;AACZ,aAAO,kBAAkB;AAAA,QACvB,WAAW,EAAE,GAAG,KAAK,GAAG,WAAW,MAAM,eAAe,KAAK,UAAU;AAAA,QACvE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,IAAI,IAAI;AAAA,EACjB;AAEA,SAAO;AACT;","names":["z","result","z","z","z","z","z","z","z","z","z","yaml"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/conditions/types.ts","../src/schemas/value.ts","../src/conditions/string.ts","../src/conditions/number.ts","../src/conditions/utils.ts","../src/conditions/datetime.ts","../src/conditions/bool.ts","../src/conditions/env.ts","../src/conditions/start-at.ts","../src/conditions/end-at.ts","../src/logger.ts","../src/conditions/evaluate.ts","../src/conditions/and.ts","../src/conditions/or.ts","../src/conditions/check-annotations.ts","../src/conditions/index.ts","../src/resolver.ts","../src/parsers.ts","../src/schemas/condition.ts","../src/schemas/context.ts","../src/schemas/variation.ts","../src/schemas/definition.ts","../src/schemas/preset.ts","../src/schemas/resolution.ts","../src/data.ts","../src/presets.ts"],"sourcesContent":["import type { ZodError } from \"zod\";\n\nexport class ShowwhatError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"ShowwhatError\";\n }\n}\n\nexport class ParseError extends ShowwhatError {\n constructor(\n message: string,\n public readonly line?: number,\n ) {\n super(message);\n this.name = \"ParseError\";\n }\n}\n\nfunction formatHeader(context?: string): string {\n return `Validation failed${context ? ` in ${context}` : \"\"}:`;\n}\n\nexport class ValidationError extends ShowwhatError {\n public readonly issues: ZodError[\"issues\"];\n\n constructor(message: string, context?: string) {\n super(`${formatHeader(context)}\\n ${message}`);\n this.name = \"ValidationError\";\n this.issues = [{ code: \"custom\" as const, message, path: [] }];\n }\n}\n\nexport class SchemaValidationError extends ValidationError {\n constructor(zodError: ZodError, context?: string) {\n const lines = zodError.issues.map((i) => `[${i.path.join(\".\")}] ${i.message}`);\n super(lines.join(\"\\n \"), context);\n this.name = \"SchemaValidationError\";\n // Overwrite the generic issue created by ValidationError with the real Zod issues\n (this as { issues: ZodError[\"issues\"] }).issues = zodError.issues;\n }\n}\n\nexport class DefinitionNotFoundError extends ShowwhatError {\n constructor(public readonly key: string) {\n super(`Definition \"${key}\" not found`);\n this.name = \"DefinitionNotFoundError\";\n }\n}\n\nexport class DefinitionInactiveError extends ShowwhatError {\n constructor(public readonly key: string) {\n super(`Definition \"${key}\" is inactive`);\n this.name = \"DefinitionInactiveError\";\n }\n}\n\nexport class VariationNotFoundError extends ShowwhatError {\n constructor(public readonly key: string) {\n super(`No matching variation for \"${key}\"`);\n this.name = \"VariationNotFoundError\";\n }\n}\n\nexport class InvalidContextError extends ShowwhatError {\n constructor(\n public readonly key: string,\n public readonly value: string | number | boolean,\n ) {\n super(`Invalid context value for \"${key}\": \"${value}\"`);\n this.name = \"InvalidContextError\";\n }\n}\n\nexport class DataError extends ShowwhatError {\n constructor(message: string, cause?: unknown) {\n super(message, cause !== undefined ? { cause } : undefined);\n this.name = \"DataError\";\n }\n}\n\nexport class ConditionError extends ShowwhatError {\n constructor(\n public readonly conditionType: string,\n message: string,\n cause?: unknown,\n ) {\n super(message, cause !== undefined ? { cause } : undefined);\n this.name = \"ConditionError\";\n }\n}\n\nexport class UnknownConditionTypeError extends ShowwhatError {\n constructor(\n public readonly conditionType: string,\n public readonly condition: unknown,\n ) {\n super(`Unknown condition type \"${conditionType}\".`);\n this.name = \"UnknownConditionTypeError\";\n }\n}\n","import { z } from \"zod\";\nimport type { Context } from \"../schemas/context.js\";\nimport { DataValueSchema } from \"../schemas/value.js\";\nimport type { DataValue } from \"../schemas/value.js\";\nimport type { Logger } from \"../logger.js\";\n\nexport const AnnotationValueSchema = DataValueSchema;\n\n/**\n * Semantic alias for `DataValue`. Annotations share the same structural base today,\n * but may diverge in the future (e.g. restricted to flat records). Keeping the alias\n * lets call sites express intent and makes a future split a non-breaking change.\n */\nexport type AnnotationValue = DataValue;\n\nexport const AnnotationsSchema = z.record(z.string(), AnnotationValueSchema);\n\nexport type Annotations = Record<string, AnnotationValue>;\nexport type Dependencies = Record<string, unknown>;\n\nexport type RegexFactory = (pattern: string) => { test: (input: string) => boolean };\nexport type AnnotationsFactory = (definitionKey?: string) => Annotations;\n\nexport const defaultCreateRegex: RegexFactory = (pattern) => new RegExp(pattern);\n\nexport type ConditionEvaluatorArgs = {\n condition: unknown;\n context: Readonly<Context>;\n annotations: Annotations;\n deps: Readonly<Dependencies>;\n depth: string;\n\n // Functions\n createRegex: RegexFactory;\n evaluators: ConditionEvaluators;\n logger?: Logger;\n};\n\nexport type ConditionEvaluator = (args: ConditionEvaluatorArgs) => Promise<boolean>;\n\nexport const FALLBACK_EVALUATOR_KEY: unique symbol = Symbol(\"fallback\");\n\nexport type ConditionEvaluators = Record<string, ConditionEvaluator> & {\n [FALLBACK_EVALUATOR_KEY]?: ConditionEvaluator;\n};\n\nexport const noConditionEvaluator: ConditionEvaluator = async () => false;\n","import { z } from \"zod\";\n\nconst DataPrimitiveSchema = z.union([z.string(), z.number(), z.boolean()]);\n\n/**\n * Primitive values inferred from the schema — string | number | boolean.\n */\ntype DataPrimitive = z.infer<typeof DataPrimitiveSchema>;\n\n/**\n * The set of value types that showwhat's data model understands.\n *\n * Used as the structural base for both `ContextValue` and `AnnotationValue`.\n *\n * **Why this isn't `z.infer`:** TypeScript cannot infer recursive types from\n * self-referencing `const` declarations (TS7022). The schema below must be\n * annotated with this type; `DataPrimitive` is still inferred from its schema,\n * keeping the non-recursive portion derived from the single source of truth.\n */\nexport type DataValue = DataPrimitive | DataPrimitive[] | { [key: string]: DataValue };\n\nexport const DataValueSchema: z.ZodType<DataValue> = z.union([\n DataPrimitiveSchema,\n z.array(DataPrimitiveSchema),\n z.lazy(() => z.record(z.string(), DataValueSchema)),\n]);\n","import type { Context } from \"../schemas/context.js\";\nimport type { StringCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator, RegexFactory } from \"./types.js\";\nimport { defaultCreateRegex } from \"./types.js\";\nimport { ConditionError } from \"../errors.js\";\n\nexport async function evaluateString(\n condition: StringCondition,\n ctx: Readonly<Context>,\n createRegex: RegexFactory = defaultCreateRegex,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) return false;\n const raw = ctx[condition.key];\n if (typeof raw !== \"string\") return false;\n const actual = raw;\n\n switch (condition.op) {\n case \"eq\":\n return actual === condition.value;\n\n case \"neq\":\n return actual !== condition.value;\n\n case \"in\":\n return (condition.value as string[]).includes(actual);\n\n case \"nin\":\n const incl = (condition.value as string[]).includes(actual);\n return !incl;\n\n case \"regex\": {\n const pattern = condition.value as string;\n let regex: { test: (input: string) => boolean };\n\n try {\n regex = createRegex(pattern);\n } catch (e) {\n throw new ConditionError(\n \"string\",\n `Invalid regex pattern \"${pattern}\": ${(e as Error).message}`,\n e,\n );\n }\n\n return regex.test(actual);\n }\n }\n}\n\nexport const stringEvaluator: ConditionEvaluator = ({ condition, context, createRegex }) =>\n evaluateString(condition as StringCondition, context, createRegex);\n","import type { Context } from \"../schemas/context.js\";\nimport type { NumberCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateNumber(\n condition: NumberCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) return false;\n const raw = ctx[condition.key];\n if (typeof raw !== \"number\" && typeof raw !== \"string\") return false;\n const actual = Number(raw);\n if (Number.isNaN(actual)) return false;\n\n switch (condition.op) {\n case \"eq\":\n return actual === (condition.value as number);\n case \"neq\":\n return actual !== (condition.value as number);\n case \"gt\":\n return actual > (condition.value as number);\n case \"gte\":\n return actual >= (condition.value as number);\n case \"lt\":\n return actual < (condition.value as number);\n case \"lte\":\n return actual <= (condition.value as number);\n case \"in\":\n return (condition.value as number[]).includes(actual);\n case \"nin\":\n return !(condition.value as number[]).includes(actual);\n }\n}\n\nexport const numberEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateNumber(condition as NumberCondition, context);\n","import { z } from \"zod\";\nimport { InvalidContextError } from \"../errors.js\";\n\nconst IsoUtcDatetime = z.iso.datetime();\n\nexport function parseDate(key: string, raw: string): Date {\n if (!IsoUtcDatetime.safeParse(raw).success) {\n throw new InvalidContextError(key, raw);\n }\n\n return new Date(raw);\n}\n","import type { Context } from \"../schemas/context.js\";\nimport type { DatetimeCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\nimport { parseDate } from \"./utils.js\";\n\nexport async function evaluateDatetime(\n condition: DatetimeCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) {\n return false;\n }\n\n const raw = ctx[condition.key];\n\n if (typeof raw !== \"string\") {\n return false;\n }\n\n const actual = parseDate(condition.key, raw);\n const expected = new Date(condition.value);\n\n switch (condition.op) {\n case \"eq\":\n return actual.getTime() === expected.getTime();\n case \"gt\":\n return actual > expected;\n case \"gte\":\n return actual >= expected;\n case \"lt\":\n return actual < expected;\n case \"lte\":\n return actual <= expected;\n }\n}\n\nexport const datetimeEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateDatetime(condition as DatetimeCondition, context);\n","import type { Context } from \"../schemas/context.js\";\nimport type { BoolCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateBool(\n condition: BoolCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (!Object.hasOwn(ctx, condition.key)) {\n return false;\n }\n\n const raw = ctx[condition.key];\n\n if (typeof raw === \"boolean\") {\n return raw === condition.value;\n }\n\n if (typeof raw !== \"string\") {\n return false;\n }\n\n if (raw === \"true\") {\n return condition.value === true;\n }\n\n if (raw === \"false\") {\n return condition.value === false;\n }\n\n return false;\n}\n\nexport const boolEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateBool(condition as BoolCondition, context);\n","import type { Context } from \"../schemas/context.js\";\nimport type { EnvCondition } from \"../schemas/condition.js\";\nimport { evaluateString } from \"./string.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateEnv(\n condition: EnvCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n if (Array.isArray(condition.value)) {\n return evaluateString({ type: \"string\", key: \"env\", op: \"in\", value: condition.value }, ctx);\n }\n return evaluateString({ type: \"string\", key: \"env\", op: \"eq\", value: condition.value }, ctx);\n}\n\nexport const envEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateEnv(condition as EnvCondition, context);\n","import type { ConditionEvaluator } from \"./types.js\";\nimport type { Context } from \"../schemas/context.js\";\nimport type { StartAtCondition } from \"../schemas/condition.js\";\nimport { evaluateDatetime } from \"./datetime.js\";\n\nexport async function evaluateStartAt(\n condition: StartAtCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n return evaluateDatetime(\n {\n type: \"datetime\",\n key: \"at\",\n op: \"gte\",\n value: condition.value,\n },\n ctx,\n );\n}\n\nexport const startAtEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateStartAt(condition as StartAtCondition, context);\n","import type { ConditionEvaluator } from \"./types.js\";\nimport type { Context } from \"../schemas/context.js\";\nimport type { EndAtCondition } from \"../schemas/condition.js\";\nimport { evaluateDatetime } from \"./datetime.js\";\n\nexport async function evaluateEndAt(\n condition: EndAtCondition,\n ctx: Readonly<Context>,\n): Promise<boolean> {\n return evaluateDatetime(\n {\n type: \"datetime\",\n key: \"at\",\n op: \"lt\",\n value: condition.value,\n },\n ctx,\n );\n}\n\nexport const endAtEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateEndAt(condition as EndAtCondition, context);\n","export interface Logger {\n debug(message: string, data?: Record<string, unknown>): void;\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n error(message: string, data?: Record<string, unknown>): void;\n}\n\nexport const noopLogger: Logger = {\n debug() {},\n info() {},\n warn() {},\n error() {},\n};\n","import type { Condition } from \"../schemas/condition.js\";\nimport type { Context } from \"../schemas/context.js\";\nimport type { Annotations, ConditionEvaluators, Dependencies, RegexFactory } from \"./types.js\";\nimport { defaultCreateRegex, FALLBACK_EVALUATOR_KEY } from \"./types.js\";\nimport type { Logger } from \"../logger.js\";\nimport { noopLogger } from \"../logger.js\";\nimport { UnknownConditionTypeError } from \"../errors.js\";\n\nexport type EvaluateConditionArgs = {\n condition: Condition;\n context: Readonly<Context>;\n evaluators: ConditionEvaluators;\n annotations: Annotations;\n deps?: Readonly<Dependencies>;\n depth?: string;\n logger?: Logger;\n createRegex?: RegexFactory;\n};\n\nexport async function evaluateCondition({\n condition,\n context,\n evaluators,\n annotations,\n deps = {},\n depth = \"\",\n logger = noopLogger,\n createRegex = defaultCreateRegex,\n}: EvaluateConditionArgs): Promise<boolean> {\n const evaluator = evaluators[condition.type] ?? evaluators[FALLBACK_EVALUATOR_KEY];\n\n if (!evaluator) {\n throw new UnknownConditionTypeError(condition.type, condition);\n }\n\n const result = await evaluator({\n condition,\n context,\n annotations,\n deps,\n depth,\n createRegex,\n logger,\n evaluators,\n });\n\n logger.debug(\"condition evaluated\", {\n type: condition.type,\n depth,\n result,\n });\n return result;\n}\n","import type { AndCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\nimport { evaluateCondition } from \"./evaluate.js\";\n\nexport const andEvaluator: ConditionEvaluator = async (args) => {\n const { conditions } = args.condition as AndCondition;\n const { depth } = args;\n\n for (let i = 0; i < conditions.length; i++) {\n const childDepth = depth === \"\" ? `${i}` : `${depth}.${i}`;\n const result = await evaluateCondition({\n ...args,\n condition: conditions[i],\n depth: childDepth,\n });\n\n if (!result) {\n args.logger?.debug(\"and condition short-circuited (child returned false)\", {\n childType: conditions[i].type,\n depth: childDepth,\n });\n\n return false;\n }\n }\n return true;\n};\n","import type { OrCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\nimport { evaluateCondition } from \"./evaluate.js\";\n\nexport const orEvaluator: ConditionEvaluator = async (args) => {\n const { conditions } = args.condition as OrCondition;\n const { depth } = args;\n\n for (let i = 0; i < conditions.length; i++) {\n const childDepth = depth === \"\" ? `${i}` : `${depth}.${i}`;\n\n const result = await evaluateCondition({\n ...args,\n condition: conditions[i],\n depth: childDepth,\n });\n\n if (result) {\n args.logger?.debug(\"or condition short-circuited (child returned true)\", {\n childType: conditions[i].type,\n depth: childDepth,\n });\n\n return true;\n }\n }\n return false;\n};\n","import type { CheckAnnotationsCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\nimport { evaluateCondition } from \"./evaluate.js\";\n\nexport const checkAnnotationsEvaluator: ConditionEvaluator = async (args) => {\n const { conditions } = args.condition as CheckAnnotationsCondition;\n const { depth, annotations: annotationsAsContext } = args;\n\n for (let i = 0; i < conditions.length; i++) {\n const childDepth = depth === \"\" ? `${i}` : `${depth}.${i}`;\n\n const result = await evaluateCondition({\n ...args,\n condition: conditions[i],\n context: annotationsAsContext,\n annotations: {},\n depth: childDepth,\n });\n\n if (!result) {\n args.logger?.debug(\"checkAnnotations condition short-circuited (child returned false)\", {\n childType: conditions[i].type,\n depth: childDepth,\n });\n\n return false;\n }\n }\n return true;\n};\n","import { stringEvaluator } from \"./string.js\";\nimport { numberEvaluator } from \"./number.js\";\nimport { datetimeEvaluator } from \"./datetime.js\";\nimport { boolEvaluator } from \"./bool.js\";\nimport { envEvaluator } from \"./env.js\";\nimport { startAtEvaluator } from \"./start-at.js\";\nimport { endAtEvaluator } from \"./end-at.js\";\nimport { andEvaluator } from \"./and.js\";\nimport { orEvaluator } from \"./or.js\";\nimport { checkAnnotationsEvaluator } from \"./check-annotations.js\";\nimport type { ConditionEvaluators } from \"./types.js\";\nexport {\n noConditionEvaluator,\n AnnotationValueSchema,\n AnnotationsSchema,\n FALLBACK_EVALUATOR_KEY,\n} from \"./types.js\";\nexport type {\n Annotations,\n AnnotationsFactory,\n AnnotationValue,\n ConditionEvaluator,\n ConditionEvaluatorArgs,\n ConditionEvaluators,\n Dependencies,\n RegexFactory,\n} from \"./types.js\";\nexport { defaultCreateRegex } from \"./types.js\";\nexport { evaluateCondition } from \"./evaluate.js\";\nexport type { EvaluateConditionArgs } from \"./evaluate.js\";\n\nexport const builtinEvaluators: ConditionEvaluators = {\n string: stringEvaluator,\n number: numberEvaluator,\n datetime: datetimeEvaluator,\n bool: boolEvaluator,\n env: envEvaluator,\n startAt: startAtEvaluator,\n endAt: endAtEvaluator,\n and: andEvaluator,\n or: orEvaluator,\n checkAnnotations: checkAnnotationsEvaluator,\n};\n","import type {\n Definitions,\n Resolution,\n ResolutionError,\n Variation,\n Context,\n} from \"./schemas/index.js\";\nimport { evaluateCondition, FALLBACK_EVALUATOR_KEY } from \"./conditions/index.js\";\nimport type {\n Annotations,\n AnnotationsFactory,\n ConditionEvaluator,\n ConditionEvaluators,\n Dependencies,\n RegexFactory,\n} from \"./conditions/index.js\";\nimport { defaultCreateRegex } from \"./conditions/index.js\";\nimport {\n DefinitionInactiveError,\n DefinitionNotFoundError,\n ShowwhatError,\n VariationNotFoundError,\n} from \"./errors.js\";\nimport type { Logger } from \"./logger.js\";\nimport { noopLogger } from \"./logger.js\";\n\nexport type ResolverOptions = {\n evaluators?: ConditionEvaluators;\n fallback?: ConditionEvaluator;\n logger?: Logger;\n createRegex?: RegexFactory;\n createAnnotations?: AnnotationsFactory;\n};\n\nfunction getEvaluators(options?: ResolverOptions): ConditionEvaluators {\n if (!options?.evaluators) {\n throw new ShowwhatError(\"No evaluators registered. Pass evaluators via options.\");\n }\n if (options.fallback) {\n return { ...options.evaluators, [FALLBACK_EVALUATOR_KEY]: options.fallback };\n }\n return options.evaluators;\n}\n\nfunction getLogger(options?: { logger?: Logger }): Logger {\n return options?.logger ?? noopLogger;\n}\n\nexport async function resolveVariation({\n variations,\n context,\n deps,\n options,\n definitionKey,\n}: {\n variations: Variation[];\n context: Readonly<Context>;\n deps?: Dependencies;\n options?: ResolverOptions;\n definitionKey?: string;\n}): Promise<{ variation: Variation; variationIndex: number; annotations: Annotations } | null> {\n const evaluators = getEvaluators(options);\n const logger = getLogger(options);\n\n for (let i = 0; i < variations.length; i++) {\n const variation = variations[i];\n const conditions = Array.isArray(variation.conditions) ? variation.conditions : [];\n const annotations: Annotations = options?.createAnnotations?.(definitionKey) ?? {};\n\n if (conditions.length === 0) {\n logger.debug(\"variation matched (no conditions)\", { variationIndex: i });\n return { variation, variationIndex: i, annotations };\n }\n\n const rulesMatch = await evaluateCondition({\n condition: { type: \"and\", conditions },\n context,\n evaluators,\n annotations,\n deps: deps ?? {},\n logger,\n createRegex: options?.createRegex ?? defaultCreateRegex,\n });\n\n if (!rulesMatch) {\n logger.debug(\"variation did not match\", {\n variationIndex: i,\n conditionCount: conditions.length,\n });\n continue;\n }\n\n logger.debug(\"variation matched\", {\n variationIndex: i,\n conditionCount: conditions.length,\n });\n return { variation, variationIndex: i, annotations };\n }\n\n logger.debug(\"no variation matched\", { variationCount: variations.length });\n return null;\n}\n\nasync function resolveKey(\n key: string,\n definitions: Definitions,\n context: Readonly<Context>,\n deps?: Dependencies,\n options?: ResolverOptions,\n): Promise<Resolution> {\n const logger = getLogger(options);\n const definition = definitions[key];\n\n if (!definition) {\n logger.warn(\"definition not found\", { key });\n throw new DefinitionNotFoundError(key);\n }\n\n if (definition.active !== undefined && definition.active !== true) {\n logger.warn(\"definition inactive\", { key });\n throw new DefinitionInactiveError(key);\n }\n\n logger.debug(\"resolving definition\", {\n key,\n variationCount: definition.variations.length,\n });\n\n const result = await resolveVariation({\n variations: definition.variations,\n context,\n deps,\n options,\n definitionKey: key,\n });\n\n if (!result) {\n logger.warn(\"no matching variation\", { key });\n throw new VariationNotFoundError(key);\n }\n\n logger.debug(\"resolved\", {\n key,\n variationIndex: result.variationIndex,\n value: result.variation.value,\n });\n\n const conditionCount = Array.isArray(result.variation.conditions)\n ? result.variation.conditions.length\n : 0;\n\n return {\n success: true,\n key,\n value: result.variation.value,\n meta: {\n variation: {\n index: result.variationIndex,\n id: result.variation.id,\n description: result.variation.description,\n conditionCount,\n },\n annotations: result.annotations,\n },\n };\n}\n\n/**\n * Resolve all definitions against the given context.\n *\n * Each key is resolved independently — a failure for one key does not\n * affect others. Failed keys are returned as `ResolutionError` entries.\n */\nexport async function resolve({\n definitions,\n context,\n deps,\n options,\n}: {\n definitions: Definitions;\n context: Readonly<Context>;\n deps?: Dependencies;\n options?: ResolverOptions;\n}): Promise<Record<string, Resolution | ResolutionError>> {\n const keys = Object.keys(definitions);\n const entries = await Promise.all(\n keys.map((key) =>\n resolveKey(key, definitions, context, deps, options).catch(\n (reason): ResolutionError => ({\n success: false,\n key,\n error:\n reason instanceof ShowwhatError\n ? reason\n : new ShowwhatError(String(reason), { cause: reason }),\n }),\n ),\n ),\n );\n\n return Object.fromEntries(keys.map((key, i) => [key, entries[i]]));\n}\n","import yaml from \"js-yaml\";\nimport { FileFormatSchema } from \"./schemas/index.js\";\nimport { ParseError, SchemaValidationError } from \"./errors.js\";\nimport type { FileFormat } from \"./schemas/index.js\";\nimport { PresetsSchema } from \"./schemas/index.js\";\nimport type { Presets } from \"./schemas/index.js\";\n\nfunction loadYaml(input: string): unknown {\n try {\n return yaml.load(input);\n } catch (e: unknown) {\n const err = e as Error;\n const line = (e as yaml.YAMLException)?.mark?.line;\n\n throw new ParseError(`YAML: ${err.message}`, line);\n }\n}\n\nfunction assertPlainObject(raw: unknown, label: string): asserts raw is Record<string, unknown> {\n if (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) {\n throw new ParseError(label);\n }\n}\n\nexport async function parseYaml(input: string): Promise<FileFormat> {\n const raw = loadYaml(input);\n assertPlainObject(raw, \"YAML: Unknown structure at the root level\");\n\n return await parseObject(raw);\n}\n\nexport async function parseObject(raw: unknown): Promise<FileFormat> {\n const result = FileFormatSchema.safeParse(raw);\n\n if (!result.success) {\n throw new SchemaValidationError(result.error, \"flags\");\n }\n\n return result.data;\n}\n\nexport async function parsePresetsObject(raw: unknown): Promise<Presets> {\n assertPlainObject(raw, \"Expected object with presets key\");\n const result = PresetsSchema.safeParse(raw.presets ?? {});\n\n if (!result.success) {\n throw new SchemaValidationError(result.error, \"presets\");\n }\n\n return result.data;\n}\n\nexport async function parsePresetsYaml(input: string): Promise<Presets> {\n return parsePresetsObject(loadYaml(input));\n}\n","import { z } from \"zod\";\n\n// ── Constants ─────────────────────────────────────────────────────────────────\n\nexport const PRIMITIVE_CONDITION_TYPES = {\n string: \"string\",\n number: \"number\",\n bool: \"bool\",\n datetime: \"datetime\",\n} as const;\n\nexport type PrimitiveConditionType =\n (typeof PRIMITIVE_CONDITION_TYPES)[keyof typeof PRIMITIVE_CONDITION_TYPES];\n\nexport const CONDITION_TYPES = {\n ...PRIMITIVE_CONDITION_TYPES,\n env: \"env\",\n startAt: \"startAt\",\n endAt: \"endAt\",\n and: \"and\",\n or: \"or\",\n checkAnnotations: \"checkAnnotations\",\n} as const;\n\nexport const CONTEXT_KEYS = {\n env: \"env\",\n at: \"at\",\n} as const;\n\n// ── Primitive condition schemas ──────────────────────────────────────────────\n\nexport const StringConditionSchema = z\n .object({\n id: z.string().optional(),\n type: z.literal(\"string\"),\n key: z.string().min(1),\n op: z.enum([\"eq\", \"neq\", \"in\", \"nin\", \"regex\"]),\n value: z.union([z.string(), z.array(z.string())]),\n })\n .superRefine((val, ctx) => {\n const isArrayOp = val.op === \"in\" || val.op === \"nin\";\n const isArray = Array.isArray(val.value);\n if (isArrayOp && !isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires an array value`,\n path: [\"value\"],\n });\n }\n if (!isArrayOp && isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires a string value`,\n path: [\"value\"],\n });\n }\n });\nexport type StringCondition = z.infer<typeof StringConditionSchema>;\n\nexport const NumberConditionSchema = z\n .object({\n id: z.string().optional(),\n type: z.literal(\"number\"),\n key: z.string().min(1),\n op: z.enum([\"eq\", \"neq\", \"gt\", \"gte\", \"lt\", \"lte\", \"in\", \"nin\"]),\n value: z.union([z.number(), z.array(z.number())]),\n })\n .superRefine((val, ctx) => {\n const isArrayOp = val.op === \"in\" || val.op === \"nin\";\n const isArray = Array.isArray(val.value);\n if (isArrayOp && !isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires an array value`,\n path: [\"value\"],\n });\n }\n if (!isArrayOp && isArray) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"${val.op}\" operator requires a number value`,\n path: [\"value\"],\n });\n }\n });\nexport type NumberCondition = z.infer<typeof NumberConditionSchema>;\n\nexport const DatetimeConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"datetime\"),\n key: z.string().min(1),\n op: z.enum([\"eq\", \"gt\", \"gte\", \"lt\", \"lte\"]),\n value: z.iso.datetime({ message: '\"datetime\" must be a valid ISO 8601 datetime' }),\n});\nexport type DatetimeCondition = z.infer<typeof DatetimeConditionSchema>;\n\nexport const BoolConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"bool\"),\n key: z.string().min(1),\n op: z.literal(\"eq\").optional(),\n value: z.boolean(),\n});\nexport type BoolCondition = z.infer<typeof BoolConditionSchema>;\n\n// ── Sugar condition schemas ──────────────────────────────────────────────────\n\nexport const EnvConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"env\"),\n op: z.literal(\"eq\").optional(),\n value: z.union([z.string(), z.array(z.string())]),\n});\nexport type EnvCondition = z.infer<typeof EnvConditionSchema>;\n\nexport const StartAtConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"startAt\"),\n value: z.iso.datetime({ message: '\"startAt\" must be a valid ISO 8601 datetime' }),\n});\nexport type StartAtCondition = z.infer<typeof StartAtConditionSchema>;\n\nexport const EndAtConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"endAt\"),\n value: z.iso.datetime({ message: '\"endAt\" must be a valid ISO 8601 datetime' }),\n});\nexport type EndAtCondition = z.infer<typeof EndAtConditionSchema>;\n\n// ── Built-in union ────────────────────────────────────────────────────────────\n\nexport const BuiltinConditionSchema = z.discriminatedUnion(\"type\", [\n StringConditionSchema,\n NumberConditionSchema,\n DatetimeConditionSchema,\n BoolConditionSchema,\n EnvConditionSchema,\n StartAtConditionSchema,\n EndAtConditionSchema,\n]);\nexport type BuiltinCondition = z.infer<typeof BuiltinConditionSchema>;\n\n// ── Condition (explicit recursive type) ──────────────────────────────────────\n\nexport type Condition =\n | BuiltinCondition\n | { id?: string; type: \"and\"; conditions: Condition[] }\n | { id?: string; type: \"or\"; conditions: Condition[] }\n | { id?: string; type: \"checkAnnotations\"; conditions: Condition[] }\n | { type: string; [key: string]: unknown };\n\n// ── Composite schemas ─────────────────────────────────────────────────────────\n// z.lazy is safe here: all schemas are in this file, so ConditionSchema\n// is defined before any .parse() call occurs.\n\nconst AndConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"and\"),\n conditions: z.array(z.lazy(() => ConditionSchema)).min(1),\n});\nconst OrConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"or\"),\n conditions: z.array(z.lazy(() => ConditionSchema)).min(1),\n});\nconst CheckAnnotationsConditionSchema = z.object({\n id: z.string().optional(),\n type: z.literal(\"checkAnnotations\"),\n conditions: z.array(z.lazy(() => ConditionSchema)).min(1),\n});\n\n// All built-in and composite types must not pass through the open-union custom-condition arm.\nconst BLOCKED_OPEN_UNION_TYPES = new Set<string>(Object.values(CONDITION_TYPES));\n\n// ── ConditionSchema ───────────────────────────────────────────────────────────\n// z.ZodType<Condition> annotation is required for the recursive schema.\n\n// Regex pattern validation is deferred to resolve time via the configured\n// createRegex factory (see ResolverOptions). This avoids divergence between\n// the parse-time engine (always native RegExp) and the runtime engine\n// (which may be RE2 or another safe-regex implementation).\nexport const ConditionSchema: z.ZodType<Condition> = z.union([\n BuiltinConditionSchema,\n AndConditionSchema,\n OrConditionSchema,\n CheckAnnotationsConditionSchema,\n z.looseObject({ type: z.string() }).refine((val) => !BLOCKED_OPEN_UNION_TYPES.has(val.type), {\n message: \"Reserved condition type\",\n }),\n]);\n\n// ── Composite types (inferred after schema is defined) ────────────────────────\n\nexport type AndCondition = z.infer<typeof AndConditionSchema>;\nexport type OrCondition = z.infer<typeof OrConditionSchema>;\nexport type CheckAnnotationsCondition = z.infer<typeof CheckAnnotationsConditionSchema>;\nexport type CompositeCondition = AndCondition | OrCondition | CheckAnnotationsCondition;\n\n// ── Type guards ───────────────────────────────────────────────────────────────\n\nexport function isAndCondition(c: Condition): c is AndCondition {\n return c.type === CONDITION_TYPES.and;\n}\nexport function isOrCondition(c: Condition): c is OrCondition {\n return c.type === CONDITION_TYPES.or;\n}\nexport function isCheckAnnotationsCondition(c: Condition): c is CheckAnnotationsCondition {\n return c.type === CONDITION_TYPES.checkAnnotations;\n}\n","import { z } from \"zod\";\nimport { DataValueSchema } from \"./value.js\";\nimport type { DataValue } from \"./value.js\";\n\nexport type ContextValue = DataValue;\n\nexport const ContextValueSchema = DataValueSchema;\n\nexport const ContextSchema = z.record(z.string(), ContextValueSchema);\n\nexport type Context = Record<string, ContextValue>;\n","import { z } from \"zod\";\nimport { ConditionSchema } from \"./condition.js\";\n\nexport type VariationValue = unknown;\nexport const VariationValueSchema: z.ZodType<VariationValue> = z.unknown();\n\nexport const VariationSchema = z.object({\n id: z.string().optional(),\n value: VariationValueSchema,\n conditions: z.array(ConditionSchema).optional(),\n description: z.string().optional(),\n});\n\nexport type Variation = z.infer<typeof VariationSchema>;\n","import { z } from \"zod\";\nimport { VariationSchema } from \"./variation.js\";\nimport { PresetsSchema } from \"./preset.js\";\n\nexport const DefinitionSchema = z.object({\n id: z.string().optional(),\n active: z.boolean().optional(),\n description: z.string().optional(),\n variations: z.array(VariationSchema).min(1),\n});\nexport type Definition = z.infer<typeof DefinitionSchema>;\n\nexport const DefinitionsSchema = z.record(z.string().min(1), DefinitionSchema);\nexport type Definitions = z.infer<typeof DefinitionsSchema>;\n\nexport const FileFormatSchema = z\n .object({\n definitions: DefinitionsSchema,\n presets: PresetsSchema.optional(),\n })\n .strict();\n\nexport type FileFormat = z.infer<typeof FileFormatSchema>;\n","import { z } from \"zod\";\nimport { PRIMITIVE_CONDITION_TYPES, ConditionSchema } from \"./condition.js\";\n\nexport type PresetDefinition = {\n type: string;\n key?: string;\n overrides?: Record<string, unknown>;\n};\n\nexport type Presets = Record<string, PresetDefinition>;\n\nconst PRIMITIVE_TYPES = new Set<string>(Object.values(PRIMITIVE_CONDITION_TYPES));\nconst COMPOSITE_TYPES = new Set<string>([\"and\", \"or\", \"checkAnnotations\"]);\n\nconst PresetDefinitionSchema = z\n .object({\n type: z.string().min(1),\n key: z.string().min(1).optional(),\n overrides: z.record(z.string(), z.unknown()).optional(),\n })\n .superRefine((val, ctx) => {\n if (PRIMITIVE_TYPES.has(val.type) && !val.key) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"key\" is required when type is a built-in preset type (\"${val.type}\")`,\n path: [\"key\"],\n });\n }\n if (COMPOSITE_TYPES.has(val.type)) {\n const conditions = val.overrides?.conditions;\n\n if (!Array.isArray(conditions) || conditions.length === 0) {\n ctx.addIssue({\n code: \"custom\",\n message: `\"overrides.conditions\" must be a non-empty array for composite type (\"${val.type}\")`,\n path: [\"overrides\", \"conditions\"],\n });\n\n return;\n }\n\n for (let i = 0; i < conditions.length; i++) {\n const result = ConditionSchema.safeParse(conditions[i]);\n\n if (!result.success) {\n for (const issue of result.error.issues) {\n ctx.addIssue({\n ...issue,\n path: [\"overrides\", \"conditions\", i, ...issue.path],\n });\n }\n }\n }\n }\n });\n\nexport const PresetsSchema = z.record(z.string(), PresetDefinitionSchema);\n","import { z } from \"zod\";\nimport { VariationValueSchema } from \"./variation.js\";\nimport type { ShowwhatError } from \"../errors.js\";\n\nexport const ResolutionSchema = z.object({\n key: z.string(),\n value: VariationValueSchema,\n meta: z.object({\n variation: z.object({\n index: z.number().int().nonnegative(),\n id: z.string().optional(),\n description: z.string().optional(),\n conditionCount: z.number().int().nonnegative(),\n }),\n annotations: z.record(z.string(), z.unknown()),\n }),\n});\n\ntype BaseResolution = z.infer<typeof ResolutionSchema>;\n\nexport type Resolution = Omit<BaseResolution, \"value\"> & {\n success: true;\n value: unknown;\n};\n\nexport type ResolutionError = {\n success: false;\n key: string;\n error: ShowwhatError;\n};\n","import { parseObject, parseYaml } from \"./parsers.js\";\nimport type { Definitions, Definition } from \"./schemas/index.js\";\nimport type { Presets } from \"./schemas/index.js\";\n\nexport interface DefinitionReader {\n get(key: string): Promise<Definition | null>;\n getAll(): Promise<Definitions>;\n listKeys(): Promise<string[]>;\n load?(): Promise<void>;\n close?(): Promise<void>;\n ping?(): Promise<void>;\n}\n\nexport interface DefinitionWriter {\n put(key: string, definition: Definition): Promise<void>;\n delete(key: string): Promise<void>;\n putMany(flags: Definitions, options?: { replace?: boolean }): Promise<void>;\n load?(): Promise<void>;\n close?(): Promise<void>;\n ping?(): Promise<void>;\n}\n\nexport interface DefinitionData extends DefinitionReader, DefinitionWriter {}\n\nexport interface PresetReader {\n getPresets(): Promise<Presets>;\n getPresets(key: string): Promise<Presets>;\n}\n\nfunction hasMethod(obj: object, key: string): boolean {\n return key in obj && typeof (obj as Record<string, unknown>)[key] === \"function\";\n}\n\nexport function isWritable(reader: DefinitionReader): reader is DefinitionData {\n return hasMethod(reader, \"put\") && hasMethod(reader, \"delete\") && hasMethod(reader, \"putMany\");\n}\n\nexport class MemoryData implements DefinitionReader, PresetReader {\n #flags: Definitions;\n #presets: Presets;\n\n private constructor(flags: Definitions, presets: Presets) {\n this.#flags = flags;\n this.#presets = presets;\n }\n\n static async fromObject(raw: unknown): Promise<MemoryData> {\n const fileFormat = await parseObject(raw);\n return new MemoryData(fileFormat.definitions, fileFormat.presets ?? {});\n }\n\n static async fromYaml(yaml: string): Promise<MemoryData> {\n const fileFormat = await parseYaml(yaml);\n return new MemoryData(fileFormat.definitions, fileFormat.presets ?? {});\n }\n\n async get(key: string): Promise<Definition | null> {\n const def = this.#flags[key];\n if (def === undefined) {\n return null;\n }\n return structuredClone(def);\n }\n\n async getAll(): Promise<Definitions> {\n return structuredClone(this.#flags);\n }\n\n async listKeys(): Promise<string[]> {\n return Object.keys(this.#flags);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async getPresets(_key?: string): Promise<Presets> {\n return structuredClone(this.#presets);\n }\n}\n","import { evaluateCondition } from \"./conditions/evaluate.js\";\nimport type { ConditionEvaluator, ConditionEvaluators } from \"./conditions/types.js\";\nimport { CONDITION_TYPES } from \"./schemas/condition.js\";\nimport type { Condition } from \"./schemas/condition.js\";\nimport type { Presets } from \"./schemas/preset.js\";\n\nconst RESERVED_CONDITION_TYPES = new Set([...Object.values(CONDITION_TYPES), \"__custom\"]);\n\nexport function createPresetConditions(presets: Presets): ConditionEvaluators {\n const result: ConditionEvaluators = {};\n\n for (const [name, preset] of Object.entries(presets)) {\n if (RESERVED_CONDITION_TYPES.has(name)) {\n throw new Error(`Preset name \"${name}\" collides with a built-in or reserved condition type`);\n }\n\n const overrides = preset.overrides ?? {};\n\n const evaluator: ConditionEvaluator = async ({\n condition,\n context,\n annotations,\n deps,\n depth,\n createRegex,\n evaluators,\n logger,\n }) => {\n const rec = condition as Record<string, unknown>;\n const rewritten: Record<string, unknown> = { ...rec, ...overrides, type: preset.type };\n\n if (preset.key) {\n rewritten.key = preset.key;\n }\n\n return evaluateCondition({\n condition: rewritten as Condition,\n context,\n evaluators,\n annotations,\n deps,\n depth,\n logger,\n createRegex,\n });\n };\n\n result[name] = evaluator;\n }\n\n return result;\n}\n"],"mappings":";AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB,SAAwB;AACnD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,aAAN,cAAyB,cAAc;AAAA,EAC5C,YACE,SACgB,MAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAEA,SAAS,aAAa,SAA0B;AAC9C,SAAO,oBAAoB,UAAU,OAAO,OAAO,KAAK,EAAE;AAC5D;AAEO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EACjC;AAAA,EAEhB,YAAY,SAAiB,SAAkB;AAC7C,UAAM,GAAG,aAAa,OAAO,CAAC;AAAA,IAAO,OAAO,EAAE;AAC9C,SAAK,OAAO;AACZ,SAAK,SAAS,CAAC,EAAE,MAAM,UAAmB,SAAS,MAAM,CAAC,EAAE,CAAC;AAAA,EAC/D;AACF;AAEO,IAAM,wBAAN,cAAoC,gBAAgB;AAAA,EACzD,YAAY,UAAoB,SAAkB;AAChD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name": "@showwhat/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Core rule engine and schemas for showwhat library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"feature-flags",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/js-yaml": "^4.0.9",
|
|
46
46
|
"@types/node": "^25.5.0",
|
|
47
|
-
"@vitest/coverage-v8": "^4.1.
|
|
47
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
48
48
|
"tsup": "^8.5.1",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
|
-
"vitest": "^4.1.
|
|
50
|
+
"vitest": "^4.1.4"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsup",
|