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,51 @@
1
+ export default firebaseObject;
2
+ declare namespace firebaseObject {
3
+ /**
4
+ * Retrieves a Firebase app by its identifier.
5
+ *
6
+ * @param {string|number} value - The app identifier to retrieve.
7
+ * @returns {Object|null} The Firebase app or `null` if not found.
8
+ */
9
+ export function get(value: string | number): Object | null;
10
+ export { AuthSystem as cookieSession };
11
+ export { domainRedirect };
12
+ export { database };
13
+ export { dbEscape as escape };
14
+ export { mySQL as mysql };
15
+ export { getDBAsync };
16
+ export { getDBValue };
17
+ export { getDBData };
18
+ export { transactionDBAsync };
19
+ export { databaseEscape };
20
+ export let logger: Object;
21
+ export { isEmulator };
22
+ /**
23
+ * Starts Firebase modules based on the provided configuration.
24
+ * Initializes services such as Database, Auth, Firestore, etc.
25
+ *
26
+ * @param {string} value - The Firebase app ID.
27
+ * @param {Object} item - Configuration for the Firebase app and services to initialize.
28
+ * @returns {boolean} `true` if the modules were successfully started, `false` otherwise.
29
+ */
30
+ export function startModule(value: string, item: Object): boolean;
31
+ /**
32
+ * Starts the Firebase app and initializes required services.
33
+ *
34
+ * @param {Object} admin - The Firebase Admin SDK.
35
+ * @param {Object} item - Configuration containing app details and options.
36
+ * @param {Object} data - Additional data to initialize the app.
37
+ * @throws {Error} Throws an error if the Firebase file is not found or if the app ID is missing.
38
+ */
39
+ export function start(admin: Object, item: Object, data: Object): void;
40
+ }
41
+ import AuthSystem from './cookieSession.mjs';
42
+ import domainRedirect from './domainRedirect.mjs';
43
+ import database from './database/index.mjs';
44
+ import * as dbEscape from './escape.mjs';
45
+ import mySQL from './mySQL.mjs';
46
+ import getDBAsync from './getDBAsync.mjs';
47
+ import getDBValue from './getDBValue.mjs';
48
+ import getDBData from './getDBData.mjs';
49
+ import transactionDBAsync from './transactionDBAsync.mjs';
50
+ import databaseEscape from './databaseEscape.mjs';
51
+ import isEmulator from './isEmulator.mjs';
@@ -0,0 +1,234 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import AuthSystem from './cookieSession.mjs';
4
+ import domainRedirect from './domainRedirect.mjs';
5
+ import database from './database/index.mjs';
6
+ import * as dbEscape from './escape.mjs';
7
+ import mySQL from './mySQL.mjs';
8
+ import getDBAsync from './getDBAsync.mjs';
9
+ import getDBValue from './getDBValue.mjs';
10
+ import getDBData from './getDBData.mjs';
11
+ import transactionDBAsync from './transactionDBAsync.mjs';
12
+ import databaseEscape from './databaseEscape.mjs';
13
+ import isEmulator from './isEmulator.mjs';
14
+ /**
15
+ * Firebase Object to handle various Firebase services and utilities.
16
+ * Includes database, authentication, Firestore, storage, and more.
17
+ *
18
+ * @namespace firebaseObject
19
+ */
20
+ const firebaseObject = { apps: {} };
21
+ /**
22
+ * Retrieves a Firebase app by its identifier.
23
+ *
24
+ * @param {string|number} value - The app identifier to retrieve.
25
+ * @returns {Object|null} The Firebase app or `null` if not found.
26
+ */
27
+ firebaseObject.get = function (value) {
28
+ // Check
29
+ if ((typeof value === 'string' || typeof value === 'number') && firebaseObject.apps[value]) {
30
+ // Send Item
31
+ return firebaseObject.apps[value];
32
+ }
33
+ // Nope
34
+ else
35
+ return null;
36
+ };
37
+ /**
38
+ * Manages cookie session for authentication.
39
+ *
40
+ * @type {AuthSystem}
41
+ */
42
+ firebaseObject.cookieSession = AuthSystem;
43
+ /**
44
+ * Manages domain redirection.
45
+ *
46
+ * @type {domainRedirect}
47
+ */
48
+ firebaseObject.domainRedirect = domainRedirect;
49
+ /**
50
+ * Handles Firebase Database interactions.
51
+ *
52
+ * @type {database}
53
+ */
54
+ firebaseObject.database = database;
55
+ /**
56
+ * Handles database escaping for safe queries.
57
+ *
58
+ * @type {Object}
59
+ */
60
+ firebaseObject.escape = dbEscape;
61
+ /**
62
+ * Manages MySQL database interactions.
63
+ *
64
+ * @type {mySQL}
65
+ */
66
+ firebaseObject.mysql = mySQL;
67
+ /**
68
+ * Retrieves the database asynchronously.
69
+ *
70
+ * @type {getDBAsync}
71
+ */
72
+ firebaseObject.getDBAsync = getDBAsync;
73
+ /**
74
+ * Retrieves a specific database value.
75
+ *
76
+ * @type {getDBValue}
77
+ */
78
+ firebaseObject.getDBValue = getDBValue;
79
+ /**
80
+ * Retrieves database data asynchronously.
81
+ *
82
+ * @type {getDBData}
83
+ */
84
+ firebaseObject.getDBData = getDBData;
85
+ /**
86
+ * Handles asynchronous database transactions.
87
+ *
88
+ * @type {transactionDBAsync}
89
+ */
90
+ firebaseObject.transactionDBAsync = transactionDBAsync;
91
+ /**
92
+ * Provides database escape functionality for safe querying.
93
+ *
94
+ * @type {databaseEscape}
95
+ */
96
+ firebaseObject.databaseEscape = databaseEscape;
97
+ /**
98
+ * Logger to log information using Firebase or console.
99
+ *
100
+ * @type {Object}
101
+ */
102
+ firebaseObject.logger = logger;
103
+ /**
104
+ * Checks if the Firebase environment is running in emulator mode.
105
+ *
106
+ * @type {isEmulator}
107
+ */
108
+ firebaseObject.isEmulator = isEmulator;
109
+ /**
110
+ * Starts Firebase modules based on the provided configuration.
111
+ * Initializes services such as Database, Auth, Firestore, etc.
112
+ *
113
+ * @param {string} value - The Firebase app ID.
114
+ * @param {Object} item - Configuration for the Firebase app and services to initialize.
115
+ * @returns {boolean} `true` if the modules were successfully started, `false` otherwise.
116
+ */
117
+ firebaseObject.startModule = function (value, item) {
118
+ // Check
119
+ if ((typeof value === 'string' || typeof value === 'number') && firebaseObject.apps[value]) {
120
+ // Confirm Action
121
+ let action_confirmed = false;
122
+ // Database
123
+ if (item.database) {
124
+ firebaseObject.apps[value].db = firebaseObject.apps[value].root.database();
125
+ action_confirmed = true;
126
+ }
127
+ // Auth
128
+ if (item.auth) {
129
+ firebaseObject.apps[value].auth = firebaseObject.apps[value].root.auth();
130
+ action_confirmed = true;
131
+ }
132
+ // Firestore
133
+ if (item.firestore) {
134
+ firebaseObject.apps[value].store = firebaseObject.apps[value].root.firestore();
135
+ action_confirmed = true;
136
+ }
137
+ // Storage
138
+ if (item.storage) {
139
+ firebaseObject.apps[value].storage = firebaseObject.apps[value].root.storage();
140
+ action_confirmed = true;
141
+ }
142
+ // Cloud Messaging
143
+ if (item.messaging) {
144
+ firebaseObject.apps[value].messaging = firebaseObject.apps[value].root.messaging();
145
+ action_confirmed = true;
146
+ }
147
+ // Send positive result
148
+ return action_confirmed;
149
+ }
150
+ // Nope
151
+ else
152
+ return false;
153
+ };
154
+ /**
155
+ * Starts the Firebase app and initializes required services.
156
+ *
157
+ * @param {Object} admin - The Firebase Admin SDK.
158
+ * @param {Object} item - Configuration containing app details and options.
159
+ * @param {Object} data - Additional data to initialize the app.
160
+ * @throws {Error} Throws an error if the Firebase file is not found or if the app ID is missing.
161
+ */
162
+ firebaseObject.start = function (admin, item, data) {
163
+ // Try
164
+ try {
165
+ // Start Firebase
166
+ const start_firebase = function (json_file = null) {
167
+ // Check Exist
168
+ if (!firebaseObject.apps[item.id]) {
169
+ // Firebase Settings
170
+ const firebase_settings = {};
171
+ // Exist File
172
+ if (json_file)
173
+ firebase_settings.credential = admin.credential.cert(json_file);
174
+ // Read Data
175
+ if (data) {
176
+ for (const data_item in data)
177
+ firebase_settings[data_item] = data[data_item];
178
+ }
179
+ // Fix Database URL
180
+ if (typeof firebase_settings.databaseURL === 'string') {
181
+ if (!firebase_settings.databaseURL.startsWith('https://') &&
182
+ !firebase_settings.databaseURL.endsWith('.firebaseio.com'))
183
+ firebase_settings.databaseURL = `https://${firebase_settings.databaseURL}.firebaseio.com`;
184
+ }
185
+ // Fix Storage URL
186
+ if (typeof firebase_settings.storageBucket === 'string')
187
+ if (!firebase_settings.storageBucket.endsWith('.appspot.com'))
188
+ firebase_settings.storageBucket = `${firebase_settings.storageBucket}.appspot.com`;
189
+ // Prepare Base
190
+ firebaseObject.apps[item.id] = {};
191
+ // Initialize App
192
+ firebaseObject.apps[item.id].root = admin.initializeApp(firebase_settings, item.id);
193
+ // Auto Start
194
+ if (item.autoStart)
195
+ firebaseObject.startModule(item.id, item.autoStart);
196
+ }
197
+ };
198
+ // Exist ID
199
+ if (item && typeof item.id === 'string' && item.id !== 'start') {
200
+ // Check Variables
201
+ if (typeof item.appID === 'string') {
202
+ // Key File
203
+ let keyFile = null;
204
+ if (item.keysFolder)
205
+ keyFile = path.join(item.keysFolder, item.appID + '.json');
206
+ // Exist File
207
+ if (keyFile && fs.existsSync(keyFile) && fs.lstatSync(keyFile).isFile()) {
208
+ try {
209
+ const jsonData = fs.readFileSync(keyFile, 'utf8');
210
+ const parsedKey = JSON.parse(jsonData);
211
+ start_firebase(parsedKey);
212
+ }
213
+ catch (err) {
214
+ console.error(new Error('Failed to parse Firebase JSON file: ' + err.message));
215
+ }
216
+ }
217
+ else
218
+ console.error(new Error('Firebase File Not Found.'));
219
+ }
220
+ // Nope
221
+ else
222
+ start_firebase();
223
+ }
224
+ // Nope
225
+ else
226
+ console.error(new Error('You need to insert a ID value!'));
227
+ }
228
+ catch (err) {
229
+ // Get Error
230
+ console.error(err);
231
+ }
232
+ };
233
+ // Send Module
234
+ export default firebaseObject;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Checks if the Firebase Functions are running in the emulator environment.
5
+ * This function relies on the environment variable `FUNCTIONS_EMULATOR` to determine
6
+ * whether the Firebase Functions are being executed locally in an emulator or in production.
7
+ *
8
+ * @returns {boolean} `true` if the Firebase Functions are running in the emulator, `false` otherwise.
9
+ */
10
+ function isEmulator() {
11
+ return process.env.FUNCTIONS_EMULATOR;
12
+ }
13
+
14
+ module.exports = isEmulator;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if the Firebase Functions are running in the emulator environment.
3
+ * This function relies on the environment variable `FUNCTIONS_EMULATOR` to determine
4
+ * whether the Firebase Functions are being executed locally in an emulator or in production.
5
+ *
6
+ * @returns {boolean} `true` if the Firebase Functions are running in the emulator, `false` otherwise.
7
+ */
8
+ export default function isEmulator(): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks if the Firebase Functions are running in the emulator environment.
3
+ * This function relies on the environment variable `FUNCTIONS_EMULATOR` to determine
4
+ * whether the Firebase Functions are being executed locally in an emulator or in production.
5
+ *
6
+ * @returns {boolean} `true` if the Firebase Functions are running in the emulator, `false` otherwise.
7
+ */
8
+ export default function isEmulator() {
9
+ return process.env.FUNCTIONS_EMULATOR;
10
+ }
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ var clone = require('clone');
4
+ var index = require('../../_virtual/index.cjs');
5
+ var objType = require('../get/objType.cjs');
6
+ var isEmulator = require('./isEmulator.cjs');
7
+
8
+ /**
9
+ * Recursively handles nested objects and arrays, converting any `BigInt` values
10
+ * into an object with the type `_type_object: 'BIGINT'` and the `value` as a string.
11
+ * This ensures that `BigInt` values are properly serialized and handled.
12
+ *
13
+ * @param {Object|Array} data - The data to process, which can be an object or an array.
14
+ * @returns {Object|Array} The processed data with `BigInt` values converted into objects.
15
+ */
16
+ const loopInteraction = function (data) {
17
+ const checkData = function (item) {
18
+ // Checking
19
+ if (objType(data[item], 'object') || Array.isArray(data[item])) {
20
+ loopInteraction(data[item]);
21
+ }
22
+
23
+ // BigInt
24
+ else if (objType(data[item], 'bigint'))
25
+ data[item] = { _type_object: 'BIGINT', value: data[item].toString() };
26
+ };
27
+
28
+ // Data
29
+ if (objType(data, 'object') || Array.isArray(data)) for (const item in data) checkData(item);
30
+ else {
31
+ // Get BigInt
32
+ if (objType(data, 'bigint')) data = { _type_object: 'BIGINT', value: data.toString() };
33
+ }
34
+
35
+ // Complete
36
+ return data;
37
+ };
38
+
39
+ /**
40
+ * A utility function that handles logging messages based on the environment.
41
+ * If the environment is production and the `firebase-functions/logger` is available,
42
+ * it will use Firebase's logger. Otherwise, it falls back to using the native JavaScript console.
43
+ * The function also handles special cases like `BigInt` serialization and nested objects/arrays.
44
+ *
45
+ * @param {string} type - The type of log message (e.g., `log`, `info`, `warn`, `error`).
46
+ * @param {Arguments} args - The arguments to be logged.
47
+ * @returns {Promise<Object>} A promise resolving with the result of the logging operation,
48
+ * or the result of logging to the native console if Firebase logger is not available.
49
+ */
50
+ const logBase = async function (type, args) {
51
+ // Production
52
+ if (!isEmulator()) {
53
+ // Exist Log
54
+ if (index) {
55
+ let consoleData;
56
+ if (objType(args, 'error'))
57
+ consoleData = JSON.parse(JSON.stringify(args, Object.getOwnPropertyNames(args)));
58
+ else consoleData = args;
59
+
60
+ for (const item in consoleData) {
61
+ let argData = clone(consoleData[item]);
62
+ loopInteraction(argData);
63
+
64
+ if (objType(argData, 'object') || Array.isArray(argData))
65
+ argData = JSON.stringify(argData, null, 2);
66
+
67
+ consoleData[item] = argData;
68
+ }
69
+
70
+ const result = await index[type].apply(index, consoleData);
71
+
72
+ return {
73
+ result: result,
74
+ type: 'firebase-functions/logger',
75
+ };
76
+ }
77
+
78
+ // Nope
79
+ else
80
+ return {
81
+ result: console[type].apply(console, args),
82
+ type: 'console/javascript-vanilla',
83
+ };
84
+ }
85
+
86
+ // Nope
87
+ else
88
+ return {
89
+ result: console[type].apply(console, args),
90
+ type: 'console/javascript-vanilla',
91
+ };
92
+ };
93
+
94
+ // Module
95
+ const fbLogger = {
96
+ /**
97
+ * Logs a message with the `log` level. If not in emulator mode, it uses Firebase's logger.
98
+ *
99
+ * @param {...*} args - The arguments to log.
100
+ * @returns {Promise<Object>} A promise resolving with the logging result.
101
+ */
102
+ log: function () {
103
+ return logBase('log', arguments);
104
+ },
105
+
106
+ /**
107
+ * Logs a message with the `info` level. If not in emulator mode, it uses Firebase's logger.
108
+ *
109
+ * @param {...*} args - The arguments to log.
110
+ * @returns {Promise<Object>} A promise resolving with the logging result.
111
+ */
112
+ info: function () {
113
+ return logBase('info', arguments);
114
+ },
115
+
116
+ /**
117
+ * Logs a message with the `warn` level. If not in emulator mode, it uses Firebase's logger.
118
+ *
119
+ * @param {...*} args - The arguments to log.
120
+ * @returns {Promise<Object>} A promise resolving with the logging result.
121
+ */
122
+ warn: function () {
123
+ return logBase('warn', arguments);
124
+ },
125
+
126
+ /**
127
+ * Logs a message with the `error` level. If not in emulator mode, it uses Firebase's logger.
128
+ *
129
+ * @param {...*} args - The arguments to log.
130
+ * @returns {Promise<Object>} A promise resolving with the logging result.
131
+ */
132
+ error: function () {
133
+ return logBase('error', arguments);
134
+ },
135
+ };
136
+
137
+ module.exports = fbLogger;
@@ -0,0 +1,7 @@
1
+ export default fbLogger;
2
+ declare namespace fbLogger {
3
+ function log(...args: any[]): Promise<Object>;
4
+ function info(...args: any[]): Promise<Object>;
5
+ function warn(...args: any[]): Promise<Object>;
6
+ function error(...args: any[]): Promise<Object>;
7
+ }
@@ -0,0 +1,125 @@
1
+ import clone from 'clone';
2
+ import logger from 'firebase-functions/logger';
3
+ import objType from '../get/objType.mjs';
4
+ import isEmulator from './isEmulator.mjs';
5
+ /**
6
+ * Recursively handles nested objects and arrays, converting any `BigInt` values
7
+ * into an object with the type `_type_object: 'BIGINT'` and the `value` as a string.
8
+ * This ensures that `BigInt` values are properly serialized and handled.
9
+ *
10
+ * @param {Object|Array} data - The data to process, which can be an object or an array.
11
+ * @returns {Object|Array} The processed data with `BigInt` values converted into objects.
12
+ */
13
+ const loopInteraction = function (data) {
14
+ // Check Data
15
+ const interaction = {};
16
+ const checkData = function (item) {
17
+ // Checking
18
+ if (objType(data[item], 'object') || Array.isArray(data[item])) {
19
+ interaction[item] = {};
20
+ interaction[item] = loopInteraction(data[item]);
21
+ }
22
+ // BigInt
23
+ else if (objType(data[item], 'bigint'))
24
+ data[item] = { _type_object: 'BIGINT', value: data[item].toString() };
25
+ };
26
+ // Data
27
+ if (objType(data, 'object') || Array.isArray(data))
28
+ for (const item in data)
29
+ checkData(item);
30
+ else {
31
+ // Get BigInt
32
+ if (objType(data, 'bigint'))
33
+ data = { _type_object: 'BIGINT', value: data.toString() };
34
+ }
35
+ // Complete
36
+ return data;
37
+ };
38
+ /**
39
+ * A utility function that handles logging messages based on the environment.
40
+ * If the environment is production and the `firebase-functions/logger` is available,
41
+ * it will use Firebase's logger. Otherwise, it falls back to using the native JavaScript console.
42
+ * The function also handles special cases like `BigInt` serialization and nested objects/arrays.
43
+ *
44
+ * @param {string} type - The type of log message (e.g., `log`, `info`, `warn`, `error`).
45
+ * @param {Arguments} args - The arguments to be logged.
46
+ * @returns {Promise<Object>} A promise resolving with the result of the logging operation,
47
+ * or the result of logging to the native console if Firebase logger is not available.
48
+ */
49
+ const logBase = async function (type, args) {
50
+ // Production
51
+ if (!isEmulator()) {
52
+ // Exist Log
53
+ if (logger) {
54
+ let consoleData;
55
+ if (objType(args, 'error'))
56
+ consoleData = JSON.parse(JSON.stringify(args, Object.getOwnPropertyNames(args)));
57
+ else
58
+ consoleData = args;
59
+ for (const item in consoleData) {
60
+ let argData = clone(consoleData[item]);
61
+ loopInteraction(argData);
62
+ if (objType(argData, 'object') || Array.isArray(argData))
63
+ argData = JSON.stringify(argData, null, 2);
64
+ consoleData[item] = argData;
65
+ }
66
+ const result = await logger[type].apply(logger, consoleData);
67
+ return {
68
+ result: result,
69
+ type: 'firebase-functions/logger',
70
+ };
71
+ }
72
+ // Nope
73
+ else
74
+ return {
75
+ result: console[type].apply(console, args),
76
+ type: 'console/javascript-vanilla',
77
+ };
78
+ }
79
+ // Nope
80
+ else
81
+ return {
82
+ result: console[type].apply(console, args),
83
+ type: 'console/javascript-vanilla',
84
+ };
85
+ };
86
+ // Module
87
+ const fbLogger = {
88
+ /**
89
+ * Logs a message with the `log` level. If not in emulator mode, it uses Firebase's logger.
90
+ *
91
+ * @param {...*} args - The arguments to log.
92
+ * @returns {Promise<Object>} A promise resolving with the logging result.
93
+ */
94
+ log: function () {
95
+ return logBase('log', arguments);
96
+ },
97
+ /**
98
+ * Logs a message with the `info` level. If not in emulator mode, it uses Firebase's logger.
99
+ *
100
+ * @param {...*} args - The arguments to log.
101
+ * @returns {Promise<Object>} A promise resolving with the logging result.
102
+ */
103
+ info: function () {
104
+ return logBase('info', arguments);
105
+ },
106
+ /**
107
+ * Logs a message with the `warn` level. If not in emulator mode, it uses Firebase's logger.
108
+ *
109
+ * @param {...*} args - The arguments to log.
110
+ * @returns {Promise<Object>} A promise resolving with the logging result.
111
+ */
112
+ warn: function () {
113
+ return logBase('warn', arguments);
114
+ },
115
+ /**
116
+ * Logs a message with the `error` level. If not in emulator mode, it uses Firebase's logger.
117
+ *
118
+ * @param {...*} args - The arguments to log.
119
+ * @returns {Promise<Object>} A promise resolving with the logging result.
120
+ */
121
+ error: function () {
122
+ return logBase('error', arguments);
123
+ },
124
+ };
125
+ export default fbLogger;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ require('clone');
4
+
5
+ /**
6
+ * Connects to a MySQL database using the provided configuration and credentials.
7
+ * The function utilizes `mySqlConnector.create` to establish the connection.
8
+ *
9
+ * @param {Object} mysql - The MySQL module instance.
10
+ * @param {Array|string} databases - The list of databases to connect to, or a single database name.
11
+ * @param {Object} cfg - The configuration object containing connection details (e.g., host, user, password).
12
+ * @returns {Promise} Resolves with the connection object or rejects with an error.
13
+ */
14
+ function mySQL(mysql, databases, cfg) {
15
+ return new Promise(function (resolve, reject) {
16
+ // Get Module
17
+ try {
18
+ mySqlConnector.create(mysql, databases, cfg, 'firebase').then(resolve).catch(reject);
19
+ } catch (err) {
20
+ // Error
21
+ reject(err);
22
+ }
23
+ });
24
+ }
25
+
26
+ module.exports = mySQL;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Connects to a MySQL database using the provided configuration and credentials.
3
+ * The function utilizes `mySqlConnector.create` to establish the connection.
4
+ *
5
+ * @param {Object} mysql - The MySQL module instance.
6
+ * @param {Array|string} databases - The list of databases to connect to, or a single database name.
7
+ * @param {Object} cfg - The configuration object containing connection details (e.g., host, user, password).
8
+ * @returns {Promise} Resolves with the connection object or rejects with an error.
9
+ */
10
+ export default function mySQL(mysql: Object, databases: any[] | string, cfg: Object): Promise<any>;
@@ -0,0 +1,22 @@
1
+ import mysqlConnector from './mysqlConnector/index.mjs';
2
+ /**
3
+ * Connects to a MySQL database using the provided configuration and credentials.
4
+ * The function utilizes `mySqlConnector.create` to establish the connection.
5
+ *
6
+ * @param {Object} mysql - The MySQL module instance.
7
+ * @param {Array|string} databases - The list of databases to connect to, or a single database name.
8
+ * @param {Object} cfg - The configuration object containing connection details (e.g., host, user, password).
9
+ * @returns {Promise} Resolves with the connection object or rejects with an error.
10
+ */
11
+ export default function mySQL(mysql, databases, cfg) {
12
+ return new Promise(function (resolve, reject) {
13
+ // Get Module
14
+ try {
15
+ mySqlConnector.create(mysql, databases, cfg, 'firebase').then(resolve).catch(reject);
16
+ }
17
+ catch (err) {
18
+ // Error
19
+ reject(err);
20
+ }
21
+ });
22
+ }