tyneq 1.0.0 → 1.0.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 (52) hide show
  1. package/README.md +67 -1
  2. package/dist/{TyneqCachedTerminalOperator.d.ts → TyneqCachedTerminalOperator-BrW77zIy.d.ts} +328 -173
  3. package/dist/{TyneqCachedTerminalOperator.d.cts → TyneqCachedTerminalOperator-EaNiNt61.d.cts} +328 -173
  4. package/dist/chunk-5R4AALC7.js +680 -0
  5. package/dist/chunk-C5PBY3ZU.cjs +46 -0
  6. package/dist/chunk-OWKUE3AC.cjs +680 -0
  7. package/dist/chunk-PCBN5AFG.js +46 -0
  8. package/dist/chunk-VJAICXA6.cjs +3788 -0
  9. package/dist/chunk-ZP6WMZCK.js +3788 -0
  10. package/dist/core-C54TSmgW.d.cts +1390 -0
  11. package/dist/core-C54TSmgW.d.ts +1390 -0
  12. package/dist/index.cjs +638 -843
  13. package/dist/index.d.cts +405 -605
  14. package/dist/index.d.ts +405 -605
  15. package/dist/index.js +630 -781
  16. package/dist/plugin/index.cjs +51 -24
  17. package/dist/plugin/index.d.cts +35 -38
  18. package/dist/plugin/index.d.ts +35 -38
  19. package/dist/plugin/index.js +51 -2
  20. package/dist/utility/index.cjs +18 -9
  21. package/dist/utility/index.d.cts +312 -2
  22. package/dist/utility/index.d.ts +312 -2
  23. package/dist/utility/index.js +18 -3
  24. package/package.json +5 -5
  25. package/dist/Lazy.cjs +0 -762
  26. package/dist/Lazy.cjs.map +0 -1
  27. package/dist/Lazy.js +0 -691
  28. package/dist/Lazy.js.map +0 -1
  29. package/dist/TyneqCachedTerminalOperator.cjs +0 -4950
  30. package/dist/TyneqCachedTerminalOperator.cjs.map +0 -1
  31. package/dist/TyneqCachedTerminalOperator.d.cts.map +0 -1
  32. package/dist/TyneqCachedTerminalOperator.d.ts.map +0 -1
  33. package/dist/TyneqCachedTerminalOperator.js +0 -4741
  34. package/dist/TyneqCachedTerminalOperator.js.map +0 -1
  35. package/dist/ValidationBuilder.cjs +0 -80
  36. package/dist/ValidationBuilder.cjs.map +0 -1
  37. package/dist/ValidationBuilder.d.cts +0 -319
  38. package/dist/ValidationBuilder.d.cts.map +0 -1
  39. package/dist/ValidationBuilder.d.ts +0 -319
  40. package/dist/ValidationBuilder.d.ts.map +0 -1
  41. package/dist/ValidationBuilder.js +0 -69
  42. package/dist/ValidationBuilder.js.map +0 -1
  43. package/dist/core.d.cts +0 -1393
  44. package/dist/core.d.cts.map +0 -1
  45. package/dist/core.d.ts +0 -1393
  46. package/dist/core.d.ts.map +0 -1
  47. package/dist/index.cjs.map +0 -1
  48. package/dist/index.d.cts.map +0 -1
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/plugin/index.d.cts.map +0 -1
  52. package/dist/plugin/index.d.ts.map +0 -1
@@ -1,2 +1,312 @@
1
- import { a as reflect, c as MemberDescriptor, d as ArgumentUtility, i as ReflectionContext, l as MethodDescriptor, n as Lazy, o as AccessorDescriptor, r as TypeGuardUtility, s as DataDescriptor, t as ValidationBuilder, u as ReflectOptions } from "../ValidationBuilder.cjs";
2
- export { type AccessorDescriptor, ArgumentUtility, type DataDescriptor, Lazy, type MemberDescriptor, type MethodDescriptor, type ReflectOptions, ReflectionContext, TypeGuardUtility, ValidationBuilder, reflect };
1
+ import { N as Nullable, M as Maybe, a as Optional, H as HasLength, k as Enumerable, E as Enumerator, F as Factory } from '../core-C54TSmgW.cjs';
2
+
3
+ /**
4
+ * Facade for all argument validation guards.
5
+ *
6
+ * Every method accepts either a single-property object (`{ count }`) - where the
7
+ * property name becomes the error message's parameter name - or a raw value with
8
+ * an explicit `paramName` string. Prefer the object form; the name is inferred
9
+ * automatically via `nameof`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { ArgumentUtility } from "tyneq/utility";
14
+ *
15
+ * function take(count: number) {
16
+ * ArgumentUtility.checkNonNegative({ count }); // throws ArgumentOutOfRangeError if count < 0
17
+ * ArgumentUtility.checkInteger({ count }); // throws ArgumentError if count is not an integer
18
+ * }
19
+ * ```
20
+ *
21
+ * @group Utilities
22
+ */
23
+ declare class ArgumentUtility {
24
+ private constructor();
25
+ static checkNotNull<T>(param: Record<string, Nullable<T>>): asserts param is Record<string, T>;
26
+ static checkNotNull<T>(param: Nullable<T>, paramName: string): asserts param is T;
27
+ static checkNotUndefined<T>(param: Record<string, Maybe<T>>): asserts param is Record<string, T>;
28
+ static checkNotUndefined<T>(param: Maybe<T>, paramName: string): asserts param is T;
29
+ static checkNotOptional<T>(param: Record<string, Optional<T>>): asserts param is Record<string, T>;
30
+ static checkNotOptional<T>(param: Optional<T>, paramName: string): asserts param is T;
31
+ static checkNotNullOrEmpty<T extends HasLength>(param: Record<string, Nullable<T>>): asserts param is Record<string, T>;
32
+ static checkNotNullOrEmpty<T extends HasLength>(param: Nullable<T>, paramName: string): asserts param is T;
33
+ static checkNotOptionalOrEmpty<T extends HasLength>(param: Record<string, Optional<T>>): asserts param is Record<string, T>;
34
+ static checkNotOptionalOrEmpty<T extends HasLength>(param: Optional<T>, paramName: string): asserts param is T;
35
+ static checkNotNullOrWhiteSpace(param: Record<string, Optional<string>>): asserts param is Record<string, string>;
36
+ static checkNotNullOrWhiteSpace(param: Optional<string>, paramName: string): asserts param is string;
37
+ static checkNonNegative(param: Record<string, number>): void;
38
+ static checkNonNegative(param: number, paramName: string): void;
39
+ static checkPositive(param: Record<string, number>): void;
40
+ static checkPositive(param: number, paramName: string): void;
41
+ static checkNegative(param: Record<string, number>): void;
42
+ static checkNegative(param: number, paramName: string): void;
43
+ static checkNonPositive(param: Record<string, number>): void;
44
+ static checkNonPositive(param: number, paramName: string): void;
45
+ static checkInRange(param: Record<string, number>, min: number, max: number): void;
46
+ static checkInRange(param: number, min: number, max: number, paramName: string): void;
47
+ static checkInteger(param: Record<string, number>): void;
48
+ static checkInteger(param: number, paramName: string): void;
49
+ static checkFinite(param: Record<string, number>): void;
50
+ static checkFinite(param: number, paramName: string): void;
51
+ static checkNotNaN(param: Record<string, number>): void;
52
+ static checkNotNaN(param: number, paramName: string): void;
53
+ static checkSafeInteger(param: Record<string, number>): void;
54
+ static checkSafeInteger(param: number, paramName: string): void;
55
+ static checkArrayIndex(param: Record<string, number>, arrayLength?: number): void;
56
+ static checkArrayIndex(param: number, paramName: string, arrayLength?: number): void;
57
+ static checkFunction(param: Record<string, unknown>): asserts param is Record<string, Function>;
58
+ static checkFunction(param: unknown, paramName: string): asserts param is Function;
59
+ static checkIterable<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Iterable<T>>;
60
+ static checkIterable<T = unknown>(param: unknown, paramName: string): asserts param is Iterable<T>;
61
+ static checkIterator<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Iterator<T>>;
62
+ static checkIterator<T = unknown>(param: unknown, paramName: string): asserts param is Iterator<T>;
63
+ static checkEnumerable<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Enumerable<T>>;
64
+ static checkEnumerable<T = unknown>(param: unknown, paramName: string): asserts param is Enumerable<T>;
65
+ static checkEnumerator<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Enumerator<T>>;
66
+ static checkEnumerator<T = unknown>(param: unknown, paramName: string): asserts param is Enumerator<T>;
67
+ static checkInstanceOf<T>(param: Record<string, unknown>, constructor: new (...args: any[]) => T): asserts param is Record<string, T>;
68
+ static checkInstanceOf<T>(param: unknown, constructor: new (...args: any[]) => T, paramName: string): asserts param is T;
69
+ static checkHasLength(param: Record<string, unknown>): asserts param is Record<string, HasLength>;
70
+ static checkHasLength(param: unknown, paramName: string): asserts param is HasLength;
71
+ static check<T>(param: Record<string, T>, predicate: (v: T) => boolean, message: string): void;
72
+ static check<T>(param: T, paramName: string, predicate: (v: T) => boolean, message: string): void;
73
+ private static extractParameter;
74
+ }
75
+
76
+ /**
77
+ * Describes a method (function-valued own property) on a reflected target.
78
+ *
79
+ * @group Reflection
80
+ */
81
+ interface MethodDescriptor {
82
+ readonly kind: "method";
83
+ readonly name: string | symbol;
84
+ /** The raw function value. */
85
+ readonly value: Function;
86
+ /** Calls the method with the given `this` context and arguments. */
87
+ readonly invoke: (thisArg: unknown, ...args: unknown[]) => unknown;
88
+ }
89
+ /**
90
+ * Describes a data property (non-function own value property) on a reflected target.
91
+ *
92
+ * @group Reflection
93
+ */
94
+ interface DataDescriptor {
95
+ readonly kind: "data";
96
+ readonly name: string | symbol;
97
+ readonly value: unknown;
98
+ readonly writable: boolean;
99
+ readonly configurable: boolean;
100
+ readonly enumerable: boolean;
101
+ }
102
+ /**
103
+ * Describes an accessor property (get and/or set) on a reflected target.
104
+ *
105
+ * @group Reflection
106
+ */
107
+ interface AccessorDescriptor {
108
+ readonly kind: "accessor";
109
+ readonly name: string | symbol;
110
+ readonly get: Maybe<() => unknown>;
111
+ readonly set: Maybe<(value: unknown) => void>;
112
+ readonly configurable: boolean;
113
+ readonly enumerable: boolean;
114
+ /** `true` if the accessor defines a getter. */
115
+ readonly canRead: boolean;
116
+ /** `true` if the accessor defines a setter. */
117
+ readonly canWrite: boolean;
118
+ }
119
+ /**
120
+ * A discriminated union of all member descriptor types returned by {@link ReflectionContext}.
121
+ *
122
+ * Use `descriptor.kind` to narrow to the specific descriptor type.
123
+ *
124
+ * @group Reflection
125
+ */
126
+ type MemberDescriptor = MethodDescriptor | DataDescriptor | AccessorDescriptor;
127
+ /**
128
+ * Options for the {@link reflect} factory.
129
+ *
130
+ * @group Reflection
131
+ */
132
+ interface ReflectOptions {
133
+ /**
134
+ * When `true`, walks the full prototype chain and includes inherited members
135
+ * up to (but not including) `Object.prototype`.
136
+ *
137
+ * Equivalent to C# `BindingFlags.FlattenHierarchy`.
138
+ *
139
+ * @defaultValue false
140
+ */
141
+ readonly inherited?: boolean;
142
+ /**
143
+ * When `true`, includes Symbol-keyed members in addition to string-keyed members.
144
+ *
145
+ * @defaultValue false
146
+ */
147
+ readonly symbols?: boolean;
148
+ }
149
+
150
+ /**
151
+ * The result of a {@link reflect} call. Provides typed access to the members of
152
+ * the reflected target.
153
+ *
154
+ * @group Reflection
155
+ */
156
+ declare class ReflectionContext<_T extends object> {
157
+ private readonly proto;
158
+ private readonly options;
159
+ /** @internal */
160
+ constructor(proto: object, options: ReflectOptions);
161
+ /**
162
+ * Returns descriptors for all own (and optionally inherited) members,
163
+ * excluding `constructor`.
164
+ */
165
+ members(): readonly MemberDescriptor[];
166
+ /**
167
+ * Returns descriptors for all method members (function-valued own properties),
168
+ * excluding `constructor`.
169
+ */
170
+ methods(): readonly MethodDescriptor[];
171
+ /**
172
+ * Returns descriptors for all data members (non-function value properties).
173
+ */
174
+ fields(): readonly DataDescriptor[];
175
+ /**
176
+ * Returns descriptors for all accessor members (get/set properties).
177
+ */
178
+ accessors(): readonly AccessorDescriptor[];
179
+ /**
180
+ * Returns the descriptor for the named member, or `undefined` if not found.
181
+ */
182
+ get(name: string | symbol): Maybe<MemberDescriptor>;
183
+ /**
184
+ * Returns `true` if a member with the given name exists on the target.
185
+ */
186
+ has(name: string | symbol): boolean;
187
+ /**
188
+ * Returns the method descriptor for `name`, or throws {@link ReflectionError}
189
+ * if the member does not exist or is not a method.
190
+ *
191
+ * @throws {ReflectionError} when the member is absent or is not a method.
192
+ */
193
+ getMethod(name: string | symbol): MethodDescriptor;
194
+ /**
195
+ * Returns the accessor descriptor for `name`, or throws {@link ReflectionError}
196
+ * if the member does not exist or is not an accessor.
197
+ *
198
+ * @throws {ReflectionError} when the member is absent or is not an accessor.
199
+ */
200
+ getAccessor(name: string | symbol): AccessorDescriptor;
201
+ /**
202
+ * Returns `true` if a method with the given name exists on the target.
203
+ *
204
+ * Unlike {@link has}, this returns `false` if the member exists but is an accessor or data property.
205
+ */
206
+ hasMethod(name: string | symbol): boolean;
207
+ /**
208
+ * Returns the method descriptor for `name`, or `undefined` if the member does not
209
+ * exist or is not a method. Never throws.
210
+ */
211
+ tryGetMethod(name: string | symbol): Maybe<MethodDescriptor>;
212
+ private findDescriptor;
213
+ private collectDescriptors;
214
+ }
215
+ /**
216
+ * Creates a {@link ReflectionContext} for the given target.
217
+ *
218
+ * The `target` can be:
219
+ * - A **constructor function** - reflects the class prototype (instance members). Preferred form.
220
+ * - A **prototype object** (`MyClass.prototype`) - reflects it directly.
221
+ * - Any **object** - reflects the object's own properties directly.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * import { reflect } from "tyneq/utility";
226
+ *
227
+ * class Service {
228
+ * public name = "svc";
229
+ * public get label(): string { return this.name; }
230
+ * public run(): void { /* ... *\/ }
231
+ * }
232
+ *
233
+ * const ctx = reflect(Service);
234
+ *
235
+ * ctx.methods(); // -> [{ kind: "method", name: "run", ... }]
236
+ * ctx.accessors(); // -> [{ kind: "accessor", name: "label", canRead: true, canWrite: false, ... }]
237
+ *
238
+ * const m = ctx.getMethod("run");
239
+ * m.invoke(new Service()); // calls run()
240
+ * ```
241
+ *
242
+ * Walk the full prototype chain:
243
+ *
244
+ * ```ts
245
+ * const ctx = reflect(DerivedClass, { inherited: true });
246
+ * ctx.members(); // includes members from base classes too
247
+ * ```
248
+ *
249
+ * @group Reflection
250
+ */
251
+ declare function reflect<T extends object>(target: (new (...args: any[]) => T) | T, options?: ReflectOptions): ReflectionContext<T>;
252
+
253
+ /**
254
+ * Type guard predicates for Tyneq's core protocol types.
255
+ *
256
+ * @group Utilities
257
+ */
258
+ declare class TypeGuardUtility {
259
+ private constructor();
260
+ static isIterable<T = unknown>(value: unknown): value is Iterable<T>;
261
+ static isIterator<T = unknown>(value: unknown): value is Iterator<T>;
262
+ static isIterableIterator<T = unknown>(value: unknown): value is IterableIterator<T>;
263
+ static isEnumerator<T = unknown>(value: unknown): value is Enumerator<T>;
264
+ static isEnumerable<T = unknown>(value: unknown): value is Enumerable<T>;
265
+ }
266
+
267
+ /**
268
+ * Utility class for lazy initialization of values.
269
+ *
270
+ * @group Utilities
271
+ */
272
+ declare class Lazy<T> {
273
+ private readonly factory;
274
+ /** The lazily initialized value, or `undefined` if not yet initialized. */
275
+ private lazyValue;
276
+ /** Indicates whether the value has been initialized. */
277
+ private initialized;
278
+ constructor(factory: Factory<T, []>);
279
+ /** Returns the lazily initialized value, initializing it if necessary. */
280
+ get value(): T;
281
+ }
282
+
283
+ /**
284
+ * Accumulates validation errors and throws a single `ValidationError` containing all of them.
285
+ *
286
+ * Use when multiple independent arguments must be validated together so callers see all
287
+ * failures in one throw rather than one at a time.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * new ValidationBuilder()
292
+ * .check(() => ArgumentUtility.checkNotOptional({ selector }))
293
+ * .check(() => ArgumentUtility.checkPositive({ count }))
294
+ * .throwIfAny();
295
+ * ```
296
+ *
297
+ * @group Utilities
298
+ */
299
+ declare class ValidationBuilder {
300
+ private readonly errors;
301
+ /**
302
+ * Runs `fn` and collects any thrown error message. Returns `this` for chaining.
303
+ */
304
+ check(fn: () => void): this;
305
+ /**
306
+ * Throws a `ValidationError` with all collected messages if any `check` calls failed.
307
+ * Does nothing when no errors were collected.
308
+ */
309
+ throwIfAny(): void;
310
+ }
311
+
312
+ export { type AccessorDescriptor, ArgumentUtility, type DataDescriptor, Lazy, type MemberDescriptor, type MethodDescriptor, type ReflectOptions, ReflectionContext, TypeGuardUtility, ValidationBuilder, reflect };
@@ -1,2 +1,312 @@
1
- import { a as reflect, c as MemberDescriptor, d as ArgumentUtility, i as ReflectionContext, l as MethodDescriptor, n as Lazy, o as AccessorDescriptor, r as TypeGuardUtility, s as DataDescriptor, t as ValidationBuilder, u as ReflectOptions } from "../ValidationBuilder.js";
2
- export { type AccessorDescriptor, ArgumentUtility, type DataDescriptor, Lazy, type MemberDescriptor, type MethodDescriptor, type ReflectOptions, ReflectionContext, TypeGuardUtility, ValidationBuilder, reflect };
1
+ import { N as Nullable, M as Maybe, a as Optional, H as HasLength, k as Enumerable, E as Enumerator, F as Factory } from '../core-C54TSmgW.js';
2
+
3
+ /**
4
+ * Facade for all argument validation guards.
5
+ *
6
+ * Every method accepts either a single-property object (`{ count }`) - where the
7
+ * property name becomes the error message's parameter name - or a raw value with
8
+ * an explicit `paramName` string. Prefer the object form; the name is inferred
9
+ * automatically via `nameof`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { ArgumentUtility } from "tyneq/utility";
14
+ *
15
+ * function take(count: number) {
16
+ * ArgumentUtility.checkNonNegative({ count }); // throws ArgumentOutOfRangeError if count < 0
17
+ * ArgumentUtility.checkInteger({ count }); // throws ArgumentError if count is not an integer
18
+ * }
19
+ * ```
20
+ *
21
+ * @group Utilities
22
+ */
23
+ declare class ArgumentUtility {
24
+ private constructor();
25
+ static checkNotNull<T>(param: Record<string, Nullable<T>>): asserts param is Record<string, T>;
26
+ static checkNotNull<T>(param: Nullable<T>, paramName: string): asserts param is T;
27
+ static checkNotUndefined<T>(param: Record<string, Maybe<T>>): asserts param is Record<string, T>;
28
+ static checkNotUndefined<T>(param: Maybe<T>, paramName: string): asserts param is T;
29
+ static checkNotOptional<T>(param: Record<string, Optional<T>>): asserts param is Record<string, T>;
30
+ static checkNotOptional<T>(param: Optional<T>, paramName: string): asserts param is T;
31
+ static checkNotNullOrEmpty<T extends HasLength>(param: Record<string, Nullable<T>>): asserts param is Record<string, T>;
32
+ static checkNotNullOrEmpty<T extends HasLength>(param: Nullable<T>, paramName: string): asserts param is T;
33
+ static checkNotOptionalOrEmpty<T extends HasLength>(param: Record<string, Optional<T>>): asserts param is Record<string, T>;
34
+ static checkNotOptionalOrEmpty<T extends HasLength>(param: Optional<T>, paramName: string): asserts param is T;
35
+ static checkNotNullOrWhiteSpace(param: Record<string, Optional<string>>): asserts param is Record<string, string>;
36
+ static checkNotNullOrWhiteSpace(param: Optional<string>, paramName: string): asserts param is string;
37
+ static checkNonNegative(param: Record<string, number>): void;
38
+ static checkNonNegative(param: number, paramName: string): void;
39
+ static checkPositive(param: Record<string, number>): void;
40
+ static checkPositive(param: number, paramName: string): void;
41
+ static checkNegative(param: Record<string, number>): void;
42
+ static checkNegative(param: number, paramName: string): void;
43
+ static checkNonPositive(param: Record<string, number>): void;
44
+ static checkNonPositive(param: number, paramName: string): void;
45
+ static checkInRange(param: Record<string, number>, min: number, max: number): void;
46
+ static checkInRange(param: number, min: number, max: number, paramName: string): void;
47
+ static checkInteger(param: Record<string, number>): void;
48
+ static checkInteger(param: number, paramName: string): void;
49
+ static checkFinite(param: Record<string, number>): void;
50
+ static checkFinite(param: number, paramName: string): void;
51
+ static checkNotNaN(param: Record<string, number>): void;
52
+ static checkNotNaN(param: number, paramName: string): void;
53
+ static checkSafeInteger(param: Record<string, number>): void;
54
+ static checkSafeInteger(param: number, paramName: string): void;
55
+ static checkArrayIndex(param: Record<string, number>, arrayLength?: number): void;
56
+ static checkArrayIndex(param: number, paramName: string, arrayLength?: number): void;
57
+ static checkFunction(param: Record<string, unknown>): asserts param is Record<string, Function>;
58
+ static checkFunction(param: unknown, paramName: string): asserts param is Function;
59
+ static checkIterable<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Iterable<T>>;
60
+ static checkIterable<T = unknown>(param: unknown, paramName: string): asserts param is Iterable<T>;
61
+ static checkIterator<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Iterator<T>>;
62
+ static checkIterator<T = unknown>(param: unknown, paramName: string): asserts param is Iterator<T>;
63
+ static checkEnumerable<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Enumerable<T>>;
64
+ static checkEnumerable<T = unknown>(param: unknown, paramName: string): asserts param is Enumerable<T>;
65
+ static checkEnumerator<T = unknown>(param: Record<string, unknown>): asserts param is Record<string, Enumerator<T>>;
66
+ static checkEnumerator<T = unknown>(param: unknown, paramName: string): asserts param is Enumerator<T>;
67
+ static checkInstanceOf<T>(param: Record<string, unknown>, constructor: new (...args: any[]) => T): asserts param is Record<string, T>;
68
+ static checkInstanceOf<T>(param: unknown, constructor: new (...args: any[]) => T, paramName: string): asserts param is T;
69
+ static checkHasLength(param: Record<string, unknown>): asserts param is Record<string, HasLength>;
70
+ static checkHasLength(param: unknown, paramName: string): asserts param is HasLength;
71
+ static check<T>(param: Record<string, T>, predicate: (v: T) => boolean, message: string): void;
72
+ static check<T>(param: T, paramName: string, predicate: (v: T) => boolean, message: string): void;
73
+ private static extractParameter;
74
+ }
75
+
76
+ /**
77
+ * Describes a method (function-valued own property) on a reflected target.
78
+ *
79
+ * @group Reflection
80
+ */
81
+ interface MethodDescriptor {
82
+ readonly kind: "method";
83
+ readonly name: string | symbol;
84
+ /** The raw function value. */
85
+ readonly value: Function;
86
+ /** Calls the method with the given `this` context and arguments. */
87
+ readonly invoke: (thisArg: unknown, ...args: unknown[]) => unknown;
88
+ }
89
+ /**
90
+ * Describes a data property (non-function own value property) on a reflected target.
91
+ *
92
+ * @group Reflection
93
+ */
94
+ interface DataDescriptor {
95
+ readonly kind: "data";
96
+ readonly name: string | symbol;
97
+ readonly value: unknown;
98
+ readonly writable: boolean;
99
+ readonly configurable: boolean;
100
+ readonly enumerable: boolean;
101
+ }
102
+ /**
103
+ * Describes an accessor property (get and/or set) on a reflected target.
104
+ *
105
+ * @group Reflection
106
+ */
107
+ interface AccessorDescriptor {
108
+ readonly kind: "accessor";
109
+ readonly name: string | symbol;
110
+ readonly get: Maybe<() => unknown>;
111
+ readonly set: Maybe<(value: unknown) => void>;
112
+ readonly configurable: boolean;
113
+ readonly enumerable: boolean;
114
+ /** `true` if the accessor defines a getter. */
115
+ readonly canRead: boolean;
116
+ /** `true` if the accessor defines a setter. */
117
+ readonly canWrite: boolean;
118
+ }
119
+ /**
120
+ * A discriminated union of all member descriptor types returned by {@link ReflectionContext}.
121
+ *
122
+ * Use `descriptor.kind` to narrow to the specific descriptor type.
123
+ *
124
+ * @group Reflection
125
+ */
126
+ type MemberDescriptor = MethodDescriptor | DataDescriptor | AccessorDescriptor;
127
+ /**
128
+ * Options for the {@link reflect} factory.
129
+ *
130
+ * @group Reflection
131
+ */
132
+ interface ReflectOptions {
133
+ /**
134
+ * When `true`, walks the full prototype chain and includes inherited members
135
+ * up to (but not including) `Object.prototype`.
136
+ *
137
+ * Equivalent to C# `BindingFlags.FlattenHierarchy`.
138
+ *
139
+ * @defaultValue false
140
+ */
141
+ readonly inherited?: boolean;
142
+ /**
143
+ * When `true`, includes Symbol-keyed members in addition to string-keyed members.
144
+ *
145
+ * @defaultValue false
146
+ */
147
+ readonly symbols?: boolean;
148
+ }
149
+
150
+ /**
151
+ * The result of a {@link reflect} call. Provides typed access to the members of
152
+ * the reflected target.
153
+ *
154
+ * @group Reflection
155
+ */
156
+ declare class ReflectionContext<_T extends object> {
157
+ private readonly proto;
158
+ private readonly options;
159
+ /** @internal */
160
+ constructor(proto: object, options: ReflectOptions);
161
+ /**
162
+ * Returns descriptors for all own (and optionally inherited) members,
163
+ * excluding `constructor`.
164
+ */
165
+ members(): readonly MemberDescriptor[];
166
+ /**
167
+ * Returns descriptors for all method members (function-valued own properties),
168
+ * excluding `constructor`.
169
+ */
170
+ methods(): readonly MethodDescriptor[];
171
+ /**
172
+ * Returns descriptors for all data members (non-function value properties).
173
+ */
174
+ fields(): readonly DataDescriptor[];
175
+ /**
176
+ * Returns descriptors for all accessor members (get/set properties).
177
+ */
178
+ accessors(): readonly AccessorDescriptor[];
179
+ /**
180
+ * Returns the descriptor for the named member, or `undefined` if not found.
181
+ */
182
+ get(name: string | symbol): Maybe<MemberDescriptor>;
183
+ /**
184
+ * Returns `true` if a member with the given name exists on the target.
185
+ */
186
+ has(name: string | symbol): boolean;
187
+ /**
188
+ * Returns the method descriptor for `name`, or throws {@link ReflectionError}
189
+ * if the member does not exist or is not a method.
190
+ *
191
+ * @throws {ReflectionError} when the member is absent or is not a method.
192
+ */
193
+ getMethod(name: string | symbol): MethodDescriptor;
194
+ /**
195
+ * Returns the accessor descriptor for `name`, or throws {@link ReflectionError}
196
+ * if the member does not exist or is not an accessor.
197
+ *
198
+ * @throws {ReflectionError} when the member is absent or is not an accessor.
199
+ */
200
+ getAccessor(name: string | symbol): AccessorDescriptor;
201
+ /**
202
+ * Returns `true` if a method with the given name exists on the target.
203
+ *
204
+ * Unlike {@link has}, this returns `false` if the member exists but is an accessor or data property.
205
+ */
206
+ hasMethod(name: string | symbol): boolean;
207
+ /**
208
+ * Returns the method descriptor for `name`, or `undefined` if the member does not
209
+ * exist or is not a method. Never throws.
210
+ */
211
+ tryGetMethod(name: string | symbol): Maybe<MethodDescriptor>;
212
+ private findDescriptor;
213
+ private collectDescriptors;
214
+ }
215
+ /**
216
+ * Creates a {@link ReflectionContext} for the given target.
217
+ *
218
+ * The `target` can be:
219
+ * - A **constructor function** - reflects the class prototype (instance members). Preferred form.
220
+ * - A **prototype object** (`MyClass.prototype`) - reflects it directly.
221
+ * - Any **object** - reflects the object's own properties directly.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * import { reflect } from "tyneq/utility";
226
+ *
227
+ * class Service {
228
+ * public name = "svc";
229
+ * public get label(): string { return this.name; }
230
+ * public run(): void { /* ... *\/ }
231
+ * }
232
+ *
233
+ * const ctx = reflect(Service);
234
+ *
235
+ * ctx.methods(); // -> [{ kind: "method", name: "run", ... }]
236
+ * ctx.accessors(); // -> [{ kind: "accessor", name: "label", canRead: true, canWrite: false, ... }]
237
+ *
238
+ * const m = ctx.getMethod("run");
239
+ * m.invoke(new Service()); // calls run()
240
+ * ```
241
+ *
242
+ * Walk the full prototype chain:
243
+ *
244
+ * ```ts
245
+ * const ctx = reflect(DerivedClass, { inherited: true });
246
+ * ctx.members(); // includes members from base classes too
247
+ * ```
248
+ *
249
+ * @group Reflection
250
+ */
251
+ declare function reflect<T extends object>(target: (new (...args: any[]) => T) | T, options?: ReflectOptions): ReflectionContext<T>;
252
+
253
+ /**
254
+ * Type guard predicates for Tyneq's core protocol types.
255
+ *
256
+ * @group Utilities
257
+ */
258
+ declare class TypeGuardUtility {
259
+ private constructor();
260
+ static isIterable<T = unknown>(value: unknown): value is Iterable<T>;
261
+ static isIterator<T = unknown>(value: unknown): value is Iterator<T>;
262
+ static isIterableIterator<T = unknown>(value: unknown): value is IterableIterator<T>;
263
+ static isEnumerator<T = unknown>(value: unknown): value is Enumerator<T>;
264
+ static isEnumerable<T = unknown>(value: unknown): value is Enumerable<T>;
265
+ }
266
+
267
+ /**
268
+ * Utility class for lazy initialization of values.
269
+ *
270
+ * @group Utilities
271
+ */
272
+ declare class Lazy<T> {
273
+ private readonly factory;
274
+ /** The lazily initialized value, or `undefined` if not yet initialized. */
275
+ private lazyValue;
276
+ /** Indicates whether the value has been initialized. */
277
+ private initialized;
278
+ constructor(factory: Factory<T, []>);
279
+ /** Returns the lazily initialized value, initializing it if necessary. */
280
+ get value(): T;
281
+ }
282
+
283
+ /**
284
+ * Accumulates validation errors and throws a single `ValidationError` containing all of them.
285
+ *
286
+ * Use when multiple independent arguments must be validated together so callers see all
287
+ * failures in one throw rather than one at a time.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * new ValidationBuilder()
292
+ * .check(() => ArgumentUtility.checkNotOptional({ selector }))
293
+ * .check(() => ArgumentUtility.checkPositive({ count }))
294
+ * .throwIfAny();
295
+ * ```
296
+ *
297
+ * @group Utilities
298
+ */
299
+ declare class ValidationBuilder {
300
+ private readonly errors;
301
+ /**
302
+ * Runs `fn` and collects any thrown error message. Returns `this` for chaining.
303
+ */
304
+ check(fn: () => void): this;
305
+ /**
306
+ * Throws a `ValidationError` with all collected messages if any `check` calls failed.
307
+ * Does nothing when no errors were collected.
308
+ */
309
+ throwIfAny(): void;
310
+ }
311
+
312
+ export { type AccessorDescriptor, ArgumentUtility, type DataDescriptor, Lazy, type MemberDescriptor, type MethodDescriptor, type ReflectOptions, ReflectionContext, TypeGuardUtility, ValidationBuilder, reflect };
@@ -1,3 +1,18 @@
1
- import { a as ArgumentUtility, n as ReflectionContext, o as TypeGuardUtility, r as reflect, t as Lazy } from "../Lazy.js";
2
- import { t as ValidationBuilder } from "../ValidationBuilder.js";
3
- export { ArgumentUtility, Lazy, ReflectionContext, TypeGuardUtility, ValidationBuilder, reflect };
1
+ import {
2
+ ValidationBuilder
3
+ } from "../chunk-PCBN5AFG.js";
4
+ import {
5
+ ArgumentUtility,
6
+ Lazy,
7
+ ReflectionContext,
8
+ TypeGuardUtility,
9
+ reflect
10
+ } from "../chunk-5R4AALC7.js";
11
+ export {
12
+ ArgumentUtility,
13
+ Lazy,
14
+ ReflectionContext,
15
+ TypeGuardUtility,
16
+ ValidationBuilder,
17
+ reflect
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tyneq",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Lazy query pipelines for TypeScript.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "LICENSE"
29
29
  ],
30
30
  "scripts": {
31
- "build": "tsc --noEmit && eslint src tests && tsdown",
32
- "dev": "tsdown --watch",
31
+ "build": "tsc --noEmit && eslint src tests && tsup",
32
+ "dev": "tsup --watch",
33
33
  "test": "vitest run",
34
34
  "test:watch": "vitest",
35
35
  "test:coverage": "vitest run --coverage",
@@ -65,7 +65,7 @@
65
65
  "author": "chrisitopherus",
66
66
  "license": "MIT",
67
67
  "engines": {
68
- "node": ">=20.19.0"
68
+ "node": ">=18"
69
69
  },
70
70
  "sideEffects": [
71
71
  "./dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "eslint": "^10.0.3",
85
85
  "gh-pages": "^6.3.0",
86
86
  "jiti": "^2.6.1",
87
- "tsdown": "^0.21.10",
87
+ "tsup": "8.5.1",
88
88
  "tsx": "^4.21.0",
89
89
  "typedoc": "^0.28.13",
90
90
  "typedoc-plugin-markdown": "^4.9.0",