@nestia/e2e 10.0.1 → 11.0.0-dev.20260305

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.
@@ -1,373 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __generator = (this && this.__generator) || function (thisArg, body) {
45
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
46
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
47
- function verb(n) { return function (v) { return step([n, v]); }; }
48
- function step(op) {
49
- if (f) throw new TypeError("Generator is already executing.");
50
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
51
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
52
- if (y = 0, t) op = [op[0] & 2, t.value];
53
- switch (op[0]) {
54
- case 0: case 1: t = op; break;
55
- case 4: _.label++; return { value: op[1], done: false };
56
- case 5: _.label++; y = op[1]; op = [0]; continue;
57
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
58
- default:
59
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
60
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
61
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
62
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
63
- if (t[2]) _.ops.pop();
64
- _.trys.pop(); continue;
65
- }
66
- op = body.call(thisArg, _);
67
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
68
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
69
- }
70
- };
71
- var __values = (this && this.__values) || function(o) {
72
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
73
- if (m) return m.call(o);
74
- if (o && typeof o.length === "number") return {
75
- next: function () {
76
- if (o && i >= o.length) o = void 0;
77
- return { value: o && o[i++], done: !o };
78
- }
79
- };
80
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
81
- };
82
- var __read = (this && this.__read) || function (o, n) {
83
- var m = typeof Symbol === "function" && o[Symbol.iterator];
84
- if (!m) return o;
85
- var i = m.call(o), r, ar = [], e;
86
- try {
87
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
88
- }
89
- catch (error) { e = { error: error }; }
90
- finally {
91
- try {
92
- if (r && !r.done && (m = i["return"])) m.call(i);
93
- }
94
- finally { if (e) throw e.error; }
95
- }
96
- return ar;
97
- };
98
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
99
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
100
- if (ar || !(i in from)) {
101
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
102
- ar[i] = from[i];
103
- }
104
- }
105
- return to.concat(ar || Array.prototype.slice.call(from));
106
- };
107
- var __importDefault = (this && this.__importDefault) || function (mod) {
108
- return (mod && mod.__esModule) ? mod : { "default": mod };
109
- };
110
- Object.defineProperty(exports, "__esModule", { value: true });
111
- exports.DynamicExecutor = void 0;
112
- var fs_1 = __importDefault(require("fs"));
113
- var path_1 = __importDefault(require("path"));
114
- /**
115
- * Dynamic Executor running prefixed functions.
116
- *
117
- * `DynamicExecutor` runs every (or some filtered) prefixed functions in a
118
- * specific directory.
119
- *
120
- * For reference, it's useful for test program development of a backend server.
121
- * Just write test functions under a directory, and just specify it.
122
- * Furthermore, if you compose e2e test programs to utilize the `@nestia/sdk`
123
- * generated API functions, you can take advantage of {@link DynamicBenchmarker}
124
- * at the same time.
125
- *
126
- * When you want to see some utilization cases, see the below example links.
127
- *
128
- * @author Jeongho Nam - https://github.com/samchon
129
- * @example
130
- * https://github.com/samchon/nestia-start/blob/master/test/index.ts
131
- *
132
- * @example
133
- * https://github.com/samchon/backend/blob/master/test/index.ts
134
- */
135
- var DynamicExecutor;
136
- (function (DynamicExecutor) {
137
- var _this = this;
138
- /**
139
- * Prepare dynamic executor in strict mode.
140
- *
141
- * In strict mode, if any error occurs, the program will be terminated
142
- * directly. Otherwise, {@link validate} mode does not terminate when error
143
- * occurs, but just archive the error log.
144
- *
145
- * @param props Properties of dynamic execution
146
- * @returns Report of dynamic test functions execution
147
- */
148
- DynamicExecutor.assert = function (props) { return main(true)(props); };
149
- /**
150
- * Prepare dynamic executor in loose mode.
151
- *
152
- * In loose mode, the program would not be terminated even when error occurs.
153
- * Instead, the error would be archived and returns as a list. Otherwise,
154
- * {@link assert} mode terminates the program directly when error occurs.
155
- *
156
- * @param props Properties of dynamic executor
157
- * @returns Report of dynamic test functions execution
158
- */
159
- DynamicExecutor.validate = function (props) { return main(false)(props); };
160
- var main = function (assert) {
161
- return function (props) { return __awaiter(_this, void 0, void 0, function () {
162
- var report, executor, processes;
163
- var _this = this;
164
- var _a, _b;
165
- return __generator(this, function (_c) {
166
- switch (_c.label) {
167
- case 0:
168
- report = {
169
- location: props.location,
170
- time: Date.now(),
171
- executions: [],
172
- };
173
- executor = execute(props)(report)(assert);
174
- return [4 /*yield*/, iterate({
175
- extension: (_a = props.extension) !== null && _a !== void 0 ? _a : "js",
176
- location: props.location,
177
- executor: executor,
178
- })];
179
- case 1:
180
- processes = _c.sent();
181
- return [4 /*yield*/, Promise.all(new Array((_b = props.simultaneous) !== null && _b !== void 0 ? _b : 1).fill(0).map(function () { return __awaiter(_this, void 0, void 0, function () {
182
- var task;
183
- return __generator(this, function (_a) {
184
- switch (_a.label) {
185
- case 0:
186
- if (!(processes.length !== 0)) return [3 /*break*/, 2];
187
- task = processes.shift();
188
- return [4 /*yield*/, (task === null || task === void 0 ? void 0 : task())];
189
- case 1:
190
- _a.sent();
191
- return [3 /*break*/, 0];
192
- case 2: return [2 /*return*/];
193
- }
194
- });
195
- }); }))];
196
- case 2:
197
- _c.sent();
198
- report.time = Date.now() - report.time;
199
- return [2 /*return*/, report];
200
- }
201
- });
202
- }); };
203
- };
204
- var iterate = function (props) { return __awaiter(_this, void 0, void 0, function () {
205
- var container, visitor;
206
- var _this = this;
207
- return __generator(this, function (_a) {
208
- switch (_a.label) {
209
- case 0:
210
- container = [];
211
- visitor = function (path) { return __awaiter(_this, void 0, void 0, function () {
212
- var directory, _loop_1, directory_1, directory_1_1, file, e_1_1;
213
- var e_1, _a;
214
- return __generator(this, function (_b) {
215
- switch (_b.label) {
216
- case 0: return [4 /*yield*/, fs_1.default.promises.readdir(path)];
217
- case 1:
218
- directory = _b.sent();
219
- _loop_1 = function (file) {
220
- var location_1, stats, modulo;
221
- return __generator(this, function (_c) {
222
- switch (_c.label) {
223
- case 0:
224
- location_1 = path_1.default.resolve("".concat(path, "/").concat(file));
225
- return [4 /*yield*/, fs_1.default.promises.lstat(location_1)];
226
- case 1:
227
- stats = _c.sent();
228
- if (!(stats.isDirectory() === true)) return [3 /*break*/, 3];
229
- return [4 /*yield*/, visitor(location_1)];
230
- case 2:
231
- _c.sent();
232
- return [2 /*return*/, "continue"];
233
- case 3:
234
- if (file.substr(-3) !== ".".concat(props.extension))
235
- return [2 /*return*/, "continue"];
236
- _c.label = 4;
237
- case 4: return [4 /*yield*/, Promise.resolve("".concat(location_1)).then(function (s) { return __importStar(require(s)); })];
238
- case 5:
239
- modulo = _c.sent();
240
- container.push(function () { return props.executor(location_1, modulo); });
241
- return [2 /*return*/];
242
- }
243
- });
244
- };
245
- _b.label = 2;
246
- case 2:
247
- _b.trys.push([2, 7, 8, 9]);
248
- directory_1 = __values(directory), directory_1_1 = directory_1.next();
249
- _b.label = 3;
250
- case 3:
251
- if (!!directory_1_1.done) return [3 /*break*/, 6];
252
- file = directory_1_1.value;
253
- return [5 /*yield**/, _loop_1(file)];
254
- case 4:
255
- _b.sent();
256
- _b.label = 5;
257
- case 5:
258
- directory_1_1 = directory_1.next();
259
- return [3 /*break*/, 3];
260
- case 6: return [3 /*break*/, 9];
261
- case 7:
262
- e_1_1 = _b.sent();
263
- e_1 = { error: e_1_1 };
264
- return [3 /*break*/, 9];
265
- case 8:
266
- try {
267
- if (directory_1_1 && !directory_1_1.done && (_a = directory_1.return)) _a.call(directory_1);
268
- }
269
- finally { if (e_1) throw e_1.error; }
270
- return [7 /*endfinally*/];
271
- case 9: return [2 /*return*/];
272
- }
273
- });
274
- }); };
275
- return [4 /*yield*/, visitor(props.location)];
276
- case 1:
277
- _a.sent();
278
- return [2 /*return*/, container];
279
- }
280
- });
281
- }); };
282
- var execute = function (props) {
283
- return function (report) {
284
- return function (assert) {
285
- return function (location, modulo) { return __awaiter(_this, void 0, void 0, function () {
286
- var _loop_2, _a, _b, _c, key, closure, e_2_1;
287
- var e_2, _d;
288
- return __generator(this, function (_e) {
289
- switch (_e.label) {
290
- case 0:
291
- _loop_2 = function (key, closure) {
292
- var func, result, _f, exp_1;
293
- return __generator(this, function (_g) {
294
- switch (_g.label) {
295
- case 0:
296
- if (key.substring(0, props.prefix.length) !== props.prefix ||
297
- typeof closure !== "function" ||
298
- (props.filter && props.filter(key) === false))
299
- return [2 /*return*/, "continue"];
300
- func = function () {
301
- if (props.wrapper !== undefined)
302
- return props.wrapper(key, closure, props.parameters(key));
303
- else
304
- return closure.apply(void 0, __spreadArray([], __read(props.parameters(key)), false));
305
- };
306
- result = {
307
- name: key,
308
- location: location,
309
- value: undefined,
310
- error: null,
311
- started_at: new Date().toISOString(),
312
- completed_at: new Date().toISOString(),
313
- };
314
- report.executions.push(result);
315
- _g.label = 1;
316
- case 1:
317
- _g.trys.push([1, 3, 4, 5]);
318
- _f = result;
319
- return [4 /*yield*/, func()];
320
- case 2:
321
- _f.value = _g.sent();
322
- result.completed_at = new Date().toISOString();
323
- return [3 /*break*/, 5];
324
- case 3:
325
- exp_1 = _g.sent();
326
- result.error = exp_1;
327
- if (assert === true)
328
- throw exp_1;
329
- return [3 /*break*/, 5];
330
- case 4:
331
- result.completed_at = new Date().toISOString();
332
- if (props.onComplete)
333
- props.onComplete(result);
334
- return [7 /*endfinally*/];
335
- case 5: return [2 /*return*/];
336
- }
337
- });
338
- };
339
- _e.label = 1;
340
- case 1:
341
- _e.trys.push([1, 6, 7, 8]);
342
- _a = __values(Object.entries(modulo)), _b = _a.next();
343
- _e.label = 2;
344
- case 2:
345
- if (!!_b.done) return [3 /*break*/, 5];
346
- _c = __read(_b.value, 2), key = _c[0], closure = _c[1];
347
- return [5 /*yield**/, _loop_2(key, closure)];
348
- case 3:
349
- _e.sent();
350
- _e.label = 4;
351
- case 4:
352
- _b = _a.next();
353
- return [3 /*break*/, 2];
354
- case 5: return [3 /*break*/, 8];
355
- case 6:
356
- e_2_1 = _e.sent();
357
- e_2 = { error: e_2_1 };
358
- return [3 /*break*/, 8];
359
- case 7:
360
- try {
361
- if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
362
- }
363
- finally { if (e_2) throw e_2.error; }
364
- return [7 /*endfinally*/];
365
- case 8: return [2 /*return*/];
366
- }
367
- });
368
- }); };
369
- };
370
- };
371
- };
372
- })(DynamicExecutor || (exports.DynamicExecutor = DynamicExecutor = {}));
373
- //# sourceMappingURL=DynamicExecutor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicExecutor.js","sourceRoot":"","sources":["../src/DynamicExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoB;AACpB,8CAA4B;AAE5B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,IAAiB,eAAe,CAyP/B;AAzPD,WAAiB,eAAe;;IA0H9B;;;;;;;;;OASG;IACU,sBAAM,GAAG,UACpB,KAAwB,IACH,OAAA,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAjB,CAAiB,CAAC;IAEzC;;;;;;;;;OASG;IACU,wBAAQ,GAAG,UACtB,KAAwB,IACH,OAAA,IAAI,CAAC,K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;;;;;;;;;;;;;;;;;qBAmCzB;YApCD,CAoCC;QArCD,CAqCC;IAtCD,CAsCC,CAAC;AAKN,CAAC,EAzPgB,eAAe,+BAAf,eAAe,QAyP/B"}
@@ -1,255 +0,0 @@
1
- /**
2
- * Type-safe comparator functions for Array.sort() operations with advanced
3
- * field access.
4
- *
5
- * GaffComparator provides a collection of specialized comparator functions
6
- * designed to work seamlessly with Array.sort() and testing frameworks like
7
- * TestValidator.sort(). Each comparator supports both single values and arrays
8
- * of values, enabling complex multi-field sorting scenarios with lexicographic
9
- * ordering.
10
- *
11
- * Key features:
12
- *
13
- * - Generic type safety for any object structure
14
- * - Support for single values or arrays of values per field
15
- * - Lexicographic comparison for multi-value scenarios
16
- * - Locale-aware string comparison
17
- * - Automatic type conversion for dates and numbers
18
- *
19
- * The comparators follow the standard JavaScript sort contract:
20
- *
21
- * - Return < 0 if first element should come before second
22
- * - Return > 0 if first element should come after second
23
- * - Return 0 if elements are equal
24
- *
25
- * @author Jeongho Nam - https://github.com/samchon
26
- * @example
27
- * ```typescript
28
- * // Basic usage with single fields
29
- * users.sort(GaffComparator.strings(user => user.name));
30
- * posts.sort(GaffComparator.dates(post => post.createdAt));
31
- * products.sort(GaffComparator.numbers(product => product.price));
32
- *
33
- * // Multi-field sorting with arrays
34
- * users.sort(GaffComparator.strings(user => [user.lastName, user.firstName]));
35
- * events.sort(GaffComparator.dates(event => [event.startDate, event.endDate]));
36
- *
37
- * // Integration with TestValidator's currying pattern
38
- * const validator = TestValidator.sort("user sorting",
39
- * (sortable) => api.getUsers({ sort: sortable })
40
- * )("name", "email")(
41
- * GaffComparator.strings(user => [user.name, user.email])
42
- * );
43
- * await validator("+"); // ascending
44
- * await validator("-"); // descending
45
- * ```;
46
- */
47
- export declare namespace GaffComparator {
48
- /**
49
- * Creates a comparator function for string-based sorting with locale-aware
50
- * comparison.
51
- *
52
- * Generates a comparator that extracts string values from objects and
53
- * performs lexicographic comparison using locale-sensitive string comparison.
54
- * Supports both single strings and arrays of strings for multi-field sorting
55
- * scenarios.
56
- *
57
- * When comparing arrays, performs lexicographic ordering: compares the first
58
- * elements, then the second elements if the first are equal, and so on. This
59
- * enables complex sorting like "sort by last name, then by first name".
60
- *
61
- * @example
62
- * ```typescript
63
- * interface User {
64
- * id: string;
65
- * firstName: string;
66
- * lastName: string;
67
- * email: string;
68
- * status: 'active' | 'inactive';
69
- * }
70
- *
71
- * const users: User[] = [
72
- * { id: '1', firstName: 'John', lastName: 'Doe', email: 'john@example.com', status: 'active' },
73
- * { id: '2', firstName: 'Jane', lastName: 'Doe', email: 'jane@example.com', status: 'inactive' },
74
- * { id: '3', firstName: 'Bob', lastName: 'Smith', email: 'bob@example.com', status: 'active' }
75
- * ];
76
- *
77
- * // Single field sorting
78
- * users.sort(GaffComparator.strings(user => user.lastName));
79
- * // Result: Doe, Doe, Smith
80
- *
81
- * // Multi-field sorting: last name, then first name
82
- * users.sort(GaffComparator.strings(user => [user.lastName, user.firstName]));
83
- * // Result: Doe Jane, Doe John, Smith Bob
84
- *
85
- * // Status-based sorting
86
- * users.sort(GaffComparator.strings(user => user.status));
87
- * // Result: active users first, then inactive
88
- *
89
- * // Complex multi-field: status, then last name, then first name
90
- * users.sort(GaffComparator.strings(user => [user.status, user.lastName, user.firstName]));
91
- *
92
- * // Integration with TestValidator sorting validation
93
- * const sortValidator = TestValidator.sort("user name sorting",
94
- * (sortFields) => userApi.getUsers({ sort: sortFields })
95
- * )("lastName", "firstName")(
96
- * GaffComparator.strings(user => [user.lastName, user.firstName])
97
- * );
98
- * await sortValidator("+"); // test ascending order
99
- * await sortValidator("-"); // test descending order
100
- * ```;
101
- *
102
- * @template T - The type of objects being compared
103
- * @param getter - Function that extracts string value(s) from input objects
104
- * @returns A comparator function suitable for Array.sort()
105
- */
106
- const strings: <T>(getter: (input: T) => string | string[]) => (x: T, y: T) => number;
107
- /**
108
- * Creates a comparator function for date-based sorting with automatic string
109
- * parsing.
110
- *
111
- * Generates a comparator that extracts date values from objects,
112
- * automatically converting string representations to Date objects for
113
- * numerical comparison. Supports both single dates and arrays of dates for
114
- * complex temporal sorting.
115
- *
116
- * Date strings are parsed using the standard Date constructor, which supports
117
- * ISO 8601 format, RFC 2822 format, and other common date representations.
118
- * The comparison is performed on millisecond timestamps for precise
119
- * ordering.
120
- *
121
- * @example
122
- * ```typescript
123
- * interface Event {
124
- * id: string;
125
- * title: string;
126
- * startDate: string;
127
- * endDate: string;
128
- * createdAt: string;
129
- * updatedAt: string;
130
- * }
131
- *
132
- * const events: Event[] = [
133
- * {
134
- * id: '1',
135
- * title: 'Conference',
136
- * startDate: '2024-03-15T09:00:00Z',
137
- * endDate: '2024-03-15T17:00:00Z',
138
- * createdAt: '2024-01-10T10:00:00Z',
139
- * updatedAt: '2024-02-01T15:30:00Z'
140
- * },
141
- * {
142
- * id: '2',
143
- * title: 'Workshop',
144
- * startDate: '2024-03-10T14:00:00Z',
145
- * endDate: '2024-03-10T16:00:00Z',
146
- * createdAt: '2024-01-15T11:00:00Z',
147
- * updatedAt: '2024-01-20T09:15:00Z'
148
- * }
149
- * ];
150
- *
151
- * // Sort by start date (chronological order)
152
- * events.sort(GaffComparator.dates(event => event.startDate));
153
- *
154
- * // Sort by creation date (oldest first)
155
- * events.sort(GaffComparator.dates(event => event.createdAt));
156
- *
157
- * // Multi-field: start date, then end date
158
- * events.sort(GaffComparator.dates(event => [event.startDate, event.endDate]));
159
- *
160
- * // Sort by modification history: created date, then updated date
161
- * events.sort(GaffComparator.dates(event => [event.createdAt, event.updatedAt]));
162
- *
163
- * // Validate API date sorting with TestValidator
164
- * const dateValidator = TestValidator.sort("event chronological sorting",
165
- * (sortFields) => eventApi.getEvents({ sort: sortFields })
166
- * )("startDate")(
167
- * GaffComparator.dates(event => event.startDate)
168
- * );
169
- * await dateValidator("+", true); // ascending with trace logging
170
- *
171
- * // Test complex date-based sorting
172
- * const sortByEventSchedule = GaffComparator.dates(event => [
173
- * event.startDate,
174
- * event.endDate
175
- * ]);
176
- * ```;
177
- *
178
- * @template T - The type of objects being compared
179
- * @param getter - Function that extracts date string(s) from input objects
180
- * @returns A comparator function suitable for Array.sort()
181
- */
182
- const dates: <T>(getter: (input: T) => string | string[]) => (x: T, y: T) => number;
183
- /**
184
- * Creates a comparator function for numerical sorting with multi-value
185
- * support.
186
- *
187
- * Generates a comparator that extracts numerical values from objects and
188
- * performs mathematical comparison. Supports both single numbers and arrays
189
- * of numbers for complex numerical sorting scenarios like sorting by price
190
- * then by rating.
191
- *
192
- * When comparing arrays, performs lexicographic numerical ordering: compares
193
- * the first numbers, then the second numbers if the first are equal, and so
194
- * on. This enables sophisticated sorting like "sort by price ascending, then
195
- * by rating descending".
196
- *
197
- * @example
198
- * ```typescript
199
- * interface Product {
200
- * id: string;
201
- * name: string;
202
- * price: number;
203
- * rating: number;
204
- * stock: number;
205
- * categoryId: number;
206
- * salesCount: number;
207
- * }
208
- *
209
- * const products: Product[] = [
210
- * { id: '1', name: 'Laptop', price: 999.99, rating: 4.5, stock: 15, categoryId: 1, salesCount: 150 },
211
- * { id: '2', name: 'Mouse', price: 29.99, rating: 4.2, stock: 50, categoryId: 1, salesCount: 300 },
212
- * { id: '3', name: 'Keyboard', price: 79.99, rating: 4.8, stock: 25, categoryId: 1, salesCount: 200 }
213
- * ];
214
- *
215
- * // Sort by price (ascending)
216
- * products.sort(GaffComparator.numbers(product => product.price));
217
- * // Result: Mouse ($29.99), Keyboard ($79.99), Laptop ($999.99)
218
- *
219
- * // Sort by rating (descending requires negation)
220
- * products.sort(GaffComparator.numbers(product => -product.rating));
221
- * // Result: Keyboard (4.8), Laptop (4.5), Mouse (4.2)
222
- *
223
- * // Multi-field: category, then price
224
- * products.sort(GaffComparator.numbers(product => [product.categoryId, product.price]));
225
- *
226
- * // Complex business logic: popularity (sales) then rating
227
- * products.sort(GaffComparator.numbers(product => [-product.salesCount, -product.rating]));
228
- * // Negative values for descending order
229
- *
230
- * // Sort by inventory priority: low stock first, then by sales
231
- * products.sort(GaffComparator.numbers(product => [product.stock, -product.salesCount]));
232
- *
233
- * // Validate API numerical sorting with TestValidator
234
- * const priceValidator = TestValidator.sort("product price sorting",
235
- * (sortFields) => productApi.getProducts({ sort: sortFields })
236
- * )("price")(
237
- * GaffComparator.numbers(product => product.price)
238
- * );
239
- * await priceValidator("+"); // test ascending order
240
- * await priceValidator("-"); // test descending order
241
- *
242
- * // Test multi-criteria sorting
243
- * const sortByBusinessValue = GaffComparator.numbers(product => [
244
- * -product.salesCount, // High sales first
245
- * -product.rating, // High rating first
246
- * product.price // Low price first (for tie-breaking)
247
- * ]);
248
- * ```;
249
- *
250
- * @template T - The type of objects being compared
251
- * @param closure - Function that extracts number value(s) from input objects
252
- * @returns A comparator function suitable for Array.sort()
253
- */
254
- const numbers: <T>(closure: (input: T) => number | number[]) => (x: T, y: T) => number;
255
- }