@qwickapps/server 1.3.1 → 1.5.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 (395) hide show
  1. package/README.md +157 -0
  2. package/dist/core/control-panel.d.ts.map +1 -1
  3. package/dist/core/control-panel.js +114 -0
  4. package/dist/core/control-panel.js.map +1 -1
  5. package/dist/core/types.d.ts +19 -0
  6. package/dist/core/types.d.ts.map +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +15 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/plugins/auth/adapter-wrapper.d.ts +47 -0
  12. package/dist/plugins/auth/adapter-wrapper.d.ts.map +1 -0
  13. package/dist/plugins/auth/adapter-wrapper.js +166 -0
  14. package/dist/plugins/auth/adapter-wrapper.js.map +1 -0
  15. package/dist/plugins/auth/adapter-wrapper.test.d.ts +7 -0
  16. package/dist/plugins/auth/adapter-wrapper.test.d.ts.map +1 -0
  17. package/dist/plugins/auth/adapter-wrapper.test.js +303 -0
  18. package/dist/plugins/auth/adapter-wrapper.test.js.map +1 -0
  19. package/dist/plugins/auth/config-store.d.ts +11 -0
  20. package/dist/plugins/auth/config-store.d.ts.map +1 -0
  21. package/dist/plugins/auth/config-store.js +232 -0
  22. package/dist/plugins/auth/config-store.js.map +1 -0
  23. package/dist/plugins/auth/config-store.test.d.ts +7 -0
  24. package/dist/plugins/auth/config-store.test.d.ts.map +1 -0
  25. package/dist/plugins/auth/config-store.test.js +299 -0
  26. package/dist/plugins/auth/config-store.test.js.map +1 -0
  27. package/dist/plugins/auth/env-config.d.ts +51 -1
  28. package/dist/plugins/auth/env-config.d.ts.map +1 -1
  29. package/dist/plugins/auth/env-config.js +640 -7
  30. package/dist/plugins/auth/env-config.js.map +1 -1
  31. package/dist/plugins/auth/index.d.ts +6 -2
  32. package/dist/plugins/auth/index.d.ts.map +1 -1
  33. package/dist/plugins/auth/index.js +5 -1
  34. package/dist/plugins/auth/index.js.map +1 -1
  35. package/dist/plugins/auth/types.d.ts +106 -0
  36. package/dist/plugins/auth/types.d.ts.map +1 -1
  37. package/dist/plugins/bans/bans-plugin.d.ts.map +1 -1
  38. package/dist/plugins/bans/bans-plugin.js +12 -3
  39. package/dist/plugins/bans/bans-plugin.js.map +1 -1
  40. package/dist/plugins/devices/__tests__/devices-plugin.test.d.ts +11 -0
  41. package/dist/plugins/devices/__tests__/devices-plugin.test.d.ts.map +1 -0
  42. package/dist/plugins/devices/__tests__/devices-plugin.test.js +410 -0
  43. package/dist/plugins/devices/__tests__/devices-plugin.test.js.map +1 -0
  44. package/dist/plugins/devices/__tests__/token-utils.test.d.ts +7 -0
  45. package/dist/plugins/devices/__tests__/token-utils.test.d.ts.map +1 -0
  46. package/dist/plugins/devices/__tests__/token-utils.test.js +197 -0
  47. package/dist/plugins/devices/__tests__/token-utils.test.js.map +1 -0
  48. package/dist/plugins/devices/adapters/compute-adapter.d.ts +36 -0
  49. package/dist/plugins/devices/adapters/compute-adapter.d.ts.map +1 -0
  50. package/dist/plugins/devices/adapters/compute-adapter.js +100 -0
  51. package/dist/plugins/devices/adapters/compute-adapter.js.map +1 -0
  52. package/dist/plugins/devices/adapters/index.d.ts +12 -0
  53. package/dist/plugins/devices/adapters/index.d.ts.map +1 -0
  54. package/dist/plugins/devices/adapters/index.js +10 -0
  55. package/dist/plugins/devices/adapters/index.js.map +1 -0
  56. package/dist/plugins/devices/adapters/mobile-adapter.d.ts +41 -0
  57. package/dist/plugins/devices/adapters/mobile-adapter.d.ts.map +1 -0
  58. package/dist/plugins/devices/adapters/mobile-adapter.js +131 -0
  59. package/dist/plugins/devices/adapters/mobile-adapter.js.map +1 -0
  60. package/dist/plugins/devices/devices-plugin.d.ts +70 -0
  61. package/dist/plugins/devices/devices-plugin.d.ts.map +1 -0
  62. package/dist/plugins/devices/devices-plugin.js +453 -0
  63. package/dist/plugins/devices/devices-plugin.js.map +1 -0
  64. package/dist/plugins/devices/index.d.ts +18 -0
  65. package/dist/plugins/devices/index.d.ts.map +1 -0
  66. package/dist/plugins/devices/index.js +18 -0
  67. package/dist/plugins/devices/index.js.map +1 -0
  68. package/dist/plugins/devices/stores/index.d.ts +9 -0
  69. package/dist/plugins/devices/stores/index.d.ts.map +1 -0
  70. package/dist/plugins/devices/stores/index.js +9 -0
  71. package/dist/plugins/devices/stores/index.js.map +1 -0
  72. package/dist/plugins/devices/stores/postgres-store.d.ts +26 -0
  73. package/dist/plugins/devices/stores/postgres-store.d.ts.map +1 -0
  74. package/dist/plugins/devices/stores/postgres-store.js +199 -0
  75. package/dist/plugins/devices/stores/postgres-store.js.map +1 -0
  76. package/dist/plugins/devices/token-utils.d.ts +100 -0
  77. package/dist/plugins/devices/token-utils.d.ts.map +1 -0
  78. package/dist/plugins/devices/token-utils.js +162 -0
  79. package/dist/plugins/devices/token-utils.js.map +1 -0
  80. package/dist/plugins/devices/types.d.ts +307 -0
  81. package/dist/plugins/devices/types.d.ts.map +1 -0
  82. package/dist/plugins/devices/types.js +10 -0
  83. package/dist/plugins/devices/types.js.map +1 -0
  84. package/dist/plugins/index.d.ts +18 -4
  85. package/dist/plugins/index.d.ts.map +1 -1
  86. package/dist/plugins/index.js +16 -2
  87. package/dist/plugins/index.js.map +1 -1
  88. package/dist/plugins/notifications/__tests__/notifications-manager.test.d.ts +5 -0
  89. package/dist/plugins/notifications/__tests__/notifications-manager.test.d.ts.map +1 -0
  90. package/dist/plugins/notifications/__tests__/notifications-manager.test.js +470 -0
  91. package/dist/plugins/notifications/__tests__/notifications-manager.test.js.map +1 -0
  92. package/dist/plugins/notifications/index.d.ts +71 -0
  93. package/dist/plugins/notifications/index.d.ts.map +1 -0
  94. package/dist/plugins/notifications/index.js +72 -0
  95. package/dist/plugins/notifications/index.js.map +1 -0
  96. package/dist/plugins/notifications/notifications-manager.d.ts +182 -0
  97. package/dist/plugins/notifications/notifications-manager.d.ts.map +1 -0
  98. package/dist/plugins/notifications/notifications-manager.js +610 -0
  99. package/dist/plugins/notifications/notifications-manager.js.map +1 -0
  100. package/dist/plugins/notifications/notifications-plugin.d.ts +83 -0
  101. package/dist/plugins/notifications/notifications-plugin.d.ts.map +1 -0
  102. package/dist/plugins/notifications/notifications-plugin.js +337 -0
  103. package/dist/plugins/notifications/notifications-plugin.js.map +1 -0
  104. package/dist/plugins/notifications/types.d.ts +164 -0
  105. package/dist/plugins/notifications/types.d.ts.map +1 -0
  106. package/dist/plugins/notifications/types.js +9 -0
  107. package/dist/plugins/notifications/types.js.map +1 -0
  108. package/dist/plugins/parental/__tests__/parental-plugin.test.d.ts +12 -0
  109. package/dist/plugins/parental/__tests__/parental-plugin.test.d.ts.map +1 -0
  110. package/dist/plugins/parental/__tests__/parental-plugin.test.js +349 -0
  111. package/dist/plugins/parental/__tests__/parental-plugin.test.js.map +1 -0
  112. package/dist/plugins/parental/adapters/index.d.ts +8 -0
  113. package/dist/plugins/parental/adapters/index.d.ts.map +1 -0
  114. package/dist/plugins/parental/adapters/index.js +7 -0
  115. package/dist/plugins/parental/adapters/index.js.map +1 -0
  116. package/dist/plugins/parental/adapters/kids-adapter.d.ts +24 -0
  117. package/dist/plugins/parental/adapters/kids-adapter.d.ts.map +1 -0
  118. package/dist/plugins/parental/adapters/kids-adapter.js +174 -0
  119. package/dist/plugins/parental/adapters/kids-adapter.js.map +1 -0
  120. package/dist/plugins/parental/index.d.ts +14 -0
  121. package/dist/plugins/parental/index.d.ts.map +1 -0
  122. package/dist/plugins/parental/index.js +15 -0
  123. package/dist/plugins/parental/index.js.map +1 -0
  124. package/dist/plugins/parental/parental-plugin.d.ts +88 -0
  125. package/dist/plugins/parental/parental-plugin.d.ts.map +1 -0
  126. package/dist/plugins/parental/parental-plugin.js +666 -0
  127. package/dist/plugins/parental/parental-plugin.js.map +1 -0
  128. package/dist/plugins/parental/stores/index.d.ts +7 -0
  129. package/dist/plugins/parental/stores/index.d.ts.map +1 -0
  130. package/dist/plugins/parental/stores/index.js +7 -0
  131. package/dist/plugins/parental/stores/index.js.map +1 -0
  132. package/dist/plugins/parental/stores/postgres-store.d.ts +10 -0
  133. package/dist/plugins/parental/stores/postgres-store.d.ts.map +1 -0
  134. package/dist/plugins/parental/stores/postgres-store.js +209 -0
  135. package/dist/plugins/parental/stores/postgres-store.js.map +1 -0
  136. package/dist/plugins/parental/types.d.ts +154 -0
  137. package/dist/plugins/parental/types.d.ts.map +1 -0
  138. package/dist/plugins/parental/types.js +10 -0
  139. package/dist/plugins/parental/types.js.map +1 -0
  140. package/dist/plugins/profiles/__tests__/profiles-plugin.test.d.ts +11 -0
  141. package/dist/plugins/profiles/__tests__/profiles-plugin.test.d.ts.map +1 -0
  142. package/dist/plugins/profiles/__tests__/profiles-plugin.test.js +243 -0
  143. package/dist/plugins/profiles/__tests__/profiles-plugin.test.js.map +1 -0
  144. package/dist/plugins/profiles/index.d.ts +12 -0
  145. package/dist/plugins/profiles/index.d.ts.map +1 -0
  146. package/dist/plugins/profiles/index.js +13 -0
  147. package/dist/plugins/profiles/index.js.map +1 -0
  148. package/dist/plugins/profiles/profiles-plugin.d.ts +71 -0
  149. package/dist/plugins/profiles/profiles-plugin.d.ts.map +1 -0
  150. package/dist/plugins/profiles/profiles-plugin.js +481 -0
  151. package/dist/plugins/profiles/profiles-plugin.js.map +1 -0
  152. package/dist/plugins/profiles/stores/index.d.ts +9 -0
  153. package/dist/plugins/profiles/stores/index.d.ts.map +1 -0
  154. package/dist/plugins/profiles/stores/index.js +9 -0
  155. package/dist/plugins/profiles/stores/index.js.map +1 -0
  156. package/dist/plugins/profiles/stores/postgres-store.d.ts +18 -0
  157. package/dist/plugins/profiles/stores/postgres-store.d.ts.map +1 -0
  158. package/dist/plugins/profiles/stores/postgres-store.js +310 -0
  159. package/dist/plugins/profiles/stores/postgres-store.js.map +1 -0
  160. package/dist/plugins/profiles/types.d.ts +289 -0
  161. package/dist/plugins/profiles/types.d.ts.map +1 -0
  162. package/dist/plugins/profiles/types.js +10 -0
  163. package/dist/plugins/profiles/types.js.map +1 -0
  164. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.d.ts +7 -0
  165. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.d.ts.map +1 -0
  166. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.js +220 -0
  167. package/dist/plugins/rate-limit/__tests__/rate-limit-plugin.test.js.map +1 -0
  168. package/dist/plugins/rate-limit/cleanup.d.ts +40 -0
  169. package/dist/plugins/rate-limit/cleanup.d.ts.map +1 -0
  170. package/dist/plugins/rate-limit/cleanup.js +72 -0
  171. package/dist/plugins/rate-limit/cleanup.js.map +1 -0
  172. package/dist/plugins/rate-limit/env-config.d.ts +91 -0
  173. package/dist/plugins/rate-limit/env-config.d.ts.map +1 -0
  174. package/dist/plugins/rate-limit/env-config.js +318 -0
  175. package/dist/plugins/rate-limit/env-config.js.map +1 -0
  176. package/dist/plugins/rate-limit/index.d.ts +76 -0
  177. package/dist/plugins/rate-limit/index.d.ts.map +1 -0
  178. package/dist/plugins/rate-limit/index.js +79 -0
  179. package/dist/plugins/rate-limit/index.js.map +1 -0
  180. package/dist/plugins/rate-limit/middleware.d.ts +40 -0
  181. package/dist/plugins/rate-limit/middleware.d.ts.map +1 -0
  182. package/dist/plugins/rate-limit/middleware.js +169 -0
  183. package/dist/plugins/rate-limit/middleware.js.map +1 -0
  184. package/dist/plugins/rate-limit/rate-limit-plugin.d.ts +44 -0
  185. package/dist/plugins/rate-limit/rate-limit-plugin.d.ts.map +1 -0
  186. package/dist/plugins/rate-limit/rate-limit-plugin.js +354 -0
  187. package/dist/plugins/rate-limit/rate-limit-plugin.js.map +1 -0
  188. package/dist/plugins/rate-limit/rate-limit-service.d.ts +110 -0
  189. package/dist/plugins/rate-limit/rate-limit-service.d.ts.map +1 -0
  190. package/dist/plugins/rate-limit/rate-limit-service.js +172 -0
  191. package/dist/plugins/rate-limit/rate-limit-service.js.map +1 -0
  192. package/dist/plugins/rate-limit/stores/cache-store.d.ts +33 -0
  193. package/dist/plugins/rate-limit/stores/cache-store.d.ts.map +1 -0
  194. package/dist/plugins/rate-limit/stores/cache-store.js +225 -0
  195. package/dist/plugins/rate-limit/stores/cache-store.js.map +1 -0
  196. package/dist/plugins/rate-limit/stores/index.d.ts +8 -0
  197. package/dist/plugins/rate-limit/stores/index.d.ts.map +1 -0
  198. package/dist/plugins/rate-limit/stores/index.js +8 -0
  199. package/dist/plugins/rate-limit/stores/index.js.map +1 -0
  200. package/dist/plugins/rate-limit/stores/postgres-store.d.ts +34 -0
  201. package/dist/plugins/rate-limit/stores/postgres-store.d.ts.map +1 -0
  202. package/dist/plugins/rate-limit/stores/postgres-store.js +320 -0
  203. package/dist/plugins/rate-limit/stores/postgres-store.js.map +1 -0
  204. package/dist/plugins/rate-limit/strategies/fixed-window.d.ts +21 -0
  205. package/dist/plugins/rate-limit/strategies/fixed-window.d.ts.map +1 -0
  206. package/dist/plugins/rate-limit/strategies/fixed-window.js +97 -0
  207. package/dist/plugins/rate-limit/strategies/fixed-window.js.map +1 -0
  208. package/dist/plugins/rate-limit/strategies/index.d.ts +14 -0
  209. package/dist/plugins/rate-limit/strategies/index.d.ts.map +1 -0
  210. package/dist/plugins/rate-limit/strategies/index.js +27 -0
  211. package/dist/plugins/rate-limit/strategies/index.js.map +1 -0
  212. package/dist/plugins/rate-limit/strategies/sliding-window.d.ts +22 -0
  213. package/dist/plugins/rate-limit/strategies/sliding-window.d.ts.map +1 -0
  214. package/dist/plugins/rate-limit/strategies/sliding-window.js +122 -0
  215. package/dist/plugins/rate-limit/strategies/sliding-window.js.map +1 -0
  216. package/dist/plugins/rate-limit/strategies/token-bucket.d.ts +28 -0
  217. package/dist/plugins/rate-limit/strategies/token-bucket.d.ts.map +1 -0
  218. package/dist/plugins/rate-limit/strategies/token-bucket.js +121 -0
  219. package/dist/plugins/rate-limit/strategies/token-bucket.js.map +1 -0
  220. package/dist/plugins/rate-limit/types.d.ts +265 -0
  221. package/dist/plugins/rate-limit/types.d.ts.map +1 -0
  222. package/dist/plugins/rate-limit/types.js +9 -0
  223. package/dist/plugins/rate-limit/types.js.map +1 -0
  224. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.d.ts +11 -0
  225. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.d.ts.map +1 -0
  226. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.js +305 -0
  227. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.js.map +1 -0
  228. package/dist/plugins/subscriptions/index.d.ts +12 -0
  229. package/dist/plugins/subscriptions/index.d.ts.map +1 -0
  230. package/dist/plugins/subscriptions/index.js +13 -0
  231. package/dist/plugins/subscriptions/index.js.map +1 -0
  232. package/dist/plugins/subscriptions/stores/index.d.ts +9 -0
  233. package/dist/plugins/subscriptions/stores/index.d.ts.map +1 -0
  234. package/dist/plugins/subscriptions/stores/index.js +9 -0
  235. package/dist/plugins/subscriptions/stores/index.js.map +1 -0
  236. package/dist/plugins/subscriptions/stores/postgres-store.d.ts +14 -0
  237. package/dist/plugins/subscriptions/stores/postgres-store.d.ts.map +1 -0
  238. package/dist/plugins/subscriptions/stores/postgres-store.js +359 -0
  239. package/dist/plugins/subscriptions/stores/postgres-store.js.map +1 -0
  240. package/dist/plugins/subscriptions/subscriptions-plugin.d.ts +82 -0
  241. package/dist/plugins/subscriptions/subscriptions-plugin.d.ts.map +1 -0
  242. package/dist/plugins/subscriptions/subscriptions-plugin.js +449 -0
  243. package/dist/plugins/subscriptions/subscriptions-plugin.js.map +1 -0
  244. package/dist/plugins/subscriptions/types.d.ts +308 -0
  245. package/dist/plugins/subscriptions/types.d.ts.map +1 -0
  246. package/dist/plugins/subscriptions/types.js +10 -0
  247. package/dist/plugins/subscriptions/types.js.map +1 -0
  248. package/dist/plugins/usage/__tests__/usage-plugin.test.d.ts +11 -0
  249. package/dist/plugins/usage/__tests__/usage-plugin.test.d.ts.map +1 -0
  250. package/dist/plugins/usage/__tests__/usage-plugin.test.js +218 -0
  251. package/dist/plugins/usage/__tests__/usage-plugin.test.js.map +1 -0
  252. package/dist/plugins/usage/index.d.ts +12 -0
  253. package/dist/plugins/usage/index.d.ts.map +1 -0
  254. package/dist/plugins/usage/index.js +13 -0
  255. package/dist/plugins/usage/index.js.map +1 -0
  256. package/dist/plugins/usage/stores/index.d.ts +9 -0
  257. package/dist/plugins/usage/stores/index.d.ts.map +1 -0
  258. package/dist/plugins/usage/stores/index.js +9 -0
  259. package/dist/plugins/usage/stores/index.js.map +1 -0
  260. package/dist/plugins/usage/stores/postgres-store.d.ts +14 -0
  261. package/dist/plugins/usage/stores/postgres-store.d.ts.map +1 -0
  262. package/dist/plugins/usage/stores/postgres-store.js +146 -0
  263. package/dist/plugins/usage/stores/postgres-store.js.map +1 -0
  264. package/dist/plugins/usage/types.d.ts +195 -0
  265. package/dist/plugins/usage/types.d.ts.map +1 -0
  266. package/dist/plugins/usage/types.js +10 -0
  267. package/dist/plugins/usage/types.js.map +1 -0
  268. package/dist/plugins/usage/usage-plugin.d.ts +51 -0
  269. package/dist/plugins/usage/usage-plugin.d.ts.map +1 -0
  270. package/dist/plugins/usage/usage-plugin.js +412 -0
  271. package/dist/plugins/usage/usage-plugin.js.map +1 -0
  272. package/dist/plugins/users/__tests__/postgres-store.test.d.ts +10 -0
  273. package/dist/plugins/users/__tests__/postgres-store.test.d.ts.map +1 -0
  274. package/dist/plugins/users/__tests__/postgres-store.test.js +229 -0
  275. package/dist/plugins/users/__tests__/postgres-store.test.js.map +1 -0
  276. package/dist/plugins/users/__tests__/users-plugin.test.js +3 -0
  277. package/dist/plugins/users/__tests__/users-plugin.test.js.map +1 -1
  278. package/dist/plugins/users/index.d.ts +2 -2
  279. package/dist/plugins/users/index.d.ts.map +1 -1
  280. package/dist/plugins/users/index.js +1 -1
  281. package/dist/plugins/users/index.js.map +1 -1
  282. package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -1
  283. package/dist/plugins/users/stores/postgres-store.js +76 -0
  284. package/dist/plugins/users/stores/postgres-store.js.map +1 -1
  285. package/dist/plugins/users/types.d.ts +74 -6
  286. package/dist/plugins/users/types.d.ts.map +1 -1
  287. package/dist/plugins/users/users-plugin.d.ts +15 -1
  288. package/dist/plugins/users/users-plugin.d.ts.map +1 -1
  289. package/dist/plugins/users/users-plugin.js +29 -0
  290. package/dist/plugins/users/users-plugin.js.map +1 -1
  291. package/dist-ui/assets/index-CynOqPkb.js +469 -0
  292. package/dist-ui/assets/{index-BY8OxNgO.js.map → index-CynOqPkb.js.map} +1 -1
  293. package/dist-ui/index.html +1 -1
  294. package/dist-ui-lib/api/controlPanelApi.d.ts +187 -0
  295. package/dist-ui-lib/components/StatCard.d.ts +16 -0
  296. package/dist-ui-lib/dashboard/widgets/AuthStatusWidget.d.ts +9 -0
  297. package/dist-ui-lib/dashboard/widgets/IntegrationStatusWidget.d.ts +9 -0
  298. package/dist-ui-lib/dashboard/widgets/NotificationsStatsWidget.d.ts +12 -0
  299. package/dist-ui-lib/dashboard/widgets/index.d.ts +3 -0
  300. package/dist-ui-lib/index.js +3579 -2379
  301. package/dist-ui-lib/index.js.map +1 -1
  302. package/dist-ui-lib/pages/IntegrationsPage.d.ts +1 -0
  303. package/dist-ui-lib/pages/NotificationsPage.d.ts +9 -0
  304. package/dist-ui-lib/pages/RateLimitPage.d.ts +1 -0
  305. package/dist-ui-lib/utils/formatters.d.ts +19 -0
  306. package/package.json +1 -1
  307. package/src/core/control-panel.ts +128 -0
  308. package/src/core/types.ts +17 -0
  309. package/src/index.ts +216 -0
  310. package/src/plugins/auth/adapter-wrapper.test.ts +395 -0
  311. package/src/plugins/auth/adapter-wrapper.ts +205 -0
  312. package/src/plugins/auth/config-store.test.ts +417 -0
  313. package/src/plugins/auth/config-store.ts +305 -0
  314. package/src/plugins/auth/env-config.ts +714 -7
  315. package/src/plugins/auth/index.ts +22 -1
  316. package/src/plugins/auth/types.ts +138 -0
  317. package/src/plugins/bans/bans-plugin.ts +15 -3
  318. package/src/plugins/devices/__tests__/devices-plugin.test.ts +551 -0
  319. package/src/plugins/devices/__tests__/token-utils.test.ts +264 -0
  320. package/src/plugins/devices/adapters/compute-adapter.ts +139 -0
  321. package/src/plugins/devices/adapters/index.ts +13 -0
  322. package/src/plugins/devices/adapters/mobile-adapter.ts +179 -0
  323. package/src/plugins/devices/devices-plugin.ts +538 -0
  324. package/src/plugins/devices/index.ts +69 -0
  325. package/src/plugins/devices/stores/index.ts +9 -0
  326. package/src/plugins/devices/stores/postgres-store.ts +304 -0
  327. package/src/plugins/devices/token-utils.ts +213 -0
  328. package/src/plugins/devices/types.ts +351 -0
  329. package/src/plugins/index.ts +267 -0
  330. package/src/plugins/notifications/__tests__/notifications-manager.test.ts +637 -0
  331. package/src/plugins/notifications/index.ts +91 -0
  332. package/src/plugins/notifications/notifications-manager.ts +773 -0
  333. package/src/plugins/notifications/notifications-plugin.ts +398 -0
  334. package/src/plugins/notifications/types.ts +207 -0
  335. package/src/plugins/parental/__tests__/parental-plugin.test.ts +465 -0
  336. package/src/plugins/parental/adapters/index.ts +8 -0
  337. package/src/plugins/parental/adapters/kids-adapter.ts +206 -0
  338. package/src/plugins/parental/index.ts +55 -0
  339. package/src/plugins/parental/parental-plugin.ts +759 -0
  340. package/src/plugins/parental/stores/index.ts +7 -0
  341. package/src/plugins/parental/stores/postgres-store.ts +304 -0
  342. package/src/plugins/parental/types.ts +180 -0
  343. package/src/plugins/profiles/__tests__/profiles-plugin.test.ts +321 -0
  344. package/src/plugins/profiles/index.ts +49 -0
  345. package/src/plugins/profiles/profiles-plugin.ts +546 -0
  346. package/src/plugins/profiles/stores/index.ts +9 -0
  347. package/src/plugins/profiles/stores/postgres-store.ts +439 -0
  348. package/src/plugins/profiles/types.ts +338 -0
  349. package/src/plugins/rate-limit/__tests__/rate-limit-plugin.test.ts +259 -0
  350. package/src/plugins/rate-limit/cleanup.ts +117 -0
  351. package/src/plugins/rate-limit/env-config.ts +400 -0
  352. package/src/plugins/rate-limit/index.ts +128 -0
  353. package/src/plugins/rate-limit/middleware.ts +212 -0
  354. package/src/plugins/rate-limit/rate-limit-plugin.ts +400 -0
  355. package/src/plugins/rate-limit/rate-limit-service.ts +228 -0
  356. package/src/plugins/rate-limit/stores/cache-store.ts +261 -0
  357. package/src/plugins/rate-limit/stores/index.ts +8 -0
  358. package/src/plugins/rate-limit/stores/postgres-store.ts +402 -0
  359. package/src/plugins/rate-limit/strategies/fixed-window.ts +116 -0
  360. package/src/plugins/rate-limit/strategies/index.ts +30 -0
  361. package/src/plugins/rate-limit/strategies/sliding-window.ts +157 -0
  362. package/src/plugins/rate-limit/strategies/token-bucket.ts +154 -0
  363. package/src/plugins/rate-limit/types.ts +338 -0
  364. package/src/plugins/subscriptions/__tests__/subscriptions-plugin.test.ts +404 -0
  365. package/src/plugins/subscriptions/index.ts +51 -0
  366. package/src/plugins/subscriptions/stores/index.ts +9 -0
  367. package/src/plugins/subscriptions/stores/postgres-store.ts +482 -0
  368. package/src/plugins/subscriptions/subscriptions-plugin.ts +530 -0
  369. package/src/plugins/subscriptions/types.ts +355 -0
  370. package/src/plugins/usage/__tests__/usage-plugin.test.ts +288 -0
  371. package/src/plugins/usage/index.ts +39 -0
  372. package/src/plugins/usage/stores/index.ts +9 -0
  373. package/src/plugins/usage/stores/postgres-store.ts +213 -0
  374. package/src/plugins/usage/types.ts +222 -0
  375. package/src/plugins/usage/usage-plugin.ts +484 -0
  376. package/src/plugins/users/__tests__/postgres-store.test.ts +326 -0
  377. package/src/plugins/users/__tests__/users-plugin.test.ts +3 -0
  378. package/src/plugins/users/index.ts +6 -0
  379. package/src/plugins/users/stores/postgres-store.ts +104 -0
  380. package/src/plugins/users/types.ts +82 -6
  381. package/src/plugins/users/users-plugin.ts +37 -0
  382. package/ui/src/App.tsx +36 -14
  383. package/ui/src/api/controlPanelApi.ts +329 -6
  384. package/ui/src/components/StatCard.tsx +58 -0
  385. package/ui/src/dashboard/builtInWidgets.tsx +7 -1
  386. package/ui/src/dashboard/widgets/AuthStatusWidget.tsx +143 -0
  387. package/ui/src/dashboard/widgets/IntegrationStatusWidget.tsx +135 -0
  388. package/ui/src/dashboard/widgets/NotificationsStatsWidget.tsx +167 -0
  389. package/ui/src/dashboard/widgets/index.ts +3 -0
  390. package/ui/src/pages/AuthPage.tsx +986 -142
  391. package/ui/src/pages/IntegrationsPage.tsx +288 -0
  392. package/ui/src/pages/NotificationsPage.tsx +417 -0
  393. package/ui/src/pages/RateLimitPage.tsx +292 -0
  394. package/ui/src/utils/formatters.ts +33 -0
  395. package/dist-ui/assets/index-BY8OxNgO.js +0 -465
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Rate Limit Plugin Tests
3
+ *
4
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
5
+ */
6
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
7
+ import { RateLimitService } from '../rate-limit-service.js';
8
+ import { createSlidingWindowStrategy } from '../strategies/sliding-window.js';
9
+ import { createFixedWindowStrategy } from '../strategies/fixed-window.js';
10
+ import { createTokenBucketStrategy } from '../strategies/token-bucket.js';
11
+ // Mock store implementation
12
+ function createMockStore() {
13
+ const records = new Map();
14
+ return {
15
+ name: 'mock',
16
+ async initialize() {
17
+ // No-op
18
+ },
19
+ async get(key) {
20
+ return records.get(key) || null;
21
+ },
22
+ async increment(key, options) {
23
+ const now = new Date();
24
+ const windowMs = options.windowMs;
25
+ const windowStart = new Date(now.getTime() - (now.getTime() % windowMs));
26
+ const windowEnd = new Date(windowStart.getTime() + windowMs);
27
+ const existing = records.get(key);
28
+ if (existing && existing.windowStart.getTime() === windowStart.getTime()) {
29
+ existing.count += options.amount || 1;
30
+ existing.updatedAt = now;
31
+ return existing;
32
+ }
33
+ const newRecord = {
34
+ id: `mock-${Date.now()}`,
35
+ key,
36
+ count: options.amount || 1,
37
+ maxRequests: options.maxRequests,
38
+ windowMs: options.windowMs,
39
+ windowStart,
40
+ windowEnd,
41
+ strategy: options.strategy,
42
+ userId: options.userId,
43
+ tenantId: options.tenantId,
44
+ ipAddress: options.ipAddress,
45
+ createdAt: now,
46
+ updatedAt: now,
47
+ };
48
+ records.set(key, newRecord);
49
+ return newRecord;
50
+ },
51
+ async clear(key) {
52
+ return records.delete(key);
53
+ },
54
+ async cleanup() {
55
+ const now = Date.now();
56
+ let deleted = 0;
57
+ for (const [key, record] of records) {
58
+ if (record.windowEnd.getTime() < now) {
59
+ records.delete(key);
60
+ deleted++;
61
+ }
62
+ }
63
+ return deleted;
64
+ },
65
+ async shutdown() {
66
+ records.clear();
67
+ },
68
+ };
69
+ }
70
+ // Mock cache implementation
71
+ function createMockCache() {
72
+ const cache = new Map();
73
+ return {
74
+ name: 'mock',
75
+ async get(key) {
76
+ const entry = cache.get(key);
77
+ if (!entry)
78
+ return null;
79
+ if (entry.expiresAt <= Date.now()) {
80
+ cache.delete(key);
81
+ return null;
82
+ }
83
+ return entry.value;
84
+ },
85
+ async set(key, value, ttlMs) {
86
+ cache.set(key, { value, expiresAt: Date.now() + ttlMs });
87
+ },
88
+ async increment(key, amount = 1) {
89
+ const entry = cache.get(key);
90
+ if (!entry || entry.expiresAt <= Date.now())
91
+ return null;
92
+ entry.value.count += amount;
93
+ return entry.value.count;
94
+ },
95
+ async delete(key) {
96
+ return cache.delete(key);
97
+ },
98
+ isAvailable() {
99
+ return true;
100
+ },
101
+ async shutdown() {
102
+ cache.clear();
103
+ },
104
+ };
105
+ }
106
+ describe('RateLimitService', () => {
107
+ let store;
108
+ let cache;
109
+ let service;
110
+ beforeEach(() => {
111
+ store = createMockStore();
112
+ cache = createMockCache();
113
+ service = new RateLimitService({
114
+ store,
115
+ cache,
116
+ defaults: {
117
+ windowMs: 60000,
118
+ maxRequests: 100,
119
+ strategy: 'sliding-window',
120
+ },
121
+ });
122
+ });
123
+ afterEach(async () => {
124
+ await store.shutdown();
125
+ await cache.shutdown();
126
+ });
127
+ describe('checkLimit', () => {
128
+ it('should return not limited for first request', async () => {
129
+ const status = await service.checkLimit('test:key', { increment: false });
130
+ expect(status.limited).toBe(false);
131
+ expect(status.current).toBe(0);
132
+ expect(status.limit).toBe(100);
133
+ expect(status.remaining).toBe(100);
134
+ });
135
+ it('should use provided options over defaults', async () => {
136
+ const status = await service.checkLimit('test:key', {
137
+ maxRequests: 50,
138
+ windowMs: 30000,
139
+ increment: false,
140
+ });
141
+ expect(status.limit).toBe(50);
142
+ });
143
+ });
144
+ describe('incrementLimit', () => {
145
+ it('should increment the counter', async () => {
146
+ const status1 = await service.incrementLimit('test:key');
147
+ expect(status1.current).toBe(1);
148
+ expect(status1.remaining).toBe(99);
149
+ const status2 = await service.incrementLimit('test:key');
150
+ expect(status2.current).toBe(2);
151
+ expect(status2.remaining).toBe(98);
152
+ });
153
+ it('should return limited when max reached', async () => {
154
+ // Set low limit for testing
155
+ for (let i = 0; i < 5; i++) {
156
+ await service.incrementLimit('test:key', { maxRequests: 5 });
157
+ }
158
+ const status = await service.incrementLimit('test:key', { maxRequests: 5 });
159
+ expect(status.limited).toBe(true);
160
+ expect(status.remaining).toBe(0);
161
+ });
162
+ });
163
+ describe('isLimited', () => {
164
+ it('should return false when not limited', async () => {
165
+ const limited = await service.isLimited('test:key');
166
+ expect(limited).toBe(false);
167
+ });
168
+ it('should return true when limited', async () => {
169
+ // Exhaust the limit
170
+ for (let i = 0; i < 5; i++) {
171
+ await service.incrementLimit('test:key', { maxRequests: 5 });
172
+ }
173
+ const limited = await service.isLimited('test:key', { maxRequests: 5 });
174
+ expect(limited).toBe(true);
175
+ });
176
+ });
177
+ describe('clearLimit', () => {
178
+ it('should clear the limit', async () => {
179
+ // Create some limits
180
+ await service.incrementLimit('test:key');
181
+ await service.incrementLimit('test:key');
182
+ // Verify exists
183
+ const beforeStatus = await service.checkLimit('test:key', { increment: false });
184
+ expect(beforeStatus.current).toBeGreaterThan(0);
185
+ // Clear
186
+ await service.clearLimit('test:key');
187
+ // Verify cleared
188
+ const afterStatus = await service.checkLimit('test:key', { increment: false });
189
+ expect(afterStatus.current).toBe(0);
190
+ });
191
+ });
192
+ });
193
+ describe('Strategies', () => {
194
+ describe('Sliding Window', () => {
195
+ it('should create strategy with correct name', () => {
196
+ const strategy = createSlidingWindowStrategy();
197
+ expect(strategy.name).toBe('sliding-window');
198
+ });
199
+ });
200
+ describe('Fixed Window', () => {
201
+ it('should create strategy with correct name', () => {
202
+ const strategy = createFixedWindowStrategy();
203
+ expect(strategy.name).toBe('fixed-window');
204
+ });
205
+ });
206
+ describe('Token Bucket', () => {
207
+ it('should create strategy with correct name', () => {
208
+ const strategy = createTokenBucketStrategy();
209
+ expect(strategy.name).toBe('token-bucket');
210
+ });
211
+ });
212
+ });
213
+ describe('Types', () => {
214
+ it('should export all required types', async () => {
215
+ // This test verifies that the types module compiles correctly
216
+ const types = await import('../types.js');
217
+ expect(types).toBeDefined();
218
+ });
219
+ });
220
+ //# sourceMappingURL=rate-limit-plugin.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-plugin.test.js","sourceRoot":"","sources":["../../../../src/plugins/rate-limit/__tests__/rate-limit-plugin.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAM,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,4BAA4B;AAC5B,SAAS,eAAe;IACtB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE/C,OAAO;QACL,IAAI,EAAE,MAAM;QAEZ,KAAK,CAAC,UAAU;YACd,QAAQ;QACV,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,GAAW;YACnB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAA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,QAAQ,GAAG,2BAA2B,EAAE,CAAC;YAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;YAClD,MAAM,QAAQ,GAAG,yBAAyB,EAAE,CAAC;YAC7C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;YAClD,MAAM,QAAQ,GAAG,yBAAyB,EAAE,CAAC;YAC7C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,8DAA8D;QAC9D,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Rate Limit Cleanup Job
3
+ *
4
+ * Periodically removes expired rate limit records from the database.
5
+ *
6
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
7
+ */
8
+ import type { RateLimitStore } from './types.js';
9
+ /**
10
+ * Cleanup job configuration
11
+ */
12
+ export interface CleanupJobConfig {
13
+ /** Store to clean up */
14
+ store: RateLimitStore;
15
+ /** Cleanup interval in milliseconds (default: 300000 = 5 min) */
16
+ intervalMs?: number;
17
+ /** Enable debug logging */
18
+ debug?: boolean;
19
+ }
20
+ /**
21
+ * Cleanup job state
22
+ */
23
+ export interface CleanupJob {
24
+ /** Start the cleanup job */
25
+ start(): void;
26
+ /** Stop the cleanup job */
27
+ stop(): void;
28
+ /** Run cleanup immediately */
29
+ runNow(): Promise<number>;
30
+ /** Check if job is running */
31
+ isRunning(): boolean;
32
+ }
33
+ /**
34
+ * Create a cleanup job
35
+ *
36
+ * @param config Cleanup configuration
37
+ * @returns CleanupJob instance
38
+ */
39
+ export declare function createCleanupJob(config: CleanupJobConfig): CleanupJob;
40
+ //# sourceMappingURL=cleanup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../../src/plugins/rate-limit/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB;IACxB,KAAK,EAAE,cAAc,CAAC;IAEtB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAAC;IAEd,2BAA2B;IAC3B,IAAI,IAAI,IAAI,CAAC;IAEb,8BAA8B;IAC9B,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B,8BAA8B;IAC9B,SAAS,IAAI,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAqErE"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Rate Limit Cleanup Job
3
+ *
4
+ * Periodically removes expired rate limit records from the database.
5
+ *
6
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
7
+ */
8
+ /**
9
+ * Create a cleanup job
10
+ *
11
+ * @param config Cleanup configuration
12
+ * @returns CleanupJob instance
13
+ */
14
+ export function createCleanupJob(config) {
15
+ const { store, intervalMs = 300000, // 5 minutes default
16
+ debug = false, } = config;
17
+ let intervalId = null;
18
+ let isRunningCleanup = false;
19
+ function log(message, data) {
20
+ if (debug) {
21
+ console.log(`[RateLimitCleanup] ${message}`, data || '');
22
+ }
23
+ }
24
+ async function runCleanup() {
25
+ if (isRunningCleanup) {
26
+ log('Cleanup already in progress, skipping');
27
+ return 0;
28
+ }
29
+ isRunningCleanup = true;
30
+ try {
31
+ log('Starting cleanup');
32
+ const startTime = Date.now();
33
+ const deletedCount = await store.cleanup();
34
+ const duration = Date.now() - startTime;
35
+ log('Cleanup complete', { deletedCount, durationMs: duration });
36
+ return deletedCount;
37
+ }
38
+ catch (error) {
39
+ console.error('[RateLimitCleanup] Error during cleanup:', error);
40
+ return 0;
41
+ }
42
+ finally {
43
+ isRunningCleanup = false;
44
+ }
45
+ }
46
+ return {
47
+ start() {
48
+ if (intervalId) {
49
+ log('Cleanup job already running');
50
+ return;
51
+ }
52
+ log('Starting cleanup job', { intervalMs });
53
+ intervalId = setInterval(runCleanup, intervalMs);
54
+ // Run initial cleanup after a short delay
55
+ setTimeout(runCleanup, 10000);
56
+ },
57
+ stop() {
58
+ if (intervalId) {
59
+ log('Stopping cleanup job');
60
+ clearInterval(intervalId);
61
+ intervalId = null;
62
+ }
63
+ },
64
+ async runNow() {
65
+ return runCleanup();
66
+ },
67
+ isRunning() {
68
+ return intervalId !== null;
69
+ },
70
+ };
71
+ }
72
+ //# sourceMappingURL=cleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../../src/plugins/rate-limit/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmCH;;;;;GAKG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YACT,CAAC;YAED,GAAG,CAAC,sBAAsB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YAC5C,UAAU,GAAG,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAEjD,0CAA0C;YAC1C,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,IAAI;YACF,IAAI,UAAU,EAAE,CAAC;gBACf,GAAG,CAAC,sBAAsB,CAAC,CAAC;gBAC5B,aAAa,CAAC,UAAU,CAAC,CAAC;gBAC1B,UAAU,GAAG,IAAI,CAAC;YACpB,CAAC;QACH,CAAC;QAED,KAAK,CAAC,MAAM;YACV,OAAO,UAAU,EAAE,CAAC;QACtB,CAAC;QAED,SAAS;YACP,OAAO,UAAU,KAAK,IAAI,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Rate Limit Plugin Environment Configuration
3
+ *
4
+ * Factory function for configuring rate limiting via environment variables.
5
+ *
6
+ * Environment Variables:
7
+ * - RATE_LIMIT_ENABLED: Enable rate limiting (default: true)
8
+ * - RATE_LIMIT_STRATEGY: Strategy to use: sliding-window, fixed-window, token-bucket (default: sliding-window)
9
+ * - RATE_LIMIT_WINDOW_MS: Window size in milliseconds (default: 60000 = 1 minute)
10
+ * - RATE_LIMIT_MAX_REQUESTS: Maximum requests per window (default: 100)
11
+ * - RATE_LIMIT_CACHE_TYPE: Cache type: redis, memory, auto (default: auto)
12
+ * - RATE_LIMIT_CLEANUP_ENABLED: Enable cleanup job (default: true)
13
+ * - RATE_LIMIT_CLEANUP_INTERVAL_MS: Cleanup interval in ms (default: 300000 = 5 minutes)
14
+ * - RATE_LIMIT_API_ENABLED: Enable status API endpoints (default: true)
15
+ * - RATE_LIMIT_API_PREFIX: API route prefix (default: /rate-limit)
16
+ * - RATE_LIMIT_DEBUG: Enable debug logging (default: false)
17
+ *
18
+ * PostgreSQL Store (via postgres-plugin):
19
+ * - RATE_LIMIT_TABLE_NAME: Table name (default: rate_limits)
20
+ * - RATE_LIMIT_ENABLE_RLS: Enable Row-Level Security (default: true)
21
+ * - RATE_LIMIT_AUTO_CREATE_TABLES: Auto-create tables (default: true)
22
+ *
23
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
24
+ */
25
+ import type { Plugin } from '../../core/plugin-registry.js';
26
+ import type { RateLimitPluginConfig, RateLimitStrategy } from './types.js';
27
+ interface RateLimitConfigStatus {
28
+ state: 'disabled' | 'enabled' | 'error';
29
+ strategy: RateLimitStrategy | null;
30
+ error?: string;
31
+ config?: Record<string, string | number | boolean>;
32
+ }
33
+ /**
34
+ * Get an environment variable, treating empty strings as undefined
35
+ */
36
+ declare function getEnv(key: string): string | undefined;
37
+ /**
38
+ * Parse a boolean environment variable
39
+ */
40
+ declare function getEnvBool(key: string, defaultValue: boolean): boolean;
41
+ /**
42
+ * Parse an integer environment variable
43
+ */
44
+ declare function getEnvInt(key: string, defaultValue: number): number;
45
+ export interface RateLimitEnvPluginOptions {
46
+ /**
47
+ * Override the default store. If not provided, uses postgres-plugin.
48
+ */
49
+ store?: RateLimitPluginConfig['store'];
50
+ /**
51
+ * Debug mode override
52
+ */
53
+ debug?: boolean;
54
+ }
55
+ /**
56
+ * Create a rate limit plugin configured from environment variables.
57
+ *
58
+ * The plugin state depends on environment configuration:
59
+ * - **disabled**: RATE_LIMIT_ENABLED=false - no rate limiting is applied
60
+ * - **enabled**: Valid configuration - rate limiting is active
61
+ * - **error**: Invalid configuration or missing postgres - plugin is disabled with error details
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Zero-config setup - reads everything from env vars
66
+ * // Requires postgres-plugin to be registered first
67
+ * const rateLimitPlugin = createRateLimitPluginFromEnv();
68
+ *
69
+ * // With custom store
70
+ * const rateLimitPlugin = createRateLimitPluginFromEnv({
71
+ * store: myCustomStore,
72
+ * });
73
+ * ```
74
+ *
75
+ * @param options - Optional overrides
76
+ * @returns A Plugin instance
77
+ */
78
+ export declare function createRateLimitPluginFromEnv(options?: RateLimitEnvPluginOptions): Plugin;
79
+ /**
80
+ * Get current rate limit plugin status
81
+ */
82
+ export declare function getRateLimitConfigStatus(): RateLimitConfigStatus;
83
+ export declare const __testing: {
84
+ getEnv: typeof getEnv;
85
+ getEnvBool: typeof getEnvBool;
86
+ getEnvInt: typeof getEnvInt;
87
+ VALID_STRATEGIES: RateLimitStrategy[];
88
+ VALID_CACHE_TYPES: ("redis" | "memory" | "auto" | undefined)[];
89
+ };
90
+ export {};
91
+ //# sourceMappingURL=env-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-config.d.ts","sourceRoot":"","sources":["../../../src/plugins/rate-limit/env-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAgC,MAAM,+BAA+B,CAAC;AAC1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAwB,MAAM,YAAY,CAAC;AASjG,UAAU,qBAAqB;IAC7B,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACpD;AAWD;;GAEG;AACH,iBAAS,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM/C;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAa/D;AAED;;GAEG;AACH,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAO5D;AAMD,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,KAAK,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAEvC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AASD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,MAAM,CAkGxF;AAMD;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,qBAAqB,CAEhE;AAiJD,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC"}