@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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import ApiClient from "../ApiClient.js";
|
|
2
|
+
import { ApiError, ApiResponseError } from "../error.js";
|
|
3
|
+
import { Badge } from "./Badge.js";
|
|
4
|
+
import { Comment } from "./Comment.js";
|
|
5
|
+
import EndpointApi from "./EndpointApi.js";
|
|
6
|
+
import { Event } from "./Event.js";
|
|
7
|
+
import { News } from "./News.js";
|
|
8
|
+
import { Organization } from "./Organization.js";
|
|
9
|
+
import { Poi } from "./Poi.js";
|
|
10
|
+
import { Project } from "./Project.js";
|
|
11
|
+
import { User } from "./User.js";
|
|
12
|
+
|
|
13
|
+
type AxiosResponse = import("axios").AxiosResponse;
|
|
14
|
+
|
|
15
|
+
function isAxiosResponse(r: any): r is AxiosResponse {
|
|
16
|
+
return r && typeof r === "object" && "status" in r && "data" in r;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* API orientée utilisateur pour gérer l'authentification et
|
|
21
|
+
* récupérer l'utilisateur connecté.
|
|
22
|
+
*/
|
|
23
|
+
export class UserApi {
|
|
24
|
+
client: ApiClient;
|
|
25
|
+
loggedUser: User | null = null;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param clientOrOptions - Soit une instance ApiClient, soit des options pour en créer une
|
|
29
|
+
*/
|
|
30
|
+
constructor(clientOrOptions: ApiClient | ConstructorParameters<typeof ApiClient>[0]) {
|
|
31
|
+
if (clientOrOptions instanceof ApiClient) {
|
|
32
|
+
this.client = clientOrOptions;
|
|
33
|
+
} else {
|
|
34
|
+
// Injection de dépendance : ApiClient est créé à partir des options
|
|
35
|
+
this.client = new ApiClient(clientOrOptions);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Indique si un utilisateur est connecté.
|
|
41
|
+
*/
|
|
42
|
+
get isConnected(): boolean {
|
|
43
|
+
return this.client.isConnected;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Retourne l'ID de l'utilisateur connecté ou `null` s'il n'y a pas de session.
|
|
48
|
+
*/
|
|
49
|
+
get userId(): string | null {
|
|
50
|
+
return this.client.userId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Authentifie un utilisateur et retourne l'instance `User` correspondante.
|
|
55
|
+
*
|
|
56
|
+
* @param email - Adresse email de l'utilisateur.
|
|
57
|
+
* @param password - Mot de passe de l'utilisateur.
|
|
58
|
+
* @returns {Promise<User>}
|
|
59
|
+
* @throws {ApiError} En cas d'échec de connexion réseau ou de problème interne.
|
|
60
|
+
* @throws {ApiResponseError} Si l'API retourne une erreur d'authentification.
|
|
61
|
+
*/
|
|
62
|
+
async login(email: string, password: string): Promise<User> {
|
|
63
|
+
return this.client.safeCall(async () => {
|
|
64
|
+
const response = await this.client.callEndpoint("AUTHENTICATE_URL", { email, password });
|
|
65
|
+
|
|
66
|
+
this.loggedUser = new User(
|
|
67
|
+
this.client,
|
|
68
|
+
response.data.user,
|
|
69
|
+
{ EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment }
|
|
70
|
+
);
|
|
71
|
+
return this.loggedUser;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Récupère l'instance `User` correspondant à l'utilisateur actuellement connecté.
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<User>}
|
|
79
|
+
* @throws {ApiError} Si aucun utilisateur n'est connecté (`isConnected` faux ou `userId` absent).
|
|
80
|
+
*/
|
|
81
|
+
async meIsconnected(): Promise<User> {
|
|
82
|
+
if (!this.client.isConnected || !this.client.userId) {
|
|
83
|
+
throw new ApiError("User not connected", 401);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.client._logger.info("UserApi", "meIsconnected", this.client.userId);
|
|
87
|
+
|
|
88
|
+
this.loggedUser = new User(
|
|
89
|
+
this.client,
|
|
90
|
+
{ id: this.client.userId },
|
|
91
|
+
{ EndpointApi, Organization, Project, Event, Poi, Badge, News, Comment }
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return this.loggedUser;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Enregistre un nouvel utilisateur.
|
|
99
|
+
*
|
|
100
|
+
* @param params
|
|
101
|
+
* @param params.name - Nom complet.
|
|
102
|
+
* @param params.username - Nom d'utilisateur.
|
|
103
|
+
* @param params.email - Adresse email.
|
|
104
|
+
* @param params.pwd - Mot de passe.
|
|
105
|
+
* @returns Réponse brute de l'API.
|
|
106
|
+
* @throws {ApiResponseError} Si l'API retourne un échec (`result === false`).
|
|
107
|
+
*/
|
|
108
|
+
async register({ name, username, email, pwd }: { name: string; username: string; email: string; pwd: string }): Promise<any> {
|
|
109
|
+
return this.client.safeCall(async () => {
|
|
110
|
+
const response = await this.client.callEndpoint("PERSON_REGISTER", {
|
|
111
|
+
name, username, email, pwd
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (!isAxiosResponse(response)) {
|
|
115
|
+
throw new ApiError("Requête mise en file (offline/circuit breaker)", 503, response);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (response?.data?.result === false) {
|
|
119
|
+
throw new ApiResponseError(response.data.msg, response.status, response.data);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return response.data;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Lance une procédure de récupération de mot de passe.
|
|
128
|
+
*
|
|
129
|
+
* @param email - Adresse email de l'utilisateur.
|
|
130
|
+
* @returns Réponse brute de l'API.
|
|
131
|
+
* @throws {ApiResponseError} Si l'API retourne un échec (`result === false`).
|
|
132
|
+
*/
|
|
133
|
+
async recoverPassword(email: string): Promise<any> {
|
|
134
|
+
return this.client.safeCall(async () => {
|
|
135
|
+
const response = await this.client.callEndpoint("PASSWORD_RECOVERY", { email });
|
|
136
|
+
|
|
137
|
+
if (!isAxiosResponse(response)) {
|
|
138
|
+
throw new ApiError("Requête mise en file (offline/circuit breaker)", 503, response);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (response?.data?.result === false) {
|
|
142
|
+
throw new ApiResponseError(response.data.msg, response.status, response.data);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return response.data;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IdObject,
|
|
3
|
+
DateValue
|
|
4
|
+
} from "./common.js";
|
|
5
|
+
import type EJSONType from "../../EJSONType.js";
|
|
6
|
+
import type { Organization } from "../Organization.js";
|
|
7
|
+
import type { User } from "../User.js";
|
|
8
|
+
|
|
9
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
10
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Auteur d'un commentaire (version brute de l'API)
|
|
14
|
+
*/
|
|
15
|
+
export interface CommentAuthorJson {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
username?: string;
|
|
19
|
+
email?: string;
|
|
20
|
+
profilImageUrl?: string;
|
|
21
|
+
profilThumbImageUrl?: string;
|
|
22
|
+
typeSig?: string;
|
|
23
|
+
[k: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Auteur d'un commentaire (version normalisée côté client)
|
|
28
|
+
*/
|
|
29
|
+
export interface CommentAuthor extends CommentAuthorJson {
|
|
30
|
+
type?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Vues d'un commentaire (qui a vu et quand)
|
|
35
|
+
*/
|
|
36
|
+
export interface CommentViews {
|
|
37
|
+
[userId: string]: {
|
|
38
|
+
date: DateValue;
|
|
39
|
+
[k: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Structure JSON brute retournée par l'API
|
|
45
|
+
*/
|
|
46
|
+
export interface CommentItemJson {
|
|
47
|
+
_id: IdObject;
|
|
48
|
+
collection: "comments";
|
|
49
|
+
contextId: string;
|
|
50
|
+
contextType: string;
|
|
51
|
+
parentId: string;
|
|
52
|
+
text: string;
|
|
53
|
+
created: DateValue;
|
|
54
|
+
author: CommentAuthorJson;
|
|
55
|
+
tags?: string[] | null;
|
|
56
|
+
status: string;
|
|
57
|
+
views?: CommentViews;
|
|
58
|
+
postedDate: number;
|
|
59
|
+
markdownActive: boolean;
|
|
60
|
+
argval?: string;
|
|
61
|
+
replies?: CommentItemJson[];
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Structure normalisée utilisée côté client
|
|
67
|
+
* Les dates sont converties en objets Date
|
|
68
|
+
* Le champ author peut être une instance d'entité (User ou Organization)
|
|
69
|
+
*/
|
|
70
|
+
export interface CommentItemNormalized {
|
|
71
|
+
id: string;
|
|
72
|
+
_id: ObjectID;
|
|
73
|
+
collection: "comments";
|
|
74
|
+
contextId: string;
|
|
75
|
+
contextType: string;
|
|
76
|
+
parentId: string;
|
|
77
|
+
text: string;
|
|
78
|
+
created: Date;
|
|
79
|
+
author: CommentAuthor | User | Organization;
|
|
80
|
+
tags?: string[] | null;
|
|
81
|
+
status: string;
|
|
82
|
+
views?: Record<string, { date: Date; [k: string]: unknown }>;
|
|
83
|
+
postedDate: number;
|
|
84
|
+
markdownActive: boolean;
|
|
85
|
+
argval?: string;
|
|
86
|
+
replies?: CommentItemNormalized[];
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GeoCoordinates,
|
|
3
|
+
GeoPosition,
|
|
4
|
+
IdObject,
|
|
5
|
+
LinkAttendeesRef,
|
|
6
|
+
LinkOrganizerRef,
|
|
7
|
+
ParentsMap,
|
|
8
|
+
OrganizerMap,
|
|
9
|
+
PostalAddress,
|
|
10
|
+
DateValue
|
|
11
|
+
} from "./common.js";
|
|
12
|
+
import type EJSONType from "../../EJSONType.js";
|
|
13
|
+
|
|
14
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
15
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
16
|
+
|
|
17
|
+
export interface EventLinksBlock {
|
|
18
|
+
attendees?: Record<string, LinkAttendeesRef>;
|
|
19
|
+
organizer?: Record<string, LinkOrganizerRef>;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface EventItemJson {
|
|
24
|
+
_id: IdObject;
|
|
25
|
+
collection: "events";
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
startDate: DateValue;
|
|
29
|
+
endDate: DateValue;
|
|
30
|
+
created?: DateValue;
|
|
31
|
+
updated?: DateValue;
|
|
32
|
+
modified?: DateValue;
|
|
33
|
+
parent?: ParentsMap;
|
|
34
|
+
description?: string;
|
|
35
|
+
shortDescription?: string;
|
|
36
|
+
slug?: string;
|
|
37
|
+
address?: PostalAddress;
|
|
38
|
+
geo?: GeoCoordinates;
|
|
39
|
+
geoPosition?: GeoPosition;
|
|
40
|
+
tags?: string[];
|
|
41
|
+
links?: EventLinksBlock;
|
|
42
|
+
organizer?: OrganizerMap;
|
|
43
|
+
creator?: string;
|
|
44
|
+
profilImageUrl?: string;
|
|
45
|
+
profilMediumImageUrl?: string;
|
|
46
|
+
profilThumbImageUrl?: string;
|
|
47
|
+
profilMarkerImageUrl?: string;
|
|
48
|
+
timeZone?: string;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface EventItemNormalized {
|
|
53
|
+
id: string;
|
|
54
|
+
_id: ObjectID;
|
|
55
|
+
collection: "events";
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
startDate: Date;
|
|
59
|
+
endDate: Date;
|
|
60
|
+
created?: Date;
|
|
61
|
+
updated?: Date;
|
|
62
|
+
modified?: Date;
|
|
63
|
+
parent?: ParentsMap;
|
|
64
|
+
description?: string;
|
|
65
|
+
shortDescription?: string;
|
|
66
|
+
slug?: string;
|
|
67
|
+
address?: PostalAddress;
|
|
68
|
+
geo?: GeoCoordinates;
|
|
69
|
+
geoPosition?: GeoPosition;
|
|
70
|
+
tags?: string[];
|
|
71
|
+
links?: EventLinksBlock;
|
|
72
|
+
organizer?: OrganizerMap;
|
|
73
|
+
creator?: string;
|
|
74
|
+
profilImageUrl?: string;
|
|
75
|
+
profilMediumImageUrl?: string;
|
|
76
|
+
profilThumbImageUrl?: string;
|
|
77
|
+
profilMarkerImageUrl?: string;
|
|
78
|
+
timeZone?: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IdObject,
|
|
3
|
+
DateValue,
|
|
4
|
+
} from "./common.js";
|
|
5
|
+
import type EJSONType from "../../EJSONType.js";
|
|
6
|
+
import type { Organization } from "../Organization.js";
|
|
7
|
+
import type { Project } from "../Project.js";
|
|
8
|
+
import type { User } from "../User.js";
|
|
9
|
+
|
|
10
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
11
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Auteur d'une actualité
|
|
15
|
+
*/
|
|
16
|
+
export interface NewsAuthor {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
profilThumbImageUrl?: string;
|
|
21
|
+
[k: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Personne ayant partagé l'actualité
|
|
26
|
+
*/
|
|
27
|
+
export interface NewsSharedBy {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
updated: DateValue;
|
|
32
|
+
comment: string | null;
|
|
33
|
+
profilThumbImageUrl?: string;
|
|
34
|
+
[k: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Cible de l'actualité
|
|
39
|
+
*/
|
|
40
|
+
export interface NewsTarget {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
type: string;
|
|
44
|
+
profilThumbImageUrl?: string;
|
|
45
|
+
[k: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Mention dans une actualité
|
|
50
|
+
*/
|
|
51
|
+
export interface NewsMention {
|
|
52
|
+
id: string;
|
|
53
|
+
slug: string;
|
|
54
|
+
type: string;
|
|
55
|
+
name: string;
|
|
56
|
+
value: string;
|
|
57
|
+
count: string; // API returns as string
|
|
58
|
+
[k: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Médias fichiers
|
|
63
|
+
*/
|
|
64
|
+
export interface NewsMediaFile {
|
|
65
|
+
countFiles: string; // API returns as string
|
|
66
|
+
files: any[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Médias images
|
|
71
|
+
*/
|
|
72
|
+
export interface NewsMediaImg {
|
|
73
|
+
countImages: string; // API returns as string
|
|
74
|
+
images: any[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Scope de l'actualité
|
|
79
|
+
*/
|
|
80
|
+
export interface NewsScope {
|
|
81
|
+
type: string;
|
|
82
|
+
[k: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Structure JSON brute retournée par l'API
|
|
87
|
+
*/
|
|
88
|
+
export interface NewsItemJson {
|
|
89
|
+
_id: IdObject;
|
|
90
|
+
id: string;
|
|
91
|
+
type: "news";
|
|
92
|
+
collection: "news";
|
|
93
|
+
text: string;
|
|
94
|
+
date: DateValue;
|
|
95
|
+
created: DateValue;
|
|
96
|
+
updated: DateValue;
|
|
97
|
+
markdownActive: boolean;
|
|
98
|
+
scope: NewsScope;
|
|
99
|
+
comment: string | null;
|
|
100
|
+
typeSig: "news";
|
|
101
|
+
author: NewsAuthor;
|
|
102
|
+
sharedBy: NewsSharedBy[];
|
|
103
|
+
lastAuthorShare: NewsSharedBy;
|
|
104
|
+
target: NewsTarget;
|
|
105
|
+
mediaFile: NewsMediaFile;
|
|
106
|
+
mediaImg: NewsMediaImg;
|
|
107
|
+
mentions?: NewsMention[];
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Structure normalisée utilisée côté client
|
|
113
|
+
* Les dates sont converties en objets Date
|
|
114
|
+
* Les counts sont convertis en numbers
|
|
115
|
+
* Les champs author, target, sharedBy peuvent être des instances d'entités
|
|
116
|
+
*/
|
|
117
|
+
export interface NewsItemNormalized {
|
|
118
|
+
_id: ObjectID;
|
|
119
|
+
id: string;
|
|
120
|
+
type: "news";
|
|
121
|
+
collection: "news";
|
|
122
|
+
text: string;
|
|
123
|
+
date: Date;
|
|
124
|
+
created: Date;
|
|
125
|
+
updated: Date;
|
|
126
|
+
markdownActive: boolean;
|
|
127
|
+
scope: NewsScope;
|
|
128
|
+
comment: string | null;
|
|
129
|
+
typeSig: "news";
|
|
130
|
+
author: NewsAuthor | User | Organization;
|
|
131
|
+
sharedBy: Array<(Omit<NewsSharedBy, "updated"> & { updated: Date }) | User | Organization>;
|
|
132
|
+
lastAuthorShare: (Omit<NewsSharedBy, "updated"> & { updated: Date }) | User | Organization;
|
|
133
|
+
target: NewsTarget | User | Organization | Project;
|
|
134
|
+
mediaFile: NewsMediaFile;
|
|
135
|
+
mediaImg: NewsMediaImg;
|
|
136
|
+
mentions?: NewsMention[];
|
|
137
|
+
[key: string]: unknown;
|
|
138
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GeoCoordinates,
|
|
3
|
+
GeoPosition,
|
|
4
|
+
IdObject,
|
|
5
|
+
LinkMemberOfRef,
|
|
6
|
+
LinkMemberRef,
|
|
7
|
+
LinkProjectRef,
|
|
8
|
+
LinkEventsRef,
|
|
9
|
+
OpeningHoursEntry,
|
|
10
|
+
ParentsMap,
|
|
11
|
+
PostalAddress,
|
|
12
|
+
DateValue
|
|
13
|
+
} from "./common.js";
|
|
14
|
+
import type EJSONType from "../../EJSONType.js";
|
|
15
|
+
|
|
16
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
17
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
18
|
+
|
|
19
|
+
export interface OrganizationLinksBlock {
|
|
20
|
+
members?: Record<string, LinkMemberRef>;
|
|
21
|
+
projects?: Record<string, LinkProjectRef>;
|
|
22
|
+
memberOf?: Record<string, LinkMemberOfRef>;
|
|
23
|
+
events?: Record<string, LinkEventsRef>;
|
|
24
|
+
[k: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface OrganizationItemJson {
|
|
28
|
+
_id: IdObject;
|
|
29
|
+
collection: "organizations";
|
|
30
|
+
name: string;
|
|
31
|
+
created?: DateValue;
|
|
32
|
+
updated?: DateValue;
|
|
33
|
+
modified?: DateValue;
|
|
34
|
+
parent?: ParentsMap;
|
|
35
|
+
description?: string;
|
|
36
|
+
shortDescription?: string;
|
|
37
|
+
slug?: string;
|
|
38
|
+
type?: "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative";
|
|
39
|
+
address?: PostalAddress;
|
|
40
|
+
geo?: GeoCoordinates;
|
|
41
|
+
geoPosition?: GeoPosition;
|
|
42
|
+
tags?: string[];
|
|
43
|
+
links?: OrganizationLinksBlock;
|
|
44
|
+
creator?: string;
|
|
45
|
+
openingHours?: OpeningHoursEntry[];
|
|
46
|
+
profilImageUrl?: string;
|
|
47
|
+
profilMediumImageUrl?: string;
|
|
48
|
+
profilThumbImageUrl?: string;
|
|
49
|
+
profilMarkerImageUrl?: string;
|
|
50
|
+
email?: string;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface OrganizationItemNormalized {
|
|
55
|
+
id: string;
|
|
56
|
+
_id: ObjectID;
|
|
57
|
+
collection: "organizations";
|
|
58
|
+
name: string;
|
|
59
|
+
created?: Date;
|
|
60
|
+
updated?: Date;
|
|
61
|
+
modified?: Date;
|
|
62
|
+
parent?: ParentsMap;
|
|
63
|
+
description?: string;
|
|
64
|
+
shortDescription?: string;
|
|
65
|
+
slug?: string;
|
|
66
|
+
type?: "NGO" | "LocalBusiness" | "Group" | "GovernmentOrganization" | "Cooperative";
|
|
67
|
+
address?: PostalAddress;
|
|
68
|
+
geo?: GeoCoordinates;
|
|
69
|
+
geoPosition?: GeoPosition;
|
|
70
|
+
tags?: string[];
|
|
71
|
+
links?: OrganizationLinksBlock;
|
|
72
|
+
creator?: string;
|
|
73
|
+
openingHours?: OpeningHoursEntry[];
|
|
74
|
+
profilImageUrl?: string;
|
|
75
|
+
profilMediumImageUrl?: string;
|
|
76
|
+
profilThumbImageUrl?: string;
|
|
77
|
+
profilMarkerImageUrl?: string;
|
|
78
|
+
email?: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GeoCoordinates,
|
|
3
|
+
GeoPosition,
|
|
4
|
+
IdObject,
|
|
5
|
+
LinkContributorsRef,
|
|
6
|
+
LinkProjectRef,
|
|
7
|
+
LinkEventsRef,
|
|
8
|
+
ParentsMap,
|
|
9
|
+
PostalAddress,
|
|
10
|
+
DateValue
|
|
11
|
+
} from "./common.js";
|
|
12
|
+
import type EJSONType from "../../EJSONType.js";
|
|
13
|
+
|
|
14
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
15
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
16
|
+
|
|
17
|
+
export interface ProjectLinksBlock {
|
|
18
|
+
contributors?: Record<string, LinkContributorsRef>;
|
|
19
|
+
projects?: Record<string, LinkProjectRef>;
|
|
20
|
+
events?: Record<string, LinkEventsRef>;
|
|
21
|
+
[k: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ProjectItemJson {
|
|
25
|
+
_id: IdObject;
|
|
26
|
+
collection: "projects";
|
|
27
|
+
name: string;
|
|
28
|
+
created?: DateValue;
|
|
29
|
+
updated?: DateValue;
|
|
30
|
+
modified?: DateValue;
|
|
31
|
+
parent?: ParentsMap;
|
|
32
|
+
description?: string;
|
|
33
|
+
shortDescription?: string;
|
|
34
|
+
slug?: string;
|
|
35
|
+
address?: PostalAddress;
|
|
36
|
+
geo?: GeoCoordinates;
|
|
37
|
+
geoPosition?: GeoPosition;
|
|
38
|
+
tags?: string[];
|
|
39
|
+
links?: ProjectLinksBlock;
|
|
40
|
+
creator?: string;
|
|
41
|
+
profilImageUrl?: string;
|
|
42
|
+
profilMediumImageUrl?: string;
|
|
43
|
+
profilThumbImageUrl?: string;
|
|
44
|
+
profilMarkerImageUrl?: string;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ProjectItemNormalized {
|
|
49
|
+
id: string;
|
|
50
|
+
_id: ObjectID;
|
|
51
|
+
collection: "projects";
|
|
52
|
+
name: string;
|
|
53
|
+
created?: Date;
|
|
54
|
+
updated?: Date;
|
|
55
|
+
modified?: Date;
|
|
56
|
+
parent?: ParentsMap;
|
|
57
|
+
description?: string;
|
|
58
|
+
shortDescription?: string;
|
|
59
|
+
slug?: string;
|
|
60
|
+
address?: PostalAddress;
|
|
61
|
+
geo?: GeoCoordinates;
|
|
62
|
+
geoPosition?: GeoPosition;
|
|
63
|
+
tags?: string[];
|
|
64
|
+
links?: ProjectLinksBlock;
|
|
65
|
+
creator?: string;
|
|
66
|
+
profilImageUrl?: string;
|
|
67
|
+
profilMediumImageUrl?: string;
|
|
68
|
+
profilThumbImageUrl?: string;
|
|
69
|
+
profilMarkerImageUrl?: string;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GeoCoordinates,
|
|
3
|
+
GeoPosition,
|
|
4
|
+
IdObject,
|
|
5
|
+
LinkMemberOfUserRef,
|
|
6
|
+
LinkProjectRef,
|
|
7
|
+
LinkEventsRef,
|
|
8
|
+
LinkfriendsRef,
|
|
9
|
+
LinkFollowsUserRef,
|
|
10
|
+
LinkFollowersUserRef,
|
|
11
|
+
PostalAddress,
|
|
12
|
+
DateValue
|
|
13
|
+
} from "./common.js";
|
|
14
|
+
import type EJSONType from "../../EJSONType.js";
|
|
15
|
+
|
|
16
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
17
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
18
|
+
|
|
19
|
+
export interface UserLinksBlock {
|
|
20
|
+
projects?: Record<string, LinkProjectRef>;
|
|
21
|
+
memberOf?: Record<string, LinkMemberOfUserRef>;
|
|
22
|
+
events?: Record<string, LinkEventsRef>;
|
|
23
|
+
friends?: Record<string, LinkfriendsRef>;
|
|
24
|
+
followers?: Record<string, LinkFollowersUserRef>;
|
|
25
|
+
follows?: Record<string, LinkFollowsUserRef>;
|
|
26
|
+
[k: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UserRoles {
|
|
30
|
+
superAdmin?: boolean;
|
|
31
|
+
betaTester?: boolean;
|
|
32
|
+
standalonePageAccess?: boolean;
|
|
33
|
+
toBeValidated?: boolean;
|
|
34
|
+
[k: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface UserPreferences {
|
|
38
|
+
isOpenData?: boolean;
|
|
39
|
+
badge?: boolean;
|
|
40
|
+
activitypub?: boolean;
|
|
41
|
+
[k: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface UserItemJson {
|
|
45
|
+
_id: IdObject;
|
|
46
|
+
collection: "citoyens";
|
|
47
|
+
name: string;
|
|
48
|
+
username: string;
|
|
49
|
+
email: string;
|
|
50
|
+
roles: UserRoles;
|
|
51
|
+
created?: DateValue;
|
|
52
|
+
updated?: DateValue;
|
|
53
|
+
modified?: DateValue;
|
|
54
|
+
birthDate?: DateValue;
|
|
55
|
+
language?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
shortDescription?: string;
|
|
58
|
+
slug?: string;
|
|
59
|
+
address?: PostalAddress;
|
|
60
|
+
geo?: GeoCoordinates;
|
|
61
|
+
geoPosition?: GeoPosition;
|
|
62
|
+
tags?: string[];
|
|
63
|
+
links?: UserLinksBlock;
|
|
64
|
+
profilImageUrl?: string;
|
|
65
|
+
profilMediumImageUrl?: string;
|
|
66
|
+
profilThumbImageUrl?: string;
|
|
67
|
+
profilMarkerImageUrl?: string;
|
|
68
|
+
profilBannerUrl?: string;
|
|
69
|
+
profilRealBannerUrl?: string;
|
|
70
|
+
preferences?: UserPreferences;
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface UserItemNormalized {
|
|
75
|
+
id: string;
|
|
76
|
+
_id: ObjectID;
|
|
77
|
+
collection: "citoyens";
|
|
78
|
+
name: string;
|
|
79
|
+
username: string;
|
|
80
|
+
email: string;
|
|
81
|
+
roles: UserRoles;
|
|
82
|
+
created?: Date;
|
|
83
|
+
updated?: Date;
|
|
84
|
+
modified?: Date;
|
|
85
|
+
birthDate?: Date;
|
|
86
|
+
language?: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
shortDescription?: string;
|
|
89
|
+
slug?: string;
|
|
90
|
+
address?: PostalAddress;
|
|
91
|
+
geo?: GeoCoordinates;
|
|
92
|
+
geoPosition?: GeoPosition;
|
|
93
|
+
tags?: string[];
|
|
94
|
+
links?: UserLinksBlock;
|
|
95
|
+
profilImageUrl?: string;
|
|
96
|
+
profilMediumImageUrl?: string;
|
|
97
|
+
profilThumbImageUrl?: string;
|
|
98
|
+
profilMarkerImageUrl?: string;
|
|
99
|
+
profilBannerUrl?: string;
|
|
100
|
+
profilRealBannerUrl?: string;
|
|
101
|
+
preferences?: UserPreferences;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
}
|