@carlonicora/nextjs-jsonapi 1.5.0 → 1.6.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 (282) hide show
  1. package/dist/{ApiResponseInterface-DDI7QQPR.d.ts → ApiResponseInterface-CfcC7pPC.d.mts} +11 -2
  2. package/dist/{ApiResponseInterface-BHN5D9r5.d.mts → ApiResponseInterface-DTBJaV5R.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-7FM7B737.js} +19 -22
  6. package/dist/BlockNoteEditor-7FM7B737.js.map +1 -0
  7. package/dist/{BlockNoteEditor-AIEEQM6A.mjs → BlockNoteEditor-RVL76ZAS.mjs} +11 -14
  8. package/dist/BlockNoteEditor-RVL76ZAS.mjs.map +1 -0
  9. package/dist/JsonApiRequest-KOKGVPBI.js +25 -0
  10. package/dist/{JsonApiRequest-UJ7FGIVI.js.map → JsonApiRequest-KOKGVPBI.js.map} +1 -1
  11. package/dist/{JsonApiRequest-6UR7DIAR.mjs → JsonApiRequest-VCCRO732.mjs} +2 -2
  12. package/dist/chunk-2Z56AS2S.js +2723 -0
  13. package/dist/chunk-2Z56AS2S.js.map +1 -0
  14. package/dist/chunk-37NJZ2VD.mjs +637 -0
  15. package/dist/chunk-37NJZ2VD.mjs.map +1 -0
  16. package/dist/{chunk-2K3Q24UF.js → chunk-3ZPK4QOB.js} +24 -14
  17. package/dist/chunk-3ZPK4QOB.js.map +1 -0
  18. package/dist/chunk-AGWQ75PQ.js +142 -0
  19. package/dist/chunk-AGWQ75PQ.js.map +1 -0
  20. package/dist/{chunk-32HM6MDD.js → chunk-CSM6AIAP.js} +1 -1
  21. package/dist/{chunk-32HM6MDD.js.map → chunk-CSM6AIAP.js.map} +1 -1
  22. package/dist/{chunk-IKBA4AHN.mjs → chunk-F4Y3GZG4.mjs} +3 -3
  23. package/dist/{chunk-YF5XQZDR.mjs → chunk-F5UNXZ3J.mjs} +1 -1
  24. package/dist/chunk-F5UNXZ3J.mjs.map +1 -0
  25. package/dist/chunk-IGOWVLJH.mjs +142 -0
  26. package/dist/chunk-IGOWVLJH.mjs.map +1 -0
  27. package/dist/{chunk-HAG77QBV.mjs → chunk-K4W5QXL5.mjs} +1 -1
  28. package/dist/chunk-KFL5ZFM4.mjs +2723 -0
  29. package/dist/chunk-KFL5ZFM4.mjs.map +1 -0
  30. package/dist/{chunk-HR4H2FP7.mjs → chunk-KJ4ETLJB.mjs} +24 -14
  31. package/dist/chunk-KJ4ETLJB.mjs.map +1 -0
  32. package/dist/chunk-LOSPCUCF.js +637 -0
  33. package/dist/chunk-LOSPCUCF.js.map +1 -0
  34. package/dist/{chunk-VET55IZO.js → chunk-SVX7E6RR.js} +10293 -7536
  35. package/dist/chunk-SVX7E6RR.js.map +1 -0
  36. package/dist/{chunk-EFJEWLRL.js → chunk-YUO55Q5A.js} +1 -1
  37. package/dist/chunk-YUO55Q5A.js.map +1 -0
  38. package/dist/chunk-ZQTFZKLJ.mjs +12089 -0
  39. package/dist/chunk-ZQTFZKLJ.mjs.map +1 -0
  40. package/dist/{chunk-PMXG5WBC.js → chunk-ZUEEIQHW.js} +3 -3
  41. package/dist/{chunk-PMXG5WBC.js.map → chunk-ZUEEIQHW.js.map} +1 -1
  42. package/dist/client/index.d.mts +161 -11
  43. package/dist/client/index.d.ts +161 -11
  44. package/dist/client/index.js +74 -11
  45. package/dist/client/index.js.map +1 -1
  46. package/dist/client/index.mjs +73 -10
  47. package/dist/components/index.d.mts +763 -11
  48. package/dist/components/index.d.ts +763 -11
  49. package/dist/components/index.js +465 -11
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/components/index.mjs +466 -12
  52. package/dist/config-B43zxEvn.d.mts +69 -0
  53. package/dist/config-D2OUrI_G.d.ts +69 -0
  54. package/dist/content.fields-Ck5lkQ5d.d.mts +47 -0
  55. package/dist/content.fields-Ck5lkQ5d.d.ts +47 -0
  56. package/dist/{content.interface-CR2aBeAW.d.ts → content.interface-Bs8a7uW6.d.mts} +2 -3
  57. package/dist/{content.interface-FpLfsaRm.d.mts → content.interface-UtsJ-mzs.d.ts} +2 -3
  58. package/dist/contexts/index.d.mts +13 -6
  59. package/dist/contexts/index.d.ts +13 -6
  60. package/dist/contexts/index.js +10 -11
  61. package/dist/contexts/index.js.map +1 -1
  62. package/dist/contexts/index.mjs +9 -10
  63. package/dist/core/index.d.mts +539 -8
  64. package/dist/core/index.d.ts +539 -8
  65. package/dist/core/index.js +104 -2
  66. package/dist/core/index.js.map +1 -1
  67. package/dist/core/index.mjs +105 -3
  68. package/dist/index.d.mts +131 -70
  69. package/dist/index.d.ts +131 -70
  70. package/dist/index.js +97 -7
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +118 -28
  73. package/dist/notification.interface-BdcwkuQE.d.mts +228 -0
  74. package/dist/notification.interface-BdcwkuQE.d.ts +228 -0
  75. package/dist/request-GBLBPYFM.js +8 -0
  76. package/dist/request-GBLBPYFM.js.map +1 -0
  77. package/dist/request-XABCMU25.mjs +8 -0
  78. package/dist/{AbstractService-wLid8dB0.d.ts → s3.interface-D7ttGatc.d.ts} +36 -26
  79. package/dist/{AbstractService-BsY6W3Ej.d.mts → s3.interface-DlaMDRTn.d.mts} +36 -26
  80. package/dist/server/index.d.mts +299 -4
  81. package/dist/server/index.d.ts +299 -4
  82. package/dist/server/index.js +215 -5
  83. package/dist/server/index.js.map +1 -1
  84. package/dist/server/index.mjs +214 -4
  85. package/dist/server/index.mjs.map +1 -1
  86. package/dist/token-2UWQJY5T.js +8 -0
  87. package/dist/token-2UWQJY5T.js.map +1 -0
  88. package/dist/token-EOK3N45S.mjs +8 -0
  89. package/dist/{useSocket-BV6yMdWS.d.ts → useSocket-8vwK_R_c.d.ts} +1 -1
  90. package/dist/{useSocket-L-An7_Mr.d.mts → useSocket-BWJUXuOl.d.mts} +1 -1
  91. package/package.json +12 -52
  92. package/src/client/JsonApiClient.ts +248 -0
  93. package/src/client/config.ts +78 -0
  94. package/src/client/index.ts +6 -1
  95. package/src/components/containers/TabsContainer.tsx +1 -1
  96. package/src/components/editors/BlockNoteEditor.tsx +3 -1
  97. package/src/components/index.ts +4 -0
  98. package/src/components/navigations/Breadcrumb.tsx +1 -1
  99. package/src/components/navigations/Header.tsx +2 -2
  100. package/src/contexts/CommonContext.tsx +1 -1
  101. package/src/contexts/SocketContext.tsx +1 -1
  102. package/src/contexts/index.ts +3 -0
  103. package/src/core/abstracts/ClientAbstractService.ts +255 -0
  104. package/src/core/abstracts/ServerAbstractService.ts +180 -0
  105. package/src/core/abstracts/index.ts +2 -0
  106. package/src/core/index.ts +32 -3
  107. package/src/discord/config.ts +15 -0
  108. package/src/discord/index.ts +1 -0
  109. package/src/features/auth/components/details/LandingComponent.tsx +2 -2
  110. package/src/features/auth/components/forms/AcceptInvitation.tsx +1 -1
  111. package/src/features/auth/components/forms/ActivateAccount.tsx +1 -1
  112. package/src/features/auth/components/forms/Cookies.tsx +2 -1
  113. package/src/features/auth/components/forms/ForgotPassword.tsx +1 -1
  114. package/src/features/auth/components/forms/Login.tsx +1 -1
  115. package/src/features/auth/components/forms/Logout.tsx +1 -1
  116. package/src/features/auth/components/forms/RefreshUser.tsx +2 -1
  117. package/src/features/auth/components/forms/Register.tsx +1 -1
  118. package/src/features/auth/components/forms/ResetPassword.tsx +1 -1
  119. package/src/features/auth/data/auth.service.ts +1 -1
  120. package/src/features/auth/data/index.ts +0 -1
  121. package/src/features/auth/utils/AuthCookies.ts +1 -1
  122. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +4 -2
  123. package/src/features/company/components/forms/CompanyDeleter.tsx +2 -1
  124. package/src/features/company/components/forms/CompanyEditor.tsx +6 -3
  125. package/src/features/company/components/forms/CompanyLicense.tsx +4 -2
  126. package/src/features/company/components/lists/CompaniesList.tsx +2 -1
  127. package/src/features/company/data/index.ts +0 -1
  128. package/src/features/content/components/lists/ContentsListById.tsx +2 -1
  129. package/src/features/content/components/lists/RelevantContentsList.tsx +2 -1
  130. package/src/features/content/data/index.ts +0 -1
  131. package/src/features/feature/data/index.ts +0 -1
  132. package/src/features/notification/components/lists/NotificationsList.tsx +2 -1
  133. package/src/features/notification/contexts/NotificationContext.tsx +2 -1
  134. package/src/features/notification/data/index.ts +0 -1
  135. package/src/features/push/data/index.ts +0 -1
  136. package/src/features/role/components/forms/RemoveUserFromRole.tsx +4 -2
  137. package/src/features/role/components/forms/UserRoleAdd.tsx +2 -1
  138. package/src/features/role/components/lists/RolesList.tsx +2 -1
  139. package/src/features/role/components/lists/UserRolesList.tsx +2 -1
  140. package/src/features/role/data/index.ts +0 -1
  141. package/src/features/s3/data/index.ts +0 -1
  142. package/src/features/user/components/forms/RoleUserAdd.tsx +4 -2
  143. package/src/features/user/components/forms/UserDeleter.tsx +2 -1
  144. package/src/features/user/components/forms/UserEditor.tsx +6 -3
  145. package/src/features/user/components/forms/UserMultiSelect.tsx +2 -1
  146. package/src/features/user/components/forms/UserReactivator.tsx +2 -1
  147. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -1
  148. package/src/features/user/components/forms/UserSelector.tsx +2 -1
  149. package/src/features/user/components/lists/AdminUsersList.tsx +2 -1
  150. package/src/features/user/components/lists/CompanyUsersList.tsx +2 -1
  151. package/src/features/user/components/lists/RelevantUsersList.tsx +2 -1
  152. package/src/features/user/components/lists/RoleUsersList.tsx +2 -1
  153. package/src/features/user/components/lists/UsersListByContentIds.tsx +2 -1
  154. package/src/features/user/data/index.ts +0 -1
  155. package/src/features/user/hooks/useUserSearch.ts +2 -1
  156. package/src/hooks/useDataListRetriever.ts +4 -4
  157. package/src/hooks/usePageTracker.ts +1 -1
  158. package/src/hooks/usePushNotifications.ts +3 -2
  159. package/src/hooks/useSocket.ts +1 -1
  160. package/src/index.ts +7 -2
  161. package/src/roles/config.ts +0 -15
  162. package/src/roles/index.ts +1 -9
  163. package/src/server/JsonApiServer.ts +249 -0
  164. package/src/server/cache.ts +1 -1
  165. package/src/server/index.ts +13 -0
  166. package/src/server/request.ts +32 -18
  167. package/src/server/token.ts +1 -1
  168. package/dist/ApiData-DPKNfY-9.d.mts +0 -10
  169. package/dist/ApiData-DPKNfY-9.d.ts +0 -10
  170. package/dist/ApiDataInterface-DPP8s46n.d.mts +0 -21
  171. package/dist/ApiDataInterface-DPP8s46n.d.ts +0 -21
  172. package/dist/AuthComponent-B_Ps2Vb9.d.ts +0 -78
  173. package/dist/AuthComponent-CxnGgvoh.d.mts +0 -78
  174. package/dist/BlockNoteEditor-AIEEQM6A.mjs.map +0 -1
  175. package/dist/BlockNoteEditor-G6AK2NWA.js.map +0 -1
  176. package/dist/JsonApiRequest-UJ7FGIVI.js +0 -25
  177. package/dist/atoms/index.d.mts +0 -12
  178. package/dist/atoms/index.d.ts +0 -12
  179. package/dist/atoms/index.js +0 -9
  180. package/dist/atoms/index.js.map +0 -1
  181. package/dist/atoms/index.mjs +0 -9
  182. package/dist/chunk-2K3Q24UF.js.map +0 -1
  183. package/dist/chunk-3FBCC4G3.js +0 -8
  184. package/dist/chunk-3FBCC4G3.js.map +0 -1
  185. package/dist/chunk-3UELCPIN.js +0 -46
  186. package/dist/chunk-3UELCPIN.js.map +0 -1
  187. package/dist/chunk-5IET37O4.js +0 -4210
  188. package/dist/chunk-5IET37O4.js.map +0 -1
  189. package/dist/chunk-AYHKQWHH.js +0 -68
  190. package/dist/chunk-AYHKQWHH.js.map +0 -1
  191. package/dist/chunk-DEYKTLA3.js +0 -1131
  192. package/dist/chunk-DEYKTLA3.js.map +0 -1
  193. package/dist/chunk-EFJEWLRL.js.map +0 -1
  194. package/dist/chunk-FMBQZAIP.mjs +0 -490
  195. package/dist/chunk-FMBQZAIP.mjs.map +0 -1
  196. package/dist/chunk-HR4H2FP7.mjs.map +0 -1
  197. package/dist/chunk-J7YDGYSW.mjs +0 -9332
  198. package/dist/chunk-J7YDGYSW.mjs.map +0 -1
  199. package/dist/chunk-JGFWIT2E.mjs +0 -1131
  200. package/dist/chunk-JGFWIT2E.mjs.map +0 -1
  201. package/dist/chunk-P2F54I7Q.mjs +0 -4210
  202. package/dist/chunk-P2F54I7Q.mjs.map +0 -1
  203. package/dist/chunk-Q2N6SQYW.mjs +0 -8
  204. package/dist/chunk-Q2N6SQYW.mjs.map +0 -1
  205. package/dist/chunk-Q4FXESVT.js +0 -490
  206. package/dist/chunk-Q4FXESVT.js.map +0 -1
  207. package/dist/chunk-SM63SZCP.mjs +0 -68
  208. package/dist/chunk-SM63SZCP.mjs.map +0 -1
  209. package/dist/chunk-SZZYEG3P.mjs +0 -46
  210. package/dist/chunk-SZZYEG3P.mjs.map +0 -1
  211. package/dist/chunk-VET55IZO.js.map +0 -1
  212. package/dist/chunk-YF5XQZDR.mjs.map +0 -1
  213. package/dist/config-BmnK65TD.d.mts +0 -35
  214. package/dist/config-BmnK65TD.d.ts +0 -35
  215. package/dist/config-DQeAo9Kf.d.mts +0 -49
  216. package/dist/config-DQeAo9Kf.d.ts +0 -49
  217. package/dist/content.fields-cHPdM8GJ.d.mts +0 -27
  218. package/dist/content.fields-cHPdM8GJ.d.ts +0 -27
  219. package/dist/d3.link.interface-ClC4Irqp.d.mts +0 -21
  220. package/dist/d3.link.interface-ClC4Irqp.d.ts +0 -21
  221. package/dist/features/index.d.mts +0 -477
  222. package/dist/features/index.d.ts +0 -477
  223. package/dist/features/index.js +0 -108
  224. package/dist/features/index.js.map +0 -1
  225. package/dist/features/index.mjs +0 -108
  226. package/dist/hooks/index.d.mts +0 -69
  227. package/dist/hooks/index.d.ts +0 -69
  228. package/dist/hooks/index.js +0 -55
  229. package/dist/hooks/index.js.map +0 -1
  230. package/dist/hooks/index.mjs +0 -55
  231. package/dist/hooks/index.mjs.map +0 -1
  232. package/dist/interfaces/index.d.mts +0 -4
  233. package/dist/interfaces/index.d.ts +0 -4
  234. package/dist/interfaces/index.js +0 -2
  235. package/dist/interfaces/index.js.map +0 -1
  236. package/dist/interfaces/index.mjs +0 -2
  237. package/dist/interfaces/index.mjs.map +0 -1
  238. package/dist/notification.interface-B2BrLoDA.d.mts +0 -14
  239. package/dist/notification.interface-DlZLnAfg.d.ts +0 -14
  240. package/dist/permissions/index.d.mts +0 -41
  241. package/dist/permissions/index.d.ts +0 -41
  242. package/dist/permissions/index.js +0 -14
  243. package/dist/permissions/index.js.map +0 -1
  244. package/dist/permissions/index.mjs +0 -14
  245. package/dist/permissions/index.mjs.map +0 -1
  246. package/dist/request-7FE3LJLV.mjs +0 -9
  247. package/dist/request-7FE3LJLV.mjs.map +0 -1
  248. package/dist/request-QFS7NEIE.js +0 -9
  249. package/dist/request-QFS7NEIE.js.map +0 -1
  250. package/dist/roles/index.d.mts +0 -39
  251. package/dist/roles/index.d.ts +0 -39
  252. package/dist/roles/index.js +0 -18
  253. package/dist/roles/index.js.map +0 -1
  254. package/dist/roles/index.mjs +0 -18
  255. package/dist/roles/index.mjs.map +0 -1
  256. package/dist/shadcnui/index.d.mts +0 -698
  257. package/dist/shadcnui/index.d.ts +0 -698
  258. package/dist/shadcnui/index.js +0 -468
  259. package/dist/shadcnui/index.js.map +0 -1
  260. package/dist/shadcnui/index.mjs +0 -467
  261. package/dist/shadcnui/index.mjs.map +0 -1
  262. package/dist/token-IJSPOMW6.mjs +0 -9
  263. package/dist/token-IJSPOMW6.mjs.map +0 -1
  264. package/dist/token-UYE7CV6X.js +0 -9
  265. package/dist/token-UYE7CV6X.js.map +0 -1
  266. package/dist/types-B2QRyqyK.d.ts +0 -39
  267. package/dist/types-CgvNmxTd.d.mts +0 -39
  268. package/dist/types-t2PyXhDu.d.mts +0 -116
  269. package/dist/types-t2PyXhDu.d.ts +0 -116
  270. package/dist/user.interface-CooB1R79.d.mts +0 -85
  271. package/dist/user.interface-KnIT9pVY.d.ts +0 -85
  272. package/dist/utils/index.d.mts +0 -224
  273. package/dist/utils/index.d.ts +0 -224
  274. package/dist/utils/index.js +0 -46
  275. package/dist/utils/index.js.map +0 -1
  276. package/dist/utils/index.mjs +0 -46
  277. package/dist/utils/index.mjs.map +0 -1
  278. /package/dist/{JsonApiRequest-6UR7DIAR.mjs.map → JsonApiRequest-VCCRO732.mjs.map} +0 -0
  279. /package/dist/{chunk-IKBA4AHN.mjs.map → chunk-F4Y3GZG4.mjs.map} +0 -0
  280. /package/dist/{chunk-HAG77QBV.mjs.map → chunk-K4W5QXL5.mjs.map} +0 -0
  281. /package/dist/{atoms/index.mjs.map → request-XABCMU25.mjs.map} +0 -0
  282. /package/dist/{features/index.mjs.map → token-EOK3N45S.mjs.map} +0 -0
@@ -1,8 +0,0 @@
1
- // src/atoms/recentPagesAtom.ts
2
- import { atomWithStorage } from "jotai/utils";
3
- var recentPagesAtom = atomWithStorage("recentPages", []);
4
-
5
- export {
6
- recentPagesAtom
7
- };
8
- //# sourceMappingURL=chunk-Q2N6SQYW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/atoms/recentPagesAtom.ts"],"sourcesContent":["import { atomWithStorage } from \"jotai/utils\";\n\nexport interface RecentPage {\n url: string;\n title: string;\n moduleType: string;\n timestamp: number;\n}\n\nexport const recentPagesAtom = atomWithStorage<RecentPage[]>(\"recentPages\", []);\n"],"mappings":";AAAA,SAAS,uBAAuB;AASzB,IAAM,kBAAkB,gBAA8B,eAAe,CAAC,CAAC;","names":[]}
@@ -1,490 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
2
-
3
- var _chunkAGAJMJ4Tjs = require('./chunk-AGAJMJ4T.js');
4
-
5
-
6
- var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
7
-
8
- // src/core/factories/RehydrationFactory.ts
9
- var RehydrationFactory = class {
10
- static {
11
- _chunk7QVYU63Ejs.__name.call(void 0, this, "RehydrationFactory");
12
- }
13
- static rehydrate(classKey, data) {
14
- const factoryClass = _chunkAGAJMJ4Tjs.DataClassRegistry.get(classKey);
15
- const instance = new factoryClass();
16
- return instance.rehydrate(data);
17
- }
18
- static rehydrateList(classKey, data) {
19
- const factoryClass = _chunkAGAJMJ4Tjs.DataClassRegistry.get(classKey);
20
- const response = data.map((item) => {
21
- const instance = new factoryClass();
22
- return instance.rehydrate(item);
23
- });
24
- return response;
25
- }
26
- };
27
-
28
- // src/core/abstracts/AbstractApiData.ts
29
- var AbstractApiData = class {
30
- static {
31
- _chunk7QVYU63Ejs.__name.call(void 0, this, "AbstractApiData");
32
- }
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
- get type() {
41
- if (!this._type) throw new Error("Type is not set.");
42
- return this._type;
43
- }
44
- get id() {
45
- if (!this._id) throw new Error("Id is not set.");
46
- return this._id;
47
- }
48
- get self() {
49
- return this._self;
50
- }
51
- get createdAt() {
52
- return _nullishCoalesce(this._createdAt, () => ( /* @__PURE__ */ new Date()));
53
- }
54
- get updatedAt() {
55
- return _nullishCoalesce(this._updatedAt, () => ( /* @__PURE__ */ new Date()));
56
- }
57
- get included() {
58
- return _nullishCoalesce(this._included, () => ( []));
59
- }
60
- get jsonApi() {
61
- return this._jsonApi;
62
- }
63
- ingestJsonApi(_data) {
64
- }
65
- generateApiUrl(_params) {
66
- throw new Error("Method not implemented.");
67
- }
68
- createJsonApi(_data) {
69
- throw new Error("Method not implemented.");
70
- }
71
- _readIncluded(data, type, dataType) {
72
- 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) {
73
- return void 0;
74
- }
75
- if (Array.isArray(data.jsonApi.relationships[type].data)) {
76
- const response = data.jsonApi.relationships[type].data.map((jsonApiData) => {
77
- const includedData2 = data.included.find(
78
- (includedData3) => includedData3.id === jsonApiData.id && includedData3.type === jsonApiData.type
79
- );
80
- if (includedData2 === void 0) return void 0;
81
- return RehydrationFactory.rehydrate(dataType, {
82
- jsonApi: includedData2,
83
- included: data.included
84
- });
85
- });
86
- return response.filter((item) => item !== void 0);
87
- }
88
- const includedData = data.included.find(
89
- (includedData2) => includedData2.id === data.jsonApi.relationships[type].data.id && includedData2.type === data.jsonApi.relationships[type].data.type
90
- );
91
- if (includedData === void 0 && data.allData !== void 0) {
92
- const fallbackData = data.allData.find(
93
- (includedData2) => includedData2.id === data.jsonApi.relationships[type].data.id && includedData2.type === data.jsonApi.relationships[type].data.type
94
- );
95
- if (fallbackData !== void 0) {
96
- return RehydrationFactory.rehydrate(dataType, {
97
- jsonApi: fallbackData,
98
- included: data.included
99
- });
100
- }
101
- }
102
- if (includedData === void 0) return void 0;
103
- return RehydrationFactory.rehydrate(dataType, {
104
- jsonApi: includedData,
105
- included: data.included
106
- });
107
- }
108
- dehydrate() {
109
- return {
110
- jsonApi: this._jsonApi,
111
- included: _nullishCoalesce(this._included, () => ( []))
112
- };
113
- }
114
- rehydrate(data) {
115
- this._jsonApi = data.jsonApi;
116
- this._included = data.included;
117
- this._type = this._jsonApi.type;
118
- this._id = this._jsonApi.id;
119
- this._createdAt = _optionalChain([this, 'access', _2 => _2._jsonApi, 'access', _3 => _3.meta, 'optionalAccess', _4 => _4.createdAt]) !== void 0 ? new Date(this._jsonApi.meta.createdAt) : void 0;
120
- this._updatedAt = _optionalChain([this, 'access', _5 => _5._jsonApi, 'access', _6 => _6.meta, 'optionalAccess', _7 => _7.updatedAt]) !== void 0 ? new Date(this._jsonApi.meta.updatedAt) : void 0;
121
- this._self = _nullishCoalesce(_optionalChain([this, 'access', _8 => _8._jsonApi, 'access', _9 => _9.links, 'optionalAccess', _10 => _10.self]), () => ( void 0));
122
- return this;
123
- }
124
- };
125
-
126
- // src/core/abstracts/AbstractService.ts
127
- var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
128
- HttpMethod2["GET"] = "GET";
129
- HttpMethod2["POST"] = "POST";
130
- HttpMethod2["PUT"] = "PUT";
131
- HttpMethod2["PATCH"] = "PATCH";
132
- HttpMethod2["DELETE"] = "DELETE";
133
- return HttpMethod2;
134
- })(HttpMethod || {});
135
- var globalErrorHandler = null;
136
- function setGlobalErrorHandler(handler) {
137
- globalErrorHandler = handler;
138
- }
139
- _chunk7QVYU63Ejs.__name.call(void 0, setGlobalErrorHandler, "setGlobalErrorHandler");
140
- function getGlobalErrorHandler() {
141
- return globalErrorHandler;
142
- }
143
- _chunk7QVYU63Ejs.__name.call(void 0, getGlobalErrorHandler, "getGlobalErrorHandler");
144
- var AbstractService = class {
145
- static {
146
- _chunk7QVYU63Ejs.__name.call(void 0, this, "AbstractService");
147
- }
148
- /**
149
- * Extract locale from client-side URL pathname
150
- * URL structure: /{locale}/route-path (e.g., /it/accounts)
151
- * Fallback chain: URL locale → navigator.language → "en"
152
- */
153
- static getClientLocale() {
154
- if (typeof window === "undefined") {
155
- return "en";
156
- }
157
- const pathSegments = window.location.pathname.split("/").filter(Boolean);
158
- const urlLocale = pathSegments[0];
159
- const supportedLocales = ["en"];
160
- if (urlLocale && supportedLocales.includes(urlLocale)) {
161
- return urlLocale;
162
- }
163
- const navigatorLocale = navigator.language.split("-")[0];
164
- if (navigatorLocale && supportedLocales.includes(navigatorLocale)) {
165
- return navigatorLocale;
166
- }
167
- return "en";
168
- }
169
- static async next(params) {
170
- return await this.callApi({
171
- method: "GET" /* GET */,
172
- type: params.type,
173
- endpoint: params.endpoint,
174
- next: params.next,
175
- previous: params.previous,
176
- self: params.self
177
- });
178
- }
179
- /**
180
- * Fetch the previous page of results.
181
- */
182
- static async previous(params) {
183
- return await this.callApi({
184
- method: "GET" /* GET */,
185
- type: params.type,
186
- endpoint: params.endpoint,
187
- next: params.next,
188
- previous: params.previous,
189
- self: params.self
190
- });
191
- }
192
- /**
193
- * Make an API call with automatic environment detection and error handling.
194
- */
195
- static async callApi(params) {
196
- const { JsonApiGet, JsonApiPost, JsonApiPut, JsonApiPatch, JsonApiDelete } = await Promise.resolve().then(() => _interopRequireWildcard(require("./JsonApiRequest-UJ7FGIVI.js")));
197
- let apiResponse;
198
- let language = "en";
199
- if (typeof window === "undefined") {
200
- const { getLocale } = await Promise.resolve().then(() => _interopRequireWildcard(require("next-intl/server")));
201
- language = await _asyncNullishCoalesce(await getLocale(), async () => ( "en"));
202
- } else {
203
- language = this.getClientLocale();
204
- }
205
- switch (params.method) {
206
- case "GET" /* GET */:
207
- apiResponse = await JsonApiGet({
208
- classKey: params.type,
209
- endpoint: params.endpoint,
210
- companyId: params.companyId,
211
- language
212
- });
213
- break;
214
- case "POST" /* POST */:
215
- apiResponse = await JsonApiPost({
216
- classKey: params.type,
217
- endpoint: params.endpoint,
218
- companyId: params.companyId,
219
- body: params.input,
220
- overridesJsonApiCreation: params.overridesJsonApiCreation,
221
- language,
222
- responseType: params.responseType,
223
- files: params.files
224
- });
225
- break;
226
- case "PUT" /* PUT */:
227
- apiResponse = await JsonApiPut({
228
- classKey: params.type,
229
- endpoint: params.endpoint,
230
- companyId: params.companyId,
231
- body: params.input,
232
- language,
233
- responseType: params.responseType,
234
- files: params.files
235
- });
236
- break;
237
- case "PATCH" /* PATCH */:
238
- apiResponse = await JsonApiPatch({
239
- classKey: params.type,
240
- endpoint: params.endpoint,
241
- companyId: params.companyId,
242
- body: params.input,
243
- overridesJsonApiCreation: params.overridesJsonApiCreation,
244
- language,
245
- responseType: params.responseType,
246
- files: params.files
247
- });
248
- break;
249
- case "DELETE" /* DELETE */:
250
- apiResponse = await JsonApiDelete({
251
- classKey: params.type,
252
- endpoint: params.endpoint,
253
- companyId: params.companyId,
254
- language,
255
- responseType: params.responseType
256
- });
257
- break;
258
- default:
259
- throw new Error("Method not found");
260
- }
261
- if (!apiResponse.ok) {
262
- if (globalErrorHandler && typeof window !== "undefined") {
263
- globalErrorHandler(apiResponse.response, apiResponse.error);
264
- return void 0;
265
- } else {
266
- const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
267
- error.status = apiResponse.response;
268
- error.digest = `HTTP_${apiResponse.response}`;
269
- throw error;
270
- }
271
- }
272
- if (apiResponse.next && params.next) params.next.next = apiResponse.next;
273
- if (apiResponse.prev && params.previous) params.previous.previous = apiResponse.prev;
274
- if (apiResponse.self && params.self) params.self.self = apiResponse.self;
275
- return apiResponse.data;
276
- }
277
- /**
278
- * Get raw JSON:API response data without deserialization.
279
- */
280
- static async getRawData(params) {
281
- const { JsonApiGet } = await Promise.resolve().then(() => _interopRequireWildcard(require("./JsonApiRequest-UJ7FGIVI.js")));
282
- let language = "en";
283
- if (typeof window === "undefined") {
284
- const { getLocale } = await Promise.resolve().then(() => _interopRequireWildcard(require("next-intl/server")));
285
- language = await _asyncNullishCoalesce(await getLocale(), async () => ( "en"));
286
- } else {
287
- language = this.getClientLocale();
288
- }
289
- const apiResponse = await JsonApiGet({
290
- classKey: params.type,
291
- endpoint: params.endpoint,
292
- companyId: params.companyId,
293
- language
294
- });
295
- if (!apiResponse.ok) {
296
- if (globalErrorHandler && typeof window !== "undefined") {
297
- globalErrorHandler(apiResponse.response, apiResponse.error);
298
- return void 0;
299
- } else {
300
- const error = new Error(`${apiResponse.response}:${apiResponse.error}`);
301
- error.status = apiResponse.response;
302
- error.digest = `HTTP_${apiResponse.response}`;
303
- throw error;
304
- }
305
- }
306
- return apiResponse.raw;
307
- }
308
- };
309
-
310
- // src/core/registry/ModuleRegistrar.ts
311
- var ModuleRegistrar = (_class = class {
312
- static {
313
- _chunk7QVYU63Ejs.__name.call(void 0, this, "ModuleRegistrar");
314
- }
315
- static __initStatic() {this._isBootstrapped = false}
316
- /**
317
- * Bootstrap the registry from a Modules class.
318
- * Automatically detects static getters and registers their models.
319
- *
320
- * @param modulesClass - The Modules class with static getters
321
- */
322
- static bootstrap(modulesClass) {
323
- if (this._isBootstrapped) return;
324
- const data = Object.getOwnPropertyNames(modulesClass).filter((key) => {
325
- const descriptor = Object.getOwnPropertyDescriptor(modulesClass, key);
326
- return descriptor && typeof descriptor.get === "function";
327
- }).map((key) => modulesClass[key]);
328
- data.forEach((item) => {
329
- if (item && item.model) {
330
- _chunkAGAJMJ4Tjs.DataClassRegistry.registerObjectClass(item, item.model);
331
- }
332
- });
333
- this._isBootstrapped = true;
334
- }
335
- /**
336
- * Reset the bootstrapped state. Useful for testing.
337
- */
338
- static reset() {
339
- this._isBootstrapped = false;
340
- _chunkAGAJMJ4Tjs.DataClassRegistry.clear();
341
- }
342
- }, _class.__initStatic(), _class);
343
-
344
- // src/core/registry/ModuleRegistry.ts
345
- var ModuleRegistryClass = (_class2 = class {constructor() { _class2.prototype.__init.call(this); }
346
- static {
347
- _chunk7QVYU63Ejs.__name.call(void 0, this, "ModuleRegistryClass");
348
- }
349
- __init() {this._modules = /* @__PURE__ */ new Map()}
350
- register(name, module) {
351
- this._modules.set(name, module);
352
- }
353
- get(name) {
354
- const module = this._modules.get(name);
355
- if (!module) {
356
- throw new Error(`Module "${String(name)}" not registered. Call bootstrap() first.`);
357
- }
358
- return module;
359
- }
360
- findByName(moduleName) {
361
- for (const module of this._modules.values()) {
362
- if (module.name === moduleName) {
363
- return module;
364
- }
365
- }
366
- throw new Error(`Module not found: ${moduleName}`);
367
- }
368
- findByModelName(modelName) {
369
- const module = this._modules.get(modelName);
370
- if (!module) {
371
- throw new Error(`Module not found for model: ${modelName}`);
372
- }
373
- return module;
374
- }
375
- }, _class2);
376
- var ModuleRegistry = new ModuleRegistryClass();
377
- var Modules = new Proxy({}, {
378
- get(_, prop) {
379
- if (prop === "findByName") {
380
- return (name) => ModuleRegistry.findByName(name);
381
- }
382
- if (prop === "findByModelName") {
383
- return (name) => ModuleRegistry.findByModelName(name);
384
- }
385
- return ModuleRegistry.get(prop);
386
- }
387
- });
388
-
389
- // src/core/endpoint/EndpointCreator.ts
390
- var EndpointCreator = class {
391
- static {
392
- _chunk7QVYU63Ejs.__name.call(void 0, this, "EndpointCreator");
393
- }
394
-
395
- constructor(params) {
396
- this._endpoint = {
397
- endpoint: params.endpoint,
398
- id: params.id,
399
- childEndpoint: params.childEndpoint,
400
- childId: params.childId,
401
- additionalParams: _nullishCoalesce(params.additionalParams, () => ( []))
402
- };
403
- }
404
- endpoint(value) {
405
- this._endpoint.endpoint = value;
406
- return this;
407
- }
408
- id(value) {
409
- this._endpoint.id = value;
410
- return this;
411
- }
412
- childEndpoint(value) {
413
- this._endpoint.childEndpoint = value;
414
- return this;
415
- }
416
- childId(value) {
417
- this._endpoint.childId = value;
418
- return this;
419
- }
420
- set additionalParams(value) {
421
- this._endpoint.additionalParams = value;
422
- }
423
- addAdditionalParam(key, value) {
424
- if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];
425
- this._endpoint.additionalParams.push({ key, value });
426
- return this;
427
- }
428
- limitToType(selectors) {
429
- this.addAdditionalParam(`include`, selectors.join(","));
430
- return this;
431
- }
432
- limitToFields(selectors) {
433
- if (selectors.length === 0) return this;
434
- selectors.forEach((selector) => {
435
- const fieldString = selector.fields.join(",");
436
- this.addAdditionalParam(`fields[${selector.type}]`, fieldString);
437
- });
438
- return this;
439
- }
440
- generate() {
441
- let additionalParams = "";
442
- if (this._endpoint.additionalParams) {
443
- additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join("&");
444
- }
445
- let response = `${this._endpoint.endpoint.name}`;
446
- if (this._endpoint.id) response += `/${this._endpoint.id}`;
447
- if (this._endpoint.childEndpoint) {
448
- response += `/${typeof this._endpoint.childEndpoint === "string" ? this._endpoint.childEndpoint : this._endpoint.childEndpoint.name}`;
449
- }
450
- if (this._endpoint.childId) response += `/${this._endpoint.childId}`;
451
- if (additionalParams) response += `?${additionalParams}`;
452
- return response;
453
- }
454
- };
455
-
456
- // src/core/fields/FieldSelector.ts
457
- function createJsonApiInclusion(dataType, fields) {
458
- return {
459
- type: dataType,
460
- fields
461
- };
462
- }
463
- _chunk7QVYU63Ejs.__name.call(void 0, createJsonApiInclusion, "createJsonApiInclusion");
464
-
465
- // src/core/utils/rehydrate.ts
466
- function rehydrate(classKey, data) {
467
- return RehydrationFactory.rehydrate(classKey, data);
468
- }
469
- _chunk7QVYU63Ejs.__name.call(void 0, rehydrate, "rehydrate");
470
- function rehydrateList(classKey, data) {
471
- return RehydrationFactory.rehydrateList(classKey, data);
472
- }
473
- _chunk7QVYU63Ejs.__name.call(void 0, rehydrateList, "rehydrateList");
474
-
475
-
476
-
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
-
489
- exports.RehydrationFactory = RehydrationFactory; exports.AbstractApiData = AbstractApiData; exports.HttpMethod = HttpMethod; exports.setGlobalErrorHandler = setGlobalErrorHandler; exports.getGlobalErrorHandler = getGlobalErrorHandler; exports.AbstractService = AbstractService; exports.ModuleRegistrar = ModuleRegistrar; exports.ModuleRegistry = ModuleRegistry; exports.Modules = Modules; exports.EndpointCreator = EndpointCreator; exports.createJsonApiInclusion = createJsonApiInclusion; exports.rehydrate = rehydrate; exports.rehydrateList = rehydrateList;
490
- //# sourceMappingURL=chunk-Q4FXESVT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-Q4FXESVT.js","../src/core/factories/RehydrationFactory.ts","../src/core/abstracts/AbstractApiData.ts","../src/core/abstracts/AbstractService.ts","../src/core/registry/ModuleRegistrar.ts","../src/core/registry/ModuleRegistry.ts","../src/core/endpoint/EndpointCreator.ts","../src/core/fields/FieldSelector.ts","../src/core/utils/rehydrate.ts"],"names":["includedData","HttpMethod"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACFO,IAAM,mBAAA,EAAN,MAAyB;AAAA,EALhC,OAKgC;AAAA,IAAA,qCAAA,IAAA,EAAA,oBAAA,CAAA;AAAA,EAAA;AAAA,EAC9B,OAAc,SAAA,CACZ,QAAA,EACA,IAAA,EACG;AACH,IAAA,MAAM,aAAA,EAAe,kCAAA,CAAkB,GAAA,CAAI,QAAQ,CAAA;AAEnD,IAAA,MAAM,SAAA,EAAW,IAAI,YAAA,CAAa,CAAA;AAClC,IAAA,OAAO,QAAA,CAAS,SAAA,CAAU,IAAI,CAAA;AAAA,EAChC;AAAA,EAEA,OAAc,aAAA,CACZ,QAAA,EACA,IAAA,EACK;AACL,IAAA,MAAM,aAAA,EAAe,kCAAA,CAAkB,GAAA,CAAI,QAAQ,CAAA;AAEnD,IAAA,MAAM,SAAA,EAAW,IAAA,CAAK,GAAA,CAAI,CAAC,IAAA,EAAA,GAAuC;AAChE,MAAA,MAAM,SAAA,EAAW,IAAI,YAAA,CAAa,CAAA;AAClC,MAAA,OAAO,QAAA,CAAS,SAAA,CAAU,IAAI,CAAA;AAAA,IAChC,CAAC,CAAA;AAED,IAAA,OAAO,QAAA;AAAA,EACT;AACF,CAAA;ADHA;AACA;AEtBO,IAAe,gBAAA,EAAf,MAA2D;AAAA,EALlE,OAKkE;AAAA,IAAA,qCAAA,IAAA,EAAA,iBAAA,CAAA;AAAA,EAAA;AAAA,EACtD;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEV,IAAI,IAAA,CAAA,EAAe;AACjB,IAAA,GAAA,CAAI,CAAC,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,KAAA,CAAM,kBAAk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;AACjB,EAAA;AAE2E,EAAA;AACrD,IAAA;AACL,IAAA;AACR,IAAA;AACT,EAAA;AAEuC,EAAA;AACb,IAAA;AACjB,IAAA;AACT,EAAA;AAEqD,EAAA;AACvB,IAAA;AAET,IAAA;AACG,MAAA;AACI,MAAA;AACzB,IAAA;AAEM,IAAA;AACT,EAAA;AAEmB,EAAA;AACM,IAAA;AACJ,IAAA;AACO,MAAA;AAC1B,IAAA;AAEuB,IAAA;AACA,IAAA;AACJ,IAAA;AAER,MAAA;AAIX,IAAA;AAC4B,IAAA;AACN,IAAA;AAEf,IAAA;AACT,EAAA;AACF;ANsWiC;AACA;AO9bS;AACjC,EAAA;AACC,IAAA;AACN,IAAA;AACF,EAAA;AACF;AALgB;APsciB;AACA;AQtc/B;AAE0B,EAAA;AAC5B;AALgB;AAYd;AAE0B,EAAA;AAC5B;AALgB;ARuciB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-Q4FXESVT.js","sourcesContent":[null,"import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\nimport { DataClassRegistry } from \"../registry/DataClassRegistry\";\n\nexport class RehydrationFactory {\n public static rehydrate<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface,\n ): T {\n const factoryClass = DataClassRegistry.get(classKey);\n\n const instance = new factoryClass();\n return instance.rehydrate(data) as T;\n }\n\n public static rehydrateList<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface[],\n ): T[] {\n const factoryClass = DataClassRegistry.get(classKey);\n\n const response = data.map((item: JsonApiHydratedDataInterface) => {\n const instance = new factoryClass();\n return instance.rehydrate(item) as T;\n });\n\n return response;\n }\n}\n","import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\nimport { RehydrationFactory } from \"../factories/RehydrationFactory\";\n\nexport abstract class AbstractApiData implements ApiDataInterface {\n protected _jsonApi?: any;\n protected _included?: any[];\n\n protected _id?: string;\n protected _type?: string;\n protected _createdAt?: Date;\n protected _updatedAt?: Date;\n\n protected _self?: string;\n\n get type(): string {\n if (!this._type) throw new Error(\"Type is not set.\");\n return this._type;\n }\n\n get id(): string {\n if (!this._id) throw new Error(\"Id is not set.\");\n return this._id;\n }\n\n get self(): string | undefined {\n return this._self;\n }\n\n get createdAt(): Date {\n return this._createdAt ?? new Date();\n }\n\n get updatedAt(): Date {\n return this._updatedAt ?? new Date();\n }\n\n get included(): any[] {\n return this._included ?? [];\n }\n\n get jsonApi(): any {\n return this._jsonApi;\n }\n\n ingestJsonApi(_data: JsonApiHydratedDataInterface): void {}\n\n generateApiUrl(_params?: any): string {\n throw new Error(\"Method not implemented.\");\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"Method not implemented.\");\n }\n\n protected _readIncluded<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): T | T[] | undefined {\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n if (Array.isArray(data.jsonApi.relationships[type].data)) {\n const response: T[] = data.jsonApi.relationships[type].data.map((jsonApiData: any) => {\n const includedData = data.included.find(\n (includedData: any) => includedData.id === jsonApiData.id && includedData.type === jsonApiData.type,\n );\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n });\n\n return response.filter((item: T | undefined) => item !== undefined) as T[];\n }\n\n const includedData = data.included.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n\n if (includedData === undefined && data.allData !== undefined) {\n // Try to find in allData as a fallback\n const fallbackData = data.allData.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n if (fallbackData !== undefined) {\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n }\n }\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n }\n\n dehydrate(): JsonApiHydratedDataInterface {\n return {\n jsonApi: this._jsonApi,\n included: this._included ?? [],\n };\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n this._jsonApi = data.jsonApi;\n this._included = data.included;\n\n this._type = this._jsonApi.type;\n this._id = this._jsonApi.id;\n this._createdAt = this._jsonApi.meta?.createdAt !== undefined ? new Date(this._jsonApi.meta.createdAt) : undefined;\n this._updatedAt = this._jsonApi.meta?.updatedAt !== undefined ? new Date(this._jsonApi.meta.updatedAt) : undefined;\n\n this._self = this._jsonApi.links?.self ?? undefined;\n\n return this;\n }\n}\n","import { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../interfaces/ApiResponseInterface\";\n\nexport enum HttpMethod {\n GET = \"GET\",\n POST = \"POST\",\n PUT = \"PUT\",\n PATCH = \"PATCH\",\n DELETE = \"DELETE\",\n}\n\nexport interface NextRef {\n next?: string;\n}\n\nexport interface PreviousRef {\n previous?: string;\n}\n\nexport interface SelfRef {\n self?: string;\n}\n\nlet globalErrorHandler: ((status: number, message: string) => void) | null = null;\n\n/**\n * Set a global error handler for API errors (client-side only).\n * This handler will be called instead of throwing errors.\n */\nexport function setGlobalErrorHandler(handler: (status: number, message: string) => void) {\n globalErrorHandler = handler;\n}\n\n/**\n * Get the current global error handler.\n */\nexport function getGlobalErrorHandler(): ((status: number, message: string) => void) | null {\n return globalErrorHandler;\n}\n\n/**\n * Abstract base class for services that interact with the JSON:API.\n * Extend this class to create feature-specific services.\n */\nexport abstract class AbstractService {\n /**\n * Extract locale from client-side URL pathname\n * URL structure: /{locale}/route-path (e.g., /it/accounts)\n * Fallback chain: URL locale → navigator.language → \"en\"\n */\n private static getClientLocale(): string {\n if (typeof window === \"undefined\") {\n return \"en\"; // Server-side fallback\n }\n\n // Extract locale from URL pathname (first segment after leading slash)\n const pathSegments = window.location.pathname.split(\"/\").filter(Boolean);\n const urlLocale = pathSegments[0];\n\n // Validate against supported locales (currently only \"en\")\n const supportedLocales = [\"en\"];\n if (urlLocale && supportedLocales.includes(urlLocale)) {\n return urlLocale;\n }\n\n // Fallback to navigator language\n const navigatorLocale = navigator.language.split(\"-\")[0];\n if (navigatorLocale && supportedLocales.includes(navigatorLocale)) {\n return navigatorLocale;\n }\n\n // Final fallback\n return \"en\";\n }\n\n static async next<T>(params: {\n type: ApiRequestDataTypeInterface;\n endpoint: string;\n next?: NextRef;\n previous?: PreviousRef;\n self?: SelfRef;\n }): Promise<T> {\n return await this.callApi<T>({\n method: HttpMethod.GET,\n type: params.type,\n endpoint: params.endpoint,\n next: params.next,\n previous: params.previous,\n self: params.self,\n });\n }\n\n /**\n * Fetch the previous page of results.\n */\n static async previous<T>(params: {\n type: ApiRequestDataTypeInterface;\n endpoint: string;\n next?: NextRef;\n previous?: PreviousRef;\n self?: SelfRef;\n }): Promise<T> {\n return await this.callApi<T>({\n method: HttpMethod.GET,\n type: params.type,\n endpoint: params.endpoint,\n next: params.next,\n previous: params.previous,\n self: params.self,\n });\n }\n\n /**\n * Make an API call with automatic environment detection and error handling.\n */\n protected static async callApi<T>(params: {\n type: ApiRequestDataTypeInterface;\n method: HttpMethod;\n endpoint: string;\n companyId?: string;\n input?: any;\n overridesJsonApiCreation?: boolean;\n next?: NextRef;\n previous?: PreviousRef;\n self?: SelfRef;\n responseType?: ApiRequestDataTypeInterface;\n files?: { [key: string]: File | Blob } | File | Blob;\n }): Promise<T> {\n // Dynamic import to avoid bundling issues\n const { JsonApiGet, JsonApiPost, JsonApiPut, JsonApiPatch, JsonApiDelete } =\n await import(\"../../unified/JsonApiRequest\");\n\n let apiResponse: ApiResponseInterface;\n\n // Get language based on environment\n let language = \"en\";\n if (typeof window === \"undefined\") {\n const { getLocale } = await import(\"next-intl/server\");\n language = (await getLocale()) ?? \"en\";\n } else {\n // Client-side: extract locale from URL pathname\n language = this.getClientLocale();\n }\n\n switch (params.method) {\n case HttpMethod.GET:\n apiResponse = await JsonApiGet({\n classKey: params.type,\n endpoint: params.endpoint,\n companyId: params.companyId,\n language: language,\n });\n break;\n case HttpMethod.POST:\n apiResponse = await JsonApiPost({\n classKey: params.type,\n endpoint: params.endpoint,\n companyId: params.companyId,\n body: params.input,\n overridesJsonApiCreation: params.overridesJsonApiCreation,\n language: language,\n responseType: params.responseType,\n files: params.files,\n });\n break;\n case HttpMethod.PUT:\n apiResponse = await JsonApiPut({\n classKey: params.type,\n endpoint: params.endpoint,\n companyId: params.companyId,\n body: params.input,\n language: language,\n responseType: params.responseType,\n files: params.files,\n });\n break;\n case HttpMethod.PATCH:\n apiResponse = await JsonApiPatch({\n classKey: params.type,\n endpoint: params.endpoint,\n companyId: params.companyId,\n body: params.input,\n overridesJsonApiCreation: params.overridesJsonApiCreation,\n language: language,\n responseType: params.responseType,\n files: params.files,\n });\n break;\n case HttpMethod.DELETE:\n apiResponse = await JsonApiDelete({\n classKey: params.type,\n endpoint: params.endpoint,\n companyId: params.companyId,\n language: language,\n responseType: params.responseType,\n });\n break;\n default:\n throw new Error(\"Method not found\");\n }\n\n if (!apiResponse.ok) {\n if (globalErrorHandler && typeof window !== \"undefined\") {\n globalErrorHandler(apiResponse.response, apiResponse.error);\n return undefined as any;\n } else {\n const error = new Error(`${apiResponse.response}:${apiResponse.error}`) as any;\n error.status = apiResponse.response;\n error.digest = `HTTP_${apiResponse.response}`;\n throw error;\n }\n }\n\n if (apiResponse.next && params.next) params.next.next = apiResponse.next;\n if (apiResponse.prev && params.previous) params.previous.previous = apiResponse.prev;\n if (apiResponse.self && params.self) params.self.self = apiResponse.self;\n\n return apiResponse.data as T;\n }\n\n /**\n * Get raw JSON:API response data without deserialization.\n */\n protected static async getRawData(params: {\n type: ApiRequestDataTypeInterface;\n method: HttpMethod;\n endpoint: string;\n companyId?: string;\n }): Promise<any> {\n const { JsonApiGet } = await import(\"../../unified/JsonApiRequest\");\n\n let language = \"en\";\n\n if (typeof window === \"undefined\") {\n const { getLocale } = await import(\"next-intl/server\");\n language = (await getLocale()) ?? \"en\";\n } else {\n // Client-side: extract locale from URL pathname\n language = this.getClientLocale();\n }\n\n const apiResponse: ApiResponseInterface = await JsonApiGet({\n classKey: params.type,\n endpoint: params.endpoint,\n companyId: params.companyId,\n language: language,\n });\n\n if (!apiResponse.ok) {\n if (globalErrorHandler && typeof window !== \"undefined\") {\n globalErrorHandler(apiResponse.response, apiResponse.error);\n return undefined as any;\n } else {\n const error = new Error(`${apiResponse.response}:${apiResponse.error}`) as any;\n error.status = apiResponse.response;\n error.digest = `HTTP_${apiResponse.response}`;\n throw error;\n }\n }\n\n return apiResponse.raw;\n }\n}\n","import { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { DataClassRegistry } from \"./DataClassRegistry\";\n\n/**\n * Helper class to bootstrap the registry from a Modules-style class.\n * This supports the pattern where modules are defined as static getters.\n */\nexport class ModuleRegistrar {\n private static _isBootstrapped = false;\n\n /**\n * Bootstrap the registry from a Modules class.\n * Automatically detects static getters and registers their models.\n *\n * @param modulesClass - The Modules class with static getters\n */\n static bootstrap<T extends object>(modulesClass: T): void {\n if (this._isBootstrapped) return;\n\n const data = Object.getOwnPropertyNames(modulesClass)\n .filter((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(modulesClass, key);\n return descriptor && typeof descriptor.get === \"function\";\n })\n .map((key) => (modulesClass as any)[key] as ApiRequestDataTypeInterface);\n\n data.forEach((item) => {\n if (item && item.model) {\n DataClassRegistry.registerObjectClass(item, item.model);\n }\n });\n\n this._isBootstrapped = true;\n }\n\n /**\n * Reset the bootstrapped state. Useful for testing.\n */\n static reset(): void {\n this._isBootstrapped = false;\n DataClassRegistry.clear();\n }\n}\n","import { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { ModuleWithPermissions } from \"../../permissions/types\";\n\n// Foundation module types - defined by LIBRARY\nexport interface FoundationModuleDefinitions {\n S3: ModuleWithPermissions;\n Auth: ModuleWithPermissions;\n User: ModuleWithPermissions;\n Author: ModuleWithPermissions;\n Company: ModuleWithPermissions;\n Role: ModuleWithPermissions;\n Notification: ModuleWithPermissions;\n Push: ModuleWithPermissions;\n Feature: ModuleWithPermissions;\n Module: ModuleWithPermissions;\n Content: ModuleWithPermissions;\n UserTopic: ModuleWithPermissions;\n UserExpertise: ModuleWithPermissions;\n}\n\n// App-specific modules - apps will augment this interface ONLY\n\nexport interface AppModuleDefinitions {}\n\n// Combined type for full autocompletion\nexport type ModuleDefinitions = FoundationModuleDefinitions & AppModuleDefinitions;\n\nclass ModuleRegistryClass {\n private _modules: Map<string, ApiRequestDataTypeInterface> = new Map();\n\n register<K extends string>(name: K, module: ApiRequestDataTypeInterface): void {\n this._modules.set(name, module);\n }\n\n get<K extends keyof ModuleDefinitions>(name: K): ModuleDefinitions[K] {\n const module = this._modules.get(name as string);\n if (!module) {\n throw new Error(`Module \"${String(name)}\" not registered. Call bootstrap() first.`);\n }\n return module as ModuleDefinitions[K];\n }\n\n findByName(moduleName: string): ModuleWithPermissions {\n // Search by module's name property (e.g., \"topics\", \"articles\")\n for (const module of this._modules.values()) {\n if ((module as ModuleWithPermissions).name === moduleName) {\n return module as ModuleWithPermissions;\n }\n }\n throw new Error(`Module not found: ${moduleName}`);\n }\n\n findByModelName(modelName: string): ModuleWithPermissions {\n // Direct lookup by registry key (e.g., \"Article\", \"Document\")\n const module = this._modules.get(modelName);\n if (!module) {\n throw new Error(`Module not found for model: ${modelName}`);\n }\n return module as ModuleWithPermissions;\n }\n}\n\nexport const ModuleRegistry = new ModuleRegistryClass();\n\n// Proxy object for Modules.X syntax with autocompletion\nexport const Modules = new Proxy({} as ModuleDefinitions, {\n get(_, prop: string) {\n if (prop === \"findByName\") {\n return (name: string) => ModuleRegistry.findByName(name);\n }\n if (prop === \"findByModelName\") {\n return (name: string) => ModuleRegistry.findByModelName(name);\n }\n return ModuleRegistry.get(prop as keyof ModuleDefinitions);\n },\n}) as ModuleDefinitions & {\n findByName: (name: string) => ModuleWithPermissions;\n findByModelName: (name: string) => ModuleWithPermissions;\n};\n","import { FieldSelector } from \"../fields/FieldSelector\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\n\nexport type EndpointQuery = {\n endpoint: ApiRequestDataTypeInterface;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string | string[] }[];\n};\n\nexport class EndpointCreator {\n private _endpoint: EndpointQuery;\n\n constructor(params: {\n endpoint: ApiRequestDataTypeInterface;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string }[];\n }) {\n this._endpoint = {\n endpoint: params.endpoint,\n id: params.id,\n childEndpoint: params.childEndpoint,\n childId: params.childId,\n additionalParams: params.additionalParams ?? [],\n };\n }\n\n endpoint(value: ApiRequestDataTypeInterface): EndpointCreator {\n this._endpoint.endpoint = value;\n return this;\n }\n\n id(value: string): EndpointCreator {\n this._endpoint.id = value;\n return this;\n }\n\n childEndpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.childEndpoint = value;\n return this;\n }\n\n childId(value: string): EndpointCreator {\n this._endpoint.childId = value;\n return this;\n }\n\n set additionalParams(value: { key: string; value: string }[]) {\n this._endpoint.additionalParams = value;\n }\n\n addAdditionalParam(key: string, value: string | string[]): EndpointCreator {\n if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];\n this._endpoint.additionalParams.push({ key, value });\n return this;\n }\n\n limitToType(selectors: string[]): this {\n this.addAdditionalParam(`include`, selectors.join(\",\"));\n return this;\n }\n\n limitToFields(selectors: FieldSelector<any>[]): this {\n if (selectors.length === 0) return this;\n\n selectors.forEach((selector) => {\n const fieldString = selector.fields.join(\",\");\n this.addAdditionalParam(`fields[${selector.type}]`, fieldString);\n });\n\n return this;\n }\n\n generate(): string {\n let additionalParams = \"\";\n if (this._endpoint.additionalParams) {\n additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join(\"&\");\n }\n\n let response = `${this._endpoint.endpoint.name}`;\n if (this._endpoint.id) response += `/${this._endpoint.id}`;\n if (this._endpoint.childEndpoint) {\n response += `/${\n typeof this._endpoint.childEndpoint === \"string\"\n ? this._endpoint.childEndpoint\n : this._endpoint.childEndpoint.name\n }`;\n }\n if (this._endpoint.childId) response += `/${this._endpoint.childId}`;\n if (additionalParams) response += `?${additionalParams}`;\n\n return response;\n }\n}\n","export type GetterKeys<T> = {\n [K in keyof T]: T[K] extends () => any ? never : K;\n}[keyof T];\n\nexport type FieldSelector<T> = {\n type: string;\n fields: ReadonlyArray<GetterKeys<T>>;\n};\n\nexport function createJsonApiInclusion<T>(dataType: string, fields: ReadonlyArray<GetterKeys<T>>): FieldSelector<T> {\n return {\n type: dataType,\n fields,\n };\n}\n","import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\nimport { RehydrationFactory } from \"../factories/RehydrationFactory\";\n\n/**\n * Rehydrate a single dehydrated object back into its typed class instance.\n */\nexport function rehydrate<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface,\n): T {\n return RehydrationFactory.rehydrate(classKey, data) as T;\n}\n\n/**\n * Rehydrate a list of dehydrated objects back into typed class instances.\n */\nexport function rehydrateList<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface[],\n): T[] {\n return RehydrationFactory.rehydrateList(classKey, data) as T[];\n}\n"]}
@@ -1,68 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-PAWJFY3S.mjs";
4
-
5
- // src/i18n/config.ts
6
- var _config = null;
7
- function configureI18n(config) {
8
- _config = config;
9
- }
10
- __name(configureI18n, "configureI18n");
11
- function useI18nRouter() {
12
- if (!_config?.useRouter) {
13
- throw new Error("i18n not configured. Call configureI18n() at app startup.");
14
- }
15
- return _config.useRouter();
16
- }
17
- __name(useI18nRouter, "useI18nRouter");
18
- function useI18nTranslations(namespace) {
19
- if (!_config?.useTranslations) {
20
- return (key) => key;
21
- }
22
- return _config.useTranslations(namespace);
23
- }
24
- __name(useI18nTranslations, "useI18nTranslations");
25
- function getI18nLink() {
26
- if (!_config?.Link) {
27
- throw new Error("i18n not configured. Call configureI18n() at app startup.");
28
- }
29
- return _config.Link;
30
- }
31
- __name(getI18nLink, "getI18nLink");
32
- function useI18nLocale() {
33
- if (_config?.useLocale) {
34
- return _config.useLocale();
35
- }
36
- return "en";
37
- }
38
- __name(useI18nLocale, "useI18nLocale");
39
- function useI18nDateFnsLocale() {
40
- if (_config?.useDateFnsLocale) {
41
- return _config.useDateFnsLocale();
42
- }
43
- return void 0;
44
- }
45
- __name(useI18nDateFnsLocale, "useI18nDateFnsLocale");
46
-
47
- // src/features/auth/config.ts
48
- var _tokenHandler = null;
49
- function configureAuth(handler) {
50
- _tokenHandler = handler;
51
- }
52
- __name(configureAuth, "configureAuth");
53
- function getTokenHandler() {
54
- return _tokenHandler;
55
- }
56
- __name(getTokenHandler, "getTokenHandler");
57
-
58
- export {
59
- configureI18n,
60
- useI18nRouter,
61
- useI18nTranslations,
62
- getI18nLink,
63
- useI18nLocale,
64
- useI18nDateFnsLocale,
65
- configureAuth,
66
- getTokenHandler
67
- };
68
- //# sourceMappingURL=chunk-SM63SZCP.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/i18n/config.ts","../src/features/auth/config.ts"],"sourcesContent":["import { ComponentType } from \"react\";\n\n// Types for injected hooks\nexport interface I18nRouter {\n push: (href: string) => void;\n replace: (href: string) => void;\n back: () => void;\n forward: () => void;\n refresh: () => void;\n prefetch: (href: string) => void;\n}\n\nexport type UseRouterHook = () => I18nRouter;\nexport type UseTranslationsHook = (namespace?: string) => (key: string, values?: Record<string, any>) => string;\nexport type UseLocaleHook = () => string;\n\nexport type UseDateFnsLocaleHook = () => any; // date-fns Locale type\nexport type LinkComponent = ComponentType<{ href: string; children: React.ReactNode; [key: string]: any }>;\n\nexport interface I18nConfig {\n useRouter: UseRouterHook;\n useTranslations: UseTranslationsHook;\n useLocale?: UseLocaleHook;\n useDateFnsLocale?: UseDateFnsLocaleHook;\n Link: LinkComponent;\n usePathname: () => string;\n}\n\n// Private storage\nlet _config: I18nConfig | null = null;\n\n// Configuration function (called by app at startup)\nexport function configureI18n(config: I18nConfig): void {\n _config = config;\n}\n\n// Hooks for library components to use\nexport function useI18nRouter(): I18nRouter {\n if (!_config?.useRouter) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.useRouter();\n}\n\nexport function useI18nTranslations(namespace?: string): (key: string, values?: Record<string, any>) => string {\n if (!_config?.useTranslations) {\n // Fallback: return key as-is (safe for server/client)\n return (key: string) => key;\n }\n return _config.useTranslations(namespace);\n}\n\nexport function getI18nLink(): LinkComponent {\n if (!_config?.Link) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.Link;\n}\n\nexport function useI18nLocale(): string {\n if (_config?.useLocale) {\n return _config.useLocale();\n }\n // Fallback to English (safe for server/client)\n return \"en\";\n}\n\nexport function useI18nDateFnsLocale(): any {\n if (_config?.useDateFnsLocale) {\n return _config.useDateFnsLocale();\n }\n // Fallback to undefined (Calendar will use default)\n return undefined;\n}\n","/**\n * Token parameters for authentication cookie management\n */\nexport interface TokenParams {\n token?: string;\n refreshToken?: string;\n userId?: string;\n companyId?: string;\n licenseExpirationDate?: Date;\n roles?: string[];\n features?: string[];\n modules?: {\n id: string;\n permissions: {\n create: boolean | string;\n read: boolean | string;\n update: boolean | string;\n delete: boolean | string;\n };\n }[];\n}\n\n/**\n * Token handler interface for dependency injection\n * Apps must provide implementations of these functions via configureAuth()\n */\nexport interface TokenHandler {\n updateToken: (params: TokenParams) => Promise<void>;\n removeToken: () => Promise<void>;\n}\n\n// Private storage for the injected token handler\nlet _tokenHandler: TokenHandler | null = null;\n\n/**\n * Configure authentication token handling\n * Call this at app startup to provide Server Actions for cookie management\n *\n * @example\n * ```typescript\n * import { configureAuth } from \"@carlonicora/nextjs-jsonapi/features\";\n * import { updateToken, removeToken } from \"@/features/auth/utils/AuthCookies\";\n *\n * configureAuth({ updateToken, removeToken });\n * ```\n */\nexport function configureAuth(handler: TokenHandler): void {\n _tokenHandler = handler;\n}\n\n/**\n * Internal getter for AuthService to access the token handler\n * @internal\n */\nexport function getTokenHandler(): TokenHandler | null {\n return _tokenHandler;\n}\n"],"mappings":";;;;;AA6BA,IAAI,UAA6B;AAG1B,SAAS,cAAc,QAA0B;AACtD,YAAU;AACZ;AAFgB;AAKT,SAAS,gBAA4B;AAC1C,MAAI,CAAC,SAAS,WAAW;AACvB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO,QAAQ,UAAU;AAC3B;AALgB;AAOT,SAAS,oBAAoB,WAA2E;AAC7G,MAAI,CAAC,SAAS,iBAAiB;AAE7B,WAAO,CAAC,QAAgB;AAAA,EAC1B;AACA,SAAO,QAAQ,gBAAgB,SAAS;AAC1C;AANgB;AAQT,SAAS,cAA6B;AAC3C,MAAI,CAAC,SAAS,MAAM;AAClB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO,QAAQ;AACjB;AALgB;AAOT,SAAS,gBAAwB;AACtC,MAAI,SAAS,WAAW;AACtB,WAAO,QAAQ,UAAU;AAAA,EAC3B;AAEA,SAAO;AACT;AANgB;AAQT,SAAS,uBAA4B;AAC1C,MAAI,SAAS,kBAAkB;AAC7B,WAAO,QAAQ,iBAAiB;AAAA,EAClC;AAEA,SAAO;AACT;AANgB;;;ACnChB,IAAI,gBAAqC;AAclC,SAAS,cAAc,SAA6B;AACzD,kBAAgB;AAClB;AAFgB;AAQT,SAAS,kBAAuC;AACrD,SAAO;AACT;AAFgB;","names":[]}