erpnext-queue-client 1.5.4 → 1.7.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/dist/client.js +1 -1
- package/dist/erpnext/doctypeResourceRequest.d.ts +1 -1
- package/dist/erpnext/doctypes/address.d.ts +14 -14
- package/dist/erpnext/doctypes/contact.d.ts +26 -26
- package/dist/erpnext/doctypes/deliveryNote.d.ts +16 -16
- package/dist/erpnext/doctypes/item.d.ts +26 -26
- package/dist/erpnext/doctypes/purchaseInvoice.d.ts +34 -34
- package/dist/erpnext/doctypes/purchaseReceipt.d.ts +20 -20
- package/dist/erpnext/doctypes/shipment.d.ts +31 -31
- package/dist/erpnext/model/Account.d.ts +2 -2
- package/dist/erpnext/model/Address.d.ts +8 -8
- package/dist/erpnext/model/Contact.d.ts +20 -20
- package/dist/erpnext/model/Country.d.ts +2 -2
- package/dist/erpnext/model/Customer.d.ts +2 -2
- package/dist/erpnext/model/DeliveryNote.d.ts +12 -12
- package/dist/erpnext/model/DispatchRun.d.ts +25 -25
- package/dist/erpnext/model/DispatcherPreset.d.ts +8 -8
- package/dist/erpnext/model/File.d.ts +4 -4
- package/dist/erpnext/model/Fulfiller.d.ts +2 -2
- package/dist/erpnext/model/Item.d.ts +44 -44
- package/dist/erpnext/model/PaymentEntry.d.ts +2 -2
- package/dist/erpnext/model/ProductBundle.d.ts +6 -6
- package/dist/erpnext/model/PurchaseInvoice.d.ts +26 -26
- package/dist/erpnext/model/PurchaseOrder.d.ts +10 -10
- package/dist/erpnext/model/Receipt.d.ts +6 -6
- package/dist/erpnext/model/ReceiptDraft.d.ts +4 -4
- package/dist/erpnext/model/Shipment.d.ts +32 -32
- package/dist/erpnext/model/ShippingProvider.d.ts +2 -2
- package/dist/erpnext/model/StockEntry.d.ts +2 -2
- package/dist/erpnext/model/StockReconciliation.d.ts +2 -2
- package/dist/erpnext/model/Supplier.d.ts +6 -6
- package/dist/erpnext/resourceRequest.d.ts +1 -1
- package/dist/erpnext/resourceRequest.js +38 -14
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ const zod_1 = require("zod");
|
|
|
14
14
|
const zodUtils_1 = require("../utils/zodUtils");
|
|
15
15
|
const ERPNextResponse_1 = require("./model/ERPNextResponse");
|
|
16
16
|
const utils_1 = require("../utils/utils");
|
|
17
|
+
const logger_1 = require("../utils/logger");
|
|
17
18
|
class ERPNextResourceRequest {
|
|
18
19
|
constructor(temporalClient) {
|
|
19
20
|
this.getParams = (fields, filters, asDict, params) => {
|
|
@@ -21,7 +22,7 @@ class ERPNextResourceRequest {
|
|
|
21
22
|
const filtersParams = filters
|
|
22
23
|
? {
|
|
23
24
|
filters: `[${filters
|
|
24
|
-
.map((f) => `[${f.map((fi) => `"${fi}"`)}]`)
|
|
25
|
+
.map((f) => `[${f.map((fi) => typeof fi === "string" ? `"${fi}"` : `["${fi.join('","')}"]`)}]`)
|
|
25
26
|
.join(",")}]`,
|
|
26
27
|
}
|
|
27
28
|
: {};
|
|
@@ -45,20 +46,43 @@ class ERPNextResourceRequest {
|
|
|
45
46
|
? (resourceModel === null || resourceModel === void 0 ? void 0 : resourceModel.description) + " "
|
|
46
47
|
: ""}List with fields ${JSON.stringify(erpNextFields)} as dict = false`)
|
|
47
48
|
: resourceModel
|
|
48
|
-
?
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
? (fields === null || fields === void 0 ? void 0 : fields[0]) === "*"
|
|
50
|
+
? zod_1.z
|
|
51
|
+
.object({ data: zod_1.z.array(resourceModel.omit({ doctype: true })) })
|
|
52
|
+
.describe(`${resourceModel.description} List`)
|
|
53
|
+
: zod_1.z
|
|
54
|
+
.object({
|
|
55
|
+
data: zod_1.z.array((0, zodUtils_1.pickFromSchema)(resourceModel, erpNextFields)),
|
|
56
|
+
})
|
|
57
|
+
.describe(`${resourceModel.description} List with fields ${JSON.stringify(erpNextFields)}`)
|
|
53
58
|
: zod_1.z.any().describe("Any response");
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const defaultPaginationSize = 500;
|
|
60
|
+
let loopLimit = defaultPaginationSize;
|
|
61
|
+
let loopSkip = 0;
|
|
62
|
+
let results = [];
|
|
63
|
+
let currentResult = [];
|
|
64
|
+
// when skip or limit are defined, don't loop automatically.
|
|
65
|
+
const autoPaginate = skip || limit ? false : true;
|
|
66
|
+
if (autoPaginate)
|
|
67
|
+
logger_1.lg.info("AUTO PAGINATE");
|
|
68
|
+
do {
|
|
69
|
+
// use limit & skip whenever it is directly provided. In other cases use loopLimit & loopSkip to remove pagination
|
|
70
|
+
const paramsString = (0, utils_1.paramsToString)(Object.assign(Object.assign(Object.assign({}, this.getParams(fields, filters, asDict, params)), (limit === undefined && !autoPaginate
|
|
71
|
+
? {}
|
|
72
|
+
: { limit: String(limit !== null && limit !== void 0 ? limit : loopLimit) })), (skip === undefined && !autoPaginate
|
|
73
|
+
? {}
|
|
74
|
+
: { limit_start: String(skip !== null && skip !== void 0 ? skip : loopSkip) })));
|
|
75
|
+
const result = yield this.temporalClient.executeERPNextRequestWorkflow(`GET-${resourceName.toLowerCase()}-List`, {
|
|
76
|
+
requestMethod: "GET",
|
|
77
|
+
resourceName,
|
|
78
|
+
responseValidationModel: schema,
|
|
79
|
+
params: paramsString,
|
|
80
|
+
}, "erpnext", priority);
|
|
81
|
+
currentResult = result.data;
|
|
82
|
+
results = [...results, ...currentResult];
|
|
83
|
+
loopSkip = loopSkip + loopLimit;
|
|
84
|
+
} while (autoPaginate && currentResult.length);
|
|
85
|
+
return results;
|
|
62
86
|
});
|
|
63
87
|
}
|
|
64
88
|
getById(_a) {
|