@ancon/wildcat-utils 1.24.2 → 1.25.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.
@@ -1,941 +1,18 @@
1
- var cr = Object.defineProperty;
2
- var dr = (r, e, t) => e in r ? cr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var O = (r, e, t) => (dr(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { ErrorCode as k } from "@ancon/wildcat-types";
5
- import L from "../error/createCodedError.mjs";
6
- import hr from "../api/isNoContentResponse.mjs";
7
- function pr(r) {
8
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
9
- }
10
- var le = {}, mr = {
11
- get exports() {
12
- return le;
13
- },
14
- set exports(r) {
15
- le = r;
16
- }
17
- }, j = {}, vr = {
18
- get exports() {
19
- return j;
20
- },
21
- set exports(r) {
22
- j = r;
23
- }
24
- }, ze = function(e, t) {
25
- return function() {
26
- for (var n = new Array(arguments.length), s = 0; s < n.length; s++)
27
- n[s] = arguments[s];
28
- return e.apply(t, n);
29
- };
30
- }, Er = ze, de = Object.prototype.toString, he = function(r) {
31
- return function(e) {
32
- var t = de.call(e);
33
- return r[t] || (r[t] = t.slice(8, -1).toLowerCase());
34
- };
35
- }(/* @__PURE__ */ Object.create(null));
36
- function x(r) {
37
- return r = r.toLowerCase(), function(t) {
38
- return he(t) === r;
39
- };
40
- }
41
- function pe(r) {
42
- return Array.isArray(r);
43
- }
44
- function I(r) {
45
- return typeof r > "u";
46
- }
47
- function yr(r) {
48
- return r !== null && !I(r) && r.constructor !== null && !I(r.constructor) && typeof r.constructor.isBuffer == "function" && r.constructor.isBuffer(r);
49
- }
50
- var Ge = x("ArrayBuffer");
51
- function br(r) {
52
- var e;
53
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(r) : e = r && r.buffer && Ge(r.buffer), e;
54
- }
55
- function Rr(r) {
56
- return typeof r == "string";
57
- }
58
- function wr(r) {
59
- return typeof r == "number";
60
- }
61
- function Je(r) {
62
- return r !== null && typeof r == "object";
63
- }
64
- function F(r) {
65
- if (he(r) !== "object")
66
- return !1;
67
- var e = Object.getPrototypeOf(r);
68
- return e === null || e === Object.prototype;
69
- }
70
- var gr = x("Date"), Or = x("File"), xr = x("Blob"), Ar = x("FileList");
71
- function me(r) {
72
- return de.call(r) === "[object Function]";
73
- }
74
- function Sr(r) {
75
- return Je(r) && me(r.pipe);
76
- }
77
- function Cr(r) {
78
- var e = "[object FormData]";
79
- return r && (typeof FormData == "function" && r instanceof FormData || de.call(r) === e || me(r.toString) && r.toString() === e);
80
- }
81
- var Tr = x("URLSearchParams");
82
- function Pr(r) {
83
- return r.trim ? r.trim() : r.replace(/^\s+|\s+$/g, "");
84
- }
85
- function Nr() {
86
- return typeof navigator < "u" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS") ? !1 : typeof window < "u" && typeof document < "u";
87
- }
88
- function ve(r, e) {
89
- if (!(r === null || typeof r > "u"))
90
- if (typeof r != "object" && (r = [r]), pe(r))
91
- for (var t = 0, i = r.length; t < i; t++)
92
- e.call(null, r[t], t, r);
93
- else
94
- for (var n in r)
95
- Object.prototype.hasOwnProperty.call(r, n) && e.call(null, r[n], n, r);
96
- }
97
- function ce() {
98
- var r = {};
99
- function e(n, s) {
100
- F(r[s]) && F(n) ? r[s] = ce(r[s], n) : F(n) ? r[s] = ce({}, n) : pe(n) ? r[s] = n.slice() : r[s] = n;
101
- }
102
- for (var t = 0, i = arguments.length; t < i; t++)
103
- ve(arguments[t], e);
104
- return r;
105
- }
106
- function _r(r, e, t) {
107
- return ve(e, function(n, s) {
108
- t && typeof n == "function" ? r[s] = Er(n, t) : r[s] = n;
109
- }), r;
110
- }
111
- function Dr(r) {
112
- return r.charCodeAt(0) === 65279 && (r = r.slice(1)), r;
113
- }
114
- function Ur(r, e, t, i) {
115
- r.prototype = Object.create(e.prototype, i), r.prototype.constructor = r, t && Object.assign(r.prototype, t);
116
- }
117
- function qr(r, e, t) {
118
- var i, n, s, a = {};
119
- e = e || {};
120
- do {
121
- for (i = Object.getOwnPropertyNames(r), n = i.length; n-- > 0; )
122
- s = i[n], a[s] || (e[s] = r[s], a[s] = !0);
123
- r = Object.getPrototypeOf(r);
124
- } while (r && (!t || t(r, e)) && r !== Object.prototype);
125
- return e;
126
- }
127
- function Br(r, e, t) {
128
- r = String(r), (t === void 0 || t > r.length) && (t = r.length), t -= e.length;
129
- var i = r.indexOf(e, t);
130
- return i !== -1 && i === t;
131
- }
132
- function kr(r) {
133
- if (!r)
134
- return null;
135
- var e = r.length;
136
- if (I(e))
137
- return null;
138
- for (var t = new Array(e); e-- > 0; )
139
- t[e] = r[e];
140
- return t;
141
- }
142
- var Lr = function(r) {
143
- return function(e) {
144
- return r && e instanceof r;
145
- };
146
- }(typeof Uint8Array < "u" && Object.getPrototypeOf(Uint8Array)), m = {
147
- isArray: pe,
148
- isArrayBuffer: Ge,
149
- isBuffer: yr,
150
- isFormData: Cr,
151
- isArrayBufferView: br,
152
- isString: Rr,
153
- isNumber: wr,
154
- isObject: Je,
155
- isPlainObject: F,
156
- isUndefined: I,
157
- isDate: gr,
158
- isFile: Or,
159
- isBlob: xr,
160
- isFunction: me,
161
- isStream: Sr,
162
- isURLSearchParams: Tr,
163
- isStandardBrowserEnv: Nr,
164
- forEach: ve,
165
- merge: ce,
166
- extend: _r,
167
- trim: Pr,
168
- stripBOM: Dr,
169
- inherits: Ur,
170
- toFlatObject: qr,
171
- kindOf: he,
172
- kindOfTest: x,
173
- endsWith: Br,
174
- toArray: kr,
175
- isTypedArray: Lr,
176
- isFileList: Ar
177
- }, T = m;
178
- function ge(r) {
179
- return encodeURIComponent(r).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
180
- }
181
- var Ve = function(e, t, i) {
182
- if (!t)
183
- return e;
184
- var n;
185
- if (i)
186
- n = i(t);
187
- else if (T.isURLSearchParams(t))
188
- n = t.toString();
189
- else {
190
- var s = [];
191
- T.forEach(t, function(f, d) {
192
- f === null || typeof f > "u" || (T.isArray(f) ? d = d + "[]" : f = [f], T.forEach(f, function(h) {
193
- T.isDate(h) ? h = h.toISOString() : T.isObject(h) && (h = JSON.stringify(h)), s.push(ge(d) + "=" + ge(h));
194
- }));
195
- }), n = s.join("&");
196
- }
197
- if (n) {
198
- var a = e.indexOf("#");
199
- a !== -1 && (e = e.slice(0, a)), e += (e.indexOf("?") === -1 ? "?" : "&") + n;
200
- }
201
- return e;
202
- }, Fr = m;
203
- function H() {
204
- this.handlers = [];
205
- }
206
- H.prototype.use = function(e, t, i) {
207
- return this.handlers.push({
208
- fulfilled: e,
209
- rejected: t,
210
- synchronous: i ? i.synchronous : !1,
211
- runWhen: i ? i.runWhen : null
212
- }), this.handlers.length - 1;
213
- };
214
- H.prototype.eject = function(e) {
215
- this.handlers[e] && (this.handlers[e] = null);
216
- };
217
- H.prototype.forEach = function(e) {
218
- Fr.forEach(this.handlers, function(i) {
219
- i !== null && e(i);
220
- });
221
- };
222
- var $r = H, jr = m, Ir = function(e, t) {
223
- jr.forEach(e, function(n, s) {
224
- s !== t && s.toUpperCase() === t.toUpperCase() && (e[t] = n, delete e[s]);
225
- });
226
- }, Xe = m;
227
- function N(r, e, t, i, n) {
228
- Error.call(this), this.message = r, this.name = "AxiosError", e && (this.code = e), t && (this.config = t), i && (this.request = i), n && (this.response = n);
229
- }
230
- Xe.inherits(N, Error, {
231
- toJSON: function() {
232
- return {
233
- message: this.message,
234
- name: this.name,
235
- description: this.description,
236
- number: this.number,
237
- fileName: this.fileName,
238
- lineNumber: this.lineNumber,
239
- columnNumber: this.columnNumber,
240
- stack: this.stack,
241
- config: this.config,
242
- code: this.code,
243
- status: this.response && this.response.status ? this.response.status : null
244
- };
245
- }
246
- });
247
- var Ke = N.prototype, Qe = {};
248
- [
249
- "ERR_BAD_OPTION_VALUE",
250
- "ERR_BAD_OPTION",
251
- "ECONNABORTED",
252
- "ETIMEDOUT",
253
- "ERR_NETWORK",
254
- "ERR_FR_TOO_MANY_REDIRECTS",
255
- "ERR_DEPRECATED",
256
- "ERR_BAD_RESPONSE",
257
- "ERR_BAD_REQUEST",
258
- "ERR_CANCELED"
259
- ].forEach(function(r) {
260
- Qe[r] = { value: r };
261
- });
262
- Object.defineProperties(N, Qe);
263
- Object.defineProperty(Ke, "isAxiosError", { value: !0 });
264
- N.from = function(r, e, t, i, n, s) {
265
- var a = Object.create(Ke);
266
- return Xe.toFlatObject(r, a, function(f) {
267
- return f !== Error.prototype;
268
- }), N.call(a, r.message, e, t, i, n), a.name = r.name, s && Object.assign(a, s), a;
269
- };
270
- var D = N, Ye = {
271
- silentJSONParsing: !0,
272
- forcedJSONParsing: !0,
273
- clarifyTimeoutError: !1
274
- }, R = m;
275
- function Hr(r, e) {
276
- e = e || new FormData();
277
- var t = [];
278
- function i(s) {
279
- return s === null ? "" : R.isDate(s) ? s.toISOString() : R.isArrayBuffer(s) || R.isTypedArray(s) ? typeof Blob == "function" ? new Blob([s]) : Buffer.from(s) : s;
280
- }
281
- function n(s, a) {
282
- if (R.isPlainObject(s) || R.isArray(s)) {
283
- if (t.indexOf(s) !== -1)
284
- throw Error("Circular reference detected in " + a);
285
- t.push(s), R.forEach(s, function(f, d) {
286
- if (!R.isUndefined(f)) {
287
- var c = a ? a + "." + d : d, h;
288
- if (f && !a && typeof f == "object") {
289
- if (R.endsWith(d, "{}"))
290
- f = JSON.stringify(f);
291
- else if (R.endsWith(d, "[]") && (h = R.toArray(f))) {
292
- h.forEach(function(u) {
293
- !R.isUndefined(u) && e.append(c, i(u));
294
- });
295
- return;
296
- }
297
- }
298
- n(f, c);
299
- }
300
- }), t.pop();
301
- } else
302
- e.append(a, i(s));
303
- }
304
- return n(r), e;
305
- }
306
- var Ze = Hr, X, Oe;
307
- function Mr() {
308
- if (Oe)
309
- return X;
310
- Oe = 1;
311
- var r = D;
312
- return X = function(t, i, n) {
313
- var s = n.config.validateStatus;
314
- !n.status || !s || s(n.status) ? t(n) : i(new r(
315
- "Request failed with status code " + n.status,
316
- [r.ERR_BAD_REQUEST, r.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4],
317
- n.config,
318
- n.request,
319
- n
320
- ));
321
- }, X;
322
- }
323
- var K, xe;
324
- function Wr() {
325
- if (xe)
326
- return K;
327
- xe = 1;
328
- var r = m;
329
- return K = r.isStandardBrowserEnv() ? function() {
330
- return {
331
- write: function(i, n, s, a, o, f) {
332
- var d = [];
333
- d.push(i + "=" + encodeURIComponent(n)), r.isNumber(s) && d.push("expires=" + new Date(s).toGMTString()), r.isString(a) && d.push("path=" + a), r.isString(o) && d.push("domain=" + o), f === !0 && d.push("secure"), document.cookie = d.join("; ");
334
- },
335
- read: function(i) {
336
- var n = document.cookie.match(new RegExp("(^|;\\s*)(" + i + ")=([^;]*)"));
337
- return n ? decodeURIComponent(n[3]) : null;
338
- },
339
- remove: function(i) {
340
- this.write(i, "", Date.now() - 864e5);
341
- }
342
- };
343
- }() : function() {
344
- return {
345
- write: function() {
346
- },
347
- read: function() {
348
- return null;
349
- },
350
- remove: function() {
351
- }
352
- };
353
- }(), K;
354
- }
355
- var zr = function(e) {
356
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
357
- }, Gr = function(e, t) {
358
- return t ? e.replace(/\/+$/, "") + "/" + t.replace(/^\/+/, "") : e;
359
- }, Jr = zr, Vr = Gr, er = function(e, t) {
360
- return e && !Jr(t) ? Vr(e, t) : t;
361
- }, Q, Ae;
362
- function Xr() {
363
- if (Ae)
364
- return Q;
365
- Ae = 1;
366
- var r = m, e = [
367
- "age",
368
- "authorization",
369
- "content-length",
370
- "content-type",
371
- "etag",
372
- "expires",
373
- "from",
374
- "host",
375
- "if-modified-since",
376
- "if-unmodified-since",
377
- "last-modified",
378
- "location",
379
- "max-forwards",
380
- "proxy-authorization",
381
- "referer",
382
- "retry-after",
383
- "user-agent"
384
- ];
385
- return Q = function(i) {
386
- var n = {}, s, a, o;
387
- return i && r.forEach(i.split(`
388
- `), function(d) {
389
- if (o = d.indexOf(":"), s = r.trim(d.substr(0, o)).toLowerCase(), a = r.trim(d.substr(o + 1)), s) {
390
- if (n[s] && e.indexOf(s) >= 0)
391
- return;
392
- s === "set-cookie" ? n[s] = (n[s] ? n[s] : []).concat([a]) : n[s] = n[s] ? n[s] + ", " + a : a;
393
- }
394
- }), n;
395
- }, Q;
396
- }
397
- var Y, Se;
398
- function Kr() {
399
- if (Se)
400
- return Y;
401
- Se = 1;
402
- var r = m;
403
- return Y = r.isStandardBrowserEnv() ? function() {
404
- var t = /(msie|trident)/i.test(navigator.userAgent), i = document.createElement("a"), n;
405
- function s(a) {
406
- var o = a;
407
- return t && (i.setAttribute("href", o), o = i.href), i.setAttribute("href", o), {
408
- href: i.href,
409
- protocol: i.protocol ? i.protocol.replace(/:$/, "") : "",
410
- host: i.host,
411
- search: i.search ? i.search.replace(/^\?/, "") : "",
412
- hash: i.hash ? i.hash.replace(/^#/, "") : "",
413
- hostname: i.hostname,
414
- port: i.port,
415
- pathname: i.pathname.charAt(0) === "/" ? i.pathname : "/" + i.pathname
416
- };
417
- }
418
- return n = s(window.location.href), function(o) {
419
- var f = r.isString(o) ? s(o) : o;
420
- return f.protocol === n.protocol && f.host === n.host;
421
- };
422
- }() : function() {
423
- return function() {
424
- return !0;
425
- };
426
- }(), Y;
427
- }
428
- var Z, Ce;
429
- function M() {
430
- if (Ce)
431
- return Z;
432
- Ce = 1;
433
- var r = D, e = m;
434
- function t(i) {
435
- r.call(this, i ?? "canceled", r.ERR_CANCELED), this.name = "CanceledError";
436
- }
437
- return e.inherits(t, r, {
438
- __CANCEL__: !0
439
- }), Z = t, Z;
440
- }
441
- var ee, Te;
442
- function Qr() {
443
- return Te || (Te = 1, ee = function(e) {
444
- var t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
445
- return t && t[1] || "";
446
- }), ee;
447
- }
448
- var re, Pe;
449
- function Ne() {
450
- if (Pe)
451
- return re;
452
- Pe = 1;
453
- var r = m, e = Mr(), t = Wr(), i = Ve, n = er, s = Xr(), a = Kr(), o = Ye, f = D, d = M(), c = Qr();
454
- return re = function(u) {
455
- return new Promise(function(or, A) {
456
- var U = u.data, q = u.headers, B = u.responseType, S;
457
- function be() {
458
- u.cancelToken && u.cancelToken.unsubscribe(S), u.signal && u.signal.removeEventListener("abort", S);
459
- }
460
- r.isFormData(U) && r.isStandardBrowserEnv() && delete q["Content-Type"];
461
- var l = new XMLHttpRequest();
462
- if (u.auth) {
463
- var ur = u.auth.username || "", fr = u.auth.password ? unescape(encodeURIComponent(u.auth.password)) : "";
464
- q.Authorization = "Basic " + btoa(ur + ":" + fr);
465
- }
466
- var G = n(u.baseURL, u.url);
467
- l.open(u.method.toUpperCase(), i(G, u.params, u.paramsSerializer), !0), l.timeout = u.timeout;
468
- function Re() {
469
- if (l) {
470
- var b = "getAllResponseHeaders" in l ? s(l.getAllResponseHeaders()) : null, C = !B || B === "text" || B === "json" ? l.responseText : l.response, g = {
471
- data: C,
472
- status: l.status,
473
- statusText: l.statusText,
474
- headers: b,
475
- config: u,
476
- request: l
477
- };
478
- e(function(V) {
479
- or(V), be();
480
- }, function(V) {
481
- A(V), be();
482
- }, g), l = null;
483
- }
484
- }
485
- if ("onloadend" in l ? l.onloadend = Re : l.onreadystatechange = function() {
486
- !l || l.readyState !== 4 || l.status === 0 && !(l.responseURL && l.responseURL.indexOf("file:") === 0) || setTimeout(Re);
487
- }, l.onabort = function() {
488
- l && (A(new f("Request aborted", f.ECONNABORTED, u, l)), l = null);
489
- }, l.onerror = function() {
490
- A(new f("Network Error", f.ERR_NETWORK, u, l, l)), l = null;
491
- }, l.ontimeout = function() {
492
- var C = u.timeout ? "timeout of " + u.timeout + "ms exceeded" : "timeout exceeded", g = u.transitional || o;
493
- u.timeoutErrorMessage && (C = u.timeoutErrorMessage), A(new f(
494
- C,
495
- g.clarifyTimeoutError ? f.ETIMEDOUT : f.ECONNABORTED,
496
- u,
497
- l
498
- )), l = null;
499
- }, r.isStandardBrowserEnv()) {
500
- var we = (u.withCredentials || a(G)) && u.xsrfCookieName ? t.read(u.xsrfCookieName) : void 0;
501
- we && (q[u.xsrfHeaderName] = we);
502
- }
503
- "setRequestHeader" in l && r.forEach(q, function(C, g) {
504
- typeof U > "u" && g.toLowerCase() === "content-type" ? delete q[g] : l.setRequestHeader(g, C);
505
- }), r.isUndefined(u.withCredentials) || (l.withCredentials = !!u.withCredentials), B && B !== "json" && (l.responseType = u.responseType), typeof u.onDownloadProgress == "function" && l.addEventListener("progress", u.onDownloadProgress), typeof u.onUploadProgress == "function" && l.upload && l.upload.addEventListener("progress", u.onUploadProgress), (u.cancelToken || u.signal) && (S = function(b) {
506
- l && (A(!b || b && b.type ? new d() : b), l.abort(), l = null);
507
- }, u.cancelToken && u.cancelToken.subscribe(S), u.signal && (u.signal.aborted ? S() : u.signal.addEventListener("abort", S))), U || (U = null);
508
- var J = c(G);
509
- if (J && ["http", "https", "file"].indexOf(J) === -1) {
510
- A(new f("Unsupported protocol " + J + ":", f.ERR_BAD_REQUEST, u));
511
- return;
512
- }
513
- l.send(U);
514
- });
515
- }, re;
516
- }
517
- var te, _e;
518
- function Yr() {
519
- return _e || (_e = 1, te = null), te;
520
- }
521
- var p = m, De = Ir, Ue = D, Zr = Ye, et = Ze, rt = {
522
- "Content-Type": "application/x-www-form-urlencoded"
523
- };
524
- function qe(r, e) {
525
- !p.isUndefined(r) && p.isUndefined(r["Content-Type"]) && (r["Content-Type"] = e);
526
- }
527
- function tt() {
528
- var r;
529
- return (typeof XMLHttpRequest < "u" || typeof process < "u" && Object.prototype.toString.call(process) === "[object process]") && (r = Ne()), r;
530
- }
531
- function nt(r, e, t) {
532
- if (p.isString(r))
533
- try {
534
- return (e || JSON.parse)(r), p.trim(r);
535
- } catch (i) {
536
- if (i.name !== "SyntaxError")
537
- throw i;
538
- }
539
- return (t || JSON.stringify)(r);
540
- }
541
- var W = {
542
- transitional: Zr,
543
- adapter: tt(),
544
- transformRequest: [function(e, t) {
545
- if (De(t, "Accept"), De(t, "Content-Type"), p.isFormData(e) || p.isArrayBuffer(e) || p.isBuffer(e) || p.isStream(e) || p.isFile(e) || p.isBlob(e))
546
- return e;
547
- if (p.isArrayBufferView(e))
548
- return e.buffer;
549
- if (p.isURLSearchParams(e))
550
- return qe(t, "application/x-www-form-urlencoded;charset=utf-8"), e.toString();
551
- var i = p.isObject(e), n = t && t["Content-Type"], s;
552
- if ((s = p.isFileList(e)) || i && n === "multipart/form-data") {
553
- var a = this.env && this.env.FormData;
554
- return et(s ? { "files[]": e } : e, a && new a());
555
- } else if (i || n === "application/json")
556
- return qe(t, "application/json"), nt(e);
557
- return e;
558
- }],
559
- transformResponse: [function(e) {
560
- var t = this.transitional || W.transitional, i = t && t.silentJSONParsing, n = t && t.forcedJSONParsing, s = !i && this.responseType === "json";
561
- if (s || n && p.isString(e) && e.length)
562
- try {
563
- return JSON.parse(e);
564
- } catch (a) {
565
- if (s)
566
- throw a.name === "SyntaxError" ? Ue.from(a, Ue.ERR_BAD_RESPONSE, this, null, this.response) : a;
567
- }
568
- return e;
569
- }],
570
- timeout: 0,
571
- xsrfCookieName: "XSRF-TOKEN",
572
- xsrfHeaderName: "X-XSRF-TOKEN",
573
- maxContentLength: -1,
574
- maxBodyLength: -1,
575
- env: {
576
- FormData: Yr()
577
- },
578
- validateStatus: function(e) {
579
- return e >= 200 && e < 300;
580
- },
581
- headers: {
582
- common: {
583
- Accept: "application/json, text/plain, */*"
584
- }
585
- }
586
- };
587
- p.forEach(["delete", "get", "head"], function(e) {
588
- W.headers[e] = {};
589
- });
590
- p.forEach(["post", "put", "patch"], function(e) {
591
- W.headers[e] = p.merge(rt);
592
- });
593
- var Ee = W, it = m, st = Ee, at = function(e, t, i) {
594
- var n = this || st;
595
- return it.forEach(i, function(a) {
596
- e = a.call(n, e, t);
597
- }), e;
598
- }, ne, Be;
599
- function rr() {
600
- return Be || (Be = 1, ne = function(e) {
601
- return !!(e && e.__CANCEL__);
602
- }), ne;
603
- }
604
- var ke = m, ie = at, ot = rr(), ut = Ee, ft = M();
605
- function se(r) {
606
- if (r.cancelToken && r.cancelToken.throwIfRequested(), r.signal && r.signal.aborted)
607
- throw new ft();
608
- }
609
- var lt = function(e) {
610
- se(e), e.headers = e.headers || {}, e.data = ie.call(
611
- e,
612
- e.data,
613
- e.headers,
614
- e.transformRequest
615
- ), e.headers = ke.merge(
616
- e.headers.common || {},
617
- e.headers[e.method] || {},
618
- e.headers
619
- ), ke.forEach(
620
- ["delete", "get", "head", "post", "put", "patch", "common"],
621
- function(n) {
622
- delete e.headers[n];
623
- }
624
- );
625
- var t = e.adapter || ut.adapter;
626
- return t(e).then(function(n) {
627
- return se(e), n.data = ie.call(
628
- e,
629
- n.data,
630
- n.headers,
631
- e.transformResponse
632
- ), n;
633
- }, function(n) {
634
- return ot(n) || (se(e), n && n.response && (n.response.data = ie.call(
635
- e,
636
- n.response.data,
637
- n.response.headers,
638
- e.transformResponse
639
- ))), Promise.reject(n);
640
- });
641
- }, E = m, tr = function(e, t) {
642
- t = t || {};
643
- var i = {};
644
- function n(c, h) {
645
- return E.isPlainObject(c) && E.isPlainObject(h) ? E.merge(c, h) : E.isPlainObject(h) ? E.merge({}, h) : E.isArray(h) ? h.slice() : h;
646
- }
647
- function s(c) {
648
- if (E.isUndefined(t[c])) {
649
- if (!E.isUndefined(e[c]))
650
- return n(void 0, e[c]);
651
- } else
652
- return n(e[c], t[c]);
653
- }
654
- function a(c) {
655
- if (!E.isUndefined(t[c]))
656
- return n(void 0, t[c]);
657
- }
658
- function o(c) {
659
- if (E.isUndefined(t[c])) {
660
- if (!E.isUndefined(e[c]))
661
- return n(void 0, e[c]);
662
- } else
663
- return n(void 0, t[c]);
664
- }
665
- function f(c) {
666
- if (c in t)
667
- return n(e[c], t[c]);
668
- if (c in e)
669
- return n(void 0, e[c]);
670
- }
671
- var d = {
672
- url: a,
673
- method: a,
674
- data: a,
675
- baseURL: o,
676
- transformRequest: o,
677
- transformResponse: o,
678
- paramsSerializer: o,
679
- timeout: o,
680
- timeoutMessage: o,
681
- withCredentials: o,
682
- adapter: o,
683
- responseType: o,
684
- xsrfCookieName: o,
685
- xsrfHeaderName: o,
686
- onUploadProgress: o,
687
- onDownloadProgress: o,
688
- decompress: o,
689
- maxContentLength: o,
690
- maxBodyLength: o,
691
- beforeRedirect: o,
692
- transport: o,
693
- httpAgent: o,
694
- httpsAgent: o,
695
- cancelToken: o,
696
- socketPath: o,
697
- responseEncoding: o,
698
- validateStatus: f
699
- };
700
- return E.forEach(Object.keys(e).concat(Object.keys(t)), function(h) {
701
- var u = d[h] || s, y = u(h);
702
- E.isUndefined(y) && u !== f || (i[h] = y);
703
- }), i;
704
- }, ae, Le;
705
- function nr() {
706
- return Le || (Le = 1, ae = {
707
- version: "0.27.2"
708
- }), ae;
709
- }
710
- var ct = nr().version, w = D, ye = {};
711
- ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(r, e) {
712
- ye[r] = function(i) {
713
- return typeof i === r || "a" + (e < 1 ? "n " : " ") + r;
714
- };
715
- });
716
- var Fe = {};
717
- ye.transitional = function(e, t, i) {
718
- function n(s, a) {
719
- return "[Axios v" + ct + "] Transitional option '" + s + "'" + a + (i ? ". " + i : "");
720
- }
721
- return function(s, a, o) {
722
- if (e === !1)
723
- throw new w(
724
- n(a, " has been removed" + (t ? " in " + t : "")),
725
- w.ERR_DEPRECATED
726
- );
727
- return t && !Fe[a] && (Fe[a] = !0, console.warn(
728
- n(
729
- a,
730
- " has been deprecated since v" + t + " and will be removed in the near future"
731
- )
732
- )), e ? e(s, a, o) : !0;
733
- };
734
- };
735
- function dt(r, e, t) {
736
- if (typeof r != "object")
737
- throw new w("options must be an object", w.ERR_BAD_OPTION_VALUE);
738
- for (var i = Object.keys(r), n = i.length; n-- > 0; ) {
739
- var s = i[n], a = e[s];
740
- if (a) {
741
- var o = r[s], f = o === void 0 || a(o, s, r);
742
- if (f !== !0)
743
- throw new w("option " + s + " must be " + f, w.ERR_BAD_OPTION_VALUE);
744
- continue;
745
- }
746
- if (t !== !0)
747
- throw new w("Unknown option " + s, w.ERR_BAD_OPTION);
748
- }
749
- }
750
- var ht = {
751
- assertOptions: dt,
752
- validators: ye
753
- }, ir = m, pt = Ve, $e = $r, je = lt, z = tr, mt = er, sr = ht, P = sr.validators;
754
- function _(r) {
755
- this.defaults = r, this.interceptors = {
756
- request: new $e(),
757
- response: new $e()
758
- };
759
- }
760
- _.prototype.request = function(e, t) {
761
- typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = z(this.defaults, t), t.method ? t.method = t.method.toLowerCase() : this.defaults.method ? t.method = this.defaults.method.toLowerCase() : t.method = "get";
762
- var i = t.transitional;
763
- i !== void 0 && sr.assertOptions(i, {
764
- silentJSONParsing: P.transitional(P.boolean),
765
- forcedJSONParsing: P.transitional(P.boolean),
766
- clarifyTimeoutError: P.transitional(P.boolean)
767
- }, !1);
768
- var n = [], s = !0;
769
- this.interceptors.request.forEach(function(y) {
770
- typeof y.runWhen == "function" && y.runWhen(t) === !1 || (s = s && y.synchronous, n.unshift(y.fulfilled, y.rejected));
771
- });
772
- var a = [];
773
- this.interceptors.response.forEach(function(y) {
774
- a.push(y.fulfilled, y.rejected);
775
- });
776
- var o;
777
- if (!s) {
778
- var f = [je, void 0];
779
- for (Array.prototype.unshift.apply(f, n), f = f.concat(a), o = Promise.resolve(t); f.length; )
780
- o = o.then(f.shift(), f.shift());
781
- return o;
782
- }
783
- for (var d = t; n.length; ) {
784
- var c = n.shift(), h = n.shift();
785
- try {
786
- d = c(d);
787
- } catch (u) {
788
- h(u);
789
- break;
790
- }
791
- }
792
- try {
793
- o = je(d);
794
- } catch (u) {
795
- return Promise.reject(u);
796
- }
797
- for (; a.length; )
798
- o = o.then(a.shift(), a.shift());
799
- return o;
800
- };
801
- _.prototype.getUri = function(e) {
802
- e = z(this.defaults, e);
803
- var t = mt(e.baseURL, e.url);
804
- return pt(t, e.params, e.paramsSerializer);
805
- };
806
- ir.forEach(["delete", "get", "head", "options"], function(e) {
807
- _.prototype[e] = function(t, i) {
808
- return this.request(z(i || {}, {
809
- method: e,
810
- url: t,
811
- data: (i || {}).data
812
- }));
813
- };
814
- });
815
- ir.forEach(["post", "put", "patch"], function(e) {
816
- function t(i) {
817
- return function(s, a, o) {
818
- return this.request(z(o || {}, {
819
- method: e,
820
- headers: i ? {
821
- "Content-Type": "multipart/form-data"
822
- } : {},
823
- url: s,
824
- data: a
825
- }));
826
- };
827
- }
828
- _.prototype[e] = t(), _.prototype[e + "Form"] = t(!0);
829
- });
830
- var vt = _, oe, Ie;
831
- function Et() {
832
- if (Ie)
833
- return oe;
834
- Ie = 1;
835
- var r = M();
836
- function e(t) {
837
- if (typeof t != "function")
838
- throw new TypeError("executor must be a function.");
839
- var i;
840
- this.promise = new Promise(function(a) {
841
- i = a;
842
- });
843
- var n = this;
844
- this.promise.then(function(s) {
845
- if (n._listeners) {
846
- var a, o = n._listeners.length;
847
- for (a = 0; a < o; a++)
848
- n._listeners[a](s);
849
- n._listeners = null;
850
- }
851
- }), this.promise.then = function(s) {
852
- var a, o = new Promise(function(f) {
853
- n.subscribe(f), a = f;
854
- }).then(s);
855
- return o.cancel = function() {
856
- n.unsubscribe(a);
857
- }, o;
858
- }, t(function(a) {
859
- n.reason || (n.reason = new r(a), i(n.reason));
860
- });
861
- }
862
- return e.prototype.throwIfRequested = function() {
863
- if (this.reason)
864
- throw this.reason;
865
- }, e.prototype.subscribe = function(i) {
866
- if (this.reason) {
867
- i(this.reason);
868
- return;
869
- }
870
- this._listeners ? this._listeners.push(i) : this._listeners = [i];
871
- }, e.prototype.unsubscribe = function(i) {
872
- if (this._listeners) {
873
- var n = this._listeners.indexOf(i);
874
- n !== -1 && this._listeners.splice(n, 1);
875
- }
876
- }, e.source = function() {
877
- var i, n = new e(function(a) {
878
- i = a;
879
- });
880
- return {
881
- token: n,
882
- cancel: i
883
- };
884
- }, oe = e, oe;
885
- }
886
- var ue, He;
887
- function yt() {
888
- return He || (He = 1, ue = function(e) {
889
- return function(i) {
890
- return e.apply(null, i);
891
- };
892
- }), ue;
893
- }
894
- var fe, Me;
895
- function bt() {
896
- if (Me)
897
- return fe;
898
- Me = 1;
899
- var r = m;
900
- return fe = function(t) {
901
- return r.isObject(t) && t.isAxiosError === !0;
902
- }, fe;
903
- }
904
- var We = m, Rt = ze, $ = vt, wt = tr, gt = Ee;
905
- function ar(r) {
906
- var e = new $(r), t = Rt($.prototype.request, e);
907
- return We.extend(t, $.prototype, e), We.extend(t, e), t.create = function(n) {
908
- return ar(wt(r, n));
909
- }, t;
910
- }
911
- var v = ar(gt);
912
- v.Axios = $;
913
- v.CanceledError = M();
914
- v.CancelToken = Et();
915
- v.isCancel = rr();
916
- v.VERSION = nr().version;
917
- v.toFormData = Ze;
918
- v.AxiosError = D;
919
- v.Cancel = v.CanceledError;
920
- v.all = function(e) {
921
- return Promise.all(e);
922
- };
923
- v.spread = yt();
924
- v.isAxiosError = bt();
925
- vr.exports = v;
926
- j.default = v;
927
- (function(r) {
928
- r.exports = j;
929
- })(mr);
930
- const Ot = /* @__PURE__ */ pr(le);
931
- class xt {
1
+ var g = Object.defineProperty;
2
+ var c = (t, e, r) => e in t ? g(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var i = (t, e, r) => (c(t, typeof e != "symbol" ? e + "" : e, r), r);
4
+ import { a as f } from "../axios-aa12e368.mjs";
5
+ import { ErrorCode as n } from "@ancon/wildcat-types";
6
+ import h from "../error/createCodedError.mjs";
7
+ import p from "../api/isNoContentResponse.mjs";
8
+ class m {
932
9
  constructor(e) {
933
- O(this, "busyWorkers", /* @__PURE__ */ new Set());
934
- O(this, "enabledGroups", /* @__PURE__ */ new Set());
935
- O(this, "groups", /* @__PURE__ */ new Map());
936
- O(this, "workerByIdMap", /* @__PURE__ */ new Map());
937
- O(this, "timer", null);
938
- O(this, "config", {
10
+ i(this, "busyWorkers", /* @__PURE__ */ new Set());
11
+ i(this, "enabledGroups", /* @__PURE__ */ new Set());
12
+ i(this, "groups", /* @__PURE__ */ new Map());
13
+ i(this, "workerByIdMap", /* @__PURE__ */ new Map());
14
+ i(this, "timer", null);
15
+ i(this, "config", {
939
16
  maxGroupsSize: 50,
940
17
  maxWorkersSize: 20,
941
18
  getIsNetworkOnline() {
@@ -958,9 +35,9 @@ class xt {
958
35
  }
959
36
  startTimer() {
960
37
  if (this.timer != null)
961
- throw L(
38
+ throw h(
962
39
  new Error("Timer already started"),
963
- k.GenericUnexpectedHangfireError
40
+ n.GenericUnexpectedHangfireError
964
41
  );
965
42
  this.config.debug("*start timer*"), this.timer = setInterval(() => {
966
43
  this.config.debug("*tick*", {
@@ -968,71 +45,71 @@ class xt {
968
45
  enabledGroups: this.enabledGroups.size,
969
46
  groups: this.groups
970
47
  }), this.enabledGroups.forEach((e) => {
971
- const t = this.groups.get(e);
972
- t && t.forEach((i) => this.executeWorkerRequest(i));
48
+ const r = this.groups.get(e);
49
+ r && r.forEach((s) => this.executeWorkerRequest(s));
973
50
  }), this.groups.size < 1 && this.stopTimer();
974
51
  }, 5e3);
975
52
  }
976
53
  async executeWorkerRequest(e) {
977
- const t = this.config.getIsNetworkOnline();
978
- !this.busyWorkers.has(e.workerId) && t && (this.busyWorkers.add(e.workerId), Ot({
54
+ const r = this.config.getIsNetworkOnline();
55
+ !this.busyWorkers.has(e.workerId) && r && (this.busyWorkers.add(e.workerId), f({
979
56
  url: e.url,
980
57
  method: "get",
981
58
  headers: await this.config.getRequestHeaders()
982
- }).then((i) => {
983
- i && !hr(i) ? (e.resolve(i), this.deleteWorker(e.groupId, e.workerId)) : this.busyWorkers.delete(e.workerId);
984
- }).catch((i) => {
985
- e.reject(i), this.deleteWorker(e.groupId, e.workerId);
59
+ }).then((s) => {
60
+ s && !p(s) ? (e.resolve(s), this.deleteWorker(e.groupId, e.workerId)) : this.busyWorkers.delete(e.workerId);
61
+ }).catch((s) => {
62
+ e.reject(s), this.deleteWorker(e.groupId, e.workerId);
986
63
  }));
987
64
  }
988
- deleteWorker(e, t) {
989
- const i = this.groups.get(e);
990
- i && (this.config.debug("*delete worker*", i.size, i), i.delete(t), this.workerByIdMap.delete(t), this.busyWorkers.delete(t), i.size < 1 && (this.groups.delete(e), this.enabledGroups.delete(e), this.enabledGroups.size < 1 && this.stopTimer()));
65
+ deleteWorker(e, r) {
66
+ const s = this.groups.get(e);
67
+ s && (this.config.debug("*delete worker*", s.size, s), s.delete(r), this.workerByIdMap.delete(r), this.busyWorkers.delete(r), s.size < 1 && (this.groups.delete(e), this.enabledGroups.delete(e), this.enabledGroups.size < 1 && this.stopTimer()));
991
68
  }
992
69
  createWorker(e, {
993
- workerId: t,
994
- url: i
70
+ workerId: r,
71
+ url: s
995
72
  }) {
996
73
  if (!this.groups.has(e)) {
997
74
  if (this.groups.size >= this.config.maxGroupsSize) {
998
- const s = L(
75
+ const a = h(
999
76
  new Error("Max number of Hangfire groups exceeded"),
1000
- k.GenericUnexpectedHangfireError,
77
+ n.GenericUnexpectedHangfireError,
1001
78
  { count: this.groups.size }
1002
79
  );
1003
- throw this.destroy(), s;
80
+ throw this.destroy(), a;
1004
81
  }
1005
82
  this.groups.set(e, /* @__PURE__ */ new Map());
1006
83
  }
1007
- const n = this.groups.get(e);
1008
- return new Promise((s, a) => {
1009
- if (n.has(t))
1010
- throw L(
84
+ const o = this.groups.get(e);
85
+ return new Promise((a, u) => {
86
+ if (o.has(r))
87
+ throw h(
1011
88
  new Error("Duplicate Hangfire worker ID"),
1012
- k.GenericUnexpectedHangfireError
89
+ n.GenericUnexpectedHangfireError
1013
90
  );
1014
- if (n.size >= this.config.maxWorkersSize) {
1015
- const f = L(
91
+ if (o.size >= this.config.maxWorkersSize) {
92
+ const d = h(
1016
93
  new Error("Max number of Hangfire workers in group exceeded"),
1017
- k.GenericUnexpectedHangfireError,
1018
- { groupId: e, count: n.size }
94
+ n.GenericUnexpectedHangfireError,
95
+ { groupId: e, count: o.size }
1019
96
  );
1020
- throw a(f), this.destroy(), f;
97
+ throw u(d), this.destroy(), d;
1021
98
  }
1022
- const o = {
1023
- workerId: t,
99
+ const l = {
100
+ workerId: r,
1024
101
  groupId: e,
1025
- url: i,
1026
- resolve: s,
1027
- reject: a
102
+ url: s,
103
+ resolve: a,
104
+ reject: u
1028
105
  };
1029
- n.set(t, o), this.workerByIdMap.set(t, o), this.enabledGroups.has(e) || this.enabledGroups.add(e), this.timer == null && this.enabledGroups.size > 0 && this.startTimer();
106
+ o.set(r, l), this.workerByIdMap.set(r, l), this.enabledGroups.has(e) || this.enabledGroups.add(e), this.timer == null && this.enabledGroups.size > 0 && this.startTimer();
1030
107
  });
1031
108
  }
1032
109
  triggerWorker(e) {
1033
110
  this.config.debug("*triggerWorker*");
1034
- const t = this.workerByIdMap.get(e);
1035
- t && this.executeWorkerRequest(t);
111
+ const r = this.workerByIdMap.get(e);
112
+ r && this.executeWorkerRequest(r);
1036
113
  }
1037
114
  enableWorkers(e) {
1038
115
  this.config.debug("*enable*", e), this.enabledGroups.add(e), this.groups.has(e) && this.timer == null && this.startTimer();
@@ -1044,10 +121,10 @@ class xt {
1044
121
  this.config.debug("*destroy*"), this.groups.clear(), this.stopTimer();
1045
122
  }
1046
123
  }
1047
- function Pt(r) {
1048
- return new xt(r);
124
+ function G(t) {
125
+ return new m(t);
1049
126
  }
1050
127
  export {
1051
- xt as HangfirePoller,
1052
- Pt as default
128
+ m as HangfirePoller,
129
+ G as default
1053
130
  };