@communecter/cocolight-api-client 1.0.154 → 1.0.156

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 (331) hide show
  1. package/dist/1035.cocolight-api-client.browser.js +1 -1
  2. package/dist/1035.cocolight-api-client.cjs +1 -1
  3. package/dist/1483.cocolight-api-client.browser.js +1 -1
  4. package/dist/1483.cocolight-api-client.cjs +1 -1
  5. package/dist/1491.cocolight-api-client.browser.js +1 -1
  6. package/dist/1491.cocolight-api-client.cjs +1 -1
  7. package/dist/1494.cocolight-api-client.browser.js +1 -1
  8. package/dist/1494.cocolight-api-client.cjs +1 -1
  9. package/dist/1641.cocolight-api-client.browser.js +1 -1
  10. package/dist/1641.cocolight-api-client.cjs +1 -1
  11. package/dist/1678.cocolight-api-client.browser.js +1 -1
  12. package/dist/1678.cocolight-api-client.cjs +1 -1
  13. package/dist/2041.cocolight-api-client.browser.js +1 -1
  14. package/dist/2041.cocolight-api-client.cjs +1 -1
  15. package/dist/2302.cocolight-api-client.browser.js +1 -1
  16. package/dist/2302.cocolight-api-client.cjs +1 -1
  17. package/dist/2313.cocolight-api-client.browser.js +1 -1
  18. package/dist/2313.cocolight-api-client.cjs +1 -1
  19. package/dist/2379.cocolight-api-client.browser.js +1 -1
  20. package/dist/2379.cocolight-api-client.cjs +1 -1
  21. package/dist/2439.cocolight-api-client.browser.js +1 -1
  22. package/dist/2439.cocolight-api-client.cjs +1 -1
  23. package/dist/2594.cocolight-api-client.browser.js +1 -1
  24. package/dist/2594.cocolight-api-client.cjs +1 -1
  25. package/dist/2766.cocolight-api-client.browser.js +1 -1
  26. package/dist/2766.cocolight-api-client.cjs +1 -1
  27. package/dist/2812.cocolight-api-client.browser.js +1 -1
  28. package/dist/2812.cocolight-api-client.cjs +1 -1
  29. package/dist/2918.cocolight-api-client.browser.js +1 -1
  30. package/dist/2918.cocolight-api-client.cjs +1 -1
  31. package/dist/3028.cocolight-api-client.browser.js +1 -1
  32. package/dist/3028.cocolight-api-client.cjs +1 -1
  33. package/dist/3330.cocolight-api-client.browser.js +1 -1
  34. package/dist/3330.cocolight-api-client.cjs +1 -1
  35. package/dist/3371.cocolight-api-client.browser.js +1 -1
  36. package/dist/3371.cocolight-api-client.cjs +1 -1
  37. package/dist/3401.cocolight-api-client.browser.js +1 -1
  38. package/dist/3401.cocolight-api-client.cjs +1 -1
  39. package/dist/3516.cocolight-api-client.browser.js +1 -1
  40. package/dist/3516.cocolight-api-client.cjs +1 -1
  41. package/dist/3593.cocolight-api-client.browser.js +1 -1
  42. package/dist/3593.cocolight-api-client.cjs +1 -1
  43. package/dist/3764.cocolight-api-client.browser.js +1 -1
  44. package/dist/3764.cocolight-api-client.cjs +1 -1
  45. package/dist/3873.cocolight-api-client.browser.js +1 -1
  46. package/dist/3873.cocolight-api-client.cjs +1 -1
  47. package/dist/3911.cocolight-api-client.browser.js +1 -1
  48. package/dist/3911.cocolight-api-client.cjs +1 -1
  49. package/dist/4031.cocolight-api-client.browser.js +1 -1
  50. package/dist/4031.cocolight-api-client.cjs +1 -1
  51. package/dist/4152.cocolight-api-client.browser.js +1 -1
  52. package/dist/4152.cocolight-api-client.cjs +1 -1
  53. package/dist/4203.cocolight-api-client.browser.js +1 -1
  54. package/dist/4203.cocolight-api-client.cjs +1 -1
  55. package/dist/424.cocolight-api-client.browser.js +1 -1
  56. package/dist/424.cocolight-api-client.cjs +1 -1
  57. package/dist/435.cocolight-api-client.browser.js +1 -1
  58. package/dist/435.cocolight-api-client.cjs +1 -1
  59. package/dist/4402.cocolight-api-client.browser.js +1 -1
  60. package/dist/4402.cocolight-api-client.cjs +1 -1
  61. package/dist/4425.cocolight-api-client.browser.js +1 -1
  62. package/dist/4425.cocolight-api-client.cjs +1 -1
  63. package/dist/4472.cocolight-api-client.browser.js +1 -1
  64. package/dist/4472.cocolight-api-client.cjs +1 -1
  65. package/dist/4914.cocolight-api-client.browser.js +1 -1
  66. package/dist/4914.cocolight-api-client.cjs +1 -1
  67. package/dist/4959.cocolight-api-client.browser.js +1 -1
  68. package/dist/4959.cocolight-api-client.cjs +1 -1
  69. package/dist/5100.cocolight-api-client.browser.js +1 -1
  70. package/dist/5100.cocolight-api-client.cjs +1 -1
  71. package/dist/5111.cocolight-api-client.browser.js +1 -1
  72. package/dist/5111.cocolight-api-client.cjs +1 -1
  73. package/dist/5286.cocolight-api-client.browser.js +1 -1
  74. package/dist/5286.cocolight-api-client.cjs +1 -1
  75. package/dist/5380.cocolight-api-client.browser.js +1 -1
  76. package/dist/5380.cocolight-api-client.cjs +1 -1
  77. package/dist/5383.cocolight-api-client.browser.js +1 -1
  78. package/dist/5383.cocolight-api-client.cjs +1 -1
  79. package/dist/5480.cocolight-api-client.browser.js +1 -1
  80. package/dist/5480.cocolight-api-client.cjs +1 -1
  81. package/dist/5541.cocolight-api-client.browser.js +1 -1
  82. package/dist/5541.cocolight-api-client.cjs +1 -1
  83. package/dist/5839.cocolight-api-client.browser.js +1 -1
  84. package/dist/5839.cocolight-api-client.cjs +1 -1
  85. package/dist/5862.cocolight-api-client.browser.js +1 -1
  86. package/dist/5862.cocolight-api-client.cjs +1 -1
  87. package/dist/5869.cocolight-api-client.browser.js +1 -1
  88. package/dist/5869.cocolight-api-client.cjs +1 -1
  89. package/dist/588.cocolight-api-client.browser.js +1 -1
  90. package/dist/588.cocolight-api-client.cjs +1 -1
  91. package/dist/601.cocolight-api-client.browser.js +1 -1
  92. package/dist/601.cocolight-api-client.cjs +1 -1
  93. package/dist/6012.cocolight-api-client.browser.js +1 -1
  94. package/dist/6012.cocolight-api-client.cjs +1 -1
  95. package/dist/6200.cocolight-api-client.browser.js +1 -1
  96. package/dist/6200.cocolight-api-client.cjs +1 -1
  97. package/dist/6369.cocolight-api-client.browser.js +1 -1
  98. package/dist/6369.cocolight-api-client.cjs +1 -1
  99. package/dist/7009.cocolight-api-client.browser.js +1 -1
  100. package/dist/7009.cocolight-api-client.cjs +1 -1
  101. package/dist/725.cocolight-api-client.browser.js +1 -1
  102. package/dist/725.cocolight-api-client.cjs +1 -1
  103. package/dist/7320.cocolight-api-client.browser.js +1 -1
  104. package/dist/7339.cocolight-api-client.browser.js +1 -1
  105. package/dist/7339.cocolight-api-client.cjs +1 -1
  106. package/dist/7398.cocolight-api-client.browser.js +1 -1
  107. package/dist/7398.cocolight-api-client.cjs +1 -1
  108. package/dist/7888.cocolight-api-client.browser.js +1 -1
  109. package/dist/7888.cocolight-api-client.cjs +1 -1
  110. package/dist/7975.cocolight-api-client.browser.js +1 -1
  111. package/dist/7975.cocolight-api-client.cjs +1 -1
  112. package/dist/809.cocolight-api-client.browser.js +1 -1
  113. package/dist/809.cocolight-api-client.cjs +1 -1
  114. package/dist/8300.cocolight-api-client.browser.js +1 -1
  115. package/dist/8300.cocolight-api-client.cjs +1 -1
  116. package/dist/8317.cocolight-api-client.browser.js +1 -1
  117. package/dist/8317.cocolight-api-client.cjs +1 -1
  118. package/dist/8525.cocolight-api-client.browser.js +1 -1
  119. package/dist/8525.cocolight-api-client.cjs +1 -1
  120. package/dist/8894.cocolight-api-client.browser.js +1 -1
  121. package/dist/8894.cocolight-api-client.cjs +1 -1
  122. package/dist/9301.cocolight-api-client.browser.js +1 -1
  123. package/dist/9301.cocolight-api-client.cjs +1 -1
  124. package/dist/9438.cocolight-api-client.browser.js +1 -1
  125. package/dist/9438.cocolight-api-client.cjs +1 -1
  126. package/dist/9478.cocolight-api-client.browser.js +1 -1
  127. package/dist/9478.cocolight-api-client.cjs +1 -1
  128. package/dist/9568.cocolight-api-client.browser.js +1 -1
  129. package/dist/9568.cocolight-api-client.cjs +1 -1
  130. package/dist/cocolight-api-client.browser.js +6 -6
  131. package/dist/cocolight-api-client.cjs +1 -1
  132. package/dist/cocolight-api-client.vite.mjs.js +1 -1
  133. package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
  134. package/package.json +7 -17
  135. package/types/Api.d.ts +1 -0
  136. package/types/ApiClient.d.ts +10 -1
  137. package/types/api/BaseEntity.d.ts +24 -0
  138. package/types/api/EndpointApi.d.ts +4 -4
  139. package/types/api/EndpointApi.types.d.ts +3 -3
  140. package/types/utils/OfflineClientManager.d.ts +8 -0
  141. package/dist/1035.cocolight-api-client.mjs.js +0 -1
  142. package/dist/1483.cocolight-api-client.mjs.js +0 -1
  143. package/dist/1491.cocolight-api-client.mjs.js +0 -1
  144. package/dist/1494.cocolight-api-client.mjs.js +0 -1
  145. package/dist/1641.cocolight-api-client.mjs.js +0 -1
  146. package/dist/1678.cocolight-api-client.mjs.js +0 -1
  147. package/dist/2041.cocolight-api-client.mjs.js +0 -1
  148. package/dist/2302.cocolight-api-client.mjs.js +0 -1
  149. package/dist/2313.cocolight-api-client.mjs.js +0 -1
  150. package/dist/2379.cocolight-api-client.mjs.js +0 -1
  151. package/dist/2439.cocolight-api-client.mjs.js +0 -1
  152. package/dist/2594.cocolight-api-client.mjs.js +0 -1
  153. package/dist/2766.cocolight-api-client.mjs.js +0 -1
  154. package/dist/2812.cocolight-api-client.mjs.js +0 -1
  155. package/dist/2918.cocolight-api-client.mjs.js +0 -1
  156. package/dist/3028.cocolight-api-client.mjs.js +0 -1
  157. package/dist/3330.cocolight-api-client.mjs.js +0 -1
  158. package/dist/3371.cocolight-api-client.mjs.js +0 -1
  159. package/dist/3401.cocolight-api-client.mjs.js +0 -1
  160. package/dist/3516.cocolight-api-client.mjs.js +0 -1
  161. package/dist/3593.cocolight-api-client.mjs.js +0 -1
  162. package/dist/3764.cocolight-api-client.mjs.js +0 -1
  163. package/dist/3873.cocolight-api-client.mjs.js +0 -1
  164. package/dist/3911.cocolight-api-client.mjs.js +0 -1
  165. package/dist/4031.cocolight-api-client.mjs.js +0 -1
  166. package/dist/4152.cocolight-api-client.mjs.js +0 -1
  167. package/dist/4203.cocolight-api-client.mjs.js +0 -1
  168. package/dist/424.cocolight-api-client.mjs.js +0 -1
  169. package/dist/435.cocolight-api-client.mjs.js +0 -1
  170. package/dist/4402.cocolight-api-client.mjs.js +0 -1
  171. package/dist/4425.cocolight-api-client.mjs.js +0 -1
  172. package/dist/4472.cocolight-api-client.mjs.js +0 -1
  173. package/dist/4914.cocolight-api-client.mjs.js +0 -1
  174. package/dist/4959.cocolight-api-client.mjs.js +0 -1
  175. package/dist/5100.cocolight-api-client.mjs.js +0 -1
  176. package/dist/5111.cocolight-api-client.mjs.js +0 -1
  177. package/dist/5286.cocolight-api-client.mjs.js +0 -1
  178. package/dist/5380.cocolight-api-client.mjs.js +0 -1
  179. package/dist/5383.cocolight-api-client.mjs.js +0 -1
  180. package/dist/5480.cocolight-api-client.mjs.js +0 -1
  181. package/dist/5541.cocolight-api-client.mjs.js +0 -1
  182. package/dist/5839.cocolight-api-client.mjs.js +0 -1
  183. package/dist/5862.cocolight-api-client.mjs.js +0 -1
  184. package/dist/5869.cocolight-api-client.mjs.js +0 -1
  185. package/dist/588.cocolight-api-client.mjs.js +0 -1
  186. package/dist/601.cocolight-api-client.mjs.js +0 -1
  187. package/dist/6012.cocolight-api-client.mjs.js +0 -1
  188. package/dist/6200.cocolight-api-client.mjs.js +0 -1
  189. package/dist/6369.cocolight-api-client.mjs.js +0 -1
  190. package/dist/7009.cocolight-api-client.mjs.js +0 -1
  191. package/dist/725.cocolight-api-client.mjs.js +0 -1
  192. package/dist/7339.cocolight-api-client.mjs.js +0 -1
  193. package/dist/7398.cocolight-api-client.mjs.js +0 -1
  194. package/dist/7888.cocolight-api-client.mjs.js +0 -1
  195. package/dist/7975.cocolight-api-client.mjs.js +0 -1
  196. package/dist/809.cocolight-api-client.mjs.js +0 -1
  197. package/dist/8300.cocolight-api-client.mjs.js +0 -1
  198. package/dist/8317.cocolight-api-client.mjs.js +0 -1
  199. package/dist/8525.cocolight-api-client.mjs.js +0 -1
  200. package/dist/8894.cocolight-api-client.mjs.js +0 -1
  201. package/dist/9301.cocolight-api-client.mjs.js +0 -1
  202. package/dist/9438.cocolight-api-client.mjs.js +0 -1
  203. package/dist/9478.cocolight-api-client.mjs.js +0 -1
  204. package/dist/9568.cocolight-api-client.mjs.js +0 -1
  205. package/dist/cocolight-api-client.mjs.js +0 -1
  206. package/src/Api.ts +0 -348
  207. package/src/ApiClient.ts +0 -1994
  208. package/src/EJSONType.ts +0 -103
  209. package/src/api/Action.ts +0 -665
  210. package/src/api/Answer.ts +0 -1392
  211. package/src/api/Badge.ts +0 -143
  212. package/src/api/BaseEntity.ts +0 -6338
  213. package/src/api/Classified.ts +0 -175
  214. package/src/api/Comment.ts +0 -280
  215. package/src/api/EndpointApi.ts +0 -2270
  216. package/src/api/EndpointApi.types.ts +0 -6566
  217. package/src/api/EntityRegistry.ts +0 -324
  218. package/src/api/Event.ts +0 -360
  219. package/src/api/Form.ts +0 -282
  220. package/src/api/News.ts +0 -547
  221. package/src/api/Notifications.ts +0 -196
  222. package/src/api/Organization.ts +0 -771
  223. package/src/api/Poi.ts +0 -242
  224. package/src/api/Project.ts +0 -545
  225. package/src/api/User.ts +0 -1889
  226. package/src/api/UserApi.ts +0 -192
  227. package/src/api/serverDataType/Action.ts +0 -177
  228. package/src/api/serverDataType/Answer.ts +0 -106
  229. package/src/api/serverDataType/Classified.ts +0 -152
  230. package/src/api/serverDataType/Comment.ts +0 -88
  231. package/src/api/serverDataType/Country.ts +0 -1
  232. package/src/api/serverDataType/Event.ts +0 -112
  233. package/src/api/serverDataType/Form.ts +0 -157
  234. package/src/api/serverDataType/News.ts +0 -138
  235. package/src/api/serverDataType/Notification.ts +0 -81
  236. package/src/api/serverDataType/Organization.ts +0 -111
  237. package/src/api/serverDataType/Poi.ts +0 -75
  238. package/src/api/serverDataType/Project.ts +0 -115
  239. package/src/api/serverDataType/User.ts +0 -112
  240. package/src/api/serverDataType/Zone.ts +0 -33
  241. package/src/api/serverDataType/common.ts +0 -84
  242. package/src/costum/normalize.ts +0 -7
  243. package/src/costum/registry.ts +0 -138
  244. package/src/costum/runtime-map.ts +0 -221
  245. package/src/costum/runtime.ts +0 -274
  246. package/src/costum/schemas/CercleTravailleursSociauxLiberauxLaPlumeSociale.ts +0 -19
  247. package/src/costum/schemas/FabEn.ts +0 -19
  248. package/src/costum/schemas/LivingLabInnovationSocialeBraspanon.ts +0 -19
  249. package/src/costum/schemas/alfph.ts +0 -27
  250. package/src/costum/schemas/campagne.ts +0 -19
  251. package/src/costum/schemas/chtitube.ts +0 -19
  252. package/src/costum/schemas/circuitCourt.ts +0 -19
  253. package/src/costum/schemas/cmcasHauteBretagne.ts +0 -19
  254. package/src/costum/schemas/coFinancementTierslieux.ts +0 -27
  255. package/src/costum/schemas/coeurNumerique.ts +0 -19
  256. package/src/costum/schemas/communLundi.ts +0 -19
  257. package/src/costum/schemas/cressReunion.ts +0 -35
  258. package/src/costum/schemas/cressReunionNetwork.ts +0 -35
  259. package/src/costum/schemas/ctenat.ts +0 -43
  260. package/src/costum/schemas/cyberReunion.ts +0 -19
  261. package/src/costum/schemas/ekisphere.ts +0 -35
  262. package/src/costum/schemas/equipementsSportifs974.ts +0 -19
  263. package/src/costum/schemas/federationDesCae.ts +0 -19
  264. package/src/costum/schemas/formationGenerique.ts +0 -35
  265. package/src/costum/schemas/franceTierslieux.ts +0 -19
  266. package/src/costum/schemas/hinaura.ts +0 -27
  267. package/src/costum/schemas/hubmayotte.ts +0 -19
  268. package/src/costum/schemas/hubnouvellecaledonie.ts +0 -19
  269. package/src/costum/schemas/hubpolynesiefrancaise.ts +0 -19
  270. package/src/costum/schemas/hubreunion.ts +0 -19
  271. package/src/costum/schemas/hubterritoires.ts +0 -19
  272. package/src/costum/schemas/hubwallisetfutuna.ts +0 -19
  273. package/src/costum/schemas/hva.ts +0 -27
  274. package/src/costum/schemas/ibv2.ts +0 -19
  275. package/src/costum/schemas/institutBleu.ts +0 -19
  276. package/src/costum/schemas/journalInsoumisChambery.ts +0 -27
  277. package/src/costum/schemas/kpacite.ts +0 -19
  278. package/src/costum/schemas/laCompagnieDesTierslieux.ts +0 -43
  279. package/src/costum/schemas/laMaisonDesFaiseurs.ts +0 -19
  280. package/src/costum/schemas/laReunionPourUnNumeriqueInclusif.ts +0 -19
  281. package/src/costum/schemas/laSemaineDesTierslieux.ts +0 -19
  282. package/src/costum/schemas/labEnCommuns.ts +0 -19
  283. package/src/costum/schemas/lakou.ts +0 -27
  284. package/src/costum/schemas/lesCommunsDesTierslieux.ts +0 -19
  285. package/src/costum/schemas/mayottePourUnNumeriqueInclusif.ts +0 -19
  286. package/src/costum/schemas/meir.ts +0 -27
  287. package/src/costum/schemas/navigatorDesTierslieux.ts +0 -19
  288. package/src/costum/schemas/notragora.ts +0 -27
  289. package/src/costum/schemas/nouvellecaledoniePourUnNumeriqueInclusif.ts +0 -19
  290. package/src/costum/schemas/openAtlas.ts +0 -19
  291. package/src/costum/schemas/polynesieFrancaisePourUnNumeriqueInclusif.ts +0 -19
  292. package/src/costum/schemas/prdr.ts +0 -19
  293. package/src/costum/schemas/reseauTierslieux.ts +0 -19
  294. package/src/costum/schemas/rfflabs.ts +0 -19
  295. package/src/costum/schemas/ries.ts +0 -19
  296. package/src/costum/schemas/siteDuPactePourLaTransition.ts +0 -27
  297. package/src/costum/schemas/sportSanteBienetre.ts +0 -43
  298. package/src/costum/schemas/suppa.ts +0 -19
  299. package/src/costum/schemas/terramies.ts +0 -19
  300. package/src/costum/schemas/testeTplFormation.ts +0 -35
  301. package/src/costum/schemas/tierslieuxbelgique.ts +0 -19
  302. package/src/costum/schemas/tierslieuxorg1.ts +0 -35
  303. package/src/costum/schemas/transiter.ts +0 -35
  304. package/src/costum/schemas/vhelioPeiTour2025.ts +0 -19
  305. package/src/costum/schemas/wallisetfutunaPourUnNumeriqueInclusif.ts +0 -19
  306. package/src/costum/symbol.ts +0 -26
  307. package/src/costum/types.ts +0 -895
  308. package/src/endpoints.module.ts +0 -4253
  309. package/src/error.ts +0 -86
  310. package/src/forms/entityForm.ts +0 -142
  311. package/src/index.ts +0 -161
  312. package/src/mixin/UserMixin.ts +0 -4
  313. package/src/types/api-responses.ts +0 -217
  314. package/src/types/entities.ts +0 -58
  315. package/src/types/error-guards.ts +0 -230
  316. package/src/types/index.ts +0 -41
  317. package/src/types/payloads.ts +0 -21
  318. package/src/types/transforms.ts +0 -119
  319. package/src/utils/FileOfflineStorageStrategy.node.ts +0 -50
  320. package/src/utils/FileStorageStrategy.node.ts +0 -63
  321. package/src/utils/MultiServerFileStorageStrategy.node.ts +0 -67
  322. package/src/utils/MultiServerTokenStorageStrategy.ts +0 -139
  323. package/src/utils/OfflineClientManager.ts +0 -216
  324. package/src/utils/OfflineQueueStorageStrategy.ts +0 -47
  325. package/src/utils/TokenStorage.ts +0 -77
  326. package/src/utils/compat.ts +0 -12
  327. package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +0 -35
  328. package/src/utils/createDefaultOfflineStrategy.ts +0 -34
  329. package/src/utils/createDefaultTokenStorageStrategy.ts +0 -33
  330. package/src/utils/reactive.ts +0 -243
  331. package/src/utils/stream-utils.node.ts +0 -12
@@ -1,139 +0,0 @@
1
- import { TokenStorageStrategy } from "./TokenStorage.js";
2
-
3
- export abstract class MultiServerTokenStorageStrategy extends TokenStorageStrategy {
4
- protected _currentBaseURL: string | null = null;
5
-
6
- constructor() {
7
- super();
8
- }
9
-
10
- use(baseURL: string): void {
11
- if (!baseURL) throw new Error("baseURL est requis");
12
- this._currentBaseURL = baseURL.replace(/\/+$/, "");
13
- }
14
-
15
- protected _ensureContext(): void {
16
- if (!this._currentBaseURL) throw new Error("baseURL non défini. Appelez use(baseURL)");
17
- }
18
-
19
- protected _requireBaseURL(): string {
20
- this._ensureContext();
21
- return this._currentBaseURL!;
22
- }
23
-
24
- abstract getServers(): string[];
25
- abstract exportAll(): Record<string, { accessToken?: string | null; refreshToken?: string | null }>;
26
-
27
- }
28
-
29
- export class MultiServerMemoryStorageStrategy extends MultiServerTokenStorageStrategy {
30
- private _storage = new Map<string, { accessToken?: string | null; refreshToken?: string | null }>();
31
-
32
- constructor() {
33
- super();
34
- }
35
-
36
- getAccessToken(): string | null {
37
- const base = this._requireBaseURL();
38
- return this._storage.get(base)?.accessToken ?? null;
39
- }
40
-
41
- setAccessToken(token: string | null): void {
42
- const base = this._requireBaseURL();
43
- const current = this._storage.get(base) || {};
44
- this._storage.set(base, { ...current, accessToken: token });
45
- }
46
-
47
- getRefreshToken(): string | null {
48
- const base = this._requireBaseURL();
49
- return this._storage.get(base)?.refreshToken ?? null;
50
- }
51
-
52
- setRefreshToken(token: string | null): void {
53
- const base = this._requireBaseURL();
54
- const current = this._storage.get(base) || {};
55
- this._storage.set(base, { ...current, refreshToken: token });
56
- }
57
-
58
- clear(): void {
59
- const base = this._requireBaseURL();
60
- this._storage.delete(base);
61
- }
62
-
63
- getServers(): string[] {
64
- return Array.from(this._storage.keys());
65
- }
66
-
67
- exportAll(): Record<string, { accessToken?: string | null; refreshToken?: string | null }> {
68
- return Object.fromEntries(this._storage.entries());
69
- }
70
- }
71
-
72
- export class MultiServerLocalStorageStrategy extends MultiServerTokenStorageStrategy {
73
- public readonly prefix: string;
74
-
75
- constructor(prefix: string = "cocolight") {
76
- super();
77
- this.prefix = prefix;
78
- }
79
-
80
- private _key(baseURL: string): string {
81
- return `${this.prefix}_tokens_${baseURL}`;
82
- }
83
-
84
- private _getData(): any {
85
- this._ensureContext();
86
- if (typeof localStorage === "undefined") return {};
87
- const raw = localStorage.getItem(this._key(this._currentBaseURL!));
88
- return raw ? JSON.parse(raw) : {};
89
- }
90
-
91
- private _setData(data: any): void {
92
- if (typeof localStorage === "undefined") return;
93
- localStorage.setItem(this._key(this._currentBaseURL!), JSON.stringify(data));
94
- }
95
-
96
- getAccessToken(): string | null {
97
- return this._getData().accessToken ?? null;
98
- }
99
-
100
- setAccessToken(token: string | null): void {
101
- const data = this._getData();
102
- data.accessToken = token;
103
- this._setData(data);
104
- }
105
-
106
- getRefreshToken(): string | null {
107
- return this._getData().refreshToken ?? null;
108
- }
109
-
110
- setRefreshToken(token: string | null): void {
111
- const data = this._getData();
112
- data.refreshToken = token;
113
- this._setData(data);
114
- }
115
-
116
- clear(): void {
117
- if (typeof localStorage === "undefined") return;
118
- localStorage.removeItem(this._key(this._currentBaseURL!));
119
- }
120
-
121
- getServers(): string[] {
122
- if (typeof localStorage === "undefined") return [];
123
- const keys = Object.keys(localStorage);
124
- return keys
125
- .filter(k => k.startsWith(`${this.prefix}_tokens_`))
126
- .map(k => k.replace(`${this.prefix}_tokens_`, ""));
127
- }
128
-
129
- exportAll(): Record<string, { accessToken?: string | null; refreshToken?: string | null }> {
130
- const result: Record<string, { accessToken?: string | null; refreshToken?: string | null }> = {};
131
-
132
- for (const baseURL of this.getServers()) {
133
- const key = this._key(baseURL);
134
- const raw = typeof localStorage !== "undefined" ? localStorage.getItem(key) : null;
135
- if (raw) result[baseURL] = JSON.parse(raw);
136
- }
137
- return result;
138
- }
139
- }
@@ -1,216 +0,0 @@
1
- // OfflineClientManager.ts
2
- import ApiClient from "../ApiClient.js";
3
- import { createDefaultOfflineStrategy } from "./createDefaultOfflineStrategy.js";
4
- import { OfflineQueueStorageStrategy } from "./OfflineQueueStorageStrategy.js";
5
-
6
- type OfflineQueueStorageStrategyAction = import("./OfflineQueueStorageStrategy.js").OfflineQueueStorageStrategy<OfflineAction>;
7
-
8
- /**
9
- * Métadonnées nécessaires pour rejouer une action offline sur le bon serveur.
10
- */
11
- interface OfflineActionMeta {
12
- baseURL: string;
13
- accessToken?: string | null;
14
- refreshToken?: string | null;
15
- timestamp: number; // Epoch ms de l'enfilement.
16
- }
17
-
18
- /**
19
- * Options passées à l'appel de l'endpoint lors du replay.
20
- */
21
- interface OfflineActionOptions {
22
- transformResponseData?: boolean | ((...args: any[]) => any);
23
- validateResponseSchema?: boolean;
24
- }
25
-
26
- /**
27
- * Élément de la file d'attente offline.
28
- */
29
- export interface OfflineAction {
30
- constant: string; // Nom de l'endpoint à appeler.
31
- data: unknown; // Payload d'entrée (forme dépendante de l'endpoint).
32
- options?: OfflineActionOptions;
33
- meta: OfflineActionMeta;
34
- }
35
-
36
- /**
37
- * Options d'attache du gestionnaire offline.
38
- */
39
- interface AttachOptions {
40
- offlineStorageStrategy?: "auto" | "memory" | "localStorage" | "file";
41
- disableOfflineMonitoring?: boolean;
42
- interval?: number; // Intervalle de ping réseau (ms), relayé à startOfflineMonitoring.
43
- }
44
-
45
- export class OfflineClientManager {
46
- private _clients: Map<string, any>;
47
- private _client: any;
48
- private _offlineMode: boolean | undefined;
49
- private _pingInterval: ReturnType<typeof setInterval> | undefined;
50
- private _offlineQueueStorage: OfflineQueueStorageStrategyAction | undefined;
51
- private _offlineQueue: OfflineAction[];
52
- private _monitoringStarted: boolean | undefined;
53
-
54
- constructor(apiClient: any) {
55
- if (!apiClient || !(apiClient instanceof ApiClient)) {
56
- throw new Error("[OfflineClientManager] apiClient doit être une instance de ApiClient");
57
- }
58
- this._clients = new Map();
59
- this._client = apiClient;
60
- this._offlineMode = undefined;
61
- this._pingInterval = undefined;
62
- this._offlineQueueStorage = undefined;
63
- this._offlineQueue = [];
64
- this._monitoringStarted = undefined;
65
- }
66
-
67
- static async attachTo(apiClient: any, options: AttachOptions = {}): Promise<any> {
68
- apiClient._offlineClientManager = new OfflineClientManager(apiClient);
69
- const strategy = await createDefaultOfflineStrategy(options?.offlineStorageStrategy || "auto");
70
- await apiClient._offlineClientManager._initOfflineQueue(strategy);
71
- if (!options?.disableOfflineMonitoring) {
72
- apiClient._offlineClientManager.startOfflineMonitoring(options);
73
- }
74
- }
75
-
76
- async getClient(meta: OfflineActionMeta): Promise<any> {
77
- const key = `${meta.baseURL}|${meta.accessToken}`;
78
- if (this._clients.has(key)) return this._clients.get(key);
79
-
80
- const client = new ApiClient({
81
- baseURL: meta.baseURL,
82
- accessToken: meta.accessToken,
83
- refreshToken: meta.refreshToken,
84
- debug: this._client._debug,
85
- });
86
-
87
- this._clients.set(key, client);
88
- return client;
89
- }
90
-
91
- async replayAction(action: OfflineAction): Promise<any> {
92
- const client = await this.getClient(action.meta);
93
- try {
94
- const result = await client.callEndpoint(
95
- action.constant,
96
- action.data,
97
- action.options?.transformResponseData ?? true,
98
- action.options?.validateResponseSchema ?? true
99
- );
100
- this._client._logger.info(`[OfflineReplay] Succès ${action.constant} sur ${action.meta.baseURL}`);
101
- return result;
102
- } catch (err) {
103
- this._client._logger.error(`[OfflineReplay] Échec ${action.constant}`, (err as Error).message);
104
- throw err;
105
- }
106
- }
107
-
108
- startOfflineMonitoring({ interval = 30000, disableOfflineMonitoring = false }: Pick<AttachOptions, "interval" | "disableOfflineMonitoring"> = {}) {
109
- if (disableOfflineMonitoring || this._monitoringStarted) return;
110
-
111
- this._monitoringStarted = true;
112
- this._offlineMode = typeof window !== "undefined" && typeof navigator !== "undefined" && !navigator.onLine;
113
-
114
- if (typeof window !== "undefined") {
115
- window.addEventListener("online", () => this.setOfflineMode(false));
116
- window.addEventListener("offline", () => this.setOfflineMode(true));
117
- }
118
-
119
- this._pingInterval = setInterval(async () => {
120
- const wasOffline = this._offlineMode;
121
- try {
122
- await this._client._client.head("/api/cocolight/infoserver", { timeout: 5000 });
123
- if (wasOffline) this.setOfflineMode(false);
124
-
125
- } catch {
126
- this._client._logger.error("[OfflineMonitor] ping() échoué → passage en offline");
127
- this.setOfflineMode(true);
128
- }
129
- }, interval);
130
- }
131
-
132
- setOfflineMode(isOffline: boolean) {
133
- if (this._offlineMode === isOffline) return;
134
- this._offlineMode = isOffline;
135
- if (typeof this._client.emit === "function") {
136
- this._client.emit("offlineModeChanged", isOffline);
137
- }
138
- this._client._logger.info(`[ApiClient] Mode offline : ${isOffline} (set depuis monitoring)`);
139
-
140
- if (!isOffline && typeof this._replayOfflineQueue === "function") {
141
- this._replayOfflineQueue();
142
- }
143
- }
144
-
145
- isOffline(): boolean {
146
- return !!this._offlineMode;
147
- }
148
-
149
- async _enqueueOfflineAction({ constant, data, options = {} }: { constant: string; data: unknown; options?: OfflineActionOptions }): Promise<any> {
150
- if (!this._offlineQueueStorage) {
151
- throw new Error("[OfflineClientManager] _offlineQueueStorage non initialisé");
152
- }
153
- const hasToken = this._client.getToken() || this._client.getRefreshToken();
154
- const endpoint = this._client._endpoints.find((e: any) => e.constant === constant);
155
- const authPolicy = endpoint?.authPolicy || (endpoint?.auth === "none" ? "none" : "required");
156
- if (authPolicy === "required" && !hasToken) {
157
- this._client._logger.warn(`[Offline] Action ignorée : token requis mais absent (${constant})`);
158
- return;
159
- }
160
-
161
- const action: OfflineAction = {
162
- constant,
163
- data,
164
- options,
165
- meta: {
166
- baseURL: this._client._baseURL,
167
- accessToken: this._client.getToken(),
168
- refreshToken: this._client.getRefreshToken(),
169
- timestamp: Date.now()
170
- }
171
- };
172
-
173
- this._offlineQueue.push(action);
174
- await this._offlineQueueStorage.saveQueue(this._offlineQueue);
175
- this._client._logger.info(`[Offline] Action mise en file : ${constant}`);
176
- }
177
-
178
- async _replayOfflineQueue(): Promise<any> {
179
- if (!this._offlineQueueStorage) {
180
- throw new Error("[OfflineClientManager] _offlineQueueStorage non initialisé");
181
- }
182
- const queueCopy = [...this._offlineQueue];
183
- this._offlineQueue = [];
184
- await this._offlineQueueStorage.saveQueue([]);
185
-
186
- for (const action of queueCopy) {
187
- const endpoint = this._client._endpoints.find((e: any) => e.constant === action.constant);
188
- const authPolicy = endpoint?.authPolicy || (endpoint?.auth === "none" ? "none" : "required");
189
- const hasToken = action.meta.accessToken || action.meta.refreshToken;
190
-
191
- if (authPolicy === "required" && !hasToken) {
192
- this._client._logger.warn(`[Offline] Rejetée : token requis manquant (${action.constant})`);
193
- continue;
194
- }
195
-
196
- try {
197
- await this.replayAction(action);
198
- } catch (e) {
199
- this._client._logger.error("[Offline] Relecture échouée :", (e as Error).message);
200
- this._offlineQueue.push(action); // requeue si erreur
201
- }
202
- }
203
-
204
- await this._offlineQueueStorage.saveQueue(this._offlineQueue);
205
- }
206
-
207
- async _initOfflineQueue(storageStrategy: OfflineQueueStorageStrategyAction): Promise<any> {
208
- if(!storageStrategy || !(storageStrategy instanceof OfflineQueueStorageStrategy)) {
209
- throw new Error("[OfflineClientManager] storageStrategy doit être une instance de OfflineQueueStorageStrategy");
210
- }
211
- this._offlineQueueStorage = storageStrategy;
212
- this._offlineQueue = await storageStrategy.loadQueue();
213
- }
214
- }
215
-
216
- export default OfflineClientManager;
@@ -1,47 +0,0 @@
1
- export abstract class OfflineQueueStorageStrategy<T = any> {
2
- abstract loadQueue(): Promise<T[]>;
3
- abstract saveQueue(queue: T[]): Promise<void>;
4
- }
5
-
6
- export class MemoryOfflineStorage<T = any> extends OfflineQueueStorageStrategy<T> {
7
- private _queue: T[] = [];
8
-
9
- constructor() {
10
- super();
11
- }
12
-
13
- async loadQueue(): Promise<T[]> {
14
- return this._queue;
15
- }
16
-
17
- async saveQueue(queue: T[]): Promise<void> {
18
- this._queue = [...queue];
19
- }
20
- }
21
-
22
- export class LocalStorageOfflineStorage<T = any> extends OfflineQueueStorageStrategy<T> {
23
- public readonly key: string;
24
-
25
- constructor(key: string = "cocolight-api-offline-queue") {
26
- super();
27
- this.key = key;
28
- }
29
-
30
- async loadQueue(): Promise<T[]> {
31
- try {
32
- const raw = localStorage.getItem(this.key);
33
- const parsed: T[] | null = raw ? JSON.parse(raw) : null;
34
- return parsed ?? [];
35
- } catch {
36
- return [];
37
- }
38
- }
39
-
40
- async saveQueue(queue: T[]): Promise<void> {
41
- try {
42
- localStorage.setItem(this.key, JSON.stringify(queue));
43
- } catch (e) {
44
- console.warn("[Offline] Échec du stockage localStorage", e);
45
- }
46
- }
47
- }
@@ -1,77 +0,0 @@
1
- export abstract class TokenStorageStrategy {
2
- abstract getAccessToken(): string | null;
3
- abstract setAccessToken(token: string | null): void;
4
- abstract getRefreshToken(): string | null;
5
- abstract setRefreshToken(token: string | null): void;
6
- abstract clear(): void;
7
- }
8
-
9
- export class MemoryStorageStrategy extends TokenStorageStrategy {
10
- private _accessToken: string | null = null;
11
- private _refreshToken: string | null = null;
12
-
13
- constructor() {
14
- super();
15
- }
16
-
17
- getAccessToken(): string | null {
18
- return this._accessToken;
19
- }
20
-
21
- setAccessToken(token: string | null): void {
22
- this._accessToken = token;
23
- }
24
-
25
- getRefreshToken(): string | null {
26
- return this._refreshToken;
27
- }
28
-
29
- setRefreshToken(token: string | null): void {
30
- this._refreshToken = token;
31
- }
32
-
33
- clear(): void {
34
- this._accessToken = null;
35
- this._refreshToken = null;
36
- }
37
- }
38
-
39
- export class LocalStorageStrategy extends TokenStorageStrategy {
40
- public readonly prefix: string;
41
-
42
- constructor(prefix: string = "cocolight") {
43
- super();
44
- this.prefix = prefix;
45
- }
46
-
47
- getAccessToken(): string | null {
48
- return typeof localStorage !== "undefined"
49
- ? localStorage.getItem(`${this.prefix}_accessToken`)
50
- : null;
51
- }
52
-
53
- setAccessToken(token: string | null): void {
54
- if (typeof localStorage !== "undefined") {
55
- localStorage.setItem(`${this.prefix}_accessToken`, token ?? "");
56
- }
57
- }
58
-
59
- getRefreshToken(): string | null {
60
- return typeof localStorage !== "undefined"
61
- ? localStorage.getItem(`${this.prefix}_refreshToken`)
62
- : null;
63
- }
64
-
65
- setRefreshToken(token: string | null): void {
66
- if (typeof localStorage !== "undefined") {
67
- localStorage.setItem(`${this.prefix}_refreshToken`, token ?? "");
68
- }
69
- }
70
-
71
- clear(): void {
72
- if (typeof localStorage !== "undefined") {
73
- localStorage.removeItem(`${this.prefix}_accessToken`);
74
- localStorage.removeItem(`${this.prefix}_refreshToken`);
75
- }
76
- }
77
- }
@@ -1,12 +0,0 @@
1
- // utils/compat.ts - Compatibility layer for default imports
2
- const _def = <T>(m: T & { default?: any }): any => (m && m.default) ? m.default : m;
3
-
4
- import * as AjvNS from "ajv";
5
- import * as addFormatsNS from "ajv-formats";
6
- import * as EJSONNS from "ejson";
7
- import * as pinoNS from "pino";
8
-
9
- export const Ajv = _def(AjvNS); // constructible
10
- export const addFormats = _def(addFormatsNS); // callable
11
- export const pino = _def(pinoNS); // callable
12
- export const EJSON = _def(EJSONNS); // default safe
@@ -1,35 +0,0 @@
1
- import {
2
- MultiServerMemoryStorageStrategy,
3
- MultiServerLocalStorageStrategy,
4
- type MultiServerTokenStorageStrategy,
5
- } from "./MultiServerTokenStorageStrategy.js";
6
-
7
- export async function createDefaultMultiServerTokenStorageStrategy(
8
- strategyType: "memory" | "localStorage" | "file" | "auto" = "auto"
9
- ): Promise<MultiServerTokenStorageStrategy> {
10
- if (strategyType === "memory") {
11
- return new MultiServerMemoryStorageStrategy();
12
- }
13
-
14
- if (strategyType === "localStorage") {
15
- if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
16
- return new MultiServerLocalStorageStrategy();
17
- }
18
- throw new Error("localStorage n'est pas disponible dans cet environnement.");
19
- }
20
-
21
- if (strategyType === "file") {
22
- if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
23
- throw new Error("Le stockage fichier n'est pas disponible côté navigateur.");
24
- }
25
- const { MultiServerFileStorageStrategy } = await import("./MultiServerFileStorageStrategy.node.js");
26
- return new MultiServerFileStorageStrategy();
27
- }
28
-
29
- // auto
30
- if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
31
- return new MultiServerLocalStorageStrategy();
32
- }
33
- const { MultiServerFileStorageStrategy } = await import("./MultiServerFileStorageStrategy.node.js");
34
- return new MultiServerFileStorageStrategy();
35
- }
@@ -1,34 +0,0 @@
1
- import { LocalStorageOfflineStorage, MemoryOfflineStorage, type OfflineQueueStorageStrategy } from "./OfflineQueueStorageStrategy.js";
2
-
3
- export async function createDefaultOfflineStrategy<T = any>(
4
- offlineStorageStrategy: "auto" | "memory" | "localStorage" | "file" = "auto"
5
- ): Promise<OfflineQueueStorageStrategy<T>> {
6
- if (offlineStorageStrategy === "memory") {
7
- return new MemoryOfflineStorage();
8
- }
9
- if (offlineStorageStrategy === "localStorage") {
10
- if (typeof window !== "undefined" && window.localStorage) {
11
- return new LocalStorageOfflineStorage();
12
- } else {
13
- throw new Error("localStorage is not available in this environment.");
14
- }
15
- }
16
- if (offlineStorageStrategy === "file") {
17
- if (typeof window !== "undefined" && window.localStorage) {
18
- throw new Error("file storage is not available in this environment.");
19
- }
20
- const { FileOfflineStorage } = await import("./FileOfflineStorageStrategy.node.js");
21
- return new FileOfflineStorage();
22
- }
23
- if (offlineStorageStrategy === "auto") {
24
- if (typeof window !== "undefined" && window.localStorage) {
25
- return new LocalStorageOfflineStorage();
26
- } else {
27
- const { FileOfflineStorage } = await import("./FileOfflineStorageStrategy.node.js");
28
- return new FileOfflineStorage();
29
- }
30
- }
31
-
32
- // Handle unexpected strategy values
33
- throw new Error(`Unsupported offline storage strategy: ${offlineStorageStrategy}`);
34
- }
@@ -1,33 +0,0 @@
1
- import { LocalStorageStrategy, MemoryStorageStrategy } from "./TokenStorage.js";
2
-
3
- import type { TokenStorageStrategy } from "./TokenStorage.js";
4
-
5
- export async function createDefaultTokenStorageStrategy(
6
- tokenStorageStrategy: "memory" | "localStorage" | "file" | "auto" = "auto"
7
- ): Promise<TokenStorageStrategy> {
8
- if (tokenStorageStrategy === "memory") {
9
- return new MemoryStorageStrategy();
10
- }
11
-
12
- if (tokenStorageStrategy === "localStorage") {
13
- if (typeof window !== "undefined" && window.localStorage) {
14
- return new LocalStorageStrategy();
15
- }
16
- throw new Error("localStorage is not available in this environment.");
17
- }
18
-
19
- if (tokenStorageStrategy === "file") {
20
- if (typeof window !== "undefined" && window.localStorage) {
21
- throw new Error("file storage is not available in this environment.");
22
- }
23
- const { FileStorageStrategy } = await import("./FileStorageStrategy.node.js");
24
- return new FileStorageStrategy();
25
- }
26
-
27
- // 'auto'
28
- if (typeof window !== "undefined" && window.localStorage) {
29
- return new LocalStorageStrategy();
30
- }
31
- const { FileStorageStrategy } = await import("./FileStorageStrategy.node.js");
32
- return new FileStorageStrategy();
33
- }