@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.
- package/dist/cocolight-api-client.browser.js +3 -3
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +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/src/Api.ts +9 -9
- package/src/ApiClient.ts +3 -1
- package/src/api/Action.ts +4 -0
- package/src/api/Answer.ts +846 -6
- package/src/api/Badge.ts +5 -0
- package/src/api/BaseEntity.ts +190 -11
- package/src/api/Classified.ts +4 -0
- package/src/api/Comment.ts +3 -0
- package/src/api/EndpointApi.ts +16 -1
- package/src/api/EndpointApi.types.ts +375 -44
- package/src/api/Event.ts +5 -0
- package/src/api/Form.ts +102 -2
- package/src/api/News.ts +3 -0
- package/src/api/Organization.ts +44 -2
- package/src/api/Poi.ts +4 -0
- package/src/api/Project.ts +48 -0
- package/src/api/User.ts +10 -0
- package/src/api/serverDataType/Answer.ts +25 -0
- package/src/api/serverDataType/Form.ts +84 -4
- package/src/api/serverDataType/Organization.ts +13 -0
- package/src/api/serverDataType/Project.ts +15 -0
- package/src/endpoints.module.ts +1185 -208
- package/types/api/Action.d.ts +1 -0
- package/types/api/Answer.d.ts +296 -2
- package/types/api/Badge.d.ts +1 -0
- package/types/api/BaseEntity.d.ts +101 -3
- package/types/api/Classified.d.ts +1 -0
- package/types/api/Comment.d.ts +1 -0
- package/types/api/EndpointApi.d.ts +10 -1
- package/types/api/EndpointApi.types.d.ts +334 -41
- package/types/api/Event.d.ts +1 -0
- package/types/api/Form.d.ts +58 -0
- package/types/api/News.d.ts +1 -0
- package/types/api/Organization.d.ts +20 -1
- package/types/api/Poi.d.ts +1 -0
- package/types/api/Project.d.ts +21 -0
- package/types/api/User.d.ts +7 -0
- package/types/api/serverDataType/Answer.d.ts +22 -0
- package/types/api/serverDataType/Form.d.ts +89 -4
- package/types/api/serverDataType/Organization.d.ts +13 -0
- package/types/api/serverDataType/Project.d.ts +15 -0
- package/types/endpoints.module.d.ts +1222 -1005
package/src/api/Badge.ts
CHANGED
|
@@ -135,4 +135,9 @@ export class Badge extends BaseEntity<any> {
|
|
|
135
135
|
throw new ApiError(`news n'existe pas dans ${this.constructor.name}`, 501);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
|
|
139
|
+
override async form(): Promise<never> {
|
|
140
|
+
throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
|
|
141
|
+
}
|
|
142
|
+
|
|
138
143
|
}
|
package/src/api/BaseEntity.ts
CHANGED
|
@@ -78,6 +78,8 @@ type ClassifiedInput = { id: string } | Record<string, any>;
|
|
|
78
78
|
type BadgeInput = { id: string } | Record<string, any>;
|
|
79
79
|
type NewsInput = { id: string } | Record<string, any>;
|
|
80
80
|
type ActionInput = { id: string } | Record<string, any>;
|
|
81
|
+
type FormInput = { id: string } | Record<string, any>;
|
|
82
|
+
type AnswerInput = { id: string } | Record<string, any>;
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* On force le type de l'import comme une fabrique qui renvoie un objet
|
|
@@ -106,6 +108,21 @@ type Action = import("./Action.js").Action;
|
|
|
106
108
|
type AnyEntity = User | Organization | Project | Poi | EventEntity | Badge | News | Comment | Answer | Form | Classified | Action;
|
|
107
109
|
type ParentLike = BaseEntity<any> & { apiClient: ApiClient, userContext?: User | null };
|
|
108
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Variantes d'endpoint disponibles pour `searchCostum`.
|
|
113
|
+
* Tous les variants doivent accepter le même schéma de requête/réponse que
|
|
114
|
+
* `GLOBAL_AUTOCOMPLETE_COSTUM` (drop-in remplacement).
|
|
115
|
+
*
|
|
116
|
+
* - `default` → `/co2/search/globalautocomplete`
|
|
117
|
+
* - `navigator-tl` → `/costum/navigator/gettl`
|
|
118
|
+
*/
|
|
119
|
+
export type SearchCostumVariant = "default" | "navigator-tl";
|
|
120
|
+
|
|
121
|
+
const SEARCH_COSTUM_ENDPOINTS = {
|
|
122
|
+
"default": "globalAutocompleteCostum",
|
|
123
|
+
"navigator-tl": "navigatorGettl",
|
|
124
|
+
} as const satisfies Record<SearchCostumVariant, keyof EndpointApi>;
|
|
125
|
+
|
|
109
126
|
// Types pour les dépendances
|
|
110
127
|
type EndpointApiCtor = { new(apiClient: ApiClient): EndpointApi };
|
|
111
128
|
type EndpointApiDep = EndpointApi | EndpointApiCtor;
|
|
@@ -147,7 +164,7 @@ interface EntityTypeMap {
|
|
|
147
164
|
}
|
|
148
165
|
|
|
149
166
|
// Types pour les streams et uploads
|
|
150
|
-
type ReadableWithMeta = import("stream").Readable & { path?: string, mimeType?: string };
|
|
167
|
+
type ReadableWithMeta = import("stream").Readable & { path?: string, mimeType?: string, size?: number };
|
|
151
168
|
type UploadInput = File | Blob | Buffer | import("stream").Readable;
|
|
152
169
|
type ValidatedUpload = File | Buffer | ReadableWithMeta;
|
|
153
170
|
|
|
@@ -179,6 +196,9 @@ export type CostumContextFields = {
|
|
|
179
196
|
costumSlug: string;
|
|
180
197
|
contextId: string;
|
|
181
198
|
contextType: EntityType;
|
|
199
|
+
// Aliases historiques lus en fallback côté backend (cf. SearchNew::getQueries).
|
|
200
|
+
costumId: string;
|
|
201
|
+
costumType: EntityType;
|
|
182
202
|
sourceKey: string[];
|
|
183
203
|
};
|
|
184
204
|
|
|
@@ -205,6 +225,12 @@ export type PaginatorState = {
|
|
|
205
225
|
index: number;
|
|
206
226
|
history: PaginationCursor[];
|
|
207
227
|
sizes: number[];
|
|
228
|
+
/**
|
|
229
|
+
* Métadonnées libres survivant à la sérialisation JSON. Permet aux méthodes paginées
|
|
230
|
+
* de stocker des paramètres spécifiques (ex. `variant` pour `searchCostum`) qui doivent
|
|
231
|
+
* être restaurés lors d'un `restorePaginationFromJSON`.
|
|
232
|
+
*/
|
|
233
|
+
meta?: Record<string, unknown>;
|
|
208
234
|
};
|
|
209
235
|
|
|
210
236
|
// PaginatorPage interface pour les résultats paginés
|
|
@@ -1131,6 +1157,74 @@ export class BaseEntity<TServerData = any> {
|
|
|
1131
1157
|
return file;
|
|
1132
1158
|
}
|
|
1133
1159
|
|
|
1160
|
+
/**
|
|
1161
|
+
* Prépare un fichier pour un upload multipart **sans restriction MIME**.
|
|
1162
|
+
*
|
|
1163
|
+
* Diffère de `_validateImage` / `_validateFile` (liste MIME blanche stricte) :
|
|
1164
|
+
* accepte tout MIME et garantit la conversion `Buffer → annotated stream` en
|
|
1165
|
+
* Node (le multipart encoder du package `form-data` ignore les Buffer bruts ;
|
|
1166
|
+
* il a besoin de `path` + `mimeType` sur un Readable).
|
|
1167
|
+
*
|
|
1168
|
+
* Pensé pour les endpoints d'upload large-spectre (ex: coform où l'utilisateur
|
|
1169
|
+
* peut uploader PNG, GIF, WebP, PDF, DOCX, XLSX, etc. — c'est le backend qui
|
|
1170
|
+
* filtre selon la config du Form, pas le client).
|
|
1171
|
+
*
|
|
1172
|
+
* Compatible browser + Node :
|
|
1173
|
+
* - Browser `File` → pass-through
|
|
1174
|
+
* - Browser `Blob` → wrap en `File` (génère nom + extension via MIME)
|
|
1175
|
+
* - Node `Buffer` → détecte MIME via `file-type`, convertit en `Readable`
|
|
1176
|
+
* annoté (`path`, `mimeType`)
|
|
1177
|
+
* - Node `Readable` → pass-through si annoté, sinon utilise `fallbackName`
|
|
1178
|
+
*
|
|
1179
|
+
* @param input - Fichier à uploader (Buffer/File/Blob/Readable)
|
|
1180
|
+
* @param fallbackName - Nom à utiliser si l'input n'en porte pas. Défaut `upload-<ts>`.
|
|
1181
|
+
* @returns `{ qqfile, qqfilename, qqtotalfilesize }` prêt pour multipart.
|
|
1182
|
+
* @throws {ApiError} si le type de l'input n'est pas reconnu.
|
|
1183
|
+
*
|
|
1184
|
+
* @protected
|
|
1185
|
+
*/
|
|
1186
|
+
protected async _prepareUploadFile(
|
|
1187
|
+
input: UploadInput,
|
|
1188
|
+
fallbackName: string = `upload-${Date.now()}`,
|
|
1189
|
+
): Promise<{ qqfile: ValidatedUpload; qqfilename: string; qqtotalfilesize: number }> {
|
|
1190
|
+
const isNode = typeof window === "undefined" && typeof process !== "undefined";
|
|
1191
|
+
|
|
1192
|
+
// Browser : File natif
|
|
1193
|
+
if (typeof File !== "undefined" && input instanceof File) {
|
|
1194
|
+
return { qqfile: input, qqfilename: input.name, qqtotalfilesize: input.size };
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// Browser : Blob → wrap en File
|
|
1198
|
+
if (typeof Blob !== "undefined" && input instanceof Blob) {
|
|
1199
|
+
const ext = input.type.split("/")[1] || "bin";
|
|
1200
|
+
const name = `${fallbackName}.${ext}`;
|
|
1201
|
+
const file = new File([input], name, { type: input.type });
|
|
1202
|
+
return { qqfile: file, qqfilename: name, qqtotalfilesize: file.size };
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// Node : Buffer → annotated stream (file-type pour MIME)
|
|
1206
|
+
if (isNode && Buffer.isBuffer(input)) {
|
|
1207
|
+
const ft = await fromBuffer(input);
|
|
1208
|
+
const mime = ft?.mime ?? "application/octet-stream";
|
|
1209
|
+
const ext = ft?.ext ?? "bin";
|
|
1210
|
+
const name = /\.[a-z0-9]+$/i.test(fallbackName) ? fallbackName : `${fallbackName}.${ext}`;
|
|
1211
|
+
const stream = await this._createReadStreamFromBuffer(input, name, mime);
|
|
1212
|
+
return { qqfile: stream, qqfilename: name, qqtotalfilesize: input.length };
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// Node : Readable déjà annoté (ex: fs.createReadStream)
|
|
1216
|
+
if (isNode && input && typeof (input as { pipe?: unknown }).pipe === "function") {
|
|
1217
|
+
const stream = input as ReadableWithMeta;
|
|
1218
|
+
const name = (typeof stream.path === "string" && stream.path) || fallbackName;
|
|
1219
|
+
// `.size` peut être annoté manuellement par le caller (cf. `fs.statSync(...).size`).
|
|
1220
|
+
// Si absent → 0, à compléter via `opts.qqtotalfilesize` côté méthode appelante.
|
|
1221
|
+
const size = typeof stream.size === "number" ? stream.size : 0;
|
|
1222
|
+
return { qqfile: stream, qqfilename: name, qqtotalfilesize: size };
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
throw new ApiError("Type de fichier non reconnu pour l'upload.", 400);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1134
1228
|
/**
|
|
1135
1229
|
* Valide les entrées d'upload de fichiers.
|
|
1136
1230
|
*
|
|
@@ -1243,14 +1337,17 @@ export class BaseEntity<TServerData = any> {
|
|
|
1243
1337
|
}
|
|
1244
1338
|
|
|
1245
1339
|
/**
|
|
1246
|
-
* Transforme un Buffer en ReadableStream équivalent à fs.createReadStream
|
|
1340
|
+
* Transforme un Buffer en ReadableStream équivalent à fs.createReadStream.
|
|
1341
|
+
*
|
|
1342
|
+
* Note : passé `protected` car réutilisé par `_prepareUploadFile()` (Answer).
|
|
1343
|
+
*
|
|
1247
1344
|
* @param buffer - Le buffer contenant les données binaires
|
|
1248
1345
|
* @param [filename="file.bin"] - Nom de fichier (utilisé dans FormData)
|
|
1249
1346
|
* @param [mimeType="application/octet-stream"] - Type MIME (utilisé dans FormData)
|
|
1250
1347
|
* @returns - Readable doté de `path` et `mimeType`
|
|
1251
|
-
* @
|
|
1348
|
+
* @protected
|
|
1252
1349
|
*/
|
|
1253
|
-
|
|
1350
|
+
protected async _createReadStreamFromBuffer(buffer: Buffer, filename = "file.bin", mimeType = "application/octet-stream"): Promise<ReadableWithMeta> {
|
|
1254
1351
|
const stream = await this._bufferToReadable(buffer);
|
|
1255
1352
|
(stream as ReadableWithMeta).path = filename;
|
|
1256
1353
|
(stream as ReadableWithMeta).mimeType = mimeType;
|
|
@@ -2229,6 +2326,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
2229
2326
|
answers: ["id"],
|
|
2230
2327
|
classifieds: ["id"],
|
|
2231
2328
|
actions: ["id"],
|
|
2329
|
+
forms: ["id"],
|
|
2232
2330
|
};
|
|
2233
2331
|
|
|
2234
2332
|
const fetchKeys = (fetchKeysByEntity as Record<string, string[] | undefined>)[entityType];
|
|
@@ -3278,6 +3376,45 @@ export class BaseEntity<TServerData = any> {
|
|
|
3278
3376
|
throw new ApiError(`action n'existe pas dans ${this.constructor.name}`, 501);
|
|
3279
3377
|
}
|
|
3280
3378
|
|
|
3379
|
+
/**
|
|
3380
|
+
* Crée une instance de Form **dans le contexte costum de l'entité courante**.
|
|
3381
|
+
*
|
|
3382
|
+
* Méthode autorisée uniquement sur `Organization` et `Project` (les entités qui
|
|
3383
|
+
* portent un costumContext). Les autres entités la bloquent via un override
|
|
3384
|
+
* qui throw — cf. `User.form()`, `Event.form()`, `Poi.form()`, etc.
|
|
3385
|
+
*
|
|
3386
|
+
* @param formData - `{ id: string }` (Form n'a pas de slug)
|
|
3387
|
+
* @returns Le Form, déjà fetché (`get()` est appelé par `entity()` quand `id` est fourni).
|
|
3388
|
+
*
|
|
3389
|
+
* @example
|
|
3390
|
+
* const org = await api.organization({ slug: "navigatorDesTierslieux" });
|
|
3391
|
+
* const form = await org.form({ id: "6925e2b05dd63b02ca70d6d9" });
|
|
3392
|
+
* console.log(form.serverData.name); // "Coworking"
|
|
3393
|
+
* const answers = await form.getAnswers(); // utilise le costumContext de l'org
|
|
3394
|
+
*/
|
|
3395
|
+
async form(formData: FormInput = {}): Promise<Form> {
|
|
3396
|
+
const entity = await this.entity("forms", formData);
|
|
3397
|
+
return entity as Form;
|
|
3398
|
+
}
|
|
3399
|
+
|
|
3400
|
+
/**
|
|
3401
|
+
* Crée une instance d'Answer rattachée à l'entité courante.
|
|
3402
|
+
*
|
|
3403
|
+
* Méthode autorisée uniquement sur `Form` (la seule entité qui porte un
|
|
3404
|
+
* `id` de formulaire pré-rempli pour les drafts). Les autres entités la
|
|
3405
|
+
* bloquent via cet override par défaut qui throw.
|
|
3406
|
+
*
|
|
3407
|
+
* Pour fetch une Answer existante sans contexte Form, passer par
|
|
3408
|
+
* `EntityRegistry.createEntityFromData` ou un endpoint adhoc.
|
|
3409
|
+
*
|
|
3410
|
+
* @param _answerData - `{ id: string }` (fetch) ou objet partiel (draft).
|
|
3411
|
+
* @returns Une Answer.
|
|
3412
|
+
* @throws {ApiError} 501 sur les entités non supportées.
|
|
3413
|
+
*/
|
|
3414
|
+
async answer(_answerData: AnswerInput = {}): Promise<Answer> {
|
|
3415
|
+
throw new ApiError(`answer n'existe pas dans ${this.constructor.name}`, 501);
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3281
3418
|
/**
|
|
3282
3419
|
* Récupérer les organisations d'une entitée : la liste des organisations dont l'entité est membre ou admin valide.
|
|
3283
3420
|
* Constant : GET_ORGANIZATIONS_ADMIN | GET_ORGANIZATIONS_NO_ADMIN
|
|
@@ -4279,6 +4416,16 @@ export class BaseEntity<TServerData = any> {
|
|
|
4279
4416
|
|
|
4280
4417
|
const hasStep = (d: PaginationCursor | null | undefined) => Boolean(d?.indexStep && d.indexStep > 0);
|
|
4281
4418
|
|
|
4419
|
+
// searchBy "actif" = truthy non-vide (cohérent avec `!empty($post["searchBy"])` côté PHP).
|
|
4420
|
+
// Couvre les 3 formes acceptées par le backend : "ALL", CSV ("name,slug"), array (["name", "slug"]).
|
|
4421
|
+
// Quand actif → pagination simple indexMin/indexMax (pas de ranges multi-collection).
|
|
4422
|
+
const isSearchByActive = (sb: unknown): boolean => {
|
|
4423
|
+
if (sb == null) return false;
|
|
4424
|
+
if (typeof sb === "string") return sb.length > 0;
|
|
4425
|
+
if (Array.isArray(sb)) return sb.length > 0;
|
|
4426
|
+
return false;
|
|
4427
|
+
};
|
|
4428
|
+
|
|
4282
4429
|
async function getPage(isNext = false) {
|
|
4283
4430
|
const data: PaginationCursor = { ...initialData };
|
|
4284
4431
|
|
|
@@ -4291,14 +4438,14 @@ export class BaseEntity<TServerData = any> {
|
|
|
4291
4438
|
// hydrate data pour le premier appel
|
|
4292
4439
|
data.countType = data.searchType;
|
|
4293
4440
|
|
|
4294
|
-
if (!data.searchBy && hasStep(data)) {
|
|
4441
|
+
if (!isSearchByActive(data.searchBy) && hasStep(data)) {
|
|
4295
4442
|
data.ranges = Entity._generateRanges(
|
|
4296
4443
|
data.searchType as string[],
|
|
4297
4444
|
data.indexStep as number
|
|
4298
4445
|
);
|
|
4299
4446
|
data.indexMin = data.indexMin ?? 0;
|
|
4300
4447
|
data.indexMax = data.indexMax ?? data.indexStep;
|
|
4301
|
-
} else if (data.searchBy
|
|
4448
|
+
} else if (isSearchByActive(data.searchBy) && hasStep(data)) {
|
|
4302
4449
|
data.indexMin = data.indexMin ?? 0;
|
|
4303
4450
|
data.indexMax = data.indexMax ?? data.indexStep;
|
|
4304
4451
|
}
|
|
@@ -4311,7 +4458,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
4311
4458
|
if (isNext && cursor) {
|
|
4312
4459
|
state.history.push({ ...cursor });
|
|
4313
4460
|
|
|
4314
|
-
if (!cursor.searchBy && hasStep(cursor)) {
|
|
4461
|
+
if (!isSearchByActive(cursor.searchBy) && hasStep(cursor)) {
|
|
4315
4462
|
cursor.ranges = Entity._generateRanges(
|
|
4316
4463
|
cursor.searchType as string[],
|
|
4317
4464
|
cursor.indexStep as number,
|
|
@@ -4319,7 +4466,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
4319
4466
|
);
|
|
4320
4467
|
cursor.indexMin = cursor.indexMax ?? 0;
|
|
4321
4468
|
cursor.indexMax = (cursor.indexMax ?? 0) + (cursor.indexStep as number);
|
|
4322
|
-
} else if (cursor.searchBy
|
|
4469
|
+
} else if (isSearchByActive(cursor.searchBy) && hasStep(cursor)) {
|
|
4323
4470
|
cursor.indexMin = cursor.indexMax ?? 0;
|
|
4324
4471
|
cursor.indexMax = (cursor.indexMax ?? 0) + (cursor.indexStep as number);
|
|
4325
4472
|
}
|
|
@@ -4410,6 +4557,10 @@ export class BaseEntity<TServerData = any> {
|
|
|
4410
4557
|
costumSlug: sd.slug,
|
|
4411
4558
|
contextId: sd.id,
|
|
4412
4559
|
contextType: this.getEntityType(),
|
|
4560
|
+
// Aliases historiques lus en fallback par le backend (cf. SearchNew::getQueries) :
|
|
4561
|
+
// `$contextId = isset($post['contextId']) ? $post['contextId'] : $post['costumId']`
|
|
4562
|
+
costumId: sd.id,
|
|
4563
|
+
costumType: this.getEntityType(),
|
|
4413
4564
|
sourceKey: [...inSourceKey, sd.slug] as string[]
|
|
4414
4565
|
} as TIn & CostumContextFields;
|
|
4415
4566
|
|
|
@@ -4452,20 +4603,48 @@ export class BaseEntity<TServerData = any> {
|
|
|
4452
4603
|
* const nextPage = await page.next();
|
|
4453
4604
|
* console.log(nextPage.pageNumber, nextPage.results.length);
|
|
4454
4605
|
* }
|
|
4606
|
+
*
|
|
4607
|
+
* @example
|
|
4608
|
+
* // Cibler l'endpoint navigator/gettl (mêmes paramètres et même format de réponse)
|
|
4609
|
+
* const page = await entity.searchCostum(
|
|
4610
|
+
* { name: "marseille", searchType: ["projects"] },
|
|
4611
|
+
* { variant: "navigator-tl" }
|
|
4612
|
+
* );
|
|
4455
4613
|
*/
|
|
4456
4614
|
async searchCostum(
|
|
4457
4615
|
data: Partial<GlobalAutocompleteCostumData> = {},
|
|
4458
|
-
options?: { restoredState?: PaginatorState }
|
|
4616
|
+
options?: { restoredState?: PaginatorState; variant?: SearchCostumVariant }
|
|
4459
4617
|
): Promise<PaginatorPage<any>> {
|
|
4618
|
+
// Le variant peut être fourni explicitement OU restauré depuis le state d'une page sérialisée.
|
|
4619
|
+
// Ainsi `JSON.stringify(page) → restorePaginationFromJSON → next()` conserve l'endpoint cible.
|
|
4620
|
+
const restoredVariant = (options?.restoredState?.meta?.variant as SearchCostumVariant | undefined);
|
|
4621
|
+
const variant: SearchCostumVariant = options?.variant ?? restoredVariant ?? "default";
|
|
4622
|
+
const endpointMethod = SEARCH_COSTUM_ENDPOINTS[variant];
|
|
4623
|
+
|
|
4460
4624
|
const paginator = this._createPaginatorEngine({
|
|
4461
4625
|
initialData: data,
|
|
4626
|
+
// Toujours "searchCostum" (la vraie méthode) — sinon `restorePaginationFromJSON`
|
|
4627
|
+
// ne pourrait pas la retrouver via `entity[methodName]`. Le variant est persisté dans `state.meta`.
|
|
4462
4628
|
methodName: "searchCostum",
|
|
4463
4629
|
restoredState: options?.restoredState,
|
|
4464
4630
|
finalizer: this._withCostumContext(
|
|
4465
|
-
(finalData: GlobalAutocompleteCostumData) =>
|
|
4631
|
+
(finalData: GlobalAutocompleteCostumData) => {
|
|
4632
|
+
// Les variants partagent le même schéma request/response côté backend
|
|
4633
|
+
// (cf. SEARCH_COSTUM_ENDPOINTS) — cast safe.
|
|
4634
|
+
const fn = this.endpointApi[endpointMethod] as typeof this.endpointApi.globalAutocompleteCostum;
|
|
4635
|
+
return fn.call(this.endpointApi, finalData);
|
|
4636
|
+
}
|
|
4466
4637
|
),
|
|
4467
4638
|
});
|
|
4468
|
-
|
|
4639
|
+
|
|
4640
|
+
const page = await paginator.next() as PaginatorPage<any>;
|
|
4641
|
+
|
|
4642
|
+
// Persiste le variant dans le state pour qu'il survive à JSON.stringify/restore.
|
|
4643
|
+
if (page._state) {
|
|
4644
|
+
page._state.meta = { ...(page._state.meta || {}), variant };
|
|
4645
|
+
}
|
|
4646
|
+
|
|
4647
|
+
return page;
|
|
4469
4648
|
}
|
|
4470
4649
|
|
|
4471
4650
|
/**
|
package/src/api/Classified.ts
CHANGED
|
@@ -157,6 +157,10 @@ export class Classified extends BaseEntity<ClassifiedItemNormalized> {
|
|
|
157
157
|
throw new ApiError(`classified n'existe pas dans ${this.constructor.name}`, 501);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
override async form(): Promise<never> {
|
|
161
|
+
throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
|
|
162
|
+
}
|
|
163
|
+
|
|
160
164
|
override async follow(): Promise<never> {
|
|
161
165
|
throw new ApiError(`follow n'existe pas dans ${this.constructor.name}`, 501);
|
|
162
166
|
}
|
package/src/api/Comment.ts
CHANGED
|
@@ -249,4 +249,7 @@ export class Comment extends BaseEntity<CommentItemNormalized> {
|
|
|
249
249
|
return await this.callIsConnected(() => this.endpointApi.addReportAbuse(payload));
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
override async form(): Promise<never> {
|
|
253
|
+
throw new ApiError(`form n'existe pas dans ${this.constructor.name}`, 501);
|
|
254
|
+
}
|
|
252
255
|
}
|
package/src/api/EndpointApi.ts
CHANGED
|
@@ -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, 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";
|
|
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, 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";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Classe EndpointApi générée automatiquement depuis endpoints-copie.json
|
|
@@ -1444,6 +1444,21 @@ export class EndpointApi {
|
|
|
1444
1444
|
return this.call("GLOBAL_AUTOCOMPLETE_COSTUM", data);
|
|
1445
1445
|
}
|
|
1446
1446
|
|
|
1447
|
+
/**
|
|
1448
|
+
* Navigator timeline (alias de globalautocomplete) : Recherche globale via navigator/gettl — schémas request/response identiques à GLOBAL_AUTOCOMPLETE_COSTUM
|
|
1449
|
+
* Constant : NAVIGATOR_GETTL
|
|
1450
|
+
* @param data - Données envoyées à l'API
|
|
1451
|
+
* @returns Les données de réponse.
|
|
1452
|
+
* @throws {ApiResponseError} - En cas d'erreur détectée dans la réponse.
|
|
1453
|
+
* @throws {Error} - En cas d'erreur inattendue.
|
|
1454
|
+
*/
|
|
1455
|
+
async navigatorGettl(data: NavigatorGettlData): Promise<any> {
|
|
1456
|
+
if (!data || typeof data !== "object") {
|
|
1457
|
+
throw new TypeError("Le paramètre data doit être un objet.");
|
|
1458
|
+
}
|
|
1459
|
+
return this.call("NAVIGATOR_GETTL", data);
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1447
1462
|
/**
|
|
1448
1463
|
* Récupérer les acteurs d'événement : Récupérer les acteurs (organizers, attendees, creators, animators) d'une entité événement.
|
|
1449
1464
|
* Constant : COSTUM_EVENT_REQUEST_ACTORS
|