erpnext-queue-client 2.7.8 → 2.9.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.
@@ -10,7 +10,7 @@ export declare class ERPNextDoctypeResourceRequest<TModel extends AnyZodObject>
10
10
  protected resourceModel: TModel;
11
11
  protected baseRequest: ERPNextResourceRequest;
12
12
  constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: TModel);
13
- getList<TFieldOptions extends KeysOfModel<TModel>, TSelectedFields extends readonly TFieldOptions[] | readonly ["*"] | undefined = undefined, TAsDict extends boolean | undefined = undefined>(args: {
13
+ getList<TFieldOptions extends KeysOfModel<TModel>, TSelectedFields extends readonly TFieldOptions[] | readonly ["*"] | undefined = undefined, TAsDict extends boolean | undefined = undefined, TReturnPaginationMeta extends boolean | undefined = undefined>(args: {
14
14
  fields?: TSelectedFields;
15
15
  filters?: (string | string[])[][];
16
16
  skip?: number;
@@ -18,9 +18,10 @@ export declare class ERPNextDoctypeResourceRequest<TModel extends AnyZodObject>
18
18
  priority?: number;
19
19
  asDict?: TAsDict;
20
20
  params?: Record<string, string>;
21
+ returnPaginationMeta?: TReturnPaginationMeta;
21
22
  resourceModel?: undefined;
22
- }): Promise<GetListReturnValue<TModel, TFieldOptions, TSelectedFields, TAsDict>>;
23
- getList<TOverrideModel extends AnyZodObject, TFieldOptions extends KeysOfModel<TOverrideModel>, TSelectedFields extends readonly TFieldOptions[] | readonly ["*"] | undefined = undefined, TAsDict extends boolean | undefined = undefined>(args: {
23
+ }): Promise<GetListReturnValue<TModel, TFieldOptions, TSelectedFields, TAsDict, TReturnPaginationMeta>>;
24
+ getList<TOverrideModel extends AnyZodObject, TFieldOptions extends KeysOfModel<TOverrideModel>, TSelectedFields extends readonly TFieldOptions[] | readonly ["*"] | undefined = undefined, TAsDict extends boolean | undefined = undefined, TReturnPaginationMeta extends boolean | undefined = undefined>(args: {
24
25
  fields?: TSelectedFields;
25
26
  filters?: (string | string[])[][];
26
27
  skip?: number;
@@ -29,7 +30,8 @@ export declare class ERPNextDoctypeResourceRequest<TModel extends AnyZodObject>
29
30
  priority?: number;
30
31
  asDict?: TAsDict;
31
32
  params?: Record<string, string>;
32
- }): Promise<GetListReturnValue<TOverrideModel, TFieldOptions, TSelectedFields, TAsDict>>;
33
+ returnPaginationMeta?: TReturnPaginationMeta;
34
+ }): Promise<GetListReturnValue<TOverrideModel, TFieldOptions, TSelectedFields, TAsDict, TReturnPaginationMeta>>;
33
35
  getById({ resourceId, priority, }: {
34
36
  resourceId: string;
35
37
  priority?: number;
@@ -13,7 +13,7 @@ class ERPNextDoctypeResourceRequest {
13
13
  this.resourceModel = resourceModel.describe(resourceName);
14
14
  this.baseRequest = new resourceRequest_1.ERPNextResourceRequest(this.temporalClient);
15
15
  }
16
- async getList({ fields, filters, skip, limit, resourceModel, priority = 5, asDict, params, } = {}) {
16
+ async getList({ fields, filters, skip, limit, resourceModel, priority = 5, asDict, params, returnPaginationMeta, } = {}) {
17
17
  return await this.baseRequest.getList({
18
18
  resourceName: this.resourceName,
19
19
  resourceModel: resourceModel ?? this.resourceModel,
@@ -24,6 +24,7 @@ class ERPNextDoctypeResourceRequest {
24
24
  ...(skip !== undefined ? { skip } : {}),
25
25
  ...(params !== undefined ? { params } : {}),
26
26
  ...(asDict !== undefined ? { asDict } : {}),
27
+ ...(returnPaginationMeta !== undefined ? { returnPaginationMeta } : {}),
27
28
  });
28
29
  }
29
30
  async getById({ resourceId, priority = 5, }) {
@@ -72,8 +72,8 @@ export declare class ERPNextServicecase extends ERPNextDoctypeResourceRequest<ty
72
72
  parentfield: string;
73
73
  quantity: number;
74
74
  item: string;
75
- return_fee: number;
76
75
  return_item: string;
76
+ return_fee: number;
77
77
  shipment_id: string;
78
78
  _user_tags?: string | null | undefined;
79
79
  return_label?: string | null | undefined;
@@ -85,6 +85,25 @@ export declare class ERPNextServicecase extends ERPNextDoctypeResourceRequest<ty
85
85
  complaint_date?: string | null | undefined;
86
86
  customer_message?: string | null | undefined;
87
87
  agreed_terms?: string | null | undefined;
88
+ replacement_parts?: {
89
+ status: "requested" | "approved" | "rejected";
90
+ name: string;
91
+ docstatus: number;
92
+ owner: string;
93
+ creation: string;
94
+ modified: string;
95
+ modified_by: string;
96
+ idx: number;
97
+ doctype: string;
98
+ parent: string;
99
+ parenttype: string;
100
+ parentfield: string;
101
+ quantity: number;
102
+ item: string;
103
+ return_item: string;
104
+ _user_tags?: string | null | undefined;
105
+ replacement_order_number?: string | null | undefined;
106
+ }[] | undefined;
88
107
  }>;
89
108
  updateServicecase(resourceId: string, servicecase: ServicecaseInputType, options?: {
90
109
  priority: number;
@@ -148,8 +167,8 @@ export declare class ERPNextServicecase extends ERPNextDoctypeResourceRequest<ty
148
167
  parentfield: string;
149
168
  quantity: number;
150
169
  item: string;
151
- return_fee: number;
152
170
  return_item: string;
171
+ return_fee: number;
153
172
  shipment_id: string;
154
173
  _user_tags?: string | null | undefined;
155
174
  return_label?: string | null | undefined;
@@ -161,6 +180,25 @@ export declare class ERPNextServicecase extends ERPNextDoctypeResourceRequest<ty
161
180
  complaint_date?: string | null | undefined;
162
181
  customer_message?: string | null | undefined;
163
182
  agreed_terms?: string | null | undefined;
183
+ replacement_parts?: {
184
+ status: "requested" | "approved" | "rejected";
185
+ name: string;
186
+ docstatus: number;
187
+ owner: string;
188
+ creation: string;
189
+ modified: string;
190
+ modified_by: string;
191
+ idx: number;
192
+ doctype: string;
193
+ parent: string;
194
+ parenttype: string;
195
+ parentfield: string;
196
+ quantity: number;
197
+ item: string;
198
+ return_item: string;
199
+ _user_tags?: string | null | undefined;
200
+ replacement_order_number?: string | null | undefined;
201
+ }[] | undefined;
164
202
  }>;
165
203
  getServicecasesExtended({ email, id, priority, }: {
166
204
  email?: string;
@@ -244,8 +282,8 @@ export declare class ERPNextServicecase extends ERPNextDoctypeResourceRequest<ty
244
282
  return_shipping_items: {
245
283
  quantity: number;
246
284
  item: string;
247
- return_fee: number;
248
285
  return_item: string;
286
+ return_fee: number;
249
287
  shipment_id: string;
250
288
  return_label?: string | null | undefined;
251
289
  shipping_provider?: string | null | undefined;
@@ -256,6 +294,25 @@ export declare class ERPNextServicecase extends ERPNextDoctypeResourceRequest<ty
256
294
  complaint_date?: string | null | undefined;
257
295
  customer_message?: string | null | undefined;
258
296
  agreed_terms?: string | null | undefined;
297
+ replacement_parts?: {
298
+ status: "requested" | "approved" | "rejected";
299
+ name: string;
300
+ docstatus: number;
301
+ owner: string;
302
+ creation: string;
303
+ modified: string;
304
+ modified_by: string;
305
+ idx: number;
306
+ doctype: string;
307
+ parent: string;
308
+ parenttype: string;
309
+ parentfield: string;
310
+ quantity: number;
311
+ item: string;
312
+ return_item: string;
313
+ _user_tags?: string | null | undefined;
314
+ replacement_order_number?: string | null | undefined;
315
+ }[] | undefined;
259
316
  }[]>;
260
317
  attachmentUpdate(resourceId: string, body: AttachmentCollectionType, options?: {
261
318
  priority: number;
@@ -2,6 +2,12 @@ import { AnyZodObject, z, ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawS
2
2
  import { Prettify } from "../../utils/utils";
3
3
  import { KeysOf } from "../../utils/zodUtils";
4
4
  import { DocTypeChildTableEntryMeta, DocTypeMeta, SubmittableMeta } from "./ERPNextDocTypeMeta";
5
+ type ListFilterValue = string | string[];
6
+ export type ListFilter<TValue extends ListFilterValue = ListFilterValue> = [
7
+ field: string,
8
+ operator: string,
9
+ value: TValue
10
+ ];
5
11
  export type KeysOfModel<T> = Extract<KeysOf<T extends AnyZodObject ? DocModelListEntryType<T> : never>, string>;
6
12
  /**
7
13
  * Extracts the alias from a field name if it contains " as ".
@@ -16,9 +22,19 @@ type ExtractAlias<T extends string> = T extends `${infer _Before} as ${infer Ali
16
22
  type PickWithAliases<TModel extends AnyZodObject, TFields extends readonly string[]> = {
17
23
  [K in TFields[number] as ExtractAlias<K>]: ExtractAlias<K> extends keyof z.infer<DocModelListEntryType<TModel>> ? z.infer<DocModelListEntryType<TModel>>[ExtractAlias<K>] : never;
18
24
  };
19
- export type GetListReturnValue<TModel, TFieldOptions extends string, TSelectedFields, TAsDict> = Prettify<TAsDict extends false ? Array<Array<string>> : TModel extends AnyZodObject ? TSelectedFields extends undefined ? Array<{
25
+ export type ListPaginationMeta = {
26
+ totalCount: number;
27
+ page?: number;
28
+ pageSize?: number;
29
+ };
30
+ export type GetListPaginatedReturnValue<TListData> = Prettify<{
31
+ page: TListData;
32
+ pagination: ListPaginationMeta;
33
+ }>;
34
+ type GetListData<TModel, TFieldOptions extends string, TSelectedFields, TAsDict> = Prettify<TAsDict extends false ? Array<Array<string>> : TModel extends AnyZodObject ? TSelectedFields extends undefined ? Array<{
20
35
  name: string;
21
36
  }> : TSelectedFields extends readonly ["*"] ? Array<z.infer<DocModelListEntryType<TModel>>> : TSelectedFields extends readonly TFieldOptions[] ? Array<PickWithAliases<TModel, TSelectedFields>> : any : any>;
37
+ export type GetListReturnValue<TModel, TFieldOptions extends string, TSelectedFields, TAsDict, TReturnPaginationMeta extends boolean | undefined = undefined> = TReturnPaginationMeta extends true ? GetListPaginatedReturnValue<GetListData<TModel, TFieldOptions, TSelectedFields, TAsDict>> : GetListData<TModel, TFieldOptions, TSelectedFields, TAsDict>;
22
38
  export declare const LoadDocumentWrapper: <T extends AnyZodObject>(BaseModel: T) => z.ZodObject<{
23
39
  [x: string]: any;
24
40
  } & {
@@ -59,6 +59,26 @@ export declare const InternalReasonCollection: z.ZodObject<{
59
59
  }[] | undefined;
60
60
  }>;
61
61
  export type InternalReasonCollectionType = z.infer<typeof InternalReasonCollection>;
62
+ export declare const ReplacementPart: z.ZodObject<{
63
+ item: z.ZodString;
64
+ return_item: z.ZodString;
65
+ quantity: z.ZodNumber;
66
+ status: z.ZodDefault<z.ZodEnum<["requested", "approved", "rejected"]>>;
67
+ replacement_order_number: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ status: "requested" | "approved" | "rejected";
70
+ quantity: number;
71
+ item: string;
72
+ return_item: string;
73
+ replacement_order_number?: string | null | undefined;
74
+ }, {
75
+ quantity: number;
76
+ item: string;
77
+ return_item: string;
78
+ status?: "requested" | "approved" | "rejected" | undefined;
79
+ replacement_order_number?: string | null | undefined;
80
+ }>;
81
+ export type ReplacementPartType = z.infer<typeof ReplacementPart>;
62
82
  export declare const ReturnItem: z.ZodObject<{
63
83
  item: z.ZodString;
64
84
  line_item_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -267,8 +287,8 @@ export declare const ReturnShippingItem: z.ZodObject<{
267
287
  }, "strip", z.ZodTypeAny, {
268
288
  quantity: number;
269
289
  item: string;
270
- return_fee: number;
271
290
  return_item: string;
291
+ return_fee: number;
272
292
  shipment_id: string;
273
293
  return_label?: string | null | undefined;
274
294
  shipping_provider?: string | null | undefined;
@@ -362,8 +382,8 @@ export declare const Servicecase: z.ZodObject<{
362
382
  }, "strip", z.ZodTypeAny, {
363
383
  quantity: number;
364
384
  item: string;
365
- return_fee: number;
366
385
  return_item: string;
386
+ return_fee: number;
367
387
  shipment_id: string;
368
388
  return_label?: string | null | undefined;
369
389
  shipping_provider?: string | null | undefined;
@@ -376,6 +396,25 @@ export declare const Servicecase: z.ZodObject<{
376
396
  return_label?: string | null | undefined;
377
397
  shipping_provider?: string | null | undefined;
378
398
  }>, "many">;
399
+ replacement_parts: z.ZodOptional<z.ZodArray<z.ZodObject<{
400
+ item: z.ZodString;
401
+ return_item: z.ZodString;
402
+ quantity: z.ZodNumber;
403
+ status: z.ZodDefault<z.ZodEnum<["requested", "approved", "rejected"]>>;
404
+ replacement_order_number: z.ZodNullable<z.ZodOptional<z.ZodString>>;
405
+ }, "strip", z.ZodTypeAny, {
406
+ status: "requested" | "approved" | "rejected";
407
+ quantity: number;
408
+ item: string;
409
+ return_item: string;
410
+ replacement_order_number?: string | null | undefined;
411
+ }, {
412
+ quantity: number;
413
+ item: string;
414
+ return_item: string;
415
+ status?: "requested" | "approved" | "rejected" | undefined;
416
+ replacement_order_number?: string | null | undefined;
417
+ }>, "many">>;
379
418
  }, "strip", z.ZodTypeAny, {
380
419
  status: "EDITING" | "SUBMITTED" | "COMPLETED";
381
420
  country: string;
@@ -405,8 +444,8 @@ export declare const Servicecase: z.ZodObject<{
405
444
  return_shipping_items: {
406
445
  quantity: number;
407
446
  item: string;
408
- return_fee: number;
409
447
  return_item: string;
448
+ return_fee: number;
410
449
  shipment_id: string;
411
450
  return_label?: string | null | undefined;
412
451
  shipping_provider?: string | null | undefined;
@@ -416,6 +455,13 @@ export declare const Servicecase: z.ZodObject<{
416
455
  complaint_date?: string | null | undefined;
417
456
  customer_message?: string | null | undefined;
418
457
  agreed_terms?: string | null | undefined;
458
+ replacement_parts?: {
459
+ status: "requested" | "approved" | "rejected";
460
+ quantity: number;
461
+ item: string;
462
+ return_item: string;
463
+ replacement_order_number?: string | null | undefined;
464
+ }[] | undefined;
419
465
  }, {
420
466
  country: string;
421
467
  title: string;
@@ -456,6 +502,13 @@ export declare const Servicecase: z.ZodObject<{
456
502
  customer_message?: string | null | undefined;
457
503
  agreed_terms?: string | null | undefined;
458
504
  created_with?: "Amazon FBA" | "Amazon FBM" | "Serviceportal" | "Missive Sidebar" | undefined;
505
+ replacement_parts?: {
506
+ quantity: number;
507
+ item: string;
508
+ return_item: string;
509
+ status?: "requested" | "approved" | "rejected" | undefined;
510
+ replacement_order_number?: string | null | undefined;
511
+ }[] | undefined;
459
512
  }>;
460
513
  export type ServicecaseType = z.infer<typeof Servicecase>;
461
514
  export declare const ServicecaseInput: import("../../utils/zodContextOptionals").ResourceInputType<z.ZodObject<{
@@ -545,8 +598,8 @@ export declare const ServicecaseInput: import("../../utils/zodContextOptionals")
545
598
  }, "strip", z.ZodTypeAny, {
546
599
  quantity: number;
547
600
  item: string;
548
- return_fee: number;
549
601
  return_item: string;
602
+ return_fee: number;
550
603
  shipment_id: string;
551
604
  return_label?: string | null | undefined;
552
605
  shipping_provider?: string | null | undefined;
@@ -559,6 +612,25 @@ export declare const ServicecaseInput: import("../../utils/zodContextOptionals")
559
612
  return_label?: string | null | undefined;
560
613
  shipping_provider?: string | null | undefined;
561
614
  }>, "many">>;
615
+ replacement_parts: z.ZodOptional<z.ZodArray<z.ZodObject<{
616
+ item: z.ZodString;
617
+ return_item: z.ZodString;
618
+ quantity: z.ZodNumber;
619
+ status: z.ZodDefault<z.ZodEnum<["requested", "approved", "rejected"]>>;
620
+ replacement_order_number: z.ZodNullable<z.ZodOptional<z.ZodString>>;
621
+ }, "strip", z.ZodTypeAny, {
622
+ status: "requested" | "approved" | "rejected";
623
+ quantity: number;
624
+ item: string;
625
+ return_item: string;
626
+ replacement_order_number?: string | null | undefined;
627
+ }, {
628
+ quantity: number;
629
+ item: string;
630
+ return_item: string;
631
+ status?: "requested" | "approved" | "rejected" | undefined;
632
+ replacement_order_number?: string | null | undefined;
633
+ }>, "many">>;
562
634
  }, z.UnknownKeysParam, z.ZodTypeAny, {
563
635
  status: "EDITING" | "SUBMITTED" | "COMPLETED";
564
636
  country: string;
@@ -594,12 +666,19 @@ export declare const ServicecaseInput: import("../../utils/zodContextOptionals")
594
666
  return_shipping_items?: {
595
667
  quantity: number;
596
668
  item: string;
597
- return_fee: number;
598
669
  return_item: string;
670
+ return_fee: number;
599
671
  shipment_id: string;
600
672
  return_label?: string | null | undefined;
601
673
  shipping_provider?: string | null | undefined;
602
674
  }[] | undefined;
675
+ replacement_parts?: {
676
+ status: "requested" | "approved" | "rejected";
677
+ quantity: number;
678
+ item: string;
679
+ return_item: string;
680
+ replacement_order_number?: string | null | undefined;
681
+ }[] | undefined;
603
682
  }, {
604
683
  country: string;
605
684
  title: string;
@@ -641,6 +720,13 @@ export declare const ServicecaseInput: import("../../utils/zodContextOptionals")
641
720
  return_label?: string | null | undefined;
642
721
  shipping_provider?: string | null | undefined;
643
722
  }[] | undefined;
723
+ replacement_parts?: {
724
+ quantity: number;
725
+ item: string;
726
+ return_item: string;
727
+ status?: "requested" | "approved" | "rejected" | undefined;
728
+ replacement_order_number?: string | null | undefined;
729
+ }[] | undefined;
644
730
  }>>;
645
731
  export type ServicecaseInputType = z.infer<typeof ServicecaseInput>;
646
732
  export declare const ServicecaseExtended: z.ZodObject<{
@@ -655,6 +741,65 @@ export declare const ServicecaseExtended: z.ZodObject<{
655
741
  agreed_terms: z.ZodNullable<z.ZodOptional<z.ZodString>>;
656
742
  created_with: z.ZodDefault<z.ZodEnum<["Serviceportal", "Missive Sidebar", "Amazon FBA", "Amazon FBM"]>>;
657
743
  country: z.ZodString;
744
+ replacement_parts: z.ZodOptional<z.ZodArray<z.ZodObject<{
745
+ item: z.ZodString;
746
+ return_item: z.ZodString;
747
+ quantity: z.ZodNumber;
748
+ status: z.ZodDefault<z.ZodEnum<["requested", "approved", "rejected"]>>;
749
+ replacement_order_number: z.ZodNullable<z.ZodOptional<z.ZodString>>;
750
+ } & {
751
+ name: z.ZodString;
752
+ owner: z.ZodString;
753
+ creation: z.ZodString;
754
+ modified: z.ZodString;
755
+ modified_by: z.ZodString;
756
+ idx: z.ZodNumber;
757
+ docstatus: z.ZodDefault<z.ZodNumber> & {
758
+ __optionalForInput: true;
759
+ };
760
+ doctype: z.ZodString;
761
+ _user_tags: z.ZodNullable<z.ZodOptional<z.ZodString>>;
762
+ } & {
763
+ parent: z.ZodString;
764
+ parenttype: z.ZodString;
765
+ parentfield: z.ZodString;
766
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
767
+ status: "requested" | "approved" | "rejected";
768
+ name: string;
769
+ docstatus: number;
770
+ owner: string;
771
+ creation: string;
772
+ modified: string;
773
+ modified_by: string;
774
+ idx: number;
775
+ doctype: string;
776
+ parent: string;
777
+ parenttype: string;
778
+ parentfield: string;
779
+ quantity: number;
780
+ item: string;
781
+ return_item: string;
782
+ _user_tags?: string | null | undefined;
783
+ replacement_order_number?: string | null | undefined;
784
+ }, {
785
+ name: string;
786
+ owner: string;
787
+ creation: string;
788
+ modified: string;
789
+ modified_by: string;
790
+ idx: number;
791
+ doctype: string;
792
+ parent: string;
793
+ parenttype: string;
794
+ parentfield: string;
795
+ quantity: number;
796
+ item: string;
797
+ return_item: string;
798
+ status?: "requested" | "approved" | "rejected" | undefined;
799
+ docstatus?: number | undefined;
800
+ _user_tags?: string | null | undefined;
801
+ replacement_order_number?: string | null | undefined;
802
+ }>, "many">>;
658
803
  name: z.ZodString;
659
804
  owner: z.ZodString;
660
805
  creation: z.ZodString;
@@ -764,8 +909,8 @@ export declare const ServicecaseExtended: z.ZodObject<{
764
909
  }, "strip", z.ZodTypeAny, {
765
910
  quantity: number;
766
911
  item: string;
767
- return_fee: number;
768
912
  return_item: string;
913
+ return_fee: number;
769
914
  shipment_id: string;
770
915
  return_label?: string | null | undefined;
771
916
  shipping_provider?: string | null | undefined;
@@ -858,8 +1003,8 @@ export declare const ServicecaseExtended: z.ZodObject<{
858
1003
  return_shipping_items: {
859
1004
  quantity: number;
860
1005
  item: string;
861
- return_fee: number;
862
1006
  return_item: string;
1007
+ return_fee: number;
863
1008
  shipment_id: string;
864
1009
  return_label?: string | null | undefined;
865
1010
  shipping_provider?: string | null | undefined;
@@ -870,6 +1015,25 @@ export declare const ServicecaseExtended: z.ZodObject<{
870
1015
  complaint_date?: string | null | undefined;
871
1016
  customer_message?: string | null | undefined;
872
1017
  agreed_terms?: string | null | undefined;
1018
+ replacement_parts?: {
1019
+ status: "requested" | "approved" | "rejected";
1020
+ name: string;
1021
+ docstatus: number;
1022
+ owner: string;
1023
+ creation: string;
1024
+ modified: string;
1025
+ modified_by: string;
1026
+ idx: number;
1027
+ doctype: string;
1028
+ parent: string;
1029
+ parenttype: string;
1030
+ parentfield: string;
1031
+ quantity: number;
1032
+ item: string;
1033
+ return_item: string;
1034
+ _user_tags?: string | null | undefined;
1035
+ replacement_order_number?: string | null | undefined;
1036
+ }[] | undefined;
873
1037
  }, {
874
1038
  name: string;
875
1039
  owner: string;
@@ -960,6 +1124,25 @@ export declare const ServicecaseExtended: z.ZodObject<{
960
1124
  customer_message?: string | null | undefined;
961
1125
  agreed_terms?: string | null | undefined;
962
1126
  created_with?: "Amazon FBA" | "Amazon FBM" | "Serviceportal" | "Missive Sidebar" | undefined;
1127
+ replacement_parts?: {
1128
+ name: string;
1129
+ owner: string;
1130
+ creation: string;
1131
+ modified: string;
1132
+ modified_by: string;
1133
+ idx: number;
1134
+ doctype: string;
1135
+ parent: string;
1136
+ parenttype: string;
1137
+ parentfield: string;
1138
+ quantity: number;
1139
+ item: string;
1140
+ return_item: string;
1141
+ status?: "requested" | "approved" | "rejected" | undefined;
1142
+ docstatus?: number | undefined;
1143
+ _user_tags?: string | null | undefined;
1144
+ replacement_order_number?: string | null | undefined;
1145
+ }[] | undefined;
963
1146
  }>;
964
1147
  export type ServicecaseExtendedType = z.infer<typeof ServicecaseExtended>;
965
1148
  export declare const ServicecaseMethodResponse: z.ZodArray<z.ZodObject<{
@@ -974,6 +1157,65 @@ export declare const ServicecaseMethodResponse: z.ZodArray<z.ZodObject<{
974
1157
  agreed_terms: z.ZodNullable<z.ZodOptional<z.ZodString>>;
975
1158
  created_with: z.ZodDefault<z.ZodEnum<["Serviceportal", "Missive Sidebar", "Amazon FBA", "Amazon FBM"]>>;
976
1159
  country: z.ZodString;
1160
+ replacement_parts: z.ZodOptional<z.ZodArray<z.ZodObject<{
1161
+ item: z.ZodString;
1162
+ return_item: z.ZodString;
1163
+ quantity: z.ZodNumber;
1164
+ status: z.ZodDefault<z.ZodEnum<["requested", "approved", "rejected"]>>;
1165
+ replacement_order_number: z.ZodNullable<z.ZodOptional<z.ZodString>>;
1166
+ } & {
1167
+ name: z.ZodString;
1168
+ owner: z.ZodString;
1169
+ creation: z.ZodString;
1170
+ modified: z.ZodString;
1171
+ modified_by: z.ZodString;
1172
+ idx: z.ZodNumber;
1173
+ docstatus: z.ZodDefault<z.ZodNumber> & {
1174
+ __optionalForInput: true;
1175
+ };
1176
+ doctype: z.ZodString;
1177
+ _user_tags: z.ZodNullable<z.ZodOptional<z.ZodString>>;
1178
+ } & {
1179
+ parent: z.ZodString;
1180
+ parenttype: z.ZodString;
1181
+ parentfield: z.ZodString;
1182
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
1183
+ status: "requested" | "approved" | "rejected";
1184
+ name: string;
1185
+ docstatus: number;
1186
+ owner: string;
1187
+ creation: string;
1188
+ modified: string;
1189
+ modified_by: string;
1190
+ idx: number;
1191
+ doctype: string;
1192
+ parent: string;
1193
+ parenttype: string;
1194
+ parentfield: string;
1195
+ quantity: number;
1196
+ item: string;
1197
+ return_item: string;
1198
+ _user_tags?: string | null | undefined;
1199
+ replacement_order_number?: string | null | undefined;
1200
+ }, {
1201
+ name: string;
1202
+ owner: string;
1203
+ creation: string;
1204
+ modified: string;
1205
+ modified_by: string;
1206
+ idx: number;
1207
+ doctype: string;
1208
+ parent: string;
1209
+ parenttype: string;
1210
+ parentfield: string;
1211
+ quantity: number;
1212
+ item: string;
1213
+ return_item: string;
1214
+ status?: "requested" | "approved" | "rejected" | undefined;
1215
+ docstatus?: number | undefined;
1216
+ _user_tags?: string | null | undefined;
1217
+ replacement_order_number?: string | null | undefined;
1218
+ }>, "many">>;
977
1219
  name: z.ZodString;
978
1220
  owner: z.ZodString;
979
1221
  creation: z.ZodString;
@@ -1083,8 +1325,8 @@ export declare const ServicecaseMethodResponse: z.ZodArray<z.ZodObject<{
1083
1325
  }, "strip", z.ZodTypeAny, {
1084
1326
  quantity: number;
1085
1327
  item: string;
1086
- return_fee: number;
1087
1328
  return_item: string;
1329
+ return_fee: number;
1088
1330
  shipment_id: string;
1089
1331
  return_label?: string | null | undefined;
1090
1332
  shipping_provider?: string | null | undefined;
@@ -1177,8 +1419,8 @@ export declare const ServicecaseMethodResponse: z.ZodArray<z.ZodObject<{
1177
1419
  return_shipping_items: {
1178
1420
  quantity: number;
1179
1421
  item: string;
1180
- return_fee: number;
1181
1422
  return_item: string;
1423
+ return_fee: number;
1182
1424
  shipment_id: string;
1183
1425
  return_label?: string | null | undefined;
1184
1426
  shipping_provider?: string | null | undefined;
@@ -1189,6 +1431,25 @@ export declare const ServicecaseMethodResponse: z.ZodArray<z.ZodObject<{
1189
1431
  complaint_date?: string | null | undefined;
1190
1432
  customer_message?: string | null | undefined;
1191
1433
  agreed_terms?: string | null | undefined;
1434
+ replacement_parts?: {
1435
+ status: "requested" | "approved" | "rejected";
1436
+ name: string;
1437
+ docstatus: number;
1438
+ owner: string;
1439
+ creation: string;
1440
+ modified: string;
1441
+ modified_by: string;
1442
+ idx: number;
1443
+ doctype: string;
1444
+ parent: string;
1445
+ parenttype: string;
1446
+ parentfield: string;
1447
+ quantity: number;
1448
+ item: string;
1449
+ return_item: string;
1450
+ _user_tags?: string | null | undefined;
1451
+ replacement_order_number?: string | null | undefined;
1452
+ }[] | undefined;
1192
1453
  }, {
1193
1454
  name: string;
1194
1455
  owner: string;
@@ -1279,6 +1540,25 @@ export declare const ServicecaseMethodResponse: z.ZodArray<z.ZodObject<{
1279
1540
  customer_message?: string | null | undefined;
1280
1541
  agreed_terms?: string | null | undefined;
1281
1542
  created_with?: "Amazon FBA" | "Amazon FBM" | "Serviceportal" | "Missive Sidebar" | undefined;
1543
+ replacement_parts?: {
1544
+ name: string;
1545
+ owner: string;
1546
+ creation: string;
1547
+ modified: string;
1548
+ modified_by: string;
1549
+ idx: number;
1550
+ doctype: string;
1551
+ parent: string;
1552
+ parenttype: string;
1553
+ parentfield: string;
1554
+ quantity: number;
1555
+ item: string;
1556
+ return_item: string;
1557
+ status?: "requested" | "approved" | "rejected" | undefined;
1558
+ docstatus?: number | undefined;
1559
+ _user_tags?: string | null | undefined;
1560
+ replacement_order_number?: string | null | undefined;
1561
+ }[] | undefined;
1282
1562
  }>, "many">;
1283
1563
  export type ServicecaseMethodResponseType = z.infer<typeof ServicecaseMethodResponse>;
1284
1564
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServicecaseMethodResponse = exports.ServicecaseExtended = exports.ServicecaseInput = exports.Servicecase = exports.ReturnShippingItem = exports.ReturnItemExtended = exports.ReturnItemInput = exports.ReturnItem = exports.InternalReasonCollection = exports.AttachmentCollection = void 0;
3
+ exports.ServicecaseMethodResponse = exports.ServicecaseExtended = exports.ServicecaseInput = exports.Servicecase = exports.ReturnShippingItem = exports.ReturnItemExtended = exports.ReturnItemInput = exports.ReturnItem = exports.ReplacementPart = exports.InternalReasonCollection = exports.AttachmentCollection = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const Boolean_1 = require("./Boolean");
6
6
  const DocTypeHelpers_1 = require("./DocTypeHelpers");
@@ -41,6 +41,16 @@ exports.InternalReasonCollection = zod_1.z
41
41
  internal_reasons: zod_1.z.array(InternalReasonChildTableEntry).optional(),
42
42
  })
43
43
  .describe("InternalReasonCollection");
44
+ const ReplacementPartStatus = zod_1.z.enum(["requested", "approved", "rejected"]);
45
+ exports.ReplacementPart = zod_1.z
46
+ .object({
47
+ item: zod_1.z.string(),
48
+ return_item: zod_1.z.string(),
49
+ quantity: zod_1.z.number(),
50
+ status: ReplacementPartStatus.default("requested"),
51
+ replacement_order_number: zod_1.z.string().optional().nullable(),
52
+ })
53
+ .describe("ReplacementPart");
44
54
  exports.ReturnItem = zod_1.z
45
55
  .object({
46
56
  item: zod_1.z.string(),
@@ -102,11 +112,13 @@ exports.Servicecase = zod_1.z
102
112
  country: zod_1.z.string(),
103
113
  return_items: zod_1.z.array(exports.ReturnItem),
104
114
  return_shipping_items: zod_1.z.array(exports.ReturnShippingItem),
115
+ replacement_parts: zod_1.z.array(exports.ReplacementPart).optional(),
105
116
  })
106
117
  .describe("Servicecase");
107
118
  exports.ServicecaseInput = (0, zodContextOptionals_1.ResourceInput)(exports.Servicecase.extend({
108
119
  return_items: zod_1.z.array(exports.ReturnItemInput),
109
120
  return_shipping_items: zod_1.z.array(exports.ReturnShippingItem).optional(),
121
+ replacement_parts: zod_1.z.array(exports.ReplacementPart).optional(),
110
122
  })).describe("ServicecaseInput");
111
123
  exports.ServicecaseExtended = (0, DocTypeHelpers_1.DocModel)(exports.Servicecase).extend({
112
124
  return_items: zod_1.z.array(exports.ReturnItemExtended),
@@ -10,7 +10,9 @@ export declare class ERPNextResourceRequest {
10
10
  protected temporalClient: TemporalClient;
11
11
  constructor(temporalClient: TemporalClient);
12
12
  private getParams;
13
- getList<TModel extends AnyZodObject | undefined = undefined, TFieldOptions extends GetListFieldOptions<TModel> = GetListFieldOptions<TModel>, TSelectedFields extends readonly TFieldOptions[] | readonly ["*"] | undefined = undefined, TAsDict extends boolean | undefined = undefined>({ resourceName, fields, filters, resourceModel, skip, limit, priority, asDict, params, }: {
13
+ private buildListPaginationMeta;
14
+ private getListTotalCount;
15
+ getList<TModel extends AnyZodObject | undefined = undefined, TFieldOptions extends GetListFieldOptions<TModel> = GetListFieldOptions<TModel>, TSelectedFields extends readonly TFieldOptions[] | readonly ["*"] | undefined = undefined, TAsDict extends boolean | undefined = undefined, TReturnPaginationMeta extends boolean | undefined = undefined>({ resourceName, fields, filters, resourceModel, skip, limit, priority, asDict, params, returnPaginationMeta, }: {
14
16
  resourceName: string;
15
17
  fields?: TSelectedFields;
16
18
  filters?: (string | string[])[][];
@@ -20,7 +22,8 @@ export declare class ERPNextResourceRequest {
20
22
  priority?: number;
21
23
  asDict?: TAsDict;
22
24
  params?: Record<string, string>;
23
- }): Promise<GetListReturnValue<TModel, TFieldOptions, TSelectedFields, TAsDict>>;
25
+ returnPaginationMeta?: TReturnPaginationMeta;
26
+ }): Promise<GetListReturnValue<TModel, TFieldOptions, TSelectedFields, TAsDict, TReturnPaginationMeta>>;
24
27
  getById<TModel extends AnyZodObject | undefined = undefined>({ resourceName, resourceId, resourceModel, priority, }: {
25
28
  resourceName: string;
26
29
  resourceId: string;
@@ -45,7 +45,32 @@ class ERPNextResourceRequest {
45
45
  };
46
46
  return allParams;
47
47
  };
48
- async getList({ resourceName, fields, filters, resourceModel, skip, limit, priority = 5, asDict, params, }) {
48
+ buildListPaginationMeta({ totalCount, skip, limit, }) {
49
+ const pagination = { totalCount };
50
+ if (limit !== undefined && Number.isInteger(limit) && limit > 0) {
51
+ pagination.pageSize = limit;
52
+ pagination.page = Math.floor((skip ?? 0) / limit) + 1;
53
+ }
54
+ return pagination;
55
+ }
56
+ async getListTotalCount({ resourceName, filters, priority, params, }) {
57
+ const countSchema = zod_1.z
58
+ .object({
59
+ data: zod_1.z.array(zod_1.z.object({ "count(name)": zod_1.z.number() })),
60
+ })
61
+ .describe("Count Response");
62
+ const paramsString = (0, utils_1.paramsToString)({
63
+ ...this.getParams(["count(name)"], filters, true, params),
64
+ });
65
+ const result = await this.temporalClient.executeERPNextRequestWorkflow(`GET-${resourceName}-List-count`, {
66
+ requestMethod: "GET",
67
+ resourceName,
68
+ responseValidationModel: countSchema,
69
+ params: paramsString,
70
+ }, "erpnext", priority);
71
+ return result.data[0]?.["count(name)"] ?? 0;
72
+ }
73
+ async getList({ resourceName, fields, filters, resourceModel, skip, limit, priority = 5, asDict, params, returnPaginationMeta, }) {
49
74
  const erpNextFields = fields?.length
50
75
  ? fields
51
76
  : ["name"]; // default field is name
@@ -89,7 +114,7 @@ class ERPNextResourceRequest {
89
114
  ? {}
90
115
  : { limit_start: String(skip ?? loopSkip) }),
91
116
  });
92
- const result = await this.temporalClient.executeERPNextRequestWorkflow(`GET-${resourceName.toLowerCase()}-List`, {
117
+ const result = await this.temporalClient.executeERPNextRequestWorkflow(`GET-${resourceName}-List`, {
93
118
  requestMethod: "GET",
94
119
  resourceName,
95
120
  responseValidationModel: schema,
@@ -99,7 +124,23 @@ class ERPNextResourceRequest {
99
124
  results = [...results, ...currentResult];
100
125
  loopSkip = loopSkip + loopLimit;
101
126
  } while (autoPaginate && currentResult.length);
102
- return results;
127
+ if (!returnPaginationMeta) {
128
+ return results;
129
+ }
130
+ const totalCount = await this.getListTotalCount({
131
+ resourceName,
132
+ priority,
133
+ ...(filters !== undefined ? { filters } : {}),
134
+ ...(params !== undefined ? { params } : {}),
135
+ });
136
+ return {
137
+ page: results,
138
+ pagination: this.buildListPaginationMeta({
139
+ totalCount,
140
+ ...(skip !== undefined ? { skip } : {}),
141
+ ...(limit !== undefined ? { limit } : {}),
142
+ }),
143
+ };
103
144
  }
104
145
  async getById({ resourceName, resourceId, resourceModel, priority = 5, }) {
105
146
  if (!resourceId)
@@ -29,9 +29,8 @@ describe("stringifyFiltersForParams", () => {
29
29
  test("adds context when filter serialization fails", () => {
30
30
  const cyclicFilterValue = {};
31
31
  cyclicFilterValue.self = cyclicFilterValue;
32
- const filters = [
33
- ["custom", "=", cyclicFilterValue],
34
- ];
32
+ const filters = [["custom", "=", cyclicFilterValue]];
33
+ // @ts-expect-error - we want to test the error case, filters has wrong format here
35
34
  expect(() => (0, resourceRequest_1.stringifyFiltersForParams)(filters)).toThrow("Failed to serialize ERPNext filters for query params");
36
35
  });
37
36
  test("passes typed getList filters as encoded JSON query params", async () => {
@@ -61,3 +60,91 @@ describe("stringifyFiltersForParams", () => {
61
60
  expect((0, resourceRequest_1.stringifyFiltersForParams)(undefined)).toBeUndefined();
62
61
  });
63
62
  });
63
+ describe("ERPNextResourceRequest.getList returnPaginationMeta", () => {
64
+ const createResourceRequest = (listData, totalCount, mockOptions) => {
65
+ let listRequestCount = 0;
66
+ const executeERPNextRequestWorkflow = vi
67
+ .fn()
68
+ .mockImplementation((_workflowId, requestOptions) => {
69
+ const params = new URLSearchParams(requestOptions.params.slice(1));
70
+ const fields = params.get("fields");
71
+ if (fields?.includes("count(name)")) {
72
+ return Promise.resolve({ data: [{ "count(name)": totalCount }] });
73
+ }
74
+ if (mockOptions?.paginateOnce) {
75
+ listRequestCount += 1;
76
+ return Promise.resolve({
77
+ data: listRequestCount === 1 ? listData : [],
78
+ });
79
+ }
80
+ return Promise.resolve({ data: listData });
81
+ });
82
+ return new resourceRequest_1.ERPNextResourceRequest({
83
+ executeERPNextRequestWorkflow,
84
+ });
85
+ };
86
+ test("returns a plain array by default", async () => {
87
+ const resourceRequest = createResourceRequest([{ name: "ITEM-0001" }], 42);
88
+ const result = await resourceRequest.getList({
89
+ resourceName: "Item",
90
+ fields: ["name"],
91
+ limit: 10,
92
+ skip: 0,
93
+ });
94
+ expect(result).toEqual([{ name: "ITEM-0001" }]);
95
+ });
96
+ test("wraps results with page and pagination when returnPaginationMeta is true", async () => {
97
+ const resourceRequest = createResourceRequest([{ name: "ITEM-0001" }, { name: "ITEM-0002" }], 42);
98
+ const filters = [["disabled", "=", "0"]];
99
+ const result = await resourceRequest.getList({
100
+ resourceName: "Item",
101
+ fields: ["name"],
102
+ filters,
103
+ limit: 10,
104
+ skip: 10,
105
+ returnPaginationMeta: true,
106
+ });
107
+ expect(result).toEqual({
108
+ page: [{ name: "ITEM-0001" }, { name: "ITEM-0002" }],
109
+ pagination: {
110
+ totalCount: 42,
111
+ pageSize: 10,
112
+ page: 2,
113
+ },
114
+ });
115
+ });
116
+ test("requests count(name) with the same filters as the list query", async () => {
117
+ const resourceRequest = createResourceRequest([], 7);
118
+ const filters = [["item_group", "=", "Products"]];
119
+ const executeERPNextRequestWorkflow = resourceRequest
120
+ .temporalClient.executeERPNextRequestWorkflow;
121
+ await resourceRequest.getList({
122
+ resourceName: "Item",
123
+ fields: ["name"],
124
+ filters,
125
+ limit: 5,
126
+ returnPaginationMeta: true,
127
+ });
128
+ const countCall = executeERPNextRequestWorkflow.mock.calls.find((call) => call[1].params.includes("count(name)"));
129
+ const listCall = executeERPNextRequestWorkflow.mock.calls.find((call) => !call[1].params.includes("count(name)"));
130
+ const countParams = new URLSearchParams((countCall?.[1]).params.slice(1));
131
+ const listParams = new URLSearchParams((listCall?.[1]).params.slice(1));
132
+ expect(countParams.get("fields")).toBe('["count(name)"]');
133
+ expect(countParams.get("filters")).toBe(listParams.get("filters"));
134
+ expect(JSON.parse(countParams.get("filters") ?? "")).toEqual(filters);
135
+ });
136
+ test("includes only totalCount when limit is not set", async () => {
137
+ const resourceRequest = createResourceRequest([{ name: "ITEM-0001" }], 3, {
138
+ paginateOnce: true,
139
+ });
140
+ const result = await resourceRequest.getList({
141
+ resourceName: "Item",
142
+ fields: ["name"],
143
+ returnPaginationMeta: true,
144
+ });
145
+ expect(result).toEqual({
146
+ page: [{ name: "ITEM-0001" }],
147
+ pagination: { totalCount: 3 },
148
+ });
149
+ });
150
+ });
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "winston": "^3.15.0",
30
30
  "zod": "3.25.76"
31
31
  },
32
- "version": "2.7.8",
32
+ "version": "2.9.0",
33
33
  "engines": {
34
34
  "node": ">=22"
35
35
  },