@showwhat/core 1.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.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/conditions/types.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) {\n super(message);\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(\n message: string,\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"DataError\";\n }\n}\n","import type { Context } from \"../schemas/context.js\";\nimport type { StringCondition } from \"../schemas/condition.js\";\nimport type { ConditionEvaluator } from \"./types.js\";\n\nexport async function evaluateString(\n condition: StringCondition,\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 = 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 try {\n return new RegExp(condition.value as string).test(actual);\n } catch {\n return false;\n }\n }\n}\n\nexport const stringEvaluator: ConditionEvaluator = ({ condition, context }) =>\n evaluateString(condition as StringCondition, context);\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 let actual: Date;\n\n if (Object.hasOwn(ctx, condition.key)) {\n const raw = ctx[condition.key];\n if (typeof raw !== \"string\") return false;\n actual = parseDate(condition.key, raw);\n } else if (condition.key === \"at\") {\n // Default to \"now\" when the \"at\" key is absent (preserves existing behavior)\n actual = new Date();\n } else {\n return false;\n }\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 type { Context } from \"../schemas/context.js\";\n\nexport type Annotations = Record<string, unknown>;\n\nexport type ConditionEvaluatorArgs = {\n condition: unknown;\n context: Readonly<Context>;\n annotations: Annotations;\n depth: string;\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 { 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\nexport const ConditionSchema: z.ZodType<Condition> = z\n .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 .superRefine((val, ctx) => {\n // Defense-in-depth: catches edge cases like catastrophic backtracking patterns that pass schema format validation\n if (val.type === CONDITION_TYPES.string) {\n const sc = val as StringCondition;\n if (sc.op === \"regex\") {\n try {\n new RegExp(sc.value as string);\n } catch (e) {\n ctx.addIssue({\n code: \"custom\",\n message: `Invalid regex pattern \"${sc.value}\": ${(e as Error).message}`,\n path: [\"value\"],\n });\n }\n }\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 { Annotations, ConditionEvaluator, ConditionEvaluators } 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 depth?: string;\n logger?: Logger;\n fallback?: ConditionEvaluator;\n};\n\nexport async function evaluateCondition({\n condition,\n context,\n evaluators,\n annotations,\n depth = \"\",\n logger = noopLogger,\n fallback,\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 depth: childDepth,\n logger,\n fallback,\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 depth: childDepth,\n logger,\n fallback,\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, depth });\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, depth });\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} 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 { Definitions, Resolution, Variation, Context } from \"./schemas/index.js\";\nimport { evaluateCondition } from \"./conditions/index.js\";\nimport type { Annotations, ConditionEvaluator, ConditionEvaluators } 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};\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 variations,\n context,\n options,\n}: {\n variations: Variation[];\n context: Readonly<Context>;\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 logger,\n fallback: options?.fallback,\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 context: Readonly<Context>,\n): Resolution {\n const conditionCount = Array.isArray(result.variation.conditions)\n ? result.variation.conditions.length\n : 0;\n\n return {\n key,\n value: result.variation.value,\n meta: {\n context: { ...context },\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(\n key: string,\n definitions: Definitions,\n context: Readonly<Context>,\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({ variations: definition.variations, context, options });\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, context);\n}\n\n/**\n * Resolve all definitions against the given context.\n *\n * Uses `Promise.all` — if any single key fails (not found, inactive, no match),\n * the entire call rejects. Callers who need partial results should resolve\n * keys individually via `resolveVariation`.\n */\nexport async function resolve({\n definitions,\n context,\n options,\n}: {\n definitions: Definitions;\n context: Readonly<Context>;\n options?: ResolverOptions;\n}): Promise<Record<string, Resolution>> {\n const keys = Object.keys(definitions);\n const entries = await Promise.all(\n keys.map(async (key) => [key, await resolveKey(key, definitions, context, options)] as const),\n );\n\n return Object.fromEntries(entries);\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 = 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});\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 defaults?: 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 defaults: 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 { ContextSchema } from \"./context.js\";\nimport { VariationValueSchema } from \"./variation.js\";\n\nexport const ResolutionSchema = z.object({\n key: z.string(),\n value: VariationValueSchema,\n meta: z.object({\n context: ContextSchema,\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});\nexport type Resolution = z.infer<typeof ResolutionSchema>;\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 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 listKeys(): Promise<string[]>;\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 (\n hasMethod(reader, \"put\") &&\n hasMethod(reader, \"delete\") &&\n hasMethod(reader, \"putMany\") &&\n hasMethod(reader, \"listKeys\")\n );\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 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 evaluator: ConditionEvaluator = ({ condition, context, annotations, depth }) => {\n const rec = condition as Record<string, unknown>;\n return delegateEvaluator({\n condition: { ...rec, type: primitiveType, key: presetKey },\n context,\n annotations,\n depth,\n });\n };\n\n result[name] = evaluator;\n }\n\n return result;\n}\n"],"mappings":";AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,aAAN,cAAyB,cAAc;AAAA,EAC5C,YACE,SACgB,MACh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AAI,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,YAAgC,CAAC,EAAE,WAAW,SAAS,aAAa,MAAM,MAAM;AACpF,YAAM,MAAM;AACZ,aAAO,kBAAkB;AAAA,QACvB,WAAW,EAAE,GAAG,KAAK,MAAM,eAAe,KAAK,UAAU;AAAA,QACzD;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"]}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@showwhat/core",
3
+ "version": "1.0.0",
4
+ "description": "Core rule engine and schemas for showwhat",
5
+ "keywords": [
6
+ "feature-flags",
7
+ "feature-toggles",
8
+ "rule-engine",
9
+ "schema",
10
+ "targeting",
11
+ "showwhat"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/yeojz/showwhat.git",
17
+ "directory": "packages/core"
18
+ },
19
+ "homepage": "https://showwhat.yeojz.dev",
20
+ "bugs": {
21
+ "url": "https://github.com/yeojz/showwhat/issues"
22
+ },
23
+ "type": "module",
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ }
31
+ },
32
+ "engines": {
33
+ "node": ">=22.0.0"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "dependencies": {
39
+ "js-yaml": "^4.1.0",
40
+ "zod": "^4.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/js-yaml": "^4.0.9",
44
+ "@types/node": "^25.4.0",
45
+ "@vitest/coverage-v8": "^4.0.0",
46
+ "tsup": "^8.0.0",
47
+ "typescript": "^5.4.0",
48
+ "vitest": "^4.0.0"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup",
52
+ "clean": "rm -rf dist .tsbuildinfo",
53
+ "lint": "eslint src",
54
+ "typecheck": "tsc --noEmit"
55
+ }
56
+ }