erpnext-queue-client 1.3.1 → 1.4.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/dist/erpnext/doctypeResourceRequest.d.ts +1 -1
- package/dist/erpnext/doctypeResourceRequest.js +1 -1
- package/dist/erpnext/doctypeSubmittableResourceRequest.d.ts +6 -2
- package/dist/erpnext/doctypeSubmittableResourceRequest.js +4 -4
- package/dist/erpnext/doctypes/address.d.ts +1 -1
- package/dist/erpnext/doctypes/contact.d.ts +1 -1
- package/dist/erpnext/doctypes/deliveryNote.d.ts +1 -1
- package/dist/erpnext/doctypes/item.d.ts +2 -2
- package/dist/erpnext/doctypes/purchaseInvoice.d.ts +7 -3
- package/dist/erpnext/doctypes/purchaseInvoice.js +2 -2
- package/dist/erpnext/doctypes/purchaseReceipt.d.ts +7 -3
- package/dist/erpnext/doctypes/purchaseReceipt.js +2 -2
- package/dist/erpnext/doctypes/shipment.d.ts +7 -3
- package/dist/erpnext/doctypes/shipment.js +1 -1
- package/dist/erpnext/doctypes/stock.js +8 -5
- package/dist/erpnext/methodRequest.d.ts +1 -1
- package/dist/erpnext/methodRequest.js +2 -1
- package/dist/erpnext/resourceRequest.d.ts +1 -1
- package/dist/erpnext/resourceRequest.js +12 -12
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +13 -1
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ export declare class ERPNextDoctypeResourceRequest<TModel extends ZodObject<any>
|
|
|
16
16
|
limit?: number;
|
|
17
17
|
priority?: number;
|
|
18
18
|
asDict?: TAsDict;
|
|
19
|
-
params?: string
|
|
19
|
+
params?: Record<string, string>;
|
|
20
20
|
}): Promise<TAsDict extends false ? Array<Array<string>> : typeof fields extends undefined ? Array<Pick<z.infer<TModel>, "name">> : Array<Pick<z.infer<TModel>, TField>>>;
|
|
21
21
|
getById({ resourceId, priority, }: {
|
|
22
22
|
resourceId: string;
|
|
@@ -20,7 +20,7 @@ class ERPNextDoctypeResourceRequest {
|
|
|
20
20
|
}
|
|
21
21
|
getList() {
|
|
22
22
|
return __awaiter(this, arguments, void 0, function* ({ fields, filters, skip, limit, priority = 5, asDict, params, } = {}) {
|
|
23
|
-
return yield this.baseRequest.getList(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ resourceName: this.resourceName, resourceModel: this.resourceModel, priority }, (fields ? { fields } : {})), (filters ? { filters } : {})), (limit ? { limit } : {})), (skip ? { skip } : {})), (params ? { params } : {})), (asDict ? { asDict } : {})));
|
|
23
|
+
return yield this.baseRequest.getList(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ resourceName: this.resourceName, resourceModel: this.resourceModel, priority }, (fields !== undefined ? { fields } : {})), (filters !== undefined ? { filters } : {})), (limit !== undefined ? { limit } : {})), (skip !== undefined ? { skip } : {})), (params !== undefined ? { params } : {})), (asDict !== undefined ? { asDict } : {})));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
getById(_a) {
|
|
@@ -3,6 +3,10 @@ import { ERPNextDoctypeResourceRequest } from "./doctypeResourceRequest";
|
|
|
3
3
|
import { TemporalClient } from "../client";
|
|
4
4
|
export declare class ERPNextDoctypeSubmittableResourceRequest<TModel extends ZodObject<any>> extends ERPNextDoctypeResourceRequest<TModel> {
|
|
5
5
|
constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: TModel);
|
|
6
|
-
cancel(resourceId
|
|
7
|
-
|
|
6
|
+
cancel({ resourceId }: {
|
|
7
|
+
resourceId: string;
|
|
8
|
+
}): Promise<import("zod").TypeOf<TModel>>;
|
|
9
|
+
submit({ resourceId }: {
|
|
10
|
+
resourceId: string;
|
|
11
|
+
}): Promise<import("zod").TypeOf<TModel>>;
|
|
8
12
|
}
|
|
@@ -15,8 +15,8 @@ class ERPNextDoctypeSubmittableResourceRequest extends doctypeResourceRequest_1.
|
|
|
15
15
|
constructor(temporalClient, resourceName, resourceModel) {
|
|
16
16
|
super(temporalClient, resourceName, resourceModel);
|
|
17
17
|
}
|
|
18
|
-
cancel(
|
|
19
|
-
return __awaiter(this,
|
|
18
|
+
cancel(_a) {
|
|
19
|
+
return __awaiter(this, arguments, void 0, function* ({ resourceId }) {
|
|
20
20
|
return this.updateById({
|
|
21
21
|
resourceId,
|
|
22
22
|
body: {
|
|
@@ -25,8 +25,8 @@ class ERPNextDoctypeSubmittableResourceRequest extends doctypeResourceRequest_1.
|
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
submit(
|
|
29
|
-
return __awaiter(this,
|
|
28
|
+
submit(_a) {
|
|
29
|
+
return __awaiter(this, arguments, void 0, function* ({ resourceId }) {
|
|
30
30
|
return this.updateById({
|
|
31
31
|
resourceId,
|
|
32
32
|
body: {
|
|
@@ -396,7 +396,7 @@ export declare class ERPNextDeliveryNote {
|
|
|
396
396
|
limit?: number;
|
|
397
397
|
priority?: number;
|
|
398
398
|
asDict?: TAsDict;
|
|
399
|
-
params?: string
|
|
399
|
+
params?: Record<string, string>;
|
|
400
400
|
}) => Promise<TAsDict extends false ? string[][] : Pick<{
|
|
401
401
|
status: string;
|
|
402
402
|
name: string;
|
|
@@ -15,7 +15,7 @@ export declare class ERPNextItem {
|
|
|
15
15
|
limit?: number;
|
|
16
16
|
priority?: number;
|
|
17
17
|
asDict?: TAsDict;
|
|
18
|
-
params?: string
|
|
18
|
+
params?: Record<string, string>;
|
|
19
19
|
}) => Promise<TAsDict extends false ? string[][] : Pick<{
|
|
20
20
|
description: string;
|
|
21
21
|
name: string;
|
|
@@ -799,7 +799,7 @@ export declare class ERPNextItem {
|
|
|
799
799
|
packaging_weight_plastic?: number | null | undefined;
|
|
800
800
|
}>;
|
|
801
801
|
constructor(temporalClient: TemporalClient);
|
|
802
|
-
getNoneStockItems(params?: string): Promise<string[]>;
|
|
802
|
+
getNoneStockItems(params?: Record<string, string>): Promise<string[]>;
|
|
803
803
|
getStockDict(warehouse: string): Promise<Record<string | number, number>>;
|
|
804
804
|
getProjectedQuantity(options?: GetProjectedQuantityInputOptionsType): Promise<Record<string, number>>;
|
|
805
805
|
createBStockItems(aStockSkus: string[]): Promise<string[]>;
|
|
@@ -13,7 +13,7 @@ export declare class ERPNextPurchaseInvoice {
|
|
|
13
13
|
limit?: number;
|
|
14
14
|
priority?: number;
|
|
15
15
|
asDict?: TAsDict;
|
|
16
|
-
params?: string
|
|
16
|
+
params?: Record<string, string>;
|
|
17
17
|
}) => Promise<TAsDict extends false ? string[][] : Pick<{
|
|
18
18
|
name: string;
|
|
19
19
|
owner: string;
|
|
@@ -801,7 +801,9 @@ export declare class ERPNextPurchaseInvoice {
|
|
|
801
801
|
resourceId: string;
|
|
802
802
|
priority?: number;
|
|
803
803
|
}) => Promise<import("zod").TypeOf<typeof import("../model/ERPNextResponse").DeleteResponseModel>>;
|
|
804
|
-
cancel: (resourceId:
|
|
804
|
+
cancel: ({ resourceId }: {
|
|
805
|
+
resourceId: string;
|
|
806
|
+
}) => Promise<{
|
|
805
807
|
name: string;
|
|
806
808
|
owner: string;
|
|
807
809
|
idx: number;
|
|
@@ -995,7 +997,9 @@ export declare class ERPNextPurchaseInvoice {
|
|
|
995
997
|
advance_tax?: string[] | null | undefined;
|
|
996
998
|
remarks?: string | null | undefined;
|
|
997
999
|
}>;
|
|
998
|
-
submit: (resourceId:
|
|
1000
|
+
submit: ({ resourceId }: {
|
|
1001
|
+
resourceId: string;
|
|
1002
|
+
}) => Promise<{
|
|
999
1003
|
name: string;
|
|
1000
1004
|
owner: string;
|
|
1001
1005
|
idx: number;
|
|
@@ -39,7 +39,7 @@ class ERPNextPurchaseInvoice {
|
|
|
39
39
|
methodName: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
|
40
40
|
requestMethod: "POST",
|
|
41
41
|
responseValidationModel: PurchaseInvoice_1.PurchaseInvoiceDraft,
|
|
42
|
-
params:
|
|
42
|
+
params: { source_name: purchaseOrderName },
|
|
43
43
|
});
|
|
44
44
|
return draft;
|
|
45
45
|
});
|
|
@@ -60,7 +60,7 @@ class ERPNextPurchaseInvoice {
|
|
|
60
60
|
methodName: `erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice`,
|
|
61
61
|
requestMethod: "POST",
|
|
62
62
|
responseValidationModel: PurchaseInvoice_1.PurchaseInvoiceDraft,
|
|
63
|
-
params:
|
|
63
|
+
params: { source_name: purchaseReceiptName },
|
|
64
64
|
});
|
|
65
65
|
return draft;
|
|
66
66
|
});
|
|
@@ -13,7 +13,7 @@ export declare class ERPNextPurchaseReceipt {
|
|
|
13
13
|
limit?: number;
|
|
14
14
|
priority?: number;
|
|
15
15
|
asDict?: TAsDict;
|
|
16
|
-
params?: string
|
|
16
|
+
params?: Record<string, string>;
|
|
17
17
|
}) => Promise<TAsDict extends false ? string[][] : Pick<{
|
|
18
18
|
status: string;
|
|
19
19
|
name: string;
|
|
@@ -825,7 +825,9 @@ export declare class ERPNextPurchaseReceipt {
|
|
|
825
825
|
resourceId: string;
|
|
826
826
|
priority?: number;
|
|
827
827
|
}) => Promise<import("zod").TypeOf<typeof import("../model/ERPNextResponse").DeleteResponseModel>>;
|
|
828
|
-
cancel: (resourceId:
|
|
828
|
+
cancel: ({ resourceId }: {
|
|
829
|
+
resourceId: string;
|
|
830
|
+
}) => Promise<{
|
|
829
831
|
status: string;
|
|
830
832
|
name: string;
|
|
831
833
|
owner: string;
|
|
@@ -1025,7 +1027,9 @@ export declare class ERPNextPurchaseReceipt {
|
|
|
1025
1027
|
supplier_warehouse?: any;
|
|
1026
1028
|
range?: any;
|
|
1027
1029
|
}>;
|
|
1028
|
-
submit: (resourceId:
|
|
1030
|
+
submit: ({ resourceId }: {
|
|
1031
|
+
resourceId: string;
|
|
1032
|
+
}) => Promise<{
|
|
1029
1033
|
status: string;
|
|
1030
1034
|
name: string;
|
|
1031
1035
|
owner: string;
|
|
@@ -32,7 +32,7 @@ class ERPNextPurchaseReceipt {
|
|
|
32
32
|
methodName: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
|
33
33
|
requestMethod: "POST",
|
|
34
34
|
responseValidationModel: ReceiptDraft_1.ReceiptDraft,
|
|
35
|
-
params:
|
|
35
|
+
params: { source_name: purchaseOrderName },
|
|
36
36
|
});
|
|
37
37
|
return draft;
|
|
38
38
|
});
|
|
@@ -53,7 +53,7 @@ class ERPNextPurchaseReceipt {
|
|
|
53
53
|
methodName: `erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_purchase_receipt`,
|
|
54
54
|
requestMethod: "POST",
|
|
55
55
|
responseValidationModel: ReceiptDraft_1.ReceiptDraft,
|
|
56
|
-
params:
|
|
56
|
+
params: { source_name: purchaseInvoiceName },
|
|
57
57
|
});
|
|
58
58
|
return draft;
|
|
59
59
|
});
|
|
@@ -13,7 +13,7 @@ export declare class ERPNextShipment {
|
|
|
13
13
|
limit?: number;
|
|
14
14
|
priority?: number;
|
|
15
15
|
asDict?: TAsDict;
|
|
16
|
-
params?: string
|
|
16
|
+
params?: Record<string, string>;
|
|
17
17
|
}) => Promise<TAsDict extends false ? string[][] : Pick<{
|
|
18
18
|
status: string;
|
|
19
19
|
name: string;
|
|
@@ -604,7 +604,9 @@ export declare class ERPNextShipment {
|
|
|
604
604
|
tracking_status_info?: string | null | undefined;
|
|
605
605
|
tracking_url?: string | null | undefined;
|
|
606
606
|
}>;
|
|
607
|
-
cancel: (resourceId:
|
|
607
|
+
cancel: ({ resourceId }: {
|
|
608
|
+
resourceId: string;
|
|
609
|
+
}) => Promise<{
|
|
608
610
|
status: string;
|
|
609
611
|
name: string;
|
|
610
612
|
owner: string;
|
|
@@ -700,7 +702,9 @@ export declare class ERPNextShipment {
|
|
|
700
702
|
tracking_status_info?: string | null | undefined;
|
|
701
703
|
tracking_url?: string | null | undefined;
|
|
702
704
|
}>;
|
|
703
|
-
submit: (resourceId:
|
|
705
|
+
submit: ({ resourceId }: {
|
|
706
|
+
resourceId: string;
|
|
707
|
+
}) => Promise<{
|
|
704
708
|
status: string;
|
|
705
709
|
name: string;
|
|
706
710
|
owner: string;
|
|
@@ -32,7 +32,7 @@ class ERPNextShipment {
|
|
|
32
32
|
methodName: "erpnext.stock.doctype.delivery_note.delivery_note.make_shipment",
|
|
33
33
|
requestMethod: "POST",
|
|
34
34
|
responseValidationModel: Shipment_1.ShipmentDraftFromDeliveryNote,
|
|
35
|
-
params:
|
|
35
|
+
params: { source_name: deliveryNoteName },
|
|
36
36
|
});
|
|
37
37
|
return draft;
|
|
38
38
|
});
|
|
@@ -27,7 +27,10 @@ class ERPNextStock {
|
|
|
27
27
|
const result = yield this.methodRequest.request({
|
|
28
28
|
methodName: "frappe.desk.query_report.background_enqueue_run",
|
|
29
29
|
requestMethod: "POST",
|
|
30
|
-
params:
|
|
30
|
+
params: {
|
|
31
|
+
report_name: "Stock Balance",
|
|
32
|
+
filters: `"from_date":"${dateString}","to_date":"${dateString}"${warehouse ? `,"warehouse":"${warehouse}"` : ""}`,
|
|
33
|
+
},
|
|
31
34
|
responseValidationModel: Stock_1.StockBalanceReportRequest,
|
|
32
35
|
});
|
|
33
36
|
const { name } = result;
|
|
@@ -68,7 +71,7 @@ class ERPNextStock {
|
|
|
68
71
|
return yield this.methodRequest.request({
|
|
69
72
|
methodName: `get_stock_from_bin`,
|
|
70
73
|
requestMethod: "GET",
|
|
71
|
-
params:
|
|
74
|
+
params: { warehouse: topLevelWarehouse },
|
|
72
75
|
});
|
|
73
76
|
});
|
|
74
77
|
}
|
|
@@ -77,7 +80,7 @@ class ERPNextStock {
|
|
|
77
80
|
return yield this.methodRequest.request({
|
|
78
81
|
methodName: `get_bundle_stock_from_bin`,
|
|
79
82
|
requestMethod: "GET",
|
|
80
|
-
params:
|
|
83
|
+
params: { warehouse: topLevelWarehouse },
|
|
81
84
|
});
|
|
82
85
|
});
|
|
83
86
|
}
|
|
@@ -86,14 +89,14 @@ class ERPNextStock {
|
|
|
86
89
|
const stock = yield this.methodRequest.request({
|
|
87
90
|
methodName: `get_stock_from_bin`,
|
|
88
91
|
requestMethod: "GET",
|
|
89
|
-
params:
|
|
92
|
+
params: { warehouse: topLevelWarehouse },
|
|
90
93
|
});
|
|
91
94
|
if (!options.includeBundleStock)
|
|
92
95
|
return stock;
|
|
93
96
|
const bundleStock = yield this.methodRequest.request({
|
|
94
97
|
methodName: `get_bundle_stock_from_bin`,
|
|
95
98
|
requestMethod: "GET",
|
|
96
|
-
params:
|
|
99
|
+
params: { warehouse: topLevelWarehouse },
|
|
97
100
|
});
|
|
98
101
|
return Object.assign(Object.assign({}, stock), bundleStock);
|
|
99
102
|
});
|
|
@@ -10,7 +10,7 @@ export declare class ERPNextMethodRequest {
|
|
|
10
10
|
inputValidationModel?: K;
|
|
11
11
|
responseValidationModel?: T;
|
|
12
12
|
isAutoWrapResponseValidationWithMessage?: boolean;
|
|
13
|
-
params?: string
|
|
13
|
+
params?: Record<string, string>;
|
|
14
14
|
priority?: number;
|
|
15
15
|
}): Promise<z.TypeOf<T>>;
|
|
16
16
|
}
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ERPNextMethodRequest = void 0;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
|
+
const utils_1 = require("../utils/utils");
|
|
14
15
|
class ERPNextMethodRequest {
|
|
15
16
|
constructor(temporalClient) {
|
|
16
17
|
this.temporalClient = temporalClient;
|
|
@@ -26,7 +27,7 @@ class ERPNextMethodRequest {
|
|
|
26
27
|
.object({ message: responseValidationModel })
|
|
27
28
|
.describe(responseValidationModel.description)
|
|
28
29
|
: responseValidationModel
|
|
29
|
-
: undefined }), (params ? { params } : {})), { body }), "erpnext", priority);
|
|
30
|
+
: undefined }), (params ? { params: (0, utils_1.paramsToString)(params) } : {})), { body }), "erpnext", priority);
|
|
30
31
|
return isAutoWrapResponseValidationWithMessage ? result.message : result;
|
|
31
32
|
});
|
|
32
33
|
}
|
|
@@ -15,7 +15,7 @@ export declare class ERPNextResourceRequest {
|
|
|
15
15
|
limit?: number;
|
|
16
16
|
priority?: number;
|
|
17
17
|
asDict?: TAsDict;
|
|
18
|
-
params?: string
|
|
18
|
+
params?: Record<string, string>;
|
|
19
19
|
}): Promise<TAsDict extends false ? Array<Array<string>> : TModel extends ZodObject<any> ? typeof fields extends undefined ? Array<Pick<z.infer<TModel>, "name">> : Array<Pick<z.infer<TModel>, TField>> : any>;
|
|
20
20
|
getById<TModel extends ZodObject<any> | undefined = undefined>({ resourceName, resourceId, resourceModel, priority, }: {
|
|
21
21
|
resourceName: string;
|
|
@@ -13,20 +13,20 @@ exports.ERPNextResourceRequest = void 0;
|
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
14
|
const zodUtils_1 = require("../utils/zodUtils");
|
|
15
15
|
const ERPNextResponse_1 = require("./model/ERPNextResponse");
|
|
16
|
+
const utils_1 = require("../utils/utils");
|
|
16
17
|
class ERPNextResourceRequest {
|
|
17
18
|
constructor(temporalClient) {
|
|
18
19
|
this.getParams = (fields, filters, asDict, params) => {
|
|
19
|
-
const fieldsParams = fields ?
|
|
20
|
+
const fieldsParams = fields ? { fields: JSON.stringify(fields) } : {};
|
|
20
21
|
const filtersParams = filters
|
|
21
|
-
?
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
].join("&")}`;
|
|
22
|
+
? {
|
|
23
|
+
filters: `[${filters
|
|
24
|
+
.map((f) => `[${f.map((fi) => `"${fi}"`)}]`)
|
|
25
|
+
.join(",")}]`,
|
|
26
|
+
}
|
|
27
|
+
: {};
|
|
28
|
+
const asDictParams = asDict === false ? { as_dict: "False" } : {};
|
|
29
|
+
const allParams = Object.assign(Object.assign(Object.assign(Object.assign({}, fieldsParams), filtersParams), asDictParams), params);
|
|
30
30
|
return allParams;
|
|
31
31
|
};
|
|
32
32
|
this.temporalClient = temporalClient;
|
|
@@ -51,12 +51,12 @@ class ERPNextResourceRequest {
|
|
|
51
51
|
})
|
|
52
52
|
.describe(`${resourceModel.description} List with fields ${JSON.stringify(erpNextFields)}`)
|
|
53
53
|
: zod_1.z.any().describe("Any response");
|
|
54
|
+
const paramsString = (0, utils_1.paramsToString)(Object.assign(Object.assign(Object.assign({}, this.getParams(fields, filters, asDict, params)), (skip ? { skip: String(skip) } : {})), { limit: String(limit !== null && limit !== void 0 ? limit : 0) }));
|
|
54
55
|
const result = yield this.temporalClient.executeERPNextRequestWorkflow(`GET-${resourceName.toLowerCase()}-List`, {
|
|
55
56
|
requestMethod: "GET",
|
|
56
57
|
resourceName,
|
|
57
58
|
responseValidationModel: schema,
|
|
58
|
-
params:
|
|
59
|
-
`${skip ? `&skip=${skip}` : ""}&limit=${limit || 0}`,
|
|
59
|
+
params: paramsString,
|
|
60
60
|
}, "erpnext", priority);
|
|
61
61
|
return result.data;
|
|
62
62
|
});
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export declare function addDays(date: string | number | Date, days: number): Dat
|
|
|
2
2
|
export declare function addMinutes(date: Date, minutes: number): Date;
|
|
3
3
|
export declare function timeout(ms: number): Promise<void>;
|
|
4
4
|
export declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
5
|
+
export declare function paramsToString(paramsObj?: Record<string, string>): string;
|
package/dist/utils/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.addDays = addDays;
|
|
|
4
4
|
exports.addMinutes = addMinutes;
|
|
5
5
|
exports.timeout = timeout;
|
|
6
6
|
exports.isDefined = isDefined;
|
|
7
|
+
exports.paramsToString = paramsToString;
|
|
7
8
|
function addDays(date, days) {
|
|
8
9
|
const result = new Date(date);
|
|
9
10
|
result.setUTCDate(result.getUTCDate() + days);
|
|
@@ -16,8 +17,19 @@ function addMinutes(date, minutes) {
|
|
|
16
17
|
}
|
|
17
18
|
// async await version of setTimeout
|
|
18
19
|
function timeout(ms) {
|
|
19
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
20
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
20
21
|
}
|
|
21
22
|
function isDefined(value) {
|
|
22
23
|
return value !== null && value !== undefined;
|
|
23
24
|
}
|
|
25
|
+
function paramsToString(paramsObj) {
|
|
26
|
+
return paramsObj
|
|
27
|
+
? `?${Object.entries(paramsObj)
|
|
28
|
+
.reduce((acc, [key, value]) => {
|
|
29
|
+
const uriComponent = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
30
|
+
acc.push(uriComponent);
|
|
31
|
+
return acc;
|
|
32
|
+
}, [])
|
|
33
|
+
.join("&")}`
|
|
34
|
+
: "";
|
|
35
|
+
}
|