@communecter/cocolight-api-client 1.0.166 → 1.0.167
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/cocolight-api-client.browser.js +1 -1
- 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 +1 -1
- package/types/api/BaseEntity.d.ts +62 -0
- package/types/api/EndpointApi.d.ts +11 -1
- package/types/api/EndpointApi.types.d.ts +74 -2
- package/types/costum/runtime.d.ts +11 -5
- package/types/endpoints.module.d.ts +615 -296
package/package.json
CHANGED
|
@@ -708,6 +708,48 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
708
708
|
* await news.deleteFile(imageDocId);
|
|
709
709
|
*/
|
|
710
710
|
deleteFile(docId: string): Promise<void>;
|
|
711
|
+
/**
|
|
712
|
+
* Champs de contexte costum à joindre à un upload multipart (profil/bannière/galerie) pour que le
|
|
713
|
+
* backend stampe `source.key` (Document.php:228-232). Dérivés de `_costumCtx` (résolu du `source.key`
|
|
714
|
+
* de l'élément) → un POI scopé "parent62" envoie `costumSlug="parent62"`. `{}` hors contexte costum.
|
|
715
|
+
*/
|
|
716
|
+
protected _costumUploadFields(): {
|
|
717
|
+
costumSlug?: string;
|
|
718
|
+
costumId?: string;
|
|
719
|
+
costumType?: string;
|
|
720
|
+
};
|
|
721
|
+
/**
|
|
722
|
+
* Uploade un document (image/fichier) rattaché à CET élément, avec `contentKey`/`docType`
|
|
723
|
+
* PARAMÉTRABLES — ex. `contentKey:"slider"` pour une galerie (Option C). La provenance costum
|
|
724
|
+
* (`source.key`) est injectée automatiquement depuis `_costumCtx` (résolu du `source.key` de
|
|
725
|
+
* l'élément). L'élément DOIT préexister (pas d'auto-création, contraste avec `Answer.uploadFile`).
|
|
726
|
+
* Endpoint générique `UPLOAD_DOCUMENT` (backend `co2/document/upload-save`, route wildcard).
|
|
727
|
+
*
|
|
728
|
+
* STATELESS : ne rafraîchit PAS `serverData` (pas de push local façon `News.addImage`). Pour refléter
|
|
729
|
+
* la nouvelle image dans `getGalleryImages()`, re-fetch l'élément via `about` après upload (le
|
|
730
|
+
* consommateur peut afficher optimistement via le `docPath` retourné en attendant). Cf. patron
|
|
731
|
+
* `Answer.processUploads` : la galerie s'uploade APRÈS `save()` (l'élément doit avoir un `id`).
|
|
732
|
+
*
|
|
733
|
+
* @returns `{ docId, docPath }` — id du document créé + URL relative servie.
|
|
734
|
+
* @throws {ApiError} 404 si l'entité n'est pas enregistrée (pas d'`id`).
|
|
735
|
+
*/
|
|
736
|
+
uploadDocument(file: UploadInput, opts: {
|
|
737
|
+
contentKey: string;
|
|
738
|
+
docType?: "image" | "file";
|
|
739
|
+
subKey?: string;
|
|
740
|
+
folder?: string;
|
|
741
|
+
ownerId?: string;
|
|
742
|
+
}): Promise<{
|
|
743
|
+
docId: string;
|
|
744
|
+
docPath: string;
|
|
745
|
+
}>;
|
|
746
|
+
/**
|
|
747
|
+
* Images d'une galerie de CET élément, lues depuis le champ `images` fusionné par `about`/getById
|
|
748
|
+
* (backend `enrichAbout` — {Poi,Classified}::getById), filtrées par `contentKey` (défaut `"slider"`).
|
|
749
|
+
* SYNCHRONE : nécessite que l'entité ait été chargée via `about` (sinon `[]`). Forme = getListOfImage
|
|
750
|
+
* (`{ id, _id, contentKey, imagePath, imageThumbPath, imageMediumPath, subKey, name, ... }`).
|
|
751
|
+
*/
|
|
752
|
+
getGalleryImages(contentKey?: string): Array<Record<string, unknown>>;
|
|
711
753
|
/**
|
|
712
754
|
* Liste les documents (images/fichiers) attachés à CETTE entité (`id` + `type`) via `DOCUMENT_LIST`
|
|
713
755
|
* (port legacy `document/list`). Renvoie un tableau plat `{ id, name, path, author, contentKey }`.
|
|
@@ -721,6 +763,26 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
721
763
|
author?: string;
|
|
722
764
|
contentKey?: string;
|
|
723
765
|
}>>;
|
|
766
|
+
/**
|
|
767
|
+
* Liste les FICHIERS (documents non-image, `doctype:"file"`) attachés à CETTE entité via `GET_GALLERY`
|
|
768
|
+
* (`co2/gallery/index`, branche fichier : `docs` = OBJET keyé par `_id`, records BRUTS + `docPath`
|
|
769
|
+
* absolutisé par `_imageFields`). Source UNIQUE et uniforme tous types (org/projet/citoyen/poi/events/
|
|
770
|
+
* classifieds — l'`IndexAction` legacy est type-agnostique). Contraste `getGalleryImages` (images,
|
|
771
|
+
* synchrone via `about`) et `getDocuments` (DOCUMENT_LIST, forme réduite sans `size`/`docType`, `path`
|
|
772
|
+
* = dossier seul). Les fichiers rangés en dossier (`folderId`) sont exclus par défaut (parité
|
|
773
|
+
* `IndexAction` : `folderId:{$exists:false}`).
|
|
774
|
+
*
|
|
775
|
+
* @returns `{ docId, docPath, name, size, contentKey }[]` — `contentKey` = valeur DÉRIVÉE stockée
|
|
776
|
+
* (`pdf`/`spreadsheet`/`text`/`presentation`), utilisable pour choisir l'icône.
|
|
777
|
+
* @throws {ApiError} 404 si l'entité n'est pas enregistrée.
|
|
778
|
+
*/
|
|
779
|
+
getGalleryFiles(): Promise<Array<{
|
|
780
|
+
docId: string;
|
|
781
|
+
docPath?: string;
|
|
782
|
+
name?: string;
|
|
783
|
+
size?: number;
|
|
784
|
+
contentKey?: string;
|
|
785
|
+
}>>;
|
|
724
786
|
/**
|
|
725
787
|
* Supprime l'image de PROFIL de cette entité : récupère le `docId` du document `contentKey:"profil"`
|
|
726
788
|
* (via `getDocuments`) puis `deleteFile`. No-op (`false`) s'il n'y a pas d'image. Pendant exact de
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type ApiClient from "../ApiClient.js";
|
|
2
|
-
import type { DocumentListData, PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, ProfilBannerData, GetElementsAboutData, MulticonnectData, GetNewsData, GetNewsByIdData, AddNewsData, AddImageNewsData, AddFileNewsData, DeleteNewsData, UpdateNewsData, ShareNewsData, GetCommentsData, AddCommentsData, DeleteCommentsData, UpdateCommentsData, SearchTagsData, ShowVoteData, GlobalAutocompleteData, CityAutocompleteData, CityAutocompleteByCountryData, SuggestionInputData, GetProjectsNoAdminData, GetProjectsAdminData, GetPoisNoAdminData, GetPoisAdminData, GlobalAutocompleteAdminCostumData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetUserEligiblePlacesData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, SearchEventsCostumData, ShareEventsData, InviteMembersData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, NavigatorGettlData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, DeleteCoformAnswerFileData, CoformGetAnswerFilesData, GetCoformCatalogsData, SaveCoformAnswerData, GetCoformAnswerHistoryData, GetCoformMultievalDataData, GetCoformCommontableContributorsData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DeleteDocumentByIdData, DemoteAdminData, CostumFilterCoformData, CostumFilterCoformByPathData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, GenerateAnswerFromFormData, FundingEnvelopeData, CoremuOperationData, CostumProjectActionRequestNewData, CostumProjectActionRequestSetStatusData, CostumProjectActionRequestSetDateData, CostumProjectActionRequestSetContributorsData, CostumProjectActionRequestCancelData, CostumProjectActionRequestArchiveData, LinkDiscourseAccountData, UnlinkDiscourseAccountData, DiscourseProfileData, DiscourseCheckEmailData, DiscourseDismissLinkData, LinkMediawikiAccountData, UnlinkMediawikiAccountData, GetMediawikiContributionsData, AddClassifiedData, PersonActivateData, ImportPreviewData, ExportElementsData, ImportElementsData, GeocodageData, ValidateGroupData, SetSourceData, ModerateData, NewsModerateData, CommentModerateData } from "./EndpointApi.types.js";
|
|
2
|
+
import type { DocumentListData, PersonRegisterData, AuthenticateUrlData, RefreshTokenUrlData, PasswordRecoveryData, ServerExchangeTokenData, ChangePasswordData, DeleteAccountData, UpdateSettingsData, UpdateBlockDescriptionData, UpdateBlockInfoData, UpdateBlockSocialData, UpdateBlockLocalityData, UpdateBlockSlugData, CheckData, ProfilImageData, ProfilBannerData, GetElementsAboutData, MulticonnectData, GetNewsData, GetNewsByIdData, AddNewsData, AddImageNewsData, AddFileNewsData, DeleteNewsData, UpdateNewsData, ShareNewsData, GetCommentsData, AddCommentsData, DeleteCommentsData, UpdateCommentsData, SearchTagsData, ShowVoteData, GlobalAutocompleteData, CityAutocompleteData, CityAutocompleteByCountryData, SuggestionInputData, GetProjectsNoAdminData, GetProjectsAdminData, GetPoisNoAdminData, GetPoisAdminData, GlobalAutocompleteAdminCostumData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetUserEligiblePlacesData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, SearchEventsCostumData, ShareEventsData, InviteMembersData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, NavigatorGettlData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, DeleteCoformAnswerFileData, CoformGetAnswerFilesData, GetCoformCatalogsData, SaveCoformAnswerData, GetCoformAnswerHistoryData, GetCoformMultievalDataData, GetCoformCommontableContributorsData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DeleteDocumentByIdData, DemoteAdminData, CostumFilterCoformData, CostumFilterCoformByPathData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, GenerateAnswerFromFormData, FundingEnvelopeData, CoremuOperationData, CostumProjectActionRequestNewData, CostumProjectActionRequestSetStatusData, CostumProjectActionRequestSetDateData, CostumProjectActionRequestSetContributorsData, CostumProjectActionRequestCancelData, CostumProjectActionRequestArchiveData, LinkDiscourseAccountData, UnlinkDiscourseAccountData, DiscourseProfileData, DiscourseCheckEmailData, DiscourseDismissLinkData, LinkMediawikiAccountData, UnlinkMediawikiAccountData, GetMediawikiContributionsData, AddClassifiedData, PersonActivateData, ImportPreviewData, ExportElementsData, ImportElementsData, GeocodageData, ValidateGroupData, SetSourceData, ModerateData, NewsModerateData, CommentModerateData, UploadDocumentData } from "./EndpointApi.types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Classe EndpointApi générée automatiquement depuis endpoints-copie.json
|
|
5
5
|
*/
|
|
@@ -1502,5 +1502,15 @@ export declare class EndpointApi {
|
|
|
1502
1502
|
* @throws {Error} - En cas d'erreur inattendue.
|
|
1503
1503
|
*/
|
|
1504
1504
|
commentModerate(data: CommentModerateData): Promise<any>;
|
|
1505
|
+
/**
|
|
1506
|
+
* Uploader un document/image sur un élément (galerie) : Uploade un document (image/fichier) rattaché à un ÉLÉMENT, avec docType/contentKey PARAMÉTRABLES (ex. contentKey=slider pour une galerie) et provenance costum optionnelle (costumSlug/costumId/costumType stampent source.key). Backend: co2/document/upload-save (route wildcard, parseKv). L'élément doit préexister.
|
|
1507
|
+
* Constant : UPLOAD_DOCUMENT
|
|
1508
|
+
* @param data - Données envoyées à l'API
|
|
1509
|
+
* @returns Les données de réponse.
|
|
1510
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1511
|
+
* @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
|
|
1512
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1513
|
+
*/
|
|
1514
|
+
uploadDocument(data: UploadDocumentData): Promise<any>;
|
|
1505
1515
|
}
|
|
1506
1516
|
export default EndpointApi;
|
|
@@ -364,6 +364,18 @@ export interface ProfilImageData {
|
|
|
364
364
|
profil_avatar: {
|
|
365
365
|
[k: string]: unknown;
|
|
366
366
|
};
|
|
367
|
+
/**
|
|
368
|
+
* Slug du costum actif (stampe source.key côté backend) — optionnel
|
|
369
|
+
*/
|
|
370
|
+
costumSlug?: string;
|
|
371
|
+
/**
|
|
372
|
+
* ID du contexte costum — optionnel
|
|
373
|
+
*/
|
|
374
|
+
costumId?: string;
|
|
375
|
+
/**
|
|
376
|
+
* Type (collection) du contexte costum — optionnel
|
|
377
|
+
*/
|
|
378
|
+
costumType?: string;
|
|
367
379
|
pathParams?: {
|
|
368
380
|
/**
|
|
369
381
|
* Type d'entité
|
|
@@ -391,6 +403,18 @@ export interface ProfilBannerData {
|
|
|
391
403
|
cropH: number;
|
|
392
404
|
cropX: number;
|
|
393
405
|
cropY: number;
|
|
406
|
+
/**
|
|
407
|
+
* Slug du costum actif (stampe source.key côté backend) — optionnel
|
|
408
|
+
*/
|
|
409
|
+
costumSlug?: string;
|
|
410
|
+
/**
|
|
411
|
+
* ID du contexte costum — optionnel
|
|
412
|
+
*/
|
|
413
|
+
costumId?: string;
|
|
414
|
+
/**
|
|
415
|
+
* Type (collection) du contexte costum — optionnel
|
|
416
|
+
*/
|
|
417
|
+
costumType?: string;
|
|
394
418
|
pathParams?: {
|
|
395
419
|
/**
|
|
396
420
|
* Type d'entité
|
|
@@ -4912,9 +4936,9 @@ export interface GetGalleryData {
|
|
|
4912
4936
|
*/
|
|
4913
4937
|
id: string;
|
|
4914
4938
|
/**
|
|
4915
|
-
* Type d'entité
|
|
4939
|
+
* Type d'entité (IndexAction legacy est type-agnostique ; poi/events/classifieds ajoutés pour la lecture des documents/fichiers via getGalleryFiles)
|
|
4916
4940
|
*/
|
|
4917
|
-
type: "citoyens" | "organizations" | "projects";
|
|
4941
|
+
type: "citoyens" | "organizations" | "projects" | "poi" | "events" | "classifieds";
|
|
4918
4942
|
/**
|
|
4919
4943
|
* Type de document
|
|
4920
4944
|
*/
|
|
@@ -6348,3 +6372,51 @@ export interface CommentModerateData {
|
|
|
6348
6372
|
isAnAbuse?: "true" | "false";
|
|
6349
6373
|
[k: string]: unknown;
|
|
6350
6374
|
}
|
|
6375
|
+
export interface UploadDocumentData {
|
|
6376
|
+
/**
|
|
6377
|
+
* Fichier à uploader
|
|
6378
|
+
*/
|
|
6379
|
+
qqfile: {
|
|
6380
|
+
[k: string]: unknown;
|
|
6381
|
+
};
|
|
6382
|
+
/**
|
|
6383
|
+
* Slug du costum actif (stampe source.key=costumSlug)
|
|
6384
|
+
*/
|
|
6385
|
+
costumSlug?: string;
|
|
6386
|
+
/**
|
|
6387
|
+
* ID du contexte costum
|
|
6388
|
+
*/
|
|
6389
|
+
costumId?: string;
|
|
6390
|
+
/**
|
|
6391
|
+
* Type (collection) du contexte costum
|
|
6392
|
+
*/
|
|
6393
|
+
costumType?: string;
|
|
6394
|
+
/**
|
|
6395
|
+
* Sous-clé de galerie (optionnelle)
|
|
6396
|
+
*/
|
|
6397
|
+
subKey?: string;
|
|
6398
|
+
/**
|
|
6399
|
+
* Dossier d'album cible (optionnel)
|
|
6400
|
+
*/
|
|
6401
|
+
folderId?: string;
|
|
6402
|
+
pathParams?: {
|
|
6403
|
+
/**
|
|
6404
|
+
* Type (collection) de l'élément porteur
|
|
6405
|
+
*/
|
|
6406
|
+
folder: "citoyens" | "projects" | "organizations" | "events" | "poi" | "classifieds";
|
|
6407
|
+
/**
|
|
6408
|
+
* ID de l'élément porteur (doit exister)
|
|
6409
|
+
*/
|
|
6410
|
+
ownerId: string;
|
|
6411
|
+
/**
|
|
6412
|
+
* Nature du document
|
|
6413
|
+
*/
|
|
6414
|
+
docType: "image" | "file";
|
|
6415
|
+
/**
|
|
6416
|
+
* Clé de contenu (ex: 'slider' pour galerie, 'file', 'profil', 'banner'...)
|
|
6417
|
+
*/
|
|
6418
|
+
contentKey: string;
|
|
6419
|
+
[k: string]: unknown;
|
|
6420
|
+
};
|
|
6421
|
+
[k: string]: unknown;
|
|
6422
|
+
}
|
|
@@ -121,12 +121,18 @@ export declare class CostumScope {
|
|
|
121
121
|
*/
|
|
122
122
|
export declare function resolveCostumCtxFromSource(sourceKey: string | undefined | null, collection: Collection, type?: string | null): CostumRuntimeContext | null;
|
|
123
123
|
/**
|
|
124
|
-
* Ouvre un scope costum
|
|
125
|
-
* l'entité (= `source.key` posé par le backend), `costumId/costumType` = l'entité porteuse.
|
|
126
|
-
*
|
|
127
|
-
*
|
|
124
|
+
* Ouvre un scope costum depuis une entité DÉJÀ CHARGÉE (org/projet/event porteur d'un costum) : `costumSlug`
|
|
125
|
+
* = slug de l'entité (= `source.key` posé par le backend), `costumId/costumType` = l'entité porteuse. C'est
|
|
126
|
+
* la voie AMBIANTE (« costum du déploiement ») de `me.costum(entity)`.
|
|
127
|
+
*
|
|
128
|
+
* Le scope porte les DÉFINITIONS du costum (champs + presets de sous-type, ex. `type:"article"`), PAS
|
|
129
|
+
* seulement l'identité : sinon un CREATE de sous-type sous l'ambiant perd le `type` forcé → rejet enum ADD_*.
|
|
130
|
+
* Résolution (dégradée, jamais throw) : 1) cache live frais (zéro fetch — le costum est déjà chargé au rendu
|
|
131
|
+
* du site) ; 2) digest live `getcostumjson` (comble presets/champs + peuple le cache) ; 3) fieldless
|
|
132
|
+
* (identité seule — site nu sans costum, ou offline = comportement historique). Le backend re-gate `found`
|
|
133
|
+
* sur l'existence d'un costum → un site sans costum n'estampille rien.
|
|
128
134
|
*/
|
|
129
|
-
export declare function costumScopeFromEntity(user: BaseEntity, entity: BaseEntity): CostumScope
|
|
135
|
+
export declare function costumScopeFromEntity(user: BaseEntity, entity: BaseEntity): Promise<CostumScope>;
|
|
130
136
|
/**
|
|
131
137
|
* Résout un `CostumScope` par SLUG pour un user connecté.
|
|
132
138
|
* - slug à champs (meta + loader) → charge le module généré (code-split via dynamic import).
|