@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.
package/lib/ArrayUtil.js DELETED
@@ -1,410 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- 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);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __values = (this && this.__values) || function(o) {
39
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
- if (m) return m.call(o);
41
- if (o && typeof o.length === "number") return {
42
- next: function () {
43
- if (o && i >= o.length) o = void 0;
44
- return { value: o && o[i++], done: !o };
45
- }
46
- };
47
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.ArrayUtil = void 0;
51
- /**
52
- * A namespace providing utility functions for array manipulation.
53
- *
54
- * This namespace contains utility functions for array operations including
55
- * asynchronous processing, filtering, mapping, and repetition tasks implemented
56
- * in functional programming style. Functions use direct parameter passing for
57
- * simplicity while maintaining functional programming principles.
58
- *
59
- * @author Jeongho Nam - https://github.com/samchon
60
- * @example
61
- * ```typescript
62
- * // Asynchronous filtering example
63
- * const numbers = [1, 2, 3, 4, 5];
64
- * const evenNumbers = await ArrayUtil.asyncFilter(numbers,
65
- * async (num) => num % 2 === 0
66
- * );
67
- * console.log(evenNumbers); // [2, 4]
68
- * ```;
69
- */
70
- var ArrayUtil;
71
- (function (ArrayUtil) {
72
- var _this = this;
73
- /**
74
- * Filters an array by applying an asynchronous predicate function to each
75
- * element.
76
- *
77
- * Elements are processed sequentially, ensuring order is maintained. The
78
- * predicate function receives the element, index, and the full array as
79
- * parameters.
80
- *
81
- * @example
82
- * ```typescript
83
- * const users = [
84
- * { id: 1, name: 'Alice', active: true },
85
- * { id: 2, name: 'Bob', active: false },
86
- * { id: 3, name: 'Charlie', active: true }
87
- * ];
88
- *
89
- * const activeUsers = await ArrayUtil.asyncFilter(users,
90
- * async (user) => {
91
- * // Async validation logic (e.g., API call)
92
- * await new Promise(resolve => setTimeout(resolve, 100));
93
- * return user.active;
94
- * }
95
- * );
96
- * console.log(activeUsers); // [{ id: 1, name: 'Alice', active: true }, { id: 3, name: 'Charlie', active: true }]
97
- * ```;
98
- *
99
- * @template Input - The type of elements in the input array
100
- * @param elements - The readonly array to filter
101
- * @param pred - The asynchronous predicate function to test each element
102
- * @returns A Promise resolving to the filtered array
103
- */
104
- ArrayUtil.asyncFilter = function (elements, pred) { return __awaiter(_this, void 0, void 0, function () {
105
- var ret;
106
- var _this = this;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0:
110
- ret = [];
111
- return [4 /*yield*/, ArrayUtil.asyncForEach(elements, function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
112
- var flag;
113
- return __generator(this, function (_a) {
114
- switch (_a.label) {
115
- case 0: return [4 /*yield*/, pred(elem, index, array)];
116
- case 1:
117
- flag = _a.sent();
118
- if (flag === true)
119
- ret.push(elem);
120
- return [2 /*return*/];
121
- }
122
- });
123
- }); })];
124
- case 1:
125
- _a.sent();
126
- return [2 /*return*/, ret];
127
- }
128
- });
129
- }); };
130
- /**
131
- * Executes an asynchronous function for each element in an array
132
- * sequentially.
133
- *
134
- * Unlike JavaScript's native forEach, this function processes asynchronous
135
- * functions sequentially and waits for all operations to complete. It
136
- * performs sequential processing rather than parallel processing, making it
137
- * suitable for operations where order matters.
138
- *
139
- * @example
140
- * ```typescript
141
- * const urls = ['url1', 'url2', 'url3'];
142
- *
143
- * await ArrayUtil.asyncForEach(urls, async (url, index) => {
144
- * console.log(`Processing ${index}: ${url}`);
145
- * const data = await fetch(url);
146
- * await processData(data);
147
- * console.log(`Completed ${index}: ${url}`);
148
- * });
149
- * console.log('All URLs processed sequentially');
150
- * ```
151
- *
152
- * @template Input - The type of elements in the input array
153
- * @param elements - The readonly array to process
154
- * @param closure - The asynchronous function to execute for each element
155
- * @returns A Promise<void> that resolves when all operations complete
156
- */
157
- ArrayUtil.asyncForEach = function (elements, closure) { return __awaiter(_this, void 0, void 0, function () {
158
- return __generator(this, function (_a) {
159
- switch (_a.label) {
160
- case 0: return [4 /*yield*/, ArrayUtil.asyncRepeat(elements.length, function (index) {
161
- return closure(elements[index], index, elements);
162
- })];
163
- case 1:
164
- _a.sent();
165
- return [2 /*return*/];
166
- }
167
- });
168
- }); };
169
- /**
170
- * Transforms each element of an array using an asynchronous function to
171
- * create a new array.
172
- *
173
- * Similar to JavaScript's native map but processes asynchronous functions
174
- * sequentially. Each element's transformation is completed before proceeding
175
- * to the next element, ensuring order is maintained. This function still
176
- * maintains the currying pattern for composition.
177
- *
178
- * @example
179
- * ```typescript
180
- * const userIds = [1, 2, 3, 4, 5];
181
- *
182
- * const userDetails = await ArrayUtil.asyncMap(userIds)(
183
- * async (id, index) => {
184
- * console.log(`Fetching user ${id} (${index + 1}/${userIds.length})`);
185
- * const response = await fetch(`/api/users/${id}`);
186
- * return await response.json();
187
- * }
188
- * );
189
- * console.log('All users fetched:', userDetails);
190
- * ```
191
- *
192
- * @template Input - The type of elements in the input array
193
- * @param elements - The readonly array to transform
194
- * @returns A function that takes a transformation function and returns a
195
- * Promise resolving to the transformed array
196
- */
197
- ArrayUtil.asyncMap = function (elements, closure) { return __awaiter(_this, void 0, void 0, function () {
198
- var ret;
199
- var _this = this;
200
- return __generator(this, function (_a) {
201
- switch (_a.label) {
202
- case 0:
203
- ret = [];
204
- return [4 /*yield*/, ArrayUtil.asyncForEach(elements, function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
205
- var output;
206
- return __generator(this, function (_a) {
207
- switch (_a.label) {
208
- case 0: return [4 /*yield*/, closure(elem, index, array)];
209
- case 1:
210
- output = _a.sent();
211
- ret.push(output);
212
- return [2 /*return*/];
213
- }
214
- });
215
- }); })];
216
- case 1:
217
- _a.sent();
218
- return [2 /*return*/, ret];
219
- }
220
- });
221
- }); };
222
- /**
223
- * Executes an asynchronous function a specified number of times sequentially.
224
- *
225
- * Executes the function with indices from 0 to count-1 incrementally. Each
226
- * execution is performed sequentially, and all results are collected into an
227
- * array.
228
- *
229
- * @example
230
- * ```typescript
231
- * // Generate random data 5 times
232
- * const randomData = await ArrayUtil.asyncRepeat(5, async (index) => {
233
- * await new Promise(resolve => setTimeout(resolve, 100)); // Wait 0.1 seconds
234
- * return {
235
- * id: index,
236
- * value: Math.random(),
237
- * timestamp: new Date().toISOString()
238
- * };
239
- * });
240
- * console.log('Generated data:', randomData);
241
- * ```;
242
- *
243
- * @template T - The type of the result from each execution
244
- * @param count - The number of times to repeat (non-negative integer)
245
- * @param closure - The asynchronous function to execute repeatedly
246
- * @returns A Promise resolving to an array of results
247
- */
248
- ArrayUtil.asyncRepeat = function (count, closure) { return __awaiter(_this, void 0, void 0, function () {
249
- var indexes, output, indexes_1, indexes_1_1, index, _a, _b, e_1_1;
250
- var e_1, _c;
251
- return __generator(this, function (_d) {
252
- switch (_d.label) {
253
- case 0:
254
- indexes = new Array(count).fill(1).map(function (_, index) { return index; });
255
- output = [];
256
- _d.label = 1;
257
- case 1:
258
- _d.trys.push([1, 6, 7, 8]);
259
- indexes_1 = __values(indexes), indexes_1_1 = indexes_1.next();
260
- _d.label = 2;
261
- case 2:
262
- if (!!indexes_1_1.done) return [3 /*break*/, 5];
263
- index = indexes_1_1.value;
264
- _b = (_a = output).push;
265
- return [4 /*yield*/, closure(index)];
266
- case 3:
267
- _b.apply(_a, [_d.sent()]);
268
- _d.label = 4;
269
- case 4:
270
- indexes_1_1 = indexes_1.next();
271
- return [3 /*break*/, 2];
272
- case 5: return [3 /*break*/, 8];
273
- case 6:
274
- e_1_1 = _d.sent();
275
- e_1 = { error: e_1_1 };
276
- return [3 /*break*/, 8];
277
- case 7:
278
- try {
279
- if (indexes_1_1 && !indexes_1_1.done && (_c = indexes_1.return)) _c.call(indexes_1);
280
- }
281
- finally { if (e_1) throw e_1.error; }
282
- return [7 /*endfinally*/];
283
- case 8: return [2 /*return*/, output];
284
- }
285
- });
286
- }); };
287
- /**
288
- * Checks if at least one element in the array satisfies the given condition.
289
- *
290
- * Similar to JavaScript's native some() method. Returns true immediately when
291
- * the first element satisfying the condition is found.
292
- *
293
- * @example
294
- * ```typescript
295
- * const numbers = [1, 3, 5, 7, 8, 9];
296
- * const products = [
297
- * { name: 'Apple', price: 100, inStock: true },
298
- * { name: 'Banana', price: 50, inStock: false },
299
- * { name: 'Orange', price: 80, inStock: true }
300
- * ];
301
- *
302
- * const hasEvenNumber = ArrayUtil.has(numbers, num => num % 2 === 0);
303
- * console.log(hasEvenNumber); // true (8 exists)
304
- *
305
- * const hasExpensiveItem = ArrayUtil.has(products, product => product.price > 90);
306
- * console.log(hasExpensiveItem); // true (Apple costs 100)
307
- *
308
- * const hasOutOfStock = ArrayUtil.has(products, product => !product.inStock);
309
- * console.log(hasOutOfStock); // true (Banana is out of stock)
310
- * ```;
311
- *
312
- * @template T - The type of elements in the array
313
- * @param elements - The readonly array to check
314
- * @param pred - The predicate function to test elements
315
- * @returns Boolean indicating if any element satisfies the condition
316
- */
317
- ArrayUtil.has = function (elements, pred) { return elements.find(pred) !== undefined; };
318
- /**
319
- * Executes a function a specified number of times and collects the results
320
- * into an array.
321
- *
322
- * A synchronous repetition function that executes the given function for each
323
- * index (from 0 to count-1) and collects the results into an array.
324
- *
325
- * @example
326
- * ```typescript
327
- * // Generate an array of squares from 1 to 5
328
- * const squares = ArrayUtil.repeat(5, index => (index + 1) ** 2);
329
- * console.log(squares); // [1, 4, 9, 16, 25]
330
- *
331
- * // Generate an array of default user objects
332
- * const users = ArrayUtil.repeat(3, index => ({
333
- * id: index + 1,
334
- * name: `User${index + 1}`,
335
- * email: `user${index + 1}@example.com`
336
- * }));
337
- * console.log(users);
338
- * // [
339
- * // { id: 1, name: 'User1', email: 'user1@example.com' },
340
- * // { id: 2, name: 'User2', email: 'user2@example.com' },
341
- * // { id: 3, name: 'User3', email: 'user3@example.com' }
342
- * // ]
343
- * ```
344
- *
345
- * @template T - The type of the result from each execution
346
- * @param count - The number of times to repeat (non-negative integer)
347
- * @param closure - The function to execute repeatedly
348
- * @returns An array of results
349
- */
350
- ArrayUtil.repeat = function (count, closure) { return new Array(count).fill("").map(function (_, index) { return closure(index); }); };
351
- /**
352
- * Generates all possible subsets of a given array.
353
- *
354
- * Implements the mathematical concept of power set, generating 2^n subsets
355
- * from an array of n elements. Uses depth-first search (DFS) algorithm to
356
- * calculate all possible combinations of including or excluding each
357
- * element.
358
- *
359
- * @example
360
- * ```typescript
361
- * const numbers = [1, 2, 3];
362
- * const allSubsets = ArrayUtil.subsets(numbers);
363
- * console.log(allSubsets);
364
- * // [
365
- * // [], // empty set
366
- * // [3], // {3}
367
- * // [2], // {2}
368
- * // [2, 3], // {2, 3}
369
- * // [1], // {1}
370
- * // [1, 3], // {1, 3}
371
- * // [1, 2], // {1, 2}
372
- * // [1, 2, 3] // {1, 2, 3}
373
- * // ]
374
- *
375
- * const colors = ['red', 'blue'];
376
- * const colorSubsets = ArrayUtil.subsets(colors);
377
- * console.log(colorSubsets);
378
- * // [
379
- * // [],
380
- * // ['blue'],
381
- * // ['red'],
382
- * // ['red', 'blue']
383
- * // ]
384
- *
385
- * // Warning: Result size grows exponentially with array size
386
- * // Example: 10 elements → 1,024 subsets, 20 elements → 1,048,576 subsets
387
- * ```;
388
- *
389
- * @template T - The type of elements in the array
390
- * @param array - The array to generate subsets from
391
- * @returns An array containing all possible subsets
392
- */
393
- ArrayUtil.subsets = function (array) {
394
- var check = new Array(array.length).fill(false);
395
- var output = [];
396
- var dfs = function (depth) {
397
- if (depth === check.length)
398
- output.push(array.filter(function (_v, idx) { return check[idx]; }));
399
- else {
400
- check[depth] = true;
401
- dfs(depth + 1);
402
- check[depth] = false;
403
- dfs(depth + 1);
404
- }
405
- };
406
- dfs(0);
407
- return output;
408
- };
409
- })(ArrayUtil || (exports.ArrayUtil = ArrayUtil = {}));
410
- //# sourceMappingURL=ArrayUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArrayUtil.js","sourceRoot":"","sources":["../src/ArrayUtil.ts"],"names":[],"mappings":"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"}
@@ -1,144 +0,0 @@
1
- /**
2
- * Dynamic Executor running prefixed functions.
3
- *
4
- * `DynamicExecutor` runs every (or some filtered) prefixed functions in a
5
- * specific directory.
6
- *
7
- * For reference, it's useful for test program development of a backend server.
8
- * Just write test functions under a directory, and just specify it.
9
- * Furthermore, if you compose e2e test programs to utilize the `@nestia/sdk`
10
- * generated API functions, you can take advantage of {@link DynamicBenchmarker}
11
- * at the same time.
12
- *
13
- * When you want to see some utilization cases, see the below example links.
14
- *
15
- * @author Jeongho Nam - https://github.com/samchon
16
- * @example
17
- * https://github.com/samchon/nestia-start/blob/master/test/index.ts
18
- *
19
- * @example
20
- * https://github.com/samchon/backend/blob/master/test/index.ts
21
- */
22
- export declare namespace DynamicExecutor {
23
- /**
24
- * Function type of a prefixed.
25
- *
26
- * @template Arguments Type of parameters
27
- * @template Ret Type of return value
28
- */
29
- interface Closure<Arguments extends any[], Ret = any> {
30
- (...args: Arguments): Promise<Ret>;
31
- }
32
- /** Options for dynamic executor. */
33
- interface IProps<Parameters extends any[], Ret = any> {
34
- /**
35
- * Prefix of function name.
36
- *
37
- * Every prefixed function will be executed.
38
- *
39
- * In other words, if a function name doesn't start with the prefix, then it
40
- * would never be executed.
41
- */
42
- prefix: string;
43
- /** Location of the test functions. */
44
- location: string;
45
- /**
46
- * Get parameters of a function.
47
- *
48
- * @param name Function name
49
- * @returns Parameters
50
- */
51
- parameters: (name: string) => Parameters;
52
- /**
53
- * On complete function.
54
- *
55
- * Listener of completion of a test function.
56
- *
57
- * @param exec Execution result of a test function
58
- */
59
- onComplete?: (exec: IExecution) => void;
60
- /**
61
- * Filter function whether to run or not.
62
- *
63
- * @param name Function name
64
- * @returns Whether to run or not
65
- */
66
- filter?: (name: string) => boolean;
67
- /**
68
- * Wrapper of test function.
69
- *
70
- * If you specify this `wrapper` property, every dynamic functions loaded
71
- * and called by this `DynamicExecutor` would be wrapped by the `wrapper`
72
- * function.
73
- *
74
- * @param name Function name
75
- * @param closure Function to be executed
76
- * @param parameters Parameters, result of options.parameters function.
77
- * @returns Wrapper function
78
- */
79
- wrapper?: (name: string, closure: Closure<Parameters, Ret>, parameters: Parameters) => Promise<any>;
80
- /**
81
- * Number of simultaneous requests.
82
- *
83
- * The number of requests to be executed simultaneously.
84
- *
85
- * If you configure a value greater than one, the dynamic executor will
86
- * process the functions concurrently with the given capacity value.
87
- *
88
- * @default 1
89
- */
90
- simultaneous?: number;
91
- /**
92
- * Extension of dynamic functions.
93
- *
94
- * @default js
95
- */
96
- extension?: string;
97
- }
98
- /** Report, result of dynamic execution. */
99
- interface IReport {
100
- /** Location path of dynamic functions. */
101
- location: string;
102
- /** Execution results of dynamic functions. */
103
- executions: IExecution[];
104
- /** Total elapsed time. */
105
- time: number;
106
- }
107
- /** Execution of a test function. */
108
- interface IExecution {
109
- /** Name of function. */
110
- name: string;
111
- /** Location path of the function. */
112
- location: string;
113
- /** Returned value from the function. */
114
- value: unknown;
115
- /** Error when occurred. */
116
- error: Error | null;
117
- /** Elapsed time. */
118
- started_at: string;
119
- /** Completion time. */
120
- completed_at: string;
121
- }
122
- /**
123
- * Prepare dynamic executor in strict mode.
124
- *
125
- * In strict mode, if any error occurs, the program will be terminated
126
- * directly. Otherwise, {@link validate} mode does not terminate when error
127
- * occurs, but just archive the error log.
128
- *
129
- * @param props Properties of dynamic execution
130
- * @returns Report of dynamic test functions execution
131
- */
132
- const assert: <Arguments extends any[]>(props: IProps<Arguments>) => Promise<IReport>;
133
- /**
134
- * Prepare dynamic executor in loose mode.
135
- *
136
- * In loose mode, the program would not be terminated even when error occurs.
137
- * Instead, the error would be archived and returns as a list. Otherwise,
138
- * {@link assert} mode terminates the program directly when error occurs.
139
- *
140
- * @param props Properties of dynamic executor
141
- * @returns Report of dynamic test functions execution
142
- */
143
- const validate: <Arguments extends any[]>(props: IProps<Arguments>) => Promise<IReport>;
144
- }