itrm-tools 1.3.5-beta.1 → 1.3.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/api/APIService.js +8 -2
- package/dist/api/APIService.js.map +1 -1
- package/dist/api/express/ExpressStandardConfiguration.d.ts +1 -1
- package/dist/api/express/ExpressStandardConfiguration.js +9 -1
- package/dist/api/express/ExpressStandardConfiguration.js.map +1 -1
- package/dist/api/external/ExternalApiConnection.d.ts +13 -0
- package/dist/api/external/ExternalApiConnection.js +24 -0
- package/dist/api/external/ExternalApiConnection.js.map +1 -0
- package/dist/api/external/cetus/CetusStrategyApiManager.d.ts +4 -3
- package/dist/api/external/cetus/CetusStrategyApiManager.js +4 -4
- package/dist/api/external/cetus/CetusStrategyApiManager.js.map +1 -1
- package/dist/api/request/RequestAxiosCall.d.ts +4 -4
- package/dist/api/request/RequestAxiosCall.js.map +1 -1
- package/dist/api/request/crud/CrudManager.d.ts +2 -2
- package/dist/api/request/crud/CrudServiceManager.d.ts +5 -5
- package/dist/api/request/crud/CrudServiceManager.js.map +1 -1
- package/dist/api/request/crud/common/ActivityHistoryManager.d.ts +40 -0
- package/dist/api/request/crud/common/ActivityHistoryManager.js +69 -0
- package/dist/api/request/crud/common/ActivityHistoryManager.js.map +1 -0
- package/dist/api/request/crud/common/ApplicationManager.d.ts +39 -0
- package/dist/api/request/crud/common/ApplicationManager.js +57 -0
- package/dist/api/request/crud/common/ApplicationManager.js.map +1 -0
- package/dist/api/request/crud/common/AvailablePlatformManager.d.ts +39 -0
- package/dist/api/request/crud/common/AvailablePlatformManager.js +69 -0
- package/dist/api/request/crud/common/AvailablePlatformManager.js.map +1 -0
- package/dist/api/request/crud/common/ComponentManager.d.ts +56 -0
- package/dist/api/request/crud/common/ComponentManager.js +63 -0
- package/dist/api/request/crud/common/ComponentManager.js.map +1 -0
- package/dist/api/request/crud/common/KeyManager.d.ts +42 -0
- package/dist/api/request/crud/common/KeyManager.js +70 -0
- package/dist/api/request/crud/common/KeyManager.js.map +1 -0
- package/dist/api/request/crud/common/PlatformManager.d.ts +44 -0
- package/dist/api/request/crud/common/PlatformManager.js +60 -0
- package/dist/api/request/crud/common/PlatformManager.js.map +1 -0
- package/dist/api/request/crud/common/RoleManager.d.ts +51 -0
- package/dist/api/request/crud/common/RoleManager.js +57 -0
- package/dist/api/request/crud/common/RoleManager.js.map +1 -0
- package/dist/api/request/crud/common/StatusManager.d.ts +34 -0
- package/dist/api/request/crud/common/StatusManager.js +57 -0
- package/dist/api/request/crud/common/StatusManager.js.map +1 -0
- package/dist/api/request/crud/common/TypeManager.d.ts +33 -0
- package/dist/api/request/crud/common/TypeManager.js +57 -0
- package/dist/api/request/crud/common/TypeManager.js.map +1 -0
- package/dist/api/request/crud/common/UserCredentialsManager.d.ts +39 -0
- package/dist/api/request/crud/common/UserCredentialsManager.js +67 -0
- package/dist/api/request/crud/common/UserCredentialsManager.js.map +1 -0
- package/dist/api/request/crud/common/UserManager.d.ts +35 -0
- package/dist/api/request/crud/common/UserManager.js +63 -0
- package/dist/api/request/crud/common/UserManager.js.map +1 -0
- package/dist/api/request/docs/DocumentationModels.d.ts +4 -4
- package/dist/api/request/docs/DocumentationModels.js.map +1 -1
- package/dist/cryptography/CipheringAlgorithm.d.ts +4 -0
- package/dist/cryptography/CipheringAlgorithm.js +3 -0
- package/dist/cryptography/CipheringAlgorithm.js.map +1 -0
- package/dist/cryptography/EncryptionAlgorithm.js.map +1 -0
- package/dist/cryptography/KeyGenerator.d.ts +3 -0
- package/dist/cryptography/KeyGenerator.js +3 -0
- package/dist/cryptography/KeyGenerator.js.map +1 -0
- package/dist/cryptography/Signer.d.ts +4 -0
- package/dist/cryptography/Signer.js +3 -0
- package/dist/cryptography/Signer.js.map +1 -0
- package/dist/cryptography/algorithm/AesCipheringAlgorithm.d.ts +6 -0
- package/dist/cryptography/algorithm/AesCipheringAlgorithm.js +28 -0
- package/dist/cryptography/algorithm/AesCipheringAlgorithm.js.map +1 -0
- package/dist/cryptography/generate/StandardApiKeyGenerator.d.ts +9 -0
- package/dist/cryptography/generate/StandardApiKeyGenerator.js +18 -0
- package/dist/cryptography/generate/StandardApiKeyGenerator.js.map +1 -0
- package/dist/cryptography/sign/ApiKeySigner.d.ts +14 -0
- package/dist/cryptography/sign/ApiKeySigner.js +35 -0
- package/dist/cryptography/sign/ApiKeySigner.js.map +1 -0
- package/dist/database/mongoose/MongooseModelManager.d.ts +40 -8
- package/dist/index.d.ts +17 -2
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/package.json +75 -68
- package/.github/workflows/node.js.yml +0 -30
- package/dist/algorithm/encryption/EncryptionAlgorithm.js.map +0 -1
- package/dist/api/external/ExternalApiSigner.d.ts +0 -15
- package/dist/api/external/ExternalApiSigner.js +0 -25
- package/dist/api/external/ExternalApiSigner.js.map +0 -1
- package/jest.config.js +0 -7
- package/sequelize.sqlite +0 -0
- package/src/algorithm/encryption/EncryptionAlgorithm.ts +0 -4
- package/src/api/APIRequest.ts +0 -176
- package/src/api/APIRequestBuilder.ts +0 -28
- package/src/api/APIRouter.ts +0 -26
- package/src/api/APIService.ts +0 -117
- package/src/api/ExpressConfiguration.ts +0 -5
- package/src/api/HttpsAPIService.ts +0 -35
- package/src/api/alegra/AlegraConnectionManager.ts +0 -54
- package/src/api/alegra/AlegraTypes.ts +0 -150
- package/src/api/builder/StandardGetRequestBuilder.ts +0 -34
- package/src/api/channel/ServerSentEventsManager.ts +0 -28
- package/src/api/check/APIChecker.ts +0 -50
- package/src/api/check/CheckableAPIRequest.ts +0 -33
- package/src/api/check/CheckableAPIRouter.ts +0 -39
- package/src/api/check/request/CheckableDeleteRequest.ts +0 -17
- package/src/api/check/request/CheckableFileUploadingPostRequest.ts +0 -26
- package/src/api/check/request/CheckableGetRequest.ts +0 -17
- package/src/api/check/request/CheckablePostRequest.ts +0 -17
- package/src/api/check/request/CheckablePutRequest.ts +0 -17
- package/src/api/check/route/CorsCheckApiRouter.ts +0 -22
- package/src/api/check/route/SimpleCheckableAPIRouter.ts +0 -14
- package/src/api/express/ExpressFileUploadingConfiguration.ts +0 -22
- package/src/api/express/ExpressLogableConfig.ts +0 -11
- package/src/api/express/ExpressStandardConfiguration.ts +0 -25
- package/src/api/external/ExternalApiSigner.ts +0 -29
- package/src/api/external/cetus/CetusStrategyApiManager.ts +0 -48
- package/src/api/request/DeleteRequest.ts +0 -16
- package/src/api/request/GetRequest.ts +0 -16
- package/src/api/request/PostRequest.ts +0 -16
- package/src/api/request/PutRequest.ts +0 -16
- package/src/api/request/RequestAxiosCall.ts +0 -38
- package/src/api/request/crud/CrudManager.ts +0 -11
- package/src/api/request/crud/CrudServiceManager.ts +0 -117
- package/src/api/request/docs/DocumentationModels.ts +0 -121
- package/src/api/request/docs/DocumentationRequest.ts +0 -132
- package/src/api/route/SimpleAPIRouter.ts +0 -12
- package/src/database/mongoose/MongooseModelManager.ts +0 -65
- package/src/database/redis/RedisConnection.ts +0 -18
- package/src/database/redis/RedisModelManager.ts +0 -23
- package/src/database/sequelize/SequelizeConnection.ts +0 -45
- package/src/database/sequelize/SequelizeModelManager.ts +0 -71
- package/src/index.ts +0 -51
- package/src/log/Logger.ts +0 -27
- package/src/log/LoggerManager.ts +0 -50
- package/src/log/LoggerWebSocket.ts +0 -13
- package/src/math/Utils.ts +0 -4
- package/src/types/payments.ts +0 -811
- package/src/web3/Coin.ts +0 -18
- package/src/web3/coingecko/CoingeckoPriceFinder.ts +0 -75
- package/test/api/APIRouter.test.ts +0 -78
- package/test/api/APIService.test.ts +0 -50
- package/test/api/APITestDefinitions.ts +0 -7
- package/test/api/CORS.test.ts +0 -56
- package/test/api/alegra/AlegraConnectionManager.test.ts +0 -32
- package/test/api/check/CheckDefinitions.ts +0 -47
- package/test/api/check/CheckableAPIRouter.test.ts +0 -67
- package/test/api/check/CheckableDeleteRequest.test.ts +0 -92
- package/test/api/check/CheckableGetRequest.test.ts +0 -99
- package/test/api/check/CheckablePostRequest.test.ts +0 -108
- package/test/api/check/CheckablePutRequest.test.ts +0 -99
- package/test/api/docs/DocumentationRequest.test.ts +0 -192
- package/test/api/request/DeleteRequest.test.ts +0 -117
- package/test/api/request/GetRequest.test.ts +0 -140
- package/test/api/request/PostRequest.test.ts +0 -237
- package/test/api/request/PutRequest.test.ts +0 -166
- package/test/database/mongoose/MongooseModelManager.test.ts +0 -139
- package/test/database/redis/RedisConnection.test.ts +0 -7
- package/test/database/sequelize/SequealizeDefinitions.ts +0 -6
- package/test/database/sequelize/SequelizeConnection.test.ts +0 -30
- package/test/database/sequelize/SequelizeModelManager.test.ts +0 -206
- package/test/log/Logger.test.ts +0 -44
- package/test/web3/coingecko/CoingeckoPriceFinder.test.ts +0 -72
- package/tsconfig.json +0 -23
- /package/dist/{algorithm/encryption → cryptography}/EncryptionAlgorithm.d.ts +0 -0
- /package/dist/{algorithm/encryption → cryptography}/EncryptionAlgorithm.js +0 -0
package/src/api/APIService.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import express, { Express, Request, Response } from 'express';
|
|
2
|
-
import { APIRequest } from './APIRequest';
|
|
3
|
-
import { APIRouter } from './APIRouter';
|
|
4
|
-
import { ExpressConfiguration } from './ExpressConfiguration';
|
|
5
|
-
import { DocumentationRequest } from './request/docs/DocumentationRequest';
|
|
6
|
-
|
|
7
|
-
export namespace ITRMAPIServiceGlobal {
|
|
8
|
-
export var memory: any = {};
|
|
9
|
-
export var service: APIService | undefined = undefined;
|
|
10
|
-
export var requests: any = {};
|
|
11
|
-
export var routers: any = {};
|
|
12
|
-
export var whitelist: string[] = [];
|
|
13
|
-
export var tools: any = {};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export declare interface APIServiceConfig {
|
|
17
|
-
name: string,
|
|
18
|
-
port: string | number,
|
|
19
|
-
express: ExpressConfiguration
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export declare interface APIServiceResponse {
|
|
23
|
-
status: string,
|
|
24
|
-
message: string,
|
|
25
|
-
error?: any
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class APIService {
|
|
29
|
-
protected server: any = undefined;
|
|
30
|
-
protected app: Express = express();
|
|
31
|
-
protected name: string;
|
|
32
|
-
protected port: number | string;
|
|
33
|
-
protected config: ExpressConfiguration;
|
|
34
|
-
|
|
35
|
-
constructor(config: APIServiceConfig) {
|
|
36
|
-
this.name = config.name;
|
|
37
|
-
this.port = config.port;
|
|
38
|
-
this.config = config.express;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public init() {
|
|
42
|
-
ITRMAPIServiceGlobal.service = this;
|
|
43
|
-
this.config.apply(this.app);
|
|
44
|
-
this.app.get('/', (req: Request, res: Response | any) => {
|
|
45
|
-
return res.send('Server working!');
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public addRouter(router: APIRouter) {
|
|
50
|
-
ITRMAPIServiceGlobal.routers[router.path] = router;
|
|
51
|
-
this.app.use(router.path, router.router);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public addRequest(request: APIRequest) {
|
|
55
|
-
ITRMAPIServiceGlobal.requests[request.method + "_" + request.path] = request;
|
|
56
|
-
request.addToApp(this.app);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public getServerInformation() {
|
|
60
|
-
return {
|
|
61
|
-
name: this.name,
|
|
62
|
-
port: this.port,
|
|
63
|
-
routers: ITRMAPIServiceGlobal.routers,
|
|
64
|
-
requests: ITRMAPIServiceGlobal.requests
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public enableDocumentation() {
|
|
69
|
-
const swaggerUi = require('swagger-ui-express');
|
|
70
|
-
const documentationRequest = new DocumentationRequest();
|
|
71
|
-
this.app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(documentationRequest.init()));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public run(init: Function): Promise<APIServiceResponse> {
|
|
75
|
-
return new Promise<APIServiceResponse>((resolve, reject) => {
|
|
76
|
-
this.server = this.app.listen(this.port, async () => {
|
|
77
|
-
console.log(`⚡️[server]: Server is running at http://localhost:${this.port}`);
|
|
78
|
-
try {
|
|
79
|
-
await init();
|
|
80
|
-
resolve({ status: 'Ok', message: 'Server has been Initialized' });
|
|
81
|
-
} catch (err: any) {
|
|
82
|
-
reject({
|
|
83
|
-
status: 'Error',
|
|
84
|
-
message: 'An error has ocurred in the initialization function',
|
|
85
|
-
error: err
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public close(finish: Function): Promise<APIServiceResponse> {
|
|
93
|
-
return new Promise<APIServiceResponse>((resolve, reject) => {
|
|
94
|
-
this.server.close(async (err: any) => {
|
|
95
|
-
if (err)
|
|
96
|
-
reject({
|
|
97
|
-
status: 'Error',
|
|
98
|
-
message: 'An error has ocurred when closing Server',
|
|
99
|
-
error: err
|
|
100
|
-
});
|
|
101
|
-
try {
|
|
102
|
-
await finish();
|
|
103
|
-
resolve({
|
|
104
|
-
status: 'Ok',
|
|
105
|
-
message: 'Server has been closed'
|
|
106
|
-
});
|
|
107
|
-
} catch (err: any) {
|
|
108
|
-
reject({
|
|
109
|
-
status: 'Error',
|
|
110
|
-
message: 'An error has ocurred in the closing function',
|
|
111
|
-
error: err
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import https, { ServerOptions } from 'https';
|
|
2
|
-
import { APIService, APIServiceConfig, APIServiceResponse } from "./APIService";
|
|
3
|
-
|
|
4
|
-
export class HttpsAPIService extends APIService {
|
|
5
|
-
private httpsServer: any = undefined;
|
|
6
|
-
private options: ServerOptions;
|
|
7
|
-
|
|
8
|
-
constructor(config: APIServiceConfig, options: ServerOptions) {
|
|
9
|
-
super(config);
|
|
10
|
-
this.options = options;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public init() {
|
|
14
|
-
super.init();
|
|
15
|
-
this.httpsServer = https.createServer(this.options, this.app);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public run(init: Function): Promise<APIServiceResponse> {
|
|
19
|
-
return new Promise<APIServiceResponse>((resolve, reject) => {
|
|
20
|
-
this.server = this.httpsServer.listen(this.port, async () => {
|
|
21
|
-
console.log(`⚡️[server]: Server is running at https://localhost:${this.port}`);
|
|
22
|
-
try {
|
|
23
|
-
await init();
|
|
24
|
-
resolve({ status: 'Ok', message: 'Server has been Initialized' });
|
|
25
|
-
} catch (err: any) {
|
|
26
|
-
reject({
|
|
27
|
-
status: 'Error',
|
|
28
|
-
message: 'An error has ocurred in the initialization function',
|
|
29
|
-
error: err
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
import { RequestAxiosCall } from "../request/RequestAxiosCall";
|
|
3
|
-
import { IAlegraContact, IAlegraJournal, IAlegraPayment, IAlegraResult } from "./AlegraTypes";
|
|
4
|
-
|
|
5
|
-
export class AlegraConnectionManager {
|
|
6
|
-
private alegraUrl: string;
|
|
7
|
-
private headers: AxiosRequestConfig;
|
|
8
|
-
|
|
9
|
-
constructor(alegraUrl: string, token: string) {
|
|
10
|
-
this.alegraUrl = alegraUrl;
|
|
11
|
-
this.headers = { headers: { Authorization: `Basic ${token}` } };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public async createContact(contact: IAlegraContact) {
|
|
15
|
-
return (await RequestAxiosCall.post(`${this.alegraUrl}/v1/contacts`, contact, this.headers)) as IAlegraContact;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async findContact(document: string): Promise<IAlegraContact | undefined> {
|
|
19
|
-
let response: any = await RequestAxiosCall.get(`${this.alegraUrl}/v1/contacts?order_direction=ASC&identification=${document}`, this.headers);
|
|
20
|
-
return response.length > 0 ? response[0] : undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public async createJournal(body: IAlegraJournal) {
|
|
24
|
-
return (await RequestAxiosCall.post(`${this.alegraUrl}/v1/journals`, body, this.headers)) as IAlegraJournal;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public async findJournal(journalId: string | number) {
|
|
28
|
-
return (await RequestAxiosCall.get(`${this.alegraUrl}/v1/journals/${journalId}`, this.headers) as IAlegraJournal);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public async updateJournal(journalId: string | number, body: IAlegraJournal) {
|
|
32
|
-
return await RequestAxiosCall.put(`${this.alegraUrl}/v1/journals/${journalId}`, body, this.headers);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public async deleteJournal(journalId: string | number) {
|
|
36
|
-
return (await RequestAxiosCall.delete(`${this.alegraUrl}/v1/journals/${journalId}`, this.headers)) as IAlegraResult;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public async createPayment(body: IAlegraPayment) {
|
|
40
|
-
return (await RequestAxiosCall.post(`${this.alegraUrl}/v1/payments`, body, this.headers)) as IAlegraPayment;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public async findPayment(paymentId: string | number) {
|
|
44
|
-
return (await RequestAxiosCall.get(`${this.alegraUrl}/v1/payments/${paymentId}`, this.headers) as IAlegraPayment);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public async updatePayment(paymentId: string | number, body: IAlegraPayment) {
|
|
48
|
-
return await RequestAxiosCall.put(`${this.alegraUrl}/v1/payments/${paymentId}`, body, this.headers);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public async deletePayment(paymentId: string | number) {
|
|
52
|
-
return (await RequestAxiosCall.delete(`${this.alegraUrl}/v1/payments/${paymentId}`, this.headers)) as IAlegraResult;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
export interface IAlegraContact {
|
|
2
|
-
id?: string | number;
|
|
3
|
-
name?: string;
|
|
4
|
-
identification?: string;
|
|
5
|
-
email?: string;
|
|
6
|
-
phonePrimary?: string;
|
|
7
|
-
phoneSecondary?: string;
|
|
8
|
-
fax?: string;
|
|
9
|
-
mobile?: string;
|
|
10
|
-
observations?: string;
|
|
11
|
-
status?: 'active' | 'inactive';
|
|
12
|
-
kindOfPerson?: 'PERSON_ENTITY' | 'LEGAL_ENTITY ' | 'OTHER_ENTITY ';
|
|
13
|
-
regime?: 'COMMON_REGIME' | 'SIMPLIFIED_REGIME' | 'NATIONAL_CONSUMPTION_TAX' | 'NOT_REPONSIBLE_FOR_CONSUMPTION' | 'INC_IVA_RESPONSIBLE' | 'SPECIAL_REGIME';
|
|
14
|
-
nameObject?: {
|
|
15
|
-
firstName: string;
|
|
16
|
-
secondName: string;
|
|
17
|
-
lastName: string;
|
|
18
|
-
secondLastName?: string;
|
|
19
|
-
};
|
|
20
|
-
identificationObject?: {
|
|
21
|
-
type: 'CC' | 'TI' | 'NIT' | 'DIE' | 'PP' | 'CE' | 'TE' | 'RC' | 'FOREIGN_NIT' | 'NUIP';
|
|
22
|
-
number: string;
|
|
23
|
-
dv?: string;
|
|
24
|
-
};
|
|
25
|
-
fiscalResidence?: 'RESIDENT' | 'NON_RESIDENT';
|
|
26
|
-
enableHealthSector?: boolean;
|
|
27
|
-
healthPatients?: any;
|
|
28
|
-
address?: {
|
|
29
|
-
address: string;
|
|
30
|
-
city: string;
|
|
31
|
-
department?: string;
|
|
32
|
-
country?: 'Colombia';
|
|
33
|
-
zipCode?: string;
|
|
34
|
-
};
|
|
35
|
-
type?: string[];
|
|
36
|
-
seller?: any;
|
|
37
|
-
term?: {
|
|
38
|
-
id: number;
|
|
39
|
-
name: string;
|
|
40
|
-
days: string;
|
|
41
|
-
};
|
|
42
|
-
priceList?: {
|
|
43
|
-
id: number;
|
|
44
|
-
name: string;
|
|
45
|
-
};
|
|
46
|
-
internalContacts?: string[];
|
|
47
|
-
settings?: { sendElectronicDocuments: boolean; };
|
|
48
|
-
statementAttached?: boolean;
|
|
49
|
-
accounting?: {
|
|
50
|
-
accountReceivable: {
|
|
51
|
-
id: string;
|
|
52
|
-
idParent: string;
|
|
53
|
-
name: string;
|
|
54
|
-
text: string;
|
|
55
|
-
code: string;
|
|
56
|
-
description: string;
|
|
57
|
-
type: string;
|
|
58
|
-
readOnly: boolean;
|
|
59
|
-
nature: string;
|
|
60
|
-
blocked: string;
|
|
61
|
-
status: string;
|
|
62
|
-
categoryRule: any;
|
|
63
|
-
use: string;
|
|
64
|
-
showThirdPartyBalance: boolean
|
|
65
|
-
};
|
|
66
|
-
debtToPay: {
|
|
67
|
-
id: string;
|
|
68
|
-
idParent: string;
|
|
69
|
-
name: string;
|
|
70
|
-
text: string;
|
|
71
|
-
code: string;
|
|
72
|
-
description: string;
|
|
73
|
-
type: string;
|
|
74
|
-
readOnly: boolean;
|
|
75
|
-
nature: string;
|
|
76
|
-
blocked: string;
|
|
77
|
-
status: string;
|
|
78
|
-
categoryRule?: any;
|
|
79
|
-
use: string;
|
|
80
|
-
showThirdPartyBalance: boolean
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface IAlegraPayment {
|
|
86
|
-
id?: string | number;
|
|
87
|
-
date: string;
|
|
88
|
-
bankAccount: {
|
|
89
|
-
id: string | number;
|
|
90
|
-
};
|
|
91
|
-
client: IAlegraContact,
|
|
92
|
-
paymentMethod: 'transfer' | 'cash' | 'deposit' | 'check' | 'credit-card' | 'debit-card';
|
|
93
|
-
observations: string;
|
|
94
|
-
anotation: string;
|
|
95
|
-
type: 'in' | 'out';
|
|
96
|
-
categories: IAlegraCategory[];
|
|
97
|
-
costCenter?: any;
|
|
98
|
-
numberTemplate?: {
|
|
99
|
-
id: string;
|
|
100
|
-
prefix: any,
|
|
101
|
-
number: string;
|
|
102
|
-
fullNumber: string;
|
|
103
|
-
formattedNumber:string;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface IAlegraCategory {
|
|
108
|
-
id: string | number;
|
|
109
|
-
name?: string;
|
|
110
|
-
price: number;
|
|
111
|
-
quantity: number;
|
|
112
|
-
observations: string;
|
|
113
|
-
total?: number;
|
|
114
|
-
behavior?: string;
|
|
115
|
-
tax?: any[]
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface IAlegraJournal {
|
|
119
|
-
id?: string | number;
|
|
120
|
-
date: string;
|
|
121
|
-
observations: string;
|
|
122
|
-
entries: IAlegraEntry[];
|
|
123
|
-
client?: IAlegraContact;
|
|
124
|
-
reference?: string;
|
|
125
|
-
status?: string;
|
|
126
|
-
total?: number;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface IAlegraEntry {
|
|
130
|
-
id: string | number;
|
|
131
|
-
client: IAlegraContact;
|
|
132
|
-
description: string;
|
|
133
|
-
debit: number;
|
|
134
|
-
credit: number;
|
|
135
|
-
name?: string;
|
|
136
|
-
type?: string;
|
|
137
|
-
line?: string;
|
|
138
|
-
lineParent?: any;
|
|
139
|
-
costCenter?: any;
|
|
140
|
-
associatedDocument?: {
|
|
141
|
-
idResource: any;
|
|
142
|
-
resourceType: any;
|
|
143
|
-
resource: any;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface IAlegraResult {
|
|
148
|
-
code: number;
|
|
149
|
-
message: string;
|
|
150
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { GroupedParameters, RequestContext, RequestParameterType } from "../APIRequest";
|
|
2
|
-
import { APIRequestBuilder } from "../APIRequestBuilder";
|
|
3
|
-
|
|
4
|
-
export abstract class StandardGetRequestBuilder extends APIRequestBuilder {
|
|
5
|
-
protected buildDefaultParams(): GroupedParameters[] {
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
context: RequestContext.QUERY,
|
|
9
|
-
properties: [{ name: "id", type: RequestParameterType.STRING }],
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
context: RequestContext.QUERY,
|
|
13
|
-
properties: [{ name: "limit", type: RequestParameterType.STRING }],
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
context: RequestContext.QUERY,
|
|
17
|
-
properties: [{ name: "count", type: RequestParameterType.STRING }],
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
context: RequestContext.QUERY,
|
|
21
|
-
properties: [
|
|
22
|
-
{ name: "limit", type: RequestParameterType.STRING },
|
|
23
|
-
{ name: "offset", type: RequestParameterType.STRING },
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public abstract buildSpecificParams(): GroupedParameters[];
|
|
30
|
-
|
|
31
|
-
public buildParams(): GroupedParameters[] {
|
|
32
|
-
return this.buildDefaultParams().concat(this.buildSpecificParams());
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Response } from 'express';
|
|
2
|
-
|
|
3
|
-
export class ServerSentEventsManager {
|
|
4
|
-
private res: Response;
|
|
5
|
-
|
|
6
|
-
constructor(res: Response, config?: any) {
|
|
7
|
-
config = config ?? {
|
|
8
|
-
'Cache-control': 'no-cahe',
|
|
9
|
-
'Content-Type': 'text/event-stream',
|
|
10
|
-
'Connection': 'keep-alive'
|
|
11
|
-
};
|
|
12
|
-
res.set(config);
|
|
13
|
-
res.flushHeaders();
|
|
14
|
-
this.res = res;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public write(status: number, payload: string) {
|
|
18
|
-
this.res.status(status).write(payload);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public writeObject(status: number, payload: any) {
|
|
22
|
-
this.res.status(status).write(JSON.stringify(payload));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public end(status: number, payload: string) {
|
|
26
|
-
this.res.status(200).end(payload);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from "express";
|
|
2
|
-
|
|
3
|
-
export declare interface APICheckResult {
|
|
4
|
-
approved: boolean,
|
|
5
|
-
payload?: any,
|
|
6
|
-
rejection?: {
|
|
7
|
-
code: number,
|
|
8
|
-
payload: any
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export declare interface APICheckConfig {
|
|
13
|
-
check: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface APICheck {
|
|
17
|
-
getConfig(): APICheckConfig;
|
|
18
|
-
apply(config: APICheckConfig, req: Request): PromiseLike<APICheckResult>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface Checkable {
|
|
22
|
-
addCheck(check: APICheck): void;
|
|
23
|
-
check(req: Request, res: Response, next: NextFunction): PromiseLike<void | Response>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class APIChecker {
|
|
27
|
-
private checks: APICheck[] = [];
|
|
28
|
-
|
|
29
|
-
public addCheck(check: APICheck) {
|
|
30
|
-
this.checks.push(check);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public async applyChecks(req: Request): Promise<APICheckResult> {
|
|
34
|
-
if (!req.body || !req.body.checkResults)
|
|
35
|
-
req.body = { ...(req.body ?? {}), checkResults: {} };
|
|
36
|
-
for (let check of this.checks) {
|
|
37
|
-
let result = await check.apply(check.getConfig(), req);
|
|
38
|
-
req.body.checkResults[check.getConfig().check] = result.payload;
|
|
39
|
-
if (!result.approved)
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
return { approved: true };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public reject(res: Response, result: APICheckResult) {
|
|
46
|
-
if (result.rejection)
|
|
47
|
-
return res.status(result.rejection.code).json(result.rejection.payload);
|
|
48
|
-
return res.status(401).json({ message: 'Unknown reason' });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from "express";
|
|
2
|
-
import { APIRequest, APIRequestConfig, RequestMethod } from "../APIRequest";
|
|
3
|
-
import { ITRMAPIServiceGlobal } from "../APIService";
|
|
4
|
-
import { APICheckResult, APIChecker, APICheck, Checkable } from "./APIChecker";
|
|
5
|
-
|
|
6
|
-
export abstract class CheckableAPIRequest extends APIRequest implements Checkable {
|
|
7
|
-
private checker: APIChecker = new APIChecker();
|
|
8
|
-
|
|
9
|
-
constructor(method: RequestMethod, config: APIRequestConfig) {
|
|
10
|
-
super(method, config);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public addCheck(check: APICheck) {
|
|
14
|
-
this.checker.addCheck(check);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async check(req: Request, res: Response | any, next: NextFunction) {
|
|
18
|
-
try {
|
|
19
|
-
let request: CheckableAPIRequest = ITRMAPIServiceGlobal.requests[APIRequest.buildKey(req)];
|
|
20
|
-
let result: APICheckResult = await request.checker.applyChecks(req);
|
|
21
|
-
if (result.approved)
|
|
22
|
-
return next();
|
|
23
|
-
return request.checker.reject(res, result);
|
|
24
|
-
} catch (error: any) {
|
|
25
|
-
console.log("> error:", error);
|
|
26
|
-
return await res.status(error?.response?.status ?? 500).json({
|
|
27
|
-
type: 'InternalRequestCheckError',
|
|
28
|
-
error: 'An error has ocurred when runing the checks for the request',
|
|
29
|
-
payload: error?.response?.data ?? error
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { RouterOptions, Request, Response, NextFunction } from "express";
|
|
2
|
-
import { APIRouter } from "../APIRouter";
|
|
3
|
-
import { ITRMAPIServiceGlobal } from "../APIService";
|
|
4
|
-
import { APICheck, APIChecker, APICheckResult, Checkable } from "./APIChecker";
|
|
5
|
-
|
|
6
|
-
export abstract class CheckableAPIRouter extends APIRouter implements Checkable {
|
|
7
|
-
private checker: APIChecker = new APIChecker();
|
|
8
|
-
|
|
9
|
-
constructor(path: string, options?: RouterOptions) {
|
|
10
|
-
super(path, options);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public init() {
|
|
14
|
-
this.router.use(this.check);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public addCheck(checker: APICheck) {
|
|
18
|
-
this.checker.addCheck(checker);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public async check(req: Request, res: Response, next: NextFunction): Promise<void | Response | any> {
|
|
22
|
-
try {
|
|
23
|
-
let route: CheckableAPIRouter = ITRMAPIServiceGlobal.routers[req.baseUrl];
|
|
24
|
-
route.setHeaders(res);
|
|
25
|
-
let result: APICheckResult = await route.checker.applyChecks(req)
|
|
26
|
-
if (result.approved)
|
|
27
|
-
return route.runMiddleware(req, res, next);
|
|
28
|
-
return route.checker.reject(res, result);
|
|
29
|
-
} catch (error: any) {
|
|
30
|
-
return await res.status(error?.response?.status ?? 500).json({
|
|
31
|
-
type: 'InternalRouterCheckError',
|
|
32
|
-
error: 'An error has ocurred when runing the checks for the router',
|
|
33
|
-
payload: error?.response?.data ?? error
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected abstract setHeaders(res: Response) : void;
|
|
39
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Express, Router } from "express";
|
|
2
|
-
import { APIRequestConfig, RequestMethod } from "../../APIRequest";
|
|
3
|
-
import { CheckableAPIRequest } from "../CheckableAPIRequest";
|
|
4
|
-
|
|
5
|
-
export abstract class CheckableDeleteRequest extends CheckableAPIRequest {
|
|
6
|
-
constructor(config: APIRequestConfig) {
|
|
7
|
-
super(RequestMethod.DELETE, config);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public addToApp(app: Express): void {
|
|
11
|
-
app.delete(this.path, this.check, this.process);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public addToRouter(router: Router): void {
|
|
15
|
-
router.delete(this.path, this.check, this.process);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Express, Router } from "express";
|
|
2
|
-
import { APIRequestConfig, RequestMethod } from "../../APIRequest";
|
|
3
|
-
import { CheckableAPIRequest } from "../CheckableAPIRequest";
|
|
4
|
-
import { Multer, StorageEngine } from "multer";
|
|
5
|
-
import { ITRMAPIServiceGlobal } from "../../APIService";
|
|
6
|
-
import { initializeFileUploadingGlobalVars } from "../../express/ExpressFileUploadingConfiguration";
|
|
7
|
-
|
|
8
|
-
export abstract class CheckableFileUploadingPostRequest extends CheckableAPIRequest {
|
|
9
|
-
protected upload: Multer;
|
|
10
|
-
protected storage: StorageEngine;
|
|
11
|
-
|
|
12
|
-
constructor(config: APIRequestConfig) {
|
|
13
|
-
super(RequestMethod.GET, config);
|
|
14
|
-
initializeFileUploadingGlobalVars();
|
|
15
|
-
this.upload = ITRMAPIServiceGlobal.tools.file.upload;
|
|
16
|
-
this.storage = ITRMAPIServiceGlobal.tools.file.storage;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public addToApp(app: Express): void {
|
|
20
|
-
app.post(this.path, this.upload.single("file"), this.check, this.process);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public addToRouter(router: Router): void {
|
|
24
|
-
router.post(this.path, this.upload.single("file"), this.check, this.process);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Express, Router } from "express";
|
|
2
|
-
import { APIRequestConfig, RequestMethod } from "../../APIRequest";
|
|
3
|
-
import { CheckableAPIRequest } from "../CheckableAPIRequest";
|
|
4
|
-
|
|
5
|
-
export abstract class CheckableGetRequest extends CheckableAPIRequest {
|
|
6
|
-
constructor(config: APIRequestConfig) {
|
|
7
|
-
super(RequestMethod.GET, config);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public addToApp(app: Express): void {
|
|
11
|
-
app.get(this.path, this.check, this.process);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public addToRouter(router: Router): void {
|
|
15
|
-
router.get(this.path, this.check, this.process);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Express, Router } from "express";
|
|
2
|
-
import { APIRequestConfig, RequestMethod } from "../../APIRequest";
|
|
3
|
-
import { CheckableAPIRequest } from "../CheckableAPIRequest";
|
|
4
|
-
|
|
5
|
-
export abstract class CheckablePostRequest extends CheckableAPIRequest {
|
|
6
|
-
constructor(config: APIRequestConfig) {
|
|
7
|
-
super(RequestMethod.POST, config);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public addToApp(app: Express): void {
|
|
11
|
-
app.post(this.path, this.check, this.process);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public addToRouter(router: Router): void {
|
|
15
|
-
router.post(this.path, this.check, this.process);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Express, Router } from "express";
|
|
2
|
-
import { APIRequestConfig, RequestMethod } from "../../APIRequest";
|
|
3
|
-
import { CheckableAPIRequest } from "../CheckableAPIRequest";
|
|
4
|
-
|
|
5
|
-
export abstract class CheckablePutRequest extends CheckableAPIRequest {
|
|
6
|
-
constructor(config: APIRequestConfig) {
|
|
7
|
-
super(RequestMethod.PUT, config);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public addToApp(app: Express): void {
|
|
11
|
-
app.put(this.path, this.check, this.process);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public addToRouter(router: Router): void {
|
|
15
|
-
router.put(this.path, this.check, this.process);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response, RouterOptions } from "express";
|
|
2
|
-
import { CheckableAPIRouter } from "../CheckableAPIRouter";
|
|
3
|
-
|
|
4
|
-
export class CorsCheckApiRouter extends CheckableAPIRouter {
|
|
5
|
-
constructor(path: string, options?: RouterOptions) {
|
|
6
|
-
super(path, options);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
protected setHeaders(res: Response<any, Record<string, any>>): void {
|
|
10
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
11
|
-
res.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
|
|
12
|
-
res.setHeader("Access-Control-Allow-Headers", "Content-Type,Authorization,platform");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
protected async runMiddleware(
|
|
16
|
-
req: Request,
|
|
17
|
-
res: Response,
|
|
18
|
-
next: NextFunction
|
|
19
|
-
): Promise<void | Response> {
|
|
20
|
-
return next();
|
|
21
|
-
}
|
|
22
|
-
}
|