@communecter/cocolight-api-client 1.0.128 → 1.0.130
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 +2 -2
- 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 +1 -1
- package/src/api/BaseEntity.ts +14 -3
- package/src/api/EndpointApi.types.ts +24 -4
- package/src/api/EntityRegistry.ts +43 -0
- package/src/api/Organization.ts +15 -4
- package/src/api/Project.ts +15 -2
- package/src/endpoints.module.ts +113 -98
- package/src/index.ts +2 -1
- package/types/api/EndpointApi.types.d.ts +24 -4
- package/types/api/EntityRegistry.d.ts +21 -0
- package/types/api/Organization.d.ts +5 -0
- package/types/api/Project.d.ts +6 -0
- package/types/endpoints.module.d.ts +4 -8
- package/types/index.d.ts +2 -1
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseEntity } from "./api/BaseEntity.js";
|
|
2
|
-
import { fromEntityJSON } from "./api/EntityRegistry.js";
|
|
2
|
+
import { fromEntityJSON, reviveEntities } from "./api/EntityRegistry.js";
|
|
3
3
|
import Api from "./Api.js";
|
|
4
4
|
import ApiClient from "./ApiClient.js";
|
|
5
5
|
import * as error from "./error.js";
|
|
@@ -33,6 +33,7 @@ const cocolightApiClient = {
|
|
|
33
33
|
},
|
|
34
34
|
helper: {
|
|
35
35
|
fromEntityJSON,
|
|
36
|
+
reviveEntities,
|
|
36
37
|
restorePaginationFromJSON: BaseEntity.restorePaginationFromJSON
|
|
37
38
|
},
|
|
38
39
|
OfflineClientManager
|
|
@@ -1524,8 +1524,13 @@ export interface GetMembersNoAdminData {
|
|
|
1524
1524
|
name?: string;
|
|
1525
1525
|
/**
|
|
1526
1526
|
* Types d'entités à inclure dans la recherche
|
|
1527
|
+
*
|
|
1528
|
+
* @minItems 1
|
|
1527
1529
|
*/
|
|
1528
|
-
searchType:
|
|
1530
|
+
searchType: [
|
|
1531
|
+
"citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative",
|
|
1532
|
+
...("citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative")[]
|
|
1533
|
+
];
|
|
1529
1534
|
/**
|
|
1530
1535
|
* Critère de recherche (actuellement vide)
|
|
1531
1536
|
*/
|
|
@@ -1597,8 +1602,13 @@ export interface GetMembersAdminData {
|
|
|
1597
1602
|
name?: string;
|
|
1598
1603
|
/**
|
|
1599
1604
|
* Types d'entités à inclure dans la recherche
|
|
1605
|
+
*
|
|
1606
|
+
* @minItems 1
|
|
1600
1607
|
*/
|
|
1601
|
-
searchType:
|
|
1608
|
+
searchType: [
|
|
1609
|
+
"citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative",
|
|
1610
|
+
...("citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative")[]
|
|
1611
|
+
];
|
|
1602
1612
|
/**
|
|
1603
1613
|
* Critère de recherche (actuellement vide)
|
|
1604
1614
|
*/
|
|
@@ -2036,8 +2046,13 @@ export interface GetContributorsNoAdminData {
|
|
|
2036
2046
|
name?: string;
|
|
2037
2047
|
/**
|
|
2038
2048
|
* Types d'entités à inclure dans la recherche
|
|
2049
|
+
*
|
|
2050
|
+
* @minItems 1
|
|
2039
2051
|
*/
|
|
2040
|
-
searchType:
|
|
2052
|
+
searchType: [
|
|
2053
|
+
"citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative",
|
|
2054
|
+
...("citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative")[]
|
|
2055
|
+
];
|
|
2041
2056
|
/**
|
|
2042
2057
|
* Critère de recherche (actuellement vide)
|
|
2043
2058
|
*/
|
|
@@ -2109,8 +2124,13 @@ export interface GetContributorsAdminData {
|
|
|
2109
2124
|
name?: string;
|
|
2110
2125
|
/**
|
|
2111
2126
|
* Types d'entités à inclure dans la recherche
|
|
2127
|
+
*
|
|
2128
|
+
* @minItems 1
|
|
2112
2129
|
*/
|
|
2113
|
-
searchType:
|
|
2130
|
+
searchType: [
|
|
2131
|
+
"citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative",
|
|
2132
|
+
...("citoyens" | "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative")[]
|
|
2133
|
+
];
|
|
2114
2134
|
/**
|
|
2115
2135
|
* Critère de recherche (actuellement vide)
|
|
2116
2136
|
*/
|
|
@@ -17,6 +17,27 @@ export declare function registerEntity(tag: EntityTag, EntityClass: EntityClass)
|
|
|
17
17
|
* Si la collection ou la métadonnée d'entité est absente, renvoie l'objet d'origine.
|
|
18
18
|
*/
|
|
19
19
|
export declare function fromEntityJSON(json: unknown, parent?: ApiClient | BaseEntity | null): BaseEntity | unknown | null;
|
|
20
|
+
/**
|
|
21
|
+
* Walker récursif : parcourt un objet/tableau et ressuscite toutes les entités
|
|
22
|
+
* sérialisées (marqueurs `__isSerializedEntity` / `__entityTag`) rencontrées.
|
|
23
|
+
*
|
|
24
|
+
* Pensé pour les wrappers non-entité retournés par certains endpoints (ex: `fundingEnvelope`)
|
|
25
|
+
* ou pour réhydrater un état côté client après un transfert JSON (SSR, cache restore).
|
|
26
|
+
*
|
|
27
|
+
* Dates, RegExp et primitives sont préservées. Pour les entités, la chaîne de parents
|
|
28
|
+
* est reconstruite automatiquement depuis les méta embarquées par `toJSON()`.
|
|
29
|
+
*
|
|
30
|
+
* @param obj - L'objet à parcourir (wrapper, array, primitive…)
|
|
31
|
+
* @param parent - Parent racine (typiquement l'ApiClient côté client)
|
|
32
|
+
* @returns L'objet avec toutes les entités revived
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Côté client SSR : revive l'état dehydraté
|
|
36
|
+
* const apiClient = new ApiClient({ baseURL });
|
|
37
|
+
* const envelope = reviveEntities(window.__INIT__.envelope, apiClient);
|
|
38
|
+
* envelope.projects[0].serverData.actions[0]; // Action instance
|
|
39
|
+
*/
|
|
40
|
+
export declare function reviveEntities<T = unknown>(obj: unknown, parent?: ApiClient | BaseEntity | null): T;
|
|
20
41
|
/**
|
|
21
42
|
* Crée une instance d'entité basée sur le seul nom de la collection.
|
|
22
43
|
*/
|
|
@@ -156,7 +156,11 @@ export declare class Organization extends BaseEntity<OrganizationItemNormalized>
|
|
|
156
156
|
* // Récupérer les membres en attente de validation pour être admin
|
|
157
157
|
* const adminPendingMembers = await organization.getMembers({}, { isAdminPending: true });
|
|
158
158
|
*
|
|
159
|
+
* // Restreindre la recherche : uniquement les citoyens
|
|
160
|
+
* const onlyCitoyens = await organization.getMembers({}, { searchType: "citoyens" });
|
|
159
161
|
*
|
|
162
|
+
* // Restreindre la recherche : uniquement les organisations
|
|
163
|
+
* const onlyOrgas = await organization.getMembers({}, { searchType: "organizations" });
|
|
160
164
|
*/
|
|
161
165
|
getMembers(data?: Partial<GetMembersAdminData | GetMembersNoAdminData>, options?: {
|
|
162
166
|
toBeValidated?: boolean;
|
|
@@ -164,6 +168,7 @@ export declare class Organization extends BaseEntity<OrganizationItemNormalized>
|
|
|
164
168
|
isAdminPending?: boolean;
|
|
165
169
|
isInviting?: boolean;
|
|
166
170
|
roles?: any[];
|
|
171
|
+
searchType?: "all" | "citoyens" | "organizations";
|
|
167
172
|
restoredState?: PaginatorState;
|
|
168
173
|
}): Promise<PaginatorPage<User | Organization>>;
|
|
169
174
|
/**
|
package/types/api/Project.d.ts
CHANGED
|
@@ -91,6 +91,11 @@ export declare class Project extends BaseEntity<ProjectItemNormalized> {
|
|
|
91
91
|
* // Récupérer les contributeurs en attente d'invitation
|
|
92
92
|
* const invitingContributors = await project.getContributors({}, { isInviting: true });
|
|
93
93
|
*
|
|
94
|
+
* // Restreindre la recherche : uniquement les citoyens
|
|
95
|
+
* const onlyCitoyens = await project.getContributors({}, { searchType: "citoyens" });
|
|
96
|
+
*
|
|
97
|
+
* // Restreindre la recherche : uniquement les organisations
|
|
98
|
+
* const onlyOrgas = await project.getContributors({}, { searchType: "organizations" });
|
|
94
99
|
*/
|
|
95
100
|
getContributors(data?: Partial<GetContributorsAdminData | GetContributorsNoAdminData>, options?: {
|
|
96
101
|
toBeValidated?: boolean;
|
|
@@ -98,6 +103,7 @@ export declare class Project extends BaseEntity<ProjectItemNormalized> {
|
|
|
98
103
|
isAdminPending?: boolean;
|
|
99
104
|
isInviting?: boolean;
|
|
100
105
|
roles?: any[];
|
|
106
|
+
searchType?: "all" | "citoyens" | "organizations";
|
|
101
107
|
restoredState?: PaginatorState;
|
|
102
108
|
}): Promise<PaginatorPage<User | Organization>>;
|
|
103
109
|
/**
|
|
@@ -11897,7 +11897,6 @@ declare const endpoints: {
|
|
|
11897
11897
|
type: string;
|
|
11898
11898
|
};
|
|
11899
11899
|
countType: {
|
|
11900
|
-
const: string[];
|
|
11901
11900
|
default: string[];
|
|
11902
11901
|
items: {
|
|
11903
11902
|
enum: string[];
|
|
@@ -12094,12 +12093,12 @@ declare const endpoints: {
|
|
|
12094
12093
|
type: string;
|
|
12095
12094
|
};
|
|
12096
12095
|
searchType: {
|
|
12097
|
-
const: string[];
|
|
12098
12096
|
default: string[];
|
|
12099
12097
|
items: {
|
|
12100
12098
|
enum: string[];
|
|
12101
12099
|
type: string;
|
|
12102
12100
|
};
|
|
12101
|
+
minItems: number;
|
|
12103
12102
|
type: string;
|
|
12104
12103
|
};
|
|
12105
12104
|
app?: undefined;
|
|
@@ -12327,7 +12326,6 @@ declare const endpoints: {
|
|
|
12327
12326
|
type: string;
|
|
12328
12327
|
};
|
|
12329
12328
|
countType: {
|
|
12330
|
-
const: string[];
|
|
12331
12329
|
default: string[];
|
|
12332
12330
|
items: {
|
|
12333
12331
|
enum: string[];
|
|
@@ -12566,12 +12564,12 @@ declare const endpoints: {
|
|
|
12566
12564
|
type: string;
|
|
12567
12565
|
};
|
|
12568
12566
|
searchType: {
|
|
12569
|
-
const: string[];
|
|
12570
12567
|
default: string[];
|
|
12571
12568
|
items: {
|
|
12572
12569
|
enum: string[];
|
|
12573
12570
|
type: string;
|
|
12574
12571
|
};
|
|
12572
|
+
minItems: number;
|
|
12575
12573
|
type: string;
|
|
12576
12574
|
};
|
|
12577
12575
|
app?: undefined;
|
|
@@ -14859,7 +14857,6 @@ declare const endpoints: {
|
|
|
14859
14857
|
type: string;
|
|
14860
14858
|
};
|
|
14861
14859
|
countType: {
|
|
14862
|
-
const: string[];
|
|
14863
14860
|
default: string[];
|
|
14864
14861
|
items: {
|
|
14865
14862
|
enum: string[];
|
|
@@ -15056,12 +15053,12 @@ declare const endpoints: {
|
|
|
15056
15053
|
type: string;
|
|
15057
15054
|
};
|
|
15058
15055
|
searchType: {
|
|
15059
|
-
const: string[];
|
|
15060
15056
|
default: string[];
|
|
15061
15057
|
items: {
|
|
15062
15058
|
enum: string[];
|
|
15063
15059
|
type: string;
|
|
15064
15060
|
};
|
|
15061
|
+
minItems: number;
|
|
15065
15062
|
type: string;
|
|
15066
15063
|
};
|
|
15067
15064
|
app?: undefined;
|
|
@@ -15289,7 +15286,6 @@ declare const endpoints: {
|
|
|
15289
15286
|
type: string;
|
|
15290
15287
|
};
|
|
15291
15288
|
countType: {
|
|
15292
|
-
const: string[];
|
|
15293
15289
|
default: string[];
|
|
15294
15290
|
items: {
|
|
15295
15291
|
enum: string[];
|
|
@@ -15528,12 +15524,12 @@ declare const endpoints: {
|
|
|
15528
15524
|
type: string;
|
|
15529
15525
|
};
|
|
15530
15526
|
searchType: {
|
|
15531
|
-
const: string[];
|
|
15532
15527
|
default: string[];
|
|
15533
15528
|
items: {
|
|
15534
15529
|
enum: string[];
|
|
15535
15530
|
type: string;
|
|
15536
15531
|
};
|
|
15532
|
+
minItems: number;
|
|
15537
15533
|
type: string;
|
|
15538
15534
|
};
|
|
15539
15535
|
app?: undefined;
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseEntity } from "./api/BaseEntity.js";
|
|
2
|
-
import { fromEntityJSON } from "./api/EntityRegistry.js";
|
|
2
|
+
import { fromEntityJSON, reviveEntities } from "./api/EntityRegistry.js";
|
|
3
3
|
import Api from "./Api.js";
|
|
4
4
|
import ApiClient from "./ApiClient.js";
|
|
5
5
|
import * as error from "./error.js";
|
|
@@ -31,6 +31,7 @@ declare const cocolightApiClient: {
|
|
|
31
31
|
};
|
|
32
32
|
helper: {
|
|
33
33
|
fromEntityJSON: typeof fromEntityJSON;
|
|
34
|
+
reviveEntities: typeof reviveEntities;
|
|
34
35
|
restorePaginationFromJSON: typeof BaseEntity.restorePaginationFromJSON;
|
|
35
36
|
};
|
|
36
37
|
OfflineClientManager: typeof OfflineClientManager;
|