@hegeldev/hegel 0.1.0 → 0.1.2

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.
Files changed (78) hide show
  1. package/dist/generators/combinators.d.ts +1 -1
  2. package/dist/generators/combinators.d.ts.map +1 -1
  3. package/dist/generators/combinators.js.map +1 -1
  4. package/dist/generators/strings.d.ts +2 -2
  5. package/dist/generators/strings.d.ts.map +1 -1
  6. package/package.json +7 -2
  7. package/dist/binary.d.ts +0 -27
  8. package/dist/binary.d.ts.map +0 -1
  9. package/dist/binary.js +0 -50
  10. package/dist/binary.js.map +0 -1
  11. package/dist/collections.d.ts +0 -114
  12. package/dist/collections.d.ts.map +0 -1
  13. package/dist/collections.js +0 -313
  14. package/dist/collections.js.map +0 -1
  15. package/dist/combinators.d.ts +0 -34
  16. package/dist/combinators.d.ts.map +0 -1
  17. package/dist/combinators.js +0 -152
  18. package/dist/combinators.js.map +0 -1
  19. package/dist/conformance.d.ts +0 -31
  20. package/dist/conformance.d.ts.map +0 -1
  21. package/dist/conformance.js +0 -60
  22. package/dist/conformance.js.map +0 -1
  23. package/dist/derive.d.ts +0 -225
  24. package/dist/derive.d.ts.map +0 -1
  25. package/dist/derive.js +0 -296
  26. package/dist/derive.js.map +0 -1
  27. package/dist/embedded.d.ts +0 -38
  28. package/dist/embedded.d.ts.map +0 -1
  29. package/dist/embedded.js +0 -237
  30. package/dist/embedded.js.map +0 -1
  31. package/dist/floats.d.ts +0 -57
  32. package/dist/floats.d.ts.map +0 -1
  33. package/dist/floats.js +0 -100
  34. package/dist/floats.js.map +0 -1
  35. package/dist/formats.d.ts +0 -62
  36. package/dist/formats.d.ts.map +0 -1
  37. package/dist/formats.js +0 -164
  38. package/dist/formats.js.map +0 -1
  39. package/dist/generator.d.ts +0 -80
  40. package/dist/generator.d.ts.map +0 -1
  41. package/dist/generator.js +0 -128
  42. package/dist/generator.js.map +0 -1
  43. package/dist/generators/primitives.d.ts +0 -138
  44. package/dist/generators/primitives.d.ts.map +0 -1
  45. package/dist/generators/primitives.js +0 -240
  46. package/dist/generators/primitives.js.map +0 -1
  47. package/dist/generators.d.ts +0 -408
  48. package/dist/generators.d.ts.map +0 -1
  49. package/dist/generators.js +0 -898
  50. package/dist/generators.js.map +0 -1
  51. package/dist/install.d.ts +0 -6
  52. package/dist/install.d.ts.map +0 -1
  53. package/dist/install.js +0 -91
  54. package/dist/install.js.map +0 -1
  55. package/dist/integers.d.ts +0 -37
  56. package/dist/integers.d.ts.map +0 -1
  57. package/dist/integers.js +0 -63
  58. package/dist/integers.js.map +0 -1
  59. package/dist/labels.d.ts +0 -21
  60. package/dist/labels.d.ts.map +0 -1
  61. package/dist/labels.js +0 -20
  62. package/dist/labels.js.map +0 -1
  63. package/dist/objects.d.ts +0 -39
  64. package/dist/objects.d.ts.map +0 -1
  65. package/dist/objects.js +0 -98
  66. package/dist/objects.js.map +0 -1
  67. package/dist/primitives.d.ts +0 -14
  68. package/dist/primitives.d.ts.map +0 -1
  69. package/dist/primitives.js +0 -51
  70. package/dist/primitives.js.map +0 -1
  71. package/dist/spans.d.ts +0 -23
  72. package/dist/spans.d.ts.map +0 -1
  73. package/dist/spans.js +0 -51
  74. package/dist/spans.js.map +0 -1
  75. package/dist/strings.d.ts +0 -67
  76. package/dist/strings.d.ts.map +0 -1
  77. package/dist/strings.js +0 -107
  78. package/dist/strings.js.map +0 -1
package/dist/floats.js DELETED
@@ -1,100 +0,0 @@
1
- import { generateFromSchema } from "./connection.js";
2
- import { BaseGenerator } from "./generator.js";
3
- /**
4
- * Generator for floating-point values with builder pattern.
5
- */
6
- export class FloatGenerator extends BaseGenerator {
7
- _min;
8
- _max;
9
- _excludeMin;
10
- _excludeMax;
11
- _allowNan;
12
- _allowInfinity;
13
- constructor(_min, _max, _excludeMin = false, _excludeMax = false, _allowNan = true, _allowInfinity = true) {
14
- super();
15
- this._min = _min;
16
- this._max = _max;
17
- this._excludeMin = _excludeMin;
18
- this._excludeMax = _excludeMax;
19
- this._allowNan = _allowNan;
20
- this._allowInfinity = _allowInfinity;
21
- }
22
- /**
23
- * Create a new FloatGenerator.
24
- */
25
- static create() {
26
- return new FloatGenerator();
27
- }
28
- /**
29
- * Set the minimum value.
30
- */
31
- min(value) {
32
- return new FloatGenerator(value, this._max, this._excludeMin, this._excludeMax, this._allowNan, this._allowInfinity);
33
- }
34
- /**
35
- * Set the maximum value.
36
- */
37
- max(value) {
38
- return new FloatGenerator(this._min, value, this._excludeMin, this._excludeMax, this._allowNan, this._allowInfinity);
39
- }
40
- /**
41
- * Exclude the minimum value from the range.
42
- */
43
- excludeMin() {
44
- return new FloatGenerator(this._min, this._max, true, this._excludeMax, this._allowNan, this._allowInfinity);
45
- }
46
- /**
47
- * Exclude the maximum value from the range.
48
- */
49
- excludeMax() {
50
- return new FloatGenerator(this._min, this._max, this._excludeMin, true, this._allowNan, this._allowInfinity);
51
- }
52
- /**
53
- * Set whether NaN values can be generated.
54
- */
55
- allowNan(allow) {
56
- return new FloatGenerator(this._min, this._max, this._excludeMin, this._excludeMax, allow, this._allowInfinity);
57
- }
58
- /**
59
- * Set whether infinity values can be generated.
60
- */
61
- allowInfinity(allow) {
62
- return new FloatGenerator(this._min, this._max, this._excludeMin, this._excludeMax, this._allowNan, allow);
63
- }
64
- generate() {
65
- return generateFromSchema(this.schema());
66
- }
67
- schema() {
68
- const schema = {
69
- type: "number",
70
- exclude_minimum: this._excludeMin,
71
- exclude_maximum: this._excludeMax,
72
- allow_nan: this._allowNan,
73
- allow_infinity: this._allowInfinity,
74
- width: 64, // JavaScript numbers are always f64
75
- };
76
- if (this._min !== undefined) {
77
- schema.minimum = this._min;
78
- }
79
- if (this._max !== undefined) {
80
- schema.maximum = this._max;
81
- }
82
- return schema;
83
- }
84
- }
85
- /**
86
- * Create a generator for floating-point values.
87
- *
88
- * @example
89
- * ```typescript
90
- * // Generate any float
91
- * const gen = floats();
92
- *
93
- * // Generate floats in a range (exclusive)
94
- * const bounded = floats().min(0).max(1).excludeMin().excludeMax();
95
- * ```
96
- */
97
- export function floats() {
98
- return FloatGenerator.create();
99
- }
100
- //# sourceMappingURL=floats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"floats.js","sourceRoot":"","sources":["../src/floats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAc,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE1D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAqB;IAEpC;IACA;IACA;IACA;IACA;IACA;IANnB,YACmB,IAAa,EACb,IAAa,EACb,cAAuB,KAAK,EAC5B,cAAuB,KAAK,EAC5B,YAAqB,IAAI,EACzB,iBAA0B,IAAI;QAE/C,KAAK,EAAE,CAAA;QAPU,SAAI,GAAJ,IAAI,CAAS;QACb,SAAI,GAAJ,IAAI,CAAS;QACb,gBAAW,GAAX,WAAW,CAAiB;QAC5B,gBAAW,GAAX,WAAW,CAAiB;QAC5B,cAAS,GAAT,SAAS,CAAgB;QACzB,mBAAc,GAAd,cAAc,CAAgB;IAGjD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,cAAc,EAAE,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,KAAa;QACf,OAAO,IAAI,cAAc,CACvB,KAAK,EACL,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,cAAc,CACpB,CAAA;IACH,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,KAAa;QACf,OAAO,IAAI,cAAc,CACvB,IAAI,CAAC,IAAI,EACT,KAAK,EACL,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,cAAc,CACpB,CAAA;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAA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;QAC5B,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAA;QAC5B,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,cAAc,CAAC,MAAM,EAAE,CAAA;AAChC,CAAC"}
package/dist/formats.d.ts DELETED
@@ -1,62 +0,0 @@
1
- import { Generator, JsonSchema, BaseGenerator } from "./generator.js";
2
- /**
3
- * Create a generator for email addresses.
4
- */
5
- export declare function emails(): Generator<string>;
6
- /**
7
- * Create a generator for URLs.
8
- */
9
- export declare function urls(): Generator<string>;
10
- /**
11
- * Generator for domain names with optional max length.
12
- */
13
- export declare class DomainGenerator extends BaseGenerator<string> {
14
- private readonly _maxLength;
15
- private constructor();
16
- static create(): DomainGenerator;
17
- /**
18
- * Set the maximum length for the domain.
19
- */
20
- maxLength(value: number): DomainGenerator;
21
- generate(): string;
22
- schema(): JsonSchema;
23
- }
24
- /**
25
- * Create a generator for domain names.
26
- */
27
- export declare function domains(): DomainGenerator;
28
- /**
29
- * Generator for IP addresses.
30
- */
31
- export declare class IpAddressGenerator extends BaseGenerator<string> {
32
- private readonly _version;
33
- private constructor();
34
- static create(): IpAddressGenerator;
35
- /**
36
- * Generate only IPv4 addresses.
37
- */
38
- v4(): IpAddressGenerator;
39
- /**
40
- * Generate only IPv6 addresses.
41
- */
42
- v6(): IpAddressGenerator;
43
- generate(): string;
44
- schema(): JsonSchema;
45
- }
46
- /**
47
- * Create a generator for IP addresses.
48
- */
49
- export declare function ipAddresses(): IpAddressGenerator;
50
- /**
51
- * Create a generator for date strings (ISO 8601 date format).
52
- */
53
- export declare function dates(): Generator<string>;
54
- /**
55
- * Create a generator for time strings (ISO 8601 time format).
56
- */
57
- export declare function times(): Generator<string>;
58
- /**
59
- * Create a generator for datetime strings (ISO 8601 datetime format).
60
- */
61
- export declare function datetimes(): Generator<string>;
62
- //# sourceMappingURL=formats.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AA0BrE;;GAEG;AACH,wBAAgB,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAE1C;AAWD;;GAEG;AACH,wBAAgB,IAAI,IAAI,SAAS,CAAC,MAAM,CAAC,CAExC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa,CAAC,MAAM,CAAC;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAA/C,OAAO;IAIP,MAAM,CAAC,MAAM,IAAI,eAAe;IAIhC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe;IAIzC,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,UAAU;CAMrB;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,eAAe,CAEzC;AAOD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa,CAAC,MAAM,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAA7C,OAAO;IAIP,MAAM,CAAC,MAAM,IAAI,kBAAkB;IAInC;;OAEG;IACH,EAAE,IAAI,kBAAkB;IAIxB;;OAEG;IACH,EAAE,IAAI,kBAAkB;IAIxB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,UAAU;CAYrB;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,kBAAkB,CAEhD;AAWD;;GAEG;AACH,wBAAgB,KAAK,IAAI,SAAS,CAAC,MAAM,CAAC,CAEzC;AAWD;;GAEG;AACH,wBAAgB,KAAK,IAAI,SAAS,CAAC,MAAM,CAAC,CAEzC;AAWD;;GAEG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC,CAE7C"}
package/dist/formats.js DELETED
@@ -1,164 +0,0 @@
1
- import { generateFromSchema } from "./connection.js";
2
- import { BaseGenerator } from "./generator.js";
3
- /**
4
- * Base class for format string generators.
5
- */
6
- class FormatGenerator extends BaseGenerator {
7
- generate() {
8
- return generateFromSchema(this.schema());
9
- }
10
- schema() {
11
- return this.getSchema();
12
- }
13
- }
14
- /**
15
- * Generator for email addresses.
16
- */
17
- class EmailGenerator extends FormatGenerator {
18
- getSchema() {
19
- return { type: "email" };
20
- }
21
- }
22
- /**
23
- * Create a generator for email addresses.
24
- */
25
- export function emails() {
26
- return new EmailGenerator();
27
- }
28
- /**
29
- * Generator for URLs.
30
- */
31
- class UrlGenerator extends FormatGenerator {
32
- getSchema() {
33
- return { type: "url" };
34
- }
35
- }
36
- /**
37
- * Create a generator for URLs.
38
- */
39
- export function urls() {
40
- return new UrlGenerator();
41
- }
42
- /**
43
- * Generator for domain names with optional max length.
44
- */
45
- export class DomainGenerator extends BaseGenerator {
46
- _maxLength;
47
- constructor(_maxLength = 255) {
48
- super();
49
- this._maxLength = _maxLength;
50
- }
51
- static create() {
52
- return new DomainGenerator();
53
- }
54
- /**
55
- * Set the maximum length for the domain.
56
- */
57
- maxLength(value) {
58
- return new DomainGenerator(value);
59
- }
60
- generate() {
61
- return generateFromSchema(this.schema());
62
- }
63
- schema() {
64
- return {
65
- type: "domain",
66
- max_length: this._maxLength,
67
- };
68
- }
69
- }
70
- /**
71
- * Create a generator for domain names.
72
- */
73
- export function domains() {
74
- return DomainGenerator.create();
75
- }
76
- /**
77
- * Generator for IP addresses.
78
- */
79
- export class IpAddressGenerator extends BaseGenerator {
80
- _version;
81
- constructor(_version = "any") {
82
- super();
83
- this._version = _version;
84
- }
85
- static create() {
86
- return new IpAddressGenerator();
87
- }
88
- /**
89
- * Generate only IPv4 addresses.
90
- */
91
- v4() {
92
- return new IpAddressGenerator("v4");
93
- }
94
- /**
95
- * Generate only IPv6 addresses.
96
- */
97
- v6() {
98
- return new IpAddressGenerator("v6");
99
- }
100
- generate() {
101
- return generateFromSchema(this.schema());
102
- }
103
- schema() {
104
- switch (this._version) {
105
- case "v4":
106
- return { type: "ipv4" };
107
- case "v6":
108
- return { type: "ipv6" };
109
- default:
110
- return {
111
- one_of: [{ type: "ipv4" }, { type: "ipv6" }],
112
- };
113
- }
114
- }
115
- }
116
- /**
117
- * Create a generator for IP addresses.
118
- */
119
- export function ipAddresses() {
120
- return IpAddressGenerator.create();
121
- }
122
- /**
123
- * Generator for date strings (YYYY-MM-DD format).
124
- */
125
- class DateGenerator extends FormatGenerator {
126
- getSchema() {
127
- return { type: "date" };
128
- }
129
- }
130
- /**
131
- * Create a generator for date strings (ISO 8601 date format).
132
- */
133
- export function dates() {
134
- return new DateGenerator();
135
- }
136
- /**
137
- * Generator for time strings (HH:MM:SS format).
138
- */
139
- class TimeGenerator extends FormatGenerator {
140
- getSchema() {
141
- return { type: "time" };
142
- }
143
- }
144
- /**
145
- * Create a generator for time strings (ISO 8601 time format).
146
- */
147
- export function times() {
148
- return new TimeGenerator();
149
- }
150
- /**
151
- * Generator for datetime strings (ISO 8601 format).
152
- */
153
- class DateTimeGenerator extends FormatGenerator {
154
- getSchema() {
155
- return { type: "datetime" };
156
- }
157
- }
158
- /**
159
- * Create a generator for datetime strings (ISO 8601 datetime format).
160
- */
161
- export function datetimes() {
162
- return new DateTimeGenerator();
163
- }
164
- //# sourceMappingURL=formats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formats.js","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAyB,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAErE;;GAEG;AACH,MAAe,eAAgB,SAAQ,aAAqB;IAG1D,QAAQ;QACN,OAAO,kBAAkB,CAAS,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,S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AU,EAAE,CAAA;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,iBAAiB,EAAE,CAAA;AAChC,CAAC"}
@@ -1,80 +0,0 @@
1
- /**
2
- * JSON Schema type for generator schemas.
3
- */
4
- export type JsonSchema = Record<string, unknown>;
5
- /**
6
- * Core Generator interface.
7
- * All generators implement this interface.
8
- */
9
- export interface Generator<T> {
10
- /**
11
- * Generate a value of type T.
12
- */
13
- generate(): T;
14
- /**
15
- * Get the JSON Schema for this generator, or null if unavailable.
16
- * When a schema is available, generation is more efficient (single socket round-trip).
17
- */
18
- schema(): JsonSchema | null;
19
- /**
20
- * Transform generated values with a function.
21
- * Note: This invalidates the schema, causing compositional generation.
22
- */
23
- map<U>(f: (value: T) => U): Generator<U>;
24
- /**
25
- * Dependent generation where the next generator depends on the generated value.
26
- * Note: This invalidates the schema, causing compositional generation.
27
- */
28
- flatMap<U>(f: (value: T) => Generator<U>): Generator<U>;
29
- /**
30
- * Filter generated values by a predicate.
31
- * Note: This invalidates the schema, causing compositional generation.
32
- * @param predicate - Function that returns true for valid values
33
- */
34
- filter(predicate: (value: T) => boolean): Generator<T>;
35
- }
36
- /**
37
- * Abstract base class providing default implementations of map, flatMap, and filter.
38
- * Concrete generators only need to implement generate() and schema().
39
- */
40
- export declare abstract class BaseGenerator<T> implements Generator<T> {
41
- abstract generate(): T;
42
- abstract schema(): JsonSchema | null;
43
- map<U>(f: (value: T) => U): Generator<U>;
44
- flatMap<U>(f: (value: T) => Generator<U>): Generator<U>;
45
- filter(predicate: (value: T) => boolean): Generator<T>;
46
- }
47
- /**
48
- * Schema-based generator that uses a JSON schema for generation.
49
- * Provides efficient single socket round-trip generation.
50
- */
51
- export declare class SchemaGenerator<T> extends BaseGenerator<T> {
52
- private readonly _schema;
53
- constructor(_schema: JsonSchema);
54
- generate(): T;
55
- schema(): JsonSchema;
56
- }
57
- /**
58
- * Function-based generator that wraps a generation function.
59
- * May or may not have a schema.
60
- */
61
- export declare class FuncGenerator<T> extends BaseGenerator<T> {
62
- private readonly genFn;
63
- private readonly _schema;
64
- constructor(genFn: () => T, _schema?: JsonSchema | null);
65
- generate(): T;
66
- schema(): JsonSchema | null;
67
- }
68
- /**
69
- * Generator that filters values by a predicate.
70
- * Retries up to 3 times before rejecting.
71
- * Always has no schema.
72
- */
73
- export declare class FilteredGenerator<T> extends BaseGenerator<T> {
74
- private readonly source;
75
- private readonly predicate;
76
- constructor(source: Generator<T>, predicate: (value: T) => boolean);
77
- generate(): T;
78
- schema(): null;
79
- }
80
- //# sourceMappingURL=generator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEhD;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B;;OAEG;IACH,QAAQ,IAAI,CAAC,CAAA;IAEb;;;OAGG;IACH,MAAM,IAAI,UAAU,GAAG,IAAI,CAAA;IAE3B;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IAExC;;;OAGG;IACH,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IAEvD;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;CACvD;AAED;;;GAGG;AACH,8BAAsB,aAAa,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,QAAQ,IAAI,CAAC;IACtB,QAAQ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{ generateFromSchema, assume } from "./connection.js";
2
- import { LABELS } from "./labels.js";
3
- import { discardableGroup, group } from "./spans.js";
4
- /**
5
- * Abstract base class providing default implementations of map, flatMap, and filter.
6
- * Concrete generators only need to implement generate() and schema().
7
- */
8
- export class BaseGenerator {
9
- map(f) {
10
- return new MappedGenerator(this, f);
11
- }
12
- flatMap(f) {
13
- return new FlatMappedGenerator(this, f);
14
- }
15
- filter(predicate) {
16
- return new FilteredGenerator(this, predicate);
17
- }
18
- }
19
- /**
20
- * Schema-based generator that uses a JSON schema for generation.
21
- * Provides efficient single socket round-trip generation.
22
- */
23
- export class SchemaGenerator extends BaseGenerator {
24
- _schema;
25
- constructor(_schema) {
26
- super();
27
- this._schema = _schema;
28
- }
29
- generate() {
30
- return generateFromSchema(this._schema);
31
- }
32
- schema() {
33
- return this._schema;
34
- }
35
- }
36
- /**
37
- * Function-based generator that wraps a generation function.
38
- * May or may not have a schema.
39
- */
40
- export class FuncGenerator extends BaseGenerator {
41
- genFn;
42
- _schema;
43
- constructor(genFn, _schema = null) {
44
- super();
45
- this.genFn = genFn;
46
- this._schema = _schema;
47
- }
48
- generate() {
49
- return this.genFn();
50
- }
51
- schema() {
52
- return this._schema;
53
- }
54
- }
55
- /**
56
- * Generator that transforms values from another generator.
57
- * Always has no schema (transformation invalidates it).
58
- */
59
- class MappedGenerator extends BaseGenerator {
60
- source;
61
- f;
62
- constructor(source, f) {
63
- super();
64
- this.source = source;
65
- this.f = f;
66
- }
67
- generate() {
68
- return this.f(this.source.generate());
69
- }
70
- schema() {
71
- return null;
72
- }
73
- }
74
- /**
75
- * Generator for dependent generation.
76
- * The next generator depends on the value from the first generator.
77
- * Always has no schema.
78
- */
79
- class FlatMappedGenerator extends BaseGenerator {
80
- source;
81
- f;
82
- constructor(source, f) {
83
- super();
84
- this.source = source;
85
- this.f = f;
86
- }
87
- generate() {
88
- return group(LABELS.FLAT_MAP, () => {
89
- const intermediate = this.source.generate();
90
- const nextGen = this.f(intermediate);
91
- return nextGen.generate();
92
- });
93
- }
94
- schema() {
95
- return null;
96
- }
97
- }
98
- /**
99
- * Generator that filters values by a predicate.
100
- * Retries up to 3 times before rejecting.
101
- * Always has no schema.
102
- */
103
- export class FilteredGenerator extends BaseGenerator {
104
- source;
105
- predicate;
106
- constructor(source, predicate) {
107
- super();
108
- this.source = source;
109
- this.predicate = predicate;
110
- }
111
- generate() {
112
- for (let i = 0; i < 3; i++) {
113
- const result = discardableGroup(LABELS.FILTER, () => {
114
- const value = this.source.generate();
115
- return this.predicate(value) ? value : null;
116
- });
117
- if (result !== null) {
118
- return result;
119
- }
120
- }
121
- assume(false);
122
- throw new Error("unreachable"); // assume(false) exits the process
123
- }
124
- schema() {
125
- return null;
126
- }
127
- }
128
- //# sourceMappingURL=generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AA2CpD;;;GAGG;AACH,MAAM,OAAgB,aAAa;IAIjC,GAAG,CAAI,CAAkB;QACvB,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,CAAI,CAA6B;QACtC,OAAO,IAAI,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,SAAgC;QACrC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAC/C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,eAAmB,SAAQ,aAAgB;IACzB;IAA7B,YAA6B,OAAmB;QAC9C,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAY;IAEhD,CAAC;I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