erpnext-queue-client 2.4.2 → 2.4.4
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 +87 -105
- package/dist/constants.js +1 -0
- package/dist/dataConverter.js +4 -13
- package/dist/erpnext/decryptFromErpNext.server.js +1 -1
- package/dist/erpnext/decryptFromErpNext.server.test.js +2 -11
- package/dist/erpnext/doctypeResourceRequest.js +44 -37
- package/dist/erpnext/doctypeSubmittableResourceRequest.js +19 -33
- package/dist/erpnext/doctypes/address.js +40 -41
- package/dist/erpnext/doctypes/consolidatedCustomsInvoice.js +18 -20
- package/dist/erpnext/doctypes/contact.js +30 -30
- package/dist/erpnext/doctypes/deliveryNote.js +13 -12
- package/dist/erpnext/doctypes/item.d.ts +10 -10
- package/dist/erpnext/doctypes/item.js +64 -63
- package/dist/erpnext/doctypes/paymentEntry.js +42 -43
- package/dist/erpnext/doctypes/productBundle.js +15 -17
- package/dist/erpnext/doctypes/purchaseInvoice.js +45 -49
- package/dist/erpnext/doctypes/purchaseReceipt.js +41 -43
- package/dist/erpnext/doctypes/salesInvoice.js +42 -43
- package/dist/erpnext/doctypes/servicecase.js +103 -114
- package/dist/erpnext/doctypes/shipment.js +30 -35
- package/dist/erpnext/doctypes/stock.js +94 -109
- package/dist/erpnext/doctypes/tags.js +58 -77
- package/dist/erpnext/erpnextRequestWrapper.js +83 -80
- package/dist/erpnext/fileRequests.js +28 -29
- package/dist/erpnext/methodRequest.js +37 -43
- package/dist/erpnext/model/DocTypeHelpers.js +2 -3
- package/dist/erpnext/model/Item.d.ts +6 -6
- package/dist/erpnext/model/Item.js +1 -1
- package/dist/erpnext/model/PurchaseOrder.d.ts +34 -32
- package/dist/erpnext/model/PurchaseOrder.js +1 -1
- package/dist/erpnext/model/StockEntry.d.ts +63 -21
- package/dist/erpnext/model/StockEntry.js +22 -21
- package/dist/erpnext/reports.js +81 -89
- package/dist/erpnext/resourceRequest.js +142 -150
- package/dist/index.js +43 -3
- package/dist/index.test.js +69 -83
- package/dist/utils/fernet.server.js +24 -4
- package/dist/utils/request.js +59 -72
- package/dist/utils/zodContextOptionals.js +15 -6
- package/dist/utils/zodUtils.js +2 -2
- package/package.json +1 -1
|
@@ -24,27 +24,51 @@ declare const StockEntryItem: z.ZodObject<{
|
|
|
24
24
|
export type StockEntryItemType = z.infer<typeof StockEntryItem>;
|
|
25
25
|
export declare const StockEntry: z.ZodObject<{
|
|
26
26
|
external_name: z.ZodOptional<z.ZodString>;
|
|
27
|
-
naming_series: z.ZodString
|
|
27
|
+
naming_series: z.ZodString & {
|
|
28
|
+
__optionalForInput: true;
|
|
29
|
+
};
|
|
28
30
|
stock_entry_type: z.ZodString;
|
|
29
31
|
outgoing_stock_entry: z.ZodOptional<z.ZodString>;
|
|
30
|
-
purpose: z.ZodString
|
|
31
|
-
|
|
32
|
+
purpose: z.ZodString & {
|
|
33
|
+
__optionalForInput: true;
|
|
34
|
+
};
|
|
35
|
+
add_to_transit: z.ZodNumber & {
|
|
36
|
+
__optionalForInput: true;
|
|
37
|
+
};
|
|
32
38
|
work_order: z.ZodOptional<z.ZodString>;
|
|
33
39
|
purchase_order: z.ZodOptional<z.ZodString>;
|
|
34
40
|
delivery_note_no: z.ZodOptional<z.ZodString>;
|
|
35
41
|
sales_invoice_no: z.ZodOptional<z.ZodString>;
|
|
36
42
|
pick_list: z.ZodOptional<z.ZodString>;
|
|
37
43
|
purchase_receipt_no: z.ZodOptional<z.ZodString>;
|
|
38
|
-
company: z.ZodString
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
company: z.ZodString & {
|
|
45
|
+
__optionalForInput: true;
|
|
46
|
+
};
|
|
47
|
+
posting_date: z.ZodString & {
|
|
48
|
+
__optionalForInput: true;
|
|
49
|
+
};
|
|
50
|
+
posting_time: z.ZodString & {
|
|
51
|
+
__optionalForInput: true;
|
|
52
|
+
};
|
|
53
|
+
set_posting_time: z.ZodNumber & {
|
|
54
|
+
__optionalForInput: true;
|
|
55
|
+
};
|
|
56
|
+
inspection_required: z.ZodNumber & {
|
|
57
|
+
__optionalForInput: true;
|
|
58
|
+
};
|
|
59
|
+
from_bom: z.ZodNumber & {
|
|
60
|
+
__optionalForInput: true;
|
|
61
|
+
};
|
|
62
|
+
apply_putaway_rule: z.ZodNumber & {
|
|
63
|
+
__optionalForInput: true;
|
|
64
|
+
};
|
|
45
65
|
bom_no: z.ZodOptional<z.ZodString>;
|
|
46
|
-
fg_completed_qty: z.ZodNumber
|
|
47
|
-
|
|
66
|
+
fg_completed_qty: z.ZodNumber & {
|
|
67
|
+
__optionalForInput: true;
|
|
68
|
+
};
|
|
69
|
+
use_multi_level_bom: z.ZodNumber & {
|
|
70
|
+
__optionalForInput: true;
|
|
71
|
+
};
|
|
48
72
|
from_warehouse: z.ZodOptional<z.ZodString>;
|
|
49
73
|
source_warehouse_address: z.ZodOptional<z.ZodString>;
|
|
50
74
|
source_address_display: z.ZodOptional<z.ZodString>;
|
|
@@ -52,10 +76,18 @@ export declare const StockEntry: z.ZodObject<{
|
|
|
52
76
|
target_warehouse_address: z.ZodOptional<z.ZodString>;
|
|
53
77
|
target_address_display: z.ZodOptional<z.ZodString>;
|
|
54
78
|
scan_barcode: z.ZodOptional<z.ZodString>;
|
|
55
|
-
total_outgoing_value: z.ZodNumber
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
79
|
+
total_outgoing_value: z.ZodNumber & {
|
|
80
|
+
__optionalForInput: true;
|
|
81
|
+
};
|
|
82
|
+
total_incoming_value: z.ZodNumber & {
|
|
83
|
+
__optionalForInput: true;
|
|
84
|
+
};
|
|
85
|
+
value_difference: z.ZodNumber & {
|
|
86
|
+
__optionalForInput: true;
|
|
87
|
+
};
|
|
88
|
+
total_additional_costs: z.ZodNumber & {
|
|
89
|
+
__optionalForInput: true;
|
|
90
|
+
};
|
|
59
91
|
supplier: z.ZodOptional<z.ZodString>;
|
|
60
92
|
supplier_name: z.ZodOptional<z.ZodString>;
|
|
61
93
|
supplier_address: z.ZodOptional<z.ZodString>;
|
|
@@ -63,14 +95,22 @@ export declare const StockEntry: z.ZodObject<{
|
|
|
63
95
|
project: z.ZodOptional<z.ZodString>;
|
|
64
96
|
select_print_heading: z.ZodOptional<z.ZodString>;
|
|
65
97
|
letter_head: z.ZodOptional<z.ZodString>;
|
|
66
|
-
is_opening: z.ZodString
|
|
98
|
+
is_opening: z.ZodString & {
|
|
99
|
+
__optionalForInput: true;
|
|
100
|
+
};
|
|
67
101
|
remarks: z.ZodOptional<z.ZodString>;
|
|
68
|
-
per_transferred: z.ZodNumber
|
|
69
|
-
|
|
102
|
+
per_transferred: z.ZodNumber & {
|
|
103
|
+
__optionalForInput: true;
|
|
104
|
+
};
|
|
105
|
+
total_amount: z.ZodNumber & {
|
|
106
|
+
__optionalForInput: true;
|
|
107
|
+
};
|
|
70
108
|
job_card: z.ZodOptional<z.ZodString>;
|
|
71
109
|
amended_from: z.ZodOptional<z.ZodString>;
|
|
72
110
|
credit_note: z.ZodOptional<z.ZodString>;
|
|
73
|
-
is_return: z.ZodNumber
|
|
111
|
+
is_return: z.ZodNumber & {
|
|
112
|
+
__optionalForInput: true;
|
|
113
|
+
};
|
|
74
114
|
items: z.ZodArray<z.ZodObject<{
|
|
75
115
|
t_warehouse: z.ZodOptional<z.ZodString>;
|
|
76
116
|
s_warehouse: z.ZodOptional<z.ZodString>;
|
|
@@ -93,7 +133,9 @@ export declare const StockEntry: z.ZodObject<{
|
|
|
93
133
|
s_warehouse?: string | undefined;
|
|
94
134
|
basic_rate?: number | undefined;
|
|
95
135
|
}>, "many">;
|
|
96
|
-
additional_costs: z.ZodArray<z.ZodString, "many"
|
|
136
|
+
additional_costs: z.ZodArray<z.ZodString, "many"> & {
|
|
137
|
+
__optionalForInput: true;
|
|
138
|
+
};
|
|
97
139
|
}, "strip", z.ZodTypeAny, {
|
|
98
140
|
company: string;
|
|
99
141
|
naming_series: string;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StockEntry = void 0;
|
|
4
4
|
// convert from types to zod schema
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
|
+
const zodContextOptionals_1 = require("../../utils/zodContextOptionals");
|
|
6
7
|
const StockEntryItem = zod_1.z
|
|
7
8
|
.object({
|
|
8
9
|
t_warehouse: zod_1.z.string().optional(),
|
|
@@ -16,27 +17,27 @@ const StockEntryItem = zod_1.z
|
|
|
16
17
|
exports.StockEntry = zod_1.z
|
|
17
18
|
.object({
|
|
18
19
|
external_name: zod_1.z.string().optional(),
|
|
19
|
-
naming_series: zod_1.z.string(),
|
|
20
|
+
naming_series: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
20
21
|
stock_entry_type: zod_1.z.string(),
|
|
21
22
|
outgoing_stock_entry: zod_1.z.string().optional(),
|
|
22
|
-
purpose: zod_1.z.string(),
|
|
23
|
-
add_to_transit: zod_1.z.number(),
|
|
23
|
+
purpose: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
24
|
+
add_to_transit: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
24
25
|
work_order: zod_1.z.string().optional(),
|
|
25
26
|
purchase_order: zod_1.z.string().optional(),
|
|
26
27
|
delivery_note_no: zod_1.z.string().optional(),
|
|
27
28
|
sales_invoice_no: zod_1.z.string().optional(),
|
|
28
29
|
pick_list: zod_1.z.string().optional(),
|
|
29
30
|
purchase_receipt_no: zod_1.z.string().optional(),
|
|
30
|
-
company: zod_1.z.string(),
|
|
31
|
-
posting_date: zod_1.z.string(),
|
|
32
|
-
posting_time: zod_1.z.string(),
|
|
33
|
-
set_posting_time: zod_1.z.number(),
|
|
34
|
-
inspection_required: zod_1.z.number(),
|
|
35
|
-
from_bom: zod_1.z.number(),
|
|
36
|
-
apply_putaway_rule: zod_1.z.number(),
|
|
31
|
+
company: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
32
|
+
posting_date: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
33
|
+
posting_time: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
34
|
+
set_posting_time: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
35
|
+
inspection_required: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
36
|
+
from_bom: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
37
|
+
apply_putaway_rule: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
37
38
|
bom_no: zod_1.z.string().optional(),
|
|
38
|
-
fg_completed_qty: zod_1.z.number(),
|
|
39
|
-
use_multi_level_bom: zod_1.z.number(),
|
|
39
|
+
fg_completed_qty: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
40
|
+
use_multi_level_bom: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
40
41
|
from_warehouse: zod_1.z.string().optional(),
|
|
41
42
|
source_warehouse_address: zod_1.z.string().optional(),
|
|
42
43
|
source_address_display: zod_1.z.string().optional(),
|
|
@@ -44,10 +45,10 @@ exports.StockEntry = zod_1.z
|
|
|
44
45
|
target_warehouse_address: zod_1.z.string().optional(),
|
|
45
46
|
target_address_display: zod_1.z.string().optional(),
|
|
46
47
|
scan_barcode: zod_1.z.string().optional(),
|
|
47
|
-
total_outgoing_value: zod_1.z.number(),
|
|
48
|
-
total_incoming_value: zod_1.z.number(),
|
|
49
|
-
value_difference: zod_1.z.number(),
|
|
50
|
-
total_additional_costs: zod_1.z.number(),
|
|
48
|
+
total_outgoing_value: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
49
|
+
total_incoming_value: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
50
|
+
value_difference: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
51
|
+
total_additional_costs: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
51
52
|
supplier: zod_1.z.string().optional(),
|
|
52
53
|
supplier_name: zod_1.z.string().optional(),
|
|
53
54
|
supplier_address: zod_1.z.string().optional(),
|
|
@@ -55,15 +56,15 @@ exports.StockEntry = zod_1.z
|
|
|
55
56
|
project: zod_1.z.string().optional(),
|
|
56
57
|
select_print_heading: zod_1.z.string().optional(),
|
|
57
58
|
letter_head: zod_1.z.string().optional(),
|
|
58
|
-
is_opening: zod_1.z.string(),
|
|
59
|
+
is_opening: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
59
60
|
remarks: zod_1.z.string().optional(),
|
|
60
|
-
per_transferred: zod_1.z.number(),
|
|
61
|
-
total_amount: zod_1.z.number(),
|
|
61
|
+
per_transferred: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
62
|
+
total_amount: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
62
63
|
job_card: zod_1.z.string().optional(),
|
|
63
64
|
amended_from: zod_1.z.string().optional(),
|
|
64
65
|
credit_note: zod_1.z.string().optional(),
|
|
65
|
-
is_return: zod_1.z.number(),
|
|
66
|
+
is_return: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
66
67
|
items: zod_1.z.array(StockEntryItem),
|
|
67
|
-
additional_costs: zod_1.z.array(zod_1.z.string()),
|
|
68
|
+
additional_costs: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.array(zod_1.z.string())),
|
|
68
69
|
})
|
|
69
70
|
.describe("Stock Entry");
|
package/dist/erpnext/reports.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.ERPNextReports = void 0;
|
|
13
4
|
const zod_1 = require("zod");
|
|
@@ -17,98 +8,99 @@ const lodash_1 = require("lodash");
|
|
|
17
8
|
const utils_1 = require("../utils/utils");
|
|
18
9
|
const resourceRequest_1 = require("./resourceRequest");
|
|
19
10
|
class ERPNextReports extends methodRequest_1.ERPNextMethodRequest {
|
|
11
|
+
resourceRequest;
|
|
20
12
|
constructor(temporalClient) {
|
|
21
13
|
super(temporalClient);
|
|
22
14
|
this.resourceRequest = new resourceRequest_1.ERPNextResourceRequest(temporalClient);
|
|
23
15
|
}
|
|
24
|
-
enqueueReport(reportName, body) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
16
|
+
async enqueueReport(reportName, body) {
|
|
17
|
+
const result = await this.request({
|
|
18
|
+
methodName: "frappe.core.doctype.prepared_report.prepared_report.make_prepared_report",
|
|
19
|
+
requestMethod: "POST",
|
|
20
|
+
body: {
|
|
21
|
+
report_name: reportName,
|
|
22
|
+
...body,
|
|
23
|
+
},
|
|
24
|
+
responseValidationModel: Report_1.EnqueueReportResponse,
|
|
33
25
|
});
|
|
26
|
+
return result;
|
|
34
27
|
}
|
|
35
|
-
isPreparedReport(reportName) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
resourceModel: Report_1.PendingPreparedReport,
|
|
43
|
-
});
|
|
44
|
-
if (!result[0])
|
|
45
|
-
throw new Error(`Report ${reportName} not found`);
|
|
46
|
-
return result[0].prepared_report;
|
|
28
|
+
async isPreparedReport(reportName) {
|
|
29
|
+
const result = await this.resourceRequest.getList({
|
|
30
|
+
resourceName: "Report",
|
|
31
|
+
fields: ["prepared_report"],
|
|
32
|
+
filters: [["name", "=", reportName]],
|
|
33
|
+
limit: 1,
|
|
34
|
+
resourceModel: Report_1.PendingPreparedReport,
|
|
47
35
|
});
|
|
36
|
+
if (!result[0])
|
|
37
|
+
throw new Error(`Report ${reportName} not found`);
|
|
38
|
+
return result[0].prepared_report;
|
|
48
39
|
}
|
|
49
|
-
getReport(reportName, body, reportRowModel) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
40
|
+
async getReport(reportName, body, reportRowModel) {
|
|
41
|
+
if (await this.isPreparedReport(reportName)) {
|
|
42
|
+
return this.enqueueAndGetReport(reportName, body, reportRowModel);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const responseValidationModel = (0, Report_1.Report)(reportRowModel ?? zod_1.z.any());
|
|
46
|
+
const reportResponse = await this.request({
|
|
47
|
+
methodName: `frappe.desk.query_report.run`,
|
|
48
|
+
body: {
|
|
49
|
+
report_name: reportName,
|
|
50
|
+
...body,
|
|
51
|
+
},
|
|
52
|
+
requestMethod: "POST",
|
|
53
|
+
responseValidationModel,
|
|
54
|
+
});
|
|
55
|
+
return reportResponse?.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
56
|
+
}
|
|
65
57
|
}
|
|
66
|
-
getEnqueuedReport(reportName, body, enqueuedReportName, reportRowModel) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
body
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
yield (0, utils_1.timeout)(1000);
|
|
58
|
+
async getEnqueuedReport(reportName, body, enqueuedReportName, reportRowModel) {
|
|
59
|
+
for (let i = 0; i < 100; i++) {
|
|
60
|
+
const responseValidationModel = (0, Report_1.Report)(reportRowModel ?? zod_1.z.any());
|
|
61
|
+
const reportResponse = await this.request({
|
|
62
|
+
methodName: `frappe.desk.query_report.run`,
|
|
63
|
+
body: {
|
|
64
|
+
report_name: reportName,
|
|
65
|
+
...body,
|
|
66
|
+
},
|
|
67
|
+
requestMethod: "POST",
|
|
68
|
+
responseValidationModel: zod_1.z.any().describe("Any"),
|
|
69
|
+
});
|
|
70
|
+
// Casting to correct type since Typescript is not able to infer the type correctly.
|
|
71
|
+
// Type safety is ensured by zod
|
|
72
|
+
if (reportResponse?.result &&
|
|
73
|
+
reportResponse?.doc?.name === enqueuedReportName) {
|
|
74
|
+
const validatedReponse = responseValidationModel.parse(reportResponse);
|
|
75
|
+
return validatedReponse.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
}
|
|
77
|
+
await (0, utils_1.timeout)(1000);
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Failed to get report ${reportName} with body ${JSON.stringify(body)}`);
|
|
88
80
|
}
|
|
89
|
-
enqueueAndGetReport(reportName, body, reportRowModel) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
body
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
yield (0, utils_1.timeout)(1000);
|
|
81
|
+
async enqueueAndGetReport(reportName, body, reportRowModel) {
|
|
82
|
+
const result = await this.enqueueReport(reportName, body);
|
|
83
|
+
const { name } = result;
|
|
84
|
+
for (let i = 0; i < 100; i++) {
|
|
85
|
+
const responseValidationModel = (0, Report_1.Report)(reportRowModel ?? zod_1.z.any());
|
|
86
|
+
const reportResponse = await this.request({
|
|
87
|
+
methodName: `frappe.desk.query_report.run`,
|
|
88
|
+
body: {
|
|
89
|
+
report_name: reportName,
|
|
90
|
+
...body,
|
|
91
|
+
},
|
|
92
|
+
requestMethod: "POST",
|
|
93
|
+
responseValidationModel: zod_1.z.any().describe("Any"),
|
|
94
|
+
});
|
|
95
|
+
// Casting to correct type since Typescript is not able to infer the type correctly.
|
|
96
|
+
// Type safety is ensured by zod
|
|
97
|
+
if (reportResponse?.result && reportResponse?.doc?.name === name) {
|
|
98
|
+
const validatedReponse = responseValidationModel.parse(reportResponse);
|
|
99
|
+
return validatedReponse.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
109
100
|
}
|
|
110
|
-
|
|
111
|
-
}
|
|
101
|
+
await (0, utils_1.timeout)(1000);
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`Failed to get report ${reportName} with body ${JSON.stringify(body)}`);
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
exports.ERPNextReports = ERPNextReports;
|