@communecter/cocolight-api-client 1.0.155 → 1.0.157
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.
- package/dist/1035.cocolight-api-client.browser.js +1 -1
- package/dist/1035.cocolight-api-client.cjs +1 -1
- package/dist/1483.cocolight-api-client.browser.js +1 -1
- package/dist/1483.cocolight-api-client.cjs +1 -1
- package/dist/1491.cocolight-api-client.browser.js +1 -1
- package/dist/1491.cocolight-api-client.cjs +1 -1
- package/dist/1494.cocolight-api-client.browser.js +1 -1
- package/dist/1494.cocolight-api-client.cjs +1 -1
- package/dist/1641.cocolight-api-client.browser.js +1 -1
- package/dist/1641.cocolight-api-client.cjs +1 -1
- package/dist/1678.cocolight-api-client.browser.js +1 -1
- package/dist/1678.cocolight-api-client.cjs +1 -1
- package/dist/2041.cocolight-api-client.browser.js +1 -1
- package/dist/2041.cocolight-api-client.cjs +1 -1
- package/dist/2302.cocolight-api-client.browser.js +1 -1
- package/dist/2302.cocolight-api-client.cjs +1 -1
- package/dist/2313.cocolight-api-client.browser.js +1 -1
- package/dist/2313.cocolight-api-client.cjs +1 -1
- package/dist/2379.cocolight-api-client.browser.js +1 -1
- package/dist/2379.cocolight-api-client.cjs +1 -1
- package/dist/2439.cocolight-api-client.browser.js +1 -1
- package/dist/2439.cocolight-api-client.cjs +1 -1
- package/dist/2594.cocolight-api-client.browser.js +1 -1
- package/dist/2594.cocolight-api-client.cjs +1 -1
- package/dist/2766.cocolight-api-client.browser.js +1 -1
- package/dist/2766.cocolight-api-client.cjs +1 -1
- package/dist/2812.cocolight-api-client.browser.js +1 -1
- package/dist/2812.cocolight-api-client.cjs +1 -1
- package/dist/2918.cocolight-api-client.browser.js +1 -1
- package/dist/2918.cocolight-api-client.cjs +1 -1
- package/dist/3028.cocolight-api-client.browser.js +1 -1
- package/dist/3028.cocolight-api-client.cjs +1 -1
- package/dist/3330.cocolight-api-client.browser.js +1 -1
- package/dist/3330.cocolight-api-client.cjs +1 -1
- package/dist/3371.cocolight-api-client.browser.js +1 -1
- package/dist/3371.cocolight-api-client.cjs +1 -1
- package/dist/3401.cocolight-api-client.browser.js +1 -1
- package/dist/3401.cocolight-api-client.cjs +1 -1
- package/dist/3516.cocolight-api-client.browser.js +1 -1
- package/dist/3516.cocolight-api-client.cjs +1 -1
- package/dist/3593.cocolight-api-client.browser.js +1 -1
- package/dist/3593.cocolight-api-client.cjs +1 -1
- package/dist/3764.cocolight-api-client.browser.js +1 -1
- package/dist/3764.cocolight-api-client.cjs +1 -1
- package/dist/3873.cocolight-api-client.browser.js +1 -1
- package/dist/3873.cocolight-api-client.cjs +1 -1
- package/dist/3911.cocolight-api-client.browser.js +1 -1
- package/dist/3911.cocolight-api-client.cjs +1 -1
- package/dist/4031.cocolight-api-client.browser.js +1 -1
- package/dist/4031.cocolight-api-client.cjs +1 -1
- package/dist/4152.cocolight-api-client.browser.js +1 -1
- package/dist/4152.cocolight-api-client.cjs +1 -1
- package/dist/4203.cocolight-api-client.browser.js +1 -1
- package/dist/4203.cocolight-api-client.cjs +1 -1
- package/dist/424.cocolight-api-client.browser.js +1 -1
- package/dist/424.cocolight-api-client.cjs +1 -1
- package/dist/435.cocolight-api-client.browser.js +1 -1
- package/dist/435.cocolight-api-client.cjs +1 -1
- package/dist/4402.cocolight-api-client.browser.js +1 -1
- package/dist/4402.cocolight-api-client.cjs +1 -1
- package/dist/4425.cocolight-api-client.browser.js +1 -1
- package/dist/4425.cocolight-api-client.cjs +1 -1
- package/dist/4472.cocolight-api-client.browser.js +1 -1
- package/dist/4472.cocolight-api-client.cjs +1 -1
- package/dist/4914.cocolight-api-client.browser.js +1 -1
- package/dist/4914.cocolight-api-client.cjs +1 -1
- package/dist/4959.cocolight-api-client.browser.js +1 -1
- package/dist/4959.cocolight-api-client.cjs +1 -1
- package/dist/5100.cocolight-api-client.browser.js +1 -1
- package/dist/5100.cocolight-api-client.cjs +1 -1
- package/dist/5111.cocolight-api-client.browser.js +1 -1
- package/dist/5111.cocolight-api-client.cjs +1 -1
- package/dist/5286.cocolight-api-client.browser.js +1 -1
- package/dist/5286.cocolight-api-client.cjs +1 -1
- package/dist/5380.cocolight-api-client.browser.js +1 -1
- package/dist/5380.cocolight-api-client.cjs +1 -1
- package/dist/5383.cocolight-api-client.browser.js +1 -1
- package/dist/5383.cocolight-api-client.cjs +1 -1
- package/dist/5480.cocolight-api-client.browser.js +1 -1
- package/dist/5480.cocolight-api-client.cjs +1 -1
- package/dist/5541.cocolight-api-client.browser.js +1 -1
- package/dist/5541.cocolight-api-client.cjs +1 -1
- package/dist/5839.cocolight-api-client.browser.js +1 -1
- package/dist/5839.cocolight-api-client.cjs +1 -1
- package/dist/5862.cocolight-api-client.browser.js +1 -1
- package/dist/5862.cocolight-api-client.cjs +1 -1
- package/dist/5869.cocolight-api-client.browser.js +1 -1
- package/dist/5869.cocolight-api-client.cjs +1 -1
- package/dist/588.cocolight-api-client.browser.js +1 -1
- package/dist/588.cocolight-api-client.cjs +1 -1
- package/dist/601.cocolight-api-client.browser.js +1 -1
- package/dist/601.cocolight-api-client.cjs +1 -1
- package/dist/6012.cocolight-api-client.browser.js +1 -1
- package/dist/6012.cocolight-api-client.cjs +1 -1
- package/dist/6200.cocolight-api-client.browser.js +1 -1
- package/dist/6200.cocolight-api-client.cjs +1 -1
- package/dist/6369.cocolight-api-client.browser.js +1 -1
- package/dist/6369.cocolight-api-client.cjs +1 -1
- package/dist/7009.cocolight-api-client.browser.js +1 -1
- package/dist/7009.cocolight-api-client.cjs +1 -1
- package/dist/725.cocolight-api-client.browser.js +1 -1
- package/dist/725.cocolight-api-client.cjs +1 -1
- package/dist/7320.cocolight-api-client.browser.js +1 -1
- package/dist/7339.cocolight-api-client.browser.js +1 -1
- package/dist/7339.cocolight-api-client.cjs +1 -1
- package/dist/7398.cocolight-api-client.browser.js +1 -1
- package/dist/7398.cocolight-api-client.cjs +1 -1
- package/dist/7888.cocolight-api-client.browser.js +1 -1
- package/dist/7888.cocolight-api-client.cjs +1 -1
- package/dist/7975.cocolight-api-client.browser.js +1 -1
- package/dist/7975.cocolight-api-client.cjs +1 -1
- package/dist/809.cocolight-api-client.browser.js +1 -1
- package/dist/809.cocolight-api-client.cjs +1 -1
- package/dist/8300.cocolight-api-client.browser.js +1 -1
- package/dist/8300.cocolight-api-client.cjs +1 -1
- package/dist/8317.cocolight-api-client.browser.js +1 -1
- package/dist/8317.cocolight-api-client.cjs +1 -1
- package/dist/8525.cocolight-api-client.browser.js +1 -1
- package/dist/8525.cocolight-api-client.cjs +1 -1
- package/dist/8894.cocolight-api-client.browser.js +1 -1
- package/dist/8894.cocolight-api-client.cjs +1 -1
- package/dist/9301.cocolight-api-client.browser.js +1 -1
- package/dist/9301.cocolight-api-client.cjs +1 -1
- package/dist/9438.cocolight-api-client.browser.js +1 -1
- package/dist/9438.cocolight-api-client.cjs +1 -1
- package/dist/9478.cocolight-api-client.browser.js +1 -1
- package/dist/9478.cocolight-api-client.cjs +1 -1
- package/dist/9568.cocolight-api-client.browser.js +1 -1
- package/dist/9568.cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.browser.js +6 -6
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.vite.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
- package/package.json +7 -17
- package/types/Api.d.ts +1 -0
- package/types/ApiClient.d.ts +10 -1
- package/types/api/Answer.d.ts +27 -9
- package/types/api/BaseEntity.d.ts +77 -0
- package/types/api/EndpointApi.d.ts +51 -3
- package/types/api/EndpointApi.types.d.ts +112 -1
- package/types/api/User.d.ts +20 -0
- package/types/costum/types.d.ts +0 -2
- package/types/endpoints.module.d.ts +3039 -1009
- package/types/index.d.ts +1 -0
- package/types/utils/OfflineClientManager.d.ts +8 -0
- package/types/utils/adminImportExport.d.ts +29 -0
- package/dist/1035.cocolight-api-client.mjs.js +0 -1
- package/dist/1483.cocolight-api-client.mjs.js +0 -1
- package/dist/1491.cocolight-api-client.mjs.js +0 -1
- package/dist/1494.cocolight-api-client.mjs.js +0 -1
- package/dist/1641.cocolight-api-client.mjs.js +0 -1
- package/dist/1678.cocolight-api-client.mjs.js +0 -1
- package/dist/2041.cocolight-api-client.mjs.js +0 -1
- package/dist/2302.cocolight-api-client.mjs.js +0 -1
- package/dist/2313.cocolight-api-client.mjs.js +0 -1
- package/dist/2379.cocolight-api-client.mjs.js +0 -1
- package/dist/2439.cocolight-api-client.mjs.js +0 -1
- package/dist/2594.cocolight-api-client.mjs.js +0 -1
- package/dist/2766.cocolight-api-client.mjs.js +0 -1
- package/dist/2812.cocolight-api-client.mjs.js +0 -1
- package/dist/2918.cocolight-api-client.mjs.js +0 -1
- package/dist/3028.cocolight-api-client.mjs.js +0 -1
- package/dist/3330.cocolight-api-client.mjs.js +0 -1
- package/dist/3371.cocolight-api-client.mjs.js +0 -1
- package/dist/3401.cocolight-api-client.mjs.js +0 -1
- package/dist/3516.cocolight-api-client.mjs.js +0 -1
- package/dist/3593.cocolight-api-client.mjs.js +0 -1
- package/dist/3764.cocolight-api-client.mjs.js +0 -1
- package/dist/3873.cocolight-api-client.mjs.js +0 -1
- package/dist/3911.cocolight-api-client.mjs.js +0 -1
- package/dist/4031.cocolight-api-client.mjs.js +0 -1
- package/dist/4152.cocolight-api-client.mjs.js +0 -1
- package/dist/4203.cocolight-api-client.mjs.js +0 -1
- package/dist/424.cocolight-api-client.mjs.js +0 -1
- package/dist/435.cocolight-api-client.mjs.js +0 -1
- package/dist/4402.cocolight-api-client.mjs.js +0 -1
- package/dist/4425.cocolight-api-client.mjs.js +0 -1
- package/dist/4472.cocolight-api-client.mjs.js +0 -1
- package/dist/4914.cocolight-api-client.mjs.js +0 -1
- package/dist/4959.cocolight-api-client.mjs.js +0 -1
- package/dist/5100.cocolight-api-client.mjs.js +0 -1
- package/dist/5111.cocolight-api-client.mjs.js +0 -1
- package/dist/5286.cocolight-api-client.mjs.js +0 -1
- package/dist/5380.cocolight-api-client.mjs.js +0 -1
- package/dist/5383.cocolight-api-client.mjs.js +0 -1
- package/dist/5480.cocolight-api-client.mjs.js +0 -1
- package/dist/5541.cocolight-api-client.mjs.js +0 -1
- package/dist/5839.cocolight-api-client.mjs.js +0 -1
- package/dist/5862.cocolight-api-client.mjs.js +0 -1
- package/dist/5869.cocolight-api-client.mjs.js +0 -1
- package/dist/588.cocolight-api-client.mjs.js +0 -1
- package/dist/601.cocolight-api-client.mjs.js +0 -1
- package/dist/6012.cocolight-api-client.mjs.js +0 -1
- package/dist/6200.cocolight-api-client.mjs.js +0 -1
- package/dist/6369.cocolight-api-client.mjs.js +0 -1
- package/dist/7009.cocolight-api-client.mjs.js +0 -1
- package/dist/725.cocolight-api-client.mjs.js +0 -1
- package/dist/7339.cocolight-api-client.mjs.js +0 -1
- package/dist/7398.cocolight-api-client.mjs.js +0 -1
- package/dist/7888.cocolight-api-client.mjs.js +0 -1
- package/dist/7975.cocolight-api-client.mjs.js +0 -1
- package/dist/809.cocolight-api-client.mjs.js +0 -1
- package/dist/8300.cocolight-api-client.mjs.js +0 -1
- package/dist/8317.cocolight-api-client.mjs.js +0 -1
- package/dist/8525.cocolight-api-client.mjs.js +0 -1
- package/dist/8894.cocolight-api-client.mjs.js +0 -1
- package/dist/9301.cocolight-api-client.mjs.js +0 -1
- package/dist/9438.cocolight-api-client.mjs.js +0 -1
- package/dist/9478.cocolight-api-client.mjs.js +0 -1
- package/dist/9568.cocolight-api-client.mjs.js +0 -1
- package/dist/cocolight-api-client.mjs.js +0 -1
- package/src/Api.ts +0 -348
- package/src/ApiClient.ts +0 -1994
- package/src/EJSONType.ts +0 -103
- package/src/api/Action.ts +0 -665
- package/src/api/Answer.ts +0 -1392
- package/src/api/Badge.ts +0 -143
- package/src/api/BaseEntity.ts +0 -6384
- package/src/api/Classified.ts +0 -175
- package/src/api/Comment.ts +0 -280
- package/src/api/EndpointApi.ts +0 -2270
- package/src/api/EndpointApi.types.ts +0 -6566
- package/src/api/EntityRegistry.ts +0 -324
- package/src/api/Event.ts +0 -360
- package/src/api/Form.ts +0 -282
- package/src/api/News.ts +0 -547
- package/src/api/Notifications.ts +0 -196
- package/src/api/Organization.ts +0 -771
- package/src/api/Poi.ts +0 -242
- package/src/api/Project.ts +0 -545
- package/src/api/User.ts +0 -1889
- package/src/api/UserApi.ts +0 -192
- package/src/api/serverDataType/Action.ts +0 -177
- package/src/api/serverDataType/Answer.ts +0 -106
- package/src/api/serverDataType/Classified.ts +0 -152
- package/src/api/serverDataType/Comment.ts +0 -88
- package/src/api/serverDataType/Country.ts +0 -1
- package/src/api/serverDataType/Event.ts +0 -112
- package/src/api/serverDataType/Form.ts +0 -157
- package/src/api/serverDataType/News.ts +0 -138
- package/src/api/serverDataType/Notification.ts +0 -81
- package/src/api/serverDataType/Organization.ts +0 -111
- package/src/api/serverDataType/Poi.ts +0 -75
- package/src/api/serverDataType/Project.ts +0 -115
- package/src/api/serverDataType/User.ts +0 -112
- package/src/api/serverDataType/Zone.ts +0 -33
- package/src/api/serverDataType/common.ts +0 -84
- package/src/costum/normalize.ts +0 -7
- package/src/costum/registry.ts +0 -138
- package/src/costum/runtime-map.ts +0 -221
- package/src/costum/runtime.ts +0 -274
- package/src/costum/schemas/CercleTravailleursSociauxLiberauxLaPlumeSociale.ts +0 -19
- package/src/costum/schemas/FabEn.ts +0 -19
- package/src/costum/schemas/LivingLabInnovationSocialeBraspanon.ts +0 -19
- package/src/costum/schemas/alfph.ts +0 -27
- package/src/costum/schemas/campagne.ts +0 -19
- package/src/costum/schemas/chtitube.ts +0 -19
- package/src/costum/schemas/circuitCourt.ts +0 -19
- package/src/costum/schemas/cmcasHauteBretagne.ts +0 -19
- package/src/costum/schemas/coFinancementTierslieux.ts +0 -27
- package/src/costum/schemas/coeurNumerique.ts +0 -19
- package/src/costum/schemas/communLundi.ts +0 -19
- package/src/costum/schemas/cressReunion.ts +0 -35
- package/src/costum/schemas/cressReunionNetwork.ts +0 -35
- package/src/costum/schemas/ctenat.ts +0 -43
- package/src/costum/schemas/cyberReunion.ts +0 -19
- package/src/costum/schemas/ekisphere.ts +0 -35
- package/src/costum/schemas/equipementsSportifs974.ts +0 -19
- package/src/costum/schemas/federationDesCae.ts +0 -19
- package/src/costum/schemas/formationGenerique.ts +0 -35
- package/src/costum/schemas/franceTierslieux.ts +0 -19
- package/src/costum/schemas/hinaura.ts +0 -27
- package/src/costum/schemas/hubmayotte.ts +0 -19
- package/src/costum/schemas/hubnouvellecaledonie.ts +0 -19
- package/src/costum/schemas/hubpolynesiefrancaise.ts +0 -19
- package/src/costum/schemas/hubreunion.ts +0 -19
- package/src/costum/schemas/hubterritoires.ts +0 -19
- package/src/costum/schemas/hubwallisetfutuna.ts +0 -19
- package/src/costum/schemas/hva.ts +0 -27
- package/src/costum/schemas/ibv2.ts +0 -19
- package/src/costum/schemas/institutBleu.ts +0 -19
- package/src/costum/schemas/journalInsoumisChambery.ts +0 -27
- package/src/costum/schemas/kpacite.ts +0 -19
- package/src/costum/schemas/laCompagnieDesTierslieux.ts +0 -43
- package/src/costum/schemas/laMaisonDesFaiseurs.ts +0 -19
- package/src/costum/schemas/laReunionPourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/laSemaineDesTierslieux.ts +0 -19
- package/src/costum/schemas/labEnCommuns.ts +0 -19
- package/src/costum/schemas/lakou.ts +0 -27
- package/src/costum/schemas/lesCommunsDesTierslieux.ts +0 -19
- package/src/costum/schemas/mayottePourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/meir.ts +0 -27
- package/src/costum/schemas/navigatorDesTierslieux.ts +0 -19
- package/src/costum/schemas/notragora.ts +0 -27
- package/src/costum/schemas/nouvellecaledoniePourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/openAtlas.ts +0 -19
- package/src/costum/schemas/polynesieFrancaisePourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/schemas/prdr.ts +0 -19
- package/src/costum/schemas/reseauTierslieux.ts +0 -19
- package/src/costum/schemas/rfflabs.ts +0 -19
- package/src/costum/schemas/ries.ts +0 -19
- package/src/costum/schemas/siteDuPactePourLaTransition.ts +0 -27
- package/src/costum/schemas/sportSanteBienetre.ts +0 -43
- package/src/costum/schemas/suppa.ts +0 -19
- package/src/costum/schemas/terramies.ts +0 -19
- package/src/costum/schemas/testeTplFormation.ts +0 -35
- package/src/costum/schemas/tierslieuxbelgique.ts +0 -19
- package/src/costum/schemas/tierslieuxorg1.ts +0 -35
- package/src/costum/schemas/transiter.ts +0 -35
- package/src/costum/schemas/vhelioPeiTour2025.ts +0 -19
- package/src/costum/schemas/wallisetfutunaPourUnNumeriqueInclusif.ts +0 -19
- package/src/costum/symbol.ts +0 -26
- package/src/costum/types.ts +0 -895
- package/src/endpoints.module.ts +0 -4253
- package/src/error.ts +0 -86
- package/src/forms/entityForm.ts +0 -142
- package/src/index.ts +0 -161
- package/src/mixin/UserMixin.ts +0 -4
- package/src/types/api-responses.ts +0 -217
- package/src/types/entities.ts +0 -58
- package/src/types/error-guards.ts +0 -230
- package/src/types/index.ts +0 -41
- package/src/types/payloads.ts +0 -21
- package/src/types/transforms.ts +0 -119
- package/src/utils/FileOfflineStorageStrategy.node.ts +0 -50
- package/src/utils/FileStorageStrategy.node.ts +0 -63
- package/src/utils/MultiServerFileStorageStrategy.node.ts +0 -67
- package/src/utils/MultiServerTokenStorageStrategy.ts +0 -139
- package/src/utils/OfflineClientManager.ts +0 -216
- package/src/utils/OfflineQueueStorageStrategy.ts +0 -47
- package/src/utils/TokenStorage.ts +0 -77
- package/src/utils/compat.ts +0 -12
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +0 -35
- package/src/utils/createDefaultOfflineStrategy.ts +0 -34
- package/src/utils/createDefaultTokenStorageStrategy.ts +0 -33
- package/src/utils/reactive.ts +0 -243
- package/src/utils/stream-utils.node.ts +0 -12
package/src/api/Classified.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { ApiError } from "../error.js";
|
|
2
|
-
import { BaseEntity } from "./BaseEntity.js";
|
|
3
|
-
import { transformEntityRefs } from "../types/transforms.js";
|
|
4
|
-
|
|
5
|
-
import type { AddClassifiedData } from "./EndpointApi.types.js";
|
|
6
|
-
import type { ClassifiedItemNormalized } from "./serverDataType/Classified.js";
|
|
7
|
-
|
|
8
|
-
export class Classified extends BaseEntity<ClassifiedItemNormalized> {
|
|
9
|
-
static override entityType = "classifieds";
|
|
10
|
-
|
|
11
|
-
static override entityTag = "Classified";
|
|
12
|
-
|
|
13
|
-
static override SCHEMA_CONSTANTS: string[] = [
|
|
14
|
-
"ADD_CLASSIFIED",
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
static ADD_BLOCKS = new Map([
|
|
18
|
-
["ADD_CLASSIFIED", "addClassified"],
|
|
19
|
-
] as const);
|
|
20
|
-
|
|
21
|
-
override defaultFields: Record<string, unknown> = {
|
|
22
|
-
typeElement: "classified",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
override removeFields: string[] = [
|
|
26
|
-
"typeElement",
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
// Le serveur enrichit `parent` avec _id/slug/id/profilThumbImageUrl/etc.
|
|
30
|
-
// qui ne sont pas dans le schéma d'envoi (additionalProperties: false → name, type seuls).
|
|
31
|
-
// On filtre via transformEntityRefs à la construction du draft pour rester compatible
|
|
32
|
-
// côté update (pattern identique à Event.transforms).
|
|
33
|
-
override transforms: Record<string, (val: any, full?: any) => any> = {
|
|
34
|
-
parent: transformEntityRefs,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
override _add = async (payload: Record<string, unknown>): Promise<void> => {
|
|
38
|
-
if (!this._calledFromSave) {
|
|
39
|
-
throw new ApiError("utilisation invalide de _add, utilisez save", 400);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
payload.id = this._newId?.();
|
|
43
|
-
// if (payload.slug) delete payload.slug;
|
|
44
|
-
|
|
45
|
-
for (const [constant, methodName] of Array.from(Classified.ADD_BLOCKS)) {
|
|
46
|
-
const blockData = this._extractChangedFieldsFromSchema(
|
|
47
|
-
this.apiClient,
|
|
48
|
-
constant,
|
|
49
|
-
{ ...payload, ...this.defaultFields },
|
|
50
|
-
() => {}
|
|
51
|
-
);
|
|
52
|
-
if (blockData && Object.keys(blockData).length > 0) {
|
|
53
|
-
const data = await (this as any)[methodName](blockData);
|
|
54
|
-
if (!this.id && data?.map?.id) {
|
|
55
|
-
this._draftData.id = data.map.id;
|
|
56
|
-
this._draftData.slug = data.map.slug;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// L'endpoint /co2/element/save (ADD_CLASSIFIED) gère création ET mise à jour selon que
|
|
63
|
-
// l'id existe ou pas côté serveur. On réutilise donc le même schéma pour valider les
|
|
64
|
-
// champs en update (pattern identique à Event._update).
|
|
65
|
-
// Droit de modifier : auteur du classified OU admin d'un parent (orga/projet) si le
|
|
66
|
-
// classified est rattaché.
|
|
67
|
-
override _update = async (payload: Record<string, unknown>): Promise<boolean> => {
|
|
68
|
-
if (!this._calledFromSave) {
|
|
69
|
-
throw new ApiError("utilisation invalide de _update, utilisez save", 400);
|
|
70
|
-
}
|
|
71
|
-
if (!this.isAuthor() && !this.isAdmin({ checkHierarchy: true })) {
|
|
72
|
-
throw new ApiError("Vous n'êtes pas autorisé à modifier cette ressource", 403);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let hasChanged = false;
|
|
76
|
-
|
|
77
|
-
const blockData = this._extractAllValidFieldsFromSchema(
|
|
78
|
-
this.apiClient,
|
|
79
|
-
"ADD_CLASSIFIED",
|
|
80
|
-
{ ...payload, ...this.defaultFields },
|
|
81
|
-
() => this.initialDraftData,
|
|
82
|
-
this.removeFields
|
|
83
|
-
);
|
|
84
|
-
if (blockData && Object.keys(blockData).length > 0) {
|
|
85
|
-
await this.addClassified(blockData);
|
|
86
|
-
hasChanged = true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return hasChanged;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
async addClassified(data: Partial<AddClassifiedData> = {}): Promise<unknown> {
|
|
93
|
-
// Si le parent direct n'est pas l'utilisateur connecté (ex: création via une org),
|
|
94
|
-
// on injecte le parent dans le payload. Sans ça, le default schéma `{ "@userId": ... }`
|
|
95
|
-
// pose me comme parent — ce qui est faux pour `me.org().classified()`.
|
|
96
|
-
// NB: this.isMe est trompeur ici car userContext propage jusqu'au User connecté
|
|
97
|
-
// (donc isMe=true même quand le parent direct est une org).
|
|
98
|
-
// Si le caller fournit déjà `data.parent`, on respecte sa valeur (pas de merge automatique).
|
|
99
|
-
const parentData = data as Record<string, unknown>;
|
|
100
|
-
if (this.parent && this.parent.id && this.parent.id !== this.userId && !parentData.parent) {
|
|
101
|
-
parentData.parent = {};
|
|
102
|
-
const parentMap = parentData.parent as Record<string, unknown>;
|
|
103
|
-
parentMap[`${this.parent.id}`] = {
|
|
104
|
-
type: this.parent.getEntityType(),
|
|
105
|
-
name: (this.parent as unknown as Record<string, unknown>).name,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return this.callIsConnected(() => this.endpointApi.addClassified(data as AddClassifiedData));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
override async getOrganizations(): Promise<never> {
|
|
113
|
-
throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`, 501);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
override async getProjects(): Promise<never> {
|
|
117
|
-
throw new ApiError(`getProjects n'existe pas dans ${this.constructor.name}`, 501);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
override async getEvents(): Promise<never> {
|
|
121
|
-
throw new ApiError(`getEvents n'existe pas dans ${this.constructor.name}`, 501);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
override async getPois(): Promise<never> {
|
|
125
|
-
throw new ApiError(`getPois n'existe pas dans ${this.constructor.name}`, 501);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
override async getBadgesIssuer(): Promise<never> {
|
|
129
|
-
throw new ApiError(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`, 501);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
override async getNews(): Promise<never> {
|
|
133
|
-
throw new ApiError(`getNews n'existe pas dans ${this.constructor.name}`, 501);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
override async project(): Promise<never> {
|
|
137
|
-
throw new ApiError(`project n'existe pas dans ${this.constructor.name}`, 501);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
override async poi(): Promise<never> {
|
|
141
|
-
throw new ApiError(`poi n'existe pas dans ${this.constructor.name}`, 501);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
override async event(): Promise<never> {
|
|
145
|
-
throw new ApiError(`event n'existe pas dans ${this.constructor.name}`, 501);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
override async badge(): Promise<never> {
|
|
149
|
-
throw new ApiError(`badge n'existe pas dans ${this.constructor.name}`, 501);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
override async news(): Promise<never> {
|
|
153
|
-
throw new ApiError(`news n'existe pas dans ${this.constructor.name}`, 501);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
override async classified(): Promise<never> {
|
|
157
|
-
throw new ApiError(`classified n'existe pas dans ${this.constructor.name}`, 501);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
override async form(): Promise<never> {
|
|
161
|
-
throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
override async follow(): Promise<never> {
|
|
165
|
-
throw new ApiError(`follow n'existe pas dans ${this.constructor.name}`, 501);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
override async unfollow(): Promise<never> {
|
|
169
|
-
throw new ApiError(`unfollow n'existe pas dans ${this.constructor.name}`, 501);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
override async getGallery(): Promise<never> {
|
|
173
|
-
throw new ApiError(`getGallery n'existe pas dans ${this.constructor.name}`, 501);
|
|
174
|
-
}
|
|
175
|
-
}
|
package/src/api/Comment.ts
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { ApiError } from "../error.js";
|
|
2
|
-
import { BaseEntity } from "./BaseEntity.js";
|
|
3
|
-
|
|
4
|
-
import type { AddCommentsData, AddReportAbuseData, AddVoteData, DeleteCommentsData, ShowVoteData, UpdateCommentsData } from "./EndpointApi.types.js";
|
|
5
|
-
import type { CommentItemNormalized } from "./serverDataType/Comment.js";
|
|
6
|
-
|
|
7
|
-
export class Comment extends BaseEntity<CommentItemNormalized> {
|
|
8
|
-
static override entityType = "comments";
|
|
9
|
-
|
|
10
|
-
static override entityTag = "Comment";
|
|
11
|
-
|
|
12
|
-
static override SCHEMA_CONSTANTS: string[] = [
|
|
13
|
-
"ADD_COMMENTS"
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
static ADD_BLOCKS = new Map([
|
|
17
|
-
["ADD_COMMENTS", "addComments"]
|
|
18
|
-
] as const);
|
|
19
|
-
|
|
20
|
-
static UPDATE_BLOCKS = new Map([
|
|
21
|
-
["ADD_COMMENTS", "updateComments"]
|
|
22
|
-
] as const);
|
|
23
|
-
|
|
24
|
-
override defaultFields: Record<string, any> = {};
|
|
25
|
-
|
|
26
|
-
override removeFields: string[] = ["contextId", "contextType", "parentCommentId", "argval"];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Transforme les champs imbriqués (author) en instances d'entités.
|
|
30
|
-
* @param data - Les données brutes du serveur.
|
|
31
|
-
* @returns Les données transformées.
|
|
32
|
-
* @protected
|
|
33
|
-
*/
|
|
34
|
-
protected override _transformServerData(data: CommentItemNormalized): CommentItemNormalized {
|
|
35
|
-
// Transformer author en instance User/Organization
|
|
36
|
-
if (data.author) {
|
|
37
|
-
data.author = this._linkNestedEntity(data.author);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (Array.isArray(data.replies)) {
|
|
41
|
-
data.replies = data.replies.map(reply => {
|
|
42
|
-
// Ajouter les propriétés nécessaires pour _linkNestedEntity
|
|
43
|
-
if (reply && typeof reply === "object" && !reply.type) {
|
|
44
|
-
reply.type = "comments";
|
|
45
|
-
reply.collection = "comments";
|
|
46
|
-
}
|
|
47
|
-
return this._linkNestedEntity(reply);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return data;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
override async get(): Promise<never> {
|
|
55
|
-
throw new ApiError(`get n'existe pas dans ${this.constructor.name}`, 501);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
override async save(): Promise<Record<string, any>> {
|
|
59
|
-
// Pour les commentaires, on ne peut pas refresh après save
|
|
60
|
-
// car il n'y a pas d'endpoint GET_COMMENT
|
|
61
|
-
const originalRefresh = this.refresh;
|
|
62
|
-
this.refresh = async () => this._serverData; // No-op
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
return await super.save();
|
|
66
|
-
} finally {
|
|
67
|
-
this.refresh = originalRefresh;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
override _add = async (payload: Record<string, any>): Promise<void> => {
|
|
72
|
-
if (!this._calledFromSave) {
|
|
73
|
-
throw new Error("utilisation invalide de _add, utilisez save");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if(!this.parent?.id){
|
|
77
|
-
throw new Error("Le parent doit être défini pour ajouter un commentaire.");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if(payload.text === ""){
|
|
81
|
-
payload.text = " ";
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Si le parent est un Comment, on met son ID dans parentCommentId
|
|
85
|
-
if(this.parent.getEntityType() === "comments"){
|
|
86
|
-
payload.parentCommentId = this.parent.id;
|
|
87
|
-
// Le contextId et contextType doivent pointer vers l'entité racine (news, etc.)
|
|
88
|
-
// Il faut remonter jusqu'à trouver le parent qui n'est pas un commentaire
|
|
89
|
-
let rootParent = this.parent.parent;
|
|
90
|
-
while(rootParent && rootParent.getEntityType && rootParent.getEntityType() === "comments"){
|
|
91
|
-
rootParent = rootParent.parent;
|
|
92
|
-
}
|
|
93
|
-
if(rootParent){
|
|
94
|
-
payload.contextId = rootParent.id;
|
|
95
|
-
payload.contextType = rootParent.getEntityType();
|
|
96
|
-
} else {
|
|
97
|
-
throw new Error("Impossible de trouver l'entité racine pour le commentaire.");
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
// bug doit mettre une chaîne vide si pas de parentCommentId car dans getComments il y a un bug sur l'api dans la requete
|
|
101
|
-
payload.parentCommentId = payload.parentCommentId || "";
|
|
102
|
-
payload.contextId = this.parent.id;
|
|
103
|
-
payload.contextType = this.parent.getEntityType();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
for (const [constant, methodName] of Array.from(Comment.ADD_BLOCKS)) {
|
|
108
|
-
const blockData = this._extractChangedFieldsFromSchema(
|
|
109
|
-
this.apiClient,
|
|
110
|
-
constant,
|
|
111
|
-
{ ...payload, ...this.defaultFields },
|
|
112
|
-
() => {},
|
|
113
|
-
[]
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
if (blockData && Object.keys(blockData).length > 0) {
|
|
117
|
-
const data = await this._invokeBlockMethod(Comment.ADD_BLOCKS, methodName, blockData);
|
|
118
|
-
// L'API retourne l'ID soit dans data.object.id, soit dans data.id
|
|
119
|
-
const responseId = data?.object?.id || data?.id?.$id || data?.id;
|
|
120
|
-
if (!this.id && responseId) {
|
|
121
|
-
this._draftData.id = responseId;
|
|
122
|
-
this._setData(data.newComment as any, { forceInitialDraftReset: true });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
override _update = async (payload: Record<string, any>): Promise<boolean> => {
|
|
129
|
-
if (!this._calledFromSave) {
|
|
130
|
-
throw new Error("utilisation invalide de _update, utilisez save");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if(!this.parent?.id){
|
|
134
|
-
throw new Error("Le parent doit être défini pour ajouter un commentaire.");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// si le texte est vide, on met un espace pour que le champ soit pris en compte car sur le serveur
|
|
138
|
-
// il y a une vérification de la taille du texte je pense
|
|
139
|
-
if(payload?.text === ""){
|
|
140
|
-
payload.text = " ";
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
payload.params = {
|
|
144
|
-
text: payload.text
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
delete payload.text;
|
|
148
|
-
|
|
149
|
-
let hasChanged = false;
|
|
150
|
-
const data = await this.callIsConnected(() => this.endpointApi.updateComments(payload as UpdateCommentsData)) as any;
|
|
151
|
-
if(data?.comment){
|
|
152
|
-
this._setData(data.comment as any, { forceInitialDraftReset: true });
|
|
153
|
-
}
|
|
154
|
-
hasChanged = true;
|
|
155
|
-
return hasChanged;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
async addComments(data: Partial<AddCommentsData> = {}): Promise<unknown> {
|
|
159
|
-
return this.callIsConnected(() => this.endpointApi.addComments(data as AddCommentsData));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async updateComments(data: Partial<UpdateCommentsData> = {}): Promise<unknown> {
|
|
163
|
-
return this.callIsConnected(() => this.endpointApi.updateComments(data as UpdateCommentsData));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Supprimer un commentaire : Supprime un commentaire existant.
|
|
168
|
-
* Constant : DELETE_COMMENT
|
|
169
|
-
*/
|
|
170
|
-
async delete(): Promise<void> {
|
|
171
|
-
if(!this.id) {
|
|
172
|
-
throw new ApiError("Vous devez fournir un id pour supprimer un commentaire.", 400);
|
|
173
|
-
}
|
|
174
|
-
const data = {
|
|
175
|
-
pathParams: { id: this.id },
|
|
176
|
-
};
|
|
177
|
-
await this.callIsConnected(() => this.endpointApi.deleteComments(data as DeleteCommentsData));
|
|
178
|
-
|
|
179
|
-
// Vider les objets réactifs sans casser la réactivité
|
|
180
|
-
Object.keys(this._draftData).forEach(key => delete this._draftData[key]);
|
|
181
|
-
Object.keys(this._serverData).forEach(key => delete (this._serverData as any)[key]);
|
|
182
|
-
|
|
183
|
-
// Marquer comme supprimé
|
|
184
|
-
this._isDeleted = true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Créer une réponse à ce commentaire (commentaire sur commentaire).
|
|
189
|
-
* @param commentData - Données du commentaire.
|
|
190
|
-
* @returns Instance de Comment.
|
|
191
|
-
*/
|
|
192
|
-
async comment(commentData: Record<string, any> = {}): Promise<Comment> {
|
|
193
|
-
if(!this.isConnected){
|
|
194
|
-
throw new ApiError("Vous devez être connecté.", 401);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const entity = await this.entity("comments", commentData);
|
|
198
|
-
return entity as Comment;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Ajoute un vote sur ce commentaire
|
|
203
|
-
*
|
|
204
|
-
* @param status - Statut du vote (ex: 'like', 'dislike', 'love', etc.)
|
|
205
|
-
* @returns Promise contenant la réponse de l'API après l'ajout du vote
|
|
206
|
-
* @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
|
|
207
|
-
*/
|
|
208
|
-
async addVote(status: string){
|
|
209
|
-
if (!this.id) {
|
|
210
|
-
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const payload: AddVoteData = {
|
|
214
|
-
collection: "comments",
|
|
215
|
-
id: this.id,
|
|
216
|
-
action: "vote",
|
|
217
|
-
details: {
|
|
218
|
-
status
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return await this.callIsConnected(() => this.endpointApi.addVote(payload));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Récupère la liste des votes (like, love, etc.) sur ce commentaire.
|
|
227
|
-
*
|
|
228
|
-
* Wrap de `SHOW_VOTE` avec auto-injection du `type` (`"comments"`) et de
|
|
229
|
-
* `this.id` dans `pathParams`. Le retour contient `vote` (votes individuels
|
|
230
|
-
* indexés par userId) et `voteCount` (compteurs par statut).
|
|
231
|
-
*
|
|
232
|
-
* @returns Réponse API : `{ _id, vote, voteCount }` ou variante d'erreur.
|
|
233
|
-
* @throws {ApiError} 404 si le commentaire n'a pas d'id (non enregistré).
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* const votes = await comment.getVotes();
|
|
237
|
-
* votes.voteCount?.like; // nombre de likes
|
|
238
|
-
* votes.vote?.[userId]; // vote détaillé d'un user
|
|
239
|
-
*/
|
|
240
|
-
async getVotes(): Promise<unknown> {
|
|
241
|
-
if (!this.id) {
|
|
242
|
-
throw new ApiError(`${this.constructor.name} non enregistré.`, 404);
|
|
243
|
-
}
|
|
244
|
-
const payload: ShowVoteData = {
|
|
245
|
-
pathParams: { type: "comments", id: this.id },
|
|
246
|
-
};
|
|
247
|
-
return this.endpointApi.showVote(payload);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Signale un abus sur ce commentaire
|
|
252
|
-
*
|
|
253
|
-
* @param params - Paramètres du signalement
|
|
254
|
-
* @param params.reason - Raison du signalement
|
|
255
|
-
* @param params.comment - Commentaire expliquant le signalement (optionnel)
|
|
256
|
-
* @returns Promise contenant la réponse de l'API après le signalement
|
|
257
|
-
* @throws {ApiError} Si la news n'a pas d'ID (non enregistrée)
|
|
258
|
-
*/
|
|
259
|
-
async addReportAbuse({ reason, comment }: { reason: string, comment?: string}){
|
|
260
|
-
if (!this.id) {
|
|
261
|
-
throw new ApiError(`${this.constructor.name} non enregistrée.`, 404);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const payload: AddReportAbuseData = {
|
|
265
|
-
collection: "comments",
|
|
266
|
-
id: this.id,
|
|
267
|
-
action: "reportAbuse",
|
|
268
|
-
details: {
|
|
269
|
-
reason,
|
|
270
|
-
comment
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
return await this.callIsConnected(() => this.endpointApi.addReportAbuse(payload));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
override async form(): Promise<never> {
|
|
278
|
-
throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
|
|
279
|
-
}
|
|
280
|
-
}
|