itrm-tools 1.3.5-viio.3 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +2 -2
  2. package/dist/api/APIRequest.js +29 -22
  3. package/dist/api/APIRequest.js.map +1 -1
  4. package/dist/api/APIRouter.js +1 -3
  5. package/dist/api/APIRouter.js.map +1 -1
  6. package/dist/api/APIService.js +17 -11
  7. package/dist/api/APIService.js.map +1 -1
  8. package/dist/api/HttpsAPIService.js +13 -5
  9. package/dist/api/HttpsAPIService.js.map +1 -1
  10. package/dist/api/alegra/AlegraConnectionManager.js +50 -23
  11. package/dist/api/alegra/AlegraConnectionManager.js.map +1 -1
  12. package/dist/api/channel/ServerSentEventsManager.js +1 -2
  13. package/dist/api/channel/ServerSentEventsManager.js.map +1 -1
  14. package/dist/api/check/APIChecker.js +25 -11
  15. package/dist/api/check/APIChecker.js.map +1 -1
  16. package/dist/api/check/CheckableAPIRequest.js +29 -17
  17. package/dist/api/check/CheckableAPIRequest.js.map +1 -1
  18. package/dist/api/check/CheckableAPIRouter.js +29 -17
  19. package/dist/api/check/CheckableAPIRouter.js.map +1 -1
  20. package/dist/api/check/request/CheckableFileUploadingPostRequest.js +0 -2
  21. package/dist/api/check/request/CheckableFileUploadingPostRequest.js.map +1 -1
  22. package/dist/api/check/route/CorsCheckApiRouter.js +13 -2
  23. package/dist/api/check/route/CorsCheckApiRouter.js.map +1 -1
  24. package/dist/api/check/route/SimpleCheckableAPIRouter.js +13 -2
  25. package/dist/api/check/route/SimpleCheckableAPIRouter.js.map +1 -1
  26. package/dist/api/express/ExpressStandardConfiguration.d.ts +1 -1
  27. package/dist/api/express/ExpressStandardConfiguration.js +9 -1
  28. package/dist/api/express/ExpressStandardConfiguration.js.map +1 -1
  29. package/dist/api/external/ExternalApiConnection.d.ts +13 -0
  30. package/dist/api/external/ExternalApiConnection.js +21 -0
  31. package/dist/api/external/ExternalApiConnection.js.map +1 -0
  32. package/dist/api/external/cetus/CetusStrategyApiManager.d.ts +4 -3
  33. package/dist/api/external/cetus/CetusStrategyApiManager.js +22 -10
  34. package/dist/api/external/cetus/CetusStrategyApiManager.js.map +1 -1
  35. package/dist/api/request/RequestAxiosCall.d.ts +4 -4
  36. package/dist/api/request/RequestAxiosCall.js +37 -20
  37. package/dist/api/request/RequestAxiosCall.js.map +1 -1
  38. package/dist/api/request/crud/CrudManager.d.ts +2 -2
  39. package/dist/api/request/crud/CrudServiceManager.d.ts +5 -5
  40. package/dist/api/request/crud/CrudServiceManager.js +17 -6
  41. package/dist/api/request/crud/CrudServiceManager.js.map +1 -1
  42. package/dist/api/request/crud/common/ActivityHistoryManager.d.ts +40 -0
  43. package/dist/api/request/crud/common/ActivityHistoryManager.js +84 -0
  44. package/dist/api/request/crud/common/ActivityHistoryManager.js.map +1 -0
  45. package/dist/api/request/crud/common/ApplicationManager.d.ts +39 -0
  46. package/dist/api/request/crud/common/ApplicationManager.js +72 -0
  47. package/dist/api/request/crud/common/ApplicationManager.js.map +1 -0
  48. package/dist/api/request/crud/common/AvailablePlatformManager.d.ts +39 -0
  49. package/dist/api/request/crud/common/AvailablePlatformManager.js +84 -0
  50. package/dist/api/request/crud/common/AvailablePlatformManager.js.map +1 -0
  51. package/dist/api/request/crud/common/ComponentManager.d.ts +56 -0
  52. package/dist/api/request/crud/common/ComponentManager.js +78 -0
  53. package/dist/api/request/crud/common/ComponentManager.js.map +1 -0
  54. package/dist/api/request/crud/common/KeyManager.d.ts +42 -0
  55. package/dist/api/request/crud/common/KeyManager.js +85 -0
  56. package/dist/api/request/crud/common/KeyManager.js.map +1 -0
  57. package/dist/api/request/crud/common/PlatformManager.d.ts +44 -0
  58. package/dist/api/request/crud/common/PlatformManager.js +75 -0
  59. package/dist/api/request/crud/common/PlatformManager.js.map +1 -0
  60. package/dist/api/request/crud/common/RoleManager.d.ts +51 -0
  61. package/dist/api/request/crud/common/RoleManager.js +72 -0
  62. package/dist/api/request/crud/common/RoleManager.js.map +1 -0
  63. package/dist/api/request/crud/common/StatusManager.d.ts +34 -0
  64. package/dist/api/request/crud/common/StatusManager.js +72 -0
  65. package/dist/api/request/crud/common/StatusManager.js.map +1 -0
  66. package/dist/api/request/crud/common/TypeManager.d.ts +33 -0
  67. package/dist/api/request/crud/common/TypeManager.js +74 -0
  68. package/dist/api/request/crud/common/TypeManager.js.map +1 -0
  69. package/dist/api/request/crud/common/UserCredentialsManager.d.ts +39 -0
  70. package/dist/api/request/crud/common/UserCredentialsManager.js +82 -0
  71. package/dist/api/request/crud/common/UserCredentialsManager.js.map +1 -0
  72. package/dist/api/request/crud/common/UserManager.d.ts +35 -0
  73. package/dist/api/request/crud/common/UserManager.js +78 -0
  74. package/dist/api/request/crud/common/UserManager.js.map +1 -0
  75. package/dist/api/request/docs/DocumentationModels.d.ts +4 -4
  76. package/dist/api/request/docs/DocumentationModels.js.map +1 -1
  77. package/dist/api/request/docs/DocumentationRequest.js +7 -4
  78. package/dist/api/request/docs/DocumentationRequest.js.map +1 -1
  79. package/dist/api/route/SimpleAPIRouter.js +13 -2
  80. package/dist/api/route/SimpleAPIRouter.js.map +1 -1
  81. package/dist/cryptography/CipheringAlgorithm.d.ts +4 -0
  82. package/dist/cryptography/CipheringAlgorithm.js +3 -0
  83. package/dist/cryptography/CipheringAlgorithm.js.map +1 -0
  84. package/dist/cryptography/EncryptionAlgorithm.js.map +1 -0
  85. package/dist/cryptography/KeyGenerator.d.ts +3 -0
  86. package/dist/cryptography/KeyGenerator.js +3 -0
  87. package/dist/cryptography/KeyGenerator.js.map +1 -0
  88. package/dist/cryptography/Signer.d.ts +4 -0
  89. package/dist/cryptography/Signer.js +3 -0
  90. package/dist/cryptography/Signer.js.map +1 -0
  91. package/dist/cryptography/algorithm/AesCipheringAlgorithm.d.ts +6 -0
  92. package/dist/cryptography/algorithm/AesCipheringAlgorithm.js +28 -0
  93. package/dist/cryptography/algorithm/AesCipheringAlgorithm.js.map +1 -0
  94. package/dist/cryptography/generate/StandardApiKeyGenerator.d.ts +9 -0
  95. package/dist/cryptography/generate/StandardApiKeyGenerator.js +18 -0
  96. package/dist/cryptography/generate/StandardApiKeyGenerator.js.map +1 -0
  97. package/dist/cryptography/sign/ApiKeySigner.d.ts +14 -0
  98. package/dist/cryptography/sign/ApiKeySigner.js +35 -0
  99. package/dist/cryptography/sign/ApiKeySigner.js.map +1 -0
  100. package/dist/database/mongoose/MongooseModelManager.d.ts +7 -1
  101. package/dist/database/mongoose/MongooseModelManager.js +14 -5
  102. package/dist/database/mongoose/MongooseModelManager.js.map +1 -1
  103. package/dist/database/redis/RedisConnection.js +0 -1
  104. package/dist/database/redis/RedisConnection.js.map +1 -1
  105. package/dist/database/redis/RedisModelManager.js +0 -1
  106. package/dist/database/redis/RedisModelManager.js.map +1 -1
  107. package/dist/database/sequelize/SequelizeConnection.js +0 -1
  108. package/dist/database/sequelize/SequelizeConnection.js.map +1 -1
  109. package/dist/database/sequelize/SequelizeModelManager.js +15 -6
  110. package/dist/database/sequelize/SequelizeModelManager.js.map +1 -1
  111. package/dist/index.d.ts +17 -2
  112. package/dist/index.js +32 -3
  113. package/dist/index.js.map +1 -1
  114. package/dist/log/Logger.js +0 -2
  115. package/dist/log/Logger.js.map +1 -1
  116. package/dist/log/LoggerManager.js +21 -11
  117. package/dist/log/LoggerManager.js.map +1 -1
  118. package/dist/log/LoggerWebSocket.js +2 -4
  119. package/dist/log/LoggerWebSocket.js.map +1 -1
  120. package/dist/web3/coingecko/CoingeckoPriceFinder.js +36 -24
  121. package/dist/web3/coingecko/CoingeckoPriceFinder.js.map +1 -1
  122. package/package.json +74 -99
  123. package/.github/workflows/node.js.yml +0 -30
  124. package/dist/algorithm/encryption/EncryptionAlgorithm.js.map +0 -1
  125. package/dist/api/external/ExternalApiSigner.d.ts +0 -15
  126. package/dist/api/external/ExternalApiSigner.js +0 -25
  127. package/dist/api/external/ExternalApiSigner.js.map +0 -1
  128. package/jest.config.js +0 -7
  129. package/sequelize.sqlite +0 -0
  130. package/src/algorithm/encryption/EncryptionAlgorithm.ts +0 -4
  131. package/src/api/APIRequest.ts +0 -176
  132. package/src/api/APIRequestBuilder.ts +0 -28
  133. package/src/api/APIRouter.ts +0 -26
  134. package/src/api/APIService.ts +0 -117
  135. package/src/api/ExpressConfiguration.ts +0 -5
  136. package/src/api/HttpsAPIService.ts +0 -35
  137. package/src/api/alegra/AlegraConnectionManager.ts +0 -54
  138. package/src/api/alegra/AlegraTypes.ts +0 -150
  139. package/src/api/builder/StandardGetRequestBuilder.ts +0 -34
  140. package/src/api/channel/ServerSentEventsManager.ts +0 -28
  141. package/src/api/check/APIChecker.ts +0 -50
  142. package/src/api/check/CheckableAPIRequest.ts +0 -33
  143. package/src/api/check/CheckableAPIRouter.ts +0 -39
  144. package/src/api/check/request/CheckableDeleteRequest.ts +0 -17
  145. package/src/api/check/request/CheckableFileUploadingPostRequest.ts +0 -26
  146. package/src/api/check/request/CheckableGetRequest.ts +0 -17
  147. package/src/api/check/request/CheckablePostRequest.ts +0 -17
  148. package/src/api/check/request/CheckablePutRequest.ts +0 -17
  149. package/src/api/check/route/CorsCheckApiRouter.ts +0 -22
  150. package/src/api/check/route/SimpleCheckableAPIRouter.ts +0 -14
  151. package/src/api/express/ExpressFileUploadingConfiguration.ts +0 -22
  152. package/src/api/express/ExpressLogableConfig.ts +0 -11
  153. package/src/api/express/ExpressStandardConfiguration.ts +0 -25
  154. package/src/api/external/ExternalApiSigner.ts +0 -29
  155. package/src/api/external/cetus/CetusStrategyApiManager.ts +0 -48
  156. package/src/api/request/DeleteRequest.ts +0 -16
  157. package/src/api/request/GetRequest.ts +0 -16
  158. package/src/api/request/PostRequest.ts +0 -16
  159. package/src/api/request/PutRequest.ts +0 -16
  160. package/src/api/request/RequestAxiosCall.ts +0 -38
  161. package/src/api/request/crud/CrudManager.ts +0 -11
  162. package/src/api/request/crud/CrudServiceManager.ts +0 -117
  163. package/src/api/request/docs/DocumentationModels.ts +0 -121
  164. package/src/api/request/docs/DocumentationRequest.ts +0 -132
  165. package/src/api/route/SimpleAPIRouter.ts +0 -12
  166. package/src/database/mongoose/MongooseModelManager.ts +0 -65
  167. package/src/database/redis/RedisConnection.ts +0 -18
  168. package/src/database/redis/RedisModelManager.ts +0 -23
  169. package/src/database/sequelize/SequelizeConnection.ts +0 -45
  170. package/src/database/sequelize/SequelizeModelManager.ts +0 -71
  171. package/src/index.ts +0 -51
  172. package/src/log/Logger.ts +0 -27
  173. package/src/log/LoggerManager.ts +0 -50
  174. package/src/log/LoggerWebSocket.ts +0 -13
  175. package/src/math/Utils.ts +0 -4
  176. package/src/types/payments.ts +0 -811
  177. package/src/web3/Coin.ts +0 -18
  178. package/src/web3/coingecko/CoingeckoPriceFinder.ts +0 -75
  179. package/test/api/APIRouter.test.ts +0 -78
  180. package/test/api/APIService.test.ts +0 -50
  181. package/test/api/APITestDefinitions.ts +0 -7
  182. package/test/api/CORS.test.ts +0 -56
  183. package/test/api/alegra/AlegraConnectionManager.test.ts +0 -32
  184. package/test/api/check/CheckDefinitions.ts +0 -47
  185. package/test/api/check/CheckableAPIRouter.test.ts +0 -67
  186. package/test/api/check/CheckableDeleteRequest.test.ts +0 -92
  187. package/test/api/check/CheckableGetRequest.test.ts +0 -99
  188. package/test/api/check/CheckablePostRequest.test.ts +0 -108
  189. package/test/api/check/CheckablePutRequest.test.ts +0 -99
  190. package/test/api/docs/DocumentationRequest.test.ts +0 -192
  191. package/test/api/request/DeleteRequest.test.ts +0 -117
  192. package/test/api/request/GetRequest.test.ts +0 -140
  193. package/test/api/request/PostRequest.test.ts +0 -237
  194. package/test/api/request/PutRequest.test.ts +0 -166
  195. package/test/database/mongoose/MongooseModelManager.test.ts +0 -139
  196. package/test/database/redis/RedisConnection.test.ts +0 -7
  197. package/test/database/sequelize/SequealizeDefinitions.ts +0 -6
  198. package/test/database/sequelize/SequelizeConnection.test.ts +0 -30
  199. package/test/database/sequelize/SequelizeModelManager.test.ts +0 -206
  200. package/test/log/Logger.test.ts +0 -44
  201. package/test/web3/coingecko/CoingeckoPriceFinder.test.ts +0 -72
  202. package/tsconfig.json +0 -23
  203. /package/dist/{algorithm/encryption → cryptography}/EncryptionAlgorithm.d.ts +0 -0
  204. /package/dist/{algorithm/encryption → cryptography}/EncryptionAlgorithm.js +0 -0
@@ -1,28 +0,0 @@
1
- import { GroupedParameters } from "./APIRequest"
2
-
3
- export declare interface ISamples {
4
- status: number,
5
- input: any,
6
- output: any
7
- }
8
-
9
- export declare interface DocDetails {
10
- description: string,
11
- samples: ISamples[]
12
- }
13
-
14
- export abstract class APIRequestBuilder {
15
-
16
- constructor() { }
17
-
18
- public abstract buildParams(): GroupedParameters[];
19
- public abstract buildDocDetails(): DocDetails;
20
-
21
- public buildApiRequestConfig(path: string) {
22
- return {
23
- path: path,
24
- params: this.buildParams(),
25
- details: this.buildDocDetails()
26
- }
27
- }
28
- }
@@ -1,26 +0,0 @@
1
- import { NextFunction, Router, RouterOptions,Request, Response } from 'express';
2
- import { APIRequest } from './APIRequest';
3
- import { ITRMAPIServiceGlobal } from './APIService';
4
-
5
- export abstract class APIRouter {
6
- public path: string;
7
- public router: Router;
8
- public linkedRequest: string[] = [];
9
-
10
- constructor(path: string, options?: RouterOptions) {
11
- this.path = path;
12
- this.router = Router(options);
13
- }
14
-
15
- public init() {
16
- this.router.use(this.runMiddleware);
17
- }
18
-
19
- public addRequest(request: APIRequest) {
20
- ITRMAPIServiceGlobal.requests[request.method + "_" + this.path + request.path] = request;
21
- request.addToRouter(this.router);
22
- this.linkedRequest.push(request.method + "_" + this.path + request.path);
23
- }
24
-
25
- protected abstract runMiddleware(req: Request, res: Response, next: NextFunction): Promise<void | Response | any>;
26
- }
@@ -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,5 +0,0 @@
1
- import { Express } from 'express';
2
-
3
- export interface ExpressConfiguration {
4
- apply(app: Express): void;
5
- }
@@ -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
- }