@alanszp/express 12.0.2 → 13.0.0

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 (180) hide show
  1. package/dist/helpers/getRequestBaseLog.d.ts +2 -0
  2. package/dist/helpers/getRequestBaseLog.js +9 -0
  3. package/dist/helpers/getRequestBaseLog.js.map +1 -0
  4. package/dist/helpers/renderErrorJson.d.ts +1 -0
  5. package/dist/helpers/renderErrorJson.js +10 -1
  6. package/dist/helpers/renderErrorJson.js.map +1 -1
  7. package/dist/index.d.ts +3 -1
  8. package/dist/index.js +3 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/middlewares/errorRequestHandlerMiddleware.d.ts +4 -0
  11. package/dist/middlewares/errorRequestHandlerMiddleware.js +68 -0
  12. package/dist/middlewares/errorRequestHandlerMiddleware.js.map +1 -0
  13. package/dist/middlewares/hasPermissions.d.ts +20 -0
  14. package/dist/middlewares/hasPermissions.js +90 -0
  15. package/dist/middlewares/hasPermissions.js.map +1 -0
  16. package/dist/middlewares/hasRoles.js +4 -4
  17. package/dist/middlewares/hasRoles.js.map +1 -1
  18. package/package.json +9 -10
  19. package/.gitignore +0 -3
  20. package/.npmignore +0 -3
  21. package/dist/middlewares/returnInternalServerError.d.ts +0 -4
  22. package/dist/middlewares/returnInternalServerError.js +0 -10
  23. package/dist/middlewares/returnInternalServerError.js.map +0 -1
  24. package/node_modules/@jest/expect-utils/LICENSE +0 -21
  25. package/node_modules/@jest/expect-utils/README.md +0 -5
  26. package/node_modules/@jest/expect-utils/build/index.d.ts +0 -93
  27. package/node_modules/@jest/expect-utils/build/index.js +0 -37
  28. package/node_modules/@jest/expect-utils/build/jasmineUtils.js +0 -282
  29. package/node_modules/@jest/expect-utils/build/types.js +0 -1
  30. package/node_modules/@jest/expect-utils/build/utils.js +0 -457
  31. package/node_modules/@jest/expect-utils/package.json +0 -33
  32. package/node_modules/@jest/types/LICENSE +0 -21
  33. package/node_modules/@jest/types/README.md +0 -30
  34. package/node_modules/@jest/types/build/Circus.js +0 -1
  35. package/node_modules/@jest/types/build/Config.js +0 -1
  36. package/node_modules/@jest/types/build/Global.js +0 -1
  37. package/node_modules/@jest/types/build/TestResult.js +0 -1
  38. package/node_modules/@jest/types/build/Transform.js +0 -1
  39. package/node_modules/@jest/types/build/index.d.ts +0 -1166
  40. package/node_modules/@jest/types/build/index.js +0 -1
  41. package/node_modules/@jest/types/package.json +0 -38
  42. package/node_modules/@types/jest/LICENSE +0 -21
  43. package/node_modules/@types/jest/README.md +0 -17
  44. package/node_modules/@types/jest/index.d.ts +0 -1608
  45. package/node_modules/@types/jest/package.json +0 -159
  46. package/node_modules/@types/node/LICENSE +0 -21
  47. package/node_modules/@types/node/README.md +0 -15
  48. package/node_modules/@types/node/assert/strict.d.ts +0 -8
  49. package/node_modules/@types/node/assert.d.ts +0 -996
  50. package/node_modules/@types/node/async_hooks.d.ts +0 -539
  51. package/node_modules/@types/node/buffer.d.ts +0 -2362
  52. package/node_modules/@types/node/child_process.d.ts +0 -1540
  53. package/node_modules/@types/node/cluster.d.ts +0 -432
  54. package/node_modules/@types/node/console.d.ts +0 -415
  55. package/node_modules/@types/node/constants.d.ts +0 -19
  56. package/node_modules/@types/node/crypto.d.ts +0 -4487
  57. package/node_modules/@types/node/dgram.d.ts +0 -596
  58. package/node_modules/@types/node/diagnostics_channel.d.ts +0 -545
  59. package/node_modules/@types/node/dns/promises.d.ts +0 -425
  60. package/node_modules/@types/node/dns.d.ts +0 -809
  61. package/node_modules/@types/node/dom-events.d.ts +0 -122
  62. package/node_modules/@types/node/domain.d.ts +0 -170
  63. package/node_modules/@types/node/events.d.ts +0 -879
  64. package/node_modules/@types/node/fs/promises.d.ts +0 -1239
  65. package/node_modules/@types/node/fs.d.ts +0 -4311
  66. package/node_modules/@types/node/globals.d.ts +0 -411
  67. package/node_modules/@types/node/globals.global.d.ts +0 -1
  68. package/node_modules/@types/node/http.d.ts +0 -1887
  69. package/node_modules/@types/node/http2.d.ts +0 -2382
  70. package/node_modules/@types/node/https.d.ts +0 -550
  71. package/node_modules/@types/node/index.d.ts +0 -88
  72. package/node_modules/@types/node/inspector.d.ts +0 -2747
  73. package/node_modules/@types/node/module.d.ts +0 -315
  74. package/node_modules/@types/node/net.d.ts +0 -949
  75. package/node_modules/@types/node/os.d.ts +0 -478
  76. package/node_modules/@types/node/package.json +0 -229
  77. package/node_modules/@types/node/path.d.ts +0 -191
  78. package/node_modules/@types/node/perf_hooks.d.ts +0 -645
  79. package/node_modules/@types/node/process.d.ts +0 -1561
  80. package/node_modules/@types/node/punycode.d.ts +0 -117
  81. package/node_modules/@types/node/querystring.d.ts +0 -141
  82. package/node_modules/@types/node/readline/promises.d.ts +0 -150
  83. package/node_modules/@types/node/readline.d.ts +0 -539
  84. package/node_modules/@types/node/repl.d.ts +0 -430
  85. package/node_modules/@types/node/stream/consumers.d.ts +0 -12
  86. package/node_modules/@types/node/stream/promises.d.ts +0 -83
  87. package/node_modules/@types/node/stream/web.d.ts +0 -366
  88. package/node_modules/@types/node/stream.d.ts +0 -1701
  89. package/node_modules/@types/node/string_decoder.d.ts +0 -67
  90. package/node_modules/@types/node/test.d.ts +0 -1465
  91. package/node_modules/@types/node/timers/promises.d.ts +0 -93
  92. package/node_modules/@types/node/timers.d.ts +0 -240
  93. package/node_modules/@types/node/tls.d.ts +0 -1210
  94. package/node_modules/@types/node/trace_events.d.ts +0 -182
  95. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  96. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
  97. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
  98. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2362
  99. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
  100. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  101. package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
  102. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  103. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4487
  104. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -596
  105. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -545
  106. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
  107. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  108. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  109. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  110. package/node_modules/@types/node/ts4.8/events.d.ts +0 -879
  111. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1239
  112. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4311
  113. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -411
  114. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  115. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1887
  116. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
  117. package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
  118. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  119. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
  120. package/node_modules/@types/node/ts4.8/module.d.ts +0 -315
  121. package/node_modules/@types/node/ts4.8/net.d.ts +0 -949
  122. package/node_modules/@types/node/ts4.8/os.d.ts +0 -478
  123. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  124. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -645
  125. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1561
  126. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  127. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  128. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
  129. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
  130. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  131. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  132. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  133. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -366
  134. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
  135. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  136. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1465
  137. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  138. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
  139. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
  140. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  141. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
  142. package/node_modules/@types/node/ts4.8/url.d.ts +0 -927
  143. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2183
  144. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -764
  145. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -903
  146. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -179
  147. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
  148. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  149. package/node_modules/@types/node/tty.d.ts +0 -208
  150. package/node_modules/@types/node/url.d.ts +0 -927
  151. package/node_modules/@types/node/util.d.ts +0 -2183
  152. package/node_modules/@types/node/v8.d.ts +0 -764
  153. package/node_modules/@types/node/vm.d.ts +0 -903
  154. package/node_modules/@types/node/wasi.d.ts +0 -179
  155. package/node_modules/@types/node/worker_threads.d.ts +0 -691
  156. package/node_modules/@types/node/zlib.d.ts +0 -517
  157. package/src/helpers/getIp.ts +0 -5
  158. package/src/helpers/getRequestLogger.ts +0 -6
  159. package/src/helpers/now.ts +0 -3
  160. package/src/helpers/renderErrorJson.ts +0 -29
  161. package/src/index.ts +0 -10
  162. package/src/middlewares/accessLogger.ts +0 -34
  163. package/src/middlewares/auditLog.ts +0 -52
  164. package/src/middlewares/authedForOrg.ts +0 -50
  165. package/src/middlewares/authenticateUser.test.ts +0 -403
  166. package/src/middlewares/authenticateUser.ts +0 -171
  167. package/src/middlewares/createContext.test.ts +0 -85
  168. package/src/middlewares/createContext.ts +0 -49
  169. package/src/middlewares/hasRoles.ts +0 -24
  170. package/src/middlewares/jsonBodyParser.ts +0 -22
  171. package/src/middlewares/returnInternalServerError.ts +0 -15
  172. package/src/middlewares/returnNotFound.ts +0 -11
  173. package/src/test/mocks/authOptionsMocks.ts +0 -35
  174. package/src/test/mocks/expressMocks.ts +0 -33
  175. package/src/test/mocks/jwtUserMocks.ts +0 -19
  176. package/src/test/setup.test.ts +0 -15
  177. package/src/test/setup.ts +0 -3
  178. package/src/types/AuthMethod.ts +0 -27
  179. package/src/types/GenericRequest.ts +0 -3
  180. package/src/types/custom.d.ts +0 -20
@@ -1,457 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- });
6
- exports.arrayBufferEquality = void 0;
7
- exports.emptyObject = emptyObject;
8
- exports.typeEquality =
9
- exports.subsetEquality =
10
- exports.sparseArrayEquality =
11
- exports.pathAsArray =
12
- exports.partition =
13
- exports.iterableEquality =
14
- exports.isOneline =
15
- exports.isError =
16
- exports.getPath =
17
- exports.getObjectSubset =
18
- void 0;
19
-
20
- var _jestGetType = require('jest-get-type');
21
-
22
- var _jasmineUtils = require('./jasmineUtils');
23
-
24
- var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
25
-
26
- /**
27
- * Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.
28
- */
29
- const hasPropertyInObject = (object, key) => {
30
- const shouldTerminate =
31
- !object || typeof object !== 'object' || object === Object.prototype;
32
-
33
- if (shouldTerminate) {
34
- return false;
35
- }
36
-
37
- return (
38
- Object.prototype.hasOwnProperty.call(object, key) ||
39
- hasPropertyInObject(Object.getPrototypeOf(object), key)
40
- );
41
- };
42
-
43
- const getPath = (object, propertyPath) => {
44
- if (!Array.isArray(propertyPath)) {
45
- propertyPath = pathAsArray(propertyPath);
46
- }
47
-
48
- if (propertyPath.length) {
49
- const lastProp = propertyPath.length === 1;
50
- const prop = propertyPath[0];
51
- const newObject = object[prop];
52
-
53
- if (!lastProp && (newObject === null || newObject === undefined)) {
54
- // This is not the last prop in the chain. If we keep recursing it will
55
- // hit a `can't access property X of undefined | null`. At this point we
56
- // know that the chain has broken and we can return right away.
57
- return {
58
- hasEndProp: false,
59
- lastTraversedObject: object,
60
- traversedPath: []
61
- };
62
- }
63
-
64
- const result = getPath(newObject, propertyPath.slice(1));
65
-
66
- if (result.lastTraversedObject === null) {
67
- result.lastTraversedObject = object;
68
- }
69
-
70
- result.traversedPath.unshift(prop);
71
-
72
- if (lastProp) {
73
- // Does object have the property with an undefined value?
74
- // Although primitive values support bracket notation (above)
75
- // they would throw TypeError for in operator (below).
76
- result.endPropIsDefined =
77
- !(0, _jestGetType.isPrimitive)(object) && prop in object;
78
- result.hasEndProp = newObject !== undefined || result.endPropIsDefined;
79
-
80
- if (!result.hasEndProp) {
81
- result.traversedPath.shift();
82
- }
83
- }
84
-
85
- return result;
86
- }
87
-
88
- return {
89
- lastTraversedObject: null,
90
- traversedPath: [],
91
- value: object
92
- };
93
- }; // Strip properties from object that are not present in the subset. Useful for
94
- // printing the diff for toMatchObject() without adding unrelated noise.
95
-
96
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
97
-
98
- exports.getPath = getPath;
99
-
100
- const getObjectSubset = (object, subset, seenReferences = new WeakMap()) => {
101
- /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
102
- if (Array.isArray(object)) {
103
- if (Array.isArray(subset) && subset.length === object.length) {
104
- // The map method returns correct subclass of subset.
105
- return subset.map((sub, i) => getObjectSubset(object[i], sub));
106
- }
107
- } else if (object instanceof Date) {
108
- return object;
109
- } else if (isObject(object) && isObject(subset)) {
110
- if (
111
- (0, _jasmineUtils.equals)(object, subset, [
112
- iterableEquality,
113
- subsetEquality
114
- ])
115
- ) {
116
- // Avoid unnecessary copy which might return Object instead of subclass.
117
- return subset;
118
- }
119
-
120
- const trimmed = {};
121
- seenReferences.set(object, trimmed);
122
- Object.keys(object)
123
- .filter(key => hasPropertyInObject(subset, key))
124
- .forEach(key => {
125
- trimmed[key] = seenReferences.has(object[key])
126
- ? seenReferences.get(object[key])
127
- : getObjectSubset(object[key], subset[key], seenReferences);
128
- });
129
-
130
- if (Object.keys(trimmed).length > 0) {
131
- return trimmed;
132
- }
133
- }
134
-
135
- return object;
136
- };
137
-
138
- exports.getObjectSubset = getObjectSubset;
139
- const IteratorSymbol = Symbol.iterator;
140
-
141
- const hasIterator = object => !!(object != null && object[IteratorSymbol]);
142
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
143
-
144
- const iterableEquality = (
145
- a,
146
- b,
147
- /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
148
- aStack = [],
149
- bStack = []
150
- ) => {
151
- if (
152
- typeof a !== 'object' ||
153
- typeof b !== 'object' ||
154
- Array.isArray(a) ||
155
- Array.isArray(b) ||
156
- !hasIterator(a) ||
157
- !hasIterator(b)
158
- ) {
159
- return undefined;
160
- }
161
-
162
- if (a.constructor !== b.constructor) {
163
- return false;
164
- }
165
-
166
- let length = aStack.length;
167
-
168
- while (length--) {
169
- // Linear search. Performance is inversely proportional to the number of
170
- // unique nested structures.
171
- // circular references at same depth are equal
172
- // circular reference is not equal to non-circular one
173
- if (aStack[length] === a) {
174
- return bStack[length] === b;
175
- }
176
- }
177
-
178
- aStack.push(a);
179
- bStack.push(b);
180
-
181
- const iterableEqualityWithStack = (a, b) =>
182
- iterableEquality(a, b, [...aStack], [...bStack]);
183
-
184
- if (a.size !== undefined) {
185
- if (a.size !== b.size) {
186
- return false;
187
- } else if (
188
- (0, _jasmineUtils.isA)('Set', a) ||
189
- (0, _jasmineUtils.isImmutableUnorderedSet)(a)
190
- ) {
191
- let allFound = true;
192
-
193
- for (const aValue of a) {
194
- if (!b.has(aValue)) {
195
- let has = false;
196
-
197
- for (const bValue of b) {
198
- const isEqual = (0, _jasmineUtils.equals)(aValue, bValue, [
199
- iterableEqualityWithStack
200
- ]);
201
-
202
- if (isEqual === true) {
203
- has = true;
204
- }
205
- }
206
-
207
- if (has === false) {
208
- allFound = false;
209
- break;
210
- }
211
- }
212
- } // Remove the first value from the stack of traversed values.
213
-
214
- aStack.pop();
215
- bStack.pop();
216
- return allFound;
217
- } else if (
218
- (0, _jasmineUtils.isA)('Map', a) ||
219
- (0, _jasmineUtils.isImmutableUnorderedKeyed)(a)
220
- ) {
221
- let allFound = true;
222
-
223
- for (const aEntry of a) {
224
- if (
225
- !b.has(aEntry[0]) ||
226
- !(0, _jasmineUtils.equals)(aEntry[1], b.get(aEntry[0]), [
227
- iterableEqualityWithStack
228
- ])
229
- ) {
230
- let has = false;
231
-
232
- for (const bEntry of b) {
233
- const matchedKey = (0, _jasmineUtils.equals)(aEntry[0], bEntry[0], [
234
- iterableEqualityWithStack
235
- ]);
236
- let matchedValue = false;
237
-
238
- if (matchedKey === true) {
239
- matchedValue = (0, _jasmineUtils.equals)(aEntry[1], bEntry[1], [
240
- iterableEqualityWithStack
241
- ]);
242
- }
243
-
244
- if (matchedValue === true) {
245
- has = true;
246
- }
247
- }
248
-
249
- if (has === false) {
250
- allFound = false;
251
- break;
252
- }
253
- }
254
- } // Remove the first value from the stack of traversed values.
255
-
256
- aStack.pop();
257
- bStack.pop();
258
- return allFound;
259
- }
260
- }
261
-
262
- const bIterator = b[IteratorSymbol]();
263
-
264
- for (const aValue of a) {
265
- const nextB = bIterator.next();
266
-
267
- if (
268
- nextB.done ||
269
- !(0, _jasmineUtils.equals)(aValue, nextB.value, [
270
- iterableEqualityWithStack
271
- ])
272
- ) {
273
- return false;
274
- }
275
- }
276
-
277
- if (!bIterator.next().done) {
278
- return false;
279
- }
280
-
281
- if (
282
- !(0, _jasmineUtils.isImmutableList)(a) &&
283
- !(0, _jasmineUtils.isImmutableOrderedKeyed)(a) &&
284
- !(0, _jasmineUtils.isImmutableOrderedSet)(a)
285
- ) {
286
- const aEntries = Object.entries(a);
287
- const bEntries = Object.entries(b);
288
-
289
- if (!(0, _jasmineUtils.equals)(aEntries, bEntries)) {
290
- return false;
291
- }
292
- } // Remove the first value from the stack of traversed values.
293
-
294
- aStack.pop();
295
- bStack.pop();
296
- return true;
297
- };
298
-
299
- exports.iterableEquality = iterableEquality;
300
-
301
- const isObject = a => a !== null && typeof a === 'object';
302
-
303
- const isObjectWithKeys = a =>
304
- isObject(a) &&
305
- !(a instanceof Error) &&
306
- !(a instanceof Array) &&
307
- !(a instanceof Date);
308
-
309
- const subsetEquality = (object, subset) => {
310
- // subsetEquality needs to keep track of the references
311
- // it has already visited to avoid infinite loops in case
312
- // there are circular references in the subset passed to it.
313
- const subsetEqualityWithContext =
314
- (seenReferences = new WeakMap()) =>
315
- (object, subset) => {
316
- if (!isObjectWithKeys(subset)) {
317
- return undefined;
318
- }
319
-
320
- return Object.keys(subset).every(key => {
321
- if (isObjectWithKeys(subset[key])) {
322
- if (seenReferences.has(subset[key])) {
323
- return (0, _jasmineUtils.equals)(object[key], subset[key], [
324
- iterableEquality
325
- ]);
326
- }
327
-
328
- seenReferences.set(subset[key], true);
329
- }
330
-
331
- const result =
332
- object != null &&
333
- hasPropertyInObject(object, key) &&
334
- (0, _jasmineUtils.equals)(object[key], subset[key], [
335
- iterableEquality,
336
- subsetEqualityWithContext(seenReferences)
337
- ]); // The main goal of using seenReference is to avoid circular node on tree.
338
- // It will only happen within a parent and its child, not a node and nodes next to it (same level)
339
- // We should keep the reference for a parent and its child only
340
- // Thus we should delete the reference immediately so that it doesn't interfere
341
- // other nodes within the same level on tree.
342
-
343
- seenReferences.delete(subset[key]);
344
- return result;
345
- });
346
- };
347
-
348
- return subsetEqualityWithContext()(object, subset);
349
- }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
350
-
351
- exports.subsetEquality = subsetEquality;
352
-
353
- const typeEquality = (a, b) => {
354
- if (a == null || b == null || a.constructor === b.constructor) {
355
- return undefined;
356
- }
357
-
358
- return false;
359
- };
360
-
361
- exports.typeEquality = typeEquality;
362
-
363
- const arrayBufferEquality = (a, b) => {
364
- if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer)) {
365
- return undefined;
366
- }
367
-
368
- const dataViewA = new DataView(a);
369
- const dataViewB = new DataView(b); // Buffers are not equal when they do not have the same byte length
370
-
371
- if (dataViewA.byteLength !== dataViewB.byteLength) {
372
- return false;
373
- } // Check if every byte value is equal to each other
374
-
375
- for (let i = 0; i < dataViewA.byteLength; i++) {
376
- if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) {
377
- return false;
378
- }
379
- }
380
-
381
- return true;
382
- };
383
-
384
- exports.arrayBufferEquality = arrayBufferEquality;
385
-
386
- const sparseArrayEquality = (a, b) => {
387
- if (!Array.isArray(a) || !Array.isArray(b)) {
388
- return undefined;
389
- } // A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"]
390
-
391
- const aKeys = Object.keys(a);
392
- const bKeys = Object.keys(b);
393
- return (
394
- (0, _jasmineUtils.equals)(a, b, [iterableEquality, typeEquality], true) &&
395
- (0, _jasmineUtils.equals)(aKeys, bKeys)
396
- );
397
- };
398
-
399
- exports.sparseArrayEquality = sparseArrayEquality;
400
-
401
- const partition = (items, predicate) => {
402
- const result = [[], []];
403
- items.forEach(item => result[predicate(item) ? 0 : 1].push(item));
404
- return result;
405
- };
406
-
407
- exports.partition = partition;
408
-
409
- const pathAsArray = propertyPath => {
410
- const properties = [];
411
-
412
- if (propertyPath === '') {
413
- properties.push('');
414
- return properties;
415
- } // will match everything that's not a dot or a bracket, and "" for consecutive dots.
416
-
417
- const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g'); // Because the regex won't match a dot in the beginning of the path, if present.
418
-
419
- if (propertyPath[0] === '.') {
420
- properties.push('');
421
- }
422
-
423
- propertyPath.replace(pattern, match => {
424
- properties.push(match);
425
- return match;
426
- });
427
- return properties;
428
- }; // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
429
-
430
- exports.pathAsArray = pathAsArray;
431
-
432
- const isError = value => {
433
- switch (Object.prototype.toString.call(value)) {
434
- case '[object Error]':
435
- case '[object Exception]':
436
- case '[object DOMException]':
437
- return true;
438
-
439
- default:
440
- return value instanceof Error;
441
- }
442
- };
443
-
444
- exports.isError = isError;
445
-
446
- function emptyObject(obj) {
447
- return obj && typeof obj === 'object' ? !Object.keys(obj).length : false;
448
- }
449
-
450
- const MULTILINE_REGEXP = /[\r\n]/;
451
-
452
- const isOneline = (expected, received) =>
453
- typeof expected === 'string' &&
454
- typeof received === 'string' &&
455
- (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
456
-
457
- exports.isOneline = isOneline;
@@ -1,33 +0,0 @@
1
- {
2
- "name": "@jest/expect-utils",
3
- "version": "28.1.3",
4
- "repository": {
5
- "type": "git",
6
- "url": "https://github.com/facebook/jest.git",
7
- "directory": "packages/expect-utils"
8
- },
9
- "license": "MIT",
10
- "main": "./build/index.js",
11
- "types": "./build/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "types": "./build/index.d.ts",
15
- "default": "./build/index.js"
16
- },
17
- "./package.json": "./package.json"
18
- },
19
- "dependencies": {
20
- "jest-get-type": "^28.0.2"
21
- },
22
- "devDependencies": {
23
- "immutable": "^4.0.0",
24
- "jest-matcher-utils": "^28.1.3"
25
- },
26
- "engines": {
27
- "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
28
- },
29
- "publishConfig": {
30
- "access": "public"
31
- },
32
- "gitHead": "2cce069800dab3fc8ca7c469b32d2e2b2f7e2bb1"
33
- }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Facebook, Inc. and its affiliates.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,30 +0,0 @@
1
- # @jest/types
2
-
3
- This package contains shared types of Jest's packages.
4
-
5
- If you are looking for types of [Jest globals](https://jestjs.io/docs/api), you can import them from `@jest/globals` package:
6
-
7
- ```ts
8
- import {describe, expect, it} from '@jest/globals';
9
-
10
- describe('my tests', () => {
11
- it('works', () => {
12
- expect(1).toBe(1);
13
- });
14
- });
15
- ```
16
-
17
- If you prefer to omit imports, a similar result can be achieved installing the [@types/jest](https://npmjs.com/package/@types/jest) package. Note that this is a third party library maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) and may not cover the latest Jest features.
18
-
19
- Another use-case for `@types/jest` is a typed Jest config as those types are not provided by Jest out of the box:
20
-
21
- ```ts
22
- // jest.config.ts
23
- import {Config} from '@jest/types';
24
-
25
- const config: Config.InitialOptions = {
26
- // some typed config
27
- };
28
-
29
- export default config;
30
- ```
@@ -1 +0,0 @@
1
- 'use strict';
@@ -1 +0,0 @@
1
- 'use strict';
@@ -1 +0,0 @@
1
- 'use strict';
@@ -1 +0,0 @@
1
- 'use strict';
@@ -1 +0,0 @@
1
- 'use strict';