@communecter/cocolight-api-client 1.0.54 → 1.0.56
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/401.cocolight-api-client.browser.js +1 -0
- package/dist/401.cocolight-api-client.cjs +1 -0
- package/dist/401.cocolight-api-client.mjs.js +1 -0
- package/dist/588.cocolight-api-client.browser.js +1 -0
- package/dist/588.cocolight-api-client.cjs +1 -0
- package/dist/588.cocolight-api-client.mjs.js +1 -0
- package/dist/593.cocolight-api-client.browser.js +1 -0
- package/dist/593.cocolight-api-client.cjs +1 -0
- package/dist/593.cocolight-api-client.mjs.js +1 -0
- package/dist/839.cocolight-api-client.browser.js +1 -0
- package/dist/839.cocolight-api-client.cjs +1 -0
- package/dist/839.cocolight-api-client.mjs.js +1 -0
- 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 +29 -17
- package/src/{Api.js → Api.ts} +85 -95
- package/src/{ApiClient.js → ApiClient.ts} +436 -247
- package/src/EJSONType.ts +103 -0
- package/src/api/{Badge.js → Badge.ts} +56 -45
- package/src/api/BaseEntity.ts +3890 -0
- package/src/api/Comment.ts +200 -0
- package/src/api/{EndpointApi.js → EndpointApi.ts} +363 -297
- package/src/api/EndpointApi.types.ts +4609 -0
- package/src/api/EntityRegistry.ts +203 -0
- package/src/api/Event.ts +332 -0
- package/src/api/News.ts +331 -0
- package/src/api/{Organization.js → Organization.ts} +155 -119
- package/src/api/{Poi.js → Poi.ts} +68 -60
- package/src/api/{Project.js → Project.ts} +150 -127
- package/src/api/{User.js → User.ts} +321 -256
- package/src/api/UserApi.ts +148 -0
- package/src/api/serverDataType/Comment.ts +88 -0
- package/src/api/serverDataType/Event.ts +80 -0
- package/src/api/serverDataType/News.ts +138 -0
- package/src/api/serverDataType/Organization.ts +80 -0
- package/src/api/serverDataType/Project.ts +71 -0
- package/src/api/serverDataType/User.ts +103 -0
- package/src/api/serverDataType/common.ts +80 -0
- package/src/endpoints.module.ts +2621 -0
- package/src/error.ts +86 -0
- package/src/index.ts +86 -0
- package/src/mixin/UserMixin.ts +4 -0
- package/src/types/api-responses.ts +217 -0
- package/src/types/entities.ts +22 -0
- package/src/types/error-guards.ts +230 -0
- package/src/types/index.ts +39 -0
- package/src/types/payloads.ts +21 -0
- package/src/types/transforms.ts +110 -0
- package/src/utils/{FileOfflineStorageStrategy.node.js → FileOfflineStorageStrategy.node.ts} +15 -12
- package/src/utils/{FileStorageStrategy.node.js → FileStorageStrategy.node.ts} +16 -39
- package/src/utils/MultiServerFileStorageStrategy.node.ts +67 -0
- package/src/utils/MultiServerTokenStorageStrategy.ts +139 -0
- package/src/utils/{OfflineClientManager.js → OfflineClientManager.ts} +82 -86
- package/src/utils/OfflineQueueStorageStrategy.ts +47 -0
- package/src/utils/TokenStorage.ts +77 -0
- package/src/utils/compat.ts +12 -0
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.ts +35 -0
- package/src/utils/{createDefaultOfflineStrategy.js → createDefaultOfflineStrategy.ts} +8 -3
- package/src/utils/createDefaultTokenStorageStrategy.ts +33 -0
- package/src/utils/{reactive.js → reactive.ts} +49 -40
- package/src/utils/stream-utils.node.ts +12 -0
- package/types/Api.d.ts +38 -82
- package/types/Api.d.ts.map +1 -0
- package/types/ApiClient.d.ts +244 -184
- package/types/ApiClient.d.ts.map +1 -0
- package/types/EJSONType.d.ts +48 -22
- package/types/EJSONType.d.ts.map +1 -0
- package/types/api/Badge.d.ts +20 -20
- package/types/api/Badge.d.ts.map +1 -0
- package/types/api/BaseEntity.d.ts +751 -446
- package/types/api/BaseEntity.d.ts.map +1 -0
- package/types/api/Comment.d.ts +36 -0
- package/types/api/EndpointApi.d.ts +347 -295
- package/types/api/EndpointApi.d.ts.map +1 -0
- package/types/api/EndpointApi.types.d.ts +3914 -4133
- package/types/api/EntityRegistry.d.ts +18 -16
- package/types/api/EntityRegistry.d.ts.map +1 -0
- package/types/api/Event.d.ts +119 -35
- package/types/api/Event.d.ts.map +1 -0
- package/types/api/News.d.ts +52 -20
- package/types/api/News.d.ts.map +1 -0
- package/types/api/Organization.d.ts +165 -49
- package/types/api/Organization.d.ts.map +1 -0
- package/types/api/Poi.d.ts +51 -22
- package/types/api/Poi.d.ts.map +1 -0
- package/types/api/Project.d.ts +151 -52
- package/types/api/Project.d.ts.map +1 -0
- package/types/api/User.d.ts +222 -93
- package/types/api/User.d.ts.map +1 -0
- package/types/api/UserApi.d.ts +60 -9
- package/types/api/UserApi.d.ts.map +1 -0
- package/types/api/serverDataType/Comment.d.ts +83 -0
- package/types/api/serverDataType/Event.d.ts +67 -0
- package/types/api/serverDataType/News.d.ts +130 -0
- package/types/api/serverDataType/Organization.d.ts +65 -0
- package/types/api/serverDataType/Organization.d.ts.map +1 -0
- package/types/api/serverDataType/Project.d.ts +58 -0
- package/types/api/serverDataType/Project.d.ts.map +1 -0
- package/types/api/serverDataType/User.d.ts +86 -0
- package/types/api/serverDataType/User.d.ts.map +1 -0
- package/types/api/serverDataType/common.d.ts +71 -0
- package/types/api/serverDataType/common.d.ts.map +1 -0
- package/types/endpoints.module.d.ts +6922 -1215
- package/types/endpoints.module.d.ts.map +1 -0
- package/types/error.d.ts +25 -51
- package/types/error.d.ts.map +1 -0
- package/types/index.d.ts +55 -48
- package/types/index.d.ts.map +1 -0
- package/types/mixin/UserMixin.d.ts +1 -1
- package/types/mixin/UserMixin.d.ts.map +1 -0
- package/types/types/api-responses.d.ts +190 -0
- package/types/types/api-responses.d.ts.map +1 -0
- package/types/types/entities.d.ts +17 -0
- package/types/types/entities.d.ts.map +1 -0
- package/types/types/error-guards.d.ts +99 -0
- package/types/types/error-guards.d.ts.map +1 -0
- package/types/types/index.d.ts +7 -0
- package/types/types/payloads.d.ts +17 -0
- package/types/types/payloads.d.ts.map +1 -0
- package/types/types/transforms.d.ts +79 -0
- package/types/types/transforms.d.ts.map +1 -0
- package/types/utils/FileOfflineStorageStrategy.node.d.ts +10 -9
- package/types/utils/FileOfflineStorageStrategy.node.d.ts.map +1 -0
- package/types/utils/FileStorageStrategy.node.d.ts +9 -20
- package/types/utils/FileStorageStrategy.node.d.ts.map +1 -0
- package/types/utils/MultiServerFileStorageStrategy.node.d.ts +13 -18
- package/types/utils/MultiServerFileStorageStrategy.node.d.ts.map +1 -0
- package/types/utils/MultiServerTokenStorageStrategy.d.ts +30 -51
- package/types/utils/MultiServerTokenStorageStrategy.d.ts.map +1 -0
- package/types/utils/OfflineClientManager.d.ts +52 -88
- package/types/utils/OfflineClientManager.d.ts.map +1 -0
- package/types/utils/OfflineQueueStorageStrategy.d.ts +12 -9
- package/types/utils/OfflineQueueStorageStrategy.d.ts.map +1 -0
- package/types/utils/TokenStorage.d.ts +20 -70
- package/types/utils/TokenStorage.d.ts.map +1 -0
- package/types/utils/compat.d.ts +4 -0
- package/types/utils/compat.d.ts.map +1 -0
- package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts +2 -11
- package/types/utils/createDefaultMultiServerTokenStorageStrategy.d.ts.map +1 -0
- package/types/utils/createDefaultOfflineStrategy.d.ts +2 -3
- package/types/utils/createDefaultOfflineStrategy.d.ts.map +1 -0
- package/types/utils/createDefaultTokenStorageStrategy.d.ts +2 -12
- package/types/utils/createDefaultTokenStorageStrategy.d.ts.map +1 -0
- package/types/utils/reactive.d.ts +10 -16
- package/types/utils/reactive.d.ts.map +1 -0
- package/types/utils/stream-utils.node.d.ts +3 -2
- package/types/utils/stream-utils.node.d.ts.map +1 -0
- package/dist/123.cocolight-api-client.browser.js +0 -1
- package/dist/123.cocolight-api-client.cjs +0 -1
- package/dist/22.cocolight-api-client.mjs.js +0 -1
- package/dist/339.cocolight-api-client.mjs.js +0 -1
- package/dist/394.cocolight-api-client.browser.js +0 -1
- package/dist/394.cocolight-api-client.cjs +0 -1
- package/dist/405.cocolight-api-client.browser.js +0 -1
- package/dist/405.cocolight-api-client.cjs +0 -1
- package/dist/774.cocolight-api-client.mjs.js +0 -1
- package/dist/790.cocolight-api-client.mjs.js +0 -1
- package/dist/931.cocolight-api-client.browser.js +0 -1
- package/dist/931.cocolight-api-client.cjs +0 -1
- package/src/EJSONType.js +0 -53
- package/src/api/BaseEntity.js +0 -2828
- package/src/api/EntityRegistry.js +0 -152
- package/src/api/Event.js +0 -226
- package/src/api/News.js +0 -244
- package/src/api/UserApi.js +0 -81
- package/src/endpoints.module.js +0 -5
- package/src/error.js +0 -121
- package/src/index.js +0 -97
- package/src/mixin/UserMixin.js +0 -8
- package/src/utils/MultiServerFileStorageStrategy.node.js +0 -87
- package/src/utils/MultiServerTokenStorageStrategy.js +0 -188
- package/src/utils/OfflineQueueStorageStrategy.js +0 -51
- package/src/utils/TokenStorage.js +0 -153
- package/src/utils/createDefaultMultiServerTokenStorageStrategy.js +0 -51
- package/src/utils/createDefaultTokenStorageStrategy.js +0 -49
- package/src/utils/stream-utils.node.js +0 -10
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { ApiError } from "../error.js";
|
|
2
|
-
import BaseEntity from "./BaseEntity.js";
|
|
2
|
+
import { BaseEntity } from "./BaseEntity.js";
|
|
3
|
+
import { createSocialTransform, transformEntityRefs } from "../types/transforms.js";
|
|
3
4
|
|
|
4
|
-
export class Project extends BaseEntity {
|
|
5
|
-
static entityType = "projects";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
import type { PaginatorPage } from "./BaseEntity.js";
|
|
7
|
+
import type { AddProjectData, GetContributorsAdminData, GetContributorsNoAdminData } from "./EndpointApi.types.js";
|
|
8
|
+
import type { Organization } from "./Organization.js";
|
|
9
|
+
import type { User } from "./User.js";
|
|
10
|
+
import type { ProjectTransforms } from "../types/transforms.js";
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
type ProjectItemNormalized = import("./serverDataType/Project.js").ProjectItemNormalized;
|
|
13
|
+
|
|
14
|
+
export class Project extends BaseEntity<ProjectItemNormalized> {
|
|
15
|
+
static override entityType = "projects";
|
|
16
|
+
|
|
17
|
+
static override entityTag = "Project";
|
|
18
|
+
|
|
19
|
+
static override SCHEMA_CONSTANTS: string[] = [
|
|
10
20
|
"ADD_PROJECT",
|
|
11
21
|
"UPDATE_BLOCK_DESCRIPTION",
|
|
12
22
|
"UPDATE_BLOCK_INFO",
|
|
@@ -19,7 +29,7 @@ export class Project extends BaseEntity {
|
|
|
19
29
|
static ADD_BLOCKS = new Map([
|
|
20
30
|
["ADD_PROJECT", "addProject"],
|
|
21
31
|
["PROFIL_IMAGE", "updateImageProfil"]
|
|
22
|
-
]);
|
|
32
|
+
] as const);
|
|
23
33
|
|
|
24
34
|
static UPDATE_BLOCKS = new Map([
|
|
25
35
|
["UPDATE_BLOCK_DESCRIPTION", "updateDescription"],
|
|
@@ -28,51 +38,39 @@ export class Project extends BaseEntity {
|
|
|
28
38
|
["UPDATE_BLOCK_INFO", "updateInfo"],
|
|
29
39
|
["UPDATE_BLOCK_SLUG", "updateSlug"],
|
|
30
40
|
["PROFIL_IMAGE", "updateImageProfil"]
|
|
31
|
-
]);
|
|
41
|
+
] as const);
|
|
32
42
|
|
|
33
|
-
defaultFields = {
|
|
43
|
+
override defaultFields: Record<string, any> = {
|
|
34
44
|
typeElement: this.getEntityType()
|
|
35
45
|
};
|
|
36
46
|
|
|
37
|
-
removeFields = [
|
|
47
|
+
override removeFields: string[] = [
|
|
38
48
|
"typeElement"
|
|
39
49
|
];
|
|
40
50
|
|
|
41
51
|
// links.contributors.${this.userId}.isAdmin === true
|
|
42
|
-
transforms = {
|
|
43
|
-
github: (
|
|
44
|
-
gitlab: (
|
|
45
|
-
facebook: (
|
|
46
|
-
twitter: (
|
|
47
|
-
instagram: (
|
|
48
|
-
diaspora: (
|
|
49
|
-
mastodon: (
|
|
50
|
-
telegram: (
|
|
51
|
-
signal: (
|
|
52
|
-
parent:
|
|
53
|
-
if (!val || typeof val !== "object") return null;
|
|
54
|
-
|
|
55
|
-
return Object.fromEntries(
|
|
56
|
-
Object.entries(val).map(([key, obj]) => [
|
|
57
|
-
key,
|
|
58
|
-
{
|
|
59
|
-
type: obj?.type ?? null,
|
|
60
|
-
name: obj?.name ?? null
|
|
61
|
-
}
|
|
62
|
-
])
|
|
63
|
-
);
|
|
64
|
-
}
|
|
52
|
+
override transforms: ProjectTransforms = {
|
|
53
|
+
github: createSocialTransform("github"),
|
|
54
|
+
gitlab: createSocialTransform("gitlab"),
|
|
55
|
+
facebook: createSocialTransform("facebook"),
|
|
56
|
+
twitter: createSocialTransform("twitter"),
|
|
57
|
+
instagram: createSocialTransform("instagram"),
|
|
58
|
+
diaspora: createSocialTransform("diaspora"),
|
|
59
|
+
mastodon: createSocialTransform("mastodon"),
|
|
60
|
+
telegram: createSocialTransform("telegram"),
|
|
61
|
+
signal: createSocialTransform("signal"),
|
|
62
|
+
parent: transformEntityRefs
|
|
65
63
|
};
|
|
66
64
|
|
|
67
|
-
async
|
|
65
|
+
override _add = async (payload: Record<string, any>): Promise<void> => {
|
|
68
66
|
if (!this._calledFromSave) {
|
|
69
|
-
throw new ApiError("utilisation invalide de _add, utilisez save");
|
|
67
|
+
throw new ApiError("utilisation invalide de _add, utilisez save", 400);
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
payload.id = this._newId?.();
|
|
73
71
|
if (payload.slug) delete payload.slug;
|
|
74
72
|
|
|
75
|
-
for (const [constant, methodName] of Project.ADD_BLOCKS) {
|
|
73
|
+
for (const [constant, methodName] of Array.from(Project.ADD_BLOCKS)) {
|
|
76
74
|
const blockData = this._extractChangedFieldsFromSchema(
|
|
77
75
|
this.apiClient,
|
|
78
76
|
constant,
|
|
@@ -80,28 +78,28 @@ export class Project extends BaseEntity {
|
|
|
80
78
|
() => {}
|
|
81
79
|
);
|
|
82
80
|
if (blockData && Object.keys(blockData).length > 0) {
|
|
83
|
-
const data = await this
|
|
81
|
+
const data = await this._invokeBlockMethod(Project.ADD_BLOCKS, methodName, blockData);
|
|
84
82
|
if (!this.id && data?.map?.id) {
|
|
85
83
|
this._draftData.id = data.map.id;
|
|
86
84
|
this._draftData.slug = data.map.slug;
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
|
-
}
|
|
88
|
+
};
|
|
91
89
|
|
|
92
|
-
async
|
|
90
|
+
override _update = async (payload: Record<string, any>): Promise<boolean> => {
|
|
93
91
|
if(!this.isAdmin()){
|
|
94
92
|
throw new ApiError("Vous n'avez pas les droits pour modifier ce projet", 403);
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
if (!this._calledFromSave) {
|
|
98
|
-
throw new ApiError("utilisation invalide de _update, utilisez save");
|
|
96
|
+
throw new ApiError("utilisation invalide de _update, utilisez save", 400);
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
if (payload.id) delete payload.id;
|
|
102
100
|
let hasChanged = false;
|
|
103
101
|
|
|
104
|
-
for (const [constant, methodName] of Project.UPDATE_BLOCKS) {
|
|
102
|
+
for (const [constant, methodName] of Array.from(Project.UPDATE_BLOCKS)) {
|
|
105
103
|
const blockData = this._extractChangedFieldsFromSchema(
|
|
106
104
|
this.apiClient,
|
|
107
105
|
constant,
|
|
@@ -110,88 +108,132 @@ export class Project extends BaseEntity {
|
|
|
110
108
|
this.removeFields
|
|
111
109
|
);
|
|
112
110
|
if (blockData && Object.keys(blockData).length > 0) {
|
|
113
|
-
await this
|
|
111
|
+
await this._invokeBlockMethod(Project.UPDATE_BLOCKS, methodName, blockData);
|
|
114
112
|
hasChanged = true;
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
return hasChanged;
|
|
119
|
-
}
|
|
117
|
+
};
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Ajoute un projet.
|
|
121
|
+
*
|
|
122
|
+
* @param data - Données du projet à ajouter.
|
|
123
|
+
* @returns - Résultat de l'ajout du projet.
|
|
124
|
+
* @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité n'est pas enregistrée.
|
|
125
|
+
*/
|
|
126
|
+
async addProject(data: Partial<AddProjectData> = {}): Promise<unknown> {
|
|
122
127
|
|
|
123
128
|
// le parent n'est pas me donc on doit ajouter le parent
|
|
124
|
-
if (!this.isMe) {
|
|
129
|
+
if (!this.isMe && this.parent) {
|
|
125
130
|
data.parent = {};
|
|
126
131
|
data.parent[`${this.parent.id}`] = {
|
|
127
132
|
type: this.parent.getEntityType(),
|
|
128
|
-
name: this.parent.name
|
|
133
|
+
name: (this.parent as any).name
|
|
129
134
|
};
|
|
130
135
|
}
|
|
131
136
|
|
|
132
|
-
return this.callIsConnected(() => this.endpointApi.addProject(data));
|
|
137
|
+
return this.callIsConnected(() => this.endpointApi.addProject(data as AddProjectData));
|
|
133
138
|
}
|
|
134
139
|
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
|
|
141
|
+
override async getOrganizations(): Promise<never> {
|
|
142
|
+
throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`, 501);
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
|
|
145
|
+
/**
|
|
146
|
+
* {@inheritDoc BaseEntity#getProjects}
|
|
147
|
+
*
|
|
148
|
+
* Récupère les projets du projet.
|
|
149
|
+
*/
|
|
150
|
+
override async getProjects(data: Parameters<BaseEntity<ProjectItemNormalized>["getProjects"]>[0] = {}) {
|
|
140
151
|
return super.getProjects(data);
|
|
141
152
|
}
|
|
153
|
+
|
|
142
154
|
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
|
|
156
|
+
async getEvents(): Promise<never> {
|
|
157
|
+
throw new ApiError(`getEvents pas encore implémenté dans ${this.constructor.name}`, 501);
|
|
145
158
|
}
|
|
146
159
|
|
|
147
|
-
|
|
160
|
+
/**
|
|
161
|
+
* {@inheritDoc BaseEntity#getPois}
|
|
162
|
+
*
|
|
163
|
+
* Récupère les points d'intérêt d'un projet.
|
|
164
|
+
*/
|
|
165
|
+
override async getPois(data: Parameters<BaseEntity<ProjectItemNormalized>["getPois"]>[0] = {}) {
|
|
148
166
|
return super.getPois(data);
|
|
149
167
|
}
|
|
150
168
|
|
|
151
|
-
|
|
169
|
+
/**
|
|
170
|
+
* {@inheritDoc BaseEntity#getBadgesIssuer}
|
|
171
|
+
*
|
|
172
|
+
* Récupère les émetteurs de badges d'un projet.
|
|
173
|
+
*/
|
|
174
|
+
override async getBadgesIssuer(data: Parameters<BaseEntity<ProjectItemNormalized>["getBadgesIssuer"]>[0] = {}) {
|
|
152
175
|
return super.getBadgesIssuer(data);
|
|
153
176
|
}
|
|
154
177
|
|
|
155
|
-
|
|
178
|
+
/**
|
|
179
|
+
* {@inheritDoc BaseEntity#getNews}
|
|
180
|
+
*
|
|
181
|
+
* Récupère les actualités d'un projet.
|
|
182
|
+
*/
|
|
183
|
+
override async getNews(data: Parameters<BaseEntity<ProjectItemNormalized>["getNews"]>[0] = {}) {
|
|
156
184
|
return super.getNews(data);
|
|
157
185
|
}
|
|
158
186
|
|
|
159
|
-
|
|
187
|
+
/**
|
|
188
|
+
* {@inheritDoc BaseEntity#getSubscribers}
|
|
189
|
+
*
|
|
190
|
+
* Récupère les abonnés d'un projet.
|
|
191
|
+
*/
|
|
192
|
+
override async getSubscribers(data: Parameters<BaseEntity<ProjectItemNormalized>["getSubscribers"]>[0] = {}) {
|
|
160
193
|
return super.getSubscribers(data);
|
|
161
194
|
}
|
|
162
195
|
|
|
163
196
|
/**
|
|
164
197
|
* Récupérer les contributeurs d'un projet.
|
|
165
198
|
* Constant : GET_CONTRIBUTORS_ADMIN / GET_CONTRIBUTORS_NO_ADMIN
|
|
166
|
-
* @param
|
|
167
|
-
* @param
|
|
168
|
-
* @param
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
173
|
-
* @returns
|
|
199
|
+
* @param data - Paramètres (partiels) de recherche/pagination.
|
|
200
|
+
* @param options - Options supplémentaires.
|
|
201
|
+
* @param options.toBeValidated - Indique si les contributeurs doivent être validés.
|
|
202
|
+
* @param options.isAdmin - Indique si l'utilisateur est admin.
|
|
203
|
+
* @param options.isInviting - Indique si l'utilisateur est en attente d'invitation.
|
|
204
|
+
* @param options.roles - Liste des rôles à filtrer.
|
|
205
|
+
* @param isNext - Indique si c'est une recherche suivante (pagination).
|
|
206
|
+
* @returns - Un objet contenant le nombre de contributeurs et la liste des contributeurs.
|
|
174
207
|
* @throws {ApiResponseError} - Si une erreur se produit lors de la récupération des contributeurs.
|
|
175
|
-
*
|
|
208
|
+
*
|
|
176
209
|
* @example
|
|
177
210
|
* // Récupérer tous les contributeurs
|
|
178
211
|
* const contributors = await project.getContributors();
|
|
179
|
-
*
|
|
212
|
+
*
|
|
180
213
|
* // Récupérer les contributeurs avec validation en attente
|
|
181
214
|
* const contributorsToBeValidated = await project.getContributors({}, { toBeValidated: true });
|
|
182
|
-
*
|
|
215
|
+
*
|
|
183
216
|
* // Récupérer les contributeurs avec un rôle spécifique
|
|
184
217
|
* const contributorsWithRole = await project.getContributors({}, { roles: ["admin"] });
|
|
185
|
-
*
|
|
218
|
+
*
|
|
186
219
|
* // Récupérer les contributeurs administrateurs
|
|
187
220
|
* const adminContributors = await project.getContributors({}, { isAdmin: true });
|
|
188
|
-
*
|
|
221
|
+
*
|
|
189
222
|
* // Récupérer les contributeurs en attente d'invitation
|
|
190
223
|
* const invitingContributors = await project.getContributors({}, { isInviting: true });
|
|
191
|
-
*
|
|
224
|
+
*
|
|
192
225
|
*/
|
|
193
|
-
async getContributors(
|
|
194
|
-
data
|
|
226
|
+
async getContributors(
|
|
227
|
+
data: Partial<GetContributorsAdminData | GetContributorsNoAdminData> = {},
|
|
228
|
+
options: {
|
|
229
|
+
toBeValidated?: boolean;
|
|
230
|
+
isAdmin?: boolean;
|
|
231
|
+
isAdminPending?: boolean;
|
|
232
|
+
isInviting?: boolean;
|
|
233
|
+
roles?: any[];
|
|
234
|
+
} = {}
|
|
235
|
+
): Promise<PaginatorPage<User | Organization>> {
|
|
236
|
+
data.searchType = this._getDefaultFromEndpoint("GET_CONTRIBUTORS_ADMIN", "searchType") as GetContributorsAdminData["searchType"];
|
|
195
237
|
// data.searchBy = "ALL";
|
|
196
238
|
|
|
197
239
|
const paginator = this._createPaginatorEngine({
|
|
@@ -222,29 +264,24 @@ export class Project extends BaseEntity {
|
|
|
222
264
|
}
|
|
223
265
|
});
|
|
224
266
|
|
|
225
|
-
return paginator.next()
|
|
267
|
+
return paginator.next() as Promise<PaginatorPage<User | Organization>>;
|
|
226
268
|
}
|
|
227
269
|
|
|
228
270
|
/**
|
|
271
|
+
* {@inheritDoc BaseEntity#getGallery}
|
|
272
|
+
*
|
|
229
273
|
* Récupère la galerie d'un projet.
|
|
230
|
-
*
|
|
231
|
-
* @param {Object} data - Les données de requête pour la galerie.
|
|
232
|
-
* @returns {Promise<Object>} - Un objet contenant les images de la galerie.
|
|
233
|
-
* @throws {ApiResponseError} - Si une erreur se produit lors de la récupération de la galerie.
|
|
234
|
-
* @throws {Error} - En cas d'erreur inattendue.
|
|
235
274
|
*/
|
|
236
|
-
async getGallery(data = {}) {
|
|
275
|
+
override async getGallery(data: Parameters<BaseEntity<ProjectItemNormalized>["getGallery"]>[0] = {}) {
|
|
237
276
|
return super.getGallery(data);
|
|
238
277
|
}
|
|
239
278
|
|
|
240
279
|
/**
|
|
241
|
-
*
|
|
280
|
+
* {@inheritDoc BaseEntity#project}
|
|
242
281
|
*
|
|
243
|
-
*
|
|
244
|
-
* @returns {Promise<Project>} Une promesse qui résout l'objet Projet créé.
|
|
245
|
-
* @throws {Error} Si une erreur se produit lors de la création du projet.
|
|
282
|
+
* Crée une instance de projet et récupère son profil si nécessaire.
|
|
246
283
|
*/
|
|
247
|
-
async project(projectData = {}) {
|
|
284
|
+
override async project(projectData: Parameters<BaseEntity<ProjectItemNormalized>["project"]>[0] = {}) {
|
|
248
285
|
if(!this.isAdmin()){
|
|
249
286
|
throw new ApiError("Vous n'avez pas les droits pour créer un projet dans ce projet", 403);
|
|
250
287
|
}
|
|
@@ -252,13 +289,11 @@ export class Project extends BaseEntity {
|
|
|
252
289
|
}
|
|
253
290
|
|
|
254
291
|
/**
|
|
292
|
+
* {@inheritDoc BaseEntity#poi}
|
|
293
|
+
*
|
|
255
294
|
* Crée une instance de POI et la récupère si nécessaire.
|
|
256
|
-
*
|
|
257
|
-
* @param {Object} poiData - Les données nécessaires pour initialiser le POI.
|
|
258
|
-
* @returns {Promise<Poi>} Une promesse qui résout l'objet POI créé.
|
|
259
|
-
* @throws {Error} Si une erreur se produit lors de la création du POI.
|
|
260
295
|
*/
|
|
261
|
-
async poi(poiData = {}) {
|
|
296
|
+
override async poi(poiData: Parameters<BaseEntity<ProjectItemNormalized>["poi"]>[0] = {}) {
|
|
262
297
|
if(!this.isAdmin()){
|
|
263
298
|
throw new ApiError("Vous n'avez pas les droits pour créer un POI dans ce projet", 403);
|
|
264
299
|
}
|
|
@@ -266,13 +301,11 @@ export class Project extends BaseEntity {
|
|
|
266
301
|
}
|
|
267
302
|
|
|
268
303
|
/**
|
|
304
|
+
* {@inheritDoc BaseEntity#event}
|
|
305
|
+
*
|
|
269
306
|
* Crée une instance d'événement et la récupère si nécessaire.
|
|
270
|
-
*
|
|
271
|
-
* @param {Object} eventData - Les données nécessaires pour initialiser l'événement.
|
|
272
|
-
* @returns {Promise<Event>} Une promesse qui résout l'objet Événement créé.
|
|
273
|
-
* @throws {Error} Si une erreur se produit lors de la création de l'événement.
|
|
274
307
|
*/
|
|
275
|
-
async event(eventData = {}) {
|
|
308
|
+
override async event(eventData: Parameters<BaseEntity<ProjectItemNormalized>["event"]>[0] = {}) {
|
|
276
309
|
if(!this.isAdmin()){
|
|
277
310
|
throw new ApiError("Vous n'avez pas les droits pour créer un événement dans ce projet", 403);
|
|
278
311
|
}
|
|
@@ -280,13 +313,11 @@ export class Project extends BaseEntity {
|
|
|
280
313
|
}
|
|
281
314
|
|
|
282
315
|
/**
|
|
316
|
+
* {@inheritDoc BaseEntity#badge}
|
|
317
|
+
*
|
|
283
318
|
* Crée une instance de badge et la récupère si nécessaire.
|
|
284
|
-
*
|
|
285
|
-
* @param {Object} badgeData - Les données nécessaires pour initialiser le badge.
|
|
286
|
-
* @returns {Promise<Badge>} Une promesse qui résout l'objet Badge créé.
|
|
287
|
-
* @throws {Error} Si une erreur se produit lors de la création du badge.
|
|
288
319
|
*/
|
|
289
|
-
async badge(badgeData = {}) {
|
|
320
|
+
override async badge(badgeData: Parameters<BaseEntity<ProjectItemNormalized>["badge"]>[0] = {}) {
|
|
290
321
|
if(!this.isAdmin()){
|
|
291
322
|
throw new ApiError("Vous n'avez pas les droits pour créer un badge dans ce projet", 403);
|
|
292
323
|
}
|
|
@@ -294,13 +325,11 @@ export class Project extends BaseEntity {
|
|
|
294
325
|
}
|
|
295
326
|
|
|
296
327
|
/**
|
|
328
|
+
* {@inheritDoc BaseEntity#news}
|
|
329
|
+
*
|
|
297
330
|
* Crée une instance de news et la récupère si nécessaire.
|
|
298
|
-
*
|
|
299
|
-
* @param {Object} newsData - Les données nécessaires pour initialiser la news.
|
|
300
|
-
* @returns {Promise<News>} Une promesse qui résout l'objet News créé.
|
|
301
|
-
* @throws {Error} Si une erreur se produit lors de la création de la news.
|
|
302
331
|
*/
|
|
303
|
-
async news(newsData = {}) {
|
|
332
|
+
override async news(newsData: Parameters<BaseEntity<ProjectItemNormalized>["news"]>[0] = {}) {
|
|
304
333
|
// TODO: qui peut créer une news sur le projet ?
|
|
305
334
|
return super.news(newsData);
|
|
306
335
|
}
|
|
@@ -313,67 +342,61 @@ export class Project extends BaseEntity {
|
|
|
313
342
|
*/
|
|
314
343
|
|
|
315
344
|
/**
|
|
345
|
+
* {@inheritDoc BaseEntity#requestToJoin}
|
|
346
|
+
*
|
|
316
347
|
* Envoie une demande pour rejoindre le projet en tant que contributeur.
|
|
317
348
|
* L'action est soumise à validation par un administrateur du projet.
|
|
318
|
-
*
|
|
319
|
-
* @returns {Promise<Object>} - Résultat de la requête d'adhésion.
|
|
320
|
-
* @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si le projet ne supporte pas l'action.
|
|
321
349
|
*/
|
|
322
|
-
async requestToJoin(){
|
|
350
|
+
override async requestToJoin() {
|
|
323
351
|
return super.requestToJoin();
|
|
324
352
|
}
|
|
325
353
|
|
|
326
354
|
/**
|
|
355
|
+
* {@inheritDoc BaseEntity#requestToJoinAdmin}
|
|
356
|
+
*
|
|
327
357
|
* Envoie une demande pour devenir administrateur du projet.
|
|
328
358
|
* L'action est soumise à validation par un administrateur existant.
|
|
329
|
-
*
|
|
330
|
-
* @returns {Promise<Object>} - Résultat de la requête d'administration.
|
|
331
|
-
* @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si le projet ne supporte pas l'action.
|
|
332
359
|
*/
|
|
333
|
-
async requestToJoinAdmin(){
|
|
360
|
+
override async requestToJoinAdmin() {
|
|
334
361
|
return super.requestToJoinAdmin();
|
|
335
362
|
}
|
|
336
363
|
|
|
337
364
|
/**
|
|
365
|
+
* {@inheritDoc BaseEntity#acceptInvitation}
|
|
366
|
+
*
|
|
338
367
|
* Accepte une invitation à rejoindre le projet.
|
|
339
368
|
* Cette action valide un lien en attente avec l'option `isInviting`.
|
|
340
|
-
*
|
|
341
|
-
* @returns {Promise<Object>} - Résultat de la validation du lien.
|
|
342
|
-
* @throws {ApiError} - Si aucune invitation n'est en attente ou si le projet ne supporte pas l'action.
|
|
343
369
|
*/
|
|
344
|
-
async acceptInvitation(){
|
|
370
|
+
override async acceptInvitation() {
|
|
345
371
|
return super.acceptInvitation();
|
|
346
372
|
}
|
|
347
373
|
|
|
348
374
|
/**
|
|
375
|
+
* {@inheritDoc BaseEntity#leave}
|
|
376
|
+
*
|
|
349
377
|
* Quitte le projet, que ce soit en tant que contributeur ou administrateur.
|
|
350
378
|
* Cette action supprime le lien entre l'utilisateur et le projet.
|
|
351
|
-
*
|
|
352
|
-
* @returns {Promise<Object>} - Résultat de la déconnexion.
|
|
353
|
-
* @throws {ApiError} - Si l'utilisateur n'est pas connecté ou non contributeur.
|
|
354
379
|
*/
|
|
355
|
-
async leave() {
|
|
380
|
+
override async leave() {
|
|
356
381
|
return super.leave();
|
|
357
382
|
}
|
|
358
383
|
|
|
359
384
|
/**
|
|
385
|
+
* {@inheritDoc BaseEntity#follow}
|
|
386
|
+
*
|
|
360
387
|
* Suivre un projet.
|
|
361
388
|
* Cette action permet à l'utilisateur de suivre le projet.
|
|
362
|
-
*
|
|
363
|
-
* @returns {Promise<Object>} - Résultat de l'action de suivi.
|
|
364
|
-
* @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité ne supporte pas l'action.
|
|
365
389
|
*/
|
|
366
|
-
async follow() {
|
|
390
|
+
override async follow() {
|
|
367
391
|
return super.follow();
|
|
368
392
|
}
|
|
369
393
|
|
|
370
394
|
/**
|
|
395
|
+
* {@inheritDoc BaseEntity#unfollow}
|
|
396
|
+
*
|
|
371
397
|
* Se désabonne d'un projet.
|
|
372
|
-
*
|
|
373
|
-
* @returns {Promise<Object>} - Résultat de la désinscription.
|
|
374
|
-
* @throws {ApiError} - Si l'utilisateur n'est pas connecté ou si l'entité n'est pas enregistrée.
|
|
375
398
|
*/
|
|
376
|
-
async unfollow() {
|
|
399
|
+
override async unfollow() {
|
|
377
400
|
return super.unfollow();
|
|
378
401
|
}
|
|
379
402
|
|