@creator.co/wapi 1.2.4 → 1.2.6
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/.github/workflows/npmpublish.yml +1 -1
- package/README.md +216 -5
- package/dist/index.d.ts +15 -0
- package/dist/index.js.map +1 -1
- package/dist/jest.config.js +1 -1
- package/dist/jest.config.js.map +1 -1
- package/dist/package.json +13 -2
- package/dist/src/API/Request.d.ts +45 -82
- package/dist/src/API/Request.js +49 -77
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/API/Response.d.ts +94 -163
- package/dist/src/API/Response.js +101 -161
- package/dist/src/API/Response.js.map +1 -1
- package/dist/src/API/Utils.d.ts +21 -42
- package/dist/src/API/Utils.js +22 -43
- package/dist/src/API/Utils.js.map +1 -1
- package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
- package/dist/src/BaseEvent/EventProcessor.js +30 -38
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
- package/dist/src/BaseEvent/Process.d.ts +20 -43
- package/dist/src/BaseEvent/Process.js +16 -27
- package/dist/src/BaseEvent/Process.js.map +1 -1
- package/dist/src/BaseEvent/Transaction.d.ts +104 -2
- package/dist/src/BaseEvent/Transaction.js +196 -41
- package/dist/src/BaseEvent/Transaction.js.map +1 -1
- package/dist/src/Config/Configuration.d.ts +48 -66
- package/dist/src/Config/Configuration.js +25 -42
- package/dist/src/Config/Configuration.js.map +1 -1
- package/dist/src/Config/EnvironmentVar.d.ts +30 -57
- package/dist/src/Config/EnvironmentVar.js +28 -41
- package/dist/src/Config/EnvironmentVar.js.map +1 -1
- package/dist/src/Crypto/Crypto.d.ts +17 -35
- package/dist/src/Crypto/Crypto.js +12 -21
- package/dist/src/Crypto/Crypto.js.map +1 -1
- package/dist/src/Crypto/JWT.d.ts +21 -32
- package/dist/src/Crypto/JWT.js +14 -22
- package/dist/src/Crypto/JWT.js.map +1 -1
- package/dist/src/Database/Database.d.ts +18 -0
- package/dist/src/Database/Database.js +18 -0
- package/dist/src/Database/Database.js.map +1 -0
- package/dist/src/Database/DatabaseManager.d.ts +32 -0
- package/dist/src/Database/DatabaseManager.js +50 -0
- package/dist/src/Database/DatabaseManager.js.map +1 -0
- package/dist/src/Database/DatabaseTransaction.d.ts +65 -0
- package/dist/src/Database/DatabaseTransaction.js +183 -0
- package/dist/src/Database/DatabaseTransaction.js.map +1 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +22 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.js +108 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -0
- package/dist/src/Database/integrations/knex/KnexTransaction.d.ts +37 -0
- package/dist/src/Database/integrations/knex/KnexTransaction.js +60 -0
- package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +30 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +108 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +37 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +60 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -0
- package/dist/src/Globals.d.ts +26 -94
- package/dist/src/Globals.js +26 -95
- package/dist/src/Globals.js.map +1 -1
- package/dist/src/Logger/Logger.d.ts +82 -105
- package/dist/src/Logger/Logger.js +111 -136
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Mailer/Mailer.d.ts +39 -75
- package/dist/src/Mailer/Mailer.js +36 -65
- package/dist/src/Mailer/Mailer.js.map +1 -1
- package/dist/src/Publisher/Publisher.d.ts +17 -25
- package/dist/src/Publisher/Publisher.js +21 -32
- package/dist/src/Publisher/Publisher.js.map +1 -1
- package/dist/src/Server/RouteResolver.d.ts +14 -22
- package/dist/src/Server/RouteResolver.js +21 -34
- package/dist/src/Server/RouteResolver.js.map +1 -1
- package/dist/src/Server/Router.d.ts +72 -51
- package/dist/src/Server/Router.js +8 -17
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
- package/dist/src/Server/lib/ContainerServer.js +13 -28
- package/dist/src/Server/lib/ContainerServer.js.map +1 -1
- package/dist/src/Server/lib/Server.d.ts +17 -32
- package/dist/src/Server/lib/Server.js +18 -28
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
- package/dist/src/Server/lib/container/GenericHandler.js +16 -3
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
- package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
- package/dist/src/Server/lib/container/HealthHandler.js +6 -0
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
- package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
- package/dist/src/Server/lib/container/Proxy.js +52 -52
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/dist/src/Server/lib/container/Utils.d.ts +6 -10
- package/dist/src/Server/lib/container/Utils.js +6 -10
- package/dist/src/Server/lib/container/Utils.js.map +1 -1
- package/dist/src/Validation/Validator.d.ts +9 -13
- package/dist/src/Validation/Validator.js +8 -12
- package/dist/src/Validation/Validator.js.map +1 -1
- package/index.ts +15 -0
- package/jest.config.ts +1 -1
- package/package.json +13 -2
- package/src/API/Request.ts +66 -84
- package/src/API/Response.ts +144 -203
- package/src/API/Utils.ts +28 -44
- package/src/BaseEvent/EventProcessor.ts +52 -77
- package/src/BaseEvent/Process.ts +27 -52
- package/src/BaseEvent/Transaction.ts +147 -27
- package/src/Config/Configuration.ts +59 -76
- package/src/Config/EnvironmentVar.ts +39 -62
- package/src/Crypto/Crypto.ts +20 -36
- package/src/Crypto/JWT.ts +31 -35
- package/src/Database/Database.ts +19 -0
- package/src/Database/DatabaseManager.ts +51 -0
- package/src/Database/DatabaseTransaction.ts +118 -0
- package/src/Database/integrations/knex/KnexDatabase.ts +47 -0
- package/src/Database/integrations/knex/KnexTransaction.ts +51 -0
- package/src/Database/integrations/pgsql/PostgresDatabase.ts +49 -0
- package/src/Database/integrations/pgsql/PostgresTransaction.ts +54 -0
- package/src/Database/types.d.ts +49 -0
- package/src/Globals.ts +28 -96
- package/src/Logger/Logger.ts +141 -160
- package/src/Mailer/Mailer.ts +43 -76
- package/src/Publisher/Publisher.ts +31 -40
- package/src/Server/RouteResolver.ts +31 -52
- package/src/Server/Router.ts +75 -54
- package/src/Server/lib/ContainerServer.ts +20 -32
- package/src/Server/lib/Server.ts +19 -34
- package/src/Server/lib/container/GenericHandler.ts +17 -3
- package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
- package/src/Server/lib/container/HealthHandler.ts +6 -0
- package/src/Server/lib/container/Proxy.ts +39 -58
- package/src/Server/lib/container/Utils.ts +7 -10
- package/src/Validation/Validator.ts +11 -13
- package/tests/API/Response.test.ts +55 -56
- package/tests/BaseEvent/EventProcessor.test.ts +49 -50
- package/tests/BaseEvent/Process.test.ts +2 -2
- package/tests/BaseEvent/Transaction.test.ts +102 -44
- package/tests/Config/Config.test.ts +27 -27
- package/tests/Config/EnvironmentVar.test.ts +54 -18
- package/tests/Database/DatabaseManager.test.ts +55 -0
- package/tests/Database/integrations/knex/KnexDatabase.test.ts +53 -0
- package/tests/Database/integrations/knex/KnexTransaction.test.ts +133 -0
- package/tests/Database/integrations/pg/PostgresDatabase.test.ts +50 -0
- package/tests/Database/integrations/pg/PostgresTransaction.test.ts +51 -0
- package/tests/Publisher/Publisher.test.ts +3 -3
- package/tests/Server/lib/ContainerServer.test.ts +21 -22
- package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
- package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
- package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
- package/tests/Server/lib/container/Proxy.test.ts +37 -35
- package/tsconfig.json +6 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
2
|
+
* Enumeration of log levels.
|
|
3
|
+
* @enum {string}
|
|
4
|
+
* @property {string} DEBUG - Debug log level.
|
|
5
|
+
* @property {string} INFO - Info log level.
|
|
6
|
+
* @property {string} WARN - Warning log level.
|
|
7
|
+
* @property {string} ERROR - Error log level.
|
|
6
8
|
*/
|
|
7
9
|
export declare enum LOG_LEVELS {
|
|
8
10
|
DEBUG = "DEBUG",
|
|
@@ -11,170 +13,145 @@ export declare enum LOG_LEVELS {
|
|
|
11
13
|
ERROR = "ERROR"
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
16
|
+
* Configuration options for the logger.
|
|
17
|
+
* @typedef {Object} LoggerConfig
|
|
18
|
+
* @property {boolean | Array<string>} [sensitiveFilteringKeywords] - Specifies whether to filter sensitive keywords in log messages. Can be a boolean value or an array of strings.
|
|
19
|
+
* @property {LOG_LEVELS | string} [logLevel] - The log level to use for logging. Can be one of the predefined log levels or a custom string value.
|
|
18
20
|
*/
|
|
19
21
|
export type LoggerConfig = {
|
|
20
22
|
sensitiveFilteringKeywords?: boolean | Array<string>;
|
|
21
23
|
logLevel?: LOG_LEVELS | string;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @export
|
|
27
|
-
* @class Logger
|
|
28
|
-
* @typedef {Logger}
|
|
26
|
+
* Logger class for logging messages with different log levels.
|
|
29
27
|
*/
|
|
30
28
|
export default class Logger {
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @private
|
|
35
|
-
* @type {?LoggerConfig}
|
|
30
|
+
* The optional configuration object for the logger.
|
|
36
31
|
*/
|
|
37
|
-
private
|
|
32
|
+
private config?;
|
|
38
33
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @private
|
|
34
|
+
* Private property representing the transaction ID.
|
|
42
35
|
* @type {string}
|
|
36
|
+
* @private
|
|
43
37
|
*/
|
|
44
|
-
private
|
|
38
|
+
private transactionID;
|
|
45
39
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @private
|
|
49
|
-
* @type {(Array<string> | false)}
|
|
40
|
+
* An array of strings representing a blacklist of filters, or false if no blacklist is set.
|
|
50
41
|
*/
|
|
51
|
-
private
|
|
42
|
+
private filterBlacklist;
|
|
52
43
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
44
|
+
* The current log level for the application.
|
|
55
45
|
* @private
|
|
56
46
|
* @type {LOG_LEVELS}
|
|
57
47
|
*/
|
|
58
48
|
private _LOG_LEVEL;
|
|
59
49
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
50
|
+
* The origin of the object.
|
|
62
51
|
* @private
|
|
63
|
-
* @type {
|
|
52
|
+
* @type {any}
|
|
64
53
|
*/
|
|
65
54
|
private origin;
|
|
66
55
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
* @
|
|
71
|
-
* @param {string} transactionID
|
|
56
|
+
* Constructs a Logger object with the given configuration and transaction ID.
|
|
57
|
+
* @param {config} config - The configuration object for the logger. Can be undefined.
|
|
58
|
+
* @param {string} transactionID - The ID of the transaction associated with the logger.
|
|
59
|
+
* @returns None
|
|
72
60
|
*/
|
|
73
|
-
constructor(
|
|
61
|
+
constructor(config: LoggerConfig | undefined, transactionID: string);
|
|
74
62
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @public
|
|
78
|
-
* @returns {boolean}
|
|
63
|
+
* Returns a boolean value indicating whether the notGlobalLogger function is executed successfully.
|
|
64
|
+
* @returns {boolean} - true if the function is executed successfully, false otherwise.
|
|
79
65
|
*/
|
|
80
66
|
notGlobalLogger(): boolean;
|
|
81
67
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
68
|
+
* Logs the given arguments with the debug log level.
|
|
69
|
+
* @param {...any} args - The arguments to be logged.
|
|
70
|
+
* @returns None
|
|
85
71
|
*/
|
|
86
72
|
debug(...args: any[]): void;
|
|
87
73
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
74
|
+
* Logs the given arguments with the INFO log level.
|
|
75
|
+
* @param {...any} args - The arguments to be logged.
|
|
76
|
+
* @returns None
|
|
91
77
|
*/
|
|
92
78
|
log(...args: any[]): void;
|
|
93
79
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
80
|
+
* Logs an informational message.
|
|
81
|
+
* @param {...any} args - The message(s) to log.
|
|
82
|
+
* @returns None
|
|
97
83
|
*/
|
|
98
84
|
info(...args: any[]): void;
|
|
99
85
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @
|
|
86
|
+
* Logs a warning message with the provided arguments.
|
|
87
|
+
* @param {...any} args - The arguments to be logged as a warning message.
|
|
88
|
+
* @returns None
|
|
103
89
|
*/
|
|
104
90
|
warning(...args: any[]): void;
|
|
105
91
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @
|
|
92
|
+
* Logs a warning message to the console.
|
|
93
|
+
* @param {...any} args - The arguments to be logged.
|
|
94
|
+
* @returns None
|
|
109
95
|
*/
|
|
110
96
|
warn(...args: any[]): void;
|
|
111
97
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @
|
|
98
|
+
* Logs an error message with the given arguments.
|
|
99
|
+
* @param {...any} args - The arguments to log as an error message.
|
|
100
|
+
* @returns None
|
|
115
101
|
*/
|
|
116
102
|
error(...args: any[]): void;
|
|
117
103
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* @param {
|
|
121
|
-
* @
|
|
104
|
+
* Logs an exception with optional additional arguments.
|
|
105
|
+
* @param {any} exception - The exception to log.
|
|
106
|
+
* @param {...any} args - Additional arguments to include in the log.
|
|
107
|
+
* @returns None
|
|
122
108
|
*/
|
|
123
109
|
exception(exception: any, ...args: any[]): void;
|
|
124
110
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
111
|
+
* Sets up the console bindings for logging purposes.
|
|
127
112
|
* @private
|
|
113
|
+
* @returns None
|
|
128
114
|
*/
|
|
129
|
-
private
|
|
115
|
+
private setupBindings;
|
|
130
116
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* @
|
|
134
|
-
* @param {
|
|
135
|
-
* @
|
|
136
|
-
* @param {string} caller
|
|
137
|
-
* @returns {string}
|
|
117
|
+
* Formats a log message with the specified log level, message, and caller.
|
|
118
|
+
* @param {LOG_LEVELS} level - The log level of the message.
|
|
119
|
+
* @param {Array<string>} msg - An array of strings representing the message.
|
|
120
|
+
* @param {string} caller - The name of the caller function.
|
|
121
|
+
* @returns {string} - The formatted log message.
|
|
138
122
|
*/
|
|
139
|
-
private
|
|
123
|
+
private formattedLog;
|
|
140
124
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* @
|
|
144
|
-
* @param {number} index
|
|
145
|
-
* @returns {string}
|
|
125
|
+
* Returns the name of the caller at the specified index in the call stack.
|
|
126
|
+
* @param {number} index - The index of the caller in the call stack.
|
|
127
|
+
* @returns {string} The name of the caller, including the file name and line number.
|
|
146
128
|
*/
|
|
147
|
-
private
|
|
129
|
+
private callerName;
|
|
148
130
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @
|
|
152
|
-
* @
|
|
153
|
-
* @param {*} args
|
|
131
|
+
* Processes a log message based on the specified log level and arguments.
|
|
132
|
+
* @param {LOG_LEVELS} level - The log level of the message.
|
|
133
|
+
* @param {any[]} args - The arguments to be logged.
|
|
134
|
+
* @returns None
|
|
154
135
|
*/
|
|
155
|
-
private
|
|
136
|
+
private processLog;
|
|
156
137
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* @
|
|
160
|
-
* @
|
|
161
|
-
* @param {...{}\} args
|
|
138
|
+
* Logs an exception along with additional arguments and the stack trace.
|
|
139
|
+
* @param {Error} exception - The exception object to log.
|
|
140
|
+
* @param {...any} args - Additional arguments to include in the log.
|
|
141
|
+
* @returns None
|
|
162
142
|
*/
|
|
163
|
-
private
|
|
143
|
+
private iexception;
|
|
164
144
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
168
|
-
* @
|
|
169
|
-
* @param {string} fMsg
|
|
145
|
+
* Pushes a log message to the console with the specified log level.
|
|
146
|
+
* @param {LOG_LEVELS} level - The log level of the message.
|
|
147
|
+
* @param {string} fMsg - The formatted log message.
|
|
148
|
+
* @returns None
|
|
170
149
|
*/
|
|
171
|
-
private
|
|
150
|
+
private pushLog;
|
|
172
151
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
* @param {*} value
|
|
177
|
-
* @returns {string}
|
|
152
|
+
* Suppresses sensitive information in the given value based on the filter blacklist.
|
|
153
|
+
* @param {any} value - The value to suppress sensitive information from.
|
|
154
|
+
* @returns {string} - The value with sensitive information suppressed.
|
|
178
155
|
*/
|
|
179
|
-
private
|
|
156
|
+
private suppressSensitiveInfo;
|
|
180
157
|
}
|