erpnext-queue-client 1.0.5 → 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.
- package/dist/client.d.ts +6 -16
- package/dist/client.js +51 -51
- package/dist/erpnext/decryptFromErpNext.server.d.ts +1 -1
- package/dist/erpnext/decryptFromErpNext.server.test.js +3 -3
- package/dist/erpnext/doctypeResourceRequest.d.ts +38 -0
- package/dist/erpnext/doctypeResourceRequest.js +59 -0
- package/dist/erpnext/doctypeSubmittableResourceRequest.d.ts +8 -0
- package/dist/erpnext/doctypeSubmittableResourceRequest.js +39 -0
- package/dist/erpnext/doctypes/address.d.ts +263 -0
- package/dist/erpnext/doctypes/address.js +46 -0
- package/dist/erpnext/doctypes/contact.d.ts +383 -0
- package/dist/erpnext/doctypes/contact.js +46 -0
- package/dist/erpnext/doctypes/deliveryNote.d.ts +985 -0
- package/dist/erpnext/doctypes/deliveryNote.js +38 -0
- package/dist/erpnext/doctypes/item.d.ts +572 -0
- package/dist/erpnext/doctypes/item.js +95 -0
- package/dist/erpnext/doctypes/purchaseReceipt.d.ts +743 -0
- package/dist/erpnext/doctypes/purchaseReceipt.js +50 -0
- package/dist/erpnext/doctypes/shipment.d.ts +752 -0
- package/dist/erpnext/doctypes/shipment.js +51 -0
- package/dist/erpnext/erpnextRequestWrapper.js +15 -13
- package/dist/erpnext/fileRequests.d.ts +10 -0
- package/dist/erpnext/fileRequests.js +42 -0
- package/dist/erpnext/methodRequest.d.ts +15 -0
- package/dist/erpnext/methodRequest.js +32 -0
- package/dist/erpnext/model/Address.d.ts +200 -198
- package/dist/erpnext/model/Address.js +3 -2
- package/dist/erpnext/model/Contact.d.ts +343 -344
- package/dist/erpnext/model/Contact.js +2 -2
- package/dist/erpnext/model/Country.d.ts +83 -31
- package/dist/erpnext/model/Country.js +2 -6
- package/dist/erpnext/model/Customer.d.ts +64 -65
- package/dist/erpnext/model/Customer.js +2 -2
- package/dist/erpnext/model/DeliveryNote.d.ts +1048 -1048
- package/dist/erpnext/model/DispatchRun.d.ts +399 -399
- package/dist/erpnext/model/DispatcherPreset.d.ts +94 -94
- package/dist/erpnext/model/ERPNextQueue.d.ts +8 -7
- package/dist/erpnext/model/ERPNextRequest.d.ts +55 -21
- package/dist/erpnext/model/ERPNextResponse.d.ts +4 -4
- package/dist/erpnext/model/File.d.ts +88 -88
- package/dist/erpnext/model/Fulfiller.d.ts +97 -97
- package/dist/erpnext/model/FulfillerSettings.d.ts +66 -66
- package/dist/erpnext/model/FulfillmentStation.d.ts +2 -2
- package/dist/erpnext/model/Item.d.ts +821 -821
- package/dist/erpnext/model/Item.js +2 -2
- package/dist/erpnext/model/PaymentEntry.d.ts +197 -0
- package/dist/erpnext/model/PaymentEntry.js +63 -0
- package/dist/erpnext/model/ProjectedQuantityReport.d.ts +178 -178
- package/dist/erpnext/model/PurchaseOrder.d.ts +534 -534
- package/dist/erpnext/model/Receipt.d.ts +456 -456
- package/dist/erpnext/model/Receipt.js +2 -2
- package/dist/erpnext/model/ReceiptDraft.d.ts +394 -394
- package/dist/erpnext/model/Shipment.d.ts +708 -708
- package/dist/erpnext/model/ShippingProvider.d.ts +198 -198
- package/dist/erpnext/model/StockEntry.d.ts +248 -0
- package/dist/erpnext/model/StockEntry.js +76 -0
- package/dist/erpnext/model/StockReconciliation.d.ts +187 -0
- package/dist/erpnext/model/StockReconciliation.js +44 -0
- package/dist/erpnext/model/Supplier.d.ts +105 -0
- package/dist/erpnext/model/Supplier.js +39 -0
- package/dist/erpnext/model/Waitlist.d.ts +32 -0
- package/dist/erpnext/model/Waitlist.js +19 -0
- package/dist/erpnext/model/WarehouseCategory.d.ts +6 -6
- package/dist/erpnext/resourceRequest.d.ts +45 -0
- package/dist/erpnext/resourceRequest.js +135 -0
- package/dist/index.d.ts +52 -1
- package/dist/index.js +56 -12
- package/dist/utils/fernet.server.d.ts +11 -11
- package/dist/utils/fernet.server.js +0 -1
- package/dist/utils/request.js +2 -2
- package/dist/utils/zodUtils.d.ts +2 -1
- package/dist/utils/zodUtils.js +14 -1
- package/package.json +4 -1
- package/dist/erpnext/erpnextRequests.d.ts +0 -1786
- package/dist/erpnext/erpnextRequests.js +0 -339
package/dist/client.d.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { TypeOf, ZodTypeAny } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { ERPNextQueueType, TemporalClientContructorOptions } from "./erpnext/model/ERPNextQueue";
|
|
3
3
|
import { ERPNextRequestOptions } from "./erpnext/model/ERPNextRequest";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @description Provide either a temporal client or connection details to create a new client
|
|
7
|
-
*/
|
|
8
|
-
export declare class ERPNextClient {
|
|
4
|
+
export declare class TemporalClient {
|
|
9
5
|
private client;
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
constructor(options: ERPNextQueueClientContructorOptions);
|
|
6
|
+
private options;
|
|
7
|
+
constructor(options: TemporalClientContructorOptions);
|
|
13
8
|
private tryConnect;
|
|
14
9
|
private createClient;
|
|
15
10
|
private getClient;
|
|
16
11
|
/**
|
|
17
|
-
* @description Execute
|
|
12
|
+
* @description Execute a ERPNext request workflow, 0 is the highest priority, 5 is default
|
|
18
13
|
*/
|
|
19
|
-
|
|
20
|
-
utils: {
|
|
21
|
-
decryptFromErpNext: (encryptedPassword: string) => string;
|
|
22
|
-
executeERPNextRequestWithoutTemporalQueue: <T extends ZodTypeAny, K extends ZodTypeAny>(options: ERPNextRequestOptions<T, K>) => Promise<TypeOf<T>>;
|
|
23
|
-
executeERPNextRequestDownloadFile: <T extends ZodTypeAny, K extends ZodTypeAny>(url: string) => Promise<Buffer<ArrayBufferLike>>;
|
|
24
|
-
};
|
|
14
|
+
executeERPNextRequestWorkflow<T extends ZodTypeAny, K extends ZodTypeAny>(requestName: string, options: ERPNextRequestOptions<T, K>, queue: ERPNextQueueType, priority?: number): Promise<TypeOf<T>>;
|
|
25
15
|
}
|
package/dist/client.js
CHANGED
|
@@ -20,60 +20,35 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
23
|
+
exports.TemporalClient = void 0;
|
|
24
24
|
const client_1 = require("@temporalio/client");
|
|
25
25
|
const logger_1 = require("./utils/logger");
|
|
26
26
|
const zodUtils_1 = require("./utils/zodUtils");
|
|
27
27
|
const nanoid_1 = require("nanoid");
|
|
28
|
-
const erpnextRequestWrapper_1 = require("./erpnext/erpnextRequestWrapper");
|
|
29
|
-
const erpnextRequests_1 = require("./erpnext/erpnextRequests");
|
|
30
|
-
const decryptFromErpNext_server_1 = require("./erpnext/decryptFromErpNext.server");
|
|
31
28
|
const nanoid = (0, nanoid_1.customAlphabet)("1234567890", 4);
|
|
32
|
-
|
|
33
|
-
* @description Provide either a temporal client or connection details to create a new client
|
|
34
|
-
*/
|
|
35
|
-
class ERPNextClient {
|
|
29
|
+
class TemporalClient {
|
|
36
30
|
constructor(options) {
|
|
37
|
-
|
|
38
|
-
decryptFromErpNext: (encryptedPassword) => {
|
|
39
|
-
return (0, decryptFromErpNext_server_1.decryptFromErpNext)(this.credentials, encryptedPassword);
|
|
40
|
-
},
|
|
41
|
-
executeERPNextRequestWithoutTemporalQueue: (options) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
if (!this.credentials)
|
|
43
|
-
throw new Error("Direct API connection not possible. Please provide ERPNext API credentials.");
|
|
44
|
-
return yield (0, erpnextRequestWrapper_1.erpnextRequest)(this.credentials, options);
|
|
45
|
-
}),
|
|
46
|
-
executeERPNextRequestDownloadFile: (url) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (!this.credentials)
|
|
48
|
-
throw new Error("File download not possible. Please provide ERPNext API credentials.");
|
|
49
|
-
return yield (0, erpnextRequestWrapper_1.erpNextDownloadFile)(this.credentials, url);
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
52
|
-
const { client, erpnextCredentials, temporalCredentials } = options;
|
|
53
|
-
// Optional: initialize with ERPNext credentials for direct ERPNext connection
|
|
54
|
-
if (erpnextCredentials)
|
|
55
|
-
this.credentials = erpnextCredentials;
|
|
56
|
-
// Use existing client or create a new one
|
|
31
|
+
const { client } = options, clientOptions = __rest(options, ["client"]);
|
|
57
32
|
if (client)
|
|
58
33
|
this.client = client;
|
|
59
|
-
else if (
|
|
60
|
-
this.
|
|
34
|
+
else if (clientOptions.temporalHost)
|
|
35
|
+
this.options = clientOptions;
|
|
61
36
|
else
|
|
62
37
|
throw new Error("No client or connection details provided");
|
|
63
|
-
this.erpnext = (0, erpnextRequests_1.erpnextRequests)(this);
|
|
64
38
|
}
|
|
65
39
|
tryConnect(temporalHost, temporalCert, temporalKey) {
|
|
66
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
41
|
try {
|
|
68
|
-
return yield client_1.Connection.connect({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
},
|
|
74
49
|
},
|
|
75
|
-
}
|
|
76
|
-
|
|
50
|
+
}
|
|
51
|
+
: {})));
|
|
77
52
|
}
|
|
78
53
|
catch (err) {
|
|
79
54
|
return undefined;
|
|
@@ -82,34 +57,59 @@ class ERPNextClient {
|
|
|
82
57
|
}
|
|
83
58
|
createClient(options) {
|
|
84
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const
|
|
86
|
-
|
|
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);
|
|
64
|
+
console.log("Create new client", options.temporalHost);
|
|
65
|
+
this.client = new client_1.Client(Object.assign(Object.assign({}, (connection ? { connection } : {})), { namespace: options.temporalNamespace || "default" }));
|
|
87
66
|
return this.client;
|
|
88
67
|
});
|
|
89
68
|
}
|
|
90
|
-
getClient(
|
|
69
|
+
getClient() {
|
|
91
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
if (
|
|
71
|
+
if (this.client)
|
|
72
|
+
return this.client;
|
|
73
|
+
else if (this.options)
|
|
74
|
+
return yield this.createClient(this.options);
|
|
75
|
+
else
|
|
93
76
|
throw new Error("No client or connection details provided");
|
|
94
|
-
return this.client || (yield this.createClient(options));
|
|
95
77
|
});
|
|
96
78
|
}
|
|
97
79
|
/**
|
|
98
|
-
* @description Execute
|
|
80
|
+
* @description Execute a ERPNext request workflow, 0 is the highest priority, 5 is default
|
|
99
81
|
*/
|
|
100
|
-
|
|
82
|
+
executeERPNextRequestWorkflow(requestName_1, options_1, queue_1) {
|
|
101
83
|
return __awaiter(this, arguments, void 0, function* (requestName, options, queue, priority = 5) {
|
|
102
84
|
if (process.env.NODE_ENV === "test")
|
|
103
85
|
return;
|
|
104
86
|
const runId = `${requestName}-${nanoid(4)}`;
|
|
105
87
|
const client = yield this.getClient();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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)
|
|
109
109
|
(0, zodUtils_1.validateData)(options.body, inputValidationModel);
|
|
110
110
|
const data = yield client.workflow
|
|
111
111
|
.execute("erpnextRequestWorkflow", {
|
|
112
|
-
args: [
|
|
112
|
+
args: [optionsWithoutValidationModels],
|
|
113
113
|
taskQueue: priority < 5 ? `${queue}_priority` : queue, // add to priority queue if priority is 0-5
|
|
114
114
|
workflowId: runId,
|
|
115
115
|
})
|
|
@@ -138,4 +138,4 @@ class ERPNextClient {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
exports.
|
|
141
|
+
exports.TemporalClient = TemporalClient;
|
|
@@ -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;
|
|
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const __1 = require("..");
|
|
13
13
|
describe("decryptFromErpNext", () => {
|
|
14
14
|
test("should decrypt password", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const { utils
|
|
15
|
+
const { utils } = new __1.ERPNextQueueClient({
|
|
16
16
|
temporalCredentials: {
|
|
17
17
|
temporalHost: "temporalHost",
|
|
18
18
|
},
|
|
@@ -24,7 +24,7 @@ describe("decryptFromErpNext", () => {
|
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
const encryptedPassword = "gAAAAABjW77Rn3UP_3CZISSag2bsrq0huYiN5kavTd_2fUJUkcQd3tsrbsIbLk82TkqFKbwC1BnEP9iXKMQ-DrlIlLyIvZiwag==";
|
|
27
|
-
const decryptedPassword = decryptFromErpNext(encryptedPassword);
|
|
27
|
+
const decryptedPassword = utils.decryptFromErpNext(encryptedPassword);
|
|
28
28
|
expect(decryptedPassword).toBe("12345");
|
|
29
29
|
}));
|
|
30
30
|
});
|
|
@@ -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
|
+
}
|