@nestia/e2e 11.0.0-dev.20260312 → 11.0.0-dev.20260313

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,176 +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 __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.DynamicExecutor = void 0;
49
- const fs_1 = __importDefault(require("fs"));
50
- const path_1 = __importDefault(require("path"));
51
- /**
52
- * Dynamic Executor running prefixed functions.
53
- *
54
- * `DynamicExecutor` runs every (or some filtered) prefixed functions in a
55
- * specific directory.
56
- *
57
- * For reference, it's useful for test program development of a backend server.
58
- * Just write test functions under a directory, and just specify it.
59
- * Furthermore, if you compose e2e test programs to utilize the `@nestia/sdk`
60
- * generated API functions, you can take advantage of {@link DynamicBenchmarker}
61
- * at the same time.
62
- *
63
- * When you want to see some utilization cases, see the below example links.
64
- *
65
- * @author Jeongho Nam - https://github.com/samchon
66
- * @example
67
- * https://github.com/samchon/nestia-start/blob/master/test/index.ts
68
- *
69
- * @example
70
- * https://github.com/samchon/backend/blob/master/test/index.ts
71
- */
72
- var DynamicExecutor;
73
- (function (DynamicExecutor) {
74
- /**
75
- * Prepare dynamic executor in strict mode.
76
- *
77
- * In strict mode, if any error occurs, the program will be terminated
78
- * directly. Otherwise, {@link validate} mode does not terminate when error
79
- * occurs, but just archive the error log.
80
- *
81
- * @param props Properties of dynamic execution
82
- * @returns Report of dynamic test functions execution
83
- */
84
- DynamicExecutor.assert = (props) => main(true)(props);
85
- /**
86
- * Prepare dynamic executor in loose mode.
87
- *
88
- * In loose mode, the program would not be terminated even when error occurs.
89
- * Instead, the error would be archived and returns as a list. Otherwise,
90
- * {@link assert} mode terminates the program directly when error occurs.
91
- *
92
- * @param props Properties of dynamic executor
93
- * @returns Report of dynamic test functions execution
94
- */
95
- DynamicExecutor.validate = (props) => main(false)(props);
96
- const main = (assert) => (props) => __awaiter(this, void 0, void 0, function* () {
97
- var _a, _b;
98
- const report = {
99
- location: props.location,
100
- time: Date.now(),
101
- executions: [],
102
- };
103
- const executor = execute(props)(report)(assert);
104
- const processes = yield iterate({
105
- extension: (_a = props.extension) !== null && _a !== void 0 ? _a : "js",
106
- location: props.location,
107
- executor,
108
- });
109
- yield Promise.all(new Array((_b = props.simultaneous) !== null && _b !== void 0 ? _b : 1).fill(0).map(() => __awaiter(this, void 0, void 0, function* () {
110
- while (processes.length !== 0) {
111
- const task = processes.shift();
112
- yield (task === null || task === void 0 ? void 0 : task());
113
- }
114
- })));
115
- report.time = Date.now() - report.time;
116
- return report;
117
- });
118
- const iterate = (props) => __awaiter(this, void 0, void 0, function* () {
119
- const container = [];
120
- const visitor = (path) => __awaiter(this, void 0, void 0, function* () {
121
- const directory = yield fs_1.default.promises.readdir(path);
122
- for (const file of directory) {
123
- const location = path_1.default.resolve(`${path}/${file}`);
124
- const stats = yield fs_1.default.promises.lstat(location);
125
- if (stats.isDirectory() === true) {
126
- yield visitor(location);
127
- continue;
128
- }
129
- else if (file.substr(-3) !== `.${props.extension}`)
130
- continue;
131
- const modulo = yield Promise.resolve(`${location}`).then(s => __importStar(require(s)));
132
- container.push(() => props.executor(location, modulo));
133
- }
134
- });
135
- yield visitor(props.location);
136
- return container;
137
- });
138
- const execute = (props) => (report) => (assert) => (location, modulo) => __awaiter(this, void 0, void 0, function* () {
139
- for (const [key, closure] of Object.entries(modulo)) {
140
- if (key.substring(0, props.prefix.length) !== props.prefix ||
141
- typeof closure !== "function" ||
142
- (props.filter && props.filter(key) === false))
143
- continue;
144
- const func = () => {
145
- if (props.wrapper !== undefined)
146
- return props.wrapper(key, closure, props.parameters(key));
147
- else
148
- return closure(...props.parameters(key));
149
- };
150
- const result = {
151
- name: key,
152
- location,
153
- value: undefined,
154
- error: null,
155
- started_at: new Date().toISOString(),
156
- completed_at: new Date().toISOString(),
157
- };
158
- report.executions.push(result);
159
- try {
160
- result.value = yield func();
161
- result.completed_at = new Date().toISOString();
162
- }
163
- catch (exp) {
164
- result.error = exp;
165
- if (assert === true)
166
- throw exp;
167
- }
168
- finally {
169
- result.completed_at = new Date().toISOString();
170
- if (props.onComplete)
171
- props.onComplete(result);
172
- }
173
- }
174
- });
175
- })(DynamicExecutor || (exports.DynamicExecutor = DynamicExecutor = {}));
176
- //# sourceMappingURL=DynamicExecutor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicExecutor.js","sourceRoot":"","sources":["../src/DynamicExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAA4B;AAE5B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,IAAiB,eAAe,CAyP/B;AAzPD,WAAiB,eAAe;IA0H9B;;;;;;;;;OASG;IACU,sBAAM,GAAG,CACpB,KAAwB,EACN,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IAEzC;;;;;;;;;OASG;IACU,wBAAQ,GAAG,CACtB,KAAwB,EACN,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,IAAI,GACR,CAAC,MAAe,EAAE,EAAE,CACpB,CACE,KAAwB,EACN,EAAE;;QACpB,MAAM,MAAM,GAAY;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;YAChB,UAAU,EAAE,EAAE;SACf,CAAC;QAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,SAAS,GAA+B,MAAM,OAAO,CAAC;YAC1D,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,IAAI;YAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,KAAK,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,CAAC,CAAC,CAAC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CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAE/B,IAAI,CAAC;gBACH,MAAM,CAAC,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;gBAC5B,MAAM,CAAC,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACjD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,GAAG,GAAY,CAAC;gBAC5B,IAAI,MAAM,KAAK,IAAI;oBAAE,MAAM,GAAG,CAAC;YACjC,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;gBAC/C,IAAI,KAAK,CAAC,UAAU;oBAAE,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC,CAAA,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
- }