@communecter/cocolight-api-client 1.0.96 → 1.0.97
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.ts +17 -0
- package/src/api/EntityRegistry.ts +2 -2
- package/src/api/Poi.ts +14 -6
- package/src/api/serverDataType/Poi.ts +75 -0
- package/src/endpoints.module.ts +1 -1
- package/src/index.ts +2 -0
- package/types/Api.d.ts +5 -0
- package/types/api/Poi.d.ts +5 -4
- package/types/api/serverDataType/Poi.d.ts +57 -0
- package/types/endpoints.module.d.ts +10 -3
- package/types/index.d.ts +2 -0
package/package.json
CHANGED
package/src/Api.ts
CHANGED
|
@@ -190,6 +190,23 @@ export default class Api {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Creates a new Poi instance and optionally retrieves its profile.
|
|
195
|
+
*/
|
|
196
|
+
async poi(eventData: EntityData): Promise<Poi> {
|
|
197
|
+
try {
|
|
198
|
+
const poi = new Poi(this._client, eventData, { EndpointApi, User, Organization, Project, Poi, Badge, News, Comment });
|
|
199
|
+
if (!eventData.id && !eventData.slug) {
|
|
200
|
+
throw new Error("Vous devez fournir un id ou un slug pour créer une instance Event.");
|
|
201
|
+
}
|
|
202
|
+
await poi.get();
|
|
203
|
+
return poi;
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error("[Api.poi] Erreur lors de la création d'un objet poi :", (error as Error).message);
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
193
210
|
/**
|
|
194
211
|
* Creates a new Answer instance and optionally retrieves answer data.
|
|
195
212
|
*/
|
|
@@ -120,7 +120,7 @@ function _getEntityMeta(entityType: CollectionKey, __entityTag: EntityTag): Enti
|
|
|
120
120
|
organizations:{ entityClass: commonDeps.Organization as EntityClass, deps: commonDeps },
|
|
121
121
|
projects: { entityClass: commonDeps.Project as EntityClass, deps: commonDeps },
|
|
122
122
|
events: { entityClass: commonDeps.Event as EntityClass, deps: { ...commonDeps, Badge: undefined } },
|
|
123
|
-
poi: { entityClass: commonDeps.Poi as EntityClass, deps: { ...commonDeps, Badge: undefined, News: undefined } },
|
|
123
|
+
poi: { entityClass: commonDeps.Poi as EntityClass, deps: { ...commonDeps, Badge: undefined, News: undefined, Comment: undefined } },
|
|
124
124
|
news: { entityClass: commonDeps.News as EntityClass, deps: { ...commonDeps } },
|
|
125
125
|
badges: { entityClass: commonDeps.Badge as EntityClass, deps: {
|
|
126
126
|
EndpointApi: commonDeps.EndpointApi,
|
|
@@ -163,7 +163,7 @@ export function createFromCollection(collection: CollectionKey, parent: ApiClien
|
|
|
163
163
|
},
|
|
164
164
|
poi: {
|
|
165
165
|
entityTag: "Poi",
|
|
166
|
-
meta: tag => _buildMeta(tag, { remove: ["Badge","News"] })
|
|
166
|
+
meta: tag => _buildMeta(tag, { remove: ["Badge","News","Comments"] })
|
|
167
167
|
},
|
|
168
168
|
news: {
|
|
169
169
|
entityTag: "News",
|
package/src/api/Poi.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ApiError } from "../error.js";
|
|
2
2
|
import { BaseEntity } from "./BaseEntity.js";
|
|
3
|
+
import { PoiItemNormalized } from "./serverDataType/Poi.js";
|
|
3
4
|
|
|
4
5
|
import type { AddPoiData } from "./EndpointApi.types.js";
|
|
5
6
|
|
|
6
|
-
export class Poi extends BaseEntity<
|
|
7
|
+
export class Poi extends BaseEntity<PoiItemNormalized> {
|
|
7
8
|
static override entityType = "poi";
|
|
8
9
|
|
|
9
10
|
static override entityTag = "Poi";
|
|
@@ -133,16 +134,20 @@ export class Poi extends BaseEntity<any> {
|
|
|
133
134
|
*
|
|
134
135
|
* Récupère les actualités du POI.
|
|
135
136
|
*/
|
|
136
|
-
override async getNews(data: Parameters<BaseEntity<
|
|
137
|
-
|
|
137
|
+
// override async getNews(data: Parameters<BaseEntity<PoiItemNormalized>["getNews"]>[0] = {}) {
|
|
138
|
+
// return super.getNews(data);
|
|
139
|
+
// }
|
|
140
|
+
override async getNews(): Promise<never> {
|
|
141
|
+
throw new ApiError(`getNews n'existe pas dans ${this.constructor.name}`, 501);
|
|
138
142
|
}
|
|
139
143
|
|
|
144
|
+
|
|
140
145
|
/**
|
|
141
146
|
* {@inheritDoc BaseEntity#getSubscribers}
|
|
142
147
|
*
|
|
143
148
|
* Récupère les abonnés du POI.
|
|
144
149
|
*/
|
|
145
|
-
override async getSubscribers(data: Parameters<BaseEntity<
|
|
150
|
+
override async getSubscribers(data: Parameters<BaseEntity<PoiItemNormalized>["getSubscribers"]>[0] = {}) {
|
|
146
151
|
return super.getSubscribers(data);
|
|
147
152
|
}
|
|
148
153
|
|
|
@@ -167,8 +172,11 @@ export class Poi extends BaseEntity<any> {
|
|
|
167
172
|
*
|
|
168
173
|
* Crée une instance de news et la récupère si nécessaire.
|
|
169
174
|
*/
|
|
170
|
-
override async news(newsData: Parameters<BaseEntity<
|
|
171
|
-
|
|
175
|
+
// override async news(newsData: Parameters<BaseEntity<PoiItemNormalized>["news"]>[0] = {}) {
|
|
176
|
+
// return super.news(newsData);
|
|
177
|
+
// }
|
|
178
|
+
override async news(): Promise<never> {
|
|
179
|
+
throw new ApiError(`news n'existe pas dans ${this.constructor.name}`, 501);
|
|
172
180
|
}
|
|
173
181
|
|
|
174
182
|
/**
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GeoCoordinates,
|
|
3
|
+
GeoPosition,
|
|
4
|
+
IdObject,
|
|
5
|
+
ParentsMap,
|
|
6
|
+
PostalAddress,
|
|
7
|
+
DateValue
|
|
8
|
+
} from "./common.js";
|
|
9
|
+
import type EJSONType from "../../EJSONType.js";
|
|
10
|
+
|
|
11
|
+
type ObjectIDCtor = typeof EJSONType["ObjectID"];
|
|
12
|
+
type ObjectID = InstanceType<ObjectIDCtor>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Types de poi supportés
|
|
16
|
+
*/
|
|
17
|
+
export const POI_TYPES = [
|
|
18
|
+
"link", "tool", "machine", "software", "rh",
|
|
19
|
+
"Resource material", "Financial Ressource", "ficheBlanche",
|
|
20
|
+
"geoJson", "compostPickup", "video", "sharedLibrary",
|
|
21
|
+
"recoveryCenter", "trash", "history", "something2See",
|
|
22
|
+
"funPlace", "place", "artPiece", "streetArts",
|
|
23
|
+
"openScene", "stand", "parking", "other"
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
export type PoiType = (typeof POI_TYPES)[number];
|
|
27
|
+
|
|
28
|
+
export interface PoiItemJson {
|
|
29
|
+
_id: IdObject;
|
|
30
|
+
collection: "poi";
|
|
31
|
+
name: string;
|
|
32
|
+
type: PoiType;
|
|
33
|
+
created?: DateValue;
|
|
34
|
+
updated?: DateValue;
|
|
35
|
+
modified?: DateValue;
|
|
36
|
+
parent?: ParentsMap;
|
|
37
|
+
description?: string;
|
|
38
|
+
slug?: string;
|
|
39
|
+
address?: PostalAddress;
|
|
40
|
+
geo?: GeoCoordinates;
|
|
41
|
+
geoPosition?: GeoPosition;
|
|
42
|
+
tags?: string[];
|
|
43
|
+
ursl?: string[];
|
|
44
|
+
creator?: string;
|
|
45
|
+
profilImageUrl?: string;
|
|
46
|
+
profilMediumImageUrl?: string;
|
|
47
|
+
profilThumbImageUrl?: string;
|
|
48
|
+
profilMarkerImageUrl?: string;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PoiItemNormalized {
|
|
53
|
+
id: string;
|
|
54
|
+
_id: ObjectID;
|
|
55
|
+
collection: "poi";
|
|
56
|
+
name: string;
|
|
57
|
+
type: PoiType;
|
|
58
|
+
created?: Date;
|
|
59
|
+
updated?: Date;
|
|
60
|
+
modified?: Date;
|
|
61
|
+
parent?: ParentsMap;
|
|
62
|
+
description?: string;
|
|
63
|
+
slug?: string;
|
|
64
|
+
address?: PostalAddress;
|
|
65
|
+
geo?: GeoCoordinates;
|
|
66
|
+
geoPosition?: GeoPosition;
|
|
67
|
+
tags?: string[];
|
|
68
|
+
ursl?: string[];
|
|
69
|
+
creator?: string;
|
|
70
|
+
profilImageUrl?: string;
|
|
71
|
+
profilMediumImageUrl?: string;
|
|
72
|
+
profilThumbImageUrl?: string;
|
|
73
|
+
profilMarkerImageUrl?: string;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|