@qwickapps/server 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/README.md +392 -0
  2. package/dist/core/control-panel.d.ts +7 -2
  3. package/dist/core/control-panel.d.ts.map +1 -1
  4. package/dist/core/control-panel.js +120 -54
  5. package/dist/core/control-panel.js.map +1 -1
  6. package/dist/core/gateway.d.ts +159 -79
  7. package/dist/core/gateway.d.ts.map +1 -1
  8. package/dist/core/gateway.js +679 -319
  9. package/dist/core/gateway.js.map +1 -1
  10. package/dist/core/index.d.ts +3 -1
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +2 -0
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/plugin-registry.d.ts +307 -0
  15. package/dist/core/plugin-registry.d.ts.map +1 -0
  16. package/dist/core/plugin-registry.js +352 -0
  17. package/dist/core/plugin-registry.js.map +1 -0
  18. package/dist/core/types.d.ts +16 -33
  19. package/dist/core/types.d.ts.map +1 -1
  20. package/dist/index.d.ts +8 -5
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +15 -7
  23. package/dist/index.js.map +1 -1
  24. package/dist/plugins/auth/adapters/auth0-adapter.d.ts +14 -0
  25. package/dist/plugins/auth/adapters/auth0-adapter.d.ts.map +1 -0
  26. package/dist/plugins/auth/adapters/auth0-adapter.js +179 -0
  27. package/dist/plugins/auth/adapters/auth0-adapter.js.map +1 -0
  28. package/dist/plugins/auth/adapters/basic-adapter.d.ts +13 -0
  29. package/dist/plugins/auth/adapters/basic-adapter.d.ts.map +1 -0
  30. package/dist/plugins/auth/adapters/basic-adapter.js +51 -0
  31. package/dist/plugins/auth/adapters/basic-adapter.js.map +1 -0
  32. package/dist/plugins/auth/adapters/index.d.ts +10 -0
  33. package/dist/plugins/auth/adapters/index.d.ts.map +1 -0
  34. package/dist/plugins/auth/adapters/index.js +10 -0
  35. package/dist/plugins/auth/adapters/index.js.map +1 -0
  36. package/dist/plugins/auth/adapters/supabase-adapter.d.ts +13 -0
  37. package/dist/plugins/auth/adapters/supabase-adapter.d.ts.map +1 -0
  38. package/dist/plugins/auth/adapters/supabase-adapter.js +109 -0
  39. package/dist/plugins/auth/adapters/supabase-adapter.js.map +1 -0
  40. package/dist/plugins/auth/adapters/supertokens-adapter.d.ts +18 -0
  41. package/dist/plugins/auth/adapters/supertokens-adapter.d.ts.map +1 -0
  42. package/dist/plugins/auth/adapters/supertokens-adapter.js +267 -0
  43. package/dist/plugins/auth/adapters/supertokens-adapter.js.map +1 -0
  44. package/dist/plugins/auth/auth-plugin.d.ts +40 -0
  45. package/dist/plugins/auth/auth-plugin.d.ts.map +1 -0
  46. package/dist/plugins/auth/auth-plugin.js +255 -0
  47. package/dist/plugins/auth/auth-plugin.js.map +1 -0
  48. package/dist/plugins/auth/auth-plugin.test.d.ts +9 -0
  49. package/dist/plugins/auth/auth-plugin.test.d.ts.map +1 -0
  50. package/dist/plugins/auth/auth-plugin.test.js +147 -0
  51. package/dist/plugins/auth/auth-plugin.test.js.map +1 -0
  52. package/dist/plugins/auth/env-config.d.ts +88 -0
  53. package/dist/plugins/auth/env-config.d.ts.map +1 -0
  54. package/dist/plugins/auth/env-config.js +489 -0
  55. package/dist/plugins/auth/env-config.js.map +1 -0
  56. package/dist/plugins/auth/index.d.ts +14 -0
  57. package/dist/plugins/auth/index.d.ts.map +1 -0
  58. package/dist/plugins/auth/index.js +16 -0
  59. package/dist/plugins/auth/index.js.map +1 -0
  60. package/dist/plugins/auth/supertokens-adapter.test.d.ts +10 -0
  61. package/dist/plugins/auth/supertokens-adapter.test.d.ts.map +1 -0
  62. package/dist/plugins/auth/supertokens-adapter.test.js +486 -0
  63. package/dist/plugins/auth/supertokens-adapter.test.js.map +1 -0
  64. package/dist/plugins/auth/types.d.ts +218 -0
  65. package/dist/plugins/auth/types.d.ts.map +1 -0
  66. package/dist/plugins/auth/types.js +14 -0
  67. package/dist/plugins/auth/types.js.map +1 -0
  68. package/dist/plugins/bans/bans-plugin.d.ts +59 -0
  69. package/dist/plugins/bans/bans-plugin.d.ts.map +1 -0
  70. package/dist/plugins/bans/bans-plugin.js +428 -0
  71. package/dist/plugins/bans/bans-plugin.js.map +1 -0
  72. package/dist/plugins/bans/index.d.ts +9 -0
  73. package/dist/plugins/bans/index.d.ts.map +1 -0
  74. package/dist/plugins/bans/index.js +10 -0
  75. package/dist/plugins/bans/index.js.map +1 -0
  76. package/dist/plugins/bans/stores/index.d.ts +7 -0
  77. package/dist/plugins/bans/stores/index.d.ts.map +1 -0
  78. package/dist/plugins/bans/stores/index.js +7 -0
  79. package/dist/plugins/bans/stores/index.js.map +1 -0
  80. package/dist/plugins/bans/stores/postgres-store.d.ts +29 -0
  81. package/dist/plugins/bans/stores/postgres-store.d.ts.map +1 -0
  82. package/dist/plugins/bans/stores/postgres-store.js +132 -0
  83. package/dist/plugins/bans/stores/postgres-store.js.map +1 -0
  84. package/dist/plugins/bans/types.d.ts +128 -0
  85. package/dist/plugins/bans/types.d.ts.map +1 -0
  86. package/dist/plugins/bans/types.js +11 -0
  87. package/dist/plugins/bans/types.js.map +1 -0
  88. package/dist/plugins/cache-plugin.d.ts +14 -3
  89. package/dist/plugins/cache-plugin.d.ts.map +1 -1
  90. package/dist/plugins/cache-plugin.js +27 -7
  91. package/dist/plugins/cache-plugin.js.map +1 -1
  92. package/dist/plugins/cache-plugin.test.js +99 -32
  93. package/dist/plugins/cache-plugin.test.js.map +1 -1
  94. package/dist/plugins/config-plugin.d.ts +3 -2
  95. package/dist/plugins/config-plugin.d.ts.map +1 -1
  96. package/dist/plugins/config-plugin.js +17 -10
  97. package/dist/plugins/config-plugin.js.map +1 -1
  98. package/dist/plugins/diagnostics-plugin.d.ts +2 -2
  99. package/dist/plugins/diagnostics-plugin.d.ts.map +1 -1
  100. package/dist/plugins/diagnostics-plugin.js +17 -10
  101. package/dist/plugins/diagnostics-plugin.js.map +1 -1
  102. package/dist/plugins/entitlements/entitlements-plugin.d.ts +95 -0
  103. package/dist/plugins/entitlements/entitlements-plugin.d.ts.map +1 -0
  104. package/dist/plugins/entitlements/entitlements-plugin.js +707 -0
  105. package/dist/plugins/entitlements/entitlements-plugin.js.map +1 -0
  106. package/dist/plugins/entitlements/index.d.ts +12 -0
  107. package/dist/plugins/entitlements/index.d.ts.map +1 -0
  108. package/dist/plugins/entitlements/index.js +16 -0
  109. package/dist/plugins/entitlements/index.js.map +1 -0
  110. package/dist/plugins/entitlements/sources/index.d.ts +9 -0
  111. package/dist/plugins/entitlements/sources/index.d.ts.map +1 -0
  112. package/dist/plugins/entitlements/sources/index.js +9 -0
  113. package/dist/plugins/entitlements/sources/index.js.map +1 -0
  114. package/dist/plugins/entitlements/sources/postgres-source.d.ts +29 -0
  115. package/dist/plugins/entitlements/sources/postgres-source.d.ts.map +1 -0
  116. package/dist/plugins/entitlements/sources/postgres-source.js +169 -0
  117. package/dist/plugins/entitlements/sources/postgres-source.js.map +1 -0
  118. package/dist/plugins/entitlements/types.d.ts +232 -0
  119. package/dist/plugins/entitlements/types.d.ts.map +1 -0
  120. package/dist/plugins/entitlements/types.js +11 -0
  121. package/dist/plugins/entitlements/types.js.map +1 -0
  122. package/dist/plugins/frontend-app-plugin.d.ts +9 -3
  123. package/dist/plugins/frontend-app-plugin.d.ts.map +1 -1
  124. package/dist/plugins/frontend-app-plugin.js +14 -9
  125. package/dist/plugins/frontend-app-plugin.js.map +1 -1
  126. package/dist/plugins/health-plugin.d.ts +5 -2
  127. package/dist/plugins/health-plugin.d.ts.map +1 -1
  128. package/dist/plugins/health-plugin.js +20 -5
  129. package/dist/plugins/health-plugin.js.map +1 -1
  130. package/dist/plugins/index.d.ts +10 -2
  131. package/dist/plugins/index.d.ts.map +1 -1
  132. package/dist/plugins/index.js +10 -2
  133. package/dist/plugins/index.js.map +1 -1
  134. package/dist/plugins/logs-plugin.d.ts +3 -2
  135. package/dist/plugins/logs-plugin.d.ts.map +1 -1
  136. package/dist/plugins/logs-plugin.js +21 -12
  137. package/dist/plugins/logs-plugin.js.map +1 -1
  138. package/dist/plugins/postgres-plugin.d.ts +3 -3
  139. package/dist/plugins/postgres-plugin.d.ts.map +1 -1
  140. package/dist/plugins/postgres-plugin.js +9 -7
  141. package/dist/plugins/postgres-plugin.js.map +1 -1
  142. package/dist/plugins/postgres-plugin.test.js +50 -29
  143. package/dist/plugins/postgres-plugin.test.js.map +1 -1
  144. package/dist/plugins/preferences/__tests__/deep-merge.test.d.ts +7 -0
  145. package/dist/plugins/preferences/__tests__/deep-merge.test.d.ts.map +1 -0
  146. package/dist/plugins/preferences/__tests__/deep-merge.test.js +215 -0
  147. package/dist/plugins/preferences/__tests__/deep-merge.test.js.map +1 -0
  148. package/dist/plugins/preferences/__tests__/preferences-plugin.test.d.ts +7 -0
  149. package/dist/plugins/preferences/__tests__/preferences-plugin.test.d.ts.map +1 -0
  150. package/dist/plugins/preferences/__tests__/preferences-plugin.test.js +265 -0
  151. package/dist/plugins/preferences/__tests__/preferences-plugin.test.js.map +1 -0
  152. package/dist/plugins/preferences/index.d.ts +12 -0
  153. package/dist/plugins/preferences/index.d.ts.map +1 -0
  154. package/dist/plugins/preferences/index.js +13 -0
  155. package/dist/plugins/preferences/index.js.map +1 -0
  156. package/dist/plugins/preferences/preferences-plugin.d.ts +39 -0
  157. package/dist/plugins/preferences/preferences-plugin.d.ts.map +1 -0
  158. package/dist/plugins/preferences/preferences-plugin.js +226 -0
  159. package/dist/plugins/preferences/preferences-plugin.js.map +1 -0
  160. package/dist/plugins/preferences/stores/index.d.ts +9 -0
  161. package/dist/plugins/preferences/stores/index.d.ts.map +1 -0
  162. package/dist/plugins/preferences/stores/index.js +9 -0
  163. package/dist/plugins/preferences/stores/index.js.map +1 -0
  164. package/dist/plugins/preferences/stores/postgres-store.d.ts +41 -0
  165. package/dist/plugins/preferences/stores/postgres-store.d.ts.map +1 -0
  166. package/dist/plugins/preferences/stores/postgres-store.js +181 -0
  167. package/dist/plugins/preferences/stores/postgres-store.js.map +1 -0
  168. package/dist/plugins/preferences/types.d.ts +91 -0
  169. package/dist/plugins/preferences/types.d.ts.map +1 -0
  170. package/dist/plugins/preferences/types.js +10 -0
  171. package/dist/plugins/preferences/types.js.map +1 -0
  172. package/dist/plugins/users/__tests__/users-plugin.test.d.ts +9 -0
  173. package/dist/plugins/users/__tests__/users-plugin.test.d.ts.map +1 -0
  174. package/dist/plugins/users/__tests__/users-plugin.test.js +546 -0
  175. package/dist/plugins/users/__tests__/users-plugin.test.js.map +1 -0
  176. package/dist/plugins/users/index.d.ts +12 -0
  177. package/dist/plugins/users/index.d.ts.map +1 -0
  178. package/dist/plugins/users/index.js +13 -0
  179. package/dist/plugins/users/index.js.map +1 -0
  180. package/dist/plugins/users/stores/index.d.ts +7 -0
  181. package/dist/plugins/users/stores/index.d.ts.map +1 -0
  182. package/dist/plugins/users/stores/index.js +7 -0
  183. package/dist/plugins/users/stores/index.js.map +1 -0
  184. package/dist/plugins/users/stores/postgres-store.d.ts +28 -0
  185. package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -0
  186. package/dist/plugins/users/stores/postgres-store.js +157 -0
  187. package/dist/plugins/users/stores/postgres-store.js.map +1 -0
  188. package/dist/plugins/users/types.d.ts +225 -0
  189. package/dist/plugins/users/types.d.ts.map +1 -0
  190. package/dist/plugins/users/types.js +12 -0
  191. package/dist/plugins/users/types.js.map +1 -0
  192. package/dist/plugins/users/users-plugin.d.ts +45 -0
  193. package/dist/plugins/users/users-plugin.d.ts.map +1 -0
  194. package/dist/plugins/users/users-plugin.js +359 -0
  195. package/dist/plugins/users/users-plugin.js.map +1 -0
  196. package/dist-ui/assets/index-BY8OxNgO.js +465 -0
  197. package/dist-ui/assets/index-BY8OxNgO.js.map +1 -0
  198. package/dist-ui/index.html +1 -1
  199. package/dist-ui-lib/api/controlPanelApi.d.ts +278 -0
  200. package/dist-ui-lib/components/ControlPanelApp.d.ts +61 -0
  201. package/dist-ui-lib/components/index.d.ts +18 -0
  202. package/dist-ui-lib/config/AppConfig.d.ts +7 -0
  203. package/dist-ui-lib/dashboard/DashboardWidgetRegistry.d.ts +62 -0
  204. package/dist-ui-lib/dashboard/DashboardWidgetRenderer.d.ts +8 -0
  205. package/dist-ui-lib/dashboard/PluginWidgetRenderer.d.ts +19 -0
  206. package/dist-ui-lib/dashboard/WidgetComponentRegistry.d.ts +48 -0
  207. package/dist-ui-lib/dashboard/builtInWidgets.d.ts +25 -0
  208. package/dist-ui-lib/dashboard/index.d.ts +13 -0
  209. package/dist-ui-lib/dashboard/widgets/ServiceHealthWidget.d.ts +12 -0
  210. package/dist-ui-lib/dashboard/widgets/index.d.ts +6 -0
  211. package/dist-ui-lib/index.js +5172 -0
  212. package/dist-ui-lib/index.js.map +1 -0
  213. package/dist-ui-lib/pages/AuthPage.d.ts +1 -0
  214. package/dist-ui-lib/pages/ConfigPage.d.ts +1 -0
  215. package/dist-ui-lib/pages/DashboardPage.d.ts +1 -0
  216. package/dist-ui-lib/pages/DiagnosticsPage.d.ts +1 -0
  217. package/dist-ui-lib/pages/EntitlementsPage.d.ts +17 -0
  218. package/dist-ui-lib/pages/LogsPage.d.ts +1 -0
  219. package/dist-ui-lib/pages/NotFoundPage.d.ts +1 -0
  220. package/dist-ui-lib/pages/PluginPage.d.ts +15 -0
  221. package/dist-ui-lib/pages/PluginsPage.d.ts +1 -0
  222. package/dist-ui-lib/pages/SystemPage.d.ts +1 -0
  223. package/dist-ui-lib/pages/UsersPage.d.ts +22 -0
  224. package/package.json +24 -7
  225. package/src/core/control-panel.ts +145 -61
  226. package/src/core/gateway.ts +863 -403
  227. package/src/core/index.ts +21 -2
  228. package/src/core/plugin-registry.ts +716 -0
  229. package/src/core/types.ts +31 -37
  230. package/src/index.ts +125 -19
  231. package/src/plugins/auth/adapters/auth0-adapter.ts +214 -0
  232. package/src/plugins/auth/adapters/basic-adapter.ts +61 -0
  233. package/src/plugins/auth/adapters/index.ts +10 -0
  234. package/src/plugins/auth/adapters/supabase-adapter.ts +149 -0
  235. package/src/plugins/auth/adapters/supertokens-adapter.ts +326 -0
  236. package/src/plugins/auth/auth-plugin.test.ts +176 -0
  237. package/src/plugins/auth/auth-plugin.ts +303 -0
  238. package/src/plugins/auth/env-config.ts +572 -0
  239. package/src/plugins/auth/index.ts +42 -0
  240. package/src/plugins/auth/supertokens-adapter.test.ts +621 -0
  241. package/src/plugins/auth/types.ts +245 -0
  242. package/src/plugins/bans/bans-plugin.ts +485 -0
  243. package/src/plugins/bans/index.ts +31 -0
  244. package/src/plugins/bans/stores/index.ts +7 -0
  245. package/src/plugins/bans/stores/postgres-store.ts +195 -0
  246. package/src/plugins/bans/types.ts +141 -0
  247. package/src/plugins/cache-plugin.test.ts +108 -32
  248. package/src/plugins/cache-plugin.ts +40 -9
  249. package/src/plugins/config-plugin.ts +23 -12
  250. package/src/plugins/diagnostics-plugin.ts +22 -12
  251. package/src/plugins/entitlements/entitlements-plugin.ts +820 -0
  252. package/src/plugins/entitlements/index.ts +51 -0
  253. package/src/plugins/entitlements/sources/index.ts +9 -0
  254. package/src/plugins/entitlements/sources/postgres-source.ts +253 -0
  255. package/src/plugins/entitlements/types.ts +256 -0
  256. package/src/plugins/frontend-app-plugin.ts +24 -12
  257. package/src/plugins/health-plugin.ts +27 -7
  258. package/src/plugins/index.ts +132 -4
  259. package/src/plugins/logs-plugin.ts +28 -14
  260. package/src/plugins/postgres-plugin.test.ts +52 -29
  261. package/src/plugins/postgres-plugin.ts +11 -9
  262. package/src/plugins/preferences/__tests__/deep-merge.test.ts +242 -0
  263. package/src/plugins/preferences/__tests__/preferences-plugin.test.ts +350 -0
  264. package/src/plugins/preferences/index.ts +30 -0
  265. package/src/plugins/preferences/preferences-plugin.ts +270 -0
  266. package/src/plugins/preferences/stores/index.ts +9 -0
  267. package/src/plugins/preferences/stores/postgres-store.ts +252 -0
  268. package/src/plugins/preferences/types.ts +100 -0
  269. package/src/plugins/users/__tests__/users-plugin.test.ts +690 -0
  270. package/src/plugins/users/index.ts +38 -0
  271. package/src/plugins/users/stores/index.ts +7 -0
  272. package/src/plugins/users/stores/postgres-store.ts +225 -0
  273. package/src/plugins/users/types.ts +247 -0
  274. package/src/plugins/users/users-plugin.ts +418 -0
  275. package/ui/src/App.tsx +188 -31
  276. package/ui/src/api/controlPanelApi.ts +453 -1
  277. package/ui/src/components/ControlPanelApp.tsx +212 -0
  278. package/ui/src/components/index.ts +62 -0
  279. package/ui/src/dashboard/DashboardWidgetRegistry.tsx +129 -0
  280. package/ui/src/dashboard/DashboardWidgetRenderer.tsx +34 -0
  281. package/ui/src/dashboard/PluginWidgetRenderer.tsx +118 -0
  282. package/ui/src/dashboard/WidgetComponentRegistry.tsx +120 -0
  283. package/ui/src/dashboard/builtInWidgets.tsx +35 -0
  284. package/ui/src/dashboard/index.ts +35 -0
  285. package/ui/src/dashboard/widgets/ServiceHealthWidget.tsx +140 -0
  286. package/ui/src/dashboard/widgets/index.ts +7 -0
  287. package/ui/src/pages/AuthPage.tsx +259 -0
  288. package/ui/src/pages/DashboardPage.tsx +28 -149
  289. package/ui/src/pages/EntitlementsPage.tsx +557 -0
  290. package/ui/src/pages/LogsPage.tsx +174 -8
  291. package/ui/src/pages/PluginPage.tsx +148 -0
  292. package/ui/src/pages/PluginsPage.tsx +394 -0
  293. package/ui/src/pages/SystemPage.tsx +445 -0
  294. package/ui/src/pages/UsersPage.tsx +837 -0
  295. package/ui/tsconfig.lib.json +11 -0
  296. package/ui/vite.lib.config.ts +56 -0
  297. package/dist-ui/assets/index-CW1BviRn.js +0 -465
  298. package/dist-ui/assets/index-CW1BviRn.js.map +0 -1
  299. package/ui/src/pages/HealthPage.tsx +0 -204
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Users Plugin
3
+ *
4
+ * User identity management plugin for @qwickapps/server.
5
+ * Provides CRUD operations, search, and user lookup functionality.
6
+ *
7
+ * Note: Ban management is handled by the separate Bans Plugin.
8
+ *
9
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
10
+ */
11
+ // Import helpers from other plugins for buildUserInfo
12
+ // Note: These imports are used dynamically based on registry.hasPlugin() checks
13
+ import { getEntitlements } from '../entitlements/entitlements-plugin.js';
14
+ import { getPreferences } from '../preferences/preferences-plugin.js';
15
+ import { getActiveBan } from '../bans/bans-plugin.js';
16
+ // Store instance for helper access
17
+ let currentStore = null;
18
+ let currentRegistry = null;
19
+ /**
20
+ * Create the Users plugin
21
+ */
22
+ export function createUsersPlugin(config) {
23
+ const debug = config.debug || false;
24
+ // Routes are mounted under /api by the control panel, so don't include /api in prefix
25
+ const apiPrefix = config.api?.prefix || '/users';
26
+ function log(message, data) {
27
+ if (debug) {
28
+ console.log(`[UsersPlugin] ${message}`, data || '');
29
+ }
30
+ }
31
+ return {
32
+ id: 'users',
33
+ name: 'Users',
34
+ version: '1.0.0',
35
+ async onStart(_pluginConfig, registry) {
36
+ log('Starting users plugin');
37
+ // Initialize the store (creates tables if needed)
38
+ await config.store.initialize();
39
+ log('Users plugin migrations complete');
40
+ // Store references for helper access
41
+ currentStore = config.store;
42
+ currentRegistry = registry;
43
+ // Register health check
44
+ registry.registerHealthCheck({
45
+ name: 'users-store',
46
+ type: 'custom',
47
+ check: async () => {
48
+ try {
49
+ // Simple health check - try to search with limit 1
50
+ await config.store.search({ limit: 1 });
51
+ return { healthy: true };
52
+ }
53
+ catch {
54
+ return { healthy: false };
55
+ }
56
+ },
57
+ });
58
+ // Add API routes if enabled
59
+ if (config.api?.crud !== false) {
60
+ // List/Search users
61
+ registry.addRoute({
62
+ method: 'get',
63
+ path: apiPrefix,
64
+ pluginId: 'users',
65
+ handler: async (req, res) => {
66
+ try {
67
+ const params = {
68
+ query: req.query.q,
69
+ provider: req.query.provider,
70
+ page: parseInt(req.query.page) || 1,
71
+ limit: Math.min(parseInt(req.query.limit) || 20, 100),
72
+ sortBy: req.query.sortBy || 'created_at',
73
+ sortOrder: req.query.sortOrder || 'desc',
74
+ };
75
+ const result = await config.store.search(params);
76
+ res.json(result);
77
+ }
78
+ catch (error) {
79
+ console.error('[UsersPlugin] Search error:', error);
80
+ res.status(500).json({ error: 'Failed to search users' });
81
+ }
82
+ },
83
+ });
84
+ // Get user by ID
85
+ registry.addRoute({
86
+ method: 'get',
87
+ path: `${apiPrefix}/:id`,
88
+ pluginId: 'users',
89
+ handler: async (req, res) => {
90
+ try {
91
+ const user = await config.store.getById(req.params.id);
92
+ if (!user) {
93
+ return res.status(404).json({ error: 'User not found' });
94
+ }
95
+ res.json(user);
96
+ }
97
+ catch (error) {
98
+ console.error('[UsersPlugin] Get user error:', error);
99
+ res.status(500).json({ error: 'Failed to get user' });
100
+ }
101
+ },
102
+ });
103
+ // Create user
104
+ registry.addRoute({
105
+ method: 'post',
106
+ path: apiPrefix,
107
+ pluginId: 'users',
108
+ handler: async (req, res) => {
109
+ try {
110
+ const input = {
111
+ email: req.body.email,
112
+ name: req.body.name,
113
+ external_id: req.body.external_id,
114
+ provider: req.body.provider,
115
+ picture: req.body.picture,
116
+ metadata: req.body.metadata,
117
+ };
118
+ if (!input.email) {
119
+ return res.status(400).json({ error: 'Email is required' });
120
+ }
121
+ // Check if user already exists
122
+ const existing = await config.store.getByEmail(input.email);
123
+ if (existing) {
124
+ return res.status(409).json({ error: 'User with this email already exists' });
125
+ }
126
+ const user = await config.store.create(input);
127
+ res.status(201).json(user);
128
+ }
129
+ catch (error) {
130
+ console.error('[UsersPlugin] Create user error:', error);
131
+ res.status(500).json({ error: 'Failed to create user' });
132
+ }
133
+ },
134
+ });
135
+ // Update user
136
+ registry.addRoute({
137
+ method: 'put',
138
+ path: `${apiPrefix}/:id`,
139
+ pluginId: 'users',
140
+ handler: async (req, res) => {
141
+ try {
142
+ const input = {
143
+ name: req.body.name,
144
+ picture: req.body.picture,
145
+ metadata: req.body.metadata,
146
+ };
147
+ const user = await config.store.update(req.params.id, input);
148
+ if (!user) {
149
+ return res.status(404).json({ error: 'User not found' });
150
+ }
151
+ res.json(user);
152
+ }
153
+ catch (error) {
154
+ console.error('[UsersPlugin] Update user error:', error);
155
+ res.status(500).json({ error: 'Failed to update user' });
156
+ }
157
+ },
158
+ });
159
+ // Delete user
160
+ registry.addRoute({
161
+ method: 'delete',
162
+ path: `${apiPrefix}/:id`,
163
+ pluginId: 'users',
164
+ handler: async (req, res) => {
165
+ try {
166
+ const deleted = await config.store.delete(req.params.id);
167
+ if (!deleted) {
168
+ return res.status(404).json({ error: 'User not found' });
169
+ }
170
+ res.status(204).send();
171
+ }
172
+ catch (error) {
173
+ console.error('[UsersPlugin] Delete user error:', error);
174
+ res.status(500).json({ error: 'Failed to delete user' });
175
+ }
176
+ },
177
+ });
178
+ // GET /users/:id/info - Get comprehensive user info
179
+ registry.addRoute({
180
+ method: 'get',
181
+ path: `${apiPrefix}/:id/info`,
182
+ pluginId: 'users',
183
+ handler: async (req, res) => {
184
+ try {
185
+ const user = await config.store.getById(req.params.id);
186
+ if (!user) {
187
+ return res.status(404).json({ error: 'User not found' });
188
+ }
189
+ const info = await buildUserInfo(user, registry);
190
+ res.json(info);
191
+ }
192
+ catch (error) {
193
+ console.error('[UsersPlugin] Get user info error:', error);
194
+ res.status(500).json({ error: 'Failed to get user info' });
195
+ }
196
+ },
197
+ });
198
+ // POST /users/sync - Find or create user, return comprehensive info
199
+ registry.addRoute({
200
+ method: 'post',
201
+ path: `${apiPrefix}/sync`,
202
+ pluginId: 'users',
203
+ handler: async (req, res) => {
204
+ try {
205
+ const input = req.body;
206
+ // Normalize and validate email
207
+ const email = input.email?.trim().toLowerCase();
208
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
209
+ if (!email || !emailRegex.test(email)) {
210
+ return res.status(400).json({ error: 'Valid email is required' });
211
+ }
212
+ // Validate required fields
213
+ if (!input.external_id) {
214
+ return res.status(400).json({ error: 'external_id is required' });
215
+ }
216
+ if (!input.provider) {
217
+ return res.status(400).json({ error: 'provider is required' });
218
+ }
219
+ // Find or create user
220
+ const user = await findOrCreateUser({
221
+ email: email,
222
+ external_id: input.external_id,
223
+ provider: input.provider,
224
+ name: input.name?.trim(),
225
+ picture: input.picture?.trim(),
226
+ });
227
+ const info = await buildUserInfo(user, registry);
228
+ res.json(info);
229
+ }
230
+ catch (error) {
231
+ console.error('[UsersPlugin] User sync error:', error);
232
+ res.status(500).json({ error: 'Failed to sync user' });
233
+ }
234
+ },
235
+ });
236
+ }
237
+ log('Users plugin started');
238
+ },
239
+ async onStop() {
240
+ log('Stopping users plugin');
241
+ await config.store.shutdown();
242
+ currentStore = null;
243
+ currentRegistry = null;
244
+ log('Users plugin stopped');
245
+ },
246
+ };
247
+ }
248
+ // ========================================
249
+ // Helper Functions
250
+ // ========================================
251
+ /**
252
+ * Get the current user store instance
253
+ */
254
+ export function getUserStore() {
255
+ return currentStore;
256
+ }
257
+ /**
258
+ * Get a user by ID
259
+ */
260
+ export async function getUserById(id) {
261
+ if (!currentStore) {
262
+ throw new Error('Users plugin not initialized');
263
+ }
264
+ return currentStore.getById(id);
265
+ }
266
+ /**
267
+ * Get a user by email
268
+ */
269
+ export async function getUserByEmail(email) {
270
+ if (!currentStore) {
271
+ throw new Error('Users plugin not initialized');
272
+ }
273
+ return currentStore.getByEmail(email);
274
+ }
275
+ /**
276
+ * Find or create a user from auth provider data
277
+ */
278
+ export async function findOrCreateUser(data) {
279
+ if (!currentStore) {
280
+ throw new Error('Users plugin not initialized');
281
+ }
282
+ // Try to find by external ID first
283
+ let user = await currentStore.getByExternalId(data.external_id, data.provider);
284
+ if (user) {
285
+ await currentStore.updateLastLogin(user.id);
286
+ return user;
287
+ }
288
+ // Try to find by email
289
+ user = await currentStore.getByEmail(data.email);
290
+ if (user) {
291
+ // Note: external_id cannot be updated after user creation for security reasons
292
+ await currentStore.updateLastLogin(user.id);
293
+ return user;
294
+ }
295
+ // Create new user
296
+ user = await currentStore.create({
297
+ email: data.email,
298
+ name: data.name,
299
+ external_id: data.external_id,
300
+ provider: data.provider,
301
+ picture: data.picture,
302
+ });
303
+ return user;
304
+ }
305
+ /**
306
+ * Build comprehensive user info by aggregating data from all loaded plugins.
307
+ * This helper fetches data from entitlements, preferences, and bans plugins
308
+ * in parallel (if they are loaded) and returns a unified UserInfo object.
309
+ */
310
+ export async function buildUserInfo(user, registry) {
311
+ const info = { user };
312
+ // Fetch data from other plugins in parallel
313
+ const promises = [];
314
+ if (registry.hasPlugin('entitlements')) {
315
+ promises.push(getEntitlements(user.email)
316
+ .then((result) => {
317
+ info.entitlements = result.entitlements;
318
+ })
319
+ .catch((error) => {
320
+ console.error('[UsersPlugin] Failed to fetch entitlements:', error);
321
+ // Continue without entitlements - don't fail the whole request
322
+ }));
323
+ }
324
+ if (registry.hasPlugin('preferences')) {
325
+ promises.push(getPreferences(user.id)
326
+ .then((prefs) => {
327
+ info.preferences = prefs;
328
+ })
329
+ .catch((error) => {
330
+ console.error('[UsersPlugin] Failed to fetch preferences:', error);
331
+ // Continue without preferences - don't fail the whole request
332
+ }));
333
+ }
334
+ if (registry.hasPlugin('bans')) {
335
+ promises.push(getActiveBan(user.id)
336
+ .then((ban) => {
337
+ // Transform Ban to UserInfo.ban shape (only include relevant fields)
338
+ info.ban = ban
339
+ ? {
340
+ id: ban.id,
341
+ reason: ban.reason,
342
+ banned_at: ban.banned_at,
343
+ expires_at: ban.expires_at,
344
+ }
345
+ : null;
346
+ })
347
+ .catch((error) => {
348
+ console.error('[UsersPlugin] Failed to fetch ban status:', error);
349
+ // Continue without ban info - don't fail the whole request
350
+ }));
351
+ }
352
+ // Future: roles plugin
353
+ // if (registry.hasPlugin('roles')) {
354
+ // promises.push(getUserRoles(user.id).then(roles => info.roles = roles));
355
+ // }
356
+ await Promise.all(promises);
357
+ return info;
358
+ }
359
+ //# sourceMappingURL=users-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users-plugin.js","sourceRoot":"","sources":["../../../src/plugins/users/users-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAcH,sDAAsD;AACtD,gFAAgF;AAChF,OAAO,EAAE,eAAe,EAAE,MAA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