@communecter/cocolight-api-client 1.0.155 → 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 (329) 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 +2 -0
  138. package/types/utils/OfflineClientManager.d.ts +8 -0
  139. package/dist/1035.cocolight-api-client.mjs.js +0 -1
  140. package/dist/1483.cocolight-api-client.mjs.js +0 -1
  141. package/dist/1491.cocolight-api-client.mjs.js +0 -1
  142. package/dist/1494.cocolight-api-client.mjs.js +0 -1
  143. package/dist/1641.cocolight-api-client.mjs.js +0 -1
  144. package/dist/1678.cocolight-api-client.mjs.js +0 -1
  145. package/dist/2041.cocolight-api-client.mjs.js +0 -1
  146. package/dist/2302.cocolight-api-client.mjs.js +0 -1
  147. package/dist/2313.cocolight-api-client.mjs.js +0 -1
  148. package/dist/2379.cocolight-api-client.mjs.js +0 -1
  149. package/dist/2439.cocolight-api-client.mjs.js +0 -1
  150. package/dist/2594.cocolight-api-client.mjs.js +0 -1
  151. package/dist/2766.cocolight-api-client.mjs.js +0 -1
  152. package/dist/2812.cocolight-api-client.mjs.js +0 -1
  153. package/dist/2918.cocolight-api-client.mjs.js +0 -1
  154. package/dist/3028.cocolight-api-client.mjs.js +0 -1
  155. package/dist/3330.cocolight-api-client.mjs.js +0 -1
  156. package/dist/3371.cocolight-api-client.mjs.js +0 -1
  157. package/dist/3401.cocolight-api-client.mjs.js +0 -1
  158. package/dist/3516.cocolight-api-client.mjs.js +0 -1
  159. package/dist/3593.cocolight-api-client.mjs.js +0 -1
  160. package/dist/3764.cocolight-api-client.mjs.js +0 -1
  161. package/dist/3873.cocolight-api-client.mjs.js +0 -1
  162. package/dist/3911.cocolight-api-client.mjs.js +0 -1
  163. package/dist/4031.cocolight-api-client.mjs.js +0 -1
  164. package/dist/4152.cocolight-api-client.mjs.js +0 -1
  165. package/dist/4203.cocolight-api-client.mjs.js +0 -1
  166. package/dist/424.cocolight-api-client.mjs.js +0 -1
  167. package/dist/435.cocolight-api-client.mjs.js +0 -1
  168. package/dist/4402.cocolight-api-client.mjs.js +0 -1
  169. package/dist/4425.cocolight-api-client.mjs.js +0 -1
  170. package/dist/4472.cocolight-api-client.mjs.js +0 -1
  171. package/dist/4914.cocolight-api-client.mjs.js +0 -1
  172. package/dist/4959.cocolight-api-client.mjs.js +0 -1
  173. package/dist/5100.cocolight-api-client.mjs.js +0 -1
  174. package/dist/5111.cocolight-api-client.mjs.js +0 -1
  175. package/dist/5286.cocolight-api-client.mjs.js +0 -1
  176. package/dist/5380.cocolight-api-client.mjs.js +0 -1
  177. package/dist/5383.cocolight-api-client.mjs.js +0 -1
  178. package/dist/5480.cocolight-api-client.mjs.js +0 -1
  179. package/dist/5541.cocolight-api-client.mjs.js +0 -1
  180. package/dist/5839.cocolight-api-client.mjs.js +0 -1
  181. package/dist/5862.cocolight-api-client.mjs.js +0 -1
  182. package/dist/5869.cocolight-api-client.mjs.js +0 -1
  183. package/dist/588.cocolight-api-client.mjs.js +0 -1
  184. package/dist/601.cocolight-api-client.mjs.js +0 -1
  185. package/dist/6012.cocolight-api-client.mjs.js +0 -1
  186. package/dist/6200.cocolight-api-client.mjs.js +0 -1
  187. package/dist/6369.cocolight-api-client.mjs.js +0 -1
  188. package/dist/7009.cocolight-api-client.mjs.js +0 -1
  189. package/dist/725.cocolight-api-client.mjs.js +0 -1
  190. package/dist/7339.cocolight-api-client.mjs.js +0 -1
  191. package/dist/7398.cocolight-api-client.mjs.js +0 -1
  192. package/dist/7888.cocolight-api-client.mjs.js +0 -1
  193. package/dist/7975.cocolight-api-client.mjs.js +0 -1
  194. package/dist/809.cocolight-api-client.mjs.js +0 -1
  195. package/dist/8300.cocolight-api-client.mjs.js +0 -1
  196. package/dist/8317.cocolight-api-client.mjs.js +0 -1
  197. package/dist/8525.cocolight-api-client.mjs.js +0 -1
  198. package/dist/8894.cocolight-api-client.mjs.js +0 -1
  199. package/dist/9301.cocolight-api-client.mjs.js +0 -1
  200. package/dist/9438.cocolight-api-client.mjs.js +0 -1
  201. package/dist/9478.cocolight-api-client.mjs.js +0 -1
  202. package/dist/9568.cocolight-api-client.mjs.js +0 -1
  203. package/dist/cocolight-api-client.mjs.js +0 -1
  204. package/src/Api.ts +0 -348
  205. package/src/ApiClient.ts +0 -1994
  206. package/src/EJSONType.ts +0 -103
  207. package/src/api/Action.ts +0 -665
  208. package/src/api/Answer.ts +0 -1392
  209. package/src/api/Badge.ts +0 -143
  210. package/src/api/BaseEntity.ts +0 -6384
  211. package/src/api/Classified.ts +0 -175
  212. package/src/api/Comment.ts +0 -280
  213. package/src/api/EndpointApi.ts +0 -2270
  214. package/src/api/EndpointApi.types.ts +0 -6566
  215. package/src/api/EntityRegistry.ts +0 -324
  216. package/src/api/Event.ts +0 -360
  217. package/src/api/Form.ts +0 -282
  218. package/src/api/News.ts +0 -547
  219. package/src/api/Notifications.ts +0 -196
  220. package/src/api/Organization.ts +0 -771
  221. package/src/api/Poi.ts +0 -242
  222. package/src/api/Project.ts +0 -545
  223. package/src/api/User.ts +0 -1889
  224. package/src/api/UserApi.ts +0 -192
  225. package/src/api/serverDataType/Action.ts +0 -177
  226. package/src/api/serverDataType/Answer.ts +0 -106
  227. package/src/api/serverDataType/Classified.ts +0 -152
  228. package/src/api/serverDataType/Comment.ts +0 -88
  229. package/src/api/serverDataType/Country.ts +0 -1
  230. package/src/api/serverDataType/Event.ts +0 -112
  231. package/src/api/serverDataType/Form.ts +0 -157
  232. package/src/api/serverDataType/News.ts +0 -138
  233. package/src/api/serverDataType/Notification.ts +0 -81
  234. package/src/api/serverDataType/Organization.ts +0 -111
  235. package/src/api/serverDataType/Poi.ts +0 -75
  236. package/src/api/serverDataType/Project.ts +0 -115
  237. package/src/api/serverDataType/User.ts +0 -112
  238. package/src/api/serverDataType/Zone.ts +0 -33
  239. package/src/api/serverDataType/common.ts +0 -84
  240. package/src/costum/normalize.ts +0 -7
  241. package/src/costum/registry.ts +0 -138
  242. package/src/costum/runtime-map.ts +0 -221
  243. package/src/costum/runtime.ts +0 -274
  244. package/src/costum/schemas/CercleTravailleursSociauxLiberauxLaPlumeSociale.ts +0 -19
  245. package/src/costum/schemas/FabEn.ts +0 -19
  246. package/src/costum/schemas/LivingLabInnovationSocialeBraspanon.ts +0 -19
  247. package/src/costum/schemas/alfph.ts +0 -27
  248. package/src/costum/schemas/campagne.ts +0 -19
  249. package/src/costum/schemas/chtitube.ts +0 -19
  250. package/src/costum/schemas/circuitCourt.ts +0 -19
  251. package/src/costum/schemas/cmcasHauteBretagne.ts +0 -19
  252. package/src/costum/schemas/coFinancementTierslieux.ts +0 -27
  253. package/src/costum/schemas/coeurNumerique.ts +0 -19
  254. package/src/costum/schemas/communLundi.ts +0 -19
  255. package/src/costum/schemas/cressReunion.ts +0 -35
  256. package/src/costum/schemas/cressReunionNetwork.ts +0 -35
  257. package/src/costum/schemas/ctenat.ts +0 -43
  258. package/src/costum/schemas/cyberReunion.ts +0 -19
  259. package/src/costum/schemas/ekisphere.ts +0 -35
  260. package/src/costum/schemas/equipementsSportifs974.ts +0 -19
  261. package/src/costum/schemas/federationDesCae.ts +0 -19
  262. package/src/costum/schemas/formationGenerique.ts +0 -35
  263. package/src/costum/schemas/franceTierslieux.ts +0 -19
  264. package/src/costum/schemas/hinaura.ts +0 -27
  265. package/src/costum/schemas/hubmayotte.ts +0 -19
  266. package/src/costum/schemas/hubnouvellecaledonie.ts +0 -19
  267. package/src/costum/schemas/hubpolynesiefrancaise.ts +0 -19
  268. package/src/costum/schemas/hubreunion.ts +0 -19
  269. package/src/costum/schemas/hubterritoires.ts +0 -19
  270. package/src/costum/schemas/hubwallisetfutuna.ts +0 -19
  271. package/src/costum/schemas/hva.ts +0 -27
  272. package/src/costum/schemas/ibv2.ts +0 -19
  273. package/src/costum/schemas/institutBleu.ts +0 -19
  274. package/src/costum/schemas/journalInsoumisChambery.ts +0 -27
  275. package/src/costum/schemas/kpacite.ts +0 -19
  276. package/src/costum/schemas/laCompagnieDesTierslieux.ts +0 -43
  277. package/src/costum/schemas/laMaisonDesFaiseurs.ts +0 -19
  278. package/src/costum/schemas/laReunionPourUnNumeriqueInclusif.ts +0 -19
  279. package/src/costum/schemas/laSemaineDesTierslieux.ts +0 -19
  280. package/src/costum/schemas/labEnCommuns.ts +0 -19
  281. package/src/costum/schemas/lakou.ts +0 -27
  282. package/src/costum/schemas/lesCommunsDesTierslieux.ts +0 -19
  283. package/src/costum/schemas/mayottePourUnNumeriqueInclusif.ts +0 -19
  284. package/src/costum/schemas/meir.ts +0 -27
  285. package/src/costum/schemas/navigatorDesTierslieux.ts +0 -19
  286. package/src/costum/schemas/notragora.ts +0 -27
  287. package/src/costum/schemas/nouvellecaledoniePourUnNumeriqueInclusif.ts +0 -19
  288. package/src/costum/schemas/openAtlas.ts +0 -19
  289. package/src/costum/schemas/polynesieFrancaisePourUnNumeriqueInclusif.ts +0 -19
  290. package/src/costum/schemas/prdr.ts +0 -19
  291. package/src/costum/schemas/reseauTierslieux.ts +0 -19
  292. package/src/costum/schemas/rfflabs.ts +0 -19
  293. package/src/costum/schemas/ries.ts +0 -19
  294. package/src/costum/schemas/siteDuPactePourLaTransition.ts +0 -27
  295. package/src/costum/schemas/sportSanteBienetre.ts +0 -43
  296. package/src/costum/schemas/suppa.ts +0 -19
  297. package/src/costum/schemas/terramies.ts +0 -19
  298. package/src/costum/schemas/testeTplFormation.ts +0 -35
  299. package/src/costum/schemas/tierslieuxbelgique.ts +0 -19
  300. package/src/costum/schemas/tierslieuxorg1.ts +0 -35
  301. package/src/costum/schemas/transiter.ts +0 -35
  302. package/src/costum/schemas/vhelioPeiTour2025.ts +0 -19
  303. package/src/costum/schemas/wallisetfutunaPourUnNumeriqueInclusif.ts +0 -19
  304. package/src/costum/symbol.ts +0 -26
  305. package/src/costum/types.ts +0 -895
  306. package/src/endpoints.module.ts +0 -4253
  307. package/src/error.ts +0 -86
  308. package/src/forms/entityForm.ts +0 -142
  309. package/src/index.ts +0 -161
  310. package/src/mixin/UserMixin.ts +0 -4
  311. package/src/types/api-responses.ts +0 -217
  312. package/src/types/entities.ts +0 -58
  313. package/src/types/error-guards.ts +0 -230
  314. package/src/types/index.ts +0 -41
  315. package/src/types/payloads.ts +0 -21
  316. package/src/types/transforms.ts +0 -119
  317. package/src/utils/FileOfflineStorageStrategy.node.ts +0 -50
  318. package/src/utils/FileStorageStrategy.node.ts +0 -63
  319. package/src/utils/MultiServerFileStorageStrategy.node.ts +0 -67
  320. package/src/utils/MultiServerTokenStorageStrategy.ts +0 -139
  321. package/src/utils/OfflineClientManager.ts +0 -216
  322. package/src/utils/OfflineQueueStorageStrategy.ts +0 -47
  323. package/src/utils/TokenStorage.ts +0 -77
  324. package/src/utils/compat.ts +0 -12
  325. package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +0 -35
  326. package/src/utils/createDefaultOfflineStrategy.ts +0 -34
  327. package/src/utils/createDefaultTokenStorageStrategy.ts +0 -33
  328. package/src/utils/reactive.ts +0 -243
  329. package/src/utils/stream-utils.node.ts +0 -12
@@ -1,230 +0,0 @@
1
- // types/error-guards.ts - Type guards et utilitaires pour la gestion d'erreurs
2
-
3
- import { ApiError, ApiClientError, ApiResponseError, ApiValidationError, ApiAuthenticationError, CircuitBreakerError } from "../error.js";
4
-
5
- import type { ApiErrorDetails, HttpStatusCode } from "./api-responses.js";
6
-
7
- /**
8
- * Type guard pour vérifier si une valeur est une Error
9
- */
10
- export function isError(value: unknown): value is Error {
11
- return value instanceof Error;
12
- }
13
-
14
- /**
15
- * Type guard pour vérifier si une valeur est une ApiError
16
- */
17
- export function isApiError(value: unknown): value is ApiError {
18
- return value instanceof ApiError;
19
- }
20
-
21
- /**
22
- * Type guard pour vérifier si une valeur est une ApiClientError
23
- */
24
- export function isApiClientError(value: unknown): value is ApiClientError {
25
- return value instanceof ApiClientError;
26
- }
27
-
28
- /**
29
- * Type guard pour vérifier si une valeur est une ApiResponseError
30
- */
31
- export function isApiResponseError(value: unknown): value is ApiResponseError {
32
- return value instanceof ApiResponseError;
33
- }
34
-
35
- /**
36
- * Type guard pour vérifier si une valeur est une ApiValidationError
37
- */
38
- export function isApiValidationError(value: unknown): value is ApiValidationError {
39
- return value instanceof ApiValidationError;
40
- }
41
-
42
- /**
43
- * Type guard pour vérifier si une valeur est une ApiAuthenticationError
44
- */
45
- export function isApiAuthenticationError(value: unknown): value is ApiAuthenticationError {
46
- return value instanceof ApiAuthenticationError;
47
- }
48
-
49
- /**
50
- * Type guard pour vérifier si une valeur est une CircuitBreakerError
51
- */
52
- export function isCircuitBreakerError(value: unknown): value is CircuitBreakerError {
53
- return value instanceof CircuitBreakerError;
54
- }
55
-
56
- /**
57
- * Type guard pour vérifier si une erreur a une propriété response (erreurs axios)
58
- */
59
- export function hasResponse(error: unknown): error is Error & { response: { status: number; data: any } } {
60
- return isError(error) && "response" in error &&
61
- typeof (error as any).response === "object" &&
62
- typeof (error as any).response.status === "number";
63
- }
64
-
65
- /**
66
- * Type guard pour vérifier si une erreur a un code de statut HTTP
67
- */
68
- export function hasStatusCode(error: unknown): error is Error & { status: HttpStatusCode } {
69
- return isError(error) && "status" in error &&
70
- typeof (error as any).status === "number";
71
- }
72
-
73
- /**
74
- * Utilitaire pour extraire le message d'erreur de façon type-safe
75
- */
76
- export function getErrorMessage(error: unknown): string {
77
- if (isError(error)) {
78
- return error.message;
79
- }
80
- if (typeof error === "string") {
81
- return error;
82
- }
83
- if (error && typeof error === "object" && "message" in error) {
84
- return String((error as any).message);
85
- }
86
- return "Unknown error";
87
- }
88
-
89
- /**
90
- * Utilitaire pour extraire le code de statut d'une erreur
91
- */
92
- export function getErrorStatusCode(error: unknown): HttpStatusCode | undefined {
93
- if (hasStatusCode(error)) {
94
- return error.status as HttpStatusCode;
95
- }
96
- if (hasResponse(error)) {
97
- return error.response.status as HttpStatusCode;
98
- }
99
- if (isApiError(error)) {
100
- return error.status as HttpStatusCode;
101
- }
102
- return undefined;
103
- }
104
-
105
- /**
106
- * Utilitaire pour extraire les détails d'erreur de façon type-safe
107
- */
108
- export function getErrorDetails(error: unknown): ApiErrorDetails | undefined {
109
- if (isApiError(error)) {
110
- return {
111
- code: error.status as HttpStatusCode,
112
- message: error.message,
113
- details: (error as any).responseData
114
- };
115
- }
116
-
117
- if (hasResponse(error)) {
118
- return {
119
- code: error.response.status as HttpStatusCode,
120
- message: getErrorMessage(error),
121
- details: error.response.data
122
- };
123
- }
124
-
125
- const status = getErrorStatusCode(error);
126
- if (status) {
127
- return {
128
- code: status,
129
- message: getErrorMessage(error)
130
- };
131
- }
132
-
133
- return undefined;
134
- }
135
-
136
- /**
137
- * Utilitaire pour créer une erreur typée
138
- */
139
- export function createTypedError(message: string, status: HttpStatusCode = 500, details?: any): ApiError {
140
- return new ApiError(message, status, details);
141
- }
142
-
143
- /**
144
- * Wrapper pour les fonctions qui peuvent lever des erreurs
145
- */
146
- export async function safeCall<T>(
147
- fn: () => Promise<T>,
148
- fallback?: T
149
- ): Promise<{ data: T; error: null } | { data: T | undefined; error: ApiErrorDetails }> {
150
- try {
151
- const data = await fn();
152
- return { data, error: null };
153
- } catch (error) {
154
- const errorDetails = getErrorDetails(error);
155
- return {
156
- data: fallback,
157
- error: errorDetails || {
158
- code: 500,
159
- message: getErrorMessage(error)
160
- }
161
- };
162
- }
163
- }
164
-
165
- /**
166
- * Type pour les résultats d'opérations sécurisées
167
- */
168
- export type SafeResult<T> =
169
- | { success: true; data: T; error: null }
170
- | { success: false; data: undefined; error: ApiErrorDetails };
171
-
172
- /**
173
- * Version améliorée de safeCall avec indicateur de succès
174
- */
175
- export async function trySafe<T>(fn: () => Promise<T>): Promise<SafeResult<T>> {
176
- try {
177
- const data = await fn();
178
- return { success: true, data, error: null };
179
- } catch (error) {
180
- const errorDetails = getErrorDetails(error);
181
- return {
182
- success: false,
183
- data: undefined,
184
- error: errorDetails || {
185
- code: 500,
186
- message: getErrorMessage(error)
187
- }
188
- };
189
- }
190
- }
191
-
192
- /**
193
- * Utilitaire pour valider et normaliser les erreurs
194
- */
195
- export function normalizeError(error: unknown): ApiError {
196
- if (isApiError(error)) {
197
- return error;
198
- }
199
-
200
- const message = getErrorMessage(error);
201
- const status = getErrorStatusCode(error) || 500;
202
- const details = hasResponse(error) ? error.response.data : undefined;
203
-
204
- return new ApiError(message, status, details);
205
- }
206
-
207
- /**
208
- * Type helper pour les fonctions qui peuvent lever des erreurs typées
209
- */
210
- export type ErrorProne<T> = () => Promise<T> | T;
211
-
212
- /**
213
- * Décorateur de méthode pour capturer et normaliser les erreurs
214
- */
215
- export function catchErrors<T extends any[], R>(
216
- target: any,
217
- propertyName: string,
218
- descriptor: TypedPropertyDescriptor<(...args: T) => Promise<R>>
219
- ) {
220
- const method = descriptor.value;
221
- if (!method) return;
222
-
223
- descriptor.value = async function (...args: T): Promise<R> {
224
- try {
225
- return await method.apply(this, args);
226
- } catch (error) {
227
- throw normalizeError(error);
228
- }
229
- };
230
- }
@@ -1,41 +0,0 @@
1
- // types/index.ts - Point d'entrée central pour tous les types partagés
2
-
3
- // Entity types
4
- export type {
5
- CollectionKey,
6
- EntityTag
7
- } from "../api/EntityRegistry.js";
8
-
9
- export type {
10
- EntityTypes,
11
- SearchEntity,
12
- TransformsMap,
13
- TransformFunction,
14
- } from "./entities.js";
15
-
16
- // Payload types
17
- export type {
18
- SocialNetworkPayload,
19
- } from "./payloads.js";
20
-
21
- // Transform types
22
- export type {
23
- UserTransforms,
24
- OrganizationTransforms,
25
- ProjectTransforms,
26
- EventTransforms
27
- } from "./transforms.js";
28
-
29
- // API Response types
30
- export type {
31
- BaseApiResponse,
32
- ApiDataResponse,
33
- ApiErrorResponse,
34
- PaginatedApiResponse,
35
- GetElementsKeyResponse,
36
- ApiResponse
37
- } from "./api-responses.js";
38
-
39
- // API Error types
40
- export type { ApiErrorDetails } from "./api-responses.js";
41
- export type { GenericErrorDetails } from "../error.js";
@@ -1,21 +0,0 @@
1
- // types/payloads.ts - Types pour les payloads des méthodes _add et _update
2
-
3
-
4
- /**
5
- * Types pour les réseaux sociaux
6
- */
7
- export interface SocialNetworkPayload {
8
- github?: string;
9
- gitlab?: string;
10
- facebook?: string;
11
- twitter?: string;
12
- instagram?: string;
13
- linkedIn?: string;
14
- youtube?: string;
15
- website?: string;
16
- diaspora?: string;
17
- mastodon?: string;
18
- telegram?: string;
19
- signal?: string;
20
- }
21
-
@@ -1,119 +0,0 @@
1
- // types/transforms.ts - Types spécialisés pour les transformations par entité
2
- /* eslint-disable @typescript-eslint/no-empty-object-type */
3
-
4
- import type { TransformFunction, EntityRefsMap } from "./entities.js";
5
- import type { SocialNetworkPayload } from "./payloads.js";
6
-
7
- /**
8
- * Types pour les données d'entrée des transforms
9
- */
10
- export interface ParentData {
11
- [key: string]: {
12
- type?: string;
13
- name?: string;
14
- id?: string;
15
- slug?: string;
16
- _id?: any;
17
- };
18
- }
19
-
20
- export interface OrganizerData {
21
- [key: string]: {
22
- type?: string;
23
- name?: string;
24
- id?: string;
25
- slug?: string;
26
- _id?: any;
27
- };
28
- }
29
-
30
- // Alias pour SocialNetworkPayload depuis payloads.ts (évite la duplication)
31
- export type SocialNetworkData = SocialNetworkPayload;
32
-
33
- /**
34
- * Types pour les transforms spécifiques aux événements
35
- */
36
- export interface EventTransforms {
37
- parent: TransformFunction<ParentData | null, EntityRefsMap>;
38
- organizer: TransformFunction<OrganizerData | null, EntityRefsMap>;
39
- [key: string]: TransformFunction<any, any> | undefined;
40
- }
41
-
42
- /**
43
- * Types pour les transforms spécifiques aux utilisateurs/organisations/projets (réseaux sociaux)
44
- */
45
- export interface SocialTransforms {
46
- github: TransformFunction<any, string | undefined>;
47
- gitlab: TransformFunction<any, string | undefined>;
48
- facebook: TransformFunction<any, string | undefined>;
49
- twitter: TransformFunction<any, string | undefined>;
50
- instagram: TransformFunction<any, string | undefined>;
51
- linkedIn?: TransformFunction<any, string | undefined>;
52
- youtube?: TransformFunction<any, string | undefined>;
53
- website?: TransformFunction<any, string | undefined>;
54
- diaspora?: TransformFunction<any, string | undefined>;
55
- mastodon?: TransformFunction<any, string | undefined>;
56
- telegram?: TransformFunction<any, string | undefined>;
57
- signal?: TransformFunction<any, string | undefined>;
58
- [key: string]: TransformFunction<any, any> | undefined;
59
- }
60
-
61
- /**
62
- * Types pour les transforms des utilisateurs
63
- */
64
- export interface UserTransforms extends SocialTransforms {
65
- // Ajouter d'autres transforms spécifiques aux utilisateurs si nécessaire
66
- }
67
-
68
- /**
69
- * Types pour les transforms des organisations
70
- */
71
- export interface OrganizationTransforms extends SocialTransforms {
72
- // Ajouter d'autres transforms spécifiques aux organisations si nécessaire
73
- }
74
-
75
- /**
76
- * Types pour les transforms des projets
77
- */
78
- export interface ProjectTransforms extends SocialTransforms {
79
- parent: TransformFunction<ParentData | null, EntityRefsMap>;
80
- }
81
-
82
- /**
83
- * Union de tous les types de transforms
84
- */
85
- export type EntityTransforms = EventTransforms | UserTransforms | OrganizationTransforms | ProjectTransforms;
86
-
87
- /**
88
- * Fonction helper pour créer des transforms d'entité avec type safety
89
- */
90
- export function createEntityRef(type: string, name?: string, id?: string, slug?: string, _id?: any) {
91
- return { type, name, id, slug, _id };
92
- }
93
-
94
- /**
95
- * Fonction helper pour transformer les données parent/organizer
96
- */
97
- export function transformEntityRefs(val: ParentData | OrganizerData | null): EntityRefsMap {
98
- if (!val || typeof val !== "object") return {};
99
-
100
- return Object.fromEntries(
101
- Object.entries(val).map(([key, obj]) => [
102
- key,
103
- {
104
- type: obj?.type ?? "",
105
- name: obj?.name,
106
- // id: obj?.id,
107
- // slug: obj?.slug
108
- // _id exclu volontairement
109
- }
110
- ])
111
- );
112
- }
113
-
114
- /**
115
- * Fonction helper pour extraire les données de réseaux sociaux
116
- */
117
- export function createSocialTransform(field: keyof SocialNetworkData): TransformFunction<any, string | undefined> {
118
- return (_val: any, full?: any) => full?.socialNetwork?.[field];
119
- }
@@ -1,50 +0,0 @@
1
- import * as fs from "fs";
2
- import * as os from "os";
3
- import * as path from "path";
4
-
5
- import { OfflineQueueStorageStrategy } from "./OfflineQueueStorageStrategy.js";
6
-
7
- export class FileOfflineStorage<T = any> extends OfflineQueueStorageStrategy<T> {
8
- public readonly dir: string;
9
- public readonly filePath: string;
10
-
11
- constructor(filename: string = "offline-queue.json", dir: string = path.join(os.homedir(), ".config", "cocolight")) {
12
- super();
13
- this.dir = dir;
14
- this.filePath = path.join(dir, filename);
15
- this._ensureDirectoryExists();
16
- }
17
-
18
- private _ensureDirectoryExists(): void {
19
- if (!fs.existsSync(this.dir)) {
20
- fs.mkdirSync(this.dir, { recursive: true });
21
- }
22
- }
23
-
24
- private _readFile(): T[] {
25
- if (!fs.existsSync(this.filePath)) return [];
26
- try {
27
- const json: T[] = JSON.parse(fs.readFileSync(this.filePath, "utf8"));
28
- return json;
29
- } catch (e) {
30
- console.error("Erreur lecture offline queue :", e);
31
- return [];
32
- }
33
- }
34
-
35
- private _writeFile(queue: T[]): void {
36
- try {
37
- fs.writeFileSync(this.filePath, JSON.stringify(queue, null, 2), "utf8");
38
- } catch (e) {
39
- console.warn("[OfflineQueue] Erreur d'écriture:", e);
40
- }
41
- }
42
-
43
- async loadQueue(): Promise<T[]> {
44
- return this._readFile();
45
- }
46
-
47
- async saveQueue(queue: T[]): Promise<void> {
48
- this._writeFile(queue);
49
- }
50
- }
@@ -1,63 +0,0 @@
1
-
2
- import * as fs from "fs";
3
- import * as os from "os";
4
- import * as path from "path";
5
-
6
- import { TokenStorageStrategy } from "./TokenStorage.js";
7
-
8
- export class FileStorageStrategy extends TokenStorageStrategy {
9
- public readonly dir: string;
10
- public readonly filePath: string;
11
-
12
- constructor(filename: string = "tokens.json", dir: string = path.join(os.homedir(), ".config", "cocolight")) {
13
- super();
14
- this.dir = dir;
15
- this.filePath = path.join(dir, filename);
16
- this._ensureDirectoryExists();
17
- }
18
-
19
- private _ensureDirectoryExists(): void {
20
- if (!fs.existsSync(this.dir)) {
21
- fs.mkdirSync(this.dir, { recursive: true });
22
- }
23
- }
24
-
25
- private _readFile(): any {
26
- if (!fs.existsSync(this.filePath)) return {};
27
- try {
28
- return JSON.parse(fs.readFileSync(this.filePath, "utf8"));
29
- } catch (e) {
30
-
31
- console.error("Error reading token file:", e);
32
- return {};
33
- }
34
- }
35
-
36
- private _writeFile(data: Record<string, any>): void {
37
- fs.writeFileSync(this.filePath, JSON.stringify(data, null, 2), "utf8");
38
- }
39
-
40
- getAccessToken(): string | null {
41
- return this._readFile().accessToken || null;
42
- }
43
-
44
- setAccessToken(token: string | null): void {
45
- const data = this._readFile();
46
- data.accessToken = token;
47
- this._writeFile(data);
48
- }
49
-
50
- getRefreshToken(): string | null {
51
- return this._readFile().refreshToken || null;
52
- }
53
-
54
- setRefreshToken(token: string | null): void {
55
- const data = this._readFile();
56
- data.refreshToken = token;
57
- this._writeFile(data);
58
- }
59
-
60
- clear(): void {
61
- this._writeFile({});
62
- }
63
- }
@@ -1,67 +0,0 @@
1
- import * as fs from "fs";
2
- import * as os from "os";
3
- import * as path from "path";
4
-
5
- import { MultiServerTokenStorageStrategy } from "./MultiServerTokenStorageStrategy.js";
6
-
7
- export class MultiServerFileStorageStrategy extends MultiServerTokenStorageStrategy {
8
- public readonly filePath: string;
9
-
10
- constructor(filename: string = "tokens.json", dir: string = path.join(os.homedir(), ".config", "cocolight")) {
11
- super();
12
- this.filePath = path.join(dir, filename);
13
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
14
- }
15
-
16
- private _readFile(): any {
17
- if (!fs.existsSync(this.filePath)) return {};
18
- try {
19
- return JSON.parse(fs.readFileSync(this.filePath, "utf8"));
20
- } catch {
21
- return {};
22
- }
23
- }
24
-
25
- private _writeFile(data: Record<string, { accessToken?: string | null; refreshToken?: string | null }>): void {
26
- fs.writeFileSync(this.filePath, JSON.stringify(data, null, 2), "utf8");
27
- }
28
-
29
- getAccessToken(): string | null {
30
- const base = this._requireBaseURL();
31
- return this._readFile()[base]?.accessToken ?? null;
32
- }
33
-
34
- setAccessToken(token: string | null): void {
35
- const base = this._requireBaseURL();
36
- const all = this._readFile();
37
- all[base] = { ...(all[base] || {}), accessToken: token };
38
- this._writeFile(all);
39
- }
40
-
41
- getRefreshToken(): string | null {
42
- const base = this._requireBaseURL();
43
- return this._readFile()[base]?.refreshToken ?? null;
44
- }
45
-
46
- setRefreshToken(token: string | null): void {
47
- const base = this._requireBaseURL();
48
- const all = this._readFile();
49
- all[base] = { ...(all[base] || {}), refreshToken: token };
50
- this._writeFile(all);
51
- }
52
-
53
- clear(): void {
54
- const base = this._requireBaseURL();
55
- const all = this._readFile();
56
- delete all[base];
57
- this._writeFile(all);
58
- }
59
-
60
- getServers(): string[] {
61
- return Object.keys(this._readFile());
62
- }
63
-
64
- exportAll(): Record<string, { accessToken?: string | null; refreshToken?: string | null }> {
65
- return this._readFile();
66
- }
67
- }