@nestia/e2e 7.0.0-dev.20250608 → 7.0.1

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.
@@ -2,22 +2,106 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GaffComparator = void 0;
4
4
  /**
5
- * Gaff comparator.
5
+ * Type-safe comparator functions for Array.sort() operations with advanced
6
+ * field access.
6
7
  *
7
- * `GaffComparator` is a set of comparator functions for `Array.sort()` function,
8
- * which can be used with {@link TestValidator.sort} function. If you want to see
9
- * how to use them, see the below example link.
8
+ * GaffComparator provides a collection of specialized comparator functions
9
+ * designed to work seamlessly with Array.sort() and testing frameworks like
10
+ * TestValidator.sort(). Each comparator supports both single values and arrays
11
+ * of values, enabling complex multi-field sorting scenarios with lexicographic
12
+ * ordering.
13
+ *
14
+ * Key features:
15
+ *
16
+ * - Generic type safety for any object structure
17
+ * - Support for single values or arrays of values per field
18
+ * - Lexicographic comparison for multi-value scenarios
19
+ * - Locale-aware string comparison
20
+ * - Automatic type conversion for dates and numbers
21
+ *
22
+ * The comparators follow the standard JavaScript sort contract:
23
+ *
24
+ * - Return < 0 if first element should come before second
25
+ * - Return > 0 if first element should come after second
26
+ * - Return 0 if elements are equal
10
27
  *
11
- * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts
12
28
  * @author Jeongho Nam - https://github.com/samchon
29
+ * @example
30
+ * ```typescript
31
+ * // Basic usage with single fields
32
+ * users.sort(GaffComparator.strings(user => user.name));
33
+ * posts.sort(GaffComparator.dates(post => post.createdAt));
34
+ * products.sort(GaffComparator.numbers(product => product.price));
35
+ *
36
+ * // Multi-field sorting with arrays
37
+ * users.sort(GaffComparator.strings(user => [user.lastName, user.firstName]));
38
+ * events.sort(GaffComparator.dates(event => [event.startDate, event.endDate]));
39
+ *
40
+ * // Integration with TestValidator
41
+ * await TestValidator.sort("user sorting")(
42
+ * (sortable) => api.getUsers({ sort: sortable })
43
+ * )("name", "email")(
44
+ * GaffComparator.strings(user => [user.name, user.email])
45
+ * )("+");
46
+ * ```;
13
47
  */
14
48
  var GaffComparator;
15
49
  (function (GaffComparator) {
16
50
  /**
17
- * String(s) comparator.
51
+ * Creates a comparator function for string-based sorting with locale-aware
52
+ * comparison.
53
+ *
54
+ * Generates a comparator that extracts string values from objects and
55
+ * performs lexicographic comparison using locale-sensitive string comparison.
56
+ * Supports both single strings and arrays of strings for multi-field sorting
57
+ * scenarios.
58
+ *
59
+ * When comparing arrays, performs lexicographic ordering: compares the first
60
+ * elements, then the second elements if the first are equal, and so on. This
61
+ * enables complex sorting like "sort by last name, then by first name".
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * interface User {
66
+ * id: string;
67
+ * firstName: string;
68
+ * lastName: string;
69
+ * email: string;
70
+ * status: 'active' | 'inactive';
71
+ * }
18
72
  *
19
- * @param getter Getter of string(s) from input
20
- * @returns Comparator function
73
+ * const users: User[] = [
74
+ * { id: '1', firstName: 'John', lastName: 'Doe', email: 'john@example.com', status: 'active' },
75
+ * { id: '2', firstName: 'Jane', lastName: 'Doe', email: 'jane@example.com', status: 'inactive' },
76
+ * { id: '3', firstName: 'Bob', lastName: 'Smith', email: 'bob@example.com', status: 'active' }
77
+ * ];
78
+ *
79
+ * // Single field sorting
80
+ * users.sort(GaffComparator.strings(user => user.lastName));
81
+ * // Result: Doe, Doe, Smith
82
+ *
83
+ * // Multi-field sorting: last name, then first name
84
+ * users.sort(GaffComparator.strings(user => [user.lastName, user.firstName]));
85
+ * // Result: Doe Jane, Doe John, Smith Bob
86
+ *
87
+ * // Status-based sorting
88
+ * users.sort(GaffComparator.strings(user => user.status));
89
+ * // Result: active users first, then inactive
90
+ *
91
+ * // Complex multi-field: status, then last name, then first name
92
+ * users.sort(GaffComparator.strings(user => [user.status, user.lastName, user.firstName]));
93
+ *
94
+ * // Integration with API sorting validation
95
+ * await TestValidator.sort("user name sorting")(
96
+ * (sortFields) => userApi.getUsers({ sort: sortFields })
97
+ * )("lastName", "firstName")(
98
+ * GaffComparator.strings(user => [user.lastName, user.firstName])
99
+ * )("+");
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()
21
105
  */
22
106
  GaffComparator.strings = function (getter) {
23
107
  return function (x, y) {
@@ -28,10 +112,78 @@ var GaffComparator;
28
112
  };
29
113
  };
30
114
  /**
31
- * Date(s) comparator.
115
+ * Creates a comparator function for date-based sorting with automatic string
116
+ * parsing.
117
+ *
118
+ * Generates a comparator that extracts date values from objects,
119
+ * automatically converting string representations to Date objects for
120
+ * numerical comparison. Supports both single dates and arrays of dates for
121
+ * complex temporal sorting.
122
+ *
123
+ * Date strings are parsed using the standard Date constructor, which supports
124
+ * ISO 8601 format, RFC 2822 format, and other common date representations.
125
+ * The comparison is performed on millisecond timestamps for precise
126
+ * ordering.
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * interface Event {
131
+ * id: string;
132
+ * title: string;
133
+ * startDate: string;
134
+ * endDate: string;
135
+ * createdAt: string;
136
+ * updatedAt: string;
137
+ * }
32
138
  *
33
- * @param getter Getter of date(s) from input
34
- * @returns Comparator function
139
+ * const events: Event[] = [
140
+ * {
141
+ * id: '1',
142
+ * title: 'Conference',
143
+ * startDate: '2024-03-15T09:00:00Z',
144
+ * endDate: '2024-03-15T17:00:00Z',
145
+ * createdAt: '2024-01-10T10:00:00Z',
146
+ * updatedAt: '2024-02-01T15:30:00Z'
147
+ * },
148
+ * {
149
+ * id: '2',
150
+ * title: 'Workshop',
151
+ * startDate: '2024-03-10T14:00:00Z',
152
+ * endDate: '2024-03-10T16:00:00Z',
153
+ * createdAt: '2024-01-15T11:00:00Z',
154
+ * updatedAt: '2024-01-20T09:15:00Z'
155
+ * }
156
+ * ];
157
+ *
158
+ * // Sort by start date (chronological order)
159
+ * events.sort(GaffComparator.dates(event => event.startDate));
160
+ *
161
+ * // Sort by creation date (oldest first)
162
+ * events.sort(GaffComparator.dates(event => event.createdAt));
163
+ *
164
+ * // Multi-field: start date, then end date
165
+ * events.sort(GaffComparator.dates(event => [event.startDate, event.endDate]));
166
+ *
167
+ * // Sort by modification history: created date, then updated date
168
+ * events.sort(GaffComparator.dates(event => [event.createdAt, event.updatedAt]));
169
+ *
170
+ * // Validate API date sorting
171
+ * await TestValidator.sort("event chronological sorting")(
172
+ * (sortFields) => eventApi.getEvents({ sort: sortFields })
173
+ * )("startDate")(
174
+ * GaffComparator.dates(event => event.startDate)
175
+ * )("+");
176
+ *
177
+ * // Test complex date-based sorting
178
+ * const sortByEventSchedule = GaffComparator.dates(event => [
179
+ * event.startDate,
180
+ * event.endDate
181
+ * ]);
182
+ * ```;
183
+ *
184
+ * @template T - The type of objects being compared
185
+ * @param getter - Function that extracts date string(s) from input objects
186
+ * @returns A comparator function suitable for Array.sort()
35
187
  */
36
188
  GaffComparator.dates = function (getter) {
37
189
  return function (x, y) {
@@ -45,10 +197,73 @@ var GaffComparator;
45
197
  };
46
198
  };
47
199
  /**
48
- * Number(s) comparator.
200
+ * Creates a comparator function for numerical sorting with multi-value
201
+ * support.
202
+ *
203
+ * Generates a comparator that extracts numerical values from objects and
204
+ * performs mathematical comparison. Supports both single numbers and arrays
205
+ * of numbers for complex numerical sorting scenarios like sorting by price
206
+ * then by rating.
207
+ *
208
+ * When comparing arrays, performs lexicographic numerical ordering: compares
209
+ * the first numbers, then the second numbers if the first are equal, and so
210
+ * on. This enables sophisticated sorting like "sort by price ascending, then
211
+ * by rating descending".
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * interface Product {
216
+ * id: string;
217
+ * name: string;
218
+ * price: number;
219
+ * rating: number;
220
+ * stock: number;
221
+ * categoryId: number;
222
+ * salesCount: number;
223
+ * }
224
+ *
225
+ * const products: Product[] = [
226
+ * { id: '1', name: 'Laptop', price: 999.99, rating: 4.5, stock: 15, categoryId: 1, salesCount: 150 },
227
+ * { id: '2', name: 'Mouse', price: 29.99, rating: 4.2, stock: 50, categoryId: 1, salesCount: 300 },
228
+ * { id: '3', name: 'Keyboard', price: 79.99, rating: 4.8, stock: 25, categoryId: 1, salesCount: 200 }
229
+ * ];
230
+ *
231
+ * // Sort by price (ascending)
232
+ * products.sort(GaffComparator.numbers(product => product.price));
233
+ * // Result: Mouse ($29.99), Keyboard ($79.99), Laptop ($999.99)
234
+ *
235
+ * // Sort by rating (descending requires negation)
236
+ * products.sort(GaffComparator.numbers(product => -product.rating));
237
+ * // Result: Keyboard (4.8), Laptop (4.5), Mouse (4.2)
238
+ *
239
+ * // Multi-field: category, then price
240
+ * products.sort(GaffComparator.numbers(product => [product.categoryId, product.price]));
241
+ *
242
+ * // Complex business logic: popularity (sales) then rating
243
+ * products.sort(GaffComparator.numbers(product => [-product.salesCount, -product.rating]));
244
+ * // Negative values for descending order
245
+ *
246
+ * // Sort by inventory priority: low stock first, then by sales
247
+ * products.sort(GaffComparator.numbers(product => [product.stock, -product.salesCount]));
248
+ *
249
+ * // Validate API numerical sorting
250
+ * await TestValidator.sort("product price sorting")(
251
+ * (sortFields) => productApi.getProducts({ sort: sortFields })
252
+ * )("price")(
253
+ * GaffComparator.numbers(product => product.price)
254
+ * )("+");
255
+ *
256
+ * // Test multi-criteria sorting
257
+ * const sortByBusinessValue = GaffComparator.numbers(product => [
258
+ * -product.salesCount, // High sales first
259
+ * -product.rating, // High rating first
260
+ * product.price // Low price first (for tie-breaking)
261
+ * ]);
262
+ * ```;
49
263
  *
50
- * @param closure Getter of number(s) from input
51
- * @returns Comparator function
264
+ * @template T - The type of objects being compared
265
+ * @param closure - Function that extracts number value(s) from input objects
266
+ * @returns A comparator function suitable for Array.sort()
52
267
  */
53
268
  GaffComparator.numbers = function (closure) {
54
269
  return function (x, y) {
@@ -1 +1 @@
1
- {"version":3,"file":"GaffComparator.js","sourceRoot":"","sources":["../src/GaffComparator.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,IAAiB,c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