@ancon/wildcat-utils 1.34.1 → 1.35.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.
- package/error/index.d.ts +5 -3
- package/error/index.js +1 -1
- package/error/index.mjs +6 -4
- package/error/isSerializedAPIError.d.ts +3 -0
- package/error/isSerializedAPIError.js +1 -0
- package/error/isSerializedAPIError.mjs +10 -0
- package/error/serializeError.d.ts +2 -18
- package/error/serializeError.js +1 -1
- package/error/serializeError.mjs +31 -11
- package/error/types.d.ts +26 -0
- package/error/types.js +1 -0
- package/error/types.mjs +1 -0
- package/hangfire/createHangfirePoller.d.ts +2 -1
- package/hangfire/createHangfirePoller.js +1 -1
- package/hangfire/createHangfirePoller.mjs +20 -15
- package/hangfire/createMakeHangfireRequest.d.ts +2 -2
- package/hangfire/createMakeHangfireRequest.js +1 -1
- package/hangfire/createMakeHangfireRequest.mjs +13 -12
- package/index.js +1 -1
- package/index.mjs +34 -32
- package/package.json +11 -1
package/error/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import isNetworkError from './isNetworkError';
|
|
|
4
4
|
import isLockedError from './isLockedError';
|
|
5
5
|
import isNotFoundError from './isNotFoundError';
|
|
6
6
|
import isAPIError from './isAPIError';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import isSerializedAPIError from './isSerializedAPIError';
|
|
8
|
+
import serializeError from './serializeError';
|
|
9
|
+
import { SerializedAPIError, SerializedAxiosError, SerializedCodedError, SerializedGenericError } from './types';
|
|
10
|
+
export type { CodedError, SerializedAPIError, SerializedAxiosError, SerializedCodedError, SerializedGenericError, };
|
|
11
|
+
export { createCodedError, isCodedError, isNetworkError, isLockedError, isNotFoundError, serializeError, isAPIError, isSerializedAPIError, };
|
package/error/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./createCodedError.js"),e=require("./isCodedError.js"),o=require("./isNetworkError.js"),i=require("./isLockedError.js"),s=require("./isNotFoundError.js"),t=require("./isAPIError.js"),d=require("./serializeError.js");require("axios");require("@ancon/wildcat-types");exports.createCodedError=r;exports.isCodedError=e;exports.isNetworkError=o;exports.isLockedError=i;exports.isNotFoundError=s;exports.isAPIError=t;exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./createCodedError.js"),e=require("./isCodedError.js"),o=require("./isNetworkError.js"),i=require("./isLockedError.js"),s=require("./isNotFoundError.js"),t=require("./isAPIError.js"),d=require("./isSerializedAPIError.js"),E=require("./serializeError.js");require("axios");require("@ancon/wildcat-types");exports.createCodedError=r;exports.isCodedError=e;exports.isNetworkError=o;exports.isLockedError=i;exports.isNotFoundError=s;exports.isAPIError=t;exports.isSerializedAPIError=d;exports.serializeError=E;
|
package/error/index.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { default as a } from "./createCodedError.mjs";
|
|
2
2
|
import { default as d } from "./isCodedError.mjs";
|
|
3
3
|
import { default as i } from "./isNetworkError.mjs";
|
|
4
|
-
import { default as
|
|
4
|
+
import { default as m } from "./isLockedError.mjs";
|
|
5
5
|
import { default as u } from "./isNotFoundError.mjs";
|
|
6
6
|
import { default as E } from "./isAPIError.mjs";
|
|
7
|
-
import { default as k } from "./
|
|
7
|
+
import { default as k } from "./isSerializedAPIError.mjs";
|
|
8
|
+
import { default as A } from "./serializeError.mjs";
|
|
8
9
|
import "axios";
|
|
9
10
|
import "@ancon/wildcat-types";
|
|
10
11
|
export {
|
|
11
12
|
a as createCodedError,
|
|
12
13
|
E as isAPIError,
|
|
13
14
|
d as isCodedError,
|
|
14
|
-
|
|
15
|
+
m as isLockedError,
|
|
15
16
|
i as isNetworkError,
|
|
16
17
|
u as isNotFoundError,
|
|
17
|
-
k as
|
|
18
|
+
k as isSerializedAPIError,
|
|
19
|
+
A as serializeError
|
|
18
20
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("axios"),i=require("@ancon/wildcat-types");function a(o){var e,s;const r=o;return t.isAxiosError(r)||!((s=(e=r==null?void 0:r.response)==null?void 0:e.data)!=null&&s.errorCode)?!1:Object.values(i.ErrorCode).includes(r.response.data.errorCode)}module.exports=a;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isAxiosError as t } from "axios";
|
|
2
|
+
import { ErrorCode as a } from "@ancon/wildcat-types";
|
|
3
|
+
function d(s) {
|
|
4
|
+
var e, o;
|
|
5
|
+
const r = s;
|
|
6
|
+
return t(r) || !((o = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) != null && o.errorCode) ? !1 : Object.values(a).includes(r.response.data.errorCode);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
d as default
|
|
10
|
+
};
|
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
import { AxiosError } from 'axios';
|
|
2
|
-
import { ErrorCode } from '@ancon/wildcat-types';
|
|
3
2
|
import { CodedError } from './createCodedError';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
code?: string;
|
|
7
|
-
response?: {
|
|
8
|
-
status?: number;
|
|
9
|
-
statusText?: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
declare type SerializedCodedError = {
|
|
13
|
-
code: ErrorCode;
|
|
14
|
-
message: string;
|
|
15
|
-
additionalData?: Record<string, unknown>;
|
|
16
|
-
};
|
|
17
|
-
declare type SerializedGenericError = {
|
|
18
|
-
message: string;
|
|
19
|
-
};
|
|
3
|
+
import { SerializedAPIError, SerializedAxiosError, SerializedCodedError, SerializedGenericError } from './types';
|
|
4
|
+
declare function serializeError(error: AxiosError): SerializedAPIError;
|
|
20
5
|
declare function serializeError(error: AxiosError): SerializedAxiosError;
|
|
21
6
|
declare function serializeError(error: CodedError): SerializedCodedError;
|
|
22
7
|
declare function serializeError(error: Error | {
|
|
23
8
|
message: string;
|
|
24
9
|
}): SerializedGenericError;
|
|
25
|
-
export type { SerializedAxiosError, SerializedCodedError, SerializedGenericError, };
|
|
26
10
|
export default serializeError;
|
package/error/serializeError.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const a=require("axios"),i=require("./isCodedError.js"),n=require("./isAPIError.js");require("@ancon/wildcat-types");function o(s){var e,t;return{message:s.message,code:s.code,response:{status:(e=s.response)==null?void 0:e.status,statusText:(t=s.response)==null?void 0:t.statusText,data:{errorCode:s.response.data.errorCode,message:s.response.data.message,additionalData:s.response.data.additionalData}}}}function u(s){var e,t;return{message:s.message,code:s.code,response:{status:(e=s.response)==null?void 0:e.status,statusText:(t=s.response)==null?void 0:t.statusText}}}function d(s){return{message:s.message,code:s.code,additionalData:s.additionalData}}function c(s){return{message:s.message}}function r(s){var e;if(n(s))return o(s);if(a.isAxiosError(s))return u(s);if(i(s)&&s.message)return d(s);if(s instanceof Error||(e=s==null?void 0:s.message)!=null&&e.length)return c(s);throw new Error("Failed to serialize error")}module.exports=r;
|
package/error/serializeError.mjs
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import { isAxiosError as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { isAxiosError as a } from "axios";
|
|
2
|
+
import i from "./isCodedError.mjs";
|
|
3
|
+
import n from "./isAPIError.mjs";
|
|
4
|
+
import "@ancon/wildcat-types";
|
|
5
|
+
function o(s) {
|
|
6
|
+
var e, t;
|
|
7
|
+
return {
|
|
8
|
+
message: s.message,
|
|
9
|
+
code: s.code,
|
|
10
|
+
response: {
|
|
11
|
+
status: (e = s.response) == null ? void 0 : e.status,
|
|
12
|
+
statusText: (t = s.response) == null ? void 0 : t.statusText,
|
|
13
|
+
data: {
|
|
14
|
+
errorCode: s.response.data.errorCode,
|
|
15
|
+
message: s.response.data.message,
|
|
16
|
+
additionalData: s.response.data.additionalData
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function d(s) {
|
|
4
22
|
var e, t;
|
|
5
23
|
return {
|
|
6
24
|
message: s.message,
|
|
@@ -11,28 +29,30 @@ function n(s) {
|
|
|
11
29
|
}
|
|
12
30
|
};
|
|
13
31
|
}
|
|
14
|
-
function
|
|
32
|
+
function u(s) {
|
|
15
33
|
return {
|
|
16
34
|
message: s.message,
|
|
17
35
|
code: s.code,
|
|
18
36
|
additionalData: s.additionalData
|
|
19
37
|
};
|
|
20
38
|
}
|
|
21
|
-
function
|
|
39
|
+
function m(s) {
|
|
22
40
|
return {
|
|
23
41
|
message: s.message
|
|
24
42
|
};
|
|
25
43
|
}
|
|
26
|
-
function
|
|
44
|
+
function l(s) {
|
|
27
45
|
var e;
|
|
28
|
-
if (
|
|
29
|
-
return n(s);
|
|
30
|
-
if (a(s) && s.message)
|
|
46
|
+
if (n(s))
|
|
31
47
|
return o(s);
|
|
32
|
-
if (
|
|
48
|
+
if (a(s))
|
|
49
|
+
return d(s);
|
|
50
|
+
if (i(s) && s.message)
|
|
33
51
|
return u(s);
|
|
52
|
+
if (s instanceof Error || (e = s == null ? void 0 : s.message) != null && e.length)
|
|
53
|
+
return m(s);
|
|
34
54
|
throw new Error("Failed to serialize error");
|
|
35
55
|
}
|
|
36
56
|
export {
|
|
37
|
-
|
|
57
|
+
l as default
|
|
38
58
|
};
|
package/error/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { APIGenericError, ErrorCode } from '@ancon/wildcat-types';
|
|
2
|
+
export declare type SerializedAxiosError = {
|
|
3
|
+
message: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
response?: {
|
|
6
|
+
status?: number;
|
|
7
|
+
statusText?: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare type SerializedAPIError<T = unknown> = {
|
|
11
|
+
message: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
response: {
|
|
14
|
+
status?: number;
|
|
15
|
+
statusText?: string;
|
|
16
|
+
data: APIGenericError<T>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare type SerializedCodedError = {
|
|
20
|
+
code: ErrorCode;
|
|
21
|
+
message: string;
|
|
22
|
+
additionalData?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export declare type SerializedGenericError = {
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
package/error/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/error/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -30,9 +30,10 @@ declare class HangfirePoller {
|
|
|
30
30
|
private startTimer;
|
|
31
31
|
private executeWorkerRequest;
|
|
32
32
|
private deleteWorker;
|
|
33
|
-
createWorker(groupId: string, { workerId, url, }: {
|
|
33
|
+
createWorker(groupId: string, { workerId, url, headers, }: {
|
|
34
34
|
workerId: string;
|
|
35
35
|
url: string;
|
|
36
|
+
headers: APIHeaders;
|
|
36
37
|
}): Promise<unknown>;
|
|
37
38
|
triggerWorker(workerId: string): void;
|
|
38
39
|
/** May be called either before or after `createWorker()` */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var p=(t,e,r)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var i=(t,e,r)=>(p(t,typeof e!="symbol"?e+"":e,r),r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("axios"),n=require("@ancon/wildcat-types"),a=require("../error/createCodedError.js"),m=require("../api/isNoContentResponse.js");class c{constructor(e){i(this,"busyWorkers",new Set);i(this,"enabledGroups",new Set);i(this,"groups",new Map);i(this,"workerByIdMap",new Map);i(this,"timer",null);i(this,"config",{maxGroupsSize:50,maxWorkersSize:20,getIsNetworkOnline(){return!0},async getRequestHeaders(){return{}},debug(...e){console.log(...e)}});this.config={...this.config,...e??null}}stopTimer(){this.timer!=null&&(this.config.debug("*stop timer*"),clearInterval(this.timer),this.timer=null)}startTimer(){if(this.timer!=null)throw a(new Error("Timer already started"),n.ErrorCode.GenericUnexpectedHangfireError);this.config.debug("*start timer*"),this.timer=setInterval(()=>{this.config.debug("*tick*",{busyWorkers:this.busyWorkers.size,enabledGroups:this.enabledGroups.size,groups:this.groups}),this.enabledGroups.forEach(e=>{const r=this.groups.get(e);r&&r.forEach(s=>this.executeWorkerRequest(s))}),this.groups.size<1&&this.stopTimer()},5e3)}async executeWorkerRequest(e){const r=this.config.getIsNetworkOnline();!this.busyWorkers.has(e.workerId)&&r&&(this.busyWorkers.add(e.workerId),b({url:e.url,method:"get",headers:{...await this.config.getRequestHeaders(),...e.headers}}).then(s=>{s&&!m(s)?(e.resolve(s),this.deleteWorker(e.groupId,e.workerId)):this.busyWorkers.delete(e.workerId)}).catch(s=>{e.reject(s),this.deleteWorker(e.groupId,e.workerId)}))}deleteWorker(e,r){const s=this.groups.get(e);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()))}createWorker(e,{workerId:r,url:s,headers:g}){if(!this.groups.has(e)){if(this.groups.size>=this.config.maxGroupsSize){const u=a(new Error("Max number of Hangfire groups exceeded"),n.ErrorCode.GenericUnexpectedHangfireError,{count:this.groups.size});throw this.destroy(),u}this.groups.set(e,new Map)}const o=this.groups.get(e);return new Promise((u,h)=>{if(o.has(r))throw a(new Error("Duplicate Hangfire worker ID"),n.ErrorCode.GenericUnexpectedHangfireError);if(o.size>=this.config.maxWorkersSize){const d=a(new Error("Max number of Hangfire workers in group exceeded"),n.ErrorCode.GenericUnexpectedHangfireError,{groupId:e,count:o.size});throw h(d),this.destroy(),d}const l={workerId:r,groupId:e,url:s,resolve:u,reject:h,headers:g};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()})}triggerWorker(e){this.config.debug("*triggerWorker*");const r=this.workerByIdMap.get(e);r&&this.executeWorkerRequest(r)}enableWorkers(e){this.config.debug("*enable*",e),this.enabledGroups.add(e),this.groups.has(e)&&this.timer==null&&this.startTimer()}disableWorkers(e){this.config.debug("*disable*",e),this.enabledGroups.delete(e),this.enabledGroups.size<1&&this.stopTimer()}destroy(){this.config.debug("*destroy*"),this.groups.clear(),this.stopTimer()}}function k(t){return new c(t)}exports.HangfirePoller=c;exports.default=k;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e, r) => (
|
|
4
|
-
import
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var f = (t, e, r) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var i = (t, e, r) => (f(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
+
import p from "axios";
|
|
5
5
|
import { ErrorCode as n } from "@ancon/wildcat-types";
|
|
6
6
|
import h from "../error/createCodedError.mjs";
|
|
7
|
-
import
|
|
8
|
-
class
|
|
7
|
+
import m from "../api/isNoContentResponse.mjs";
|
|
8
|
+
class b {
|
|
9
9
|
constructor(e) {
|
|
10
10
|
/** Workers currently executing a request */
|
|
11
11
|
i(this, "busyWorkers", /* @__PURE__ */ new Set());
|
|
@@ -56,12 +56,15 @@ class m {
|
|
|
56
56
|
}
|
|
57
57
|
async executeWorkerRequest(e) {
|
|
58
58
|
const r = this.config.getIsNetworkOnline();
|
|
59
|
-
!this.busyWorkers.has(e.workerId) && r && (this.busyWorkers.add(e.workerId),
|
|
59
|
+
!this.busyWorkers.has(e.workerId) && r && (this.busyWorkers.add(e.workerId), p({
|
|
60
60
|
url: e.url,
|
|
61
61
|
method: "get",
|
|
62
|
-
headers:
|
|
62
|
+
headers: {
|
|
63
|
+
...await this.config.getRequestHeaders(),
|
|
64
|
+
...e.headers
|
|
65
|
+
}
|
|
63
66
|
}).then((s) => {
|
|
64
|
-
s && !
|
|
67
|
+
s && !m(s) ? (e.resolve(s), this.deleteWorker(e.groupId, e.workerId)) : this.busyWorkers.delete(e.workerId);
|
|
65
68
|
}).catch((s) => {
|
|
66
69
|
e.reject(s), this.deleteWorker(e.groupId, e.workerId);
|
|
67
70
|
}));
|
|
@@ -72,7 +75,8 @@ class m {
|
|
|
72
75
|
}
|
|
73
76
|
createWorker(e, {
|
|
74
77
|
workerId: r,
|
|
75
|
-
url: s
|
|
78
|
+
url: s,
|
|
79
|
+
headers: g
|
|
76
80
|
}) {
|
|
77
81
|
if (!this.groups.has(e)) {
|
|
78
82
|
if (this.groups.size >= this.config.maxGroupsSize) {
|
|
@@ -105,7 +109,8 @@ class m {
|
|
|
105
109
|
groupId: e,
|
|
106
110
|
url: s,
|
|
107
111
|
resolve: a,
|
|
108
|
-
reject: u
|
|
112
|
+
reject: u,
|
|
113
|
+
headers: g
|
|
109
114
|
};
|
|
110
115
|
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();
|
|
111
116
|
});
|
|
@@ -126,10 +131,10 @@ class m {
|
|
|
126
131
|
this.config.debug("*destroy*"), this.groups.clear(), this.stopTimer();
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
|
-
function
|
|
130
|
-
return new
|
|
134
|
+
function x(t) {
|
|
135
|
+
return new b(t);
|
|
131
136
|
}
|
|
132
137
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
b as HangfirePoller,
|
|
139
|
+
x as default
|
|
135
140
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIParams, APIPostRequest, APIPutRequest } from '@ancon/wildcat-types';
|
|
1
|
+
import type { APIHeaders, APIParams, APIPostRequest, APIPutRequest } from '@ancon/wildcat-types';
|
|
2
2
|
import type { AxiosResponse } from 'axios';
|
|
3
3
|
import { HangfirePoller } from './createHangfirePoller';
|
|
4
4
|
/**
|
|
@@ -6,5 +6,5 @@ import { HangfirePoller } from './createHangfirePoller';
|
|
|
6
6
|
* @param hangfirePoller `HangfirePoller` instance from `createHangfirePoller()`
|
|
7
7
|
* @returns `makeHangfireRequest()` callback function
|
|
8
8
|
*/
|
|
9
|
-
declare function createMakeHangfireRequest(hangfirePoller: HangfirePoller): <TData extends Record<string, any>, TParams extends APIParams>(request: APIPostRequest<unknown, TData, TParams> | APIPutRequest<unknown, TData, TParams>, data: TData, params: TParams, groupId: string) => Promise<AxiosResponse>;
|
|
9
|
+
declare function createMakeHangfireRequest(hangfirePoller: HangfirePoller): <TData extends Record<string, any>, TParams extends APIParams>(request: APIPostRequest<unknown, TData, TParams> | APIPutRequest<unknown, TData, TParams>, data: TData, params: TParams, groupId: string, headers?: APIHeaders) => Promise<AxiosResponse>;
|
|
10
10
|
export default createMakeHangfireRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const c=require("./isHangfireResponse.js");require("../api/isAcceptedResponse.js");function f(e,t){return`${e.config.baseURL??""}/${e.config.url??""}/status/${t}`}function g(e){return async function(u,a,s,o,n={}){const r=await u(a,s,n);if(c(r)){const i=r.data.id;return e.createWorker(o,{workerId:i,url:f(r,i),headers:n})}return r}}module.exports=g;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import s from "./isHangfireResponse.mjs";
|
|
2
2
|
import "../api/isAcceptedResponse.mjs";
|
|
3
|
-
function
|
|
4
|
-
return `${
|
|
3
|
+
function c(r, t) {
|
|
4
|
+
return `${r.config.baseURL ?? ""}/${r.config.url ?? ""}/status/${t}`;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return async function(
|
|
8
|
-
const
|
|
9
|
-
if (s(
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
workerId:
|
|
13
|
-
url:
|
|
6
|
+
function l(r) {
|
|
7
|
+
return async function(o, i, u, f, n = {}) {
|
|
8
|
+
const e = await o(i, u, n);
|
|
9
|
+
if (s(e)) {
|
|
10
|
+
const a = e.data.id;
|
|
11
|
+
return r.createWorker(f, {
|
|
12
|
+
workerId: a,
|
|
13
|
+
url: c(e, a),
|
|
14
|
+
headers: n
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
|
-
return
|
|
17
|
+
return e;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
l as default
|
|
21
22
|
};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./shared/isWithinFlag.js"),t=require("./shared/generateId.js"),o=require("./shared/wait.js"),i=require("./outlet/getListOutletOpeningHoursTable.js"),u=require("./outlet/getOutletTagInformation.js"),s=require("./outlet/getOutletAvailabilityInfo.js"),n=require("./outlet/getOutletOfflineOrderFormats.js"),c=require("./outlet/getOutletAvailableOrderFormats.js"),a=require("./outlet/getOutletFormattedDistance.js"),l=require("./outlet/isOutletAcceptingPreOrders.js"),d=require("./outlet/getOutletDeliveryFee.js"),g=require("./outlet/getOutletTodayOpeningTimes.js"),q=require("./outlet/getOutletOrderFormats.js"),O=require("./outlet/serviceDateTimesFromOpeningHours.js"),_=require("./outlet/getPickerIntervalsForDay.js"),m=require("./outlet/getServiceIntervalRange.js"),k=require("./outlet/getServiceIntervalsForOrderFormat.js"),h=require("./outlet/getOutletFormattedAddress.js"),p=require("./outlet/getPartitionedOutletsList.js"),P=require("./outlet/getOutletPickerTimesForWeek.js"),S=require("./outlet/getOutletOrderPrepTime.js"),C=require("./outlet/getStructuredOutletAddress.js"),T=require("./outlet/getOutletNextOpeningTimeText.js"),F=require("./outlet/getOutletCurrentClosingTimeText.js"),f=require("./outlet/getOutletNextReadyToOrderTime.js"),A=require("./versioning/isVersionALessThanB.js"),y=require("./versioning/cleanVersionString.js"),I=require("./api/getUrlAndParams.js"),v=require("./api/getEndpointWithVersion.js"),E=require("./api/generateBackoffWithEqualJitter.js"),R=require("./api/isAcceptedResponse.js"),D=require("./api/isNoContentResponse.js"),b=require("./string/slugify.js"),N=require("./string/truncate.js"),V=require("./color/lighten.js"),M=require("./color/brighten.js"),H=require("./color/darken.js"),L=require("./color/isDarkBackground.js"),x=require("./user/getFullName.js"),W=require("./user/getFullAddressString.js"),B=require("./user/getCustomerAddressFromGeocoderResult.js"),U=require("./user/getFormattedPhoneNumber.js"),G=require("./user/getStructuredCustomerAddress.js"),w=require("./logger/Logger.js"),z=require("./logger/types.js"),J=require("./logger/sanitizeAsStringDict.js"),K=require("./logger/pascalCaseFormatter.js"),Q=require("./printing/getPrinterType.js"),j=require("./printing/isValidPrinter.js"),X=require("./printing/isValidNetworkPrinter.js"),Y=require("./printing/isValidStarCloudPrinter.js"),Z=require("./printing/isTerminalPrinter.js"),$=require("./printing/isCloudPrintModeEnabled.js"),ee=require("./number/randomIntFromInterval.js"),re=require("./tables/decodeTableQRPayload.js"),te=require("./checkout/getCheckoutItemModifications.js"),oe=require("./checkout/getCheckoutProductName.js"),e=require("./checkout/getCheckoutOrderStatusTexts.js"),ie=require("./checkout/getCheckoutItemsMappedByTicketItemStatus.js"),ue=require("./checkout/isCheckoutOrderSummary.js"),se=require("./checkout/buildCheckoutRequestItem.js"),ne=require("./checkout/getCheckoutGrandTotalAmount.js"),ce=require("./checkout/getCheckoutRequestItemFromCheckoutItem.js"),ae=require("./checkout/isCheckoutItemsAreEqual.js"),le=require("./checkout/checkoutHasWallet.js"),de=require("./checkout/getWalletMetaFromCheckout.js"),ge=require("./checkout/isPreOrderServiceTime.js"),qe=require("./checkout/isPreOrderCheckout.js"),Oe=require("./checkout/isUpdatingCheckoutAllowed.js"),_e=require("./currency/getFormattedCurrency.js"),me=require("./inventory/isDetailedProductOutOfStock.js"),ke=require("./inventory/isDetailedProductVariantOutOfStocks.js"),he=require("./inventory/isMenuTreeProductOutOfStock.js"),pe=require("./inventory/isDetailedProductUpSellsOutOfStock.js"),Pe=require("./inventory/isUpSellProductOutStock.js"),Se=require("./inventory/isDetailedProductOutletStockOutOfStock.js"),Ce=require("./inventory/getDetailedProductVariantStock.js"),Te=require("./signalr/createUseSignalRHook.js"),Fe=require("./signalr/SignalR.js"),fe=require("./error/createCodedError.js"),Ae=require("./error/isCodedError.js"),ye=require("./error/isNetworkError.js"),Ie=require("./error/isLockedError.js"),ve=require("./error/isNotFoundError.js"),Ee=require("./error/isAPIError.js"),Re=require("./error/isSerializedAPIError.js"),De=require("./error/serializeError.js"),be=require("./hangfire/isHangfireResponse.js"),Ne=require("./hangfire/createHangfirePoller.js"),Ve=require("./hangfire/createMakeHangfireRequest.js"),Me=require("./product/extractProductsFromMenuTree.js"),He=require("./product/calculateIngredientsCost.js"),Le=require("./product/calculateAddonGroupCost.js"),xe=require("./product/getAddonGroupInfoBySettings.js");require("moment");require("@ancon/wildcat-types");require("./outlet/constants.js");require("./outlet/getOutletCurrentActiveOperatingHour.js");require("./outlet/getMomentFromDateAndTimeString.js");require("./outlet/searchNextOpeningMoment.js");require("./_baseIsEqual-a66350f1.js");require("./isObjectLike-0cc89d64.js");require("./toString-c005c116.js");require("./shared/constants.js");require("./time/toMinutes.js");require("./time/getNextTenthMinute.js");require("./outlet/types.js");require("./outlet/getSettingsForOrderFormat.js");require("./outlet/getServiceIntervalStart.js");require("./outlet/getNextTenthMinute.js");require("./outlet/generatePickerTimesForDay.js");require("./outlet/getServiceIntervalEnd.js");require("./outlet/hoursAndMinutesToMinutes.js");require("compare-versions");require("tinycolor2");require("google-libphonenumber");require("@ancon/wildcat-printing");require("./currency/getFormattedCurrencyPostfix.js");require("react");require("react-redux");require("@microsoft/signalr");require("axios");exports.isWithinFlag=r;exports.generateId=t;exports.wait=o;exports.getListOutletOpeningHoursTable=i;exports.getOutletTagInformation=u.default;exports.getOutletAvailabilityInfo=s.default;exports.getOutletOfflineOrderFormats=n;exports.getOutletAvailableOrderFormats=c;exports.getOutletFormattedDistance=a;exports.isOutletAcceptingPreOrders=l;exports.getOutletDeliveryFee=d;exports.getOutletTodayOpeningTimes=g;exports.getOutletOrderFormats=q;exports.serviceDateTimesFromOpeningHours=O;exports.getPickerIntervalsForDay=_;exports.getServiceIntervalRange=m;exports.getServiceIntervalsForOrderFormat=k;exports.getOutletFormattedAddress=h;exports.getPartitionedOutletsList=p;exports.getOutletPickerTimesForWeek=P;exports.getOutletOrderPreparationTime=S;exports.getStructuredOutletAddress=C;exports.getOutletNextOpeningTimeText=T;exports.getOutletCurrentClosingTimeText=F;exports.getOutletNextReadyToOrderTime=f;exports.isVersionALessThanB=A;exports.cleanVersionString=y;exports.getUrlAndParams=I;exports.getEndpointWithVersion=v;exports.generateBackoffWithEqualJitter=E;exports.isAcceptedResponse=R;exports.isNoContentResponse=D;exports.slugify=b;exports.truncate=N;exports.lighten=V;exports.brighten=M;exports.darken=H;exports.isDarkBackground=L;exports.getFullName=x;exports.getFullAddressString=W;exports.getCustomerAddressFromGeocoderResult=B;exports.getFormattedPhoneNumber=U;exports.getStructuredCustomerAddress=G;exports.Logger=w;exports.LogLevel=z.LogLevel;exports.sanitizeAsStringDict=J;exports.pascalCaseFormatter=K;exports.getPrinterType=Q;exports.isValidPrinter=j;exports.isValidNetworkPrinter=X;exports.isValidStarCloudPrinter=Y;exports.isTerminalPrinter=Z;exports.isCloudPrintModeEnabled=$;exports.randomIntFromInterval=ee;exports.decodeTableQRPayload=re;exports.getCheckoutGroupedModifications=te;exports.getCheckoutProductName=oe;exports.TranslationKey=e.TranslationKey;exports.getCheckoutOrderStatusTexts=e.default;exports.getCheckoutItemsMappedByTicketItemStatus=ie;exports.isCheckoutOrderSummary=ue;exports.buildCheckoutRequestItem=se;exports.getCheckoutGrandTotalAmount=ne;exports.getCheckoutRequestItemFromCheckoutItem=ce;exports.isCheckoutItemsAreEqual=ae;exports.checkoutHasWallet=le;exports.getWalletMetaFromCheckout=de;exports.isPreOrderServiceTime=ge;exports.isPreOrderCheckout=qe;exports.isUpdatingCheckoutAllowed=Oe;exports.getFormattedCurrency=_e;exports.isDetailedProductOutOfStock=me;exports.isDetailedProductVariantOutOfStocks=ke;exports.isMenuTreeProductOutOfStock=he;exports.isDetailedProductUpSellsOutOfStock=pe;exports.isUpSellProductOutOfStock=Pe;exports.isDetailedProductOutletStockOutOfStock=Se;exports.getDetailedProductVariantStock=Ce;exports.createUseSignalRHook=Te;exports.SignalR=Fe;exports.createCodedError=fe;exports.isCodedError=Ae;exports.isNetworkError=ye;exports.isLockedError=Ie;exports.isNotFoundError=ve;exports.isAPIError=Ee;exports.isSerializedAPIError=Re;exports.serializeError=De;exports.isHangfireResponse=be;exports.createHangfirePoller=Ne.default;exports.createMakeHangfireRequest=Ve;exports.extractProductsFromMenuTree=Me;exports.calculateIngredientsCost=He;exports.calculateAddonGroupsCost=Le;exports.getAddonGroupInfoBySettings=xe.default;
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as R } from "./shared/isWithinFlag.mjs";
|
|
2
2
|
import { default as N } from "./shared/generateId.mjs";
|
|
3
3
|
import { default as V } from "./shared/wait.mjs";
|
|
4
4
|
import { default as L } from "./outlet/getListOutletOpeningHoursTable.mjs";
|
|
@@ -16,7 +16,7 @@ import { default as ae } from "./outlet/getPickerIntervalsForDay.mjs";
|
|
|
16
16
|
import { default as se } from "./outlet/getServiceIntervalRange.mjs";
|
|
17
17
|
import { default as le } from "./outlet/getServiceIntervalsForOrderFormat.mjs";
|
|
18
18
|
import { default as me } from "./outlet/getOutletFormattedAddress.mjs";
|
|
19
|
-
import { default as
|
|
19
|
+
import { default as pe } from "./outlet/getPartitionedOutletsList.mjs";
|
|
20
20
|
import { default as ne } from "./outlet/getOutletPickerTimesForWeek.mjs";
|
|
21
21
|
import { default as ce } from "./outlet/getOutletOrderPrepTime.mjs";
|
|
22
22
|
import { default as ke } from "./outlet/getStructuredOutletAddress.mjs";
|
|
@@ -25,7 +25,7 @@ import { default as Te } from "./outlet/getOutletCurrentClosingTimeText.mjs";
|
|
|
25
25
|
import { default as he } from "./outlet/getOutletNextReadyToOrderTime.mjs";
|
|
26
26
|
import { default as Ie } from "./versioning/isVersionALessThanB.mjs";
|
|
27
27
|
import { default as ve } from "./versioning/cleanVersionString.mjs";
|
|
28
|
-
import { default as
|
|
28
|
+
import { default as Re } from "./api/getUrlAndParams.mjs";
|
|
29
29
|
import { default as Ne } from "./api/getEndpointWithVersion.mjs";
|
|
30
30
|
import { default as Ve } from "./api/generateBackoffWithEqualJitter.mjs";
|
|
31
31
|
import { default as Le } from "./api/isAcceptedResponse.mjs";
|
|
@@ -43,7 +43,7 @@ import { default as at } from "./user/getFormattedPhoneNumber.mjs";
|
|
|
43
43
|
import { default as st } from "./user/getStructuredCustomerAddress.mjs";
|
|
44
44
|
import { default as lt } from "./logger/Logger.mjs";
|
|
45
45
|
import { LogLevel as mt } from "./logger/types.mjs";
|
|
46
|
-
import { default as
|
|
46
|
+
import { default as pt } from "./logger/sanitizeAsStringDict.mjs";
|
|
47
47
|
import { default as nt } from "./logger/pascalCaseFormatter.mjs";
|
|
48
48
|
import { default as ct } from "./printing/getPrinterType.mjs";
|
|
49
49
|
import { default as kt } from "./printing/isValidPrinter.mjs";
|
|
@@ -52,7 +52,7 @@ import { default as Tt } from "./printing/isValidStarCloudPrinter.mjs";
|
|
|
52
52
|
import { default as ht } from "./printing/isTerminalPrinter.mjs";
|
|
53
53
|
import { default as It } from "./printing/isCloudPrintModeEnabled.mjs";
|
|
54
54
|
import { default as vt } from "./number/randomIntFromInterval.mjs";
|
|
55
|
-
import { default as
|
|
55
|
+
import { default as Rt } from "./tables/decodeTableQRPayload.mjs";
|
|
56
56
|
import { default as Nt } from "./checkout/getCheckoutItemModifications.mjs";
|
|
57
57
|
import { default as Vt } from "./checkout/getCheckoutProductName.mjs";
|
|
58
58
|
import { TranslationKey as Lt, default as Mt } from "./checkout/getCheckoutOrderStatusTexts.mjs";
|
|
@@ -69,7 +69,7 @@ import { default as or } from "./checkout/isPreOrderCheckout.mjs";
|
|
|
69
69
|
import { default as fr } from "./checkout/isUpdatingCheckoutAllowed.mjs";
|
|
70
70
|
import { default as ur } from "./currency/getFormattedCurrency.mjs";
|
|
71
71
|
import { default as dr } from "./inventory/isDetailedProductOutOfStock.mjs";
|
|
72
|
-
import { default as
|
|
72
|
+
import { default as ir } from "./inventory/isDetailedProductVariantOutOfStocks.mjs";
|
|
73
73
|
import { default as xr } from "./inventory/isMenuTreeProductOutOfStock.mjs";
|
|
74
74
|
import { default as gr } from "./inventory/isDetailedProductUpSellsOutOfStock.mjs";
|
|
75
75
|
import { default as Or } from "./inventory/isUpSellProductOutStock.mjs";
|
|
@@ -78,19 +78,20 @@ import { default as Sr } from "./inventory/getDetailedProductVariantStock.mjs";
|
|
|
78
78
|
import { default as Fr } from "./signalr/createUseSignalRHook.mjs";
|
|
79
79
|
import { default as Ar } from "./signalr/SignalR.mjs";
|
|
80
80
|
import { default as yr } from "./error/createCodedError.mjs";
|
|
81
|
-
import { default as
|
|
82
|
-
import { default as
|
|
81
|
+
import { default as Er } from "./error/isCodedError.mjs";
|
|
82
|
+
import { default as Dr } from "./error/isNetworkError.mjs";
|
|
83
83
|
import { default as br } from "./error/isLockedError.mjs";
|
|
84
84
|
import { default as Hr } from "./error/isNotFoundError.mjs";
|
|
85
85
|
import { default as Mr } from "./error/isAPIError.mjs";
|
|
86
|
-
import { default as qr } from "./error/
|
|
87
|
-
import { default as Gr } from "./
|
|
88
|
-
import { default as wr } from "./hangfire/
|
|
89
|
-
import { default as Jr } from "./hangfire/
|
|
90
|
-
import { default as Qr } from "./
|
|
91
|
-
import { default as Xr } from "./product/
|
|
92
|
-
import { default as Zr } from "./product/
|
|
93
|
-
import { default as $r } from "./product/
|
|
86
|
+
import { default as qr } from "./error/isSerializedAPIError.mjs";
|
|
87
|
+
import { default as Gr } from "./error/serializeError.mjs";
|
|
88
|
+
import { default as wr } from "./hangfire/isHangfireResponse.mjs";
|
|
89
|
+
import { default as Jr } from "./hangfire/createHangfirePoller.mjs";
|
|
90
|
+
import { default as Qr } from "./hangfire/createMakeHangfireRequest.mjs";
|
|
91
|
+
import { default as Xr } from "./product/extractProductsFromMenuTree.mjs";
|
|
92
|
+
import { default as Zr } from "./product/calculateIngredientsCost.mjs";
|
|
93
|
+
import { default as $r } from "./product/calculateAddonGroupCost.mjs";
|
|
94
|
+
import { default as to } from "./product/getAddonGroupInfoBySettings.mjs";
|
|
94
95
|
import "moment";
|
|
95
96
|
import "@ancon/wildcat-types";
|
|
96
97
|
import "./outlet/constants.mjs";
|
|
@@ -126,20 +127,20 @@ export {
|
|
|
126
127
|
Lt as TranslationKey,
|
|
127
128
|
Ke as brighten,
|
|
128
129
|
wt as buildCheckoutRequestItem,
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
$r as calculateAddonGroupsCost,
|
|
131
|
+
Zr as calculateIngredientsCost,
|
|
131
132
|
Zt as checkoutHasWallet,
|
|
132
133
|
ve as cleanVersionString,
|
|
133
134
|
yr as createCodedError,
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
Jr as createHangfirePoller,
|
|
136
|
+
Qr as createMakeHangfireRequest,
|
|
136
137
|
Fr as createUseSignalRHook,
|
|
137
138
|
je as darken,
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
Rt as decodeTableQRPayload,
|
|
140
|
+
Xr as extractProductsFromMenuTree,
|
|
140
141
|
Ve as generateBackoffWithEqualJitter,
|
|
141
142
|
N as generateId,
|
|
142
|
-
|
|
143
|
+
to as getAddonGroupInfoBySettings,
|
|
143
144
|
Jt as getCheckoutGrandTotalAmount,
|
|
144
145
|
Nt as getCheckoutGroupedModifications,
|
|
145
146
|
qt as getCheckoutItemsMappedByTicketItemStatus,
|
|
@@ -168,35 +169,36 @@ export {
|
|
|
168
169
|
ne as getOutletPickerTimesForWeek,
|
|
169
170
|
W as getOutletTagInformation,
|
|
170
171
|
_ as getOutletTodayOpeningTimes,
|
|
171
|
-
|
|
172
|
+
pe as getPartitionedOutletsList,
|
|
172
173
|
ae as getPickerIntervalsForDay,
|
|
173
174
|
ct as getPrinterType,
|
|
174
175
|
se as getServiceIntervalRange,
|
|
175
176
|
le as getServiceIntervalsForOrderFormat,
|
|
176
177
|
st as getStructuredCustomerAddress,
|
|
177
178
|
ke as getStructuredOutletAddress,
|
|
178
|
-
|
|
179
|
+
Re as getUrlAndParams,
|
|
179
180
|
$t as getWalletMetaFromCheckout,
|
|
180
181
|
Mr as isAPIError,
|
|
181
182
|
Le as isAcceptedResponse,
|
|
182
183
|
Xt as isCheckoutItemsAreEqual,
|
|
183
184
|
Gt as isCheckoutOrderSummary,
|
|
184
185
|
It as isCloudPrintModeEnabled,
|
|
185
|
-
|
|
186
|
+
Er as isCodedError,
|
|
186
187
|
Ye as isDarkBackground,
|
|
187
188
|
dr as isDetailedProductOutOfStock,
|
|
188
189
|
Pr as isDetailedProductOutletStockOutOfStock,
|
|
189
190
|
gr as isDetailedProductUpSellsOutOfStock,
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
ir as isDetailedProductVariantOutOfStocks,
|
|
192
|
+
wr as isHangfireResponse,
|
|
192
193
|
br as isLockedError,
|
|
193
194
|
xr as isMenuTreeProductOutOfStock,
|
|
194
|
-
|
|
195
|
+
Dr as isNetworkError,
|
|
195
196
|
We as isNoContentResponse,
|
|
196
197
|
Hr as isNotFoundError,
|
|
197
198
|
j as isOutletAcceptingPreOrders,
|
|
198
199
|
or as isPreOrderCheckout,
|
|
199
200
|
tr as isPreOrderServiceTime,
|
|
201
|
+
qr as isSerializedAPIError,
|
|
200
202
|
ht as isTerminalPrinter,
|
|
201
203
|
Or as isUpSellProductOutOfStock,
|
|
202
204
|
fr as isUpdatingCheckoutAllowed,
|
|
@@ -204,12 +206,12 @@ export {
|
|
|
204
206
|
kt as isValidPrinter,
|
|
205
207
|
Tt as isValidStarCloudPrinter,
|
|
206
208
|
Ie as isVersionALessThanB,
|
|
207
|
-
|
|
209
|
+
R as isWithinFlag,
|
|
208
210
|
ze as lighten,
|
|
209
211
|
nt as pascalCaseFormatter,
|
|
210
212
|
vt as randomIntFromInterval,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
pt as sanitizeAsStringDict,
|
|
214
|
+
Gr as serializeError,
|
|
213
215
|
re as serviceDateTimesFromOpeningHours,
|
|
214
216
|
Be as slugify,
|
|
215
217
|
Ue as truncate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancon/wildcat-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -216,11 +216,21 @@
|
|
|
216
216
|
"require": "./error/isNotFoundError.js",
|
|
217
217
|
"types": "./error/isNotFoundError.d.ts"
|
|
218
218
|
},
|
|
219
|
+
"./error/isSerializedAPIError": {
|
|
220
|
+
"import": "./error/isSerializedAPIError.mjs",
|
|
221
|
+
"require": "./error/isSerializedAPIError.js",
|
|
222
|
+
"types": "./error/isSerializedAPIError.d.ts"
|
|
223
|
+
},
|
|
219
224
|
"./error/serializeError": {
|
|
220
225
|
"import": "./error/serializeError.mjs",
|
|
221
226
|
"require": "./error/serializeError.js",
|
|
222
227
|
"types": "./error/serializeError.d.ts"
|
|
223
228
|
},
|
|
229
|
+
"./error/types": {
|
|
230
|
+
"import": "./error/types.mjs",
|
|
231
|
+
"require": "./error/types.js",
|
|
232
|
+
"types": "./error/types.d.ts"
|
|
233
|
+
},
|
|
224
234
|
"./hangfire/createHangfirePoller": {
|
|
225
235
|
"import": "./hangfire/createHangfirePoller.mjs",
|
|
226
236
|
"require": "./hangfire/createHangfirePoller.js",
|