tiny-essentials 1.3.0 → 1.3.1
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/dist/TinyEssentials.js +16 -8
- package/dist/TinyLevelUp.js +16 -8
- package/dist/legacy/firebase/cookieSession.cjs +1 -1
- package/dist/legacy/firebase/cookieSession.d.mts +2 -2
- package/dist/legacy/firebase/cookieSession.mjs +1 -1
- package/dist/legacy/firebase/databaseLogger.cjs +5 -5
- package/dist/legacy/firebase/databaseLogger.d.mts +2 -2
- package/dist/legacy/firebase/databaseLogger.mjs +5 -5
- package/dist/legacy/firebase/discord/api/addGuildMember.cjs +2 -2
- package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/addGuildMember.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getToken.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getToken.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getToken.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getUser.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getUser.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getUser.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserConnections.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getUserConnections.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +2 -2
- package/dist/legacy/firebase/discord/api/refreshToken.cjs +2 -2
- package/dist/legacy/firebase/discord/api/refreshToken.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/refreshToken.mjs +2 -2
- package/dist/legacy/firebase/discord/api/revokeToken.cjs +2 -2
- package/dist/legacy/firebase/discord/api/revokeToken.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/revokeToken.mjs +2 -2
- package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +3 -3
- package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +4 -4
- package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +3 -3
- package/dist/legacy/firebase/discord/get/cookie-session.cjs +1 -1
- package/dist/legacy/firebase/discord/get/cookie-session.d.mts +2 -2
- package/dist/legacy/firebase/discord/get/cookie-session.mjs +1 -1
- package/dist/legacy/firebase/discord/get/errorValidator.cjs +1 -1
- package/dist/legacy/firebase/discord/get/errorValidator.d.mts +2 -2
- package/dist/legacy/firebase/discord/get/errorValidator.mjs +1 -1
- package/dist/legacy/firebase/discord/http/login.cjs +3 -3
- package/dist/legacy/firebase/discord/http/login.d.mts +4 -4
- package/dist/legacy/firebase/discord/http/login.mjs +3 -3
- package/dist/legacy/firebase/discord/http/logout.cjs +4 -4
- package/dist/legacy/firebase/discord/http/logout.d.mts +5 -5
- package/dist/legacy/firebase/discord/http/logout.mjs +4 -4
- package/dist/legacy/firebase/discord/http/redirect.cjs +4 -4
- package/dist/legacy/firebase/discord/http/redirect.d.mts +5 -5
- package/dist/legacy/firebase/discord/http/redirect.mjs +4 -4
- package/dist/legacy/firebase/discord/http/refreshToken.cjs +4 -4
- package/dist/legacy/firebase/discord/http/refreshToken.d.mts +5 -5
- package/dist/legacy/firebase/discord/http/refreshToken.mjs +4 -4
- package/dist/legacy/firebase/discord/template/cookie-session.cjs +2 -2
- package/dist/legacy/firebase/discord/template/cookie-session.d.mts +5 -5
- package/dist/legacy/firebase/discord/template/cookie-session.mjs +2 -2
- package/dist/legacy/firebase/escape.cjs +1 -1
- package/dist/legacy/firebase/escape.d.mts +2 -2
- package/dist/legacy/firebase/escape.mjs +1 -1
- package/dist/legacy/firebase/index.cjs +6 -6
- package/dist/legacy/firebase/index.d.mts +7 -7
- package/dist/legacy/firebase/index.mjs +6 -6
- package/dist/legacy/firebase/logger.cjs +5 -5
- package/dist/legacy/firebase/logger.d.mts +4 -4
- package/dist/legacy/firebase/logger.mjs +5 -5
- package/dist/legacy/firebase/mySQL.cjs +2 -2
- package/dist/legacy/firebase/mySQL.d.mts +3 -3
- package/dist/legacy/firebase/mySQL.mjs +2 -2
- package/dist/legacy/firebase/mysqlConnector/create.cjs +4 -4
- package/dist/legacy/firebase/mysqlConnector/create.d.mts +5 -5
- package/dist/legacy/firebase/mysqlConnector/create.mjs +4 -4
- package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +2 -2
- package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +4 -4
- package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +2 -2
- package/dist/legacy/firebase/mysqlConnector/pagination.cjs +4 -4
- package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +6 -6
- package/dist/legacy/firebase/mysqlConnector/pagination.mjs +4 -4
- package/dist/legacy/firebase/transactionDBAsync.cjs +1 -1
- package/dist/legacy/firebase/transactionDBAsync.d.mts +2 -2
- package/dist/legacy/firebase/transactionDBAsync.mjs +1 -1
- package/dist/legacy/get/pagination.cjs +1 -1
- package/dist/legacy/get/pagination.d.mts +2 -2
- package/dist/legacy/get/pagination.mjs +1 -1
- package/dist/legacy/get/versionCheck.cjs +1 -1
- package/dist/legacy/get/versionCheck.d.mts +2 -2
- package/dist/legacy/get/versionCheck.mjs +1 -1
- package/dist/legacy/http/check_domain.cjs +2 -2
- package/dist/legacy/http/check_domain.d.mts +2 -2
- package/dist/legacy/http/check_domain.mjs +2 -2
- package/dist/legacy/http/csrfTokenAnalyze.cjs +2 -2
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +3 -3
- package/dist/legacy/http/csrfTokenAnalyze.mjs +2 -2
- package/dist/legacy/http/domainValidator.cjs +3 -3
- package/dist/legacy/http/domainValidator.d.mts +4 -4
- package/dist/legacy/http/domainValidator.mjs +3 -3
- package/dist/legacy/http/userIP.cjs +1 -1
- package/dist/legacy/http/userIP.d.mts +2 -4
- package/dist/legacy/http/userIP.mjs +1 -1
- package/dist/legacy/index.d.mts +4 -4
- package/dist/legacy/libs/custom_module_loader.cjs +2 -2
- package/dist/legacy/libs/custom_module_loader.d.mts +2 -2
- package/dist/legacy/libs/custom_module_loader.mjs +2 -2
- package/dist/legacy/libs/userLevel.cjs +16 -8
- package/dist/legacy/libs/userLevel.d.mts +34 -12
- package/dist/legacy/libs/userLevel.mjs +14 -8
- package/dist/legacy/socket.io/antiFlood/install.cjs +3 -3
- package/dist/legacy/socket.io/antiFlood/install.d.mts +4 -6
- package/dist/legacy/socket.io/antiFlood/install.mjs +3 -3
- package/dist/legacy/socket.io/antiFlood/verify.cjs +4 -4
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +5 -7
- package/dist/legacy/socket.io/antiFlood/verify.mjs +4 -4
- package/dist/legacy/socket.io/cookie-session.cjs +2 -2
- package/dist/legacy/socket.io/cookie-session.d.mts +3 -3
- package/dist/legacy/socket.io/cookie-session.mjs +2 -2
- package/dist/legacy/socket.io/discord.cjs +3 -3
- package/dist/legacy/socket.io/discord.d.mts +4 -4
- package/dist/legacy/socket.io/discord.mjs +3 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default fbLogger;
|
|
2
2
|
declare namespace fbLogger {
|
|
3
|
-
function log(...args: any[]): Promise<
|
|
4
|
-
function info(...args: any[]): Promise<
|
|
5
|
-
function warn(...args: any[]): Promise<
|
|
6
|
-
function error(...args: any[]): Promise<
|
|
3
|
+
function log(...args: any[]): Promise<Record<string, any>>;
|
|
4
|
+
function info(...args: any[]): Promise<Record<string, any>>;
|
|
5
|
+
function warn(...args: any[]): Promise<Record<string, any>>;
|
|
6
|
+
function error(...args: any[]): Promise<Record<string, any>>;
|
|
7
7
|
}
|
|
@@ -44,7 +44,7 @@ const loopInteraction = function (data) {
|
|
|
44
44
|
*
|
|
45
45
|
* @param {string} type - The type of log message (e.g., `log`, `info`, `warn`, `error`).
|
|
46
46
|
* @param {Arguments} args - The arguments to be logged.
|
|
47
|
-
* @returns {Promise<
|
|
47
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the result of the logging operation,
|
|
48
48
|
* or the result of logging to the native console if Firebase logger is not available.
|
|
49
49
|
*/
|
|
50
50
|
const logBase = async function (type, args) {
|
|
@@ -90,7 +90,7 @@ const fbLogger = {
|
|
|
90
90
|
* Logs a message with the `log` level. If not in emulator mode, it uses Firebase's logger.
|
|
91
91
|
*
|
|
92
92
|
* @param {...*} args - The arguments to log.
|
|
93
|
-
* @returns {Promise<
|
|
93
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
94
94
|
*/
|
|
95
95
|
log: function () {
|
|
96
96
|
return logBase('log', arguments);
|
|
@@ -99,7 +99,7 @@ const fbLogger = {
|
|
|
99
99
|
* Logs a message with the `info` level. If not in emulator mode, it uses Firebase's logger.
|
|
100
100
|
*
|
|
101
101
|
* @param {...*} args - The arguments to log.
|
|
102
|
-
* @returns {Promise<
|
|
102
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
103
103
|
*/
|
|
104
104
|
info: function () {
|
|
105
105
|
return logBase('info', arguments);
|
|
@@ -108,7 +108,7 @@ const fbLogger = {
|
|
|
108
108
|
* Logs a message with the `warn` level. If not in emulator mode, it uses Firebase's logger.
|
|
109
109
|
*
|
|
110
110
|
* @param {...*} args - The arguments to log.
|
|
111
|
-
* @returns {Promise<
|
|
111
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
112
112
|
*/
|
|
113
113
|
warn: function () {
|
|
114
114
|
return logBase('warn', arguments);
|
|
@@ -117,7 +117,7 @@ const fbLogger = {
|
|
|
117
117
|
* Logs a message with the `error` level. If not in emulator mode, it uses Firebase's logger.
|
|
118
118
|
*
|
|
119
119
|
* @param {...*} args - The arguments to log.
|
|
120
|
-
* @returns {Promise<
|
|
120
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
121
121
|
*/
|
|
122
122
|
error: function () {
|
|
123
123
|
return logBase('error', arguments);
|
|
@@ -9,9 +9,9 @@ require('clone');
|
|
|
9
9
|
* Connects to a MySQL database using the provided configuration and credentials.
|
|
10
10
|
* The function utilizes `mySqlConnector.create` to establish the connection.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {Record<string, any>} mysql - The MySQL module instance.
|
|
13
13
|
* @param {Array|string} databases - The list of databases to connect to, or a single database name.
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Record<string, any>} cfg - The configuration object containing connection details (e.g., host, user, password).
|
|
15
15
|
* @returns {Promise} Resolves with the connection object or rejects with an error.
|
|
16
16
|
*/
|
|
17
17
|
function mySQL(mysql, databases, cfg) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Connects to a MySQL database using the provided configuration and credentials.
|
|
3
3
|
* The function utilizes `mySqlConnector.create` to establish the connection.
|
|
4
4
|
*
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} mysql - The MySQL module instance.
|
|
6
6
|
* @param {Array|string} databases - The list of databases to connect to, or a single database name.
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} cfg - The configuration object containing connection details (e.g., host, user, password).
|
|
8
8
|
* @returns {Promise} Resolves with the connection object or rejects with an error.
|
|
9
9
|
*/
|
|
10
|
-
export default function mySQL(mysql:
|
|
10
|
+
export default function mySQL(mysql: Record<string, any>, databases: any[] | string, cfg: Record<string, any>): Promise<any>;
|
|
@@ -4,9 +4,9 @@ import mysqlConnector from './mysqlConnector/index.mjs';
|
|
|
4
4
|
* Connects to a MySQL database using the provided configuration and credentials.
|
|
5
5
|
* The function utilizes `mySqlConnector.create` to establish the connection.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} mysql - The MySQL module instance.
|
|
8
8
|
* @param {Array|string} databases - The list of databases to connect to, or a single database name.
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>} cfg - The configuration object containing connection details (e.g., host, user, password).
|
|
10
10
|
* @returns {Promise} Resolves with the connection object or rejects with an error.
|
|
11
11
|
*/
|
|
12
12
|
export default function mySQL(mysql, databases, cfg) {
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* Supports Firebase and Google Cloud SQL socket-based connections, as well as local/standard MySQL setups.
|
|
8
8
|
*
|
|
9
9
|
* @async
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {Record<string, any>} mysql - The `mysql2` module or similar instance, with a `.createPool()` method.
|
|
11
11
|
* @param {string} proxyType - The type of proxy connection. Can be `"default"`, `"firebase"`, or `"google_cloud"`.
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {Record<string, any>|Record<string, any>[]} databases - A single database config object or an array of config objects.
|
|
13
|
+
* @param {Record<string, any>} cfg - Global fallback configuration, e.g., `{ charset: 'utf8mb4' }`.
|
|
14
14
|
*
|
|
15
|
-
* @returns {Promise<
|
|
15
|
+
* @returns {Promise<Record<string, any>>} Resolves with a single connection object if one database is provided,
|
|
16
16
|
* or a map of database names to connections if multiple databases are configured.
|
|
17
17
|
*
|
|
18
18
|
* @throws {Error} Will reject if any database config is invalid or if the proxyType is unsupported.
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Supports Firebase and Google Cloud SQL socket-based connections, as well as local/standard MySQL setups.
|
|
4
4
|
*
|
|
5
5
|
* @async
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} mysql - The `mysql2` module or similar instance, with a `.createPool()` method.
|
|
7
7
|
* @param {string} proxyType - The type of proxy connection. Can be `"default"`, `"firebase"`, or `"google_cloud"`.
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
8
|
+
* @param {Record<string, any>|Record<string, any>[]} databases - A single database config object or an array of config objects.
|
|
9
|
+
* @param {Record<string, any>} cfg - Global fallback configuration, e.g., `{ charset: 'utf8mb4' }`.
|
|
10
10
|
*
|
|
11
|
-
* @returns {Promise<
|
|
11
|
+
* @returns {Promise<Record<string, any>>} Resolves with a single connection object if one database is provided,
|
|
12
12
|
* or a map of database names to connections if multiple databases are configured.
|
|
13
13
|
*
|
|
14
14
|
* @throws {Error} Will reject if any database config is invalid or if the proxyType is unsupported.
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
* }
|
|
34
34
|
* ]);
|
|
35
35
|
*/
|
|
36
|
-
export default function create(mysql:
|
|
36
|
+
export default function create(mysql: Record<string, any>, proxyType: string, databases: Record<string, any> | Record<string, any>[], cfg: Record<string, any>): Promise<Record<string, any>>;
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Supports Firebase and Google Cloud SQL socket-based connections, as well as local/standard MySQL setups.
|
|
5
5
|
*
|
|
6
6
|
* @async
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} mysql - The `mysql2` module or similar instance, with a `.createPool()` method.
|
|
8
8
|
* @param {string} proxyType - The type of proxy connection. Can be `"default"`, `"firebase"`, or `"google_cloud"`.
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>|Record<string, any>[]} databases - A single database config object or an array of config objects.
|
|
10
|
+
* @param {Record<string, any>} cfg - Global fallback configuration, e.g., `{ charset: 'utf8mb4' }`.
|
|
11
11
|
*
|
|
12
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<Record<string, any>>} Resolves with a single connection object if one database is provided,
|
|
13
13
|
* or a map of database names to connections if multiple databases are configured.
|
|
14
14
|
*
|
|
15
15
|
* @throws {Error} Will reject if any database config is invalid or if the proxyType is unsupported.
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* Executes a directional query (next or previous) based on a position value and timestamp, returning a single row.
|
|
7
7
|
*
|
|
8
8
|
* @async
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>} db - The database instance with a `.query(sql, params)` method.
|
|
10
10
|
* @param {Object} tiny_search - Configuration object for the query.
|
|
11
11
|
* @param {string} tiny_search.select - SQL SELECT fields.
|
|
12
12
|
* @param {string} tiny_search.from - SQL FROM clause.
|
|
13
13
|
* @param {string} [tiny_search.where] - Optional WHERE clause (without 'WHERE') to filter results.
|
|
14
|
-
* @param {Array} tiny_search.params - Parameters for the query placeholders.
|
|
14
|
+
* @param {Array<*>} tiny_search.params - Parameters for the query placeholders.
|
|
15
15
|
* @param {*} tiny_search.position - Value to compare in the directional filter (typically an ID or timestamp).
|
|
16
16
|
* @param {boolean} [tiny_search.direction_r=false] - If `true`, selects previous record (uses `<`), otherwise selects next (`>`).
|
|
17
17
|
* @param {Object} tiny_search.database - Object with database structure details.
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Executes a directional query (next or previous) based on a position value and timestamp, returning a single row.
|
|
3
3
|
*
|
|
4
4
|
* @async
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} db - The database instance with a `.query(sql, params)` method.
|
|
6
6
|
* @param {Object} tiny_search - Configuration object for the query.
|
|
7
7
|
* @param {string} tiny_search.select - SQL SELECT fields.
|
|
8
8
|
* @param {string} tiny_search.from - SQL FROM clause.
|
|
9
9
|
* @param {string} [tiny_search.where] - Optional WHERE clause (without 'WHERE') to filter results.
|
|
10
|
-
* @param {Array} tiny_search.params - Parameters for the query placeholders.
|
|
10
|
+
* @param {Array<*>} tiny_search.params - Parameters for the query placeholders.
|
|
11
11
|
* @param {*} tiny_search.position - Value to compare in the directional filter (typically an ID or timestamp).
|
|
12
12
|
* @param {boolean} [tiny_search.direction_r=false] - If `true`, selects previous record (uses `<`), otherwise selects next (`>`).
|
|
13
13
|
* @param {Object} tiny_search.database - Object with database structure details.
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
* @param {string} tiny_search.database.positionVar - Column name used for the directional condition (e.g., `"id"`).
|
|
17
17
|
* @returns {Promise<Object|null>} Resolves with the selected row or `null` if none is found.
|
|
18
18
|
*/
|
|
19
|
-
export default function nextPrev(db:
|
|
19
|
+
export default function nextPrev(db: Record<string, any>, tiny_search: {
|
|
20
20
|
select: string;
|
|
21
21
|
from: string;
|
|
22
22
|
where?: string | undefined;
|
|
23
|
-
params: any
|
|
23
|
+
params: Array<any>;
|
|
24
24
|
position: any;
|
|
25
25
|
direction_r?: boolean | undefined;
|
|
26
26
|
database: {
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Executes a directional query (next or previous) based on a position value and timestamp, returning a single row.
|
|
4
4
|
*
|
|
5
5
|
* @async
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} db - The database instance with a `.query(sql, params)` method.
|
|
7
7
|
* @param {Object} tiny_search - Configuration object for the query.
|
|
8
8
|
* @param {string} tiny_search.select - SQL SELECT fields.
|
|
9
9
|
* @param {string} tiny_search.from - SQL FROM clause.
|
|
10
10
|
* @param {string} [tiny_search.where] - Optional WHERE clause (without 'WHERE') to filter results.
|
|
11
|
-
* @param {Array} tiny_search.params - Parameters for the query placeholders.
|
|
11
|
+
* @param {Array<*>} tiny_search.params - Parameters for the query placeholders.
|
|
12
12
|
* @param {*} tiny_search.position - Value to compare in the directional filter (typically an ID or timestamp).
|
|
13
13
|
* @param {boolean} [tiny_search.direction_r=false] - If `true`, selects previous record (uses `<`), otherwise selects next (`>`).
|
|
14
14
|
* @param {Object} tiny_search.database - Object with database structure details.
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
* Executes a paginated query on the database, returning the result set along with pagination metadata.
|
|
7
7
|
*
|
|
8
8
|
* @async
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>} db - Database instance with a `.query(sql, params)` method.
|
|
10
10
|
* @param {Object} data - Query configuration options.
|
|
11
11
|
* @param {string} data.from - The table or view name to query from.
|
|
12
12
|
* @param {string} [data.where] - Optional WHERE clause without the keyword (e.g., `"status = 'active'"`).
|
|
13
|
-
* @param {Array} [data.params] - Optional parameters for the SQL query placeholders.
|
|
13
|
+
* @param {Array<*>} [data.params] - Optional parameters for the SQL query placeholders.
|
|
14
14
|
* @param {string} [data.select="*"] - Fields to select in the query.
|
|
15
15
|
* @param {string} data.order - SQL ORDER BY clause (e.g., `"created_at DESC"`).
|
|
16
16
|
* @param {number} [data.limit] - Number of rows per page.
|
|
17
17
|
* @param {number|string} [data.page] - Current page number or `'last'` to get the last page.
|
|
18
18
|
* @param {number} [data.count] - Optional total count override (skip count query if provided).
|
|
19
19
|
* @param {boolean} [data.count_rows=false] - Whether to include a row number for each result.
|
|
20
|
-
* @returns {Promise<
|
|
20
|
+
* @returns {Promise<Record<string, any>>} Resolves with pagination metadata and result set.
|
|
21
21
|
* @returns {number} return.count - Total number of matched rows.
|
|
22
|
-
* @returns {Array} return.data - The paginated data from the query.
|
|
22
|
+
* @returns {Array<*>} return.data - The paginated data from the query.
|
|
23
23
|
* @returns {number} return.pages - Total number of pages.
|
|
24
24
|
* @returns {number} return.page - Current page number after validation.
|
|
25
25
|
* @returns {number} return.start - Row offset used in the query.
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
* Executes a paginated query on the database, returning the result set along with pagination metadata.
|
|
3
3
|
*
|
|
4
4
|
* @async
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} db - Database instance with a `.query(sql, params)` method.
|
|
6
6
|
* @param {Object} data - Query configuration options.
|
|
7
7
|
* @param {string} data.from - The table or view name to query from.
|
|
8
8
|
* @param {string} [data.where] - Optional WHERE clause without the keyword (e.g., `"status = 'active'"`).
|
|
9
|
-
* @param {Array} [data.params] - Optional parameters for the SQL query placeholders.
|
|
9
|
+
* @param {Array<*>} [data.params] - Optional parameters for the SQL query placeholders.
|
|
10
10
|
* @param {string} [data.select="*"] - Fields to select in the query.
|
|
11
11
|
* @param {string} data.order - SQL ORDER BY clause (e.g., `"created_at DESC"`).
|
|
12
12
|
* @param {number} [data.limit] - Number of rows per page.
|
|
13
13
|
* @param {number|string} [data.page] - Current page number or `'last'` to get the last page.
|
|
14
14
|
* @param {number} [data.count] - Optional total count override (skip count query if provided).
|
|
15
15
|
* @param {boolean} [data.count_rows=false] - Whether to include a row number for each result.
|
|
16
|
-
* @returns {Promise<
|
|
16
|
+
* @returns {Promise<Record<string, any>>} Resolves with pagination metadata and result set.
|
|
17
17
|
* @returns {number} return.count - Total number of matched rows.
|
|
18
|
-
* @returns {Array} return.data - The paginated data from the query.
|
|
18
|
+
* @returns {Array<*>} return.data - The paginated data from the query.
|
|
19
19
|
* @returns {number} return.pages - Total number of pages.
|
|
20
20
|
* @returns {number} return.page - Current page number after validation.
|
|
21
21
|
* @returns {number} return.start - Row offset used in the query.
|
|
22
22
|
*/
|
|
23
|
-
export default function pagination(db:
|
|
23
|
+
export default function pagination(db: Record<string, any>, data: {
|
|
24
24
|
from: string;
|
|
25
25
|
where?: string | undefined;
|
|
26
26
|
params?: any[] | undefined;
|
|
@@ -30,4 +30,4 @@ export default function pagination(db: Object, data: {
|
|
|
30
30
|
page?: string | number | undefined;
|
|
31
31
|
count?: number | undefined;
|
|
32
32
|
count_rows?: boolean | undefined;
|
|
33
|
-
}): Promise<
|
|
33
|
+
}): Promise<Record<string, any>>;
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
* Executes a paginated query on the database, returning the result set along with pagination metadata.
|
|
4
4
|
*
|
|
5
5
|
* @async
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} db - Database instance with a `.query(sql, params)` method.
|
|
7
7
|
* @param {Object} data - Query configuration options.
|
|
8
8
|
* @param {string} data.from - The table or view name to query from.
|
|
9
9
|
* @param {string} [data.where] - Optional WHERE clause without the keyword (e.g., `"status = 'active'"`).
|
|
10
|
-
* @param {Array} [data.params] - Optional parameters for the SQL query placeholders.
|
|
10
|
+
* @param {Array<*>} [data.params] - Optional parameters for the SQL query placeholders.
|
|
11
11
|
* @param {string} [data.select="*"] - Fields to select in the query.
|
|
12
12
|
* @param {string} data.order - SQL ORDER BY clause (e.g., `"created_at DESC"`).
|
|
13
13
|
* @param {number} [data.limit] - Number of rows per page.
|
|
14
14
|
* @param {number|string} [data.page] - Current page number or `'last'` to get the last page.
|
|
15
15
|
* @param {number} [data.count] - Optional total count override (skip count query if provided).
|
|
16
16
|
* @param {boolean} [data.count_rows=false] - Whether to include a row number for each result.
|
|
17
|
-
* @returns {Promise<
|
|
17
|
+
* @returns {Promise<Record<string, any>>} Resolves with pagination metadata and result set.
|
|
18
18
|
* @returns {number} return.count - Total number of matched rows.
|
|
19
|
-
* @returns {Array} return.data - The paginated data from the query.
|
|
19
|
+
* @returns {Array<*>} return.data - The paginated data from the query.
|
|
20
20
|
* @returns {number} return.pages - Total number of pages.
|
|
21
21
|
* @returns {number} return.page - Current page number after validation.
|
|
22
22
|
* @returns {number} return.start - Row offset used in the query.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* The provided callback is executed with the current value in the database, and the transaction
|
|
9
9
|
* is committed based on the result returned from the callback.
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Record<string, any>} data - The Firebase database reference object on which the transaction will be performed.
|
|
12
12
|
* @param {Function} callback - A function that accepts the current value of the data and returns the updated value.
|
|
13
13
|
* @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
|
|
14
14
|
*/
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* The provided callback is executed with the current value in the database, and the transaction
|
|
5
5
|
* is committed based on the result returned from the callback.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} data - The Firebase database reference object on which the transaction will be performed.
|
|
8
8
|
* @param {Function} callback - A function that accepts the current value of the data and returns the updated value.
|
|
9
9
|
* @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
|
|
10
10
|
*/
|
|
11
|
-
export default function transactionDBAsync(data:
|
|
11
|
+
export default function transactionDBAsync(data: Record<string, any>, callback: Function): Promise<any>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* The provided callback is executed with the current value in the database, and the transaction
|
|
6
6
|
* is committed based on the result returned from the callback.
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {Record<string, any>} data - The Firebase database reference object on which the transaction will be performed.
|
|
9
9
|
* @param {Function} callback - A function that accepts the current value of the data and returns the updated value.
|
|
10
10
|
* @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
|
|
11
11
|
*/
|
|
@@ -17,7 +17,7 @@ var queryUrlJSON = require('./queryUrlJSON.cjs');
|
|
|
17
17
|
* @param {string} [extraClass=''] - Additional class name for styling the pagination container.
|
|
18
18
|
* @param {string} [extraClass2=''] - Additional class name for individual page links.
|
|
19
19
|
*
|
|
20
|
-
* @returns {
|
|
20
|
+
* @returns {Record<string, any>} Pagination metadata including:
|
|
21
21
|
* - `url` {string} - The updated URL prefix to use for each page link.
|
|
22
22
|
* - `extraClass` {string} - Additional class name passed through.
|
|
23
23
|
* - `extraClass2` {string} - Additional class name passed through.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @param {string} [extraClass=''] - Additional class name for styling the pagination container.
|
|
11
11
|
* @param {string} [extraClass2=''] - Additional class name for individual page links.
|
|
12
12
|
*
|
|
13
|
-
* @returns {
|
|
13
|
+
* @returns {Record<string, any>} Pagination metadata including:
|
|
14
14
|
* - `url` {string} - The updated URL prefix to use for each page link.
|
|
15
15
|
* - `extraClass` {string} - Additional class name passed through.
|
|
16
16
|
* - `extraClass2` {string} - Additional class name passed through.
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* - `lastPagination` {boolean} - `true` if the last page is not in the visible pagination and should be shown separately.
|
|
23
23
|
* - `pages` {number} - Total number of pages.
|
|
24
24
|
*/
|
|
25
|
-
export default function pagination(query: string, page: number, total: number, url?: string, extraClass?: string, extraClass2?: string):
|
|
25
|
+
export default function pagination(query: string, page: number, total: number, url?: string, extraClass?: string, extraClass2?: string): Record<string, any>;
|
|
@@ -12,7 +12,7 @@ import queryUrlJSON from './queryUrlJSON.mjs';
|
|
|
12
12
|
* @param {string} [extraClass=''] - Additional class name for styling the pagination container.
|
|
13
13
|
* @param {string} [extraClass2=''] - Additional class name for individual page links.
|
|
14
14
|
*
|
|
15
|
-
* @returns {
|
|
15
|
+
* @returns {Record<string, any>} Pagination metadata including:
|
|
16
16
|
* - `url` {string} - The updated URL prefix to use for each page link.
|
|
17
17
|
* - `extraClass` {string} - Additional class name passed through.
|
|
18
18
|
* - `extraClass2` {string} - Additional class name passed through.
|
|
@@ -21,7 +21,7 @@ const check_version = {
|
|
|
21
21
|
* @param {string} pkg.name - The name of the package.
|
|
22
22
|
* @param {string} pkg.version - The current version of the package.
|
|
23
23
|
*
|
|
24
|
-
* @returns {Promise<
|
|
24
|
+
* @returns {Promise<Record<string, any>>} The result object containing:
|
|
25
25
|
* - `needUpdate`: {boolean} - `true` if the current version is outdated, `false` otherwise.
|
|
26
26
|
* - `now`: {string} - The current version of the package.
|
|
27
27
|
* - `new`: {string} - The latest version of the package available on npm.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {string} pkg.name - The name of the package.
|
|
7
7
|
* @param {string} pkg.version - The current version of the package.
|
|
8
8
|
*
|
|
9
|
-
* @returns {Promise<
|
|
9
|
+
* @returns {Promise<Record<string, any>>} The result object containing:
|
|
10
10
|
* - `needUpdate`: {boolean} - `true` if the current version is outdated, `false` otherwise.
|
|
11
11
|
* - `now`: {string} - The current version of the package.
|
|
12
12
|
* - `new`: {string} - The latest version of the package available on npm.
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
export default function versionCheck(pkg: {
|
|
15
15
|
name: string;
|
|
16
16
|
version: string;
|
|
17
|
-
}): Promise<
|
|
17
|
+
}): Promise<Record<string, any>>;
|
|
@@ -16,7 +16,7 @@ const check_version = {
|
|
|
16
16
|
* @param {string} pkg.name - The name of the package.
|
|
17
17
|
* @param {string} pkg.version - The current version of the package.
|
|
18
18
|
*
|
|
19
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<Record<string, any>>} The result object containing:
|
|
20
20
|
* - `needUpdate`: {boolean} - `true` if the current version is outdated, `false` otherwise.
|
|
21
21
|
* - `now`: {string} - The current version of the package.
|
|
22
22
|
* - `new`: {string} - The latest version of the package available on npm.
|
|
@@ -57,7 +57,7 @@ const check_domain = {
|
|
|
57
57
|
* Validates the request against a given domain using all available validators.
|
|
58
58
|
*
|
|
59
59
|
* @function
|
|
60
|
-
* @param {
|
|
60
|
+
* @param {Record<string, any>} req - The request object from Express.
|
|
61
61
|
* @param {string} the_domain - The domain to validate against.
|
|
62
62
|
* @returns {boolean} True if any validator matches the domain.
|
|
63
63
|
*/
|
|
@@ -71,7 +71,7 @@ const check_domain = {
|
|
|
71
71
|
* Returns the domain found from the first valid source in the request object.
|
|
72
72
|
*
|
|
73
73
|
* @function
|
|
74
|
-
* @param {
|
|
74
|
+
* @param {Record<string, any>} req - The request object from Express.
|
|
75
75
|
* @returns {string|null} The found domain string or `null` if none matched.
|
|
76
76
|
*/
|
|
77
77
|
get: function (req) {
|
|
@@ -5,6 +5,6 @@ declare namespace check_domain {
|
|
|
5
5
|
callback: (arg0: req) => Object;
|
|
6
6
|
the_domain?: string;
|
|
7
7
|
}>;
|
|
8
|
-
function validator(req:
|
|
9
|
-
function get(req:
|
|
8
|
+
function validator(req: Record<string, any>, the_domain: string): boolean;
|
|
9
|
+
function get(req: Record<string, any>): string | null;
|
|
10
10
|
}
|
|
@@ -54,7 +54,7 @@ const check_domain = {
|
|
|
54
54
|
* Validates the request against a given domain using all available validators.
|
|
55
55
|
*
|
|
56
56
|
* @function
|
|
57
|
-
* @param {
|
|
57
|
+
* @param {Record<string, any>} req - The request object from Express.
|
|
58
58
|
* @param {string} the_domain - The domain to validate against.
|
|
59
59
|
* @returns {boolean} True if any validator matches the domain.
|
|
60
60
|
*/
|
|
@@ -68,7 +68,7 @@ const check_domain = {
|
|
|
68
68
|
* Returns the domain found from the first valid source in the request object.
|
|
69
69
|
*
|
|
70
70
|
* @function
|
|
71
|
-
* @param {
|
|
71
|
+
* @param {Record<string, any>} req - The request object from Express.
|
|
72
72
|
* @returns {string|null} The found domain string or `null` if none matched.
|
|
73
73
|
*/
|
|
74
74
|
get: function (req) {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* Checks if the CSRF token in the request body matches the expected token from the session.
|
|
9
9
|
* If invalid, returns a 401 response and optionally executes a custom callback.
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Record<string, any>} req - The Express request object. Should contain:
|
|
12
12
|
* - `req.csrfToken.now`: The expected CSRF token.
|
|
13
13
|
* - `req.body.csrfToken`: The token provided by the client.
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Record<string, any>} res - The Express response object.
|
|
15
15
|
* @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
|
|
16
16
|
*
|
|
17
17
|
* @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Checks if the CSRF token in the request body matches the expected token from the session.
|
|
5
5
|
* If invalid, returns a 401 response and optionally executes a custom callback.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} req - The Express request object. Should contain:
|
|
8
8
|
* - `req.csrfToken.now`: The expected CSRF token.
|
|
9
9
|
* - `req.body.csrfToken`: The token provided by the client.
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {Record<string, any>} res - The Express response object.
|
|
11
11
|
* @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
|
|
12
12
|
*
|
|
13
13
|
* @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
* // Continue with request logic if CSRF is valid
|
|
19
19
|
* });
|
|
20
20
|
*/
|
|
21
|
-
export default function csrfTokenAnalyze(req:
|
|
21
|
+
export default function csrfTokenAnalyze(req: Record<string, any>, res: Record<string, any>, callback?: Function): boolean;
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Checks if the CSRF token in the request body matches the expected token from the session.
|
|
6
6
|
* If invalid, returns a 401 response and optionally executes a custom callback.
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {Record<string, any>} req - The Express request object. Should contain:
|
|
9
9
|
* - `req.csrfToken.now`: The expected CSRF token.
|
|
10
10
|
* - `req.body.csrfToken`: The token provided by the client.
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Record<string, any>} res - The Express response object.
|
|
12
12
|
* @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
|
|
13
13
|
*
|
|
14
14
|
* @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
|
|
@@ -14,14 +14,14 @@ var isEmulator = require('../firebase/isEmulator.cjs');
|
|
|
14
14
|
* This is useful for filtering requests by origin or allowing access from specific domains only.
|
|
15
15
|
* Also detects if Firebase is running in emulator mode, which bypasses domain validation.
|
|
16
16
|
*
|
|
17
|
-
* @param {
|
|
17
|
+
* @param {Record<string, any>} req - The Express request object.
|
|
18
18
|
* - `req.url`: Full URL path.
|
|
19
19
|
* - `req.headers`: Expected to contain 'host', 'x-forwarded-host', etc.
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {Record<string, any>} cfg - Configuration object.
|
|
21
21
|
* @property {string|string[]} cfg.domain - The allowed domain(s) to validate against.
|
|
22
22
|
* @property {string[]} [cfg.staticPath] - Optional list of static paths to validate.
|
|
23
23
|
*
|
|
24
|
-
* @returns {
|
|
24
|
+
* @returns {Record<string, any>} Returns an object with the following structure:
|
|
25
25
|
* @property {boolean} verified - Whether the domain is verified.
|
|
26
26
|
* @property {string|null} domain - The detected domain from the request.
|
|
27
27
|
* @property {boolean} isStaticPath - Whether the request matches a static path.
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* This is useful for filtering requests by origin or allowing access from specific domains only.
|
|
6
6
|
* Also detects if Firebase is running in emulator mode, which bypasses domain validation.
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {Record<string, any>} req - The Express request object.
|
|
9
9
|
* - `req.url`: Full URL path.
|
|
10
10
|
* - `req.headers`: Expected to contain 'host', 'x-forwarded-host', etc.
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Record<string, any>} cfg - Configuration object.
|
|
12
12
|
* @property {string|string[]} cfg.domain - The allowed domain(s) to validate against.
|
|
13
13
|
* @property {string[]} [cfg.staticPath] - Optional list of static paths to validate.
|
|
14
14
|
*
|
|
15
|
-
* @returns {
|
|
15
|
+
* @returns {Record<string, any>} Returns an object with the following structure:
|
|
16
16
|
* @property {boolean} verified - Whether the domain is verified.
|
|
17
17
|
* @property {string|null} domain - The detected domain from the request.
|
|
18
18
|
* @property {boolean} isStaticPath - Whether the request matches a static path.
|
|
@@ -27,4 +27,4 @@
|
|
|
27
27
|
* console.log('Domain OK:', result.domain);
|
|
28
28
|
* }
|
|
29
29
|
*/
|
|
30
|
-
export default function domainValidator(req:
|
|
30
|
+
export default function domainValidator(req: Record<string, any>, cfg: Record<string, any>): Record<string, any>;
|
|
@@ -9,14 +9,14 @@ import isEmulator from '../firebase/isEmulator.mjs';
|
|
|
9
9
|
* This is useful for filtering requests by origin or allowing access from specific domains only.
|
|
10
10
|
* Also detects if Firebase is running in emulator mode, which bypasses domain validation.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {Record<string, any>} req - The Express request object.
|
|
13
13
|
* - `req.url`: Full URL path.
|
|
14
14
|
* - `req.headers`: Expected to contain 'host', 'x-forwarded-host', etc.
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {Record<string, any>} cfg - Configuration object.
|
|
16
16
|
* @property {string|string[]} cfg.domain - The allowed domain(s) to validate against.
|
|
17
17
|
* @property {string[]} [cfg.staticPath] - Optional list of static paths to validate.
|
|
18
18
|
*
|
|
19
|
-
* @returns {
|
|
19
|
+
* @returns {Record<string, any>} Returns an object with the following structure:
|
|
20
20
|
* @property {boolean} verified - Whether the domain is verified.
|
|
21
21
|
* @property {string|null} domain - The detected domain from the request.
|
|
22
22
|
* @property {boolean} isStaticPath - Whether the request matches a static path.
|
|
@@ -10,7 +10,7 @@ var _ = require('lodash');
|
|
|
10
10
|
* supporting detection for Firebase/Cloud Functions, proxies, and direct connections.
|
|
11
11
|
*
|
|
12
12
|
* @param {import('express').Request} req - The Express request object.
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {Record<string, any>} [options] - Optional configuration.
|
|
14
14
|
* @param {boolean} [options.isFirebase=false] - Enable detection for Firebase environments (e.g., Fastly).
|
|
15
15
|
*
|
|
16
16
|
* @returns {{ value: string[] | null, type: string | null }} An object containing the list of IP addresses and the detection source type.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* supporting detection for Firebase/Cloud Functions, proxies, and direct connections.
|
|
4
4
|
*
|
|
5
5
|
* @param {import('express').Request} req - The Express request object.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} [options] - Optional configuration.
|
|
7
7
|
* @param {boolean} [options.isFirebase=false] - Enable detection for Firebase environments (e.g., Fastly).
|
|
8
8
|
*
|
|
9
9
|
* @returns {{ value: string[] | null, type: string | null }} An object containing the list of IP addresses and the detection source type.
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
* console.log(ipInfo.value); // ['192.168.0.1']
|
|
14
14
|
* console.log(ipInfo.type); // 'x-forwarded-for'
|
|
15
15
|
*/
|
|
16
|
-
export default function userIp(req: import("express").Request, options?: {
|
|
17
|
-
isFirebase?: boolean | undefined;
|
|
18
|
-
}): {
|
|
16
|
+
export default function userIp(req: import("express").Request, options?: Record<string, any>): {
|
|
19
17
|
value: string[] | null;
|
|
20
18
|
type: string | null;
|
|
21
19
|
};
|