@communecter/cocolight-api-client 1.0.154 → 1.0.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/BaseEntity.d.ts +24 -0
- package/types/api/EndpointApi.d.ts +4 -4
- package/types/api/EndpointApi.types.d.ts +3 -3
- package/types/utils/OfflineClientManager.d.ts +8 -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 -6338
- 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
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
// TypeScript native types
|
|
2
|
-
import type { CollectionType } from "../types/entities.js";
|
|
3
|
-
|
|
4
|
-
export type EntityTag = "User" | "Organization" | "Project" | "Event" | "Poi" | "Badge" | "News" | "Comment" | "Answer" | "Form" | "Classified" | "Action";
|
|
5
|
-
export type CollectionKey = CollectionType; // Alias pour compatibilité
|
|
6
|
-
type BaseEntity = import("./BaseEntity.js").BaseEntity<any>;
|
|
7
|
-
type ApiClient = import("../ApiClient.js").default;
|
|
8
|
-
|
|
9
|
-
type EndpointApiClass = typeof import("./EndpointApi.js").default;
|
|
10
|
-
type EntityConstructor = new (...args: any[]) => BaseEntity;
|
|
11
|
-
type EntityClass = EntityConstructor & {
|
|
12
|
-
fromJSON?: (json: unknown, parent?: ApiClient | BaseEntity | null, deps?: EntityDeps) => BaseEntity;
|
|
13
|
-
};
|
|
14
|
-
type EntityDeps = Partial<Record<EntityTag | "EndpointApi", EntityClass | EndpointApiClass | undefined>>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Métadonnées de construction d'entité.
|
|
18
|
-
*/
|
|
19
|
-
type EntityMeta = {
|
|
20
|
-
entityClass: EntityClass;
|
|
21
|
-
deps: EntityDeps;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Types minimaux pour le JSON d'entité
|
|
26
|
-
*/
|
|
27
|
-
type MinimalEntityJSON = {
|
|
28
|
-
__entityTag: EntityTag;
|
|
29
|
-
serverData?: {
|
|
30
|
-
collection?: CollectionKey;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const EntityRegistry: Map<EntityTag | "EndpointApi", EntityClass | EndpointApiClass> = new Map();
|
|
35
|
-
|
|
36
|
-
// Overloads for registerEntity
|
|
37
|
-
export function registerEntity(tag: "EndpointApi", EntityClass: EndpointApiClass): void;
|
|
38
|
-
export function registerEntity(tag: EntityTag, EntityClass: EntityClass): void;
|
|
39
|
-
export function registerEntity(tag: EntityTag | "EndpointApi", EntityClass: EntityClass | EndpointApiClass): void {
|
|
40
|
-
EntityRegistry.set(tag, EntityClass);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Type guard: vérifie si la valeur ressemble à un JSON d'entité.
|
|
46
|
-
*/
|
|
47
|
-
function isEntityJSON(v: unknown): v is MinimalEntityJSON {
|
|
48
|
-
return !!v && typeof v === "object"
|
|
49
|
-
&& "__entityTag" in (v as any);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Récupère une instance depuis un JSON générique.
|
|
54
|
-
* Si la collection ou la métadonnée d'entité est absente, renvoie l'objet d'origine.
|
|
55
|
-
*/
|
|
56
|
-
export function fromEntityJSON(json: unknown, parent: ApiClient | BaseEntity | null = null): BaseEntity | unknown | null {
|
|
57
|
-
// On gère null / non-objet / pas une entité → on renvoie tel quel (ou null si tu préfères)
|
|
58
|
-
if (!isEntityJSON(json)) return json;
|
|
59
|
-
|
|
60
|
-
// Vérifier si l'entité a son propre parent sérialisé
|
|
61
|
-
let actualParent = parent;
|
|
62
|
-
const entityJson = json as any;
|
|
63
|
-
if (entityJson.parent && typeof entityJson.parent === "object") {
|
|
64
|
-
// Vérifier si le parent passé correspond déjà au parent sérialisé
|
|
65
|
-
const serializedParent = entityJson.parent;
|
|
66
|
-
const parentId = serializedParent.serverData?.id || serializedParent.id;
|
|
67
|
-
|
|
68
|
-
if (parent && "id" in parent && parent.id === parentId) {
|
|
69
|
-
// Le parent passé est déjà le bon, on l'utilise directement
|
|
70
|
-
actualParent = parent as BaseEntity;
|
|
71
|
-
} else {
|
|
72
|
-
// Reconstruire le parent depuis les données sérialisées en transmettant le parent original
|
|
73
|
-
const reconstructedParent = fromEntityJSON(entityJson.parent, parent);
|
|
74
|
-
// Vérifier que c'est bien une BaseEntity avant de l'utiliser
|
|
75
|
-
if (reconstructedParent && typeof reconstructedParent === "object" && "id" in reconstructedParent) {
|
|
76
|
-
actualParent = reconstructedParent as BaseEntity;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Récupérer la collection depuis serverData, ou la dériver depuis __entityTag
|
|
82
|
-
let collection: CollectionKey | null | undefined = json.serverData?.collection;
|
|
83
|
-
|
|
84
|
-
// Si collection est absente, essayer de la dériver depuis __entityTag
|
|
85
|
-
if (!collection) {
|
|
86
|
-
collection = _getCollectionFromTag(json.__entityTag);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Si on n'a toujours pas de collection, on ne peut pas désérialiser
|
|
90
|
-
if (!collection) return json;
|
|
91
|
-
|
|
92
|
-
const meta = _getEntityMeta(collection, json.__entityTag);
|
|
93
|
-
if (!meta) return json;
|
|
94
|
-
|
|
95
|
-
if (!meta.entityClass?.fromJSON) {
|
|
96
|
-
throw new Error(`Classe inconnue ou fromJSON manquant pour ${json.__entityTag}`);
|
|
97
|
-
}
|
|
98
|
-
return meta.entityClass.fromJSON(json, actualParent, meta.deps);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Walker récursif : parcourt un objet/tableau et ressuscite toutes les entités
|
|
103
|
-
* sérialisées (marqueurs `__isSerializedEntity` / `__entityTag`) rencontrées.
|
|
104
|
-
*
|
|
105
|
-
* Pensé pour les wrappers non-entité retournés par certains endpoints (ex: `fundingEnvelope`)
|
|
106
|
-
* ou pour réhydrater un état côté client après un transfert JSON (SSR, cache restore).
|
|
107
|
-
*
|
|
108
|
-
* Dates, RegExp et primitives sont préservées. Pour les entités, la chaîne de parents
|
|
109
|
-
* est reconstruite automatiquement depuis les méta embarquées par `toJSON()`.
|
|
110
|
-
*
|
|
111
|
-
* @param obj - L'objet à parcourir (wrapper, array, primitive…)
|
|
112
|
-
* @param parent - Parent racine (typiquement l'ApiClient côté client)
|
|
113
|
-
* @returns L'objet avec toutes les entités revived
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* // Côté client SSR : revive l'état dehydraté
|
|
117
|
-
* const apiClient = new ApiClient({ baseURL });
|
|
118
|
-
* const envelope = reviveEntities(window.__INIT__.envelope, apiClient);
|
|
119
|
-
* envelope.projects[0].serverData.actions[0]; // Action instance
|
|
120
|
-
*/
|
|
121
|
-
export function reviveEntities<T = unknown>(
|
|
122
|
-
obj: unknown,
|
|
123
|
-
parent: ApiClient | BaseEntity | null = null
|
|
124
|
-
): T {
|
|
125
|
-
if (obj === null || obj === undefined) return obj as T;
|
|
126
|
-
if (typeof obj !== "object") return obj as T;
|
|
127
|
-
if (obj instanceof Date || obj instanceof RegExp) return obj as T;
|
|
128
|
-
|
|
129
|
-
if (isEntityJSON(obj)) {
|
|
130
|
-
return fromEntityJSON(obj, parent) as T;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (Array.isArray(obj)) {
|
|
134
|
-
return obj.map(item => reviveEntities(item, parent)) as T;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const result: Record<string, unknown> = {};
|
|
138
|
-
for (const [key, value] of Object.entries(obj as object)) {
|
|
139
|
-
result[key] = reviveEntities(value, parent);
|
|
140
|
-
}
|
|
141
|
-
return result as T;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Mappe un EntityTag vers son CollectionKey correspondant.
|
|
146
|
-
*/
|
|
147
|
-
function _getCollectionFromTag(tag: EntityTag): CollectionKey | null {
|
|
148
|
-
const map: Record<EntityTag, CollectionKey> = {
|
|
149
|
-
"User": "citoyens",
|
|
150
|
-
"Organization": "organizations",
|
|
151
|
-
"Project": "projects",
|
|
152
|
-
"Event": "events",
|
|
153
|
-
"Poi": "poi",
|
|
154
|
-
"News": "news",
|
|
155
|
-
"Badge": "badges",
|
|
156
|
-
"Comment": "comments",
|
|
157
|
-
"Answer": "answers",
|
|
158
|
-
"Form": "forms",
|
|
159
|
-
"Classified": "classifieds",
|
|
160
|
-
"Action": "actions"
|
|
161
|
-
};
|
|
162
|
-
return map[tag] || null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Récupère la classe d'entité et ses dépendances à partir du type d'entité.
|
|
167
|
-
*/
|
|
168
|
-
function _getEntityMeta(entityType: CollectionKey, __entityTag: EntityTag): EntityMeta | null {
|
|
169
|
-
const selfClass = EntityRegistry.get(__entityTag);
|
|
170
|
-
const selfTag = __entityTag;
|
|
171
|
-
|
|
172
|
-
const commonDeps: EntityDeps = {
|
|
173
|
-
EndpointApi: EntityRegistry.get("EndpointApi"),
|
|
174
|
-
User: selfTag === "User" ? selfClass : EntityRegistry.get("User"),
|
|
175
|
-
Organization: selfTag === "Organization" ? selfClass : EntityRegistry.get("Organization"),
|
|
176
|
-
Project: selfTag === "Project" ? selfClass : EntityRegistry.get("Project"),
|
|
177
|
-
Event: selfTag === "Event" ? selfClass : EntityRegistry.get("Event"),
|
|
178
|
-
Poi: selfTag === "Poi" ? selfClass : EntityRegistry.get("Poi"),
|
|
179
|
-
Badge: selfTag === "Badge" ? selfClass : EntityRegistry.get("Badge"),
|
|
180
|
-
News: selfTag === "News" ? selfClass : EntityRegistry.get("News"),
|
|
181
|
-
Comment: selfTag === "Comment" ? selfClass : EntityRegistry.get("Comment"),
|
|
182
|
-
Answer: selfTag === "Answer" ? selfClass : EntityRegistry.get("Answer"),
|
|
183
|
-
Form: selfTag === "Form" ? selfClass : EntityRegistry.get("Form"),
|
|
184
|
-
Classified: selfTag === "Classified" ? selfClass : EntityRegistry.get("Classified"),
|
|
185
|
-
Action: selfTag === "Action" ? selfClass : EntityRegistry.get("Action"),
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const map: Record<CollectionKey, EntityMeta> = {
|
|
189
|
-
citoyens: { entityClass: commonDeps.User as EntityClass, deps: commonDeps },
|
|
190
|
-
organizations:{ entityClass: commonDeps.Organization as EntityClass, deps: commonDeps },
|
|
191
|
-
projects: { entityClass: commonDeps.Project as EntityClass, deps: commonDeps },
|
|
192
|
-
events: { entityClass: commonDeps.Event as EntityClass, deps: { ...commonDeps, Badge: undefined } },
|
|
193
|
-
poi: { entityClass: commonDeps.Poi as EntityClass, deps: { ...commonDeps, Badge: undefined, News: undefined, Comment: undefined } },
|
|
194
|
-
news: { entityClass: commonDeps.News as EntityClass, deps: { ...commonDeps } },
|
|
195
|
-
badges: { entityClass: commonDeps.Badge as EntityClass, deps: {
|
|
196
|
-
EndpointApi: commonDeps.EndpointApi,
|
|
197
|
-
User: commonDeps.User,
|
|
198
|
-
Organization: commonDeps.Organization,
|
|
199
|
-
Project: commonDeps.Project
|
|
200
|
-
} },
|
|
201
|
-
comments: { entityClass: commonDeps.Comment as EntityClass, deps: { ...commonDeps } },
|
|
202
|
-
answers: { entityClass: commonDeps.Answer as EntityClass, deps: { ...commonDeps } },
|
|
203
|
-
forms: { entityClass: commonDeps.Form as EntityClass, deps: { ...commonDeps } },
|
|
204
|
-
classifieds: { entityClass: commonDeps.Classified as EntityClass, deps: { ...commonDeps, Badge: undefined, News: undefined } },
|
|
205
|
-
actions: { entityClass: commonDeps.Action as EntityClass, deps: { ...commonDeps } },
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
return map[entityType] || null;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type CollectionMapEntry = {
|
|
212
|
-
entityTag: EntityTag;
|
|
213
|
-
meta: (tag: EntityTag) => EntityMeta;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Crée une instance d'entité basée sur le seul nom de la collection.
|
|
218
|
-
*/
|
|
219
|
-
export function createFromCollection(collection: CollectionKey, parent: ApiClient | BaseEntity | null = null, data: object = {}): BaseEntity | null {
|
|
220
|
-
const _collectionMap: Record<CollectionKey, CollectionMapEntry> = {
|
|
221
|
-
citoyens: {
|
|
222
|
-
entityTag: "User",
|
|
223
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
224
|
-
},
|
|
225
|
-
organizations: {
|
|
226
|
-
entityTag: "Organization",
|
|
227
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
228
|
-
},
|
|
229
|
-
projects: {
|
|
230
|
-
entityTag: "Project",
|
|
231
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
232
|
-
},
|
|
233
|
-
events: {
|
|
234
|
-
entityTag: "Event",
|
|
235
|
-
meta: tag => _buildMeta(tag, { remove: ["Badge"] })
|
|
236
|
-
},
|
|
237
|
-
poi: {
|
|
238
|
-
entityTag: "Poi",
|
|
239
|
-
meta: tag => _buildMeta(tag, { remove: ["Badge","News","Comments"] })
|
|
240
|
-
},
|
|
241
|
-
news: {
|
|
242
|
-
entityTag: "News",
|
|
243
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
244
|
-
},
|
|
245
|
-
badges: {
|
|
246
|
-
entityTag: "Badge",
|
|
247
|
-
meta: () => _buildCustomMeta("Badge")
|
|
248
|
-
},
|
|
249
|
-
comments: {
|
|
250
|
-
entityTag: "Comment",
|
|
251
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
252
|
-
},
|
|
253
|
-
answers: {
|
|
254
|
-
entityTag: "Answer",
|
|
255
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
256
|
-
},
|
|
257
|
-
forms: {
|
|
258
|
-
entityTag: "Form",
|
|
259
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
260
|
-
},
|
|
261
|
-
classifieds: {
|
|
262
|
-
entityTag: "Classified",
|
|
263
|
-
meta: tag => _buildMeta(tag, { remove: ["Badge","News"] })
|
|
264
|
-
},
|
|
265
|
-
actions: {
|
|
266
|
-
entityTag: "Action",
|
|
267
|
-
meta: tag => _buildMeta(tag, { remove: [] })
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
const entry = _collectionMap[collection];
|
|
271
|
-
if (!entry) {
|
|
272
|
-
console.warn(`Collection inconnue : '${collection}'`);
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
const { entityTag, meta } = entry;
|
|
276
|
-
const { entityClass, deps } = meta(entityTag);
|
|
277
|
-
if (!entityClass) {
|
|
278
|
-
throw new Error(`EntityClass introuvable pour ${entityTag}`);
|
|
279
|
-
}
|
|
280
|
-
const Ctor = entityClass as EntityConstructor;
|
|
281
|
-
return new Ctor(parent, data, deps);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Construit entityClass et deps pour une collection standard.
|
|
286
|
-
*/
|
|
287
|
-
function _buildMeta(tag: EntityTag, options: { remove: string[] }): EntityMeta {
|
|
288
|
-
const EntityClass = EntityRegistry.get(tag) as EntityClass;
|
|
289
|
-
const allDeps: EntityDeps = {
|
|
290
|
-
EndpointApi: EntityRegistry.get("EndpointApi"),
|
|
291
|
-
User: EntityRegistry.get("User"),
|
|
292
|
-
Organization: EntityRegistry.get("Organization"),
|
|
293
|
-
Project: EntityRegistry.get("Project"),
|
|
294
|
-
Event: EntityRegistry.get("Event"),
|
|
295
|
-
Poi: EntityRegistry.get("Poi"),
|
|
296
|
-
Badge: EntityRegistry.get("Badge"),
|
|
297
|
-
News: EntityRegistry.get("News"),
|
|
298
|
-
Comment: EntityRegistry.get("Comment"),
|
|
299
|
-
Answer: EntityRegistry.get("Answer"),
|
|
300
|
-
Form: EntityRegistry.get("Form"),
|
|
301
|
-
Classified: EntityRegistry.get("Classified"),
|
|
302
|
-
Action: EntityRegistry.get("Action")
|
|
303
|
-
};
|
|
304
|
-
// inject self
|
|
305
|
-
(allDeps as any)[tag] = EntityClass;
|
|
306
|
-
// remove undesired
|
|
307
|
-
options.remove.forEach(dep => delete (allDeps as any)[dep]);
|
|
308
|
-
return { entityClass: EntityClass, deps: allDeps };
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Cas spécifique des badges : seules certaines dépendances.
|
|
313
|
-
*/
|
|
314
|
-
function _buildCustomMeta(tag: "Badge" | "Answer"): EntityMeta {
|
|
315
|
-
const EntityClass = EntityRegistry.get(tag) as EntityClass;
|
|
316
|
-
const deps: EntityDeps = {
|
|
317
|
-
EndpointApi: EntityRegistry.get("EndpointApi"),
|
|
318
|
-
User: EntityRegistry.get("User"),
|
|
319
|
-
Organization: EntityRegistry.get("Organization"),
|
|
320
|
-
Project: EntityRegistry.get("Project")
|
|
321
|
-
};
|
|
322
|
-
(deps as any)[tag] = EntityClass;
|
|
323
|
-
return { entityClass: EntityClass, deps };
|
|
324
|
-
}
|
package/src/api/Event.ts
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { ApiError } from "../error.js";
|
|
2
|
-
import { BaseEntity, PaginatorPage, PaginatorState } from "./BaseEntity.js";
|
|
3
|
-
import { transformEntityRefs } from "../types/transforms.js";
|
|
4
|
-
|
|
5
|
-
import type { AddEventData, GetAttendeesAdminData, GetAttendeesNoAdminData } from "./EndpointApi.types.js";
|
|
6
|
-
import type { User } from "./User.js";
|
|
7
|
-
import type { EventTransforms } from "../types/transforms.js";
|
|
8
|
-
|
|
9
|
-
type EventItemNormalized = import("./serverDataType/Event.js").EventItemNormalized;
|
|
10
|
-
|
|
11
|
-
export class Event extends BaseEntity<EventItemNormalized> {
|
|
12
|
-
static override entityType = "events";
|
|
13
|
-
static override entityTag = "Event";
|
|
14
|
-
|
|
15
|
-
/** Bloc de création où injecter les champs costum (CostumScope). */
|
|
16
|
-
static override COSTUM_ADD_CONSTANT = "ADD_EVENT";
|
|
17
|
-
|
|
18
|
-
static override SCHEMA_CONSTANTS: string[] = [
|
|
19
|
-
"ADD_EVENT",
|
|
20
|
-
"UPDATE_BLOCK_SLUG",
|
|
21
|
-
"PROFIL_IMAGE"
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
static ADD_BLOCKS = new Map([
|
|
25
|
-
["ADD_EVENT", "addEvent"],
|
|
26
|
-
["PROFIL_IMAGE", "updateImageProfil"]
|
|
27
|
-
] as const);
|
|
28
|
-
|
|
29
|
-
static UPDATE_BLOCKS = new Map([
|
|
30
|
-
["UPDATE_BLOCK_SLUG", "updateSlug"],
|
|
31
|
-
["PROFIL_IMAGE", "updateImageProfil"]
|
|
32
|
-
] as const);
|
|
33
|
-
|
|
34
|
-
override defaultFields: Record<string, any> = {
|
|
35
|
-
typeElement: this.getEntityType()
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
override removeFields: string[] = [
|
|
39
|
-
"typeElement"
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
override transforms: EventTransforms = {
|
|
43
|
-
parent: transformEntityRefs,
|
|
44
|
-
organizer: transformEntityRefs
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
override _add = async (payload: Record<string, any>): Promise<void> => {
|
|
48
|
-
if (!this._calledFromSave) {
|
|
49
|
-
throw new ApiError("utilisation invalide de _add, utilisez save", 400);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
payload.id = this._newId?.();
|
|
53
|
-
if (payload.slug) delete payload.slug;
|
|
54
|
-
|
|
55
|
-
for (const [constant, methodName] of Array.from(Event.ADD_BLOCKS)) {
|
|
56
|
-
const blockData = this._extractChangedFieldsFromSchema(
|
|
57
|
-
this.apiClient,
|
|
58
|
-
constant,
|
|
59
|
-
{ ...payload, ...this.defaultFields },
|
|
60
|
-
() => {}
|
|
61
|
-
);
|
|
62
|
-
if (blockData && Object.keys(blockData).length > 0) {
|
|
63
|
-
const data = await this._invokeBlockMethod(Event.ADD_BLOCKS, methodName, blockData);
|
|
64
|
-
if (!this.id && data?.map?.id) {
|
|
65
|
-
this._draftData.id = data.map.id;
|
|
66
|
-
this._draftData.slug = data.map.slug;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
override _update = async (payload: Record<string, any>): Promise<boolean> => {
|
|
73
|
-
if(!this.isAdmin({ checkHierarchy: true })){
|
|
74
|
-
throw new ApiError("Vous n'avez pas les droits pour modifier cet événement", 403);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!this._calledFromSave) {
|
|
78
|
-
throw new ApiError("utilisation invalide de _update, utilisez save", 400);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Entité costum-scopée : tout l'UPDATE part en UN `element/save` (pendant de l'ADD, hooks costum). cf. BaseEntity.
|
|
82
|
-
if (this._costumCtx) return this._saveCostumViaElementSave(payload);
|
|
83
|
-
|
|
84
|
-
let hasChanged = false;
|
|
85
|
-
|
|
86
|
-
const blockData = this._extractAllValidFieldsFromSchema(
|
|
87
|
-
this.apiClient,
|
|
88
|
-
"ADD_EVENT",
|
|
89
|
-
{ ...payload, ...this.defaultFields },
|
|
90
|
-
() => this.initialDraftData,
|
|
91
|
-
this.removeFields
|
|
92
|
-
);
|
|
93
|
-
if (blockData && Object.keys(blockData).length > 0) {
|
|
94
|
-
await this["addEvent"](blockData);
|
|
95
|
-
hasChanged = true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (payload.id) delete payload.id;
|
|
99
|
-
|
|
100
|
-
for (const [constant, methodName] of Array.from(Event.UPDATE_BLOCKS)) {
|
|
101
|
-
const blockData = this._extractChangedFieldsFromSchema(
|
|
102
|
-
this.apiClient,
|
|
103
|
-
constant,
|
|
104
|
-
{ ...payload, ...this.defaultFields },
|
|
105
|
-
() => this.initialDraftData,
|
|
106
|
-
this.removeFields
|
|
107
|
-
);
|
|
108
|
-
if (blockData && Object.keys(blockData).length > 0) {
|
|
109
|
-
await this._invokeBlockMethod(Event.UPDATE_BLOCKS, methodName, blockData);
|
|
110
|
-
hasChanged = true;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return hasChanged;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
async addEvent(data: Partial<AddEventData> = {}): Promise<unknown> {
|
|
118
|
-
|
|
119
|
-
// Si le parent direct n'est pas l'utilisateur connecté (ex: création via une org),
|
|
120
|
-
// on injecte l'organizer dans le payload. Sans ça, le default schéma `{ "@userId": ... }`
|
|
121
|
-
// pose me comme organizer — ce qui est faux pour `me.org().event()`.
|
|
122
|
-
// NB: this.isMe est trompeur ici car userContext propage jusqu'au User connecté
|
|
123
|
-
// (donc isMe=true même quand le parent direct est une org).
|
|
124
|
-
if (this.parent && this.parent.id && this.parent.id !== this.userId && !data.organizer) {
|
|
125
|
-
(data as any).organizer = {};
|
|
126
|
-
(data as any).organizer[`${this.parent.id}`] = {
|
|
127
|
-
type: this.parent.getEntityType(),
|
|
128
|
-
name: (this.parent as any).name
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return this.callIsConnected(() => this.endpointApi.addEvent(data as AddEventData));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Supprime cet événement via `DELETE_ELEMENT` (`type=events`).
|
|
137
|
-
*
|
|
138
|
-
* **Garde** : auteur de l'événement (`serverData.creator`) OU administrateur
|
|
139
|
-
* de l'organisation/projet organisateur (via `serverData.organizer` × hiérarchie).
|
|
140
|
-
* cf. {@link BaseEntity#_deleteViaElement}.
|
|
141
|
-
*
|
|
142
|
-
* Après succès : données vidées + `_isDeleted = true`.
|
|
143
|
-
*
|
|
144
|
-
* @param reason - Raison transmise au backend (audit). Défaut `"delete event"`.
|
|
145
|
-
* @throws {ApiError} 400 si l'événement n'a pas d'id.
|
|
146
|
-
* @throws {ApiError} 403 si ni auteur ni admin de l'organisateur.
|
|
147
|
-
*/
|
|
148
|
-
async delete(reason: string = "delete event"): Promise<void> {
|
|
149
|
-
await this._deleteViaElement(this.getEntityType(), reason);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
override async getOrganizations(): Promise<never> {
|
|
154
|
-
throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`, 501);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
override async getProjects(): Promise<never> {
|
|
159
|
-
throw new ApiError(`getProjects n'existe pas dans ${this.constructor.name}`, 501);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
override async getEvents(): Promise<never> {
|
|
164
|
-
throw new ApiError(`getEvents - les sous-events ne sont pas encore implémentés dans ${this.constructor.name}`, 501);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
override async getPois(): Promise<never> {
|
|
169
|
-
throw new ApiError(`getPois n'existe pas dans ${this.constructor.name}`, 501);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
override async getBadgesIssuer(): Promise<never> {
|
|
174
|
-
throw new ApiError(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`, 501);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* {@inheritDoc BaseEntity#getNews}
|
|
179
|
-
*
|
|
180
|
-
* Récupère les actualités de l'événement.
|
|
181
|
-
*/
|
|
182
|
-
override async getNews(data: Parameters<BaseEntity<EventItemNormalized>["getNews"]>[0] = {}) {
|
|
183
|
-
return super.getNews(data);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* {@inheritDoc BaseEntity#getSubscribers}
|
|
188
|
-
*
|
|
189
|
-
* Récupère les abonnés de l'événement.
|
|
190
|
-
*/
|
|
191
|
-
override async getSubscribers(data: Parameters<BaseEntity<EventItemNormalized>["getSubscribers"]>[0] = {}) {
|
|
192
|
-
return super.getSubscribers(data);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Récupérer les participants d'un événement.
|
|
197
|
-
* Constant : GET_ATTENDEES_NO_ADMIN
|
|
198
|
-
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
199
|
-
* @param options - Options supplémentaires.
|
|
200
|
-
* @param options.toBeValidated - Indique si les participants doivent être validés.
|
|
201
|
-
* @param options.isAdmin - Indique si l'utilisateur est admin.
|
|
202
|
-
* @param options.isInviting - Indique si l'utilisateur est en attente d'invitation.
|
|
203
|
-
* @param options.roles - Liste des rôles à filtrer.
|
|
204
|
-
* @param isNext - Indique si c'est une recherche suivante (pagination).
|
|
205
|
-
* @returns - Un objet contenant le nombre de participants et la liste des participants.
|
|
206
|
-
* @throws {ApiResponseError} - Si une erreur se produit lors de la récupération des participants.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* // Récupérer tous les participants
|
|
210
|
-
* const participants = await project.getAttendees();
|
|
211
|
-
*
|
|
212
|
-
* // Récupérer les participants avec validation en attente
|
|
213
|
-
* const participantsToBeValidated = await project.getAttendees({}, { toBeValidated: true });
|
|
214
|
-
*
|
|
215
|
-
* // Récupérer les participants avec un rôle spécifique
|
|
216
|
-
* const contributorsWithRole = await project.getAttendees({}, { roles: ["admin"] });
|
|
217
|
-
*
|
|
218
|
-
* // Récupérer les participants administrateurs
|
|
219
|
-
* const adminParticipants = await project.getAttendees({}, { isAdmin: true });
|
|
220
|
-
*
|
|
221
|
-
* // Récupérer les participants en attente d'invitation
|
|
222
|
-
* const invitingParticipants = await project.getAttendees({}, { isInviting: true });
|
|
223
|
-
*
|
|
224
|
-
*/
|
|
225
|
-
async getAttendees(
|
|
226
|
-
data: Partial<GetAttendeesNoAdminData | GetAttendeesAdminData> = {},
|
|
227
|
-
options: {
|
|
228
|
-
toBeValidated?: boolean;
|
|
229
|
-
isAdmin?: boolean;
|
|
230
|
-
isAdminPending?: boolean;
|
|
231
|
-
isInviting?: boolean;
|
|
232
|
-
roles?: any[];
|
|
233
|
-
restoredState?: PaginatorState;
|
|
234
|
-
} = {}
|
|
235
|
-
): Promise<PaginatorPage<User>> {
|
|
236
|
-
data.searchType = this._getDefaultFromEndpoint("GET_ATTENDEES_NO_ADMIN", "searchType") as GetAttendeesNoAdminData["searchType"];
|
|
237
|
-
// data.searchBy = "ALL";
|
|
238
|
-
|
|
239
|
-
const paginator = this._createPaginatorEngine({
|
|
240
|
-
initialData: data,
|
|
241
|
-
methodName: "getAttendees",
|
|
242
|
-
restoredState: options?.restoredState,
|
|
243
|
-
finalizer: async (finalData) => {
|
|
244
|
-
|
|
245
|
-
const { toBeValidated, isAdmin, isInviting, isAdminPending, roles = [] } = options;
|
|
246
|
-
|
|
247
|
-
if(this.isMe){
|
|
248
|
-
finalData.pathParams = { id: this.id };
|
|
249
|
-
// NOTE : dans le schema je crois que si pas de finalData.filters alors le default ce fait avec finalData.pathParams
|
|
250
|
-
// finalData.filters = {
|
|
251
|
-
// [`links.events.${this.id}`]: { "$exists": true },
|
|
252
|
-
// [`links.events.${this.id}.toBeValidated`]: { "$exists": false },
|
|
253
|
-
// [`links.events.${this.id}.isInviting`]: { "$exists": false }
|
|
254
|
-
// };
|
|
255
|
-
finalData.filters = this._buildLinkFilters(this.id, { linkType: "events", toBeValidated, isAdmin, isAdminPending, isInviting, roles });
|
|
256
|
-
} else {
|
|
257
|
-
delete finalData?.pathParams;
|
|
258
|
-
finalData.filters = this._buildLinkFilters(this.id, { linkType: "events", toBeValidated: false, isAdmin, isInviting, roles });
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const fetchFn = this.isMe
|
|
262
|
-
? () => this.callIsMe(() => this.endpointApi.getAttendeesAdmin(finalData))
|
|
263
|
-
: () => this.endpointApi.getAttendeesNoAdmin(finalData);
|
|
264
|
-
|
|
265
|
-
return fetchFn();
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
return paginator.next() as Promise<PaginatorPage<User>>;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
override async project(): Promise<never> {
|
|
273
|
-
throw new ApiError(`project n'existe pas dans ${this.constructor.name}`, 501);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
override async poi(): Promise<never> {
|
|
278
|
-
throw new ApiError(`poi n'existe pas dans ${this.constructor.name}`, 501);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
override async form(): Promise<never> {
|
|
283
|
-
throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
override async event(): Promise<never> {
|
|
288
|
-
throw new ApiError(`les sous-events ne sont pas encore implémentés dans ${this.constructor.name}`, 501);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
override async badge(): Promise<never> {
|
|
293
|
-
throw new ApiError(`badge n'existe pas dans ${this.constructor.name}`, 501);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* {@inheritDoc BaseEntity#news}
|
|
298
|
-
*
|
|
299
|
-
* Crée une instance de news et la récupère si nécessaire.
|
|
300
|
-
*/
|
|
301
|
-
override async news(newsData: Parameters<BaseEntity<EventItemNormalized>["news"]>[0] = {}) {
|
|
302
|
-
return super.news(newsData);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* ───────────────────────────────
|
|
307
|
-
* Lien utilisateur ↔ event
|
|
308
|
-
* (participation, abonnement)
|
|
309
|
-
* ───────────────────────────────
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* {@inheritDoc BaseEntity#requestToJoin}
|
|
314
|
-
*
|
|
315
|
-
* Rejoindre l'événement en tant que participant.
|
|
316
|
-
*/
|
|
317
|
-
override async requestToJoin() {
|
|
318
|
-
return super.requestToJoin();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* {@inheritDoc BaseEntity#acceptInvitation}
|
|
323
|
-
*
|
|
324
|
-
* Accepte une invitation à rejoindre l'événement.
|
|
325
|
-
* Cette action valide un lien en attente avec l'option `isInviting`.
|
|
326
|
-
*/
|
|
327
|
-
override async acceptInvitation() {
|
|
328
|
-
return super.acceptInvitation();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* {@inheritDoc BaseEntity#leave}
|
|
333
|
-
*
|
|
334
|
-
* Quitte l'événement, que ce soit en tant que participant ou administrateur.
|
|
335
|
-
* Cette action supprime le lien entre l'utilisateur et l'événement.
|
|
336
|
-
*/
|
|
337
|
-
override async leave() {
|
|
338
|
-
return super.leave();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* {@inheritDoc BaseEntity#follow}
|
|
343
|
-
*
|
|
344
|
-
* Suivre un événement.
|
|
345
|
-
* Cette action permet à l'utilisateur de suivre un événement.
|
|
346
|
-
*/
|
|
347
|
-
override async follow() {
|
|
348
|
-
return super.follow();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* {@inheritDoc BaseEntity#unfollow}
|
|
353
|
-
*
|
|
354
|
-
* Se désabonne d'un événement.
|
|
355
|
-
*/
|
|
356
|
-
override async unfollow() {
|
|
357
|
-
return super.unfollow();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
}
|