erpnext-queue-client 2.5.0 → 2.5.2

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.
Files changed (34) hide show
  1. package/dist/client.js +1 -1
  2. package/dist/erpnext/doctypeResourceRequest.d.ts +12 -1
  3. package/dist/erpnext/doctypeResourceRequest.js +3 -3
  4. package/dist/erpnext/doctypes/address.d.ts +3 -233
  5. package/dist/erpnext/doctypes/address.js +5 -16
  6. package/dist/erpnext/doctypes/consolidatedCustomsInvoice.d.ts +3 -486
  7. package/dist/erpnext/doctypes/consolidatedCustomsInvoice.js +4 -18
  8. package/dist/erpnext/doctypes/contact.d.ts +3 -358
  9. package/dist/erpnext/doctypes/contact.js +6 -17
  10. package/dist/erpnext/doctypes/deliveryNote.d.ts +1 -1575
  11. package/dist/erpnext/doctypes/deliveryNote.js +2 -19
  12. package/dist/erpnext/doctypes/item.d.ts +1 -1019
  13. package/dist/erpnext/doctypes/item.js +3 -16
  14. package/dist/erpnext/doctypes/paymentEntry.d.ts +1 -728
  15. package/dist/erpnext/doctypes/paymentEntry.js +4 -21
  16. package/dist/erpnext/doctypes/productBundle.d.ts +1 -143
  17. package/dist/erpnext/doctypes/productBundle.js +2 -13
  18. package/dist/erpnext/doctypes/purchaseInvoice.d.ts +1 -1395
  19. package/dist/erpnext/doctypes/purchaseInvoice.js +4 -19
  20. package/dist/erpnext/doctypes/purchaseReceipt.d.ts +1 -1204
  21. package/dist/erpnext/doctypes/purchaseReceipt.js +4 -19
  22. package/dist/erpnext/doctypes/salesInvoice.d.ts +1 -2517
  23. package/dist/erpnext/doctypes/salesInvoice.js +4 -21
  24. package/dist/erpnext/doctypes/servicecase.d.ts +24 -425
  25. package/dist/erpnext/doctypes/servicecase.js +14 -15
  26. package/dist/erpnext/doctypes/shipment.d.ts +3 -760
  27. package/dist/erpnext/doctypes/shipment.js +3 -20
  28. package/dist/erpnext/item.getList.alias-parsing.test.d.ts +1 -0
  29. package/dist/erpnext/item.getList.alias-parsing.test.js +66 -0
  30. package/dist/erpnext/model/Shipment.d.ts +4 -4
  31. package/dist/erpnext/model/Shipment.js +1 -1
  32. package/dist/index.test.js +3 -2
  33. package/dist/utils/zodUtils.js +14 -6
  34. package/package.json +1 -1
@@ -5,28 +5,11 @@ const doctypeSubmittableResourceRequest_1 = require("../doctypeSubmittableResour
5
5
  const methodRequest_1 = require("../methodRequest");
6
6
  const Shipment_1 = require("../model/Shipment");
7
7
  const zodContextOptionals_1 = require("../../utils/zodContextOptionals");
8
- class ERPNextShipment {
9
- temporalClient;
10
- baseRequest;
8
+ class ERPNextShipment extends doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest {
11
9
  methodRequest;
12
- getList;
13
- getById;
14
- updateById;
15
- deleteById;
16
- create;
17
- cancel;
18
- submit;
19
10
  constructor(temporalClient) {
20
- this.temporalClient = temporalClient;
21
- this.baseRequest = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(temporalClient, "Shipment", Shipment_1.Shipment);
11
+ super(temporalClient, "Shipment", Shipment_1.Shipment);
22
12
  this.methodRequest = new methodRequest_1.ERPNextMethodRequest(temporalClient);
23
- this.getList = this.baseRequest.getList;
24
- this.getById = this.baseRequest.getById;
25
- this.updateById = this.baseRequest.updateById;
26
- this.deleteById = this.baseRequest.deleteById;
27
- this.create = this.baseRequest.create;
28
- this.cancel = this.baseRequest.cancel;
29
- this.submit = this.baseRequest.submit;
30
13
  }
31
14
  async createShipmentDraft(deliveryNoteName) {
32
15
  const draft = await this.methodRequest.request({
@@ -47,7 +30,7 @@ class ERPNextShipment {
47
30
  return shipmentInfo;
48
31
  }
49
32
  async addShippingLabelAndSubmit(shipmentErpNextName, body) {
50
- const shipment = await this.baseRequest.updateById({
33
+ const shipment = await this.updateById({
51
34
  resourceId: shipmentErpNextName,
52
35
  inputValidationModel: Shipment_1.ShipmentAddShippingLabelAndSubmitBody,
53
36
  body,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const item_1 = require("./doctypes/item");
4
+ const zod_1 = require("zod");
5
+ const zodUtils_1 = require("../utils/zodUtils");
6
+ describe("Item.getList field alias parsing", () => {
7
+ test("does not treat field names containing 'as' as aliases", async () => {
8
+ const temporalClientStub = {
9
+ executeERPNextRequestWorkflow: async (_requestName, options) => {
10
+ const { responseValidationModel } = options;
11
+ if (!responseValidationModel) {
12
+ throw new Error("Missing responseValidationModel in stub options");
13
+ }
14
+ // Intentionally omit the wrongly-selected key "undefined" that results from
15
+ // the buggy alias parsing logic in pickFromSchema.
16
+ const data = {
17
+ data: [
18
+ {
19
+ name: "ITEM-0001",
20
+ item_code: "ITEM-0001",
21
+ item_name: "Test Item",
22
+ ean: "EAN-1",
23
+ disabled: 0,
24
+ has_variants: 1,
25
+ is_purchase_item: 1,
26
+ is_stock_item: 1,
27
+ custom_product_version: "v1",
28
+ custom_supplier: "SUP-1",
29
+ },
30
+ ],
31
+ };
32
+ return (0, zodUtils_1.validateData)(data, responseValidationModel);
33
+ },
34
+ };
35
+ const itemApi = new item_1.ERPNextItem(temporalClientStub);
36
+ const fields = [
37
+ "name",
38
+ "item_code",
39
+ "item_name",
40
+ "ean",
41
+ "disabled",
42
+ "has_variants",
43
+ "is_purchase_item",
44
+ "is_stock_item",
45
+ "custom_product_version",
46
+ "custom_supplier",
47
+ ];
48
+ const result = await itemApi.getList({
49
+ fields: fields,
50
+ limit: 1,
51
+ });
52
+ expect(result).toHaveLength(1);
53
+ expect(result.at(0)?.name).toBeTypeOf("string");
54
+ expect(result.at(0)?.has_variants).toBeTypeOf("number");
55
+ expect(result.at(0)?.is_purchase_item).toBeTypeOf("number");
56
+ expect(result.at(0)?.custom_product_version).toBeTypeOf("string");
57
+ });
58
+ test("supports uppercase AS delimiter in alias expressions", () => {
59
+ const schema = zod_1.z.object({
60
+ "item_name AS item_title": zod_1.z.string(),
61
+ });
62
+ const picked = (0, zodUtils_1.pickFromSchema)(schema, ["item_name AS item_title"]);
63
+ const parsed = picked.parse({ item_title: "x" });
64
+ expect(parsed.item_title).toBe("x");
65
+ });
66
+ });
@@ -35,7 +35,7 @@ export declare const Shipment: z.ZodObject<{
35
35
  delivery_to_type: z.ZodString;
36
36
  delivery_to: z.ZodNullable<z.ZodOptional<z.ZodString>>;
37
37
  description_of_content: z.ZodString;
38
- incoterm: z.ZodString;
38
+ incoterm: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
39
  pallets: z.ZodString;
40
40
  parcel_template: z.ZodNullable<z.ZodOptional<z.ZodString>>;
41
41
  pickup_address_name: z.ZodString;
@@ -107,7 +107,6 @@ export declare const Shipment: z.ZodObject<{
107
107
  custom_export_status: z.ZodNullable<z.ZodOptional<z.ZodDefault<z.ZodEnum<["Open", "Customs Declaration in Progress", "Customs Declaration Submitted", "Customs Declaration Confirmed"]>>>>;
108
108
  }, "strip", z.ZodTypeAny, {
109
109
  status: string;
110
- incoterm: string;
111
110
  shipment_id: string;
112
111
  delivery_address_name: string;
113
112
  delivery_address: string;
@@ -143,6 +142,7 @@ export declare const Shipment: z.ZodObject<{
143
142
  tracking_status: string;
144
143
  value_of_goods: number;
145
144
  custom_delivery_country: string;
145
+ incoterm?: string | null | undefined;
146
146
  shipping_provider?: string | null | undefined;
147
147
  awb_number?: string | null | undefined;
148
148
  carrier_service?: string | null | undefined;
@@ -168,7 +168,6 @@ export declare const Shipment: z.ZodObject<{
168
168
  custom_export_status?: "Open" | "Customs Declaration in Progress" | "Customs Declaration Submitted" | "Customs Declaration Confirmed" | null | undefined;
169
169
  }, {
170
170
  status: string;
171
- incoterm: string;
172
171
  shipment_id: string;
173
172
  delivery_address_name: string;
174
173
  delivery_address: string;
@@ -204,6 +203,7 @@ export declare const Shipment: z.ZodObject<{
204
203
  tracking_status: string;
205
204
  value_of_goods: number;
206
205
  custom_delivery_country: string;
206
+ incoterm?: string | null | undefined;
207
207
  shipping_provider?: string | null | undefined;
208
208
  awb_number?: string | null | undefined;
209
209
  carrier_service?: string | null | undefined;
@@ -244,7 +244,7 @@ export declare const ShipmentAddShippingLabelAndSubmitBody: z.ZodObject<Pick<{
244
244
  delivery_to_type: z.ZodString;
245
245
  delivery_to: z.ZodNullable<z.ZodOptional<z.ZodString>>;
246
246
  description_of_content: z.ZodString;
247
- incoterm: z.ZodString;
247
+ incoterm: z.ZodOptional<z.ZodNullable<z.ZodString>>;
248
248
  pallets: z.ZodString;
249
249
  parcel_template: z.ZodNullable<z.ZodOptional<z.ZodString>>;
250
250
  pickup_address_name: z.ZodString;
@@ -59,7 +59,7 @@ exports.Shipment = zod_1.z
59
59
  delivery_to_type: zod_1.z.string(),
60
60
  delivery_to: zod_1.z.string().optional().nullable(),
61
61
  description_of_content: zod_1.z.string(),
62
- incoterm: zod_1.z.string(),
62
+ incoterm: zod_1.z.string().nullish(),
63
63
  pallets: zod_1.z.string(),
64
64
  parcel_template: zod_1.z.string().optional().nullable(),
65
65
  pickup_address_name: zod_1.z.string(),
@@ -113,8 +113,9 @@ describe.skipIf(constants_1.constants.TEMPORAL_HOST === "test")("Type tests", as
113
113
  });
114
114
  test("Item List with invalid field list", async () => {
115
115
  // don't execute, this is just for type testing statically
116
- () => erp.item.getList({
117
- // @ts-expect-error
116
+ () =>
117
+ // @ts-expect-error barcode is not a valid Item list field
118
+ erp.item.getList({
118
119
  fields: ["name", "barcode"],
119
120
  limit: 10,
120
121
  });
@@ -39,16 +39,24 @@ function validateData(data, ValidationModel, isDebug) {
39
39
  }
40
40
  function pickFromSchema(schema, keys) {
41
41
  const pickedShape = keys?.reduce((acc, key) => {
42
- if (typeof key === "string" && key.includes("as")) {
43
- const [field, alias] = key.split(" as ");
44
- if (key in schema.shape) {
45
- acc[alias] = schema.shape[key];
42
+ // ERPNext alias fields use: `<field> as <alias>` (case-insensitive).
43
+ // Don't treat substring matches like `has_variants` as aliases.
44
+ if (typeof key === "string") {
45
+ const match = key.match(/^(.*?)\s+as\s+(.*?)$/i);
46
+ if (match) {
47
+ const alias = match[2].trim();
48
+ if (key in schema.shape) {
49
+ acc[alias] = schema.shape[key];
50
+ }
51
+ return acc;
46
52
  }
53
+ // Not an alias expression, treat it as a direct field key.
54
+ if (key in schema.shape)
55
+ acc[key] = schema.shape[key];
47
56
  }
48
57
  else {
49
- if (key in schema.shape) {
58
+ if (key in schema.shape)
50
59
  acc[key] = schema.shape[key];
51
- }
52
60
  }
53
61
  return acc;
54
62
  }, {});
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "winston": "^3.15.0",
31
31
  "zod": "3.25.76"
32
32
  },
33
- "version": "2.5.0",
33
+ "version": "2.5.2",
34
34
  "devDependencies": {
35
35
  "@types/crypto-js": "^4.2.2",
36
36
  "@types/lodash": "^4.17.13",