@qwickapps/server 1.4.0 → 1.5.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 (273) hide show
  1. package/CHANGELOG.md +507 -0
  2. package/README.md +9 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +12 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/plugins/bans/bans-plugin.d.ts.map +1 -1
  8. package/dist/plugins/bans/bans-plugin.js +12 -3
  9. package/dist/plugins/bans/bans-plugin.js.map +1 -1
  10. package/dist/plugins/devices/__tests__/devices-plugin.test.d.ts +11 -0
  11. package/dist/plugins/devices/__tests__/devices-plugin.test.d.ts.map +1 -0
  12. package/dist/plugins/devices/__tests__/devices-plugin.test.js +410 -0
  13. package/dist/plugins/devices/__tests__/devices-plugin.test.js.map +1 -0
  14. package/dist/plugins/devices/__tests__/token-utils.test.d.ts +7 -0
  15. package/dist/plugins/devices/__tests__/token-utils.test.d.ts.map +1 -0
  16. package/dist/plugins/devices/__tests__/token-utils.test.js +197 -0
  17. package/dist/plugins/devices/__tests__/token-utils.test.js.map +1 -0
  18. package/dist/plugins/devices/adapters/compute-adapter.d.ts +36 -0
  19. package/dist/plugins/devices/adapters/compute-adapter.d.ts.map +1 -0
  20. package/dist/plugins/devices/adapters/compute-adapter.js +100 -0
  21. package/dist/plugins/devices/adapters/compute-adapter.js.map +1 -0
  22. package/dist/plugins/devices/adapters/index.d.ts +12 -0
  23. package/dist/plugins/devices/adapters/index.d.ts.map +1 -0
  24. package/dist/plugins/devices/adapters/index.js +10 -0
  25. package/dist/plugins/devices/adapters/index.js.map +1 -0
  26. package/dist/plugins/devices/adapters/mobile-adapter.d.ts +41 -0
  27. package/dist/plugins/devices/adapters/mobile-adapter.d.ts.map +1 -0
  28. package/dist/plugins/devices/adapters/mobile-adapter.js +131 -0
  29. package/dist/plugins/devices/adapters/mobile-adapter.js.map +1 -0
  30. package/dist/plugins/devices/devices-plugin.d.ts +70 -0
  31. package/dist/plugins/devices/devices-plugin.d.ts.map +1 -0
  32. package/dist/plugins/devices/devices-plugin.js +453 -0
  33. package/dist/plugins/devices/devices-plugin.js.map +1 -0
  34. package/dist/plugins/devices/index.d.ts +18 -0
  35. package/dist/plugins/devices/index.d.ts.map +1 -0
  36. package/dist/plugins/devices/index.js +18 -0
  37. package/dist/plugins/devices/index.js.map +1 -0
  38. package/dist/plugins/devices/stores/index.d.ts +9 -0
  39. package/dist/plugins/devices/stores/index.d.ts.map +1 -0
  40. package/dist/plugins/devices/stores/index.js +9 -0
  41. package/dist/plugins/devices/stores/index.js.map +1 -0
  42. package/dist/plugins/devices/stores/postgres-store.d.ts +26 -0
  43. package/dist/plugins/devices/stores/postgres-store.d.ts.map +1 -0
  44. package/dist/plugins/devices/stores/postgres-store.js +199 -0
  45. package/dist/plugins/devices/stores/postgres-store.js.map +1 -0
  46. package/dist/plugins/devices/token-utils.d.ts +100 -0
  47. package/dist/plugins/devices/token-utils.d.ts.map +1 -0
  48. package/dist/plugins/devices/token-utils.js +162 -0
  49. package/dist/plugins/devices/token-utils.js.map +1 -0
  50. package/dist/plugins/devices/types.d.ts +307 -0
  51. package/dist/plugins/devices/types.d.ts.map +1 -0
  52. package/dist/plugins/devices/types.js +10 -0
  53. package/dist/plugins/devices/types.js.map +1 -0
  54. package/dist/plugins/index.d.ts +14 -2
  55. package/dist/plugins/index.d.ts.map +1 -1
  56. package/dist/plugins/index.js +13 -1
  57. package/dist/plugins/index.js.map +1 -1
  58. package/dist/plugins/notifications/__tests__/notifications-manager.test.d.ts +5 -0
  59. package/dist/plugins/notifications/__tests__/notifications-manager.test.d.ts.map +1 -0
  60. package/dist/plugins/notifications/__tests__/notifications-manager.test.js +470 -0
  61. package/dist/plugins/notifications/__tests__/notifications-manager.test.js.map +1 -0
  62. package/dist/plugins/notifications/index.d.ts +71 -0
  63. package/dist/plugins/notifications/index.d.ts.map +1 -0
  64. package/dist/plugins/notifications/index.js +72 -0
  65. package/dist/plugins/notifications/index.js.map +1 -0
  66. package/dist/plugins/notifications/notifications-manager.d.ts +182 -0
  67. package/dist/plugins/notifications/notifications-manager.d.ts.map +1 -0
  68. package/dist/plugins/notifications/notifications-manager.js +610 -0
  69. package/dist/plugins/notifications/notifications-manager.js.map +1 -0
  70. package/dist/plugins/notifications/notifications-plugin.d.ts +83 -0
  71. package/dist/plugins/notifications/notifications-plugin.d.ts.map +1 -0
  72. package/dist/plugins/notifications/notifications-plugin.js +337 -0
  73. package/dist/plugins/notifications/notifications-plugin.js.map +1 -0
  74. package/dist/plugins/notifications/types.d.ts +164 -0
  75. package/dist/plugins/notifications/types.d.ts.map +1 -0
  76. package/dist/plugins/notifications/types.js +9 -0
  77. package/dist/plugins/notifications/types.js.map +1 -0
  78. package/dist/plugins/parental/__tests__/parental-plugin.test.d.ts +12 -0
  79. package/dist/plugins/parental/__tests__/parental-plugin.test.d.ts.map +1 -0
  80. package/dist/plugins/parental/__tests__/parental-plugin.test.js +349 -0
  81. package/dist/plugins/parental/__tests__/parental-plugin.test.js.map +1 -0
  82. package/dist/plugins/parental/adapters/index.d.ts +8 -0
  83. package/dist/plugins/parental/adapters/index.d.ts.map +1 -0
  84. package/dist/plugins/parental/adapters/index.js +7 -0
  85. package/dist/plugins/parental/adapters/index.js.map +1 -0
  86. package/dist/plugins/parental/adapters/kids-adapter.d.ts +24 -0
  87. package/dist/plugins/parental/adapters/kids-adapter.d.ts.map +1 -0
  88. package/dist/plugins/parental/adapters/kids-adapter.js +174 -0
  89. package/dist/plugins/parental/adapters/kids-adapter.js.map +1 -0
  90. package/dist/plugins/parental/index.d.ts +14 -0
  91. package/dist/plugins/parental/index.d.ts.map +1 -0
  92. package/dist/plugins/parental/index.js +15 -0
  93. package/dist/plugins/parental/index.js.map +1 -0
  94. package/dist/plugins/parental/parental-plugin.d.ts +88 -0
  95. package/dist/plugins/parental/parental-plugin.d.ts.map +1 -0
  96. package/dist/plugins/parental/parental-plugin.js +666 -0
  97. package/dist/plugins/parental/parental-plugin.js.map +1 -0
  98. package/dist/plugins/parental/stores/index.d.ts +7 -0
  99. package/dist/plugins/parental/stores/index.d.ts.map +1 -0
  100. package/dist/plugins/parental/stores/index.js +7 -0
  101. package/dist/plugins/parental/stores/index.js.map +1 -0
  102. package/dist/plugins/parental/stores/postgres-store.d.ts +10 -0
  103. package/dist/plugins/parental/stores/postgres-store.d.ts.map +1 -0
  104. package/dist/plugins/parental/stores/postgres-store.js +209 -0
  105. package/dist/plugins/parental/stores/postgres-store.js.map +1 -0
  106. package/dist/plugins/parental/types.d.ts +154 -0
  107. package/dist/plugins/parental/types.d.ts.map +1 -0
  108. package/dist/plugins/parental/types.js +10 -0
  109. package/dist/plugins/parental/types.js.map +1 -0
  110. package/dist/plugins/profiles/__tests__/profiles-plugin.test.d.ts +11 -0
  111. package/dist/plugins/profiles/__tests__/profiles-plugin.test.d.ts.map +1 -0
  112. package/dist/plugins/profiles/__tests__/profiles-plugin.test.js +243 -0
  113. package/dist/plugins/profiles/__tests__/profiles-plugin.test.js.map +1 -0
  114. package/dist/plugins/profiles/index.d.ts +12 -0
  115. package/dist/plugins/profiles/index.d.ts.map +1 -0
  116. package/dist/plugins/profiles/index.js +13 -0
  117. package/dist/plugins/profiles/index.js.map +1 -0
  118. package/dist/plugins/profiles/profiles-plugin.d.ts +71 -0
  119. package/dist/plugins/profiles/profiles-plugin.d.ts.map +1 -0
  120. package/dist/plugins/profiles/profiles-plugin.js +481 -0
  121. package/dist/plugins/profiles/profiles-plugin.js.map +1 -0
  122. package/dist/plugins/profiles/stores/index.d.ts +9 -0
  123. package/dist/plugins/profiles/stores/index.d.ts.map +1 -0
  124. package/dist/plugins/profiles/stores/index.js +9 -0
  125. package/dist/plugins/profiles/stores/index.js.map +1 -0
  126. package/dist/plugins/profiles/stores/postgres-store.d.ts +18 -0
  127. package/dist/plugins/profiles/stores/postgres-store.d.ts.map +1 -0
  128. package/dist/plugins/profiles/stores/postgres-store.js +310 -0
  129. package/dist/plugins/profiles/stores/postgres-store.js.map +1 -0
  130. package/dist/plugins/profiles/types.d.ts +289 -0
  131. package/dist/plugins/profiles/types.d.ts.map +1 -0
  132. package/dist/plugins/profiles/types.js +10 -0
  133. package/dist/plugins/profiles/types.js.map +1 -0
  134. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.d.ts +11 -0
  135. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.d.ts.map +1 -0
  136. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.js +305 -0
  137. package/dist/plugins/subscriptions/__tests__/subscriptions-plugin.test.js.map +1 -0
  138. package/dist/plugins/subscriptions/index.d.ts +12 -0
  139. package/dist/plugins/subscriptions/index.d.ts.map +1 -0
  140. package/dist/plugins/subscriptions/index.js +13 -0
  141. package/dist/plugins/subscriptions/index.js.map +1 -0
  142. package/dist/plugins/subscriptions/stores/index.d.ts +9 -0
  143. package/dist/plugins/subscriptions/stores/index.d.ts.map +1 -0
  144. package/dist/plugins/subscriptions/stores/index.js +9 -0
  145. package/dist/plugins/subscriptions/stores/index.js.map +1 -0
  146. package/dist/plugins/subscriptions/stores/postgres-store.d.ts +14 -0
  147. package/dist/plugins/subscriptions/stores/postgres-store.d.ts.map +1 -0
  148. package/dist/plugins/subscriptions/stores/postgres-store.js +359 -0
  149. package/dist/plugins/subscriptions/stores/postgres-store.js.map +1 -0
  150. package/dist/plugins/subscriptions/subscriptions-plugin.d.ts +82 -0
  151. package/dist/plugins/subscriptions/subscriptions-plugin.d.ts.map +1 -0
  152. package/dist/plugins/subscriptions/subscriptions-plugin.js +449 -0
  153. package/dist/plugins/subscriptions/subscriptions-plugin.js.map +1 -0
  154. package/dist/plugins/subscriptions/types.d.ts +308 -0
  155. package/dist/plugins/subscriptions/types.d.ts.map +1 -0
  156. package/dist/plugins/subscriptions/types.js +10 -0
  157. package/dist/plugins/subscriptions/types.js.map +1 -0
  158. package/dist/plugins/usage/__tests__/usage-plugin.test.d.ts +11 -0
  159. package/dist/plugins/usage/__tests__/usage-plugin.test.d.ts.map +1 -0
  160. package/dist/plugins/usage/__tests__/usage-plugin.test.js +218 -0
  161. package/dist/plugins/usage/__tests__/usage-plugin.test.js.map +1 -0
  162. package/dist/plugins/usage/index.d.ts +12 -0
  163. package/dist/plugins/usage/index.d.ts.map +1 -0
  164. package/dist/plugins/usage/index.js +13 -0
  165. package/dist/plugins/usage/index.js.map +1 -0
  166. package/dist/plugins/usage/stores/index.d.ts +9 -0
  167. package/dist/plugins/usage/stores/index.d.ts.map +1 -0
  168. package/dist/plugins/usage/stores/index.js +9 -0
  169. package/dist/plugins/usage/stores/index.js.map +1 -0
  170. package/dist/plugins/usage/stores/postgres-store.d.ts +14 -0
  171. package/dist/plugins/usage/stores/postgres-store.d.ts.map +1 -0
  172. package/dist/plugins/usage/stores/postgres-store.js +146 -0
  173. package/dist/plugins/usage/stores/postgres-store.js.map +1 -0
  174. package/dist/plugins/usage/types.d.ts +195 -0
  175. package/dist/plugins/usage/types.d.ts.map +1 -0
  176. package/dist/plugins/usage/types.js +10 -0
  177. package/dist/plugins/usage/types.js.map +1 -0
  178. package/dist/plugins/usage/usage-plugin.d.ts +51 -0
  179. package/dist/plugins/usage/usage-plugin.d.ts.map +1 -0
  180. package/dist/plugins/usage/usage-plugin.js +412 -0
  181. package/dist/plugins/usage/usage-plugin.js.map +1 -0
  182. package/dist/plugins/users/__tests__/postgres-store.test.d.ts +10 -0
  183. package/dist/plugins/users/__tests__/postgres-store.test.d.ts.map +1 -0
  184. package/dist/plugins/users/__tests__/postgres-store.test.js +229 -0
  185. package/dist/plugins/users/__tests__/postgres-store.test.js.map +1 -0
  186. package/dist/plugins/users/__tests__/users-plugin.test.js +3 -0
  187. package/dist/plugins/users/__tests__/users-plugin.test.js.map +1 -1
  188. package/dist/plugins/users/index.d.ts +2 -2
  189. package/dist/plugins/users/index.d.ts.map +1 -1
  190. package/dist/plugins/users/index.js +1 -1
  191. package/dist/plugins/users/index.js.map +1 -1
  192. package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -1
  193. package/dist/plugins/users/stores/postgres-store.js +76 -0
  194. package/dist/plugins/users/stores/postgres-store.js.map +1 -1
  195. package/dist/plugins/users/types.d.ts +74 -6
  196. package/dist/plugins/users/types.d.ts.map +1 -1
  197. package/dist/plugins/users/users-plugin.d.ts +15 -1
  198. package/dist/plugins/users/users-plugin.d.ts.map +1 -1
  199. package/dist/plugins/users/users-plugin.js +29 -0
  200. package/dist/plugins/users/users-plugin.js.map +1 -1
  201. package/dist-ui/assets/index-CynOqPkb.js +469 -0
  202. package/dist-ui/assets/index-CynOqPkb.js.map +1 -0
  203. package/dist-ui/index.html +1 -1
  204. package/dist-ui-lib/api/controlPanelApi.d.ts +46 -0
  205. package/dist-ui-lib/components/StatCard.d.ts +16 -0
  206. package/dist-ui-lib/dashboard/widgets/NotificationsStatsWidget.d.ts +12 -0
  207. package/dist-ui-lib/dashboard/widgets/index.d.ts +1 -0
  208. package/dist-ui-lib/index.js +1822 -1611
  209. package/dist-ui-lib/index.js.map +1 -1
  210. package/dist-ui-lib/pages/NotificationsPage.d.ts +9 -0
  211. package/dist-ui-lib/utils/formatters.d.ts +19 -0
  212. package/package.json +3 -2
  213. package/src/index.ts +178 -0
  214. package/src/plugins/bans/bans-plugin.ts +15 -3
  215. package/src/plugins/devices/__tests__/devices-plugin.test.ts +551 -0
  216. package/src/plugins/devices/__tests__/token-utils.test.ts +264 -0
  217. package/src/plugins/devices/adapters/compute-adapter.ts +139 -0
  218. package/src/plugins/devices/adapters/index.ts +13 -0
  219. package/src/plugins/devices/adapters/mobile-adapter.ts +179 -0
  220. package/src/plugins/devices/devices-plugin.ts +538 -0
  221. package/src/plugins/devices/index.ts +69 -0
  222. package/src/plugins/devices/stores/index.ts +9 -0
  223. package/src/plugins/devices/stores/postgres-store.ts +304 -0
  224. package/src/plugins/devices/token-utils.ts +213 -0
  225. package/src/plugins/devices/types.ts +351 -0
  226. package/src/plugins/index.ts +218 -0
  227. package/src/plugins/notifications/__tests__/notifications-manager.test.ts +637 -0
  228. package/src/plugins/notifications/index.ts +91 -0
  229. package/src/plugins/notifications/notifications-manager.ts +773 -0
  230. package/src/plugins/notifications/notifications-plugin.ts +398 -0
  231. package/src/plugins/notifications/types.ts +207 -0
  232. package/src/plugins/parental/__tests__/parental-plugin.test.ts +465 -0
  233. package/src/plugins/parental/adapters/index.ts +8 -0
  234. package/src/plugins/parental/adapters/kids-adapter.ts +206 -0
  235. package/src/plugins/parental/index.ts +55 -0
  236. package/src/plugins/parental/parental-plugin.ts +759 -0
  237. package/src/plugins/parental/stores/index.ts +7 -0
  238. package/src/plugins/parental/stores/postgres-store.ts +304 -0
  239. package/src/plugins/parental/types.ts +180 -0
  240. package/src/plugins/profiles/__tests__/profiles-plugin.test.ts +321 -0
  241. package/src/plugins/profiles/index.ts +49 -0
  242. package/src/plugins/profiles/profiles-plugin.ts +546 -0
  243. package/src/plugins/profiles/stores/index.ts +9 -0
  244. package/src/plugins/profiles/stores/postgres-store.ts +439 -0
  245. package/src/plugins/profiles/types.ts +338 -0
  246. package/src/plugins/subscriptions/__tests__/subscriptions-plugin.test.ts +404 -0
  247. package/src/plugins/subscriptions/index.ts +51 -0
  248. package/src/plugins/subscriptions/stores/index.ts +9 -0
  249. package/src/plugins/subscriptions/stores/postgres-store.ts +482 -0
  250. package/src/plugins/subscriptions/subscriptions-plugin.ts +530 -0
  251. package/src/plugins/subscriptions/types.ts +355 -0
  252. package/src/plugins/usage/__tests__/usage-plugin.test.ts +288 -0
  253. package/src/plugins/usage/index.ts +39 -0
  254. package/src/plugins/usage/stores/index.ts +9 -0
  255. package/src/plugins/usage/stores/postgres-store.ts +213 -0
  256. package/src/plugins/usage/types.ts +222 -0
  257. package/src/plugins/usage/usage-plugin.ts +484 -0
  258. package/src/plugins/users/__tests__/postgres-store.test.ts +326 -0
  259. package/src/plugins/users/__tests__/users-plugin.test.ts +3 -0
  260. package/src/plugins/users/index.ts +6 -0
  261. package/src/plugins/users/stores/postgres-store.ts +104 -0
  262. package/src/plugins/users/types.ts +82 -6
  263. package/src/plugins/users/users-plugin.ts +37 -0
  264. package/ui/src/App.tsx +5 -1
  265. package/ui/src/api/controlPanelApi.ts +103 -6
  266. package/ui/src/components/StatCard.tsx +58 -0
  267. package/ui/src/dashboard/builtInWidgets.tsx +3 -1
  268. package/ui/src/dashboard/widgets/NotificationsStatsWidget.tsx +167 -0
  269. package/ui/src/dashboard/widgets/index.ts +1 -0
  270. package/ui/src/pages/NotificationsPage.tsx +417 -0
  271. package/ui/src/utils/formatters.ts +33 -0
  272. package/dist-ui/assets/index-D7DoZ9rL.js +0 -478
  273. package/dist-ui/assets/index-D7DoZ9rL.js.map +0 -1
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Profiles Plugin Tests
3
+ *
4
+ * Unit tests for the profiles plugin including:
5
+ * - Plugin lifecycle
6
+ * - Profile CRUD operations
7
+ * - Age group calculation
8
+ * - Default profile management
9
+ */
10
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
11
+ import { createProfilesPlugin, getProfileStore, createProfile, getProfileById, updateProfile, deleteProfile, listUserProfiles, setDefaultProfile, } from '../profiles-plugin.js';
12
+ describe('Profiles Plugin', () => {
13
+ // Mock profile data
14
+ const mockProfile = {
15
+ id: 'profile-id-123',
16
+ org_id: 'org-123',
17
+ user_id: 'user-123',
18
+ name: 'Emma',
19
+ avatar: 'robot_pink',
20
+ birth_date: new Date('2018-06-15'),
21
+ age: 6,
22
+ age_group: 'child',
23
+ content_filter_level: 'strict',
24
+ daily_time_limit_minutes: 60,
25
+ allowed_hours_start: '08:00',
26
+ allowed_hours_end: '20:00',
27
+ is_active: true,
28
+ is_default: false,
29
+ metadata: { voice_id: 'en-US-child-1' },
30
+ created_at: new Date(),
31
+ updated_at: new Date(),
32
+ };
33
+ // Mock store factory
34
+ const createMockStore = () => ({
35
+ name: 'mock',
36
+ initialize: vi.fn().mockResolvedValue(undefined),
37
+ getById: vi.fn().mockResolvedValue(mockProfile),
38
+ create: vi.fn().mockResolvedValue(mockProfile),
39
+ update: vi.fn().mockResolvedValue(mockProfile),
40
+ delete: vi.fn().mockResolvedValue(true),
41
+ search: vi.fn().mockResolvedValue({
42
+ profiles: [mockProfile],
43
+ total: 1,
44
+ page: 1,
45
+ limit: 20,
46
+ totalPages: 1,
47
+ }),
48
+ listByUser: vi.fn().mockResolvedValue([mockProfile]),
49
+ getDefaultProfile: vi.fn().mockResolvedValue(mockProfile),
50
+ getProfileCount: vi.fn().mockResolvedValue(1),
51
+ getByAgeGroup: vi.fn().mockResolvedValue([mockProfile]),
52
+ setDefaultProfile: vi.fn().mockResolvedValue(true),
53
+ shutdown: vi.fn().mockResolvedValue(undefined),
54
+ });
55
+ // Mock registry factory
56
+ const createMockRegistry = () => ({
57
+ hasPlugin: vi.fn().mockReturnValue(false),
58
+ getPlugin: vi.fn().mockReturnValue(null),
59
+ listPlugins: vi.fn().mockReturnValue([]),
60
+ addRoute: vi.fn(),
61
+ addMenuItem: vi.fn(),
62
+ addPage: vi.fn(),
63
+ addWidget: vi.fn(),
64
+ getRoutes: vi.fn().mockReturnValue([]),
65
+ getMenuItems: vi.fn().mockReturnValue([]),
66
+ getPages: vi.fn().mockReturnValue([]),
67
+ getWidgets: vi.fn().mockReturnValue([]),
68
+ getConfig: vi.fn().mockReturnValue({}),
69
+ setConfig: vi.fn().mockResolvedValue(undefined),
70
+ subscribe: vi.fn().mockReturnValue(() => { }),
71
+ emit: vi.fn(),
72
+ registerHealthCheck: vi.fn(),
73
+ getApp: vi.fn().mockReturnValue({}),
74
+ getRouter: vi.fn().mockReturnValue({}),
75
+ getLogger: vi.fn().mockReturnValue({
76
+ debug: vi.fn(),
77
+ info: vi.fn(),
78
+ warn: vi.fn(),
79
+ error: vi.fn(),
80
+ }),
81
+ });
82
+ let mockStore;
83
+ let mockRegistry;
84
+ beforeEach(() => {
85
+ vi.clearAllMocks();
86
+ mockStore = createMockStore();
87
+ mockRegistry = createMockRegistry();
88
+ });
89
+ afterEach(async () => {
90
+ // Clean up by stopping the plugin if it was started
91
+ const store = getProfileStore();
92
+ if (store) {
93
+ const plugin = createProfilesPlugin({ store: mockStore });
94
+ await plugin.onStop?.();
95
+ }
96
+ });
97
+ describe('createProfilesPlugin', () => {
98
+ it('should create a plugin with correct id', () => {
99
+ const plugin = createProfilesPlugin({ store: mockStore });
100
+ expect(plugin.id).toBe('profiles');
101
+ });
102
+ it('should create a plugin with correct name', () => {
103
+ const plugin = createProfilesPlugin({ store: mockStore });
104
+ expect(plugin.name).toBe('Profiles');
105
+ });
106
+ it('should create a plugin with version', () => {
107
+ const plugin = createProfilesPlugin({ store: mockStore });
108
+ expect(plugin.version).toBe('1.0.0');
109
+ });
110
+ });
111
+ describe('onStart', () => {
112
+ it('should initialize store on start', async () => {
113
+ const plugin = createProfilesPlugin({ store: mockStore });
114
+ await plugin.onStart({}, mockRegistry);
115
+ expect(mockStore.initialize).toHaveBeenCalled();
116
+ });
117
+ it('should register health check', async () => {
118
+ const plugin = createProfilesPlugin({ store: mockStore });
119
+ await plugin.onStart({}, mockRegistry);
120
+ expect(mockRegistry.registerHealthCheck).toHaveBeenCalledWith(expect.objectContaining({
121
+ name: 'profiles-store',
122
+ type: 'custom',
123
+ }));
124
+ });
125
+ it('should register CRUD routes by default', async () => {
126
+ const plugin = createProfilesPlugin({ store: mockStore });
127
+ await plugin.onStart({}, mockRegistry);
128
+ // GET /profiles, GET /profiles/:id, POST /profiles, PUT /profiles/:id,
129
+ // DELETE /profiles/:id, POST /profiles/:id/default
130
+ expect(mockRegistry.addRoute).toHaveBeenCalled();
131
+ });
132
+ });
133
+ describe('onStop', () => {
134
+ it('should shutdown store', async () => {
135
+ const plugin = createProfilesPlugin({ store: mockStore });
136
+ await plugin.onStart({}, mockRegistry);
137
+ await plugin.onStop?.();
138
+ expect(mockStore.shutdown).toHaveBeenCalled();
139
+ });
140
+ it('should clear store reference', async () => {
141
+ const plugin = createProfilesPlugin({ store: mockStore });
142
+ await plugin.onStart({}, mockRegistry);
143
+ await plugin.onStop?.();
144
+ expect(getProfileStore()).toBeNull();
145
+ });
146
+ });
147
+ describe('helper functions', () => {
148
+ describe('getProfileStore', () => {
149
+ it('should return null when plugin not started', () => {
150
+ expect(getProfileStore()).toBeNull();
151
+ });
152
+ it('should return store when plugin started', async () => {
153
+ const plugin = createProfilesPlugin({ store: mockStore });
154
+ await plugin.onStart({}, mockRegistry);
155
+ expect(getProfileStore()).toBe(mockStore);
156
+ });
157
+ });
158
+ describe('createProfile', () => {
159
+ it('should throw when plugin not initialized', async () => {
160
+ await expect(createProfile({ user_id: 'user-123', name: 'Test' })).rejects.toThrow('Profiles plugin not initialized');
161
+ });
162
+ it('should create profile', async () => {
163
+ const plugin = createProfilesPlugin({ store: mockStore });
164
+ await plugin.onStart({}, mockRegistry);
165
+ const result = await createProfile({
166
+ user_id: 'user-123',
167
+ name: 'Emma',
168
+ age: 6,
169
+ });
170
+ expect(result.id).toBe(mockProfile.id);
171
+ expect(mockStore.create).toHaveBeenCalled();
172
+ });
173
+ });
174
+ describe('getProfileById', () => {
175
+ it('should throw when plugin not initialized', async () => {
176
+ await expect(getProfileById('profile-id')).rejects.toThrow('Profiles plugin not initialized');
177
+ });
178
+ it('should return profile when found', async () => {
179
+ const plugin = createProfilesPlugin({ store: mockStore });
180
+ await plugin.onStart({}, mockRegistry);
181
+ const result = await getProfileById(mockProfile.id);
182
+ expect(result).toEqual(mockProfile);
183
+ });
184
+ it('should return null when not found', async () => {
185
+ const plugin = createProfilesPlugin({ store: mockStore });
186
+ await plugin.onStart({}, mockRegistry);
187
+ mockStore.getById.mockResolvedValue(null);
188
+ const result = await getProfileById('non-existent');
189
+ expect(result).toBeNull();
190
+ });
191
+ });
192
+ describe('updateProfile', () => {
193
+ it('should throw when plugin not initialized', async () => {
194
+ await expect(updateProfile('profile-id', { name: 'New Name' })).rejects.toThrow('Profiles plugin not initialized');
195
+ });
196
+ it('should update profile', async () => {
197
+ const plugin = createProfilesPlugin({ store: mockStore });
198
+ await plugin.onStart({}, mockRegistry);
199
+ const updated = { ...mockProfile, name: 'Updated Name' };
200
+ mockStore.update.mockResolvedValue(updated);
201
+ const result = await updateProfile(mockProfile.id, { name: 'Updated Name' });
202
+ expect(result?.name).toBe('Updated Name');
203
+ });
204
+ });
205
+ describe('deleteProfile', () => {
206
+ it('should throw when plugin not initialized', async () => {
207
+ await expect(deleteProfile('profile-id')).rejects.toThrow('Profiles plugin not initialized');
208
+ });
209
+ it('should delete profile', async () => {
210
+ const plugin = createProfilesPlugin({ store: mockStore });
211
+ await plugin.onStart({}, mockRegistry);
212
+ const result = await deleteProfile(mockProfile.id);
213
+ expect(result).toBe(true);
214
+ expect(mockStore.delete).toHaveBeenCalledWith(mockProfile.id);
215
+ });
216
+ });
217
+ describe('listUserProfiles', () => {
218
+ it('should throw when plugin not initialized', async () => {
219
+ await expect(listUserProfiles('user-id')).rejects.toThrow('Profiles plugin not initialized');
220
+ });
221
+ it('should return user profiles', async () => {
222
+ const plugin = createProfilesPlugin({ store: mockStore });
223
+ await plugin.onStart({}, mockRegistry);
224
+ const result = await listUserProfiles('user-123');
225
+ expect(result).toHaveLength(1);
226
+ expect(result[0]).toEqual(mockProfile);
227
+ });
228
+ });
229
+ describe('setDefaultProfile', () => {
230
+ it('should throw when plugin not initialized', async () => {
231
+ await expect(setDefaultProfile('profile-id', 'user-id')).rejects.toThrow('Profiles plugin not initialized');
232
+ });
233
+ it('should set default profile', async () => {
234
+ const plugin = createProfilesPlugin({ store: mockStore });
235
+ await plugin.onStart({}, mockRegistry);
236
+ const result = await setDefaultProfile(mockProfile.id, 'user-123');
237
+ expect(result).toBe(true);
238
+ expect(mockStore.setDefaultProfile).toHaveBeenCalledWith(mockProfile.id, 'user-123');
239
+ });
240
+ });
241
+ });
242
+ });
243
+ //# sourceMappingURL=profiles-plugin.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles-plugin.test.js","sourceRoot":"","sources":["../../../../src/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AAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;YACjC,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;gBACxD,MAAM,MAAM,CACV,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC,CAC3C,CAAC,OAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;YACvD,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;gBAC1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC1D,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;gBAEvC,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;gBAEnE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC1B,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,oBAAoB,CACtD,WAAW,CAAC,EAAE,EACd,UAAU,CACX,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Profiles Plugin
3
+ *
4
+ * Generic multi-profile management with age support.
5
+ * Exports all profile-related functionality.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ export { createProfilesPlugin, getProfileStore, createProfile, getProfileById, updateProfile, deleteProfile, listUserProfiles, getDefaultProfile, setDefaultProfile, getProfilesByAgeGroup, getChildProfiles, getProfileAge, checkTimeRestrictions, getContentFilterLevel, canAccessContent, } from './profiles-plugin.js';
10
+ export type { Profile, CreateProfileInput, UpdateProfileInput, ProfileSearchParams, ProfileListResponse, TimeRestrictionResult, ContentFilterLevel, AgeGroup, ProfileStore, ProfilesPluginConfig, ProfilesApiConfig, PostgresProfileStoreConfig, AgeThresholds, QwickBotProfileMetadata, GamingProfileMetadata, } from './types.js';
11
+ export { postgresProfileStore } from './stores/index.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/profiles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,OAAO,EACP,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Profiles Plugin
3
+ *
4
+ * Generic multi-profile management with age support.
5
+ * Exports all profile-related functionality.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ // Main plugin
10
+ export { createProfilesPlugin, getProfileStore, createProfile, getProfileById, updateProfile, deleteProfile, listUserProfiles, getDefaultProfile, setDefaultProfile, getProfilesByAgeGroup, getChildProfiles, getProfileAge, checkTimeRestrictions, getContentFilterLevel, canAccessContent, } from './profiles-plugin.js';
11
+ // Stores
12
+ export { postgresProfileStore } from './stores/index.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/profiles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc;AACd,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAqB9B,SAAS;AACT,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Profiles Plugin
3
+ *
4
+ * Generic multi-profile management plugin for @qwickapps/server.
5
+ * Supports age-based categorization and content filtering.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import type { Plugin } from '../../core/plugin-registry.js';
10
+ import type { ProfilesPluginConfig, ProfileStore, Profile, CreateProfileInput, UpdateProfileInput, AgeGroup, ContentFilterLevel, TimeRestrictionResult } from './types.js';
11
+ /**
12
+ * Create the Profiles plugin
13
+ */
14
+ export declare function createProfilesPlugin(config: ProfilesPluginConfig): Plugin;
15
+ /**
16
+ * Get the current profile store instance
17
+ */
18
+ export declare function getProfileStore(): ProfileStore | null;
19
+ /**
20
+ * Create a new profile
21
+ */
22
+ export declare function createProfile(input: CreateProfileInput): Promise<Profile>;
23
+ /**
24
+ * Get a profile by ID
25
+ */
26
+ export declare function getProfileById(id: string): Promise<Profile | null>;
27
+ /**
28
+ * Update a profile
29
+ */
30
+ export declare function updateProfile(id: string, input: UpdateProfileInput): Promise<Profile | null>;
31
+ /**
32
+ * Delete a profile
33
+ */
34
+ export declare function deleteProfile(id: string): Promise<boolean>;
35
+ /**
36
+ * List profiles for a user
37
+ */
38
+ export declare function listUserProfiles(userId: string): Promise<Profile[]>;
39
+ /**
40
+ * Get the default profile for a user
41
+ */
42
+ export declare function getDefaultProfile(userId: string): Promise<Profile | null>;
43
+ /**
44
+ * Set a profile as the default
45
+ */
46
+ export declare function setDefaultProfile(profileId: string, userId: string): Promise<boolean>;
47
+ /**
48
+ * Get profiles by age group
49
+ */
50
+ export declare function getProfilesByAgeGroup(userId: string, ageGroup: AgeGroup): Promise<Profile[]>;
51
+ /**
52
+ * Get child profiles (age_group = 'child')
53
+ */
54
+ export declare function getChildProfiles(userId: string): Promise<Profile[]>;
55
+ /**
56
+ * Get the current age for a profile
57
+ */
58
+ export declare function getProfileAge(profile: Profile): number | null;
59
+ /**
60
+ * Check time restrictions for a profile
61
+ */
62
+ export declare function checkTimeRestrictions(profile: Profile): TimeRestrictionResult;
63
+ /**
64
+ * Get content filter level for a profile
65
+ */
66
+ export declare function getContentFilterLevel(profile: Profile): ContentFilterLevel;
67
+ /**
68
+ * Check if profile can access content based on filter level
69
+ */
70
+ export declare function canAccessContent(profile: Profile, requiredLevel: ContentFilterLevel): boolean;
71
+ //# sourceMappingURL=profiles-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/profiles/profiles-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAgC,MAAM,+BAA+B,CAAC;AAC1F,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,OAAO,EACP,kBAAkB,EAClB,kBAAkB,EAElB,QAAQ,EACR,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AA8CpB;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAoSzE;AAMD;;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