erpnext-queue-client 1.6.0 → 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.
@@ -11,7 +11,7 @@ export declare class ERPNextDoctypeResourceRequest<TModel extends ZodObject<any>
11
11
  constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: TModel);
12
12
  getList<TField extends KeysOf<TModel>, TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
13
13
  fields?: TField[] | undefined;
14
- filters?: string[][];
14
+ filters?: (string | string[])[][];
15
15
  skip?: number;
16
16
  limit?: number;
17
17
  priority?: number;
@@ -9,7 +9,7 @@ export declare class ERPNextAddress {
9
9
  protected methodRequest: ERPNextMethodRequest;
10
10
  getList: <TField extends ("name" | "doctype" | "address_title" | "address_line1" | "address_type" | "city" | "pincode" | "country" | "is_shipping_address" | "links" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "is_primary_address" | "is_your_company_address" | "disabled") | ("address_line2" | "email_id" | "parent" | "parentfield" | "parenttype" | "import_reference" | "state" | "phone" | "fax" | "tax_category" | "county"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
11
11
  fields?: TField[] | undefined;
12
- filters?: string[][];
12
+ filters?: (string | string[])[][];
13
13
  skip?: number;
14
14
  limit?: number;
15
15
  priority?: number;
@@ -6,7 +6,7 @@ export declare class ERPNextContact {
6
6
  protected baseRequest: ERPNextDoctypeResourceRequest<typeof Contact>;
7
7
  getList: <TField extends ("name" | "doctype" | "email_id" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "first_name" | "email_ids" | "sync_with_google_contacts" | "pulled_from_google_contacts" | "is_primary_contact" | "is_billing_contact" | "unsubscribed") | ("status" | "links" | "phone" | "image" | "company" | "last_name" | "middle_name" | "mobile_no" | "phone_nos"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
8
8
  fields?: TField[] | undefined;
9
- filters?: string[][];
9
+ filters?: (string | string[])[][];
10
10
  skip?: number;
11
11
  limit?: number;
12
12
  priority?: number;
@@ -391,7 +391,7 @@ export declare class ERPNextDeliveryNote {
391
391
  }>;
392
392
  getList: <TField extends ("status" | "name" | "doctype" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "tax_category" | "company" | "naming_series" | "language" | "customer" | "items" | "discount_amount" | "pricing_rules" | "title" | "customer_name" | "posting_date" | "posting_time" | "set_posting_time" | "is_return" | "issue_credit_note" | "po_no" | "currency" | "conversion_rate" | "selling_price_list" | "price_list_currency" | "plc_conversion_rate" | "ignore_pricing_rule" | "total_qty" | "base_total" | "base_net_total" | "total_net_weight" | "total" | "net_total" | "base_total_taxes_and_charges" | "total_taxes_and_charges" | "apply_discount_on" | "base_discount_amount" | "additional_discount_percentage" | "base_grand_total" | "base_rounding_adjustment" | "base_rounded_total" | "base_in_words" | "grand_total" | "rounding_adjustment" | "rounded_total" | "in_words" | "disable_rounded_total" | "is_internal_customer" | "per_billed" | "customer_group" | "territory" | "print_without_amount" | "group_same_items" | "per_installed" | "installation_status" | "per_returned" | "amount_eligible_for_commission" | "commission_rate" | "total_commission" | "packed_items" | "taxes" | "sales_team") | ("parent" | "parentfield" | "parenttype" | "cost_center" | "project" | "amended_from" | "return_against" | "po_date" | "pick_list" | "shipping_address_name" | "shipping_address" | "dispatch_address_name" | "dispatch_address" | "contact_person" | "contact_display" | "contact_mobile" | "contact_email" | "customer_address" | "tax_id" | "address_display" | "company_address" | "company_address_display" | "set_warehouse" | "set_target_warehouse" | "scan_barcode" | "shipping_rule" | "taxes_and_charges" | "other_charges_calculation" | "tc_name" | "terms" | "transporter" | "driver" | "lr_no" | "vehicle_no" | "transporter_name" | "driver_name" | "lr_date" | "campaign" | "source" | "represents_company" | "inter_company_reference" | "letter_head" | "select_print_heading" | "excise_page" | "instructions" | "auto_repeat" | "sales_partner" | "dispatch_run"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
393
393
  fields?: TField[] | undefined;
394
- filters?: string[][];
394
+ filters?: (string | string[])[][];
395
395
  skip?: number;
396
396
  limit?: number;
397
397
  priority?: number;
@@ -10,7 +10,7 @@ export declare class ERPNextItem {
10
10
  protected methodRequest: ERPNextMethodRequest;
11
11
  getList: <TField extends ("description" | "name" | "doctype" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "disabled" | "naming_series" | "item_code" | "item_name" | "item_group" | "stock_uom" | "grant_commission" | "weight_per_unit" | "weight_uom" | "taxes" | "override_base_name" | "sync_from_warehouse" | "allow_alternative_item" | "is_stock_item" | "include_item_in_manufacturing" | "opening_stock" | "valuation_rate" | "standard_rate" | "is_fixed_asset" | "auto_create_assets" | "over_delivery_receipt_allowance" | "over_billing_allowance" | "custom_is_shipping_enabled" | "shipping_dimensions_unit" | "packaging_weight_unit_cardboard" | "packaging_weight_unit_plastic" | "shelf_life_in_days" | "end_of_life" | "default_material_request_type" | "valuation_method" | "product_weight" | "product_weight_unit" | "has_batch_no" | "create_new_batch" | "has_expiry_date" | "retain_sample" | "sample_quantity" | "has_serial_no" | "has_variants" | "variant_based_on" | "is_purchase_item" | "min_order_qty" | "safety_stock" | "lead_time_days" | "last_purchase_rate" | "is_customer_provided_item" | "delivered_by_supplier" | "sales_uom" | "is_sales_item" | "max_discount" | "enable_deferred_revenue" | "no_of_months" | "enable_deferred_expense" | "no_of_months_exp" | "inspection_required_before_purchase" | "inspection_required_before_delivery" | "is_sub_contracted_item" | "customer_code" | "total_projected_qty" | "barcodes" | "reorder_levels" | "uoms" | "attributes" | "item_defaults" | "supplier_items" | "customer_items") | ("image" | "warehouse_category" | "ean" | "shipping_template" | "shipping_width" | "shipping_length" | "shipping_height" | "packaging_weight_cardboard" | "packaging_weight_plastic" | "custom_product_version" | "custom_supplier" | "custom_stock_reserve"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
12
12
  fields?: TField[] | undefined;
13
- filters?: string[][];
13
+ filters?: (string | string[])[][];
14
14
  skip?: number;
15
15
  limit?: number;
16
16
  priority?: number;
@@ -8,7 +8,7 @@ export declare class ERPNextPurchaseInvoice {
8
8
  protected methodRequest: ERPNextMethodRequest;
9
9
  getList: <TField extends ("name" | "owner" | "idx" | "docstatus" | "taxes" | "payment_schedule") | ("status" | "doctype" | "tax_category" | "__onload" | "company" | "naming_series" | "supplier_name" | "is_internal_supplier" | "on_hold" | "language" | "items" | "discount_amount" | "pricing_rules" | "__unsaved" | "posting_date" | "posting_time" | "set_posting_time" | "is_return" | "shipping_address" | "currency" | "conversion_rate" | "price_list_currency" | "plc_conversion_rate" | "ignore_pricing_rule" | "total_qty" | "base_total" | "base_net_total" | "total_net_weight" | "total" | "net_total" | "other_charges_calculation" | "base_total_taxes_and_charges" | "total_taxes_and_charges" | "apply_discount_on" | "base_discount_amount" | "additional_discount_percentage" | "base_grand_total" | "base_rounding_adjustment" | "base_rounded_total" | "base_in_words" | "grand_total" | "rounding_adjustment" | "rounded_total" | "in_words" | "disable_rounded_total" | "group_same_items" | "supplier" | "due_date" | "paid_amount" | "__islocal" | "bill_id" | "is_paid" | "apply_tds" | "bill_no" | "shipping_address_display" | "billing_address" | "billing_address_display" | "buying_price_list" | "is_subcontracted" | "update_stock" | "base_taxes_and_charges_added" | "base_taxes_and_charges_deducted" | "taxes_and_charges_added" | "taxes_and_charges_deducted" | "total_advance" | "outstanding_amount" | "base_paid_amount" | "write_off_amount" | "base_write_off_amount" | "allocate_advances_automatically" | "payment_terms_template" | "ignore_default_payment_terms_template" | "credit_to" | "party_account_currency" | "is_opening" | "per_received" | "supplied_items" | "advances" | "advance_tax" | "remarks"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
10
10
  fields?: TField[] | undefined;
11
- filters?: string[][];
11
+ filters?: (string | string[])[][];
12
12
  skip?: number;
13
13
  limit?: number;
14
14
  priority?: number;
@@ -8,7 +8,7 @@ export declare class ERPNextPurchaseReceipt {
8
8
  protected methodRequest: ERPNextMethodRequest;
9
9
  getList: <TField extends ("status" | "name" | "doctype" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "company" | "naming_series" | "items" | "pricing_rules" | "posting_date" | "posting_time" | "set_posting_time" | "currency" | "conversion_rate" | "base_net_total" | "taxes" | "supplier" | "is_subcontracted" | "supplied_items") | ("parent" | "parentfield" | "parenttype" | "tax_category" | "__onload" | "supplier_name" | "is_internal_supplier" | "language" | "discount_amount" | "cost_center" | "project" | "title" | "amended_from" | "is_return" | "return_against" | "shipping_address" | "contact_person" | "contact_display" | "contact_mobile" | "contact_email" | "address_display" | "price_list_currency" | "plc_conversion_rate" | "ignore_pricing_rule" | "set_warehouse" | "scan_barcode" | "total_qty" | "base_total" | "total_net_weight" | "total" | "net_total" | "shipping_rule" | "taxes_and_charges" | "other_charges_calculation" | "base_total_taxes_and_charges" | "total_taxes_and_charges" | "apply_discount_on" | "base_discount_amount" | "additional_discount_percentage" | "base_grand_total" | "base_rounding_adjustment" | "base_rounded_total" | "base_in_words" | "grand_total" | "rounding_adjustment" | "rounded_total" | "in_words" | "disable_rounded_total" | "tc_name" | "terms" | "lr_no" | "transporter_name" | "lr_date" | "represents_company" | "inter_company_reference" | "per_billed" | "letter_head" | "select_print_heading" | "group_same_items" | "per_returned" | "instructions" | "auto_repeat" | "shipping_address_display" | "billing_address" | "billing_address_display" | "buying_price_list" | "base_taxes_and_charges_added" | "base_taxes_and_charges_deducted" | "taxes_and_charges_added" | "taxes_and_charges_deducted" | "remarks" | "rejected_warehouse" | "purchase_receipt_number" | "supplier_delivery_note" | "notes" | "apply_putaway_rule" | "supplier_address" | "set_from_warehouse" | "supplier_warehouse" | "range"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
10
10
  fields?: TField[] | undefined;
11
- filters?: string[][];
11
+ filters?: (string | string[])[][];
12
12
  skip?: number;
13
13
  limit?: number;
14
14
  priority?: number;
@@ -8,7 +8,7 @@ export declare class ERPNextShipment {
8
8
  protected methodRequest: ERPNextMethodRequest;
9
9
  getList: <TField extends ("status" | "name" | "doctype" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "delivery_address_name" | "delivery_address" | "delivery_customer" | "delivery_to_type" | "incoterm" | "pallets" | "pickup_address_name" | "pickup_address" | "pickup_company" | "pickup_contact_email" | "pickup_contact_person" | "pickup_contact" | "pickup_from_type" | "pickup_from" | "pickup_to" | "pickup_type" | "shipment_amount" | "shipment_delivery_note" | "shipment_parcel" | "shipment_type" | "tracking_status" | "value_of_goods" | "description_of_content" | "pickup_date" | "shipment_id") | ("parent" | "parentfield" | "parenttype" | "__onload" | "amended_from" | "delivery_contact" | "awb_number" | "carrier_service" | "carrier" | "delivery_company" | "delivery_contact_email" | "delivery_contact_name" | "delivery_supplier" | "delivery_to" | "parcel_template" | "pickup_contact_name" | "pickup_customer" | "pickup_supplier" | "pickup" | "service_provider" | "shipping_label" | "shipping_provider" | "custom_return_label" | "custom_return_shipping_provider" | "tracking_status_info" | "tracking_url"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }?: {
10
10
  fields?: TField[] | undefined;
11
- filters?: string[][];
11
+ filters?: (string | string[])[][];
12
12
  skip?: number;
13
13
  limit?: number;
14
14
  priority?: number;
@@ -9,7 +9,7 @@ export declare class ERPNextResourceRequest {
9
9
  getList<TField extends KeysOf<TModel>, TModel extends ZodObject<any> | undefined = undefined, TAsDict extends boolean | undefined = undefined>({ resourceName, fields, filters, resourceModel, skip, limit, priority, asDict, params, }: {
10
10
  resourceName: string;
11
11
  fields?: TField[] | undefined;
12
- filters?: string[][];
12
+ filters?: (string | string[])[][];
13
13
  resourceModel?: TModel | undefined;
14
14
  skip?: number;
15
15
  limit?: number;
@@ -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
  : {};
@@ -55,14 +56,33 @@ class ERPNextResourceRequest {
55
56
  })
56
57
  .describe(`${resourceModel.description} List with fields ${JSON.stringify(erpNextFields)}`)
57
58
  : zod_1.z.any().describe("Any response");
58
- 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) }));
59
- const result = yield this.temporalClient.executeERPNextRequestWorkflow(`GET-${resourceName.toLowerCase()}-List`, {
60
- requestMethod: "GET",
61
- resourceName,
62
- responseValidationModel: schema,
63
- params: paramsString,
64
- }, "erpnext", priority);
65
- return result.data;
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;
66
86
  });
67
87
  }
68
88
  getById(_a) {
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "winston": "^3.15.0",
25
25
  "zod": "3.24.1"
26
26
  },
27
- "version": "1.6.0",
27
+ "version": "1.7.0",
28
28
  "devDependencies": {
29
29
  "@types/crypto-js": "^4.2.2",
30
30
  "@types/lodash": "^4.17.13",