@communecter/cocolight-api-client 1.0.121 → 1.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/203.cocolight-api-client.cjs +1 -0
  2. package/dist/278.cocolight-api-client.browser.js +1 -0
  3. package/dist/278.cocolight-api-client.cjs +1 -0
  4. package/dist/278.cocolight-api-client.mjs.js +1 -0
  5. package/dist/401.cocolight-api-client.mjs.js +1 -1
  6. package/dist/407.cocolight-api-client.browser.js +1 -0
  7. package/dist/407.cocolight-api-client.mjs.js +1 -0
  8. package/dist/499.cocolight-api-client.browser.js +1 -0
  9. package/dist/499.cocolight-api-client.cjs +1 -0
  10. package/dist/499.cocolight-api-client.mjs.js +1 -0
  11. package/dist/556.cocolight-api-client.browser.js +1 -0
  12. package/dist/556.cocolight-api-client.cjs +1 -0
  13. package/dist/556.cocolight-api-client.mjs.js +1 -0
  14. package/dist/588.cocolight-api-client.mjs.js +1 -1
  15. package/dist/593.cocolight-api-client.mjs.js +1 -1
  16. package/dist/839.cocolight-api-client.mjs.js +1 -1
  17. package/dist/85.cocolight-api-client.browser.js +1 -0
  18. package/dist/85.cocolight-api-client.cjs +1 -0
  19. package/dist/85.cocolight-api-client.mjs.js +1 -0
  20. package/dist/906.cocolight-api-client.browser.js +1 -0
  21. package/dist/906.cocolight-api-client.cjs +1 -0
  22. package/dist/906.cocolight-api-client.mjs.js +1 -0
  23. package/dist/cocolight-api-client.browser.js +3 -3
  24. package/dist/cocolight-api-client.cjs +1 -1
  25. package/dist/cocolight-api-client.mjs.js +1 -1
  26. package/dist/cocolight-api-client.vite.mjs.js +1 -1
  27. package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/Api.ts +21 -2
  30. package/src/api/BaseEntity.ts +145 -4
  31. package/src/api/EndpointApi.ts +125 -1
  32. package/src/api/EndpointApi.types.ts +180 -1
  33. package/src/api/EntityRegistry.ts +11 -3
  34. package/src/api/Form.ts +60 -0
  35. package/src/api/User.ts +2 -0
  36. package/src/api/UserApi.ts +3 -2
  37. package/src/api/serverDataType/Form.ts +56 -0
  38. package/src/endpoints.module.ts +1 -1
  39. package/src/index.ts +3 -1
  40. package/src/types/entities.ts +3 -2
  41. package/types/Api.d.ts +7 -0
  42. package/types/api/BaseEntity.d.ts +99 -3
  43. package/types/api/EndpointApi.d.ts +77 -1
  44. package/types/api/EndpointApi.types.d.ts +164 -1
  45. package/types/api/EntityRegistry.d.ts +1 -1
  46. package/types/api/Form.d.ts +23 -0
  47. package/types/api/Organization.d.ts +1 -1
  48. package/types/api/User.d.ts +1 -0
  49. package/types/api/serverDataType/Form.d.ts +51 -0
  50. package/types/endpoints.module.d.ts +2661 -166
  51. package/types/index.d.ts +3 -1
  52. package/types/types/entities.d.ts +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.121",
3
+ "version": "1.0.122",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
package/src/Api.ts CHANGED
@@ -5,6 +5,7 @@ import { Comment } from "./api/Comment.js";
5
5
  import EndpointApi from "./api/EndpointApi.js";
6
6
  import { createFromCollection, registerEntity } from "./api/EntityRegistry.js";
7
7
  import { Event } from "./api/Event.js";
8
+ import { Form } from "./api/Form.js";
8
9
  import { News } from "./api/News.js";
9
10
  import { Organization } from "./api/Organization.js";
10
11
  import { Poi } from "./api/Poi.js";
@@ -29,6 +30,7 @@ registerEntity("EndpointApi", EndpointApi);
29
30
  registerEntity("News", News);
30
31
  registerEntity("Comment", Comment);
31
32
  registerEntity("Answer", Answer);
33
+ registerEntity("Form", Form);
32
34
 
33
35
 
34
36
 
@@ -126,9 +128,9 @@ export default class Api {
126
128
  async user(userData: EntityData): Promise<User> {
127
129
  try {
128
130
  if (!userData.id && !userData.slug) {
129
- return new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment });
131
+ return new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment, Answer });
130
132
  } else {
131
- const user = new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment });
133
+ const user = new User(this._client, userData, { EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment, Answer });
132
134
  await user.get();
133
135
  return user;
134
136
  }
@@ -224,6 +226,23 @@ export default class Api {
224
226
  }
225
227
  }
226
228
 
229
+ /**
230
+ * Creates a new Form instance and optionally retrieves form data.
231
+ */
232
+ async form(formData: { id: string }): Promise<Form> {
233
+ try {
234
+ const form = new Form(this._client, formData, { EndpointApi, User, Organization, Project });
235
+ if (!formData.id) {
236
+ throw new Error("Vous devez fournir un id pour créer une instance Form.");
237
+ }
238
+ await form.get();
239
+ return form;
240
+ } catch (error) {
241
+ console.error("[Api.form] Erreur lors de la création d'un objet Form :", (error as Error).message);
242
+ throw error;
243
+ }
244
+ }
245
+
227
246
  /**
228
247
  * Retourne une entité à partir d'un slug.
229
248
  */
@@ -47,7 +47,9 @@ import type {
47
47
  GetEventsData,
48
48
  CostumFilterCoformData,
49
49
  GetCountriesData,
50
- SearchZonesData
50
+ SearchZonesData,
51
+ CoformAnswersByFormsData,
52
+ FundingEnvelopeData
51
53
  } from "./EndpointApi.types.js";
52
54
  import type { GetElementsKeyResponse } from "../types/api-responses.js";
53
55
  import type { TransformsMap } from "../types/entities.js";
@@ -85,9 +87,10 @@ type News = import("./News.js").News;
85
87
  type Badge = import("./Badge.js").Badge;
86
88
  type Comment = import("./Comment.js").Comment;
87
89
  type Answer = import("./Answer.js").Answer;
90
+ type Form = import("./Form.js").Form;
88
91
 
89
92
  // Types d'union
90
- type AnyEntity = User | Organization | Project | Poi | EventEntity | Badge | News | Comment | Answer;
93
+ type AnyEntity = User | Organization | Project | Poi | EventEntity | Badge | News | Comment | Answer | Form;
91
94
  type ParentLike = BaseEntity<any> & { apiClient: ApiClient, userContext?: User | null };
92
95
 
93
96
  // Types pour les dépendances
@@ -105,6 +108,7 @@ interface Deps {
105
108
  News?: any;
106
109
  Comment?: any;
107
110
  Answer?: any;
111
+ Form?: any;
108
112
  }
109
113
 
110
114
  interface BaseEntityConfig {
@@ -122,6 +126,7 @@ interface EntityTypeMap {
122
126
  badges: Badge;
123
127
  comments: Comment;
124
128
  answers: Answer;
129
+ forms: Form;
125
130
  }
126
131
 
127
132
  // Types pour les streams et uploads
@@ -129,6 +134,19 @@ type ReadableWithMeta = import("stream").Readable & { path?: string, mimeType?:
129
134
  type UploadInput = File | Blob | Buffer | import("stream").Readable;
130
135
  type ValidatedUpload = File | Buffer | ReadableWithMeta;
131
136
 
137
+ // Type de retour pour fundingEnvelope
138
+ export type FundingEnvelopeResult = {
139
+ contextData?: AnyEntity | object;
140
+ context?: AnyEntity | object;
141
+ links?: object;
142
+ form?: object;
143
+ paymentMethods?: object;
144
+ nopropProject?: AnyEntity[] | object;
145
+ projects?: AnyEntity[] | any[];
146
+ userOrga?: AnyEntity[] | object;
147
+ [k: string]: unknown;
148
+ };
149
+
132
150
  // Type pour le curseur de pagination utilisé dans _createPaginatorEngine
133
151
  type PaginationCursor = {
134
152
  searchType?: string[];
@@ -1894,6 +1912,7 @@ export class BaseEntity<TServerData = any> {
1894
1912
  News: selfTag === "News" ? selfClass : this.deps.News,
1895
1913
  Comment: selfTag === "Comment" ? selfClass : this.deps.Comment,
1896
1914
  Answer: selfTag === "Answer" ? selfClass : this.deps.Answer,
1915
+ Form: selfTag === "Form" ? selfClass : this.deps.Form,
1897
1916
  };
1898
1917
 
1899
1918
  const map = {
@@ -1911,6 +1930,7 @@ export class BaseEntity<TServerData = any> {
1911
1930
  } },
1912
1931
  comments: { entityClass: commonDeps.Comment, deps: { ...commonDeps } },
1913
1932
  answers: { entityClass: commonDeps.Answer, deps: { ...commonDeps } },
1933
+ forms: { entityClass: commonDeps.Form, deps: { ...commonDeps } },
1914
1934
  };
1915
1935
 
1916
1936
  return (map as Record<string, EntityMeta | undefined>)[entityType] || null;
@@ -4629,10 +4649,37 @@ export class BaseEntity<TServerData = any> {
4629
4649
  }
4630
4650
 
4631
4651
 
4652
+ /**
4653
+ * Recherche paginée des réponses CoForm liées à l'entité courante.
4654
+ * Injecte automatiquement le contexte (costumSlug, contextId, contextType) via `_withCostumContext`,
4655
+ * puis pagine via `_createPaginatorEngine`.
4656
+ *
4657
+ * `searchType` est pré-rempli à `["answers"]` si non fourni.
4658
+ * Les autres champs required (`indexStep`, `count`, `initType`, `fediverse`)
4659
+ * sont injectés automatiquement par AJV via les `default` du schema.
4660
+ *
4661
+ * @param data - Paramètres de recherche (partiels). Seuls `filters` et `fields` sont
4662
+ * généralement nécessaires côté appelant.
4663
+ * @param options - Options de pagination
4664
+ * @param options.restoredState - État de pagination à restaurer (pour reprendre une navigation)
4665
+ * @returns Première page paginée avec `results` (Answer[]), `count`, `hasNext`, `hasPrev`, etc.
4666
+ *
4667
+ * @example
4668
+ * const page = await organization.coformAnswersSearch({
4669
+ * filters: { form: "6927e9f0db22da724360303c" },
4670
+ * fields: ["vote", "voteCount", "user"],
4671
+ * sortBy: { created: -1 }
4672
+ * });
4673
+ * page.results; // Answer[]
4674
+ * page.count.total; // nombre total de résultats
4675
+ * page.hasNext; // true si une page suivante existe
4676
+ */
4632
4677
  async coformAnswersSearch(
4633
4678
  data: Partial<CoformAnswersSearchData> = {},
4634
4679
  options?: { restoredState?: PaginatorState }
4635
- ): Promise<PaginatorPage<any>> {
4680
+ ): Promise<PaginatorPage<Answer>> {
4681
+ data.searchType = data.searchType ?? ["answers"];
4682
+
4636
4683
  const paginator = this._createPaginatorEngine({
4637
4684
  initialData: data,
4638
4685
  methodName: "coformAnswersSearch",
@@ -4641,10 +4688,84 @@ export class BaseEntity<TServerData = any> {
4641
4688
  (finalData: CoformAnswersSearchData) => this.endpointApi.coformAnswersSearch(finalData)
4642
4689
  ),
4643
4690
  });
4644
- return paginator.next() as Promise<PaginatorPage<any>>;
4691
+ return paginator.next() as Promise<PaginatorPage<Answer>>;
4645
4692
  }
4646
4693
 
4647
4694
 
4695
+ /**
4696
+ * Récupère les réponses pour plusieurs formulaires CoForm.
4697
+ * Chaque entrée du résultat contient les `answers` liées en entités
4698
+ * et les `documents` associés.
4699
+ *
4700
+ * @param data - Paramètres de recherche
4701
+ * @param data.forms - Objet `{ [formId]: pathDeRecherche }` — au moins une entrée requise.
4702
+ * Chaque clé est un ObjectID de formulaire, chaque valeur est un chemin
4703
+ * dot-notation vers le champ answers (ex: `"answers.xxx.finderxxx.orgId"`).
4704
+ * @returns Tableau d'items par formulaire, avec `answers` transformées en entités
4705
+ * @throws {ApiError} Si `forms` est absent, vide, ou n'est pas un objet
4706
+ *
4707
+ * @example
4708
+ * const results = await organization.searchAnswersByForms({
4709
+ * forms: {
4710
+ * "646498a5f2b3d6423d74b7f6": "answers.formName.finderPath.orgId",
4711
+ * "645b300b6d70bb35426fc0e3": "answers.formName.finderPath.orgId"
4712
+ * }
4713
+ * });
4714
+ */
4715
+ async searchAnswersByForms(
4716
+ data: Partial<CoformAnswersByFormsData> = {},
4717
+ ): Promise<{ answers: Answer[]; documents: any[]; [k: string]: unknown }[]> {
4718
+ if(!data.forms || Array.isArray(data.forms) || Object.keys(data.forms).length === 0){
4719
+ throw new ApiError("Le paramètre 'forms' est requis et doit être un objet non vide.", 400);
4720
+ }
4721
+ const result = await this.endpointApi.coformAnswersByForms(data);
4722
+
4723
+ return result.map((item: any) => ({
4724
+ ...item,
4725
+ answers: this._linkEntities(Object.values(item.answers || {}))
4726
+ }));
4727
+ }
4728
+
4729
+ /**
4730
+ * Récupère les informations d'enveloppes de financement pour l'entité courante.
4731
+ * Injecte automatiquement le contexte (costumSlug, contextId, contextType) via `_withCostumContext`.
4732
+ *
4733
+ * Les champs `contextData`, `context`, `nopropProject`, `projects` et `userOrga`
4734
+ * de la réponse sont automatiquement liés en entités quand possible.
4735
+ *
4736
+ * @param data - Paramètres optionnels de recherche
4737
+ * @param data.action - Action à effectuer (`"getEnvelopeData"`, `"getFormData"`, etc.)
4738
+ * @param data.formId - ID du formulaire cible (pour `action: "getFormData"`)
4739
+ * @param data.financerId - ID du financeur pour filtrer
4740
+ * @param data.financerType - Type du financeur (ex: `"citoyens"`)
4741
+ * @param data.params - Paramètres supplémentaires (ex: `{ project: "all" }`)
4742
+ * @returns Données d'enveloppe avec entités liées
4743
+ *
4744
+ * @example
4745
+ * const envelope = await organization.fundingEnvelope({
4746
+ * action: "getEnvelopeData"
4747
+ * });
4748
+ * envelope.form; // données du formulaire
4749
+ * envelope.projects; // Project[] liés
4750
+ */
4751
+ async fundingEnvelope(
4752
+ data: Partial<Omit<FundingEnvelopeData, "contextId" | "contextType">> = {},
4753
+ ): Promise<FundingEnvelopeResult> {
4754
+ const wrappedFinalizer = this._withCostumContext(
4755
+ (finalData: FundingEnvelopeData) => this.endpointApi.fundingEnvelope(finalData)
4756
+ );
4757
+
4758
+ const result = await wrappedFinalizer(data as FundingEnvelopeData);
4759
+ return {
4760
+ ...result,
4761
+ ...(result.contextData && { contextData: this._linkEntity(result.contextData.collection, result.contextData) ?? result.contextData }),
4762
+ ...(result.context && { context: this._linkEntity(result.context.collection, result.context) ?? result.context }),
4763
+ ...(result.nopropProject && { nopropProject: this._linkEntities(Object.values(result.nopropProject)) ?? result.nopropProject }),
4764
+ ...(result.projects && { projects: this._linkEntities(result.projects) ?? result.projects }),
4765
+ ...(result.userOrga && { userOrga: this._linkEntities(Object.values(result.userOrga)) ?? result.userOrga })
4766
+ };
4767
+ }
4768
+
4648
4769
  /**
4649
4770
  * Récupère les filtres disponibles basés sur les réponses CoForm de l'entité courante.
4650
4771
  * Utilise le contexte Communecter (costumSlug, contextId, contextType) de l'entité.
@@ -4719,6 +4840,24 @@ export class BaseEntity<TServerData = any> {
4719
4840
  return this.endpointApi.getCountries(data as GetCountriesData) as Promise<CountryItem[]>;
4720
4841
  }
4721
4842
 
4843
+ /**
4844
+ * Generer un nouveau identifiant unique pour un answers basé sur un formulaire donnée
4845
+ *
4846
+ * @param formId - Identifiant du formulaire pour lequel générer un nouvel ID d'answers
4847
+ * @returns Un nouvel answers avec le nouveau ID généré
4848
+ * @throws {ApiError} Si formId est absent ou invalide
4849
+ *
4850
+ */
4851
+ async generateNewAnswerId(
4852
+ formId: string
4853
+ ): Promise<any> {
4854
+ if (!formId || typeof formId !== "string") {
4855
+ throw new ApiError("formId est requis et doit être une chaîne de caractères.", 400);
4856
+ }
4857
+ const result = await this.endpointApi.generateAnswerFromForm({pathParams: { formId }, action: "new" });
4858
+ return this._linkEntity?.(result.collection, result) ?? result;
4859
+ }
4860
+
4722
4861
  /**
4723
4862
  * ───────────────────────────────
4724
4863
  * Pagination restoration methods
@@ -4809,6 +4948,8 @@ export class BaseEntity<TServerData = any> {
4809
4948
  };
4810
4949
  }
4811
4950
 
4951
+
4952
+
4812
4953
  }
4813
4954
 
4814
4955
  export default BaseEntity;
@@ -2,7 +2,7 @@
2
2
  import { ApiAuthenticationError } from "../error.js";
3
3
 
4
4
  import type ApiClient from "../ApiClient.js";
5
- import type { 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, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeletePoiData, DeleteEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DemoteAdminData, CostumFilterCoformData, GetCountriesData, SearchZonesData } from "./EndpointApi.types.js";
5
+ import type { 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, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetMembersNoAdminData, GetMembersAdminData, GetFriendsAdminData, GetSubscriptionsData, GetSubscriptionsAdminData, GetSubscribersData, GetSubscribersAdminData, GetContributorsNoAdminData, GetContributorsAdminData, GetBadgesData, GetBadgesFiltersData, ConnectData, DisconnectData, GetElementsKeyData, GetFavorisData, DeleteFavorisData, AddFavorisData, AddOrganizationData, AddProjectData, AddPoiData, AddEventData, DeletePoiData, DeleteEventData, DeleteElementData, AddImageElementData, LinkValidateData, SearchMemberAutocompleteData, GetNotificationsData, GetNotificationsCountData, NotificationUpdateData, MarkNotificationAsReadData, ActivitypubSearchData, ActivitypubLinkData, ActivitypubGetCommunityData, GetBadgeData, AddBadgesData, AssignBadgesData, GetEventsData, ShareEventsData, InviteEventData, FollowData, GetCostumJsonData, GlobalAutocompleteCostumData, CostumEventRequestActorsData, CostumEventRequestSubeventsData, CostumEventRequestElementEventData, CostumEventRequestCategoriesData, CostumEventRequestDatesData, CostumEventRequestEventData, CostumEventRequestLinkTlToEventData, CostumEventRequestLoadContextTagData, GetGalleryData, GetAttendeesNoAdminData, GetAttendeesAdminData, CoformAnswersSearchData, CoformAnswersByIdData, GetCoformByIdData, CoformUploadAnswerFileData, CoformGetAnswerFilesData, SaveCoformAnswerData, AddVoteData, AddReportAbuseData, UpdatePathValueData, DeleteDocumentByContextData, DeleteDocumentByIdData, DemoteAdminData, CostumFilterCoformData, GetCountriesData, SearchZonesData, CoformAnswersByFormsData, GenerateAnswerFromFormData, FundingEnvelopeData } from "./EndpointApi.types.js";
6
6
 
7
7
  /**
8
8
  * Classe EndpointApi générée automatiquement depuis endpoints-copie.json
@@ -1640,6 +1640,69 @@ export class EndpointApi {
1640
1640
  return this.call("COFORM_ANSWERS_BY_ID", data);
1641
1641
  }
1642
1642
 
1643
+ /**
1644
+ * Récupérer un formulaire par son ID : Récupère les informations complètes d'un formulaire CoForm par son ID parent
1645
+ * Constant : GET_COFORM_BY_ID
1646
+ * @param data - Données envoyées à l'API
1647
+ * @returns Les données de réponse.
1648
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1649
+ * @throws {Error} - En cas d'erreur inattendue.
1650
+ */
1651
+ async getCoformById(data: GetCoformByIdData): Promise<any> {
1652
+ if (!data || typeof data !== "object") {
1653
+ throw new TypeError("Le paramètre data doit être un objet.");
1654
+ }
1655
+ return this.call("GET_COFORM_BY_ID", data);
1656
+ }
1657
+
1658
+ /**
1659
+ * Uploader un fichier de réponse CoForm : Endpoint de pré-upload CoForm (image/document). Si answerId est absent, l'endpoint crée un MongoId de réponse, réutilise la logique d'upload document existante et retourne answerId + docPath.
1660
+ * Constant : COFORM_UPLOAD_ANSWER_FILE
1661
+ * @param data - Données envoyées à l'API
1662
+ * @returns Les données de réponse.
1663
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1664
+ * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1665
+ * @throws {Error} - En cas d'erreur inattendue.
1666
+ */
1667
+ async coformUploadAnswerFile(data: CoformUploadAnswerFileData): Promise<any> {
1668
+ if (!data || typeof data !== "object") {
1669
+ throw new TypeError("Le paramètre data doit être un objet.");
1670
+ }
1671
+ return this.callIsConnected("COFORM_UPLOAD_ANSWER_FILE", data);
1672
+ }
1673
+
1674
+ /**
1675
+ * Récupérer les fichiers d'une réponse CoForm : Récupère la liste des fichiers uploadés pour un input spécifique dans une réponse CoForm. Utilisé pour récupérer les fichiers de l'ancien système qui n'ont que 'updateDate' sans la clé 'files'.
1676
+ * Constant : COFORM_GET_ANSWER_FILES
1677
+ * @param data - Données envoyées à l'API
1678
+ * @returns Les données de réponse.
1679
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1680
+ * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1681
+ * @throws {Error} - En cas d'erreur inattendue.
1682
+ */
1683
+ async coformGetAnswerFiles(data: CoformGetAnswerFilesData): Promise<any> {
1684
+ if (!data || typeof data !== "object") {
1685
+ throw new TypeError("Le paramètre data doit être un objet.");
1686
+ }
1687
+ return this.callIsConnected("COFORM_GET_ANSWER_FILES", data);
1688
+ }
1689
+
1690
+ /**
1691
+ * Sauvegarder une réponse de formulaire CoForm : Enregistre ou met à jour les réponses d'un utilisateur pour un formulaire CoForm
1692
+ * Constant : SAVE_COFORM_ANSWER
1693
+ * @param data - Données envoyées à l'API
1694
+ * @returns Les données de réponse.
1695
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1696
+ * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1697
+ * @throws {Error} - En cas d'erreur inattendue.
1698
+ */
1699
+ async saveCoformAnswer(data: SaveCoformAnswerData): Promise<any> {
1700
+ if (!data || typeof data !== "object") {
1701
+ throw new TypeError("Le paramètre data doit être un objet.");
1702
+ }
1703
+ return this.callIsConnected("SAVE_COFORM_ANSWER", data);
1704
+ }
1705
+
1643
1706
  /**
1644
1707
  * Voter sur un élément (commentaire ou news) : Permet de voter sur un commentaire ou une news en spécifiant un statut de vote
1645
1708
  * Constant : ADD_VOTE
@@ -1704,6 +1767,22 @@ export class EndpointApi {
1704
1767
  return this.callIsConnected("DELETE_DOCUMENT_BY_CONTEXT", data);
1705
1768
  }
1706
1769
 
1770
+ /**
1771
+ * Supprimer un document par son ID : Supprime un document (fichier ou image) par son identifiant MongoDB
1772
+ * Constant : DELETE_DOCUMENT_BY_ID
1773
+ * @param data - Données envoyées à l'API
1774
+ * @returns Les données de réponse.
1775
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1776
+ * @throws {ApiAuthenticationError} - En cas d'erreur d'authentification.
1777
+ * @throws {Error} - En cas d'erreur inattendue.
1778
+ */
1779
+ async deleteDocumentById(data: DeleteDocumentByIdData): Promise<any> {
1780
+ if (!data || typeof data !== "object") {
1781
+ throw new TypeError("Le paramètre data doit être un objet.");
1782
+ }
1783
+ return this.callIsConnected("DELETE_DOCUMENT_BY_ID", data);
1784
+ }
1785
+
1707
1786
  /**
1708
1787
  * Rétirer les droits d’administrateur d’un membre : Rétirer les droits d’administrateur d’un membre d’une organisation ou d’un projet
1709
1788
  * Constant : DEMOTE_ADMIN
@@ -1765,6 +1844,51 @@ export class EndpointApi {
1765
1844
  return this.call("SEARCH_ZONES", data);
1766
1845
  }
1767
1846
 
1847
+ /**
1848
+ * Recuperer la liste des reponses pour plusieurs formulaires : Recuperer la liste des reponses pour plusieurs formulaires
1849
+ * Constant : COFORM_ANSWERS_BY_FORMS
1850
+ * @param data - Données envoyées à l'API
1851
+ * @returns Les données de réponse.
1852
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1853
+ * @throws {Error} - En cas d'erreur inattendue.
1854
+ */
1855
+ async coformAnswersByForms(data: CoformAnswersByFormsData): Promise<any> {
1856
+ if (!data || typeof data !== "object") {
1857
+ throw new TypeError("Le paramètre data doit être un objet.");
1858
+ }
1859
+ return this.call("COFORM_ANSWERS_BY_FORMS", data);
1860
+ }
1861
+
1862
+ /**
1863
+ * Generer une nouvelle reponse à partir d'un formulaire : Generer une nouvelle reponse à partir d'un formulaire
1864
+ * Constant : GENERATE_ANSWER_FROM_FORM
1865
+ * @param data - Données envoyées à l'API
1866
+ * @returns Les données de réponse.
1867
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1868
+ * @throws {Error} - En cas d'erreur inattendue.
1869
+ */
1870
+ async generateAnswerFromForm(data: GenerateAnswerFromFormData): Promise<any> {
1871
+ if (!data || typeof data !== "object") {
1872
+ throw new TypeError("Le paramètre data doit être un objet.");
1873
+ }
1874
+ return this.call("GENERATE_ANSWER_FROM_FORM", data);
1875
+ }
1876
+
1877
+ /**
1878
+ * Trouver les informations sur les enveloppes d’un formulaire : Trouver les informations sur les enveloppes d’un formulaire
1879
+ * Constant : FUNDING_ENVELOPE
1880
+ * @param data - Données envoyées à l'API
1881
+ * @returns Les données de réponse.
1882
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
1883
+ * @throws {Error} - En cas d'erreur inattendue.
1884
+ */
1885
+ async fundingEnvelope(data: FundingEnvelopeData): Promise<any> {
1886
+ if (!data || typeof data !== "object") {
1887
+ throw new TypeError("Le paramètre data doit être un objet.");
1888
+ }
1889
+ return this.call("FUNDING_ENVELOPE", data);
1890
+ }
1891
+
1768
1892
  }
1769
1893
 
1770
1894
  export default EndpointApi;
@@ -4829,6 +4829,108 @@ export interface CoformAnswersByIdData {
4829
4829
  * Liste des champs à retourner
4830
4830
  */
4831
4831
  fields?: string[];
4832
+ /**
4833
+ * ID du formulaire parent (utilisé pour calculer les droits d'édition côté serveur)
4834
+ */
4835
+ formId?: string;
4836
+ [k: string]: unknown;
4837
+ }
4838
+
4839
+
4840
+ export interface GetCoformByIdData {
4841
+ /**
4842
+ * ID du formulaire parent à récupérer
4843
+ */
4844
+ parentFormId: string;
4845
+ [k: string]: unknown;
4846
+ }
4847
+
4848
+
4849
+ export interface CoformUploadAnswerFileData {
4850
+ /**
4851
+ * ID du formulaire parent (pour contrôles d'accès).
4852
+ */
4853
+ formId: string;
4854
+ /**
4855
+ * ID de réponse existant. Si absent, un MongoId est généré côté serveur.
4856
+ */
4857
+ answerId?: string;
4858
+ /**
4859
+ * Type de document à uploader.
4860
+ */
4861
+ docType?: "image" | "file";
4862
+ /**
4863
+ * Clé de contenu (ex: slider pour images).
4864
+ */
4865
+ contentKey?: string;
4866
+ /**
4867
+ * Sous-clé optionnelle pour rattachement du document.
4868
+ */
4869
+ subKey?: string;
4870
+ /**
4871
+ * UUID client du fichier (compat fine-uploader).
4872
+ */
4873
+ qquuid: string;
4874
+ /**
4875
+ * Nom original du fichier.
4876
+ */
4877
+ qqfilename: string;
4878
+ /**
4879
+ * Taille du fichier en octets.
4880
+ */
4881
+ qqtotalfilesize: number;
4882
+ /**
4883
+ * Fichier binaire multipart.
4884
+ */
4885
+ qqfile: {
4886
+ [k: string]: unknown;
4887
+ };
4888
+ [k: string]: unknown;
4889
+ }
4890
+
4891
+
4892
+ export interface CoformGetAnswerFilesData {
4893
+ /**
4894
+ * ID de la réponse CoForm
4895
+ */
4896
+ answerId: string;
4897
+ /**
4898
+ * Clé d'identification de l'input (ex: formId.inputId)
4899
+ */
4900
+ subKey: string;
4901
+ /**
4902
+ * Clé de contenu utilisée lors de l'upload
4903
+ */
4904
+ contentKey?: string;
4905
+ /**
4906
+ * Type de document à récupérer
4907
+ */
4908
+ docType?: "image" | "file";
4909
+ [k: string]: unknown;
4910
+ }
4911
+
4912
+
4913
+ export interface SaveCoformAnswerData {
4914
+ /**
4915
+ * ID du formulaire parent
4916
+ */
4917
+ formId: string;
4918
+ /**
4919
+ * Réponses du formulaire sérialisées en JSON, organisées par subFormId > inputId > valeur
4920
+ */
4921
+ answers: string;
4922
+ /**
4923
+ * ID d'une réponse existante (pour mise à jour)
4924
+ */
4925
+ answerId?: string;
4926
+ /**
4927
+ * Options ajoutées dynamiquement sérialisées en JSON (pour multiCheckboxPlus avec addValue)
4928
+ */
4929
+ addedOptions?: string;
4930
+ /**
4931
+ * Links des champs Finder sérialisés en JSON (pour answer.links). Format: { "organizations": { "mongoId": { "name": "...", "type": "organizations" } } }
4932
+ */
4933
+ links?: string;
4832
4934
  [k: string]: unknown;
4833
4935
  }
4834
4936
 
@@ -4891,7 +4993,7 @@ export interface UpdatePathValueData {
4891
4993
  /**
4892
4994
  * Collection de l’entité
4893
4995
  */
4894
- collection: "citoyens" | "organizations" | "projects" | "events" | "poi";
4996
+ collection: "citoyens" | "organizations" | "projects" | "events" | "poi" | "answers" | "forms";
4895
4997
  /**
4896
4998
  * Chemin de la valeur à mettre à jour
4897
4999
  */
@@ -4936,6 +5038,18 @@ export interface DeleteDocumentByContextData {
4936
5038
  }
4937
5039
 
4938
5040
 
5041
+ export interface DeleteDocumentByIdData {
5042
+ pathParams?: {
5043
+ /**
5044
+ * ID MongoDB du document à supprimer
5045
+ */
5046
+ id: string;
5047
+ [k: string]: unknown;
5048
+ };
5049
+ [k: string]: unknown;
5050
+ }
5051
+
5052
+
4939
5053
  export interface DemoteAdminData {
4940
5054
  parentId: string;
4941
5055
  /**
@@ -5025,3 +5139,68 @@ export interface SearchZonesData {
5025
5139
  costumType?: string;
5026
5140
  [k: string]: unknown;
5027
5141
  }
5142
+
5143
+
5144
+ export interface CoformAnswersByFormsData {
5145
+ /**
5146
+ * Liste des IDs de formulaires pour lesquels récupérer les réponses et le champ de recherche
5147
+ */
5148
+ forms?: {
5149
+ /**
5150
+ * This interface was referenced by `undefined`'s JSON-Schema definition
5151
+ * via the `patternProperty` "^[a-fA-F0-9]{24}$".
5152
+ */
5153
+ [k: string]: string;
5154
+ };
5155
+ [k: string]: unknown;
5156
+ }
5157
+
5158
+
5159
+ export interface GenerateAnswerFromFormData {
5160
+ action?: string;
5161
+ pathParams?: {
5162
+ /**
5163
+ * ID du formulaire pour lequel générer une nouvelle réponse
5164
+ */
5165
+ formId: string;
5166
+ [k: string]: unknown;
5167
+ };
5168
+ [k: string]: unknown;
5169
+ }
5170
+
5171
+
5172
+ export interface FundingEnvelopeData {
5173
+ /**
5174
+ * ID du contexte de l’entité
5175
+ */
5176
+ contextId: string;
5177
+ /**
5178
+ * Type de contexte de l’entité
5179
+ */
5180
+ contextType: string;
5181
+ /**
5182
+ * ID du formulaire pour lequel générer une nouvelle réponse
5183
+ */
5184
+ formId?: string;
5185
+ action?: string;
5186
+ /**
5187
+ * ID du projet
5188
+ */
5189
+ project?: string;
5190
+ /**
5191
+ * ID de la réponse
5192
+ */
5193
+ answer?: string;
5194
+ /**
5195
+ * ID du financeur
5196
+ */
5197
+ financerId?: string;
5198
+ financerType?: string;
5199
+ /**
5200
+ * Paramètres supplémentaires pour la recherche d’enveloppes
5201
+ */
5202
+ params?: {
5203
+ [k: string]: unknown;
5204
+ };
5205
+ [k: string]: unknown;
5206
+ }