@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
package/src/api/News.ts DELETED
@@ -1,547 +0,0 @@
1
- import { ApiError, ApiResponseError } from "../error.js";
2
- import { BaseEntity } from "./BaseEntity.js";
3
-
4
- import type { Comment } from "./Comment.js";
5
- import type { AddNewsData, UpdateNewsData, DeleteNewsData, AddImageNewsData, AddFileNewsData, GetCommentsData, AddVoteData, AddReportAbuseData, ShareNewsData, ShowVoteData } from "./EndpointApi.types.js";
6
- import type { NewsItemNormalized } from "./serverDataType/News.js";
7
-
8
- export class News extends BaseEntity<NewsItemNormalized> {
9
- static override entityType = "news";
10
-
11
- static override entityTag = "News";
12
-
13
- static override SCHEMA_CONSTANTS: string[] = [
14
- "ADD_NEWS"
15
- ];
16
-
17
- static ADD_BLOCKS = new Map([
18
- ["ADD_NEWS", "addNews"]
19
- ] as const);
20
-
21
- static UPDATE_BLOCKS = new Map([
22
- ["ADD_NEWS", "updateNews"]
23
- ] as const);
24
-
25
- override defaultFields: Record<string, any> = {};
26
-
27
- override removeFields: string[] = ["parentId", "parentType"];
28
-
29
- override transforms: {
30
- scope: (val: any) => any;
31
- mentions: (val: any) => any[];
32
- mediaImg: (val: any) => {
33
- countImages: number;
34
- images: string[];
35
- };
36
- mediaFile: (val: any) => {
37
- countFiles: number;
38
- files: any[];
39
- };
40
- } = {
41
- scope: val => val?.type,
42
- mentions: val =>
43
- Array.isArray(val)
44
- ? val.map(m => ({ ...m, count: parseInt(m.count) }))
45
- : [],
46
- mediaImg: val => {
47
- const images = val?.images?.map((img: any) => img.id).filter(Boolean) || [];
48
- return images.length > 0 ? { countImages: images.length, images } : { countImages: 0, images: [] };
49
- },
50
- mediaFile: val => {
51
- const files = val?.files?.map((f: any) => f.id).filter(Boolean) || [];
52
- return files.length > 0 ? { countFiles: files.length, files } : { countFiles: 0, files: [] };
53
- }
54
- };
55
-
56
- /**
57
- * Transforme les champs imbriqués (author, target, sharedBy, etc.) en instances d'entités.
58
- * @param data - Les données brutes du serveur.
59
- * @returns Les données transformées.
60
- * @protected
61
- */
62
- protected override _transformServerData(data: NewsItemNormalized): NewsItemNormalized {
63
- // Transformer author en instance User/Organization
64
- if (data.author) {
65
- data.author = this._linkNestedEntity(data.author);
66
- }
67
-
68
- // Transformer target en instance User/Organization/Project
69
- if (data.target) {
70
- data.target = this._linkNestedEntity(data.target);
71
- }
72
-
73
- // Transformer lastAuthorShare en instance
74
- if (data.lastAuthorShare) {
75
- data.lastAuthorShare = this._linkNestedEntity(data.lastAuthorShare);
76
- }
77
-
78
- // Transformer le tableau sharedBy
79
- if (Array.isArray(data.sharedBy)) {
80
- data.sharedBy = data.sharedBy.map(item => this._linkNestedEntity(item));
81
- }
82
-
83
- return data;
84
- }
85
-
86
- /**
87
- * Récupérer des actualités par IDs : Récupère des actualités à partir d'une liste d'identifiants.
88
- * Constant : GET_NEWS_BY_ID
89
- */
90
- override async get(): Promise<Record<string, any>> {
91
- if (!this.id) throw new ApiError("Impossible de rafraîchir sans ID.", 400);
92
- const id = this.id; // Type narrowing
93
-
94
- const newsArray = await this.endpointApi.getNewsById({ ids: [id] });
95
-
96
- if (newsArray && Array.isArray(newsArray) && newsArray.length === 1) {
97
- const data = newsArray[0];
98
- this._setData(data, { forceInitialDraftReset: true });
99
- return this.serverData;
100
- }
101
- throw new ApiError(`Aucune actualité trouvée pour l'ID ${this.id}`, 404);
102
- }
103
-
104
-
105
- override _add = async (payload: Record<string, any>): Promise<void> => {
106
- if (!this._calledFromSave) {
107
- throw new Error("utilisation invalide de _add, utilisez save");
108
- }
109
-
110
- // si le texte est vide, on met un espace pour que le champ soit pris en compte car sur le serveur
111
- // il y a une vérification de la taille du texte je pense
112
- if(payload.text === ""){
113
- payload.text = " ";
114
- }
115
- if (this.parent) {
116
- payload.parentId = this.parent.id;
117
- payload.parentType = this.parent.getEntityType();
118
- }
119
-
120
- // const data = await this.callIsConnected(() => this.endpointApi.addNews(payload));
121
- // this._draftData.id = data.object.id;
122
- // // TODO : voir si j'ai ce qui faut dans reponseData de ADD_NEWS pour mettre à jour #serverData
123
- // // c'est dans reponseData.object
124
- // // if(data?.object){
125
- // // this._serverData = { ...data.object };
126
- // // }
127
-
128
- for (const [constant, methodName] of Array.from(News.ADD_BLOCKS)) {
129
- const blockData = this._extractChangedFieldsFromSchema(
130
- this.apiClient,
131
- constant,
132
- { ...payload, ...this.defaultFields },
133
- () => {},
134
- []
135
- );
136
- if (blockData && Object.keys(blockData).length > 0) {
137
- const data = await this._invokeBlockMethod(News.ADD_BLOCKS, methodName, blockData);
138
- if (!this.id && data?.object?.id) {
139
- this._draftData.id = data.object.id;
140
- // this._serverData = { ...data.object };
141
- }
142
- }
143
- }
144
- };
145
-
146
- override _update = async (payload: Record<string, any>): Promise<boolean> => {
147
- if (!this._calledFromSave) {
148
- throw new Error("utilisation invalide de _update, utilisez save");
149
- }
150
-
151
- if (payload.id) delete payload.id;
152
-
153
- // si le texte est vide, on met un espace pour que le champ soit pris en compte car sur le serveur
154
- // il y a une vérification de la taille du texte je pense
155
- if(payload?.text === ""){
156
- payload.text = " ";
157
- }
158
-
159
- if (this.parent) {
160
- payload.parentId = this.parent.id;
161
- payload.parentType = this.parent.getEntityType();
162
- }
163
- payload.idNews = this.id;
164
-
165
- let hasChanged = false;
166
-
167
-
168
- // il faut que j'ai les ids des images et fichiers avant la mise à jour venant de serverData
169
- // if (this._serverData?.mediaImg?.images && this._serverData?.mediaImg?.images.length > 0) {
170
- // imagesIds = this._serverData.mediaImg.images.map((img: any) => img.id);
171
- // }
172
-
173
- // if (this._serverData?.mediaFile?.files && this._serverData?.mediaFile?.files.length > 0) {
174
- // filesIds = this._serverData.mediaFile.files.map((f: any) => f.id);
175
- // }
176
-
177
- // comparer avec this._draftData.mediaImg.images pour voir si des images ont été supprimées
178
- // comparer avec this._draftData.mediaFile.files pour voir si des fichiers ont été supprimés
179
-
180
-
181
- await this.callIsConnected(() => this.endpointApi.updateNews(payload as UpdateNewsData)) as any;
182
-
183
- // TODO : je voudrais pouvoir comparer les images et fichiers pour supprimer ceux qui ont été enlevés
184
- // avec deleteDocumentByContext() mais il faut que j'ai les ids des images et fichiers avant la mise à jour
185
-
186
- hasChanged = true;
187
- return hasChanged;
188
- };
189
-
190
- async addNews(data: Partial<AddNewsData> = {}): Promise<unknown> {
191
- return this.callIsConnected(() => this.endpointApi.addNews(data as AddNewsData));
192
- }
193
-
194
- async updateNews(data: Partial<UpdateNewsData> = {}): Promise<unknown> {
195
- return this.callIsConnected(() => this.endpointApi.updateNews(data as UpdateNewsData));
196
- }
197
-
198
- async addMention({ slug, id }: { slug?: string; id?: string; }): Promise<any[]> {
199
- try {
200
- if (!slug && !id) {
201
- throw new ApiError("Vous devez fournir un slug ou un id pour ajouter une mention.", 400);
202
- }
203
-
204
- const userInstance = await this.entity("citoyens", { id, slug });
205
- // const userInstance = new this.deps.User(this.apiClient, { id, slug }, { EndpointApi: this.endpointApi });
206
- const user = userInstance.serverData;
207
-
208
- if (!this._draftData.mentions) {
209
- this._draftData.mentions = [];
210
- }
211
- // Vérification si la mention existe déjà
212
- if (this._draftData.mentions.find((mention: any) => mention.id === user.id)) {
213
- // Si la mention existe déjà, on incrémente le compteur
214
- this._draftData.mentions = this._draftData.mentions.map((mention: any) => {
215
- if (mention.id === user.id) {
216
- mention.count += 1;
217
- }
218
- return mention;
219
- });
220
- return this._draftData.mentions;
221
- }
222
- const mention = { id: user.id, slug: user.slug, type: userInstance.getEntityType(), name: user.name, value: user.name, count: 1 };
223
- this._draftData.mentions.push(mention);
224
- return this._draftData.mentions;
225
- } catch (error) {
226
- this.apiClient._logger.error("Erreur lors de l'ajout de la mention :", error);
227
- throw error;
228
- }
229
-
230
- }
231
-
232
-
233
- /**
234
- * Ajouter une image à une actualité : Ajoute une images à une actualité.
235
- * Constant : ADD_IMAGE_NEWS
236
- */
237
- async addImage(image: File | Blob | Buffer | import("stream").Readable): Promise<{ id: string; [key: string]: any }> {
238
- const validatedImage = await this._validateImage(image);
239
- const data: AddImageNewsData = {
240
- pathParams: {
241
- folder: this.parent?.getEntityType() as "citoyens" | "projects" | "organizations",
242
- ownerId: this.parent?.id as string
243
- },
244
- newsImage: validatedImage as any
245
- };
246
- const dataImage = await this.callIsConnected(() => this.endpointApi.addImageNews(data)) as { id: string; [key: string]: any };
247
- if (this._draftData.mediaImg) {
248
- this._draftData.mediaImg.countImages = this._draftData.mediaImg.countImages + 1;
249
- this._draftData.mediaImg.images.push(dataImage.id);
250
- } else {
251
- this._draftData.mediaImg = { countImages: 1, images: [dataImage.id] };
252
- }
253
- return dataImage;
254
- }
255
-
256
- /**
257
- * Ajouter un fichier à une actualité : Ajoute un fichier à une actualité.
258
- * Constant : ADD_FILE_NEWS
259
- */
260
- async addFile(file: File | Blob | Buffer | import("stream").Readable): Promise<unknown> {
261
- const validatedFile = await this._validateFile(file);
262
- const data: AddFileNewsData = {
263
- pathParams: {
264
- folder: this.parent?.getEntityType() as "citoyens" | "projects" | "organizations",
265
- ownerId: this.parent?.id as string
266
- },
267
- newsFile: validatedFile as any
268
- };
269
- const dataFile = await this.callIsConnected(() => this.endpointApi.addFileNews(data)) as { id: string; [key: string]: any };
270
- if (this._draftData.mediaFile) {
271
- this._draftData.mediaFile.countFiles = this._draftData.mediaFile.countFiles + 1;
272
- this._draftData.mediaFile.files.push(dataFile.id);
273
- } else {
274
- this._draftData.mediaFile = { countFiles: 1, files: [dataFile.id] };
275
- }
276
- return dataFile;
277
- }
278
-
279
-
280
-
281
- /**
282
- * Supprimer une actualité : Supprime une actualité existante.
283
- * Constant : DELETE_NEWS
284
- */
285
- async delete(): Promise<void> {
286
- if(!this.id) {
287
- throw new ApiError("Vous devez fournir un id pour supprimer une news.", 400);
288
- }
289
- const data = {
290
- pathParams: { id: this.id },
291
- isLive: false // Valeur par défaut, peut être surchargée
292
- };
293
- await this.callIsConnected(() => this.endpointApi.deleteNews(data as DeleteNewsData));
294
-
295
- // Vider les objets réactifs sans casser la réactivité
296
- Object.keys(this._draftData).forEach(key => delete this._draftData[key]);
297
- Object.keys(this._serverData).forEach(key => delete (this._serverData as any)[key]);
298
-
299
- // Marquer comme supprimé
300
- this._isDeleted = true;
301
- }
302
-
303
- /**
304
- * Créer une instance de commentaire pour cette news.
305
- * @param commentData - Données du commentaire.
306
- * @returns Instance de Comment.
307
- */
308
- async comment(commentData: Record<string, any> = {}): Promise<Comment> {
309
- if(!this.isConnected){
310
- throw new ApiError("Vous devez être connecté.", 401);
311
- }
312
-
313
- const entity = await this.entity("comments", commentData);
314
- return entity as Comment;
315
- }
316
-
317
- /**
318
- * Récupérer les commentaires : Récupère la liste de commentaires selon plusieurs critères.
319
- * Constant : GET_COMMENTS
320
- * @returns - Les données de réponse.
321
- * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
322
- * @throws {Error} - En cas d'erreur inattendue.
323
- */
324
- async getComments(): Promise<Comment[]> {
325
-
326
- if (!this.id) {
327
- throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
328
- }
329
-
330
- const payload: GetCommentsData = {
331
- pathParams: { type: "news", id: this.id },
332
- };
333
-
334
- const arrayObjet = await this.endpointApi.getComments(payload);
335
-
336
- if(!Array.isArray(arrayObjet)){
337
- throw new ApiResponseError("Erreur lors de la récupération des commentaires.", 500, arrayObjet as object);
338
- }
339
-
340
- const rawList = this._linkEntities(arrayObjet);
341
-
342
- return this._createFilteredProxy(rawList);
343
- }
344
-
345
- /**
346
- * Ajoute un vote sur cette news
347
- *
348
- * @param status - Statut du vote (ex: 'like', 'dislike', 'love', etc.)
349
- * @returns Promise contenant la réponse de l'API après l'ajout du vote
350
- * @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
351
- */
352
- async addVote(status: string){
353
- if (!this.id) {
354
- throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
355
- }
356
-
357
- const payload: AddVoteData = {
358
- collection: "news",
359
- id: this.id,
360
- action: "vote",
361
- details: {
362
- status
363
- }
364
- };
365
-
366
- return await this.callIsConnected(() => this.endpointApi.addVote(payload));
367
- }
368
-
369
- /**
370
- * Récupère la liste des votes (like, love, etc.) sur cette news.
371
- *
372
- * Wrap de `SHOW_VOTE` avec auto-injection du `type` (`"news"`) et de
373
- * `this.id` dans `pathParams`. Le retour contient `vote` (votes individuels
374
- * indexés par userId) et `voteCount` (compteurs par statut).
375
- *
376
- * @returns Réponse API : `{ _id, vote, voteCount }` ou variante d'erreur.
377
- * @throws {ApiError} 404 si la news n'a pas d'id (non enregistrée).
378
- *
379
- * @example
380
- * const votes = await news.getVotes();
381
- * votes.voteCount?.like; // nombre de likes
382
- * votes.vote?.[userId]; // vote détaillé d'un user
383
- */
384
- async getVotes(): Promise<unknown> {
385
- if (!this.id) {
386
- throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
387
- }
388
- const payload: ShowVoteData = {
389
- pathParams: { type: "news", id: this.id },
390
- };
391
- return this.endpointApi.showVote(payload);
392
- }
393
-
394
- /**
395
- * Signale un abus sur cette news
396
- *
397
- * @param params - Paramètres du signalement
398
- * @param params.reason - Raison du signalement
399
- * @param params.comment - Commentaire expliquant le signalement (optionnel)
400
- * @returns Promise contenant la réponse de l'API après le signalement
401
- * @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
402
- */
403
- async addReportAbuse({ reason, comment }: { reason: string, comment?: string}){
404
- if (!this.id) {
405
- throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
406
- }
407
-
408
- const payload: AddReportAbuseData = {
409
- collection: "news",
410
- id: this.id,
411
- action: "reportAbuse",
412
- details: {
413
- reason,
414
- comment
415
- }
416
- };
417
-
418
- return await this.callIsConnected(() =>this.endpointApi.addReportAbuse(payload));
419
- }
420
-
421
- /**
422
- * Partage cette news vers une entité (utilisateur, projet ou organisation)
423
- *
424
- * @param params - Paramètres de partage
425
- * @param params.childId - ID de l'entité cible (par défaut: utilisateur connecté)
426
- * @param params.childType - Type de l'entité cible (par défaut: "citoyens")
427
- * @param params.comment - Commentaire optionnel accompagnant le partage
428
- * @returns Promise contenant la réponse de l'API après le partage
429
- * @throws {ApiError} Si la news n'a pas d'ID (404)
430
- * @throws {ApiError} Si l'utilisateur n'est pas connecté (400)
431
- * @throws {ApiError} Si le parent n'est pas défini (400)
432
- * @throws {ApiError} Si on tente de partager sa propre news à soi-même (400)
433
- * @throws {ApiError} Si le type cible n'est pas valide (400)
434
- */
435
- async shareNews({ childId, childType, comment }: { childId?: string, childType?: string, comment?: string } = {}){
436
- // Validations préalables
437
- if (!this.id) {
438
- throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
439
- }
440
-
441
- if (!this.userId) {
442
- throw new ApiError("L'utilisateur connecté n'est pas défini.", 400);
443
- }
444
-
445
- if(!this.parent?.id){
446
- throw new ApiError("Le parent doit être défini pour partager une news", 400);
447
- }
448
-
449
- // Déterminer la cible du partage (par défaut: l'utilisateur connecté)
450
- const targetId = childId ?? this.userId;
451
- const targetType = childType ?? "citoyens";
452
-
453
- // Valider que le type est autorisé
454
- const validChildTypes: Array<"citoyens" | "projects" | "organizations"> = ["citoyens", "projects", "organizations"];
455
- if (!validChildTypes.includes(targetType as any)) {
456
- throw new ApiError(
457
- `Le type de cible "${targetType}" n'est pas valide. Types autorisés: ${validChildTypes.join(", ")}`,
458
- 400
459
- );
460
- }
461
-
462
- // Empêcher l'auto-partage: on ne peut pas partager sa propre news à soi-même
463
- if (this.parent.id === this.userId && targetId === this.userId) {
464
- throw new ApiError("Vous ne pouvez pas partager votre propre news à vous-même", 400);
465
- }
466
-
467
- const payload: ShareNewsData = {
468
- parentId: this.id,
469
- parentType: "news",
470
- connectType: "share",
471
- childType: targetType as "citoyens" | "projects" | "organizations",
472
- childId: targetId,
473
- comment
474
- };
475
-
476
- return await this.callIsConnected(() => this.endpointApi.shareNews(payload));
477
- }
478
-
479
- /**
480
- * Vérifie si l'utilisateur connecté est l'auteur de cette actualité.
481
- *
482
- * Cette méthode compare l'ID de l'utilisateur connecté avec l'ID de l'auteur
483
- * de l'actualité. L'auteur peut être soit un objet simple NewsAuthor, soit
484
- * une instance d'entité User ou Organization.
485
- * @param options - Options de vérification.
486
- * @param options.silent - Si `true`, retourne `false` au lieu de lever une exception. Par défaut `true`.
487
- * @returns `true` si l'utilisateur connecté est l'auteur, `false` sinon
488
- * @throws {ApiError} Si l'utilisateur n'est pas connecté (401)
489
- * @throws {ApiError} Si l'actualité n'a pas d'ID - non enregistrée (404)
490
- * @throws {ApiError} Si les données serveur ne sont pas disponibles (404)
491
- *
492
- * @example
493
- * ```typescript
494
- * const news = await me.news({ id: "123" });
495
- * await news.get();
496
- *
497
- * if (news.isAuthor()) {
498
- * console.log("Vous êtes l'auteur de cette actualité");
499
- * await news.delete(); // Vous pouvez la supprimer
500
- * }
501
- * ```
502
- */
503
- override isAuthor(options?: { silent?: boolean }): boolean {
504
- const silent = options?.silent ?? true;
505
-
506
- try {
507
- if (!this.isMe) {
508
- throw new ApiError("Vous devez être connecté pour vérifier l'auteur.", 401);
509
- }
510
- if (!this.id) {
511
- throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
512
- }
513
- if (!this.serverData) {
514
- throw new ApiError("Aucune donnée serveur disponible.", 404);
515
- }
516
- if (!this.userId) {
517
- throw new ApiError("Utilisateur non connecté.", 401);
518
- }
519
- } catch (e) {
520
- if (silent) return false;
521
- throw e;
522
- }
523
-
524
- const author = this.serverData.author;
525
- if (!author) {
526
- return false;
527
- }
528
-
529
- // Extraire l'ID selon le type d'author
530
- // author peut être NewsAuthor (objet simple avec .id) ou User/Organization (entité avec .serverData.id)
531
- let authorId: string | undefined;
532
-
533
- if ("serverData" in author && author.serverData && typeof author.serverData === "object" && "id" in author.serverData) {
534
- // C'est une instance d'entité (User ou Organization)
535
- authorId = author.serverData.id as string;
536
- } else if ("id" in author) {
537
- // C'est un objet NewsAuthor simple
538
- authorId = author.id as string;
539
- }
540
-
541
- return Boolean(authorId && this.userId === authorId);
542
- }
543
-
544
- override async form(): Promise<never> {
545
- throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
546
- }
547
- }