erpnext-queue-client 1.0.6 → 1.1.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 (76) 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 +38 -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 +263 -0
  8. package/dist/erpnext/doctypes/address.js +46 -0
  9. package/dist/erpnext/doctypes/contact.d.ts +383 -0
  10. package/dist/erpnext/doctypes/contact.js +46 -0
  11. package/dist/erpnext/doctypes/deliveryNote.d.ts +985 -0
  12. package/dist/erpnext/doctypes/deliveryNote.js +38 -0
  13. package/dist/erpnext/doctypes/item.d.ts +572 -0
  14. package/dist/erpnext/doctypes/item.js +95 -0
  15. package/dist/erpnext/doctypes/purchaseReceipt.d.ts +743 -0
  16. package/dist/erpnext/doctypes/purchaseReceipt.js +50 -0
  17. package/dist/erpnext/doctypes/shipment.d.ts +752 -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 +4 -4
  37. package/dist/erpnext/model/File.d.ts +88 -88
  38. package/dist/erpnext/model/Fulfiller.d.ts +97 -97
  39. package/dist/erpnext/model/FulfillerSettings.d.ts +66 -66
  40. package/dist/erpnext/model/FulfillmentStation.d.ts +2 -2
  41. package/dist/erpnext/model/Item.d.ts +819 -819
  42. package/dist/erpnext/model/Item.js +2 -2
  43. package/dist/erpnext/model/PaymentEntry.d.ts +197 -0
  44. package/dist/erpnext/model/PaymentEntry.js +63 -0
  45. package/dist/erpnext/model/ProjectedQuantityReport.d.ts +178 -178
  46. package/dist/erpnext/model/PurchaseOrder.d.ts +528 -528
  47. package/dist/erpnext/model/Receipt.d.ts +448 -448
  48. package/dist/erpnext/model/Receipt.js +2 -2
  49. package/dist/erpnext/model/ReceiptDraft.d.ts +392 -392
  50. package/dist/erpnext/model/Shipment.d.ts +709 -709
  51. package/dist/erpnext/model/ShippingProvider.d.ts +198 -198
  52. package/dist/erpnext/model/StockEntry.d.ts +248 -0
  53. package/dist/erpnext/model/StockEntry.js +76 -0
  54. package/dist/erpnext/model/StockReconciliation.d.ts +187 -0
  55. package/dist/erpnext/model/StockReconciliation.js +44 -0
  56. package/dist/erpnext/model/Supplier.d.ts +105 -0
  57. package/dist/erpnext/model/Supplier.js +39 -0
  58. package/dist/erpnext/model/Waitlist.d.ts +32 -0
  59. package/dist/erpnext/model/Waitlist.js +19 -0
  60. package/dist/erpnext/model/WarehouseCategory.d.ts +6 -6
  61. package/dist/erpnext/resourceRequest.d.ts +39 -10
  62. package/dist/erpnext/resourceRequest.js +115 -14
  63. package/dist/index.d.ts +39 -4
  64. package/dist/index.js +43 -8
  65. package/dist/utils/fernet.server.d.ts +11 -11
  66. package/dist/utils/fernet.server.js +0 -1
  67. package/dist/utils/request.js +2 -2
  68. package/dist/utils/zodUtils.d.ts +2 -1
  69. package/dist/utils/zodUtils.js +14 -1
  70. package/package.json +4 -1
  71. package/dist/erpnext/doctypes/country.d.ts +0 -9
  72. package/dist/erpnext/doctypes/country.js +0 -28
  73. package/dist/erpnext/erpnextRequests.d.ts +0 -1
  74. package/dist/erpnext/erpnextRequests.js +0 -15
  75. package/dist/erpnext.d.ts +0 -20
  76. 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,38 @@
1
+ import { z, ZodObject, ZodTypeAny } from "zod";
2
+ import { TemporalClient } from "../client";
3
+ import { ERPNextResourceRequest } from "./resourceRequest";
4
+ export declare class ERPNextDoctypeResourceRequest<T extends ZodObject<any>> {
5
+ protected temporalClient: TemporalClient;
6
+ protected resourceName: string;
7
+ protected resourceModel: ZodTypeAny;
8
+ protected baseRequest: ERPNextResourceRequest;
9
+ constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: ZodTypeAny);
10
+ getList<K extends keyof T["_type"], B extends boolean>({ fields, filters, skip, limit, priority, asDict, params, }: {
11
+ fields?: K[];
12
+ filters?: string[][];
13
+ skip?: number;
14
+ limit?: number;
15
+ priority?: number;
16
+ asDict?: B;
17
+ params?: string;
18
+ }): Promise<B extends false ? Array<Array<string>> : T extends undefined ? any : Array<Pick<z.infer<T>, K extends keyof z.infer<T> ? K : never>>>;
19
+ getById<T extends ZodTypeAny>({ resourceId, priority, }: {
20
+ resourceId: string;
21
+ priority?: number;
22
+ }): Promise<z.TypeOf<T>>;
23
+ updateById<K extends ZodTypeAny>({ resourceId, inputValidationModel, body, priority, }: {
24
+ resourceId: string;
25
+ inputValidationModel?: K;
26
+ priority?: number;
27
+ body: z.TypeOf<K>;
28
+ }): Promise<z.TypeOf<T>>;
29
+ create<K extends ZodTypeAny>({ inputValidationModel, body, priority, }: {
30
+ inputValidationModel?: K;
31
+ priority?: number;
32
+ body: z.TypeOf<K>;
33
+ }): Promise<z.TypeOf<T>>;
34
+ deleteById({ resourceId, priority, }: {
35
+ resourceId: string;
36
+ priority?: number;
37
+ }): Promise<z.TypeOf<T>>;
38
+ }
@@ -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 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 } : {})), (typeof asDict === "boolean" ? { asDict } : {})), (params ? { params } : {})));
24
+ });
25
+ }
26
+ getById(_a) {
27
+ return __awaiter(this, arguments, void 0, function* ({ resourceId, priority = 5, }) {
28
+ return 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 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 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 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<T extends ZodObject<any>> extends ERPNextDoctypeResourceRequest<T> {
5
+ constructor(temporalClient: TemporalClient, resourceName: string, resourceModel: ZodObject<any>);
6
+ cancel(resourceId: string): Promise<import("zod").TypeOf<T>>;
7
+ submit(resourceId: string): Promise<import("zod").TypeOf<T>>;
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,263 @@
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: <K 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"), B extends boolean>({ fields, filters, skip, limit, priority, asDict, params, }: {
8
+ fields?: K[];
9
+ filters?: string[][];
10
+ skip?: number;
11
+ limit?: number;
12
+ priority?: number;
13
+ asDict?: B;
14
+ params?: string;
15
+ }) => Promise<B 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
+ }, K 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") ? K : never>[]>;
62
+ getById: <T extends import("zod").ZodTypeAny>({ resourceId, priority, }: {
63
+ resourceId: string;
64
+ priority?: number;
65
+ }) => Promise<import("zod").TypeOf<T>>;
66
+ updateById: <K extends import("zod").ZodTypeAny>({ resourceId, inputValidationModel, body, priority, }: {
67
+ resourceId: string;
68
+ inputValidationModel?: K;
69
+ priority?: number;
70
+ body: import("zod").TypeOf<K>;
71
+ }) => Promise<{
72
+ name: string;
73
+ address_title: string;
74
+ address_line1: string;
75
+ address_type: string;
76
+ city: string;
77
+ pincode: string;
78
+ country: string;
79
+ email_id: string;
80
+ is_shipping_address: boolean;
81
+ links: {
82
+ name: string;
83
+ link_doctype: string;
84
+ link_name: string;
85
+ owner: string;
86
+ creation: string;
87
+ modified: string;
88
+ modified_by: string;
89
+ parent: string;
90
+ parentfield: string;
91
+ parenttype: string;
92
+ idx: number;
93
+ docstatus: number;
94
+ link_title: string;
95
+ doctype: string;
96
+ }[];
97
+ owner: string;
98
+ creation: string;
99
+ modified: string;
100
+ modified_by: string;
101
+ idx: number;
102
+ docstatus: number;
103
+ doctype: string;
104
+ is_primary_address: boolean;
105
+ is_your_company_address: boolean;
106
+ disabled: boolean;
107
+ address_line2?: string | null | undefined;
108
+ parent?: string | null | undefined;
109
+ parentfield?: string | null | undefined;
110
+ parenttype?: string | null | undefined;
111
+ import_reference?: string | null | undefined;
112
+ state?: string | null | undefined;
113
+ phone?: string | null | undefined;
114
+ fax?: string | null | undefined;
115
+ tax_category?: string | null | undefined;
116
+ county?: string | null | undefined;
117
+ }>;
118
+ deleteById: ({ resourceId, priority, }: {
119
+ resourceId: string;
120
+ priority?: number;
121
+ }) => Promise<{
122
+ name: string;
123
+ address_title: string;
124
+ address_line1: string;
125
+ address_type: string;
126
+ city: string;
127
+ pincode: string;
128
+ country: string;
129
+ email_id: string;
130
+ is_shipping_address: boolean;
131
+ links: {
132
+ name: string;
133
+ link_doctype: string;
134
+ link_name: string;
135
+ owner: string;
136
+ creation: string;
137
+ modified: string;
138
+ modified_by: string;
139
+ parent: string;
140
+ parentfield: string;
141
+ parenttype: string;
142
+ idx: number;
143
+ docstatus: number;
144
+ link_title: string;
145
+ doctype: string;
146
+ }[];
147
+ owner: string;
148
+ creation: string;
149
+ modified: string;
150
+ modified_by: string;
151
+ idx: number;
152
+ docstatus: number;
153
+ doctype: string;
154
+ is_primary_address: boolean;
155
+ is_your_company_address: boolean;
156
+ disabled: boolean;
157
+ address_line2?: string | null | undefined;
158
+ parent?: string | null | undefined;
159
+ parentfield?: string | null | undefined;
160
+ parenttype?: string | null | undefined;
161
+ import_reference?: string | null | undefined;
162
+ state?: string | null | undefined;
163
+ phone?: string | null | undefined;
164
+ fax?: string | null | undefined;
165
+ tax_category?: string | null | undefined;
166
+ county?: string | null | undefined;
167
+ }>;
168
+ constructor(temporalClient: TemporalClient);
169
+ create(address: Omit<AddressPostBodyType, "links">, customerName: string): Promise<{
170
+ name: string;
171
+ address_title: string;
172
+ address_line1: string;
173
+ address_type: string;
174
+ city: string;
175
+ pincode: string;
176
+ country: string;
177
+ email_id: string;
178
+ is_shipping_address: boolean;
179
+ links: {
180
+ name: string;
181
+ link_doctype: string;
182
+ link_name: string;
183
+ owner: string;
184
+ creation: string;
185
+ modified: string;
186
+ modified_by: string;
187
+ parent: string;
188
+ parentfield: string;
189
+ parenttype: string;
190
+ idx: number;
191
+ docstatus: number;
192
+ link_title: string;
193
+ doctype: string;
194
+ }[];
195
+ owner: string;
196
+ creation: string;
197
+ modified: string;
198
+ modified_by: string;
199
+ idx: number;
200
+ docstatus: number;
201
+ doctype: string;
202
+ is_primary_address: boolean;
203
+ is_your_company_address: boolean;
204
+ disabled: boolean;
205
+ address_line2?: string | null | undefined;
206
+ parent?: string | null | undefined;
207
+ parentfield?: string | null | undefined;
208
+ parenttype?: string | null | undefined;
209
+ import_reference?: string | null | undefined;
210
+ state?: string | null | undefined;
211
+ phone?: string | null | undefined;
212
+ fax?: string | null | undefined;
213
+ tax_category?: string | null | undefined;
214
+ county?: string | null | undefined;
215
+ }>;
216
+ getAddressesByEmail: <K extends keyof (typeof Address)["_type"]>(email: string, fields?: K[]) => Promise<string[][] | Pick<{
217
+ name: string;
218
+ address_title: string;
219
+ address_line1: string;
220
+ address_type: string;
221
+ city: string;
222
+ pincode: string;
223
+ country: string;
224
+ email_id: string;
225
+ is_shipping_address: boolean;
226
+ links: {
227
+ name: string;
228
+ link_doctype: string;
229
+ link_name: string;
230
+ owner: string;
231
+ creation: string;
232
+ modified: string;
233
+ modified_by: string;
234
+ parent: string;
235
+ parentfield: string;
236
+ parenttype: string;
237
+ idx: number;
238
+ docstatus: number;
239
+ link_title: string;
240
+ doctype: string;
241
+ }[];
242
+ owner: string;
243
+ creation: string;
244
+ modified: string;
245
+ modified_by: string;
246
+ idx: number;
247
+ docstatus: number;
248
+ doctype: string;
249
+ is_primary_address: boolean;
250
+ is_your_company_address: boolean;
251
+ disabled: boolean;
252
+ address_line2?: string | null | undefined;
253
+ parent?: string | null | undefined;
254
+ parentfield?: string | null | undefined;
255
+ parenttype?: string | null | undefined;
256
+ import_reference?: string | null | undefined;
257
+ state?: string | null | undefined;
258
+ phone?: string | null | undefined;
259
+ fax?: string | null | undefined;
260
+ tax_category?: string | null | undefined;
261
+ county?: string | null | undefined;
262
+ }, K 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") ? K : never>[]>;
263
+ }
@@ -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;