@eleva-io/erp-sdk 0.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/client.d.ts +11 -0
- package/dist/client/client.js +41 -0
- package/dist/client/http.d.ts +12 -0
- package/dist/client/http.js +80 -0
- package/dist/client/resources/horizontal/api.d.ts +8 -0
- package/dist/client/resources/horizontal/api.js +28 -0
- package/dist/client/resources/horizontal/communities/api.d.ts +12 -0
- package/dist/client/resources/horizontal/communities/api.js +34 -0
- package/dist/client/resources/horizontal/communities/types.d.ts +49 -0
- package/dist/client/resources/horizontal/communities/types.js +2 -0
- package/dist/client/resources/tasks/api.d.ts +18 -0
- package/dist/client/resources/tasks/api.js +54 -0
- package/dist/client/resources/tasks/types.d.ts +58 -0
- package/dist/client/resources/tasks/types.js +24 -0
- package/dist/client/resources/ticketing/api.d.ts +18 -0
- package/dist/client/resources/ticketing/api.js +54 -0
- package/dist/client/resources/ticketing/types.d.ts +61 -0
- package/dist/client/resources/ticketing/types.js +24 -0
- package/dist/client/resources/types.d.ts +12 -0
- package/dist/client/resources/types.js +2 -0
- package/dist/client/utils/signature.d.ts +5 -0
- package/dist/client/utils/signature.js +19 -0
- package/dist/erp.d.ts +14 -0
- package/dist/erp.js +27 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/tasks/creator.d.ts +9 -0
- package/dist/tasks/creator.js +25 -0
- package/dist/tasks/std.d.ts +36 -0
- package/dist/tasks/std.js +79 -0
- package/dist/tasks/template.d.ts +43 -0
- package/dist/tasks/template.js +56 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.js +2 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +2 -0
- package/package.json +42 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HorizontalAPI } from "./resources/horizontal/api";
|
|
2
|
+
import { TicketingAPI } from "./resources/ticketing/api";
|
|
3
|
+
export * from "./resources/ticketing/types";
|
|
4
|
+
export declare class ERPClient {
|
|
5
|
+
private httpClient;
|
|
6
|
+
private _tasks;
|
|
7
|
+
private _horizontal;
|
|
8
|
+
constructor(apiKey: string, apiSecret: string, baseURL: string);
|
|
9
|
+
tasks(): TicketingAPI;
|
|
10
|
+
horizontal(): HorizontalAPI;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ERPClient = void 0;
|
|
18
|
+
const http_1 = require("./http");
|
|
19
|
+
const api_1 = require("./resources/horizontal/api");
|
|
20
|
+
const api_2 = require("./resources/ticketing/api");
|
|
21
|
+
__exportStar(require("./resources/ticketing/types"), exports);
|
|
22
|
+
class ERPClient {
|
|
23
|
+
constructor(apiKey, apiSecret, baseURL) {
|
|
24
|
+
this._tasks = null;
|
|
25
|
+
this._horizontal = null;
|
|
26
|
+
this.httpClient = new http_1.HTTPClient(apiKey, apiSecret, baseURL);
|
|
27
|
+
}
|
|
28
|
+
tasks() {
|
|
29
|
+
if (!this._tasks) {
|
|
30
|
+
this._tasks = new api_2.TicketingAPI(this.httpClient);
|
|
31
|
+
}
|
|
32
|
+
return this._tasks;
|
|
33
|
+
}
|
|
34
|
+
horizontal() {
|
|
35
|
+
if (!this._horizontal) {
|
|
36
|
+
this._horizontal = new api_1.HorizontalAPI(this.httpClient);
|
|
37
|
+
}
|
|
38
|
+
return this._horizontal;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ERPClient = ERPClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { APIResponse } from "../types";
|
|
2
|
+
export declare class HTTPClient {
|
|
3
|
+
private apiKey;
|
|
4
|
+
private apiSecret;
|
|
5
|
+
private client;
|
|
6
|
+
constructor(apiKey: string, apiSecret: string, baseURL: string);
|
|
7
|
+
get<T>(path: string, params?: Record<string, unknown>): Promise<APIResponse<T>>;
|
|
8
|
+
post<T>(path: string, data?: unknown, params?: Record<string, unknown>): Promise<APIResponse<T>>;
|
|
9
|
+
put<T>(path: string, data?: unknown, params?: Record<string, unknown>): Promise<APIResponse<T>>;
|
|
10
|
+
delete<T>(path: string, params?: Record<string, unknown>): Promise<APIResponse<T>>;
|
|
11
|
+
getBinary(path: string, params?: Record<string, unknown>): Promise<Buffer>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HTTPClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const signature_1 = require("./utils/signature");
|
|
9
|
+
const querystring_1 = __importDefault(require("querystring"));
|
|
10
|
+
class HTTPClient {
|
|
11
|
+
constructor(apiKey, apiSecret, baseURL) {
|
|
12
|
+
this.apiKey = apiKey;
|
|
13
|
+
this.apiSecret = apiSecret;
|
|
14
|
+
this.client = axios_1.default.create({
|
|
15
|
+
baseURL,
|
|
16
|
+
headers: {
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
// Interceptor para agregar headers de autenticación
|
|
21
|
+
this.client.interceptors.request.use((config) => {
|
|
22
|
+
const signatureData = (0, signature_1.generateSignature)(config.data || {}, this.apiKey, this.apiSecret);
|
|
23
|
+
// Manejar query params
|
|
24
|
+
if (config.params) {
|
|
25
|
+
const queryStr = querystring_1.default.stringify(config.params);
|
|
26
|
+
config.url = `${config.url}?${queryStr}`;
|
|
27
|
+
config.params = undefined; // Limpiamos params ya que los incluimos en la URL
|
|
28
|
+
}
|
|
29
|
+
if (config.headers) {
|
|
30
|
+
config.headers.set("x-api-key", this.apiKey);
|
|
31
|
+
config.headers.set("x-timestamp", signatureData.timestamp.toString());
|
|
32
|
+
config.headers.set("x-signature", signatureData.signature);
|
|
33
|
+
}
|
|
34
|
+
return config;
|
|
35
|
+
});
|
|
36
|
+
// Interceptor para manejar respuestas
|
|
37
|
+
this.client.interceptors.response.use((response) => {
|
|
38
|
+
// Mantener la respuesta original de Axios
|
|
39
|
+
return response;
|
|
40
|
+
}, (error) => {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f;
|
|
42
|
+
const apiError = {
|
|
43
|
+
code: ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.code) || "UNKNOWN_ERROR",
|
|
44
|
+
message: ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) || "An unexpected error occurred",
|
|
45
|
+
errors: ((_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.errors) || [],
|
|
46
|
+
};
|
|
47
|
+
return Promise.reject(apiError);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async get(path, params) {
|
|
51
|
+
const response = await this.client.get(path, { params });
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
async post(path, data, params) {
|
|
55
|
+
const response = await this.client.post(path, data, {
|
|
56
|
+
params,
|
|
57
|
+
});
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
async put(path, data, params) {
|
|
61
|
+
const response = await this.client.put(path, data, {
|
|
62
|
+
params,
|
|
63
|
+
});
|
|
64
|
+
return response.data;
|
|
65
|
+
}
|
|
66
|
+
async delete(path, params) {
|
|
67
|
+
const response = await this.client.delete(path, {
|
|
68
|
+
params,
|
|
69
|
+
});
|
|
70
|
+
return response.data;
|
|
71
|
+
}
|
|
72
|
+
async getBinary(path, params) {
|
|
73
|
+
const response = await this.client.get(path, {
|
|
74
|
+
params,
|
|
75
|
+
responseType: "arraybuffer",
|
|
76
|
+
});
|
|
77
|
+
return Buffer.from(response.data);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.HTTPClient = HTTPClient;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTTPClient } from "../../http";
|
|
2
|
+
import { CommunitiesAPI } from "./communities/api";
|
|
3
|
+
export declare class HorizontalAPI {
|
|
4
|
+
private httpClient;
|
|
5
|
+
constructor(httpClient: HTTPClient);
|
|
6
|
+
communities(): CommunitiesAPI;
|
|
7
|
+
}
|
|
8
|
+
export * from "./communities/types";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.HorizontalAPI = void 0;
|
|
18
|
+
const api_1 = require("./communities/api");
|
|
19
|
+
class HorizontalAPI {
|
|
20
|
+
constructor(httpClient) {
|
|
21
|
+
this.httpClient = httpClient;
|
|
22
|
+
}
|
|
23
|
+
communities() {
|
|
24
|
+
return new api_1.CommunitiesAPI(this.httpClient);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.HorizontalAPI = HorizontalAPI;
|
|
28
|
+
__exportStar(require("./communities/types"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTTPClient } from "../../../http";
|
|
2
|
+
import { APIResponse } from "../../../../types";
|
|
3
|
+
import { AgentRole, Community, CommunityAgent } from "./types";
|
|
4
|
+
export declare class CommunitiesAPI {
|
|
5
|
+
private httpClient;
|
|
6
|
+
private readonly basePath;
|
|
7
|
+
constructor(httpClient: HTTPClient);
|
|
8
|
+
getById(communityId: string): Promise<APIResponse<Community>>;
|
|
9
|
+
getAgentRoles(): Promise<APIResponse<AgentRole[]>>;
|
|
10
|
+
getCommunityAgents(communityId: string): Promise<APIResponse<CommunityAgent[]>>;
|
|
11
|
+
}
|
|
12
|
+
export * from "./types";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CommunitiesAPI = void 0;
|
|
18
|
+
class CommunitiesAPI {
|
|
19
|
+
constructor(httpClient) {
|
|
20
|
+
this.httpClient = httpClient;
|
|
21
|
+
this.basePath = "/api/v1/horizontal/communities";
|
|
22
|
+
}
|
|
23
|
+
async getById(communityId) {
|
|
24
|
+
return this.httpClient.get(`${this.basePath}/${communityId}`);
|
|
25
|
+
}
|
|
26
|
+
async getAgentRoles() {
|
|
27
|
+
return this.httpClient.get(`${this.basePath}/config/agents`);
|
|
28
|
+
}
|
|
29
|
+
async getCommunityAgents(communityId) {
|
|
30
|
+
return this.httpClient.get(`${this.basePath}/${communityId}/agents`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.CommunitiesAPI = CommunitiesAPI;
|
|
34
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ResourceInfo } from "../../types";
|
|
2
|
+
export interface AgentRole {
|
|
3
|
+
id: number;
|
|
4
|
+
domainId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
unique: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CommunityAgent {
|
|
10
|
+
communityId: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
roleId: number;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Community {
|
|
16
|
+
id: string;
|
|
17
|
+
domainId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
personId: string;
|
|
20
|
+
enrollmentDate: string | null;
|
|
21
|
+
macrocommunityId: string | null;
|
|
22
|
+
coefficient: number | null;
|
|
23
|
+
churnDate: string | null;
|
|
24
|
+
churnReasonId: number | null;
|
|
25
|
+
tags: string[] | null;
|
|
26
|
+
customFields: Record<string, any>;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
neighbors: Array<{
|
|
29
|
+
personId: string;
|
|
30
|
+
typeId: number;
|
|
31
|
+
}>;
|
|
32
|
+
person: {
|
|
33
|
+
id: string;
|
|
34
|
+
domainId: string;
|
|
35
|
+
typeId: number;
|
|
36
|
+
langId: number;
|
|
37
|
+
fullName: string;
|
|
38
|
+
legalId: string | null;
|
|
39
|
+
legalRepresentative: string | null;
|
|
40
|
+
bornAt: string | null;
|
|
41
|
+
phones: string[] | null;
|
|
42
|
+
emails: string[] | null;
|
|
43
|
+
notificationEmail: boolean;
|
|
44
|
+
notificationPhone: boolean;
|
|
45
|
+
notificationPostal: boolean;
|
|
46
|
+
tags: string[] | null;
|
|
47
|
+
};
|
|
48
|
+
resourceInfo: ResourceInfo;
|
|
49
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTTPClient } from "../../http";
|
|
2
|
+
import { APIResponse } from "../../../types";
|
|
3
|
+
import { CreateTaskDTO, Task, TaskCategory } from "./types";
|
|
4
|
+
export declare class TasksAPI {
|
|
5
|
+
private httpClient;
|
|
6
|
+
private readonly basePath;
|
|
7
|
+
constructor(httpClient: HTTPClient);
|
|
8
|
+
create(data: CreateTaskDTO): Promise<APIResponse<Task>>;
|
|
9
|
+
getAll(filters?: Record<string, unknown>): Promise<APIResponse<Task[]>>;
|
|
10
|
+
getById(id: string): Promise<APIResponse<Task>>;
|
|
11
|
+
update(id: string, data: Partial<Task>): Promise<APIResponse<Task>>;
|
|
12
|
+
delete(id: string): Promise<APIResponse<void>>;
|
|
13
|
+
downloadAttachment(taskId: string, documentId: string): Promise<Buffer>;
|
|
14
|
+
getCategories(filters?: Record<string, unknown>): Promise<APIResponse<TaskCategory[]>>;
|
|
15
|
+
getCategoryById(id: number): Promise<APIResponse<TaskCategory>>;
|
|
16
|
+
getSubtaskFromParentId(parentId: string): Promise<APIResponse<Task[]>>;
|
|
17
|
+
}
|
|
18
|
+
export * from "./types";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TasksAPI = void 0;
|
|
18
|
+
class TasksAPI {
|
|
19
|
+
constructor(httpClient) {
|
|
20
|
+
this.httpClient = httpClient;
|
|
21
|
+
this.basePath = "/api/v1/ticketing";
|
|
22
|
+
}
|
|
23
|
+
async create(data) {
|
|
24
|
+
return this.httpClient.post(`${this.basePath}/tasks`, data);
|
|
25
|
+
}
|
|
26
|
+
async getAll(filters) {
|
|
27
|
+
return this.httpClient.get(`${this.basePath}/tasks`, filters);
|
|
28
|
+
}
|
|
29
|
+
async getById(id) {
|
|
30
|
+
return this.httpClient.get(`${this.basePath}/tasks/${id}`);
|
|
31
|
+
}
|
|
32
|
+
async update(id, data) {
|
|
33
|
+
return this.httpClient.put(`${this.basePath}/tasks/${id}`, data);
|
|
34
|
+
}
|
|
35
|
+
async delete(id) {
|
|
36
|
+
return this.httpClient.delete(`${this.basePath}/tasks/${id}`);
|
|
37
|
+
}
|
|
38
|
+
async downloadAttachment(taskId, documentId) {
|
|
39
|
+
return this.httpClient.getBinary(`${this.basePath}/tasks/${taskId}/attachments/${documentId}`);
|
|
40
|
+
}
|
|
41
|
+
async getCategories(filters) {
|
|
42
|
+
return this.httpClient.get(`${this.basePath}/tasks/config/categories`, filters);
|
|
43
|
+
}
|
|
44
|
+
async getCategoryById(id) {
|
|
45
|
+
return this.getCategories({ "id[]": [id] }).then((response) => response[0]);
|
|
46
|
+
}
|
|
47
|
+
async getSubtaskFromParentId(parentId) {
|
|
48
|
+
return this.httpClient.get(`${this.basePath}/tasks`, {
|
|
49
|
+
"parentId[]": [parentId],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.TasksAPI = TasksAPI;
|
|
54
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare enum TaskPriority {
|
|
2
|
+
low = 1,
|
|
3
|
+
medium = 2,
|
|
4
|
+
high = 3
|
|
5
|
+
}
|
|
6
|
+
export declare enum TaskStatus {
|
|
7
|
+
todo = 1,
|
|
8
|
+
wip = 2,
|
|
9
|
+
done = 3,
|
|
10
|
+
discarded = 4
|
|
11
|
+
}
|
|
12
|
+
export declare enum TaskReporterType {
|
|
13
|
+
agent = 1,
|
|
14
|
+
contact = 2,
|
|
15
|
+
provider = 3,
|
|
16
|
+
system = 4,
|
|
17
|
+
ai = 5
|
|
18
|
+
}
|
|
19
|
+
export interface Task {
|
|
20
|
+
id: string;
|
|
21
|
+
domainId: string;
|
|
22
|
+
parentId: string | null;
|
|
23
|
+
contactId: string | null;
|
|
24
|
+
categoryId: number;
|
|
25
|
+
priorityId: TaskPriority;
|
|
26
|
+
statusId: TaskStatus;
|
|
27
|
+
code: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string | null;
|
|
30
|
+
reporterTypeId: TaskReporterType;
|
|
31
|
+
reporterId: string;
|
|
32
|
+
responsibleId: string;
|
|
33
|
+
executorId: string;
|
|
34
|
+
providerId: string | null;
|
|
35
|
+
tags: string[] | null;
|
|
36
|
+
dueDate: string | null;
|
|
37
|
+
firstResponseDue: string | null;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CreateTaskDTO {
|
|
41
|
+
title: string;
|
|
42
|
+
categoryId: number;
|
|
43
|
+
priorityId: TaskPriority;
|
|
44
|
+
executorId: string;
|
|
45
|
+
responsibleId: string;
|
|
46
|
+
reporterId: string;
|
|
47
|
+
reporterTypeId: TaskReporterType;
|
|
48
|
+
parentId?: string;
|
|
49
|
+
dueDate?: string | null;
|
|
50
|
+
description?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface TaskCategory {
|
|
53
|
+
id: number;
|
|
54
|
+
domainId: string;
|
|
55
|
+
name: string;
|
|
56
|
+
key: string;
|
|
57
|
+
icon: string;
|
|
58
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskReporterType = exports.TaskStatus = exports.TaskPriority = void 0;
|
|
4
|
+
var TaskPriority;
|
|
5
|
+
(function (TaskPriority) {
|
|
6
|
+
TaskPriority[TaskPriority["low"] = 1] = "low";
|
|
7
|
+
TaskPriority[TaskPriority["medium"] = 2] = "medium";
|
|
8
|
+
TaskPriority[TaskPriority["high"] = 3] = "high";
|
|
9
|
+
})(TaskPriority || (exports.TaskPriority = TaskPriority = {}));
|
|
10
|
+
var TaskStatus;
|
|
11
|
+
(function (TaskStatus) {
|
|
12
|
+
TaskStatus[TaskStatus["todo"] = 1] = "todo";
|
|
13
|
+
TaskStatus[TaskStatus["wip"] = 2] = "wip";
|
|
14
|
+
TaskStatus[TaskStatus["done"] = 3] = "done";
|
|
15
|
+
TaskStatus[TaskStatus["discarded"] = 4] = "discarded";
|
|
16
|
+
})(TaskStatus || (exports.TaskStatus = TaskStatus = {}));
|
|
17
|
+
var TaskReporterType;
|
|
18
|
+
(function (TaskReporterType) {
|
|
19
|
+
TaskReporterType[TaskReporterType["agent"] = 1] = "agent";
|
|
20
|
+
TaskReporterType[TaskReporterType["contact"] = 2] = "contact";
|
|
21
|
+
TaskReporterType[TaskReporterType["provider"] = 3] = "provider";
|
|
22
|
+
TaskReporterType[TaskReporterType["system"] = 4] = "system";
|
|
23
|
+
TaskReporterType[TaskReporterType["ai"] = 5] = "ai";
|
|
24
|
+
})(TaskReporterType || (exports.TaskReporterType = TaskReporterType = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTTPClient } from "../../http";
|
|
2
|
+
import { APIResponse } from "../../../types";
|
|
3
|
+
import { CreateTaskDTO, Task, TaskCategory } from "./types";
|
|
4
|
+
export declare class TicketingAPI {
|
|
5
|
+
private httpClient;
|
|
6
|
+
private readonly basePath;
|
|
7
|
+
constructor(httpClient: HTTPClient);
|
|
8
|
+
create(data: CreateTaskDTO): Promise<APIResponse<Task>>;
|
|
9
|
+
getAll(filters?: Record<string, unknown>): Promise<APIResponse<Task[]>>;
|
|
10
|
+
getById(id: string): Promise<APIResponse<Task>>;
|
|
11
|
+
update(id: string, data: Partial<Task>): Promise<APIResponse<Task>>;
|
|
12
|
+
delete(id: string): Promise<APIResponse<void>>;
|
|
13
|
+
downloadAttachment(taskId: string, documentId: string): Promise<Buffer>;
|
|
14
|
+
getCategories(filters?: Record<string, unknown>): Promise<APIResponse<TaskCategory[]>>;
|
|
15
|
+
getCategoryById(id: number): Promise<APIResponse<TaskCategory>>;
|
|
16
|
+
getSubtaskFromParentId(parentId: string): Promise<APIResponse<Task[]>>;
|
|
17
|
+
}
|
|
18
|
+
export * from "./types";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TicketingAPI = void 0;
|
|
18
|
+
class TicketingAPI {
|
|
19
|
+
constructor(httpClient) {
|
|
20
|
+
this.httpClient = httpClient;
|
|
21
|
+
this.basePath = "/api/v1/ticketing";
|
|
22
|
+
}
|
|
23
|
+
async create(data) {
|
|
24
|
+
return this.httpClient.post(`${this.basePath}/tasks`, data);
|
|
25
|
+
}
|
|
26
|
+
async getAll(filters) {
|
|
27
|
+
return this.httpClient.get(`${this.basePath}/tasks`, filters);
|
|
28
|
+
}
|
|
29
|
+
async getById(id) {
|
|
30
|
+
return this.httpClient.get(`${this.basePath}/tasks/${id}`);
|
|
31
|
+
}
|
|
32
|
+
async update(id, data) {
|
|
33
|
+
return this.httpClient.put(`${this.basePath}/tasks/${id}`, data);
|
|
34
|
+
}
|
|
35
|
+
async delete(id) {
|
|
36
|
+
return this.httpClient.delete(`${this.basePath}/tasks/${id}`);
|
|
37
|
+
}
|
|
38
|
+
async downloadAttachment(taskId, documentId) {
|
|
39
|
+
return this.httpClient.getBinary(`${this.basePath}/tasks/${taskId}/attachments/${documentId}`);
|
|
40
|
+
}
|
|
41
|
+
async getCategories(filters) {
|
|
42
|
+
return this.httpClient.get(`${this.basePath}/tasks/config/categories`, filters);
|
|
43
|
+
}
|
|
44
|
+
async getCategoryById(id) {
|
|
45
|
+
return this.getCategories({ "id[]": [id] }).then((response) => response[0]);
|
|
46
|
+
}
|
|
47
|
+
async getSubtaskFromParentId(parentId) {
|
|
48
|
+
return this.httpClient.get(`${this.basePath}/tasks`, {
|
|
49
|
+
"parentId[]": [parentId],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.TicketingAPI = TicketingAPI;
|
|
54
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ResourceInfo } from "../types";
|
|
2
|
+
export declare enum TaskPriority {
|
|
3
|
+
low = 1,
|
|
4
|
+
medium = 2,
|
|
5
|
+
high = 3
|
|
6
|
+
}
|
|
7
|
+
export declare enum TaskStatus {
|
|
8
|
+
todo = 1,
|
|
9
|
+
wip = 2,
|
|
10
|
+
done = 3,
|
|
11
|
+
discarded = 4
|
|
12
|
+
}
|
|
13
|
+
export declare enum TaskReporterType {
|
|
14
|
+
agent = 1,
|
|
15
|
+
contact = 2,
|
|
16
|
+
provider = 3,
|
|
17
|
+
system = 4,
|
|
18
|
+
ai = 5
|
|
19
|
+
}
|
|
20
|
+
export interface Task {
|
|
21
|
+
id: string;
|
|
22
|
+
domainId: string;
|
|
23
|
+
parentId: string | null;
|
|
24
|
+
contactId: string | null;
|
|
25
|
+
categoryId: number;
|
|
26
|
+
priorityId: TaskPriority;
|
|
27
|
+
statusId: TaskStatus;
|
|
28
|
+
code: string;
|
|
29
|
+
title: string;
|
|
30
|
+
description: string | null;
|
|
31
|
+
reporterTypeId: TaskReporterType;
|
|
32
|
+
reporterId: string;
|
|
33
|
+
responsibleId: string;
|
|
34
|
+
executorId: string;
|
|
35
|
+
providerId: string | null;
|
|
36
|
+
tags: string[] | null;
|
|
37
|
+
dueDate: string | null;
|
|
38
|
+
firstResponseDue: string | null;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
resourceInfo?: ResourceInfo;
|
|
41
|
+
}
|
|
42
|
+
export interface CreateTaskDTO {
|
|
43
|
+
title: string;
|
|
44
|
+
categoryId: number;
|
|
45
|
+
priorityId: TaskPriority;
|
|
46
|
+
executorId: string;
|
|
47
|
+
responsibleId: string;
|
|
48
|
+
reporterId: string;
|
|
49
|
+
reporterTypeId: TaskReporterType;
|
|
50
|
+
parentId?: string;
|
|
51
|
+
dueDate?: string | null;
|
|
52
|
+
description?: string;
|
|
53
|
+
resourceInfo?: ResourceInfo;
|
|
54
|
+
}
|
|
55
|
+
export interface TaskCategory {
|
|
56
|
+
id: number;
|
|
57
|
+
domainId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
key: string;
|
|
60
|
+
icon: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskReporterType = exports.TaskStatus = exports.TaskPriority = void 0;
|
|
4
|
+
var TaskPriority;
|
|
5
|
+
(function (TaskPriority) {
|
|
6
|
+
TaskPriority[TaskPriority["low"] = 1] = "low";
|
|
7
|
+
TaskPriority[TaskPriority["medium"] = 2] = "medium";
|
|
8
|
+
TaskPriority[TaskPriority["high"] = 3] = "high";
|
|
9
|
+
})(TaskPriority || (exports.TaskPriority = TaskPriority = {}));
|
|
10
|
+
var TaskStatus;
|
|
11
|
+
(function (TaskStatus) {
|
|
12
|
+
TaskStatus[TaskStatus["todo"] = 1] = "todo";
|
|
13
|
+
TaskStatus[TaskStatus["wip"] = 2] = "wip";
|
|
14
|
+
TaskStatus[TaskStatus["done"] = 3] = "done";
|
|
15
|
+
TaskStatus[TaskStatus["discarded"] = 4] = "discarded";
|
|
16
|
+
})(TaskStatus || (exports.TaskStatus = TaskStatus = {}));
|
|
17
|
+
var TaskReporterType;
|
|
18
|
+
(function (TaskReporterType) {
|
|
19
|
+
TaskReporterType[TaskReporterType["agent"] = 1] = "agent";
|
|
20
|
+
TaskReporterType[TaskReporterType["contact"] = 2] = "contact";
|
|
21
|
+
TaskReporterType[TaskReporterType["provider"] = 3] = "provider";
|
|
22
|
+
TaskReporterType[TaskReporterType["system"] = 4] = "system";
|
|
23
|
+
TaskReporterType[TaskReporterType["ai"] = 5] = "ai";
|
|
24
|
+
})(TaskReporterType || (exports.TaskReporterType = TaskReporterType = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateSignature = generateSignature;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
function generateSignature(body, apiKey, apiSecret) {
|
|
9
|
+
const bodyStr = JSON.stringify(body, null, 0) || "";
|
|
10
|
+
const timestamp = Date.now();
|
|
11
|
+
const signature = crypto_1.default
|
|
12
|
+
.createHmac("sha256", apiSecret)
|
|
13
|
+
.update(`${bodyStr}:${timestamp}:${apiKey}`)
|
|
14
|
+
.digest("hex");
|
|
15
|
+
return {
|
|
16
|
+
signature,
|
|
17
|
+
timestamp,
|
|
18
|
+
};
|
|
19
|
+
}
|
package/dist/erp.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ERPClient } from "./client/client";
|
|
2
|
+
import { TaskCreator } from "./tasks/creator";
|
|
3
|
+
import { ElevaERPConfig } from "./types";
|
|
4
|
+
export declare class ElevaERPTasks {
|
|
5
|
+
private _erp;
|
|
6
|
+
constructor(_erp: ElevaERP);
|
|
7
|
+
creator(): TaskCreator;
|
|
8
|
+
}
|
|
9
|
+
export declare class ElevaERP {
|
|
10
|
+
private _client;
|
|
11
|
+
constructor(config: ElevaERPConfig);
|
|
12
|
+
client(): ERPClient;
|
|
13
|
+
tasks(): ElevaERPTasks;
|
|
14
|
+
}
|
package/dist/erp.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ElevaERP = exports.ElevaERPTasks = void 0;
|
|
4
|
+
const client_1 = require("./client/client");
|
|
5
|
+
const creator_1 = require("./tasks/creator");
|
|
6
|
+
class ElevaERPTasks {
|
|
7
|
+
constructor(_erp) {
|
|
8
|
+
this._erp = _erp;
|
|
9
|
+
}
|
|
10
|
+
creator() {
|
|
11
|
+
return new creator_1.TaskCreator(this._erp);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ElevaERPTasks = ElevaERPTasks;
|
|
15
|
+
class ElevaERP {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
const baseURL = config.baseURL || "https://api.eleva.io";
|
|
18
|
+
this._client = new client_1.ERPClient(config.apiKey, config.apiSecret, baseURL);
|
|
19
|
+
}
|
|
20
|
+
client() {
|
|
21
|
+
return this._client;
|
|
22
|
+
}
|
|
23
|
+
tasks() {
|
|
24
|
+
return new ElevaERPTasks(this);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ElevaERP = ElevaERP;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./erp"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./tasks/template"), exports);
|
|
20
|
+
__exportStar(require("./tasks/creator"), exports);
|
|
21
|
+
__exportStar(require("./client/resources/ticketing/types"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElevaERP } from "../erp";
|
|
2
|
+
import { STD } from "./std";
|
|
3
|
+
import { TaskTemplate } from "./template";
|
|
4
|
+
export declare class TaskCreator {
|
|
5
|
+
private _erp;
|
|
6
|
+
constructor(_erp: ElevaERP);
|
|
7
|
+
private createTaskWithSubtasks;
|
|
8
|
+
template(template: TaskTemplate, std: STD): Promise<import("..").Task>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskCreator = void 0;
|
|
4
|
+
class TaskCreator {
|
|
5
|
+
constructor(_erp) {
|
|
6
|
+
this._erp = _erp;
|
|
7
|
+
}
|
|
8
|
+
async createTaskWithSubtasks(task, parentId) {
|
|
9
|
+
const { subtasks, ...taskData } = task;
|
|
10
|
+
const createdTask = await this._erp
|
|
11
|
+
.client()
|
|
12
|
+
.tasks()
|
|
13
|
+
.create({
|
|
14
|
+
...taskData,
|
|
15
|
+
parentId,
|
|
16
|
+
});
|
|
17
|
+
await Promise.all(subtasks.map((subtask) => this.createTaskWithSubtasks(subtask, createdTask.id)));
|
|
18
|
+
return createdTask;
|
|
19
|
+
}
|
|
20
|
+
async template(template, std) {
|
|
21
|
+
const task = await template.toTask(std);
|
|
22
|
+
return this.createTaskWithSubtasks(task);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.TaskCreator = TaskCreator;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TaskCategory } from "../client/client";
|
|
2
|
+
import { AgentRole, Community, CommunityAgent } from "../client/resources/horizontal/communities/types";
|
|
3
|
+
import { ElevaERP } from "../erp";
|
|
4
|
+
export interface STD {
|
|
5
|
+
agentLookupByRoleName(roleName: string): Promise<string>;
|
|
6
|
+
getCategoryIdByName(name: string): Promise<number>;
|
|
7
|
+
getCategoryIdByKey(key: string): Promise<number>;
|
|
8
|
+
getOrganizationUnitId(name?: string): Promise<string | undefined | null>;
|
|
9
|
+
date(): DateSTD;
|
|
10
|
+
}
|
|
11
|
+
export declare class DateSTD {
|
|
12
|
+
absoluteDay(day: number): string;
|
|
13
|
+
relativeDay(day: number): string;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class STDBase implements STD {
|
|
16
|
+
abstract agentLookupByRoleName(roleName: string): Promise<string>;
|
|
17
|
+
abstract getCategoryIdByName(name: string): Promise<number>;
|
|
18
|
+
abstract getCategoryIdByKey(key: string): Promise<number>;
|
|
19
|
+
abstract getOrganizationUnitId(name?: string): Promise<string | undefined | null>;
|
|
20
|
+
date(): DateSTD;
|
|
21
|
+
}
|
|
22
|
+
type HOAAgentWithRole = CommunityAgent & {
|
|
23
|
+
role: AgentRole | undefined;
|
|
24
|
+
};
|
|
25
|
+
export declare class HOASTD extends STDBase {
|
|
26
|
+
private _hoa;
|
|
27
|
+
private _agents;
|
|
28
|
+
private _categories;
|
|
29
|
+
static fromId(erp: ElevaERP, hoaId: string): Promise<HOASTD>;
|
|
30
|
+
constructor(_hoa: Community, _agents: HOAAgentWithRole[], _categories: TaskCategory[]);
|
|
31
|
+
agentLookupByRoleName(roleName: string): Promise<string>;
|
|
32
|
+
getCategoryIdByName(name: string): Promise<number>;
|
|
33
|
+
getCategoryIdByKey(key: string): Promise<number>;
|
|
34
|
+
getOrganizationUnitId(name?: string): Promise<string | undefined>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HOASTD = exports.STDBase = exports.DateSTD = void 0;
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
class DateSTD {
|
|
9
|
+
absoluteDay(day) {
|
|
10
|
+
const today = (0, moment_1.default)();
|
|
11
|
+
if (day < today.date()) {
|
|
12
|
+
today.add(1, "month");
|
|
13
|
+
}
|
|
14
|
+
return today.set("date", day).toISOString();
|
|
15
|
+
}
|
|
16
|
+
relativeDay(day) {
|
|
17
|
+
return (0, moment_1.default)().add(day, "days").toISOString();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.DateSTD = DateSTD;
|
|
21
|
+
class STDBase {
|
|
22
|
+
date() {
|
|
23
|
+
return new DateSTD();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.STDBase = STDBase;
|
|
27
|
+
class HOASTD extends STDBase {
|
|
28
|
+
static async fromId(erp, hoaId) {
|
|
29
|
+
const hoa = await erp.client().horizontal().communities().getById(hoaId);
|
|
30
|
+
const globalAgents = await erp
|
|
31
|
+
.client()
|
|
32
|
+
.horizontal()
|
|
33
|
+
.communities()
|
|
34
|
+
.getAgentRoles();
|
|
35
|
+
const agentsRaw = await erp
|
|
36
|
+
.client()
|
|
37
|
+
.horizontal()
|
|
38
|
+
.communities()
|
|
39
|
+
.getCommunityAgents(hoaId);
|
|
40
|
+
const agents = agentsRaw.map((agent) => ({
|
|
41
|
+
...agent,
|
|
42
|
+
role: globalAgents.find((role) => role.id === agent.roleId),
|
|
43
|
+
}));
|
|
44
|
+
const categories = await erp.client().tasks().getCategories();
|
|
45
|
+
return new HOASTD(hoa, agents, categories);
|
|
46
|
+
}
|
|
47
|
+
constructor(_hoa, _agents, _categories) {
|
|
48
|
+
super();
|
|
49
|
+
this._hoa = _hoa;
|
|
50
|
+
this._agents = _agents;
|
|
51
|
+
this._categories = _categories;
|
|
52
|
+
}
|
|
53
|
+
async agentLookupByRoleName(roleName) {
|
|
54
|
+
const agent = this._agents.find((agent) => { var _a; return ((_a = agent.role) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) === roleName.toLowerCase(); });
|
|
55
|
+
if (!agent) {
|
|
56
|
+
throw new Error(`Agent with role name ${roleName} not found`);
|
|
57
|
+
}
|
|
58
|
+
return agent.agentId;
|
|
59
|
+
}
|
|
60
|
+
async getCategoryIdByName(name) {
|
|
61
|
+
const category = this._categories.find((category) => category.name.toLowerCase() === name.toLowerCase());
|
|
62
|
+
if (!category) {
|
|
63
|
+
throw new Error(`Category with name ${name} not found`);
|
|
64
|
+
}
|
|
65
|
+
return category.id;
|
|
66
|
+
}
|
|
67
|
+
async getCategoryIdByKey(key) {
|
|
68
|
+
const category = this._categories.find((category) => category.key.toLowerCase() === key.toLowerCase());
|
|
69
|
+
if (!category) {
|
|
70
|
+
throw new Error(`Category with key ${key} not found`);
|
|
71
|
+
}
|
|
72
|
+
return category.id;
|
|
73
|
+
}
|
|
74
|
+
async getOrganizationUnitId(name) {
|
|
75
|
+
var _a;
|
|
76
|
+
return (_a = this._hoa.resourceInfo.organizationUnit) === null || _a === void 0 ? void 0 : _a.id;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.HOASTD = HOASTD;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Task, TaskPriority, TaskReporterType } from "../client/client";
|
|
2
|
+
import { ResourceInfo } from "../client/resources/types";
|
|
3
|
+
import { STD } from "./std";
|
|
4
|
+
type Caller<T> = ((std: STD) => T) | ((std: STD) => Promise<T>);
|
|
5
|
+
export interface TaskTemplateEvaluated {
|
|
6
|
+
title: string;
|
|
7
|
+
priorityId: TaskPriority;
|
|
8
|
+
categoryId: number;
|
|
9
|
+
reporterId: string;
|
|
10
|
+
reporterTypeId: TaskReporterType;
|
|
11
|
+
responsibleId: string;
|
|
12
|
+
executorId: string;
|
|
13
|
+
dueDate: string | null;
|
|
14
|
+
subtasks: TaskTemplateEvaluated[];
|
|
15
|
+
resourceInfo?: ResourceInfo;
|
|
16
|
+
}
|
|
17
|
+
export declare class TaskTemplate {
|
|
18
|
+
title: Caller<Task["title"]>;
|
|
19
|
+
priorityId: Caller<Task["priorityId"]>;
|
|
20
|
+
categoryId: Caller<Task["categoryId"]>;
|
|
21
|
+
reporterId: Caller<Task["reporterId"]>;
|
|
22
|
+
responsibleId: Caller<Task["responsibleId"]>;
|
|
23
|
+
executorId: Caller<Task["executorId"]>;
|
|
24
|
+
dueDate: Caller<Task["dueDate"]>;
|
|
25
|
+
subtasks: Caller<TaskTemplate[]>;
|
|
26
|
+
reporterTypeId: Caller<Task["reporterTypeId"]>;
|
|
27
|
+
organizationUnitId: Caller<string | undefined | null>;
|
|
28
|
+
constructor({ title, priorityId, categoryId, reporterId, responsibleId, executorId, dueDate, subtasks, reporterTypeId, organizationUnitId, }: {
|
|
29
|
+
title: Caller<Task["title"]>;
|
|
30
|
+
priorityId: Caller<Task["priorityId"]>;
|
|
31
|
+
categoryId: Caller<Task["categoryId"]>;
|
|
32
|
+
reporterId: Caller<Task["reporterId"]>;
|
|
33
|
+
responsibleId: Caller<Task["responsibleId"]>;
|
|
34
|
+
executorId: Caller<Task["executorId"]>;
|
|
35
|
+
dueDate: Caller<Task["dueDate"]>;
|
|
36
|
+
subtasks: Caller<TaskTemplate[]>;
|
|
37
|
+
reporterTypeId: Caller<Task["reporterTypeId"]>;
|
|
38
|
+
organizationUnitId: Caller<string | undefined | null>;
|
|
39
|
+
});
|
|
40
|
+
private _caller;
|
|
41
|
+
toTask(std: STD): Promise<TaskTemplateEvaluated>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskTemplate = void 0;
|
|
4
|
+
class TaskTemplate {
|
|
5
|
+
constructor({ title, priorityId, categoryId, reporterId, responsibleId, executorId, dueDate, subtasks, reporterTypeId, organizationUnitId, }) {
|
|
6
|
+
this.title = title;
|
|
7
|
+
this.priorityId = priorityId;
|
|
8
|
+
this.dueDate = dueDate;
|
|
9
|
+
this.subtasks = subtasks;
|
|
10
|
+
this.reporterTypeId = reporterTypeId;
|
|
11
|
+
this.categoryId = categoryId;
|
|
12
|
+
this.reporterId = reporterId;
|
|
13
|
+
this.responsibleId = responsibleId;
|
|
14
|
+
this.executorId = executorId;
|
|
15
|
+
this.subtasks = subtasks;
|
|
16
|
+
this.organizationUnitId = organizationUnitId;
|
|
17
|
+
}
|
|
18
|
+
async _caller(caller, std) {
|
|
19
|
+
return caller(std);
|
|
20
|
+
}
|
|
21
|
+
async toTask(std) {
|
|
22
|
+
const [title, priorityId, categoryId, reporterId, responsibleId, executorId, dueDate, subtasksTemplate, reporterTypeId, organizationUnitId,] = await Promise.all([
|
|
23
|
+
this._caller(this.title, std),
|
|
24
|
+
this._caller(this.priorityId, std),
|
|
25
|
+
this._caller(this.categoryId, std),
|
|
26
|
+
this._caller(this.reporterId, std),
|
|
27
|
+
this._caller(this.responsibleId, std),
|
|
28
|
+
this._caller(this.executorId, std),
|
|
29
|
+
this._caller(this.dueDate, std),
|
|
30
|
+
this._caller(this.subtasks, std),
|
|
31
|
+
this._caller(this.reporterTypeId, std),
|
|
32
|
+
this._caller(this.organizationUnitId, std),
|
|
33
|
+
]);
|
|
34
|
+
const subtasks = await Promise.all(subtasksTemplate.map((subtask) => subtask.toTask(std)));
|
|
35
|
+
const resourceInfo = organizationUnitId
|
|
36
|
+
? {
|
|
37
|
+
organizationUnit: {
|
|
38
|
+
id: organizationUnitId,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: undefined;
|
|
42
|
+
return {
|
|
43
|
+
title,
|
|
44
|
+
priorityId,
|
|
45
|
+
categoryId,
|
|
46
|
+
reporterId,
|
|
47
|
+
reporterTypeId,
|
|
48
|
+
responsibleId,
|
|
49
|
+
executorId,
|
|
50
|
+
dueDate,
|
|
51
|
+
subtasks,
|
|
52
|
+
resourceInfo,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TaskTemplate = TaskTemplate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ElevaERPConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface APIResponse<T> {
|
|
6
|
+
data: T;
|
|
7
|
+
status: number;
|
|
8
|
+
message?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface APIError {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
details?: Record<string, unknown>;
|
|
14
|
+
}
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eleva-io/erp-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK oficial para el ERP de Eleva",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"eleva",
|
|
12
|
+
"erp",
|
|
13
|
+
"sdk",
|
|
14
|
+
"proptech"
|
|
15
|
+
],
|
|
16
|
+
"author": "Eleva",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.0.0",
|
|
20
|
+
"dotenv": "^16.4.5",
|
|
21
|
+
"tsx": "^4.19.3",
|
|
22
|
+
"typescript": "^5.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"axios": "^1.6.0",
|
|
26
|
+
"moment": "2.30.1"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16",
|
|
33
|
+
"pnpm": ">=8"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "pnpm tsc",
|
|
37
|
+
"test": "jest",
|
|
38
|
+
"dev": "pnpm tsc --watch",
|
|
39
|
+
"sandbox": "tsx sandbox/index.ts",
|
|
40
|
+
"sandbox:watch": "tsx watch sandbox/index.ts"
|
|
41
|
+
}
|
|
42
|
+
}
|