@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.
Files changed (153) hide show
  1. package/.github/workflows/npmpublish.yml +1 -1
  2. package/README.md +216 -5
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/jest.config.js +1 -1
  6. package/dist/jest.config.js.map +1 -1
  7. package/dist/package.json +13 -2
  8. package/dist/src/API/Request.d.ts +45 -82
  9. package/dist/src/API/Request.js +49 -77
  10. package/dist/src/API/Request.js.map +1 -1
  11. package/dist/src/API/Response.d.ts +94 -163
  12. package/dist/src/API/Response.js +101 -161
  13. package/dist/src/API/Response.js.map +1 -1
  14. package/dist/src/API/Utils.d.ts +21 -42
  15. package/dist/src/API/Utils.js +22 -43
  16. package/dist/src/API/Utils.js.map +1 -1
  17. package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
  18. package/dist/src/BaseEvent/EventProcessor.js +30 -38
  19. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  20. package/dist/src/BaseEvent/Process.d.ts +20 -43
  21. package/dist/src/BaseEvent/Process.js +16 -27
  22. package/dist/src/BaseEvent/Process.js.map +1 -1
  23. package/dist/src/BaseEvent/Transaction.d.ts +104 -2
  24. package/dist/src/BaseEvent/Transaction.js +196 -41
  25. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  26. package/dist/src/Config/Configuration.d.ts +48 -66
  27. package/dist/src/Config/Configuration.js +25 -42
  28. package/dist/src/Config/Configuration.js.map +1 -1
  29. package/dist/src/Config/EnvironmentVar.d.ts +30 -57
  30. package/dist/src/Config/EnvironmentVar.js +28 -41
  31. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  32. package/dist/src/Crypto/Crypto.d.ts +17 -35
  33. package/dist/src/Crypto/Crypto.js +12 -21
  34. package/dist/src/Crypto/Crypto.js.map +1 -1
  35. package/dist/src/Crypto/JWT.d.ts +21 -32
  36. package/dist/src/Crypto/JWT.js +14 -22
  37. package/dist/src/Crypto/JWT.js.map +1 -1
  38. package/dist/src/Database/Database.d.ts +18 -0
  39. package/dist/src/Database/Database.js +18 -0
  40. package/dist/src/Database/Database.js.map +1 -0
  41. package/dist/src/Database/DatabaseManager.d.ts +32 -0
  42. package/dist/src/Database/DatabaseManager.js +50 -0
  43. package/dist/src/Database/DatabaseManager.js.map +1 -0
  44. package/dist/src/Database/DatabaseTransaction.d.ts +65 -0
  45. package/dist/src/Database/DatabaseTransaction.js +183 -0
  46. package/dist/src/Database/DatabaseTransaction.js.map +1 -0
  47. package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +22 -0
  48. package/dist/src/Database/integrations/knex/KnexDatabase.js +108 -0
  49. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -0
  50. package/dist/src/Database/integrations/knex/KnexTransaction.d.ts +37 -0
  51. package/dist/src/Database/integrations/knex/KnexTransaction.js +60 -0
  52. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -0
  53. package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +30 -0
  54. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +108 -0
  55. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -0
  56. package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +37 -0
  57. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +60 -0
  58. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -0
  59. package/dist/src/Globals.d.ts +26 -94
  60. package/dist/src/Globals.js +26 -95
  61. package/dist/src/Globals.js.map +1 -1
  62. package/dist/src/Logger/Logger.d.ts +82 -105
  63. package/dist/src/Logger/Logger.js +111 -136
  64. package/dist/src/Logger/Logger.js.map +1 -1
  65. package/dist/src/Mailer/Mailer.d.ts +39 -75
  66. package/dist/src/Mailer/Mailer.js +36 -65
  67. package/dist/src/Mailer/Mailer.js.map +1 -1
  68. package/dist/src/Publisher/Publisher.d.ts +17 -25
  69. package/dist/src/Publisher/Publisher.js +21 -32
  70. package/dist/src/Publisher/Publisher.js.map +1 -1
  71. package/dist/src/Server/RouteResolver.d.ts +14 -22
  72. package/dist/src/Server/RouteResolver.js +21 -34
  73. package/dist/src/Server/RouteResolver.js.map +1 -1
  74. package/dist/src/Server/Router.d.ts +72 -51
  75. package/dist/src/Server/Router.js +8 -17
  76. package/dist/src/Server/Router.js.map +1 -1
  77. package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
  78. package/dist/src/Server/lib/ContainerServer.js +13 -28
  79. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  80. package/dist/src/Server/lib/Server.d.ts +17 -32
  81. package/dist/src/Server/lib/Server.js +18 -28
  82. package/dist/src/Server/lib/Server.js.map +1 -1
  83. package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
  84. package/dist/src/Server/lib/container/GenericHandler.js +16 -3
  85. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  86. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
  87. package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
  88. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  89. package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
  90. package/dist/src/Server/lib/container/HealthHandler.js +6 -0
  91. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  92. package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
  93. package/dist/src/Server/lib/container/Proxy.js +52 -52
  94. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  95. package/dist/src/Server/lib/container/Utils.d.ts +6 -10
  96. package/dist/src/Server/lib/container/Utils.js +6 -10
  97. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  98. package/dist/src/Validation/Validator.d.ts +9 -13
  99. package/dist/src/Validation/Validator.js +8 -12
  100. package/dist/src/Validation/Validator.js.map +1 -1
  101. package/index.ts +15 -0
  102. package/jest.config.ts +1 -1
  103. package/package.json +13 -2
  104. package/src/API/Request.ts +66 -84
  105. package/src/API/Response.ts +144 -203
  106. package/src/API/Utils.ts +28 -44
  107. package/src/BaseEvent/EventProcessor.ts +52 -77
  108. package/src/BaseEvent/Process.ts +27 -52
  109. package/src/BaseEvent/Transaction.ts +147 -27
  110. package/src/Config/Configuration.ts +59 -76
  111. package/src/Config/EnvironmentVar.ts +39 -62
  112. package/src/Crypto/Crypto.ts +20 -36
  113. package/src/Crypto/JWT.ts +31 -35
  114. package/src/Database/Database.ts +19 -0
  115. package/src/Database/DatabaseManager.ts +51 -0
  116. package/src/Database/DatabaseTransaction.ts +118 -0
  117. package/src/Database/integrations/knex/KnexDatabase.ts +47 -0
  118. package/src/Database/integrations/knex/KnexTransaction.ts +51 -0
  119. package/src/Database/integrations/pgsql/PostgresDatabase.ts +49 -0
  120. package/src/Database/integrations/pgsql/PostgresTransaction.ts +54 -0
  121. package/src/Database/types.d.ts +49 -0
  122. package/src/Globals.ts +28 -96
  123. package/src/Logger/Logger.ts +141 -160
  124. package/src/Mailer/Mailer.ts +43 -76
  125. package/src/Publisher/Publisher.ts +31 -40
  126. package/src/Server/RouteResolver.ts +31 -52
  127. package/src/Server/Router.ts +75 -54
  128. package/src/Server/lib/ContainerServer.ts +20 -32
  129. package/src/Server/lib/Server.ts +19 -34
  130. package/src/Server/lib/container/GenericHandler.ts +17 -3
  131. package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
  132. package/src/Server/lib/container/HealthHandler.ts +6 -0
  133. package/src/Server/lib/container/Proxy.ts +39 -58
  134. package/src/Server/lib/container/Utils.ts +7 -10
  135. package/src/Validation/Validator.ts +11 -13
  136. package/tests/API/Response.test.ts +55 -56
  137. package/tests/BaseEvent/EventProcessor.test.ts +49 -50
  138. package/tests/BaseEvent/Process.test.ts +2 -2
  139. package/tests/BaseEvent/Transaction.test.ts +102 -44
  140. package/tests/Config/Config.test.ts +27 -27
  141. package/tests/Config/EnvironmentVar.test.ts +54 -18
  142. package/tests/Database/DatabaseManager.test.ts +55 -0
  143. package/tests/Database/integrations/knex/KnexDatabase.test.ts +53 -0
  144. package/tests/Database/integrations/knex/KnexTransaction.test.ts +133 -0
  145. package/tests/Database/integrations/pg/PostgresDatabase.test.ts +50 -0
  146. package/tests/Database/integrations/pg/PostgresTransaction.test.ts +51 -0
  147. package/tests/Publisher/Publisher.test.ts +3 -3
  148. package/tests/Server/lib/ContainerServer.test.ts +21 -22
  149. package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
  150. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
  151. package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
  152. package/tests/Server/lib/container/Proxy.test.ts +37 -35
  153. package/tsconfig.json +6 -1
@@ -1,8 +1,10 @@
1
1
  /**
2
- * ${1:Description placeholder}
3
- *
4
- * @export
5
- * @enum {number}
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
- * ${1:Description placeholder}
15
- *
16
- * @export
17
- * @typedef {LoggerConfig}
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
- * ${1:Description placeholder}
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
- * ${1:Description placeholder}
33
- *
34
- * @private
35
- * @type {?LoggerConfig}
30
+ * The optional configuration object for the logger.
36
31
  */
37
- private _config?;
32
+ private config?;
38
33
  /**
39
- * ${1:Description placeholder}
40
- *
41
- * @private
34
+ * Private property representing the transaction ID.
42
35
  * @type {string}
36
+ * @private
43
37
  */
44
- private _transactionID;
38
+ private transactionID;
45
39
  /**
46
- * ${1:Description placeholder}
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 _filterBlacklist;
42
+ private filterBlacklist;
52
43
  /**
53
- * ${1:Description placeholder}
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
- * ${1:Description placeholder}
61
- *
50
+ * The origin of the object.
62
51
  * @private
63
- * @type {*}
52
+ * @type {any}
64
53
  */
65
54
  private origin;
66
55
  /**
67
- * Creates an instance of Logger.
68
- *
69
- * @constructor
70
- * @param {(LoggerConfig | undefined)} _config
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(_config: LoggerConfig | undefined, transactionID: string);
61
+ constructor(config: LoggerConfig | undefined, transactionID: string);
74
62
  /**
75
- * ${1:Description placeholder}
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
- * ${1:Description placeholder}
83
- *
84
- * @param {...{}\} args
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
- * ${1:Description placeholder}
89
- *
90
- * @param {...{}\} args
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
- * ${1:Description placeholder}
95
- *
96
- * @param {...{}\} args
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
- * ${1:Description placeholder}
101
- *
102
- * @param {...{}\} args
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
- * ${1:Description placeholder}
107
- *
108
- * @param {...{}\} args
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
- * ${1:Description placeholder}
113
- *
114
- * @param {...{}\} args
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
- * ${1:Description placeholder}
119
- *
120
- * @param {*} exception
121
- * @param {...{}\} args
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
- * ${1:Description placeholder}
126
- *
111
+ * Sets up the console bindings for logging purposes.
127
112
  * @private
113
+ * @returns None
128
114
  */
129
- private _setupBindings;
115
+ private setupBindings;
130
116
  /**
131
- * ${1:Description placeholder}
132
- *
133
- * @private
134
- * @param {LOG_LEVELS} level
135
- * @param {Array<string>} msg
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 _formattedLog;
123
+ private formattedLog;
140
124
  /**
141
- * ${1:Description placeholder}
142
- *
143
- * @private
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 _callerName;
129
+ private callerName;
148
130
  /**
149
- * ${1:Description placeholder}
150
- *
151
- * @private
152
- * @param {LOG_LEVELS} level
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 _processLog;
136
+ private processLog;
156
137
  /**
157
- * ${1:Description placeholder}
158
- *
159
- * @private
160
- * @param {Error} exception
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 _exception;
143
+ private iexception;
164
144
  /**
165
- * ${1:Description placeholder}
166
- *
167
- * @private
168
- * @param {LOG_LEVELS} level
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 _pushLog;
150
+ private pushLog;
172
151
  /**
173
- * ${1:Description placeholder}
174
- *
175
- * @private
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 _suppressSensitiveInfo;
156
+ private suppressSensitiveInfo;
180
157
  }