constructa-generators 0.3.2 → 0.4.1

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 CHANGED
@@ -34,12 +34,16 @@ The first implementation set will include integer, boolean, choice, decimal, str
34
34
 
35
35
  ## Object
36
36
 
37
- `object(fields)` composes named child definitions and infers a mapped object output from them. Each child is delegated through the execution engine using its field name as the path segment, so nested errors retain their full field path. `registerObjectGenerator(registry)` is available for advanced custom registries.
37
+ `object(fields)` composes named child definitions and infers a mapped object output from them. Each child is delegated through the execution engine using its field name as the path segment, so nested errors retain their full field path. Template references are validated against the object's direct and nested fields before execution; independent fields use a stable name-based execution order while output preserves declaration order. `registerObjectGenerator(registry)` is available for advanced custom registries.
38
38
 
39
39
  ## Array
40
40
 
41
41
  `array(item, { length })` creates one fixed-length array value and infers `Infer<typeof item>[]`. Length must be a non-negative safe integer no greater than 10,000. Array items are delegated through the execution engine using numeric index path segments; this is distinct from repeated root execution. `registerArrayGenerator(registry)` is available for advanced custom registries.
42
42
 
43
+ ## Template
44
+
45
+ `template(source)` returns a string definition that interpolates object-local `{field}` and `{sibling.nested}` values. `{{` and `}}` emit literal braces. Only strings, finite numbers, booleans, and `null` can be interpolated; objects and arrays fail with `NON_SCALAR_REFERENCE`. Templates do not support expressions, transforms, or functions. `registerTemplateGenerator(registry)` is available for advanced custom registries.
46
+
43
47
  ## Dependency boundary
44
48
 
45
49
  This package may import `constructa-core` for the generator contract and registration APIs, and `constructa-schema` for portable definitions. It must not import exporters, the SDK, applications, UI, environment, persistence, or transport code.
package/dist/index.d.ts CHANGED
@@ -28,6 +28,14 @@ type InferGenerator<Definition> = Definition extends GeneratorDefinition<infer O
28
28
  declare function object<const Fields extends ObjectFields>(fields: Fields): ObjectDefinition<Fields>;
29
29
  declare const objectGenerator: GeneratorImplementation<ObjectDefinition, Record<string, unknown>>;
30
30
  declare function registerObjectGenerator(registry: GeneratorRegistry): void;
31
+ type TemplateDefinition = GeneratorDefinition<string> & {
32
+ readonly type: "template";
33
+ readonly source: string;
34
+ };
35
+ /** Builds a string template with object-local `{field}` references. */
36
+ declare function template(source: string): TemplateDefinition;
37
+ declare const templateGenerator: GeneratorImplementation<TemplateDefinition, string>;
38
+ declare function registerTemplateGenerator(registry: GeneratorRegistry): void;
31
39
  type ArrayOptions = {
32
40
  readonly length: number;
33
41
  };
@@ -115,5 +123,5 @@ declare const integerGenerator: GeneratorImplementation<IntegerDefinition, numbe
115
123
  /** Registers the integer built-in with an advanced custom registry. */
116
124
  declare function registerIntegerGenerator(registry: GeneratorRegistry): void;
117
125
  //#endregion
118
- export { ArrayDefinition, ArrayOptions, BooleanDefinition, ChoiceDefinition, DateDefinition, DateOptions, DecimalDefinition, DecimalOptions, IntegerDefinition, IntegerOptions, MAX_ARRAY_LENGTH, MAX_DECIMAL_PRECISION, MAX_STRING_LENGTH, ObjectDefinition, ObjectFields, ObjectOutput, StringCharset, StringDefinition, StringOptions, UuidDefinition, array, arrayGenerator, boolean, booleanGenerator, choice, choiceGenerator, date, dateGenerator, decimal, decimalGenerator, integer, integerGenerator, object, objectGenerator, registerArrayGenerator, registerBooleanGenerator, registerChoiceGenerator, registerDateGenerator, registerDecimalGenerator, registerIntegerGenerator, registerObjectGenerator, registerStringGenerator, registerUuidGenerator, string, stringGenerator, uuid, uuidGenerator };
126
+ export { ArrayDefinition, ArrayOptions, BooleanDefinition, ChoiceDefinition, DateDefinition, DateOptions, DecimalDefinition, DecimalOptions, IntegerDefinition, IntegerOptions, MAX_ARRAY_LENGTH, MAX_DECIMAL_PRECISION, MAX_STRING_LENGTH, ObjectDefinition, ObjectFields, ObjectOutput, StringCharset, StringDefinition, StringOptions, TemplateDefinition, UuidDefinition, array, arrayGenerator, boolean, booleanGenerator, choice, choiceGenerator, date, dateGenerator, decimal, decimalGenerator, integer, integerGenerator, object, objectGenerator, registerArrayGenerator, registerBooleanGenerator, registerChoiceGenerator, registerDateGenerator, registerDecimalGenerator, registerIntegerGenerator, registerObjectGenerator, registerStringGenerator, registerTemplateGenerator, registerUuidGenerator, string, stringGenerator, template, templateGenerator, uuid, uuidGenerator };
119
127
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAiBa;cACA;cACA;cAEP;;;;;;KAQM,iBAAiB;WAClB;;;iBAIK,QAAQ;cAIX,eAAe,wBAAwB;iBAapC,sBAAsB,UAAU;KAIpC,eAAe,SAAS,eAAe;KACvC,aAAa,eAAe,mBACrC,aAAa,SAAS,eAAe,OAAO;KAEnC,iBAAiB,eAAe,eAAe,gBACzD,oBAAoB,aAAa;WACtB;WACA,QAAQ;;KAGhB,eAAe,cAClB,mBAAmB,0BAA0B,UAAU;;iBAGzC,aAAa,eAAe,cAC1C,QAAQ,SACP,iBAAiB;cAUP,iBAAiB,wBAC5B,kBACA;iBA6Bc,wBAAwB,UAAU;KAItC;WACD;;KAEC,gBACV,aAAa,sBAAsB,uBACjC,oBAAoB,eAAe;WAC5B;WACA,MAAM;WACN;;;iBAIK,YAAY,aAAa,qBACvC,MAAM,MACN,SAAS,eACR,gBAAgB;cAeN,gBAAgB,wBAC3B;iBAec,uBAAuB,UAAU;KAIrC,iBAAiB,cAAc,YAAY,aACrD,oBAAoB;WACT;WACA,iBAAiB;;;iBAId,aAAa,wBAAwB,aACnD,QAAQ,SACP,iBAAiB;cASP,iBAAiB,wBAC5B,kBACA;iBAYc,wBAAwB,UAAU;KAItC;WACD;WACA;WACA;;KAGC,oBAAoB;WACrB;WACA;WACA;WACA;;;iBAIK,QAAQ,SAAS,iBAAiB;cAWrC,kBAAkB,wBAC7B;iBAcc,yBAAyB,UAAU;KAIvC,6BAA6B;KAC7B;WACD;WACA,UAAU;;KAGT,mBAAmB;WACpB;WACA;WACA;;;iBAIK,OAAO,SAAS,gBAAgB;cAYnC,iBAAiB,wBAC5B;iBAgBc,wBAAwB,UAAU;KAItC;WACD;WACA;;KAGC,i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AAoB;WACrB;WACA;WACA;WACA;;;iBAIK,QAAQ,SAAS,iBAAiB;cAWrC,kBAAkB,wBAC7B;iBAcc,yBAAyB,UAAU;KAIvC,6BAA6B;KAC7B;WACD;WACA,UAAU;;KAGT,mBAAmB;WACpB;WACA;WACA;;;iBAIK,OAAO,SAAS,gBAAgB;cAYnC,iBAAiB,wBAC5B;iBAgBc,wBAAwB,UAAU;KAItC;WACD;WACA;;KAGC,iBAAiB;WAClB;WACA;WACA;;;iBAIK,KAAK,SAAS,cAAc;cAW/B,eAAe,wBAAwB;iBAcpC,sBAAsB,UAAU;KAIpC;WACD;WACA;;KAGC,oBAAoB;WACrB;;;iBAIK,WAAW;;cAKd,kBAAkB,wBAC7B;;iBAYc,yBAAyB,UAAU;KAIvC,oBAAoB;WACrB;WACA;WACA;;;iBAIK,QAAQ,SAAS,iBAAiB;;cAsBrC,kBAAkB,wBAC7B;;iBAac,yBAAyB,UAAU"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createCompositeDependencyAnalysis, createGeneratorDefinition, defineGenerator, scheduleCompositeDependencies } from "constructa-core";
1
+ import { createCompositeDependencyAnalysis, createGeneratorDefinition, defineGenerator, parseTemplateTokens, scheduleCompositeDependencies } from "constructa-core";
2
2
  import { ConstructaError, validateGeneratorDefinition, validateJsonValue } from "constructa-schema";
3
3
  //#region src/index.ts
4
4
  const MAX_DECIMAL_PRECISION = 15;
@@ -51,19 +51,51 @@ const objectGenerator = defineGenerator({
51
51
  dependencies: context.analyzeChildValueDependencies(child, key)
52
52
  })));
53
53
  const scope = context.createObjectScope();
54
- for (const key of scheduleCompositeDependencies(dependencies)) {
54
+ for (const key of scheduleCompositeDependencies(dependencies, { referencePaths: collectObjectReferencePaths(definition.fields) })) {
55
55
  const child = children.get(key);
56
56
  if (child === void 0) continue;
57
57
  completed.set(key, scope.executeChild(child, key));
58
58
  }
59
59
  const result = {};
60
- for (const [key] of fields) result[key] = completed.get(key);
60
+ for (const [key] of fields) Object.defineProperty(result, key, {
61
+ value: completed.get(key),
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true
65
+ });
61
66
  return result;
62
67
  }
63
68
  });
64
69
  function registerObjectGenerator(registry) {
65
70
  registry.register(objectGenerator);
66
71
  }
72
+ function template(source) {
73
+ assertValidGeneratorOptions(validateTemplateDefinition({
74
+ type: "template",
75
+ source
76
+ }));
77
+ return createGeneratorDefinition({
78
+ type: "template",
79
+ source
80
+ });
81
+ }
82
+ const templateGenerator = defineGenerator({
83
+ type: "template",
84
+ version: 1,
85
+ validateDefinition: validateTemplateDefinition,
86
+ analyzeValueDependencies({ source }) {
87
+ return parseTemplateTokens(source, { path: ["source"] }).filter((token) => token.type === "reference").map((token) => ({ path: token.path }));
88
+ },
89
+ generate({ definition, context }) {
90
+ return parseTemplateTokens(definition.source, { path: ["source"] }).map((token) => {
91
+ if (token.type === "literal") return token.value;
92
+ return stringifyTemplateValue(context.references.resolve(token.path), context.path);
93
+ }).join("");
94
+ }
95
+ });
96
+ function registerTemplateGenerator(registry) {
97
+ registry.register(templateGenerator);
98
+ }
67
99
  function array(item, options) {
68
100
  assertValidGeneratorOptions(validateArrayDefinition({
69
101
  type: "array",
@@ -251,6 +283,36 @@ function validateObjectDefinition(value) {
251
283
  });
252
284
  return issues;
253
285
  }
286
+ function validateTemplateDefinition(value) {
287
+ const keyIssues = validateExactDefinitionKeys(value, "template", ["source"]);
288
+ if (keyIssues.length > 0) return keyIssues;
289
+ const source = value.source;
290
+ if (typeof source !== "string") return [invalidConfiguration(["source"], "source must be a string")];
291
+ try {
292
+ parseTemplateTokens(source, { path: ["source"] });
293
+ } catch (cause) {
294
+ if (cause instanceof ConstructaError) return [{
295
+ code: "invalid_template_token",
296
+ path: cause.path,
297
+ message: cause.message
298
+ }];
299
+ throw cause;
300
+ }
301
+ return [];
302
+ }
303
+ function collectObjectReferencePaths(fields) {
304
+ const paths = [];
305
+ const visit = (definitions, prefix) => {
306
+ for (const [key, definition] of Object.entries(definitions)) {
307
+ const path = [...prefix, key];
308
+ paths.push(path);
309
+ const nestedFields = definition.fields;
310
+ if (definition.type === "object" && isDefinitionRecord(nestedFields)) visit(nestedFields, path);
311
+ }
312
+ };
313
+ visit(fields, []);
314
+ return paths;
315
+ }
254
316
  function validateArrayDefinition(value) {
255
317
  const keyIssues = validateExactDefinitionKeys(value, "array", ["item", "length"]);
256
318
  if (keyIssues.length > 0) return keyIssues;
@@ -342,13 +404,24 @@ function assertValidGeneratorOptions(issues) {
342
404
  code: {
343
405
  empty_choice: "EMPTY_CHOICE",
344
406
  invalid_length: "INVALID_LENGTH",
345
- invalid_range: "INVALID_RANGE"
407
+ invalid_range: "INVALID_RANGE",
408
+ invalid_template_token: "INVALID_TEMPLATE_TOKEN"
346
409
  }[issue.code] ?? "INVALID_CONFIGURATION",
347
410
  path: issue.path,
348
411
  message: issue.message,
349
412
  details: { issueCode: issue.code }
350
413
  });
351
414
  }
415
+ function stringifyTemplateValue(value, path) {
416
+ if (typeof value === "string" || typeof value === "boolean" || value === null) return String(value);
417
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
418
+ throw new ConstructaError({
419
+ kind: "dependency",
420
+ code: "NON_SCALAR_REFERENCE",
421
+ path,
422
+ message: "Template references must resolve to a scalar value."
423
+ });
424
+ }
352
425
  function isDefinitionRecord(value) {
353
426
  return typeof value === "object" && value !== null && !Array.isArray(value);
354
427
  }
@@ -396,6 +469,6 @@ function invalidRange(path, message) {
396
469
  };
397
470
  }
398
471
  //#endregion
399
- export { MAX_ARRAY_LENGTH, MAX_DECIMAL_PRECISION, MAX_STRING_LENGTH, array, arrayGenerator, boolean, booleanGenerator, choice, choiceGenerator, date, dateGenerator, decimal, decimalGenerator, integer, integerGenerator, object, objectGenerator, registerArrayGenerator, registerBooleanGenerator, registerChoiceGenerator, registerDateGenerator, registerDecimalGenerator, registerIntegerGenerator, registerObjectGenerator, registerStringGenerator, registerUuidGenerator, string, stringGenerator, uuid, uuidGenerator };
472
+ export { MAX_ARRAY_LENGTH, MAX_DECIMAL_PRECISION, MAX_STRING_LENGTH, array, arrayGenerator, boolean, booleanGenerator, choice, choiceGenerator, date, dateGenerator, decimal, decimalGenerator, integer, integerGenerator, object, objectGenerator, registerArrayGenerator, registerBooleanGenerator, registerChoiceGenerator, registerDateGenerator, registerDecimalGenerator, registerIntegerGenerator, registerObjectGenerator, registerStringGenerator, registerTemplateGenerator, registerUuidGenerator, string, stringGenerator, template, templateGenerator, uuid, uuidGenerator };
400
473
 
401
474
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["definition"],"sources":["../src/index.ts"],"sourcesContent":["import {\n createCompositeDependencyAnalysis,\n createGeneratorDefinition,\n defineGenerator,\n type GeneratorDefinition,\n type GeneratorImplementation,\n type GeneratorRegistry,\n scheduleCompositeDependencies,\n type ValidationIssue,\n} from \"constructa-core\";\nimport {\n ConstructaError,\n type JsonValue,\n validateGeneratorDefinition,\n validateJsonValue,\n} from \"constructa-schema\";\n\nexport const MAX_DECIMAL_PRECISION = 15;\nexport const MAX_STRING_LENGTH = 10_000;\nexport const MAX_ARRAY_LENGTH = 10_000;\n\nconst STRING_CHARSETS = {\n alphabetic: \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\",\n numeric: \"0123456789\",\n alphanumeric:\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\",\n hex: \"0123456789abcdef\",\n} as const;\n\nexport type UuidDefinition = GeneratorDefinition<string> & {\n readonly type: \"uuid\";\n};\n\n/** Builds a portable UUID version 4 definition. */\nexport function uuid(): UuidDefinition {\n return createGeneratorDefinition({ type: \"uuid\" }) as UuidDefinition;\n}\n\nexport const uuidGenerator: GeneratorImplementation<UuidDefinition, string> =\n defineGenerator({\n type: \"uuid\",\n version: 1,\n validateDefinition: validateUuidDefinition,\n generate({ context }) {\n const bytes = context.random.bytes(16);\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n return formatUuid(bytes);\n },\n });\n\nexport function registerUuidGenerator(registry: GeneratorRegistry): void {\n registry.register(uuidGenerator);\n}\n\nexport type ObjectFields = Readonly<Record<string, GeneratorDefinition>>;\nexport type ObjectOutput<Fields extends ObjectFields> = {\n [Key in keyof Fields]: InferGenerator<Fields[Key]>;\n};\nexport type ObjectDefinition<Fields extends ObjectFields = ObjectFields> =\n GeneratorDefinition<ObjectOutput<Fields>> & {\n readonly type: \"object\";\n readonly fields: Fields;\n };\n\ntype InferGenerator<Definition> =\n Definition extends GeneratorDefinition<infer Output> ? Output : never;\n\n/** Builds a composite object definition from named child definitions. */\nexport function object<const Fields extends ObjectFields>(\n fields: Fields,\n): ObjectDefinition<Fields>;\nexport function object(fields: unknown): ObjectDefinition {\n const issues = validateObjectDefinition({ type: \"object\", fields });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"object\",\n fields: fields as ObjectFields,\n }) as ObjectDefinition;\n}\n\nexport const objectGenerator: GeneratorImplementation<\n ObjectDefinition,\n Record<string, unknown>\n> = defineGenerator({\n type: \"object\",\n version: 1,\n validateDefinition: validateObjectDefinition,\n generate({ definition, context }) {\n const fields = Object.entries(definition.fields);\n const children = new Map(fields);\n const completed = new Map<string, unknown>();\n const dependencies = createCompositeDependencyAnalysis(\n fields.map(([key, child]) => ({\n fieldPath: [key] as const,\n dependencies: context.analyzeChildValueDependencies(child, key),\n })),\n );\n const scope = context.createObjectScope();\n for (const key of scheduleCompositeDependencies(dependencies)) {\n const child = children.get(key);\n if (child === undefined) continue;\n completed.set(key, scope.executeChild(child, key));\n }\n const result: Record<string, unknown> = {};\n for (const [key] of fields) {\n result[key] = completed.get(key);\n }\n return result;\n },\n});\n\nexport function registerObjectGenerator(registry: GeneratorRegistry): void {\n registry.register(objectGenerator);\n}\n\nexport type ArrayOptions = {\n readonly length: number;\n};\nexport type ArrayDefinition<\n Item extends GeneratorDefinition = GeneratorDefinition,\n> = GeneratorDefinition<InferGenerator<Item>[]> & {\n readonly type: \"array\";\n readonly item: Item;\n readonly length: number;\n};\n\n/** Builds a fixed-length composite array definition. */\nexport function array<const Item extends GeneratorDefinition>(\n item: Item,\n options: ArrayOptions,\n): ArrayDefinition<Item>;\nexport function array(item: unknown, options: unknown): ArrayDefinition {\n const issues = validateArrayDefinition({\n type: \"array\",\n item,\n ...(isDefinitionRecord(options) ? options : { length: undefined }),\n });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"array\",\n item: item as GeneratorDefinition,\n length: (options as ArrayOptions).length,\n }) as ArrayDefinition;\n}\n\nexport const arrayGenerator: GeneratorImplementation<\n ArrayDefinition,\n unknown[]\n> = defineGenerator({\n type: \"array\",\n version: 1,\n validateDefinition: validateArrayDefinition,\n generate({ definition, context }) {\n const result: unknown[] = [];\n for (let index = 0; index < definition.length; index += 1) {\n result.push(context.executeChild(definition.item, index));\n }\n return result;\n },\n});\n\nexport function registerArrayGenerator(registry: GeneratorRegistry): void {\n registry.register(arrayGenerator);\n}\n\nexport type ChoiceDefinition<Value extends JsonValue = JsonValue> =\n GeneratorDefinition<Value> & {\n readonly type: \"choice\";\n readonly values: readonly Value[];\n };\n\n/** Builds a portable choice definition while preserving array-literal unions. */\nexport function choice<const Values extends readonly JsonValue[]>(\n values: Values,\n): ChoiceDefinition<Values[number]> {\n const issues = validateChoiceDefinition({ type: \"choice\", values });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"choice\",\n values,\n }) as ChoiceDefinition<Values[number]>;\n}\n\nexport const choiceGenerator: GeneratorImplementation<\n ChoiceDefinition,\n JsonValue\n> = defineGenerator({\n type: \"choice\",\n version: 1,\n validateDefinition: validateChoiceDefinition,\n generate({ definition, context }) {\n return definition.values[\n context.random.integer(definition.values.length)\n ] as JsonValue;\n },\n});\n\nexport function registerChoiceGenerator(registry: GeneratorRegistry): void {\n registry.register(choiceGenerator);\n}\n\nexport type DecimalOptions = {\n readonly min: number;\n readonly max: number;\n readonly precision: number;\n};\n\nexport type DecimalDefinition = GeneratorDefinition<number> & {\n readonly type: \"decimal\";\n readonly min: number;\n readonly max: number;\n readonly precision: number;\n};\n\n/** Builds a finite JavaScript-number decimal definition. Precision is at most 15. */\nexport function decimal(options: DecimalOptions): DecimalDefinition;\nexport function decimal(options: unknown): DecimalDefinition {\n const issues = validateDecimalDefinition(options);\n assertValidGeneratorOptions(issues);\n const definition = options as DecimalOptions;\n return createGeneratorDefinition({\n type: \"decimal\",\n ...definition,\n }) as DecimalDefinition;\n}\n\nexport const decimalGenerator: GeneratorImplementation<\n DecimalDefinition,\n number\n> = defineGenerator({\n type: \"decimal\",\n version: 1,\n validateDefinition: validateDecimalDefinition,\n generate({ definition, context }) {\n const value =\n definition.min +\n context.random.float() * (definition.max - definition.min);\n return Number(value.toFixed(definition.precision));\n },\n});\n\nexport function registerDecimalGenerator(registry: GeneratorRegistry): void {\n registry.register(decimalGenerator);\n}\n\nexport type StringCharset = keyof typeof STRING_CHARSETS | string;\nexport type StringOptions = {\n readonly length: number;\n readonly charset?: StringCharset;\n};\n\nexport type StringDefinition = GeneratorDefinition<string> & {\n readonly type: \"string\";\n readonly length: number;\n readonly charset: string;\n};\n\n/** Builds a random-character string definition. The default charset is alphanumeric. */\nexport function string(options: StringOptions): StringDefinition;\nexport function string(options: unknown): StringDefinition {\n const normalized = normalizeStringOptions(options);\n const issues = validateStringDefinition(normalized);\n assertValidGeneratorOptions(issues);\n const definition = normalized as StringOptions & { readonly charset: string };\n return createGeneratorDefinition({\n type: \"string\",\n ...definition,\n }) as StringDefinition;\n}\n\nexport const stringGenerator: GeneratorImplementation<\n StringDefinition,\n string\n> = defineGenerator({\n type: \"string\",\n version: 1,\n validateDefinition: validateStringDefinition,\n generate({ definition, context }) {\n const characters = Array.from(resolveCharset(definition.charset));\n let result = \"\";\n for (let index = 0; index < definition.length; index += 1) {\n result += characters[context.random.integer(characters.length)];\n }\n return result;\n },\n});\n\nexport function registerStringGenerator(registry: GeneratorRegistry): void {\n registry.register(stringGenerator);\n}\n\nexport type DateOptions = {\n readonly min: string;\n readonly max: string;\n};\n\nexport type DateDefinition = GeneratorDefinition<string> & {\n readonly type: \"date\";\n readonly min: string;\n readonly max: string;\n};\n\n/** Builds an inclusive timezone-independent ISO calendar-date definition. */\nexport function date(options: DateOptions): DateDefinition;\nexport function date(options: unknown): DateDefinition {\n const issues = validateDateDefinition(options);\n assertValidGeneratorOptions(issues);\n const definition = options as DateOptions;\n return createGeneratorDefinition({\n type: \"date\",\n ...definition,\n }) as DateDefinition;\n}\n\nexport const dateGenerator: GeneratorImplementation<DateDefinition, string> =\n defineGenerator({\n type: \"date\",\n version: 1,\n validateDefinition: validateDateDefinition,\n generate({ definition, context }) {\n const minimum = isoDateToDay(definition.min);\n const maximum = isoDateToDay(definition.max);\n return dayToIsoDate(\n minimum + context.random.integer(maximum - minimum + 1),\n );\n },\n });\n\nexport function registerDateGenerator(registry: GeneratorRegistry): void {\n registry.register(dateGenerator);\n}\n\nexport type IntegerOptions = {\n readonly min: number;\n readonly max: number;\n};\n\nexport type BooleanDefinition = GeneratorDefinition<boolean> & {\n readonly type: \"boolean\";\n};\n\n/** Builds a portable, evenly distributed boolean definition. */\nexport function boolean(): BooleanDefinition {\n return createGeneratorDefinition({ type: \"boolean\" }) as BooleanDefinition;\n}\n\n/** Trusted implementation for the portable `boolean` definition. */\nexport const booleanGenerator: GeneratorImplementation<\n BooleanDefinition,\n boolean\n> = defineGenerator({\n type: \"boolean\",\n version: 1,\n validateDefinition: validateBooleanDefinition,\n generate({ context }) {\n return context.random.integer(2) === 1;\n },\n});\n\n/** Registers the boolean built-in with an advanced custom registry. */\nexport function registerBooleanGenerator(registry: GeneratorRegistry): void {\n registry.register(booleanGenerator);\n}\n\nexport type IntegerDefinition = GeneratorDefinition<number> & {\n readonly type: \"integer\";\n readonly min: number;\n readonly max: number;\n};\n\n/** Builds a portable integer definition with inclusive minimum and maximum bounds. */\nexport function integer(options: IntegerOptions): IntegerDefinition;\nexport function integer(options: unknown): IntegerDefinition {\n const issues = validateIntegerDefinition(options);\n const issue = issues[0];\n if (issue !== undefined) {\n throw new ConstructaError({\n kind: \"configuration\",\n code: \"INVALID_RANGE\",\n path: issue.path,\n message: issue.message,\n details: { issueCode: issue.code },\n });\n }\n const definition = options as IntegerOptions;\n return createGeneratorDefinition({\n type: \"integer\",\n min: definition.min,\n max: definition.max,\n }) as IntegerDefinition;\n}\n\n/** Trusted implementation for the portable `integer` definition. */\nexport const integerGenerator: GeneratorImplementation<\n IntegerDefinition,\n number\n> = defineGenerator({\n type: \"integer\",\n version: 1,\n validateDefinition: validateIntegerDefinition,\n generate({ definition, context }) {\n const rangeSize = definition.max - definition.min + 1;\n return definition.min + context.random.integer(rangeSize);\n },\n});\n\n/** Registers the integer built-in with an advanced custom registry. */\nexport function registerIntegerGenerator(registry: GeneratorRegistry): void {\n registry.register(integerGenerator);\n}\n\nfunction validateIntegerDefinition(value: unknown): readonly ValidationIssue[] {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return [invalidRange([], \"integer definition must be an object\")];\n }\n\n const definition = value as {\n readonly min?: unknown;\n readonly max?: unknown;\n };\n const issues: ValidationIssue[] = [];\n if (!Number.isSafeInteger(definition.min)) {\n issues.push(invalidRange([\"min\"], \"min must be a safe integer\"));\n }\n if (!Number.isSafeInteger(definition.max)) {\n issues.push(invalidRange([\"max\"], \"max must be a safe integer\"));\n }\n if (issues.length > 0) return issues;\n\n const min = definition.min as number;\n const max = definition.max as number;\n if (min > max) {\n return [invalidRange([\"min\"], \"min must be less than or equal to max\")];\n }\n if (!Number.isSafeInteger(max - min + 1)) {\n return [\n invalidRange(\n [\"max\"],\n \"the inclusive integer range must fit within a safe integer\",\n ),\n ];\n }\n return [];\n}\n\nfunction validateUuidDefinition(value: unknown): readonly ValidationIssue[] {\n return validateExactDefinitionKeys(value, \"uuid\", []);\n}\n\nfunction validateObjectDefinition(value: unknown): readonly ValidationIssue[] {\n const keyIssues = validateExactDefinitionKeys(value, \"object\", [\"fields\"]);\n if (keyIssues.length > 0) return keyIssues;\n\n const fields = (value as { readonly fields?: unknown }).fields;\n if (!isDefinitionRecord(fields)) {\n return [invalidConfiguration([\"fields\"], \"fields must be an object\")];\n }\n\n const issues: ValidationIssue[] = [];\n for (const [key, child] of Object.entries(fields)) {\n for (const issue of validateGeneratorDefinition(child)) {\n issues.push({ ...issue, path: [\"fields\", key, ...issue.path] });\n }\n }\n return issues;\n}\n\nfunction validateArrayDefinition(value: unknown): readonly ValidationIssue[] {\n const keyIssues = validateExactDefinitionKeys(value, \"array\", [\n \"item\",\n \"length\",\n ]);\n if (keyIssues.length > 0) return keyIssues;\n\n const definition = value as {\n readonly item?: unknown;\n readonly length?: unknown;\n };\n const issues: ValidationIssue[] = [];\n for (const issue of validateGeneratorDefinition(definition.item)) {\n issues.push({ ...issue, path: [\"item\", ...issue.path] });\n }\n if (\n !Number.isSafeInteger(definition.length) ||\n (definition.length as number) < 0 ||\n (definition.length as number) > MAX_ARRAY_LENGTH\n ) {\n issues.push(\n invalidLength(\n [\"length\"],\n `length must be an integer from 0 to ${MAX_ARRAY_LENGTH}`,\n ),\n );\n }\n return issues;\n}\n\nfunction validateExactDefinitionKeys(\n value: unknown,\n type: string,\n keys: readonly string[],\n): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidConfiguration([], `${type} definition must be an object`)];\n }\n const definition = value as { readonly type?: unknown };\n if (definition.type !== type) {\n return [invalidConfiguration([\"type\"], `type must be ${type}`)];\n }\n const allowed = new Set([\"type\", ...keys]);\n return Object.keys(value)\n .filter((key) => !allowed.has(key))\n .map((key) =>\n invalidConfiguration([key], `Unknown ${type} property: ${key}`),\n );\n}\n\nfunction validateBooleanDefinition(value: unknown): readonly ValidationIssue[] {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return [\n {\n code: \"invalid_boolean_definition\",\n path: [],\n message: \"boolean definition must be an object\",\n },\n ];\n }\n return Object.keys(value)\n .filter((key) => key !== \"type\")\n .map((key) => ({\n code: \"unknown_property\",\n path: [key],\n message: `Unknown boolean property: ${key}`,\n }));\n}\n\nfunction validateChoiceDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value) || !Array.isArray(value.values)) {\n return [\n invalidConfiguration([], \"choice definition must contain a values array\"),\n ];\n }\n if (value.values.length === 0) {\n return [\n {\n code: \"empty_choice\",\n path: [\"values\"],\n message: \"values must not be empty\",\n },\n ];\n }\n const issues: ValidationIssue[] = [];\n for (let index = 0; index < value.values.length; index += 1) {\n for (const issue of validateJsonValue(value.values[index])) {\n issues.push({ ...issue, path: [\"values\", index, ...issue.path] });\n }\n }\n return issues;\n}\n\nfunction validateDecimalDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidRange([], \"decimal definition must be an object\")];\n }\n const issues: ValidationIssue[] = [];\n if (!Number.isFinite(value.min))\n issues.push(invalidRange([\"min\"], \"min must be finite\"));\n if (!Number.isFinite(value.max))\n issues.push(invalidRange([\"max\"], \"max must be finite\"));\n if (\n !Number.isSafeInteger(value.precision) ||\n (value.precision as number) < 0 ||\n (value.precision as number) > MAX_DECIMAL_PRECISION\n ) {\n issues.push(\n invalidConfiguration(\n [\"precision\"],\n `precision must be an integer from 0 to ${MAX_DECIMAL_PRECISION}`,\n ),\n );\n }\n if (issues.length > 0) return issues;\n const min = value.min as number;\n const max = value.max as number;\n if (min > max || !Number.isFinite(max - min)) {\n return [\n invalidRange(\n [\"max\"],\n \"max must be greater than or equal to min within a finite range\",\n ),\n ];\n }\n return [];\n}\n\nfunction normalizeStringOptions(value: unknown): unknown {\n if (!isDefinitionRecord(value)) return value;\n return { ...value, charset: value.charset ?? \"alphanumeric\" };\n}\n\nfunction validateStringDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidConfiguration([], \"string definition must be an object\")];\n }\n const issues: ValidationIssue[] = [];\n if (\n !Number.isSafeInteger(value.length) ||\n (value.length as number) < 0 ||\n (value.length as number) > MAX_STRING_LENGTH\n ) {\n issues.push(\n invalidLength(\n [\"length\"],\n `length must be an integer from 0 to ${MAX_STRING_LENGTH}`,\n ),\n );\n }\n if (\n typeof value.charset !== \"string\" ||\n Array.from(resolveCharset(value.charset)).length === 0\n ) {\n issues.push(\n invalidConfiguration([\"charset\"], \"charset must be a non-empty string\"),\n );\n }\n return issues;\n}\n\nfunction validateDateDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidRange([], \"date definition must be an object\")];\n }\n const issues: ValidationIssue[] = [];\n if (typeof value.min !== \"string\" || !isCanonicalIsoDate(value.min)) {\n issues.push(\n invalidRange([\"min\"], \"min must be a canonical ISO calendar date\"),\n );\n }\n if (typeof value.max !== \"string\" || !isCanonicalIsoDate(value.max)) {\n issues.push(\n invalidRange([\"max\"], \"max must be a canonical ISO calendar date\"),\n );\n }\n if (issues.length > 0) return issues;\n if (isoDateToDay(value.min as string) > isoDateToDay(value.max as string)) {\n return [invalidRange([\"min\"], \"min must be on or before max\")];\n }\n return [];\n}\n\nfunction assertValidGeneratorOptions(issues: readonly ValidationIssue[]): void {\n const issue = issues[0];\n if (issue === undefined) return;\n const codes: Record<string, Uppercase<string>> = {\n empty_choice: \"EMPTY_CHOICE\",\n invalid_length: \"INVALID_LENGTH\",\n invalid_range: \"INVALID_RANGE\",\n };\n throw new ConstructaError({\n kind: \"configuration\",\n code: codes[issue.code] ?? \"INVALID_CONFIGURATION\",\n path: issue.path,\n message: issue.message,\n details: { issueCode: issue.code },\n });\n}\n\nfunction isDefinitionRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction resolveCharset(charset: string): string {\n return STRING_CHARSETS[charset as keyof typeof STRING_CHARSETS] ?? charset;\n}\n\nfunction formatUuid(bytes: Uint8Array): string {\n const hexadecimal = Array.from(bytes, (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n );\n return `${hexadecimal.slice(0, 4).join(\"\")}-${hexadecimal.slice(4, 6).join(\"\")}-${hexadecimal.slice(6, 8).join(\"\")}-${hexadecimal.slice(8, 10).join(\"\")}-${hexadecimal.slice(10, 16).join(\"\")}`;\n}\n\nfunction isCanonicalIsoDate(value: string): boolean {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/u.test(value)) return false;\n const day = isoDateToDay(value);\n return Number.isFinite(day) && dayToIsoDate(day) === value;\n}\n\nfunction isoDateToDay(value: string): number {\n const [year, month, day] = value.split(\"-\").map(Number);\n const date = new Date(0);\n date.setUTCFullYear(year as number, (month as number) - 1, day as number);\n date.setUTCHours(0, 0, 0, 0);\n return date.getTime() / 86_400_000;\n}\n\nfunction dayToIsoDate(day: number): string {\n return new Date(day * 86_400_000).toISOString().slice(0, 10);\n}\n\nfunction invalidLength(\n path: readonly (string | number)[],\n message: string,\n): ValidationIssue {\n return { code: \"invalid_length\", path, message };\n}\n\nfunction invalidConfiguration(\n path: readonly (string | number)[],\n message: string,\n): ValidationIssue {\n return { code: \"invalid_configuration\", path, message };\n}\n\nfunction invalidRange(\n path: readonly (string | number)[],\n message: string,\n): ValidationIssue {\n return { code: \"invalid_range\", path, message };\n}\n"],"mappings":";;;AAiBA,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;AACjC,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;CACtB,YAAY;CACZ,SAAS;CACT,cACE;CACF,KAAK;AACP;;AAOA,SAAgB,OAAuB;CACrC,OAAO,0BAA0B,EAAE,MAAM,OAAO,CAAC;AACnD;AAEA,MAAa,gBACX,gBAAgB;CACd,MAAM;CACN,SAAS;CACT,oBAAoB;CACpB,SAAS,EAAE,WAAW;EACpB,MAAM,QAAQ,QAAQ,OAAO,MAAM,EAAE;EACrC,MAAM,MAAO,MAAM,MAAM,KAAK,KAAQ;EACtC,MAAM,MAAO,MAA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AC,uBAAuB,KAAK,KAAK,GAAG,OAAO;CAChD,MAAM,MAAM,aAAa,KAAK;CAC9B,OAAO,OAAO,SAAS,GAAG,KAAK,aAAa,GAAG,MAAM;AACvD;AAEA,SAAS,aAAa,OAAuB;CAC3C,MAAM,CAAC,MAAM,OAAO,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtD,MAAM,uBAAO,IAAI,KAAK,CAAC;CACvB,KAAK,eAAe,MAAiB,QAAmB,GAAG,GAAa;CACxE,KAAK,YAAY,GAAG,GAAG,GAAG,CAAC;CAC3B,OAAO,KAAK,QAAQ,IAAI;AAC1B;AAEA,SAAS,aAAa,KAAqB;CACzC,wBAAO,IAAI,KAAK,MAAM,KAAU,EAAA,CAAE,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE;AAC7D;AAEA,SAAS,cACP,MACA,SACiB;CACjB,OAAO;EAAE,MAAM;EAAkB;EAAM;CAAQ;AACjD;AAEA,SAAS,qBACP,MACA,SACiB;CACjB,OAAO;EAAE,MAAM;EAAyB;EAAM;CAAQ;AACxD;AAEA,SAAS,aACP,MACA,SACiB;CACjB,OAAO;EAAE,MAAM;EAAiB;EAAM;CAAQ;AAChD"}
1
+ {"version":3,"file":"index.js","names":["definition"],"sources":["../src/index.ts"],"sourcesContent":["import {\n createCompositeDependencyAnalysis,\n createGeneratorDefinition,\n defineGenerator,\n type GeneratorDefinition,\n type GeneratorImplementation,\n type GeneratorRegistry,\n parseTemplateTokens,\n scheduleCompositeDependencies,\n type ValidationIssue,\n} from \"constructa-core\";\nimport {\n ConstructaError,\n type JsonValue,\n validateGeneratorDefinition,\n validateJsonValue,\n} from \"constructa-schema\";\n\nexport const MAX_DECIMAL_PRECISION = 15;\nexport const MAX_STRING_LENGTH = 10_000;\nexport const MAX_ARRAY_LENGTH = 10_000;\n\nconst STRING_CHARSETS = {\n alphabetic: \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\",\n numeric: \"0123456789\",\n alphanumeric:\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\",\n hex: \"0123456789abcdef\",\n} as const;\n\nexport type UuidDefinition = GeneratorDefinition<string> & {\n readonly type: \"uuid\";\n};\n\n/** Builds a portable UUID version 4 definition. */\nexport function uuid(): UuidDefinition {\n return createGeneratorDefinition({ type: \"uuid\" }) as UuidDefinition;\n}\n\nexport const uuidGenerator: GeneratorImplementation<UuidDefinition, string> =\n defineGenerator({\n type: \"uuid\",\n version: 1,\n validateDefinition: validateUuidDefinition,\n generate({ context }) {\n const bytes = context.random.bytes(16);\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n return formatUuid(bytes);\n },\n });\n\nexport function registerUuidGenerator(registry: GeneratorRegistry): void {\n registry.register(uuidGenerator);\n}\n\nexport type ObjectFields = Readonly<Record<string, GeneratorDefinition>>;\nexport type ObjectOutput<Fields extends ObjectFields> = {\n [Key in keyof Fields]: InferGenerator<Fields[Key]>;\n};\nexport type ObjectDefinition<Fields extends ObjectFields = ObjectFields> =\n GeneratorDefinition<ObjectOutput<Fields>> & {\n readonly type: \"object\";\n readonly fields: Fields;\n };\n\ntype InferGenerator<Definition> =\n Definition extends GeneratorDefinition<infer Output> ? Output : never;\n\n/** Builds a composite object definition from named child definitions. */\nexport function object<const Fields extends ObjectFields>(\n fields: Fields,\n): ObjectDefinition<Fields>;\nexport function object(fields: unknown): ObjectDefinition {\n const issues = validateObjectDefinition({ type: \"object\", fields });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"object\",\n fields: fields as ObjectFields,\n }) as ObjectDefinition;\n}\n\nexport const objectGenerator: GeneratorImplementation<\n ObjectDefinition,\n Record<string, unknown>\n> = defineGenerator({\n type: \"object\",\n version: 1,\n validateDefinition: validateObjectDefinition,\n generate({ definition, context }) {\n const fields = Object.entries(definition.fields);\n const children = new Map(fields);\n const completed = new Map<string, unknown>();\n const dependencies = createCompositeDependencyAnalysis(\n fields.map(([key, child]) => ({\n fieldPath: [key] as const,\n dependencies: context.analyzeChildValueDependencies(child, key),\n })),\n );\n const scope = context.createObjectScope();\n for (const key of scheduleCompositeDependencies(dependencies, {\n referencePaths: collectObjectReferencePaths(definition.fields),\n })) {\n const child = children.get(key);\n if (child === undefined) continue;\n completed.set(key, scope.executeChild(child, key));\n }\n const result: Record<string, unknown> = {};\n for (const [key] of fields) {\n Object.defineProperty(result, key, {\n value: completed.get(key),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n return result;\n },\n});\n\nexport function registerObjectGenerator(registry: GeneratorRegistry): void {\n registry.register(objectGenerator);\n}\n\nexport type TemplateDefinition = GeneratorDefinition<string> & {\n readonly type: \"template\";\n readonly source: string;\n};\n\n/** Builds a string template with object-local `{field}` references. */\nexport function template(source: string): TemplateDefinition;\nexport function template(source: unknown): TemplateDefinition {\n const issues = validateTemplateDefinition({ type: \"template\", source });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"template\",\n source: source as string,\n }) as TemplateDefinition;\n}\n\nexport const templateGenerator: GeneratorImplementation<\n TemplateDefinition,\n string\n> = defineGenerator({\n type: \"template\",\n version: 1,\n validateDefinition: validateTemplateDefinition,\n analyzeValueDependencies({ source }) {\n return parseTemplateTokens(source, { path: [\"source\"] })\n .filter((token) => token.type === \"reference\")\n .map((token) => ({ path: token.path }));\n },\n generate({ definition, context }) {\n return parseTemplateTokens(definition.source, { path: [\"source\"] })\n .map((token) => {\n if (token.type === \"literal\") return token.value;\n return stringifyTemplateValue(\n context.references.resolve(token.path),\n context.path,\n );\n })\n .join(\"\");\n },\n});\n\nexport function registerTemplateGenerator(registry: GeneratorRegistry): void {\n registry.register(templateGenerator);\n}\n\nexport type ArrayOptions = {\n readonly length: number;\n};\nexport type ArrayDefinition<\n Item extends GeneratorDefinition = GeneratorDefinition,\n> = GeneratorDefinition<InferGenerator<Item>[]> & {\n readonly type: \"array\";\n readonly item: Item;\n readonly length: number;\n};\n\n/** Builds a fixed-length composite array definition. */\nexport function array<const Item extends GeneratorDefinition>(\n item: Item,\n options: ArrayOptions,\n): ArrayDefinition<Item>;\nexport function array(item: unknown, options: unknown): ArrayDefinition {\n const issues = validateArrayDefinition({\n type: \"array\",\n item,\n ...(isDefinitionRecord(options) ? options : { length: undefined }),\n });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"array\",\n item: item as GeneratorDefinition,\n length: (options as ArrayOptions).length,\n }) as ArrayDefinition;\n}\n\nexport const arrayGenerator: GeneratorImplementation<\n ArrayDefinition,\n unknown[]\n> = defineGenerator({\n type: \"array\",\n version: 1,\n validateDefinition: validateArrayDefinition,\n generate({ definition, context }) {\n const result: unknown[] = [];\n for (let index = 0; index < definition.length; index += 1) {\n result.push(context.executeChild(definition.item, index));\n }\n return result;\n },\n});\n\nexport function registerArrayGenerator(registry: GeneratorRegistry): void {\n registry.register(arrayGenerator);\n}\n\nexport type ChoiceDefinition<Value extends JsonValue = JsonValue> =\n GeneratorDefinition<Value> & {\n readonly type: \"choice\";\n readonly values: readonly Value[];\n };\n\n/** Builds a portable choice definition while preserving array-literal unions. */\nexport function choice<const Values extends readonly JsonValue[]>(\n values: Values,\n): ChoiceDefinition<Values[number]> {\n const issues = validateChoiceDefinition({ type: \"choice\", values });\n assertValidGeneratorOptions(issues);\n return createGeneratorDefinition({\n type: \"choice\",\n values,\n }) as ChoiceDefinition<Values[number]>;\n}\n\nexport const choiceGenerator: GeneratorImplementation<\n ChoiceDefinition,\n JsonValue\n> = defineGenerator({\n type: \"choice\",\n version: 1,\n validateDefinition: validateChoiceDefinition,\n generate({ definition, context }) {\n return definition.values[\n context.random.integer(definition.values.length)\n ] as JsonValue;\n },\n});\n\nexport function registerChoiceGenerator(registry: GeneratorRegistry): void {\n registry.register(choiceGenerator);\n}\n\nexport type DecimalOptions = {\n readonly min: number;\n readonly max: number;\n readonly precision: number;\n};\n\nexport type DecimalDefinition = GeneratorDefinition<number> & {\n readonly type: \"decimal\";\n readonly min: number;\n readonly max: number;\n readonly precision: number;\n};\n\n/** Builds a finite JavaScript-number decimal definition. Precision is at most 15. */\nexport function decimal(options: DecimalOptions): DecimalDefinition;\nexport function decimal(options: unknown): DecimalDefinition {\n const issues = validateDecimalDefinition(options);\n assertValidGeneratorOptions(issues);\n const definition = options as DecimalOptions;\n return createGeneratorDefinition({\n type: \"decimal\",\n ...definition,\n }) as DecimalDefinition;\n}\n\nexport const decimalGenerator: GeneratorImplementation<\n DecimalDefinition,\n number\n> = defineGenerator({\n type: \"decimal\",\n version: 1,\n validateDefinition: validateDecimalDefinition,\n generate({ definition, context }) {\n const value =\n definition.min +\n context.random.float() * (definition.max - definition.min);\n return Number(value.toFixed(definition.precision));\n },\n});\n\nexport function registerDecimalGenerator(registry: GeneratorRegistry): void {\n registry.register(decimalGenerator);\n}\n\nexport type StringCharset = keyof typeof STRING_CHARSETS | string;\nexport type StringOptions = {\n readonly length: number;\n readonly charset?: StringCharset;\n};\n\nexport type StringDefinition = GeneratorDefinition<string> & {\n readonly type: \"string\";\n readonly length: number;\n readonly charset: string;\n};\n\n/** Builds a random-character string definition. The default charset is alphanumeric. */\nexport function string(options: StringOptions): StringDefinition;\nexport function string(options: unknown): StringDefinition {\n const normalized = normalizeStringOptions(options);\n const issues = validateStringDefinition(normalized);\n assertValidGeneratorOptions(issues);\n const definition = normalized as StringOptions & { readonly charset: string };\n return createGeneratorDefinition({\n type: \"string\",\n ...definition,\n }) as StringDefinition;\n}\n\nexport const stringGenerator: GeneratorImplementation<\n StringDefinition,\n string\n> = defineGenerator({\n type: \"string\",\n version: 1,\n validateDefinition: validateStringDefinition,\n generate({ definition, context }) {\n const characters = Array.from(resolveCharset(definition.charset));\n let result = \"\";\n for (let index = 0; index < definition.length; index += 1) {\n result += characters[context.random.integer(characters.length)];\n }\n return result;\n },\n});\n\nexport function registerStringGenerator(registry: GeneratorRegistry): void {\n registry.register(stringGenerator);\n}\n\nexport type DateOptions = {\n readonly min: string;\n readonly max: string;\n};\n\nexport type DateDefinition = GeneratorDefinition<string> & {\n readonly type: \"date\";\n readonly min: string;\n readonly max: string;\n};\n\n/** Builds an inclusive timezone-independent ISO calendar-date definition. */\nexport function date(options: DateOptions): DateDefinition;\nexport function date(options: unknown): DateDefinition {\n const issues = validateDateDefinition(options);\n assertValidGeneratorOptions(issues);\n const definition = options as DateOptions;\n return createGeneratorDefinition({\n type: \"date\",\n ...definition,\n }) as DateDefinition;\n}\n\nexport const dateGenerator: GeneratorImplementation<DateDefinition, string> =\n defineGenerator({\n type: \"date\",\n version: 1,\n validateDefinition: validateDateDefinition,\n generate({ definition, context }) {\n const minimum = isoDateToDay(definition.min);\n const maximum = isoDateToDay(definition.max);\n return dayToIsoDate(\n minimum + context.random.integer(maximum - minimum + 1),\n );\n },\n });\n\nexport function registerDateGenerator(registry: GeneratorRegistry): void {\n registry.register(dateGenerator);\n}\n\nexport type IntegerOptions = {\n readonly min: number;\n readonly max: number;\n};\n\nexport type BooleanDefinition = GeneratorDefinition<boolean> & {\n readonly type: \"boolean\";\n};\n\n/** Builds a portable, evenly distributed boolean definition. */\nexport function boolean(): BooleanDefinition {\n return createGeneratorDefinition({ type: \"boolean\" }) as BooleanDefinition;\n}\n\n/** Trusted implementation for the portable `boolean` definition. */\nexport const booleanGenerator: GeneratorImplementation<\n BooleanDefinition,\n boolean\n> = defineGenerator({\n type: \"boolean\",\n version: 1,\n validateDefinition: validateBooleanDefinition,\n generate({ context }) {\n return context.random.integer(2) === 1;\n },\n});\n\n/** Registers the boolean built-in with an advanced custom registry. */\nexport function registerBooleanGenerator(registry: GeneratorRegistry): void {\n registry.register(booleanGenerator);\n}\n\nexport type IntegerDefinition = GeneratorDefinition<number> & {\n readonly type: \"integer\";\n readonly min: number;\n readonly max: number;\n};\n\n/** Builds a portable integer definition with inclusive minimum and maximum bounds. */\nexport function integer(options: IntegerOptions): IntegerDefinition;\nexport function integer(options: unknown): IntegerDefinition {\n const issues = validateIntegerDefinition(options);\n const issue = issues[0];\n if (issue !== undefined) {\n throw new ConstructaError({\n kind: \"configuration\",\n code: \"INVALID_RANGE\",\n path: issue.path,\n message: issue.message,\n details: { issueCode: issue.code },\n });\n }\n const definition = options as IntegerOptions;\n return createGeneratorDefinition({\n type: \"integer\",\n min: definition.min,\n max: definition.max,\n }) as IntegerDefinition;\n}\n\n/** Trusted implementation for the portable `integer` definition. */\nexport const integerGenerator: GeneratorImplementation<\n IntegerDefinition,\n number\n> = defineGenerator({\n type: \"integer\",\n version: 1,\n validateDefinition: validateIntegerDefinition,\n generate({ definition, context }) {\n const rangeSize = definition.max - definition.min + 1;\n return definition.min + context.random.integer(rangeSize);\n },\n});\n\n/** Registers the integer built-in with an advanced custom registry. */\nexport function registerIntegerGenerator(registry: GeneratorRegistry): void {\n registry.register(integerGenerator);\n}\n\nfunction validateIntegerDefinition(value: unknown): readonly ValidationIssue[] {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return [invalidRange([], \"integer definition must be an object\")];\n }\n\n const definition = value as {\n readonly min?: unknown;\n readonly max?: unknown;\n };\n const issues: ValidationIssue[] = [];\n if (!Number.isSafeInteger(definition.min)) {\n issues.push(invalidRange([\"min\"], \"min must be a safe integer\"));\n }\n if (!Number.isSafeInteger(definition.max)) {\n issues.push(invalidRange([\"max\"], \"max must be a safe integer\"));\n }\n if (issues.length > 0) return issues;\n\n const min = definition.min as number;\n const max = definition.max as number;\n if (min > max) {\n return [invalidRange([\"min\"], \"min must be less than or equal to max\")];\n }\n if (!Number.isSafeInteger(max - min + 1)) {\n return [\n invalidRange(\n [\"max\"],\n \"the inclusive integer range must fit within a safe integer\",\n ),\n ];\n }\n return [];\n}\n\nfunction validateUuidDefinition(value: unknown): readonly ValidationIssue[] {\n return validateExactDefinitionKeys(value, \"uuid\", []);\n}\n\nfunction validateObjectDefinition(value: unknown): readonly ValidationIssue[] {\n const keyIssues = validateExactDefinitionKeys(value, \"object\", [\"fields\"]);\n if (keyIssues.length > 0) return keyIssues;\n\n const fields = (value as { readonly fields?: unknown }).fields;\n if (!isDefinitionRecord(fields)) {\n return [invalidConfiguration([\"fields\"], \"fields must be an object\")];\n }\n\n const issues: ValidationIssue[] = [];\n for (const [key, child] of Object.entries(fields)) {\n for (const issue of validateGeneratorDefinition(child)) {\n issues.push({ ...issue, path: [\"fields\", key, ...issue.path] });\n }\n }\n return issues;\n}\n\nfunction validateTemplateDefinition(\n value: unknown,\n): readonly ValidationIssue[] {\n const keyIssues = validateExactDefinitionKeys(value, \"template\", [\"source\"]);\n if (keyIssues.length > 0) return keyIssues;\n const source = (value as { readonly source?: unknown }).source;\n if (typeof source !== \"string\") {\n return [invalidConfiguration([\"source\"], \"source must be a string\")];\n }\n try {\n parseTemplateTokens(source, { path: [\"source\"] });\n } catch (cause) {\n if (cause instanceof ConstructaError) {\n return [\n {\n code: \"invalid_template_token\",\n path: cause.path,\n message: cause.message,\n },\n ];\n }\n throw cause;\n }\n return [];\n}\n\nfunction collectObjectReferencePaths(\n fields: ObjectFields,\n): readonly string[][] {\n const paths: string[][] = [];\n const visit = (definitions: ObjectFields, prefix: readonly string[]) => {\n for (const [key, definition] of Object.entries(definitions)) {\n const path = [...prefix, key];\n paths.push(path);\n const nestedFields = (definition as { readonly fields?: unknown }).fields;\n if (definition.type === \"object\" && isDefinitionRecord(nestedFields)) {\n visit(nestedFields as ObjectFields, path);\n }\n }\n };\n visit(fields, []);\n return paths;\n}\n\nfunction validateArrayDefinition(value: unknown): readonly ValidationIssue[] {\n const keyIssues = validateExactDefinitionKeys(value, \"array\", [\n \"item\",\n \"length\",\n ]);\n if (keyIssues.length > 0) return keyIssues;\n\n const definition = value as {\n readonly item?: unknown;\n readonly length?: unknown;\n };\n const issues: ValidationIssue[] = [];\n for (const issue of validateGeneratorDefinition(definition.item)) {\n issues.push({ ...issue, path: [\"item\", ...issue.path] });\n }\n if (\n !Number.isSafeInteger(definition.length) ||\n (definition.length as number) < 0 ||\n (definition.length as number) > MAX_ARRAY_LENGTH\n ) {\n issues.push(\n invalidLength(\n [\"length\"],\n `length must be an integer from 0 to ${MAX_ARRAY_LENGTH}`,\n ),\n );\n }\n return issues;\n}\n\nfunction validateExactDefinitionKeys(\n value: unknown,\n type: string,\n keys: readonly string[],\n): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidConfiguration([], `${type} definition must be an object`)];\n }\n const definition = value as { readonly type?: unknown };\n if (definition.type !== type) {\n return [invalidConfiguration([\"type\"], `type must be ${type}`)];\n }\n const allowed = new Set([\"type\", ...keys]);\n return Object.keys(value)\n .filter((key) => !allowed.has(key))\n .map((key) =>\n invalidConfiguration([key], `Unknown ${type} property: ${key}`),\n );\n}\n\nfunction validateBooleanDefinition(value: unknown): readonly ValidationIssue[] {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return [\n {\n code: \"invalid_boolean_definition\",\n path: [],\n message: \"boolean definition must be an object\",\n },\n ];\n }\n return Object.keys(value)\n .filter((key) => key !== \"type\")\n .map((key) => ({\n code: \"unknown_property\",\n path: [key],\n message: `Unknown boolean property: ${key}`,\n }));\n}\n\nfunction validateChoiceDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value) || !Array.isArray(value.values)) {\n return [\n invalidConfiguration([], \"choice definition must contain a values array\"),\n ];\n }\n if (value.values.length === 0) {\n return [\n {\n code: \"empty_choice\",\n path: [\"values\"],\n message: \"values must not be empty\",\n },\n ];\n }\n const issues: ValidationIssue[] = [];\n for (let index = 0; index < value.values.length; index += 1) {\n for (const issue of validateJsonValue(value.values[index])) {\n issues.push({ ...issue, path: [\"values\", index, ...issue.path] });\n }\n }\n return issues;\n}\n\nfunction validateDecimalDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidRange([], \"decimal definition must be an object\")];\n }\n const issues: ValidationIssue[] = [];\n if (!Number.isFinite(value.min))\n issues.push(invalidRange([\"min\"], \"min must be finite\"));\n if (!Number.isFinite(value.max))\n issues.push(invalidRange([\"max\"], \"max must be finite\"));\n if (\n !Number.isSafeInteger(value.precision) ||\n (value.precision as number) < 0 ||\n (value.precision as number) > MAX_DECIMAL_PRECISION\n ) {\n issues.push(\n invalidConfiguration(\n [\"precision\"],\n `precision must be an integer from 0 to ${MAX_DECIMAL_PRECISION}`,\n ),\n );\n }\n if (issues.length > 0) return issues;\n const min = value.min as number;\n const max = value.max as number;\n if (min > max || !Number.isFinite(max - min)) {\n return [\n invalidRange(\n [\"max\"],\n \"max must be greater than or equal to min within a finite range\",\n ),\n ];\n }\n return [];\n}\n\nfunction normalizeStringOptions(value: unknown): unknown {\n if (!isDefinitionRecord(value)) return value;\n return { ...value, charset: value.charset ?? \"alphanumeric\" };\n}\n\nfunction validateStringDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidConfiguration([], \"string definition must be an object\")];\n }\n const issues: ValidationIssue[] = [];\n if (\n !Number.isSafeInteger(value.length) ||\n (value.length as number) < 0 ||\n (value.length as number) > MAX_STRING_LENGTH\n ) {\n issues.push(\n invalidLength(\n [\"length\"],\n `length must be an integer from 0 to ${MAX_STRING_LENGTH}`,\n ),\n );\n }\n if (\n typeof value.charset !== \"string\" ||\n Array.from(resolveCharset(value.charset)).length === 0\n ) {\n issues.push(\n invalidConfiguration([\"charset\"], \"charset must be a non-empty string\"),\n );\n }\n return issues;\n}\n\nfunction validateDateDefinition(value: unknown): readonly ValidationIssue[] {\n if (!isDefinitionRecord(value)) {\n return [invalidRange([], \"date definition must be an object\")];\n }\n const issues: ValidationIssue[] = [];\n if (typeof value.min !== \"string\" || !isCanonicalIsoDate(value.min)) {\n issues.push(\n invalidRange([\"min\"], \"min must be a canonical ISO calendar date\"),\n );\n }\n if (typeof value.max !== \"string\" || !isCanonicalIsoDate(value.max)) {\n issues.push(\n invalidRange([\"max\"], \"max must be a canonical ISO calendar date\"),\n );\n }\n if (issues.length > 0) return issues;\n if (isoDateToDay(value.min as string) > isoDateToDay(value.max as string)) {\n return [invalidRange([\"min\"], \"min must be on or before max\")];\n }\n return [];\n}\n\nfunction assertValidGeneratorOptions(issues: readonly ValidationIssue[]): void {\n const issue = issues[0];\n if (issue === undefined) return;\n const codes: Record<string, Uppercase<string>> = {\n empty_choice: \"EMPTY_CHOICE\",\n invalid_length: \"INVALID_LENGTH\",\n invalid_range: \"INVALID_RANGE\",\n invalid_template_token: \"INVALID_TEMPLATE_TOKEN\",\n };\n throw new ConstructaError({\n kind: \"configuration\",\n code: codes[issue.code] ?? \"INVALID_CONFIGURATION\",\n path: issue.path,\n message: issue.message,\n details: { issueCode: issue.code },\n });\n}\n\nfunction stringifyTemplateValue(\n value: unknown,\n path: readonly (string | number)[],\n): string {\n if (\n typeof value === \"string\" ||\n typeof value === \"boolean\" ||\n value === null\n ) {\n return String(value);\n }\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n throw new ConstructaError({\n kind: \"dependency\",\n code: \"NON_SCALAR_REFERENCE\",\n path,\n message: \"Template references must resolve to a scalar value.\",\n });\n}\n\nfunction isDefinitionRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction resolveCharset(charset: string): string {\n return STRING_CHARSETS[charset as keyof typeof STRING_CHARSETS] ?? charset;\n}\n\nfunction formatUuid(bytes: Uint8Array): string {\n const hexadecimal = Array.from(bytes, (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n );\n return `${hexadecimal.slice(0, 4).join(\"\")}-${hexadecimal.slice(4, 6).join(\"\")}-${hexadecimal.slice(6, 8).join(\"\")}-${hexadecimal.slice(8, 10).join(\"\")}-${hexadecimal.slice(10, 16).join(\"\")}`;\n}\n\nfunction isCanonicalIsoDate(value: string): boolean {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/u.test(value)) return false;\n const day = isoDateToDay(value);\n return Number.isFinite(day) && dayToIsoDate(day) === value;\n}\n\nfunction isoDateToDay(value: string): number {\n const [year, month, day] = value.split(\"-\").map(Number);\n const date = new Date(0);\n date.setUTCFullYear(year as number, (month as number) - 1, day as number);\n date.setUTCHours(0, 0, 0, 0);\n return date.getTime() / 86_400_000;\n}\n\nfunction dayToIsoDate(day: number): string {\n return new Date(day * 86_400_000).toISOString().slice(0, 10);\n}\n\nfunction invalidLength(\n path: readonly (string | number)[],\n message: string,\n): ValidationIssue {\n return { code: \"invalid_length\", path, message };\n}\n\nfunction invalidConfiguration(\n path: readonly (string | number)[],\n message: string,\n): ValidationIssue {\n return { code: \"invalid_configuration\", path, message };\n}\n\nfunction invalidRange(\n path: readonly (string | number)[],\n message: string,\n): ValidationIssue {\n return { code: \"invalid_range\", path, message };\n}\n"],"mappings":";;;AAkBA,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;AACjC,MAAa,mBAAmB;AAEhC,MAAM,kBAAkB;CACtB,YAAY;CACZ,SAAS;CACT,cACE;CACF,KAAK;AACP;;AAOA,SAAgB,OAAuB;CACrC,OAAO,0BAA0B,EAAE,MAAM,OAAO,CAAC;AACnD;AAEA,MAAa,gBACX,gBAAgB;CACd,MAAM;CACN,SAAS;CACT,oBAAoB;CACpB,SAAS,EAAE,WAAW;EACpB,MAAM,QAAQ,QAAQ,OAAO,MAAM,EAAE;EACrC,MAAM,MAAO,MAAM,MAAM,KAAK,KAAQ;EACtC,MAAM,MAAO,MAAM,MAAM,KAAK,KAAQ;EACtC,OAAO,WAAW,KAAK;CACzB;AACF,CAAC;AAEH,SAAgB,sBAAsB,UAAmC;CACvE,SAAS,SAAS,aAAa;AACjC;AAmBA,SAAgB,OAAO,QAAmC;CAExD,4BADe,yBAAyB;EAAE,MAAM;EAAU;CAAO,CAChC,CAAC;CAClC,OAAO,0BAA0B;EAC/B,MAAM;EACE;CACV,CAAC;AACH;AAEA,MAAa,kBAGT,gBAAgB;CAClB,MAAM;CACN,SAAS;CACT,oBAAoB;CACpB,SAAS,EAAE,YAAY,WAAW;EAChC,MAAM,SAA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A,OAAO,GAAG,YAAY,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,YAAY,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,YAAY,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,YAAY,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE;AAC9L;AAEA,SAAS,mBAAmB,OAAwB;CAClD,IAAI,CAAC,uBAAuB,KAAK,KAAK,GAAG,OAAO;CAChD,MAAM,MAAM,aAAa,KAAK;CAC9B,OAAO,OAAO,SAAS,GAAG,KAAK,aAAa,GAAG,MAAM;AACvD;AAEA,SAAS,aAAa,OAAuB;CAC3C,MAAM,CAAC,MAAM,OAAO,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtD,MAAM,uBAAO,IAAI,KAAK,CAAC;CACvB,KAAK,eAAe,MAAiB,QAAmB,GAAG,GAAa;CACxE,KAAK,YAAY,GAAG,GAAG,GAAG,CAAC;CAC3B,OAAO,KAAK,QAAQ,IAAI;AAC1B;AAEA,SAAS,aAAa,KAAqB;CACzC,wBAAO,IAAI,KAAK,MAAM,KAAU,EAAA,CAAE,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE;AAC7D;AAEA,SAAS,cACP,MACA,SACiB;CACjB,OAAO;EAAE,MAAM;EAAkB;EAAM;CAAQ;AACjD;AAEA,SAAS,qBACP,MACA,SACiB;CACjB,OAAO;EAAE,MAAM;EAAyB;EAAM;CAAQ;AACxD;AAEA,SAAS,aACP,MACA,SACiB;CACjB,OAAO;EAAE,MAAM;EAAiB;EAAM;CAAQ;AAChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "constructa-generators",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "description": "Built-in primitive and composite generators for Constructa.",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "constructa-core": "0.7.0",
29
+ "constructa-core": "0.8.0",
30
30
  "constructa-schema": "2.2.0"
31
31
  },
32
32
  "devDependencies": {