@ancon/wildcat-utils 1.21.6 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/error/createCodedError.d.ts +11 -0
- package/error/createCodedError.js +1 -0
- package/error/createCodedError.mjs +17 -0
- package/error/index.d.ts +4 -0
- package/error/index.js +1 -0
- package/error/index.mjs +6 -0
- package/error/isCodedError.d.ts +7 -0
- package/error/isCodedError.js +1 -0
- package/error/isCodedError.mjs +6 -0
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +40 -36
- package/package.json +16 -1
- package/signalr/createUseSignalRHook.d.ts +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorCode } from '@ancon/wildcat-types';
|
|
2
|
+
/** Client-side generated error */
|
|
3
|
+
declare type CodedError = {
|
|
4
|
+
code: ErrorCode;
|
|
5
|
+
message?: string;
|
|
6
|
+
additionalData: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
/** Create a new client-side generated error */
|
|
9
|
+
declare function createCodedError(err: unknown, code?: ErrorCode, additionalData?: Record<string, unknown>): CodedError;
|
|
10
|
+
export type { CodedError };
|
|
11
|
+
export default createCodedError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function i(t){return t instanceof Error||typeof t=="object"&&!!(t!=null&&t.message)}function f(t){return typeof(t==null?void 0:t.message)=="string"}function c(t,o,e){if(i(t)){const s=t;return o&&(s.code=o),e&&(s.additionalData=e),s}const n=new Error("Unknown error");return f(t)?(t.message&&(n.message=t.message),n):(typeof t=="string"&&(n.message=t,o&&(n.code=o)),n)}module.exports=c;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function f(n) {
|
|
2
|
+
return n instanceof Error || typeof n == "object" && !!(n != null && n.message);
|
|
3
|
+
}
|
|
4
|
+
function i(n) {
|
|
5
|
+
return typeof (n == null ? void 0 : n.message) == "string";
|
|
6
|
+
}
|
|
7
|
+
function a(n, t, e) {
|
|
8
|
+
if (f(n)) {
|
|
9
|
+
const s = n;
|
|
10
|
+
return t && (s.code = t), e && (s.additionalData = e), s;
|
|
11
|
+
}
|
|
12
|
+
const o = new Error("Unknown error");
|
|
13
|
+
return i(n) ? (n.message && (o.message = n.message), o) : (typeof n == "string" && (o.message = n, t && (o.code = t)), o);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
a as default
|
|
17
|
+
};
|
package/error/index.d.ts
ADDED
package/error/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./createCodedError.js"),e=require("./isCodedError.js");exports.createCodedError=r;exports.isCodedError=e;
|
package/error/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ErrorCode } from '@ancon/wildcat-types';
|
|
2
|
+
import { CodedError } from './createCodedError';
|
|
3
|
+
/** Whether provided error is an `CodedError` */
|
|
4
|
+
declare function isCodedError(error: unknown): error is CodedError;
|
|
5
|
+
/** Whether provided error is an `CodedError` with the provided `code` */
|
|
6
|
+
declare function isCodedError(error: unknown, code: ErrorCode): error is CodedError;
|
|
7
|
+
export default isCodedError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function i(n,t){return t!=null?n instanceof Error&&n.code===t:n instanceof Error&&n.code!=null}module.exports=i;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),i=require("./shared/generateId.js"),o=require("./shared/wait.js"),n=require("./outlet/getListOutletOpeningHoursTable.js"),u=require("./outlet/getOutletTagInformation.js"),s=require("./outlet/getOutletAvailabilityInfo.js"),a=require("./outlet/getOutletOfflineOrderFormats.js"),c=require("./outlet/getOutletAvailableOrderFormats.js"),l=require("./outlet/getOutletFormattedDistance.js"),g=require("./outlet/isOutletAcceptingPreOrders.js"),d=require("./outlet/getOutletDeliveryFee.js"),q=require("./outlet/getOutletTodayOpeningTimes.js"),O=require("./outlet/getOutletOrderFormats.js"),_=require("./outlet/serviceDateTimesFromOpeningHours.js"),k=require("./versioning/isVersionALessThanB.js"),m=require("./versioning/cleanVersionString.js"),S=require("./api/getUrlAndParams.js"),y=require("./api/getEndpointWithVersion.js"),f=require("./api/generateBackoffWithEqualJitter.js"),p=require("./string/slugify.js"),P=require("./string/truncate.js"),h=require("./color/lighten.js"),T=require("./color/brighten.js"),v=require("./color/darken.js"),F=require("./color/isDarkBackground.js"),D=require("./user/getFullName.js"),I=require("./user/getFullAddressString.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),i=require("./shared/generateId.js"),o=require("./shared/wait.js"),n=require("./outlet/getListOutletOpeningHoursTable.js"),u=require("./outlet/getOutletTagInformation.js"),s=require("./outlet/getOutletAvailabilityInfo.js"),a=require("./outlet/getOutletOfflineOrderFormats.js"),c=require("./outlet/getOutletAvailableOrderFormats.js"),l=require("./outlet/getOutletFormattedDistance.js"),g=require("./outlet/isOutletAcceptingPreOrders.js"),d=require("./outlet/getOutletDeliveryFee.js"),q=require("./outlet/getOutletTodayOpeningTimes.js"),O=require("./outlet/getOutletOrderFormats.js"),_=require("./outlet/serviceDateTimesFromOpeningHours.js"),k=require("./versioning/isVersionALessThanB.js"),m=require("./versioning/cleanVersionString.js"),S=require("./api/getUrlAndParams.js"),y=require("./api/getEndpointWithVersion.js"),f=require("./api/generateBackoffWithEqualJitter.js"),p=require("./string/slugify.js"),P=require("./string/truncate.js"),h=require("./color/lighten.js"),T=require("./color/brighten.js"),v=require("./color/darken.js"),F=require("./color/isDarkBackground.js"),D=require("./user/getFullName.js"),I=require("./user/getFullAddressString.js"),C=require("./logger/Logger.js"),V=require("./logger/types.js"),b=require("./logger/sanitizeAsStringDict.js"),A=require("./printing/getPrinterType.js"),L=require("./printing/isValidPrinter.js"),B=require("./printing/isValidNetworkPrinter.js"),E=require("./printing/isValidStarCloudPrinter.js"),U=require("./printing/isTerminalPrinter.js"),W=require("./number/randomIntFromInterval.js"),M=require("./tables/decodeTableQRPayload.js"),H=require("./checkout/getCheckoutItemModifications.js"),N=require("./checkout/getCheckoutProductName.js"),t=require("./checkout/getCheckoutOrderStatusTexts.js"),R=require("./checkout/getCheckoutItemsMappedByTicketItemStatus.js"),w=require("./checkout/isCheckoutOrderSummary.js"),x=require("./currency/getFormattedCurrency.js"),z=require("./inventory/isDetailedProductOutOfStock.js"),J=require("./inventory/isDetailedProductVariantOutOfStocks.js"),K=require("./inventory/isMenuTreeProductOutOfStock.js"),Q=require("./inventory/isDetailedProductUpSellsOutOfStock.js"),j=require("./inventory/isUpSellProductOutStock.js"),G=require("./inventory/isDetailedProductOutletStockOutOfStock.js"),X=require("./inventory/getDetailedProductVariantStock.js"),Y=require("./signalr/createUseSignalRHook.js"),Z=require("./signalr/SignalR.js"),$=require("./error/createCodedError.js"),ee=require("./error/isCodedError.js");require("moment");require("@ancon/wildcat-types");require("./outlet/types.js");require("./outlet/constants.js");require("./outlet/getOutletCurrentActiveOperatingHour.js");require("./outlet/getMomentFromDateAndTimeString.js");require("./outlet/searchNextOpeningMoment.js");require("lodash");require("compare-versions");require("tinycolor2");require("@ancon/wildcat-printing");require("./currency/getFormattedCurrencyPostfix.js");require("react");require("react-redux");require("@microsoft/signalr");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=i;exports.wait=o;exports.getListOutletOpeningHoursTable=n;exports.getOutletTagInformation=u.default;exports.getOutletAvailabilityInfo=s.default;exports.getOutletOfflineOrderFormats=a;exports.getOutletAvailableOrderFormats=c;exports.getOutletFormattedDistance=l;exports.isOutletAcceptingPreOrders=g;exports.getOutletDeliveryFee=d;exports.getOutletTodayOpeningTimes=q;exports.getOutletOrderFormats=O;exports.serviceDateTimesFromOpeningHours=_;exports.isVersionALessThanB=k;exports.cleanVersionString=m;exports.getUrlAndParams=S;exports.getEndpointWithVersion=y;exports.generateBackoffWithEqualJitter=f;exports.slugify=p;exports.truncate=P;exports.lighten=h;exports.brighten=T;exports.darken=v;exports.isDarkBackground=F;exports.getFullName=D;exports.getFullAddressString=I;exports.Logger=C;exports.LogLevel=V.LogLevel;exports.sanitizeAsStringDict=b;exports.getPrinterType=A;exports.isValidPrinter=L;exports.isValidNetworkPrinter=B;exports.isValidStarCloudPrinter=E;exports.isTerminalPrinter=U;exports.randomIntFromInterval=W;exports.decodeTableQRPayload=M;exports.getCheckoutGroupedModifications=H;exports.getCheckoutProductName=N;exports.TranslationKey=t.TranslationKey;exports.getCheckoutOrderStatusTexts=t.default;exports.getCheckoutItemsMappedByTicketItemStatus=R;exports.isCheckoutOrderSummary=w;exports.getFormattedCurrency=x;exports.isDetailedProductOutOfStock=z;exports.isDetailedProductVariantOutOfStocks=J;exports.isMenuTreeProductOutOfStock=K;exports.isDetailedProductUpSellsOutOfStock=Q;exports.isUpSellProductOutOfStock=j;exports.isDetailedProductOutletStockOutOfStock=G;exports.getDetailedProductVariantStock=X;exports.createUseSignalRHook=Y;exports.SignalR=Z;exports.createCodedError=$;exports.isCodedError=ee;
|
package/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DayOfWeek as O, IntervalState as k, IntervalType as S, OrderFormat as P } from "./shared/enums.mjs";
|
|
2
2
|
import { default as y } from "./shared/isWithinFlag.mjs";
|
|
3
3
|
import { default as h } from "./shared/generateId.mjs";
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
4
|
+
import { default as C } from "./shared/wait.mjs";
|
|
5
|
+
import { default as v } from "./outlet/getListOutletOpeningHoursTable.mjs";
|
|
6
|
+
import { default as A } from "./outlet/getOutletTagInformation.mjs";
|
|
7
7
|
import { default as L } from "./outlet/getOutletAvailabilityInfo.mjs";
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
8
|
+
import { default as E } from "./outlet/getOutletOfflineOrderFormats.mjs";
|
|
9
|
+
import { default as W } from "./outlet/getOutletAvailableOrderFormats.mjs";
|
|
10
|
+
import { default as M } from "./outlet/getOutletFormattedDistance.mjs";
|
|
11
|
+
import { default as R } from "./outlet/isOutletAcceptingPreOrders.mjs";
|
|
12
12
|
import { default as q } from "./outlet/getOutletDeliveryFee.mjs";
|
|
13
13
|
import { default as G } from "./outlet/getOutletTodayOpeningTimes.mjs";
|
|
14
14
|
import { default as K } from "./outlet/getOutletOrderFormats.mjs";
|
|
@@ -19,8 +19,8 @@ import { default as tt } from "./api/getUrlAndParams.mjs";
|
|
|
19
19
|
import { default as rt } from "./api/getEndpointWithVersion.mjs";
|
|
20
20
|
import { default as at } from "./api/generateBackoffWithEqualJitter.mjs";
|
|
21
21
|
import { default as lt } from "./string/slugify.mjs";
|
|
22
|
-
import { default as
|
|
23
|
-
import { default as
|
|
22
|
+
import { default as dt } from "./string/truncate.mjs";
|
|
23
|
+
import { default as mt } from "./color/lighten.mjs";
|
|
24
24
|
import { default as pt } from "./color/brighten.mjs";
|
|
25
25
|
import { default as nt } from "./color/darken.mjs";
|
|
26
26
|
import { default as ct } from "./color/isDarkBackground.mjs";
|
|
@@ -28,14 +28,14 @@ import { default as kt } from "./user/getFullName.mjs";
|
|
|
28
28
|
import { default as Pt } from "./user/getFullAddressString.mjs";
|
|
29
29
|
import { default as yt } from "./logger/Logger.mjs";
|
|
30
30
|
import { LogLevel as ht } from "./logger/types.mjs";
|
|
31
|
-
import { default as
|
|
32
|
-
import { default as
|
|
33
|
-
import { default as
|
|
31
|
+
import { default as Ct } from "./logger/sanitizeAsStringDict.mjs";
|
|
32
|
+
import { default as vt } from "./printing/getPrinterType.mjs";
|
|
33
|
+
import { default as At } from "./printing/isValidPrinter.mjs";
|
|
34
34
|
import { default as Lt } from "./printing/isValidNetworkPrinter.mjs";
|
|
35
|
-
import { default as
|
|
36
|
-
import { default as
|
|
37
|
-
import { default as
|
|
38
|
-
import { default as
|
|
35
|
+
import { default as Et } from "./printing/isValidStarCloudPrinter.mjs";
|
|
36
|
+
import { default as Wt } from "./printing/isTerminalPrinter.mjs";
|
|
37
|
+
import { default as Mt } from "./number/randomIntFromInterval.mjs";
|
|
38
|
+
import { default as Rt } from "./tables/decodeTableQRPayload.mjs";
|
|
39
39
|
import { default as qt } from "./checkout/getCheckoutItemModifications.mjs";
|
|
40
40
|
import { default as Gt } from "./checkout/getCheckoutProductName.mjs";
|
|
41
41
|
import { TranslationKey as Kt, default as Qt } from "./checkout/getCheckoutOrderStatusTexts.mjs";
|
|
@@ -46,11 +46,13 @@ import { default as ee } from "./inventory/isDetailedProductOutOfStock.mjs";
|
|
|
46
46
|
import { default as oe } from "./inventory/isDetailedProductVariantOutOfStocks.mjs";
|
|
47
47
|
import { default as fe } from "./inventory/isMenuTreeProductOutOfStock.mjs";
|
|
48
48
|
import { default as se } from "./inventory/isDetailedProductUpSellsOutOfStock.mjs";
|
|
49
|
-
import { default as
|
|
50
|
-
import { default as
|
|
49
|
+
import { default as ue } from "./inventory/isUpSellProductOutStock.mjs";
|
|
50
|
+
import { default as ie } from "./inventory/isDetailedProductOutletStockOutOfStock.mjs";
|
|
51
51
|
import { default as xe } from "./inventory/getDetailedProductVariantStock.mjs";
|
|
52
52
|
import { default as ge } from "./signalr/createUseSignalRHook.mjs";
|
|
53
53
|
import { default as Oe } from "./signalr/SignalR.mjs";
|
|
54
|
+
import { default as Se } from "./error/createCodedError.mjs";
|
|
55
|
+
import { default as Te } from "./error/isCodedError.mjs";
|
|
54
56
|
import "moment";
|
|
55
57
|
import "@ancon/wildcat-types";
|
|
56
58
|
import "./outlet/types.mjs";
|
|
@@ -77,9 +79,10 @@ export {
|
|
|
77
79
|
Kt as TranslationKey,
|
|
78
80
|
pt as brighten,
|
|
79
81
|
_ as cleanVersionString,
|
|
82
|
+
Se as createCodedError,
|
|
80
83
|
ge as createUseSignalRHook,
|
|
81
84
|
nt as darken,
|
|
82
|
-
|
|
85
|
+
Rt as decodeTableQRPayload,
|
|
83
86
|
at as generateBackoffWithEqualJitter,
|
|
84
87
|
h as generateId,
|
|
85
88
|
qt as getCheckoutGroupedModifications,
|
|
@@ -91,37 +94,38 @@ export {
|
|
|
91
94
|
$t as getFormattedCurrency,
|
|
92
95
|
Pt as getFullAddressString,
|
|
93
96
|
kt as getFullName,
|
|
94
|
-
|
|
97
|
+
v as getListOutletOpeningHoursTable,
|
|
95
98
|
L as getOutletAvailabilityInfo,
|
|
96
|
-
|
|
99
|
+
W as getOutletAvailableOrderFormats,
|
|
97
100
|
q as getOutletDeliveryFee,
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
M as getOutletFormattedDistance,
|
|
102
|
+
E as getOutletOfflineOrderFormats,
|
|
100
103
|
K as getOutletOrderFormats,
|
|
101
|
-
|
|
104
|
+
A as getOutletTagInformation,
|
|
102
105
|
G as getOutletTodayOpeningTimes,
|
|
103
|
-
|
|
106
|
+
vt as getPrinterType,
|
|
104
107
|
tt as getUrlAndParams,
|
|
105
108
|
Zt as isCheckoutOrderSummary,
|
|
109
|
+
Te as isCodedError,
|
|
106
110
|
ct as isDarkBackground,
|
|
107
111
|
ee as isDetailedProductOutOfStock,
|
|
108
|
-
|
|
112
|
+
ie as isDetailedProductOutletStockOutOfStock,
|
|
109
113
|
se as isDetailedProductUpSellsOutOfStock,
|
|
110
114
|
oe as isDetailedProductVariantOutOfStocks,
|
|
111
115
|
fe as isMenuTreeProductOutOfStock,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
R as isOutletAcceptingPreOrders,
|
|
117
|
+
Wt as isTerminalPrinter,
|
|
118
|
+
ue as isUpSellProductOutOfStock,
|
|
115
119
|
Lt as isValidNetworkPrinter,
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
At as isValidPrinter,
|
|
121
|
+
Et as isValidStarCloudPrinter,
|
|
118
122
|
Y as isVersionALessThanB,
|
|
119
123
|
y as isWithinFlag,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
mt as lighten,
|
|
125
|
+
Mt as randomIntFromInterval,
|
|
126
|
+
Ct as sanitizeAsStringDict,
|
|
123
127
|
j as serviceDateTimesFromOpeningHours,
|
|
124
128
|
lt as slugify,
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
dt as truncate,
|
|
130
|
+
C as wait
|
|
127
131
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancon/wildcat-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -96,6 +96,21 @@
|
|
|
96
96
|
"require": "./currency/index.js",
|
|
97
97
|
"types": "./currency/index.d.ts"
|
|
98
98
|
},
|
|
99
|
+
"./error/createCodedError": {
|
|
100
|
+
"import": "./error/createCodedError.mjs",
|
|
101
|
+
"require": "./error/createCodedError.js",
|
|
102
|
+
"types": "./error/createCodedError.d.ts"
|
|
103
|
+
},
|
|
104
|
+
"./error": {
|
|
105
|
+
"import": "./error/index.mjs",
|
|
106
|
+
"require": "./error/index.js",
|
|
107
|
+
"types": "./error/index.d.ts"
|
|
108
|
+
},
|
|
109
|
+
"./error/isCodedError": {
|
|
110
|
+
"import": "./error/isCodedError.mjs",
|
|
111
|
+
"require": "./error/isCodedError.js",
|
|
112
|
+
"types": "./error/isCodedError.d.ts"
|
|
113
|
+
},
|
|
99
114
|
".": {
|
|
100
115
|
"import": "./index.mjs",
|
|
101
116
|
"require": "./index.js",
|
|
@@ -12,8 +12,8 @@ declare type ReduxActionsArg = Partial<{
|
|
|
12
12
|
}>;
|
|
13
13
|
declare type ReduxHooksArg = Partial<{
|
|
14
14
|
useAppDispatch: () => (action: unknown) => unknown;
|
|
15
|
-
useAppStore:
|
|
16
|
-
getState: () =>
|
|
15
|
+
useAppStore: () => {
|
|
16
|
+
getState: () => unknown;
|
|
17
17
|
};
|
|
18
18
|
useAppSelector: <T extends (...args: any[]) => any>(selector: T) => ReturnType<T>;
|
|
19
19
|
}>;
|