@showwhat/core 1.0.0 → 2.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.
- package/README.md +3 -3
- package/dist/index.d.ts +44 -21
- package/dist/index.js +89 -58
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @showwhat/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Low-level schemas, parsers, and rule engine for [`showwhat`](https://www.npmjs.com/package/showwhat).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use `@showwhat/core` when you want the evaluation primitives without the higher-level convenience API.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -39,7 +39,7 @@ console.log(result.checkout_v2.value); // true
|
|
|
39
39
|
|
|
40
40
|
- Built-in condition types: `string`, `number`, `datetime`, `bool`, `env`, `startAt`, `endAt`
|
|
41
41
|
- Composite conditions with `and`/`or` logic
|
|
42
|
-
- Custom condition types via
|
|
42
|
+
- Custom condition types via evaluator composition
|
|
43
43
|
- YAML and JSON parsing with schema validation
|
|
44
44
|
- Pluggable data sources (`DefinitionReader` / `DefinitionWriter`)
|
|
45
45
|
- Typed error hierarchy
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodError, z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare class ShowwhatError extends Error {
|
|
4
|
-
constructor(message: string);
|
|
4
|
+
constructor(message: string, options?: ErrorOptions);
|
|
5
5
|
}
|
|
6
6
|
declare class ParseError extends ShowwhatError {
|
|
7
7
|
readonly line?: number | undefined;
|
|
@@ -32,8 +32,11 @@ declare class InvalidContextError extends ShowwhatError {
|
|
|
32
32
|
constructor(key: string, value: string | number | boolean);
|
|
33
33
|
}
|
|
34
34
|
declare class DataError extends ShowwhatError {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
constructor(message: string, cause?: unknown);
|
|
36
|
+
}
|
|
37
|
+
declare class ConditionError extends ShowwhatError {
|
|
38
|
+
readonly conditionType: string;
|
|
39
|
+
constructor(conditionType: string, message: string, cause?: unknown);
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
declare const PRIMITIVE_CONDITION_TYPES: {
|
|
@@ -224,7 +227,7 @@ type ContextPrimitive = string | number | boolean;
|
|
|
224
227
|
type ContextValue = ContextPrimitive | ContextPrimitive[] | {
|
|
225
228
|
[key: string]: ContextValue;
|
|
226
229
|
};
|
|
227
|
-
type Context = Record<string, ContextValue
|
|
230
|
+
type Context<T extends Record<string, ContextValue> = Record<string, ContextValue>> = T;
|
|
228
231
|
|
|
229
232
|
type VariationValue = unknown;
|
|
230
233
|
declare const VariationValueSchema: z.ZodType<VariationValue>;
|
|
@@ -275,7 +278,7 @@ declare const FileFormatSchema: z.ZodObject<{
|
|
|
275
278
|
presets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
276
279
|
type: z.ZodString;
|
|
277
280
|
key: z.ZodOptional<z.ZodString>;
|
|
278
|
-
|
|
281
|
+
overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
279
282
|
}, z.core.$strip>>>;
|
|
280
283
|
}, z.core.$strict>;
|
|
281
284
|
type FileFormat = z.infer<typeof FileFormatSchema>;
|
|
@@ -283,21 +286,20 @@ type FileFormat = z.infer<typeof FileFormatSchema>;
|
|
|
283
286
|
type PresetDefinition = {
|
|
284
287
|
type: string;
|
|
285
288
|
key?: string;
|
|
286
|
-
|
|
289
|
+
overrides?: Record<string, unknown>;
|
|
287
290
|
};
|
|
288
291
|
type Presets = Record<string, PresetDefinition>;
|
|
289
292
|
declare const PRIMITIVE_TYPES: Set<string>;
|
|
290
293
|
declare const PresetsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
291
294
|
type: z.ZodString;
|
|
292
295
|
key: z.ZodOptional<z.ZodString>;
|
|
293
|
-
|
|
296
|
+
overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
294
297
|
}, z.core.$strip>>;
|
|
295
298
|
|
|
296
299
|
declare const ResolutionSchema: z.ZodObject<{
|
|
297
300
|
key: z.ZodString;
|
|
298
301
|
value: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
299
302
|
meta: z.ZodObject<{
|
|
300
|
-
context: z.ZodRecord<z.ZodString, z.ZodType<ContextValue, unknown, z.core.$ZodTypeInternals<ContextValue, unknown>>>;
|
|
301
303
|
variation: z.ZodObject<{
|
|
302
304
|
index: z.ZodNumber;
|
|
303
305
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -307,14 +309,30 @@ declare const ResolutionSchema: z.ZodObject<{
|
|
|
307
309
|
annotations: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
308
310
|
}, z.core.$strip>;
|
|
309
311
|
}, z.core.$strip>;
|
|
310
|
-
type
|
|
312
|
+
type BaseResolution = z.infer<typeof ResolutionSchema>;
|
|
313
|
+
type Resolution = Omit<BaseResolution, "value"> & {
|
|
314
|
+
success: true;
|
|
315
|
+
value: unknown;
|
|
316
|
+
};
|
|
317
|
+
type ResolutionError = {
|
|
318
|
+
success: false;
|
|
319
|
+
key: string;
|
|
320
|
+
error: ShowwhatError;
|
|
321
|
+
};
|
|
311
322
|
|
|
312
|
-
type Annotations = Record<string, unknown
|
|
323
|
+
type Annotations<T extends Record<string, unknown> = Record<string, unknown>> = T;
|
|
324
|
+
type Dependencies<T extends Record<string, unknown> = Record<string, unknown>> = T;
|
|
325
|
+
type RegexFactory = (pattern: string) => {
|
|
326
|
+
test: (input: string) => boolean;
|
|
327
|
+
};
|
|
328
|
+
declare const defaultCreateRegex: RegexFactory;
|
|
313
329
|
type ConditionEvaluatorArgs = {
|
|
314
330
|
condition: unknown;
|
|
315
331
|
context: Readonly<Context>;
|
|
316
332
|
annotations: Annotations;
|
|
333
|
+
deps: Readonly<Dependencies>;
|
|
317
334
|
depth: string;
|
|
335
|
+
createRegex: RegexFactory;
|
|
318
336
|
};
|
|
319
337
|
type ConditionEvaluator = (args: ConditionEvaluatorArgs) => Promise<boolean>;
|
|
320
338
|
type ConditionEvaluators<T extends string = string> = Record<T, ConditionEvaluator>;
|
|
@@ -333,11 +351,13 @@ type EvaluateConditionArgs = {
|
|
|
333
351
|
context: Readonly<Context>;
|
|
334
352
|
evaluators: ConditionEvaluators;
|
|
335
353
|
annotations: Annotations;
|
|
354
|
+
deps?: Readonly<Dependencies>;
|
|
336
355
|
depth?: string;
|
|
337
356
|
logger?: Logger;
|
|
338
357
|
fallback?: ConditionEvaluator;
|
|
358
|
+
createRegex?: RegexFactory;
|
|
339
359
|
};
|
|
340
|
-
declare function evaluateCondition({ condition, context, evaluators, annotations, depth, logger, fallback, }: EvaluateConditionArgs): Promise<boolean>;
|
|
360
|
+
declare function evaluateCondition({ condition, context, evaluators, annotations, deps, depth, logger, fallback, createRegex, }: EvaluateConditionArgs): Promise<boolean>;
|
|
341
361
|
|
|
342
362
|
declare const builtinEvaluators: ConditionEvaluators<BuiltinCondition["type"]>;
|
|
343
363
|
|
|
@@ -345,10 +365,12 @@ type ResolverOptions = {
|
|
|
345
365
|
evaluators?: ConditionEvaluators;
|
|
346
366
|
fallback?: ConditionEvaluator;
|
|
347
367
|
logger?: Logger;
|
|
368
|
+
createRegex?: RegexFactory;
|
|
348
369
|
};
|
|
349
|
-
declare function resolveVariation({ variations, context, options, }: {
|
|
370
|
+
declare function resolveVariation<T extends Record<string, ContextValue> = Record<string, ContextValue>, D extends Record<string, unknown> = Record<string, unknown>>({ variations, context, deps, options, }: {
|
|
350
371
|
variations: Variation[];
|
|
351
|
-
context: Readonly<Context
|
|
372
|
+
context: Readonly<Context<T>>;
|
|
373
|
+
deps?: Dependencies<D>;
|
|
352
374
|
options?: ResolverOptions;
|
|
353
375
|
}): Promise<{
|
|
354
376
|
variation: Variation;
|
|
@@ -358,19 +380,20 @@ declare function resolveVariation({ variations, context, options, }: {
|
|
|
358
380
|
/**
|
|
359
381
|
* Resolve all definitions against the given context.
|
|
360
382
|
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* keys individually via `resolveVariation`.
|
|
383
|
+
* Each key is resolved independently — a failure for one key does not
|
|
384
|
+
* affect others. Failed keys are returned as `ResolutionError` entries.
|
|
364
385
|
*/
|
|
365
|
-
declare function resolve({ definitions, context, options, }: {
|
|
386
|
+
declare function resolve<T extends Record<string, ContextValue> = Record<string, ContextValue>, D extends Record<string, unknown> = Record<string, unknown>>({ definitions, context, deps, options, }: {
|
|
366
387
|
definitions: Definitions;
|
|
367
|
-
context: Readonly<Context
|
|
388
|
+
context: Readonly<Context<T>>;
|
|
389
|
+
deps?: Dependencies<D>;
|
|
368
390
|
options?: ResolverOptions;
|
|
369
|
-
}): Promise<Record<string, Resolution>>;
|
|
391
|
+
}): Promise<Record<string, Resolution | ResolutionError>>;
|
|
370
392
|
|
|
371
393
|
interface DefinitionReader {
|
|
372
394
|
get(key: string): Promise<Definition | null>;
|
|
373
395
|
getAll(): Promise<Definitions>;
|
|
396
|
+
listKeys(): Promise<string[]>;
|
|
374
397
|
load?(): Promise<void>;
|
|
375
398
|
close?(): Promise<void>;
|
|
376
399
|
ping?(): Promise<void>;
|
|
@@ -381,7 +404,6 @@ interface DefinitionWriter {
|
|
|
381
404
|
putMany(flags: Definitions, options?: {
|
|
382
405
|
replace?: boolean;
|
|
383
406
|
}): Promise<void>;
|
|
384
|
-
listKeys(): Promise<string[]>;
|
|
385
407
|
load?(): Promise<void>;
|
|
386
408
|
close?(): Promise<void>;
|
|
387
409
|
ping?(): Promise<void>;
|
|
@@ -400,6 +422,7 @@ declare class MemoryData implements DefinitionReader, PresetReader {
|
|
|
400
422
|
static fromYaml(yaml: string): Promise<MemoryData>;
|
|
401
423
|
get(key: string): Promise<Definition | null>;
|
|
402
424
|
getAll(): Promise<Definitions>;
|
|
425
|
+
listKeys(): Promise<string[]>;
|
|
403
426
|
getPresets(): Promise<Presets>;
|
|
404
427
|
}
|
|
405
428
|
|
|
@@ -410,4 +433,4 @@ declare function parsePresetsYaml(input: string): Promise<Presets>;
|
|
|
410
433
|
|
|
411
434
|
declare function createPresetConditions(presets: Presets): ConditionEvaluators;
|
|
412
435
|
|
|
413
|
-
export { type AndCondition, type Annotations, type BoolCondition, BoolConditionSchema, type BuiltinCondition, BuiltinConditionSchema, CONDITION_TYPES, CONTEXT_KEYS, type CompositeCondition, type Condition, type ConditionEvaluator, type ConditionEvaluatorArgs, type ConditionEvaluators, ConditionSchema, type Context, ContextSchema, type ContextValue, DataError, type DatetimeCondition, DatetimeConditionSchema, type Definition, type DefinitionData, DefinitionInactiveError, DefinitionNotFoundError, type DefinitionReader, DefinitionSchema, type DefinitionWriter, type Definitions, DefinitionsSchema, type EndAtCondition, EndAtConditionSchema, type EnvCondition, EnvConditionSchema, type EvaluateConditionArgs, type FileFormat, FileFormatSchema, InvalidContextError, type Logger, MemoryData, type NumberCondition, NumberConditionSchema, type OrCondition, PRIMITIVE_CONDITION_TYPES, PRIMITIVE_TYPES, ParseError, type PresetDefinition, type PresetReader, type Presets, PresetsSchema, type PrimitiveConditionType, type Resolution, ResolutionSchema, type ResolverOptions, SchemaValidationError, ShowwhatError, type StartAtCondition, StartAtConditionSchema, type StringCondition, StringConditionSchema, ValidationError, type Variation, VariationNotFoundError, VariationSchema, type VariationValue, VariationValueSchema, builtinEvaluators, createPresetConditions, evaluateCondition, isAndCondition, isOrCondition, isWritable, noConditionEvaluator, noopLogger, parseObject, parsePresetsObject, parsePresetsYaml, parseYaml, resolve, resolveVariation };
|
|
436
|
+
export { type AndCondition, type Annotations, type BoolCondition, BoolConditionSchema, type BuiltinCondition, BuiltinConditionSchema, CONDITION_TYPES, CONTEXT_KEYS, type CompositeCondition, type Condition, ConditionError, type ConditionEvaluator, type ConditionEvaluatorArgs, type ConditionEvaluators, ConditionSchema, type Context, ContextSchema, type ContextValue, DataError, type DatetimeCondition, DatetimeConditionSchema, type Definition, type DefinitionData, DefinitionInactiveError, DefinitionNotFoundError, type DefinitionReader, DefinitionSchema, type DefinitionWriter, type Definitions, DefinitionsSchema, type Dependencies, type EndAtCondition, EndAtConditionSchema, type EnvCondition, EnvConditionSchema, type EvaluateConditionArgs, type FileFormat, FileFormatSchema, InvalidContextError, type Logger, MemoryData, type NumberCondition, NumberConditionSchema, type OrCondition, PRIMITIVE_CONDITION_TYPES, PRIMITIVE_TYPES, ParseError, type PresetDefinition, type PresetReader, type Presets, PresetsSchema, type PrimitiveConditionType, type RegexFactory, type Resolution, type ResolutionError, ResolutionSchema, type ResolverOptions, SchemaValidationError, ShowwhatError, type StartAtCondition, StartAtConditionSchema, type StringCondition, StringConditionSchema, ValidationError, type Variation, VariationNotFoundError, VariationSchema, type VariationValue, VariationValueSchema, builtinEvaluators, createPresetConditions, defaultCreateRegex, evaluateCondition, isAndCondition, isOrCondition, isWritable, noConditionEvaluator, noopLogger, parseObject, parsePresetsObject, parsePresetsYaml, parseYaml, resolve, resolveVariation };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/errors.ts
|
|
2
2
|
var ShowwhatError = class extends Error {
|
|
3
|
-
constructor(message) {
|
|
4
|
-
super(message);
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message, options);
|
|
5
5
|
this.name = "ShowwhatError";
|
|
6
6
|
}
|
|
7
7
|
};
|
|
@@ -63,14 +63,24 @@ var InvalidContextError = class extends ShowwhatError {
|
|
|
63
63
|
};
|
|
64
64
|
var DataError = class extends ShowwhatError {
|
|
65
65
|
constructor(message, cause) {
|
|
66
|
-
super(message);
|
|
67
|
-
this.cause = cause;
|
|
66
|
+
super(message, cause !== void 0 ? { cause } : void 0);
|
|
68
67
|
this.name = "DataError";
|
|
69
68
|
}
|
|
70
69
|
};
|
|
70
|
+
var ConditionError = class extends ShowwhatError {
|
|
71
|
+
constructor(conditionType, message, cause) {
|
|
72
|
+
super(message, cause !== void 0 ? { cause } : void 0);
|
|
73
|
+
this.conditionType = conditionType;
|
|
74
|
+
this.name = "ConditionError";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/conditions/types.ts
|
|
79
|
+
var defaultCreateRegex = (pattern) => new RegExp(pattern);
|
|
80
|
+
var noConditionEvaluator = async () => false;
|
|
71
81
|
|
|
72
82
|
// src/conditions/string.ts
|
|
73
|
-
async function evaluateString(condition, ctx) {
|
|
83
|
+
async function evaluateString(condition, ctx, createRegex = defaultCreateRegex) {
|
|
74
84
|
if (!Object.hasOwn(ctx, condition.key)) return false;
|
|
75
85
|
const raw = ctx[condition.key];
|
|
76
86
|
if (typeof raw !== "string") return false;
|
|
@@ -84,15 +94,23 @@ async function evaluateString(condition, ctx) {
|
|
|
84
94
|
return condition.value.includes(actual);
|
|
85
95
|
case "nin":
|
|
86
96
|
return !condition.value.includes(actual);
|
|
87
|
-
case "regex":
|
|
97
|
+
case "regex": {
|
|
98
|
+
const pattern = condition.value;
|
|
99
|
+
let regex;
|
|
88
100
|
try {
|
|
89
|
-
|
|
90
|
-
} catch {
|
|
91
|
-
|
|
101
|
+
regex = createRegex(pattern);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
throw new ConditionError(
|
|
104
|
+
"string",
|
|
105
|
+
`Invalid regex pattern "${pattern}": ${e.message}`,
|
|
106
|
+
e
|
|
107
|
+
);
|
|
92
108
|
}
|
|
109
|
+
return regex.test(actual);
|
|
110
|
+
}
|
|
93
111
|
}
|
|
94
112
|
}
|
|
95
|
-
var stringEvaluator = ({ condition, context }) => evaluateString(condition, context);
|
|
113
|
+
var stringEvaluator = ({ condition, context, createRegex }) => evaluateString(condition, context, createRegex);
|
|
96
114
|
|
|
97
115
|
// src/conditions/number.ts
|
|
98
116
|
async function evaluateNumber(condition, ctx) {
|
|
@@ -134,16 +152,10 @@ function parseDate(key, raw) {
|
|
|
134
152
|
|
|
135
153
|
// src/conditions/datetime.ts
|
|
136
154
|
async function evaluateDatetime(condition, ctx) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
actual = parseDate(condition.key, raw);
|
|
142
|
-
} else if (condition.key === "at") {
|
|
143
|
-
actual = /* @__PURE__ */ new Date();
|
|
144
|
-
} else {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
155
|
+
if (!Object.hasOwn(ctx, condition.key)) return false;
|
|
156
|
+
const raw = ctx[condition.key];
|
|
157
|
+
if (typeof raw !== "string") return false;
|
|
158
|
+
const actual = parseDate(condition.key, raw);
|
|
147
159
|
const expected = new Date(condition.value);
|
|
148
160
|
switch (condition.op) {
|
|
149
161
|
case "eq":
|
|
@@ -212,9 +224,6 @@ async function evaluateEndAt(condition, ctx) {
|
|
|
212
224
|
}
|
|
213
225
|
var endAtEvaluator = ({ condition, context }) => evaluateEndAt(condition, context);
|
|
214
226
|
|
|
215
|
-
// src/conditions/types.ts
|
|
216
|
-
var noConditionEvaluator = async () => false;
|
|
217
|
-
|
|
218
227
|
// src/schemas/condition.ts
|
|
219
228
|
import { z as z2 } from "zod";
|
|
220
229
|
var PRIMITIVE_CONDITION_TYPES = {
|
|
@@ -340,22 +349,7 @@ var ConditionSchema = z2.union([
|
|
|
340
349
|
z2.looseObject({ type: z2.string() }).refine((val) => !BLOCKED_OPEN_UNION_TYPES.has(val.type), {
|
|
341
350
|
message: "Reserved condition type"
|
|
342
351
|
})
|
|
343
|
-
])
|
|
344
|
-
if (val.type === CONDITION_TYPES.string) {
|
|
345
|
-
const sc = val;
|
|
346
|
-
if (sc.op === "regex") {
|
|
347
|
-
try {
|
|
348
|
-
new RegExp(sc.value);
|
|
349
|
-
} catch (e) {
|
|
350
|
-
ctx.addIssue({
|
|
351
|
-
code: "custom",
|
|
352
|
-
message: `Invalid regex pattern "${sc.value}": ${e.message}`,
|
|
353
|
-
path: ["value"]
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
});
|
|
352
|
+
]);
|
|
359
353
|
function isAndCondition(c) {
|
|
360
354
|
return c.type === CONDITION_TYPES.and;
|
|
361
355
|
}
|
|
@@ -381,9 +375,11 @@ async function evaluateCondition({
|
|
|
381
375
|
context,
|
|
382
376
|
evaluators,
|
|
383
377
|
annotations,
|
|
378
|
+
deps = {},
|
|
384
379
|
depth = "",
|
|
385
380
|
logger = noopLogger,
|
|
386
|
-
fallback
|
|
381
|
+
fallback,
|
|
382
|
+
createRegex = defaultCreateRegex
|
|
387
383
|
}) {
|
|
388
384
|
if (isAndCondition(condition)) {
|
|
389
385
|
for (let i = 0; i < condition.conditions.length; i++) {
|
|
@@ -393,9 +389,11 @@ async function evaluateCondition({
|
|
|
393
389
|
context,
|
|
394
390
|
evaluators,
|
|
395
391
|
annotations,
|
|
392
|
+
deps,
|
|
396
393
|
depth: childDepth,
|
|
397
394
|
logger,
|
|
398
|
-
fallback
|
|
395
|
+
fallback,
|
|
396
|
+
createRegex
|
|
399
397
|
});
|
|
400
398
|
if (!result2) {
|
|
401
399
|
logger.debug("and condition short-circuited (child returned false)", {
|
|
@@ -415,9 +413,11 @@ async function evaluateCondition({
|
|
|
415
413
|
context,
|
|
416
414
|
evaluators,
|
|
417
415
|
annotations,
|
|
416
|
+
deps,
|
|
418
417
|
depth: childDepth,
|
|
419
418
|
logger,
|
|
420
|
-
fallback
|
|
419
|
+
fallback,
|
|
420
|
+
createRegex
|
|
421
421
|
});
|
|
422
422
|
if (result2) {
|
|
423
423
|
logger.debug("or condition short-circuited (child returned true)", {
|
|
@@ -432,7 +432,7 @@ async function evaluateCondition({
|
|
|
432
432
|
const evaluator = evaluators[condition.type];
|
|
433
433
|
if (!evaluator) {
|
|
434
434
|
if (fallback) {
|
|
435
|
-
const result2 = await fallback({ condition, context, annotations, depth });
|
|
435
|
+
const result2 = await fallback({ condition, context, annotations, deps, depth, createRegex });
|
|
436
436
|
logger.debug("condition evaluated (fallback)", {
|
|
437
437
|
type: condition.type,
|
|
438
438
|
depth,
|
|
@@ -442,7 +442,7 @@ async function evaluateCondition({
|
|
|
442
442
|
}
|
|
443
443
|
throw new ShowwhatError(`Unknown condition type "${condition.type}".`);
|
|
444
444
|
}
|
|
445
|
-
const result = await evaluator({ condition, context, annotations, depth });
|
|
445
|
+
const result = await evaluator({ condition, context, annotations, deps, depth, createRegex });
|
|
446
446
|
logger.debug("condition evaluated", {
|
|
447
447
|
type: condition.type,
|
|
448
448
|
depth,
|
|
@@ -475,6 +475,7 @@ function getLogger(options) {
|
|
|
475
475
|
async function resolveVariation({
|
|
476
476
|
variations,
|
|
477
477
|
context,
|
|
478
|
+
deps,
|
|
478
479
|
options
|
|
479
480
|
}) {
|
|
480
481
|
const evaluators = getEvaluators(options);
|
|
@@ -492,8 +493,10 @@ async function resolveVariation({
|
|
|
492
493
|
context,
|
|
493
494
|
evaluators,
|
|
494
495
|
annotations,
|
|
496
|
+
deps: deps ?? {},
|
|
495
497
|
logger,
|
|
496
|
-
fallback: options?.fallback
|
|
498
|
+
fallback: options?.fallback,
|
|
499
|
+
createRegex: options?.createRegex
|
|
497
500
|
});
|
|
498
501
|
if (!rulesMatch) {
|
|
499
502
|
logger.debug("variation did not match", {
|
|
@@ -511,13 +514,13 @@ async function resolveVariation({
|
|
|
511
514
|
logger.debug("no variation matched", { variationCount: variations.length });
|
|
512
515
|
return null;
|
|
513
516
|
}
|
|
514
|
-
function toResolution(key, result
|
|
517
|
+
function toResolution(key, result) {
|
|
515
518
|
const conditionCount = Array.isArray(result.variation.conditions) ? result.variation.conditions.length : 0;
|
|
516
519
|
return {
|
|
520
|
+
success: true,
|
|
517
521
|
key,
|
|
518
522
|
value: result.variation.value,
|
|
519
523
|
meta: {
|
|
520
|
-
context: { ...context },
|
|
521
524
|
variation: {
|
|
522
525
|
index: result.variationIndex,
|
|
523
526
|
id: result.variation.id,
|
|
@@ -528,7 +531,7 @@ function toResolution(key, result, context) {
|
|
|
528
531
|
}
|
|
529
532
|
};
|
|
530
533
|
}
|
|
531
|
-
async function resolveKey(key, definitions, context, options) {
|
|
534
|
+
async function resolveKey(key, definitions, context, deps, options) {
|
|
532
535
|
const logger = getLogger(options);
|
|
533
536
|
const definition = definitions[key];
|
|
534
537
|
if (!definition) {
|
|
@@ -543,7 +546,12 @@ async function resolveKey(key, definitions, context, options) {
|
|
|
543
546
|
key,
|
|
544
547
|
variationCount: definition.variations.length
|
|
545
548
|
});
|
|
546
|
-
const result = await resolveVariation({
|
|
549
|
+
const result = await resolveVariation({
|
|
550
|
+
variations: definition.variations,
|
|
551
|
+
context,
|
|
552
|
+
deps,
|
|
553
|
+
options
|
|
554
|
+
});
|
|
547
555
|
if (!result) {
|
|
548
556
|
logger.warn("no matching variation", { key });
|
|
549
557
|
throw new VariationNotFoundError(key);
|
|
@@ -553,18 +561,27 @@ async function resolveKey(key, definitions, context, options) {
|
|
|
553
561
|
variationIndex: result.variationIndex,
|
|
554
562
|
value: result.variation.value
|
|
555
563
|
});
|
|
556
|
-
return toResolution(key, result
|
|
564
|
+
return toResolution(key, result);
|
|
557
565
|
}
|
|
558
566
|
async function resolve({
|
|
559
567
|
definitions,
|
|
560
568
|
context,
|
|
569
|
+
deps,
|
|
561
570
|
options
|
|
562
571
|
}) {
|
|
563
572
|
const keys = Object.keys(definitions);
|
|
564
573
|
const entries = await Promise.all(
|
|
565
|
-
keys.map(
|
|
574
|
+
keys.map(
|
|
575
|
+
(key) => resolveKey(key, definitions, context, deps, options).catch(
|
|
576
|
+
(reason) => ({
|
|
577
|
+
success: false,
|
|
578
|
+
key,
|
|
579
|
+
error: reason instanceof ShowwhatError ? reason : new ShowwhatError(String(reason), { cause: reason })
|
|
580
|
+
})
|
|
581
|
+
)
|
|
582
|
+
)
|
|
566
583
|
);
|
|
567
|
-
return Object.fromEntries(entries);
|
|
584
|
+
return Object.fromEntries(keys.map((key, i) => [key, entries[i]]));
|
|
568
585
|
}
|
|
569
586
|
|
|
570
587
|
// src/parsers.ts
|
|
@@ -599,7 +616,7 @@ var PRIMITIVE_TYPES = new Set(Object.values(PRIMITIVE_CONDITION_TYPES));
|
|
|
599
616
|
var PresetDefinitionSchema = z5.object({
|
|
600
617
|
type: z5.string().min(1),
|
|
601
618
|
key: z5.string().min(1).optional(),
|
|
602
|
-
|
|
619
|
+
overrides: z5.record(z5.string(), z5.unknown()).optional()
|
|
603
620
|
}).superRefine((val, ctx) => {
|
|
604
621
|
if (PRIMITIVE_TYPES.has(val.type) && !val.key) {
|
|
605
622
|
ctx.addIssue({
|
|
@@ -630,7 +647,6 @@ var ResolutionSchema = z7.object({
|
|
|
630
647
|
key: z7.string(),
|
|
631
648
|
value: VariationValueSchema,
|
|
632
649
|
meta: z7.object({
|
|
633
|
-
context: ContextSchema,
|
|
634
650
|
variation: z7.object({
|
|
635
651
|
index: z7.number().int().nonnegative(),
|
|
636
652
|
id: z7.string().optional(),
|
|
@@ -685,7 +701,7 @@ function hasMethod(obj, key) {
|
|
|
685
701
|
return key in obj && typeof obj[key] === "function";
|
|
686
702
|
}
|
|
687
703
|
function isWritable(reader) {
|
|
688
|
-
return hasMethod(reader, "put") && hasMethod(reader, "delete") && hasMethod(reader, "putMany")
|
|
704
|
+
return hasMethod(reader, "put") && hasMethod(reader, "delete") && hasMethod(reader, "putMany");
|
|
689
705
|
}
|
|
690
706
|
var MemoryData = class _MemoryData {
|
|
691
707
|
#flags;
|
|
@@ -712,6 +728,9 @@ var MemoryData = class _MemoryData {
|
|
|
712
728
|
async getAll() {
|
|
713
729
|
return structuredClone(this.#flags);
|
|
714
730
|
}
|
|
731
|
+
async listKeys() {
|
|
732
|
+
return Object.keys(this.#flags);
|
|
733
|
+
}
|
|
715
734
|
async getPresets() {
|
|
716
735
|
return structuredClone(this.#presets);
|
|
717
736
|
}
|
|
@@ -737,13 +756,23 @@ function createPresetConditions(presets) {
|
|
|
737
756
|
const primitiveType = preset.type;
|
|
738
757
|
const delegateEvaluator = BUILTIN_EVALUATORS[primitiveType];
|
|
739
758
|
const presetKey = preset.key;
|
|
740
|
-
const
|
|
759
|
+
const overrides = preset.overrides ?? {};
|
|
760
|
+
const evaluator = ({
|
|
761
|
+
condition,
|
|
762
|
+
context,
|
|
763
|
+
annotations,
|
|
764
|
+
deps,
|
|
765
|
+
depth,
|
|
766
|
+
createRegex
|
|
767
|
+
}) => {
|
|
741
768
|
const rec = condition;
|
|
742
769
|
return delegateEvaluator({
|
|
743
|
-
condition: { ...rec, type: primitiveType, key: presetKey },
|
|
770
|
+
condition: { ...rec, ...overrides, type: primitiveType, key: presetKey },
|
|
744
771
|
context,
|
|
745
772
|
annotations,
|
|
746
|
-
|
|
773
|
+
deps,
|
|
774
|
+
depth,
|
|
775
|
+
createRegex
|
|
747
776
|
});
|
|
748
777
|
};
|
|
749
778
|
result[name] = evaluator;
|
|
@@ -755,6 +784,7 @@ export {
|
|
|
755
784
|
BuiltinConditionSchema,
|
|
756
785
|
CONDITION_TYPES,
|
|
757
786
|
CONTEXT_KEYS,
|
|
787
|
+
ConditionError,
|
|
758
788
|
ConditionSchema,
|
|
759
789
|
ContextSchema,
|
|
760
790
|
DataError,
|
|
@@ -784,6 +814,7 @@ export {
|
|
|
784
814
|
VariationValueSchema,
|
|
785
815
|
builtinEvaluators,
|
|
786
816
|
createPresetConditions,
|
|
817
|
+
defaultCreateRegex,
|
|
787
818
|
evaluateCondition,
|
|
788
819
|
isAndCondition,
|
|
789
820
|
isOrCondition,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,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,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AEA,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/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,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;AAC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AAI,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"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@showwhat/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Core rule engine and schemas for showwhat",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Core rule engine and schemas for showwhat library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"feature-flags",
|
|
7
7
|
"feature-toggles",
|
|
8
8
|
"rule-engine",
|
|
9
|
+
"configuration",
|
|
9
10
|
"schema",
|
|
11
|
+
"specification",
|
|
10
12
|
"targeting",
|
|
11
13
|
"showwhat"
|
|
12
14
|
],
|
|
@@ -36,16 +38,16 @@
|
|
|
36
38
|
"dist"
|
|
37
39
|
],
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"js-yaml": "^4.1.
|
|
40
|
-
"zod": "^4.
|
|
41
|
+
"js-yaml": "^4.1.1",
|
|
42
|
+
"zod": "^4.3.6"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@types/js-yaml": "^4.0.9",
|
|
44
|
-
"@types/node": "^25.
|
|
45
|
-
"@vitest/coverage-v8": "^4.
|
|
46
|
-
"tsup": "^8.
|
|
47
|
-
"typescript": "^5.
|
|
48
|
-
"vitest": "^4.
|
|
46
|
+
"@types/node": "^25.5.0",
|
|
47
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
48
|
+
"tsup": "^8.5.1",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"vitest": "^4.1.2"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
53
|
"build": "tsup",
|