@keq-request/exception 5.0.0-alpha.9 → 5.0.0-beta.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,368 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-beta.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [95908fd]
8
+ - keq@5.0.0-beta.10
9
+
10
+ ## 5.0.0-beta.9
11
+
12
+ ### Patch Changes
13
+
14
+ - keq@5.0.0-beta.9
15
+
16
+ ## 5.0.0-beta.8
17
+
18
+ ### Minor Changes
19
+
20
+ - a183653: **Feat:** add clarifyFetchFailed middleware.
21
+
22
+ ### Patch Changes
23
+
24
+ - keq@5.0.0-beta.8
25
+
26
+ ## 5.0.0-beta.7
27
+
28
+ ### Patch Changes
29
+
30
+ - keq@5.0.0-beta.7
31
+
32
+ ## 5.0.0-beta.6
33
+
34
+ ### Patch Changes
35
+
36
+ - keq@5.0.0-beta.6
37
+
38
+ ## 5.0.0-beta.5
39
+
40
+ ### Patch Changes
41
+
42
+ - keq@5.0.0-beta.5
43
+
44
+ ## 5.0.0-beta.4
45
+
46
+ ### Patch Changes
47
+
48
+ - keq@5.0.0-beta.4
49
+
50
+ ## 5.0.0-beta.3
51
+
52
+ ### Patch Changes
53
+
54
+ - keq@5.0.0-beta.3
55
+
56
+ ## 5.0.0-beta.2
57
+
58
+ ### Patch Changes
59
+
60
+ - keq@5.0.0-beta.2
61
+
62
+ ## 5.0.0-beta.1
63
+
64
+ ### Major Changes
65
+
66
+ - 214ae66: **BREAKING CHANGE:** RequestException third parameter changed from retry: boolean to options: { fatal: boolean, response: Response }
67
+
68
+ ```javascript
69
+ // Before
70
+ new RequestException(400, "Error message", true);
71
+
72
+ // After
73
+ new RequestException(400, "Error message", {
74
+ fatal: false,
75
+ response: someResponseObject,
76
+ });
77
+ ```
78
+
79
+ - 5175097: **BREAKING CHANGE:** group all packages under the @keq-request scope
80
+
81
+ - keq-cache => @keq-request/cache
82
+ - keq-headers => @keq-request/headers
83
+ - keq-cli => @keq-request/cli
84
+ - keq-url => @keq-request/url
85
+ - keq-exception => @keq-request/exception
86
+
87
+ - 153244f: **BREAKING CHANGE:** move `RequestException` form `@keq-request/exception` to `keq`
88
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
89
+
90
+ ### Minor Changes
91
+
92
+ - 74803c8: export `createExceptionByStatusCode` to create HTTP exceptions from a `Response` object
93
+ - 241a2ca: **Feat:** add a validateStatusCode middleware and plugin use to validate http response and throw standard exception
94
+
95
+ ### Patch Changes
96
+
97
+ - b36df33: ValidateStatusCode plugin generate wrong code
98
+ - 2686b8d: build with turbo
99
+ - 2686b8d: remove private dependencies
100
+ - e7eb9dc: Don't publish .turbo and jest.config.cts to npm
101
+ - 0873c7e: Incorrect build before release.
102
+ - 153244f: remove override `retryOn`.
103
+ - 30b0848: rename validateResponse to validateStatusCode
104
+ - 581815a: ensure compatibility
105
+ - 7343445: Incorrect build before release
106
+ - Updated dependencies [cbc5d17]
107
+ - Updated dependencies [153244f]
108
+ - Updated dependencies [153244f]
109
+ - Updated dependencies [153244f]
110
+ - Updated dependencies [0a2eb2f]
111
+ - Updated dependencies [153244f]
112
+ - Updated dependencies [214ae66]
113
+ - Updated dependencies [c7ffd1f]
114
+ - Updated dependencies [90311b3]
115
+ - Updated dependencies [1f367c0]
116
+ - Updated dependencies [0c7db81]
117
+ - Updated dependencies [df114d1]
118
+ - Updated dependencies [2686b8d]
119
+ - Updated dependencies [842e555]
120
+ - Updated dependencies [153244f]
121
+ - Updated dependencies [2686b8d]
122
+ - Updated dependencies [9290139]
123
+ - Updated dependencies [7873a0a]
124
+ - Updated dependencies [e7eb9dc]
125
+ - Updated dependencies [7ff2162]
126
+ - Updated dependencies [22ce01a]
127
+ - Updated dependencies [0873c7e]
128
+ - Updated dependencies [153244f]
129
+ - Updated dependencies [a7a83da]
130
+ - Updated dependencies [f194c41]
131
+ - Updated dependencies [153244f]
132
+ - Updated dependencies [153244f]
133
+ - Updated dependencies [d076b76]
134
+ - Updated dependencies [f8abc63]
135
+ - Updated dependencies [153244f]
136
+ - Updated dependencies [ca6c879]
137
+ - Updated dependencies [63161c4]
138
+ - Updated dependencies [d472648]
139
+ - Updated dependencies [b8d02ca]
140
+ - Updated dependencies [0a04864]
141
+ - Updated dependencies [581815a]
142
+ - Updated dependencies [7343445]
143
+ - Updated dependencies [153244f]
144
+ - Updated dependencies [eed26f9]
145
+ - keq@5.0.0-beta.1
146
+
147
+ ## 5.0.0-alpha.36
148
+
149
+ ### Patch Changes
150
+
151
+ - keq@5.0.0-alpha.36
152
+
153
+ ## 5.0.0-alpha.35
154
+
155
+ ### Major Changes
156
+
157
+ - 0a04864: **Fix:** fix: update browser targets to chrome91/firefox90/safari15/edge91 to resolve esbuild 0.27 destructuring build errors.
158
+
159
+ ### Patch Changes
160
+
161
+ - Updated dependencies [0a04864]
162
+ - keq@5.0.0-alpha.35
163
+
164
+ ## 5.0.0-alpha.34
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [a7a83da]
169
+ - Updated dependencies [f8abc63]
170
+ - keq@5.0.0-alpha.34
171
+
172
+ ## 5.0.0-alpha.33
173
+
174
+ ### Patch Changes
175
+
176
+ - keq@5.0.0-alpha.33
177
+
178
+ ## 5.0.0-alpha.32
179
+
180
+ ### Minor Changes
181
+
182
+ - 74803c8: export `createExceptionByStatusCode` to create HTTP exceptions from a `Response` object
183
+
184
+ ### Patch Changes
185
+
186
+ - Updated dependencies [f194c41]
187
+ - Updated dependencies [b8d02ca]
188
+ - keq@5.0.0-alpha.32
189
+
190
+ ## 5.0.0-alpha.31
191
+
192
+ ### Patch Changes
193
+
194
+ - keq@5.0.0-alpha.31
195
+
196
+ ## 5.0.0-alpha.30
197
+
198
+ ### Patch Changes
199
+
200
+ - keq@5.0.0-alpha.30
201
+
202
+ ## 5.0.0-alpha.29
203
+
204
+ ### Patch Changes
205
+
206
+ - keq@5.0.0-alpha.29
207
+
208
+ ## 5.0.0-alpha.28
209
+
210
+ ### Patch Changes
211
+
212
+ - Updated dependencies [d076b76]
213
+ - keq@5.0.0-alpha.28
214
+
215
+ ## 5.0.0-alpha.27
216
+
217
+ ### Patch Changes
218
+
219
+ - Updated dependencies [0c7db81]
220
+ - keq@5.0.0-alpha.27
221
+
222
+ ## 5.0.0-alpha.26
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies [22ce01a]
227
+ - Updated dependencies [63161c4]
228
+ - keq@5.0.0-alpha.26
229
+
230
+ ## 5.0.0-alpha.25
231
+
232
+ ### Major Changes
233
+
234
+ - 214ae66: **BREAKING CHANGE:** RequestException third parameter changed from retry: boolean to options: { fatal: boolean, response: Response }
235
+
236
+ ```javascript
237
+ // Before
238
+ new RequestException(400, "Error message", true);
239
+
240
+ // After
241
+ new RequestException(400, "Error message", {
242
+ fatal: false,
243
+ response: someResponseObject,
244
+ });
245
+ ```
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies [214ae66]
250
+ - Updated dependencies [9290139]
251
+ - keq@5.0.0-alpha.25
252
+
253
+ ## 5.0.0-alpha.24
254
+
255
+ ### Patch Changes
256
+
257
+ - Updated dependencies [0a2eb2f]
258
+ - keq@5.0.0-alpha.24
259
+
260
+ ## 5.0.0-alpha.23
261
+
262
+ ### Patch Changes
263
+
264
+ - Updated dependencies [842e555]
265
+ - Updated dependencies [7873a0a]
266
+ - keq@5.0.0-alpha.23
267
+
268
+ ## 5.0.0-alpha.22
269
+
270
+ ### Patch Changes
271
+
272
+ - Updated dependencies [df114d1]
273
+ - keq@5.0.0-alpha.22
274
+
275
+ ## 5.0.0-alpha.21
276
+
277
+ ### Patch Changes
278
+
279
+ - b36df33: ValidateStatusCode plugin generate wrong code
280
+ - Updated dependencies [90311b3]
281
+ - keq@5.0.0-alpha.21
282
+
283
+ ## 5.0.0-alpha.20
284
+
285
+ ### Patch Changes
286
+
287
+ - Updated dependencies [1f367c0]
288
+ - keq@5.0.0-alpha.20
289
+
290
+ ## 5.0.0-alpha.19
291
+
292
+ ### Patch Changes
293
+
294
+ - 30b0848: rename validateResponse to validateStatusCode
295
+ - keq@5.0.0-alpha.19
296
+
297
+ ## 5.0.0-alpha.18
298
+
299
+ ### Minor Changes
300
+
301
+ - 241a2ca: **Feat:** add a validateResponse middleware and plugin use to validate http response and throw standard exception
302
+
303
+ ### Patch Changes
304
+
305
+ - Updated dependencies [cbc5d17]
306
+ - keq@5.0.0-alpha.18
307
+
308
+ ## 5.0.0-alpha.17
309
+
310
+ ### Patch Changes
311
+
312
+ - Updated dependencies [d472648]
313
+ - Updated dependencies [eed26f9]
314
+ - keq@5.0.0-alpha.17
315
+
316
+ ## 5.0.0-alpha.16
317
+
318
+ ### Patch Changes
319
+
320
+ - Updated dependencies [ca6c879]
321
+ - keq@5.0.0-alpha.16
322
+
323
+ ## 5.0.0-alpha.15
324
+
325
+ ### Patch Changes
326
+
327
+ - keq@5.0.0-alpha.15
328
+
329
+ ## 5.0.0-alpha.14
330
+
331
+ ### Patch Changes
332
+
333
+ - keq@5.0.0-alpha.14
334
+
335
+ ## 5.0.0-alpha.13
336
+
337
+ ### Patch Changes
338
+
339
+ - keq@5.0.0-alpha.13
340
+
341
+ ## 5.0.0-alpha.12
342
+
343
+ ### Patch Changes
344
+
345
+ - 581815a: ensure compatibility
346
+ - Updated dependencies [581815a]
347
+ - keq@5.0.0-alpha.12
348
+
349
+ ## 5.0.0-alpha.11
350
+
351
+ ### Patch Changes
352
+
353
+ - Updated dependencies [c7ffd1f]
354
+ - keq@5.0.0-alpha.11
355
+
356
+ ## 5.0.0-alpha.10
357
+
358
+ ### Patch Changes
359
+
360
+ - e7eb9dc: Don't publish .turbo and jest.config.cts to npm
361
+ - 7343445: Incorrect build before release
362
+ - Updated dependencies [e7eb9dc]
363
+ - Updated dependencies [7343445]
364
+ - keq@5.0.0-alpha.10
365
+
3
366
  ## 5.0.0-alpha.9
4
367
 
5
368
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ import { KeqContext, KeqMiddleware } from "keq";
2
+ import { Promisable } from "type-fest";
3
+
4
+ //#region src/throw-exception.d.ts
5
+ type Check = (ctx: KeqContext) => Promisable<void>;
6
+ declare function throwException(check: Check): KeqMiddleware;
7
+ //#endregion
8
+ //#region src/catch-exception.d.ts
9
+ declare function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware;
10
+ //#endregion
11
+ //#region src/validate-status-code.d.ts
12
+ declare function validateStatusCode(): KeqMiddleware;
13
+ //#endregion
14
+ //#region src/create-exception-by-status-code.d.ts
15
+ declare function createExceptionByStatusCode(response: Response): Error;
16
+ //#endregion
17
+ //#region src/clarify-fetch-failed.d.ts
18
+ declare function clarifyFetchFailed(): KeqMiddleware;
19
+ //#endregion
20
+ export { Check, catchException, clarifyFetchFailed, createExceptionByStatusCode, throwException, validateStatusCode };
21
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/validate-status-code.ts","../src/create-exception-by-status-code.ts","../src/clarify-fetch-failed.ts"],"mappings":";;;;KAIY,KAAA,IAAS,GAAA,EAAK,UAAA,KAAe,UAAA;AAAA,iBAEzB,cAAA,CAAe,KAAA,EAAO,KAAA,GAAQ,aAAA;;;iBCF9B,cAAA,CAAe,OAAA,GAAU,CAAA,cAAe,UAAA,SAAmB,aAAA;;;iBCD3D,kBAAA,CAAA,GAAsB,aAAA;;;iBCqBtB,2BAAA,CAA4B,QAAA,EAAU,QAAA,GAAW,KAAA;;;iBCtBjD,kBAAA,CAAA,GAAsB,aAAA"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,21 @@
1
- export * from './throw-exception.js';
2
- export * from './catch-exception.js';
1
+ import { KeqContext, KeqMiddleware } from "keq";
2
+ import { Promisable } from "type-fest";
3
+
4
+ //#region src/throw-exception.d.ts
5
+ type Check = (ctx: KeqContext) => Promisable<void>;
6
+ declare function throwException(check: Check): KeqMiddleware;
7
+ //#endregion
8
+ //#region src/catch-exception.d.ts
9
+ declare function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware;
10
+ //#endregion
11
+ //#region src/validate-status-code.d.ts
12
+ declare function validateStatusCode(): KeqMiddleware;
13
+ //#endregion
14
+ //#region src/create-exception-by-status-code.d.ts
15
+ declare function createExceptionByStatusCode(response: Response): Error;
16
+ //#endregion
17
+ //#region src/clarify-fetch-failed.d.ts
18
+ declare function clarifyFetchFailed(): KeqMiddleware;
19
+ //#endregion
20
+ export { Check, catchException, clarifyFetchFailed, createExceptionByStatusCode, throwException, validateStatusCode };
3
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/validate-status-code.ts","../src/create-exception-by-status-code.ts","../src/clarify-fetch-failed.ts"],"mappings":";;;;KAIY,KAAA,IAAS,GAAA,EAAK,UAAA,KAAe,UAAA;AAAA,iBAEzB,cAAA,CAAe,KAAA,EAAO,KAAA,GAAQ,aAAA;;;iBCF9B,cAAA,CAAe,OAAA,GAAU,CAAA,cAAe,UAAA,SAAmB,aAAA;;;iBCD3D,kBAAA,CAAA,GAAsB,aAAA;;;iBCqBtB,2BAAA,CAA4B,QAAA,EAAU,QAAA,GAAW,KAAA;;;iBCtBjD,kBAAA,CAAA,GAAsB,aAAA"}
package/dist/index.js CHANGED
@@ -1,51 +1,104 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- catchException: () => catchException,
24
- throwException: () => throwException
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/throw-exception.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let keq = require("keq");
3
+ //#region src/throw-exception.ts
29
4
  function throwException(check) {
30
- return async function throwException2(ctx, next) {
31
- await next();
32
- await check(ctx);
33
- };
5
+ return async function throwException(ctx, next) {
6
+ await next();
7
+ await check(ctx);
8
+ };
34
9
  }
35
-
36
- // src/catch-exception.ts
10
+ //#endregion
11
+ //#region src/catch-exception.ts
37
12
  function catchException(handler) {
38
- return async function catchException2(ctx, next) {
39
- try {
40
- await next();
41
- } catch (err) {
42
- await handler(err);
43
- }
44
- };
13
+ return async function catchException(ctx, next) {
14
+ try {
15
+ await next();
16
+ } catch (err) {
17
+ await handler(err);
18
+ }
19
+ };
20
+ }
21
+ //#endregion
22
+ //#region src/create-exception-by-status-code.ts
23
+ function createExceptionByStatusCode(response) {
24
+ const { status, statusText } = response;
25
+ if (status >= 400 && status < 500) switch (status) {
26
+ case 400: return new keq.BadRequestException(statusText, { response });
27
+ case 401: return new keq.UnauthorizedException(statusText, { response });
28
+ case 403: return new keq.ForbiddenException(statusText, { response });
29
+ case 404: return new keq.NotFoundedException(statusText, { response });
30
+ case 405: return new keq.MethodNotAllowedException(statusText, { response });
31
+ case 406: return new keq.NotAcceptableException(statusText, { response });
32
+ case 407: return new keq.ProxyAuthenticationRequiredException(statusText, { response });
33
+ case 408: return new keq.RequestTimeoutException(statusText, { response });
34
+ case 409: return new keq.ConflictException(statusText, { response });
35
+ case 412: return new keq.PreconditionFailedException(statusText, { response });
36
+ case 413: return new keq.ContentTooLargeException(statusText, { response });
37
+ case 414: return new keq.UriTooLongException(statusText, { response });
38
+ case 415: return new keq.UnsupportedMediaTypeException(statusText, { response });
39
+ case 418: return new keq.ImATeapotException(statusText, { response });
40
+ case 429: return new keq.TooManyRequestsException(statusText, { response });
41
+ default: return new keq.RequestException(status, statusText, {
42
+ fatal: true,
43
+ response
44
+ });
45
+ }
46
+ if (status >= 500) switch (status) {
47
+ case 500: return new keq.InternalServerErrorException(statusText, { response });
48
+ case 501: return new keq.NotImplementedException(statusText, { response });
49
+ case 502: return new keq.BadGatewayException(statusText, { response });
50
+ case 503: return new keq.ServiceUnavailableException(statusText, { response });
51
+ case 504: return new keq.GatewayTimeoutException(statusText, { response });
52
+ default: return new keq.RequestException(status, statusText, {
53
+ fatal: false,
54
+ response
55
+ });
56
+ }
57
+ return new keq.RequestException(status, statusText, {
58
+ fatal: false,
59
+ response
60
+ });
45
61
  }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- catchException,
49
- throwException
50
- });
62
+ //#endregion
63
+ //#region src/validate-status-code.ts
64
+ function validateStatusCode() {
65
+ return async function validateStatusCode(context, next) {
66
+ await next();
67
+ const response = context.response;
68
+ if (!response) return;
69
+ const { status } = response;
70
+ if (status >= 200 && status < 300) return;
71
+ if (status >= 300 && status < 400) return;
72
+ throw createExceptionByStatusCode(response);
73
+ };
74
+ }
75
+ //#endregion
76
+ //#region src/clarify-fetch-failed.ts
77
+ function clarifyFetchFailed() {
78
+ return async function clarifyFetchFailedMiddleware(ctx, next) {
79
+ try {
80
+ await next();
81
+ } catch (error) {
82
+ throw resolveCause(error);
83
+ }
84
+ };
85
+ }
86
+ function resolveCause(error) {
87
+ if (!(error instanceof Error)) return error;
88
+ const causes = [];
89
+ let current = error.cause;
90
+ while (current instanceof Error) {
91
+ causes.push(current.message);
92
+ current = current.cause;
93
+ }
94
+ if (!causes.length) return error;
95
+ return new error.constructor(`${error.message}: ${causes.join(" - ")}`, { cause: error.cause });
96
+ }
97
+ //#endregion
98
+ exports.catchException = catchException;
99
+ exports.clarifyFetchFailed = clarifyFetchFailed;
100
+ exports.createExceptionByStatusCode = createExceptionByStatusCode;
101
+ exports.throwException = throwException;
102
+ exports.validateStatusCode = validateStatusCode;
103
+
51
104
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/throw-exception.ts","../src/catch-exception.ts"],"sourcesContent":["export * from './throw-exception.js'\nexport * from './catch-exception.js'\n","import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,eAAe,OAA6B;AAC1D,SAAO,eAAeA,gBAAe,KAAK,MAAM;AAC9C,UAAM,KAAK;AAEX,UAAM,MAAM,GAAG;AAAA,EACjB;AACF;;;ACRO,SAAS,eAAe,SAA0D;AACvF,SAAO,eAAeC,gBAAe,KAAK,MAAM;AAC9C,QAAI;AACF,YAAM,KAAK;AAAA,IACb,SAAS,KAAK;AACZ,YAAM,QAAQ,GAAG;AAAA,IACnB;AAAA,EACF;AACF;","names":["throwException","catchException"]}
1
+ {"version":3,"file":"index.js","names":["BadRequestException","UnauthorizedException","ForbiddenException","NotFoundedException","MethodNotAllowedException","NotAcceptableException","ProxyAuthenticationRequiredException","RequestTimeoutException","ConflictException","PreconditionFailedException","ContentTooLargeException","UriTooLongException","UnsupportedMediaTypeException","ImATeapotException","TooManyRequestsException","RequestException","InternalServerErrorException","NotImplementedException","BadGatewayException","ServiceUnavailableException","GatewayTimeoutException"],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/create-exception-by-status-code.ts","../src/validate-status-code.ts","../src/clarify-fetch-failed.ts"],"sourcesContent":["import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n","import {\n BadGatewayException,\n BadRequestException,\n ConflictException,\n ForbiddenException,\n GatewayTimeoutException,\n InternalServerErrorException,\n NotAcceptableException,\n NotFoundedException,\n PreconditionFailedException,\n RequestException,\n ServiceUnavailableException,\n UnauthorizedException,\n ImATeapotException,\n MethodNotAllowedException,\n UriTooLongException,\n ContentTooLargeException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n TooManyRequestsException,\n NotImplementedException,\n UnsupportedMediaTypeException,\n} from 'keq'\n\nexport function createExceptionByStatusCode(response: Response): Error {\n const { status, statusText } = response\n\n // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n return new BadRequestException(statusText, { response })\n case 401:\n return new UnauthorizedException(statusText, { response })\n case 403:\n return new ForbiddenException(statusText, { response })\n case 404:\n return new NotFoundedException(statusText, { response })\n case 405:\n return new MethodNotAllowedException(statusText, { response })\n case 406:\n return new NotAcceptableException(statusText, { response })\n case 407:\n return new ProxyAuthenticationRequiredException(statusText, { response })\n case 408:\n return new RequestTimeoutException(statusText, { response })\n case 409:\n return new ConflictException(statusText, { response })\n case 412:\n return new PreconditionFailedException(statusText, { response })\n case 413:\n return new ContentTooLargeException(statusText, { response })\n case 414:\n return new UriTooLongException(statusText, { response })\n case 415:\n return new UnsupportedMediaTypeException(statusText, { response })\n case 418:\n return new ImATeapotException(statusText, { response })\n case 429:\n return new TooManyRequestsException(statusText, { response })\n default:\n // Other 4xx errors, don't retry by default\n return new RequestException(status, statusText, { fatal: true, response })\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n return new InternalServerErrorException(statusText, { response })\n case 501:\n return new NotImplementedException(statusText, { response })\n case 502:\n return new BadGatewayException(statusText, { response })\n case 503:\n return new ServiceUnavailableException(statusText, { response })\n case 504:\n return new GatewayTimeoutException(statusText, { response })\n default:\n // Other 5xx errors, retry by default\n return new RequestException(status, statusText, { fatal: false, response })\n }\n }\n\n return new RequestException(status, statusText, { fatal: false, response })\n}\n","import { KeqMiddleware } from 'keq'\nimport { createExceptionByStatusCode } from './create-exception-by-status-code.js'\n\nexport function validateStatusCode(): KeqMiddleware {\n return async function validateStatusCode(context, next) {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status } = response\n\n // 2xx success status codes - no error\n if (status >= 200 && status < 300) return\n\n // 3xx redirection status codes - no error (handled by fetch)\n if (status >= 300 && status < 400) return\n\n throw createExceptionByStatusCode(response)\n }\n}\n","import type { KeqMiddleware } from 'keq'\n\nexport function clarifyFetchFailed(): KeqMiddleware {\n return async function clarifyFetchFailedMiddleware(ctx, next) {\n try {\n await next()\n } catch (error) {\n throw resolveCause(error)\n }\n }\n}\n\nfunction resolveCause(error: unknown): unknown {\n if (!(error instanceof Error)) return error\n\n const causes: string[] = []\n let current: unknown = error.cause\n while (current instanceof Error) {\n causes.push(current.message)\n current = current.cause\n }\n\n if (!causes.length) return error\n\n const enhanced = new (error.constructor as new (message: string, options?: { cause?: unknown }) => Error)(\n `${error.message}: ${causes.join(' - ')}`,\n { cause: error.cause },\n )\n return enhanced\n}\n"],"mappings":";;;AAMA,SAAgB,eAAe,OAA6B;AAC1D,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,QAAM,MAAM;AAEZ,QAAM,MAAM,IAAI;;;;;ACNpB,SAAgB,eAAe,SAA0D;AACvF,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,MAAI;AACF,SAAM,MAAM;WACL,KAAK;AACZ,SAAM,QAAQ,IAAI;;;;;;ACexB,SAAgB,4BAA4B,UAA2B;CACrE,MAAM,EAAE,QAAQ,eAAe;AAG/B,KAAI,UAAU,OAAO,SAAS,IAC5B,SAAQ,QAAR;EACE,KAAK,IACH,QAAO,IAAIA,IAAAA,oBAAoB,YAAY,EAAE,UAAU,CAAC;EAC1D,KAAK,IACH,QAAO,IAAIC,IAAAA,sBAAsB,YAAY,EAAE,UAAU,CAAC;EAC5D,KAAK,IACH,QAAO,IAAIC,IAAAA,mBAAmB,YAAY,EAAE,UAAU,CAAC;EACzD,KAAK,IACH,QAAO,IAAIC,IAAAA,oBAAoB,YAAY,EAAE,UAAU,CAAC;EAC1D,KAAK,IACH,QAAO,IAAIC,IAAAA,0BAA0B,YAAY,EAAE,UAAU,CAAC;EAChE,KAAK,IACH,QAAO,IAAIC,IAAAA,uBAAuB,YAAY,EAAE,UAAU,CAAC;EAC7D,KAAK,IACH,QAAO,IAAIC,IAAAA,qCAAqC,YAAY,EAAE,UAAU,CAAC;EAC3E,KAAK,IACH,QAAO,IAAIC,IAAAA,wBAAwB,YAAY,EAAE,UAAU,CAAC;EAC9D,KAAK,IACH,QAAO,IAAIC,IAAAA,kBAAkB,YAAY,EAAE,UAAU,CAAC;EACxD,KAAK,IACH,QAAO,IAAIC,IAAAA,4BAA4B,YAAY,EAAE,UAAU,CAAC;EAClE,KAAK,IACH,QAAO,IAAIC,IAAAA,yBAAyB,Y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;AAClD,QAAO,eAAe,6BAA6B,KAAK,MAAM;AAC5D,MAAI;AACF,SAAM,MAAM;WACL,OAAO;AACd,SAAM,aAAa,MAAM;;;;AAK/B,SAAS,aAAa,OAAyB;AAC7C,KAAI,EAAE,iBAAiB,OAAQ,QAAO;CAEtC,MAAM,SAAmB,EAAE;CAC3B,IAAI,UAAmB,MAAM;AAC7B,QAAO,mBAAmB,OAAO;AAC/B,SAAO,KAAK,QAAQ,QAAQ;AAC5B,YAAU,QAAQ;;AAGpB,KAAI,CAAC,OAAO,OAAQ,QAAO;AAM3B,QAAO,IAJe,MAAM,YAC1B,GAAG,MAAM,QAAQ,IAAI,OAAO,KAAK,MAAM,IACvC,EAAE,OAAO,MAAM,OAAO,CAET"}
package/dist/index.mjs CHANGED
@@ -1,23 +1,99 @@
1
- // src/throw-exception.ts
1
+ import { BadGatewayException, BadRequestException, ConflictException, ContentTooLargeException, ForbiddenException, GatewayTimeoutException, ImATeapotException, InternalServerErrorException, MethodNotAllowedException, NotAcceptableException, NotFoundedException, NotImplementedException, PreconditionFailedException, ProxyAuthenticationRequiredException, RequestException, RequestTimeoutException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UnsupportedMediaTypeException, UriTooLongException } from "keq";
2
+ //#region src/throw-exception.ts
2
3
  function throwException(check) {
3
- return async function throwException2(ctx, next) {
4
- await next();
5
- await check(ctx);
6
- };
4
+ return async function throwException(ctx, next) {
5
+ await next();
6
+ await check(ctx);
7
+ };
7
8
  }
8
-
9
- // src/catch-exception.ts
9
+ //#endregion
10
+ //#region src/catch-exception.ts
10
11
  function catchException(handler) {
11
- return async function catchException2(ctx, next) {
12
- try {
13
- await next();
14
- } catch (err) {
15
- await handler(err);
16
- }
17
- };
12
+ return async function catchException(ctx, next) {
13
+ try {
14
+ await next();
15
+ } catch (err) {
16
+ await handler(err);
17
+ }
18
+ };
19
+ }
20
+ //#endregion
21
+ //#region src/create-exception-by-status-code.ts
22
+ function createExceptionByStatusCode(response) {
23
+ const { status, statusText } = response;
24
+ if (status >= 400 && status < 500) switch (status) {
25
+ case 400: return new BadRequestException(statusText, { response });
26
+ case 401: return new UnauthorizedException(statusText, { response });
27
+ case 403: return new ForbiddenException(statusText, { response });
28
+ case 404: return new NotFoundedException(statusText, { response });
29
+ case 405: return new MethodNotAllowedException(statusText, { response });
30
+ case 406: return new NotAcceptableException(statusText, { response });
31
+ case 407: return new ProxyAuthenticationRequiredException(statusText, { response });
32
+ case 408: return new RequestTimeoutException(statusText, { response });
33
+ case 409: return new ConflictException(statusText, { response });
34
+ case 412: return new PreconditionFailedException(statusText, { response });
35
+ case 413: return new ContentTooLargeException(statusText, { response });
36
+ case 414: return new UriTooLongException(statusText, { response });
37
+ case 415: return new UnsupportedMediaTypeException(statusText, { response });
38
+ case 418: return new ImATeapotException(statusText, { response });
39
+ case 429: return new TooManyRequestsException(statusText, { response });
40
+ default: return new RequestException(status, statusText, {
41
+ fatal: true,
42
+ response
43
+ });
44
+ }
45
+ if (status >= 500) switch (status) {
46
+ case 500: return new InternalServerErrorException(statusText, { response });
47
+ case 501: return new NotImplementedException(statusText, { response });
48
+ case 502: return new BadGatewayException(statusText, { response });
49
+ case 503: return new ServiceUnavailableException(statusText, { response });
50
+ case 504: return new GatewayTimeoutException(statusText, { response });
51
+ default: return new RequestException(status, statusText, {
52
+ fatal: false,
53
+ response
54
+ });
55
+ }
56
+ return new RequestException(status, statusText, {
57
+ fatal: false,
58
+ response
59
+ });
60
+ }
61
+ //#endregion
62
+ //#region src/validate-status-code.ts
63
+ function validateStatusCode() {
64
+ return async function validateStatusCode(context, next) {
65
+ await next();
66
+ const response = context.response;
67
+ if (!response) return;
68
+ const { status } = response;
69
+ if (status >= 200 && status < 300) return;
70
+ if (status >= 300 && status < 400) return;
71
+ throw createExceptionByStatusCode(response);
72
+ };
18
73
  }
19
- export {
20
- catchException,
21
- throwException
22
- };
74
+ //#endregion
75
+ //#region src/clarify-fetch-failed.ts
76
+ function clarifyFetchFailed() {
77
+ return async function clarifyFetchFailedMiddleware(ctx, next) {
78
+ try {
79
+ await next();
80
+ } catch (error) {
81
+ throw resolveCause(error);
82
+ }
83
+ };
84
+ }
85
+ function resolveCause(error) {
86
+ if (!(error instanceof Error)) return error;
87
+ const causes = [];
88
+ let current = error.cause;
89
+ while (current instanceof Error) {
90
+ causes.push(current.message);
91
+ current = current.cause;
92
+ }
93
+ if (!causes.length) return error;
94
+ return new error.constructor(`${error.message}: ${causes.join(" - ")}`, { cause: error.cause });
95
+ }
96
+ //#endregion
97
+ export { catchException, clarifyFetchFailed, createExceptionByStatusCode, throwException, validateStatusCode };
98
+
23
99
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/throw-exception.ts","../src/catch-exception.ts"],"sourcesContent":["import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n"],"mappings":";AAMO,SAAS,eAAe,OAA6B;AAC1D,SAAO,eAAeA,gBAAe,KAAK,MAAM;AAC9C,UAAM,KAAK;AAEX,UAAM,MAAM,GAAG;AAAA,EACjB;AACF;;;ACRO,SAAS,eAAe,SAA0D;AACvF,SAAO,eAAeC,gBAAe,KAAK,MAAM;AAC9C,QAAI;AACF,YAAM,KAAK;AAAA,IACb,SAAS,KAAK;AACZ,YAAM,QAAQ,GAAG;AAAA,IACnB;AAAA,EACF;AACF;","names":["throwException","catchException"]}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/throw-exception.ts","../src/catch-exception.ts","../src/create-exception-by-status-code.ts","../src/validate-status-code.ts","../src/clarify-fetch-failed.ts"],"sourcesContent":["import { KeqContext, KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport type Check = (ctx: KeqContext) => Promisable<void>\n\nexport function throwException(check: Check): KeqMiddleware {\n return async function throwException(ctx, next) {\n await next()\n\n await check(ctx)\n }\n}\n","import { KeqMiddleware } from 'keq'\nimport { Promisable } from 'type-fest'\n\n\nexport function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware {\n return async function catchException(ctx, next) {\n try {\n await next()\n } catch (err) {\n await handler(err)\n }\n }\n}\n","import {\n BadGatewayException,\n BadRequestException,\n ConflictException,\n ForbiddenException,\n GatewayTimeoutException,\n InternalServerErrorException,\n NotAcceptableException,\n NotFoundedException,\n PreconditionFailedException,\n RequestException,\n ServiceUnavailableException,\n UnauthorizedException,\n ImATeapotException,\n MethodNotAllowedException,\n UriTooLongException,\n ContentTooLargeException,\n ProxyAuthenticationRequiredException,\n RequestTimeoutException,\n TooManyRequestsException,\n NotImplementedException,\n UnsupportedMediaTypeException,\n} from 'keq'\n\nexport function createExceptionByStatusCode(response: Response): Error {\n const { status, statusText } = response\n\n // 4xx client errors\n if (status >= 400 && status < 500) {\n switch (status) {\n case 400:\n return new BadRequestException(statusText, { response })\n case 401:\n return new UnauthorizedException(statusText, { response })\n case 403:\n return new ForbiddenException(statusText, { response })\n case 404:\n return new NotFoundedException(statusText, { response })\n case 405:\n return new MethodNotAllowedException(statusText, { response })\n case 406:\n return new NotAcceptableException(statusText, { response })\n case 407:\n return new ProxyAuthenticationRequiredException(statusText, { response })\n case 408:\n return new RequestTimeoutException(statusText, { response })\n case 409:\n return new ConflictException(statusText, { response })\n case 412:\n return new PreconditionFailedException(statusText, { response })\n case 413:\n return new ContentTooLargeException(statusText, { response })\n case 414:\n return new UriTooLongException(statusText, { response })\n case 415:\n return new UnsupportedMediaTypeException(statusText, { response })\n case 418:\n return new ImATeapotException(statusText, { response })\n case 429:\n return new TooManyRequestsException(statusText, { response })\n default:\n // Other 4xx errors, don't retry by default\n return new RequestException(status, statusText, { fatal: true, response })\n }\n }\n\n // 5xx server errors\n if (status >= 500) {\n switch (status) {\n case 500:\n return new InternalServerErrorException(statusText, { response })\n case 501:\n return new NotImplementedException(statusText, { response })\n case 502:\n return new BadGatewayException(statusText, { response })\n case 503:\n return new ServiceUnavailableException(statusText, { response })\n case 504:\n return new GatewayTimeoutException(statusText, { response })\n default:\n // Other 5xx errors, retry by default\n return new RequestException(status, statusText, { fatal: false, response })\n }\n }\n\n return new RequestException(status, statusText, { fatal: false, response })\n}\n","import { KeqMiddleware } from 'keq'\nimport { createExceptionByStatusCode } from './create-exception-by-status-code.js'\n\nexport function validateStatusCode(): KeqMiddleware {\n return async function validateStatusCode(context, next) {\n await next()\n\n const response = context.response\n if (!response) return\n\n const { status } = response\n\n // 2xx success status codes - no error\n if (status >= 200 && status < 300) return\n\n // 3xx redirection status codes - no error (handled by fetch)\n if (status >= 300 && status < 400) return\n\n throw createExceptionByStatusCode(response)\n }\n}\n","import type { KeqMiddleware } from 'keq'\n\nexport function clarifyFetchFailed(): KeqMiddleware {\n return async function clarifyFetchFailedMiddleware(ctx, next) {\n try {\n await next()\n } catch (error) {\n throw resolveCause(error)\n }\n }\n}\n\nfunction resolveCause(error: unknown): unknown {\n if (!(error instanceof Error)) return error\n\n const causes: string[] = []\n let current: unknown = error.cause\n while (current instanceof Error) {\n causes.push(current.message)\n current = current.cause\n }\n\n if (!causes.length) return error\n\n const enhanced = new (error.constructor as new (message: string, options?: { cause?: unknown }) => Error)(\n `${error.message}: ${causes.join(' - ')}`,\n { cause: error.cause },\n )\n return enhanced\n}\n"],"mappings":";;AAMA,SAAgB,eAAe,OAA6B;AAC1D,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,QAAM,MAAM;AAEZ,QAAM,MAAM,IAAI;;;;;ACNpB,SAAgB,eAAe,SAA0D;AACvF,QAAO,eAAe,eAAe,KAAK,MAAM;AAC9C,MAAI;AACF,SAAM,MAAM;WAC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",
3
- "version": "5.0.0-alpha.9",
3
+ "version": "5.0.0-beta.10",
4
4
  "description": "Request exception for keq",
5
5
  "keywords": [
6
6
  "keq",
@@ -9,7 +9,7 @@
9
9
  "error",
10
10
  "fetch"
11
11
  ],
12
- "homepage": "https://github.com/keq-request/keq#readme",
12
+ "homepage": "https://keq-request.github.io",
13
13
  "bugs": {
14
14
  "url": "https://github.com/keq-request/keq/issues"
15
15
  },
@@ -29,18 +29,18 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "type-fest": "^5.2.0"
32
+ "type-fest": "^5.6.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/node": "^20.19.24",
36
- "keq": "5.0.0-alpha.9"
35
+ "@types/node": "^20.19.39",
36
+ "keq": "5.0.0-beta.10"
37
37
  },
38
38
  "peerDependencies": {
39
- "keq": "^5.0.0-alpha.9"
39
+ "keq": "^5.0.0-beta.10"
40
40
  },
41
41
  "scripts": {
42
- "build": "tsup",
43
- "dev": "tsup --watch",
42
+ "build": "tsdown",
43
+ "dev": "tsdown --watch",
44
44
  "test": "jest",
45
45
  "test:update": "jest -u"
46
46
  }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'tsdown'
2
+
3
+ export default defineConfig([
4
+ {
5
+ entry: ['src/index.ts'],
6
+ format: ['cjs', 'esm'],
7
+ target: ['chrome91', 'firefox90', 'safari15', 'edge91', 'node20'],
8
+ outDir: 'dist',
9
+ platform: 'neutral',
10
+ tsconfig: 'tsconfig.lib.json',
11
+ dts: { sourcemap: true },
12
+ sourcemap: true,
13
+ clean: true,
14
+ },
15
+ ])
@@ -1,18 +0,0 @@
1
-
2
- > @keq-request/exception@5.0.0-alpha.9 build /home/runner/work/keq/keq/packages/exception
3
- > tsup
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.lib.json
7
- CLI tsup v8.5.0
8
- CLI Using tsup config: /home/runner/work/keq/keq/packages/exception/tsup.config.ts
9
- CLI Target: esnext
10
- CLI Cleaning output folder
11
- CJS Build start
12
- ESM Build start
13
- ESM dist/index.mjs 444.00 B
14
- ESM dist/index.mjs.map 1.03 KB
15
- ESM ⚡️ Build success in 34ms
16
- CJS dist/index.js 1.48 KB
17
- CJS dist/index.js.map 1.18 KB
18
- CJS ⚡️ Build success in 34ms
@@ -1,4 +0,0 @@
1
- import { KeqMiddleware } from 'keq';
2
- import { Promisable } from 'type-fest';
3
- export declare function catchException(handler: (e: unknown) => Promisable<void>): KeqMiddleware;
4
- //# sourceMappingURL=catch-exception.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catch-exception.d.ts","sourceRoot":"","sources":["../src/catch-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,wBAAgB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAQvF"}
@@ -1,5 +0,0 @@
1
- import { KeqContext, KeqMiddleware } from 'keq';
2
- import { Promisable } from 'type-fest';
3
- export type Check = (ctx: KeqContext) => Promisable<void>;
4
- export declare function throwException(check: Check): KeqMiddleware;
5
- //# sourceMappingURL=throw-exception.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"throw-exception.d.ts","sourceRoot":"","sources":["../src/throw-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,UAAU,KAAK,UAAU,CAAC,IAAI,CAAC,CAAA;AAEzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAM1D"}
package/jest.config.cts DELETED
@@ -1,14 +0,0 @@
1
- import type { Config } from 'jest'
2
- import { pathsToModuleNameMapper } from 'ts-jest'
3
- import { compilerOptions } from './tsconfig.json'
4
-
5
-
6
- export default async (): Promise<Config> => ({
7
- preset: 'ts-jest',
8
- // setupFilesAfterEnv: ['<rootDir>/__tests__/setup.ts'],
9
- moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src', useESM: true }),
10
- testMatch: [
11
- '<rootDir>/__tests__/**/*.spec.ts',
12
- '<rootDir>/src/**/*.spec.ts',
13
- ],
14
- })