erpnext-queue-client 1.0.6 → 1.1.1

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 (77) hide show
  1. package/dist/client.js +41 -16
  2. package/dist/erpnext/decryptFromErpNext.server.d.ts +1 -1
  3. package/dist/erpnext/doctypeResourceRequest.d.ts +40 -0
  4. package/dist/erpnext/doctypeResourceRequest.js +59 -0
  5. package/dist/erpnext/doctypeSubmittableResourceRequest.d.ts +8 -0
  6. package/dist/erpnext/doctypeSubmittableResourceRequest.js +39 -0
  7. package/dist/erpnext/doctypes/address.d.ts +309 -0
  8. package/dist/erpnext/doctypes/address.js +46 -0
  9. package/dist/erpnext/doctypes/contact.d.ts +453 -0
  10. package/dist/erpnext/doctypes/contact.js +46 -0
  11. package/dist/erpnext/doctypes/deliveryNote.d.ts +1363 -0
  12. package/dist/erpnext/doctypes/deliveryNote.js +38 -0
  13. package/dist/erpnext/doctypes/item.d.ts +836 -0
  14. package/dist/erpnext/doctypes/item.js +95 -0
  15. package/dist/erpnext/doctypes/purchaseReceipt.d.ts +1566 -0
  16. package/dist/erpnext/doctypes/purchaseReceipt.js +51 -0
  17. package/dist/erpnext/doctypes/shipment.d.ts +942 -0
  18. package/dist/erpnext/doctypes/shipment.js +51 -0
  19. package/dist/erpnext/erpnextRequestWrapper.js +15 -13
  20. package/dist/erpnext/fileRequests.d.ts +10 -0
  21. package/dist/erpnext/fileRequests.js +42 -0
  22. package/dist/erpnext/methodRequest.d.ts +15 -0
  23. package/dist/erpnext/methodRequest.js +32 -0
  24. package/dist/erpnext/model/Address.d.ts +200 -198
  25. package/dist/erpnext/model/Address.js +3 -2
  26. package/dist/erpnext/model/Contact.d.ts +343 -344
  27. package/dist/erpnext/model/Contact.js +2 -2
  28. package/dist/erpnext/model/Country.d.ts +83 -31
  29. package/dist/erpnext/model/Country.js +2 -6
  30. package/dist/erpnext/model/Customer.d.ts +64 -65
  31. package/dist/erpnext/model/Customer.js +2 -2
  32. package/dist/erpnext/model/DeliveryNote.d.ts +1048 -1048
  33. package/dist/erpnext/model/DispatchRun.d.ts +399 -399
  34. package/dist/erpnext/model/DispatcherPreset.d.ts +94 -94
  35. package/dist/erpnext/model/ERPNextRequest.d.ts +47 -30
  36. package/dist/erpnext/model/ERPNextResponse.d.ts +11 -4
  37. package/dist/erpnext/model/ERPNextResponse.js +6 -1
  38. package/dist/erpnext/model/File.d.ts +88 -88
  39. package/dist/erpnext/model/Fulfiller.d.ts +97 -97
  40. package/dist/erpnext/model/FulfillerSettings.d.ts +66 -66
  41. package/dist/erpnext/model/FulfillmentStation.d.ts +2 -2
  42. package/dist/erpnext/model/Item.d.ts +819 -819
  43. package/dist/erpnext/model/Item.js +2 -2
  44. package/dist/erpnext/model/PaymentEntry.d.ts +197 -0
  45. package/dist/erpnext/model/PaymentEntry.js +63 -0
  46. package/dist/erpnext/model/ProjectedQuantityReport.d.ts +178 -178
  47. package/dist/erpnext/model/PurchaseOrder.d.ts +528 -528
  48. package/dist/erpnext/model/Receipt.d.ts +448 -448
  49. package/dist/erpnext/model/Receipt.js +2 -2
  50. package/dist/erpnext/model/ReceiptDraft.d.ts +392 -392
  51. package/dist/erpnext/model/Shipment.d.ts +709 -709
  52. package/dist/erpnext/model/ShippingProvider.d.ts +198 -198
  53. package/dist/erpnext/model/StockEntry.d.ts +248 -0
  54. package/dist/erpnext/model/StockEntry.js +76 -0
  55. package/dist/erpnext/model/StockReconciliation.d.ts +187 -0
  56. package/dist/erpnext/model/StockReconciliation.js +44 -0
  57. package/dist/erpnext/model/Supplier.d.ts +105 -0
  58. package/dist/erpnext/model/Supplier.js +39 -0
  59. package/dist/erpnext/model/Waitlist.d.ts +32 -0
  60. package/dist/erpnext/model/Waitlist.js +19 -0
  61. package/dist/erpnext/model/WarehouseCategory.d.ts +6 -6
  62. package/dist/erpnext/resourceRequest.d.ts +41 -10
  63. package/dist/erpnext/resourceRequest.js +113 -14
  64. package/dist/index.d.ts +39 -4
  65. package/dist/index.js +43 -8
  66. package/dist/utils/fernet.server.d.ts +11 -11
  67. package/dist/utils/fernet.server.js +0 -1
  68. package/dist/utils/request.js +2 -2
  69. package/dist/utils/zodUtils.d.ts +3 -1
  70. package/dist/utils/zodUtils.js +14 -1
  71. package/package.json +4 -1
  72. package/dist/erpnext/doctypes/country.d.ts +0 -9
  73. package/dist/erpnext/doctypes/country.js +0 -28
  74. package/dist/erpnext/erpnextRequests.d.ts +0 -1
  75. package/dist/erpnext/erpnextRequests.js +0 -15
  76. package/dist/erpnext.d.ts +0 -20
  77. package/dist/erpnext.js +0 -45
package/dist/client.js CHANGED
@@ -39,15 +39,16 @@ class TemporalClient {
39
39
  tryConnect(temporalHost, temporalCert, temporalKey) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  try {
42
- return yield client_1.Connection.connect({
43
- address: temporalHost,
44
- tls: {
45
- clientCertPair: {
46
- crt: Buffer.from(temporalCert, "base64"),
47
- key: Buffer.from(temporalKey, "base64"),
42
+ return yield client_1.Connection.connect(Object.assign({ address: temporalHost }, (temporalCert && temporalKey
43
+ ? {
44
+ tls: {
45
+ clientCertPair: {
46
+ crt: Buffer.from(temporalCert, "base64"),
47
+ key: Buffer.from(temporalKey, "base64"),
48
+ },
48
49
  },
49
- },
50
- });
50
+ }
51
+ : {})));
51
52
  }
52
53
  catch (err) {
53
54
  return undefined;
@@ -56,17 +57,23 @@ class TemporalClient {
56
57
  }
57
58
  createClient(options) {
58
59
  return __awaiter(this, void 0, void 0, function* () {
59
- const connection = yield this.tryConnect(options.temporalHost, options.temporalCert, options.temporalKey);
60
+ const { temporalCert, temporalHost, temporalKey, temporalNamespace } = options;
61
+ if (!temporalHost)
62
+ throw new Error("No temporal credentials provided");
63
+ const connection = yield this.tryConnect(temporalHost, temporalCert, temporalKey);
60
64
  console.log("Create new client", options.temporalHost);
61
- this.client = new client_1.Client(Object.assign({ connection }, { namespace: options.temporalNamespace || "default" }));
65
+ this.client = new client_1.Client(Object.assign(Object.assign({}, (connection ? { connection } : {})), { namespace: options.temporalNamespace || "default" }));
62
66
  return this.client;
63
67
  });
64
68
  }
65
69
  getClient() {
66
70
  return __awaiter(this, void 0, void 0, function* () {
67
- if (!this.client && !this.options)
71
+ if (this.client)
72
+ return this.client;
73
+ else if (this.options)
74
+ return yield this.createClient(this.options);
75
+ else
68
76
  throw new Error("No client or connection details provided");
69
- return this.client || (yield this.createClient(this.options));
70
77
  });
71
78
  }
72
79
  /**
@@ -78,13 +85,31 @@ class TemporalClient {
78
85
  return;
79
86
  const runId = `${requestName}-${nanoid(4)}`;
80
87
  const client = yield this.getClient();
81
- logger_1.lg.info(`Enqueue to ERPNext Queue: ${options.url || options.uri || ""}${options.methodName || options.resourceName || ""}${options.resourceId || ""}${options.params || ""}`);
82
- const { inputValidationModel, responseValidationModel } = options, optionsWithoutValidation = __rest(options, ["inputValidationModel", "responseValidationModel"]);
83
- if (options.body && inputValidationModel)
88
+ logger_1.lg.info(`Enqueue to ERPNext Queue: ${("url" in options && options.url) ||
89
+ ("uri" in options && options.uri) ||
90
+ ""}${("methodName" in options && options.methodName) ||
91
+ ("resourceName" in options && options.resourceName) ||
92
+ ""}${("resourceId" in options && encodeURIComponent(options.resourceId)) ||
93
+ ""}${options.params || ""}`);
94
+ let optionsWithoutValidationModels = Object.assign({}, options);
95
+ let inputValidationModel;
96
+ let responseValidationModel;
97
+ let body;
98
+ if ("inputValidationModel" in optionsWithoutValidationModels) {
99
+ const { inputValidationModel: a } = optionsWithoutValidationModels, rest = __rest(optionsWithoutValidationModels, ["inputValidationModel"]);
100
+ inputValidationModel = a;
101
+ optionsWithoutValidationModels = rest;
102
+ }
103
+ if ("responseValidationModel" in optionsWithoutValidationModels) {
104
+ const { responseValidationModel: b } = optionsWithoutValidationModels, rest = __rest(optionsWithoutValidationModels, ["responseValidationModel"]);
105
+ responseValidationModel = b;
106
+ optionsWithoutValidationModels = rest;
107
+ }
108
+ if ("body" in options && options.body && inputValidationModel)
84
109
  (0, zodUtils_1.validateData)(options.body, inputValidationModel);
85
110
  const data = yield client.workflow
86
111
  .execute("erpnextRequestWorkflow", {
87
- args: [optionsWithoutValidation],
112
+ args: [optionsWithoutValidationModels],
88
113
  taskQueue: priority < 5 ? `${queue}_priority` : queue, // add to priority queue if priority is 0-5
89
114
  workflowId: runId,
90
115
  })
@@ -1,2 +1,2 @@
1
1
  import { ERPNextCredentials } from "./model/ERPNextQueue";
2
- export declare function decryptFromErpNext(credentials: ERPNextCredentials, encryptedPassword: string): string;
2
+ export declare function decryptFromErpNext(credentials: ERPNextCredentials | undefined, encryptedPassword: string): string;
@@ -0,0 +1,40 @@
1
+ import { z, ZodObject, ZodTypeAny } from "zod";
2
+ import { TemporalClient } from "../client";
3
+ import { ERPNextResourceRequest } from "./resourceRequest";
4
+ import { KeysOf } from "../utils/zodUtils";
5
+ import { DeleteResponseModel } from "./model/ERPNextResponse";
6
+ export declare class ERPNextDoctypeResourceRequest<TModel extends ZodObject<any>> {
7
+ protected temporalClient: TemporalClient;
8
+ protected resourceName: string;
9
+ protected resourceModel: TModel;
10
+ protected baseRequest: ERPNextResourceRequest;
11
+ constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: TModel);
12
+ getList<TField extends KeysOf<TModel>, TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }: {
13
+ fields?: TField[] | undefined;
14
+ filters?: string[][];
15
+ skip?: number;
16
+ limit?: number;
17
+ priority?: number;
18
+ asDict?: TAsDict;
19
+ params?: string;
20
+ }): Promise<TAsDict extends false ? Array<Array<string>> : typeof fields extends undefined ? Array<Pick<z.infer<TModel>, "name">> : Array<Pick<z.infer<TModel>, TField>>>;
21
+ getById({ resourceId, priority, }: {
22
+ resourceId: string;
23
+ priority?: number;
24
+ }): Promise<z.TypeOf<TModel>>;
25
+ updateById<TInput extends TInputModel extends undefined ? Partial<z.TypeOf<TModel>> : TInputModel extends ZodTypeAny ? z.TypeOf<TInputModel> : any, TInputModel extends ZodTypeAny | undefined = undefined>({ resourceId, inputValidationModel, body, priority, }: {
26
+ resourceId: string;
27
+ inputValidationModel?: TInputModel;
28
+ priority?: number;
29
+ body: TInput;
30
+ }): Promise<z.TypeOf<TModel>>;
31
+ create<TInput extends TInputModel extends undefined ? Partial<z.TypeOf<TModel>> : TInputModel extends ZodTypeAny ? z.TypeOf<TInputModel> : any, TInputModel extends ZodTypeAny | undefined = undefined>({ inputValidationModel, body, priority, }: {
32
+ inputValidationModel?: TInputModel;
33
+ priority?: number;
34
+ body: TInput;
35
+ }): Promise<z.TypeOf<TModel>>;
36
+ deleteById({ resourceId, priority, }: {
37
+ resourceId: string;
38
+ priority?: number;
39
+ }): Promise<z.TypeOf<typeof DeleteResponseModel>>;
40
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ERPNextDoctypeResourceRequest = void 0;
13
+ const resourceRequest_1 = require("./resourceRequest");
14
+ class ERPNextDoctypeResourceRequest {
15
+ constructor(temporalClient, resourceName, resourceModel) {
16
+ this.temporalClient = temporalClient;
17
+ this.resourceName = resourceName;
18
+ this.resourceModel = resourceModel;
19
+ this.baseRequest = new resourceRequest_1.ERPNextResourceRequest(this.temporalClient);
20
+ }
21
+ getList(_a) {
22
+ return __awaiter(this, arguments, void 0, function* ({ fields, filters, skip, limit, priority = 5, asDict, params, }) {
23
+ return yield this.baseRequest.getList(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ resourceName: this.resourceName, resourceModel: this.resourceModel, priority }, (fields ? { fields } : {})), (filters ? { filters } : {})), (limit ? { limit } : {})), (skip ? { skip } : {})), (params ? { params } : {})), (asDict ? { asDict } : {})));
24
+ });
25
+ }
26
+ getById(_a) {
27
+ return __awaiter(this, arguments, void 0, function* ({ resourceId, priority = 5, }) {
28
+ return yield this.baseRequest.getById({
29
+ resourceName: this.resourceName,
30
+ resourceId,
31
+ resourceModel: this.resourceModel,
32
+ priority,
33
+ });
34
+ });
35
+ }
36
+ updateById(_a) {
37
+ return __awaiter(this, arguments, void 0, function* ({ resourceId, inputValidationModel, body, priority = 5, }) {
38
+ return yield this.baseRequest.updateById(Object.assign(Object.assign({ resourceName: this.resourceName, resourceId }, (inputValidationModel ? { inputValidationModel } : {})), { resourceModel: this.resourceModel, body,
39
+ priority }));
40
+ });
41
+ }
42
+ create(_a) {
43
+ return __awaiter(this, arguments, void 0, function* ({ inputValidationModel, body, priority = 5, }) {
44
+ return yield this.baseRequest.create(Object.assign(Object.assign({ resourceName: this.resourceName }, (inputValidationModel ? { inputValidationModel } : {})), { resourceModel: this.resourceModel, body,
45
+ priority }));
46
+ });
47
+ }
48
+ deleteById(_a) {
49
+ return __awaiter(this, arguments, void 0, function* ({ resourceId, priority = 5, }) {
50
+ return yield this.baseRequest.deleteById({
51
+ resourceName: this.resourceName,
52
+ resourceId,
53
+ resourceModel: this.resourceModel,
54
+ priority,
55
+ });
56
+ });
57
+ }
58
+ }
59
+ exports.ERPNextDoctypeResourceRequest = ERPNextDoctypeResourceRequest;
@@ -0,0 +1,8 @@
1
+ import { ZodObject } from "zod";
2
+ import { ERPNextDoctypeResourceRequest } from "./doctypeResourceRequest";
3
+ import { TemporalClient } from "../client";
4
+ export declare class ERPNextDoctypeSubmittableResourceRequest<TModel extends ZodObject<any>> extends ERPNextDoctypeResourceRequest<TModel> {
5
+ constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: TModel);
6
+ cancel(resourceId: string): Promise<import("zod").TypeOf<TModel>>;
7
+ submit(resourceId: string): Promise<import("zod").TypeOf<TModel>>;
8
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ERPNextDoctypeSubmittableResourceRequest = void 0;
13
+ const doctypeResourceRequest_1 = require("./doctypeResourceRequest");
14
+ class ERPNextDoctypeSubmittableResourceRequest extends doctypeResourceRequest_1.ERPNextDoctypeResourceRequest {
15
+ constructor(temporalClient, resourceName, resourceModel) {
16
+ super(temporalClient, resourceName, resourceModel);
17
+ }
18
+ cancel(resourceId) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return this.updateById({
21
+ resourceId,
22
+ body: {
23
+ docstatus: 2,
24
+ },
25
+ });
26
+ });
27
+ }
28
+ submit(resourceId) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this.updateById({
31
+ resourceId,
32
+ body: {
33
+ docstatus: 1,
34
+ },
35
+ });
36
+ });
37
+ }
38
+ }
39
+ exports.ERPNextDoctypeSubmittableResourceRequest = ERPNextDoctypeSubmittableResourceRequest;
@@ -0,0 +1,309 @@
1
+ import { TemporalClient } from "../../client";
2
+ import { ERPNextDoctypeResourceRequest } from "../doctypeResourceRequest";
3
+ import { Address, AddressPostBodyType } from "../model/Address";
4
+ export declare class ERPNextAddress {
5
+ protected temporalClient: TemporalClient;
6
+ protected baseRequest: ERPNextDoctypeResourceRequest<typeof Address>;
7
+ getList: <TField extends ("name" | "address_title" | "address_line1" | "address_type" | "city" | "pincode" | "country" | "email_id" | "is_shipping_address" | "links" | "owner" | "creation" | "modified" | "modified_by" | "idx" | "docstatus" | "doctype" | "is_primary_address" | "is_your_company_address" | "disabled") | ("address_line2" | "parent" | "parentfield" | "parenttype" | "import_reference" | "state" | "phone" | "fax" | "tax_category" | "county"), TAsDict extends boolean | undefined = undefined>({ fields, filters, skip, limit, priority, asDict, params, }: {
8
+ fields?: TField[] | undefined;
9
+ filters?: string[][];
10
+ skip?: number;
11
+ limit?: number;
12
+ priority?: number;
13
+ asDict?: TAsDict;
14
+ params?: string;
15
+ }) => Promise<TAsDict extends false ? string[][] : Pick<{
16
+ name: string;
17
+ address_title: string;
18
+ address_line1: string;
19
+ address_type: string;
20
+ city: string;
21
+ pincode: string;
22
+ country: string;
23
+ email_id: string;
24
+ is_shipping_address: boolean;
25
+ links: {
26
+ name: string;
27
+ link_doctype: string;
28
+ link_name: string;
29
+ owner: string;
30
+ creation: string;
31
+ modified: string;
32
+ modified_by: string;
33
+ parent: string;
34
+ parentfield: string;
35
+ parenttype: string;
36
+ idx: number;
37
+ docstatus: number;
38
+ link_title: string;
39
+ doctype: string;
40
+ }[];
41
+ owner: string;
42
+ creation: string;
43
+ modified: string;
44
+ modified_by: string;
45
+ idx: number;
46
+ docstatus: number;
47
+ doctype: string;
48
+ is_primary_address: boolean;
49
+ is_your_company_address: boolean;
50
+ disabled: boolean;
51
+ address_line2?: string | null | undefined;
52
+ parent?: string | null | undefined;
53
+ parentfield?: string | null | undefined;
54
+ parenttype?: string | null | undefined;
55
+ import_reference?: string | null | undefined;
56
+ state?: string | null | undefined;
57
+ phone?: string | null | undefined;
58
+ fax?: string | null | undefined;
59
+ tax_category?: string | null | undefined;
60
+ county?: string | null | undefined;
61
+ }, TField>[]>;
62
+ getById: ({ resourceId, priority, }: {
63
+ resourceId: string;
64
+ priority?: number;
65
+ }) => Promise<{
66
+ name: string;
67
+ address_title: string;
68
+ address_line1: string;
69
+ address_type: string;
70
+ city: string;
71
+ pincode: string;
72
+ country: string;
73
+ email_id: string;
74
+ is_shipping_address: boolean;
75
+ links: {
76
+ name: string;
77
+ link_doctype: string;
78
+ link_name: string;
79
+ owner: string;
80
+ creation: string;
81
+ modified: string;
82
+ modified_by: string;
83
+ parent: string;
84
+ parentfield: string;
85
+ parenttype: string;
86
+ idx: number;
87
+ docstatus: number;
88
+ link_title: string;
89
+ doctype: string;
90
+ }[];
91
+ owner: string;
92
+ creation: string;
93
+ modified: string;
94
+ modified_by: string;
95
+ idx: number;
96
+ docstatus: number;
97
+ doctype: string;
98
+ is_primary_address: boolean;
99
+ is_your_company_address: boolean;
100
+ disabled: boolean;
101
+ address_line2?: string | null | undefined;
102
+ parent?: string | null | undefined;
103
+ parentfield?: string | null | undefined;
104
+ parenttype?: string | null | undefined;
105
+ import_reference?: string | null | undefined;
106
+ state?: string | null | undefined;
107
+ phone?: string | null | undefined;
108
+ fax?: string | null | undefined;
109
+ tax_category?: string | null | undefined;
110
+ county?: string | null | undefined;
111
+ }>;
112
+ updateById: <TInput extends TInputModel extends undefined ? Partial<{
113
+ name: string;
114
+ address_title: string;
115
+ address_line1: string;
116
+ address_type: string;
117
+ city: string;
118
+ pincode: string;
119
+ country: string;
120
+ email_id: string;
121
+ is_shipping_address: boolean;
122
+ links: {
123
+ name: string;
124
+ link_doctype: string;
125
+ link_name: string;
126
+ owner: string;
127
+ creation: string;
128
+ modified: string;
129
+ modified_by: string;
130
+ parent: string;
131
+ parentfield: string;
132
+ parenttype: string;
133
+ idx: number;
134
+ docstatus: number;
135
+ link_title: string;
136
+ doctype: string;
137
+ }[];
138
+ owner: string;
139
+ creation: string;
140
+ modified: string;
141
+ modified_by: string;
142
+ idx: number;
143
+ docstatus: number;
144
+ doctype: string;
145
+ is_primary_address: boolean;
146
+ is_your_company_address: boolean;
147
+ disabled: boolean;
148
+ address_line2?: string | null | undefined;
149
+ parent?: string | null | undefined;
150
+ parentfield?: string | null | undefined;
151
+ parenttype?: string | null | undefined;
152
+ import_reference?: string | null | undefined;
153
+ state?: string | null | undefined;
154
+ phone?: string | null | undefined;
155
+ fax?: string | null | undefined;
156
+ tax_category?: string | null | undefined;
157
+ county?: string | null | undefined;
158
+ }> : TInputModel extends import("zod").ZodTypeAny ? import("zod").TypeOf<TInputModel> : any, TInputModel extends import("zod").ZodTypeAny | undefined = undefined>({ resourceId, inputValidationModel, body, priority, }: {
159
+ resourceId: string;
160
+ inputValidationModel?: TInputModel;
161
+ priority?: number;
162
+ body: TInput;
163
+ }) => Promise<{
164
+ name: string;
165
+ address_title: string;
166
+ address_line1: string;
167
+ address_type: string;
168
+ city: string;
169
+ pincode: string;
170
+ country: string;
171
+ email_id: string;
172
+ is_shipping_address: boolean;
173
+ links: {
174
+ name: string;
175
+ link_doctype: string;
176
+ link_name: string;
177
+ owner: string;
178
+ creation: string;
179
+ modified: string;
180
+ modified_by: string;
181
+ parent: string;
182
+ parentfield: string;
183
+ parenttype: string;
184
+ idx: number;
185
+ docstatus: number;
186
+ link_title: string;
187
+ doctype: string;
188
+ }[];
189
+ owner: string;
190
+ creation: string;
191
+ modified: string;
192
+ modified_by: string;
193
+ idx: number;
194
+ docstatus: number;
195
+ doctype: string;
196
+ is_primary_address: boolean;
197
+ is_your_company_address: boolean;
198
+ disabled: boolean;
199
+ address_line2?: string | null | undefined;
200
+ parent?: string | null | undefined;
201
+ parentfield?: string | null | undefined;
202
+ parenttype?: string | null | undefined;
203
+ import_reference?: string | null | undefined;
204
+ state?: string | null | undefined;
205
+ phone?: string | null | undefined;
206
+ fax?: string | null | undefined;
207
+ tax_category?: string | null | undefined;
208
+ county?: string | null | undefined;
209
+ }>;
210
+ deleteById: ({ resourceId, priority, }: {
211
+ resourceId: string;
212
+ priority?: number;
213
+ }) => Promise<import("zod").TypeOf<typeof import("../model/ERPNextResponse").DeleteResponseModel>>;
214
+ constructor(temporalClient: TemporalClient);
215
+ create(address: Omit<AddressPostBodyType, "links">, customerName: string): Promise<{
216
+ name: string;
217
+ address_title: string;
218
+ address_line1: string;
219
+ address_type: string;
220
+ city: string;
221
+ pincode: string;
222
+ country: string;
223
+ email_id: string;
224
+ is_shipping_address: boolean;
225
+ links: {
226
+ name: string;
227
+ link_doctype: string;
228
+ link_name: string;
229
+ owner: string;
230
+ creation: string;
231
+ modified: string;
232
+ modified_by: string;
233
+ parent: string;
234
+ parentfield: string;
235
+ parenttype: string;
236
+ idx: number;
237
+ docstatus: number;
238
+ link_title: string;
239
+ doctype: string;
240
+ }[];
241
+ owner: string;
242
+ creation: string;
243
+ modified: string;
244
+ modified_by: string;
245
+ idx: number;
246
+ docstatus: number;
247
+ doctype: string;
248
+ is_primary_address: boolean;
249
+ is_your_company_address: boolean;
250
+ disabled: boolean;
251
+ address_line2?: string | null | undefined;
252
+ parent?: string | null | undefined;
253
+ parentfield?: string | null | undefined;
254
+ parenttype?: string | null | undefined;
255
+ import_reference?: string | null | undefined;
256
+ state?: string | null | undefined;
257
+ phone?: string | null | undefined;
258
+ fax?: string | null | undefined;
259
+ tax_category?: string | null | undefined;
260
+ county?: string | null | undefined;
261
+ }>;
262
+ getAddressesByEmail: <K extends keyof (typeof Address)["_type"]>(email: string, fields?: K[]) => Promise<Pick<{
263
+ name: string;
264
+ address_title: string;
265
+ address_line1: string;
266
+ address_type: string;
267
+ city: string;
268
+ pincode: string;
269
+ country: string;
270
+ email_id: string;
271
+ is_shipping_address: boolean;
272
+ links: {
273
+ name: string;
274
+ link_doctype: string;
275
+ link_name: string;
276
+ owner: string;
277
+ creation: string;
278
+ modified: string;
279
+ modified_by: string;
280
+ parent: string;
281
+ parentfield: string;
282
+ parenttype: string;
283
+ idx: number;
284
+ docstatus: number;
285
+ link_title: string;
286
+ doctype: string;
287
+ }[];
288
+ owner: string;
289
+ creation: string;
290
+ modified: string;
291
+ modified_by: string;
292
+ idx: number;
293
+ docstatus: number;
294
+ doctype: string;
295
+ is_primary_address: boolean;
296
+ is_your_company_address: boolean;
297
+ disabled: boolean;
298
+ address_line2?: string | null | undefined;
299
+ parent?: string | null | undefined;
300
+ parentfield?: string | null | undefined;
301
+ parenttype?: string | null | undefined;
302
+ import_reference?: string | null | undefined;
303
+ state?: string | null | undefined;
304
+ phone?: string | null | undefined;
305
+ fax?: string | null | undefined;
306
+ tax_category?: string | null | undefined;
307
+ county?: string | null | undefined;
308
+ }, K>[]>;
309
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ERPNextAddress = void 0;
13
+ const doctypeResourceRequest_1 = require("../doctypeResourceRequest");
14
+ const Address_1 = require("../model/Address");
15
+ class ERPNextAddress {
16
+ constructor(temporalClient) {
17
+ this.getAddressesByEmail = (email_1, ...args_1) => __awaiter(this, [email_1, ...args_1], void 0, function* (email, fields = ["name"]) {
18
+ const result = yield this.getList({
19
+ fields,
20
+ filters: [["email_id", "=", email]],
21
+ });
22
+ return result;
23
+ });
24
+ this.temporalClient = temporalClient;
25
+ this.baseRequest = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(temporalClient, "Address", Address_1.Address);
26
+ this.getList = this.baseRequest.getList;
27
+ this.getById = this.baseRequest.getById;
28
+ this.updateById = this.baseRequest.updateById;
29
+ this.deleteById = this.baseRequest.deleteById;
30
+ }
31
+ create(address, customerName) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const result = yield this.baseRequest.create({
34
+ inputValidationModel: Address_1.AddressPostBody,
35
+ body: Object.assign(Object.assign({}, address), { links: [
36
+ {
37
+ link_doctype: "Customer",
38
+ link_name: customerName,
39
+ },
40
+ ] }),
41
+ });
42
+ return result;
43
+ });
44
+ }
45
+ }
46
+ exports.ERPNextAddress = ERPNextAddress;