@carlonicora/nextjs-jsonapi 1.5.0 → 1.7.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 (278) hide show
  1. package/dist/{ApiResponseInterface-DDI7QQPR.d.ts → ApiResponseInterface-DMwITHYP.d.mts} +11 -2
  2. package/dist/{ApiResponseInterface-BHN5D9r5.d.mts → ApiResponseInterface-DWgIAXI-.d.ts} +11 -2
  3. package/dist/AuthComponent-hxOPs9o8.d.mts +11 -0
  4. package/dist/AuthComponent-hxOPs9o8.d.ts +11 -0
  5. package/dist/{BlockNoteEditor-G6AK2NWA.js → BlockNoteEditor-IJASTIUZ.js} +16 -23
  6. package/dist/BlockNoteEditor-IJASTIUZ.js.map +1 -0
  7. package/dist/{BlockNoteEditor-AIEEQM6A.mjs → BlockNoteEditor-M6TUP3NT.mjs} +8 -15
  8. package/dist/BlockNoteEditor-M6TUP3NT.mjs.map +1 -0
  9. package/dist/JsonApiRequest-2OM5NDAW.js +24 -0
  10. package/dist/JsonApiRequest-2OM5NDAW.js.map +1 -0
  11. package/dist/{JsonApiRequest-6UR7DIAR.mjs → JsonApiRequest-SYZ6FGCA.mjs} +2 -3
  12. package/dist/{chunk-2K3Q24UF.js → chunk-3ZPK4QOB.js} +24 -14
  13. package/dist/chunk-3ZPK4QOB.js.map +1 -0
  14. package/dist/{chunk-VET55IZO.js → chunk-4L7OWJ2P.js} +10290 -7537
  15. package/dist/chunk-4L7OWJ2P.js.map +1 -0
  16. package/dist/chunk-4U5CJA44.mjs +3435 -0
  17. package/dist/chunk-4U5CJA44.mjs.map +1 -0
  18. package/dist/chunk-AGWQ75PQ.js +142 -0
  19. package/dist/chunk-AGWQ75PQ.js.map +1 -0
  20. package/dist/{chunk-PMXG5WBC.js → chunk-CKS6SVUK.js} +160 -24
  21. package/dist/chunk-CKS6SVUK.js.map +1 -0
  22. package/dist/{chunk-YF5XQZDR.mjs → chunk-F5UNXZ3J.mjs} +1 -1
  23. package/dist/chunk-F5UNXZ3J.mjs.map +1 -0
  24. package/dist/chunk-IGOWVLJH.mjs +142 -0
  25. package/dist/chunk-IGOWVLJH.mjs.map +1 -0
  26. package/dist/{chunk-HR4H2FP7.mjs → chunk-KJ4ETLJB.mjs} +24 -14
  27. package/dist/chunk-KJ4ETLJB.mjs.map +1 -0
  28. package/dist/{chunk-IKBA4AHN.mjs → chunk-SAL7XW2G.mjs} +143 -7
  29. package/dist/chunk-SAL7XW2G.mjs.map +1 -0
  30. package/dist/chunk-TW4QRJ7D.mjs +12085 -0
  31. package/dist/chunk-TW4QRJ7D.mjs.map +1 -0
  32. package/dist/chunk-U4NADAHN.js +3435 -0
  33. package/dist/chunk-U4NADAHN.js.map +1 -0
  34. package/dist/{chunk-EFJEWLRL.js → chunk-YUO55Q5A.js} +1 -1
  35. package/dist/chunk-YUO55Q5A.js.map +1 -0
  36. package/dist/client/index.d.mts +161 -11
  37. package/dist/client/index.d.ts +161 -11
  38. package/dist/client/index.js +71 -11
  39. package/dist/client/index.js.map +1 -1
  40. package/dist/client/index.mjs +70 -10
  41. package/dist/components/index.d.mts +763 -11
  42. package/dist/components/index.d.ts +763 -11
  43. package/dist/components/index.js +462 -11
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/index.mjs +463 -12
  46. package/dist/config-BdCV25CE.d.mts +69 -0
  47. package/dist/config-C9dt1QiR.d.ts +69 -0
  48. package/dist/content.fields-Ck5lkQ5d.d.mts +47 -0
  49. package/dist/content.fields-Ck5lkQ5d.d.ts +47 -0
  50. package/dist/{content.interface-CR2aBeAW.d.ts → content.interface-B6qP_ABq.d.mts} +2 -3
  51. package/dist/{content.interface-FpLfsaRm.d.mts → content.interface-DHAFLasV.d.ts} +2 -3
  52. package/dist/contexts/index.d.mts +13 -6
  53. package/dist/contexts/index.d.ts +13 -6
  54. package/dist/contexts/index.js +7 -11
  55. package/dist/contexts/index.js.map +1 -1
  56. package/dist/contexts/index.mjs +6 -10
  57. package/dist/core/index.d.mts +575 -8
  58. package/dist/core/index.d.ts +575 -8
  59. package/dist/core/index.js +131 -3
  60. package/dist/core/index.js.map +1 -1
  61. package/dist/core/index.mjs +132 -4
  62. package/dist/index.d.mts +95 -71
  63. package/dist/index.d.ts +95 -71
  64. package/dist/index.js +113 -7
  65. package/dist/index.js.map +1 -1
  66. package/dist/index.mjs +135 -29
  67. package/dist/notification.interface-agcMYCkg.d.mts +228 -0
  68. package/dist/notification.interface-agcMYCkg.d.ts +228 -0
  69. package/dist/request-GBLBPYFM.js +8 -0
  70. package/dist/request-GBLBPYFM.js.map +1 -0
  71. package/dist/request-XABCMU25.mjs +8 -0
  72. package/dist/s3.service-DYnmymEd.d.mts +350 -0
  73. package/dist/s3.service-DyXjKTqr.d.ts +350 -0
  74. package/dist/server/index.d.mts +69 -4
  75. package/dist/server/index.d.ts +69 -4
  76. package/dist/server/index.js +211 -5
  77. package/dist/server/index.js.map +1 -1
  78. package/dist/server/index.mjs +211 -5
  79. package/dist/server/index.mjs.map +1 -1
  80. package/dist/token-2UWQJY5T.js +8 -0
  81. package/dist/token-2UWQJY5T.js.map +1 -0
  82. package/dist/token-EOK3N45S.mjs +8 -0
  83. package/dist/{useSocket-L-An7_Mr.d.mts → useSocket-91s8M4Xd.d.mts} +1 -1
  84. package/dist/{useSocket-BV6yMdWS.d.ts → useSocket-DSR7vaXj.d.ts} +1 -1
  85. package/package.json +12 -52
  86. package/src/client/JsonApiClient.ts +248 -0
  87. package/src/client/config.ts +78 -0
  88. package/src/client/index.ts +6 -1
  89. package/src/components/containers/TabsContainer.tsx +1 -1
  90. package/src/components/editors/BlockNoteEditor.tsx +3 -1
  91. package/src/components/index.ts +4 -0
  92. package/src/components/navigations/Breadcrumb.tsx +1 -1
  93. package/src/components/navigations/Header.tsx +2 -2
  94. package/src/contexts/CommonContext.tsx +1 -1
  95. package/src/contexts/SocketContext.tsx +1 -1
  96. package/src/contexts/index.ts +3 -0
  97. package/src/core/abstracts/ClientAbstractService.ts +255 -0
  98. package/src/core/abstracts/ServerAbstractService.ts +180 -0
  99. package/src/core/abstracts/index.ts +2 -0
  100. package/src/core/index.ts +35 -3
  101. package/src/discord/config.ts +15 -0
  102. package/src/discord/index.ts +1 -0
  103. package/src/features/auth/components/details/LandingComponent.tsx +2 -2
  104. package/src/features/auth/components/forms/AcceptInvitation.tsx +1 -1
  105. package/src/features/auth/components/forms/ActivateAccount.tsx +1 -1
  106. package/src/features/auth/components/forms/Cookies.tsx +2 -1
  107. package/src/features/auth/components/forms/ForgotPassword.tsx +1 -1
  108. package/src/features/auth/components/forms/Login.tsx +1 -1
  109. package/src/features/auth/components/forms/Logout.tsx +1 -1
  110. package/src/features/auth/components/forms/RefreshUser.tsx +2 -1
  111. package/src/features/auth/components/forms/Register.tsx +1 -1
  112. package/src/features/auth/components/forms/ResetPassword.tsx +1 -1
  113. package/src/features/auth/data/auth.service.ts +1 -1
  114. package/src/features/auth/utils/AuthCookies.ts +1 -1
  115. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +4 -2
  116. package/src/features/company/components/forms/CompanyDeleter.tsx +2 -1
  117. package/src/features/company/components/forms/CompanyEditor.tsx +6 -3
  118. package/src/features/company/components/forms/CompanyLicense.tsx +4 -2
  119. package/src/features/company/components/lists/CompaniesList.tsx +2 -1
  120. package/src/features/content/components/lists/ContentsListById.tsx +2 -1
  121. package/src/features/content/components/lists/RelevantContentsList.tsx +2 -1
  122. package/src/features/notification/components/lists/NotificationsList.tsx +2 -1
  123. package/src/features/notification/contexts/NotificationContext.tsx +2 -1
  124. package/src/features/role/components/forms/RemoveUserFromRole.tsx +4 -2
  125. package/src/features/role/components/forms/UserRoleAdd.tsx +2 -1
  126. package/src/features/role/components/lists/RolesList.tsx +2 -1
  127. package/src/features/role/components/lists/UserRolesList.tsx +2 -1
  128. package/src/features/user/components/forms/RoleUserAdd.tsx +4 -2
  129. package/src/features/user/components/forms/UserDeleter.tsx +2 -1
  130. package/src/features/user/components/forms/UserEditor.tsx +6 -3
  131. package/src/features/user/components/forms/UserMultiSelect.tsx +2 -1
  132. package/src/features/user/components/forms/UserReactivator.tsx +2 -1
  133. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -1
  134. package/src/features/user/components/forms/UserSelector.tsx +2 -1
  135. package/src/features/user/components/lists/AdminUsersList.tsx +2 -1
  136. package/src/features/user/components/lists/CompanyUsersList.tsx +2 -1
  137. package/src/features/user/components/lists/RelevantUsersList.tsx +2 -1
  138. package/src/features/user/components/lists/RoleUsersList.tsx +2 -1
  139. package/src/features/user/components/lists/UsersListByContentIds.tsx +2 -1
  140. package/src/features/user/hooks/useUserSearch.ts +2 -1
  141. package/src/hooks/useDataListRetriever.ts +4 -4
  142. package/src/hooks/usePageTracker.ts +1 -1
  143. package/src/hooks/usePushNotifications.ts +3 -2
  144. package/src/hooks/useSocket.ts +1 -1
  145. package/src/index.ts +7 -2
  146. package/src/roles/config.ts +0 -15
  147. package/src/roles/index.ts +1 -9
  148. package/src/server/JsonApiServer.ts +249 -0
  149. package/src/server/cache.ts +1 -1
  150. package/src/server/index.ts +13 -0
  151. package/src/server/request.ts +32 -18
  152. package/src/server/token.ts +1 -1
  153. package/dist/AbstractService-BsY6W3Ej.d.mts +0 -109
  154. package/dist/AbstractService-wLid8dB0.d.ts +0 -109
  155. package/dist/ApiData-DPKNfY-9.d.mts +0 -10
  156. package/dist/ApiData-DPKNfY-9.d.ts +0 -10
  157. package/dist/ApiDataInterface-DPP8s46n.d.mts +0 -21
  158. package/dist/ApiDataInterface-DPP8s46n.d.ts +0 -21
  159. package/dist/AuthComponent-B_Ps2Vb9.d.ts +0 -78
  160. package/dist/AuthComponent-CxnGgvoh.d.mts +0 -78
  161. package/dist/BlockNoteEditor-AIEEQM6A.mjs.map +0 -1
  162. package/dist/BlockNoteEditor-G6AK2NWA.js.map +0 -1
  163. package/dist/JsonApiRequest-UJ7FGIVI.js +0 -25
  164. package/dist/JsonApiRequest-UJ7FGIVI.js.map +0 -1
  165. package/dist/atoms/index.d.mts +0 -12
  166. package/dist/atoms/index.d.ts +0 -12
  167. package/dist/atoms/index.js +0 -9
  168. package/dist/atoms/index.js.map +0 -1
  169. package/dist/atoms/index.mjs +0 -9
  170. package/dist/chunk-2K3Q24UF.js.map +0 -1
  171. package/dist/chunk-32HM6MDD.js +0 -98
  172. package/dist/chunk-32HM6MDD.js.map +0 -1
  173. package/dist/chunk-3FBCC4G3.js +0 -8
  174. package/dist/chunk-3FBCC4G3.js.map +0 -1
  175. package/dist/chunk-3UELCPIN.js +0 -46
  176. package/dist/chunk-3UELCPIN.js.map +0 -1
  177. package/dist/chunk-5IET37O4.js +0 -4210
  178. package/dist/chunk-5IET37O4.js.map +0 -1
  179. package/dist/chunk-AGAJMJ4T.js +0 -147
  180. package/dist/chunk-AGAJMJ4T.js.map +0 -1
  181. package/dist/chunk-AYHKQWHH.js +0 -68
  182. package/dist/chunk-AYHKQWHH.js.map +0 -1
  183. package/dist/chunk-DEYKTLA3.js +0 -1131
  184. package/dist/chunk-DEYKTLA3.js.map +0 -1
  185. package/dist/chunk-EFJEWLRL.js.map +0 -1
  186. package/dist/chunk-FMBQZAIP.mjs +0 -490
  187. package/dist/chunk-FMBQZAIP.mjs.map +0 -1
  188. package/dist/chunk-HAG77QBV.mjs +0 -98
  189. package/dist/chunk-HAG77QBV.mjs.map +0 -1
  190. package/dist/chunk-HR4H2FP7.mjs.map +0 -1
  191. package/dist/chunk-IKBA4AHN.mjs.map +0 -1
  192. package/dist/chunk-J7YDGYSW.mjs +0 -9332
  193. package/dist/chunk-J7YDGYSW.mjs.map +0 -1
  194. package/dist/chunk-JGFWIT2E.mjs +0 -1131
  195. package/dist/chunk-JGFWIT2E.mjs.map +0 -1
  196. package/dist/chunk-P2F54I7Q.mjs +0 -4210
  197. package/dist/chunk-P2F54I7Q.mjs.map +0 -1
  198. package/dist/chunk-PMXG5WBC.js.map +0 -1
  199. package/dist/chunk-Q2N6SQYW.mjs +0 -8
  200. package/dist/chunk-Q2N6SQYW.mjs.map +0 -1
  201. package/dist/chunk-Q4FXESVT.js +0 -490
  202. package/dist/chunk-Q4FXESVT.js.map +0 -1
  203. package/dist/chunk-RBIVEH2K.mjs +0 -147
  204. package/dist/chunk-RBIVEH2K.mjs.map +0 -1
  205. package/dist/chunk-SM63SZCP.mjs +0 -68
  206. package/dist/chunk-SM63SZCP.mjs.map +0 -1
  207. package/dist/chunk-SZZYEG3P.mjs +0 -46
  208. package/dist/chunk-SZZYEG3P.mjs.map +0 -1
  209. package/dist/chunk-VET55IZO.js.map +0 -1
  210. package/dist/chunk-YF5XQZDR.mjs.map +0 -1
  211. package/dist/config-BmnK65TD.d.mts +0 -35
  212. package/dist/config-BmnK65TD.d.ts +0 -35
  213. package/dist/config-DQeAo9Kf.d.mts +0 -49
  214. package/dist/config-DQeAo9Kf.d.ts +0 -49
  215. package/dist/content.fields-cHPdM8GJ.d.mts +0 -27
  216. package/dist/content.fields-cHPdM8GJ.d.ts +0 -27
  217. package/dist/d3.link.interface-ClC4Irqp.d.mts +0 -21
  218. package/dist/d3.link.interface-ClC4Irqp.d.ts +0 -21
  219. package/dist/features/index.d.mts +0 -477
  220. package/dist/features/index.d.ts +0 -477
  221. package/dist/features/index.js +0 -108
  222. package/dist/features/index.js.map +0 -1
  223. package/dist/features/index.mjs +0 -108
  224. package/dist/hooks/index.d.mts +0 -69
  225. package/dist/hooks/index.d.ts +0 -69
  226. package/dist/hooks/index.js +0 -55
  227. package/dist/hooks/index.js.map +0 -1
  228. package/dist/hooks/index.mjs +0 -55
  229. package/dist/hooks/index.mjs.map +0 -1
  230. package/dist/interfaces/index.d.mts +0 -4
  231. package/dist/interfaces/index.d.ts +0 -4
  232. package/dist/interfaces/index.js +0 -2
  233. package/dist/interfaces/index.js.map +0 -1
  234. package/dist/interfaces/index.mjs +0 -2
  235. package/dist/interfaces/index.mjs.map +0 -1
  236. package/dist/notification.interface-B2BrLoDA.d.mts +0 -14
  237. package/dist/notification.interface-DlZLnAfg.d.ts +0 -14
  238. package/dist/permissions/index.d.mts +0 -41
  239. package/dist/permissions/index.d.ts +0 -41
  240. package/dist/permissions/index.js +0 -14
  241. package/dist/permissions/index.js.map +0 -1
  242. package/dist/permissions/index.mjs +0 -14
  243. package/dist/permissions/index.mjs.map +0 -1
  244. package/dist/request-7FE3LJLV.mjs +0 -9
  245. package/dist/request-7FE3LJLV.mjs.map +0 -1
  246. package/dist/request-QFS7NEIE.js +0 -9
  247. package/dist/request-QFS7NEIE.js.map +0 -1
  248. package/dist/roles/index.d.mts +0 -39
  249. package/dist/roles/index.d.ts +0 -39
  250. package/dist/roles/index.js +0 -18
  251. package/dist/roles/index.js.map +0 -1
  252. package/dist/roles/index.mjs +0 -18
  253. package/dist/roles/index.mjs.map +0 -1
  254. package/dist/shadcnui/index.d.mts +0 -698
  255. package/dist/shadcnui/index.d.ts +0 -698
  256. package/dist/shadcnui/index.js +0 -468
  257. package/dist/shadcnui/index.js.map +0 -1
  258. package/dist/shadcnui/index.mjs +0 -467
  259. package/dist/shadcnui/index.mjs.map +0 -1
  260. package/dist/token-IJSPOMW6.mjs +0 -9
  261. package/dist/token-IJSPOMW6.mjs.map +0 -1
  262. package/dist/token-UYE7CV6X.js +0 -9
  263. package/dist/token-UYE7CV6X.js.map +0 -1
  264. package/dist/types-B2QRyqyK.d.ts +0 -39
  265. package/dist/types-CgvNmxTd.d.mts +0 -39
  266. package/dist/types-t2PyXhDu.d.mts +0 -116
  267. package/dist/types-t2PyXhDu.d.ts +0 -116
  268. package/dist/user.interface-CooB1R79.d.mts +0 -85
  269. package/dist/user.interface-KnIT9pVY.d.ts +0 -85
  270. package/dist/utils/index.d.mts +0 -224
  271. package/dist/utils/index.d.ts +0 -224
  272. package/dist/utils/index.js +0 -46
  273. package/dist/utils/index.js.map +0 -1
  274. package/dist/utils/index.mjs +0 -46
  275. package/dist/utils/index.mjs.map +0 -1
  276. /package/dist/{JsonApiRequest-6UR7DIAR.mjs.map → JsonApiRequest-SYZ6FGCA.mjs.map} +0 -0
  277. /package/dist/{atoms/index.mjs.map → request-XABCMU25.mjs.map} +0 -0
  278. /package/dist/{features/index.mjs.map → token-EOK3N45S.mjs.map} +0 -0
@@ -0,0 +1,3435 @@
1
+ import {
2
+ directFetch
3
+ } from "./chunk-C7C7VY4F.mjs";
4
+ import {
5
+ DataClassRegistry,
6
+ JsonApiDataFactory,
7
+ JsonApiDelete,
8
+ JsonApiGet,
9
+ JsonApiPost,
10
+ translateResponse
11
+ } from "./chunk-SAL7XW2G.mjs";
12
+ import {
13
+ getClientToken
14
+ } from "./chunk-AUXK7QSA.mjs";
15
+ import {
16
+ __name
17
+ } from "./chunk-PAWJFY3S.mjs";
18
+
19
+ // src/core/factories/RehydrationFactory.ts
20
+ var RehydrationFactory = class {
21
+ static {
22
+ __name(this, "RehydrationFactory");
23
+ }
24
+ static rehydrate(classKey, data) {
25
+ const factoryClass = DataClassRegistry.get(classKey);
26
+ const instance = new factoryClass();
27
+ return instance.rehydrate(data);
28
+ }
29
+ static rehydrateList(classKey, data) {
30
+ const factoryClass = DataClassRegistry.get(classKey);
31
+ const response = data.map((item) => {
32
+ const instance = new factoryClass();
33
+ return instance.rehydrate(item);
34
+ });
35
+ return response;
36
+ }
37
+ };
38
+
39
+ // src/core/abstracts/AbstractApiData.ts
40
+ var AbstractApiData = class {
41
+ static {
42
+ __name(this, "AbstractApiData");
43
+ }
44
+ _jsonApi;
45
+ _included;
46
+ _id;
47
+ _type;
48
+ _createdAt;
49
+ _updatedAt;
50
+ _self;
51
+ get type() {
52
+ if (!this._type) throw new Error("Type is not set.");
53
+ return this._type;
54
+ }
55
+ get id() {
56
+ if (!this._id) throw new Error("Id is not set.");
57
+ return this._id;
58
+ }
59
+ get self() {
60
+ return this._self;
61
+ }
62
+ get createdAt() {
63
+ return this._createdAt ?? /* @__PURE__ */ new Date();
64
+ }
65
+ get updatedAt() {
66
+ return this._updatedAt ?? /* @__PURE__ */ new Date();
67
+ }
68
+ get included() {
69
+ return this._included ?? [];
70
+ }
71
+ get jsonApi() {
72
+ return this._jsonApi;
73
+ }
74
+ ingestJsonApi(_data) {
75
+ }
76
+ generateApiUrl(_params) {
77
+ throw new Error("Method not implemented.");
78
+ }
79
+ createJsonApi(_data) {
80
+ throw new Error("Method not implemented.");
81
+ }
82
+ _readIncluded(data, type, dataType) {
83
+ if (data.included === void 0 || data.included.length === 0 || data.jsonApi.relationships === void 0 || data.jsonApi.relationships[type] === void 0 || data.jsonApi.relationships[type].data === void 0) {
84
+ return void 0;
85
+ }
86
+ if (Array.isArray(data.jsonApi.relationships[type].data)) {
87
+ const response = data.jsonApi.relationships[type].data.map((jsonApiData) => {
88
+ const includedData2 = data.included.find(
89
+ (includedData3) => includedData3.id === jsonApiData.id && includedData3.type === jsonApiData.type
90
+ );
91
+ if (includedData2 === void 0) return void 0;
92
+ return RehydrationFactory.rehydrate(dataType, {
93
+ jsonApi: includedData2,
94
+ included: data.included
95
+ });
96
+ });
97
+ return response.filter((item) => item !== void 0);
98
+ }
99
+ const includedData = data.included.find(
100
+ (includedData2) => includedData2.id === data.jsonApi.relationships[type].data.id && includedData2.type === data.jsonApi.relationships[type].data.type
101
+ );
102
+ if (includedData === void 0 && data.allData !== void 0) {
103
+ const fallbackData = data.allData.find(
104
+ (includedData2) => includedData2.id === data.jsonApi.relationships[type].data.id && includedData2.type === data.jsonApi.relationships[type].data.type
105
+ );
106
+ if (fallbackData !== void 0) {
107
+ return RehydrationFactory.rehydrate(dataType, {
108
+ jsonApi: fallbackData,
109
+ included: data.included
110
+ });
111
+ }
112
+ }
113
+ if (includedData === void 0) return void 0;
114
+ return RehydrationFactory.rehydrate(dataType, {
115
+ jsonApi: includedData,
116
+ included: data.included
117
+ });
118
+ }
119
+ dehydrate() {
120
+ return {
121
+ jsonApi: this._jsonApi,
122
+ included: this._included ?? []
123
+ };
124
+ }
125
+ rehydrate(data) {
126
+ this._jsonApi = data.jsonApi;
127
+ this._included = data.included;
128
+ this._type = this._jsonApi.type;
129
+ this._id = this._jsonApi.id;
130
+ this._createdAt = this._jsonApi.meta?.createdAt !== void 0 ? new Date(this._jsonApi.meta.createdAt) : void 0;
131
+ this._updatedAt = this._jsonApi.meta?.updatedAt !== void 0 ? new Date(this._jsonApi.meta.updatedAt) : void 0;
132
+ this._self = this._jsonApi.links?.self ?? void 0;
133
+ return this;
134
+ }
135
+ };
136
+
137
+ // src/core/abstracts/AbstractService.ts
138
+ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
139
+ HttpMethod2["GET"] = "GET";
140
+ HttpMethod2["POST"] = "POST";
141
+ HttpMethod2["PUT"] = "PUT";
142
+ HttpMethod2["PATCH"] = "PATCH";
143
+ HttpMethod2["DELETE"] = "DELETE";
144
+ return HttpMethod2;
145
+ })(HttpMethod || {});
146
+ var globalErrorHandler = null;
147
+ function setGlobalErrorHandler(handler) {
148
+ globalErrorHandler = handler;
149
+ }
150
+ __name(setGlobalErrorHandler, "setGlobalErrorHandler");
151
+ function getGlobalErrorHandler() {
152
+ return globalErrorHandler;
153
+ }
154
+ __name(getGlobalErrorHandler, "getGlobalErrorHandler");
155
+ var AbstractService = class {
156
+ static {
157
+ __name(this, "AbstractService");
158
+ }
159
+ /**
160
+ * Extract locale from client-side URL pathname
161
+ * URL structure: /{locale}/route-path (e.g., /it/accounts)
162
+ * Fallback chain: URL locale → navigator.language → "en"
163
+ */
164
+ static getClientLocale() {
165
+ if (typeof window === "undefined") {
166
+ return "en";
167
+ }
168
+ const pathSegments = window.location.pathname.split("/").filter(Boolean);
169
+ const urlLocale = pathSegments[0];
170
+ const supportedLocales = ["en"];
171
+ if (urlLocale && supportedLocales.includes(urlLocale)) {
172
+ return urlLocale;
173
+ }
174
+ const navigatorLocale = navigator.language.split("-")[0];
175
+ if (navigatorLocale && supportedLocales.includes(navigatorLocale)) {
176
+ return navigatorLocale;
177
+ }
178
+ return "en";
179
+ }
180
+ static async next(params) {
181
+ return await this.callApi({
182
+ method: "GET" /* GET */,
183
+ type: params.type,
184
+ endpoint: params.endpoint,
185
+ next: params.next,
186
+ previous: params.previous,
187
+ self: params.self
188
+ });
189
+ }
190
+ /**
191
+ * Fetch the previous page of results.
192
+ */
193
+ static async previous(params) {
194
+ return await this.callApi({
195
+ method: "GET" /* GET */,
196
+ type: params.type,
197
+ endpoint: params.endpoint,
198
+ next: params.next,
199
+ previous: params.previous,
200
+ self: params.self
201
+ });
202
+ }
203
+ /**
204
+ * Make an API call with automatic environment detection and error handling.
205
+ */
206
+ static async callApi(params) {
207
+ const { JsonApiGet: JsonApiGet2, JsonApiPost: JsonApiPost2, JsonApiPut, JsonApiPatch, JsonApiDelete: JsonApiDelete2 } = await import("./JsonApiRequest-SYZ6FGCA.mjs");
208
+ let apiResponse;
209
+ let language = "en";
210
+ if (typeof window === "undefined") {
211
+ const { getLocale } = await import("next-intl/server");
212
+ language = await getLocale() ?? "en";
213
+ } else {
214
+ language = this.getClientLocale();
215
+ }
216
+ switch (params.method) {
217
+ case "GET" /* GET */:
218
+ apiResponse = await JsonApiGet2({
219
+ classKey: params.type,
220
+ endpoint: params.endpoint,
221
+ companyId: params.companyId,
222
+ language
223
+ });
224
+ break;
225
+ case "POST" /* POST */:
226
+ apiResponse = await JsonApiPost2({
227
+ classKey: params.type,
228
+ endpoint: params.endpoint,
229
+ companyId: params.companyId,
230
+ body: params.input,
231
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
232
+ language,
233
+ responseType: params.responseType,
234
+ files: params.files
235
+ });
236
+ break;
237
+ case "PUT" /* PUT */:
238
+ apiResponse = await JsonApiPut({
239
+ classKey: params.type,
240
+ endpoint: params.endpoint,
241
+ companyId: params.companyId,
242
+ body: params.input,
243
+ language,
244
+ responseType: params.responseType,
245
+ files: params.files
246
+ });
247
+ break;
248
+ case "PATCH" /* PATCH */:
249
+ apiResponse = await JsonApiPatch({
250
+ classKey: params.type,
251
+ endpoint: params.endpoint,
252
+ companyId: params.companyId,
253
+ body: params.input,
254
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
255
+ language,
256
+ responseType: params.responseType,
257
+ files: params.files
258
+ });
259
+ break;
260
+ case "DELETE" /* DELETE */:
261
+ apiResponse = await JsonApiDelete2({
262
+ classKey: params.type,
263
+ endpoint: params.endpoint,
264
+ companyId: params.companyId,
265
+ language,
266
+ responseType: params.responseType
267
+ });
268
+ break;
269
+ default:
270
+ throw new Error("Method not found");
271
+ }
272
+ if (!apiResponse.ok) {
273
+ if (globalErrorHandler && typeof window !== "undefined") {
274
+ globalErrorHandler(apiResponse.response, apiResponse.error);
275
+ return void 0;
276
+ } else {
277
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
278
+ error.status = apiResponse.response;
279
+ error.digest = `HTTP_${apiResponse.response}`;
280
+ throw error;
281
+ }
282
+ }
283
+ if (apiResponse.next && params.next) params.next.next = apiResponse.next;
284
+ if (apiResponse.prev && params.previous) params.previous.previous = apiResponse.prev;
285
+ if (apiResponse.self && params.self) params.self.self = apiResponse.self;
286
+ return apiResponse.data;
287
+ }
288
+ /**
289
+ * Get raw JSON:API response data without deserialization.
290
+ */
291
+ static async getRawData(params) {
292
+ const { JsonApiGet: JsonApiGet2 } = await import("./JsonApiRequest-SYZ6FGCA.mjs");
293
+ let language = "en";
294
+ if (typeof window === "undefined") {
295
+ const { getLocale } = await import("next-intl/server");
296
+ language = await getLocale() ?? "en";
297
+ } else {
298
+ language = this.getClientLocale();
299
+ }
300
+ const apiResponse = await JsonApiGet2({
301
+ classKey: params.type,
302
+ endpoint: params.endpoint,
303
+ companyId: params.companyId,
304
+ language
305
+ });
306
+ if (!apiResponse.ok) {
307
+ if (globalErrorHandler && typeof window !== "undefined") {
308
+ globalErrorHandler(apiResponse.response, apiResponse.error);
309
+ return void 0;
310
+ } else {
311
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
312
+ error.status = apiResponse.response;
313
+ error.digest = `HTTP_${apiResponse.response}`;
314
+ throw error;
315
+ }
316
+ }
317
+ return apiResponse.raw;
318
+ }
319
+ };
320
+
321
+ // src/client/JsonApiClient.ts
322
+ var _clientConfig = null;
323
+ function configureClientJsonApi(config) {
324
+ _clientConfig = config;
325
+ if (config.bootstrapper) {
326
+ config.bootstrapper();
327
+ }
328
+ }
329
+ __name(configureClientJsonApi, "configureClientJsonApi");
330
+ function getClientApiUrl() {
331
+ if (_clientConfig?.apiUrl) {
332
+ return _clientConfig.apiUrl;
333
+ }
334
+ const envUrl = process.env.NEXT_PUBLIC_API_URL;
335
+ if (!envUrl) {
336
+ throw new Error("API URL not configured. Use configureClientJsonApi() or set NEXT_PUBLIC_API_URL environment variable.");
337
+ }
338
+ return envUrl;
339
+ }
340
+ __name(getClientApiUrl, "getClientApiUrl");
341
+ function getClientAppUrl() {
342
+ if (_clientConfig?.appUrl) {
343
+ return _clientConfig.appUrl;
344
+ }
345
+ const envUrl = process.env.NEXT_PUBLIC_ADDRESS;
346
+ if (!envUrl) {
347
+ throw new Error("App URL not configured. Use configureClientJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.");
348
+ }
349
+ return envUrl.trim().replace(/\/+$/, "");
350
+ }
351
+ __name(getClientAppUrl, "getClientAppUrl");
352
+ function getClientTrackablePages() {
353
+ return _clientConfig?.trackablePages ?? [];
354
+ }
355
+ __name(getClientTrackablePages, "getClientTrackablePages");
356
+ function runClientBootstrapper() {
357
+ if (_clientConfig?.bootstrapper) {
358
+ _clientConfig.bootstrapper();
359
+ }
360
+ }
361
+ __name(runClientBootstrapper, "runClientBootstrapper");
362
+ function buildClientUrl(endpoint) {
363
+ const apiUrl = getClientApiUrl();
364
+ return endpoint.startsWith("http") ? endpoint : `${apiUrl}${endpoint}`;
365
+ }
366
+ __name(buildClientUrl, "buildClientUrl");
367
+ async function ClientJsonApiGet(params) {
368
+ runClientBootstrapper();
369
+ const token = await getClientToken();
370
+ const apiResponse = await directFetch({
371
+ method: "GET",
372
+ url: buildClientUrl(params.endpoint),
373
+ token,
374
+ companyId: params.companyId,
375
+ language: params.language,
376
+ additionalHeaders: _clientConfig?.additionalHeaders
377
+ });
378
+ return translateResponse({
379
+ classKey: params.classKey,
380
+ apiResponse,
381
+ companyId: params.companyId,
382
+ language: params.language,
383
+ paginationHandler: /* @__PURE__ */ __name(async (endpoint) => ClientJsonApiGet({
384
+ classKey: params.classKey,
385
+ endpoint,
386
+ companyId: params.companyId,
387
+ language: params.language
388
+ }), "paginationHandler")
389
+ });
390
+ }
391
+ __name(ClientJsonApiGet, "ClientJsonApiGet");
392
+ async function ClientJsonApiPost(params) {
393
+ runClientBootstrapper();
394
+ const token = await getClientToken();
395
+ let body = params.body;
396
+ if (!body) {
397
+ body = {};
398
+ } else if (params.overridesJsonApiCreation !== true) {
399
+ body = JsonApiDataFactory.create(params.classKey, body);
400
+ }
401
+ const apiResponse = await directFetch({
402
+ method: "POST",
403
+ url: buildClientUrl(params.endpoint),
404
+ token,
405
+ body,
406
+ files: params.files,
407
+ companyId: params.companyId,
408
+ language: params.language,
409
+ additionalHeaders: _clientConfig?.additionalHeaders
410
+ });
411
+ return translateResponse({
412
+ classKey: params.responseType ?? params.classKey,
413
+ apiResponse,
414
+ companyId: params.companyId,
415
+ language: params.language
416
+ });
417
+ }
418
+ __name(ClientJsonApiPost, "ClientJsonApiPost");
419
+ async function ClientJsonApiPut(params) {
420
+ runClientBootstrapper();
421
+ const token = await getClientToken();
422
+ let body = params.body;
423
+ if (!body) {
424
+ body = {};
425
+ } else {
426
+ body = JsonApiDataFactory.create(params.classKey, body);
427
+ }
428
+ const apiResponse = await directFetch({
429
+ method: "PUT",
430
+ url: buildClientUrl(params.endpoint),
431
+ token,
432
+ body,
433
+ files: params.files,
434
+ companyId: params.companyId,
435
+ language: params.language,
436
+ additionalHeaders: _clientConfig?.additionalHeaders
437
+ });
438
+ return translateResponse({
439
+ classKey: params.responseType ?? params.classKey,
440
+ apiResponse,
441
+ companyId: params.companyId,
442
+ language: params.language
443
+ });
444
+ }
445
+ __name(ClientJsonApiPut, "ClientJsonApiPut");
446
+ async function ClientJsonApiPatch(params) {
447
+ runClientBootstrapper();
448
+ const token = await getClientToken();
449
+ let body = params.body;
450
+ if (!body) {
451
+ body = {};
452
+ } else if (params.overridesJsonApiCreation !== true) {
453
+ body = JsonApiDataFactory.create(params.classKey, body);
454
+ }
455
+ const apiResponse = await directFetch({
456
+ method: "PATCH",
457
+ url: buildClientUrl(params.endpoint),
458
+ token,
459
+ body,
460
+ files: params.files,
461
+ companyId: params.companyId,
462
+ language: params.language,
463
+ additionalHeaders: _clientConfig?.additionalHeaders
464
+ });
465
+ return translateResponse({
466
+ classKey: params.responseType ?? params.classKey,
467
+ apiResponse,
468
+ companyId: params.companyId,
469
+ language: params.language
470
+ });
471
+ }
472
+ __name(ClientJsonApiPatch, "ClientJsonApiPatch");
473
+ async function ClientJsonApiDelete(params) {
474
+ runClientBootstrapper();
475
+ const token = await getClientToken();
476
+ const apiResponse = await directFetch({
477
+ method: "DELETE",
478
+ url: buildClientUrl(params.endpoint),
479
+ token,
480
+ companyId: params.companyId,
481
+ language: params.language,
482
+ additionalHeaders: _clientConfig?.additionalHeaders
483
+ });
484
+ return translateResponse({
485
+ classKey: params.responseType ?? params.classKey,
486
+ apiResponse,
487
+ companyId: params.companyId,
488
+ language: params.language
489
+ });
490
+ }
491
+ __name(ClientJsonApiDelete, "ClientJsonApiDelete");
492
+
493
+ // src/core/abstracts/ClientAbstractService.ts
494
+ var ClientHttpMethod = /* @__PURE__ */ ((ClientHttpMethod2) => {
495
+ ClientHttpMethod2["GET"] = "GET";
496
+ ClientHttpMethod2["POST"] = "POST";
497
+ ClientHttpMethod2["PUT"] = "PUT";
498
+ ClientHttpMethod2["PATCH"] = "PATCH";
499
+ ClientHttpMethod2["DELETE"] = "DELETE";
500
+ return ClientHttpMethod2;
501
+ })(ClientHttpMethod || {});
502
+ var globalErrorHandler2 = null;
503
+ function setClientGlobalErrorHandler(handler) {
504
+ globalErrorHandler2 = handler;
505
+ }
506
+ __name(setClientGlobalErrorHandler, "setClientGlobalErrorHandler");
507
+ function getClientGlobalErrorHandler() {
508
+ return globalErrorHandler2;
509
+ }
510
+ __name(getClientGlobalErrorHandler, "getClientGlobalErrorHandler");
511
+ var ClientAbstractService = class {
512
+ static {
513
+ __name(this, "ClientAbstractService");
514
+ }
515
+ /**
516
+ * Extract locale from client-side URL pathname
517
+ * URL structure: /{locale}/route-path (e.g., /it/accounts)
518
+ * Fallback chain: URL locale → navigator.language → "en"
519
+ */
520
+ static getClientLocale() {
521
+ if (typeof window === "undefined") {
522
+ return "en";
523
+ }
524
+ const pathSegments = window.location.pathname.split("/").filter(Boolean);
525
+ const urlLocale = pathSegments[0];
526
+ const supportedLocales = ["en"];
527
+ if (urlLocale && supportedLocales.includes(urlLocale)) {
528
+ return urlLocale;
529
+ }
530
+ const navigatorLocale = navigator.language.split("-")[0];
531
+ if (navigatorLocale && supportedLocales.includes(navigatorLocale)) {
532
+ return navigatorLocale;
533
+ }
534
+ return "en";
535
+ }
536
+ /**
537
+ * Fetch the next page of results.
538
+ */
539
+ static async next(params) {
540
+ return await this.callApi({
541
+ method: "GET" /* GET */,
542
+ type: params.type,
543
+ endpoint: params.endpoint,
544
+ next: params.next,
545
+ previous: params.previous,
546
+ self: params.self
547
+ });
548
+ }
549
+ /**
550
+ * Fetch the previous page of results.
551
+ */
552
+ static async previous(params) {
553
+ return await this.callApi({
554
+ method: "GET" /* GET */,
555
+ type: params.type,
556
+ endpoint: params.endpoint,
557
+ next: params.next,
558
+ previous: params.previous,
559
+ self: params.self
560
+ });
561
+ }
562
+ /**
563
+ * Make a client-side API call.
564
+ */
565
+ static async callApi(params) {
566
+ let apiResponse;
567
+ const language = this.getClientLocale();
568
+ switch (params.method) {
569
+ case "GET" /* GET */:
570
+ apiResponse = await ClientJsonApiGet({
571
+ classKey: params.type,
572
+ endpoint: params.endpoint,
573
+ companyId: params.companyId,
574
+ language
575
+ });
576
+ break;
577
+ case "POST" /* POST */:
578
+ apiResponse = await ClientJsonApiPost({
579
+ classKey: params.type,
580
+ endpoint: params.endpoint,
581
+ companyId: params.companyId,
582
+ body: params.input,
583
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
584
+ language,
585
+ responseType: params.responseType,
586
+ files: params.files
587
+ });
588
+ break;
589
+ case "PUT" /* PUT */:
590
+ apiResponse = await ClientJsonApiPut({
591
+ classKey: params.type,
592
+ endpoint: params.endpoint,
593
+ companyId: params.companyId,
594
+ body: params.input,
595
+ language,
596
+ responseType: params.responseType,
597
+ files: params.files
598
+ });
599
+ break;
600
+ case "PATCH" /* PATCH */:
601
+ apiResponse = await ClientJsonApiPatch({
602
+ classKey: params.type,
603
+ endpoint: params.endpoint,
604
+ companyId: params.companyId,
605
+ body: params.input,
606
+ overridesJsonApiCreation: params.overridesJsonApiCreation,
607
+ language,
608
+ responseType: params.responseType,
609
+ files: params.files
610
+ });
611
+ break;
612
+ case "DELETE" /* DELETE */:
613
+ apiResponse = await ClientJsonApiDelete({
614
+ classKey: params.type,
615
+ endpoint: params.endpoint,
616
+ companyId: params.companyId,
617
+ language,
618
+ responseType: params.responseType
619
+ });
620
+ break;
621
+ default:
622
+ throw new Error("Method not found");
623
+ }
624
+ if (!apiResponse.ok) {
625
+ if (globalErrorHandler2) {
626
+ globalErrorHandler2(apiResponse.response, apiResponse.error);
627
+ return void 0;
628
+ } else {
629
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
630
+ error.status = apiResponse.response;
631
+ error.digest = `HTTP_${apiResponse.response}`;
632
+ throw error;
633
+ }
634
+ }
635
+ if (apiResponse.next && params.next) params.next.next = apiResponse.next;
636
+ if (apiResponse.prev && params.previous) params.previous.previous = apiResponse.prev;
637
+ if (apiResponse.self && params.self) params.self.self = apiResponse.self;
638
+ return apiResponse.data;
639
+ }
640
+ /**
641
+ * Get raw JSON:API response data without deserialization.
642
+ */
643
+ static async getRawData(params) {
644
+ const language = this.getClientLocale();
645
+ const apiResponse = await ClientJsonApiGet({
646
+ classKey: params.type,
647
+ endpoint: params.endpoint,
648
+ companyId: params.companyId,
649
+ language
650
+ });
651
+ if (!apiResponse.ok) {
652
+ if (globalErrorHandler2) {
653
+ globalErrorHandler2(apiResponse.response, apiResponse.error);
654
+ return void 0;
655
+ } else {
656
+ const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
657
+ error.status = apiResponse.response;
658
+ error.digest = `HTTP_${apiResponse.response}`;
659
+ throw error;
660
+ }
661
+ }
662
+ return apiResponse.raw;
663
+ }
664
+ };
665
+
666
+ // src/core/registry/ModuleRegistrar.ts
667
+ var ModuleRegistrar = class {
668
+ static {
669
+ __name(this, "ModuleRegistrar");
670
+ }
671
+ static _isBootstrapped = false;
672
+ /**
673
+ * Bootstrap the registry from a Modules class.
674
+ * Automatically detects static getters and registers their models.
675
+ *
676
+ * @param modulesClass - The Modules class with static getters
677
+ */
678
+ static bootstrap(modulesClass) {
679
+ if (this._isBootstrapped) return;
680
+ const data = Object.getOwnPropertyNames(modulesClass).filter((key) => {
681
+ const descriptor = Object.getOwnPropertyDescriptor(modulesClass, key);
682
+ return descriptor && typeof descriptor.get === "function";
683
+ }).map((key) => modulesClass[key]);
684
+ data.forEach((item) => {
685
+ if (item && item.model) {
686
+ DataClassRegistry.registerObjectClass(item, item.model);
687
+ }
688
+ });
689
+ this._isBootstrapped = true;
690
+ }
691
+ /**
692
+ * Reset the bootstrapped state. Useful for testing.
693
+ */
694
+ static reset() {
695
+ this._isBootstrapped = false;
696
+ DataClassRegistry.clear();
697
+ }
698
+ };
699
+
700
+ // src/core/registry/ModuleRegistry.ts
701
+ var ModuleRegistryClass = class {
702
+ static {
703
+ __name(this, "ModuleRegistryClass");
704
+ }
705
+ _modules = /* @__PURE__ */ new Map();
706
+ register(name, module) {
707
+ this._modules.set(name, module);
708
+ }
709
+ get(name) {
710
+ const module = this._modules.get(name);
711
+ if (!module) {
712
+ throw new Error(`Module "${String(name)}" not registered. Call bootstrap() first.`);
713
+ }
714
+ return module;
715
+ }
716
+ findByName(moduleName) {
717
+ for (const module of this._modules.values()) {
718
+ if (module.name === moduleName) {
719
+ return module;
720
+ }
721
+ }
722
+ throw new Error(`Module not found: ${moduleName}`);
723
+ }
724
+ findByModelName(modelName) {
725
+ const module = this._modules.get(modelName);
726
+ if (!module) {
727
+ throw new Error(`Module not found for model: ${modelName}`);
728
+ }
729
+ return module;
730
+ }
731
+ };
732
+ var ModuleRegistry = new ModuleRegistryClass();
733
+ var Modules = new Proxy({}, {
734
+ get(_, prop) {
735
+ if (prop === "findByName") {
736
+ return (name) => ModuleRegistry.findByName(name);
737
+ }
738
+ if (prop === "findByModelName") {
739
+ return (name) => ModuleRegistry.findByModelName(name);
740
+ }
741
+ return ModuleRegistry.get(prop);
742
+ }
743
+ });
744
+
745
+ // src/core/endpoint/EndpointCreator.ts
746
+ var EndpointCreator = class {
747
+ static {
748
+ __name(this, "EndpointCreator");
749
+ }
750
+ _endpoint;
751
+ constructor(params) {
752
+ this._endpoint = {
753
+ endpoint: params.endpoint,
754
+ id: params.id,
755
+ childEndpoint: params.childEndpoint,
756
+ childId: params.childId,
757
+ additionalParams: params.additionalParams ?? []
758
+ };
759
+ }
760
+ endpoint(value) {
761
+ this._endpoint.endpoint = value;
762
+ return this;
763
+ }
764
+ id(value) {
765
+ this._endpoint.id = value;
766
+ return this;
767
+ }
768
+ childEndpoint(value) {
769
+ this._endpoint.childEndpoint = value;
770
+ return this;
771
+ }
772
+ childId(value) {
773
+ this._endpoint.childId = value;
774
+ return this;
775
+ }
776
+ set additionalParams(value) {
777
+ this._endpoint.additionalParams = value;
778
+ }
779
+ addAdditionalParam(key, value) {
780
+ if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];
781
+ this._endpoint.additionalParams.push({ key, value });
782
+ return this;
783
+ }
784
+ limitToType(selectors) {
785
+ this.addAdditionalParam(`include`, selectors.join(","));
786
+ return this;
787
+ }
788
+ limitToFields(selectors) {
789
+ if (selectors.length === 0) return this;
790
+ selectors.forEach((selector) => {
791
+ const fieldString = selector.fields.join(",");
792
+ this.addAdditionalParam(`fields[${selector.type}]`, fieldString);
793
+ });
794
+ return this;
795
+ }
796
+ generate() {
797
+ let additionalParams = "";
798
+ if (this._endpoint.additionalParams) {
799
+ additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join("&");
800
+ }
801
+ let response = `${this._endpoint.endpoint.name}`;
802
+ if (this._endpoint.id) response += `/${this._endpoint.id}`;
803
+ if (this._endpoint.childEndpoint) {
804
+ response += `/${typeof this._endpoint.childEndpoint === "string" ? this._endpoint.childEndpoint : this._endpoint.childEndpoint.name}`;
805
+ }
806
+ if (this._endpoint.childId) response += `/${this._endpoint.childId}`;
807
+ if (additionalParams) response += `?${additionalParams}`;
808
+ return response;
809
+ }
810
+ };
811
+
812
+ // src/core/fields/FieldSelector.ts
813
+ function createJsonApiInclusion(dataType, fields) {
814
+ return {
815
+ type: dataType,
816
+ fields
817
+ };
818
+ }
819
+ __name(createJsonApiInclusion, "createJsonApiInclusion");
820
+
821
+ // src/core/utils/rehydrate.ts
822
+ function rehydrate(classKey, data) {
823
+ return RehydrationFactory.rehydrate(classKey, data);
824
+ }
825
+ __name(rehydrate, "rehydrate");
826
+ function rehydrateList(classKey, data) {
827
+ return RehydrationFactory.rehydrateList(classKey, data);
828
+ }
829
+ __name(rehydrateList, "rehydrateList");
830
+
831
+ // src/utils/cn.ts
832
+ import { clsx } from "clsx";
833
+ import { twMerge } from "tailwind-merge";
834
+ function cn(...inputs) {
835
+ return twMerge(clsx(inputs));
836
+ }
837
+ __name(cn, "cn");
838
+
839
+ // src/utils/compose-refs.ts
840
+ import * as React from "react";
841
+ function setRef(ref, value) {
842
+ if (typeof ref === "function") {
843
+ return ref(value);
844
+ }
845
+ if (ref !== null && ref !== void 0) {
846
+ ref.current = value;
847
+ }
848
+ }
849
+ __name(setRef, "setRef");
850
+ function composeRefs(...refs) {
851
+ return (node) => {
852
+ let hasCleanup = false;
853
+ const cleanups = refs.map((ref) => {
854
+ const cleanup = setRef(ref, node);
855
+ if (!hasCleanup && typeof cleanup === "function") {
856
+ hasCleanup = true;
857
+ }
858
+ return cleanup;
859
+ });
860
+ if (hasCleanup) {
861
+ return () => {
862
+ for (let i = 0; i < cleanups.length; i++) {
863
+ const cleanup = cleanups[i];
864
+ if (typeof cleanup === "function") {
865
+ cleanup();
866
+ } else {
867
+ setRef(refs[i], null);
868
+ }
869
+ }
870
+ };
871
+ }
872
+ };
873
+ }
874
+ __name(composeRefs, "composeRefs");
875
+ function useComposedRefs(...refs) {
876
+ return React.useCallback(composeRefs(...refs), refs);
877
+ }
878
+ __name(useComposedRefs, "useComposedRefs");
879
+
880
+ // src/utils/use-mobile.tsx
881
+ import * as React2 from "react";
882
+ var MOBILE_BREAKPOINT = 768;
883
+ function useIsMobile() {
884
+ const [isMobile, setIsMobile] = React2.useState(void 0);
885
+ React2.useEffect(() => {
886
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
887
+ const onChange = /* @__PURE__ */ __name(() => {
888
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
889
+ }, "onChange");
890
+ mql.addEventListener("change", onChange);
891
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
892
+ return () => mql.removeEventListener("change", onChange);
893
+ }, []);
894
+ return !!isMobile;
895
+ }
896
+ __name(useIsMobile, "useIsMobile");
897
+
898
+ // src/utils/date-formatter.ts
899
+ var formatDate = /* @__PURE__ */ __name((eventDate, formatOption) => {
900
+ const browserLocale = navigator.language || "en-US";
901
+ const formatPart = /* @__PURE__ */ __name((date, options) => new Intl.DateTimeFormat(browserLocale, options).format(date), "formatPart");
902
+ const now = /* @__PURE__ */ new Date();
903
+ const diff = now.getTime() - eventDate.getTime();
904
+ if (formatOption === "default") {
905
+ if (diff < 24 * 60 * 60 * 1e3) formatOption = "timeSince";
906
+ else formatOption = "dateTime";
907
+ }
908
+ if (formatOption === "timeSince") {
909
+ const seconds = Math.floor(diff / 1e3);
910
+ const minutes = Math.floor(seconds / 60);
911
+ const hours = Math.floor(minutes / 60);
912
+ const days = Math.floor(hours / 24);
913
+ if (days > 0) return `${days} days ago`;
914
+ if (hours > 0) return `${hours} hours ago`;
915
+ if (minutes > 0) return `${minutes} minutes ago`;
916
+ return `${seconds} seconds ago`;
917
+ }
918
+ const dateOptions = {
919
+ year: "numeric",
920
+ month: "2-digit",
921
+ day: "2-digit"
922
+ };
923
+ const timeOptions = {
924
+ hour: "2-digit",
925
+ minute: "2-digit"
926
+ };
927
+ switch (formatOption) {
928
+ case "date":
929
+ return formatPart(eventDate, dateOptions);
930
+ case "time":
931
+ return formatPart(eventDate, timeOptions);
932
+ case "dateTime":
933
+ return `${formatPart(eventDate, dateOptions)} ${formatPart(eventDate, timeOptions)}`;
934
+ default:
935
+ throw new Error("Invalid format option");
936
+ }
937
+ }, "formatDate");
938
+
939
+ // src/utils/exists.ts
940
+ var exists = /* @__PURE__ */ __name((itemOrArray) => {
941
+ if (!itemOrArray) return false;
942
+ if (Array.isArray(itemOrArray)) {
943
+ return itemOrArray.length > 0;
944
+ }
945
+ return true;
946
+ }, "exists");
947
+
948
+ // src/utils/table-options.ts
949
+ import { cloneElement, createElement, Fragment } from "react";
950
+ var TableOptions = class {
951
+ static {
952
+ __name(this, "TableOptions");
953
+ }
954
+ _components;
955
+ _hasPermissionToModule;
956
+ constructor(hasPermissionToModule) {
957
+ this._hasPermissionToModule = hasPermissionToModule;
958
+ this._components = [];
959
+ }
960
+ addOption(component, module, action) {
961
+ if (!component || module && action && !this._hasPermissionToModule({ module, action })) return;
962
+ this._components.push(component);
963
+ }
964
+ getComponents() {
965
+ return this._components;
966
+ }
967
+ getOptions() {
968
+ if (this._components.length === 0) return null;
969
+ const response = this._components.map(
970
+ (option, index) => cloneElement(option, { key: option.key ?? index })
971
+ );
972
+ return createElement(Fragment, {}, response);
973
+ }
974
+ };
975
+ function getTableOptions(params) {
976
+ const tableOptions = new TableOptions(params.hasPermissionToModule);
977
+ params.options.forEach((option) => tableOptions.addOption(option.component, option.module, option.action));
978
+ return tableOptions.getOptions();
979
+ }
980
+ __name(getTableOptions, "getTableOptions");
981
+ function getTableComponents(params) {
982
+ const tableOptions = new TableOptions(params.hasPermissionToModule);
983
+ params.options.forEach((option) => tableOptions.addOption(option.component, option.module, option.action));
984
+ return tableOptions.getComponents();
985
+ }
986
+ __name(getTableComponents, "getTableComponents");
987
+
988
+ // src/utils/schemas/user.object.schema.ts
989
+ import { z } from "zod";
990
+ var userObjectSchema = z.object({
991
+ id: z.string(),
992
+ name: z.string(),
993
+ avatar: z.string().optional()
994
+ });
995
+
996
+ // src/utils/schemas/entity.object.schema.ts
997
+ import { z as z2 } from "zod";
998
+ var entityObjectSchema = z2.object({
999
+ id: z2.uuidv4(),
1000
+ name: z2.string()
1001
+ });
1002
+
1003
+ // src/utils/blocknote-diff.util.ts
1004
+ var BlockNoteDiffUtil = class {
1005
+ static {
1006
+ __name(this, "BlockNoteDiffUtil");
1007
+ }
1008
+ static DEFAULT_OPTIONS = {
1009
+ ignoreIds: false,
1010
+ compareContent: true,
1011
+ similarityThreshold: 0.8
1012
+ };
1013
+ /**
1014
+ * Compare two BlockNote documents and return diff result
1015
+ */
1016
+ static diff(originalBlocks = [], newBlocks = [], options = {}) {
1017
+ const opts = { ...this.DEFAULT_OPTIONS, ...options };
1018
+ const originalMap = /* @__PURE__ */ new Map();
1019
+ const newMap = /* @__PURE__ */ new Map();
1020
+ originalBlocks.forEach((block) => {
1021
+ if (block.id) {
1022
+ originalMap.set(block.id, block);
1023
+ }
1024
+ });
1025
+ newBlocks.forEach((block) => {
1026
+ if (block.id) {
1027
+ newMap.set(block.id, block);
1028
+ }
1029
+ });
1030
+ const diffBlocks = [];
1031
+ const processedNewIds = /* @__PURE__ */ new Set();
1032
+ for (const originalBlock of originalBlocks) {
1033
+ const blockId = originalBlock.id;
1034
+ const processId = blockId || crypto.randomUUID();
1035
+ const newBlock = blockId ? newMap.get(blockId) : null;
1036
+ if (!newBlock) {
1037
+ const removedBlock = {
1038
+ ...originalBlock,
1039
+ id: processId,
1040
+ diffType: "removed",
1041
+ diffId: `removed-${processId}`
1042
+ };
1043
+ diffBlocks.push(removedBlock);
1044
+ } else {
1045
+ if (blockId) {
1046
+ processedNewIds.add(blockId);
1047
+ }
1048
+ if (this.areBlocksEqual(originalBlock, newBlock, opts)) {
1049
+ const unchangedBlock = {
1050
+ ...newBlock,
1051
+ diffType: "unchanged"
1052
+ };
1053
+ diffBlocks.push(unchangedBlock);
1054
+ } else {
1055
+ const wordDiffs = this.generateWordDiffs(originalBlock.content, newBlock.content, processId);
1056
+ const modifiedBlock = {
1057
+ ...newBlock,
1058
+ diffType: "modified",
1059
+ originalContent: originalBlock.content,
1060
+ diffId: `modified-${processId}`,
1061
+ wordDiffs
1062
+ };
1063
+ diffBlocks.push(modifiedBlock);
1064
+ }
1065
+ }
1066
+ }
1067
+ for (const newBlock of newBlocks) {
1068
+ const blockId = newBlock.id;
1069
+ if (blockId && processedNewIds.has(blockId)) continue;
1070
+ const generatedId = blockId || crypto.randomUUID();
1071
+ const addedBlock = {
1072
+ ...newBlock,
1073
+ id: generatedId,
1074
+ diffType: "added",
1075
+ diffId: `added-${generatedId}`
1076
+ };
1077
+ diffBlocks.push(addedBlock);
1078
+ }
1079
+ const sortedDiffBlocks = this.sortDiffBlocks(diffBlocks, originalBlocks, newBlocks);
1080
+ return {
1081
+ blocks: sortedDiffBlocks,
1082
+ hasChanges: sortedDiffBlocks.some((block) => block.diffType !== "unchanged")
1083
+ };
1084
+ }
1085
+ /**
1086
+ * Compare two blocks for equality
1087
+ */
1088
+ static areBlocksEqual(block1, block2, options) {
1089
+ if (block1.type !== block2.type) {
1090
+ return false;
1091
+ }
1092
+ if (!this.deepEqual(block1.props, block2.props)) {
1093
+ return false;
1094
+ }
1095
+ if (options.compareContent) {
1096
+ if (!this.deepEqual(block1.content, block2.content)) {
1097
+ return false;
1098
+ }
1099
+ }
1100
+ const children1 = block1.children || [];
1101
+ const children2 = block2.children || [];
1102
+ if (children1.length !== children2.length) {
1103
+ return false;
1104
+ }
1105
+ for (let i = 0; i < children1.length; i++) {
1106
+ if (!this.areBlocksEqual(children1[i], children2[i], options)) {
1107
+ return false;
1108
+ }
1109
+ }
1110
+ return true;
1111
+ }
1112
+ /**
1113
+ * Deep equality comparison for objects
1114
+ */
1115
+ static deepEqual(obj1, obj2) {
1116
+ if (obj1 === obj2) return true;
1117
+ if (obj1 == null || obj2 == null) return obj1 === obj2;
1118
+ if (typeof obj1 !== typeof obj2) return false;
1119
+ if (typeof obj1 !== "object") return obj1 === obj2;
1120
+ if (Array.isArray(obj1) !== Array.isArray(obj2)) return false;
1121
+ if (Array.isArray(obj1)) {
1122
+ if (obj1.length !== obj2.length) return false;
1123
+ for (let i = 0; i < obj1.length; i++) {
1124
+ if (!this.deepEqual(obj1[i], obj2[i])) return false;
1125
+ }
1126
+ return true;
1127
+ }
1128
+ const keys1 = Object.keys(obj1);
1129
+ const keys2 = Object.keys(obj2);
1130
+ if (keys1.length !== keys2.length) return false;
1131
+ for (const key of keys1) {
1132
+ if (!keys2.includes(key)) return false;
1133
+ if (!this.deepEqual(obj1[key], obj2[key])) return false;
1134
+ }
1135
+ return true;
1136
+ }
1137
+ /**
1138
+ * Sort diff blocks to maintain logical order
1139
+ */
1140
+ static sortDiffBlocks(diffBlocks, originalBlocks, newBlocks) {
1141
+ const originalPositions = /* @__PURE__ */ new Map();
1142
+ const newPositions = /* @__PURE__ */ new Map();
1143
+ originalBlocks.forEach((block, index) => {
1144
+ if (block.id) {
1145
+ originalPositions.set(block.id, index);
1146
+ }
1147
+ });
1148
+ newBlocks.forEach((block, index) => {
1149
+ if (block.id) {
1150
+ newPositions.set(block.id, index);
1151
+ }
1152
+ });
1153
+ return diffBlocks.sort((a, b) => {
1154
+ const aId = a.id;
1155
+ const bId = b.id;
1156
+ if (!aId || !bId) return 0;
1157
+ const aPos = newPositions.get(aId) ?? originalPositions.get(aId) ?? Infinity;
1158
+ const bPos = newPositions.get(bId) ?? originalPositions.get(bId) ?? Infinity;
1159
+ return aPos - bPos;
1160
+ });
1161
+ }
1162
+ /**
1163
+ * Calculate similarity between two text contents
1164
+ */
1165
+ static calculateSimilarity(content1, content2) {
1166
+ if (!content1 || !content2) return 0;
1167
+ const text1 = this.extractTextFromContent(content1);
1168
+ const text2 = this.extractTextFromContent(content2);
1169
+ if (text1 === text2) return 1;
1170
+ if (!text1 || !text2) return 0;
1171
+ const maxLength = Math.max(text1.length, text2.length);
1172
+ const distance = this.levenshteinDistance(text1, text2);
1173
+ return 1 - distance / maxLength;
1174
+ }
1175
+ /**
1176
+ * Extract plain text from BlockNote content array
1177
+ */
1178
+ static extractTextFromContent(content) {
1179
+ if (!Array.isArray(content)) return "";
1180
+ return content.map((item) => {
1181
+ if (item.type === "text") {
1182
+ return item.text || "";
1183
+ }
1184
+ return "";
1185
+ }).join("");
1186
+ }
1187
+ /**
1188
+ * Calculate Levenshtein distance between two strings
1189
+ */
1190
+ static levenshteinDistance(str1, str2) {
1191
+ const matrix = Array(str2.length + 1).fill(null).map(() => Array(str1.length + 1).fill(null));
1192
+ for (let i = 0; i <= str1.length; i++) {
1193
+ matrix[0][i] = i;
1194
+ }
1195
+ for (let j = 0; j <= str2.length; j++) {
1196
+ matrix[j][0] = j;
1197
+ }
1198
+ for (let j = 1; j <= str2.length; j++) {
1199
+ for (let i = 1; i <= str1.length; i++) {
1200
+ const substitutionCost = str1[i - 1] === str2[j - 1] ? 0 : 1;
1201
+ matrix[j][i] = Math.min(
1202
+ matrix[j][i - 1] + 1,
1203
+ // deletion
1204
+ matrix[j - 1][i] + 1,
1205
+ // insertion
1206
+ matrix[j - 1][i - 1] + substitutionCost
1207
+ // substitution
1208
+ );
1209
+ }
1210
+ }
1211
+ return matrix[str2.length][str1.length];
1212
+ }
1213
+ /**
1214
+ * Generate word-level diffs between two content arrays
1215
+ */
1216
+ static generateWordDiffs(originalContent, newContent, blockId) {
1217
+ const originalText = this.extractTextFromContent(originalContent || []);
1218
+ const newText = this.extractTextFromContent(newContent || []);
1219
+ if (!originalText && !newText) return [];
1220
+ if (!originalText) {
1221
+ return newText.split(/\s+/).filter((word) => word.trim()).map((word, index) => ({
1222
+ type: "added",
1223
+ text: word,
1224
+ diffId: `${blockId}-add-${index}`,
1225
+ accepted: false,
1226
+ rejected: false
1227
+ }));
1228
+ }
1229
+ if (!newText) {
1230
+ return originalText.split(/\s+/).filter((word) => word.trim()).map((word, index) => ({
1231
+ type: "removed",
1232
+ text: word,
1233
+ diffId: `${blockId}-remove-${index}`,
1234
+ accepted: false,
1235
+ rejected: false
1236
+ }));
1237
+ }
1238
+ return this.diffWords(originalText, newText, blockId);
1239
+ }
1240
+ /**
1241
+ * Perform word-level diff using word-only approach (no space tokenization)
1242
+ */
1243
+ static diffWords(text1, text2, blockId) {
1244
+ const words1 = text1.split(/\s+/).filter((word) => word.length > 0);
1245
+ const words2 = text2.split(/\s+/).filter((word) => word.length > 0);
1246
+ const diffs = this.myersDiff(words1, words2);
1247
+ const consolidatedDiffs = this.consolidateAdjacentChanges(diffs);
1248
+ const result = [];
1249
+ let diffIndex = 0;
1250
+ for (let i = 0; i < consolidatedDiffs.length; i++) {
1251
+ const diff = consolidatedDiffs[i];
1252
+ const isLastDiff = i === consolidatedDiffs.length - 1;
1253
+ switch (diff.type) {
1254
+ case "equal":
1255
+ result.push({
1256
+ type: "unchanged",
1257
+ text: diff.value,
1258
+ diffId: `${blockId}-unchanged-${diffIndex++}`,
1259
+ accepted: true,
1260
+ rejected: false
1261
+ });
1262
+ if (!isLastDiff) {
1263
+ result.push({
1264
+ type: "unchanged",
1265
+ text: " ",
1266
+ diffId: `${blockId}-space-${diffIndex++}`,
1267
+ accepted: true,
1268
+ rejected: false
1269
+ });
1270
+ }
1271
+ break;
1272
+ case "delete":
1273
+ if (diff.consolidated) {
1274
+ const nextDiff = i + 1 < consolidatedDiffs.length ? consolidatedDiffs[i + 1] : null;
1275
+ const isConsolidatedReplacement = nextDiff && nextDiff.type === "insert" && nextDiff.consolidated;
1276
+ if (isConsolidatedReplacement) {
1277
+ const replacementId = `${blockId}-replace-${diffIndex++}`;
1278
+ result.push({
1279
+ type: "removed",
1280
+ text: diff.value,
1281
+ diffId: replacementId,
1282
+ accepted: false,
1283
+ rejected: false
1284
+ });
1285
+ result.push({
1286
+ type: "added",
1287
+ text: nextDiff.value,
1288
+ diffId: replacementId,
1289
+ accepted: false,
1290
+ rejected: false
1291
+ });
1292
+ i++;
1293
+ if (i < consolidatedDiffs.length - 1) {
1294
+ result.push({
1295
+ type: "unchanged",
1296
+ text: " ",
1297
+ diffId: `${blockId}-space-${diffIndex++}`,
1298
+ accepted: true,
1299
+ rejected: false
1300
+ });
1301
+ }
1302
+ } else {
1303
+ result.push({
1304
+ type: "removed",
1305
+ text: diff.value,
1306
+ diffId: `${blockId}-remove-${diffIndex++}`,
1307
+ accepted: false,
1308
+ rejected: false
1309
+ });
1310
+ if (!isLastDiff) {
1311
+ result.push({
1312
+ type: "unchanged",
1313
+ text: " ",
1314
+ diffId: `${blockId}-space-${diffIndex++}`,
1315
+ accepted: true,
1316
+ rejected: false
1317
+ });
1318
+ }
1319
+ }
1320
+ } else {
1321
+ const nextDiff = i + 1 < consolidatedDiffs.length ? consolidatedDiffs[i + 1] : null;
1322
+ const isReplacement = nextDiff && nextDiff.type === "insert" && this.areWordsSimilar(diff.value, nextDiff.value);
1323
+ if (isReplacement) {
1324
+ const replacementId = `${blockId}-replace-${diffIndex++}`;
1325
+ result.push({
1326
+ type: "removed",
1327
+ text: diff.value,
1328
+ diffId: replacementId,
1329
+ accepted: false,
1330
+ rejected: false
1331
+ });
1332
+ result.push({
1333
+ type: "added",
1334
+ text: nextDiff.value,
1335
+ diffId: replacementId,
1336
+ accepted: false,
1337
+ rejected: false
1338
+ });
1339
+ i++;
1340
+ if (i < consolidatedDiffs.length - 1) {
1341
+ result.push({
1342
+ type: "unchanged",
1343
+ text: " ",
1344
+ diffId: `${blockId}-space-${diffIndex++}`,
1345
+ accepted: true,
1346
+ rejected: false
1347
+ });
1348
+ }
1349
+ } else {
1350
+ result.push({
1351
+ type: "removed",
1352
+ text: diff.value,
1353
+ diffId: `${blockId}-remove-${diffIndex++}`,
1354
+ accepted: false,
1355
+ rejected: false
1356
+ });
1357
+ if (!isLastDiff) {
1358
+ result.push({
1359
+ type: "unchanged",
1360
+ text: " ",
1361
+ diffId: `${blockId}-space-${diffIndex++}`,
1362
+ accepted: true,
1363
+ rejected: false
1364
+ });
1365
+ }
1366
+ }
1367
+ }
1368
+ break;
1369
+ case "insert":
1370
+ if (diff.consolidated) {
1371
+ const prevDiff = i > 0 ? consolidatedDiffs[i - 1] : null;
1372
+ const wasProcessedAsConsolidatedReplacement = prevDiff && prevDiff.type === "delete" && prevDiff.consolidated;
1373
+ if (!wasProcessedAsConsolidatedReplacement) {
1374
+ result.push({
1375
+ type: "added",
1376
+ text: diff.value,
1377
+ diffId: `${blockId}-add-${diffIndex++}`,
1378
+ accepted: false,
1379
+ rejected: false
1380
+ });
1381
+ if (!isLastDiff) {
1382
+ result.push({
1383
+ type: "unchanged",
1384
+ text: " ",
1385
+ diffId: `${blockId}-space-${diffIndex++}`,
1386
+ accepted: true,
1387
+ rejected: false
1388
+ });
1389
+ }
1390
+ }
1391
+ } else {
1392
+ const prevDiff = i > 0 ? consolidatedDiffs[i - 1] : null;
1393
+ const wasProcessedAsReplacement = prevDiff && prevDiff.type === "delete" && this.areWordsSimilar(prevDiff.value, diff.value);
1394
+ if (!wasProcessedAsReplacement) {
1395
+ result.push({
1396
+ type: "added",
1397
+ text: diff.value,
1398
+ diffId: `${blockId}-add-${diffIndex++}`,
1399
+ accepted: false,
1400
+ rejected: false
1401
+ });
1402
+ if (!isLastDiff) {
1403
+ result.push({
1404
+ type: "unchanged",
1405
+ text: " ",
1406
+ diffId: `${blockId}-space-${diffIndex++}`,
1407
+ accepted: true,
1408
+ rejected: false
1409
+ });
1410
+ }
1411
+ }
1412
+ }
1413
+ break;
1414
+ }
1415
+ }
1416
+ return result;
1417
+ }
1418
+ /**
1419
+ * Improved diff algorithm that better handles word insertions
1420
+ * Uses a combination of LCS and heuristics to minimize false changes
1421
+ */
1422
+ static myersDiff(a, b) {
1423
+ if (a.length === 0) {
1424
+ return b.map((value) => ({ type: "insert", value }));
1425
+ }
1426
+ if (b.length === 0) {
1427
+ return a.map((value) => ({ type: "delete", value }));
1428
+ }
1429
+ const dp = this.computeEditScript(a, b);
1430
+ return this.reconstructDiff(a, b, dp);
1431
+ }
1432
+ /**
1433
+ * Compute edit script using dynamic programming
1434
+ */
1435
+ static computeEditScript(a, b) {
1436
+ const m = a.length;
1437
+ const n = b.length;
1438
+ const dp = Array(m + 1).fill(null).map(() => Array(n + 1).fill(0));
1439
+ for (let i = 0; i <= m; i++) dp[i][0] = i;
1440
+ for (let j = 0; j <= n; j++) dp[0][j] = j;
1441
+ for (let i = 1; i <= m; i++) {
1442
+ for (let j = 1; j <= n; j++) {
1443
+ if (a[i - 1] === b[j - 1]) {
1444
+ dp[i][j] = dp[i - 1][j - 1];
1445
+ } else {
1446
+ dp[i][j] = 1 + Math.min(
1447
+ dp[i - 1][j],
1448
+ // Delete from a
1449
+ dp[i][j - 1],
1450
+ // Insert into a
1451
+ dp[i - 1][j - 1]
1452
+ // Replace
1453
+ );
1454
+ }
1455
+ }
1456
+ }
1457
+ return dp;
1458
+ }
1459
+ /**
1460
+ * Reconstruct the actual diff from the DP table
1461
+ */
1462
+ static reconstructDiff(a, b, dp) {
1463
+ const result = [];
1464
+ let i = a.length;
1465
+ let j = b.length;
1466
+ while (i > 0 || j > 0) {
1467
+ if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
1468
+ result.unshift({ type: "equal", value: a[i - 1] });
1469
+ i--;
1470
+ j--;
1471
+ } else {
1472
+ const deleteCost = i > 0 ? dp[i - 1][j] : Infinity;
1473
+ const insertCost = j > 0 ? dp[i][j - 1] : Infinity;
1474
+ const replaceCost = i > 0 && j > 0 ? dp[i - 1][j - 1] : Infinity;
1475
+ const minCost = Math.min(deleteCost, insertCost, replaceCost);
1476
+ if (minCost === insertCost && j > 0) {
1477
+ result.unshift({ type: "insert", value: b[j - 1] });
1478
+ j--;
1479
+ } else if (minCost === deleteCost && i > 0) {
1480
+ result.unshift({ type: "delete", value: a[i - 1] });
1481
+ i--;
1482
+ } else if (minCost === replaceCost && i > 0 && j > 0) {
1483
+ if (this.areWordsSimilar(a[i - 1], b[j - 1])) {
1484
+ result.unshift({ type: "insert", value: b[j - 1], sharedDiffId: true });
1485
+ result.unshift({ type: "delete", value: a[i - 1], sharedDiffId: true });
1486
+ i--;
1487
+ j--;
1488
+ } else {
1489
+ result.unshift({ type: "insert", value: b[j - 1] });
1490
+ j--;
1491
+ }
1492
+ }
1493
+ }
1494
+ }
1495
+ return result;
1496
+ }
1497
+ /**
1498
+ * Consolidate adjacent changes to reduce fragmentation
1499
+ * e.g., if we have: delete "Key", insert "Key!", delete "Challenges"
1500
+ * We can consolidate this into: replace ["Key", "Challenges"] with ["Key!"]
1501
+ */
1502
+ static consolidateAdjacentChanges(diffs) {
1503
+ const result = [];
1504
+ let i = 0;
1505
+ while (i < diffs.length) {
1506
+ const current = diffs[i];
1507
+ if (current.type === "equal") {
1508
+ result.push(current);
1509
+ i++;
1510
+ continue;
1511
+ }
1512
+ const changeSequence = [];
1513
+ let j = i;
1514
+ while (j < diffs.length && diffs[j].type !== "equal") {
1515
+ changeSequence.push(diffs[j]);
1516
+ j++;
1517
+ }
1518
+ if (changeSequence.length <= 1) {
1519
+ result.push(current);
1520
+ i++;
1521
+ continue;
1522
+ }
1523
+ const shouldConsolidate = this.shouldConsolidateChanges(
1524
+ changeSequence
1525
+ );
1526
+ if (shouldConsolidate) {
1527
+ const deletedWords = changeSequence.filter((c) => c.type === "delete").map((c) => c.value);
1528
+ const insertedWords = changeSequence.filter((c) => c.type === "insert").map((c) => c.value);
1529
+ if (deletedWords.length > 0) {
1530
+ result.push({
1531
+ type: "delete",
1532
+ value: deletedWords.join(" "),
1533
+ consolidated: true
1534
+ });
1535
+ }
1536
+ if (insertedWords.length > 0) {
1537
+ result.push({
1538
+ type: "insert",
1539
+ value: insertedWords.join(" "),
1540
+ consolidated: true
1541
+ });
1542
+ }
1543
+ } else {
1544
+ changeSequence.forEach((change) => result.push(change));
1545
+ }
1546
+ i = j;
1547
+ }
1548
+ return result;
1549
+ }
1550
+ /**
1551
+ * Determine if a sequence of changes should be consolidated
1552
+ */
1553
+ static shouldConsolidateChanges(changes) {
1554
+ const hasDeletes = changes.some((c) => c.type === "delete");
1555
+ const hasInserts = changes.some((c) => c.type === "insert");
1556
+ return hasDeletes && hasInserts;
1557
+ }
1558
+ /**
1559
+ * Check if two words are similar enough to be considered a replacement
1560
+ */
1561
+ static areWordsSimilar(word1, word2) {
1562
+ if (word1 === word2) return true;
1563
+ const maxLen = Math.max(word1.length, word2.length);
1564
+ const minLen = Math.min(word1.length, word2.length);
1565
+ if (maxLen > minLen * 2) {
1566
+ return false;
1567
+ }
1568
+ const word1Clean = word1.replace(/[^\w]/g, "");
1569
+ const word2Clean = word2.replace(/[^\w]/g, "");
1570
+ if (word1Clean === word2Clean && word1 !== word2) {
1571
+ return false;
1572
+ }
1573
+ const distance = this.levenshteinDistance(word1, word2);
1574
+ const similarity = 1 - distance / maxLen;
1575
+ return similarity > 0.7;
1576
+ }
1577
+ };
1578
+
1579
+ // src/utils/blocknote-word-diff-renderer.util.ts
1580
+ var BlockNoteWordDiffRendererUtil = class {
1581
+ static {
1582
+ __name(this, "BlockNoteWordDiffRendererUtil");
1583
+ }
1584
+ static renderWordDiffs(diffBlocks, onAcceptChange, onRejectChange, acceptedChanges, rejectedChanges) {
1585
+ if (acceptedChanges || rejectedChanges) {
1586
+ diffBlocks = this.updateWordDiffStates(diffBlocks, acceptedChanges, rejectedChanges);
1587
+ }
1588
+ return diffBlocks.map((block) => this.renderDiffBlock(block, onAcceptChange, onRejectChange));
1589
+ }
1590
+ static updateWordDiffStates(diffBlocks, acceptedChanges, rejectedChanges) {
1591
+ return diffBlocks.map((block) => {
1592
+ const updatedBlock = { ...block };
1593
+ if (updatedBlock.diffId) {
1594
+ updatedBlock.accepted = acceptedChanges?.has(updatedBlock.diffId) || false;
1595
+ updatedBlock.rejected = rejectedChanges?.has(updatedBlock.diffId) || false;
1596
+ }
1597
+ if (updatedBlock.wordDiffs) {
1598
+ updatedBlock.wordDiffs = updatedBlock.wordDiffs.map((wordDiff) => ({
1599
+ ...wordDiff,
1600
+ accepted: acceptedChanges?.has(wordDiff.diffId) || false,
1601
+ rejected: rejectedChanges?.has(wordDiff.diffId) || false
1602
+ }));
1603
+ }
1604
+ if (updatedBlock.children) {
1605
+ updatedBlock.children = this.updateWordDiffStates(
1606
+ updatedBlock.children,
1607
+ acceptedChanges,
1608
+ rejectedChanges
1609
+ );
1610
+ }
1611
+ return updatedBlock;
1612
+ });
1613
+ }
1614
+ static renderDiffBlock(block, onAcceptChange, onRejectChange) {
1615
+ if (block.diffType === "modified" && block.wordDiffs) {
1616
+ return this.renderWordLevelDiff(block, onAcceptChange, onRejectChange);
1617
+ }
1618
+ if (block.diffType === "added" || block.diffType === "removed") {
1619
+ return this.renderBlockLevelDiff(block, onAcceptChange, onRejectChange);
1620
+ }
1621
+ const baseBlock = {
1622
+ id: block.id || crypto.randomUUID(),
1623
+ type: block.type || "paragraph",
1624
+ props: this.getBlockProps(block),
1625
+ content: Array.isArray(block.content) ? block.content : [],
1626
+ children: block.children?.map(
1627
+ (child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
1628
+ )
1629
+ };
1630
+ return baseBlock;
1631
+ }
1632
+ static renderBlockLevelDiff(block, onAcceptChange, onRejectChange) {
1633
+ if (!block.diffId) {
1634
+ return {
1635
+ id: block.id || crypto.randomUUID(),
1636
+ type: block.type || "paragraph",
1637
+ props: block.props || {},
1638
+ content: Array.isArray(block.content) ? block.content : [],
1639
+ children: block.children?.map(
1640
+ (child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
1641
+ )
1642
+ };
1643
+ }
1644
+ const blockAccepted = block.accepted || false;
1645
+ const blockRejected = block.rejected || false;
1646
+ let content = Array.isArray(block.content) ? [...block.content] : [];
1647
+ if (block.diffType === "added") {
1648
+ if (blockRejected) {
1649
+ return {
1650
+ id: block.id || crypto.randomUUID(),
1651
+ type: "paragraph",
1652
+ props: {},
1653
+ content: [],
1654
+ children: []
1655
+ };
1656
+ } else if (!blockAccepted) {
1657
+ content = content.map((item) => ({
1658
+ ...item,
1659
+ styles: { ...item.styles, bold: true }
1660
+ }));
1661
+ content.push({
1662
+ type: "diffActions",
1663
+ props: { diffIds: block.diffId }
1664
+ });
1665
+ }
1666
+ } else if (block.diffType === "removed") {
1667
+ if (blockAccepted) {
1668
+ return {
1669
+ id: block.id || crypto.randomUUID(),
1670
+ type: "paragraph",
1671
+ props: {},
1672
+ content: [],
1673
+ children: []
1674
+ };
1675
+ } else if (!blockRejected) {
1676
+ content = content.map((item) => ({
1677
+ ...item,
1678
+ styles: { ...item.styles, strike: true }
1679
+ }));
1680
+ content.push({
1681
+ type: "diffActions",
1682
+ props: { diffIds: block.diffId }
1683
+ });
1684
+ }
1685
+ }
1686
+ const baseBlock = {
1687
+ id: block.id || crypto.randomUUID(),
1688
+ type: block.type || "paragraph",
1689
+ props: this.getBlockProps(block),
1690
+ content,
1691
+ children: block.children?.map(
1692
+ (child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
1693
+ )
1694
+ };
1695
+ return baseBlock;
1696
+ }
1697
+ static renderWordLevelDiff(block, onAcceptChange, onRejectChange) {
1698
+ if (!block.wordDiffs) {
1699
+ return {
1700
+ id: block.id || crypto.randomUUID(),
1701
+ type: block.type || "paragraph",
1702
+ props: block.props || {},
1703
+ content: Array.isArray(block.content) ? block.content : [],
1704
+ children: []
1705
+ };
1706
+ }
1707
+ const content = this.groupAndRenderWordDiffs(block.wordDiffs);
1708
+ return {
1709
+ id: block.id || crypto.randomUUID(),
1710
+ type: block.type || "paragraph",
1711
+ props: block.props || {},
1712
+ content: Array.isArray(content) ? content : [],
1713
+ children: block.children?.map((child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)) || []
1714
+ };
1715
+ }
1716
+ static groupAndRenderWordDiffs(wordDiffs) {
1717
+ const content = [];
1718
+ for (let i = 0; i < wordDiffs.length; i++) {
1719
+ const wordDiff = wordDiffs[i];
1720
+ const isLastOfGroup = this.isLastDiffInGroup(wordDiffs, i);
1721
+ const textContent = this.createTextContent(wordDiff, isLastOfGroup);
1722
+ if (textContent) {
1723
+ if (Array.isArray(textContent)) {
1724
+ content.push(...textContent);
1725
+ } else {
1726
+ content.push(textContent);
1727
+ }
1728
+ }
1729
+ }
1730
+ const cleanedContent = this.cleanupSpaces(content);
1731
+ return cleanedContent;
1732
+ }
1733
+ static cleanupSpaces(content) {
1734
+ const filtered = content.filter((item) => item !== null && item !== void 0);
1735
+ const cleaned = [];
1736
+ for (let i = 0; i < filtered.length; i++) {
1737
+ const current = filtered[i];
1738
+ if (current.type === "text" && current.text === " ") {
1739
+ const lastItem = cleaned[cleaned.length - 1];
1740
+ if (i === 0 || i === filtered.length - 1 || lastItem && lastItem.type === "text" && lastItem.text === " " || lastItem && lastItem.type === "diffActions") {
1741
+ continue;
1742
+ }
1743
+ }
1744
+ if (current.type === "diffActions") {
1745
+ const nextItem = i + 1 < filtered.length ? filtered[i + 1] : null;
1746
+ cleaned.push(current);
1747
+ if (nextItem && nextItem.type === "text" && nextItem.text !== " " && nextItem.type !== "diffActions") {
1748
+ cleaned.push({
1749
+ type: "text",
1750
+ text: " ",
1751
+ styles: {}
1752
+ });
1753
+ }
1754
+ continue;
1755
+ }
1756
+ cleaned.push(current);
1757
+ }
1758
+ return cleaned;
1759
+ }
1760
+ static isLastDiffInGroup(wordDiffs, currentIndex) {
1761
+ const currentDiff = wordDiffs[currentIndex];
1762
+ if (currentDiff.type === "unchanged") {
1763
+ return false;
1764
+ }
1765
+ for (let i = currentIndex + 1; i < wordDiffs.length; i++) {
1766
+ const nextDiff = wordDiffs[i];
1767
+ if (nextDiff.diffId === currentDiff.diffId && (nextDiff.type === "added" || nextDiff.type === "removed")) {
1768
+ return false;
1769
+ }
1770
+ if (nextDiff.type !== "unchanged" && nextDiff.diffId !== currentDiff.diffId) {
1771
+ break;
1772
+ }
1773
+ }
1774
+ return true;
1775
+ }
1776
+ static createTextContent(wordDiff, isLastOfGroup) {
1777
+ switch (wordDiff.type) {
1778
+ case "added":
1779
+ if (wordDiff.accepted) {
1780
+ return {
1781
+ type: "text",
1782
+ text: wordDiff.text,
1783
+ styles: {}
1784
+ };
1785
+ } else if (wordDiff.rejected) {
1786
+ return null;
1787
+ } else {
1788
+ if (wordDiff.text.trim() === "") {
1789
+ return {
1790
+ type: "text",
1791
+ text: wordDiff.text,
1792
+ styles: { backgroundColor: "#dcfce7" }
1793
+ };
1794
+ } else {
1795
+ const baseContent = {
1796
+ type: "text",
1797
+ text: wordDiff.text,
1798
+ styles: { bold: true }
1799
+ };
1800
+ if (isLastOfGroup) {
1801
+ return [
1802
+ baseContent,
1803
+ {
1804
+ type: "diffActions",
1805
+ props: { diffIds: wordDiff.diffId }
1806
+ }
1807
+ ];
1808
+ } else {
1809
+ return baseContent;
1810
+ }
1811
+ }
1812
+ }
1813
+ case "removed":
1814
+ if (wordDiff.accepted) {
1815
+ return null;
1816
+ } else if (wordDiff.rejected) {
1817
+ return {
1818
+ type: "text",
1819
+ text: wordDiff.text,
1820
+ styles: {}
1821
+ };
1822
+ } else {
1823
+ if (wordDiff.text.trim() === "") {
1824
+ return {
1825
+ type: "text",
1826
+ text: wordDiff.text,
1827
+ styles: { strike: true }
1828
+ };
1829
+ } else {
1830
+ const baseContent = {
1831
+ type: "text",
1832
+ text: wordDiff.text,
1833
+ styles: { strike: true }
1834
+ };
1835
+ if (isLastOfGroup) {
1836
+ return [
1837
+ baseContent,
1838
+ {
1839
+ type: "diffActions",
1840
+ props: { diffIds: wordDiff.diffId }
1841
+ }
1842
+ ];
1843
+ } else {
1844
+ return baseContent;
1845
+ }
1846
+ }
1847
+ }
1848
+ case "unchanged":
1849
+ default:
1850
+ return {
1851
+ type: "text",
1852
+ text: wordDiff.text,
1853
+ styles: {}
1854
+ };
1855
+ }
1856
+ }
1857
+ static getBlockProps(block) {
1858
+ const baseProps = block.props || {};
1859
+ return baseProps;
1860
+ }
1861
+ static generateChangeSummary(diffBlocks) {
1862
+ let totalWords = 0;
1863
+ let addedWords = 0;
1864
+ let removedWords = 0;
1865
+ let acceptedChanges = 0;
1866
+ let rejectedChanges = 0;
1867
+ let pendingChanges = 0;
1868
+ const processBlock = /* @__PURE__ */ __name((block) => {
1869
+ if (block.wordDiffs) {
1870
+ block.wordDiffs.forEach((wordDiff) => {
1871
+ totalWords++;
1872
+ if (wordDiff.type === "added") {
1873
+ addedWords++;
1874
+ } else if (wordDiff.type === "removed") {
1875
+ removedWords++;
1876
+ }
1877
+ if (wordDiff.accepted) {
1878
+ acceptedChanges++;
1879
+ } else if (wordDiff.rejected) {
1880
+ rejectedChanges++;
1881
+ } else if (wordDiff.type !== "unchanged") {
1882
+ pendingChanges++;
1883
+ }
1884
+ });
1885
+ }
1886
+ if (block.children) {
1887
+ block.children.forEach((child) => processBlock(child));
1888
+ }
1889
+ }, "processBlock");
1890
+ diffBlocks.forEach(processBlock);
1891
+ return {
1892
+ totalWords,
1893
+ addedWords,
1894
+ removedWords,
1895
+ acceptedChanges,
1896
+ rejectedChanges,
1897
+ pendingChanges
1898
+ };
1899
+ }
1900
+ };
1901
+
1902
+ // src/utils/icons.tsx
1903
+ import { jsx } from "react/jsx-runtime";
1904
+ var getIconByModule = /* @__PURE__ */ __name((params) => {
1905
+ const IconComponent = getLucideIconByModule({ module: params.module });
1906
+ if (!IconComponent) return null;
1907
+ return /* @__PURE__ */ jsx(IconComponent, { className: cn(``, params.className) });
1908
+ }, "getIconByModule");
1909
+ var getIcon = /* @__PURE__ */ __name((params) => {
1910
+ const IconComponent = getLucideIcon({ element: params.element });
1911
+ if (!IconComponent) return null;
1912
+ return /* @__PURE__ */ jsx(IconComponent, { className: cn(``, params.className) });
1913
+ }, "getIcon");
1914
+ var getIconByModuleName = /* @__PURE__ */ __name((params) => {
1915
+ return getIconByModule({ module: Modules.findByModelName(params.name), className: params.className });
1916
+ }, "getIconByModuleName");
1917
+ var getLucideIcon = /* @__PURE__ */ __name((params) => {
1918
+ if (params.element.type === "contents") {
1919
+ const contentType = params.element.contentType;
1920
+ if (!contentType) return null;
1921
+ return getLucideIconByModule({ module: Modules.findByModelName(contentType) });
1922
+ }
1923
+ return getLucideIconByModule({ module: Modules.findByName(params.element.type) });
1924
+ }, "getLucideIcon");
1925
+ var getLucideIconByModule = /* @__PURE__ */ __name((params) => {
1926
+ return params.module.icon ?? null;
1927
+ }, "getLucideIconByModule");
1928
+ var getLucideIconByModuleName = /* @__PURE__ */ __name((params) => {
1929
+ return getLucideIconByModule({ module: Modules.findByModelName(params.name) });
1930
+ }, "getLucideIconByModuleName");
1931
+
1932
+ // src/permissions/types.ts
1933
+ var Action = /* @__PURE__ */ ((Action2) => {
1934
+ Action2["Read"] = "read";
1935
+ Action2["Create"] = "create";
1936
+ Action2["Update"] = "update";
1937
+ Action2["Delete"] = "delete";
1938
+ return Action2;
1939
+ })(Action || {});
1940
+
1941
+ // src/permissions/check.ts
1942
+ function checkPermissions(params) {
1943
+ const selectedModule = params.user.modules.find((module) => module.id === params.module.moduleId);
1944
+ if (!selectedModule) return false;
1945
+ const permissionConfig = selectedModule.permissions[params.action];
1946
+ if (!permissionConfig) return false;
1947
+ if (typeof permissionConfig === "boolean") return permissionConfig;
1948
+ if (!params.data) return true;
1949
+ try {
1950
+ const singlePermissionConfig = permissionConfig.split("|").map((p) => p.trim());
1951
+ for (const path of singlePermissionConfig) {
1952
+ if (getValueFromPath(params.data, path, params.user.id)) return true;
1953
+ }
1954
+ return false;
1955
+ } catch {
1956
+ if (typeof permissionConfig === "string") {
1957
+ return getValueFromPath(params.data, permissionConfig, params.user.id);
1958
+ }
1959
+ }
1960
+ return false;
1961
+ }
1962
+ __name(checkPermissions, "checkPermissions");
1963
+ function checkPermissionsFromServer(params) {
1964
+ if (!params.selectedModule) return false;
1965
+ const permissionConfig = params.selectedModule.permissions[params.action];
1966
+ if (!permissionConfig) return false;
1967
+ if (typeof permissionConfig === "boolean") return permissionConfig;
1968
+ if (!params.data) return true;
1969
+ try {
1970
+ const singlePermissionConfig = permissionConfig.split("|").map((p) => p.trim());
1971
+ for (const path of singlePermissionConfig) {
1972
+ if (getValueFromPath(params.data, path, params.userId)) return true;
1973
+ }
1974
+ return false;
1975
+ } catch {
1976
+ if (typeof permissionConfig === "string") {
1977
+ return getValueFromPath(params.data, permissionConfig, params.userId);
1978
+ }
1979
+ }
1980
+ return false;
1981
+ }
1982
+ __name(checkPermissionsFromServer, "checkPermissionsFromServer");
1983
+ function getValueFromPath(obj, path, userId) {
1984
+ const parts = path.split(".");
1985
+ let current = obj;
1986
+ for (const part of parts) {
1987
+ if (!current) return false;
1988
+ if (Array.isArray(current)) {
1989
+ let found = false;
1990
+ for (const item of current) {
1991
+ const result = getValueFromPath(item, parts.slice(parts.indexOf(part)).join("."), userId);
1992
+ if (result === userId || result === true) {
1993
+ found = true;
1994
+ break;
1995
+ }
1996
+ }
1997
+ return found;
1998
+ } else if (current[part] !== void 0) {
1999
+ current = current[part];
2000
+ } else {
2001
+ return false;
2002
+ }
2003
+ }
2004
+ if (Array.isArray(current)) {
2005
+ return current.some((item) => {
2006
+ if (typeof item === "object" && item.id !== void 0) {
2007
+ return item.id.toString() === userId;
2008
+ }
2009
+ return item.toString() === userId;
2010
+ });
2011
+ }
2012
+ if (typeof current === "object" && current.id !== void 0) {
2013
+ return current.id.toString() === userId;
2014
+ }
2015
+ return current.toString() === userId;
2016
+ }
2017
+ __name(getValueFromPath, "getValueFromPath");
2018
+
2019
+ // src/features/auth/data/auth.ts
2020
+ var Auth = class extends AbstractApiData {
2021
+ static {
2022
+ __name(this, "Auth");
2023
+ }
2024
+ _token;
2025
+ _refreshToken;
2026
+ _user;
2027
+ get token() {
2028
+ if (!this._token) throw new Error("Token is not defined");
2029
+ return this._token;
2030
+ }
2031
+ get refreshToken() {
2032
+ if (!this._refreshToken) throw new Error("Refresh token is not defined");
2033
+ return this._refreshToken;
2034
+ }
2035
+ get user() {
2036
+ if (!this._user) throw new Error("User is not defined");
2037
+ return this._user;
2038
+ }
2039
+ rehydrate(data) {
2040
+ super.rehydrate(data);
2041
+ this._token = data.jsonApi.attributes.token ?? void 0;
2042
+ this._refreshToken = data.jsonApi.attributes.refreshToken ?? void 0;
2043
+ this._user = this._readIncluded(data, "user", Modules.User);
2044
+ return this;
2045
+ }
2046
+ createJsonApi(data) {
2047
+ const response = {
2048
+ data: {
2049
+ type: Modules.Auth.name,
2050
+ attributes: {}
2051
+ }
2052
+ };
2053
+ if (data.id) response.data.id = data.id;
2054
+ if (data.email !== void 0) response.data.attributes.email = data.email;
2055
+ if (data.name !== void 0) response.data.attributes.name = data.name;
2056
+ if (data.companyName !== void 0) response.data.attributes.companyName = data.companyName;
2057
+ if (data.password !== void 0) response.data.attributes.password = data.password;
2058
+ if (data.partitaIva !== void 0) response.data.attributes.partitaIva = data.partitaIva;
2059
+ if (data.codiceFiscale !== void 0) response.data.attributes.codiceFiscale = data.codiceFiscale;
2060
+ return response;
2061
+ }
2062
+ };
2063
+
2064
+ // src/features/auth/config.ts
2065
+ var _tokenHandler = null;
2066
+ function configureAuth(handler) {
2067
+ _tokenHandler = handler;
2068
+ }
2069
+ __name(configureAuth, "configureAuth");
2070
+ function getTokenHandler() {
2071
+ return _tokenHandler;
2072
+ }
2073
+ __name(getTokenHandler, "getTokenHandler");
2074
+
2075
+ // src/features/auth/data/auth.service.ts
2076
+ var AuthService = class extends AbstractService {
2077
+ static {
2078
+ __name(this, "AuthService");
2079
+ }
2080
+ static async login(params) {
2081
+ const language = params.language || "en-US";
2082
+ const apiResponse = await JsonApiPost({
2083
+ classKey: Modules.Auth,
2084
+ endpoint: new EndpointCreator({ endpoint: Modules.Auth, id: "login" }).generate(),
2085
+ body: { email: params.email, password: params.password },
2086
+ language
2087
+ });
2088
+ if (!apiResponse.ok) throw new Error(apiResponse.error);
2089
+ const auth = apiResponse.data;
2090
+ const handler = getTokenHandler();
2091
+ if (handler) {
2092
+ await handler.updateToken({
2093
+ token: auth.token,
2094
+ refreshToken: auth.refreshToken,
2095
+ userId: auth.user.id,
2096
+ companyId: auth.user.company?.id,
2097
+ licenseExpirationDate: auth.user.company?.licenseExpirationDate,
2098
+ roles: auth.user.roles.map((role) => role.id),
2099
+ features: auth.user.company?.features?.map((feature) => feature.id) ?? [],
2100
+ modules: auth.user.modules.map((module) => ({
2101
+ id: module.id,
2102
+ permissions: module.permissions
2103
+ }))
2104
+ });
2105
+ }
2106
+ return auth.user;
2107
+ }
2108
+ static async logout(params) {
2109
+ const language = params?.language || "en-US";
2110
+ await JsonApiDelete({
2111
+ classKey: Modules.Auth,
2112
+ endpoint: new EndpointCreator({ endpoint: Modules.Auth }).generate(),
2113
+ language
2114
+ });
2115
+ const handler = getTokenHandler();
2116
+ if (handler) {
2117
+ await handler.removeToken();
2118
+ }
2119
+ }
2120
+ static async initialiseForgotPassword(params) {
2121
+ const language = params.language || "en-US";
2122
+ const response = await JsonApiPost({
2123
+ classKey: Modules.Auth,
2124
+ endpoint: new EndpointCreator({ endpoint: Modules.Auth, id: "forgot" }).generate(),
2125
+ body: { email: params.email },
2126
+ language
2127
+ });
2128
+ if (!response.ok) {
2129
+ throw new Error(response.error);
2130
+ }
2131
+ }
2132
+ static async register(params) {
2133
+ const endpoint = new EndpointCreator({ endpoint: Modules.Auth, id: "register" });
2134
+ await this.callApi({
2135
+ type: Modules.Auth,
2136
+ method: "POST" /* POST */,
2137
+ endpoint: endpoint.generate(),
2138
+ input: params
2139
+ });
2140
+ }
2141
+ static async activate(params) {
2142
+ const endpoint = new EndpointCreator({
2143
+ endpoint: Modules.Auth,
2144
+ id: "activate",
2145
+ childEndpoint: params.activationCode
2146
+ });
2147
+ await this.callApi({ type: Modules.Auth, method: "POST" /* POST */, endpoint: endpoint.generate() });
2148
+ }
2149
+ static async validateCode(params) {
2150
+ const language = params.language || "en-US";
2151
+ const apiResponse = await JsonApiGet({
2152
+ classKey: Modules.Auth,
2153
+ endpoint: new EndpointCreator({ endpoint: Modules.Auth, id: "validate", childEndpoint: params.code }).generate(),
2154
+ language
2155
+ });
2156
+ if (!apiResponse.ok) throw new Error(apiResponse.error);
2157
+ }
2158
+ static async resetPassword(params) {
2159
+ const endpoint = new EndpointCreator({ endpoint: Modules.Auth, id: "reset", childEndpoint: params.code });
2160
+ const input = { password: params.password };
2161
+ await this.callApi({ type: Modules.Auth, method: "POST" /* POST */, endpoint: endpoint.generate(), input });
2162
+ }
2163
+ static async acceptInvitation(params) {
2164
+ const endpoint = new EndpointCreator({ endpoint: Modules.Auth, id: "invitation", childEndpoint: params.code });
2165
+ const input = { password: params.password };
2166
+ await this.callApi({ type: Modules.Auth, method: "POST" /* POST */, endpoint: endpoint.generate(), input });
2167
+ }
2168
+ static async findToken(params) {
2169
+ return await this.callApi({
2170
+ type: Modules.Auth,
2171
+ method: "POST" /* POST */,
2172
+ endpoint: new EndpointCreator({ endpoint: Modules.Auth }).addAdditionalParam("code", params.tokenCode).generate()
2173
+ });
2174
+ }
2175
+ static async saveToken(params) {
2176
+ const auth = rehydrate(Modules.Auth, params.dehydratedAuth);
2177
+ const handler = getTokenHandler();
2178
+ if (handler) {
2179
+ await handler.updateToken({
2180
+ token: auth.token,
2181
+ refreshToken: auth.refreshToken,
2182
+ userId: auth.user.id,
2183
+ companyId: auth.user.company?.id,
2184
+ licenseExpirationDate: auth.user.company?.licenseExpirationDate,
2185
+ roles: auth.user.roles.map((role) => role.id),
2186
+ features: auth.user.company?.features?.map((feature) => feature.id) ?? [],
2187
+ modules: auth.user.modules.map((module) => ({
2188
+ id: module.id,
2189
+ permissions: module.permissions
2190
+ }))
2191
+ });
2192
+ }
2193
+ }
2194
+ };
2195
+
2196
+ // src/features/auth/enums/AuthComponent.ts
2197
+ var AuthComponent = /* @__PURE__ */ ((AuthComponent2) => {
2198
+ AuthComponent2[AuthComponent2["Login"] = 0] = "Login";
2199
+ AuthComponent2[AuthComponent2["ForgotPassword"] = 1] = "ForgotPassword";
2200
+ AuthComponent2[AuthComponent2["ResetPassword"] = 2] = "ResetPassword";
2201
+ AuthComponent2[AuthComponent2["ActivateAccount"] = 3] = "ActivateAccount";
2202
+ AuthComponent2[AuthComponent2["AcceptInvitation"] = 4] = "AcceptInvitation";
2203
+ AuthComponent2[AuthComponent2["Register"] = 5] = "Register";
2204
+ AuthComponent2[AuthComponent2["Landing"] = 6] = "Landing";
2205
+ return AuthComponent2;
2206
+ })(AuthComponent || {});
2207
+
2208
+ // src/features/auth/auth.module.ts
2209
+ var AuthModule = /* @__PURE__ */ __name((factory) => factory({
2210
+ pageUrl: "/auth",
2211
+ name: "auth",
2212
+ model: Auth
2213
+ }), "AuthModule");
2214
+
2215
+ // src/features/company/data/company.ts
2216
+ var Company = class extends AbstractApiData {
2217
+ static {
2218
+ __name(this, "Company");
2219
+ }
2220
+ _name;
2221
+ _logo;
2222
+ _logoUrl;
2223
+ _configurations;
2224
+ _licenseExpirationDate;
2225
+ _features;
2226
+ _modules;
2227
+ get name() {
2228
+ if (this._name === void 0) throw new Error("Name is not defined");
2229
+ return this._name;
2230
+ }
2231
+ get logo() {
2232
+ return this._logo;
2233
+ }
2234
+ get logoUrl() {
2235
+ return this._logoUrl;
2236
+ }
2237
+ get licenseExpirationDate() {
2238
+ return this._licenseExpirationDate;
2239
+ }
2240
+ get features() {
2241
+ return this._features ?? [];
2242
+ }
2243
+ get modules() {
2244
+ return this._modules ?? [];
2245
+ }
2246
+ get configurations() {
2247
+ return this._configurations;
2248
+ }
2249
+ rehydrate(data) {
2250
+ super.rehydrate(data);
2251
+ this._name = data.jsonApi.attributes.name;
2252
+ this._configurations = data.jsonApi.attributes.configurations ? JSON.parse(data.jsonApi.attributes.configurations) : void 0;
2253
+ this._logo = data.jsonApi.attributes.logo;
2254
+ this._logoUrl = data.jsonApi.attributes.logoUrl;
2255
+ this._licenseExpirationDate = data.jsonApi.attributes.licenseExpirationDate ? new Date(data.jsonApi.attributes.licenseExpirationDate) : void 0;
2256
+ this._features = this._readIncluded(data, "features", Modules.Feature);
2257
+ this._modules = this._readIncluded(data, "modules", Modules.Module);
2258
+ return this;
2259
+ }
2260
+ createJsonApi(data) {
2261
+ const response = {
2262
+ data: {
2263
+ type: Modules.Company.name,
2264
+ id: data.id,
2265
+ attributes: {},
2266
+ meta: {},
2267
+ relationships: {}
2268
+ },
2269
+ included: []
2270
+ };
2271
+ if (data.name) response.data.attributes.name = data.name;
2272
+ if (data.configurations) response.data.attributes.configurations = JSON.stringify(data.configurations);
2273
+ if (data.logo) response.data.attributes.logo = data.logo;
2274
+ if (data.license) response.data.attributes.license = data.license;
2275
+ if (data.privateKey) response.data.attributes.privateKey = data.privateKey;
2276
+ if (data.featureIds && data.featureIds.length > 0) {
2277
+ response.data.relationships.features = {
2278
+ data: data.featureIds.map((featureId) => ({
2279
+ type: Modules.Feature.name,
2280
+ id: featureId
2281
+ }))
2282
+ };
2283
+ }
2284
+ if (data.moduleIds && data.moduleIds.length > 0) {
2285
+ response.data.relationships.modules = {
2286
+ data: data.moduleIds.map((moduleId) => ({
2287
+ type: Modules.Module.name,
2288
+ id: moduleId
2289
+ }))
2290
+ };
2291
+ }
2292
+ return response;
2293
+ }
2294
+ };
2295
+
2296
+ // src/features/company/data/company.fields.ts
2297
+ var CompanyFields = /* @__PURE__ */ ((CompanyFields2) => {
2298
+ CompanyFields2["companyId"] = "companyId";
2299
+ CompanyFields2["name"] = "name";
2300
+ CompanyFields2["createdAt"] = "createdAt";
2301
+ CompanyFields2["updatedAt"] = "updatedAt";
2302
+ return CompanyFields2;
2303
+ })(CompanyFields || {});
2304
+
2305
+ // src/features/company/data/company.service.ts
2306
+ var CompanyService = class extends AbstractService {
2307
+ static {
2308
+ __name(this, "CompanyService");
2309
+ }
2310
+ static async findOne(params) {
2311
+ return this.callApi({
2312
+ type: Modules.Company,
2313
+ method: "GET" /* GET */,
2314
+ endpoint: new EndpointCreator({ endpoint: Modules.Company, id: params.companyId }).generate()
2315
+ });
2316
+ }
2317
+ static async findMany(params) {
2318
+ const endpoint = new EndpointCreator({ endpoint: Modules.Company });
2319
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2320
+ return this.callApi({
2321
+ type: Modules.Company,
2322
+ method: "GET" /* GET */,
2323
+ endpoint: endpoint.generate(),
2324
+ next: params.next
2325
+ });
2326
+ }
2327
+ static async delete(params) {
2328
+ await this.callApi({
2329
+ type: Modules.Company,
2330
+ method: "DELETE" /* DELETE */,
2331
+ endpoint: new EndpointCreator({ endpoint: Modules.Company, id: params.companyId }).generate()
2332
+ });
2333
+ }
2334
+ static async create(params) {
2335
+ return this.callApi({
2336
+ type: Modules.Company,
2337
+ method: "POST" /* POST */,
2338
+ endpoint: new EndpointCreator({ endpoint: Modules.Company }).generate(),
2339
+ input: params
2340
+ });
2341
+ }
2342
+ static async update(params) {
2343
+ return this.callApi({
2344
+ type: Modules.Company,
2345
+ method: "PUT" /* PUT */,
2346
+ endpoint: new EndpointCreator({ endpoint: Modules.Company, id: params.id }).generate(),
2347
+ input: params
2348
+ });
2349
+ }
2350
+ static async updateConfigurations(params) {
2351
+ return this.callApi({
2352
+ type: Modules.Company,
2353
+ method: "PUT" /* PUT */,
2354
+ endpoint: new EndpointCreator({
2355
+ endpoint: Modules.Company,
2356
+ id: params.id,
2357
+ childEndpoint: "configurations"
2358
+ }).generate(),
2359
+ input: params
2360
+ });
2361
+ }
2362
+ static async activateLicense(params) {
2363
+ return this.callApi({
2364
+ type: Modules.Company,
2365
+ method: "PUT" /* PUT */,
2366
+ endpoint: new EndpointCreator({ endpoint: Modules.Company, id: params.id, childEndpoint: "license" }).generate(),
2367
+ input: params
2368
+ });
2369
+ }
2370
+ };
2371
+
2372
+ // src/features/company/company.module.ts
2373
+ var CompanyModule = /* @__PURE__ */ __name((factory) => factory({
2374
+ pageUrl: "/companies",
2375
+ name: "companies",
2376
+ model: Company,
2377
+ moduleId: "f9e77c8f-bfd1-4fd4-80b0-e1d891ab7113"
2378
+ }), "CompanyModule");
2379
+
2380
+ // src/features/content/data/content.ts
2381
+ var Content = class extends AbstractApiData {
2382
+ static {
2383
+ __name(this, "Content");
2384
+ }
2385
+ _contentType;
2386
+ _name;
2387
+ _abstract;
2388
+ _tldr;
2389
+ _aiStatus;
2390
+ _relevance;
2391
+ _author;
2392
+ _editors;
2393
+ get searchResult() {
2394
+ return this._name ?? "";
2395
+ }
2396
+ get contentType() {
2397
+ return this._contentType;
2398
+ }
2399
+ get name() {
2400
+ if (this._name === void 0) throw new Error("JsonApi error: content name is missing");
2401
+ return this._name;
2402
+ }
2403
+ get abstract() {
2404
+ return this._abstract;
2405
+ }
2406
+ get tldr() {
2407
+ return this._tldr;
2408
+ }
2409
+ get aiStatus() {
2410
+ return this._aiStatus ?? "";
2411
+ }
2412
+ get relevance() {
2413
+ return this._relevance;
2414
+ }
2415
+ get author() {
2416
+ if (this._author === void 0) throw new Error("JsonApi error: document author is missing");
2417
+ return this._author;
2418
+ }
2419
+ get editors() {
2420
+ return this._editors ?? [];
2421
+ }
2422
+ rehydrate(data) {
2423
+ super.rehydrate(data);
2424
+ this._contentType = data.jsonApi.meta.contentType;
2425
+ this._name = data.jsonApi.attributes.name;
2426
+ this._abstract = data.jsonApi.attributes.abstract;
2427
+ this._tldr = data.jsonApi.attributes.tldr;
2428
+ this._aiStatus = data.jsonApi.meta.aiStatus;
2429
+ this._relevance = data.jsonApi.meta.relevance;
2430
+ this._author = this._readIncluded(data, "author", Modules.User);
2431
+ this._editors = this._readIncluded(data, "editors", Modules.User);
2432
+ return this;
2433
+ }
2434
+ addContentInput(response, data) {
2435
+ if (data.name) response.data.attributes.name = data.name;
2436
+ if (data.authorId) {
2437
+ response.data.relationships.author = {
2438
+ data: {
2439
+ type: Modules.User.name,
2440
+ id: data.authorId
2441
+ }
2442
+ };
2443
+ }
2444
+ }
2445
+ };
2446
+
2447
+ // src/features/content/data/content.fields.ts
2448
+ var ContentFields = /* @__PURE__ */ ((ContentFields2) => {
2449
+ ContentFields2["contentId"] = "contentId";
2450
+ ContentFields2["name"] = "name";
2451
+ ContentFields2["relevance"] = "relevance";
2452
+ ContentFields2["authors"] = "authors";
2453
+ ContentFields2["createdAt"] = "createdAt";
2454
+ ContentFields2["updatedAt"] = "updatedAt";
2455
+ return ContentFields2;
2456
+ })(ContentFields || {});
2457
+
2458
+ // src/features/content/data/content.service.ts
2459
+ var ContentService = class extends AbstractService {
2460
+ static {
2461
+ __name(this, "ContentService");
2462
+ }
2463
+ static async findMany(params) {
2464
+ const endpoint = new EndpointCreator({ endpoint: Modules.Content });
2465
+ if (params.contentIds) {
2466
+ endpoint.addAdditionalParam("contentIds", params.contentIds.join(","));
2467
+ endpoint.addAdditionalParam("fetchAll", "true");
2468
+ } else {
2469
+ if (params.fetchAll) endpoint.addAdditionalParam("fetchAll", "true");
2470
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2471
+ }
2472
+ if (Modules.Content.inclusions?.lists?.fields) endpoint.limitToFields(Modules.Content.inclusions.lists.fields);
2473
+ if (Modules.Content.inclusions?.lists?.types) endpoint.limitToType(Modules.Content.inclusions.lists.types);
2474
+ return this.callApi({
2475
+ type: Modules.Content,
2476
+ method: "GET" /* GET */,
2477
+ endpoint: endpoint.generate(),
2478
+ next: params.next
2479
+ });
2480
+ }
2481
+ static async findRelevant(params) {
2482
+ const endpoint = new EndpointCreator({
2483
+ endpoint: Modules.Content,
2484
+ id: params.id,
2485
+ childEndpoint: "relevance"
2486
+ });
2487
+ if (Modules.Content.inclusions?.lists?.fields) endpoint.limitToFields(Modules.Content.inclusions.lists.fields);
2488
+ if (Modules.Content.inclusions?.lists?.types) endpoint.limitToType(Modules.Content.inclusions.lists.types);
2489
+ return this.callApi({
2490
+ type: Modules.Content,
2491
+ method: "GET" /* GET */,
2492
+ endpoint: endpoint.generate(),
2493
+ next: params.next
2494
+ });
2495
+ }
2496
+ static async findManyByAuthor(params) {
2497
+ const endpoint = new EndpointCreator({
2498
+ endpoint: Modules.Author,
2499
+ id: params.userId,
2500
+ childEndpoint: Modules.Content
2501
+ });
2502
+ if (params.fetchAll) endpoint.addAdditionalParam("fetchAll", "true");
2503
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2504
+ if (Modules.Content.inclusions?.lists?.fields) endpoint.limitToFields(Modules.Content.inclusions.lists.fields);
2505
+ if (Modules.Content.inclusions?.lists?.types) endpoint.limitToType(Modules.Content.inclusions.lists.types);
2506
+ return this.callApi({
2507
+ type: Modules.Content,
2508
+ method: "GET" /* GET */,
2509
+ endpoint: endpoint.generate(),
2510
+ next: params.next
2511
+ });
2512
+ }
2513
+ };
2514
+
2515
+ // src/features/content/content.module.ts
2516
+ var ContentModule = /* @__PURE__ */ __name((factory) => factory({
2517
+ pageUrl: "/contents",
2518
+ name: "contents",
2519
+ model: Content,
2520
+ inclusions: {
2521
+ lists: {
2522
+ fields: [
2523
+ createJsonApiInclusion("content", [`name`, `tldr`, `abstract`, `aiStatus`, `relevance`]),
2524
+ createJsonApiInclusion("users", [`name`, `avatar`]),
2525
+ createJsonApiInclusion("topics", [`name`]),
2526
+ createJsonApiInclusion("expertises", [`name`])
2527
+ ]
2528
+ }
2529
+ }
2530
+ }), "ContentModule");
2531
+
2532
+ // src/features/feature/data/feature.ts
2533
+ var Feature = class extends AbstractApiData {
2534
+ static {
2535
+ __name(this, "Feature");
2536
+ }
2537
+ _name;
2538
+ _isProduction;
2539
+ _modules = [];
2540
+ get name() {
2541
+ return this._name ?? "";
2542
+ }
2543
+ get isProduction() {
2544
+ return this._isProduction == true ? true : false;
2545
+ }
2546
+ get modules() {
2547
+ return this._modules;
2548
+ }
2549
+ rehydrate(data) {
2550
+ super.rehydrate(data);
2551
+ this._name = data.jsonApi.attributes.name;
2552
+ this._isProduction = data.jsonApi.attributes.isProduction ?? false;
2553
+ this._modules = this._readIncluded(data, `modules`, Modules.Module);
2554
+ return this;
2555
+ }
2556
+ };
2557
+
2558
+ // src/features/feature/data/feature.service.ts
2559
+ var FeatureService = class extends AbstractService {
2560
+ static {
2561
+ __name(this, "FeatureService");
2562
+ }
2563
+ static async findMany(params) {
2564
+ const endpoint = new EndpointCreator({ endpoint: Modules.Feature });
2565
+ if (params.companyId) endpoint.endpoint(Modules.Company).id(params.companyId).childEndpoint(Modules.Feature);
2566
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2567
+ return this.callApi({
2568
+ type: Modules.Feature,
2569
+ method: "GET" /* GET */,
2570
+ endpoint: endpoint.generate(),
2571
+ next: params.next
2572
+ });
2573
+ }
2574
+ };
2575
+
2576
+ // src/features/feature/feature.module.ts
2577
+ var FeatureModule = /* @__PURE__ */ __name((factory) => factory({
2578
+ pageUrl: "/features",
2579
+ name: "features",
2580
+ model: Feature,
2581
+ moduleId: "025fdd23-2803-4360-9fd9-eaa3612c2e23"
2582
+ }), "FeatureModule");
2583
+
2584
+ // src/features/module/data/module.ts
2585
+ var Module = class extends AbstractApiData {
2586
+ static {
2587
+ __name(this, "Module");
2588
+ }
2589
+ _name;
2590
+ _isCore;
2591
+ _permissions;
2592
+ get name() {
2593
+ if (!this._name) throw new Error("Name is not defined");
2594
+ return this._name ?? "";
2595
+ }
2596
+ get isCore() {
2597
+ return this._isCore ?? false;
2598
+ }
2599
+ get permissions() {
2600
+ if (!this._permissions) throw new Error("Permissions is not defined");
2601
+ return this._permissions;
2602
+ }
2603
+ rehydrate(data) {
2604
+ super.rehydrate(data);
2605
+ this._name = data.jsonApi.attributes.name;
2606
+ this._isCore = data.jsonApi.attributes.isCore;
2607
+ this._permissions = data.jsonApi.meta.permissions;
2608
+ return this;
2609
+ }
2610
+ };
2611
+
2612
+ // src/features/module/module.module.ts
2613
+ var ModuleModule = /* @__PURE__ */ __name((factory) => factory({
2614
+ pageUrl: "/modules",
2615
+ name: "modules",
2616
+ model: Module,
2617
+ moduleId: "25ffd868-8341-4ca7-963b-6e1c56b03b1d"
2618
+ }), "ModuleModule");
2619
+
2620
+ // src/features/notification/data/notification.ts
2621
+ var Notification = class extends AbstractApiData {
2622
+ static {
2623
+ __name(this, "Notification");
2624
+ }
2625
+ _notificationType;
2626
+ _isRead;
2627
+ _actor;
2628
+ get notificationType() {
2629
+ if (this._notificationType === void 0) throw new Error("notificationType is not set");
2630
+ return this._notificationType;
2631
+ }
2632
+ get isRead() {
2633
+ return this._isRead === void 0 ? false : this._isRead;
2634
+ }
2635
+ get actor() {
2636
+ return this._actor;
2637
+ }
2638
+ rehydrate(data) {
2639
+ super.rehydrate(data);
2640
+ this._notificationType = data.jsonApi.attributes.notificationType;
2641
+ this._isRead = data.jsonApi.attributes.isRead;
2642
+ this._actor = this._readIncluded(data, "actor", Modules.User);
2643
+ return this;
2644
+ }
2645
+ createJsonApi(data) {
2646
+ const response = {
2647
+ data: {
2648
+ type: Modules.Notification.name,
2649
+ id: data.id,
2650
+ attributes: {
2651
+ isRead: data.isRead
2652
+ },
2653
+ meta: {},
2654
+ relationships: {}
2655
+ },
2656
+ included: []
2657
+ };
2658
+ return response;
2659
+ }
2660
+ };
2661
+
2662
+ // src/features/notification/data/notification.fields.ts
2663
+ var NotificationFields = /* @__PURE__ */ ((NotificationFields2) => {
2664
+ NotificationFields2["notificationId"] = "notificationId";
2665
+ NotificationFields2["name"] = "name";
2666
+ NotificationFields2["createdAt"] = "createdAt";
2667
+ NotificationFields2["updatedAt"] = "updatedAt";
2668
+ return NotificationFields2;
2669
+ })(NotificationFields || {});
2670
+
2671
+ // src/features/notification/data/notification.service.ts
2672
+ var NotificationService = class extends AbstractService {
2673
+ static {
2674
+ __name(this, "NotificationService");
2675
+ }
2676
+ static async findMany(params) {
2677
+ const endpoint = new EndpointCreator({ endpoint: Modules.Notification });
2678
+ if (params.isArchived) endpoint.addAdditionalParam("isArchived", "true");
2679
+ return this.callApi({
2680
+ type: Modules.Notification,
2681
+ method: "GET" /* GET */,
2682
+ endpoint: endpoint.generate(),
2683
+ next: params.next
2684
+ });
2685
+ }
2686
+ static async markAsRead(params) {
2687
+ const endpoint = new EndpointCreator({ endpoint: Modules.Notification });
2688
+ await this.callApi({
2689
+ type: Modules.Notification,
2690
+ method: "PATCH" /* PATCH */,
2691
+ endpoint: endpoint.generate(),
2692
+ input: params.data,
2693
+ overridesJsonApiCreation: true
2694
+ });
2695
+ }
2696
+ static async archive(params) {
2697
+ const endpoint = new EndpointCreator({ endpoint: Modules.Notification, id: params.id, childEndpoint: "archive" });
2698
+ await this.callApi({ type: Modules.Notification, method: "POST" /* POST */, endpoint: endpoint.generate() });
2699
+ }
2700
+ };
2701
+
2702
+ // src/features/notification/notification.module.ts
2703
+ var NotificationModule = /* @__PURE__ */ __name((factory) => factory({
2704
+ pageUrl: "/notifications",
2705
+ name: "notifications",
2706
+ model: Notification,
2707
+ moduleId: "9259d704-c670-4e77-a3a1-a728ffc5be3d"
2708
+ }), "NotificationModule");
2709
+
2710
+ // src/features/push/data/push.ts
2711
+ var Push = class extends AbstractApiData {
2712
+ static {
2713
+ __name(this, "Push");
2714
+ }
2715
+ createJsonApi(data) {
2716
+ const response = {
2717
+ data: {
2718
+ type: Modules.Push.name,
2719
+ attributes: {
2720
+ key: data.key
2721
+ }
2722
+ },
2723
+ included: []
2724
+ };
2725
+ return response;
2726
+ }
2727
+ };
2728
+
2729
+ // src/features/push/data/push.service.ts
2730
+ var PushService = class extends AbstractService {
2731
+ static {
2732
+ __name(this, "PushService");
2733
+ }
2734
+ static async register(params) {
2735
+ const endpoint = new EndpointCreator({ endpoint: Modules.Push });
2736
+ await this.callApi({
2737
+ type: Modules.Push,
2738
+ method: "POST" /* POST */,
2739
+ endpoint: endpoint.generate(),
2740
+ input: params.data,
2741
+ overridesJsonApiCreation: true
2742
+ });
2743
+ }
2744
+ };
2745
+
2746
+ // src/features/push/push.module.ts
2747
+ var PushModule = /* @__PURE__ */ __name((factory) => factory({
2748
+ pageUrl: "/push",
2749
+ name: "push",
2750
+ model: Push,
2751
+ moduleId: ""
2752
+ }), "PushModule");
2753
+
2754
+ // src/features/role/data/role.ts
2755
+ var Role = class extends AbstractApiData {
2756
+ static {
2757
+ __name(this, "Role");
2758
+ }
2759
+ _name;
2760
+ _description;
2761
+ _isSelectable;
2762
+ _requiredFeature;
2763
+ get name() {
2764
+ if (!this._name) throw new Error("Name is not defined");
2765
+ return this._name;
2766
+ }
2767
+ get description() {
2768
+ return this._description ?? "";
2769
+ }
2770
+ get isSelectable() {
2771
+ return this._isSelectable ?? false;
2772
+ }
2773
+ get requiredFeature() {
2774
+ return this._requiredFeature;
2775
+ }
2776
+ rehydrate(data) {
2777
+ super.rehydrate(data);
2778
+ this._name = data.jsonApi.attributes.name ?? void 0;
2779
+ this._description = data.jsonApi.attributes.description ?? void 0;
2780
+ this._isSelectable = data.jsonApi.attributes.isSelectable ?? void 0;
2781
+ this._requiredFeature = this._readIncluded(
2782
+ data,
2783
+ "requiredFeature",
2784
+ Modules.Feature
2785
+ );
2786
+ return this;
2787
+ }
2788
+ createJsonApi(data) {
2789
+ const response = {
2790
+ data: {
2791
+ type: Modules.Role.name,
2792
+ id: data.id,
2793
+ attributes: {
2794
+ name: data.name
2795
+ },
2796
+ meta: {}
2797
+ },
2798
+ included: []
2799
+ };
2800
+ if (data.description !== void 0) response.data.attributes.description = data.description;
2801
+ return response;
2802
+ }
2803
+ };
2804
+
2805
+ // src/features/role/data/role.fields.ts
2806
+ var RoleFields = /* @__PURE__ */ ((RoleFields2) => {
2807
+ RoleFields2["roleId"] = "roleId";
2808
+ RoleFields2["name"] = "name";
2809
+ RoleFields2["description"] = "description";
2810
+ RoleFields2["createdAt"] = "createdAt";
2811
+ RoleFields2["updatedAt"] = "updatedAt";
2812
+ return RoleFields2;
2813
+ })(RoleFields || {});
2814
+
2815
+ // src/features/role/data/role.service.ts
2816
+ var RoleService = class extends AbstractService {
2817
+ static {
2818
+ __name(this, "RoleService");
2819
+ }
2820
+ static async findById(params) {
2821
+ return this.callApi({
2822
+ type: Modules.Role,
2823
+ method: "GET" /* GET */,
2824
+ endpoint: new EndpointCreator({ endpoint: Modules.Role, id: params.roleId }).generate()
2825
+ });
2826
+ }
2827
+ static async findAllRoles(params) {
2828
+ const endpoint = new EndpointCreator({ endpoint: Modules.Role });
2829
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2830
+ return this.callApi({
2831
+ type: Modules.Role,
2832
+ method: "GET" /* GET */,
2833
+ endpoint: endpoint.generate(),
2834
+ next: params.next
2835
+ });
2836
+ }
2837
+ static async findAllRolesByUser(params) {
2838
+ const endpoint = new EndpointCreator({ endpoint: Modules.User, id: params.userId, childEndpoint: Modules.Role });
2839
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2840
+ return this.callApi({
2841
+ type: Modules.Role,
2842
+ method: "GET" /* GET */,
2843
+ endpoint: endpoint.generate(),
2844
+ next: params.next
2845
+ });
2846
+ }
2847
+ static async findAllRolesUserNotIn(params) {
2848
+ const endpoint = new EndpointCreator({
2849
+ endpoint: Modules.User,
2850
+ id: params.userId,
2851
+ childEndpoint: Modules.Role
2852
+ }).addAdditionalParam("userNotIn", "true");
2853
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
2854
+ return this.callApi({
2855
+ type: Modules.Role,
2856
+ method: "GET" /* GET */,
2857
+ endpoint: endpoint.generate(),
2858
+ next: params.next
2859
+ });
2860
+ }
2861
+ static async addUserToRole(params) {
2862
+ this.callApi({
2863
+ type: Modules.Role,
2864
+ method: "POST" /* POST */,
2865
+ endpoint: new EndpointCreator({
2866
+ endpoint: Modules.Role,
2867
+ id: params.roleId,
2868
+ childEndpoint: Modules.User,
2869
+ childId: params.userId
2870
+ }).generate()
2871
+ });
2872
+ }
2873
+ static async removeUserFromRole(params) {
2874
+ this.callApi({
2875
+ type: Modules.Role,
2876
+ method: "DELETE" /* DELETE */,
2877
+ endpoint: new EndpointCreator({
2878
+ endpoint: Modules.Role,
2879
+ id: params.roleId,
2880
+ childEndpoint: Modules.User,
2881
+ childId: params.userId
2882
+ }).generate()
2883
+ });
2884
+ }
2885
+ static async create(params) {
2886
+ return this.callApi({
2887
+ type: Modules.Role,
2888
+ method: "POST" /* POST */,
2889
+ endpoint: new EndpointCreator({ endpoint: Modules.Role }).generate(),
2890
+ input: { id: params.roleId, name: params.name, description: params.description }
2891
+ });
2892
+ }
2893
+ static async update(params) {
2894
+ return this.callApi({
2895
+ type: Modules.Role,
2896
+ method: "PUT" /* PUT */,
2897
+ endpoint: new EndpointCreator({ endpoint: Modules.Role, id: params.roleId }).generate(),
2898
+ input: { id: params.roleId, name: params.name, description: params.description }
2899
+ });
2900
+ }
2901
+ static async delete(params) {
2902
+ return this.callApi({
2903
+ type: Modules.Role,
2904
+ method: "DELETE" /* DELETE */,
2905
+ endpoint: new EndpointCreator({ endpoint: Modules.Role, id: params.roleId }).generate()
2906
+ });
2907
+ }
2908
+ };
2909
+
2910
+ // src/features/role/role.module.ts
2911
+ var RoleModule = /* @__PURE__ */ __name((factory) => factory({
2912
+ pageUrl: "/roles",
2913
+ name: "roles",
2914
+ model: Role,
2915
+ moduleId: "9f6416e6-7b9b-4e1a-a99f-833191eca8a9"
2916
+ }), "RoleModule");
2917
+
2918
+ // src/features/s3/data/s3.ts
2919
+ var S3 = class extends AbstractApiData {
2920
+ static {
2921
+ __name(this, "S3");
2922
+ }
2923
+ _url;
2924
+ _storageType;
2925
+ _contentType;
2926
+ _blobType;
2927
+ _acl;
2928
+ get url() {
2929
+ if (!this._url) throw new Error("Image URL is not set.");
2930
+ return this._url;
2931
+ }
2932
+ get headers() {
2933
+ const headers = {};
2934
+ if (this._contentType) {
2935
+ headers["Content-Type"] = this._contentType;
2936
+ }
2937
+ if (this._blobType) {
2938
+ headers["x-ms-blob-type"] = this._blobType;
2939
+ }
2940
+ if (this._acl) {
2941
+ headers["x-amz-acl"] = this._acl;
2942
+ }
2943
+ return headers;
2944
+ }
2945
+ rehydrate(data) {
2946
+ super.rehydrate(data);
2947
+ this._url = data.jsonApi.attributes.url ?? void 0;
2948
+ this._storageType = data.jsonApi.attributes.storageType ?? void 0;
2949
+ this._contentType = data.jsonApi.attributes.contentType ?? void 0;
2950
+ this._blobType = data.jsonApi.attributes.blobType ?? void 0;
2951
+ this._acl = data.jsonApi.attributes.acl ?? void 0;
2952
+ return this;
2953
+ }
2954
+ createJsonApi(data) {
2955
+ const response = {
2956
+ data: {
2957
+ type: Modules.S3.name,
2958
+ attributes: {
2959
+ key: data.key
2960
+ }
2961
+ },
2962
+ included: []
2963
+ };
2964
+ if (data.contentType) response.data.attributes.contentType = data.contentType;
2965
+ return response;
2966
+ }
2967
+ };
2968
+
2969
+ // src/features/s3/s3.module.ts
2970
+ var S3Module = /* @__PURE__ */ __name((factory) => factory({
2971
+ pageUrl: "/s3",
2972
+ name: "s3",
2973
+ model: S3,
2974
+ moduleId: "db41ba46-e171-4324-8845-99353eba8568"
2975
+ }), "S3Module");
2976
+
2977
+ // src/features/s3/data/s3.service.ts
2978
+ var S3Service = class extends AbstractService {
2979
+ static {
2980
+ __name(this, "S3Service");
2981
+ }
2982
+ static async getPreSignedUrl(params) {
2983
+ const endpoint = new EndpointCreator({ endpoint: Modules.S3 }).addAdditionalParam("key", params.key).addAdditionalParam("contentType", params.contentType);
2984
+ if (params.isPublic) endpoint.addAdditionalParam("isPublic", "true");
2985
+ return this.callApi({ type: Modules.S3, method: "GET" /* GET */, endpoint: endpoint.generate() });
2986
+ }
2987
+ static async getSignedUrl(params) {
2988
+ const endpoint = new EndpointCreator({ endpoint: Modules.S3, id: "sign" }).addAdditionalParam("key", params.key);
2989
+ if (params.isPublic) endpoint.addAdditionalParam("isPublic", "true");
2990
+ return this.callApi({ type: Modules.S3, method: "GET" /* GET */, endpoint: endpoint.generate() });
2991
+ }
2992
+ static async deleteFile(params) {
2993
+ this.callApi({
2994
+ type: Modules.S3,
2995
+ method: "DELETE" /* DELETE */,
2996
+ endpoint: new EndpointCreator({ endpoint: Modules.S3 }).addAdditionalParam("key", params.key).generate()
2997
+ });
2998
+ }
2999
+ };
3000
+
3001
+ // src/features/user/data/user.ts
3002
+ var User = class extends AbstractApiData {
3003
+ static {
3004
+ __name(this, "User");
3005
+ }
3006
+ _name;
3007
+ _email;
3008
+ _title;
3009
+ _bio;
3010
+ _avatar;
3011
+ _avatarUrl;
3012
+ _phone;
3013
+ _rate;
3014
+ _isActivated;
3015
+ _isDeleted;
3016
+ _lastLogin;
3017
+ _relevance;
3018
+ _roles = [];
3019
+ _company;
3020
+ _modules = [];
3021
+ get searchResult() {
3022
+ return this._name ?? "";
3023
+ }
3024
+ get name() {
3025
+ return this._name ?? "";
3026
+ }
3027
+ get email() {
3028
+ return this._email ?? "";
3029
+ }
3030
+ get title() {
3031
+ return this._title ?? "";
3032
+ }
3033
+ get bio() {
3034
+ return this._bio ?? "";
3035
+ }
3036
+ get avatar() {
3037
+ return this._avatar;
3038
+ }
3039
+ get avatarUrl() {
3040
+ return this._avatarUrl;
3041
+ }
3042
+ get phone() {
3043
+ return this._phone;
3044
+ }
3045
+ get rate() {
3046
+ return this._rate;
3047
+ }
3048
+ get relevance() {
3049
+ return this._relevance;
3050
+ }
3051
+ get isActivated() {
3052
+ return this._isActivated ?? false;
3053
+ }
3054
+ get isDeleted() {
3055
+ return this._isDeleted ?? false;
3056
+ }
3057
+ get lastLogin() {
3058
+ return this._lastLogin;
3059
+ }
3060
+ get roles() {
3061
+ return this._roles;
3062
+ }
3063
+ get company() {
3064
+ return this._company;
3065
+ }
3066
+ get modules() {
3067
+ return this._modules;
3068
+ }
3069
+ rehydrate(data) {
3070
+ super.rehydrate(data);
3071
+ this._name = data.jsonApi.attributes.name;
3072
+ this._email = data.jsonApi.attributes.email;
3073
+ this._title = data.jsonApi.attributes.title;
3074
+ this._bio = data.jsonApi.attributes.bio;
3075
+ this._phone = data.jsonApi.attributes.phone;
3076
+ this._rate = data.jsonApi.attributes.rate;
3077
+ this._avatar = data.jsonApi.attributes.avatar;
3078
+ this._avatarUrl = data.jsonApi.attributes.avatarUrl;
3079
+ this._isActivated = data.jsonApi.meta.isActive;
3080
+ this._isDeleted = data.jsonApi.meta.isDeleted;
3081
+ this._lastLogin = data.jsonApi.meta.lastLogin ? new Date(data.jsonApi.meta.lastLogin) : void 0;
3082
+ this._relevance = data.jsonApi.meta.relevance;
3083
+ this._roles = this._readIncluded(data, "roles", Modules.Role);
3084
+ this._company = this._readIncluded(data, "company", Modules.Company);
3085
+ this._modules = this._readIncluded(data, "modules", Modules.Module);
3086
+ return this;
3087
+ }
3088
+ createJsonApi(data) {
3089
+ const response = {
3090
+ data: {
3091
+ type: Modules.User.name,
3092
+ id: data.id,
3093
+ attributes: {
3094
+ name: data.name
3095
+ },
3096
+ meta: {},
3097
+ relationships: {}
3098
+ },
3099
+ included: []
3100
+ };
3101
+ if (data.email !== void 0) response.data.attributes.email = data.email;
3102
+ if (data.title !== void 0) response.data.attributes.title = data.title;
3103
+ if (data.bio !== void 0) response.data.attributes.bio = data.bio;
3104
+ if (data.phone !== void 0) response.data.attributes.phone = data.phone;
3105
+ if (data.password !== void 0) response.data.attributes.password = data.password;
3106
+ if (data.sendInvitationEmail) response.data.attributes.sendInvitationEmail = true;
3107
+ if (data.adminCreated) response.data.attributes.adminCreated = true;
3108
+ if (data.avatar) response.data.attributes.avatar = data.avatar;
3109
+ if (data.rate !== void 0) response.data.attributes.rate = data.rate;
3110
+ if (data.roleIds) {
3111
+ response.data.relationships.roles = {
3112
+ data: data.roleIds.map((roleId) => ({
3113
+ type: Modules.Role.name,
3114
+ id: roleId
3115
+ }))
3116
+ };
3117
+ }
3118
+ if (data.companyId) {
3119
+ response.data.relationships.company = {
3120
+ data: {
3121
+ type: Modules.Company.name,
3122
+ id: data.companyId
3123
+ }
3124
+ };
3125
+ }
3126
+ return response;
3127
+ }
3128
+ };
3129
+
3130
+ // src/features/user/data/user.fields.ts
3131
+ var UserFields = /* @__PURE__ */ ((UserFields2) => {
3132
+ UserFields2["userId"] = "userId";
3133
+ UserFields2["name"] = "name";
3134
+ UserFields2["email"] = "email";
3135
+ UserFields2["relevance"] = "relevance";
3136
+ UserFields2["createdAt"] = "createdAt";
3137
+ UserFields2["updatedAt"] = "updatedAt";
3138
+ return UserFields2;
3139
+ })(UserFields || {});
3140
+
3141
+ // src/features/user/data/user.service.ts
3142
+ var UserService = class extends AbstractService {
3143
+ static {
3144
+ __name(this, "UserService");
3145
+ }
3146
+ static async findFullUser() {
3147
+ const endpoint = new EndpointCreator({ endpoint: Modules.User, id: "me", childEndpoint: "full" });
3148
+ return this.callApi({
3149
+ type: Modules.User,
3150
+ method: "GET" /* GET */,
3151
+ endpoint: endpoint.generate()
3152
+ });
3153
+ }
3154
+ static async findById(params) {
3155
+ return this.callApi({
3156
+ type: Modules.User,
3157
+ method: "GET" /* GET */,
3158
+ endpoint: new EndpointCreator({ endpoint: Modules.User, id: params.userId }).generate()
3159
+ });
3160
+ }
3161
+ static async findByEmail(params) {
3162
+ const endpoint = new EndpointCreator({ endpoint: Modules.User, id: "email", childEndpoint: params.email });
3163
+ return this.callApi({ type: Modules.User, method: "GET" /* GET */, endpoint: endpoint.generate() });
3164
+ }
3165
+ static async findMany(params) {
3166
+ const endpoint = new EndpointCreator({ endpoint: Modules.User });
3167
+ if (params.roleId) endpoint.addAdditionalParam("roleId", params.roleId);
3168
+ if (params.includeDeleted) endpoint.addAdditionalParam("includeDeleted", "true");
3169
+ if (params.fetchAll) endpoint.addAdditionalParam("fetchAll", "true");
3170
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
3171
+ return this.callApi({
3172
+ type: Modules.User,
3173
+ method: "GET" /* GET */,
3174
+ endpoint: endpoint.generate(),
3175
+ next: params.next
3176
+ });
3177
+ }
3178
+ static async findManyByContentIds(params) {
3179
+ const endpoint = new EndpointCreator({ endpoint: Modules.User });
3180
+ endpoint.addAdditionalParam("contentIds", params.contentIds.map((id) => id).join(","));
3181
+ endpoint.addAdditionalParam("includeDeleted", "true");
3182
+ endpoint.addAdditionalParam("fetchAll", "true");
3183
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
3184
+ return this.callApi({
3185
+ type: Modules.User,
3186
+ method: "GET" /* GET */,
3187
+ endpoint: endpoint.generate(),
3188
+ next: params.next
3189
+ });
3190
+ }
3191
+ static async findRelevant(params) {
3192
+ const endpoint = new EndpointCreator({
3193
+ endpoint: Modules.Content,
3194
+ id: params.id,
3195
+ childEndpoint: "user-relevance"
3196
+ });
3197
+ if (Modules.User.inclusions?.lists?.fields) endpoint.limitToFields(Modules.User.inclusions.lists.fields);
3198
+ if (Modules.User.inclusions?.lists?.types) endpoint.limitToType(Modules.User.inclusions.lists.types);
3199
+ return this.callApi({
3200
+ type: Modules.User,
3201
+ method: "GET" /* GET */,
3202
+ endpoint: endpoint.generate(),
3203
+ next: params.next
3204
+ });
3205
+ }
3206
+ static async findManyForAmin(params) {
3207
+ if (!params.companyId) return [];
3208
+ const endpoint = new EndpointCreator({
3209
+ endpoint: Modules.Company,
3210
+ id: params.companyId,
3211
+ childEndpoint: Modules.User
3212
+ });
3213
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
3214
+ return this.callApi({
3215
+ type: Modules.User,
3216
+ method: "GET" /* GET */,
3217
+ endpoint: endpoint.generate(),
3218
+ next: params.next,
3219
+ previous: params.prev
3220
+ });
3221
+ }
3222
+ static async findAllUsers(params) {
3223
+ const endpoint = new EndpointCreator({
3224
+ endpoint: Modules.Company,
3225
+ id: params.companyId,
3226
+ childEndpoint: Modules.User
3227
+ });
3228
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
3229
+ if (params.isDeleted) endpoint.addAdditionalParam("isDeleted", "true");
3230
+ if (params.limitToRoles && params.limitToRoles.length > 0)
3231
+ endpoint.addAdditionalParam("limitToRoles", params.limitToRoles.join(","));
3232
+ return this.callApi({
3233
+ type: Modules.User,
3234
+ method: "GET" /* GET */,
3235
+ endpoint: endpoint.generate(),
3236
+ next: params.next
3237
+ });
3238
+ }
3239
+ static async findAllUsersByRole(params) {
3240
+ const endpoint = new EndpointCreator({ endpoint: Modules.Role, id: params.roleId, childEndpoint: Modules.User });
3241
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
3242
+ return this.callApi({
3243
+ type: Modules.User,
3244
+ method: "GET" /* GET */,
3245
+ endpoint: endpoint.generate(),
3246
+ next: params.next
3247
+ });
3248
+ }
3249
+ static async findAllUsersNotInRole(params) {
3250
+ const endpoint = new EndpointCreator({
3251
+ endpoint: Modules.Role,
3252
+ id: params.roleId,
3253
+ childEndpoint: Modules.User
3254
+ }).addAdditionalParam("notInRole", "true");
3255
+ if (params.search) endpoint.addAdditionalParam("search", params.search);
3256
+ return this.callApi({
3257
+ type: Modules.User,
3258
+ method: "GET" /* GET */,
3259
+ endpoint: endpoint.generate(),
3260
+ next: params.next
3261
+ });
3262
+ }
3263
+ static async create(params) {
3264
+ return this.callApi({
3265
+ type: Modules.User,
3266
+ method: "POST" /* POST */,
3267
+ endpoint: new EndpointCreator({ endpoint: Modules.User }).generate(),
3268
+ companyId: params.companyId,
3269
+ input: params
3270
+ });
3271
+ }
3272
+ static async reactivate(params) {
3273
+ return this.callApi({
3274
+ type: Modules.User,
3275
+ method: "PATCH" /* PATCH */,
3276
+ endpoint: new EndpointCreator({ endpoint: Modules.User, id: params.userId }).generate()
3277
+ });
3278
+ }
3279
+ static async sendInvitation(params) {
3280
+ const endpoint = new EndpointCreator({
3281
+ endpoint: Modules.User,
3282
+ id: params.userId,
3283
+ childEndpoint: "send-invitation-email"
3284
+ });
3285
+ if (params.companyId) endpoint.addAdditionalParam("companyId", params.companyId);
3286
+ this.callApi({
3287
+ type: Modules.User,
3288
+ method: "POST" /* POST */,
3289
+ endpoint: endpoint.generate()
3290
+ });
3291
+ }
3292
+ static async update(params) {
3293
+ return this.callApi({
3294
+ type: Modules.User,
3295
+ method: "PUT" /* PUT */,
3296
+ endpoint: new EndpointCreator({ endpoint: Modules.User, id: params.id }).generate(),
3297
+ companyId: params.companyId,
3298
+ input: params
3299
+ });
3300
+ }
3301
+ static async patchRate(params) {
3302
+ return this.callApi({
3303
+ type: Modules.User,
3304
+ method: "PATCH" /* PATCH */,
3305
+ endpoint: new EndpointCreator({ endpoint: Modules.User, id: params.id, childEndpoint: "rates" }).generate(),
3306
+ companyId: params.companyId,
3307
+ input: params
3308
+ });
3309
+ }
3310
+ static async delete(params) {
3311
+ await this.callApi({
3312
+ type: Modules.User,
3313
+ method: "DELETE" /* DELETE */,
3314
+ endpoint: new EndpointCreator({ endpoint: Modules.User, id: params.userId }).generate(),
3315
+ companyId: params.companyId
3316
+ });
3317
+ }
3318
+ };
3319
+
3320
+ // src/features/user/user.module.ts
3321
+ var UserModule = /* @__PURE__ */ __name((factory) => factory({
3322
+ pageUrl: "/users",
3323
+ name: "users",
3324
+ model: User,
3325
+ moduleId: "04cfc677-0fd2-4f5e-adf4-2483a00c0277",
3326
+ inclusions: {
3327
+ lists: {
3328
+ fields: [
3329
+ createJsonApiInclusion("users", [`name`, `email`, `avatar`, `title`]),
3330
+ createJsonApiInclusion("usertopics", [`level`]),
3331
+ createJsonApiInclusion("userexpertises", [`level`]),
3332
+ createJsonApiInclusion("topics", [`name`])
3333
+ ]
3334
+ }
3335
+ }
3336
+ }), "UserModule");
3337
+
3338
+ // src/features/user/author.module.ts
3339
+ var AuthorModule = /* @__PURE__ */ __name((factory) => factory({
3340
+ pageUrl: "/authors",
3341
+ name: "authors",
3342
+ model: User,
3343
+ moduleId: "04cfc677-0fd2-4f5e-adf4-2483a00c0277"
3344
+ }), "AuthorModule");
3345
+
3346
+ export {
3347
+ RehydrationFactory,
3348
+ AbstractApiData,
3349
+ HttpMethod,
3350
+ setGlobalErrorHandler,
3351
+ getGlobalErrorHandler,
3352
+ AbstractService,
3353
+ configureClientJsonApi,
3354
+ getClientApiUrl,
3355
+ getClientAppUrl,
3356
+ getClientTrackablePages,
3357
+ ClientJsonApiGet,
3358
+ ClientJsonApiPost,
3359
+ ClientJsonApiPut,
3360
+ ClientJsonApiPatch,
3361
+ ClientJsonApiDelete,
3362
+ ClientHttpMethod,
3363
+ setClientGlobalErrorHandler,
3364
+ getClientGlobalErrorHandler,
3365
+ ClientAbstractService,
3366
+ ModuleRegistrar,
3367
+ ModuleRegistry,
3368
+ Modules,
3369
+ EndpointCreator,
3370
+ createJsonApiInclusion,
3371
+ rehydrate,
3372
+ rehydrateList,
3373
+ cn,
3374
+ composeRefs,
3375
+ useComposedRefs,
3376
+ useIsMobile,
3377
+ formatDate,
3378
+ exists,
3379
+ TableOptions,
3380
+ getTableOptions,
3381
+ getTableComponents,
3382
+ userObjectSchema,
3383
+ entityObjectSchema,
3384
+ BlockNoteDiffUtil,
3385
+ BlockNoteWordDiffRendererUtil,
3386
+ getIconByModule,
3387
+ getIcon,
3388
+ getIconByModuleName,
3389
+ getLucideIcon,
3390
+ getLucideIconByModule,
3391
+ getLucideIconByModuleName,
3392
+ Action,
3393
+ checkPermissions,
3394
+ checkPermissionsFromServer,
3395
+ getValueFromPath,
3396
+ Auth,
3397
+ configureAuth,
3398
+ getTokenHandler,
3399
+ AuthService,
3400
+ AuthComponent,
3401
+ AuthModule,
3402
+ Company,
3403
+ CompanyFields,
3404
+ CompanyService,
3405
+ CompanyModule,
3406
+ Content,
3407
+ ContentFields,
3408
+ ContentService,
3409
+ ContentModule,
3410
+ Feature,
3411
+ FeatureService,
3412
+ FeatureModule,
3413
+ Module,
3414
+ ModuleModule,
3415
+ Notification,
3416
+ NotificationFields,
3417
+ NotificationService,
3418
+ NotificationModule,
3419
+ Push,
3420
+ PushService,
3421
+ PushModule,
3422
+ Role,
3423
+ RoleFields,
3424
+ RoleService,
3425
+ RoleModule,
3426
+ S3,
3427
+ S3Module,
3428
+ S3Service,
3429
+ User,
3430
+ UserFields,
3431
+ UserService,
3432
+ UserModule,
3433
+ AuthorModule
3434
+ };
3435
+ //# sourceMappingURL=chunk-4U5CJA44.mjs.map