@communecter/cocolight-api-client 1.0.106 → 1.0.108

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -124,6 +124,29 @@ type ReadableWithMeta = import("stream").Readable & { path?: string, mimeType?:
124
124
  type UploadInput = File | Blob | Buffer | import("stream").Readable;
125
125
  type ValidatedUpload = File | Buffer | ReadableWithMeta;
126
126
 
127
+ // Type pour le curseur de pagination utilisé dans _createPaginatorEngine
128
+ type PaginationCursor = {
129
+ searchType?: string[];
130
+ searchBy?: string;
131
+ countType?: string[];
132
+ ranges?: Record<string, { indexMin: number; indexMax: number }>;
133
+ indexMin?: number;
134
+ indexMax?: number;
135
+ indexStep?: number;
136
+ [key: string]: unknown; // Pour les propriétés additionnelles dynamiques
137
+ };
138
+
139
+ /**
140
+ * État interne du paginateur, utilisé pour la restauration.
141
+ */
142
+ export type PaginatorState = {
143
+ cursor: PaginationCursor | null;
144
+ count: number;
145
+ index: number;
146
+ history: PaginationCursor[];
147
+ sizes: number[];
148
+ };
149
+
127
150
  // PaginatorPage interface pour les résultats paginés
128
151
  export interface PaginatorPage<T> {
129
152
  count: {
@@ -136,6 +159,11 @@ export interface PaginatorPage<T> {
136
159
  hasPrev: boolean;
137
160
  next?: () => Promise<PaginatorPage<T>>;
138
161
  prev?: () => Promise<PaginatorPage<T>>;
162
+ // Métadonnées pour la sérialisation/restauration
163
+ _initialData?: Record<string, any>;
164
+ _state?: PaginatorState;
165
+ _entity?: BaseEntity<any>;
166
+ _methodName?: string;
139
167
  }
140
168
 
141
169
  /**
@@ -207,18 +235,6 @@ type JsonSchemaProperty = Record<string, unknown> & {
207
235
  const?: unknown;
208
236
  };
209
237
 
210
- // Type pour le curseur de pagination utilisé dans _createPaginatorEngine
211
- type PaginationCursor = {
212
- searchType?: string[];
213
- searchBy?: string;
214
- countType?: string[];
215
- ranges?: Record<string, { indexMin: number; indexMax: number }>;
216
- indexMin?: number;
217
- indexMax?: number;
218
- indexStep?: number;
219
- [key: string]: unknown; // Pour les propriétés additionnelles dynamiques
220
- };
221
-
222
238
  interface FilterValueCombined {
223
239
  $in: string[];
224
240
  $exists: boolean;
@@ -742,7 +758,7 @@ export class BaseEntity<TServerData = any> {
742
758
  ...(this.parent.serverData.links && { links: this.parent.serverData.links })
743
759
  };
744
760
  }
745
-
761
+
746
762
  return {
747
763
  __entityTag: this.__entityTag,
748
764
  __isSerializedEntity: true,
@@ -912,9 +928,7 @@ export class BaseEntity<TServerData = any> {
912
928
  }
913
929
  const { serverData } = json as { serverData: object };
914
930
 
915
- const instance = this.fromServerData(this._revive(serverData, parent), parent as ApiClient | ParentLike, deps || {});
916
-
917
- return instance;
931
+ return this.fromServerData(this._revive(serverData, parent), parent as ApiClient | ParentLike, deps || {});
918
932
  }
919
933
 
920
934
  /**
@@ -3185,12 +3199,17 @@ export class BaseEntity<TServerData = any> {
3185
3199
  * @param data - Paramètres (partiels) de recherche/pagination.
3186
3200
  * @returns - Les données de réponse.
3187
3201
  */
3188
- async getOrganizations(data: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData> = {}): Promise<PaginatorPage<Organization>> {
3202
+ async getOrganizations(
3203
+ data: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData> = {},
3204
+ options?: { restoredState?: PaginatorState }
3205
+ ): Promise<PaginatorPage<Organization>> {
3189
3206
  data.searchType = this._getDefaultFromEndpoint("GET_ORGANIZATIONS_NO_ADMIN", "searchType") as GetOrganizationsNoAdminData["searchType"];
3190
3207
  // data.searchBy = "ALL";
3191
3208
 
3192
3209
  const paginator = this._createPaginatorEngine({
3193
3210
  initialData: data,
3211
+ methodName: "getOrganizations",
3212
+ restoredState: options?.restoredState,
3194
3213
  finalizer: async (finalData) => {
3195
3214
  if(this.isMe){
3196
3215
  finalData.pathParams = { type: this.getEntityType(), id: this.id };
@@ -3226,12 +3245,17 @@ export class BaseEntity<TServerData = any> {
3226
3245
  * @param data - Paramètres (partiels) de recherche/pagination.
3227
3246
  * @returns - Les données de réponse.
3228
3247
  */
3229
- async getProjects(data: Partial<GetProjectsAdminData | GetProjectsNoAdminData> = {}): Promise<PaginatorPage<Project>> {
3248
+ async getProjects(
3249
+ data: Partial<GetProjectsAdminData | GetProjectsNoAdminData> = {},
3250
+ options?: { restoredState?: PaginatorState }
3251
+ ): Promise<PaginatorPage<Project>> {
3230
3252
  data.searchType = this._getDefaultFromEndpoint("GET_PROJECTS_ADMIN", "searchType") as GetProjectsAdminData["searchType"];
3231
3253
  // data.searchBy = "ALL";
3232
3254
 
3233
3255
  const paginator = this._createPaginatorEngine({
3234
3256
  initialData: data,
3257
+ methodName: "getProjects",
3258
+ restoredState: options?.restoredState,
3235
3259
  finalizer: async (finalData) => {
3236
3260
  if(this.isMe){
3237
3261
  finalData.pathParams = { type: this.getEntityType(), id: this.id };
@@ -3271,10 +3295,15 @@ export class BaseEntity<TServerData = any> {
3271
3295
  * @param data - Paramètres (partiels) de recherche/pagination.
3272
3296
  * @returns - Les données de réponse.
3273
3297
  */
3274
- async getEvents(data: Partial<GetEventsData> = {}): Promise<PaginatorPage<EventEntity>> {
3298
+ async getEvents(
3299
+ data: Partial<GetEventsData> = {},
3300
+ options?: { restoredState?: PaginatorState }
3301
+ ): Promise<PaginatorPage<EventEntity>> {
3275
3302
  data.searchType = this._getDefaultFromEndpoint("GET_EVENTS", "searchType") as GetEventsData["searchType"];
3276
3303
  const paginator = this._createPaginatorEngine({
3277
3304
  initialData: data,
3305
+ methodName: "getEvents",
3306
+ restoredState: options?.restoredState,
3278
3307
  finalizer: async (finalData) => {
3279
3308
  delete finalData?.pathParams;
3280
3309
  finalData.filters = {
@@ -3297,12 +3326,17 @@ export class BaseEntity<TServerData = any> {
3297
3326
  * @param data - Paramètres (partiels) de recherche/pagination.
3298
3327
  * @returns - Les données de réponse.
3299
3328
  */
3300
- async getPois(data: Partial<GetPoisAdminData | GetPoisNoAdminData> = {}): Promise<PaginatorPage<Poi>> {
3329
+ async getPois(
3330
+ data: Partial<GetPoisAdminData | GetPoisNoAdminData> = {},
3331
+ options?: { restoredState?: PaginatorState }
3332
+ ): Promise<PaginatorPage<Poi>> {
3301
3333
  data.searchType = this._getDefaultFromEndpoint("GET_POIS_ADMIN", "searchType") as GetPoisAdminData["searchType"];
3302
3334
  // data.searchBy = "ALL";
3303
3335
 
3304
3336
  const paginator = this._createPaginatorEngine({
3305
3337
  initialData: data,
3338
+ methodName: "getPois",
3339
+ restoredState: options?.restoredState,
3306
3340
  finalizer: async (finalData) => {
3307
3341
  if(this.isMe){
3308
3342
  finalData.pathParams = { type: this.getEntityType(), id: this.id };
@@ -3334,12 +3368,17 @@ export class BaseEntity<TServerData = any> {
3334
3368
  * @param data - Paramètres (partiels) de recherche/pagination.
3335
3369
  * @returns - Les données de réponse.
3336
3370
  */
3337
- async getSubscribers(data: Partial<GetSubscribersData> = {}): Promise<PaginatorPage<User>> {
3371
+ async getSubscribers(
3372
+ data: Partial<GetSubscribersData> = {},
3373
+ options?: { restoredState?: PaginatorState }
3374
+ ): Promise<PaginatorPage<User>> {
3338
3375
  data.searchType = this._getDefaultFromEndpoint("GET_SUBSCRIBERS", "searchType") as GetSubscribersData["searchType"];
3339
3376
  // data.searchBy = "ALL";
3340
3377
 
3341
3378
  const paginator = this._createPaginatorEngine({
3342
3379
  initialData: data,
3380
+ methodName: "getSubscribers",
3381
+ restoredState: options?.restoredState,
3343
3382
  finalizer: async (finalData) => {
3344
3383
  delete finalData?.pathParams;
3345
3384
 
@@ -3362,12 +3401,17 @@ export class BaseEntity<TServerData = any> {
3362
3401
  * @param data - Paramètres (partiels) de recherche/pagination.
3363
3402
  * @returns - Les données de réponse.
3364
3403
  */
3365
- async getBadgesIssuer(data: Partial<GetBadgesData> = {}): Promise<PaginatorPage<Badge>> {
3404
+ async getBadgesIssuer(
3405
+ data: Partial<GetBadgesData> = {},
3406
+ options?: { restoredState?: PaginatorState }
3407
+ ): Promise<PaginatorPage<Badge>> {
3366
3408
  data.searchType = this._getDefaultFromEndpoint("GET_BADGES", "searchType") as GetBadgesData["searchType"];
3367
3409
  // data.searchBy = "ALL";
3368
3410
 
3369
3411
  const paginator = this._createPaginatorEngine({
3370
3412
  initialData: data,
3413
+ methodName: "getBadgesIssuer",
3414
+ restoredState: options?.restoredState,
3371
3415
  finalizer: async (finalData) => {
3372
3416
  delete finalData?.pathParams;
3373
3417
 
@@ -3917,14 +3961,18 @@ export class BaseEntity<TServerData = any> {
3917
3961
  /**
3918
3962
  * Coeur de pagination stateless et réutilisable.
3919
3963
  */
3920
- _createPaginatorEngine<TData extends Record<string, any>, TOut>({ initialData, finalizer }: {
3964
+ _createPaginatorEngine<TData extends Record<string, any>, TOut>({ initialData, finalizer, methodName, restoredState }: {
3921
3965
  initialData: Partial<TData>,
3922
- finalizer: (data: TData) => Promise<FinalizerResult<TOut>>
3966
+ finalizer: (data: TData) => Promise<FinalizerResult<TOut>>,
3967
+ methodName: string,
3968
+ restoredState?: PaginatorState
3923
3969
  }): { next: () => Promise<PaginatorPage<TOut>> } {
3924
3970
  // eslint-disable-next-line @typescript-eslint/no-this-alias
3925
3971
  const Entity = this;
3926
3972
 
3927
- const state: { cursor: PaginationCursor | null; count: number; index: number; history: PaginationCursor[]; sizes: number[] } = { cursor: null, count: 0, index: 0, history: [], sizes: [] };
3973
+ const state: PaginatorState = restoredState
3974
+ ? { ...restoredState }
3975
+ : { cursor: null, count: 0, index: 0, history: [], sizes: [] };
3928
3976
 
3929
3977
  const hasStep = (d: PaginationCursor | null | undefined) => Boolean(d?.indexStep && d.indexStep > 0);
3930
3978
 
@@ -4018,7 +4066,12 @@ export class BaseEntity<TServerData = any> {
4018
4066
  state.cursor = { ...previous };
4019
4067
  return getPage(false);
4020
4068
  }
4021
- : undefined
4069
+ : undefined,
4070
+ // Métadonnées pour la restauration
4071
+ _initialData: { ...initialData },
4072
+ _state: state,
4073
+ _entity: Entity,
4074
+ _methodName: methodName
4022
4075
  };
4023
4076
  }
4024
4077
 
@@ -4107,9 +4160,14 @@ export class BaseEntity<TServerData = any> {
4107
4160
  * console.log(nextPage.pageNumber, nextPage.results.length);
4108
4161
  * }
4109
4162
  */
4110
- async searchCostum(data: Partial<GlobalAutocompleteCostumData> = {}): Promise<PaginatorPage<any>> {
4163
+ async searchCostum(
4164
+ data: Partial<GlobalAutocompleteCostumData> = {},
4165
+ options?: { restoredState?: PaginatorState }
4166
+ ): Promise<PaginatorPage<any>> {
4111
4167
  const paginator = this._createPaginatorEngine({
4112
4168
  initialData: data,
4169
+ methodName: "searchCostum",
4170
+ restoredState: options?.restoredState,
4113
4171
  finalizer: this._withCostumContext(
4114
4172
  (finalData: GlobalAutocompleteCostumData) => this.endpointApi.globalAutocompleteCostum(finalData)
4115
4173
  ),
@@ -4387,9 +4445,14 @@ export class BaseEntity<TServerData = any> {
4387
4445
  }
4388
4446
 
4389
4447
 
4390
- async coformAnswersSearch(data: Partial<CoformAnswersSearchData> = {}): Promise<PaginatorPage<any>> {
4448
+ async coformAnswersSearch(
4449
+ data: Partial<CoformAnswersSearchData> = {},
4450
+ options?: { restoredState?: PaginatorState }
4451
+ ): Promise<PaginatorPage<any>> {
4391
4452
  const paginator = this._createPaginatorEngine({
4392
4453
  initialData: data,
4454
+ methodName: "coformAnswersSearch",
4455
+ restoredState: options?.restoredState,
4393
4456
  finalizer: this._withCostumContext(
4394
4457
  (finalData: CoformAnswersSearchData) => this.endpointApi.coformAnswersSearch(finalData)
4395
4458
  ),
@@ -4397,6 +4460,96 @@ export class BaseEntity<TServerData = any> {
4397
4460
  return paginator.next() as Promise<PaginatorPage<any>>;
4398
4461
  }
4399
4462
 
4463
+ /**
4464
+ * ───────────────────────────────
4465
+ * Pagination restoration methods
4466
+ * ───────────────────────────────
4467
+ */
4468
+
4469
+ /**
4470
+ * Restaure une pagination depuis des données JSON sérialisées.
4471
+ * Ne fait PAS d'appel API - utilise les results déjà présents.
4472
+ * Les fonctions next() et prev() font des appels API quand appelées.
4473
+ *
4474
+ * @param paginationJson - Les données JSON sérialisées d'une pagination
4475
+ * @param apiClientOrEntity - ApiClient ou entité parente pour la reconstruction des entités
4476
+ * @returns Une page de pagination hydratée avec next() et prev() fonctionnels
4477
+ *
4478
+ * @example
4479
+ * // Sérialiser une pagination
4480
+ * const firstPage = await user.getPois();
4481
+ * const json = JSON.stringify(firstPage);
4482
+ *
4483
+ * // Restaurer la pagination (sans appel API) - passer l'ApiClient
4484
+ * const restored = BaseEntity.restorePaginationFromJSON(JSON.parse(json), api.getClientInstance());
4485
+ *
4486
+ * // next() fait un appel API pour récupérer la page suivante
4487
+ * const secondPage = await restored.next?.();
4488
+ */
4489
+ static restorePaginationFromJSON<T>(
4490
+ paginationJson: any,
4491
+ apiClientOrEntity: ApiClient | BaseEntity<any>
4492
+ ): PaginatorPage<T> {
4493
+ // 1. Déterminer l'entité parent
4494
+ // Si c'est déjà une entité, l'utiliser directement
4495
+ // Sinon (ApiClient), restaurer depuis le JSON
4496
+ const entity = apiClientOrEntity instanceof BaseEntity
4497
+ ? apiClientOrEntity
4498
+ : fromEntityJSON(paginationJson._entity, apiClientOrEntity) as BaseEntity<any>;
4499
+
4500
+ // 2. Restaurer les results (sans appel API)
4501
+ const results = paginationJson.results.map((r: any) =>
4502
+ fromEntityJSON(r, entity)
4503
+ ) as T[];
4504
+
4505
+ // 3. Récupérer les métadonnées
4506
+ const methodName = paginationJson._methodName;
4507
+ const initialData = paginationJson._initialData;
4508
+ const savedState: PaginatorState = paginationJson._state;
4509
+
4510
+ // 4. Construire l'objet pagination restauré
4511
+ return {
4512
+ results,
4513
+ count: paginationJson.count,
4514
+ hasNext: paginationJson.hasNext,
4515
+ hasPrev: paginationJson.hasPrev,
4516
+ pageIndex: paginationJson.pageIndex,
4517
+ pageNumber: paginationJson.pageNumber,
4518
+ next: paginationJson.hasNext
4519
+ ? async () => {
4520
+ const method = (entity as any)[methodName];
4521
+ if (typeof method !== "function") {
4522
+ throw new Error(`Méthode ${methodName} non trouvée sur l'entité`);
4523
+ }
4524
+ // Appeler la méthode avec restoredState pour recréer le paginateur
4525
+ // puis appeler next() pour obtenir la page suivante
4526
+ const paginator = await method.call(entity, initialData, {
4527
+ restoredState: savedState
4528
+ });
4529
+ return paginator.next?.() ?? paginator;
4530
+ }
4531
+ : undefined,
4532
+ prev: paginationJson.hasPrev
4533
+ ? async () => {
4534
+ const method = (entity as any)[methodName];
4535
+ if (typeof method !== "function") {
4536
+ throw new Error(`Méthode ${methodName} non trouvée sur l'entité`);
4537
+ }
4538
+ // Appeler la méthode avec restoredState pour recréer le paginateur
4539
+ // puis appeler prev() pour obtenir la page précédente
4540
+ const paginator = await method.call(entity, initialData, {
4541
+ restoredState: savedState
4542
+ });
4543
+ return paginator.prev?.() ?? paginator;
4544
+ }
4545
+ : undefined,
4546
+ _initialData: initialData,
4547
+ _state: savedState,
4548
+ _entity: entity,
4549
+ _methodName: methodName
4550
+ };
4551
+ }
4552
+
4400
4553
  }
4401
4554
 
4402
4555
  export default BaseEntity;
package/src/api/Event.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ApiError } from "../error.js";
2
- import { BaseEntity, PaginatorPage } from "./BaseEntity.js";
2
+ import { BaseEntity, PaginatorPage, PaginatorState } from "./BaseEntity.js";
3
3
  import { transformEntityRefs } from "../types/transforms.js";
4
4
 
5
5
  import type { AddEventData, GetAttendeesAdminData, GetAttendeesNoAdminData } from "./EndpointApi.types.js";
@@ -210,6 +210,7 @@ export class Event extends BaseEntity<EventItemNormalized> {
210
210
  isAdminPending?: boolean;
211
211
  isInviting?: boolean;
212
212
  roles?: any[];
213
+ restoredState?: PaginatorState;
213
214
  } = {}
214
215
  ): Promise<PaginatorPage<User>> {
215
216
  data.searchType = this._getDefaultFromEndpoint("GET_ATTENDEES_NO_ADMIN", "searchType") as GetAttendeesNoAdminData["searchType"];
@@ -217,6 +218,8 @@ export class Event extends BaseEntity<EventItemNormalized> {
217
218
 
218
219
  const paginator = this._createPaginatorEngine({
219
220
  initialData: data,
221
+ methodName: "getAttendees",
222
+ restoredState: options?.restoredState,
220
223
  finalizer: async (finalData) => {
221
224
 
222
225
  const { toBeValidated, isAdmin, isInviting, isAdminPending, roles = [] } = options;
@@ -2,7 +2,7 @@ import { ApiError } from "../error.js";
2
2
  import { BaseEntity } from "./BaseEntity.js";
3
3
  import { createSocialTransform } from "../types/transforms.js";
4
4
 
5
- import type { PaginatorPage } from "./BaseEntity.js";
5
+ import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
6
6
  import type {
7
7
  AddOrganizationData,
8
8
  GetMembersAdminData,
@@ -320,6 +320,7 @@ export class Organization extends BaseEntity<OrganizationItemNormalized> {
320
320
  isAdminPending?: boolean;
321
321
  isInviting?: boolean;
322
322
  roles?: any[];
323
+ restoredState?: PaginatorState;
323
324
  } = {}
324
325
  ): Promise<PaginatorPage<User | Organization>> {
325
326
 
@@ -335,6 +336,8 @@ export class Organization extends BaseEntity<OrganizationItemNormalized> {
335
336
 
336
337
  const paginator = this._createPaginatorEngine({
337
338
  initialData: data,
339
+ methodName: "getMembers",
340
+ restoredState: options?.restoredState,
338
341
  finalizer: async (finalData) => {
339
342
 
340
343
  const { toBeValidated, isAdmin, isAdminPending, isInviting, roles = [] } = options;
@@ -3,7 +3,7 @@ import { BaseEntity } from "./BaseEntity.js";
3
3
  import { createSocialTransform, transformEntityRefs } from "../types/transforms.js";
4
4
 
5
5
 
6
- import type { PaginatorPage } from "./BaseEntity.js";
6
+ import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
7
7
  import type { AddProjectData, GetContributorsAdminData, GetContributorsNoAdminData } from "./EndpointApi.types.js";
8
8
  import type { Organization } from "./Organization.js";
9
9
  import type { User } from "./User.js";
@@ -235,6 +235,7 @@ export class Project extends BaseEntity<ProjectItemNormalized> {
235
235
  isAdminPending?: boolean;
236
236
  isInviting?: boolean;
237
237
  roles?: any[];
238
+ restoredState?: PaginatorState;
238
239
  } = {}
239
240
  ): Promise<PaginatorPage<User | Organization>> {
240
241
  data.searchType = this._getDefaultFromEndpoint("GET_CONTRIBUTORS_ADMIN", "searchType") as GetContributorsAdminData["searchType"];
@@ -242,6 +243,8 @@ export class Project extends BaseEntity<ProjectItemNormalized> {
242
243
 
243
244
  const paginator = this._createPaginatorEngine({
244
245
  initialData: data,
246
+ methodName: "getContributors",
247
+ restoredState: options?.restoredState,
245
248
  finalizer: async (finalData) => {
246
249
 
247
250
  const { toBeValidated, isAdmin, isInviting, isAdminPending, roles = [] } = options;
package/src/api/User.ts CHANGED
@@ -4,7 +4,7 @@ import { UserMixin } from "../mixin/UserMixin.js";
4
4
  import { createSocialTransform } from "../types/transforms.js";
5
5
 
6
6
  import type { Badge } from "./Badge.js";
7
- import type { PaginatorPage } from "./BaseEntity.js";
7
+ import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
8
8
  import type {
9
9
  ConnectData,
10
10
  DisconnectData,
@@ -366,12 +366,17 @@ export class User extends BaseEntity<UserItemNormalized> {
366
366
  * Récupérer les organisations d'un utilisateur : Récupère la liste des organisations auxquelles l'utilisateur appartient.
367
367
  * Constant : GET_ORGANIZATIONS_ADMIN | GET_ORGANIZATIONS_NO_ADMIN
368
368
  */
369
- override async getOrganizations(data: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData> = {}) {
369
+ override async getOrganizations(
370
+ data: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData> = {},
371
+ options?: { restoredState?: PaginatorState }
372
+ ) {
370
373
  data.searchType = this._getDefaultFromEndpoint("GET_ORGANIZATIONS_NO_ADMIN", "searchType") as GetOrganizationsNoAdminData["searchType"];
371
374
  // data.searchBy = "ALL";
372
375
 
373
376
  const paginator = this._createPaginatorEngine({
374
377
  initialData: data,
378
+ methodName: "getOrganizations",
379
+ restoredState: options?.restoredState,
375
380
  finalizer: async (finalData) => {
376
381
  delete finalData?.pathParams;
377
382
 
@@ -436,12 +441,17 @@ export class User extends BaseEntity<UserItemNormalized> {
436
441
  * question : qui peut voir la liste d'amis, seulement l'utilisateur connecté ? ou tous les utilisateurs connectés ?
437
442
  * actuellement, c'est tous les utilisateurs connectés
438
443
  */
439
- async getFriends(data: Partial<GetFriendsAdminData> = {}): Promise<PaginatorPage<User>> {
444
+ async getFriends(
445
+ data: Partial<GetFriendsAdminData> = {},
446
+ options?: { restoredState?: PaginatorState }
447
+ ): Promise<PaginatorPage<User>> {
440
448
  data.searchType = this._getDefaultFromEndpoint("GET_FRIENDS_ADMIN", "searchType") as GetFriendsAdminData["searchType"];
441
449
  // data.searchBy = "ALL";
442
450
 
443
451
  const paginator = this._createPaginatorEngine({
444
452
  initialData: data,
453
+ methodName: "getFriends",
454
+ restoredState: options?.restoredState,
445
455
  finalizer: async (finalData) => {
446
456
 
447
457
  delete finalData?.pathParams;
@@ -462,12 +472,17 @@ export class User extends BaseEntity<UserItemNormalized> {
462
472
  * Récupérer les suivis
463
473
  * Constant : GET_SUBSCRIPTIONS / GET_SUBSCRIPTIONS_ADMIN
464
474
  */
465
- async getSubscriptions(data: Partial<GetSubscriptionsAdminData | GetSubscriptionsData> = {}): Promise<PaginatorPage<BaseEntity<any>>> {
475
+ async getSubscriptions(
476
+ data: Partial<GetSubscriptionsAdminData | GetSubscriptionsData> = {},
477
+ options?: { restoredState?: PaginatorState }
478
+ ): Promise<PaginatorPage<BaseEntity<any>>> {
466
479
  data.searchType = this._getDefaultFromEndpoint("GET_SUBSCRIPTIONS", "searchType") as GetSubscriptionsAdminData["searchType"];
467
480
  // data.searchBy = "ALL";
468
481
 
469
482
  const paginator = this._createPaginatorEngine({
470
483
  initialData: data,
484
+ methodName: "getSubscriptions",
485
+ restoredState: options?.restoredState,
471
486
  finalizer: async (finalData) => {
472
487
 
473
488
  delete finalData?.pathParams;
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { BaseEntity } from "./api/BaseEntity.js";
1
2
  import { fromEntityJSON } from "./api/EntityRegistry.js";
2
3
  import Api from "./Api.js";
3
4
  import ApiClient from "./ApiClient.js";
@@ -31,7 +32,8 @@ const cocolightApiClient = {
31
32
  MultiServerTokenStorageStrategy
32
33
  },
33
34
  helper: {
34
- fromEntityJSON
35
+ fromEntityJSON,
36
+ restorePaginationFromJSON: BaseEntity.restorePaginationFromJSON
35
37
  },
36
38
  OfflineClientManager
37
39
  };
@@ -90,7 +92,7 @@ export type * from "./api/serverDataType/Answer.js";
90
92
  export type * from "./api/serverDataType/common.js";
91
93
 
92
94
  // Types utilitaires
93
- export type { PaginatorPage } from "./api/BaseEntity.js";
95
+ export type { PaginatorPage, PaginatorState } from "./api/BaseEntity.js";
94
96
 
95
97
  // Types de réponses, payloads, entités, et transforms
96
98
  export type * from "./types/index.js";
@@ -103,8 +103,8 @@ export function transformEntityRefs(val: ParentData | OrganizerData | null): Ent
103
103
  {
104
104
  type: obj?.type ?? "",
105
105
  name: obj?.name,
106
- id: obj?.id,
107
- slug: obj?.slug
106
+ // id: obj?.id,
107
+ // slug: obj?.slug
108
108
  // _id exclu volontairement
109
109
  }
110
110
  ])