@xrystal/core 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +1 -0
  2. package/bin/constants/index.mjs +14 -0
  3. package/bin/helpers/index.mjs +83 -0
  4. package/bin/main-cli.js +179 -0
  5. package/package.json +113 -0
  6. package/source/index.d.ts +2 -0
  7. package/source/index.js +8 -0
  8. package/source/loader/configs/index.d.ts +13 -0
  9. package/source/loader/configs/index.js +17 -0
  10. package/source/loader/events/index.d.ts +6 -0
  11. package/source/loader/events/index.js +25 -0
  12. package/source/loader/index.d.ts +6 -0
  13. package/source/loader/index.js +6 -0
  14. package/source/loader/localizations/index.d.ts +14 -0
  15. package/source/loader/localizations/index.js +32 -0
  16. package/source/loader/logger/index.d.ts +22 -0
  17. package/source/loader/logger/index.js +130 -0
  18. package/source/loader/system/index.d.ts +8 -0
  19. package/source/loader/system/index.js +14 -0
  20. package/source/project/index.d.ts +7 -0
  21. package/source/project/index.js +94 -0
  22. package/source/utils/constants/index.d.ts +8 -0
  23. package/source/utils/constants/index.js +10 -0
  24. package/source/utils/helpers/date/index.d.ts +16 -0
  25. package/source/utils/helpers/date/index.js +48 -0
  26. package/source/utils/helpers/filters/index.d.ts +17 -0
  27. package/source/utils/helpers/filters/index.js +44 -0
  28. package/source/utils/helpers/hash/crypto.d.ts +3 -0
  29. package/source/utils/helpers/hash/crypto.js +22 -0
  30. package/source/utils/helpers/id/index.d.ts +13 -0
  31. package/source/utils/helpers/id/index.js +24 -0
  32. package/source/utils/helpers/index.d.ts +16 -0
  33. package/source/utils/helpers/index.js +16 -0
  34. package/source/utils/helpers/ip/index.d.ts +1 -0
  35. package/source/utils/helpers/ip/index.js +3 -0
  36. package/source/utils/helpers/is/index.d.ts +11 -0
  37. package/source/utils/helpers/is/index.js +35 -0
  38. package/source/utils/helpers/locales/index.d.ts +52 -0
  39. package/source/utils/helpers/locales/index.js +161 -0
  40. package/source/utils/helpers/locales copy/index.d.ts +52 -0
  41. package/source/utils/helpers/locales copy/index.js +161 -0
  42. package/source/utils/helpers/math/index.d.ts +2 -0
  43. package/source/utils/helpers/math/index.js +14 -0
  44. package/source/utils/helpers/objects/index.d.ts +1 -0
  45. package/source/utils/helpers/objects/index.js +55 -0
  46. package/source/utils/helpers/path/index.d.ts +2 -0
  47. package/source/utils/helpers/path/index.js +4 -0
  48. package/source/utils/helpers/regex/checkSpecialRegexControl.d.ts +1 -0
  49. package/source/utils/helpers/regex/checkSpecialRegexControl.js +3 -0
  50. package/source/utils/helpers/string/index.d.ts +1 -0
  51. package/source/utils/helpers/string/index.js +9 -0
  52. package/source/utils/helpers/timer/index.d.ts +3 -0
  53. package/source/utils/helpers/timer/index.js +5 -0
  54. package/source/utils/helpers/tmp/index.d.ts +8 -0
  55. package/source/utils/helpers/tmp/index.js +109 -0
  56. package/source/utils/helpers/validates/index.d.ts +5 -0
  57. package/source/utils/helpers/validates/index.js +20 -0
  58. package/source/utils/index.d.ts +3 -0
  59. package/source/utils/index.js +3 -0
  60. package/source/utils/models/classes/class.controller.d.ts +121 -0
  61. package/source/utils/models/classes/class.controller.js +421 -0
  62. package/source/utils/models/classes/class.response.d.ts +17 -0
  63. package/source/utils/models/classes/class.response.js +37 -0
  64. package/source/utils/models/classes/class.services.d.ts +129 -0
  65. package/source/utils/models/classes/class.services.js +344 -0
  66. package/source/utils/models/classes/class.tmp-file-loader.d.ts +11 -0
  67. package/source/utils/models/classes/class.tmp-file-loader.js +38 -0
  68. package/source/utils/models/classes/class.x.d.ts +12 -0
  69. package/source/utils/models/classes/class.x.js +16 -0
  70. package/source/utils/models/enums/index.d.ts +116 -0
  71. package/source/utils/models/enums/index.js +132 -0
  72. package/source/utils/models/index.d.ts +8 -0
  73. package/source/utils/models/index.js +8 -0
  74. package/source/utils/models/types/index.d.ts +3 -0
  75. package/source/utils/models/types/index.js +2 -0
  76. package/x/tmp.yml +26 -0
@@ -0,0 +1,129 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import nodemailer from 'nodemailer';
3
+ import { LoggerService } from '../../../loader/index';
4
+ export interface IAuth {
5
+ authentication: (params: any) => Promise<void> | any;
6
+ }
7
+ declare abstract class Service {
8
+ protected logger: LoggerService;
9
+ clientName: string;
10
+ protected baseURL: string;
11
+ protected version: string | null;
12
+ protected headers: any;
13
+ protected timeout: number;
14
+ /***************
15
+ * CONSTRUCTOR *
16
+ ***************/
17
+ protected constructor({ clientName, baseURL, version, timeout, headers, }: {
18
+ clientName: string;
19
+ baseURL: string;
20
+ version?: string;
21
+ timeout?: number;
22
+ headers?: {
23
+ 'Content-Type'?: string;
24
+ 'Lang'?: string;
25
+ 'Authorization'?: string;
26
+ };
27
+ });
28
+ /***********
29
+ * HELPERS *
30
+ ***********/
31
+ protected interceptorErrorComplement(error: any): void;
32
+ routeSlashChecker(route: string): string;
33
+ static cryptoHashGenerate: ({ algorithm, input, digest }: {
34
+ algorithm: string;
35
+ input: string;
36
+ digest?: string;
37
+ }) => string;
38
+ static cryptoHashDecrypt: ({ algorithm, input, keyEncoding, key, initializationVector, inputEncoding, outputEncoding, }: {
39
+ algorithm: string;
40
+ input: string;
41
+ keyEncoding?: string;
42
+ key: string;
43
+ initializationVector: string;
44
+ inputEncoding?: BufferEncoding;
45
+ outputEncoding?: BufferEncoding;
46
+ }) => string;
47
+ static objectToFormData: (object: any) => FormData;
48
+ static generateRandomNumber: ({ prefix, suffix, hyphen, length, totalLength }: {
49
+ prefix?: string;
50
+ suffix?: string;
51
+ hyphen?: boolean;
52
+ length?: number;
53
+ totalLength?: number | null;
54
+ }) => string;
55
+ }
56
+ export declare class ServiceStore {
57
+ private static _instance;
58
+ private _store;
59
+ private constructor();
60
+ static create(): ServiceStore;
61
+ set setStore(callback: (store: Record<any, any>) => any);
62
+ get instance(): Record<any, any> | null;
63
+ get store(): Record<any, any>;
64
+ }
65
+ export declare class EmailClient extends Service {
66
+ private _port;
67
+ private _username;
68
+ private _password;
69
+ constructor({ clientName, baseURL, version, port, username, password, }: {
70
+ clientName: string;
71
+ baseURL: string;
72
+ version?: string;
73
+ port?: number;
74
+ username: string;
75
+ password: string;
76
+ });
77
+ /***********
78
+ * LOADERS *
79
+ ***********/
80
+ nodemailerLoader({ host, port, username, password, secure, }: {
81
+ host?: string;
82
+ port?: number;
83
+ username?: string;
84
+ password?: string;
85
+ secure?: boolean;
86
+ }): nodemailer.Transporter<import("nodemailer/lib/smtp-transport").SentMessageInfo, import("nodemailer/lib/smtp-transport").Options>;
87
+ }
88
+ export declare class AxiosClient extends Service {
89
+ constructor({ clientName, baseURL, version }: {
90
+ clientName: string;
91
+ baseURL: string;
92
+ version?: string;
93
+ });
94
+ /***********
95
+ * LOADERS *
96
+ ***********/
97
+ protected axiosLoader(): AxiosInstance;
98
+ }
99
+ export declare class SoapClient extends Service {
100
+ private client;
101
+ constructor({ clientName, baseURL, version }: {
102
+ clientName: string;
103
+ baseURL: string;
104
+ version?: string;
105
+ });
106
+ getAsyncBaseClient(): Promise<{
107
+ [key: string]: any;
108
+ }>;
109
+ createAsyncClient({ fullURL }: {
110
+ fullURL: string;
111
+ }): Promise<{
112
+ [key: string]: any;
113
+ }>;
114
+ getAsyncMethod(methodName: string, pathname: string, args?: {
115
+ [key: string | number]: any;
116
+ }): Promise<{
117
+ [key: string]: any;
118
+ }>;
119
+ }
120
+ export declare class BaseApiClient extends AxiosClient implements IAuth {
121
+ constructor({ clientName, baseURL, version }: {
122
+ clientName: string;
123
+ baseURL: string;
124
+ version: string;
125
+ });
126
+ protected axiosLoaderAuthMiddleware(): AxiosInstance;
127
+ authentication: () => Promise<import("axios").AxiosResponse<any, any, {}>>;
128
+ }
129
+ export default Service;
@@ -0,0 +1,344 @@
1
+ import path from 'path';
2
+ import axios from 'axios';
3
+ import soap from 'soap';
4
+ // => special
5
+ import nodemailer from 'nodemailer';
6
+ import hbs from 'nodemailer-express-handlebars';
7
+ //
8
+ import { LoggerService } from '../../../loader/index';
9
+ import { x, LoggerLayerEnum, TokensEnum } from '../../index';
10
+ // => for cryptography
11
+ import crypto from 'crypto';
12
+ class Service {
13
+ logger = x.get(LoggerService);
14
+ //private _instance: Record<string, any> = {}
15
+ clientName;
16
+ baseURL;
17
+ version = null;
18
+ headers; /* unknow */
19
+ timeout = 10000;
20
+ /***************
21
+ * CONSTRUCTOR *
22
+ ***************/
23
+ constructor({ clientName, baseURL, version, timeout, headers, }) {
24
+ this.clientName = clientName;
25
+ this.baseURL = baseURL;
26
+ version && this.version;
27
+ if (timeout) {
28
+ this.timeout = timeout;
29
+ }
30
+ if (headers) {
31
+ this.headers = {
32
+ ...headers
33
+ };
34
+ }
35
+ }
36
+ /***********
37
+ * HELPERS *
38
+ ***********/
39
+ interceptorErrorComplement(error /* unknow */) {
40
+ if (error.response) {
41
+ this.logger.winston.info({
42
+ level: LoggerLayerEnum[LoggerLayerEnum.ERROR].toLowerCase(),
43
+ message: `${this.clientName} api service error: ${JSON.stringify(error.response)}`,
44
+ });
45
+ }
46
+ else {
47
+ this.logger.winston.info({
48
+ level: LoggerLayerEnum[LoggerLayerEnum.CRITICAL].toLowerCase(),
49
+ message: `${this.clientName} api service error: ${JSON.stringify(error.message)}`,
50
+ });
51
+ }
52
+ }
53
+ routeSlashChecker(route) {
54
+ const splash = route.split('/');
55
+ let withSplash;
56
+ if (splash[0] === '') {
57
+ withSplash = route.substring(1);
58
+ }
59
+ else {
60
+ withSplash = route;
61
+ }
62
+ return withSplash;
63
+ }
64
+ static cryptoHashGenerate = ({ algorithm, input, digest = 'string' }) => {
65
+ return crypto.createHash(algorithm).update(input).digest(digest);
66
+ };
67
+ static cryptoHashDecrypt = ({ algorithm, input, keyEncoding = 'hex', key, initializationVector, inputEncoding = 'base64', outputEncoding = 'utf8', }) => {
68
+ const decipher = crypto.createDecipheriv(algorithm, Buffer.from(key, keyEncoding), Buffer.from(initializationVector, inputEncoding));
69
+ let decrypted = decipher.update(input, inputEncoding, outputEncoding);
70
+ decrypted += decipher.final(outputEncoding);
71
+ return decrypted;
72
+ };
73
+ static objectToFormData = (object) => {
74
+ const formData = new FormData();
75
+ for (const [key, value] of Object.entries(object)) {
76
+ let changedValue = null;
77
+ changedValue = value;
78
+ if (Array.isArray(value)) {
79
+ changedValue = JSON.stringify(value);
80
+ }
81
+ formData.append(key, changedValue);
82
+ }
83
+ return formData;
84
+ };
85
+ static generateRandomNumber = ({ prefix, suffix, hyphen = true, length = 10, totalLength = null }) => {
86
+ if (!Number.isInteger(length) || length <= 0) {
87
+ throw new Error(`Invalid length.`);
88
+ }
89
+ if (totalLength) {
90
+ const prefixLength = prefix ? Number(prefix?.length) : null;
91
+ const suffixLength = suffix ? Number(suffix?.length) : null;
92
+ if (prefixLength && !Number.isInteger(prefixLength) || length <= 0 ||
93
+ suffixLength && !Number.isInteger(suffixLength) || length <= 0) {
94
+ throw new Error(`Invalid type.`);
95
+ }
96
+ if (prefixLength) {
97
+ totalLength -= prefixLength + 1;
98
+ }
99
+ if (suffixLength) {
100
+ totalLength -= suffixLength + 1;
101
+ }
102
+ length = totalLength;
103
+ }
104
+ let randomNumber = '';
105
+ for (let i = 0; i < length; i++) {
106
+ const randomDigit = Math.floor(Math.random() * 10);
107
+ randomNumber += randomDigit.toString();
108
+ }
109
+ return `${prefix && hyphen ? prefix + '-' : ''}${randomNumber}${suffix && hyphen ? '-' + suffix : ''}`;
110
+ };
111
+ }
112
+ export class ServiceStore {
113
+ static _instance = null;
114
+ _store = {};
115
+ constructor() { }
116
+ static create() {
117
+ if (!ServiceStore._instance) {
118
+ ServiceStore._instance = new ServiceStore();
119
+ }
120
+ return ServiceStore._instance;
121
+ }
122
+ set setStore(callback) {
123
+ const returnCallback = callback(this._store);
124
+ this._store = {
125
+ ...this._store,
126
+ ...returnCallback
127
+ };
128
+ }
129
+ get instance() {
130
+ return ServiceStore._instance;
131
+ }
132
+ get store() {
133
+ return this._store;
134
+ }
135
+ }
136
+ export class EmailClient extends Service {
137
+ _port = null;
138
+ _username = null;
139
+ _password = null;
140
+ constructor({ clientName, baseURL, version, port, username, password, }) {
141
+ super({ clientName, baseURL, version });
142
+ this._username = username;
143
+ this._password = password;
144
+ }
145
+ /***********
146
+ * LOADERS *
147
+ ***********/
148
+ nodemailerLoader({ host, port, username, password, secure = true, }) {
149
+ const transporter = nodemailer.createTransport({
150
+ //@ts-ignore
151
+ host: host ? host : this.baseURL,
152
+ port: port ? port : this._port,
153
+ secure,
154
+ auth: {
155
+ user: username ? username : this._username,
156
+ pass: password ? password : this._password,
157
+ },
158
+ });
159
+ transporter.use('compile', hbs({
160
+ viewEngine: {
161
+ extname: '.hbs',
162
+ layoutsDir: path.resolve('source', 'static', 'email'),
163
+ defaultLayout: 'index',
164
+ partialsDir: path.resolve('source', 'static', 'email'),
165
+ },
166
+ viewPath: path.resolve('source', 'static', 'email', 'templates'),
167
+ extName: '.hbs'
168
+ }));
169
+ return transporter;
170
+ }
171
+ }
172
+ export class AxiosClient extends Service {
173
+ constructor({ clientName, baseURL, version }) {
174
+ super({ clientName, baseURL, version });
175
+ }
176
+ /***********
177
+ * LOADERS *
178
+ ***********/
179
+ axiosLoader() {
180
+ const axiosInstance = axios.create({
181
+ baseURL: this.baseURL,
182
+ timeout: this.timeout,
183
+ headers: {
184
+ ...this.headers
185
+ },
186
+ });
187
+ axiosInstance.interceptors.request.use((config /* unknow */) => {
188
+ return config;
189
+ }, (error) => {
190
+ this.logger.winston.info({
191
+ level: LoggerLayerEnum[LoggerLayerEnum.CRITICAL].toLowerCase(),
192
+ message: `${this.clientName} api service error: ${JSON.stringify(error)}`,
193
+ });
194
+ return Promise.reject(error);
195
+ });
196
+ return axiosInstance;
197
+ }
198
+ }
199
+ export class SoapClient extends Service {
200
+ client;
201
+ constructor({ clientName, baseURL, version }) {
202
+ super({ clientName, baseURL, version });
203
+ }
204
+ async getAsyncBaseClient() {
205
+ try {
206
+ this.client = await soap.createClientAsync(this.baseURL);
207
+ return this.client;
208
+ }
209
+ catch (exception) {
210
+ this.logger.winston.error({
211
+ level: LoggerLayerEnum[LoggerLayerEnum.ERROR].toLowerCase(),
212
+ message: `${this.clientName} - soap client error: ${exception}`,
213
+ });
214
+ return null;
215
+ }
216
+ }
217
+ async createAsyncClient({ fullURL }) {
218
+ try {
219
+ this.client = await soap.createClientAsync(fullURL);
220
+ //console.log(this.client)
221
+ return this.client;
222
+ }
223
+ catch (exception) {
224
+ this.logger.winston.error({
225
+ level: LoggerLayerEnum[LoggerLayerEnum.ERROR].toLowerCase(),
226
+ message: `${this.clientName} - soap client error: ${exception}`,
227
+ });
228
+ return null;
229
+ }
230
+ }
231
+ async getAsyncMethod(methodName, pathname, args) {
232
+ let client = null;
233
+ let result = null;
234
+ if (pathname) {
235
+ client = await this.createAsyncClient({ fullURL: `${this.baseURL}${pathname}` });
236
+ }
237
+ else {
238
+ client = await this.getAsyncBaseClient();
239
+ }
240
+ //console.log('client: ', client)
241
+ if (client) {
242
+ try {
243
+ let data = await client[`${methodName}Async`](args);
244
+ result = data[0];
245
+ }
246
+ catch (exception) {
247
+ this.logger.winston.error({
248
+ level: LoggerLayerEnum[LoggerLayerEnum.ERROR].toLowerCase(),
249
+ message: `${this.clientName} - soap client method error: ${exception}`,
250
+ });
251
+ return null;
252
+ }
253
+ }
254
+ else {
255
+ return null;
256
+ }
257
+ return result;
258
+ }
259
+ }
260
+ export class BaseApiClient extends AxiosClient {
261
+ constructor({ clientName, baseURL, version }) {
262
+ super({
263
+ clientName,
264
+ baseURL,
265
+ version
266
+ });
267
+ }
268
+ axiosLoaderAuthMiddleware() {
269
+ const axiosInstance = this.axiosLoader();
270
+ let _retry = false;
271
+ axiosInstance.interceptors.request.use((config) => {
272
+ const accessToken = (ServiceStore.create()).store?.[this.clientName]?.accessToken;
273
+ if (accessToken) {
274
+ config.headers['Cookie'] = `${TokensEnum.ACCESS_TOKEN}:${accessToken}`;
275
+ }
276
+ return config;
277
+ }, (error) => {
278
+ return Promise.reject(error);
279
+ });
280
+ axiosInstance.interceptors.response.use(async (response) => {
281
+ const originalRequest = response.config;
282
+ if (!_retry && response.data?.success === false && response.data?.status_code === 101) {
283
+ this.logger.winston.info({
284
+ level: LoggerLayerEnum[LoggerLayerEnum.INFO].toLowerCase(),
285
+ message: `${this.clientName} client - token refreshed!`,
286
+ });
287
+ try {
288
+ await this.authentication();
289
+ _retry = true;
290
+ originalRequest.headers['Cookie'] = `${TokensEnum.ACCESS_TOKEN}:${(ServiceStore.create()).store?.[this.clientName]?.accessToken}`;
291
+ //console.log(originalConfig)
292
+ return axiosInstance(originalRequest);
293
+ }
294
+ catch (error) {
295
+ this.logger.winston.info({
296
+ level: LoggerLayerEnum[LoggerLayerEnum.INFO].toLowerCase(),
297
+ message: `${this.clientName} client - token refresh request not initial!`,
298
+ });
299
+ return Promise.reject(error);
300
+ }
301
+ }
302
+ return response;
303
+ }, async (error) => {
304
+ const originalConfig = error.config;
305
+ if (error.response.status === 401 && !originalConfig._retry) {
306
+ this.logger.winston.info({
307
+ level: LoggerLayerEnum[LoggerLayerEnum.INFO].toLowerCase(),
308
+ message: `${this.clientName} client - token refreshed!`,
309
+ });
310
+ originalConfig._retry = true;
311
+ try {
312
+ await this.authentication();
313
+ const accessToken = (ServiceStore.create()).store?.[this.clientName]?.accessToken;
314
+ originalConfig.headers['Cookie'] = `${TokensEnum.ACCESS_TOKEN}:${accessToken}`;
315
+ //console.log(originalConfig)
316
+ return axiosInstance(originalConfig);
317
+ }
318
+ catch (error) {
319
+ this.logger.winston.info({
320
+ level: LoggerLayerEnum[LoggerLayerEnum.INFO].toLowerCase(),
321
+ message: `${this.clientName} client - token refresh request not initial!`,
322
+ });
323
+ return Promise.reject(error);
324
+ }
325
+ }
326
+ return Promise.reject(error);
327
+ });
328
+ return axiosInstance;
329
+ }
330
+ authentication = async () => {
331
+ const response = await this.axiosLoader().post(`/${this.version}/auth/sign-in`, {});
332
+ if (response.data.success !== true) {
333
+ throw new Error('Authorization not implemented');
334
+ }
335
+ const servicesStore = ServiceStore.create();
336
+ servicesStore.setStore = ((prevState => ({
337
+ [this.clientName]: {
338
+ accessToken: response.data?.payload?.data?.token
339
+ }
340
+ })));
341
+ return response;
342
+ };
343
+ }
344
+ export default Service;
@@ -0,0 +1,11 @@
1
+ import EventEmitter from "events";
2
+ export declare class TmpFileLoader extends EventEmitter {
3
+ protected tmpFileJson: Record<string, any>;
4
+ private filePath;
5
+ constructor({ filePath }: {
6
+ filePath: string;
7
+ });
8
+ private load;
9
+ private watch;
10
+ getResolvedTmpFile(): Record<string, any>;
11
+ }
@@ -0,0 +1,38 @@
1
+ import EventEmitter from "events";
2
+ import path from "path";
3
+ import fs from "fs";
4
+ import yaml from 'yaml';
5
+ import { resolveObjWithHandlebars } from "../../helpers";
6
+ export class TmpFileLoader extends EventEmitter {
7
+ tmpFileJson = {};
8
+ filePath;
9
+ constructor({ filePath }) {
10
+ super();
11
+ this.filePath = path.resolve(filePath);
12
+ this.load();
13
+ this.watch();
14
+ }
15
+ load() {
16
+ try {
17
+ const bufferFile = fs.readFileSync(this.filePath);
18
+ const parsedYaml = yaml.parse(bufferFile.toString());
19
+ this.tmpFileJson = parsedYaml;
20
+ this.emit("reload", parsedYaml);
21
+ }
22
+ catch (err) {
23
+ console.error("Error:", err);
24
+ }
25
+ }
26
+ watch() {
27
+ fs.watchFile(this.filePath, () => {
28
+ this.load();
29
+ });
30
+ }
31
+ getResolvedTmpFile() {
32
+ if (this.tmpFileJson)
33
+ return resolveObjWithHandlebars(this.tmpFileJson, this.tmpFileJson);
34
+ this.load();
35
+ resolveObjWithHandlebars(this.tmpFileJson, this.tmpFileJson);
36
+ return this.tmpFileJson;
37
+ }
38
+ }
@@ -0,0 +1,12 @@
1
+ export declare class X {
2
+ private _context;
3
+ constructor({}: {});
4
+ set: <T extends new (...args: any[]) => any>({ service, reference, args }: {
5
+ service: T;
6
+ reference: T;
7
+ args?: ConstructorParameters<T>;
8
+ }) => void;
9
+ get: <T>(service: new (...args: any) => T) => T;
10
+ }
11
+ declare const _default: X;
12
+ export default _default;
@@ -0,0 +1,16 @@
1
+ // => // X Service Locator
2
+ export class X {
3
+ _context = new Map();
4
+ constructor({}) {
5
+ }
6
+ set = ({ service, reference, args }) => {
7
+ this._context.set(service, new reference(...(args || [])));
8
+ };
9
+ get = (service) => {
10
+ if (!this._context.has(service)) {
11
+ throw new Error(`${service} not found in context.`);
12
+ }
13
+ return this._context.get(service);
14
+ };
15
+ }
16
+ export default new X({});
@@ -0,0 +1,116 @@
1
+ export declare enum NodeEnvEnum {
2
+ DEV = "dev",
3
+ TEST = "test",
4
+ PROD = "prod"
5
+ }
6
+ export declare enum ProtocolEnum {
7
+ HTTP = "http",
8
+ HTTPS = "https",
9
+ WEBSOCKET = "ws",
10
+ SOCKETIO = "ws",
11
+ NONE = "none"
12
+ }
13
+ export declare enum PolarityTypeEnum {
14
+ NOTR = 0,
15
+ POSITIVE = 1,
16
+ NEGATIVE = -1
17
+ }
18
+ export declare enum LoggerLayerEnum {
19
+ CRITICAL = 0,
20
+ ERROR = 1,
21
+ INFO = 2,
22
+ DEBUG = 3
23
+ }
24
+ export declare enum CountryCodeEnum {
25
+ EN = "en",
26
+ TR = "tr"
27
+ }
28
+ export declare enum CurrencyCodeEnum {
29
+ USD = "usd",
30
+ EUR = "eur",
31
+ TRY = "try"
32
+ }
33
+ export declare enum HttpMethodEnum {
34
+ POST = "post",
35
+ GET = "get",
36
+ PUT = "put",
37
+ DELETE = "delete"
38
+ }
39
+ export declare enum ContentTypeEnum {
40
+ applicationJson = "application/json",
41
+ applicationXWwwFormUrlencoded = "application/x-www-form-urlencoded"
42
+ }
43
+ export declare enum DevicePlatformEnum {
44
+ WEB = "web",
45
+ NATIVE = "native",
46
+ OTHER = "other"
47
+ }
48
+ export declare enum DeviceOSEnum {
49
+ ANDROID = "android",
50
+ IOS = "ios",
51
+ WINDOWS = "windows",
52
+ MACOS = "macos",
53
+ MACOSX = "macosx",
54
+ OTHER = "other"
55
+ }
56
+ export declare enum PriorityEnum {
57
+ HIGH = 0,
58
+ MEDIUM = 1,
59
+ LOW = 2
60
+ }
61
+ export declare enum PrivacyEnum {
62
+ PRIVATE = 0,
63
+ PUBLIC = 1,
64
+ ONLY_FRIENDS = 2
65
+ }
66
+ export declare enum TimezoneEnum {
67
+ UTC = "UTC",
68
+ EtcUTC = "Etc/UTC",
69
+ EtcGMT = "Etc/GMT"
70
+ }
71
+ export declare enum TokensEnum {
72
+ CSRF_TOKEN = "csrf_token",
73
+ ACCESS_TOKEN = "access_token",
74
+ REFRESH_TOKEN = "refresh_token",
75
+ REFERENCE_TOKEN = "reference_token",
76
+ PERSONAL_ACCESS_TOKEN = "personal_access_token"
77
+ }
78
+ export declare enum EndpointResourceEnum {
79
+ EXAMPLE = "example",
80
+ FULL = "full",
81
+ SYSTEM = "system",
82
+ CLIENTS = "clients",
83
+ AUTH = "auth",
84
+ ACCOUNTS = "accounts",
85
+ USERS = "users",
86
+ TRANSACTIONS = "transactions",
87
+ NOTIFICATIONS = "notifications",
88
+ ADDRESSES = "addresses",
89
+ PAYMENTS = "payments",
90
+ COMMISSIONS_AND_TAXES = "commissions-and-taxes",
91
+ SUPPORTS = "supports",
92
+ INVOICES = "invoices",
93
+ FILES = "files",
94
+ TOKENS = "tokens",
95
+ WEBHOOKS = "webhooks",
96
+ OTHERS = "others"
97
+ }
98
+ export declare enum SupportFileExtensionsEnum {
99
+ 'HTML' = "html",
100
+ 'EJS' = "ejs",
101
+ 'HBS' = "hbs",
102
+ "TS" = "",
103
+ "JS" = ".js",
104
+ "TSX" = "x",
105
+ "JSX" = ".jsx",
106
+ "TTF" = ".ttf",
107
+ "EOT" = ".eot",
108
+ "OTF" = ".otf",
109
+ "SVG" = ".svg",
110
+ "PNG" = ".png",
111
+ "WOFF" = ".woff",
112
+ "WOFF2" = ".woff2",
113
+ "CSS" = ".css",
114
+ "SCSS" = ".scss",
115
+ "SASS" = ".sass"
116
+ }