erpnext-queue-client 2.4.3 → 2.4.5
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/StockEntry.d.ts +63 -21
- package/dist/erpnext/model/StockEntry.js +22 -21
- package/dist/erpnext/model/Waitlist.d.ts +22 -6
- package/dist/erpnext/model/Waitlist.js +6 -9
- 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 +5 -3
- package/dist/utils/zodUtils.js +2 -2
- package/package.json +1 -1
|
@@ -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");
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const Waitlist: z.ZodObject<{
|
|
3
3
|
sku: z.ZodString;
|
|
4
4
|
e_mail: z.ZodString;
|
|
5
|
+
is_notified: z.ZodNumber & {
|
|
6
|
+
__optionalForInput: true;
|
|
7
|
+
};
|
|
8
|
+
requested_at: z.ZodString & {
|
|
9
|
+
__optionalForInput: true;
|
|
10
|
+
};
|
|
5
11
|
}, "strip", z.ZodTypeAny, {
|
|
6
12
|
sku: string;
|
|
7
13
|
e_mail: string;
|
|
14
|
+
is_notified: number;
|
|
15
|
+
requested_at: string;
|
|
8
16
|
}, {
|
|
9
17
|
sku: string;
|
|
10
18
|
e_mail: string;
|
|
19
|
+
is_notified: number;
|
|
20
|
+
requested_at: string;
|
|
11
21
|
}>;
|
|
12
|
-
export type
|
|
13
|
-
|
|
22
|
+
export type WaitlistType = z.infer<typeof Waitlist>;
|
|
23
|
+
/** @deprecated Use `Waitlist` instead. */
|
|
24
|
+
export declare const WaitlistInput: z.ZodObject<{
|
|
14
25
|
sku: z.ZodString;
|
|
15
26
|
e_mail: z.ZodString;
|
|
16
|
-
is_notified: z.ZodNumber
|
|
17
|
-
|
|
27
|
+
is_notified: z.ZodNumber & {
|
|
28
|
+
__optionalForInput: true;
|
|
29
|
+
};
|
|
30
|
+
requested_at: z.ZodString & {
|
|
31
|
+
__optionalForInput: true;
|
|
32
|
+
};
|
|
18
33
|
}, "strip", z.ZodTypeAny, {
|
|
19
34
|
sku: string;
|
|
20
35
|
e_mail: string;
|
|
@@ -26,4 +41,5 @@ export declare const Waitlist: z.ZodObject<{
|
|
|
26
41
|
is_notified: number;
|
|
27
42
|
requested_at: string;
|
|
28
43
|
}>;
|
|
29
|
-
|
|
44
|
+
/** @deprecated Use `WaitlistType` instead. */
|
|
45
|
+
export type WaitlistInputType = WaitlistType;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WaitlistInput = exports.Waitlist = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
|
|
6
|
-
.object({
|
|
7
|
-
sku: zod_1.z.string(),
|
|
8
|
-
e_mail: zod_1.z.string(),
|
|
9
|
-
})
|
|
10
|
-
.describe("WaitlistInput");
|
|
5
|
+
const zodContextOptionals_1 = require("../../utils/zodContextOptionals");
|
|
11
6
|
exports.Waitlist = zod_1.z
|
|
12
7
|
.object({
|
|
13
8
|
sku: zod_1.z.string(),
|
|
14
9
|
e_mail: zod_1.z.string(),
|
|
15
|
-
is_notified: zod_1.z.number(),
|
|
16
|
-
requested_at: zod_1.z.string(),
|
|
10
|
+
is_notified: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.number()),
|
|
11
|
+
requested_at: (0, zodContextOptionals_1.optionalForInput)(zod_1.z.string()),
|
|
17
12
|
})
|
|
18
13
|
.describe("Waitlist");
|
|
14
|
+
/** @deprecated Use `Waitlist` instead. */
|
|
15
|
+
exports.WaitlistInput = exports.Waitlist;
|
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;
|