@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/dist/cocolight-api-client.browser.js +1 -1
- 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/BaseEntity.ts +181 -28
- package/src/api/Event.ts +4 -1
- package/src/api/Organization.ts +4 -1
- package/src/api/Project.ts +4 -1
- package/src/api/User.ts +19 -4
- package/src/index.ts +4 -2
- package/src/types/transforms.ts +2 -2
- package/types/api/BaseEntity.d.ts +80 -9
- package/types/api/Event.d.ts +2 -1
- package/types/api/Organization.d.ts +2 -1
- package/types/api/Project.d.ts +2 -1
- package/types/api/User.d.ts +10 -4
- package/types/index.d.ts +3 -1
|
@@ -82,6 +82,29 @@ type ReadableWithMeta = import("stream").Readable & {
|
|
|
82
82
|
};
|
|
83
83
|
type UploadInput = File | Blob | Buffer | import("stream").Readable;
|
|
84
84
|
type ValidatedUpload = File | Buffer | ReadableWithMeta;
|
|
85
|
+
type PaginationCursor = {
|
|
86
|
+
searchType?: string[];
|
|
87
|
+
searchBy?: string;
|
|
88
|
+
countType?: string[];
|
|
89
|
+
ranges?: Record<string, {
|
|
90
|
+
indexMin: number;
|
|
91
|
+
indexMax: number;
|
|
92
|
+
}>;
|
|
93
|
+
indexMin?: number;
|
|
94
|
+
indexMax?: number;
|
|
95
|
+
indexStep?: number;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* État interne du paginateur, utilisé pour la restauration.
|
|
100
|
+
*/
|
|
101
|
+
export type PaginatorState = {
|
|
102
|
+
cursor: PaginationCursor | null;
|
|
103
|
+
count: number;
|
|
104
|
+
index: number;
|
|
105
|
+
history: PaginationCursor[];
|
|
106
|
+
sizes: number[];
|
|
107
|
+
};
|
|
85
108
|
export interface PaginatorPage<T> {
|
|
86
109
|
count: {
|
|
87
110
|
total: number;
|
|
@@ -93,6 +116,10 @@ export interface PaginatorPage<T> {
|
|
|
93
116
|
hasPrev: boolean;
|
|
94
117
|
next?: () => Promise<PaginatorPage<T>>;
|
|
95
118
|
prev?: () => Promise<PaginatorPage<T>>;
|
|
119
|
+
_initialData?: Record<string, any>;
|
|
120
|
+
_state?: PaginatorState;
|
|
121
|
+
_entity?: BaseEntity<any>;
|
|
122
|
+
_methodName?: string;
|
|
96
123
|
}
|
|
97
124
|
/**
|
|
98
125
|
* Type helper pour extraire les noms de méthodes depuis un Map as const
|
|
@@ -1059,42 +1086,54 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
1059
1086
|
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
1060
1087
|
* @returns - Les données de réponse.
|
|
1061
1088
|
*/
|
|
1062
|
-
getOrganizations(data?: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData
|
|
1089
|
+
getOrganizations(data?: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData>, options?: {
|
|
1090
|
+
restoredState?: PaginatorState;
|
|
1091
|
+
}): Promise<PaginatorPage<Organization>>;
|
|
1063
1092
|
/**
|
|
1064
1093
|
* Récupérer les projets d'une entitée : liste des projets de l'entité ou elle est "parent" ou "contributeur".
|
|
1065
1094
|
* Constant : GET_PROJECTS_ADMIN | GET_PROJECTS_NO_ADMIN
|
|
1066
1095
|
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
1067
1096
|
* @returns - Les données de réponse.
|
|
1068
1097
|
*/
|
|
1069
|
-
getProjects(data?: Partial<GetProjectsAdminData | GetProjectsNoAdminData
|
|
1098
|
+
getProjects(data?: Partial<GetProjectsAdminData | GetProjectsNoAdminData>, options?: {
|
|
1099
|
+
restoredState?: PaginatorState;
|
|
1100
|
+
}): Promise<PaginatorPage<Project>>;
|
|
1070
1101
|
/**
|
|
1071
1102
|
* Récupérer les événements d'une entitée : liste des événements de l'entité ou elle est "organizer" ou "attendee".
|
|
1072
1103
|
* Constant : GET_EVENTS
|
|
1073
1104
|
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
1074
1105
|
* @returns - Les données de réponse.
|
|
1075
1106
|
*/
|
|
1076
|
-
getEvents(data?: Partial<GetEventsData
|
|
1107
|
+
getEvents(data?: Partial<GetEventsData>, options?: {
|
|
1108
|
+
restoredState?: PaginatorState;
|
|
1109
|
+
}): Promise<PaginatorPage<EventEntity>>;
|
|
1077
1110
|
/**
|
|
1078
1111
|
* Récupérer les POIs d'une entité : liste des POIs de l'entité ou elle est "parent".
|
|
1079
1112
|
* Constant : GET_POIS_NO_ADMIN / GET_POIS_ADMIN
|
|
1080
1113
|
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
1081
1114
|
* @returns - Les données de réponse.
|
|
1082
1115
|
*/
|
|
1083
|
-
getPois(data?: Partial<GetPoisAdminData | GetPoisNoAdminData
|
|
1116
|
+
getPois(data?: Partial<GetPoisAdminData | GetPoisNoAdminData>, options?: {
|
|
1117
|
+
restoredState?: PaginatorState;
|
|
1118
|
+
}): Promise<PaginatorPage<Poi>>;
|
|
1084
1119
|
/**
|
|
1085
1120
|
* Récupérer les abonnés d'une entité
|
|
1086
1121
|
* Constant : GET_SUBSCRIBERS
|
|
1087
1122
|
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
1088
1123
|
* @returns - Les données de réponse.
|
|
1089
1124
|
*/
|
|
1090
|
-
getSubscribers(data?: Partial<GetSubscribersData
|
|
1125
|
+
getSubscribers(data?: Partial<GetSubscribersData>, options?: {
|
|
1126
|
+
restoredState?: PaginatorState;
|
|
1127
|
+
}): Promise<PaginatorPage<User>>;
|
|
1091
1128
|
/**
|
|
1092
1129
|
* Liste des badges créés par l'entité
|
|
1093
1130
|
* Constant : GET_BADGES
|
|
1094
1131
|
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
1095
1132
|
* @returns - Les données de réponse.
|
|
1096
1133
|
*/
|
|
1097
|
-
getBadgesIssuer(data?: Partial<GetBadgesData
|
|
1134
|
+
getBadgesIssuer(data?: Partial<GetBadgesData>, options?: {
|
|
1135
|
+
restoredState?: PaginatorState;
|
|
1136
|
+
}): Promise<PaginatorPage<Badge>>;
|
|
1098
1137
|
/**
|
|
1099
1138
|
* Récupérer les actualités : Récupère la liste d'actualités selon plusieurs critères.
|
|
1100
1139
|
* Constant : GET_NEWS
|
|
@@ -1319,9 +1358,11 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
1319
1358
|
/**
|
|
1320
1359
|
* Coeur de pagination stateless et réutilisable.
|
|
1321
1360
|
*/
|
|
1322
|
-
_createPaginatorEngine<TData extends Record<string, any>, TOut>({ initialData, finalizer }: {
|
|
1361
|
+
_createPaginatorEngine<TData extends Record<string, any>, TOut>({ initialData, finalizer, methodName, restoredState }: {
|
|
1323
1362
|
initialData: Partial<TData>;
|
|
1324
1363
|
finalizer: (data: TData) => Promise<FinalizerResult<TOut>>;
|
|
1364
|
+
methodName: string;
|
|
1365
|
+
restoredState?: PaginatorState;
|
|
1325
1366
|
}): {
|
|
1326
1367
|
next: () => Promise<PaginatorPage<TOut>>;
|
|
1327
1368
|
};
|
|
@@ -1369,7 +1410,9 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
1369
1410
|
* console.log(nextPage.pageNumber, nextPage.results.length);
|
|
1370
1411
|
* }
|
|
1371
1412
|
*/
|
|
1372
|
-
searchCostum(data?: Partial<GlobalAutocompleteCostumData
|
|
1413
|
+
searchCostum(data?: Partial<GlobalAutocompleteCostumData>, options?: {
|
|
1414
|
+
restoredState?: PaginatorState;
|
|
1415
|
+
}): Promise<PaginatorPage<any>>;
|
|
1373
1416
|
/**
|
|
1374
1417
|
* @param data
|
|
1375
1418
|
* Paramètres de recherche (partiels — les valeurs manquantes sont complétées
|
|
@@ -1449,6 +1492,34 @@ export declare class BaseEntity<TServerData = any> {
|
|
|
1449
1492
|
* @throws {Error}
|
|
1450
1493
|
*/
|
|
1451
1494
|
costumEventRequestLoadContextTag(data?: Partial<Omit<CostumEventRequestLoadContextTagData, "pathParams">>): Promise<unknown>;
|
|
1452
|
-
coformAnswersSearch(data?: Partial<CoformAnswersSearchData
|
|
1495
|
+
coformAnswersSearch(data?: Partial<CoformAnswersSearchData>, options?: {
|
|
1496
|
+
restoredState?: PaginatorState;
|
|
1497
|
+
}): Promise<PaginatorPage<any>>;
|
|
1498
|
+
/**
|
|
1499
|
+
* ───────────────────────────────
|
|
1500
|
+
* Pagination restoration methods
|
|
1501
|
+
* ───────────────────────────────
|
|
1502
|
+
*/
|
|
1503
|
+
/**
|
|
1504
|
+
* Restaure une pagination depuis des données JSON sérialisées.
|
|
1505
|
+
* Ne fait PAS d'appel API - utilise les results déjà présents.
|
|
1506
|
+
* Les fonctions next() et prev() font des appels API quand appelées.
|
|
1507
|
+
*
|
|
1508
|
+
* @param paginationJson - Les données JSON sérialisées d'une pagination
|
|
1509
|
+
* @param apiClientOrEntity - ApiClient ou entité parente pour la reconstruction des entités
|
|
1510
|
+
* @returns Une page de pagination hydratée avec next() et prev() fonctionnels
|
|
1511
|
+
*
|
|
1512
|
+
* @example
|
|
1513
|
+
* // Sérialiser une pagination
|
|
1514
|
+
* const firstPage = await user.getPois();
|
|
1515
|
+
* const json = JSON.stringify(firstPage);
|
|
1516
|
+
*
|
|
1517
|
+
* // Restaurer la pagination (sans appel API) - passer l'ApiClient
|
|
1518
|
+
* const restored = BaseEntity.restorePaginationFromJSON(JSON.parse(json), api.getClientInstance());
|
|
1519
|
+
*
|
|
1520
|
+
* // next() fait un appel API pour récupérer la page suivante
|
|
1521
|
+
* const secondPage = await restored.next?.();
|
|
1522
|
+
*/
|
|
1523
|
+
static restorePaginationFromJSON<T>(paginationJson: any, apiClientOrEntity: ApiClient | BaseEntity<any>): PaginatorPage<T>;
|
|
1453
1524
|
}
|
|
1454
1525
|
export default BaseEntity;
|
package/types/api/Event.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseEntity, PaginatorPage } from "./BaseEntity.js";
|
|
1
|
+
import { BaseEntity, PaginatorPage, PaginatorState } from "./BaseEntity.js";
|
|
2
2
|
import type { AddEventData, GetAttendeesAdminData, GetAttendeesNoAdminData } from "./EndpointApi.types.js";
|
|
3
3
|
import type { User } from "./User.js";
|
|
4
4
|
import type { EventTransforms } from "../types/transforms.js";
|
|
@@ -68,6 +68,7 @@ export declare class Event extends BaseEntity<EventItemNormalized> {
|
|
|
68
68
|
isAdminPending?: boolean;
|
|
69
69
|
isInviting?: boolean;
|
|
70
70
|
roles?: any[];
|
|
71
|
+
restoredState?: PaginatorState;
|
|
71
72
|
}): Promise<PaginatorPage<User>>;
|
|
72
73
|
project(): Promise<never>;
|
|
73
74
|
poi(): Promise<never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseEntity } from "./BaseEntity.js";
|
|
2
|
-
import type { PaginatorPage } from "./BaseEntity.js";
|
|
2
|
+
import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
|
|
3
3
|
import type { AddOrganizationData, GetMembersAdminData, GetMembersNoAdminData } from "./EndpointApi.types.js";
|
|
4
4
|
import type { OpeningHoursEntry } from "./serverDataType/common.js";
|
|
5
5
|
import type { OrganizationItemNormalized } from "./serverDataType/Organization.js";
|
|
@@ -164,6 +164,7 @@ export declare class Organization extends BaseEntity<OrganizationItemNormalized>
|
|
|
164
164
|
isAdminPending?: boolean;
|
|
165
165
|
isInviting?: boolean;
|
|
166
166
|
roles?: any[];
|
|
167
|
+
restoredState?: PaginatorState;
|
|
167
168
|
}): Promise<PaginatorPage<User | Organization>>;
|
|
168
169
|
/**
|
|
169
170
|
* {@inheritDoc BaseEntity#getGallery}
|
package/types/api/Project.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseEntity } from "./BaseEntity.js";
|
|
2
|
-
import type { PaginatorPage } from "./BaseEntity.js";
|
|
2
|
+
import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
|
|
3
3
|
import type { AddProjectData, GetContributorsAdminData, GetContributorsNoAdminData } from "./EndpointApi.types.js";
|
|
4
4
|
import type { Organization } from "./Organization.js";
|
|
5
5
|
import type { User } from "./User.js";
|
|
@@ -97,6 +97,7 @@ export declare class Project extends BaseEntity<ProjectItemNormalized> {
|
|
|
97
97
|
isAdminPending?: boolean;
|
|
98
98
|
isInviting?: boolean;
|
|
99
99
|
roles?: any[];
|
|
100
|
+
restoredState?: PaginatorState;
|
|
100
101
|
}): Promise<PaginatorPage<User | Organization>>;
|
|
101
102
|
/**
|
|
102
103
|
* {@inheritDoc BaseEntity#getGallery}
|
package/types/api/User.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseEntity } from "./BaseEntity.js";
|
|
2
2
|
import type { Badge } from "./Badge.js";
|
|
3
|
-
import type { PaginatorPage } from "./BaseEntity.js";
|
|
3
|
+
import type { PaginatorPage, PaginatorState } from "./BaseEntity.js";
|
|
4
4
|
import type { ChangePasswordData, DeleteAccountData, GetSubscriptionsAdminData, GetSubscriptionsData, GetOrganizationsNoAdminData, GetOrganizationsAdminData, GetFriendsAdminData } from "./EndpointApi.types.js";
|
|
5
5
|
import type { Organization } from "./Organization.js";
|
|
6
6
|
import type { EntityTypes } from "@/types/entities.js";
|
|
@@ -152,7 +152,9 @@ export declare class User extends BaseEntity<UserItemNormalized> {
|
|
|
152
152
|
* Récupérer les organisations d'un utilisateur : Récupère la liste des organisations auxquelles l'utilisateur appartient.
|
|
153
153
|
* Constant : GET_ORGANIZATIONS_ADMIN | GET_ORGANIZATIONS_NO_ADMIN
|
|
154
154
|
*/
|
|
155
|
-
getOrganizations(data?: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData
|
|
155
|
+
getOrganizations(data?: Partial<GetOrganizationsAdminData | GetOrganizationsNoAdminData>, options?: {
|
|
156
|
+
restoredState?: PaginatorState;
|
|
157
|
+
}): Promise<PaginatorPage<Organization>>;
|
|
156
158
|
/**
|
|
157
159
|
* {@inheritDoc BaseEntity#getProjects}
|
|
158
160
|
*
|
|
@@ -183,12 +185,16 @@ export declare class User extends BaseEntity<UserItemNormalized> {
|
|
|
183
185
|
* question : qui peut voir la liste d'amis, seulement l'utilisateur connecté ? ou tous les utilisateurs connectés ?
|
|
184
186
|
* actuellement, c'est tous les utilisateurs connectés
|
|
185
187
|
*/
|
|
186
|
-
getFriends(data?: Partial<GetFriendsAdminData
|
|
188
|
+
getFriends(data?: Partial<GetFriendsAdminData>, options?: {
|
|
189
|
+
restoredState?: PaginatorState;
|
|
190
|
+
}): Promise<PaginatorPage<User>>;
|
|
187
191
|
/**
|
|
188
192
|
* Récupérer les suivis
|
|
189
193
|
* Constant : GET_SUBSCRIPTIONS / GET_SUBSCRIPTIONS_ADMIN
|
|
190
194
|
*/
|
|
191
|
-
getSubscriptions(data?: Partial<GetSubscriptionsAdminData | GetSubscriptionsData
|
|
195
|
+
getSubscriptions(data?: Partial<GetSubscriptionsAdminData | GetSubscriptionsData>, options?: {
|
|
196
|
+
restoredState?: PaginatorState;
|
|
197
|
+
}): Promise<PaginatorPage<BaseEntity<any>>>;
|
|
192
198
|
/**
|
|
193
199
|
* {@inheritDoc BaseEntity#getSubscribers}
|
|
194
200
|
*
|
package/types/index.d.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";
|
|
@@ -30,6 +31,7 @@ declare const cocolightApiClient: {
|
|
|
30
31
|
};
|
|
31
32
|
helper: {
|
|
32
33
|
fromEntityJSON: typeof fromEntityJSON;
|
|
34
|
+
restorePaginationFromJSON: typeof BaseEntity.restorePaginationFromJSON;
|
|
33
35
|
};
|
|
34
36
|
OfflineClientManager: typeof OfflineClientManager;
|
|
35
37
|
};
|
|
@@ -65,6 +67,6 @@ export type * from "./api/serverDataType/News.js";
|
|
|
65
67
|
export type * from "./api/serverDataType/Comment.js";
|
|
66
68
|
export type * from "./api/serverDataType/Answer.js";
|
|
67
69
|
export type * from "./api/serverDataType/common.js";
|
|
68
|
-
export type { PaginatorPage } from "./api/BaseEntity.js";
|
|
70
|
+
export type { PaginatorPage, PaginatorState } from "./api/BaseEntity.js";
|
|
69
71
|
export type * from "./types/index.js";
|
|
70
72
|
export type * from "./api/EndpointApi.types.js";
|