@communecter/cocolight-api-client 1.0.102 → 1.0.103
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 +5 -5
- package/src/api/User.ts +6 -6
package/package.json
CHANGED
package/src/api/BaseEntity.ts
CHANGED
|
@@ -2862,7 +2862,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
2862
2862
|
* @throws {Error} Si une erreur se produit lors de la création de l'organisation.
|
|
2863
2863
|
*/
|
|
2864
2864
|
async organization(organizationData: OrganizationInput = {}): Promise<Organization> {
|
|
2865
|
-
if(!this.isMe){
|
|
2865
|
+
if(!("id" in organizationData) && !("slug" in organizationData) && !this.isMe){
|
|
2866
2866
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer une organisation.", 403);
|
|
2867
2867
|
}
|
|
2868
2868
|
const entity = await this.entity("organizations", organizationData);
|
|
@@ -2880,7 +2880,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
2880
2880
|
*/
|
|
2881
2881
|
async project(projectData: ProjectInput = {}): Promise<Project> {
|
|
2882
2882
|
// TODO: Vérifier si l'utilisateur est admin de l'organisation
|
|
2883
|
-
if(!this.isConnected){
|
|
2883
|
+
if(!("id" in projectData) && !("slug" in projectData) && !this.isConnected){
|
|
2884
2884
|
throw new ApiError("Vous devez être connecté pour créer un projet.", 401);
|
|
2885
2885
|
}
|
|
2886
2886
|
|
|
@@ -2899,7 +2899,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
2899
2899
|
*/
|
|
2900
2900
|
async poi(poiData: PoiInput = {}): Promise<Poi> {
|
|
2901
2901
|
// TODO: Vérifier si l'utilisateur est admin de l'organisation
|
|
2902
|
-
if(!this.isConnected){
|
|
2902
|
+
if(!("id" in poiData) && !("slug" in poiData) && !this.isConnected){
|
|
2903
2903
|
throw new ApiError("Vous devez être connecté pour créer un POI.", 401);
|
|
2904
2904
|
}
|
|
2905
2905
|
|
|
@@ -2918,7 +2918,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
2918
2918
|
*/
|
|
2919
2919
|
async event(eventData: EventInput = {}): Promise<EventEntity> {
|
|
2920
2920
|
// TODO: Vérifier si l'utilisateur est admin de l'organisation
|
|
2921
|
-
if(!this.isConnected){
|
|
2921
|
+
if(!("id" in eventData) && !("slug" in eventData) && !this.isConnected){
|
|
2922
2922
|
throw new ApiError("Vous devez être connecté pour créer un événement.", 401);
|
|
2923
2923
|
}
|
|
2924
2924
|
const entity = await this.entity("events", eventData);
|
|
@@ -2936,7 +2936,7 @@ export class BaseEntity<TServerData = any> {
|
|
|
2936
2936
|
*/
|
|
2937
2937
|
async badge(badgeData: BadgeInput = {}): Promise<Badge> {
|
|
2938
2938
|
// TODO: Vérifier si l'utilisateur est admin de l'organisation
|
|
2939
|
-
if(!this.isConnected){
|
|
2939
|
+
if(!("id" in badgeData) && !this.isConnected){
|
|
2940
2940
|
throw new ApiError("Vous devez être connecté pour créer un badge.", 401);
|
|
2941
2941
|
}
|
|
2942
2942
|
const entity = await this.entity("badges", badgeData);
|
package/src/api/User.ts
CHANGED
|
@@ -565,7 +565,7 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
565
565
|
* Crée une instance d'organisation et récupère son profil si nécessaire.
|
|
566
566
|
*/
|
|
567
567
|
override async organization(organizationData: Parameters<BaseEntity<UserItemNormalized>["organization"]>[0] = {}) {
|
|
568
|
-
if(!this.isMe){
|
|
568
|
+
if(!("id" in organizationData) && !("slug" in organizationData) && !this.isMe){
|
|
569
569
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer une organisation.", 401);
|
|
570
570
|
}
|
|
571
571
|
return super.organization(organizationData);
|
|
@@ -577,7 +577,7 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
577
577
|
* Crée une instance de projet et récupère son profil si nécessaire.
|
|
578
578
|
*/
|
|
579
579
|
override async project(projectData: Parameters<BaseEntity<UserItemNormalized>["project"]>[0] = {}) {
|
|
580
|
-
if(!this.isMe){
|
|
580
|
+
if(!("id" in projectData) && !("slug" in projectData) && !this.isMe){
|
|
581
581
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un projet.", 401);
|
|
582
582
|
}
|
|
583
583
|
return super.project(projectData);
|
|
@@ -589,7 +589,7 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
589
589
|
* Crée une instance de news et la récupère si nécessaire.
|
|
590
590
|
*/
|
|
591
591
|
override async news(newsData: Parameters<BaseEntity<UserItemNormalized>["news"]>[0] = {}) {
|
|
592
|
-
if(!this.isMe){
|
|
592
|
+
if(!("id" in newsData) && !this.isMe){
|
|
593
593
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer une actualité.", 401);
|
|
594
594
|
}
|
|
595
595
|
return super.news(newsData);
|
|
@@ -601,7 +601,7 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
601
601
|
* Crée une instance de POI et la récupère si nécessaire.
|
|
602
602
|
*/
|
|
603
603
|
override async poi(poiData: Parameters<BaseEntity<UserItemNormalized>["poi"]>[0] = {}) {
|
|
604
|
-
if(!this.isMe){
|
|
604
|
+
if(!("id" in poiData) && !("slug" in poiData) && !this.isMe){
|
|
605
605
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un POI.", 401);
|
|
606
606
|
}
|
|
607
607
|
return super.poi(poiData);
|
|
@@ -613,7 +613,7 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
613
613
|
* Crée une instance d'événement et la récupère si nécessaire.
|
|
614
614
|
*/
|
|
615
615
|
override async event(eventData: Parameters<BaseEntity<UserItemNormalized>["event"]>[0] = {}) {
|
|
616
|
-
if(!this.isMe){
|
|
616
|
+
if(!("id" in eventData) && !("slug" in eventData) && !this.isMe){
|
|
617
617
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un événement.", 401);
|
|
618
618
|
}
|
|
619
619
|
return super.event(eventData);
|
|
@@ -625,7 +625,7 @@ export class User extends BaseEntity<UserItemNormalized> {
|
|
|
625
625
|
* Crée une instance de badge et la récupère si nécessaire.
|
|
626
626
|
*/
|
|
627
627
|
override async badge(badgeData: Parameters<BaseEntity<UserItemNormalized>["badge"]>[0] = {}) {
|
|
628
|
-
if(!this.isMe){
|
|
628
|
+
if(!("id" in badgeData) && !this.isMe){
|
|
629
629
|
throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un badge.", 401);
|
|
630
630
|
}
|
|
631
631
|
return super.badge(badgeData);
|