erpnext-queue-client 2.0.0-beta.0 → 2.0.0-beta.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 (68) hide show
  1. package/dist/client.js +1 -4
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/constants.js +4 -4
  4. package/dist/erpnext/doctypeResourceRequest.d.ts +1 -1
  5. package/dist/erpnext/doctypeSubmittableResourceRequest.d.ts +56 -16
  6. package/dist/erpnext/doctypeSubmittableResourceRequest.js +10 -8
  7. package/dist/erpnext/doctypes/address.d.ts +18 -18
  8. package/dist/erpnext/doctypes/contact.d.ts +18 -18
  9. package/dist/erpnext/doctypes/deliveryNote.d.ts +44 -33
  10. package/dist/erpnext/doctypes/item.d.ts +49 -49
  11. package/dist/erpnext/doctypes/paymentEntry.d.ts +820 -0
  12. package/dist/erpnext/doctypes/paymentEntry.js +72 -0
  13. package/dist/erpnext/doctypes/productBundle.d.ts +16 -16
  14. package/dist/erpnext/doctypes/purchaseInvoice.d.ts +99 -99
  15. package/dist/erpnext/doctypes/purchaseReceipt.d.ts +48 -49
  16. package/dist/erpnext/doctypes/salesInvoice.d.ts +2205 -2203
  17. package/dist/erpnext/doctypes/servicecase.d.ts +56 -56
  18. package/dist/erpnext/doctypes/shipment.d.ts +76 -44
  19. package/dist/erpnext/doctypes/stock.d.ts +2 -0
  20. package/dist/erpnext/doctypes/stock.js +19 -3
  21. package/dist/erpnext/model/ConsolidatedCustomsInvoice.d.ts +321 -0
  22. package/dist/erpnext/model/ConsolidatedCustomsInvoice.js +83 -0
  23. package/dist/erpnext/model/DeliveryNote.d.ts +3 -0
  24. package/dist/erpnext/model/DeliveryNote.js +1 -0
  25. package/dist/erpnext/model/DispatchRun.d.ts +3 -3
  26. package/dist/erpnext/model/DispatchRun.js +1 -1
  27. package/dist/erpnext/model/DocTypeHelpers.d.ts +26 -7
  28. package/dist/erpnext/model/DocTypeHelpers.js +0 -8
  29. package/dist/erpnext/model/ERPNextDocTypeMeta.d.ts +28 -15
  30. package/dist/erpnext/model/ERPNextDocTypeMeta.js +12 -7
  31. package/dist/erpnext/model/FulfillmentStation.d.ts +3 -0
  32. package/dist/erpnext/model/FulfillmentStation.js +1 -0
  33. package/dist/erpnext/model/Item.d.ts +35 -25
  34. package/dist/erpnext/model/ItemTaxTemplate.d.ts +57 -0
  35. package/dist/erpnext/model/ItemTaxTemplate.js +25 -0
  36. package/dist/erpnext/model/PaymentEntry.d.ts +183 -16
  37. package/dist/erpnext/model/PaymentEntry.js +6 -1
  38. package/dist/erpnext/model/PurchaseInvoice.d.ts +49 -47
  39. package/dist/erpnext/model/PurchaseInvoice.js +0 -1
  40. package/dist/erpnext/model/PurchaseOrder.d.ts +10 -10
  41. package/dist/erpnext/model/Receipt.d.ts +2 -2
  42. package/dist/erpnext/model/ReceiptDraft.d.ts +0 -3
  43. package/dist/erpnext/model/ReceiptDraft.js +0 -1
  44. package/dist/erpnext/model/SalesInvoice.d.ts +1530 -1526
  45. package/dist/erpnext/model/SalesInvoice.js +182 -178
  46. package/dist/erpnext/model/SalesOrder.d.ts +778 -748
  47. package/dist/erpnext/model/SalesOrder.js +151 -149
  48. package/dist/erpnext/model/Servicecase.d.ts +30 -30
  49. package/dist/erpnext/model/Servicecase.js +8 -1
  50. package/dist/erpnext/model/ServiceportalProductConfiguration.d.ts +128 -3
  51. package/dist/erpnext/model/ServiceportalProductConfiguration.js +34 -2
  52. package/dist/erpnext/model/Shipment.d.ts +14 -0
  53. package/dist/erpnext/model/Shipment.js +14 -1
  54. package/dist/erpnext/model/ShippingFees.d.ts +36 -0
  55. package/dist/erpnext/model/ShippingFees.js +18 -0
  56. package/dist/erpnext/model/ShippingProvider.d.ts +2 -2
  57. package/dist/erpnext/model/Stock.d.ts +6 -6
  58. package/dist/erpnext/model/StockEntry.d.ts +2 -2
  59. package/dist/erpnext/model/TaxCategory.d.ts +20 -0
  60. package/dist/erpnext/model/TaxCategory.js +16 -0
  61. package/dist/erpnext/resourceRequest.d.ts +1 -1
  62. package/dist/erpnext/resourceRequest.js +11 -5
  63. package/dist/index.d.ts +8 -2
  64. package/dist/index.js +9 -2
  65. package/dist/index.test.js +104 -70
  66. package/dist/utils/zodContextOptionals.js +7 -4
  67. package/dist/utils/zodUtils.js +14 -2
  68. package/package.json +7 -2
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ const address_1 = require("./erpnext/doctypes/address");
8
8
  const contact_1 = require("./erpnext/doctypes/contact");
9
9
  const deliveryNote_1 = require("./erpnext/doctypes/deliveryNote");
10
10
  const item_1 = require("./erpnext/doctypes/item");
11
+ const paymentEntry_1 = require("./erpnext/doctypes/paymentEntry");
11
12
  const productBundle_1 = require("./erpnext/doctypes/productBundle");
12
13
  const purchaseInvoice_1 = require("./erpnext/doctypes/purchaseInvoice");
13
14
  const purchaseReceipt_1 = require("./erpnext/doctypes/purchaseReceipt");
@@ -20,12 +21,13 @@ const doctypeSubmittableResourceRequest_1 = require("./erpnext/doctypeSubmittabl
20
21
  const fileRequests_1 = require("./erpnext/fileRequests");
21
22
  const methodRequest_1 = require("./erpnext/methodRequest");
22
23
  const Compliance_1 = require("./erpnext/model/Compliance");
24
+ const ConsolidatedCustomsInvoice_1 = require("./erpnext/model/ConsolidatedCustomsInvoice");
23
25
  const Country_1 = require("./erpnext/model/Country");
24
26
  const Customer_1 = require("./erpnext/model/Customer");
25
27
  const File_1 = require("./erpnext/model/File");
26
28
  const InternalReasons_1 = require("./erpnext/model/InternalReasons");
29
+ const ItemTaxTemplate_1 = require("./erpnext/model/ItemTaxTemplate");
27
30
  const PartList_1 = require("./erpnext/model/PartList");
28
- const PaymentEntry_1 = require("./erpnext/model/PaymentEntry");
29
31
  const PurchaseOrder_1 = require("./erpnext/model/PurchaseOrder");
30
32
  const SalesOrder_1 = require("./erpnext/model/SalesOrder");
31
33
  const ServicecaseReason_1 = require("./erpnext/model/ServicecaseReason");
@@ -36,6 +38,7 @@ const ShippingProvider_1 = require("./erpnext/model/ShippingProvider");
36
38
  const StockEntry_1 = require("./erpnext/model/StockEntry");
37
39
  const StockReconciliation_1 = require("./erpnext/model/StockReconciliation");
38
40
  const Supplier_1 = require("./erpnext/model/Supplier");
41
+ const TaxCategory_1 = require("./erpnext/model/TaxCategory");
39
42
  const Waitlist_1 = require("./erpnext/model/Waitlist");
40
43
  const reports_1 = require("./erpnext/reports");
41
44
  const resourceRequest_1 = require("./erpnext/resourceRequest");
@@ -69,7 +72,7 @@ class ERPNextQueueClient {
69
72
  this.waitlist = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Waitlist", Waitlist_1.Waitlist);
70
73
  this.stockEntry = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Stock Entry", StockEntry_1.StockEntry);
71
74
  this.supplier = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Supplier", Supplier_1.Supplier);
72
- this.paymentEntry = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Payment Entry", PaymentEntry_1.PaymentEntry);
75
+ this.paymentEntry = new paymentEntry_1.ERPNextPaymentEntry(this.temporalClient);
73
76
  this.stockReconciliation = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Stock Reconciliation", StockReconciliation_1.StockReconciliation);
74
77
  this.salesOrder = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Sales Order", SalesOrder_1.SalesOrder);
75
78
  this.salesInvoice = new salesInvoice_1.ERPNextSalesInvoice(this.temporalClient);
@@ -83,6 +86,10 @@ class ERPNextQueueClient {
83
86
  this.servicecaseSolution = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Servicecase Solution", ServicecaseSolution_1.ServiceCaseSolution);
84
87
  this.internalReason = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Internal Reason", InternalReasons_1.InternalReason);
85
88
  this.shippingLabel = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Shipping Label", ShippingLabel_1.ShippingLabel);
89
+ this.consolidatedCustomsInvoice =
90
+ new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Consolidated Customs Invoice", ConsolidatedCustomsInvoice_1.ConsolidatedCustomsInvoice);
91
+ this.itemTaxTemplate = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Item Tax Template", ItemTaxTemplate_1.ItemTaxTemplate);
92
+ this.taxCategory = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Tax Category", TaxCategory_1.TaxCategory);
86
93
  this.tags = new tags_1.ERPNextTags(this.temporalClient);
87
94
  }
88
95
  }
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- // Type testing only - should not be in compiled code
3
- // Use this to statically test types before build
4
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -14,84 +12,118 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
13
  };
16
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const zod_1 = __importDefault(require("zod"));
17
16
  const _1 = require(".");
18
17
  const constants_1 = require("./constants");
19
- const zod_1 = __importDefault(require("zod"));
20
- const zodContextOptionals_1 = require("./utils/zodContextOptionals");
21
18
  const Address_1 = require("./erpnext/model/Address");
22
- describe("Type tests", () => __awaiter(void 0, void 0, void 0, function* () {
23
- beforeAll(() => {
24
- console.log("THIS TEST IS RUN ON erp-test - Make sure the test instance ");
25
- });
19
+ const zodContextOptionals_1 = require("./utils/zodContextOptionals");
20
+ const Item_1 = require("./erpnext/model/Item");
21
+ // Most tests are wrapped in async function blocks so they are declared statically but not run as tests.
22
+ // If we wanted to run the tests, a mocking system would need to be implemented.
23
+ describe.skipIf(constants_1.constants.TEMPORAL_HOST === "test")("Type tests", () => __awaiter(void 0, void 0, void 0, function* () {
26
24
  const erp = new _1.ERPNextQueueClient({
27
25
  temporalCredentials: {
28
- temporalHost: constants_1.constants.TEMPORAL_ERPNEXT_QUEUE_HOST,
29
- temporalNamespace: constants_1.constants.TEMPORAL_ERPNEXT_QUEUE_NAMESPACE,
26
+ temporalHost: constants_1.constants.TEMPORAL_HOST,
27
+ temporalNamespace: constants_1.constants.TEMPORAL_NAMESPACE,
30
28
  temporalCert: constants_1.constants.TEMPORAL_CRT,
31
29
  temporalKey: constants_1.constants.TEMPORAL_KEY,
32
30
  },
33
31
  });
34
32
  test("Single item fetch", () => __awaiter(void 0, void 0, void 0, function* () {
35
- var _a;
36
33
  // We use expect-error to statically test negative cases in typescript
37
- const items = yield erp.item.getList({ limit: 1 });
38
- const item = yield erp.item.getById({ resourceId: items[0].name });
39
- expect(item.name).toBeTypeOf("string");
40
- expect(item.doctype).toBeTypeOf("string");
41
- expect(item.description).toBeTypeOf("string");
42
- expect((_a = item.barcodes.at(0)) === null || _a === void 0 ? void 0 : _a.idx).toBeTypeOf("number");
34
+ () => __awaiter(void 0, void 0, void 0, function* () {
35
+ var _a;
36
+ const items = yield erp.item.getList({ limit: 1 });
37
+ const item = yield erp.item.getById({ resourceId: items[0].name });
38
+ expect(item === null || item === void 0 ? void 0 : item.name).toBeTypeOf("string");
39
+ expect(item === null || item === void 0 ? void 0 : item.doctype).toBeTypeOf("string");
40
+ expect(item === null || item === void 0 ? void 0 : item.description).toBeTypeOf("string");
41
+ expect((_a = item === null || item === void 0 ? void 0 : item.barcodes.at(0)) === null || _a === void 0 ? void 0 : _a.idx).toBeTypeOf("number");
42
+ });
43
+ }));
44
+ test("List with aliases", () => __awaiter(void 0, void 0, void 0, function* () {
45
+ var _a, _b, _c;
46
+ const items = yield erp.resourceRequest.getList({
47
+ resourceName: "Item",
48
+ resourceModel: Item_1.Item.merge(zod_1.default.object({
49
+ "`tabItem Supplier`.supplier as supplier": zod_1.default
50
+ .string()
51
+ .optional()
52
+ .nullable(),
53
+ "item_name as item_title": zod_1.default.string().optional().nullable(),
54
+ })).describe("Item with supplier and title"),
55
+ filters: [["name", "=", "8721225924026FBP"]],
56
+ fields: [
57
+ "name",
58
+ "`tabItem Supplier`.supplier as supplier",
59
+ "item_name as item_title",
60
+ ],
61
+ });
62
+ expect((_a = items.at(0)) === null || _a === void 0 ? void 0 : _a.name).toBeTypeOf("string");
63
+ expect((_b = items.at(0)) === null || _b === void 0 ? void 0 : _b.supplier).toBeTypeOf("string");
64
+ expect((_c = items.at(0)) === null || _c === void 0 ? void 0 : _c.item_title).toBeTypeOf("string");
43
65
  }));
44
66
  test("Item List with field description", () => __awaiter(void 0, void 0, void 0, function* () {
45
- var _a, _b, _c, _d, _e, _f;
46
- // get list with field defined
47
- const itemsOnlyFieldDescription = yield erp.item.getList({
48
- fields: ["description"],
49
- limit: 10,
67
+ () => __awaiter(void 0, void 0, void 0, function* () {
68
+ var _a, _b, _c, _d, _e, _f;
69
+ // get list with field defined
70
+ const itemsOnlyFieldDescription = yield erp.item.getList({
71
+ fields: ["description"],
72
+ limit: 10,
73
+ });
74
+ expect(
75
+ // @ts-expect-error
76
+ (_c = (_b = (_a = itemsOnlyFieldDescription.at(0)) === null || _a === void 0 ? void 0 : _a.barcodes) === null || _b === void 0 ? void 0 : _b.at(0)) === null || _c === void 0 ? void 0 : _c.idx).toBeUndefined();
77
+ expect((_d = itemsOnlyFieldDescription.at(0)) === null || _d === void 0 ? void 0 : _d.description).toBeTypeOf("string");
78
+ // @ts-expect-error
79
+ expect((_e = itemsOnlyFieldDescription.at(0)) === null || _e === void 0 ? void 0 : _e.name).toBeUndefined(); // name not valid here
80
+ // @ts-expect-error
81
+ expect((_f = itemsOnlyFieldDescription.at(0)) === null || _f === void 0 ? void 0 : _f.barcodes).toBeUndefined(); // barcodes not valid here}
50
82
  });
51
- expect(
52
- // @ts-expect-error
53
- (_c = (_b = (_a = itemsOnlyFieldDescription.at(0)) === null || _a === void 0 ? void 0 : _a.barcodes) === null || _b === void 0 ? void 0 : _b.at(0)) === null || _c === void 0 ? void 0 : _c.idx).toBeUndefined();
54
- expect((_d = itemsOnlyFieldDescription.at(0)) === null || _d === void 0 ? void 0 : _d.description).toBeTypeOf("string");
55
- // @ts-expect-error
56
- expect((_e = itemsOnlyFieldDescription.at(0)) === null || _e === void 0 ? void 0 : _e.name).toBeUndefined(); // name not valid here
57
- // @ts-expect-error
58
- expect((_f = itemsOnlyFieldDescription.at(0)) === null || _f === void 0 ? void 0 : _f.barcodes).toBeUndefined(); // barcodes not valid here
59
83
  }));
60
84
  test("Item List with default field 'name'", () => __awaiter(void 0, void 0, void 0, function* () {
61
- var _a, _b;
62
- // get list without fields defined
63
- const items2 = yield erp.item.getList({ limit: 10 });
64
- expect((_a = items2.at(0)) === null || _a === void 0 ? void 0 : _a.name).toBeTypeOf("string");
65
- // @ts-expect-error
66
- expect((_b = items2.at(0)) === null || _b === void 0 ? void 0 : _b.item_code).toBeUndefined(); // item_code not valid here
85
+ () => __awaiter(void 0, void 0, void 0, function* () {
86
+ var _a, _b;
87
+ // get list without fields defined
88
+ const items2 = yield erp.item.getList({ limit: 10 });
89
+ expect((_a = items2.at(0)) === null || _a === void 0 ? void 0 : _a.name).toBeTypeOf("string");
90
+ // @ts-expect-error
91
+ expect((_b = items2.at(0)) === null || _b === void 0 ? void 0 : _b.item_code).toBeUndefined(); // item_code not valid here
92
+ });
67
93
  }));
68
94
  test("Item List with all fields", () => __awaiter(void 0, void 0, void 0, function* () {
69
- // get list without fields defined
70
- var _a, _b, _c, _d;
71
- const itemsWithAllFields = yield erp.item.getList({
72
- fields: ["*"],
73
- limit: 10,
95
+ () => __awaiter(void 0, void 0, void 0, function* () {
96
+ var _a, _b, _c, _d;
97
+ // get list without fields defined
98
+ const itemsWithAllFields = yield erp.item.getList({
99
+ fields: ["*"],
100
+ limit: 10,
101
+ });
102
+ expect((_a = itemsWithAllFields.at(0)) === null || _a === void 0 ? void 0 : _a.name).toBeTypeOf("string");
103
+ // @ts-expect-error
104
+ expect((_b = itemsWithAllFields.at(0)) === null || _b === void 0 ? void 0 : _b.doctype).toBeUndefined(); // doctype omitted in list entries
105
+ expect((_c = itemsWithAllFields.at(0)) === null || _c === void 0 ? void 0 : _c.item_code).toBeTypeOf("string");
106
+ // @ts-expect-error
107
+ expect((_d = itemsWithAllFields.at(0)) === null || _d === void 0 ? void 0 : _d.barcodes).toBeUndefined();
74
108
  });
75
- expect((_a = itemsWithAllFields.at(0)) === null || _a === void 0 ? void 0 : _a.name).toBeTypeOf("string");
76
- // @ts-expect-error
77
- expect((_b = itemsWithAllFields.at(0)) === null || _b === void 0 ? void 0 : _b.doctype).toBeUndefined(); // doctype omitted in list entries
78
- expect((_c = itemsWithAllFields.at(0)) === null || _c === void 0 ? void 0 : _c.item_code).toBeTypeOf("string");
79
- // @ts-expect-error
80
- expect((_d = itemsWithAllFields.at(0)) === null || _d === void 0 ? void 0 : _d.barcodes).toBeUndefined();
81
109
  }));
82
110
  test("Submittable DocType", () => __awaiter(void 0, void 0, void 0, function* () {
83
- const dns = yield erp.deliveryNote.getList({ limit: 1 });
84
- if (!dns[0])
85
- throw new Error("No Delivery Notes found in test instance");
86
- const dn = yield erp.deliveryNote.getById({
87
- resourceId: dns[0].name,
111
+ () => __awaiter(void 0, void 0, void 0, function* () {
112
+ const dns = yield erp.deliveryNote.getList({ limit: 1 });
113
+ if (!dns[0])
114
+ throw new Error("No Delivery Notes found in test instance");
115
+ const dn = yield erp.deliveryNote.getById({
116
+ resourceId: dns[0].name,
117
+ });
118
+ dn === null || dn === void 0 ? void 0 : dn.amended_from; // for static type analysis}
88
119
  });
89
- dn.amended_from; // for static type analysis
90
120
  }));
91
121
  test("Get Address by Supplier", () => __awaiter(void 0, void 0, void 0, function* () {
92
- const sup = yield erp.supplier.getList({ limit: 1 });
93
- const address = yield erp.address.getAddressesBySupplier(sup[0].name);
94
- expect(address[0].city).toBeTypeOf("string");
122
+ () => __awaiter(void 0, void 0, void 0, function* () {
123
+ const sup = yield erp.supplier.getList({ limit: 1 });
124
+ const address = yield erp.address.getAddressesBySupplier(sup[0].name);
125
+ expect(address[0].city).toBeTypeOf("string");
126
+ });
95
127
  }));
96
128
  test("Item List with invalid field list", () => __awaiter(void 0, void 0, void 0, function* () {
97
129
  // don't execute, this is just for type testing statically
@@ -102,7 +134,7 @@ describe("Type tests", () => __awaiter(void 0, void 0, void 0, function* () {
102
134
  });
103
135
  }));
104
136
  test("Create with DocModel Metafields should fail", () => __awaiter(void 0, void 0, void 0, function* () {
105
- // DO NOT EXECUTE, ONLY FOR STATIC TYPE TESTING
137
+ // SHOULD NOT BE EXECUTED, ONLY FOR STATIC TYPE TESTING
106
138
  // We use expect-error to statically test negative cases in typescript
107
139
  () => erp.item.create({
108
140
  body: {
@@ -209,19 +241,21 @@ describe("Type tests", () => __awaiter(void 0, void 0, void 0, function* () {
209
241
  };
210
242
  }));
211
243
  test("Input for updateById function", () => __awaiter(void 0, void 0, void 0, function* () {
212
- // This static type test ensures, that Input as inferred here
213
- // conformes to the expected input type defined in doctypeResourceRequest -> updateById()
214
- const AddressInput = (0, zodContextOptionals_1.ResourceInput)(Address_1.Address);
215
- const typedInputBody = {
216
- address_line1: "test",
217
- address_type: "TEST",
218
- city: "CITY",
219
- country: "Country",
220
- pincode: "1234",
221
- };
222
- yield erp.address.updateById({
223
- resourceId: "TEST",
224
- body: typedInputBody,
244
+ () => __awaiter(void 0, void 0, void 0, function* () {
245
+ // This static type test ensures, that Input as inferred here
246
+ // conformes to the expected input type defined in doctypeResourceRequest -> updateById()
247
+ const AddressInput = (0, zodContextOptionals_1.ResourceInput)(Address_1.Address);
248
+ const typedInputBody = {
249
+ address_line1: "test",
250
+ address_type: "TEST",
251
+ city: "CITY",
252
+ country: "Country",
253
+ pincode: "1234",
254
+ };
255
+ yield erp.address.updateById({
256
+ resourceId: "TEST",
257
+ body: typedInputBody,
258
+ });
225
259
  });
226
260
  }));
227
261
  }));
@@ -15,9 +15,10 @@ function isMarkedOptionalForInput(schema) {
15
15
  }
16
16
  // schema transformation
17
17
  function ResourceInput(schema) {
18
+ var _a;
18
19
  const shape = schema.shape;
19
20
  function makeMarkedKeysOptional(shape) {
20
- const newShape = {};
21
+ const newShape = zod_1.z.object({}).shape;
21
22
  for (const [key, value] of Object.entries(shape)) {
22
23
  if (isMarkedOptionalForInput(value)) {
23
24
  newShape[key] = value.optional();
@@ -28,15 +29,17 @@ function ResourceInput(schema) {
28
29
  // Recurse one level into nested objects to apply the same optionalization
29
30
  if (value instanceof zod_1.z.ZodObject) {
30
31
  const innerShape = value.shape;
31
- newShape[key] = makeMarkedKeysOptional(innerShape);
32
+ newShape[key] = zod_1.z.object(makeMarkedKeysOptional(innerShape));
32
33
  }
33
34
  else if (value instanceof zod_1.ZodArray) {
34
35
  const arrayElementShape = value.element
35
36
  .shape;
36
- newShape[key] = zod_1.z.array(makeMarkedKeysOptional(arrayElementShape));
37
+ newShape[key] = zod_1.z.array(zod_1.z.object(makeMarkedKeysOptional(arrayElementShape)));
37
38
  }
38
39
  }
39
40
  return newShape;
40
41
  }
41
- return zod_1.z.object(makeMarkedKeysOptional(shape));
42
+ return zod_1.z
43
+ .object(makeMarkedKeysOptional(shape))
44
+ .describe(((_a = schema.description) !== null && _a !== void 0 ? _a : "Unnamed Model") + " Input");
42
45
  }
@@ -9,6 +9,10 @@ function validateData(data, ValidationModel) {
9
9
  if (!ValidationModel.description)
10
10
  throw new Error("ValidationModel.description is required");
11
11
  // writeFileSync("test.json", JSON.stringify(data, null, 2));
12
+ if (!(ValidationModel instanceof zod_1.ZodObject)) {
13
+ console.log(ValidationModel);
14
+ throw new Error("Invalid Zod Model");
15
+ }
12
16
  const validationResult = ValidationModel.safeParse(data);
13
17
  if (!validationResult.success) {
14
18
  const errorObject = {
@@ -31,8 +35,16 @@ function validateData(data, ValidationModel) {
31
35
  }
32
36
  function pickFromSchema(schema, keys) {
33
37
  const pickedShape = keys === null || keys === void 0 ? void 0 : keys.reduce((acc, key) => {
34
- if (key in schema.shape) {
35
- acc[key] = schema.shape[key];
38
+ if (typeof key === "string" && key.includes("as")) {
39
+ const [field, alias] = key.split(" as ");
40
+ if (key in schema.shape) {
41
+ acc[alias] = schema.shape[key];
42
+ }
43
+ }
44
+ else {
45
+ if (key in schema.shape) {
46
+ acc[key] = schema.shape[key];
47
+ }
36
48
  }
37
49
  return acc;
38
50
  }, {});
package/package.json CHANGED
@@ -7,7 +7,12 @@
7
7
  "main": "dist/index.js",
8
8
  "scripts": {
9
9
  "dev": "tsc -w",
10
+ "op:env": "op item get --fields notesPlain 'ERPNext Queue client .env' | sed -e 's/^\"//' -e 's/\"$//' | tee .env > /dev/null",
11
+ "op:env-development": "op item get --fields notesPlain 'ERPNext Queue client .env.development' | sed -e 's/^\"//' -e 's/\"$//' | tee .env.development > /dev/null",
12
+ "op": "op signin --account ehrenkind.1password.com && run-p op:*",
13
+ "ci": "yarn test && yarn lint && yarn typecheck",
10
14
  "test": "dotenv -c test vitest",
15
+ "test-on-staging": "dotenv -c development vitest",
11
16
  "build": "tsc",
12
17
  "release": "npm run build && npm publish"
13
18
  },
@@ -25,7 +30,7 @@
25
30
  "winston": "^3.15.0",
26
31
  "zod": "3.25.76"
27
32
  },
28
- "version": "2.0.0-beta.0",
33
+ "version": "2.0.0-beta.2",
29
34
  "devDependencies": {
30
35
  "@types/crypto-js": "^4.2.2",
31
36
  "@types/lodash": "^4.17.13",
@@ -34,4 +39,4 @@
34
39
  "typescript": "^5.6.3",
35
40
  "vitest": "^2.1.8"
36
41
  }
37
- }
42
+ }