tiny-essentials 1.0.0

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 (302) hide show
  1. package/.github/FUNDING.yml +4 -0
  2. package/.github/workflows/node.js.yml +31 -0
  3. package/LICENSE +674 -0
  4. package/README.md +67 -0
  5. package/dist/TinyEssentials.min.js +1 -0
  6. package/dist/_virtual/_commonjsHelpers.cjs +7 -0
  7. package/dist/_virtual/common.cjs +5 -0
  8. package/dist/_virtual/index.cjs +9 -0
  9. package/dist/_virtual/index2.cjs +5 -0
  10. package/dist/_virtual/trace.cjs +5 -0
  11. package/dist/legacy/crypto/decrypt.cjs +57 -0
  12. package/dist/legacy/crypto/decrypt.d.mts +18 -0
  13. package/dist/legacy/crypto/decrypt.mjs +47 -0
  14. package/dist/legacy/crypto/default.cjs +23 -0
  15. package/dist/legacy/crypto/default.d.mts +35 -0
  16. package/dist/legacy/crypto/default.mjs +19 -0
  17. package/dist/legacy/crypto/encrypt.cjs +54 -0
  18. package/dist/legacy/crypto/encrypt.d.mts +19 -0
  19. package/dist/legacy/crypto/encrypt.mjs +46 -0
  20. package/dist/legacy/crypto/index.cjs +11 -0
  21. package/dist/legacy/crypto/index.d.mts +4 -0
  22. package/dist/legacy/crypto/index.mjs +6 -0
  23. package/dist/legacy/firebase/cookieSession.cjs +121 -0
  24. package/dist/legacy/firebase/cookieSession.d.mts +56 -0
  25. package/dist/legacy/firebase/cookieSession.mjs +114 -0
  26. package/dist/legacy/firebase/database/index.cjs +11 -0
  27. package/dist/legacy/firebase/database/index.d.mts +7 -0
  28. package/dist/legacy/firebase/database/index.mjs +7 -0
  29. package/dist/legacy/firebase/database/presence.cjs +131 -0
  30. package/dist/legacy/firebase/database/presence.d.mts +9 -0
  31. package/dist/legacy/firebase/database/presence.mjs +111 -0
  32. package/dist/legacy/firebase/database/saveAsync.cjs +147 -0
  33. package/dist/legacy/firebase/database/saveAsync.d.mts +54 -0
  34. package/dist/legacy/firebase/database/saveAsync.mjs +147 -0
  35. package/dist/legacy/firebase/databaseEscape.cjs +42 -0
  36. package/dist/legacy/firebase/databaseEscape.d.mts +11 -0
  37. package/dist/legacy/firebase/databaseEscape.mjs +37 -0
  38. package/dist/legacy/firebase/databaseLogger.cjs +258 -0
  39. package/dist/legacy/firebase/databaseLogger.d.mts +7 -0
  40. package/dist/legacy/firebase/databaseLogger.mjs +234 -0
  41. package/dist/legacy/firebase/discord/api/addGuildMember.cjs +71 -0
  42. package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +38 -0
  43. package/dist/legacy/firebase/discord/api/addGuildMember.mjs +64 -0
  44. package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +47 -0
  45. package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +17 -0
  46. package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +43 -0
  47. package/dist/legacy/firebase/discord/api/getToken.cjs +67 -0
  48. package/dist/legacy/firebase/discord/api/getToken.d.mts +35 -0
  49. package/dist/legacy/firebase/discord/api/getToken.mjs +63 -0
  50. package/dist/legacy/firebase/discord/api/getUser.cjs +58 -0
  51. package/dist/legacy/firebase/discord/api/getUser.d.mts +27 -0
  52. package/dist/legacy/firebase/discord/api/getUser.mjs +54 -0
  53. package/dist/legacy/firebase/discord/api/getUserConnections.cjs +57 -0
  54. package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +26 -0
  55. package/dist/legacy/firebase/discord/api/getUserConnections.mjs +53 -0
  56. package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +56 -0
  57. package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +25 -0
  58. package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +52 -0
  59. package/dist/legacy/firebase/discord/api/index.cjs +24 -0
  60. package/dist/legacy/firebase/discord/api/index.d.mts +19 -0
  61. package/dist/legacy/firebase/discord/api/index.mjs +20 -0
  62. package/dist/legacy/firebase/discord/api/refreshToken.cjs +77 -0
  63. package/dist/legacy/firebase/discord/api/refreshToken.d.mts +45 -0
  64. package/dist/legacy/firebase/discord/api/refreshToken.mjs +73 -0
  65. package/dist/legacy/firebase/discord/api/revokeToken.cjs +61 -0
  66. package/dist/legacy/firebase/discord/api/revokeToken.d.mts +29 -0
  67. package/dist/legacy/firebase/discord/api/revokeToken.mjs +58 -0
  68. package/dist/legacy/firebase/discord/config.cjs +21 -0
  69. package/dist/legacy/firebase/discord/config.d.mts +27 -0
  70. package/dist/legacy/firebase/discord/config.mjs +17 -0
  71. package/dist/legacy/firebase/discord/firebase_redirect/index.cjs +11 -0
  72. package/dist/legacy/firebase/discord/firebase_redirect/index.d.mts +7 -0
  73. package/dist/legacy/firebase/discord/firebase_redirect/index.mjs +7 -0
  74. package/dist/legacy/firebase/discord/firebase_redirect/login.cjs +110 -0
  75. package/dist/legacy/firebase/discord/firebase_redirect/login.d.mts +4 -0
  76. package/dist/legacy/firebase/discord/firebase_redirect/login.mjs +107 -0
  77. package/dist/legacy/firebase/discord/firebase_redirect/logout.cjs +100 -0
  78. package/dist/legacy/firebase/discord/firebase_redirect/logout.d.mts +4 -0
  79. package/dist/legacy/firebase/discord/firebase_redirect/logout.mjs +97 -0
  80. package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +76 -0
  81. package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +23 -0
  82. package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +67 -0
  83. package/dist/legacy/firebase/discord/get/cookie-session.cjs +32 -0
  84. package/dist/legacy/firebase/discord/get/cookie-session.d.mts +20 -0
  85. package/dist/legacy/firebase/discord/get/cookie-session.mjs +28 -0
  86. package/dist/legacy/firebase/discord/get/credentials.cjs +24 -0
  87. package/dist/legacy/firebase/discord/get/credentials.d.mts +19 -0
  88. package/dist/legacy/firebase/discord/get/credentials.mjs +20 -0
  89. package/dist/legacy/firebase/discord/get/errorValidator.cjs +60 -0
  90. package/dist/legacy/firebase/discord/get/errorValidator.d.mts +28 -0
  91. package/dist/legacy/firebase/discord/get/errorValidator.mjs +55 -0
  92. package/dist/legacy/firebase/discord/get/index.cjs +17 -0
  93. package/dist/legacy/firebase/discord/get/index.d.mts +13 -0
  94. package/dist/legacy/firebase/discord/get/index.mjs +13 -0
  95. package/dist/legacy/firebase/discord/get/randomAvatar.cjs +37 -0
  96. package/dist/legacy/firebase/discord/get/randomAvatar.d.mts +22 -0
  97. package/dist/legacy/firebase/discord/get/randomAvatar.mjs +30 -0
  98. package/dist/legacy/firebase/discord/http/index.cjs +15 -0
  99. package/dist/legacy/firebase/discord/http/index.d.mts +11 -0
  100. package/dist/legacy/firebase/discord/http/index.mjs +11 -0
  101. package/dist/legacy/firebase/discord/http/login.cjs +127 -0
  102. package/dist/legacy/firebase/discord/http/login.d.mts +21 -0
  103. package/dist/legacy/firebase/discord/http/login.mjs +123 -0
  104. package/dist/legacy/firebase/discord/http/logout.cjs +155 -0
  105. package/dist/legacy/firebase/discord/http/logout.d.mts +22 -0
  106. package/dist/legacy/firebase/discord/http/logout.mjs +143 -0
  107. package/dist/legacy/firebase/discord/http/redirect.cjs +188 -0
  108. package/dist/legacy/firebase/discord/http/redirect.d.mts +24 -0
  109. package/dist/legacy/firebase/discord/http/redirect.mjs +178 -0
  110. package/dist/legacy/firebase/discord/http/refreshToken.cjs +133 -0
  111. package/dist/legacy/firebase/discord/http/refreshToken.d.mts +24 -0
  112. package/dist/legacy/firebase/discord/http/refreshToken.mjs +121 -0
  113. package/dist/legacy/firebase/discord/index.cjs +19 -0
  114. package/dist/legacy/firebase/discord/index.d.mts +15 -0
  115. package/dist/legacy/firebase/discord/index.mjs +15 -0
  116. package/dist/legacy/firebase/discord/template/cookie-session.cjs +1430 -0
  117. package/dist/legacy/firebase/discord/template/cookie-session.d.mts +22 -0
  118. package/dist/legacy/firebase/discord/template/cookie-session.mjs +1159 -0
  119. package/dist/legacy/firebase/domainRedirect.cjs +35 -0
  120. package/dist/legacy/firebase/domainRedirect.d.mts +12 -0
  121. package/dist/legacy/firebase/domainRedirect.mjs +27 -0
  122. package/dist/legacy/firebase/escape.cjs +75 -0
  123. package/dist/legacy/firebase/escape.d.mts +17 -0
  124. package/dist/legacy/firebase/escape.mjs +58 -0
  125. package/dist/legacy/firebase/getDBAsync.cjs +33 -0
  126. package/dist/legacy/firebase/getDBAsync.d.mts +10 -0
  127. package/dist/legacy/firebase/getDBAsync.mjs +26 -0
  128. package/dist/legacy/firebase/getDBData.cjs +21 -0
  129. package/dist/legacy/firebase/getDBData.d.mts +1 -0
  130. package/dist/legacy/firebase/getDBData.mjs +17 -0
  131. package/dist/legacy/firebase/getDBValue.cjs +17 -0
  132. package/dist/legacy/firebase/getDBValue.d.mts +9 -0
  133. package/dist/legacy/firebase/getDBValue.mjs +14 -0
  134. package/dist/legacy/firebase/index.cjs +261 -0
  135. package/dist/legacy/firebase/index.d.mts +51 -0
  136. package/dist/legacy/firebase/index.mjs +234 -0
  137. package/dist/legacy/firebase/isEmulator.cjs +14 -0
  138. package/dist/legacy/firebase/isEmulator.d.mts +8 -0
  139. package/dist/legacy/firebase/isEmulator.mjs +10 -0
  140. package/dist/legacy/firebase/logger.cjs +137 -0
  141. package/dist/legacy/firebase/logger.d.mts +7 -0
  142. package/dist/legacy/firebase/logger.mjs +125 -0
  143. package/dist/legacy/firebase/mySQL.cjs +26 -0
  144. package/dist/legacy/firebase/mySQL.d.mts +10 -0
  145. package/dist/legacy/firebase/mySQL.mjs +22 -0
  146. package/dist/legacy/firebase/mysqlConnector/create.cjs +119 -0
  147. package/dist/legacy/firebase/mysqlConnector/create.d.mts +36 -0
  148. package/dist/legacy/firebase/mysqlConnector/create.mjs +109 -0
  149. package/dist/legacy/firebase/mysqlConnector/index.cjs +23 -0
  150. package/dist/legacy/firebase/mysqlConnector/index.d.mts +11 -0
  151. package/dist/legacy/firebase/mysqlConnector/index.mjs +16 -0
  152. package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +75 -0
  153. package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +31 -0
  154. package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +63 -0
  155. package/dist/legacy/firebase/mysqlConnector/pagination.cjs +91 -0
  156. package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +33 -0
  157. package/dist/legacy/firebase/mysqlConnector/pagination.mjs +87 -0
  158. package/dist/legacy/firebase/mysqlConnector/sameUser.cjs +28 -0
  159. package/dist/legacy/firebase/mysqlConnector/sameUser.d.mts +12 -0
  160. package/dist/legacy/firebase/mysqlConnector/sameUser.mjs +23 -0
  161. package/dist/legacy/firebase/transactionDBAsync.cjs +33 -0
  162. package/dist/legacy/firebase/transactionDBAsync.d.mts +11 -0
  163. package/dist/legacy/firebase/transactionDBAsync.mjs +27 -0
  164. package/dist/legacy/get/countObj.cjs +24 -0
  165. package/dist/legacy/get/countObj.d.mts +11 -0
  166. package/dist/legacy/get/countObj.mjs +21 -0
  167. package/dist/legacy/get/decimalColor.cjs +60 -0
  168. package/dist/legacy/get/decimalColor.d.mts +12 -0
  169. package/dist/legacy/get/decimalColor.mjs +54 -0
  170. package/dist/legacy/get/objType.cjs +43 -0
  171. package/dist/legacy/get/objType.d.mts +19 -0
  172. package/dist/legacy/get/objType.mjs +40 -0
  173. package/dist/legacy/get/pagination.cjs +100 -0
  174. package/dist/legacy/get/pagination.d.mts +25 -0
  175. package/dist/legacy/get/pagination.mjs +91 -0
  176. package/dist/legacy/get/queryUrlByName.cjs +31 -0
  177. package/dist/legacy/get/queryUrlByName.d.mts +20 -0
  178. package/dist/legacy/get/queryUrlByName.mjs +28 -0
  179. package/dist/legacy/get/queryUrlJSON.cjs +54 -0
  180. package/dist/legacy/get/queryUrlJSON.d.mts +23 -0
  181. package/dist/legacy/get/queryUrlJSON.mjs +57 -0
  182. package/dist/legacy/get/super_string_filter.cjs +97 -0
  183. package/dist/legacy/get/super_string_filter.d.mts +25 -0
  184. package/dist/legacy/get/super_string_filter.mjs +83 -0
  185. package/dist/legacy/get/versionCheck.cjs +49 -0
  186. package/dist/legacy/get/versionCheck.d.mts +17 -0
  187. package/dist/legacy/get/versionCheck.mjs +38 -0
  188. package/dist/legacy/http/HTTP-1.0.cjs +151 -0
  189. package/dist/legacy/http/HTTP-1.0.d.mts +8 -0
  190. package/dist/legacy/http/HTTP-1.0.mjs +136 -0
  191. package/dist/legacy/http/auth.cjs +70 -0
  192. package/dist/legacy/http/auth.d.mts +41 -0
  193. package/dist/legacy/http/auth.mjs +63 -0
  194. package/dist/legacy/http/check_domain.cjs +84 -0
  195. package/dist/legacy/http/check_domain.d.mts +10 -0
  196. package/dist/legacy/http/check_domain.mjs +82 -0
  197. package/dist/legacy/http/csrfTokenAnalyze.cjs +46 -0
  198. package/dist/legacy/http/csrfTokenAnalyze.d.mts +21 -0
  199. package/dist/legacy/http/csrfTokenAnalyze.mjs +40 -0
  200. package/dist/legacy/http/domainValidator.cjs +98 -0
  201. package/dist/legacy/http/domainValidator.d.mts +30 -0
  202. package/dist/legacy/http/domainValidator.mjs +82 -0
  203. package/dist/legacy/http/errorsCallback.cjs +55 -0
  204. package/dist/legacy/http/errorsCallback.d.mts +29 -0
  205. package/dist/legacy/http/errorsCallback.mjs +48 -0
  206. package/dist/legacy/http/fetch/json.cjs +48 -0
  207. package/dist/legacy/http/fetch/json.d.mts +22 -0
  208. package/dist/legacy/http/fetch/json.mjs +41 -0
  209. package/dist/legacy/http/fetch/text.cjs +47 -0
  210. package/dist/legacy/http/fetch/text.d.mts +21 -0
  211. package/dist/legacy/http/fetch/text.mjs +40 -0
  212. package/dist/legacy/http/fileCache.cjs +79 -0
  213. package/dist/legacy/http/fileCache.d.mts +35 -0
  214. package/dist/legacy/http/fileCache.mjs +70 -0
  215. package/dist/legacy/http/getDomainURL.cjs +59 -0
  216. package/dist/legacy/http/getDomainURL.d.mts +18 -0
  217. package/dist/legacy/http/getDomainURL.mjs +54 -0
  218. package/dist/legacy/http/userIP.cjs +59 -0
  219. package/dist/legacy/http/userIP.d.mts +21 -0
  220. package/dist/legacy/http/userIP.mjs +48 -0
  221. package/dist/legacy/index.cjs +122 -0
  222. package/dist/legacy/index.d.mts +89 -0
  223. package/dist/legacy/index.mjs +92 -0
  224. package/dist/legacy/libs/arraySortPositions.cjs +30 -0
  225. package/dist/legacy/libs/arraySortPositions.d.mts +16 -0
  226. package/dist/legacy/libs/arraySortPositions.mjs +27 -0
  227. package/dist/legacy/libs/capitalize.cjs +21 -0
  228. package/dist/legacy/libs/capitalize.d.mts +13 -0
  229. package/dist/legacy/libs/capitalize.mjs +17 -0
  230. package/dist/legacy/libs/convertBytes.cjs +64 -0
  231. package/dist/legacy/libs/convertBytes.d.mts +17 -0
  232. package/dist/legacy/libs/convertBytes.mjs +55 -0
  233. package/dist/legacy/libs/custom_module_loader.cjs +82 -0
  234. package/dist/legacy/libs/custom_module_loader.d.mts +5 -0
  235. package/dist/legacy/libs/custom_module_loader.mjs +79 -0
  236. package/dist/legacy/libs/dice.cjs +35 -0
  237. package/dist/legacy/libs/dice.d.mts +5 -0
  238. package/dist/legacy/libs/dice.mjs +31 -0
  239. package/dist/legacy/libs/markdown.cjs +85 -0
  240. package/dist/legacy/libs/markdown.d.mts +75 -0
  241. package/dist/legacy/libs/markdown.mjs +78 -0
  242. package/dist/legacy/libs/percentage.cjs +22 -0
  243. package/dist/legacy/libs/percentage.d.mts +4 -0
  244. package/dist/legacy/libs/percentage.mjs +19 -0
  245. package/dist/legacy/libs/regex/getLetter.cjs +22 -0
  246. package/dist/legacy/libs/regex/getLetter.d.mts +12 -0
  247. package/dist/legacy/libs/regex/getLetter.mjs +19 -0
  248. package/dist/legacy/libs/replaceAsync.cjs +32 -0
  249. package/dist/legacy/libs/replaceAsync.d.mts +15 -0
  250. package/dist/legacy/libs/replaceAsync.mjs +25 -0
  251. package/dist/legacy/libs/rule3.cjs +58 -0
  252. package/dist/legacy/libs/rule3.d.mts +5 -0
  253. package/dist/legacy/libs/rule3.mjs +54 -0
  254. package/dist/legacy/libs/userLevel.cjs +134 -0
  255. package/dist/legacy/libs/userLevel.d.mts +69 -0
  256. package/dist/legacy/libs/userLevel.mjs +123 -0
  257. package/dist/legacy/momentjs/getAge.cjs +28 -0
  258. package/dist/legacy/momentjs/getAge.d.mts +8 -0
  259. package/dist/legacy/momentjs/getAge.mjs +22 -0
  260. package/dist/legacy/momentjs/index.cjs +9 -0
  261. package/dist/legacy/momentjs/index.d.mts +3 -0
  262. package/dist/legacy/momentjs/index.mjs +3 -0
  263. package/dist/legacy/momentjs/timeDuration.cjs +29 -0
  264. package/dist/legacy/momentjs/timeDuration.d.mts +9 -0
  265. package/dist/legacy/momentjs/timeDuration.mjs +23 -0
  266. package/dist/legacy/socket.io/antiFlood/index.cjs +9 -0
  267. package/dist/legacy/socket.io/antiFlood/index.d.mts +3 -0
  268. package/dist/legacy/socket.io/antiFlood/index.mjs +3 -0
  269. package/dist/legacy/socket.io/antiFlood/install.cjs +32 -0
  270. package/dist/legacy/socket.io/antiFlood/install.d.mts +14 -0
  271. package/dist/legacy/socket.io/antiFlood/install.mjs +27 -0
  272. package/dist/legacy/socket.io/antiFlood/verify.cjs +87 -0
  273. package/dist/legacy/socket.io/antiFlood/verify.d.mts +15 -0
  274. package/dist/legacy/socket.io/antiFlood/verify.mjs +73 -0
  275. package/dist/legacy/socket.io/cookie-session.cjs +25 -0
  276. package/dist/legacy/socket.io/cookie-session.d.mts +9 -0
  277. package/dist/legacy/socket.io/cookie-session.mjs +20 -0
  278. package/dist/legacy/socket.io/discord.cjs +61 -0
  279. package/dist/legacy/socket.io/discord.d.mts +10 -0
  280. package/dist/legacy/socket.io/discord.mjs +52 -0
  281. package/dist/legacy/socket.io/index.cjs +13 -0
  282. package/dist/legacy/socket.io/index.d.mts +9 -0
  283. package/dist/legacy/socket.io/index.mjs +9 -0
  284. package/dist/v1/basics/array.cjs +31 -0
  285. package/dist/v1/basics/array.d.mts +10 -0
  286. package/dist/v1/basics/array.mjs +22 -0
  287. package/dist/v1/basics/clock.cjs +187 -0
  288. package/dist/v1/basics/clock.d.mts +37 -0
  289. package/dist/v1/basics/clock.mjs +152 -0
  290. package/dist/v1/basics/objFilter.cjs +55 -0
  291. package/dist/v1/basics/objFilter.d.mts +27 -0
  292. package/dist/v1/basics/objFilter.mjs +52 -0
  293. package/dist/v1/basics/simpleMath.cjs +88 -0
  294. package/dist/v1/basics/simpleMath.d.mts +54 -0
  295. package/dist/v1/basics/simpleMath.mjs +75 -0
  296. package/dist/v1/basics/text.cjs +34 -0
  297. package/dist/v1/basics/text.d.mts +20 -0
  298. package/dist/v1/basics/text.mjs +25 -0
  299. package/dist/v1/index.cjs +26 -0
  300. package/dist/v1/index.d.mts +15 -0
  301. package/dist/v1/index.mjs +8 -0
  302. package/package.json +72 -0
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Initializes and caches one or more MySQL database connections using provided configuration.
5
+ * Supports Firebase and Google Cloud SQL socket-based connections, as well as local/standard MySQL setups.
6
+ *
7
+ * @async
8
+ * @param {Object} mysql - The `mysql2` module or similar instance, with a `.createPool()` method.
9
+ * @param {string} proxyType - The type of proxy connection. Can be `"default"`, `"firebase"`, or `"google_cloud"`.
10
+ * @param {Object|Object[]} databases - A single database config object or an array of config objects.
11
+ * @param {Object} cfg - Global fallback configuration, e.g., `{ charset: 'utf8mb4' }`.
12
+ *
13
+ * @returns {Promise<Object>} Resolves with a single connection object if one database is provided,
14
+ * or a map of database names to connections if multiple databases are configured.
15
+ *
16
+ * @throws {Error} Will reject if any database config is invalid or if the proxyType is unsupported.
17
+ *
18
+ * @example
19
+ * const connection = await create(mysql, 'default', {
20
+ * data: { database: 'my_db', user: 'root', password: 'pass', host: 'localhost', port: 3306 },
21
+ * default: { host: 'localhost', port: 3306 },
22
+ * });
23
+ *
24
+ * @example
25
+ * const connections = await create(mysql, 'google_cloud', [
26
+ * {
27
+ * data: { database: 'db1', user: 'user', password: 'pass' },
28
+ * google_cloud: { socketPath: '/cloudsql/project:region:instance' },
29
+ * default: { host: 'localhost', port: 3306 },
30
+ * },
31
+ * {
32
+ * data: { database: 'db2', user: 'user', password: 'pass' },
33
+ * google_cloud: { socketPath: '/cloudsql/project:region:instance2' },
34
+ * default: { host: 'localhost', port: 3306 },
35
+ * }
36
+ * ]);
37
+ */
38
+ function create(mysql, proxyType, databases, cfg) {
39
+ return new Promise(function (resolve, reject) {
40
+ let databaseList = [];
41
+
42
+ // Create Settings
43
+ const tinyCfg = _.defaultsDeep({}, cfg, {
44
+ charset: 'utf8mb4',
45
+ });
46
+
47
+ // Convert
48
+ if (!Array.isArray(databases)) databaseList = [clone(databases)];
49
+ else databaseList = clone(databases);
50
+
51
+ // Run Array
52
+ for (const item in databaseList) {
53
+ // Exist
54
+ if (objType(databaseList[item], 'object') && objType(databaseList[item].data, 'object')) {
55
+ if (!db[databaseList[item].data.database]) {
56
+ // Charset
57
+ if (typeof databaseList[item].data.charset !== 'string')
58
+ databaseList[item].data.charset = tinyCfg.charset;
59
+
60
+ // Firebase Is Emulator
61
+ let firebaseIsEmulator = false;
62
+ if (proxyType === 'firebase') {
63
+ try {
64
+ firebaseIsEmulator = isEmulator();
65
+ } catch (err) {
66
+ firebaseIsEmulator = false;
67
+ }
68
+ }
69
+
70
+ // Exist Proxy
71
+ if (!firebaseIsEmulator && typeof proxyType === 'string' && proxyType !== 'default') {
72
+ // Google Cloud
73
+ if (
74
+ (proxyType === 'firebase' || proxyType === 'google_cloud') &&
75
+ objType(databaseList[item].google_cloud, 'object') &&
76
+ typeof databaseList[item].google_cloud.socketPath === 'string'
77
+ ) {
78
+ // Insert the config
79
+ databaseList[item].data.socketPath = databaseList[item].google_cloud.socketPath;
80
+ } else reject(new Error('Invalid Proxy Type! Index:' + item));
81
+ }
82
+
83
+ // Normal Connection
84
+ else {
85
+ // SSL Files
86
+ if (objType(databaseList[item].default.ssl, 'object'))
87
+ databaseList[item].data.ssl = databaseList[item].default.ssl;
88
+
89
+ // Host and Port
90
+ databaseList[item].data.host = databaseList[item].default.host;
91
+ databaseList[item].data.port = databaseList[item].default.port;
92
+ }
93
+
94
+ // Create DB Connection
95
+ try {
96
+ db[databaseList[item].data.database] = mysql.createPool(databaseList[item].data);
97
+ db[databaseList[item].data.database].query = util.promisify(
98
+ db[databaseList[item].data.database].query,
99
+ );
100
+ } catch (err) {
101
+ reject(err);
102
+ }
103
+ }
104
+ }
105
+
106
+ // Nope
107
+ else reject(new Error('Invalid MySQL Setting! Index:' + item));
108
+ }
109
+
110
+ // Fix
111
+ const dbKets = Object.keys(databaseList);
112
+
113
+ // Complete
114
+ if (dbKets.length < 2) resolve(db[databaseList[0].data.database]);
115
+ else resolve(db);
116
+ });
117
+ }
118
+
119
+ module.exports = create;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Initializes and caches one or more MySQL database connections using provided configuration.
3
+ * Supports Firebase and Google Cloud SQL socket-based connections, as well as local/standard MySQL setups.
4
+ *
5
+ * @async
6
+ * @param {Object} mysql - The `mysql2` module or similar instance, with a `.createPool()` method.
7
+ * @param {string} proxyType - The type of proxy connection. Can be `"default"`, `"firebase"`, or `"google_cloud"`.
8
+ * @param {Object|Object[]} databases - A single database config object or an array of config objects.
9
+ * @param {Object} cfg - Global fallback configuration, e.g., `{ charset: 'utf8mb4' }`.
10
+ *
11
+ * @returns {Promise<Object>} Resolves with a single connection object if one database is provided,
12
+ * or a map of database names to connections if multiple databases are configured.
13
+ *
14
+ * @throws {Error} Will reject if any database config is invalid or if the proxyType is unsupported.
15
+ *
16
+ * @example
17
+ * const connection = await create(mysql, 'default', {
18
+ * data: { database: 'my_db', user: 'root', password: 'pass', host: 'localhost', port: 3306 },
19
+ * default: { host: 'localhost', port: 3306 },
20
+ * });
21
+ *
22
+ * @example
23
+ * const connections = await create(mysql, 'google_cloud', [
24
+ * {
25
+ * data: { database: 'db1', user: 'user', password: 'pass' },
26
+ * google_cloud: { socketPath: '/cloudsql/project:region:instance' },
27
+ * default: { host: 'localhost', port: 3306 },
28
+ * },
29
+ * {
30
+ * data: { database: 'db2', user: 'user', password: 'pass' },
31
+ * google_cloud: { socketPath: '/cloudsql/project:region:instance2' },
32
+ * default: { host: 'localhost', port: 3306 },
33
+ * }
34
+ * ]);
35
+ */
36
+ export default function create(mysql: Object, proxyType: string, databases: Object | Object[], cfg: Object): Promise<Object>;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Initializes and caches one or more MySQL database connections using provided configuration.
3
+ * Supports Firebase and Google Cloud SQL socket-based connections, as well as local/standard MySQL setups.
4
+ *
5
+ * @async
6
+ * @param {Object} mysql - The `mysql2` module or similar instance, with a `.createPool()` method.
7
+ * @param {string} proxyType - The type of proxy connection. Can be `"default"`, `"firebase"`, or `"google_cloud"`.
8
+ * @param {Object|Object[]} databases - A single database config object or an array of config objects.
9
+ * @param {Object} cfg - Global fallback configuration, e.g., `{ charset: 'utf8mb4' }`.
10
+ *
11
+ * @returns {Promise<Object>} Resolves with a single connection object if one database is provided,
12
+ * or a map of database names to connections if multiple databases are configured.
13
+ *
14
+ * @throws {Error} Will reject if any database config is invalid or if the proxyType is unsupported.
15
+ *
16
+ * @example
17
+ * const connection = await create(mysql, 'default', {
18
+ * data: { database: 'my_db', user: 'root', password: 'pass', host: 'localhost', port: 3306 },
19
+ * default: { host: 'localhost', port: 3306 },
20
+ * });
21
+ *
22
+ * @example
23
+ * const connections = await create(mysql, 'google_cloud', [
24
+ * {
25
+ * data: { database: 'db1', user: 'user', password: 'pass' },
26
+ * google_cloud: { socketPath: '/cloudsql/project:region:instance' },
27
+ * default: { host: 'localhost', port: 3306 },
28
+ * },
29
+ * {
30
+ * data: { database: 'db2', user: 'user', password: 'pass' },
31
+ * google_cloud: { socketPath: '/cloudsql/project:region:instance2' },
32
+ * default: { host: 'localhost', port: 3306 },
33
+ * }
34
+ * ]);
35
+ */
36
+ export default function create(mysql, proxyType, databases, cfg) {
37
+ return new Promise(function (resolve, reject) {
38
+ let databaseList = [];
39
+ // Create Settings
40
+ const tinyCfg = _.defaultsDeep({}, cfg, {
41
+ charset: 'utf8mb4',
42
+ });
43
+ // Convert
44
+ if (!Array.isArray(databases))
45
+ databaseList = [clone(databases)];
46
+ else
47
+ databaseList = clone(databases);
48
+ // Run Array
49
+ for (const item in databaseList) {
50
+ // Exist
51
+ if (objType(databaseList[item], 'object') && objType(databaseList[item].data, 'object')) {
52
+ if (!db[databaseList[item].data.database]) {
53
+ // Charset
54
+ if (typeof databaseList[item].data.charset !== 'string')
55
+ databaseList[item].data.charset = tinyCfg.charset;
56
+ // Firebase Is Emulator
57
+ let firebaseIsEmulator = false;
58
+ if (proxyType === 'firebase') {
59
+ try {
60
+ firebaseIsEmulator = isEmulator();
61
+ }
62
+ catch (err) {
63
+ firebaseIsEmulator = false;
64
+ }
65
+ }
66
+ // Exist Proxy
67
+ if (!firebaseIsEmulator && typeof proxyType === 'string' && proxyType !== 'default') {
68
+ // Google Cloud
69
+ if ((proxyType === 'firebase' || proxyType === 'google_cloud') &&
70
+ objType(databaseList[item].google_cloud, 'object') &&
71
+ typeof databaseList[item].google_cloud.socketPath === 'string') {
72
+ // Insert the config
73
+ databaseList[item].data.socketPath = databaseList[item].google_cloud.socketPath;
74
+ }
75
+ else
76
+ reject(new Error('Invalid Proxy Type! Index:' + item));
77
+ }
78
+ // Normal Connection
79
+ else {
80
+ // SSL Files
81
+ if (objType(databaseList[item].default.ssl, 'object'))
82
+ databaseList[item].data.ssl = databaseList[item].default.ssl;
83
+ // Host and Port
84
+ databaseList[item].data.host = databaseList[item].default.host;
85
+ databaseList[item].data.port = databaseList[item].default.port;
86
+ }
87
+ // Create DB Connection
88
+ try {
89
+ db[databaseList[item].data.database] = mysql.createPool(databaseList[item].data);
90
+ db[databaseList[item].data.database].query = util.promisify(db[databaseList[item].data.database].query);
91
+ }
92
+ catch (err) {
93
+ reject(err);
94
+ }
95
+ }
96
+ }
97
+ // Nope
98
+ else
99
+ reject(new Error('Invalid MySQL Setting! Index:' + item));
100
+ }
101
+ // Fix
102
+ const dbKets = Object.keys(databaseList);
103
+ // Complete
104
+ if (dbKets.length < 2)
105
+ resolve(db[databaseList[0].data.database]);
106
+ else
107
+ resolve(db);
108
+ });
109
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var create = require('./create.cjs');
4
+ var nextPrev = require('./nextPrev.cjs');
5
+ var pagination = require('./pagination.cjs');
6
+ var sameUser = require('./sameUser.cjs');
7
+
8
+ // Modules
9
+ const mysqlConnector = {
10
+ // Next and Prev
11
+ nextPrev,
12
+
13
+ // Pagination
14
+ pagination,
15
+
16
+ // Same User Generator
17
+ sameUser,
18
+
19
+ // Create DB Value
20
+ create,
21
+ };
22
+
23
+ module.exports = mysqlConnector;
@@ -0,0 +1,11 @@
1
+ export default mysqlConnector;
2
+ declare namespace mysqlConnector {
3
+ export { nextPrev };
4
+ export { pagination };
5
+ export { sameUser };
6
+ export { create };
7
+ }
8
+ import nextPrev from './nextPrev.mjs';
9
+ import pagination from './pagination.mjs';
10
+ import sameUser from './sameUser.mjs';
11
+ import create from './create.mjs';
@@ -0,0 +1,16 @@
1
+ import create from './create.mjs';
2
+ import nextPrev from './nextPrev.mjs';
3
+ import pagination from './pagination.mjs';
4
+ import sameUser from './sameUser.mjs';
5
+ // Modules
6
+ const mysqlConnector = {
7
+ // Next and Prev
8
+ nextPrev,
9
+ // Pagination
10
+ pagination,
11
+ // Same User Generator
12
+ sameUser,
13
+ // Create DB Value
14
+ create,
15
+ };
16
+ export default mysqlConnector;
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Executes a directional query (next or previous) based on a position value and timestamp, returning a single row.
5
+ *
6
+ * @async
7
+ * @param {Object} db - The database instance with a `.query(sql, params)` method.
8
+ * @param {Object} tiny_search - Configuration object for the query.
9
+ * @param {string} tiny_search.select - SQL SELECT fields.
10
+ * @param {string} tiny_search.from - SQL FROM clause.
11
+ * @param {string} [tiny_search.where] - Optional WHERE clause (without 'WHERE') to filter results.
12
+ * @param {Array} tiny_search.params - Parameters for the query placeholders.
13
+ * @param {*} tiny_search.position - Value to compare in the directional filter (typically an ID or timestamp).
14
+ * @param {boolean} [tiny_search.direction_r=false] - If `true`, selects previous record (uses `<`), otherwise selects next (`>`).
15
+ * @param {Object} tiny_search.database - Object with database structure details.
16
+ * @param {string} tiny_search.database.name - The table name or alias used in the query.
17
+ * @param {string} tiny_search.database.timeVar - Column name used for ordering chronologically (e.g., `"created_at"`).
18
+ * @param {string} tiny_search.database.positionVar - Column name used for the directional condition (e.g., `"id"`).
19
+ * @returns {Promise<Object|null>} Resolves with the selected row or `null` if none is found.
20
+ */
21
+ async function nextPrev(db, tiny_search) {
22
+ // Validate Database
23
+ if (
24
+ tiny_search.database &&
25
+ typeof tiny_search.database.name === 'string' &&
26
+ typeof tiny_search.database.timeVar === 'string' &&
27
+ typeof tiny_search.database.positionVar === 'string'
28
+ ) {
29
+ // Prepare Tiny Search
30
+ if (tiny_search.where) tiny_search.where += ' AND ';
31
+ tiny_search.params.push(tiny_search.position);
32
+
33
+ // Select Direction
34
+ let tiny_direction = '';
35
+ let tiny_order = '';
36
+ if (tiny_search.direction_r) {
37
+ tiny_direction = '<';
38
+ tiny_order = `${tiny_search.database.name}.${tiny_search.database.timeVar} DESC`;
39
+ } else {
40
+ tiny_direction = '>';
41
+ tiny_order = `${tiny_search.database.name}.${tiny_search.database.timeVar}`;
42
+ }
43
+
44
+ // Select Config
45
+ const existData = await db.query(
46
+ `SELECT ${tiny_search.select} FROM ${tiny_search.from}
47
+ WHERE ${tiny_search.where}${tiny_search.database.name}.${tiny_search.database.positionVar} ${tiny_direction} ? ORDER BY ${tiny_order} LIMIT 1`,
48
+ tiny_search.params,
49
+ );
50
+
51
+ // Exist Data
52
+ if (existData.length > 0) return existData[0];
53
+ else {
54
+ // Fix Where
55
+ if (tiny_search.where)
56
+ tiny_search.where = 'WHERE ' + tiny_search.where.substring(0, tiny_search.where.length - 5);
57
+
58
+ // Select Config
59
+ const existData2 = await db.query(
60
+ `SELECT ${tiny_search.select} FROM ${tiny_search.from}
61
+ ${tiny_search.where} ORDER BY ${tiny_order} LIMIT 1`,
62
+ tiny_search.params,
63
+ );
64
+
65
+ // Exist Data
66
+ if (existData2.length > 0) return existData2[0];
67
+ else return null;
68
+ }
69
+ }
70
+
71
+ // Nope
72
+ else return null;
73
+ }
74
+
75
+ module.exports = nextPrev;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Executes a directional query (next or previous) based on a position value and timestamp, returning a single row.
3
+ *
4
+ * @async
5
+ * @param {Object} db - The database instance with a `.query(sql, params)` method.
6
+ * @param {Object} tiny_search - Configuration object for the query.
7
+ * @param {string} tiny_search.select - SQL SELECT fields.
8
+ * @param {string} tiny_search.from - SQL FROM clause.
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.
11
+ * @param {*} tiny_search.position - Value to compare in the directional filter (typically an ID or timestamp).
12
+ * @param {boolean} [tiny_search.direction_r=false] - If `true`, selects previous record (uses `<`), otherwise selects next (`>`).
13
+ * @param {Object} tiny_search.database - Object with database structure details.
14
+ * @param {string} tiny_search.database.name - The table name or alias used in the query.
15
+ * @param {string} tiny_search.database.timeVar - Column name used for ordering chronologically (e.g., `"created_at"`).
16
+ * @param {string} tiny_search.database.positionVar - Column name used for the directional condition (e.g., `"id"`).
17
+ * @returns {Promise<Object|null>} Resolves with the selected row or `null` if none is found.
18
+ */
19
+ export default function nextPrev(db: Object, tiny_search: {
20
+ select: string;
21
+ from: string;
22
+ where?: string | undefined;
23
+ params: any[];
24
+ position: any;
25
+ direction_r?: boolean | undefined;
26
+ database: {
27
+ name: string;
28
+ timeVar: string;
29
+ positionVar: string;
30
+ };
31
+ }): Promise<Object | null>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Executes a directional query (next or previous) based on a position value and timestamp, returning a single row.
3
+ *
4
+ * @async
5
+ * @param {Object} db - The database instance with a `.query(sql, params)` method.
6
+ * @param {Object} tiny_search - Configuration object for the query.
7
+ * @param {string} tiny_search.select - SQL SELECT fields.
8
+ * @param {string} tiny_search.from - SQL FROM clause.
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.
11
+ * @param {*} tiny_search.position - Value to compare in the directional filter (typically an ID or timestamp).
12
+ * @param {boolean} [tiny_search.direction_r=false] - If `true`, selects previous record (uses `<`), otherwise selects next (`>`).
13
+ * @param {Object} tiny_search.database - Object with database structure details.
14
+ * @param {string} tiny_search.database.name - The table name or alias used in the query.
15
+ * @param {string} tiny_search.database.timeVar - Column name used for ordering chronologically (e.g., `"created_at"`).
16
+ * @param {string} tiny_search.database.positionVar - Column name used for the directional condition (e.g., `"id"`).
17
+ * @returns {Promise<Object|null>} Resolves with the selected row or `null` if none is found.
18
+ */
19
+ export default async function nextPrev(db, tiny_search) {
20
+ // Validate Database
21
+ if (tiny_search.database &&
22
+ typeof tiny_search.database.name === 'string' &&
23
+ typeof tiny_search.database.timeVar === 'string' &&
24
+ typeof tiny_search.database.positionVar === 'string') {
25
+ // Prepare Tiny Search
26
+ if (tiny_search.where)
27
+ tiny_search.where += ' AND ';
28
+ tiny_search.params.push(tiny_search.position);
29
+ // Select Direction
30
+ let tiny_direction = '';
31
+ let tiny_order = '';
32
+ if (tiny_search.direction_r) {
33
+ tiny_direction = '<';
34
+ tiny_order = `${tiny_search.database.name}.${tiny_search.database.timeVar} DESC`;
35
+ }
36
+ else {
37
+ tiny_direction = '>';
38
+ tiny_order = `${tiny_search.database.name}.${tiny_search.database.timeVar}`;
39
+ }
40
+ // Select Config
41
+ const existData = await db.query(`SELECT ${tiny_search.select} FROM ${tiny_search.from}
42
+ WHERE ${tiny_search.where}${tiny_search.database.name}.${tiny_search.database.positionVar} ${tiny_direction} ? ORDER BY ${tiny_order} LIMIT 1`, tiny_search.params);
43
+ // Exist Data
44
+ if (existData.length > 0)
45
+ return existData[0];
46
+ else {
47
+ // Fix Where
48
+ if (tiny_search.where)
49
+ tiny_search.where = 'WHERE ' + tiny_search.where.substring(0, tiny_search.where.length - 5);
50
+ // Select Config
51
+ const existData2 = await db.query(`SELECT ${tiny_search.select} FROM ${tiny_search.from}
52
+ ${tiny_search.where} ORDER BY ${tiny_order} LIMIT 1`, tiny_search.params);
53
+ // Exist Data
54
+ if (existData2.length > 0)
55
+ return existData2[0];
56
+ else
57
+ return null;
58
+ }
59
+ }
60
+ // Nope
61
+ else
62
+ return null;
63
+ }
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Executes a paginated query on the database, returning the result set along with pagination metadata.
5
+ *
6
+ * @async
7
+ * @param {Object} db - Database instance with a `.query(sql, params)` method.
8
+ * @param {Object} data - Query configuration options.
9
+ * @param {string} data.from - The table or view name to query from.
10
+ * @param {string} [data.where] - Optional WHERE clause without the keyword (e.g., `"status = 'active'"`).
11
+ * @param {Array} [data.params] - Optional parameters for the SQL query placeholders.
12
+ * @param {string} [data.select="*"] - Fields to select in the query.
13
+ * @param {string} data.order - SQL ORDER BY clause (e.g., `"created_at DESC"`).
14
+ * @param {number} [data.limit] - Number of rows per page.
15
+ * @param {number|string} [data.page] - Current page number or `'last'` to get the last page.
16
+ * @param {number} [data.count] - Optional total count override (skip count query if provided).
17
+ * @param {boolean} [data.count_rows=false] - Whether to include a row number for each result.
18
+ * @returns {Promise<Object>} Resolves with pagination metadata and result set.
19
+ * @returns {number} return.count - Total number of matched rows.
20
+ * @returns {Array} return.data - The paginated data from the query.
21
+ * @returns {number} return.pages - Total number of pages.
22
+ * @returns {number} return.page - Current page number after validation.
23
+ * @returns {number} return.start - Row offset used in the query.
24
+ */
25
+ async function pagination(db, data) {
26
+ // Create Where
27
+ if (data.where) data.where = ' WHERE ' + data.where;
28
+ else data.where = '';
29
+
30
+ // Values
31
+ let start = 0;
32
+ let page;
33
+ let pages;
34
+ let edit_count;
35
+
36
+ if (typeof data.page === 'number') {
37
+ // Get Count
38
+ if (!data.count) {
39
+ edit_count = await db.query(`SELECT COUNT(*) FROM ${data.from}${data.where}`, data.params);
40
+ edit_count = edit_count[0]['COUNT(*)'];
41
+ } else edit_count = data.count;
42
+
43
+ // Prepare Numbers
44
+ pages = Math.ceil(edit_count / data.limit);
45
+
46
+ // Default
47
+ page = data.page;
48
+
49
+ // Is Last
50
+ if (page === 'last') page = pages;
51
+ // is NaN
52
+ else if (isNaN(page)) page = 1;
53
+ // Bigger
54
+ else if (page > pages) page = pages;
55
+ // Smaller
56
+ else if (page < 1) page = 1;
57
+
58
+ // Offset
59
+ if (page) start = Number(page - 1) * data.limit;
60
+ else {
61
+ start = 0;
62
+ page = 1;
63
+ }
64
+ }
65
+
66
+ if (!data.select) data.select = '*';
67
+
68
+ // Count Rows
69
+ let count_rows = {
70
+ select: '',
71
+ from: '',
72
+ };
73
+
74
+ if (data.count_rows)
75
+ count_rows = {
76
+ select: `(@row_number:=@row_number + 1) AS row_num, `,
77
+ from: `(SELECT @row_number:=${start}) AS row_number, `,
78
+ };
79
+
80
+ // Edits
81
+ let tiny_query = `SELECT ${count_rows.select}${data.select} FROM ${count_rows.from}${data.from}${data.where} ORDER BY ${data.order}`;
82
+ if (typeof data.limit === 'number') tiny_query += ` LIMIT ${data.limit}`;
83
+ if (typeof data.page === 'number') tiny_query += ` OFFSET ${start}`;
84
+
85
+ let edits = await db.query(tiny_query, data.params);
86
+
87
+ // Complete
88
+ return { count: edit_count, data: edits, pages: pages, page: page, start: start };
89
+ }
90
+
91
+ module.exports = pagination;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Executes a paginated query on the database, returning the result set along with pagination metadata.
3
+ *
4
+ * @async
5
+ * @param {Object} db - Database instance with a `.query(sql, params)` method.
6
+ * @param {Object} data - Query configuration options.
7
+ * @param {string} data.from - The table or view name to query from.
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.
10
+ * @param {string} [data.select="*"] - Fields to select in the query.
11
+ * @param {string} data.order - SQL ORDER BY clause (e.g., `"created_at DESC"`).
12
+ * @param {number} [data.limit] - Number of rows per page.
13
+ * @param {number|string} [data.page] - Current page number or `'last'` to get the last page.
14
+ * @param {number} [data.count] - Optional total count override (skip count query if provided).
15
+ * @param {boolean} [data.count_rows=false] - Whether to include a row number for each result.
16
+ * @returns {Promise<Object>} Resolves with pagination metadata and result set.
17
+ * @returns {number} return.count - Total number of matched rows.
18
+ * @returns {Array} return.data - The paginated data from the query.
19
+ * @returns {number} return.pages - Total number of pages.
20
+ * @returns {number} return.page - Current page number after validation.
21
+ * @returns {number} return.start - Row offset used in the query.
22
+ */
23
+ export default function pagination(db: Object, data: {
24
+ from: string;
25
+ where?: string | undefined;
26
+ params?: any[] | undefined;
27
+ select?: string | undefined;
28
+ order: string;
29
+ limit?: number | undefined;
30
+ page?: string | number | undefined;
31
+ count?: number | undefined;
32
+ count_rows?: boolean | undefined;
33
+ }): Promise<Object>;