@baasix/baasix 0.1.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 (666) hide show
  1. package/LICENSE.MD +85 -0
  2. package/README.md +526 -0
  3. package/assets/banner.jpg +0 -0
  4. package/assets/banner_small.jpg +0 -0
  5. package/assets/logo_icon.svg +20 -0
  6. package/assets/logo_icon_rounded.svg +20 -0
  7. package/dist/LICENSE.MD +85 -0
  8. package/dist/README.md +526 -0
  9. package/dist/app/404/index.html +1 -0
  10. package/dist/app/404.html +1 -0
  11. package/dist/app/_next/static/chunks/041e1f03-56ae8a902a7f2fe6.js +24 -0
  12. package/dist/app/_next/static/chunks/1117-05479929a8da73e3.js +1 -0
  13. package/dist/app/_next/static/chunks/1299.77cc7b7b76b75cba.js +1 -0
  14. package/dist/app/_next/static/chunks/1303-35a96e9c9cdeab9d.js +1 -0
  15. package/dist/app/_next/static/chunks/1509-56ac00cdaaecdf53.js +1 -0
  16. package/dist/app/_next/static/chunks/1668-e3eabd0f6753c780.js +1 -0
  17. package/dist/app/_next/static/chunks/1783-d9fb550fd324300c.js +1 -0
  18. package/dist/app/_next/static/chunks/2117-29b5fa47421595ad.js +2 -0
  19. package/dist/app/_next/static/chunks/2344.35b46d2179a765b5.js +1 -0
  20. package/dist/app/_next/static/chunks/257.990da16794a31292.js +1 -0
  21. package/dist/app/_next/static/chunks/2676-73b0ee7c80073a84.js +1 -0
  22. package/dist/app/_next/static/chunks/3563-b8842744384391fe.js +1 -0
  23. package/dist/app/_next/static/chunks/363642f4-933b579ed3c85f60.js +1 -0
  24. package/dist/app/_next/static/chunks/3817-e20c8f0a0810fc95.js +1 -0
  25. package/dist/app/_next/static/chunks/3834.84944e390d902509.js +2 -0
  26. package/dist/app/_next/static/chunks/4043-3a30c8a75896f241.js +1 -0
  27. package/dist/app/_next/static/chunks/4225-14090c7c0cd9dec6.js +1 -0
  28. package/dist/app/_next/static/chunks/4438-c9a12ca15b6e9160.js +1 -0
  29. package/dist/app/_next/static/chunks/4458-679fd0c6884f456a.js +1 -0
  30. package/dist/app/_next/static/chunks/4475-8bdfbd536fba8c48.js +1 -0
  31. package/dist/app/_next/static/chunks/4883-8a924721bb21b3b0.js +1 -0
  32. package/dist/app/_next/static/chunks/489-683ab07188f9df2b.js +1 -0
  33. package/dist/app/_next/static/chunks/4952-1b97320cf61f3f21.js +1 -0
  34. package/dist/app/_next/static/chunks/5094-8d53e403235d4ca6.js +1 -0
  35. package/dist/app/_next/static/chunks/5101-3a146e0625747ad1.js +1 -0
  36. package/dist/app/_next/static/chunks/54a60aa6-d9747982e0a81f58.js +79 -0
  37. package/dist/app/_next/static/chunks/5650-f096291df402bfc2.js +1 -0
  38. package/dist/app/_next/static/chunks/600-539045311240f579.js +1 -0
  39. package/dist/app/_next/static/chunks/6170-803b82e19d3ade6d.js +89 -0
  40. package/dist/app/_next/static/chunks/6241-30d7169d1010e5a4.js +1 -0
  41. package/dist/app/_next/static/chunks/6530-a91e10cffa4200c4.js +1 -0
  42. package/dist/app/_next/static/chunks/6547-4bbbdb5c399aef1e.js +1 -0
  43. package/dist/app/_next/static/chunks/6712-781937c53a2c49da.js +1 -0
  44. package/dist/app/_next/static/chunks/6fcbdc68-90be1a5480b8d353.js +1 -0
  45. package/dist/app/_next/static/chunks/70e0d97a-aeaf0cdc26ba1a58.js +1 -0
  46. package/dist/app/_next/static/chunks/7214-5154a89d08d24dde.js +1 -0
  47. package/dist/app/_next/static/chunks/7324-b53229c59a640880.js +10 -0
  48. package/dist/app/_next/static/chunks/7636-66424f0b51d350e9.js +1 -0
  49. package/dist/app/_next/static/chunks/7874-39a3f2541165a675.js +1 -0
  50. package/dist/app/_next/static/chunks/7982-9da12b83f11e3f5f.js +1 -0
  51. package/dist/app/_next/static/chunks/8213a2eb-da25a3b3c5521b2b.js +1 -0
  52. package/dist/app/_next/static/chunks/8473-6598318371eca31b.js +1 -0
  53. package/dist/app/_next/static/chunks/8640fa6b-72e43370f68e5587.js +1 -0
  54. package/dist/app/_next/static/chunks/9090-3ef676f29c95f1c7.js +1 -0
  55. package/dist/app/_next/static/chunks/9124-a02f9e209e6e3cce.js +1 -0
  56. package/dist/app/_next/static/chunks/926-156f32067d111d6b.js +1 -0
  57. package/dist/app/_next/static/chunks/9487-b17481605e513b83.js +1 -0
  58. package/dist/app/_next/static/chunks/9599-a7e572bb88c3392b.js +1 -0
  59. package/dist/app/_next/static/chunks/9881-419697138376e755.js +1 -0
  60. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/all-activity/page-8917930b4d663405.js +1 -0
  61. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/email-log/page-b27a6ee32782d7df.js +1 -0
  62. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/notifications/page-b7eda523ede2702c.js +1 -0
  63. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/page-1cfa62d1caedaed0.js +1 -0
  64. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/sessions/page-3e21e20db90aeff7.js +1 -0
  65. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-executions/page-27bcc26b747fb29b.js +1 -0
  66. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-logs/page-9f9e9e952aef436e.js +1 -0
  67. package/dist/app/_next/static/chunks/app/(authenticated)/change-password/page-8d61aa499eabb127.js +1 -0
  68. package/dist/app/_next/static/chunks/app/(authenticated)/dashboard/page-1ceeac9e72997a8a.js +1 -0
  69. package/dist/app/_next/static/chunks/app/(authenticated)/data-browser/page-8cda2b57759dd670.js +1 -0
  70. package/dist/app/_next/static/chunks/app/(authenticated)/file-manager/page-8c6f1b1da66ad7e4.js +1 -0
  71. package/dist/app/_next/static/chunks/app/(authenticated)/layout-f70d225b2759c998.js +1 -0
  72. package/dist/app/_next/static/chunks/app/(authenticated)/settings/migrations/page-aacec8f7cfb40ab2.js +1 -0
  73. package/dist/app/_next/static/chunks/app/(authenticated)/settings/permissions/page-828110cfcde429c6.js +1 -0
  74. package/dist/app/_next/static/chunks/app/(authenticated)/settings/project/page-420e794bb76bd204.js +1 -0
  75. package/dist/app/_next/static/chunks/app/(authenticated)/settings/roles/page-9001d02b28f70708.js +1 -0
  76. package/dist/app/_next/static/chunks/app/(authenticated)/settings/schema/page-899574f35091dd58.js +1 -0
  77. package/dist/app/_next/static/chunks/app/(authenticated)/settings/tasks/page-ad7ab3e27c83f44f.js +1 -0
  78. package/dist/app/_next/static/chunks/app/(authenticated)/settings/templates/edit/page-bd83414cb8c4cb04.js +1 -0
  79. package/dist/app/_next/static/chunks/app/(authenticated)/settings/templates/page-3181447f8772b1d3.js +1 -0
  80. package/dist/app/_next/static/chunks/app/(authenticated)/settings/tenants/page-ef9bfbacef5a1d73.js +1 -0
  81. package/dist/app/_next/static/chunks/app/(authenticated)/users/invites/page-480306b7b2bbac7e.js +1 -0
  82. package/dist/app/_next/static/chunks/app/(authenticated)/users/list/page-74da51254c2606b3.js +1 -0
  83. package/dist/app/_next/static/chunks/app/(authenticated)/users/page-e99c6f0b915001b2.js +1 -0
  84. package/dist/app/_next/static/chunks/app/(authenticated)/users/preferences/page-1a935630ce8f2b12.js +1 -0
  85. package/dist/app/_next/static/chunks/app/(authenticated)/users/user-roles/page-901dfb8ea1f39ca8.js +1 -0
  86. package/dist/app/_next/static/chunks/app/(authenticated)/workflows/detail/page-9a6b839aea688ca4.js +1 -0
  87. package/dist/app/_next/static/chunks/app/(authenticated)/workflows/edit/page-11774efbc2fecae2.js +1 -0
  88. package/dist/app/_next/static/chunks/app/(authenticated)/workflows/execution/page-8ec1aea90412c03d.js +1 -0
  89. package/dist/app/_next/static/chunks/app/(authenticated)/workflows/page-88bc5b36ccb0a1f7.js +1 -0
  90. package/dist/app/_next/static/chunks/app/(public)/forgot-password/page-ed263fd46ef81c20.js +1 -0
  91. package/dist/app/_next/static/chunks/app/(public)/layout-f538977545844af8.js +1 -0
  92. package/dist/app/_next/static/chunks/app/(public)/login/page-c0a10b137f346096.js +1 -0
  93. package/dist/app/_next/static/chunks/app/(public)/register/page-4cb7644893efd9b3.js +1 -0
  94. package/dist/app/_next/static/chunks/app/_not-found/page-653f8815b78256cc.js +1 -0
  95. package/dist/app/_next/static/chunks/app/layout-591ca7a3e16528a1.js +1 -0
  96. package/dist/app/_next/static/chunks/app/page-dd19d124b5fa2577.js +1 -0
  97. package/dist/app/_next/static/chunks/c37d3baf.c2ff165f5b02c692.js +1 -0
  98. package/dist/app/_next/static/chunks/d0deef33.0379166a4ec23470.js +1 -0
  99. package/dist/app/_next/static/chunks/fd9d1056-54169f07cd680d6c.js +1 -0
  100. package/dist/app/_next/static/chunks/framework-8e0e0f4a6b83a956.js +1 -0
  101. package/dist/app/_next/static/chunks/main-324e91f5a430cddf.js +1 -0
  102. package/dist/app/_next/static/chunks/main-app-55bcae20c77aaf0e.js +1 -0
  103. package/dist/app/_next/static/chunks/pages/_app-3c9ca398d360b709.js +1 -0
  104. package/dist/app/_next/static/chunks/pages/_error-cf5ca766ac8f493f.js +1 -0
  105. package/dist/app/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  106. package/dist/app/_next/static/chunks/webpack-2c306566f7ee1b63.js +1 -0
  107. package/dist/app/_next/static/css/6c4002bae4e236b2.css +3 -0
  108. package/dist/app/_next/static/css/a275cc2b185e04f8.css +1 -0
  109. package/dist/app/_next/static/eCWhKA8XHqmB1zgFcEtN2/_buildManifest.js +1 -0
  110. package/dist/app/_next/static/eCWhKA8XHqmB1zgFcEtN2/_ssgManifest.js +1 -0
  111. package/dist/app/activity-log/all-activity/index.html +1 -0
  112. package/dist/app/activity-log/all-activity/index.txt +14 -0
  113. package/dist/app/activity-log/email-log/index.html +1 -0
  114. package/dist/app/activity-log/email-log/index.txt +14 -0
  115. package/dist/app/activity-log/index.html +1 -0
  116. package/dist/app/activity-log/index.txt +14 -0
  117. package/dist/app/activity-log/notifications/index.html +1 -0
  118. package/dist/app/activity-log/notifications/index.txt +14 -0
  119. package/dist/app/activity-log/sessions/index.html +1 -0
  120. package/dist/app/activity-log/sessions/index.txt +14 -0
  121. package/dist/app/activity-log/workflow-executions/index.html +1 -0
  122. package/dist/app/activity-log/workflow-executions/index.txt +14 -0
  123. package/dist/app/activity-log/workflow-logs/index.html +1 -0
  124. package/dist/app/activity-log/workflow-logs/index.txt +14 -0
  125. package/dist/app/change-password/index.html +1 -0
  126. package/dist/app/change-password/index.txt +14 -0
  127. package/dist/app/dashboard/index.html +1 -0
  128. package/dist/app/dashboard/index.txt +14 -0
  129. package/dist/app/data-browser/index.html +1 -0
  130. package/dist/app/data-browser/index.txt +14 -0
  131. package/dist/app/file-manager/index.html +1 -0
  132. package/dist/app/file-manager/index.txt +14 -0
  133. package/dist/app/forgot-password/index.html +1 -0
  134. package/dist/app/forgot-password/index.txt +13 -0
  135. package/dist/app/index.html +1 -0
  136. package/dist/app/index.txt +9 -0
  137. package/dist/app/login/index.html +1 -0
  138. package/dist/app/login/index.txt +13 -0
  139. package/dist/app/logo-dark.png +0 -0
  140. package/dist/app/logo-icon.svg +81 -0
  141. package/dist/app/logo-light.png +0 -0
  142. package/dist/app/register/index.html +1 -0
  143. package/dist/app/register/index.txt +13 -0
  144. package/dist/app/settings/migrations/index.html +1 -0
  145. package/dist/app/settings/migrations/index.txt +14 -0
  146. package/dist/app/settings/permissions/index.html +1 -0
  147. package/dist/app/settings/permissions/index.txt +14 -0
  148. package/dist/app/settings/project/index.html +1 -0
  149. package/dist/app/settings/project/index.txt +14 -0
  150. package/dist/app/settings/roles/index.html +1 -0
  151. package/dist/app/settings/roles/index.txt +14 -0
  152. package/dist/app/settings/schema/index.html +1 -0
  153. package/dist/app/settings/schema/index.txt +14 -0
  154. package/dist/app/settings/tasks/index.html +1 -0
  155. package/dist/app/settings/tasks/index.txt +14 -0
  156. package/dist/app/settings/templates/edit/index.html +1 -0
  157. package/dist/app/settings/templates/edit/index.txt +14 -0
  158. package/dist/app/settings/templates/index.html +1 -0
  159. package/dist/app/settings/templates/index.txt +14 -0
  160. package/dist/app/settings/tenants/index.html +1 -0
  161. package/dist/app/settings/tenants/index.txt +14 -0
  162. package/dist/app/users/index.html +1 -0
  163. package/dist/app/users/index.txt +14 -0
  164. package/dist/app/users/invites/index.html +1 -0
  165. package/dist/app/users/invites/index.txt +14 -0
  166. package/dist/app/users/list/index.html +1 -0
  167. package/dist/app/users/list/index.txt +14 -0
  168. package/dist/app/users/preferences/index.html +1 -0
  169. package/dist/app/users/preferences/index.txt +14 -0
  170. package/dist/app/users/user-roles/index.html +1 -0
  171. package/dist/app/users/user-roles/index.txt +14 -0
  172. package/dist/app/workflows/detail/index.html +1 -0
  173. package/dist/app/workflows/detail/index.txt +14 -0
  174. package/dist/app/workflows/edit/index.html +1 -0
  175. package/dist/app/workflows/edit/index.txt +14 -0
  176. package/dist/app/workflows/execution/index.html +1 -0
  177. package/dist/app/workflows/execution/index.txt +14 -0
  178. package/dist/app/workflows/index.html +1 -0
  179. package/dist/app/workflows/index.txt +14 -0
  180. package/dist/app.d.ts +36 -0
  181. package/dist/app.d.ts.map +1 -0
  182. package/dist/app.js +546 -0
  183. package/dist/app.js.map +1 -0
  184. package/dist/auth/adapters/baasix-adapter.d.ts +12 -0
  185. package/dist/auth/adapters/baasix-adapter.d.ts.map +1 -0
  186. package/dist/auth/adapters/baasix-adapter.js +318 -0
  187. package/dist/auth/adapters/baasix-adapter.js.map +1 -0
  188. package/dist/auth/adapters/index.d.ts +6 -0
  189. package/dist/auth/adapters/index.d.ts.map +1 -0
  190. package/dist/auth/adapters/index.js +5 -0
  191. package/dist/auth/adapters/index.js.map +1 -0
  192. package/dist/auth/core.d.ts +73 -0
  193. package/dist/auth/core.d.ts.map +1 -0
  194. package/dist/auth/core.js +528 -0
  195. package/dist/auth/core.js.map +1 -0
  196. package/dist/auth/index.d.ts +56 -0
  197. package/dist/auth/index.d.ts.map +1 -0
  198. package/dist/auth/index.js +58 -0
  199. package/dist/auth/index.js.map +1 -0
  200. package/dist/auth/oauth2/index.d.ts +5 -0
  201. package/dist/auth/oauth2/index.d.ts.map +1 -0
  202. package/dist/auth/oauth2/index.js +5 -0
  203. package/dist/auth/oauth2/index.js.map +1 -0
  204. package/dist/auth/oauth2/utils.d.ts +90 -0
  205. package/dist/auth/oauth2/utils.d.ts.map +1 -0
  206. package/dist/auth/oauth2/utils.js +167 -0
  207. package/dist/auth/oauth2/utils.js.map +1 -0
  208. package/dist/auth/providers/apple.d.ts +28 -0
  209. package/dist/auth/providers/apple.d.ts.map +1 -0
  210. package/dist/auth/providers/apple.js +192 -0
  211. package/dist/auth/providers/apple.js.map +1 -0
  212. package/dist/auth/providers/credential.d.ts +87 -0
  213. package/dist/auth/providers/credential.d.ts.map +1 -0
  214. package/dist/auth/providers/credential.js +162 -0
  215. package/dist/auth/providers/credential.js.map +1 -0
  216. package/dist/auth/providers/facebook.d.ts +26 -0
  217. package/dist/auth/providers/facebook.d.ts.map +1 -0
  218. package/dist/auth/providers/facebook.js +112 -0
  219. package/dist/auth/providers/facebook.js.map +1 -0
  220. package/dist/auth/providers/github.d.ts +29 -0
  221. package/dist/auth/providers/github.d.ts.map +1 -0
  222. package/dist/auth/providers/github.js +144 -0
  223. package/dist/auth/providers/github.js.map +1 -0
  224. package/dist/auth/providers/google.d.ts +32 -0
  225. package/dist/auth/providers/google.d.ts.map +1 -0
  226. package/dist/auth/providers/google.js +145 -0
  227. package/dist/auth/providers/google.js.map +1 -0
  228. package/dist/auth/providers/index.d.ts +22 -0
  229. package/dist/auth/providers/index.d.ts.map +1 -0
  230. package/dist/auth/providers/index.js +17 -0
  231. package/dist/auth/providers/index.js.map +1 -0
  232. package/dist/auth/routes.d.ts +63 -0
  233. package/dist/auth/routes.d.ts.map +1 -0
  234. package/dist/auth/routes.js +827 -0
  235. package/dist/auth/routes.js.map +1 -0
  236. package/dist/auth/services/index.d.ts +10 -0
  237. package/dist/auth/services/index.d.ts.map +1 -0
  238. package/dist/auth/services/index.js +7 -0
  239. package/dist/auth/services/index.js.map +1 -0
  240. package/dist/auth/services/session.d.ts +81 -0
  241. package/dist/auth/services/session.d.ts.map +1 -0
  242. package/dist/auth/services/session.js +186 -0
  243. package/dist/auth/services/session.js.map +1 -0
  244. package/dist/auth/services/token.d.ts +41 -0
  245. package/dist/auth/services/token.d.ts.map +1 -0
  246. package/dist/auth/services/token.js +44 -0
  247. package/dist/auth/services/token.js.map +1 -0
  248. package/dist/auth/services/verification.d.ts +77 -0
  249. package/dist/auth/services/verification.d.ts.map +1 -0
  250. package/dist/auth/services/verification.js +143 -0
  251. package/dist/auth/services/verification.js.map +1 -0
  252. package/dist/auth/types.d.ts +318 -0
  253. package/dist/auth/types.d.ts.map +1 -0
  254. package/dist/auth/types.js +6 -0
  255. package/dist/auth/types.js.map +1 -0
  256. package/dist/customTypes/arrays.d.ts +200 -0
  257. package/dist/customTypes/arrays.d.ts.map +1 -0
  258. package/dist/customTypes/arrays.js +309 -0
  259. package/dist/customTypes/arrays.js.map +1 -0
  260. package/dist/customTypes/index.d.ts +8 -0
  261. package/dist/customTypes/index.d.ts.map +1 -0
  262. package/dist/customTypes/index.js +11 -0
  263. package/dist/customTypes/index.js.map +1 -0
  264. package/dist/customTypes/postgis.d.ts +146 -0
  265. package/dist/customTypes/postgis.d.ts.map +1 -0
  266. package/dist/customTypes/postgis.js +315 -0
  267. package/dist/customTypes/postgis.js.map +1 -0
  268. package/dist/customTypes/ranges.d.ts +128 -0
  269. package/dist/customTypes/ranges.d.ts.map +1 -0
  270. package/dist/customTypes/ranges.js +257 -0
  271. package/dist/customTypes/ranges.js.map +1 -0
  272. package/dist/index.d.ts +37 -0
  273. package/dist/index.d.ts.map +1 -0
  274. package/dist/index.js +42 -0
  275. package/dist/index.js.map +1 -0
  276. package/dist/migrations/0.1.0-alpha.0_initial_setup.d.ts +29 -0
  277. package/dist/migrations/0.1.0-alpha.0_initial_setup.d.ts.map +1 -0
  278. package/dist/migrations/0.1.0-alpha.0_initial_setup.js +72 -0
  279. package/dist/migrations/0.1.0-alpha.0_initial_setup.js.map +1 -0
  280. package/dist/migrations/_example_migration.d.ts +31 -0
  281. package/dist/migrations/_example_migration.d.ts.map +1 -0
  282. package/dist/migrations/_example_migration.js +75 -0
  283. package/dist/migrations/_example_migration.js.map +1 -0
  284. package/dist/plugins/definePlugin.d.ts +49 -0
  285. package/dist/plugins/definePlugin.d.ts.map +1 -0
  286. package/dist/plugins/definePlugin.js +131 -0
  287. package/dist/plugins/definePlugin.js.map +1 -0
  288. package/dist/plugins/softDelete.d.ts +179 -0
  289. package/dist/plugins/softDelete.d.ts.map +1 -0
  290. package/dist/plugins/softDelete.js +235 -0
  291. package/dist/plugins/softDelete.js.map +1 -0
  292. package/dist/routes/auth.route.d.ts +14 -0
  293. package/dist/routes/auth.route.d.ts.map +1 -0
  294. package/dist/routes/auth.route.js +421 -0
  295. package/dist/routes/auth.route.js.map +1 -0
  296. package/dist/routes/file.route.d.ts +7 -0
  297. package/dist/routes/file.route.d.ts.map +1 -0
  298. package/dist/routes/file.route.js +274 -0
  299. package/dist/routes/file.route.js.map +1 -0
  300. package/dist/routes/items.route.d.ts +7 -0
  301. package/dist/routes/items.route.d.ts.map +1 -0
  302. package/dist/routes/items.route.js +369 -0
  303. package/dist/routes/items.route.js.map +1 -0
  304. package/dist/routes/migration.route.d.ts +7 -0
  305. package/dist/routes/migration.route.d.ts.map +1 -0
  306. package/dist/routes/migration.route.js +225 -0
  307. package/dist/routes/migration.route.js.map +1 -0
  308. package/dist/routes/notification.route.d.ts +7 -0
  309. package/dist/routes/notification.route.d.ts.map +1 -0
  310. package/dist/routes/notification.route.js +124 -0
  311. package/dist/routes/notification.route.js.map +1 -0
  312. package/dist/routes/openapi.route.d.ts +7 -0
  313. package/dist/routes/openapi.route.d.ts.map +1 -0
  314. package/dist/routes/openapi.route.js +2169 -0
  315. package/dist/routes/openapi.route.js.map +1 -0
  316. package/dist/routes/permission.route.d.ts +7 -0
  317. package/dist/routes/permission.route.d.ts.map +1 -0
  318. package/dist/routes/permission.route.js +158 -0
  319. package/dist/routes/permission.route.js.map +1 -0
  320. package/dist/routes/realtime.route.d.ts +21 -0
  321. package/dist/routes/realtime.route.d.ts.map +1 -0
  322. package/dist/routes/realtime.route.js +243 -0
  323. package/dist/routes/realtime.route.js.map +1 -0
  324. package/dist/routes/reports.route.d.ts +7 -0
  325. package/dist/routes/reports.route.d.ts.map +1 -0
  326. package/dist/routes/reports.route.js +95 -0
  327. package/dist/routes/reports.route.js.map +1 -0
  328. package/dist/routes/schema.route.d.ts +7 -0
  329. package/dist/routes/schema.route.d.ts.map +1 -0
  330. package/dist/routes/schema.route.js +1780 -0
  331. package/dist/routes/schema.route.js.map +1 -0
  332. package/dist/routes/settings.route.d.ts +7 -0
  333. package/dist/routes/settings.route.d.ts.map +1 -0
  334. package/dist/routes/settings.route.js +154 -0
  335. package/dist/routes/settings.route.js.map +1 -0
  336. package/dist/routes/templates.route.d.ts +7 -0
  337. package/dist/routes/templates.route.d.ts.map +1 -0
  338. package/dist/routes/templates.route.js +91 -0
  339. package/dist/routes/templates.route.js.map +1 -0
  340. package/dist/routes/utils.route.d.ts +7 -0
  341. package/dist/routes/utils.route.d.ts.map +1 -0
  342. package/dist/routes/utils.route.js +33 -0
  343. package/dist/routes/utils.route.js.map +1 -0
  344. package/dist/routes/workflow.route.d.ts +7 -0
  345. package/dist/routes/workflow.route.d.ts.map +1 -0
  346. package/dist/routes/workflow.route.js +787 -0
  347. package/dist/routes/workflow.route.js.map +1 -0
  348. package/dist/services/AssetsService.d.ts +39 -0
  349. package/dist/services/AssetsService.d.ts.map +1 -0
  350. package/dist/services/AssetsService.js +255 -0
  351. package/dist/services/AssetsService.js.map +1 -0
  352. package/dist/services/CacheService.d.ts +169 -0
  353. package/dist/services/CacheService.d.ts.map +1 -0
  354. package/dist/services/CacheService.js +722 -0
  355. package/dist/services/CacheService.js.map +1 -0
  356. package/dist/services/FilesService.d.ts +30 -0
  357. package/dist/services/FilesService.d.ts.map +1 -0
  358. package/dist/services/FilesService.js +268 -0
  359. package/dist/services/FilesService.js.map +1 -0
  360. package/dist/services/HooksManager.d.ts +38 -0
  361. package/dist/services/HooksManager.d.ts.map +1 -0
  362. package/dist/services/HooksManager.js +165 -0
  363. package/dist/services/HooksManager.js.map +1 -0
  364. package/dist/services/ItemsService.d.ts +273 -0
  365. package/dist/services/ItemsService.d.ts.map +1 -0
  366. package/dist/services/ItemsService.js +2458 -0
  367. package/dist/services/ItemsService.js.map +1 -0
  368. package/dist/services/MailService.d.ts +76 -0
  369. package/dist/services/MailService.d.ts.map +1 -0
  370. package/dist/services/MailService.js +585 -0
  371. package/dist/services/MailService.js.map +1 -0
  372. package/dist/services/MigrationService.d.ts +243 -0
  373. package/dist/services/MigrationService.d.ts.map +1 -0
  374. package/dist/services/MigrationService.js +914 -0
  375. package/dist/services/MigrationService.js.map +1 -0
  376. package/dist/services/NotificationService.d.ts +35 -0
  377. package/dist/services/NotificationService.d.ts.map +1 -0
  378. package/dist/services/NotificationService.js +159 -0
  379. package/dist/services/NotificationService.js.map +1 -0
  380. package/dist/services/PermissionService.d.ts +128 -0
  381. package/dist/services/PermissionService.d.ts.map +1 -0
  382. package/dist/services/PermissionService.js +373 -0
  383. package/dist/services/PermissionService.js.map +1 -0
  384. package/dist/services/PluginManager.d.ts +138 -0
  385. package/dist/services/PluginManager.d.ts.map +1 -0
  386. package/dist/services/PluginManager.js +463 -0
  387. package/dist/services/PluginManager.js.map +1 -0
  388. package/dist/services/RealtimeService.d.ts +209 -0
  389. package/dist/services/RealtimeService.d.ts.map +1 -0
  390. package/dist/services/RealtimeService.js +978 -0
  391. package/dist/services/RealtimeService.js.map +1 -0
  392. package/dist/services/ReportService.d.ts +13 -0
  393. package/dist/services/ReportService.d.ts.map +1 -0
  394. package/dist/services/ReportService.js +91 -0
  395. package/dist/services/ReportService.js.map +1 -0
  396. package/dist/services/SettingsService.d.ts +60 -0
  397. package/dist/services/SettingsService.d.ts.map +1 -0
  398. package/dist/services/SettingsService.js +474 -0
  399. package/dist/services/SettingsService.js.map +1 -0
  400. package/dist/services/SocketService.d.ts +129 -0
  401. package/dist/services/SocketService.d.ts.map +1 -0
  402. package/dist/services/SocketService.js +600 -0
  403. package/dist/services/SocketService.js.map +1 -0
  404. package/dist/services/StatsService.d.ts +10 -0
  405. package/dist/services/StatsService.d.ts.map +1 -0
  406. package/dist/services/StatsService.js +40 -0
  407. package/dist/services/StatsService.js.map +1 -0
  408. package/dist/services/StorageService.d.ts +20 -0
  409. package/dist/services/StorageService.d.ts.map +1 -0
  410. package/dist/services/StorageService.js +164 -0
  411. package/dist/services/StorageService.js.map +1 -0
  412. package/dist/services/TasksService.d.ts +74 -0
  413. package/dist/services/TasksService.d.ts.map +1 -0
  414. package/dist/services/TasksService.js +404 -0
  415. package/dist/services/TasksService.js.map +1 -0
  416. package/dist/services/WorkflowService.d.ts +305 -0
  417. package/dist/services/WorkflowService.d.ts.map +1 -0
  418. package/dist/services/WorkflowService.js +1811 -0
  419. package/dist/services/WorkflowService.js.map +1 -0
  420. package/dist/templates/logo/logo.png +0 -0
  421. package/dist/templates/mails/default.liquid +23 -0
  422. package/dist/types/aggregation.d.ts +40 -0
  423. package/dist/types/aggregation.d.ts.map +1 -0
  424. package/dist/types/aggregation.js +6 -0
  425. package/dist/types/aggregation.js.map +1 -0
  426. package/dist/types/assets.d.ts +32 -0
  427. package/dist/types/assets.d.ts.map +1 -0
  428. package/dist/types/assets.js +6 -0
  429. package/dist/types/assets.js.map +1 -0
  430. package/dist/types/auth.d.ts +50 -0
  431. package/dist/types/auth.d.ts.map +1 -0
  432. package/dist/types/auth.js +6 -0
  433. package/dist/types/auth.js.map +1 -0
  434. package/dist/types/cache.d.ts +47 -0
  435. package/dist/types/cache.d.ts.map +1 -0
  436. package/dist/types/cache.js +6 -0
  437. package/dist/types/cache.js.map +1 -0
  438. package/dist/types/database.d.ts +16 -0
  439. package/dist/types/database.d.ts.map +1 -0
  440. package/dist/types/database.js +6 -0
  441. package/dist/types/database.js.map +1 -0
  442. package/dist/types/fields.d.ts +71 -0
  443. package/dist/types/fields.d.ts.map +1 -0
  444. package/dist/types/fields.js +6 -0
  445. package/dist/types/fields.js.map +1 -0
  446. package/dist/types/files.d.ts +33 -0
  447. package/dist/types/files.d.ts.map +1 -0
  448. package/dist/types/files.js +6 -0
  449. package/dist/types/files.js.map +1 -0
  450. package/dist/types/hooks.d.ts +29 -0
  451. package/dist/types/hooks.d.ts.map +1 -0
  452. package/dist/types/hooks.js +6 -0
  453. package/dist/types/hooks.js.map +1 -0
  454. package/dist/types/import-export.d.ts +62 -0
  455. package/dist/types/import-export.d.ts.map +1 -0
  456. package/dist/types/import-export.js +6 -0
  457. package/dist/types/import-export.js.map +1 -0
  458. package/dist/types/index.d.ts +31 -0
  459. package/dist/types/index.d.ts.map +1 -0
  460. package/dist/types/index.js +58 -0
  461. package/dist/types/index.js.map +1 -0
  462. package/dist/types/mail.d.ts +34 -0
  463. package/dist/types/mail.d.ts.map +1 -0
  464. package/dist/types/mail.js +6 -0
  465. package/dist/types/mail.js.map +1 -0
  466. package/dist/types/notifications.d.ts +16 -0
  467. package/dist/types/notifications.d.ts.map +1 -0
  468. package/dist/types/notifications.js +6 -0
  469. package/dist/types/notifications.js.map +1 -0
  470. package/dist/types/plugin.d.ts +351 -0
  471. package/dist/types/plugin.d.ts.map +1 -0
  472. package/dist/types/plugin.js +8 -0
  473. package/dist/types/plugin.js.map +1 -0
  474. package/dist/types/query.d.ts +71 -0
  475. package/dist/types/query.d.ts.map +1 -0
  476. package/dist/types/query.js +6 -0
  477. package/dist/types/query.js.map +1 -0
  478. package/dist/types/relations.d.ts +111 -0
  479. package/dist/types/relations.d.ts.map +1 -0
  480. package/dist/types/relations.js +6 -0
  481. package/dist/types/relations.js.map +1 -0
  482. package/dist/types/reports.d.ts +17 -0
  483. package/dist/types/reports.d.ts.map +1 -0
  484. package/dist/types/reports.js +6 -0
  485. package/dist/types/reports.js.map +1 -0
  486. package/dist/types/schema.d.ts +26 -0
  487. package/dist/types/schema.d.ts.map +1 -0
  488. package/dist/types/schema.js +6 -0
  489. package/dist/types/schema.js.map +1 -0
  490. package/dist/types/seed.d.ts +27 -0
  491. package/dist/types/seed.d.ts.map +1 -0
  492. package/dist/types/seed.js +6 -0
  493. package/dist/types/seed.js.map +1 -0
  494. package/dist/types/services.d.ts +68 -0
  495. package/dist/types/services.d.ts.map +1 -0
  496. package/dist/types/services.js +6 -0
  497. package/dist/types/services.js.map +1 -0
  498. package/dist/types/settings.d.ts +36 -0
  499. package/dist/types/settings.d.ts.map +1 -0
  500. package/dist/types/settings.js +6 -0
  501. package/dist/types/settings.js.map +1 -0
  502. package/dist/types/sockets.d.ts +26 -0
  503. package/dist/types/sockets.d.ts.map +1 -0
  504. package/dist/types/sockets.js +6 -0
  505. package/dist/types/sockets.js.map +1 -0
  506. package/dist/types/sort.d.ts +25 -0
  507. package/dist/types/sort.d.ts.map +1 -0
  508. package/dist/types/sort.js +6 -0
  509. package/dist/types/sort.js.map +1 -0
  510. package/dist/types/spatial.d.ts +19 -0
  511. package/dist/types/spatial.d.ts.map +1 -0
  512. package/dist/types/spatial.js +6 -0
  513. package/dist/types/spatial.js.map +1 -0
  514. package/dist/types/stats.d.ts +21 -0
  515. package/dist/types/stats.d.ts.map +1 -0
  516. package/dist/types/stats.js +6 -0
  517. package/dist/types/stats.js.map +1 -0
  518. package/dist/types/storage.d.ts +19 -0
  519. package/dist/types/storage.d.ts.map +1 -0
  520. package/dist/types/storage.js +6 -0
  521. package/dist/types/storage.js.map +1 -0
  522. package/dist/types/tasks.d.ts +14 -0
  523. package/dist/types/tasks.d.ts.map +1 -0
  524. package/dist/types/tasks.js +6 -0
  525. package/dist/types/tasks.js.map +1 -0
  526. package/dist/types/utils.d.ts +54 -0
  527. package/dist/types/utils.d.ts.map +1 -0
  528. package/dist/types/utils.js +6 -0
  529. package/dist/types/utils.js.map +1 -0
  530. package/dist/types/workflow.d.ts +17 -0
  531. package/dist/types/workflow.d.ts.map +1 -0
  532. package/dist/types/workflow.js +6 -0
  533. package/dist/types/workflow.js.map +1 -0
  534. package/dist/utils/aggregationUtils.d.ts +192 -0
  535. package/dist/utils/aggregationUtils.d.ts.map +1 -0
  536. package/dist/utils/aggregationUtils.js +450 -0
  537. package/dist/utils/aggregationUtils.js.map +1 -0
  538. package/dist/utils/auth.d.ts +93 -0
  539. package/dist/utils/auth.d.ts.map +1 -0
  540. package/dist/utils/auth.js +557 -0
  541. package/dist/utils/auth.js.map +1 -0
  542. package/dist/utils/cache.d.ts +64 -0
  543. package/dist/utils/cache.d.ts.map +1 -0
  544. package/dist/utils/cache.js +464 -0
  545. package/dist/utils/cache.js.map +1 -0
  546. package/dist/utils/common.d.ts +53 -0
  547. package/dist/utils/common.d.ts.map +1 -0
  548. package/dist/utils/common.js +162 -0
  549. package/dist/utils/common.js.map +1 -0
  550. package/dist/utils/db.d.ts +101 -0
  551. package/dist/utils/db.d.ts.map +1 -0
  552. package/dist/utils/db.js +413 -0
  553. package/dist/utils/db.js.map +1 -0
  554. package/dist/utils/dirname.d.ts +30 -0
  555. package/dist/utils/dirname.d.ts.map +1 -0
  556. package/dist/utils/dirname.js +95 -0
  557. package/dist/utils/dirname.js.map +1 -0
  558. package/dist/utils/dynamicVariableResolver.d.ts +17 -0
  559. package/dist/utils/dynamicVariableResolver.d.ts.map +1 -0
  560. package/dist/utils/dynamicVariableResolver.js +262 -0
  561. package/dist/utils/dynamicVariableResolver.js.map +1 -0
  562. package/dist/utils/env.d.ts +38 -0
  563. package/dist/utils/env.d.ts.map +1 -0
  564. package/dist/utils/env.js +80 -0
  565. package/dist/utils/env.js.map +1 -0
  566. package/dist/utils/errorHandler.d.ts +14 -0
  567. package/dist/utils/errorHandler.d.ts.map +1 -0
  568. package/dist/utils/errorHandler.js +79 -0
  569. package/dist/utils/errorHandler.js.map +1 -0
  570. package/dist/utils/fieldExpansion.d.ts +30 -0
  571. package/dist/utils/fieldExpansion.d.ts.map +1 -0
  572. package/dist/utils/fieldExpansion.js +145 -0
  573. package/dist/utils/fieldExpansion.js.map +1 -0
  574. package/dist/utils/fieldUtils.d.ts +179 -0
  575. package/dist/utils/fieldUtils.d.ts.map +1 -0
  576. package/dist/utils/fieldUtils.js +424 -0
  577. package/dist/utils/fieldUtils.js.map +1 -0
  578. package/dist/utils/filterOperators.d.ts +472 -0
  579. package/dist/utils/filterOperators.d.ts.map +1 -0
  580. package/dist/utils/filterOperators.js +1229 -0
  581. package/dist/utils/filterOperators.js.map +1 -0
  582. package/dist/utils/importUtils.d.ts +127 -0
  583. package/dist/utils/importUtils.d.ts.map +1 -0
  584. package/dist/utils/importUtils.js +437 -0
  585. package/dist/utils/importUtils.js.map +1 -0
  586. package/dist/utils/index.d.ts +75 -0
  587. package/dist/utils/index.d.ts.map +1 -0
  588. package/dist/utils/index.js +101 -0
  589. package/dist/utils/index.js.map +1 -0
  590. package/dist/utils/logger.d.ts +41 -0
  591. package/dist/utils/logger.d.ts.map +1 -0
  592. package/dist/utils/logger.js +217 -0
  593. package/dist/utils/logger.js.map +1 -0
  594. package/dist/utils/orderUtils.d.ts +117 -0
  595. package/dist/utils/orderUtils.d.ts.map +1 -0
  596. package/dist/utils/orderUtils.js +249 -0
  597. package/dist/utils/orderUtils.js.map +1 -0
  598. package/dist/utils/queryBuilder.d.ts +118 -0
  599. package/dist/utils/queryBuilder.d.ts.map +1 -0
  600. package/dist/utils/queryBuilder.js +489 -0
  601. package/dist/utils/queryBuilder.js.map +1 -0
  602. package/dist/utils/relationLoader.d.ts +65 -0
  603. package/dist/utils/relationLoader.d.ts.map +1 -0
  604. package/dist/utils/relationLoader.js +1081 -0
  605. package/dist/utils/relationLoader.js.map +1 -0
  606. package/dist/utils/relationPathResolver.d.ts +30 -0
  607. package/dist/utils/relationPathResolver.d.ts.map +1 -0
  608. package/dist/utils/relationPathResolver.js +173 -0
  609. package/dist/utils/relationPathResolver.js.map +1 -0
  610. package/dist/utils/relationUtils.d.ts +139 -0
  611. package/dist/utils/relationUtils.d.ts.map +1 -0
  612. package/dist/utils/relationUtils.js +711 -0
  613. package/dist/utils/relationUtils.js.map +1 -0
  614. package/dist/utils/router.d.ts +6 -0
  615. package/dist/utils/router.d.ts.map +1 -0
  616. package/dist/utils/router.js +95 -0
  617. package/dist/utils/router.js.map +1 -0
  618. package/dist/utils/schema.d.ts +88 -0
  619. package/dist/utils/schema.d.ts.map +1 -0
  620. package/dist/utils/schema.js +24 -0
  621. package/dist/utils/schema.js.map +1 -0
  622. package/dist/utils/schemaManager.d.ts +238 -0
  623. package/dist/utils/schemaManager.d.ts.map +1 -0
  624. package/dist/utils/schemaManager.js +1992 -0
  625. package/dist/utils/schemaManager.js.map +1 -0
  626. package/dist/utils/schemaValidator.d.ts +83 -0
  627. package/dist/utils/schemaValidator.d.ts.map +1 -0
  628. package/dist/utils/schemaValidator.js +491 -0
  629. package/dist/utils/schemaValidator.js.map +1 -0
  630. package/dist/utils/seed.d.ts +45 -0
  631. package/dist/utils/seed.d.ts.map +1 -0
  632. package/dist/utils/seed.js +248 -0
  633. package/dist/utils/seed.js.map +1 -0
  634. package/dist/utils/sessionCleanup.d.ts +10 -0
  635. package/dist/utils/sessionCleanup.d.ts.map +1 -0
  636. package/dist/utils/sessionCleanup.js +49 -0
  637. package/dist/utils/sessionCleanup.js.map +1 -0
  638. package/dist/utils/sortUtils.d.ts +117 -0
  639. package/dist/utils/sortUtils.d.ts.map +1 -0
  640. package/dist/utils/sortUtils.js +232 -0
  641. package/dist/utils/sortUtils.js.map +1 -0
  642. package/dist/utils/spatialUtils.d.ts +244 -0
  643. package/dist/utils/spatialUtils.d.ts.map +1 -0
  644. package/dist/utils/spatialUtils.js +359 -0
  645. package/dist/utils/spatialUtils.js.map +1 -0
  646. package/dist/utils/systemschema.d.ts +11040 -0
  647. package/dist/utils/systemschema.d.ts.map +1 -0
  648. package/dist/utils/systemschema.js +1777 -0
  649. package/dist/utils/systemschema.js.map +1 -0
  650. package/dist/utils/tenantUtils.d.ts +34 -0
  651. package/dist/utils/tenantUtils.d.ts.map +1 -0
  652. package/dist/utils/tenantUtils.js +124 -0
  653. package/dist/utils/tenantUtils.js.map +1 -0
  654. package/dist/utils/typeMapper.d.ts +25 -0
  655. package/dist/utils/typeMapper.d.ts.map +1 -0
  656. package/dist/utils/typeMapper.js +282 -0
  657. package/dist/utils/typeMapper.js.map +1 -0
  658. package/dist/utils/valueValidator.d.ts +60 -0
  659. package/dist/utils/valueValidator.d.ts.map +1 -0
  660. package/dist/utils/valueValidator.js +303 -0
  661. package/dist/utils/valueValidator.js.map +1 -0
  662. package/dist/utils/workflow.d.ts +87 -0
  663. package/dist/utils/workflow.d.ts.map +1 -0
  664. package/dist/utils/workflow.js +205 -0
  665. package/dist/utils/workflow.js.map +1 -0
  666. package/package.json +115 -0
@@ -0,0 +1,722 @@
1
+ /**
2
+ * CacheService - Comprehensive caching solution for Drizzle ORM
3
+ *
4
+ * Features:
5
+ * - Multiple adapters: InMemory, Redis/Valkey, Upstash
6
+ * - Tenant-specific caching when multi-tenancy is enabled
7
+ * - Global cache with immediate invalidation
8
+ * - Automatic invalidation on create/update/delete operations
9
+ * - Integration with Drizzle's Cache class
10
+ * - Pattern-based cache key management
11
+ */
12
+ import env from '../utils/env.js';
13
+ // ============================================================================
14
+ // IN-MEMORY CACHE ADAPTER
15
+ // ============================================================================
16
+ export class InMemoryCacheAdapter {
17
+ cache = new Map();
18
+ maxSize;
19
+ cleanupInterval = null;
20
+ constructor(maxSizeGB = 1) {
21
+ this.maxSize = maxSizeGB * 1024 * 1024 * 1024; // Convert GB to bytes
22
+ if (env.get('TEST_MODE') !== 'true') {
23
+ // Start periodic cleanup of expired entries (every 5 minutes)
24
+ this.cleanupInterval = setInterval(() => this.cleanupExpired(), 5 * 60 * 1000);
25
+ }
26
+ }
27
+ async get(key) {
28
+ const entry = this.cache.get(key);
29
+ if (!entry) {
30
+ return null;
31
+ }
32
+ // Check if expired
33
+ if (entry.expiry < Date.now()) {
34
+ this.cache.delete(key);
35
+ return null;
36
+ }
37
+ return entry.value;
38
+ }
39
+ async set(key, value, ttl = 3600, metadata) {
40
+ await this.ensureCapacity();
41
+ const entry = {
42
+ value,
43
+ expiry: Date.now() + (ttl * 1000),
44
+ tables: metadata?.tables || [],
45
+ tags: metadata?.tags || [],
46
+ tenant: metadata?.tenant,
47
+ };
48
+ this.cache.set(key, entry);
49
+ }
50
+ async delete(key) {
51
+ this.cache.delete(key);
52
+ }
53
+ async clear() {
54
+ this.cache.clear();
55
+ }
56
+ async invalidateByPattern(pattern) {
57
+ const regex = new RegExp(pattern.replace(/\*/g, '.*'));
58
+ const keysToDelete = [];
59
+ for (const key of this.cache.keys()) {
60
+ if (regex.test(key)) {
61
+ keysToDelete.push(key);
62
+ }
63
+ }
64
+ for (const key of keysToDelete) {
65
+ this.cache.delete(key);
66
+ }
67
+ }
68
+ async invalidateByTables(tables, tenant) {
69
+ const keysToDelete = [];
70
+ for (const [key, entry] of this.cache.entries()) {
71
+ // Check tenant match if multi-tenant
72
+ if (tenant !== undefined && entry.tenant !== tenant) {
73
+ continue;
74
+ }
75
+ // Check if entry involves any of the specified tables
76
+ const hasTable = entry.tables.some(t => tables.includes(t));
77
+ if (hasTable) {
78
+ keysToDelete.push(key);
79
+ }
80
+ }
81
+ for (const key of keysToDelete) {
82
+ this.cache.delete(key);
83
+ }
84
+ }
85
+ async invalidateByTags(tags, tenant) {
86
+ const keysToDelete = [];
87
+ for (const [key, entry] of this.cache.entries()) {
88
+ // Check tenant match if multi-tenant
89
+ if (tenant !== undefined && entry.tenant !== tenant) {
90
+ continue;
91
+ }
92
+ // Check if entry has any of the specified tags
93
+ const hasTag = entry.tags.some(t => tags.includes(t));
94
+ if (hasTag) {
95
+ keysToDelete.push(key);
96
+ }
97
+ }
98
+ for (const key of keysToDelete) {
99
+ this.cache.delete(key);
100
+ }
101
+ }
102
+ async getStats() {
103
+ const size = this.getCurrentSize();
104
+ return { keys: this.cache.size, size };
105
+ }
106
+ async close() {
107
+ if (this.cleanupInterval) {
108
+ clearInterval(this.cleanupInterval);
109
+ this.cleanupInterval = null;
110
+ }
111
+ this.cache.clear();
112
+ }
113
+ getCurrentSize() {
114
+ let size = 0;
115
+ for (const entry of this.cache.values()) {
116
+ size += JSON.stringify(entry).length;
117
+ }
118
+ return size;
119
+ }
120
+ async ensureCapacity() {
121
+ const currentSize = this.getCurrentSize();
122
+ if (currentSize > this.maxSize) {
123
+ // Free 20% of cache by removing oldest entries
124
+ const amountToFree = this.maxSize * 0.2;
125
+ let freedSize = 0;
126
+ // Sort by expiry time (oldest first)
127
+ const entries = Array.from(this.cache.entries())
128
+ .sort((a, b) => a[1].expiry - b[1].expiry);
129
+ for (const [key, entry] of entries) {
130
+ if (freedSize >= amountToFree)
131
+ break;
132
+ const size = JSON.stringify(entry).length;
133
+ this.cache.delete(key);
134
+ freedSize += size;
135
+ }
136
+ console.log(`[InMemoryCache] Freed ${freedSize} bytes`);
137
+ }
138
+ }
139
+ cleanupExpired() {
140
+ const now = Date.now();
141
+ const expiredKeys = [];
142
+ for (const [key, entry] of this.cache.entries()) {
143
+ if (entry.expiry < now) {
144
+ expiredKeys.push(key);
145
+ }
146
+ }
147
+ for (const key of expiredKeys) {
148
+ this.cache.delete(key);
149
+ }
150
+ if (expiredKeys.length > 0) {
151
+ console.log(`[InMemoryCache] Cleaned up ${expiredKeys.length} expired entries`);
152
+ }
153
+ }
154
+ }
155
+ // ============================================================================
156
+ // REDIS/VALKEY CACHE ADAPTER
157
+ // ============================================================================
158
+ export class RedisCacheAdapter {
159
+ client; // Redis instance
160
+ metadataPrefix = '_meta:';
161
+ constructor(redisClient) {
162
+ this.client = redisClient;
163
+ }
164
+ async get(key) {
165
+ try {
166
+ const value = await this.client.get(key);
167
+ if (!value)
168
+ return null;
169
+ return JSON.parse(value);
170
+ }
171
+ catch (error) {
172
+ console.error(`[RedisCache] Error getting key ${key}:`, error);
173
+ return null;
174
+ }
175
+ }
176
+ async set(key, value, ttl = 3600, metadata) {
177
+ try {
178
+ // Store the actual value
179
+ await this.client.set(key, JSON.stringify(value), 'EX', ttl);
180
+ // Store metadata for invalidation purposes
181
+ if (metadata) {
182
+ const metaKey = this.metadataPrefix + key;
183
+ await this.client.set(metaKey, JSON.stringify(metadata), 'EX', ttl);
184
+ }
185
+ }
186
+ catch (error) {
187
+ console.error(`[RedisCache] Error setting key ${key}:`, error);
188
+ }
189
+ }
190
+ async delete(key) {
191
+ try {
192
+ await this.client.del(key);
193
+ await this.client.del(this.metadataPrefix + key);
194
+ }
195
+ catch (error) {
196
+ console.error(`[RedisCache] Error deleting key ${key}:`, error);
197
+ }
198
+ }
199
+ async clear() {
200
+ try {
201
+ await this.client.flushdb();
202
+ }
203
+ catch (error) {
204
+ console.error('[RedisCache] Error clearing cache:', error);
205
+ }
206
+ }
207
+ async invalidateByPattern(pattern) {
208
+ try {
209
+ const keys = await this.client.keys(pattern);
210
+ if (keys.length > 0) {
211
+ await this.client.del(...keys);
212
+ // Also delete metadata keys
213
+ const metaKeys = keys.map((k) => this.metadataPrefix + k);
214
+ await this.client.del(...metaKeys);
215
+ }
216
+ }
217
+ catch (error) {
218
+ console.error(`[RedisCache] Error invalidating pattern ${pattern}:`, error);
219
+ }
220
+ }
221
+ async invalidateByTables(tables, tenant) {
222
+ try {
223
+ // Get all metadata keys
224
+ const metaKeys = await this.client.keys(this.metadataPrefix + '*');
225
+ const keysToDelete = [];
226
+ for (const metaKey of metaKeys) {
227
+ const metadata = await this.client.get(metaKey);
228
+ if (!metadata)
229
+ continue;
230
+ try {
231
+ const meta = JSON.parse(metadata);
232
+ // Check tenant match if multi-tenant
233
+ if (tenant !== undefined && meta.tenant !== tenant) {
234
+ continue;
235
+ }
236
+ // Check if metadata involves any of the specified tables
237
+ const hasTable = meta.tables?.some((t) => tables.includes(t));
238
+ if (hasTable) {
239
+ const originalKey = metaKey.substring(this.metadataPrefix.length);
240
+ keysToDelete.push(originalKey);
241
+ keysToDelete.push(metaKey);
242
+ }
243
+ }
244
+ catch (e) {
245
+ // Skip invalid metadata
246
+ }
247
+ }
248
+ if (keysToDelete.length > 0) {
249
+ await this.client.del(...keysToDelete);
250
+ console.log(`[RedisCache] Invalidated ${keysToDelete.length / 2} entries for tables: ${tables.join(', ')}`);
251
+ }
252
+ }
253
+ catch (error) {
254
+ console.error('[RedisCache] Error invalidating by tables:', error);
255
+ }
256
+ }
257
+ async invalidateByTags(tags, tenant) {
258
+ try {
259
+ // Get all metadata keys
260
+ const metaKeys = await this.client.keys(this.metadataPrefix + '*');
261
+ const keysToDelete = [];
262
+ for (const metaKey of metaKeys) {
263
+ const metadata = await this.client.get(metaKey);
264
+ if (!metadata)
265
+ continue;
266
+ try {
267
+ const meta = JSON.parse(metadata);
268
+ // Check tenant match if multi-tenant
269
+ if (tenant !== undefined && meta.tenant !== tenant) {
270
+ continue;
271
+ }
272
+ // Check if metadata has any of the specified tags
273
+ const hasTag = meta.tags?.some((t) => tags.includes(t));
274
+ if (hasTag) {
275
+ const originalKey = metaKey.substring(this.metadataPrefix.length);
276
+ keysToDelete.push(originalKey);
277
+ keysToDelete.push(metaKey);
278
+ }
279
+ }
280
+ catch (e) {
281
+ // Skip invalid metadata
282
+ }
283
+ }
284
+ if (keysToDelete.length > 0) {
285
+ await this.client.del(...keysToDelete);
286
+ console.log(`[RedisCache] Invalidated ${keysToDelete.length / 2} entries for tags: ${tags.join(', ')}`);
287
+ }
288
+ }
289
+ catch (error) {
290
+ console.error('[RedisCache] Error invalidating by tags:', error);
291
+ }
292
+ }
293
+ async getStats() {
294
+ try {
295
+ const info = await this.client.info('memory');
296
+ const keys = await this.client.dbsize();
297
+ const match = info.match(/used_memory:(\d+)/);
298
+ const size = match ? parseInt(match[1]) : undefined;
299
+ return { keys, size };
300
+ }
301
+ catch (error) {
302
+ console.error('[RedisCache] Error getting stats:', error);
303
+ return { keys: 0 };
304
+ }
305
+ }
306
+ async close() {
307
+ try {
308
+ await this.client.quit();
309
+ }
310
+ catch (error) {
311
+ console.error('[RedisCache] Error closing connection:', error);
312
+ }
313
+ }
314
+ }
315
+ // ============================================================================
316
+ // UPSTASH CACHE ADAPTER
317
+ // ============================================================================
318
+ export class UpstashCacheAdapter {
319
+ client; // Upstash Redis instance
320
+ metadataPrefix = '_meta:';
321
+ constructor(upstashClient) {
322
+ this.client = upstashClient;
323
+ }
324
+ async get(key) {
325
+ try {
326
+ const value = await this.client.get(key);
327
+ if (!value)
328
+ return null;
329
+ // Upstash may return parsed JSON directly
330
+ return typeof value === 'string' ? JSON.parse(value) : value;
331
+ }
332
+ catch (error) {
333
+ console.error(`[UpstashCache] Error getting key ${key}:`, error);
334
+ return null;
335
+ }
336
+ }
337
+ async set(key, value, ttl = 3600, metadata) {
338
+ try {
339
+ // Store the actual value with TTL
340
+ await this.client.set(key, JSON.stringify(value), { ex: ttl });
341
+ // Store metadata for invalidation purposes
342
+ if (metadata) {
343
+ const metaKey = this.metadataPrefix + key;
344
+ await this.client.set(metaKey, JSON.stringify(metadata), { ex: ttl });
345
+ }
346
+ }
347
+ catch (error) {
348
+ console.error(`[UpstashCache] Error setting key ${key}:`, error);
349
+ }
350
+ }
351
+ async delete(key) {
352
+ try {
353
+ await this.client.del(key);
354
+ await this.client.del(this.metadataPrefix + key);
355
+ }
356
+ catch (error) {
357
+ console.error(`[UpstashCache] Error deleting key ${key}:`, error);
358
+ }
359
+ }
360
+ async clear() {
361
+ try {
362
+ await this.client.flushdb();
363
+ }
364
+ catch (error) {
365
+ console.error('[UpstashCache] Error clearing cache:', error);
366
+ }
367
+ }
368
+ async invalidateByPattern(pattern) {
369
+ try {
370
+ const keys = await this.client.keys(pattern);
371
+ if (keys.length > 0) {
372
+ await this.client.del(...keys);
373
+ // Also delete metadata keys
374
+ const metaKeys = keys.map((k) => this.metadataPrefix + k);
375
+ await this.client.del(...metaKeys);
376
+ }
377
+ }
378
+ catch (error) {
379
+ console.error(`[UpstashCache] Error invalidating pattern ${pattern}:`, error);
380
+ }
381
+ }
382
+ async invalidateByTables(tables, tenant) {
383
+ try {
384
+ // Get all metadata keys
385
+ const metaKeys = await this.client.keys(this.metadataPrefix + '*');
386
+ const keysToDelete = [];
387
+ for (const metaKey of metaKeys) {
388
+ const metadata = await this.client.get(metaKey);
389
+ if (!metadata)
390
+ continue;
391
+ try {
392
+ const meta = typeof metadata === 'string' ? JSON.parse(metadata) : metadata;
393
+ // Check tenant match if multi-tenant
394
+ if (tenant !== undefined && meta.tenant !== tenant) {
395
+ continue;
396
+ }
397
+ // Check if metadata involves any of the specified tables
398
+ const hasTable = meta.tables?.some((t) => tables.includes(t));
399
+ if (hasTable) {
400
+ const originalKey = metaKey.substring(this.metadataPrefix.length);
401
+ keysToDelete.push(originalKey);
402
+ keysToDelete.push(metaKey);
403
+ }
404
+ }
405
+ catch (e) {
406
+ // Skip invalid metadata
407
+ }
408
+ }
409
+ if (keysToDelete.length > 0) {
410
+ await this.client.del(...keysToDelete);
411
+ console.log(`[UpstashCache] Invalidated ${keysToDelete.length / 2} entries for tables: ${tables.join(', ')}`);
412
+ }
413
+ }
414
+ catch (error) {
415
+ console.error('[UpstashCache] Error invalidating by tables:', error);
416
+ }
417
+ }
418
+ async invalidateByTags(tags, tenant) {
419
+ try {
420
+ // Get all metadata keys
421
+ const metaKeys = await this.client.keys(this.metadataPrefix + '*');
422
+ const keysToDelete = [];
423
+ for (const metaKey of metaKeys) {
424
+ const metadata = await this.client.get(metaKey);
425
+ if (!metadata)
426
+ continue;
427
+ try {
428
+ const meta = typeof metadata === 'string' ? JSON.parse(metadata) : metadata;
429
+ // Check tenant match if multi-tenant
430
+ if (tenant !== undefined && meta.tenant !== tenant) {
431
+ continue;
432
+ }
433
+ // Check if metadata has any of the specified tags
434
+ const hasTag = meta.tags?.some((t) => tags.includes(t));
435
+ if (hasTag) {
436
+ const originalKey = metaKey.substring(this.metadataPrefix.length);
437
+ keysToDelete.push(originalKey);
438
+ keysToDelete.push(metaKey);
439
+ }
440
+ }
441
+ catch (e) {
442
+ // Skip invalid metadata
443
+ }
444
+ }
445
+ if (keysToDelete.length > 0) {
446
+ await this.client.del(...keysToDelete);
447
+ console.log(`[UpstashCache] Invalidated ${keysToDelete.length / 2} entries for tags: ${tags.join(', ')}`);
448
+ }
449
+ }
450
+ catch (error) {
451
+ console.error('[UpstashCache] Error invalidating by tags:', error);
452
+ }
453
+ }
454
+ async getStats() {
455
+ try {
456
+ const keys = await this.client.dbsize();
457
+ return { keys };
458
+ }
459
+ catch (error) {
460
+ console.error('[UpstashCache] Error getting stats:', error);
461
+ return { keys: 0 };
462
+ }
463
+ }
464
+ async close() {
465
+ // Upstash connections are typically managed differently
466
+ // No explicit close needed for HTTP-based Upstash client
467
+ }
468
+ }
469
+ // ============================================================================
470
+ // DRIZZLE CACHE IMPLEMENTATION
471
+ // ============================================================================
472
+ /**
473
+ * BaasixDrizzleCache - Implements Drizzle's cache interface
474
+ * Integrates with our adapter system and provides tenant-aware caching
475
+ */
476
+ export class BaasixDrizzleCache {
477
+ adapter;
478
+ defaultTTL;
479
+ cacheStrategy;
480
+ multiTenant;
481
+ currentTenant = null;
482
+ constructor(adapter, options = {}) {
483
+ this.adapter = adapter;
484
+ this.cacheStrategy = options.strategy || 'explicit';
485
+ this.defaultTTL = options.defaultTTL || 3600;
486
+ this.multiTenant = options.multiTenant || false;
487
+ }
488
+ /**
489
+ * Set the current tenant context for cache operations
490
+ */
491
+ setTenant(tenantId) {
492
+ this.currentTenant = tenantId;
493
+ }
494
+ /**
495
+ * Get the current tenant context
496
+ */
497
+ getTenant() {
498
+ return this.currentTenant;
499
+ }
500
+ /**
501
+ * Drizzle Cache interface: return the caching strategy
502
+ */
503
+ strategy() {
504
+ return this.cacheStrategy;
505
+ }
506
+ /**
507
+ * Generate cache key with tenant prefix if multi-tenant
508
+ */
509
+ generateKey(baseKey, tenant) {
510
+ const tenantId = tenant !== undefined ? tenant : this.currentTenant;
511
+ if (this.multiTenant && tenantId) {
512
+ return `tenant:${tenantId}:${baseKey}`;
513
+ }
514
+ return baseKey;
515
+ }
516
+ /**
517
+ * Drizzle Cache interface: get cached query result
518
+ */
519
+ async get(key) {
520
+ const fullKey = this.generateKey(key);
521
+ const result = await this.adapter.get(fullKey);
522
+ if (result !== null) {
523
+ console.log(`[DrizzleCache] Cache hit: ${fullKey}`);
524
+ return result;
525
+ }
526
+ console.log(`[DrizzleCache] Cache miss: ${fullKey}`);
527
+ return undefined;
528
+ }
529
+ /**
530
+ * Drizzle Cache interface: store query result
531
+ */
532
+ async put(key, response, tables, config) {
533
+ const ttl = config?.ex || this.defaultTTL;
534
+ const fullKey = this.generateKey(key);
535
+ const metadata = {
536
+ tables,
537
+ tags: [],
538
+ tenant: this.multiTenant ? this.currentTenant : null,
539
+ };
540
+ await this.adapter.set(fullKey, response, ttl, metadata);
541
+ console.log(`[DrizzleCache] Cached: ${fullKey} (TTL: ${ttl}s, Tables: ${tables.join(', ')})`);
542
+ }
543
+ /**
544
+ * Drizzle Cache interface: invalidate cached queries
545
+ */
546
+ async onMutate(params) {
547
+ const { tags, tables } = params;
548
+ const tenantId = this.multiTenant ? this.currentTenant : null;
549
+ // Handle table invalidation
550
+ if (tables) {
551
+ const tableNames = Array.isArray(tables)
552
+ ? tables.map(t => typeof t === 'string' ? t : t.name || t._)
553
+ : [typeof tables === 'string' ? tables : tables.name || tables._];
554
+ await this.adapter.invalidateByTables(tableNames, tenantId);
555
+ console.log(`[DrizzleCache] Invalidated tables: ${tableNames.join(', ')}${tenantId ? ` (tenant: ${tenantId})` : ''}`);
556
+ }
557
+ // Handle tag invalidation
558
+ if (tags) {
559
+ const tagArray = Array.isArray(tags) ? tags : [tags];
560
+ await this.adapter.invalidateByTags(tagArray, tenantId);
561
+ console.log(`[DrizzleCache] Invalidated tags: ${tagArray.join(', ')}${tenantId ? ` (tenant: ${tenantId})` : ''}`);
562
+ }
563
+ }
564
+ /**
565
+ * Invalidate entire cache or by collection
566
+ */
567
+ async invalidateCollection(collection, tenant) {
568
+ if (collection) {
569
+ const tenantId = tenant !== undefined ? tenant : (this.multiTenant ? this.currentTenant : null);
570
+ await this.adapter.invalidateByTables([collection], tenantId);
571
+ console.log(`[DrizzleCache] Invalidated collection: ${collection}${tenantId ? ` (tenant: ${tenantId})` : ''}`);
572
+ }
573
+ else {
574
+ await this.adapter.clear();
575
+ console.log('[DrizzleCache] Cleared entire cache');
576
+ }
577
+ }
578
+ /**
579
+ * Get cache statistics
580
+ */
581
+ async getStats() {
582
+ return await this.adapter.getStats();
583
+ }
584
+ /**
585
+ * Close cache adapter
586
+ */
587
+ async close() {
588
+ await this.adapter.close();
589
+ }
590
+ }
591
+ // Initialize globals if not already set
592
+ globalThis.__baasix_cacheInstance = globalThis.__baasix_cacheInstance ?? null;
593
+ globalThis.__baasix_cacheInitializing = globalThis.__baasix_cacheInitializing ?? null;
594
+ /**
595
+ * Initialize the cache service based on environment configuration
596
+ */
597
+ export async function initializeCacheService() {
598
+ // Return existing instance if already initialized
599
+ if (globalThis.__baasix_cacheInstance) {
600
+ return globalThis.__baasix_cacheInstance;
601
+ }
602
+ // Prevent concurrent initialization
603
+ if (globalThis.__baasix_cacheInitializing) {
604
+ return globalThis.__baasix_cacheInitializing;
605
+ }
606
+ const initPromise = (async () => {
607
+ const cacheEnabled = env.get('CACHE_ENABLED') === 'true';
608
+ if (!cacheEnabled) {
609
+ console.log('[CacheService] Cache is disabled');
610
+ return null;
611
+ }
612
+ const cacheAdapter = env.get('CACHE_ADAPTER') || 'memory'; // 'memory', 'redis', 'upstash'
613
+ const cacheStrategy = (env.get('CACHE_STRATEGY') || 'explicit');
614
+ const defaultTTL = parseInt(env.get('CACHE_TTL') || '3600', 10);
615
+ const multiTenant = env.get('MULTI_TENANT') === 'true';
616
+ let adapter;
617
+ try {
618
+ switch (cacheAdapter.toLowerCase()) {
619
+ case 'redis':
620
+ case 'valkey': {
621
+ const Redis = (await import('ioredis')).default;
622
+ const redisUrl = env.get('CACHE_REDIS_URL');
623
+ if (!redisUrl) {
624
+ throw new Error('CACHE_REDIS_URL is required for Redis adapter');
625
+ }
626
+ const redisClient = new Redis(redisUrl);
627
+ adapter = new RedisCacheAdapter(redisClient);
628
+ console.log(`[CacheService] Initialized Redis/Valkey adapter`);
629
+ break;
630
+ }
631
+ case 'upstash': {
632
+ // @ts-ignore - Optional dependency
633
+ const { Redis } = await import('@upstash/redis');
634
+ const upstashUrl = env.get('UPSTASH_REDIS_REST_URL');
635
+ const upstashToken = env.get('UPSTASH_REDIS_REST_TOKEN');
636
+ if (!upstashUrl || !upstashToken) {
637
+ throw new Error('UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN are required for Upstash adapter');
638
+ }
639
+ const upstashClient = new Redis({
640
+ url: upstashUrl,
641
+ token: upstashToken,
642
+ });
643
+ adapter = new UpstashCacheAdapter(upstashClient);
644
+ console.log('[CacheService] Initialized Upstash adapter');
645
+ break;
646
+ }
647
+ case 'memory':
648
+ default: {
649
+ const maxSizeGB = parseFloat(env.get('CACHE_SIZE_GB') || '1');
650
+ adapter = new InMemoryCacheAdapter(maxSizeGB);
651
+ console.log(`[CacheService] Initialized InMemory adapter (${maxSizeGB}GB)`);
652
+ break;
653
+ }
654
+ }
655
+ globalThis.__baasix_cacheInstance = new BaasixDrizzleCache(adapter, {
656
+ strategy: cacheStrategy,
657
+ defaultTTL,
658
+ multiTenant,
659
+ });
660
+ console.log(`[CacheService] Cache initialized - Strategy: ${cacheStrategy}, TTL: ${defaultTTL}s, Multi-tenant: ${multiTenant}`);
661
+ return globalThis.__baasix_cacheInstance;
662
+ }
663
+ catch (error) {
664
+ console.error('[CacheService] Failed to initialize cache:', error);
665
+ // Fallback to in-memory cache
666
+ const maxSizeGB = parseFloat(env.get('CACHE_SIZE_GB') || '1');
667
+ adapter = new InMemoryCacheAdapter(maxSizeGB);
668
+ globalThis.__baasix_cacheInstance = new BaasixDrizzleCache(adapter, {
669
+ strategy: cacheStrategy,
670
+ defaultTTL,
671
+ multiTenant,
672
+ });
673
+ console.warn('[CacheService] Falling back to InMemory cache');
674
+ return globalThis.__baasix_cacheInstance;
675
+ }
676
+ })();
677
+ globalThis.__baasix_cacheInitializing = initPromise;
678
+ try {
679
+ const result = await initPromise;
680
+ return result;
681
+ }
682
+ finally {
683
+ globalThis.__baasix_cacheInitializing = null;
684
+ }
685
+ }
686
+ /**
687
+ * Get the cache instance
688
+ */
689
+ export function getCacheService() {
690
+ return globalThis.__baasix_cacheInstance;
691
+ }
692
+ /**
693
+ * Close the cache service
694
+ */
695
+ export async function closeCacheService() {
696
+ if (globalThis.__baasix_cacheInstance) {
697
+ await globalThis.__baasix_cacheInstance.close();
698
+ globalThis.__baasix_cacheInstance = null;
699
+ console.log('[CacheService] Cache service closed');
700
+ }
701
+ }
702
+ // ============================================================================
703
+ // HELPER FUNCTIONS FOR BACKWARD COMPATIBILITY
704
+ // ============================================================================
705
+ /**
706
+ * Invalidate entire cache or collection-specific cache
707
+ * Compatible with old DBCache.invalidateEntireCache()
708
+ */
709
+ export async function invalidateEntireCache(collection) {
710
+ if (globalThis.__baasix_cacheInstance) {
711
+ await globalThis.__baasix_cacheInstance.invalidateCollection(collection);
712
+ }
713
+ }
714
+ /**
715
+ * Invalidate by collection name
716
+ */
717
+ export async function invalidateCollection(collection) {
718
+ if (globalThis.__baasix_cacheInstance) {
719
+ await globalThis.__baasix_cacheInstance.invalidateCollection(collection);
720
+ }
721
+ }
722
+ //# sourceMappingURL=CacheService.js.map