@communecter/cocolight-api-client 1.0.131 → 1.0.133

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 (48) hide show
  1. package/dist/cocolight-api-client.browser.js +3 -3
  2. package/dist/cocolight-api-client.cjs +1 -1
  3. package/dist/cocolight-api-client.mjs.js +1 -1
  4. package/dist/cocolight-api-client.vite.mjs.js +1 -1
  5. package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/Api.ts +9 -9
  8. package/src/ApiClient.ts +3 -1
  9. package/src/api/Action.ts +4 -0
  10. package/src/api/Answer.ts +846 -6
  11. package/src/api/Badge.ts +5 -0
  12. package/src/api/BaseEntity.ts +190 -11
  13. package/src/api/Classified.ts +4 -0
  14. package/src/api/Comment.ts +3 -0
  15. package/src/api/EndpointApi.ts +16 -1
  16. package/src/api/EndpointApi.types.ts +375 -44
  17. package/src/api/Event.ts +5 -0
  18. package/src/api/Form.ts +102 -2
  19. package/src/api/News.ts +3 -0
  20. package/src/api/Organization.ts +44 -2
  21. package/src/api/Poi.ts +4 -0
  22. package/src/api/Project.ts +48 -0
  23. package/src/api/User.ts +10 -0
  24. package/src/api/serverDataType/Answer.ts +25 -0
  25. package/src/api/serverDataType/Form.ts +84 -4
  26. package/src/api/serverDataType/Organization.ts +13 -0
  27. package/src/api/serverDataType/Project.ts +15 -0
  28. package/src/endpoints.module.ts +1185 -208
  29. package/types/api/Action.d.ts +1 -0
  30. package/types/api/Answer.d.ts +296 -2
  31. package/types/api/Badge.d.ts +1 -0
  32. package/types/api/BaseEntity.d.ts +101 -3
  33. package/types/api/Classified.d.ts +1 -0
  34. package/types/api/Comment.d.ts +1 -0
  35. package/types/api/EndpointApi.d.ts +10 -1
  36. package/types/api/EndpointApi.types.d.ts +334 -41
  37. package/types/api/Event.d.ts +1 -0
  38. package/types/api/Form.d.ts +58 -0
  39. package/types/api/News.d.ts +1 -0
  40. package/types/api/Organization.d.ts +20 -1
  41. package/types/api/Poi.d.ts +1 -0
  42. package/types/api/Project.d.ts +21 -0
  43. package/types/api/User.d.ts +7 -0
  44. package/types/api/serverDataType/Answer.d.ts +22 -0
  45. package/types/api/serverDataType/Form.d.ts +89 -4
  46. package/types/api/serverDataType/Organization.d.ts +13 -0
  47. package/types/api/serverDataType/Project.d.ts +15 -0
  48. package/types/endpoints.module.d.ts +1222 -1005
@@ -297,4 +297,5 @@ export declare class Action extends BaseEntity<ActionItemNormalized> {
297
297
  * Vérifie un format ISO 8601 date-time strict (avec T et option timezone Z ou ±HH:MM).
298
298
  */
299
299
  private _isIsoDateTime;
300
+ form(): Promise<never>;
300
301
  }
@@ -1,12 +1,89 @@
1
1
  import { BaseEntity } from "./BaseEntity.js";
2
2
  import type { AnswerItemNormalized } from "./serverDataType/Answer.js";
3
+ import type { FormItemNormalized } from "./serverDataType/Form.js";
4
+ type UploadInput = File | Blob | Buffer | import("stream").Readable;
5
+ /**
6
+ * Format des données utilisateur d'un CoForm — `{ subFormId: { inputId: value } }`.
7
+ * Générique : la lib ne fait aucune supposition sur le type des valeurs.
8
+ */
9
+ export type AllStepsData = Record<string, Record<string, unknown>>;
10
+ /**
11
+ * Valeur d'un upload en attente — objet `{ name?, data: "data:...;base64,..." }`
12
+ * inséré par les inputs uploader avant le pré-upload backend.
13
+ */
14
+ export interface PendingUploadValue {
15
+ name?: string;
16
+ data: string;
17
+ }
18
+ /**
19
+ * Un pending upload détecté dans la structure `allData` — chemin imbriqué +
20
+ * type d'input dérivé du schéma (`formData.inputs[subFormId].inputs[inputId].type`).
21
+ */
22
+ export interface PendingUpload {
23
+ value: PendingUploadValue;
24
+ path: (string | number)[];
25
+ inputType?: string;
26
+ }
27
+ /**
28
+ * Options de `Answer.processUploads()`.
29
+ */
30
+ export interface ProcessUploadsOptions {
31
+ /**
32
+ * Schéma du Form (pour déduire `inputType` des champs uploader/simpleTable).
33
+ * Auto-récupéré via `this.parent.serverData` si parent est un Form.
34
+ */
35
+ formData?: FormItemNormalized;
36
+ /** Nombre d'uploads parallèles par batch. Défaut : 4. */
37
+ batchSize?: number;
38
+ }
39
+ /**
40
+ * Options pour `Answer.uploadFile()`. Tous les champs sont optionnels — les
41
+ * défauts reproduisent les valeurs backend (`docType: "image"`, `contentKey: "slider"`).
42
+ */
43
+ export interface UploadAnswerFileOptions {
44
+ /** Type de document : `image` (défaut) ou `file` (PDF, DOCX, etc.). */
45
+ docType?: "image" | "file";
46
+ /** Clé de contenu côté backend. `"slider"` (défaut) pour images, `"presentation"` pour inputs uploader. */
47
+ contentKey?: string;
48
+ /** Sous-clé optionnelle (ex: `"subFormId.inputId"` pour les inputs `*.uploader`). */
49
+ subKey?: string;
50
+ /** UUID client (compat fine-uploader). Auto-généré si absent. */
51
+ qquuid?: string;
52
+ /** Nom du fichier. Auto-déduit (File.name, stream.path, ou fallback) si absent. */
53
+ qqfilename?: string;
54
+ /**
55
+ * Taille du fichier en octets. Auto-déduite pour `File` (`.size`), `Blob`
56
+ * (`.size`), `Buffer` (`.length`), ou `Readable` annoté (`.size`).
57
+ *
58
+ * **À fournir explicitement pour un `Readable` non annoté** (ex:
59
+ * `fs.createReadStream(path)` → faire `fs.statSync(path).size` au préalable),
60
+ * sinon `0` est envoyé et le backend peut rejeter le multipart.
61
+ */
62
+ qqtotalfilesize?: number;
63
+ }
64
+ /**
65
+ * Retour normalisé de `Answer.uploadFile()`.
66
+ */
67
+ export interface UploadAnswerFileResult {
68
+ /** ID du document MongoDB (à stocker dans `{docId, docPath}` pour les inputs uploader). */
69
+ docId: string;
70
+ /** Chemin du document. URL absolue côté backend, à nettoyer en chemin relatif si besoin (cf. `cleanUploaderUrls` site-json). */
71
+ docPath: string;
72
+ /** ID de l'Answer (créée par cet upload si premier, sinon `= this.id`). */
73
+ answerId: string;
74
+ }
3
75
  export declare class Answer extends BaseEntity<AnswerItemNormalized> {
4
76
  static entityType: string;
5
77
  static entityTag: string;
6
78
  static SCHEMA_CONSTANTS: string[];
7
- static ADD_BLOCKS: Map<string, string>;
8
- static UPDATE_BLOCKS: Map<string, string>;
79
+ static ADD_BLOCKS: Map<"SAVE_COFORM_ANSWER", "saveCoformAnswer">;
80
+ static UPDATE_BLOCKS: Map<"SAVE_COFORM_ANSWER", "saveCoformAnswer">;
9
81
  defaultFields: Record<string, any>;
82
+ /**
83
+ * Champs `serverData` à ne pas renvoyer au serveur dans le payload de save.
84
+ * `answers`, `addedOptions`, `links`, `form` sont conservés (envoyés au serveur).
85
+ * Les autres sont calculés/posés par le backend.
86
+ */
10
87
  removeFields: string[];
11
88
  /**
12
89
  * Transforme les champs imbriqués (user, context etc.) en instances d'entités.
@@ -20,4 +97,221 @@ export declare class Answer extends BaseEntity<AnswerItemNormalized> {
20
97
  * Constant : COFORM_ANSWERS_BY_ID
21
98
  */
22
99
  get(): Promise<Record<string, any>>;
100
+ form(): Promise<never>;
101
+ /**
102
+ * Supprime cette Answer côté serveur via `DELETE_ELEMENT`
103
+ * (`type=answers`, `id=this.id`).
104
+ *
105
+ * Après succès :
106
+ * - `serverData` et `draftData` sont vidés (sans casser la réactivité)
107
+ * - `_isDeleted = true` → toute mutation ultérieure (`save`, `get`, etc.) throw
108
+ *
109
+ * @param reason - Raison libre transmise au backend (audit). Défaut : `"delete coform answer"`.
110
+ * @throws {ApiError} 400 si l'Answer n'a pas d'id (jamais sauvegardée).
111
+ *
112
+ * @example
113
+ * const answer = await form.answer({ id: "..." });
114
+ * await answer.delete();
115
+ * answer._isDeleted; // true
116
+ */
117
+ delete(reason?: string): Promise<void>;
118
+ /**
119
+ * Upload un fichier rattaché à cette Answer via `COFORM_UPLOAD_ANSWER_FILE`.
120
+ *
121
+ * **Cas premier upload (Answer sans id)** : le backend crée l'Answer et
122
+ * renvoie `answerId`. La méthode pose alors `this._draftData.id = answerId`
123
+ * — les uploads suivants utiliseront cet id, et un `save()` ultérieur passera
124
+ * en update.
125
+ *
126
+ * **Cas uploads suivants (Answer avec id)** : `answerId: this.id` est envoyé.
127
+ *
128
+ * Compatible browser (File/Blob) et Node (Buffer/Readable) via
129
+ * `BaseEntity._prepareUploadFile()` — le multipart encoder du package
130
+ * `form-data` (utilisé en Node) ignore les Buffer bruts, donc conversion en
131
+ * stream annoté.
132
+ *
133
+ * @param file - Fichier à uploader (File/Blob côté browser, Buffer/Readable côté Node)
134
+ * @param opts - `docType`, `contentKey`, `subKey`, `qquuid`, `qqfilename`
135
+ * @returns `{ docId, docPath, answerId }` — toujours fournis par le backend.
136
+ * @throws {ApiError} si `formId` introuvable, ou réponse invalide.
137
+ *
138
+ * @example
139
+ * // Browser (depuis un <input type="file">)
140
+ * const form = await org.form({ id: formId });
141
+ * const answer = await form.answer(); // draft
142
+ * const { docId, docPath } = await answer.uploadFile(htmlFile, {
143
+ * contentKey: "presentation",
144
+ * subKey: `${subFormId}.${inputId}`,
145
+ * });
146
+ * // answer.id désormais défini → uploads suivants utilisent cet id.
147
+ *
148
+ * @example
149
+ * // Node (depuis un Buffer)
150
+ * const buffer = await fs.promises.readFile("./photo.jpg");
151
+ * const result = await answer.uploadFile(buffer, { docType: "image" });
152
+ */
153
+ uploadFile(file: UploadInput, opts?: UploadAnswerFileOptions): Promise<UploadAnswerFileResult>;
154
+ /**
155
+ * Orchestre l'upload de tous les fichiers pendants (`data:URI`) trouvés dans
156
+ * `allData`, puis renvoie la structure transformée prête pour `answer.save()`.
157
+ *
158
+ * **Pipeline complet** :
159
+ * 1. Walk récursif de `allData` → collecte les `data:URI` avec leur path + inputType
160
+ * 2. Premier upload (si Answer sans id) → backend crée l'Answer + pose `this.id`
161
+ * 3. Uploads restants en batches parallèles (défaut 4)
162
+ * 4. Remplacement dans la structure :
163
+ * - inputs `*.uploader` → `{ docId, docPath }`
164
+ * - autres → `docPath` string
165
+ * 5. Normalisation legacy uploader : `Array<{docId, docPath}>` → `{ updateDate, files }`
166
+ * 6. Nettoyage URLs absolues → chemins relatifs (uploader/simpleTable uniquement)
167
+ *
168
+ * Ne touche PAS `addedOptions` ni `links` — caller les pose séparément avant `save()`.
169
+ *
170
+ * @param allData - Données utilisateur `{ subFormId: { inputId: value } }`
171
+ * @param options - `formData` (auto via parent Form), `batchSize` (défaut 4)
172
+ * @returns `allData` transformé, prêt à être affecté à `answer.data.answers`
173
+ *
174
+ * @example
175
+ * const form = await org.form({ id: formId });
176
+ * const answer = await form.answer(); // ou form.answer({ id }) en édition
177
+ *
178
+ * const prepared = await answer.processUploads(allStepsDataFromForm);
179
+ * answer.data.answers = prepared;
180
+ * answer.data.addedOptions = addedOptions; // optionnel
181
+ * answer.data.links = finderLinks; // optionnel
182
+ * await answer.save();
183
+ */
184
+ processUploads(allData: AllStepsData, options?: ProcessUploadsOptions): Promise<AllStepsData>;
185
+ /**
186
+ * UUID v4 compatible browser + Node.
187
+ * Utilise `crypto.randomUUID()` si dispo, sinon fallback Math.random.
188
+ * @private
189
+ */
190
+ private _generateUuid;
191
+ /**
192
+ * Sauvegarde une nouvelle Answer (sans `id`) via `SAVE_COFORM_ANSWER`.
193
+ *
194
+ * Le payload caller-side attendu (dans `draftData`) :
195
+ * - `answers` (requis) — objet `{ subFormId: { inputId: value } }`
196
+ * - `form` ou parent Form (requis indirectement) — pour résoudre `formId`
197
+ * - `addedOptions` (optionnel) — multiCheckboxPlus dynamiques
198
+ * - `links` (optionnel) — sélections Finder à attacher à l'answer
199
+ *
200
+ * Sérialise automatiquement `answers`/`addedOptions`/`links` en JSON
201
+ * (le wire-format `application/x-www-form-urlencoded` exige des strings).
202
+ *
203
+ * Après succès, l'ID retourné par le serveur est posé dans `_draftData.id`
204
+ * → le `refresh()` de `BaseEntity.save()` peut alors récupérer l'Answer canonique.
205
+ *
206
+ * @protected — utiliser `answer.save()` (BaseEntity dispatch automatiquement).
207
+ */
208
+ _add: (payload: Record<string, any>) => Promise<void>;
209
+ /**
210
+ * Met à jour une Answer existante via `SAVE_COFORM_ANSWER` (avec `answerId`).
211
+ *
212
+ * Si `payload.answers` est `undefined` (le caller a modifié uniquement
213
+ * `addedOptions` ou `links`), on retombe sur `serverData.answers` pour ne
214
+ * pas envoyer un payload vide qui écraserait les réponses existantes.
215
+ *
216
+ * @protected — utiliser `answer.save()`.
217
+ */
218
+ _update: (payload: Record<string, any>) => Promise<boolean>;
219
+ /**
220
+ * Résout le `formId` à envoyer à `saveCoformAnswer`.
221
+ *
222
+ * Priorité :
223
+ * 1. `payload.form` (posé via `draftData.form` par `form.answer()`)
224
+ * 2. `serverData.form` (Answer chargée via `get()`)
225
+ * 3. `this.parent.id` si le parent est un `Form`
226
+ *
227
+ * @throws {ApiError} 400 si aucune source ne fournit un formId valide.
228
+ * @private
229
+ */
230
+ private _resolveFormId;
231
+ /**
232
+ * Construit le payload `SaveCoformAnswerData` en sérialisant les champs JSON
233
+ * requis par le wire-format `application/x-www-form-urlencoded`.
234
+ *
235
+ * Si `payload.answers` est absent en update, retombe sur `serverData.answers`
236
+ * (cf. design point 6.5 — indulgent envers le caller).
237
+ *
238
+ * @private
239
+ */
240
+ private _buildSavePayload;
241
+ /**
242
+ * Récupère `formData` (schéma du Form) depuis le parent si c'est un Form.
243
+ * Renvoie `undefined` si pas exploitable — `processUploads` continuera mais
244
+ * sans détection automatique d'`inputType` (pas de normalisation uploader,
245
+ * pas de clean URLs).
246
+ * @private
247
+ */
248
+ private _resolveFormData;
249
+ private _isObjectRecord;
250
+ private _isDataUri;
251
+ private _isPendingUploadValue;
252
+ private _parseMimeType;
253
+ private _inferExtensionFromMimeType;
254
+ private _sanitizeBaseName;
255
+ /**
256
+ * Convertit un `PendingUploadValue` (data:URI) en `{file, docType, filename}`
257
+ * exploitable par `uploadFile()`. Compatible browser + Node :
258
+ * - Browser → `File` natif
259
+ * - Node → `Buffer` (sera converti en stream par `_prepareUploadFile()`)
260
+ * @private
261
+ */
262
+ private _dataUriToFile;
263
+ /**
264
+ * Parcourt récursivement `allData` pour trouver tous les `data:URI` à uploader.
265
+ * Renvoie chaque pending avec son `path` (chemin imbriqué) et `inputType`
266
+ * (déduit du schéma `formData` si fourni).
267
+ * @private
268
+ */
269
+ private _collectPendingUploads;
270
+ /**
271
+ * Détermine `contentKey` et `subKey` pour un upload selon le type d'input :
272
+ * - `*.uploader` → `presentation` + subKey `"subFormId.inputId"`
273
+ * - autres → `slider` sans subKey
274
+ * @private
275
+ */
276
+ private _getUploadKeys;
277
+ private _getValueAtPath;
278
+ private _setValueAtPath;
279
+ /**
280
+ * Normalise une valeur d'input uploader vers le format legacy backend :
281
+ * `{ updateDate: ["DD/MM/YYYY"], files: { "<docId>": "<docPath>", ... } }`
282
+ * @private
283
+ */
284
+ private _normalizeUploaderValue;
285
+ private _cleanUrlToRelativePath;
286
+ /**
287
+ * Suffixes de types d'inputs dont les valeurs contiennent des URLs de fichiers
288
+ * à nettoyer avant envoi au serveur.
289
+ * @private
290
+ */
291
+ private static readonly INPUT_TYPES_TO_CLEAN_URLS;
292
+ /**
293
+ * Nettoie les URLs absolues → chemins relatifs **uniquement** sur les champs
294
+ * uploader/simpleTable. Les autres champs (finder, text…) peuvent contenir
295
+ * des URLs légitimes qu'il ne faut pas tronquer.
296
+ * @private
297
+ */
298
+ private _cleanUploaderUrls;
299
+ /**
300
+ * Upload par batches parallèles (défaut : 4 fichiers simultanés).
301
+ * @private
302
+ */
303
+ private _uploadInBatches;
304
+ /**
305
+ * Upload un PendingUpload, retourne la valeur de remplacement à insérer
306
+ * dans `allData` (`{docId, docPath}` pour uploader, `docPath` string sinon).
307
+ * @private
308
+ */
309
+ private _uploadPendingItem;
310
+ /**
311
+ * Upload un PendingUpload + remplace immédiatement dans `prepared` à son path.
312
+ * Utilisé pour le premier upload (séquentiel) qui crée l'Answer.
313
+ * @private
314
+ */
315
+ private _uploadAndReplace;
23
316
  }
317
+ export {};
@@ -21,4 +21,5 @@ export declare class Badge extends BaseEntity<any> {
21
21
  event(): Promise<never>;
22
22
  badge(): Promise<never>;
23
23
  news(): Promise<never>;
24
+ form(): Promise<never>;
24
25
  }
@@ -38,6 +38,12 @@ type NewsInput = {
38
38
  type ActionInput = {
39
39
  id: string;
40
40
  } | Record<string, any>;
41
+ type FormInput = {
42
+ id: string;
43
+ } | Record<string, any>;
44
+ type AnswerInput = {
45
+ id: string;
46
+ } | Record<string, any>;
41
47
  type ApiClient = import("../ApiClient.js").default;
42
48
  type EndpointApi = import("./EndpointApi.js").default;
43
49
  type User = import("./User.js").User;
@@ -57,6 +63,15 @@ type ParentLike = BaseEntity<any> & {
57
63
  apiClient: ApiClient;
58
64
  userContext?: User | null;
59
65
  };
66
+ /**
67
+ * Variantes d'endpoint disponibles pour `searchCostum`.
68
+ * Tous les variants doivent accepter le même schéma de requête/réponse que
69
+ * `GLOBAL_AUTOCOMPLETE_COSTUM` (drop-in remplacement).
70
+ *
71
+ * - `default` → `/co2/search/globalautocomplete`
72
+ * - `navigator-tl` → `/costum/navigator/gettl`
73
+ */
74
+ export type SearchCostumVariant = "default" | "navigator-tl";
60
75
  type EndpointApiCtor = {
61
76
  new (apiClient: ApiClient): EndpointApi;
62
77
  };
@@ -96,6 +111,7 @@ interface EntityTypeMap {
96
111
  type ReadableWithMeta = import("stream").Readable & {
97
112
  path?: string;
98
113
  mimeType?: string;
114
+ size?: number;
99
115
  };
100
116
  type UploadInput = File | Blob | Buffer | import("stream").Readable;
101
117
  type ValidatedUpload = File | Buffer | ReadableWithMeta;
@@ -118,6 +134,8 @@ export type CostumContextFields = {
118
134
  costumSlug: string;
119
135
  contextId: string;
120
136
  contextType: EntityType;
137
+ costumId: string;
138
+ costumType: EntityType;
121
139
  sourceKey: string[];
122
140
  };
123
141
  export type WithCostumContext<T> = T & CostumContextFields;
@@ -143,6 +161,12 @@ export type PaginatorState = {
143
161
  index: number;
144
162
  history: PaginationCursor[];
145
163
  sizes: number[];
164
+ /**
165
+ * Métadonnées libres survivant à la sérialisation JSON. Permet aux méthodes paginées
166
+ * de stocker des paramètres spécifiques (ex. `variant` pour `searchCostum`) qui doivent
167
+ * être restaurés lors d'un `restorePaginationFromJSON`.
168
+ */
169
+ meta?: Record<string, unknown>;
146
170
  };
147
171
  export interface PaginatorPage<T> {
148
172
  count: {
@@ -507,6 +531,37 @@ export declare class BaseEntity<TServerData = any> {
507
531
  * @private
508
532
  */
509
533
  protected _validateFile(fileInput: UploadInput): Promise<ValidatedUpload>;
534
+ /**
535
+ * Prépare un fichier pour un upload multipart **sans restriction MIME**.
536
+ *
537
+ * Diffère de `_validateImage` / `_validateFile` (liste MIME blanche stricte) :
538
+ * accepte tout MIME et garantit la conversion `Buffer → annotated stream` en
539
+ * Node (le multipart encoder du package `form-data` ignore les Buffer bruts ;
540
+ * il a besoin de `path` + `mimeType` sur un Readable).
541
+ *
542
+ * Pensé pour les endpoints d'upload large-spectre (ex: coform où l'utilisateur
543
+ * peut uploader PNG, GIF, WebP, PDF, DOCX, XLSX, etc. — c'est le backend qui
544
+ * filtre selon la config du Form, pas le client).
545
+ *
546
+ * Compatible browser + Node :
547
+ * - Browser `File` → pass-through
548
+ * - Browser `Blob` → wrap en `File` (génère nom + extension via MIME)
549
+ * - Node `Buffer` → détecte MIME via `file-type`, convertit en `Readable`
550
+ * annoté (`path`, `mimeType`)
551
+ * - Node `Readable` → pass-through si annoté, sinon utilise `fallbackName`
552
+ *
553
+ * @param input - Fichier à uploader (Buffer/File/Blob/Readable)
554
+ * @param fallbackName - Nom à utiliser si l'input n'en porte pas. Défaut `upload-<ts>`.
555
+ * @returns `{ qqfile, qqfilename, qqtotalfilesize }` prêt pour multipart.
556
+ * @throws {ApiError} si le type de l'input n'est pas reconnu.
557
+ *
558
+ * @protected
559
+ */
560
+ protected _prepareUploadFile(input: UploadInput, fallbackName?: string): Promise<{
561
+ qqfile: ValidatedUpload;
562
+ qqfilename: string;
563
+ qqtotalfilesize: number;
564
+ }>;
510
565
  /**
511
566
  * Valide les entrées d'upload de fichiers.
512
567
  *
@@ -519,14 +574,17 @@ export declare class BaseEntity<TServerData = any> {
519
574
  */
520
575
  private _validateUploadInput;
521
576
  /**
522
- * Transforme un Buffer en ReadableStream équivalent à fs.createReadStream
577
+ * Transforme un Buffer en ReadableStream équivalent à fs.createReadStream.
578
+ *
579
+ * Note : passé `protected` car réutilisé par `_prepareUploadFile()` (Answer).
580
+ *
523
581
  * @param buffer - Le buffer contenant les données binaires
524
582
  * @param [filename="file.bin"] - Nom de fichier (utilisé dans FormData)
525
583
  * @param [mimeType="application/octet-stream"] - Type MIME (utilisé dans FormData)
526
584
  * @returns - Readable doté de `path` et `mimeType`
527
- * @private
585
+ * @protected
528
586
  */
529
- private _createReadStreamFromBuffer;
587
+ protected _createReadStreamFromBuffer(buffer: Buffer, filename?: string, mimeType?: string): Promise<ReadableWithMeta>;
530
588
  /**
531
589
  * Transforme un Buffer en ReadableStream.
532
590
  *
@@ -1158,6 +1216,38 @@ export declare class BaseEntity<TServerData = any> {
1158
1216
  * @throws {ApiError} Sur les entités non supportées.
1159
1217
  */
1160
1218
  action(_actionData?: ActionInput): Promise<Action>;
1219
+ /**
1220
+ * Crée une instance de Form **dans le contexte costum de l'entité courante**.
1221
+ *
1222
+ * Méthode autorisée uniquement sur `Organization` et `Project` (les entités qui
1223
+ * portent un costumContext). Les autres entités la bloquent via un override
1224
+ * qui throw — cf. `User.form()`, `Event.form()`, `Poi.form()`, etc.
1225
+ *
1226
+ * @param formData - `{ id: string }` (Form n'a pas de slug)
1227
+ * @returns Le Form, déjà fetché (`get()` est appelé par `entity()` quand `id` est fourni).
1228
+ *
1229
+ * @example
1230
+ * const org = await api.organization({ slug: "navigatorDesTierslieux" });
1231
+ * const form = await org.form({ id: "6925e2b05dd63b02ca70d6d9" });
1232
+ * console.log(form.serverData.name); // "Coworking"
1233
+ * const answers = await form.getAnswers(); // utilise le costumContext de l'org
1234
+ */
1235
+ form(formData?: FormInput): Promise<Form>;
1236
+ /**
1237
+ * Crée une instance d'Answer rattachée à l'entité courante.
1238
+ *
1239
+ * Méthode autorisée uniquement sur `Form` (la seule entité qui porte un
1240
+ * `id` de formulaire pré-rempli pour les drafts). Les autres entités la
1241
+ * bloquent via cet override par défaut qui throw.
1242
+ *
1243
+ * Pour fetch une Answer existante sans contexte Form, passer par
1244
+ * `EntityRegistry.createEntityFromData` ou un endpoint adhoc.
1245
+ *
1246
+ * @param _answerData - `{ id: string }` (fetch) ou objet partiel (draft).
1247
+ * @returns Une Answer.
1248
+ * @throws {ApiError} 501 sur les entités non supportées.
1249
+ */
1250
+ answer(_answerData?: AnswerInput): Promise<Answer>;
1161
1251
  /**
1162
1252
  * Récupérer les organisations d'une entitée : la liste des organisations dont l'entité est membre ou admin valide.
1163
1253
  * Constant : GET_ORGANIZATIONS_ADMIN | GET_ORGANIZATIONS_NO_ADMIN
@@ -1600,9 +1690,17 @@ export declare class BaseEntity<TServerData = any> {
1600
1690
  * const nextPage = await page.next();
1601
1691
  * console.log(nextPage.pageNumber, nextPage.results.length);
1602
1692
  * }
1693
+ *
1694
+ * @example
1695
+ * // Cibler l'endpoint navigator/gettl (mêmes paramètres et même format de réponse)
1696
+ * const page = await entity.searchCostum(
1697
+ * { name: "marseille", searchType: ["projects"] },
1698
+ * { variant: "navigator-tl" }
1699
+ * );
1603
1700
  */
1604
1701
  searchCostum(data?: Partial<GlobalAutocompleteCostumData>, options?: {
1605
1702
  restoredState?: PaginatorState;
1703
+ variant?: SearchCostumVariant;
1606
1704
  }): Promise<PaginatorPage<any>>;
1607
1705
  /**
1608
1706
  * @param data
@@ -24,6 +24,7 @@ export declare class Classified extends BaseEntity<ClassifiedItemNormalized> {
24
24
  badge(): Promise<never>;
25
25
  news(): Promise<never>;
26
26
  classified(): Promise<never>;
27
+ form(): Promise<never>;
27
28
  follow(): Promise<never>;
28
29
  unfollow(): Promise<never>;
29
30
  getGallery(): Promise<never>;
@@ -54,4 +54,5 @@ export declare class Comment extends BaseEntity<CommentItemNormalized> {
54
54
  reason: string;
55
55
  comment?: string;
56
56
  }): Promise<unknown>;
57
+ form(): Promise<never>;
57
58
  }
@@ -1,5 +1,5 @@
1
1
  import type ApiClient from "../ApiClient.js";
2
- 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, CoremuOperationData, CostumProjectActionRequestNewData, CostumProjectActionRequestSetStatusData, CostumProjectActionRequestSetDateData, CostumProjectActionRequestSetContributorsData, CostumProjectActionRequestCancelData, CostumProjectActionRequestArchiveData, LinkDiscourseAccountData, UnlinkDiscourseAccountData, DiscourseProfileData, DiscourseCheckEmailData, DiscourseDismissLinkData, LinkMediawikiAccountData, UnlinkMediawikiAccountData, GetMediawikiContributionsData, AddClassifiedData } from "./EndpointApi.types.js";
2
+ 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, NavigatorGettlData, 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, CoremuOperationData, CostumProjectActionRequestNewData, CostumProjectActionRequestSetStatusData, CostumProjectActionRequestSetDateData, CostumProjectActionRequestSetContributorsData, CostumProjectActionRequestCancelData, CostumProjectActionRequestArchiveData, LinkDiscourseAccountData, UnlinkDiscourseAccountData, DiscourseProfileData, DiscourseCheckEmailData, DiscourseDismissLinkData, LinkMediawikiAccountData, UnlinkMediawikiAccountData, GetMediawikiContributionsData, AddClassifiedData } from "./EndpointApi.types.js";
3
3
  /**
4
4
  * Classe EndpointApi générée automatiquement depuis endpoints-copie.json
5
5
  */
@@ -891,6 +891,15 @@ export declare class EndpointApi {
891
891
  * @throws {Error} - En cas d'erreur inattendue.
892
892
  */
893
893
  globalAutocompleteCostum(data: GlobalAutocompleteCostumData): Promise<any>;
894
+ /**
895
+ * Navigator timeline (alias de globalautocomplete) : Recherche globale via navigator/gettl — schémas request/response identiques à GLOBAL_AUTOCOMPLETE_COSTUM
896
+ * Constant : NAVIGATOR_GETTL
897
+ * @param data - Données envoyées à l'API
898
+ * @returns Les données de réponse.
899
+ * @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
900
+ * @throws {Error} - En cas d'erreur inattendue.
901
+ */
902
+ navigatorGettl(data: NavigatorGettlData): Promise<any>;
894
903
  /**
895
904
  * Récupérer les acteurs d'événement : Récupérer les acteurs (organizers, attendees, creators, animators) d'une entité événement.
896
905
  * Constant : COSTUM_EVENT_REQUEST_ACTORS