erpnext-queue-client 1.38.0 → 2.0.0-beta.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.
Files changed (133) hide show
  1. package/dist/client.js +2 -2
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/constants.js +16 -2
  4. package/dist/erpnext/doctypeResourceRequest.d.ts +12 -11
  5. package/dist/erpnext/doctypeResourceRequest.js +3 -2
  6. package/dist/erpnext/doctypeSubmittableResourceRequest.d.ts +121 -4
  7. package/dist/erpnext/doctypeSubmittableResourceRequest.js +14 -1
  8. package/dist/erpnext/doctypes/address.d.ts +154 -219
  9. package/dist/erpnext/doctypes/address.js +0 -2
  10. package/dist/erpnext/doctypes/contact.d.ts +151 -308
  11. package/dist/erpnext/doctypes/contact.js +1 -1
  12. package/dist/erpnext/doctypes/deliveryNote.d.ts +644 -455
  13. package/dist/erpnext/doctypes/deliveryNote.js +4 -10
  14. package/dist/erpnext/doctypes/item.d.ts +215 -308
  15. package/dist/erpnext/doctypes/productBundle.d.ts +43 -53
  16. package/dist/erpnext/doctypes/purchaseInvoice.d.ts +669 -697
  17. package/dist/erpnext/doctypes/purchaseReceipt.d.ts +265 -314
  18. package/dist/erpnext/doctypes/salesInvoice.d.ts +3332 -0
  19. package/dist/erpnext/doctypes/salesInvoice.js +72 -0
  20. package/dist/erpnext/doctypes/servicecase.d.ts +197 -140
  21. package/dist/erpnext/doctypes/servicecase.js +4 -6
  22. package/dist/erpnext/doctypes/shipment.d.ts +168 -258
  23. package/dist/erpnext/doctypes/tags.d.ts +10 -0
  24. package/dist/erpnext/doctypes/tags.js +102 -0
  25. package/dist/erpnext/model/Account.d.ts +0 -33
  26. package/dist/erpnext/model/Account.js +0 -11
  27. package/dist/erpnext/model/Address.d.ts +112 -233
  28. package/dist/erpnext/model/Address.js +11 -49
  29. package/dist/erpnext/model/Attachment.d.ts +0 -3
  30. package/dist/erpnext/model/Attachment.js +0 -1
  31. package/dist/erpnext/model/Boolean.d.ts +4 -0
  32. package/dist/erpnext/model/Boolean.js +9 -0
  33. package/dist/erpnext/model/Compliance.d.ts +0 -112
  34. package/dist/erpnext/model/Compliance.js +0 -19
  35. package/dist/erpnext/model/Contact.d.ts +166 -416
  36. package/dist/erpnext/model/Contact.js +16 -69
  37. package/dist/erpnext/model/Country.d.ts +0 -64
  38. package/dist/erpnext/model/Country.js +0 -10
  39. package/dist/erpnext/model/Customer.d.ts +39 -64
  40. package/dist/erpnext/model/Customer.js +11 -25
  41. package/dist/erpnext/model/DeliveryNote.d.ts +124 -1170
  42. package/dist/erpnext/model/DeliveryNote.js +5 -52
  43. package/dist/erpnext/model/DispatchRun.d.ts +7 -113
  44. package/dist/erpnext/model/DispatchRun.js +2 -31
  45. package/dist/erpnext/model/DispatcherPreset.d.ts +0 -119
  46. package/dist/erpnext/model/DispatcherPreset.js +1 -27
  47. package/dist/erpnext/model/DocInfo.d.ts +41 -339
  48. package/dist/erpnext/model/DocInfo.js +5 -6
  49. package/dist/erpnext/model/DocTypeHelpers.d.ts +141 -2
  50. package/dist/erpnext/model/DocTypeHelpers.js +132 -1
  51. package/dist/erpnext/model/ERPNextDocTypeMeta.d.ts +124 -0
  52. package/dist/erpnext/model/ERPNextDocTypeMeta.js +37 -0
  53. package/dist/erpnext/model/ERPNextRequest.d.ts +5 -5
  54. package/dist/erpnext/model/File.d.ts +0 -48
  55. package/dist/erpnext/model/File.js +0 -8
  56. package/dist/erpnext/model/Fulfiller.d.ts +0 -121
  57. package/dist/erpnext/model/Fulfiller.js +1 -56
  58. package/dist/erpnext/model/FulfillerSettings.d.ts +0 -39
  59. package/dist/erpnext/model/FulfillerSettings.js +0 -6
  60. package/dist/erpnext/model/InternalReasons.d.ts +0 -3
  61. package/dist/erpnext/model/InternalReasons.js +0 -1
  62. package/dist/erpnext/model/Item.d.ts +478 -1847
  63. package/dist/erpnext/model/Item.js +18 -142
  64. package/dist/erpnext/model/Logs.d.ts +0 -9
  65. package/dist/erpnext/model/Logs.js +0 -3
  66. package/dist/erpnext/model/PartList.d.ts +0 -15
  67. package/dist/erpnext/model/PartList.js +0 -5
  68. package/dist/erpnext/model/PaymentEntry.d.ts +141 -128
  69. package/dist/erpnext/model/PaymentEntry.js +46 -47
  70. package/dist/erpnext/model/Permissions.d.ts +3 -3
  71. package/dist/erpnext/model/Permissions.js +1 -1
  72. package/dist/erpnext/model/ProductBundle.d.ts +6 -107
  73. package/dist/erpnext/model/ProductBundle.js +0 -17
  74. package/dist/erpnext/model/PurchaseInvoice.d.ts +290 -362
  75. package/dist/erpnext/model/PurchaseInvoice.js +5 -23
  76. package/dist/erpnext/model/PurchaseOrder.d.ts +34 -180
  77. package/dist/erpnext/model/PurchaseOrder.js +0 -34
  78. package/dist/erpnext/model/Receipt.d.ts +30 -121
  79. package/dist/erpnext/model/Receipt.js +2 -25
  80. package/dist/erpnext/model/ReceiptDraft.d.ts +28 -67
  81. package/dist/erpnext/model/ReceiptDraft.js +2 -11
  82. package/dist/erpnext/model/Report.d.ts +0 -40
  83. package/dist/erpnext/model/Report.js +0 -8
  84. package/dist/erpnext/model/SalesInvoice.d.ts +2441 -0
  85. package/dist/erpnext/model/SalesInvoice.js +326 -0
  86. package/dist/erpnext/model/SalesOrder.d.ts +1043 -0
  87. package/dist/erpnext/model/SalesOrder.js +271 -0
  88. package/dist/erpnext/model/SalesTaxesAndCharges.d.ts +47 -0
  89. package/dist/erpnext/model/SalesTaxesAndCharges.js +30 -0
  90. package/dist/erpnext/model/Servicecase.d.ts +295 -740
  91. package/dist/erpnext/model/Servicecase.js +31 -116
  92. package/dist/erpnext/model/ServicecaseReason.d.ts +0 -8
  93. package/dist/erpnext/model/ServicecaseReason.js +0 -2
  94. package/dist/erpnext/model/ServicecaseSolution.d.ts +0 -3
  95. package/dist/erpnext/model/ServicecaseSolution.js +0 -1
  96. package/dist/erpnext/model/ServiceportalProductConfiguration.d.ts +0 -575
  97. package/dist/erpnext/model/ServiceportalProductConfiguration.js +5 -50
  98. package/dist/erpnext/model/Shipment.d.ts +18 -729
  99. package/dist/erpnext/model/Shipment.js +1 -82
  100. package/dist/erpnext/model/ShippingLabel.d.ts +0 -32
  101. package/dist/erpnext/model/ShippingLabel.js +0 -8
  102. package/dist/erpnext/model/ShippingProvider.d.ts +6 -87
  103. package/dist/erpnext/model/ShippingProvider.js +3 -6
  104. package/dist/erpnext/model/Stock.d.ts +6 -46
  105. package/dist/erpnext/model/Stock.js +0 -8
  106. package/dist/erpnext/model/StockEntry.d.ts +12 -45
  107. package/dist/erpnext/model/StockEntry.js +0 -11
  108. package/dist/erpnext/model/StockReconciliation.d.ts +5 -32
  109. package/dist/erpnext/model/StockReconciliation.js +0 -10
  110. package/dist/erpnext/model/Supplier.d.ts +0 -79
  111. package/dist/erpnext/model/Supplier.js +0 -8
  112. package/dist/erpnext/model/Version.d.ts +0 -9
  113. package/dist/erpnext/model/Version.js +0 -3
  114. package/dist/erpnext/model/Waitlist.d.ts +0 -3
  115. package/dist/erpnext/model/Waitlist.js +0 -1
  116. package/dist/erpnext/model/WarehouseCategory.d.ts +0 -11
  117. package/dist/erpnext/model/WarehouseCategory.js +1 -7
  118. package/dist/erpnext/reports.js +3 -7
  119. package/dist/erpnext/resourceRequest.d.ts +13 -11
  120. package/dist/erpnext/resourceRequest.js +23 -18
  121. package/dist/index.d.ts +16 -10
  122. package/dist/index.js +24 -12
  123. package/dist/index.test.d.ts +1 -0
  124. package/dist/index.test.js +227 -0
  125. package/dist/utils/utils.d.ts +3 -0
  126. package/dist/utils/zodContextOptionals.d.ts +14 -0
  127. package/dist/utils/zodContextOptionals.js +42 -0
  128. package/dist/utils/zodUtils.js +2 -1
  129. package/package.json +2 -2
  130. package/dist/erpnext/model/ConsolidatedCustomsInvoice.d.ts +0 -433
  131. package/dist/erpnext/model/ConsolidatedCustomsInvoice.js +0 -102
  132. package/dist/erpnext/model/ShippingFees.d.ts +0 -36
  133. package/dist/erpnext/model/ShippingFees.js +0 -18
@@ -7,17 +7,16 @@ const Logs_1 = require("./Logs");
7
7
  const Version_1 = require("./Version");
8
8
  const Attachment_1 = require("./Attachment");
9
9
  const Permissions_1 = require("./Permissions");
10
+ const DocTypeHelpers_1 = require("./DocTypeHelpers");
10
11
  const DocInfo = zod_1.z
11
12
  .object({
12
- doctype: zod_1.z.string(),
13
- name: zod_1.z.string(),
14
13
  user_info: zod_1.z.record(zod_1.z.string(), User_1.UserInfo),
15
14
  attachments: zod_1.z.array(Attachment_1.Attachment),
16
15
  attachment_logs: zod_1.z.array(Logs_1.LogEntry).optional().nullable(),
17
16
  communications: zod_1.z.array(zod_1.z.unknown()),
18
17
  automated_messages: zod_1.z.array(zod_1.z.unknown()),
19
18
  comments: zod_1.z.array(zod_1.z.unknown()),
20
- total_comments: zod_1.z.number(),
19
+ total_comments: zod_1.z.number().optional().nullable(),
21
20
  versions: zod_1.z.array(Version_1.Version),
22
21
  assignments: zod_1.z.array(zod_1.z.unknown()),
23
22
  assignment_logs: zod_1.z.array(Logs_1.LogEntry).optional().nullable(),
@@ -36,11 +35,11 @@ const DocInfo = zod_1.z
36
35
  document_email: zod_1.z.string().optional().nullable(),
37
36
  })
38
37
  .describe("DocInfo");
39
- const GetDocResponse = (DocModel) => zod_1.z
38
+ const GetDocResponse = (InputDocModel) => zod_1.z
40
39
  .object({
41
- docs: zod_1.z.array(DocModel),
40
+ docs: zod_1.z.array((0, DocTypeHelpers_1.DocModel)(InputDocModel)),
42
41
  docinfo: DocInfo,
43
42
  _link_titles: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
44
43
  })
45
- .describe("GetDocResponse " + DocModel.description);
44
+ .describe("GetDocResponse " + InputDocModel.description);
46
45
  exports.GetDocResponse = GetDocResponse;
@@ -1,2 +1,141 @@
1
- import { ZodObject } from "zod";
2
- export declare const LoadDocumentWrapper: (BaseModel: ZodObject<any>) => ZodObject<any>;
1
+ import { AnyZodObject, z, ZodArray, ZodObject, ZodRawShape } from "zod";
2
+ import { Prettify } from "../../utils/utils";
3
+ import { KeysOf } from "../../utils/zodUtils";
4
+ import { DocTypeChildTableEntryMeta, DocTypeMeta } from "./ERPNextDocTypeMeta";
5
+ export type KeysOfModel<T> = KeysOf<T extends AnyZodObject ? DocModelListEntryType<T> : never>;
6
+ export type GetListReturnValue<TModel, TFieldOptions extends KeysOfModel<TModel>, TSelectedFields extends TFieldOptions[] | readonly ["*"] | undefined, TAsDict> = Prettify<TAsDict extends false ? Array<Array<string>> : TModel extends AnyZodObject ? TSelectedFields extends undefined ? Array<{
7
+ name: string;
8
+ }> : TSelectedFields extends readonly ["*"] ? Array<z.infer<DocModelListEntryType<TModel>>> : TSelectedFields extends TFieldOptions[] ? Array<Pick<z.infer<DocModelListEntryType<TModel>>, TSelectedFields[number]>> : any : any>;
9
+ export declare const LoadDocumentWrapper: <T extends AnyZodObject>(BaseModel: T) => z.ZodObject<{
10
+ [x: string]: any;
11
+ } & {
12
+ __onload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
13
+ }, any, any, {
14
+ [x: string]: any;
15
+ __onload?: unknown;
16
+ }, {
17
+ [x: string]: any;
18
+ __onload?: unknown;
19
+ }>;
20
+ /**
21
+ * Transforms a base model into a DocType by:
22
+ * 1. Merging with DocTypeMeta (adds metadata fields)
23
+ * 2. Augmenting all array fields with DocTypeChildTableEntry metadata
24
+ *
25
+ * @param BaseModel - The base Zod object schema
26
+ * @returns A properly typed DocType schema with metadata and augmented arrays
27
+ */
28
+ type AugmentArrayFields<T extends AnyZodObject> = {
29
+ [K in keyof T["shape"]]: T["shape"][K] extends ZodArray<infer Element> ? Element extends ZodObject<infer ElementShape extends ZodRawShape> ? ZodArray<ZodObject<ElementShape & typeof DocTypeChildTableEntryMeta.shape>> : T["shape"][K] : T["shape"][K];
30
+ };
31
+ export type DocModelType<T extends AnyZodObject> = ZodObject<AugmentArrayFields<T> & typeof DocTypeMeta.shape>;
32
+ export declare const DocModel: <T extends ZodRawShape>(BaseModel: ZodObject<T>) => DocModelType<ZodObject<T>>;
33
+ /**
34
+ * Creates a list model by removing all array fields from a base DocType model.
35
+ * This is useful for list endpoints where child tables are not included.
36
+ * Returns a wrapped array schema with the name "DocTypeList".
37
+ *
38
+ * @param BaseModel - The Zod object schema to create a list model from
39
+ * @returns A Zod array schema containing the base model without array fields
40
+ *
41
+ * @example
42
+ * const Item = z.object({
43
+ * item_code: z.string(),
44
+ * item_name: z.string(),
45
+ * barcodes: z.array(Barcode),
46
+ * uoms: z.array(Uom),
47
+ * });
48
+ * const ItemList = DocTypeList(Item);
49
+ * ItemList is z.array of Item without barcodes and uoms fields
50
+ */
51
+ type OmitArrayFields<T extends AnyZodObject> = ZodObject<{
52
+ [K in keyof T["shape"] as T["shape"][K] extends ZodArray<any> ? never : K extends "doctype" ? never : K]: T["shape"][K];
53
+ }>;
54
+ export type DocModelListEntryType<T extends AnyZodObject> = OmitArrayFields<DocModelType<T>>;
55
+ export declare const DocModelListEntry: <T extends ZodRawShape>(BaseModel: ZodObject<T>) => DocModelListEntryType<ZodObject<T>>;
56
+ export declare const DocTypeList: <T extends AnyZodObject>(BaseModel: T) => z.ZodArray<any, "many">;
57
+ /**
58
+ * Augments all array fields in a Zod object schema that contain object schemas
59
+ * with DocTypeChildTableEntry metadata fields (name, owner, creation, etc.)
60
+ *
61
+ * This is useful for ERPNext child table entries which need to include
62
+ * metadata fields like parenttype, parentfield, etc.
63
+ *
64
+ * @param BaseModel - The Zod object schema to augment
65
+ * @returns A new Zod object schema with augmented array fields
66
+ *
67
+ * @example
68
+ * const Item = z.object({
69
+ * name: z.string(),
70
+ * barcodes: z.array(BarcodeSchema),
71
+ * });
72
+ * const AugmentedItem = AugmentChildTableArrays(Item);
73
+ * Now barcodes array items will include DocTypeChildTableEntry fields
74
+ */
75
+ export declare const AugmentChildTableArrays: <T extends ZodRawShape>(BaseModel: ZodObject<T>) => z.ZodObject<z.ZodRawShape, "strip", z.ZodTypeAny, {
76
+ [x: string]: any;
77
+ }, {
78
+ [x: string]: any;
79
+ }>;
80
+ /**
81
+ * Creates a child table entry schema by merging business fields with DocTypeChildTableEntry metadata.
82
+ * This is the recommended way to define child table schemas for ERPNext resource models.
83
+ *
84
+ * @param businessFieldsSchema - The Zod object schema containing only business-specific fields
85
+ * @param description - Optional description for the resulting schema
86
+ * @returns A new Zod object schema with both business fields and child table metadata
87
+ *
88
+ * @example
89
+ * const BarcodeBusinessFields = z.object({
90
+ * barcode: z.string(),
91
+ * barcode_type: z.string(),
92
+ * });
93
+ * const Barcode = CreateChildTableEntrySchema(BarcodeBusinessFields, "Item Barcode");
94
+ *
95
+ * // Can then be used in parent model:
96
+ * const Item = z.object({
97
+ * item_code: z.string(),
98
+ * barcodes: z.array(Barcode),
99
+ * });
100
+ */
101
+ export declare const CreateChildTableEntrySchema: <T extends ZodRawShape>(businessFieldsSchema: ZodObject<T>, description?: string) => z.ZodObject<z.objectUtil.extendShape<T, {
102
+ name: z.ZodString;
103
+ owner: z.ZodString;
104
+ creation: z.ZodString;
105
+ modified: z.ZodString;
106
+ modified_by: z.ZodString;
107
+ idx: z.ZodNumber;
108
+ docstatus: z.ZodDefault<z.ZodNumber>;
109
+ doctype: z.ZodString;
110
+ _user_tags: z.ZodOptional<z.ZodString>;
111
+ } & {
112
+ parenttype: z.ZodString;
113
+ parentfield: z.ZodString;
114
+ }>, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<T, {
115
+ name: z.ZodString;
116
+ owner: z.ZodString;
117
+ creation: z.ZodString;
118
+ modified: z.ZodString;
119
+ modified_by: z.ZodString;
120
+ idx: z.ZodNumber;
121
+ docstatus: z.ZodDefault<z.ZodNumber>;
122
+ doctype: z.ZodString;
123
+ _user_tags: z.ZodOptional<z.ZodString>;
124
+ } & {
125
+ parenttype: z.ZodString;
126
+ parentfield: z.ZodString;
127
+ }>>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<z.objectUtil.extendShape<T, {
128
+ name: z.ZodString;
129
+ owner: z.ZodString;
130
+ creation: z.ZodString;
131
+ modified: z.ZodString;
132
+ modified_by: z.ZodString;
133
+ idx: z.ZodNumber;
134
+ docstatus: z.ZodDefault<z.ZodNumber>;
135
+ doctype: z.ZodString;
136
+ _user_tags: z.ZodOptional<z.ZodString>;
137
+ } & {
138
+ parenttype: z.ZodString;
139
+ parentfield: z.ZodString;
140
+ }>> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
141
+ export {};
@@ -1,6 +1,137 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoadDocumentWrapper = void 0;
3
+ exports.CreateChildTableEntrySchema = exports.AugmentChildTableArrays = exports.DocTypeList = exports.DocModelListEntry = exports.DocModel = exports.LoadDocumentWrapper = void 0;
4
4
  const zod_1 = require("zod");
5
+ const zodUtils_1 = require("../../utils/zodUtils");
6
+ const ERPNextDocTypeMeta_1 = require("./ERPNextDocTypeMeta");
5
7
  const LoadDocumentWrapper = (BaseModel) => BaseModel.extend({ __onload: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()) }).describe(BaseModel.description + " with __onload");
6
8
  exports.LoadDocumentWrapper = LoadDocumentWrapper;
9
+ const DocModel = (BaseModel) => {
10
+ var _a, _b;
11
+ // First merge with DocTypeMeta to add metadata fields
12
+ const withMeta = BaseModel.merge(ERPNextDocTypeMeta_1.DocTypeMeta).describe(((_a = BaseModel.description) !== null && _a !== void 0 ? _a : "Unnamed Model") + " Doc");
13
+ // Then augment array fields with child table metadata
14
+ const shape = withMeta.shape;
15
+ const newShape = {};
16
+ for (const [key, value] of Object.entries(shape)) {
17
+ if (value instanceof zod_1.ZodArray) {
18
+ const arrayElement = value._def.type;
19
+ // Check if the array contains a ZodObject
20
+ if (arrayElement instanceof zod_1.ZodObject) {
21
+ // Augment the array element with DocTypeChildTableEntry
22
+ const augmentedElement = arrayElement.merge(ERPNextDocTypeMeta_1.DocTypeChildTableEntryMeta);
23
+ newShape[key] = zod_1.z.array(augmentedElement);
24
+ }
25
+ else {
26
+ // Keep the original array as-is for non-object arrays
27
+ newShape[key] = value;
28
+ }
29
+ }
30
+ else {
31
+ // Keep non-array fields as-is
32
+ newShape[key] = value;
33
+ }
34
+ }
35
+ return zod_1.z
36
+ .object(newShape)
37
+ .describe((_b = BaseModel.description) !== null && _b !== void 0 ? _b : "Unnamed DocType Model");
38
+ };
39
+ exports.DocModel = DocModel;
40
+ const DocModelListEntry = (BaseModel) => {
41
+ const model = (0, exports.DocModel)(BaseModel);
42
+ const shape = model.shape;
43
+ const newShape = {};
44
+ // Filter out all array fields and the doctype field
45
+ for (const [key, value] of Object.entries(shape)) {
46
+ if (!(value instanceof zod_1.ZodArray) && key !== "doctype") {
47
+ newShape[key] = value;
48
+ }
49
+ }
50
+ return zod_1.z
51
+ .object(newShape)
52
+ .describe(`${BaseModel.description || "DocType"} List Item`);
53
+ };
54
+ exports.DocModelListEntry = DocModelListEntry;
55
+ const NameArray = zod_1.z.object({
56
+ name: zod_1.z.string(),
57
+ abc: zod_1.z.string(),
58
+ array: zod_1.z.array(zod_1.z.string()),
59
+ });
60
+ const newModel = (0, zodUtils_1.pickFromSchema)((0, exports.DocModelListEntry)(NameArray), ["abc"])["shape"];
61
+ newModel.abc;
62
+ const DocTypeList = (BaseModel) => {
63
+ return zod_1.z
64
+ .array(BaseModel)
65
+ .describe(`${BaseModel.description || "DocType List"}`.replace("List Item", "List"));
66
+ };
67
+ exports.DocTypeList = DocTypeList;
68
+ /**
69
+ * Augments all array fields in a Zod object schema that contain object schemas
70
+ * with DocTypeChildTableEntry metadata fields (name, owner, creation, etc.)
71
+ *
72
+ * This is useful for ERPNext child table entries which need to include
73
+ * metadata fields like parenttype, parentfield, etc.
74
+ *
75
+ * @param BaseModel - The Zod object schema to augment
76
+ * @returns A new Zod object schema with augmented array fields
77
+ *
78
+ * @example
79
+ * const Item = z.object({
80
+ * name: z.string(),
81
+ * barcodes: z.array(BarcodeSchema),
82
+ * });
83
+ * const AugmentedItem = AugmentChildTableArrays(Item);
84
+ * Now barcodes array items will include DocTypeChildTableEntry fields
85
+ */
86
+ const AugmentChildTableArrays = (BaseModel) => {
87
+ const shape = BaseModel.shape;
88
+ const newShape = {};
89
+ for (const [key, value] of Object.entries(shape)) {
90
+ if (value instanceof zod_1.ZodArray) {
91
+ const arrayElement = value._def.type;
92
+ // Check if the array contains a ZodObject
93
+ if (arrayElement instanceof zod_1.ZodObject) {
94
+ // Augment the array element with DocTypeChildTableEntry
95
+ const augmentedElement = arrayElement.merge(ERPNextDocTypeMeta_1.DocTypeChildTableEntryMeta);
96
+ newShape[key] = zod_1.z.array(augmentedElement);
97
+ }
98
+ else {
99
+ // Keep the original array as-is for non-object arrays
100
+ newShape[key] = value;
101
+ }
102
+ }
103
+ else {
104
+ // Keep non-array fields as-is
105
+ newShape[key] = value;
106
+ }
107
+ }
108
+ return zod_1.z.object(newShape).describe(BaseModel.description || "");
109
+ };
110
+ exports.AugmentChildTableArrays = AugmentChildTableArrays;
111
+ /**
112
+ * Creates a child table entry schema by merging business fields with DocTypeChildTableEntry metadata.
113
+ * This is the recommended way to define child table schemas for ERPNext resource models.
114
+ *
115
+ * @param businessFieldsSchema - The Zod object schema containing only business-specific fields
116
+ * @param description - Optional description for the resulting schema
117
+ * @returns A new Zod object schema with both business fields and child table metadata
118
+ *
119
+ * @example
120
+ * const BarcodeBusinessFields = z.object({
121
+ * barcode: z.string(),
122
+ * barcode_type: z.string(),
123
+ * });
124
+ * const Barcode = CreateChildTableEntrySchema(BarcodeBusinessFields, "Item Barcode");
125
+ *
126
+ * // Can then be used in parent model:
127
+ * const Item = z.object({
128
+ * item_code: z.string(),
129
+ * barcodes: z.array(Barcode),
130
+ * });
131
+ */
132
+ const CreateChildTableEntrySchema = (businessFieldsSchema, description) => {
133
+ return businessFieldsSchema
134
+ .merge(ERPNextDocTypeMeta_1.DocTypeChildTableEntryMeta)
135
+ .describe(description || businessFieldsSchema.description || "");
136
+ };
137
+ exports.CreateChildTableEntrySchema = CreateChildTableEntrySchema;
@@ -0,0 +1,124 @@
1
+ import { z } from "zod";
2
+ export declare const SubmittableMeta: z.ZodObject<{
3
+ amended_from: z.ZodNullable<z.ZodOptional<z.ZodString>>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ amended_from?: string | null | undefined;
6
+ }, {
7
+ amended_from?: string | null | undefined;
8
+ }>;
9
+ export declare const DocTypeMeta: z.ZodObject<{
10
+ name: z.ZodString;
11
+ owner: z.ZodString;
12
+ creation: z.ZodString;
13
+ modified: z.ZodString;
14
+ modified_by: z.ZodString;
15
+ idx: z.ZodNumber;
16
+ docstatus: z.ZodDefault<z.ZodNumber>;
17
+ doctype: z.ZodString;
18
+ _user_tags: z.ZodOptional<z.ZodString>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ name: string;
21
+ owner: string;
22
+ creation: string;
23
+ modified: string;
24
+ modified_by: string;
25
+ idx: number;
26
+ docstatus: number;
27
+ doctype: string;
28
+ _user_tags?: string | undefined;
29
+ }, {
30
+ name: string;
31
+ owner: string;
32
+ creation: string;
33
+ modified: string;
34
+ modified_by: string;
35
+ idx: number;
36
+ doctype: string;
37
+ docstatus?: number | undefined;
38
+ _user_tags?: string | undefined;
39
+ }>;
40
+ export type DocTypeMetaType = z.infer<typeof DocTypeMeta>;
41
+ export declare const DocTypeChildTableEntryMeta: z.ZodObject<{
42
+ name: z.ZodString;
43
+ owner: z.ZodString;
44
+ creation: z.ZodString;
45
+ modified: z.ZodString;
46
+ modified_by: z.ZodString;
47
+ idx: z.ZodNumber;
48
+ docstatus: z.ZodDefault<z.ZodNumber>;
49
+ doctype: z.ZodString;
50
+ _user_tags: z.ZodOptional<z.ZodString>;
51
+ } & {
52
+ parenttype: z.ZodString;
53
+ parentfield: z.ZodString;
54
+ }, "strip", z.ZodTypeAny, {
55
+ name: string;
56
+ owner: string;
57
+ creation: string;
58
+ modified: string;
59
+ modified_by: string;
60
+ idx: number;
61
+ docstatus: number;
62
+ doctype: string;
63
+ parenttype: string;
64
+ parentfield: string;
65
+ _user_tags?: string | undefined;
66
+ }, {
67
+ name: string;
68
+ owner: string;
69
+ creation: string;
70
+ modified: string;
71
+ modified_by: string;
72
+ idx: number;
73
+ doctype: string;
74
+ parenttype: string;
75
+ parentfield: string;
76
+ docstatus?: number | undefined;
77
+ _user_tags?: string | undefined;
78
+ }>;
79
+ export type DocTypeChildTableEntryMetaType = z.infer<typeof DocTypeChildTableEntryMeta>;
80
+ export declare const DocTypeNested: z.ZodObject<{
81
+ name: z.ZodString;
82
+ owner: z.ZodString;
83
+ creation: z.ZodString;
84
+ modified: z.ZodString;
85
+ modified_by: z.ZodString;
86
+ docstatus: z.ZodDefault<z.ZodNumber>;
87
+ doctype: z.ZodString;
88
+ _user_tags: z.ZodOptional<z.ZodString>;
89
+ } & {
90
+ old_parent: z.ZodString;
91
+ is_group: z.ZodNumber;
92
+ lft: z.ZodNumber;
93
+ rgt: z.ZodNumber;
94
+ idx: z.ZodNumber;
95
+ }, "strip", z.ZodTypeAny, {
96
+ name: string;
97
+ owner: string;
98
+ creation: string;
99
+ modified: string;
100
+ modified_by: string;
101
+ idx: number;
102
+ docstatus: number;
103
+ doctype: string;
104
+ old_parent: string;
105
+ is_group: number;
106
+ lft: number;
107
+ rgt: number;
108
+ _user_tags?: string | undefined;
109
+ }, {
110
+ name: string;
111
+ owner: string;
112
+ creation: string;
113
+ modified: string;
114
+ modified_by: string;
115
+ idx: number;
116
+ doctype: string;
117
+ old_parent: string;
118
+ is_group: number;
119
+ lft: number;
120
+ rgt: number;
121
+ docstatus?: number | undefined;
122
+ _user_tags?: string | undefined;
123
+ }>;
124
+ export type DocTypeNestedType = z.infer<typeof DocTypeNested>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocTypeNested = exports.DocTypeChildTableEntryMeta = exports.DocTypeMeta = exports.SubmittableMeta = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.SubmittableMeta = zod_1.z.object({
6
+ amended_from: zod_1.z.string().optional().nullable(),
7
+ });
8
+ exports.DocTypeMeta = zod_1.z
9
+ .object({
10
+ name: zod_1.z.string(),
11
+ owner: zod_1.z.string(),
12
+ creation: zod_1.z.string(),
13
+ modified: zod_1.z.string(),
14
+ modified_by: zod_1.z.string(),
15
+ idx: zod_1.z.number(),
16
+ docstatus: zod_1.z.number().default(0),
17
+ doctype: zod_1.z.string(),
18
+ _user_tags: zod_1.z.string().optional(),
19
+ })
20
+ .describe("Sales Order");
21
+ const ChildTableEntryFieldsMeta = zod_1.z
22
+ .object({
23
+ parenttype: zod_1.z.string(),
24
+ parentfield: zod_1.z.string(),
25
+ })
26
+ .describe("Sales Order");
27
+ exports.DocTypeChildTableEntryMeta = exports.DocTypeMeta.merge(ChildTableEntryFieldsMeta);
28
+ const DocTypeNestedMeta = zod_1.z
29
+ .object({
30
+ old_parent: zod_1.z.string(),
31
+ is_group: zod_1.z.number(),
32
+ lft: zod_1.z.number(),
33
+ rgt: zod_1.z.number(),
34
+ idx: zod_1.z.number(),
35
+ })
36
+ .describe("Sales Order");
37
+ exports.DocTypeNested = exports.DocTypeMeta.merge(DocTypeNestedMeta);
@@ -1,5 +1,5 @@
1
1
  import { TypeOf, ZodTypeAny } from "zod";
2
- interface ERPNextResourceGenericRequestOptions<T extends ZodTypeAny, K extends ZodTypeAny> {
2
+ interface ERPNextResourceGenericRequestOptions<T extends ZodTypeAny> {
3
3
  resourceName: string;
4
4
  resourceId: string;
5
5
  requestMethod: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
@@ -8,7 +8,7 @@ interface ERPNextResourceGenericRequestOptions<T extends ZodTypeAny, K extends Z
8
8
  headers?: Record<string, string>;
9
9
  url?: string;
10
10
  }
11
- interface ERPNextResourceGetRequestOptions<T extends ZodTypeAny, K extends ZodTypeAny> {
11
+ interface ERPNextResourceGetRequestOptions<T extends ZodTypeAny> {
12
12
  resourceName: string;
13
13
  resourceId: string;
14
14
  requestMethod: "GET";
@@ -16,7 +16,7 @@ interface ERPNextResourceGetRequestOptions<T extends ZodTypeAny, K extends ZodTy
16
16
  responseValidationModel?: T | undefined;
17
17
  headers?: Record<string, string>;
18
18
  }
19
- interface ERPNextResourceGetListRequestOptions<T extends ZodTypeAny, K extends ZodTypeAny> {
19
+ interface ERPNextResourceGetListRequestOptions<T extends ZodTypeAny> {
20
20
  resourceName: string;
21
21
  requestMethod: "GET";
22
22
  responseValidationModel?: T | undefined;
@@ -42,7 +42,7 @@ export interface ERPNextResourcePutRequestOptions<T extends ZodTypeAny, K extend
42
42
  body: K extends undefined ? Partial<TypeOf<T>> : TypeOf<K>;
43
43
  headers?: Record<string, string>;
44
44
  }
45
- export interface ERPNextResourceDeleteRequestOptions<T extends ZodTypeAny, K extends ZodTypeAny> {
45
+ export interface ERPNextResourceDeleteRequestOptions<T extends ZodTypeAny> {
46
46
  resourceName: string;
47
47
  resourceId?: string;
48
48
  requestMethod: "DELETE";
@@ -59,5 +59,5 @@ export interface ERPNextMethodRequestOptions<T extends ZodTypeAny, K extends Zod
59
59
  params?: string;
60
60
  headers?: Record<string, string>;
61
61
  }
62
- export type ERPNextRequestOptions<T extends ZodTypeAny, K extends ZodTypeAny> = ERPNextResourceGetRequestOptions<T, K> | ERPNextResourceGetListRequestOptions<T, K> | ERPNextResourcePostRequestOptions<T, K> | ERPNextResourcePutRequestOptions<T, K> | ERPNextResourceDeleteRequestOptions<T, K> | ERPNextMethodRequestOptions<T, K> | ERPNextResourceGenericRequestOptions<T, K>;
62
+ export type ERPNextRequestOptions<T extends ZodTypeAny, K extends ZodTypeAny> = ERPNextResourceGetRequestOptions<T> | ERPNextResourceGetListRequestOptions<T> | ERPNextResourcePostRequestOptions<T, K> | ERPNextResourcePutRequestOptions<T, K> | ERPNextResourceDeleteRequestOptions<T> | ERPNextMethodRequestOptions<T, K> | ERPNextResourceGenericRequestOptions<T>;
63
63
  export {};
@@ -1,12 +1,5 @@
1
1
  import { z } from "zod";
2
2
  export declare const ERPNextFile: z.ZodObject<{
3
- name: z.ZodString;
4
- owner: z.ZodString;
5
- creation: z.ZodString;
6
- modified: z.ZodString;
7
- modified_by: z.ZodString;
8
- idx: z.ZodNumber;
9
- docstatus: z.ZodNumber;
10
3
  file_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
4
  is_private: z.ZodNumber;
12
5
  is_home_folder: z.ZodNumber;
@@ -21,16 +14,7 @@ export declare const ERPNextFile: z.ZodObject<{
21
14
  s3_file_key: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
15
  uploaded_to_dropbox: z.ZodNumber;
23
16
  uploaded_to_google_drive: z.ZodNumber;
24
- doctype: z.ZodString;
25
17
  }, "strip", z.ZodTypeAny, {
26
- name: string;
27
- doctype: string;
28
- owner: string;
29
- creation: string;
30
- modified: string;
31
- modified_by: string;
32
- idx: number;
33
- docstatus: number;
34
18
  is_private: number;
35
19
  is_home_folder: number;
36
20
  is_attachments_folder: number;
@@ -46,14 +30,6 @@ export declare const ERPNextFile: z.ZodObject<{
46
30
  content_hash?: string | null | undefined;
47
31
  s3_file_key?: string | null | undefined;
48
32
  }, {
49
- name: string;
50
- doctype: string;
51
- owner: string;
52
- creation: string;
53
- modified: string;
54
- modified_by: string;
55
- idx: number;
56
- docstatus: number;
57
33
  is_private: number;
58
34
  is_home_folder: number;
59
35
  is_attachments_folder: number;
@@ -71,13 +47,6 @@ export declare const ERPNextFile: z.ZodObject<{
71
47
  }>;
72
48
  export type ERPNextFileType = z.infer<typeof ERPNextFile>;
73
49
  export declare const ERPNextValidatedFile: z.ZodObject<Omit<{
74
- name: z.ZodString;
75
- owner: z.ZodString;
76
- creation: z.ZodString;
77
- modified: z.ZodString;
78
- modified_by: z.ZodString;
79
- idx: z.ZodNumber;
80
- docstatus: z.ZodNumber;
81
50
  file_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
82
51
  is_private: z.ZodNumber;
83
52
  is_home_folder: z.ZodNumber;
@@ -92,19 +61,10 @@ export declare const ERPNextValidatedFile: z.ZodObject<Omit<{
92
61
  s3_file_key: z.ZodNullable<z.ZodOptional<z.ZodString>>;
93
62
  uploaded_to_dropbox: z.ZodNumber;
94
63
  uploaded_to_google_drive: z.ZodNumber;
95
- doctype: z.ZodString;
96
64
  }, "file_name" | "file_url"> & {
97
65
  file_name: z.ZodString;
98
66
  file_url: z.ZodString;
99
67
  }, "strip", z.ZodTypeAny, {
100
- name: string;
101
- doctype: string;
102
- owner: string;
103
- creation: string;
104
- modified: string;
105
- modified_by: string;
106
- idx: number;
107
- docstatus: number;
108
68
  file_name: string;
109
69
  file_url: string;
110
70
  is_private: number;
@@ -120,14 +80,6 @@ export declare const ERPNextValidatedFile: z.ZodObject<Omit<{
120
80
  content_hash?: string | null | undefined;
121
81
  s3_file_key?: string | null | undefined;
122
82
  }, {
123
- name: string;
124
- doctype: string;
125
- owner: string;
126
- creation: string;
127
- modified: string;
128
- modified_by: string;
129
- idx: number;
130
- docstatus: number;
131
83
  file_name: string;
132
84
  file_url: string;
133
85
  is_private: number;
@@ -4,13 +4,6 @@ exports.ERPNextValidatedFile = exports.ERPNextFile = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.ERPNextFile = zod_1.z
6
6
  .object({
7
- name: zod_1.z.string(),
8
- owner: zod_1.z.string(),
9
- creation: zod_1.z.string(),
10
- modified: zod_1.z.string(),
11
- modified_by: zod_1.z.string(),
12
- idx: zod_1.z.number(),
13
- docstatus: zod_1.z.number(),
14
7
  file_name: zod_1.z.string().optional().nullable(),
15
8
  is_private: zod_1.z.number(),
16
9
  is_home_folder: zod_1.z.number(),
@@ -25,7 +18,6 @@ exports.ERPNextFile = zod_1.z
25
18
  s3_file_key: zod_1.z.string().optional().nullable(),
26
19
  uploaded_to_dropbox: zod_1.z.number(),
27
20
  uploaded_to_google_drive: zod_1.z.number(),
28
- doctype: zod_1.z.string(),
29
21
  })
30
22
  .describe("ERPNextFile");
31
23
  exports.ERPNextValidatedFile = exports.ERPNextFile.omit({