@communecter/cocolight-api-client 1.0.7 → 1.0.9
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/README.md +4 -4
- package/dist/22.cocolight-api-client.mjs.js +1 -0
- package/dist/320.cocolight-api-client.browser.js +1 -0
- package/dist/931.cocolight-api-client.browser.js +1 -0
- package/dist/931.cocolight-api-client.cjs +1 -0
- package/dist/cocolight-api-client.browser.js +7 -6
- package/dist/cocolight-api-client.browser.js.LICENSE.txt +1 -0
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/package.json +13 -4
- package/src/Api.js +12 -8
- package/src/ApiClient.js +118 -10
- package/src/api/EndpointApi.js +1534 -0
- package/src/api/News.js +286 -0
- package/src/api/Organization.js +162 -8
- package/src/api/Project.js +163 -8
- package/src/api/User.js +150 -9
- package/src/api/UserApi.js +2 -1
- package/src/endpoints.module.js +2 -2
- package/src/error.js +11 -0
- package/src/index.js +2 -1
- package/src/mixin/EntityMixin.js +48 -0
- package/src/mixin/NewsMixin.js +8 -0
- package/src/mixin/UserMixin.js +8 -0
- package/src/mixin/UtilMixin.js +246 -0
- package/src/utils/stream-utils.node.js +10 -0
- package/src/api/EntityMixin.js +0 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"events";import*as t from"ajv";import*as o from"ajv-formats";import*as n from"axios";import*as r from"axios-retry";import*as i from"ejson";import*as s from"pino";var a={d:(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},m={};a.d(m,{A:()=>C});class c extends Error{constructor(e,t,o){super(e),this.name="ApiError",this.status=t,this.details=o}}class p extends c{constructor(e,t,o){super(e,t,o),this.name="ApiClientError"}}class l extends c{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class d extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=o,this.details=n}}class u extends c{constructor(e,t,o){super(e,t,o),this.name="ApiAuthenticationError"}}const y={async resolveId(e){return this.apiClient.safeCall((async()=>{if(!this.id&&this.slug){const t=await this.apiClient.callEndpoint("GET_ELEMENTS_KEY",{pathParams:{slug:this.slug}});if(!0!==t?.data?.result)throw new d(`Impossible de récupérer l'identifiant pour le slug ${this.slug}`,t.status,t.data);if(!t?.data?.contextId||t?.data?.contextType!==e)throw new d(`Le slug ${this.slug} ne correspond pas à un ${e}`,t.status,t.data);this.id=t.data.contextId}return this.id}))},async getPublicProfile(){return this.apiClient.safeCall((async()=>(await this.resolveId(this.getEntityType()),this.apiClient.callEndpoint("GET_ELEMENTS_ABOUT",{pathParams:{id:this.id}}))))}};class f{#e;#t;#o=null;constructor(e,{id:t,slug:o}={}){if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");this.apiClient=e,this.#e=t||null,this.#t=o||null}get id(){return this.#e}get slug(){return this.#t}_slug(e){this.#t=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#o}_setData(e){this.#o=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"organizations"}async getProfile(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e.data),e.data}))}}Object.assign(f.prototype,y);class h{#e;#t;#o=null;constructor(e,{id:t,slug:o}={}){if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");this.apiClient=e,this.#e=t||null,this.#t=o||null}get id(){return this.#e}get slug(){return this.#t}_slug(e){this.#t=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#o}_setData(e){this.#o=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"projects"}async getProfile(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e.data),e.data}))}}Object.assign(h.prototype,y);class g{#e;#t;#o;constructor(e,{id:t,slug:o}={},n={}){if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");this.apiClient=e,this.#e=t||null,this.#t=o||null,this.#o=n}get id(){return this.#e}get slug(){return this.#t}_slug(e){this.#t=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#o}_setData(e){this.#o=e}getEntityType(){return"citoyens"}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}async getProfile(){return this.apiClient.safeCall((async()=>this.isMe?(await this.apiClient.callEndpoint("ME_INFO_URL",{})).data:(await this.getPublicProfile()).data))}}Object.assign(g.prototype,y);const b=(T={EventEmitter:()=>e.EventEmitter},w={},a.d(w,T),w);var T,w;const P=(e=>{var t={};return a.d(t,e),t})({default:()=>t.default}),_=(e=>{var t={};return a.d(t,e),t})({default:()=>o.default}),j=(e=>{var t={};return a.d(t,e),t})({default:()=>n.default}),O=(e=>{var t={};return a.d(t,e),t})({default:()=>r.default}),A=(e=>{var t={};return a.d(t,e),t})({default:()=>i.default});class I extends Error{}I.prototype.name="InvalidTokenError";const k=(e=>{var t={};return a.d(t,e),t})({default:()=>s.default}),v={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!v._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof v.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new v.ObjectID(this._str)}typeName(){return"oid"}getTimestamp(){return Number.parseInt(this._str.substr(0,8),16)}valueOf(){return this._str}toJSONValue(){return this.valueOf()}toHexString(){return this.valueOf()}}},S=v,$={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{format:"uri",type:"string"},common5:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common6:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common7:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common8:{default:"",type:"string"},common9:{pattern:"^[a-f0-9]{24}$",type:"string"},common10:{const:"citoyens"},common11:{properties:{value:{type:"boolean"}}},common12:{value:{type:"boolean"}},common13:{},common14:{else:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}}},common15:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},common16:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common17:{properties:{typeElement:{const:"citoyens"}}},common18:{typeElement:{const:"citoyens"}},common19:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}},common20:{not:{type:"null"}},common21:{type:"null"},common22:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common23:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common24:{items:{type:"string"},type:"array"},common25:{enum:[""],type:"string"},common26:{properties:{name:{not:{type:"null"}}},required:["name"]},common27:{name:{not:{type:"null"}}},common28:{properties:{url:{not:{type:"null"}}},required:["url"]},common29:{url:{not:{type:"null"}}},common30:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common31:{tags:{not:{type:"null"}}},common32:{properties:{email:{not:{type:"null"}}},required:["email"]},common33:{email:{not:{type:"null"}}},common34:{const:"info",default:"info",type:"string"},common35:{$ref:"#/$defs/sharedFields/email"},common36:{$ref:"#/$defs/sharedFields/name"},common37:{$ref:"#/$defs/sharedFields/tags"},common38:{$ref:"#/$defs/sharedFields/url"},common39:{const:"projects"},common40:{const:"organizations"},common41:{$ref:"#/$defs/socialField"},common42:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common43:{id:{pattern:"^[a-f0-9]{24}$"}},common44:{pattern:"^[a-f0-9]{24}$"},common45:{minLength:0,type:"string"},common46:{type:["string","number"]},common47:{type:"number"},common48:{const:!0,default:!0,type:"boolean"},common49:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common50:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common51:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"},common52:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common53:{properties:{type:{const:"citoyens"}}},common54:{type:{const:"citoyens"}},common55:{additionalProperties:!1,else:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{folder:{const:"citoyens"}}},properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],then:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common56:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common57:{ownerId:{pattern:"^[a-f0-9]{24}$"}},common58:{properties:{folder:{const:"citoyens"}}},common59:{folder:{const:"citoyens"}},common60:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common61:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common62:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common63:{additionalProperties:!1,else:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{type:{const:"citoyens"}}},properties:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common64:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common65:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common66:{parentId:{pattern:"^[a-f0-9]{24}$"}},common67:{properties:{parentType:{const:"citoyens"}}},common68:{parentType:{const:"citoyens"}},common69:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common70:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common71:{default:!0,type:"boolean"},common72:{required:["text"]},common73:{required:["mediaImg"]},common74:{required:["mediaFile"]},common75:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common76:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common77:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common78:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common79:{additionalProperties:!1,patternProperties:{"^[0-9]+$":{additionalProperties:!1,properties:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"}},type:"object"},common80:{"^[0-9]+$":{additionalProperties:!1,properties:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"}},common81:{additionalProperties:!1,properties:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common82:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common83:{default:"public",enum:["public","private","restricted"],type:"string"},common84:{const:"news",default:"news",type:"string"},common85:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common86:{default:!1,type:"boolean"},common87:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common88:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},common89:{default:"news",enum:["news"],type:"string"},common90:{items:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common91:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common92:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common93:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common94:{const:!1,default:!1,type:"boolean"},common95:{const:"",default:"",type:"string"},common96:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common97:{indexMax:{type:"number"},indexMin:{type:"number"}},common98:{default:0,minimum:0,type:"integer"},common99:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common100:{enum:["projects"],type:"string"},common101:{$exists:!0},common102:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common103:{$exists:{const:!0}},common104:{const:!0},common105:{default:30,type:"integer"},common106:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common107:{enum:["poi"],type:"string"},common108:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common109:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common110:{$exists:!1},common111:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common112:{$exists:{const:!1}},common113:{const:!1},common114:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common115:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common116:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common117:{$exists:{default:!1,type:"boolean"}},common118:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common119:{$in:{items:{type:"string"},minItems:1,type:"array"}},common120:{items:{type:"string"},minItems:1,type:"array"},common121:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common122:{enum:["citoyens"],type:"string"},common123:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},type:"array"},common124:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common125:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common126:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common127:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common128:{"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"}},common129:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common130:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common131:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common132:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common133:{enum:["badges"],type:"string"},common134:{const:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common135:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common136:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common137:{$exists:{const:!0,type:"boolean"}},common138:{const:!0,type:"boolean"},common139:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common140:{$exists:{const:!1,type:"boolean"}},common141:{const:!1,type:"boolean"},common142:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"}},common143:{indexMax:30,indexMin:0},common144:{additionalProperties:!1,allOf:[{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},{if:{properties:{parentType:{const:"events"}}},then:{properties:{connectType:{const:"attendee",default:"attendee"}}}}],properties:{childId:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},childType:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:{pattern:"^[a-f0-9]{24}$",type:"string"},parentType:{enum:["citoyens","organizations","projects","events"],type:"string"}},required:["childId","childType","parentType","parentId","connectType"],type:"object"},common145:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common146:{properties:{connectType:{const:"friend",default:"friend"}}},common147:{connectType:{const:"friend",default:"friend"}},common148:{const:"friend",default:"friend"},common149:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common150:{properties:{parentType:{const:"organizations"}}},common151:{parentType:{const:"organizations"}},common152:{properties:{connectType:{enum:["admin","member"]}}},common153:{connectType:{enum:["admin","member"]}},common154:{enum:["admin","member"]},common155:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common156:{properties:{parentType:{const:"projects"}}},common157:{parentType:{const:"projects"}},common158:{properties:{connectType:{enum:["admin","contributor"]}}},common159:{connectType:{enum:["admin","contributor"]}},common160:{enum:["admin","contributor"]},common161:{if:{properties:{parentType:{const:"events"}}},then:{properties:{connectType:{const:"attendee",default:"attendee"}}}},common162:{properties:{parentType:{const:"events"}}},common163:{parentType:{const:"events"}},common164:{const:"events"},common165:{properties:{connectType:{const:"attendee",default:"attendee"}}},common166:{connectType:{const:"attendee",default:"attendee"}},common167:{const:"attendee",default:"attendee"},common168:{childId:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},childType:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:{pattern:"^[a-f0-9]{24}$",type:"string"},parentType:{enum:["citoyens","organizations","projects","events"],type:"string"}},common169:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common170:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common171:{enum:["admin","member","contributor","attendee","friend"],type:"string"},common172:{enum:["citoyens","organizations","projects","events"],type:"string"}},E=[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:$.common1,email:$.common2,isInvitation:$.common3,mode:$.common1,name:$.common1,pendingUserId:$.common1,pwd:$.common1,username:$.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",path:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:$.common2,password:$.common1},required:["email","password"],type:"object"}},{auth:"none",constant:"REFRESH_TOKEN_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/refreshtoken",request:{additionalProperties:!1,properties:{refreshToken:$.common1},required:["refreshToken"],type:"object"}},{auth:"bearer",constant:"ME_INFO_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/me"},{auth:"none",constant:"PASSWORD_RECOVERY",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:$.common2,type:{const:"password",default:"password",type:"string"}},required:["email","type"],type:"object"}},{auth:"bearer",constant:"SERVER_EXCHANGE_TOKEN",contentType:"application/json",method:"POST",path:"/api/cocolight/exchangetoken",request:{additionalProperties:!1,properties:{serverUrl:$.common4},required:["serverUrl"],type:"object"}},{auth:"bearer",constant:"CHANGE_PASSWORD",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/changepassword",request:{additionalProperties:!1,properties:{mode:{const:"changePassword",default:"changePassword",type:"string"},newPassword:$.common1,newPassword2:$.common1,oldPassword:$.common1,scope:{default:"",type:["string"]},userId:$.common5},required:["mode","userId","oldPassword","newPassword","newPassword2"],type:"object"}},{auth:"bearer",constant:"DELETE_ACCOUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/id/{id}/type/citoyens",pathParams:$.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:{additionalProperties:!1,properties:{reason:$.common8},required:["reason"],type:"object"}},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:$.common9}},if:{properties:{typeEntity:$.common10}},then:{properties:{idEntity:$.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:$.common10}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:$.common10}},then:$.common11},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:$.common10}}},then:$.common11}],properties:{idEntity:$.common1,type:$.common1,typeEntity:{default:"citoyens",type:"string"},value:$.common13},required:["type","value","typeEntity","idEntity"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_DESCRIPTION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{additionalProperties:!1,allOf:[$.common14,{anyOf:[{properties:{description:$.common20},required:["description"]},{properties:{shortDescription:$.common20},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:$.common8,description:$.common1,id:$.common1,scope:{default:"",type:["string","null"]},shortDescription:$.common1,typeElement:$.common22},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_INFO",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{sharedFields:{email:$.common2,name:$.common1,tags:$.common23,url:$.common4}},allOf:[{if:$.common17,then:{additionalProperties:!1,anyOf:[$.common26,{properties:{birthDate:$.common20},required:["birthDate"]},{properties:{fixe:$.common20},required:["fixe"]},{properties:{mobile:$.common20},required:["mobile"]},$.common28,$.common30,$.common32],properties:{birthDate:{format:"date",type:"string"},block:$.common34,email:$.common35,fixe:$.common1,id:$.common5,mobile:$.common1,name:$.common36,scope:$.common8,tags:$.common37,typeElement:$.common22,url:$.common38}}},{if:{properties:{typeElement:$.common39}},then:{additionalProperties:!1,anyOf:[$.common26,$.common28,$.common30,$.common32,{properties:{avancement:$.common20},required:["avancement"]},{properties:{parent:$.common20},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:$.common34,email:$.common35,id:$.common1,name:$.common36,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":{additionalProperties:!1,properties:{name:$.common1,type:$.common1},required:["type","name"],type:"object"}},type:"object"},scope:$.common8,tags:$.common37,typeElement:$.common22,url:$.common38}}},{if:{properties:{typeElement:$.common40}},then:{additionalProperties:!1,anyOf:[$.common26,$.common28,$.common30,$.common32,{properties:{type:$.common20},required:["type"]}],properties:{block:$.common34,email:$.common35,id:$.common1,name:$.common36,scope:$.common8,tags:$.common37,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:$.common22,url:$.common38}}}],properties:{block:$.common34,id:$.common1,scope:$.common8,typeElement:$.common22},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SOCIAL",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{socialField:{anyOf:[$.common25,$.common4]}},allOf:[$.common14,{anyOf:[{properties:{gitlab:$.common20},required:["gitlab"]},{properties:{github:$.common20},required:["github"]},{properties:{twitter:$.common20},required:["twitter"]},{properties:{facebook:$.common20},required:["facebook"]},{properties:{instagram:$.common20},required:["instagram"]},{properties:{diaspora:$.common20},required:["diaspora"]},{properties:{mastodon:$.common20},required:["mastodon"]},{properties:{telegram:$.common20},required:["telegram"]},{properties:{signal:$.common20},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:$.common41,facebook:$.common41,github:$.common41,gitlab:$.common41,id:$.common1,instagram:$.common41,mastodon:$.common41,scope:$.common8,signal:$.common41,telegram:$.common41,twitter:$.common41,typeElement:$.common22},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_LOCALITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:$.common42,if:$.common17,properties:{address:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:$.common1,addressLocality:$.common1,codeInsee:$.common1,level1:$.common1,level1Name:$.common1,level3:$.common45,level3Name:$.common45,level4:$.common45,level4Name:$.common45,localityId:$.common1,postalCode:$.common1,streetAddress:$.common1},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},block:{const:"localities",default:"localities",type:"string"},geo:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:$.common46,longitude:$.common46},required:["latitude","longitude"],type:"object"},geoPosition:{additionalProperties:!0,properties:{coordinates:{items:$.common47,maxItems:2,minItems:2,type:"array"},float:$.common48,type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},id:$.common1,scope:$.common8,typeElement:$.common22},required:["block","typeElement","id","address"],then:$.common49,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:$.common42,if:$.common17,properties:{block:$.common34,id:$.common1,scope:$.common8,slug:$.common52,typeElement:$.common22},required:["block","typeElement","id","slug"],then:$.common49,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:$.common42,if:$.common53,properties:{block:$.common34,id:$.common1,slug:$.common52,type:$.common22},required:["block","type","id","slug"],then:$.common49,type:"object"}},{auth:"bearer",constant:"PROFIL_IMAGE",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/profil_avatar/contentKey/profil/docType/image",pathParams:$.common55,request:{additionalProperties:!1,properties:{profil_avatar:$.common13},required:["profil_avatar"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_ABOUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/about/type/{type}/id/{id}/json/true",pathParams:$.common63,request:{additionalProperties:!1,properties:{tpl:{const:"ficheInfoElement",default:"ficheInfoElement",type:"string"}},required:["tpl"],type:"object"}},{auth:"bearer",constant:"MULTICONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:$.common65,if:$.common67,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:$.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:$.common1,parentType:$.common22},required:["parentId","parentType","listInvite"],then:$.common69,type:"object"}},{auth:"none",constant:"GET_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/get/type/{type}/id/{id}/isLive/{isLive}/json/true",pathParams:{additionalProperties:!1,else:$.common42,if:$.common53,properties:{id:$.common1,isLive:$.common71,type:$.common22},required:["isLive","type","id"],then:$.common49,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:{default:0,type:"integer"},indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:$.common8},required:["name"],type:"object"}},required:["dateLimit","indexStep"],type:"object"}},{auth:"none",constant:"GET_NEWS_BY_ID",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/getbyids",request:{additionalProperties:!1,properties:{ids:{items:$.common9,type:"array"}},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,anyOf:[$.common72,$.common73,$.common74],else:$.common65,if:$.common67,properties:{json:$.common48,markdownActive:$.common71,mediaFile:$.common75,mediaImg:$.common77,mentions:$.common79,parentId:$.common1,parentType:$.common22,scope:$.common83,tags:$.common23,text:$.common1,type:$.common84},required:["scope","markdownActive","parentId","parentType","type","json"],then:$.common69,type:"object"}},{auth:"bearer",constant:"ADD_IMAGE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/newsImage/docType/image/contentKey/slider",pathParams:$.common55,request:{additionalProperties:!1,properties:{newsImage:$.common13},required:["newsImage"],type:"object"}},{auth:"bearer",constant:"ADD_FILE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}}/input/newsFile/docType/file",pathParams:$.common55,request:{additionalProperties:!1,properties:{newsFile:$.common13},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:$.common85,request:{additionalProperties:!1,properties:{isLive:$.common86},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,anyOf:[$.common72,$.common73,$.common74],else:$.common65,if:$.common67,properties:{idNews:$.common9,markdownActive:$.common71,mediaFile:$.common75,mediaImg:$.common77,mentions:$.common79,parentId:$.common1,parentType:$.common22,scope:$.common83,tags:$.common23,text:$.common1,type:$.common84},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:$.common69,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:{properties:{childId:$.common44}},if:{properties:{childType:$.common10}},properties:{childId:$.common9,childType:$.common22,comment:$.common1,connectType:{const:"share",default:"share",type:"string"},parentId:$.common9,parentType:$.common84},required:["parentId","parentType","childId","childType","connectType"],then:{properties:{childId:$.common51}},type:"object"}},{auth:"none",constant:"GET_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/index/type/{type}/id/{id}/json/true",pathParams:$.common87},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:$.common8,contextId:$.common9,contextType:$.common89,mentions:$.common90,parentCommentId:$.common9,path:$.common8,text:$.common1},required:["text","contextId","contextType"],type:"object"}},{auth:"bearer",constant:"DELETE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/delete/id/{id}",pathParams:$.common85},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:$.common9,params:{properties:{mentions:$.common90,text:$.common1},required:["text"],type:"object"}},required:["id","params"],type:"object"}},{auth:"none",constant:"SEARCH_TAGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/tags/search?q={q}",pathParams:{additionalProperties:!1,properties:{q:$.common1},required:["q"],type:"object"}},{auth:"none",constant:"SHOW_VOTE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/action/list/type/{type}/id/{id}/actionType/vote/json/true",pathParams:$.common87},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:$.common93,type:"array"},fediverse:$.common94,filters:$.common95,indexMin:{const:0,default:0,type:"number"},indexStep:$.common47,initType:$.common95,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:$.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:$.common1,notSourceKey:$.common48,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":$.common96},type:"object"},searchTags:$.common24,searchType:{items:$.common93,type:"array"}},required:["name","searchType","countType","indexMin","indexStep","initType","count","notSourceKey","filters","fediverse"],type:"object"}},{auth:"none",constant:"CITY_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{minimum:5,type:"integer"},indexMin:{minimum:0,type:"integer"},locality:$.common95,name:$.common1,searchBy:{const:"ALL",default:"ALL",type:"string"},searchType:{const:["cities"],default:["cities"],items:{enum:["cities"],type:"string"},type:"array"}},required:["name","locality","searchType"],type:"object"}},{auth:"none",constant:"SUGGESTION_INPUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{default:20,minimum:20,type:"integer"},indexMin:$.common98,name:$.common1,searchType:{items:{enum:["organizations","projects","poi"],type:"string"},type:"array"}},required:["name","searchType","indexMin","indexMax"],type:"object"}},{auth:"none",constant:"GET_PROJECTS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common99,fediverse:$.common94,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":$.common101,"parent.@userId":$.common101},"links.contributors.@userId":$.common101},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102},type:"object"}},required:["$or"],type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common99},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_PROJECTS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:$.common63,request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common99,fediverse:$.common94,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":$.common101,"parent.@{pathParams.id}":$.common101},"links.contributors.@{pathParams.id}":$.common101},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102},type:"object"}},required:["$or"],type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common99},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_POIS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common106,fediverse:$.common94,filters:{additionalProperties:!1,default:{"parent.@userId":$.common101},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common106},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_POIS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:$.common63,request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common106,fediverse:$.common94,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":$.common101},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common106},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_ORGANIZATIONS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common108,fediverse:$.common94,filters:{additionalProperties:!1,default:{"links.members.@userId":$.common101,"links.members.@userId.isInviting":$.common110,"links.members.@userId.toBeValidated":$.common110},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":$.common111,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":$.common111},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common108},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_ORGANIZATIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,else:$.common42,if:$.common53,properties:{id:$.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:$.common49,type:"object"},request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common108,fediverse:$.common94,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":$.common101,"links.members.@{pathParams.id}.isInviting":$.common110,"links.members.@{pathParams.id}.toBeValidated":$.common110},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":$.common111,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":$.common111},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common108},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_MEMBERS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common114,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":$.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":$.common116,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":$.common118,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":$.common111},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common114},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_MEMBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/organizations/id/{id}/canSee/true",pathParams:$.common85,request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common114,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.memberOf.@{pathParams.id}":$.common101,"links.memberOf.@{pathParams.id}.isInviting":$.common110,"links.memberOf.@{pathParams.id}.toBeValidated":$.common110},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":$.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":$.common116,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":$.common118,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":$.common116},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common114},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_FRIENDS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:$.common6,request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common121,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.friends.@{pathParams.id}":$.common101,"links.friends.@{pathParams.id}.isInviting":$.common110,"links.friends.@{pathParams.id}.toBeValidated":$.common110},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":$.common116,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":$.common116},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIPTIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common123,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[$.common125],default:{"links.followers.@userId":$.common101,"links.followers.@{userId}.isInviting":$.common110,"links.followers.@{userId}.toBeValidated":$.common110},patternProperties:$.common128,type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common123},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIPTIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:$.common6,request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common123,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[$.common125],default:{"links.followers.@{pathParams.id}":$.common101,"links.followers.@{pathParams.id}.isInviting":$.common110,"links.followers.@{pathParams.id}.toBeValidated":$.common110},patternProperties:$.common128,type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common123},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIBERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common121,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[$.common129],default:{"links.follows.@userId":$.common101,"links.follows.@{userId}.isInviting":$.common110,"links.follows.@{userId}.toBeValidated":$.common110},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":$.common111,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":$.common111},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,allOf:[{else:$.common42,if:$.common53,then:$.common49}],properties:{id:$.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common121,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[$.common129],default:{"links.follows.@{pathParams.id}":$.common101},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common114,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":$.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":$.common116,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":$.common118,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":$.common111},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common114},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_CONTRIBUTORS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/projects/id/{id}/canSee/true",pathParams:$.common85,request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common114,fediverse:$.common94,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.projects.@{pathParams.id}":$.common101,"links.projects.@{pathParams.id}.isInviting":$.common110,"links.projects.@{pathParams.id}.toBeValidated":$.common110},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":$.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":$.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":$.common116,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":$.common118,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":$.common116},type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common114},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common132,fediverse:$.common94,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":$.common102},type:"object"},isParcours:$.common3,"preferences.private":$.common94},required:["preferences.private"],type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,searchType:$.common132},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES_FILTERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:$.common48,countType:$.common134,fediverse:$.common94,fields:$.common132,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":$.common136}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":$.common136,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":$.common139,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":$.common139}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:$.common142},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:$.common142,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":$.common138}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":$.common136}}],type:"object"},indexMin:$.common98,indexStep:$.common105,initType:$.common95,locality:$.common95,name:$.common1,notSourceKey:$.common48,ranges:{additionalProperties:!1,default:{Cooperative:$.common143,GovernmentOrganization:$.common143,Group:$.common143,LocalBusiness:$.common143,NGO:$.common143,citoyens:$.common143,projects:$.common143},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":$.common96},type:"object"},searchType:$.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"CONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/connect",request:$.common144},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:$.common144},{auth:"none",constant:"GET_ELEMENTS_KEY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/getinfo/key/{slug}",pathParams:{slug:$.common1}}];A.default.addType("oid",(e=>new S.ObjectID(e)));class x extends b.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:r=E,timeout:i=3e4,debug:s=!1,maxRetries:a=0,circuitBreakerThreshold:m=5,circuitBreakerResetTime:c=6e4,fromJSONValue:l=!0}={}){if(super(),!e)throw new p('Le paramètre "baseURL" est obligatoire.',500);this._baseURL=e,this._refreshToken=o,this._refreshUrl=n,this._endpoints=r,this._debug=s;let d=null;this._fromJSONValue=l,Object.defineProperty(this,"userId",{get:()=>d,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{d=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new P.default({strict:!1,useDefaults:!0}),(0,_.default)(this._ajv),this._logger=(0,k.default)({transport:{target:"pino-pretty",options:{colorize:!0}},level:s?"debug":"info"}),this._client=j.default.create({baseURL:e,timeout:i}),a>0&&((0,O.default)(this._client,{retries:a,retryDelay:O.default.exponentialDelay,retryCondition:e=>O.default.isNetworkError(e)||O.default.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${a} max`)),this._breakerThreshold=m,this._breakerResetTime=c,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,t&&this.setToken(t),this._client.interceptors.response.use((e=>e),(async e=>{if(e.response&&401===e.response.status&&this._refreshToken)try{if(await this._refreshAccessToken())return this._client.request(e.config)}catch(e){throw new p(e.message,401,e)}throw e}))}setToken(e){this._accessToken=e,this._client.defaults.headers.common.Authorization="Bearer "+e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait et défini : ${t}`)),this._logger.debug(`[ApiClient] setToken: ${e}`)}getToken(){return this._accessToken}setRefreshToken(e){this._refreshToken=e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait depuis refreshToken : ${t}`)),this._logger.debug(`[ApiClient] setRefreshToken: ${e}`)}getRefreshToken(){return this._refreshToken}get isConnected(){return!!this._accessToken}_getIdFromToken(e){if(!e)return null;try{const t=function(e,t){if("string"!=typeof e)throw new I("Invalid token specified: must be a string");t||(t={});const o=!0===t.header?0:1,n=e.split(".")[o];if("string"!=typeof n)throw new I(`Invalid token specified: missing part #${o+1}`);let r;try{r=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let o=t.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o})))}(t)}catch(e){return atob(t)}}(n)}catch(e){throw new I(`Invalid token specified: invalid base64 for part #${o+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new I(`Invalid token specified: invalid json for part #${o+1} (${e.message})`)}}(e);return this._logger.debug("[ApiClient] Payload décodé :",t),t.id||t.userId||null}catch(e){return this._logger.error("[ApiClient] Erreur lors du décodage du token :",e),null}}async _refreshAccessToken(){if(!this._refreshToken)return!1;try{const e=await this._client.post(this._refreshUrl,{refreshToken:this._refreshToken},{headers:{"Content-Type":"application/json"}});return!(!e.data||!e.data.accessToken||(this.setToken(e.data.accessToken),e.data.refreshToken&&this.setRefreshToken(e.data.refreshToken),this.emit("refreshSuccess",e.data),0))}catch(e){return this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),!0)}_updateCircuitBreakerError(){this._breakerErrorCount+=1,this._logger.warn(`[ApiClient] Erreur #${this._breakerErrorCount} sur ${this._breakerThreshold}`),this._breakerErrorCount>=this._breakerThreshold&&(this._breakerOpen=!0,this._lastBreakerOpenTime=Date.now(),this._logger.error("[ApiClient] Circuit breaker ACTIVÉ - L'API est considérée indisponible"))}_resetCircuitBreakerSuccess(){this._breakerErrorCount=0,this._breakerOpen&&(this._breakerOpen=!1,this._logger.warn("[ApiClient] Circuit breaker refermé suite à un succès"))}static stripNullsInPlace(e){if(e&&"object"==typeof e&&e.value&&"function"==typeof e.value.pipe)return e;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)null===e[t]||void 0===e[t]?e.splice(t,1):"object"==typeof e[t]&&x.stripNullsInPlace(e[t]);else if(e&&"object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null===e[t]||void 0===e[t]?delete e[t]:"object"==typeof e[t]&&x.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const o={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const o=this._getValueByPath(t,e);return null!=o?o:void 0}},n=/@(?:\{([^}]+)\}|([\w.]+))/g,r=e=>"string"!=typeof e?e:e.replace(n,((t,n,r)=>{if(n){if(n.startsWith("pathParams.")){const e=n.substring(11),t=o.pathParams(e);return null!=t?t:`@{${n}}`}{const e=o[n];if("function"==typeof e){const t=e();return null!=t?t:`@{${n}}`}return`@{${n}}`}}if(r){if(r.startsWith("pathParams.")){const e=r.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],n=e[2],i=o.pathParams(t);return null!=i?i+n:`@${r}`}return`@${r}`}{const e=o[r];if("function"==typeof e){const t=e();return null!=t?t:`@${r}`}return`@${r}`}}return e})),i=e=>{if((e=>e&&"object"==typeof e&&("function"==typeof e.pipe||"undefined"!=typeof Buffer&&e instanceof Buffer))(e))return e;if(Array.isArray(e))return e.map(i);if((e=>"[object Object]"===Object.prototype.toString.call(e))(e)){const t={};for(const[o,n]of Object.entries(e))t[r(o)]=i(n);return t}return"string"==typeof e?r(e):e};return i(e)}_cleanSchemaLeftoverAlias(e){const t=/@\w+/;if(Array.isArray(e))return e.map((e=>this._cleanSchemaLeftoverAlias(e)));if(e&&"object"==typeof e){const o={};for(const n of Object.keys(e)){const r=e[n];if(!t.test(n)){if("default"===n){if("string"==typeof r&&t.test(r))continue;if(r&&"object"==typeof r){const e=this._cleanSchemaLeftoverAlias(r);Object.keys(e).length>0&&(o[n]=e);continue}}"string"==typeof r&&t.test(r)||(o[n]=this._cleanSchemaLeftoverAlias(r))}}return o}return e}async safeCall(e,...t){try{return await e(...t)}catch(e){throw this._logger.error(`[ApiClient.safeCall] Erreur: ${e.message}`),e}}async callEndpoint(e,t={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new l("Le circuit breaker est activé, impossible d'appeler l'API");const r=this._endpoints.find((t=>t.constant===e));if(!r)throw new p(`Endpoint introuvable : ${e}`,404);const{path:i,method:s,contentType:a,auth:m,pathParams:c,request:d,responses:u}=r,y=(s||"GET").toLowerCase(),f=a||"application/json",h={"Content-Type":f};if(this._accessToken)"bearer"===m?h.Authorization=`Bearer ${this._accessToken}`:m&&"none"!==m||h.Authorization||(h.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===m)throw new p(`Token requis pour l'endpoint sécurisé : ${e}`,401);let g,b=i,T={};if(c){let e=c;"none"===m&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(c));const o=t.pathParams||{},n=this._ajv.compile(e);if(!n(o))throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new p("Path parameter validation failed.",400,n.errors);T=this._resolveSpecialValuesInPlace(o),b=b.replace(/\{(\w+)\}/g,((e,t)=>{const o=T[t];if(void 0!==o)return encodeURIComponent(o);throw new p(`Path param manquant ou non résolu : {${t}}`,400)}))}if(d){let e=d;"none"===m&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(d));const o={...t};delete o.pathParams;const n=x.stripNullsInPlace(o),r=this._ajv.compile(e);if(!r(n))throw this.emit("validationError",{stage:"request",errors:r.errors}),new p("Request validation failed.",400,r.errors);t=this._resolveSpecialValuesInPlace(n,T)}"application/json"===f||"multipart/form-data"===f?g=t:"application/x-www-form-urlencoded"===f&&(g=x.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${b}, method=${y}`);try{const e=await this._client.request({url:b,method:y,headers:h,["get"===y?"params":"data"]:g});if(n){const t=e.status.toString(),o=u?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data))throw this.emit("validationError",{stage:"response",errors:n.errors}),new p("Response validation failed.",t,n.errors)}}return this._resetCircuitBreakerSuccess(),"function"==typeof o?e.data=o(e.data):!0===o&&(e.data=this._transformData(e.data)),Array.isArray(r.postActions)&&r.postActions.forEach((t=>{const o=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(o);break;case"setRefreshToken":this.setRefreshToken(o);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,o),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,o));break;case"callMethod":"function"==typeof this[t.method]?(this[t.method](),this._logger.debug(`[ApiClient] Méthode appelée : ${t.method}`)):this._logger.warn(`[ApiClient] Méthode inconnue : ${t.method}`);break;default:this._logger.warn(`[ApiClient] Action inconnue : ${t.type}`)}})),e}catch(t){throw this._updateCircuitBreakerError(),this._logger.error(`[ApiClient] Erreur lors de l'appel de ${e}: ${t.message}`),new p(`Erreur lors de l'appel de l'API : ${t.message}`,t.response?t.response.status:500,t.response?t.response.data:null)}}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),delete this._client.defaults.headers.common.Authorization,this._logger.info("[ApiClient] Session utilisateur réinitialisée."),this.emit("sessionReset")}_getValueByPath(e,t){if(t)return t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,o={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:n=!1,indexes:r=!1,metaTokens:i=!0}=o,s=[];function a(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function m(e){return e.endsWith("[]")?e.slice(0,-2):e}function c(e,t,o=!1){return e?e.concat(t).map(((e,t)=>(e=m(e),!o&&t?`[${e}]`:e))).join(o?".":""):t}function p(e){return null==e?"":e instanceof Date?e.toISOString():(e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||ArrayBuffer.isView(e),e)}return function e(o,l=[]){null==o||s.includes(o)||(s.push(o),Object.entries(o).forEach((([o,s])=>{void 0!==s&&function(e,o,s){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=i?o:o.slice(0,-2),t.append(c(s,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(a)||o.endsWith("[]"))return o=m(o),e.forEach(((e,i)=>{if(null!=e){const a=r?c(s.concat(o),i,n):`${c(s,o,n)}[]`;t.append(a,p(e))}})),!1}return!!a(e)||(t.append(c(s,o,n),p(e)),!1)}(s,o.trim(),l)&&e(s,l.concat(m(o)))})),s.pop())}(e),t}_transformData(e){if(e&&"object"==typeof e)if(e.resultGoods?.msg)e=this._normalizeJsonData({msg:e.resultGoods.msg,...e});else if(e.resultErrors?.msg)e=this._normalizeJsonData({msg:e.resultErrors.msg,...e});else if(e.results&&"object"==typeof e.results&&!Array.isArray(e.results))e.results=Object.keys(e.results).map((t=>this._normalizeJsonData({id:t,...e.results[t]})));else if(Array.isArray(e.results))e.results=e.results.map((e=>this._normalizeJsonData(e)));else if(e.news&&Array.isArray(e.news)&&0===e.news.length)e=e.news;else if(e.news&&"object"==typeof e.news&&!Array.isArray(e.news))e=Object.keys(e.news).map((t=>this._normalizeJsonData({id:t,...e.news[t]})));else if(e.notif&&"object"==typeof e.notif&&!Array.isArray(e.notif))e.notif=Object.keys(e.notif).map((t=>this._normalizeJsonData({id:t,...e.notif[t]})));else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens)&&e.organizations&&"object"==typeof e.organizations&&!Array.isArray(e.organizations))e=[...Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]}))),...Object.keys(e.organizations).map((t=>this._normalizeJsonData({id:t,...e.organizations[t]})))];else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens))e=Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]})));else if(e.cities&&"object"==typeof e.cities&&!Array.isArray(e.cities))e=Object.keys(e.cities).map((t=>this._normalizeJsonData({id:t,...e.cities[t]})));else if(e.cities&&Array.isArray(e.cities)&&0===e.cities.length)e=e.cities;else if(e.newComment&&"object"==typeof e.newComment)e.newComment=this._normalizeJsonData({...e.newComment});else if(Array.isArray(e))e=e.map((e=>this._normalizeJsonData(e)));else if(e.map&&"object"==typeof e.map)e.map=this._normalizeJsonData(e.map);else if(e.object&&"object"==typeof e.object)e.object=this._normalizeJsonData(e.object);else if("object"==typeof e&&Object.keys(e).length>0){const t=Object.keys(e).every((e=>/^[0-9a-fA-F]{24}$/.test(e)));e=t?Object.keys(e).map((t=>({id:t,...this._normalizeJsonData(e[t])}))):this._normalizeJsonData(e)}return e}_normalizeJsonData(e){if(!e||"object"!=typeof e)return e;if(e=this._normalizeRecursively(e),e?.mediaImg?.images&&Array.isArray(e.mediaImg.images)&&e.mediaImg.images.length>0&&(e.mediaImg.countImages=e.mediaImg.images.length),e?.mediaFile?.files&&Array.isArray(e.mediaFile.files)&&e.mediaFile.files.length>0&&(e.mediaFile.countFiles=e.mediaFile.files.length),e?.src?.changes&&"object"==typeof e.src.changes&&Object.keys(e.src.changes).length>0&&Object.keys(e.src.changes).forEach((t=>{e.src.changes[t]&&(e.src.changes[t]=this._ensureFullURL(e.src.changes[t]))})),e?.openingHours&&Array.isArray(e.openingHours)&&e.openingHours.length>0&&(e.openingHours=e.openingHours.filter((e=>e.dayOfWeek&&e.hours&&e.hours[0]&&e.hours[0].opens))),e.replies&&"object"==typeof e.replies&&Object.keys(e.replies).length>0&&(e.replies=Object.keys(e.replies).map((t=>this._normalizeJsonData({id:t,...e.replies[t]})))),e?.author&&"object"==typeof e.author&&Object.keys(e.author).length>0&&!("profilThumbImageUrl"in e.author)){const t=Object.keys(e.author)[0];e.author={...e.author[t]}}return e?.timeAgo&&delete e.timeAgo,this._fromJSONValue?A.default.fromJSONValue(e):e}_ensureFullURL(e){if(!e)return e;if(!(e=e.trim())||/^https?:\/\//i.test(e))return e;let t="/";return t=this._baseURL.endsWith("/")&&e.startsWith("/")||this._baseURL.endsWith("/")||e.startsWith("/")?"":"/",`${this._baseURL}${t}${e}`}_normalizeString(e){return"true"===e||"false"!==e&&e}_normalizeId(e){return e._id&&e._id.$id&&/^[0-9a-fA-F]{24}$/.test(e._id.$id)&&(e.id=e._id.$id,e._id={$type:"oid",$value:e._id.$id}),e.id&&e.id.$id&&/^[0-9a-fA-F]{24}$/.test(e.id.$id)&&(e._id={$type:"oid",$value:e.id.$id},e.id=e.id.$id),e}_normalizeDate(e){return e&&"object"==typeof e&&"number"==typeof e.sec?{$date:1e3*e.sec}:"number"==typeof e?{$date:1e3*e}:e}_normalizeImage(e){return"string"==typeof e&&""!==e.trim()?this._ensureFullURL(e):e}_imageFields=["profilImageUrl","profilThumbImageUrl","profilMediumImageUrl","profilMarkerImageUrl","profilBannerUrl","profilRealBannerUrl","imagePath","imageThumbPath","docPath"];_dateFields=["modified","created","updated","birthDate","lastLoginDate","startDate","endDate","date"];_normalizeRecursively(e){if("string"==typeof e)return this._normalizeString(e);if(Array.isArray(e))return e.map((e=>this._normalizeRecursively(e)));if(null!==e&&"object"==typeof e){const t={};return Object.keys(e).forEach((o=>{let n=this._normalizeRecursively(e[o]);this._dateFields.includes(o)&&(n=this._normalizeDate(n)),this._imageFields.includes(o)&&(n=this._normalizeImage(n)),"content"===o&&n&&"object"==typeof n&&n.image&&(n.image=this._normalizeImage(n.image)),t[o]=n})),this._normalizeId(t)}return e}}class q{constructor(e){this.client=new x(e),this.loggedUser=null}async login(e,t){return this.client.safeCall((async()=>{const o=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new g(this.client,{id:o.data.user.id},o.data.user),this.loggedUser}))}async register({name:e,username:t,email:o,pwd:n}={}){return this.client.safeCall((async()=>{const r=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:o,pwd:n});if(!1===r?.data?.result)throw new d(r.data.msg,r.status,r.data);return r.data}))}async recoverPassword(e){return this.client.safeCall((async()=>{const t=await this.client.callEndpoint("PASSWORD_RECOVERY",{email:e});if(!1===t?.data?.result)throw new d(t.data.msg,t.status,t.data);return t.data}))}}class z{static async userLogin(e,t,o){const n=z.userApi(o);return await z.userApiLogin(n,e,t)}static userApi(e){try{return new q(e)}catch(e){throw console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :",e.message),e}}static async userApiLogin(e,t,o){try{const n=await e.login(t,o);return new z(n,e.client)}catch(e){if(e instanceof p)throw e?.details?.error?new u(e.details.error,e.status,e.details):e}}constructor(e,t){this._loggedUser=e,this._client=t}me(){if(!this._loggedUser)throw new Error("Accès refusé : utilisateur non authentifié.");return this._loggedUser}user(e){try{return new g(this._client,e)}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e,t={getProfile:!0}){try{const o=new f(this._client,e);return t.getProfile&&await o.getProfile(),o}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e,t={getProfile:!0}){try{const o=new h(this._client,e);return t.getProfile&&await o.getProfile(),o}catch(e){throw console.error("[Api.project] Erreur lors de la création d'un objet projet :",e.message),e}}get client(){return this._client}}const C={ApiClient:x,Api:z};var N=m.A;export{N as default};
|
|
1
|
+
import*as e from"stream";import*as t from"file-type";import*as o from"events";import*as n from"@segment/ajv-human-errors";import*as r from"ajv";import*as i from"ajv-formats";import*as s from"axios";import*as a from"axios-retry";import*as c from"ejson";import*as p from"jwt-decode";import*as m from"pino";var d,l,u={702:(t,o,n)=>{var r,i;t.exports=(r={PassThrough:()=>e.PassThrough,Readable:()=>e.Readable},i={},n.d(i,r),i)}},y={};function h(e){var t=y[e];if(void 0!==t)return t.exports;var o=y[e]={exports:{}};return u[e](o,o.exports,h),o.exports}h.m=u,h.d=(e,t)=>{for(var o in t)h.o(t,o)&&!h.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},h.f={},h.e=e=>Promise.all(Object.keys(h.f).reduce(((t,o)=>(h.f[o](e,t),t)),[])),h.u=e=>e+".cocolight-api-client.mjs.js",h.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),h.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d={792:0},l=e=>{var t,o,{__webpack_ids__:n,__webpack_modules__:r,__webpack_runtime__:i}=e,s=0;for(t in r)h.o(r,t)&&(h.m[t]=r[t]);for(i&&i(h);s<n.length;s++)o=n[s],h.o(d,o)&&d[o]&&d[o][0](),d[n[s]]=0},h.f.j=(e,t)=>{var o=h.o(d,e)?d[e]:void 0;if(0!==o)if(o)t.push(o[1]);else{var n=import("./"+h.u(e)).then(l,(t=>{throw 0!==d[e]&&(d[e]=void 0),t}));n=Promise.race([n,new Promise((t=>o=d[e]=[t]))]),t.push(o[1]=n)}};var f={};h.d(f,{A:()=>Y});var g={};h.r(g),h.d(g,{ApiAuthenticationError:()=>P,ApiClientError:()=>T,ApiError:()=>w,ApiResponseError:()=>_,ApiValidationError:()=>b,CircuitBreakerError:()=>E});class w extends Error{constructor(e,t,o){super(e),this.name="ApiError",this.status=t,this.details=o}}class T extends w{constructor(e,t,o){super(e,t,o),this.name="ApiClientError"}}class b extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiValidationError",this.status=t,this.messages=o,this.details=n}}class E extends w{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class _ extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=o,this.details=n}}class P extends w{constructor(e,t,o){super(e,t,o),this.name="ApiAuthenticationError"}}const A=class{constructor(e){this.apiClient=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))}async callNoConnected(e,t={}){if(this.isConnected)throw new P("Vous ne devez pas être connecté pour faire cette action.");return this.call(e,t)}async callIsConnected(e,t={}){if(!this.isConnected)throw new P("Vous devez être connecté pour effectuer cette action.");return this.call(e,t)}async personRegister(e={}){return this.callNoConnected("PERSON_REGISTER",e)}async authenticateUrl(e={}){return this.callNoConnected("AUTHENTICATE_URL",e)}async refreshTokenUrl(e={}){return this.call("REFRESH_TOKEN_URL",e)}async meInfoUrl(e={}){return this.callIsConnected("ME_INFO_URL",e)}async passwordRecovery(e={}){return this.callNoConnected("PASSWORD_RECOVERY",e)}async serverExchangeToken(e={}){return this.callIsConnected("SERVER_EXCHANGE_TOKEN",e)}async changePassword(e={}){return this.callIsConnected("CHANGE_PASSWORD",e)}async deleteAccount(e={}){return this.callIsConnected("DELETE_ACCOUNT",e)}async updateSettings(e={}){return this.callIsConnected("UPDATE_SETTINGS",e)}async updateBlockDescription(e={}){return this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",e)}async updateBlockInfo(e={}){return this.callIsConnected("UPDATE_BLOCK_INFO",e)}async updateBlockSocial(e={}){return this.callIsConnected("UPDATE_BLOCK_SOCIAL",e)}async updateBlockLocality(e={}){return this.callIsConnected("UPDATE_BLOCK_LOCALITY",e)}async updateBlockSlug(e={}){return this.callIsConnected("UPDATE_BLOCK_SLUG",e)}async check(e={}){return this.callIsConnected("CHECK",e)}async profilImage(e={}){return this.callIsConnected("PROFIL_IMAGE",e)}async getElementsAbout(e={}){return this.call("GET_ELEMENTS_ABOUT",e)}async multiconnect(e={}){return this.callIsConnected("MULTICONNECT",e)}async getNews(e={}){return this.call("GET_NEWS",e)}async getNewsById(e={}){return this.call("GET_NEWS_BY_ID",e)}async addNews(e={}){return this.callIsConnected("ADD_NEWS",e)}async addImageNews(e={}){return this.callIsConnected("ADD_IMAGE_NEWS",e)}async addFileNews(e={}){return this.callIsConnected("ADD_FILE_NEWS",e)}async deleteNews(e={}){return this.callIsConnected("DELETE_NEWS",e)}async updateNews(e={}){return this.callIsConnected("UPDATE_NEWS",e)}async shareNews(e={}){return this.callIsConnected("SHARE_NEWS",e)}async getComments(e={}){return this.call("GET_COMMENTS",e)}async addComments(e={}){return this.callIsConnected("ADD_COMMENTS",e)}async deleteComments(e={}){return this.callIsConnected("DELETE_COMMENTS",e)}async updateComments(e={}){return this.callIsConnected("UPDATE_COMMENTS",e)}async searchTags(e={}){return this.call("SEARCH_TAGS",e)}async showVote(e={}){return this.call("SHOW_VOTE",e)}async globalAutocomplete(e={}){return this.call("GLOBAL_AUTOCOMPLETE",e)}async cityAutocomplete(e={}){return this.call("CITY_AUTOCOMPLETE",e)}async suggestionInput(e={}){return this.call("SUGGESTION_INPUT",e)}async getProjectsNoAdmin(e={}){return this.call("GET_PROJECTS_NO_ADMIN",e)}async getProjectsAdmin(e={}){return this.callIsConnected("GET_PROJECTS_ADMIN",e)}async getPoisNoAdmin(e={}){return this.call("GET_POIS_NO_ADMIN",e)}async getPoisAdmin(e={}){return this.callIsConnected("GET_POIS_ADMIN",e)}async getOrganizationsNoAdmin(e={}){return this.call("GET_ORGANIZATIONS_NO_ADMIN",e)}async getOrganizationsAdmin(e={}){return this.callIsConnected("GET_ORGANIZATIONS_ADMIN",e)}async getMembersNoAdmin(e={}){return this.call("GET_MEMBERS_NO_ADMIN",e)}async getMembersAdmin(e={}){return this.callIsConnected("GET_MEMBERS_ADMIN",e)}async getFriendsAdmin(e={}){return this.callIsConnected("GET_FRIENDS_ADMIN",e)}async getSubscriptions(e={}){return this.call("GET_SUBSCRIPTIONS",e)}async getSubscriptionsAdmin(e={}){return this.callIsConnected("GET_SUBSCRIPTIONS_ADMIN",e)}async getSubscribers(e={}){return this.call("GET_SUBSCRIBERS",e)}async getSubscribersAdmin(e={}){return this.callIsConnected("GET_SUBSCRIBERS_ADMIN",e)}async getContributors(e={}){return this.call("GET_CONTRIBUTORS",e)}async getContributorsAdmin(e={}){return this.callIsConnected("GET_CONTRIBUTORS_ADMIN",e)}async getBadges(e={}){return this.call("GET_BADGES",e)}async getBadgesFilters(e={}){return this.call("GET_BADGES_FILTERS",e)}async connect(e={}){return this.callIsConnected("CONNECT",e)}async disconnect(e={}){return this.callIsConnected("DISCONNECT",e)}async getElementsKey(e={}){return this.call("GET_ELEMENTS_KEY",e)}async getFavoris(e={}){return this.callIsConnected("GET_FAVORIS",e)}async deleteFavoris(e={}){return this.callIsConnected("DELETE_FAVORIS",e)}async addFavoris(e={}){return this.callIsConnected("ADD_FAVORIS",e)}async addOrganization(e={}){return this.callIsConnected("ADD_ORGANIZATION",e)}async addProject(e={}){return this.callIsConnected("ADD_PROJECT",e)}async addPoi(e={}){return this.callIsConnected("ADD_POI",e)}async addEvent(e={}){return this.callIsConnected("ADD_EVENT",e)}async deletePoi(e={}){return this.callIsConnected("DELETE_POI",e)}async deleteEvent(e={}){return this.callIsConnected("DELETE_EVENT",e)}async deleteElement(e={}){return this.callIsConnected("DELETE_ELEMENT",e)}async addImageElement(e={}){return this.callIsConnected("ADD_IMAGE_ELEMENT",e)}},I={},O=(S={fileTypeFromBuffer:()=>t.fileTypeFromBuffer},j={},h.d(j,S),j),v={async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))},async callNoConnected(e,t={}){if(this.isConnected)throw new P("Vous devez ne devez pas être connecté pour faire cette action.");return this.call(e,t)},async callIsConnected(e,t={}){if(!this.isConnected)throw new P("Vous devez être connecté pour faire cette action.");return"function"==typeof e?await e():this.call(e,t)},async callIsMe(e,t={}){if(!this.isMe)throw new P("Vous devez être vous-même pour faire cette action.");return"function"==typeof e?await e():await this.callIsConnected(e,t)},async validateImage(e){return await this._validateUploadInput(e,{allowedMimeTypes:["image/jpeg","image/png","image/jpg"],expectedType:"image"})},async validateFile(e){return await this._validateUploadInput(e,{allowedMimeTypes:["application/pdf","text/plain","text/csv"],expectedType:"file"})},async _validateUploadInput(e,{allowedMimeTypes:t=[],expectedType:o="any"}){if(!e)throw new b("Le fichier est requis.");const n="undefined"==typeof window&&"undefined"!=typeof process;let r="",i=e;if("undefined"!=typeof File&&e instanceof File){if(r=e.type,!t.includes(r))throw new b("Le type du fichier est invalide.")}else if("undefined"!=typeof Blob&&e instanceof Blob){if(r=e.type,!t.includes(r))throw new b("Le type du fichier est invalide.");const o=r.split("/")[1]||"bin",n=`${Date.now()}.${o}`;i=new File([e],n,{type:r})}else if(n&&Buffer.isBuffer(e)){const n=await(0,O.fileTypeFromBuffer)(e);if(r=n?.mime,!n||!t.includes(r))throw new b("Le type du fichier est invalide.");if("image"===o){const t=n.ext,o=`${Date.now()}.${t}`;i=await this._createReadStreamFromBuffer(e,o,r)}}else{if(!n||!e?.readable||"function"!=typeof e._read)throw new b("Type de fichier non reconnu.");{const o=[],n=await this._passThrough(),s=await this._passThrough(),a=4100;let c=0;e.on("data",(e=>{c<a&&(o.push(e),c+=e.length)})),e.pipe(n).pipe(s),await new Promise((e=>setTimeout(e,10)));const p=Buffer.concat(o),m=await(0,O.fileTypeFromBuffer)(p);if(r=m?.mime,!m||!t.includes(r))throw new b("Le type du fichier est invalide.");s.path=`${Date.now()}.${m.ext}`,s.mimeType=r,i=s}}return i},async _createReadStreamFromBuffer(e,t="file.bin",o="application/octet-stream"){const n=await this._bufferToReadable(e);return n.path=t,n.mimeType=o,n},async _bufferToReadable(e){if("undefined"==typeof window){const{bufferToReadable:t}=await h.e(22).then(h.bind(h,22));return t(e)}throw new Error("bufferToReadable ne doit pas être appelé dans le navigateur")},async _passThrough(){if("undefined"==typeof window){const{createPassThrough:e}=await h.e(22).then(h.bind(h,22));return e()}throw new Error("passThrough ne doit pas être appelé dans le navigateur")},_omitProps(e,t){if(!e||"object"!=typeof e)return{};const o={...e};for(const e of t)delete o[e];return o},_pickProps(e,t,o={}){if(!e||"object"!=typeof e)return{};const n={};for(const r of t)if(r in e){const t=e[r];"function"==typeof o[r]?n[r]=o[r](t,e):n[r]=t}return n},_createFilteredProxy:e=>new Proxy(e,{get:(e,t,o)=>"string"!=typeof t||isNaN(t)?"length"===t?e.filter((e=>!e._isDeleted)).length:"function"==typeof e[t]?(...o)=>e.filter((e=>!e._isDeleted))[t](...o):Reflect.get(e,t,o):e.filter((e=>!e._isDeleted))[t]})};var S,j;class C{#e={};#t=null;constructor(e,t={},o={}){if(!o.EndpointApi)throw new w("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new w("User class must be injected to avoid circular dependency.");if(!e)throw new w("Parent is required.");if(this.deps=o,this.UserClass=o.User,this.apiClient=e.apiClient,"function"==typeof o.EndpointApi)this.endpointApi=new o.EndpointApi(this.apiClient);else{if("object"!=typeof o.EndpointApi)throw new w("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=o.EndpointApi}this.#e={...t},this.parent=e}get id(){return this.#e.id||null}get isConnected(){return this.apiClient.isConnected}get draftData(){return this.#e}get serverData(){return this.#t}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.parent.id}getEntityType(){return"news"}static fromServerData(e,t,o){const n=new C(t,{id:e.id},o);return n.#t={...e},n.#e=n._getDraftFromServerData(e),n}async refresh(){if(!this.id)throw new w("Impossible de rafraîchir sans ID.");return this.get()}async get(){if(!this.id)throw new w("Vous devez fournir un id pour récupérer une news.");const e=await this.callIsConnected((()=>this.endpointApi.getNewsById({ids:[this.id]})));if(e&&e.length>0)return this.#t=e[0],this.#e=this._getDraftFromServerData(this.#t),this.#t;throw new w(`Aucune actualité trouvée pour l'ID ${this.id}`)}_getDraftFromServerData(e){const t=this._pickProps(e,["scope","text","tags","mentions","mediaImg","mediaFile"],{scope:e=>e?.type,mentions:e=>Array.isArray(e)?e.map((e=>({...e,count:parseInt(e.count)}))):[],mediaImg:e=>{const t=e?.images?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countImages:parseInt(e.countImages)||t.length,images:t}:void 0},mediaFile:e=>{const t=e?.files?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countFiles:parseInt(e.countFiles)||t.length,files:t}:void 0}});return{id:e.id,...Object.fromEntries(Object.entries(t).filter((([,e])=>void 0!==e)))}}async save(){""===this.#e?.text&&(this.#e.text=" ");const e={...this.#e};if(e.parentId=this.parent.id,e.parentType=this.parent.getEntityType(),this.id){e.id&&delete e.id;const t=await this.callIsConnected((()=>this.endpointApi.updateNews({...e,idNews:this.id})));return t?.object&&(this.#t={...t.object}),t}{const t=await this.callIsConnected((()=>this.endpointApi.addNews(e)));return this.#e.id=t.object.id,t?.object&&(this.#t={...t.object}),t}}async addMention({slug:e,id:t}){try{if(!e&&!t)throw new w("Vous devez fournir un slug ou un id pour ajouter une mention.");const o=new this.UserClass(this.apiClient,{id:t,slug:e},null,{EndpointApi:this.endpointApi}),n=await o.getProfil();if(this.#e.mentions||(this.#e.mentions=[]),this.#e.mentions.find((e=>e.id===n.id)))return this.#e.mentions=this.#e.mentions.map((e=>(e.id===n.id&&(e.count+=1),e))),this.#e.mentions;const r={id:n.id,slug:n.slug,type:o.getEntityType(),name:n.name,value:n.name,count:1};return this.#e.mentions.push(r),this.#e.mentions}catch(e){throw this.apiClient._logger.error("Erreur lors de l'ajout de la mention :",e),e}}async addImage(e){e=await this.validateImage(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsImage:e},o=await this.callIsConnected((()=>this.endpointApi.addImageNews(t)));return this.#e.mediaImg?(this.#e.mediaImg.countImages=this.#e.mediaImg.countImages+1,this.#e.mediaImg.images.push(o.id)):this.#e.mediaImg={countImages:1,images:[o.id]},o}async addFile(e){e=await this.validateFile(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsFile:e},o=await this.callIsConnected((()=>this.endpointApi.addFileNews(t)));return this.#e.mediaFile?(this.#e.mediaFile.countFiles=this.#e.mediaFile.countFiles+1,this.#e.mediaFile.files.push(o)):this.#e.mediaFile={countFiles:1,files:[o]},o}async delete(){if(!this.id)throw new w("Vous devez fournir un id pour supprimer une news.");const e={pathParams:{id:this.id}};await this.callIsConnected((()=>this.endpointApi.deleteNews(e))),this.#e={},this.#t=null,this.#e.id=null,this._isDeleted=!0}}Object.assign(C.prototype,v,I);const k={async resolveId(e){if(!this.id&&this.slug)try{const t=await this.endpointApi.getElementsKey({pathParams:{slug:this.slug}});if(!t?.contextId||t?.contextType!==e)throw new _(`Le slug ${this.slug} ne correspond pas à un ${e}`,200,t);this._id(t.contextId)}catch(t){throw t instanceof _?t?.responseData?.contextType!==e?t:new _(`Impossible de récupérer l'identifiant pour le slug ${this.slug}`,t.status,t.responseData):t}return this.id},async getPublicProfile(){return await this.resolveId(this.getEntityType()),this.endpointApi.getElementsAbout({pathParams:{id:this.id,type:this.getEntityType()}})}};class D{#o;#n;#r;constructor(e,{id:t,slug:o}={},n={},r={}){if(!r.EndpointApi)throw new Error("EndpointApi class must be injected to avoid circular dependency.");if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");if(this.apiClient=e,this.deps=r,"function"==typeof r.EndpointApi)this.endpointApi=new r.EndpointApi(this.apiClient);else{if("object"!=typeof r.EndpointApi)throw new Error("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=r.EndpointApi}this.#o=t||null,this.#n=o||null,this.#r=n}get id(){return this.#o}_id(e){this.#o=e}get slug(){return this.#n}_slug(e){this.#n=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#r}_setData(e){this.#r=e}getEntityType(){return"citoyens"}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}async getProfil(){return this.apiClient.safeCall((async()=>this.isMe?await this.endpointApi.meInfoUrl():await this.getPublicProfile()))}async changePassword(e={}){return this.callIsMe((()=>this.endpointApi.changePassword(e)))}async delete(e={}){return this.callIsMe((()=>this.endpointApi.deleteAccount(e)))}async updateSettings(e={}){return this.callIsMe((()=>this.endpointApi.updateSettings(e)))}async updateDescription(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug(e){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof _)throw new _("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsMe((()=>this.endpointApi.updateBlockSlug({slug:e})))}async updateImageProfil(e){return e=await this.validateImage(e),this.callIsMe((()=>this.endpointApi.profilImage({profil_avatar:e})))}async getNews(e={}){e.pathParams&&delete e.pathParams,this.isMe||(e.pathParams={id:this.id});const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new _("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>C.fromServerData(e,this,{User:D,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e={}){try{const t=new C(this,e,{User:D,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw console.error("[Api.user.news] Erreur lors de la création d'une instance news :",e.message),e}}}Object.assign(D.prototype,k,v,{},I);class x{#o;#n;#r=null;constructor(e,{id:t,slug:o}={},n={}){if(!n.EndpointApi)throw new Error("EndpointApi class must be injected to avoid circular dependency.");if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer une instance User.");if(this.apiClient=e,this.deps=n,"function"==typeof n.EndpointApi)this.endpointApi=new n.EndpointApi(this.apiClient);else{if("object"!=typeof n.EndpointApi)throw new Error("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=n.EndpointApi}this.#o=t||null,this.#n=o||null}get id(){return this.#o}_id(e){this.#o=e}get slug(){return this.#n}_slug(e){this.#n=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#r}_setData(e){this.#r=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"organizations"}async getProfil(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e),e}))}async updateSettings(e={}){return e.idEntity=this.id,e.typeEntity=this.getEntityType(),this.callIsConnected((()=>this.endpointApi.updateSettings(e)))}async updateDescription(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug(e){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof _)throw new _("Erreur lors de la vérification du slug.",e.status,e.data);throw e}const t={typeElement:this.getEntityType(),id:this.id,slug:e};return this.callIsConnected((()=>this.endpointApi.updateBlockSlug(t)))}async updateImageProfil(e){e=await this.validateImage(e);const t={pathParams:{folder:this.getEntityType(),ownerId:this.id},profil_avatar:e};return this.callIsConnected((()=>this.endpointApi.profilImage(t)))}async getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new _("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>C.fromServerData(e,this,{User:D,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e){try{const t=new C(this,e,{User:D,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw console.error("[Api.project.news] Erreur lors de la création d'une instance news :",e.message),e}}}Object.assign(x.prototype,k,v,I);class ${#o;#n;#r=null;constructor(e,{id:t,slug:o}={},n={}){if(!n.EndpointApi)throw new Error("EndpointApi class must be injected to avoid circular dependency.");if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");if(this.apiClient=e,this.deps=n,"function"==typeof n.EndpointApi)this.endpointApi=new n.EndpointApi(this.apiClient);else{if("object"!=typeof n.EndpointApi)throw new Error("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=n.EndpointApi}this.#o=t||null,this.#n=o||null}get id(){return this.#o}_id(e){this.#o=e}get slug(){return this.#n}_slug(e){this.#n=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#r}_setData(e){this.#r=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"projects"}async getProfil(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e),e}))}async updateSettings(e={}){return e.idEntity=this.id,e.typeEntity=this.getEntityType(),this.callIsConnected((()=>this.endpointApi.updateSettings(e)))}async updateDescription(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug(e){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof _)throw new _("Erreur lors de la vérification du slug.",e.status,e.data);throw e}const t={typeElement:this.getEntityType(),id:this.id,slug:e};return this.callIsConnected((()=>this.endpointApi.updateBlockSlug(t)))}async updateImageProfil(e){e=await this.validateImage(e);const t={pathParams:{folder:this.getEntityType(),ownerId:this.id},profil_avatar:e};return this.callIsConnected((()=>this.endpointApi.profilImage(t)))}async getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new _("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>C.fromServerData(e,this,{User:D,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e){try{const t=new C(this,e,{User:D,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw console.error("[Api.project.news] Erreur lors de la création d'une instance news :",e.message),e}}}Object.assign($.prototype,k,v,I);const q=(e=>{var t={};return h.d(t,e),t})({EventEmitter:()=>o.EventEmitter}),N=(e=>{var t={};return h.d(t,e),t})({AggregateAjvError:()=>n.AggregateAjvError}),z=(e=>{var t={};return h.d(t,e),t})({default:()=>r.default}),L=(e=>{var t={};return h.d(t,e),t})({default:()=>i.default}),M=(e=>{var t={};return h.d(t,e),t})({default:()=>s.default}),B=(e=>{var t={};return h.d(t,e),t})({default:()=>a.default}),G=(e=>{var t={};return h.d(t,e),t})({default:()=>c.default}),R=(e=>{var t={};return h.d(t,e),t})({jwtDecode:()=>p.jwtDecode}),U=(e=>{var t={};return h.d(t,e),t})({default:()=>m.default}),F={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!F._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof F.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new F.ObjectID(this._str)}typeName(){return"oid"}getTimestamp(){return Number.parseInt(this._str.substr(0,8),16)}valueOf(){return this._str}toJSONValue(){return this.valueOf()}toHexString(){return this.valueOf()}}},Z=F,V={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{format:"uri",type:"string"},common5:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common6:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common7:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common8:{additionalProperties:!1,properties:{reason:{default:"",type:"string"}},required:["reason"],type:"object"},common9:{reason:{default:"",type:"string"}},common10:{default:"",type:"string"},common11:{pattern:"^[a-f0-9]{24}$",type:"string"},common12:{const:"citoyens"},common13:{properties:{value:{type:"boolean"}}},common14:{value:{type:"boolean"}},common15:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common16:{},common17:{else:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}}},common18:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},common19:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common20:{properties:{typeElement:{const:"citoyens"}}},common21:{typeElement:{const:"citoyens"}},common22:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}},common23:{not:{type:"null"}},common24:{type:"null"},common25:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common26:{items:{type:"string"},type:"array"},common27:{enum:[""],type:"string"},common28:{properties:{name:{not:{type:"null"}}},required:["name"]},common29:{name:{not:{type:"null"}}},common30:{properties:{url:{not:{type:"null"}}},required:["url"]},common31:{url:{not:{type:"null"}}},common32:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common33:{tags:{not:{type:"null"}}},common34:{properties:{email:{not:{type:"null"}}},required:["email"]},common35:{email:{not:{type:"null"}}},common36:{const:"info",default:"info",type:"string"},common37:{$ref:"#/$defs/sharedFields/email"},common38:{$ref:"#/$defs/sharedFields/name"},common39:{$ref:"#/$defs/sharedFields/tags"},common40:{$ref:"#/$defs/sharedFields/url"},common41:{const:"projects"},common42:{name:{type:"string"},type:{type:"string"}},common43:{const:"organizations"},common44:{$ref:"#/$defs/socialField"},common45:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common46:{id:{pattern:"^[a-f0-9]{24}$"}},common47:{pattern:"^[a-f0-9]{24}$"},common48:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},common49:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},common50:{const:"PostalAddress",type:"string"},common51:{minLength:0,type:"string"},common52:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},required:["latitude","longitude"],type:"object"},common53:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},common54:{const:"GeoCoordinates",type:"string"},common55:{type:["string","number"]},common56:{additionalProperties:!0,properties:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},common57:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},common58:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},common59:{type:"number"},common60:{const:!0,default:!0,type:"boolean"},common61:{const:"Point",type:"string"},common62:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common63:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common64:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"},common65:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common66:{properties:{type:{const:"citoyens"}}},common67:{type:{const:"citoyens"}},common68:{additionalProperties:!1,else:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{folder:{const:"citoyens"}}},properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],then:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common69:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common70:{ownerId:{pattern:"^[a-f0-9]{24}$"}},common71:{properties:{folder:{const:"citoyens"}}},common72:{folder:{const:"citoyens"}},common73:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common74:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common75:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common76:{additionalProperties:!1,else:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{type:{const:"citoyens"}}},properties:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common77:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common78:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common79:{parentId:{pattern:"^[a-f0-9]{24}$"}},common80:{properties:{parentType:{const:"citoyens"}}},common81:{parentType:{const:"citoyens"}},common82:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common83:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common84:{default:!0,type:"boolean"},common85:{required:["text"]},common86:{required:["mediaImg"]},common87:{required:["mediaFile"]},common88:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common89:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common90:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common91:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common92:{items:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common93:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common94:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common95:{minimum:1,type:"integer"},common96:{default:"public",enum:["public","private","restricted"],type:"string"},common97:{const:"news",default:"news",type:"string"},common98:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common99:{default:!1,type:"boolean"},common100:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common101:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},common102:{default:"news",enum:["news"],type:"string"},common103:{items:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common104:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common105:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common106:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common107:{const:!1,default:!1,type:"boolean"},common108:{const:"",default:"",type:"string"},common109:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common110:{indexMax:{type:"number"},indexMin:{type:"number"}},common111:{default:0,minimum:0,type:"integer"},common112:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common113:{enum:["projects"],type:"string"},common114:{$exists:!0},common115:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common116:{$exists:{const:!0}},common117:{const:!0},common118:{default:30,type:"integer"},common119:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common120:{enum:["poi"],type:"string"},common121:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common122:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common123:{$exists:!1},common124:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common125:{$exists:{const:!1}},common126:{const:!1},common127:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common128:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common129:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common130:{$exists:{default:!1,type:"boolean"}},common131:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common132:{$in:{items:{type:"string"},minItems:1,type:"array"}},common133:{items:{type:"string"},minItems:1,type:"array"},common134:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common135:{enum:["citoyens"],type:"string"},common136:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},type:"array"},common137:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common138:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common139:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common140:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common141:{"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"}},common142:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common143:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common144:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common145:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common146:{enum:["badges"],type:"string"},common147:{const:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common148:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common149:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common150:{$exists:{const:!0,type:"boolean"}},common151:{const:!0,type:"boolean"},common152:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common153:{$exists:{const:!1,type:"boolean"}},common154:{const:!1,type:"boolean"},common155:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"}},common156:{indexMax:30,indexMin:0},common157:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common158:{properties:{connectType:{const:"friend",default:"friend"}}},common159:{connectType:{const:"friend",default:"friend"}},common160:{const:"friend",default:"friend"},common161:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common162:{properties:{parentType:{const:"organizations"}}},common163:{parentType:{const:"organizations"}},common164:{properties:{connectType:{enum:["admin","member"]}}},common165:{connectType:{enum:["admin","member"]}},common166:{enum:["admin","member"]},common167:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common168:{properties:{parentType:{const:"projects"}}},common169:{parentType:{const:"projects"}},common170:{properties:{connectType:{enum:["admin","contributor"]}}},common171:{connectType:{enum:["admin","contributor"]}},common172:{enum:["admin","contributor"]},common173:{properties:{parentType:{const:"events"}}},common174:{parentType:{const:"events"}},common175:{const:"events"},common176:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common177:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common178:{enum:["citoyens","organizations","projects","events"],type:"string"},common179:{const:"citoyens",default:"citoyens",type:"string"},common180:{const:"@userId",default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common181:{additionalProperties:!1,default:{"@userId":{type:"citoyens"}},patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},type:"object"},common182:{"@userId":{type:"citoyens"}},common183:{type:"citoyens"},common184:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},common185:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"},common186:{const:"poi",default:"poi",type:"string"},common187:{format:"date-time",type:"string"},common188:{pattern:"^([01]\\d|2[0-3]):[0-5]\\d$",type:"string"}},K=[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:V.common1,email:V.common2,isInvitation:V.common3,mode:V.common1,name:V.common1,pendingUserId:V.common1,pwd:V.common1,username:V.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",path:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:V.common2,password:V.common1},required:["email","password"],type:"object"}},{auth:"none",constant:"REFRESH_TOKEN_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/refreshtoken",request:{additionalProperties:!1,properties:{refreshToken:V.common1},required:["refreshToken"],type:"object"}},{auth:"bearer",constant:"ME_INFO_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/me"},{auth:"none",constant:"PASSWORD_RECOVERY",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:V.common2,type:{const:"password",default:"password",type:"string"}},required:["email","type"],type:"object"}},{auth:"bearer",constant:"SERVER_EXCHANGE_TOKEN",contentType:"application/json",method:"POST",path:"/api/cocolight/exchangetoken",request:{additionalProperties:!1,properties:{serverUrl:V.common4},required:["serverUrl"],type:"object"}},{auth:"bearer",constant:"CHANGE_PASSWORD",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/changepassword",request:{additionalProperties:!1,properties:{mode:{const:"changePassword",default:"changePassword",type:"string"},newPassword:V.common1,newPassword2:V.common1,oldPassword:V.common1,scope:{default:"",type:["string"]},userId:V.common5},required:["mode","userId","oldPassword","newPassword","newPassword2"],type:"object"}},{auth:"bearer",constant:"DELETE_ACCOUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/id/{id}/type/citoyens",pathParams:V.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:V.common8},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:V.common11}},if:{properties:{typeEntity:V.common12}},then:{properties:{idEntity:V.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:V.common12}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:V.common12}},then:V.common13},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:V.common12}}},then:V.common13}],properties:{idEntity:V.common1,type:V.common1,typeEntity:V.common15,value:V.common16},required:["type","value","typeEntity","idEntity"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_DESCRIPTION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{additionalProperties:!1,allOf:[V.common17,{anyOf:[{properties:{description:V.common23},required:["description"]},{properties:{shortDescription:V.common23},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:V.common10,description:V.common1,id:V.common1,scope:{default:"",type:["string","null"]},shortDescription:V.common1,typeElement:V.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_INFO",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{sharedFields:{email:V.common2,name:V.common1,tags:V.common25,url:V.common4}},allOf:[{if:V.common20,then:{additionalProperties:!1,anyOf:[V.common28,{properties:{birthDate:V.common23},required:["birthDate"]},{properties:{fixe:V.common23},required:["fixe"]},{properties:{mobile:V.common23},required:["mobile"]},V.common30,V.common32,V.common34],properties:{birthDate:{format:"date",type:"string"},block:V.common36,email:V.common37,fixe:V.common1,id:V.common5,mobile:V.common1,name:V.common38,scope:V.common10,tags:V.common39,typeElement:V.common15,url:V.common40}}},{if:{properties:{typeElement:V.common41}},then:{additionalProperties:!1,anyOf:[V.common28,V.common30,V.common32,V.common34,{properties:{avancement:V.common23},required:["avancement"]},{properties:{parent:V.common23},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:V.common36,email:V.common37,id:V.common1,name:V.common38,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":{additionalProperties:!1,properties:V.common42,required:["type","name"],type:"object"}},type:"object"},scope:V.common10,tags:V.common39,typeElement:V.common15,url:V.common40}}},{if:{properties:{typeElement:V.common43}},then:{additionalProperties:!1,anyOf:[V.common28,V.common30,V.common32,V.common34,{properties:{type:V.common23},required:["type"]}],properties:{block:V.common36,email:V.common37,id:V.common1,name:V.common38,scope:V.common10,tags:V.common39,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:V.common15,url:V.common40}}}],properties:{block:V.common36,id:V.common1,scope:V.common10,typeElement:V.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SOCIAL",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{socialField:{anyOf:[V.common27,V.common4]}},allOf:[V.common17,{anyOf:[{properties:{gitlab:V.common23},required:["gitlab"]},{properties:{github:V.common23},required:["github"]},{properties:{twitter:V.common23},required:["twitter"]},{properties:{facebook:V.common23},required:["facebook"]},{properties:{instagram:V.common23},required:["instagram"]},{properties:{diaspora:V.common23},required:["diaspora"]},{properties:{mastodon:V.common23},required:["mastodon"]},{properties:{telegram:V.common23},required:["telegram"]},{properties:{signal:V.common23},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:V.common44,facebook:V.common44,github:V.common44,gitlab:V.common44,id:V.common1,instagram:V.common44,mastodon:V.common44,scope:V.common10,signal:V.common44,telegram:V.common44,twitter:V.common44,typeElement:V.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_LOCALITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:V.common45,if:V.common20,properties:{address:V.common48,block:{const:"localities",default:"localities",type:"string"},geo:V.common52,geoPosition:V.common56,id:V.common1,scope:V.common10,typeElement:V.common15},required:["block","typeElement","id","address"],then:V.common62,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:V.common45,if:V.common20,properties:{block:V.common36,id:V.common1,scope:V.common10,slug:V.common65,typeElement:V.common15},required:["block","typeElement","id","slug"],then:V.common62,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:V.common45,if:V.common66,properties:{block:V.common36,id:V.common1,slug:V.common65,type:V.common15},required:["block","type","id","slug"],then:V.common62,type:"object"}},{auth:"bearer",constant:"PROFIL_IMAGE",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/profil_avatar/contentKey/profil/docType/image",pathParams:V.common68,request:{additionalProperties:!1,properties:{profil_avatar:V.common16},required:["profil_avatar"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_ABOUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/about/type/{type}/id/{id}/json/true",pathParams:V.common76,request:{additionalProperties:!1,properties:{tpl:{const:"ficheInfoElement",default:"ficheInfoElement",type:"string"}},required:["tpl"],type:"object"}},{auth:"bearer",constant:"MULTICONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:V.common78,if:V.common80,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:V.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:V.common1,parentType:V.common15},required:["parentId","parentType","listInvite"],then:V.common82,type:"object"}},{auth:"none",constant:"GET_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/get/type/{type}/id/{id}/isLive/{isLive}/json/true",pathParams:{additionalProperties:!1,else:V.common45,if:V.common66,properties:{id:V.common1,isLive:V.common84,type:V.common15},required:["isLive","type","id"],then:V.common62,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:{default:0,type:"integer"},indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:V.common10},required:["name"],type:"object"}},required:["dateLimit","indexStep"],type:"object"}},{auth:"none",constant:"GET_NEWS_BY_ID",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/getbyids",request:{additionalProperties:!1,properties:{ids:{items:V.common11,type:"array"}},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,anyOf:[V.common85,V.common86,V.common87],else:V.common78,if:V.common80,properties:{json:V.common60,markdownActive:V.common84,mediaFile:V.common88,mediaImg:V.common90,mentions:V.common92,parentId:V.common1,parentType:V.common15,scope:V.common96,tags:V.common25,text:V.common1,type:V.common97},required:["scope","markdownActive","parentId","parentType","type","json"],then:V.common82,type:"object"}},{auth:"bearer",constant:"ADD_IMAGE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/newsImage/docType/image/contentKey/slider",pathParams:V.common68,request:{additionalProperties:!1,properties:{newsImage:V.common16},required:["newsImage"],type:"object"}},{auth:"bearer",constant:"ADD_FILE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}}/input/newsFile/docType/file",pathParams:V.common68,request:{additionalProperties:!1,properties:{newsFile:V.common16},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:V.common98,request:{additionalProperties:!1,properties:{isLive:V.common99},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,anyOf:[V.common85,V.common86,V.common87],else:V.common78,if:V.common80,properties:{idNews:V.common11,markdownActive:V.common84,mediaFile:V.common88,mediaImg:V.common90,mentions:V.common92,parentId:V.common1,parentType:V.common15,scope:V.common96,tags:V.common25,text:V.common1,type:V.common97},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:V.common82,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:{properties:{childId:V.common47}},if:{properties:{childType:V.common12}},properties:{childId:V.common11,childType:V.common15,comment:V.common1,connectType:{const:"share",default:"share",type:"string"},parentId:V.common11,parentType:V.common97},required:["parentId","parentType","childId","childType","connectType"],then:{properties:{childId:V.common64}},type:"object"}},{auth:"none",constant:"GET_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/index/type/{type}/id/{id}/json/true",pathParams:V.common100},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:V.common10,contextId:V.common11,contextType:V.common102,mentions:V.common103,parentCommentId:V.common11,path:V.common10,text:V.common1},required:["text","contextId","contextType"],type:"object"}},{auth:"bearer",constant:"DELETE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/delete/id/{id}",pathParams:V.common98},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:V.common11,params:{properties:{mentions:V.common103,text:V.common1},required:["text"],type:"object"}},required:["id","params"],type:"object"}},{auth:"none",constant:"SEARCH_TAGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/tags/search?q={q}",pathParams:{additionalProperties:!1,properties:{q:V.common1},required:["q"],type:"object"}},{auth:"none",constant:"SHOW_VOTE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/action/list/type/{type}/id/{id}/actionType/vote/json/true",pathParams:V.common100},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:V.common106,type:"array"},fediverse:V.common107,filters:V.common108,indexMin:{const:0,default:0,type:"number"},indexStep:V.common59,initType:V.common108,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:V.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:V.common1,notSourceKey:V.common60,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":V.common109},type:"object"},searchTags:V.common26,searchType:{items:V.common106,type:"array"}},required:["name","searchType","countType","indexMin","indexStep","initType","count","notSourceKey","filters","fediverse"],type:"object"}},{auth:"none",constant:"CITY_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{minimum:5,type:"integer"},indexMin:{minimum:0,type:"integer"},locality:V.common108,name:V.common1,searchBy:{const:"ALL",default:"ALL",type:"string"},searchType:{const:["cities"],default:["cities"],items:{enum:["cities"],type:"string"},type:"array"}},required:["name","locality","searchType"],type:"object"}},{auth:"none",constant:"SUGGESTION_INPUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{default:20,minimum:20,type:"integer"},indexMin:V.common111,name:V.common1,searchType:{items:{enum:["organizations","projects","poi"],type:"string"},type:"array"}},required:["name","searchType","indexMin","indexMax"],type:"object"}},{auth:"none",constant:"GET_PROJECTS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common112,fediverse:V.common107,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":V.common114,"parent.@userId":V.common114},"links.contributors.@userId":V.common114},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},type:"object"}},required:["$or"],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common112},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_PROJECTS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:V.common76,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common112,fediverse:V.common107,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":V.common114,"parent.@{pathParams.id}":V.common114},"links.contributors.@{pathParams.id}":V.common114},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},type:"object"}},required:["$or"],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common112},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_POIS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common119,fediverse:V.common107,filters:{additionalProperties:!1,default:{"parent.@userId":V.common114},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common119},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_POIS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:V.common76,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common119,fediverse:V.common107,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":V.common114},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common119},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_ORGANIZATIONS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common121,fediverse:V.common107,filters:{additionalProperties:!1,default:{"links.members.@userId":V.common114,"links.members.@userId.isInviting":V.common123,"links.members.@userId.toBeValidated":V.common123},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":V.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_ORGANIZATIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,else:V.common45,if:V.common66,properties:{id:V.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:V.common62,type:"object"},request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common121,fediverse:V.common107,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":V.common114,"links.members.@{pathParams.id}.isInviting":V.common123,"links.members.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_MEMBERS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":V.common129,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":V.common131,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_MEMBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/organizations/id/{id}/canSee/true",pathParams:V.common98,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.memberOf.@{pathParams.id}":V.common114,"links.memberOf.@{pathParams.id}.isInviting":V.common123,"links.memberOf.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common129,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":V.common131,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common129},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_FRIENDS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:V.common6,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common134,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.friends.@{pathParams.id}":V.common114,"links.friends.@{pathParams.id}.isInviting":V.common123,"links.friends.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common129,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common129},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIPTIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common136,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common138],default:{"links.followers.@userId":V.common114,"links.followers.@{userId}.isInviting":V.common123,"links.followers.@{userId}.toBeValidated":V.common123},patternProperties:V.common141,type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIPTIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:V.common6,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common136,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common138],default:{"links.followers.@{pathParams.id}":V.common114,"links.followers.@{pathParams.id}.isInviting":V.common123,"links.followers.@{pathParams.id}.toBeValidated":V.common123},patternProperties:V.common141,type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common136},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIBERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common134,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common142],default:{"links.follows.@userId":V.common114,"links.follows.@{userId}.isInviting":V.common123,"links.follows.@{userId}.toBeValidated":V.common123},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common124,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,allOf:[{else:V.common45,if:V.common66,then:V.common62}],properties:{id:V.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common134,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common142],default:{"links.follows.@{pathParams.id}":V.common114},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":V.common129,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":V.common131,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_CONTRIBUTORS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/projects/id/{id}/canSee/true",pathParams:V.common98,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.projects.@{pathParams.id}":V.common114,"links.projects.@{pathParams.id}.isInviting":V.common123,"links.projects.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common129,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":V.common131,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common129},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common145,fediverse:V.common107,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},type:"object"},isParcours:V.common3,"preferences.private":V.common107},required:["preferences.private"],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common145},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES_FILTERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common147,fediverse:V.common107,fields:V.common145,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":V.common149}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":V.common149,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":V.common152,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":V.common152}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:V.common155},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:V.common155,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":V.common151}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":V.common149}}],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,ranges:{additionalProperties:!1,default:{Cooperative:V.common156,GovernmentOrganization:V.common156,Group:V.common156,LocalBusiness:V.common156,NGO:V.common156,citoyens:V.common156,projects:V.common156},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":V.common109},type:"object"},searchType:V.common147},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"CONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/connect",request:{additionalProperties:!1,allOf:[V.common157,V.common161,V.common167,{if:V.common173,then:{properties:{connectType:{default:"attendee",enum:["attendee","connect"]}}}}],properties:{childId:V.common176,childType:V.common177,connectType:{enum:["admin","member","contributor","attendee","friend","connect"],type:"string"},parentId:V.common11,parentType:V.common178},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:{additionalProperties:!1,allOf:[V.common157,V.common161,V.common167,{if:V.common173,then:{properties:{connectType:{const:"attendee",default:"attendee"}}}}],properties:{childId:V.common176,childType:V.common177,connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:V.common11,parentType:V.common178},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_KEY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/getinfo/key/{slug}",pathParams:{additionalProperties:!1,properties:{slug:{pattern:"^([a-zA-Z0-9-_]+)$",type:"string"}},required:["slug"],type:"object"}},{auth:"bearer",constant:"GET_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/config/type/citoyens/id/{id}/json/true",pathParams:V.common6},{auth:"bearer",constant:"DELETE_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue?index={index}",pathParams:{properties:{index:V.common59},type:"object"},request:{additionalProperties:!1,properties:{collection:V.common179,id:V.common180,path:{const:"preferences.search.@{pathParams.index}",default:"preferences.search.@{pathParams.index}",type:"string"},pull:{const:"preferences.search",type:"string"},value:V.common108},required:["id","collection","path","pull","value"],type:"object"}},{auth:"bearer",constant:"ADD_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue",request:{additionalProperties:!1,properties:{arrayForm:V.common151,collection:V.common179,id:V.common180,path:{const:"preferences.search",default:"preferences.search",type:"string"},value:{additionalProperties:!1,properties:{description:V.common1,locality:{patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:V.common42,required:["name","type"]}},type:"object"},name:V.common1,tags:V.common26,url:V.common1},required:["url","name"],type:"object"}},required:["id","collection","path","arrayForm","value"],type:"object"}},{auth:"bearer",constant:"ADD_ORGANIZATION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:V.common48,collection:{const:"organizations",default:"organizations",type:"string"},email:V.common2,geo:V.common52,geoPosition:V.common56,id:V.common11,key:{const:"organization",default:"organization",type:"string"},name:V.common1,preferences:{default:{isOpenData:!0,isOpenEdition:!0},properties:{isOpenData:V.common84,isOpenEdition:V.common84},required:["isOpenData","isOpenEdition"],type:"object"},role:{enum:["admin","member"],type:"string"},scope:V.common108,shortDescription:V.common1,tags:V.common26,type:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},url:V.common4},required:["id","collection","key","name","type","role","scope"],type:"object"}},{auth:"bearer",constant:"ADD_PROJECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:V.common48,collection:{const:"projects",default:"projects",type:"string"},geo:V.common52,geoPosition:V.common56,id:V.common11,key:{const:"project",default:"project",type:"string"},name:V.common1,parent:V.common181,preferences:{default:{crowdfunding:!0,isOpenData:!1,isOpenEdition:!1},properties:{crowdfunding:V.common84,isOpenData:V.common99,isOpenEdition:V.common99},required:["isOpenData","isOpenEdition"],type:"object"},public:V.common84,scope:V.common108,shortDescription:V.common1,tags:V.common26,url:V.common4},required:["id","collection","key","parent","name","public","scope"],type:"object"}},{auth:"bearer",constant:"ADD_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:V.common48,collection:V.common186,description:V.common1,geo:V.common52,geoPosition:V.common56,id:V.common11,key:V.common186,name:V.common1,parent:V.common181,scope:V.common108,tags:V.common26,type:{enum:["link","tool","machine","software","rh","Resource material","Financial Ressource","ficheBlanche","geoJson","compostPickup","video","sharedLibrary","recoveryCenter","trash","history","something2See","funPlace","place","artPiece","streetArts","openScene","stand","parking","other"],type:"string"},urls:V.common26},required:["id","collection","key","parent","type","name"],type:"object"}},{auth:"bearer",constant:"ADD_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,else:{required:["openingHours"]},if:{properties:{recurrency:V.common126}},properties:{address:V.common48,collection:{const:"events",default:"events",type:"string"},email:V.common2,endDate:V.common187,geo:V.common52,geoPosition:V.common56,id:V.common11,key:{const:"event",default:"event",type:"string"},name:V.common1,openingHours:{default:["","","","","","",""],items:{anyOf:[{const:"",type:"string"},{additionalProperties:!1,properties:{dayOfWeek:{enum:["Mo","Tu","We","Th","Fr","Sa","Su"],type:"string"},hours:{default:[],items:{additionalProperties:!1,properties:{closes:V.common188,opens:V.common188},required:["opens","closes"],type:"object"},type:"array"}},required:["dayOfWeek","hours"],type:"object"}]},maxItems:7,minItems:7,type:"array"},organizer:V.common181,parent:{additionalProperties:!1,patternProperties:V.common184,type:"object"},preferences:{default:{isOpenData:!1,isOpenEdition:!1},properties:{isOpenData:V.common99,isOpenEdition:V.common99},required:["isOpenData","isOpenEdition"],type:"object"},public:V.common84,recurrency:V.common99,scope:V.common108,shortDescription:V.common1,startDate:V.common187,tags:V.common26,timeZone:V.common1,type:{enum:["workshop","competition","concert","contest","conference","debate","exhibition","festival","crowdfunding","fair","course","protest","market","film","getTogether","meeting","spectacle","internship","stand","others"],type:"string"},url:V.common4},required:["id","collection","key","organizer","type","name","scope"],startBeforeEnd:!0,then:{required:["startDate","endDate"]},type:"object"}},{auth:"bearer",constant:"DELETE_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/poi/id/{id}",pathParams:V.common98,request:V.common8},{auth:"bearer",constant:"DELETE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/events/id/{id}/",pathParams:V.common98,request:V.common8},{auth:"bearer",constant:"DELETE_ELEMENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/{type}/id/{id}",pathParams:{additionalProperties:!1,properties:{id:V.common11,type:V.common1},required:["type","id"],type:"object"},request:V.common8},{auth:"bearer",constant:"ADD_IMAGE_ELEMENT",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/qqfile/docType/image/contentKey/profil",pathParams:{additionalProperties:!1,properties:{folder:{enum:["badges","events"],type:"string"},ownerId:V.common11},required:["folder","ownerId"],type:"object"},request:{additionalProperties:!1,properties:{qqfile:V.common16,qqfilename:V.common1,qqtotalfilesize:{type:"integer"},qquuid:V.common11},required:["qquuid","qqfilename","qqtotalfilesize","qqfile"],type:"object"}}];G.default.addType("oid",(e=>new Z.ObjectID(e)));class W extends q.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:r=K,timeout:i=3e4,debug:s=!1,maxRetries:a=0,circuitBreakerThreshold:c=5,circuitBreakerResetTime:p=6e4,fromJSONValue:m=!0}={}){if(super(),!e)throw new T('Le paramètre "baseURL" est obligatoire.',500);this._baseURL=e,this._refreshToken=o,this._refreshUrl=n,this._endpoints=r,this._debug=s;let d=null;this._fromJSONValue=m,Object.defineProperty(this,"userId",{get:()=>d,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{d=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new z.default({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),(0,L.default)(this._ajv),this._ajv.addKeyword({keyword:"startBeforeEnd",type:"object",errors:!0,validate:this._startBeforeEndValidate}),this._logger=(0,U.default)({transport:{target:"pino-pretty",options:{colorize:!0}},level:s?"debug":"info"}),this._client=M.default.create({baseURL:e,timeout:i}),a>0&&((0,B.default)(this._client,{retries:a,retryDelay:B.default.exponentialDelay,retryCondition:e=>B.default.isNetworkError(e)||B.default.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${a} max`)),this._breakerThreshold=c,this._breakerResetTime=p,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,t&&this.setToken(t),this._client.interceptors.response.use((e=>e),(async e=>{if(e.response&&401===e.response.status&&this._refreshToken)try{if(await this._refreshAccessToken())return this._client.request(e.config)}catch(e){throw new T(e.message,401,e)}throw e}))}setToken(e){this._accessToken=e,this._client.defaults.headers.common.Authorization="Bearer "+e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait et défini : ${t}`)),this._logger.debug(`[ApiClient] setToken: ${e}`)}getToken(){return this._accessToken}setRefreshToken(e){this._refreshToken=e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait depuis refreshToken : ${t}`)),this._logger.debug(`[ApiClient] setRefreshToken: ${e}`)}getRefreshToken(){return this._refreshToken}get isConnected(){return!!this._accessToken}_getIdFromToken(e){if(!e)return null;try{const t=(0,R.jwtDecode)(e);return this._logger.debug("[ApiClient] Payload décodé :",t),t.id||t.userId||null}catch(e){return this._logger.error("[ApiClient] Erreur lors du décodage du token :",e),null}}async _refreshAccessToken(){if(!this._refreshToken)return!1;try{const e=await this._client.post(this._refreshUrl,{refreshToken:this._refreshToken},{headers:{"Content-Type":"application/json"}});return!(!e.data||!e.data.accessToken||(this.setToken(e.data.accessToken),e.data.refreshToken&&this.setRefreshToken(e.data.refreshToken),this.emit("refreshSuccess",e.data),0))}catch(e){return this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),!0)}_updateCircuitBreakerError(){this._breakerErrorCount+=1,this._logger.warn(`[ApiClient] Erreur #${this._breakerErrorCount} sur ${this._breakerThreshold}`),this._breakerErrorCount>=this._breakerThreshold&&(this._breakerOpen=!0,this._lastBreakerOpenTime=Date.now(),this._logger.error("[ApiClient] Circuit breaker ACTIVÉ - L'API est considérée indisponible"))}_resetCircuitBreakerSuccess(){this._breakerErrorCount=0,this._breakerOpen&&(this._breakerOpen=!1,this._logger.warn("[ApiClient] Circuit breaker refermé suite à un succès"))}static stripNullsInPlace(e){if(e&&"object"==typeof e&&e.value&&"function"==typeof e.value.pipe)return e;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)null===e[t]||void 0===e[t]?e.splice(t,1):"object"==typeof e[t]&&W.stripNullsInPlace(e[t]);else if(e&&"object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null===e[t]||void 0===e[t]?delete e[t]:"object"==typeof e[t]&&W.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const o={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const o=this._getValueByPath(t,e);return null!=o?o:void 0}},n=/@(?:\{([^}]+)\}|([\w.]+))/g,r=e=>"string"!=typeof e?e:e.replace(n,((t,n,r)=>{if(n){if(n.startsWith("pathParams.")){const e=n.substring(11),t=o.pathParams(e);return null!=t?t:`@{${n}}`}{const e=o[n];if("function"==typeof e){const t=e();return null!=t?t:`@{${n}}`}return`@{${n}}`}}if(r){if(r.startsWith("pathParams.")){const e=r.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],n=e[2],i=o.pathParams(t);return null!=i?i+n:`@${r}`}return`@${r}`}{const e=o[r];if("function"==typeof e){const t=e();return null!=t?t:`@${r}`}return`@${r}`}}return e})),i=e=>{if((e=>e&&"object"==typeof e&&("function"==typeof e.pipe||"undefined"!=typeof Buffer&&e instanceof Buffer))(e))return e;if(Array.isArray(e))return e.map(i);if((e=>"[object Object]"===Object.prototype.toString.call(e))(e)){const t={};for(const[o,n]of Object.entries(e))t[r(o)]=i(n);return t}return"string"==typeof e?r(e):e};return i(e)}_cleanSchemaLeftoverAlias(e){const t=/@\w+/;if(Array.isArray(e))return e.map((e=>this._cleanSchemaLeftoverAlias(e)));if(e&&"object"==typeof e){const o={};for(const n of Object.keys(e)){const r=e[n];if(!t.test(n)){if("default"===n){if("string"==typeof r&&t.test(r))continue;if(r&&"object"==typeof r){const e=this._cleanSchemaLeftoverAlias(r);Object.keys(e).length>0&&(o[n]=e);continue}}"string"==typeof r&&t.test(r)||(o[n]=this._cleanSchemaLeftoverAlias(r))}}return o}return e}async safeCall(e,...t){try{return await e(...t)}catch(e){throw this._logger.error(`[ApiClient.safeCall] Erreur: ${e.message}`),e}}async callEndpoint(e,t={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new E("Le circuit breaker est activé, impossible d'appeler l'API");const r=this._endpoints.find((t=>t.constant===e));if(!r)throw new T(`Endpoint introuvable : ${e}`,404);const{path:i,method:s,contentType:a,auth:c,pathParams:p,request:m,responses:d}=r,l=(s||"GET").toLowerCase(),u=a||"application/json",y={"Content-Type":u};if(this._accessToken)"bearer"===c?y.Authorization=`Bearer ${this._accessToken}`:c&&"none"!==c||y.Authorization||(y.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===c)throw new T(`Token requis pour l'endpoint sécurisé : ${e}`,401);let h,f=i,g={};if(p){let e=p;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(p));const o=t.pathParams||{},n=this._ajv.compile(e);if(!n(o)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new b("Path parameter validation failed.",400,e,n.errors)}g=this._resolveSpecialValuesInPlace(o),f=f.replace(/\{(\w+)\}/g,((e,t)=>{const o=g[t];if(void 0!==o)return encodeURIComponent(o);throw new T(`Path param manquant ou non résolu : {${t}}`,400)}))}if(m){let e=m;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(m));const o={...t};delete o.pathParams;const n=W.stripNullsInPlace(o),r=this._ajv.compile(e);if(!r(n)){const e=r.errors?this._ajvErrorHuman(r.errors):[];throw this.emit("validationError",{stage:"request",errors:r.errors}),new b("Request validation failed.",400,e,r.errors)}t=this._resolveSpecialValuesInPlace(n,g)}"application/json"===u||"multipart/form-data"===u?h=t:"application/x-www-form-urlencoded"===u&&(h=W.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${f}, method=${l}`);try{const e=await this._client.request({url:f,method:l,headers:y,["get"===l?"params":"data"]:h});if(n){const t=e.status.toString(),o=d?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"response",errors:n.errors}),new b("Response validation failed.",t,e,n.errors)}}}return this._resetCircuitBreakerSuccess(),"function"==typeof o?e.data=o(e.data):!0===o&&(e.data=this._transformData(e.data)),Array.isArray(r.postActions)&&r.postActions.forEach((t=>{const o=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(o);break;case"setRefreshToken":this.setRefreshToken(o);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,o),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,o));break;case"callMethod":"function"==typeof this[t.method]?(this[t.method](),this._logger.debug(`[ApiClient] Méthode appelée : ${t.method}`)):this._logger.warn(`[ApiClient] Méthode inconnue : ${t.method}`);break;default:this._logger.warn(`[ApiClient] Action inconnue : ${t.type}`)}})),e}catch(t){throw this._updateCircuitBreakerError(),this._logger.error(`[ApiClient] Erreur lors de l'appel de ${e}: ${t.message}`),t instanceof b?t:new T(`Erreur lors de l'appel de l'API : ${t.message}`,t.response?t.response.status:500,t.response?t.response.data:null)}}_ajvErrorHuman(e){try{return new N.AggregateAjvError(e).errors.map((({message:e})=>e))}catch(t){return this._logger.error("[ApiClient] _ajvErrorHuman",t),e.map((({message:e})=>e))}}checkAndThrowApiResponseError(e){const t=e.data;if(!t||"object"!=typeof t)return e;if("boolean"==typeof t.result&&!1===t.result)throw new _(t.msg||"Erreur inconnue",e.status,t);if(t.resultErrors&&"object"==typeof t.resultErrors&&"boolean"==typeof t.resultErrors.result&&!1===t.resultErrors.result)throw new _(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),delete this._client.defaults.headers.common.Authorization,this._logger.info("[ApiClient] Session utilisateur réinitialisée."),this.emit("sessionReset")}_getValueByPath(e,t){if(t)return t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,o={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:n=!1,indexes:r=!1,metaTokens:i=!0}=o,s=[];function a(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function c(e){return e.endsWith("[]")?e.slice(0,-2):e}function p(e,t,o=!1){return e?e.concat(t).map(((e,t)=>(e=c(e),!o&&t?`[${e}]`:e))).join(o?".":""):t}function m(e){return null==e?"":e instanceof Date?e.toISOString():(e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||ArrayBuffer.isView(e),e)}return function e(o,d=[]){null==o||s.includes(o)||(s.push(o),Object.entries(o).forEach((([o,s])=>{void 0!==s&&function(e,o,s){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=i?o:o.slice(0,-2),t.append(p(s,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(a)||o.endsWith("[]"))return o=c(o),e.forEach(((e,i)=>{if(null!=e){const a=r?p(s.concat(o),i,n):`${p(s,o,n)}[]`;t.append(a,m(e))}})),!1}return!!a(e)||(t.append(p(s,o,n),m(e)),!1)}(s,o.trim(),d)&&e(s,d.concat(c(o)))})),s.pop())}(e),t}_transformData(e){if(e&&"object"==typeof e)if(e.resultGoods?.msg)e=this._normalizeJsonData({msg:e.resultGoods.msg,...e});else if(e.resultErrors?.msg)e=this._normalizeJsonData({msg:e.resultErrors.msg,...e});else if(e.results&&"object"==typeof e.results&&!Array.isArray(e.results))e.results=Object.keys(e.results).map((t=>this._normalizeJsonData({id:t,...e.results[t]})));else if(Array.isArray(e.results))e.results=e.results.map((e=>this._normalizeJsonData(e)));else if(e.news&&Array.isArray(e.news)&&0===e.news.length)e=e.news;else if(e.news&&"object"==typeof e.news&&!Array.isArray(e.news))e=Object.keys(e.news).map((t=>this._normalizeJsonData({id:t,...e.news[t]})));else if(e.notif&&"object"==typeof e.notif&&!Array.isArray(e.notif))e.notif=Object.keys(e.notif).map((t=>this._normalizeJsonData({id:t,...e.notif[t]})));else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens)&&e.organizations&&"object"==typeof e.organizations&&!Array.isArray(e.organizations))e=[...Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]}))),...Object.keys(e.organizations).map((t=>this._normalizeJsonData({id:t,...e.organizations[t]})))];else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens))e=Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]})));else if(e.cities&&"object"==typeof e.cities&&!Array.isArray(e.cities))e=Object.keys(e.cities).map((t=>this._normalizeJsonData({id:t,...e.cities[t]})));else if(e.cities&&Array.isArray(e.cities)&&0===e.cities.length)e=e.cities;else if(e.newComment&&"object"==typeof e.newComment)e.newComment=this._normalizeJsonData({...e.newComment});else if(Array.isArray(e))e=e.map((e=>this._normalizeJsonData(e)));else if(e.map&&"object"==typeof e.map)e.map=this._normalizeJsonData(e.map);else if(e.object&&"object"==typeof e.object)e.object=this._normalizeJsonData(e.object);else if("object"==typeof e&&Object.keys(e).length>0){const t=Object.keys(e).every((e=>/^[0-9a-fA-F]{24}$/.test(e)));e=t?Object.keys(e).map((t=>({id:t,...this._normalizeJsonData(e[t])}))):this._normalizeJsonData(e)}return e}_normalizeJsonData(e){if(!e||"object"!=typeof e)return e;if(e=this._normalizeRecursively(e),e?.mediaImg?.images&&Array.isArray(e.mediaImg.images)&&e.mediaImg.images.length>0&&(e.mediaImg.countImages=e.mediaImg.images.length),e?.mediaFile?.files&&Array.isArray(e.mediaFile.files)&&e.mediaFile.files.length>0&&(e.mediaFile.countFiles=e.mediaFile.files.length),e?.src?.changes&&"object"==typeof e.src.changes&&Object.keys(e.src.changes).length>0&&Object.keys(e.src.changes).forEach((t=>{e.src.changes[t]&&(e.src.changes[t]=this._ensureFullURL(e.src.changes[t]))})),e?.openingHours&&Array.isArray(e.openingHours)&&e.openingHours.length>0&&(e.openingHours=e.openingHours.filter((e=>e.dayOfWeek&&e.hours&&e.hours[0]&&e.hours[0].opens))),e.replies&&"object"==typeof e.replies&&Object.keys(e.replies).length>0&&(e.replies=Object.keys(e.replies).map((t=>this._normalizeJsonData({id:t,...e.replies[t]})))),e?.author&&"object"==typeof e.author&&Object.keys(e.author).length>0&&!("profilThumbImageUrl"in e.author)){const t=Object.keys(e.author)[0];e.author={...e.author[t]}}return e?.timeAgo&&delete e.timeAgo,this._fromJSONValue?G.default.fromJSONValue(e):e}_ensureFullURL(e){if(!e)return e;if(!(e=e.trim())||/^https?:\/\//i.test(e))return e;let t="/";return t=this._baseURL.endsWith("/")&&e.startsWith("/")||this._baseURL.endsWith("/")||e.startsWith("/")?"":"/",`${this._baseURL}${t}${e}`}_normalizeString(e){return"true"===e||"false"!==e&&e}_normalizeId(e){return e._id&&e._id.$id&&/^[0-9a-fA-F]{24}$/.test(e._id.$id)&&(e.id=e._id.$id,e._id={$type:"oid",$value:e._id.$id}),e.id&&e.id.$id&&/^[0-9a-fA-F]{24}$/.test(e.id.$id)&&(e._id={$type:"oid",$value:e.id.$id},e.id=e.id.$id),e}_normalizeDate(e){return e&&"object"==typeof e&&"number"==typeof e.sec?{$date:1e3*e.sec}:"number"==typeof e?{$date:1e3*e}:e}_normalizeImage(e){return"string"==typeof e&&""!==e.trim()?this._ensureFullURL(e):e}_imageFields=["profilImageUrl","profilThumbImageUrl","profilMediumImageUrl","profilMarkerImageUrl","profilBannerUrl","profilRealBannerUrl","imagePath","imageThumbPath","docPath"];_dateFields=["modified","created","updated","birthDate","lastLoginDate","startDate","endDate","date"];_normalizeRecursively(e){if("string"==typeof e)return this._normalizeString(e);if(Array.isArray(e))return e.map((e=>this._normalizeRecursively(e)));if(null!==e&&"object"==typeof e){const t={};return Object.keys(e).forEach((o=>{let n=this._normalizeRecursively(e[o]);this._dateFields.includes(o)&&(n=this._normalizeDate(n)),this._imageFields.includes(o)&&(n=this._normalizeImage(n)),"content"===o&&n&&"object"==typeof n&&n.image&&(n.image=this._normalizeImage(n.image)),t[o]=n})),this._normalizeId(t)}return e}_startBeforeEndValidate=(e,t)=>{if(!t.startDate||!t.endDate)return!0;const o=new Date(t.startDate)<new Date(t.endDate);return o||(this._startBeforeEndValidate.errors=[{instancePath:"",schemaPath:"#/startBeforeEnd",keyword:"startBeforeEnd",params:{},message:"startDate must be before endDate"}]),o}}class J{constructor(e){this.client=new W(e),this.loggedUser=null}async login(e,t){return this.client.safeCall((async()=>{const o=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new D(this.client,{id:o.data.user.id},o.data.user,{EndpointApi:A}),this.loggedUser}))}async register({name:e,username:t,email:o,pwd:n}={}){return this.client.safeCall((async()=>{const r=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:o,pwd:n});if(!1===r?.data?.result)throw new _(r.data.msg,r.status,r.data);return r.data}))}async recoverPassword(e){return this.client.safeCall((async()=>{const t=await this.client.callEndpoint("PASSWORD_RECOVERY",{email:e});if(!1===t?.data?.result)throw new _(t.data.msg,t.status,t.data);return t.data}))}}class H{static async userLogin(e,t,o){const n=H.userApi(o);return await H.userApiLogin(n,e,t)}static userApi(e){try{return new J(e)}catch(e){throw console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :",e.message),e}}static async userApiLogin(e,t,o){try{const n=await e.login(t,o);return new H(n,e.client)}catch(e){if(e instanceof T&&e?.details?.error)throw new P(e.details.error,e.status,e.details);throw e}}constructor(e,t){this._loggedUser=e,this._client=t}me(){if(!this._loggedUser)throw new P("Accès refusé : utilisateur non authentifié.");return this._loggedUser}user(e){try{return new D(this._client,e,{},{EndpointApi:A})}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e,t={getProfile:!0}){try{const o=new x(this._client,e,{EndpointApi:A});return t.getProfile&&await o.getProfil(),o}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e,t={getProfile:!0}){try{const o=new $(this._client,e,{EndpointApi:A});return t.getProfile&&await o.getProfil(),o}catch(e){throw console.error("[Api.project] Erreur lors de la création d'un objet projet :",e.message),e}}get client(){return this._client}get endpointApi(){return new A(this._client)}}const Y={ApiClient:W,Api:H,error:g};var X=f.A;export{X as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@communecter/cocolight-api-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Client Axios simplifié pour l'API cocolight",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
"generate:module:publish": "node ./scripts/transform-json-module.publish.js",
|
|
30
30
|
"generate:doc": "node ./scripts/generate-doc.js",
|
|
31
31
|
"generate:test": "node ./scripts/generate-tests.js",
|
|
32
|
-
"generate:testdata": "node ./scripts/generate-test-data.js"
|
|
32
|
+
"generate:testdata": "node ./scripts/generate-test-data.js",
|
|
33
|
+
"generate:reponses": "node ./scripts/generate-constant-response-200.js",
|
|
34
|
+
"generate:methodeapi": "node ./scripts/generate-methode-api.js",
|
|
35
|
+
"generate:ajv-standalone": "node ./scripts/generate-validate-function-ajv.js"
|
|
33
36
|
},
|
|
34
37
|
"keywords": [
|
|
35
38
|
"communecter",
|
|
@@ -47,25 +50,30 @@
|
|
|
47
50
|
"README.md"
|
|
48
51
|
],
|
|
49
52
|
"peerDependencies": {
|
|
53
|
+
"@segment/ajv-human-errors": "^2.15.0",
|
|
50
54
|
"ajv": "^8.17.1",
|
|
51
55
|
"ajv-formats": "^3.0.1",
|
|
52
56
|
"axios": "^1.4.0",
|
|
53
57
|
"axios-retry": "^4.5.0",
|
|
54
58
|
"ejson": "^2.2.3",
|
|
55
59
|
"events": "^3.3.0",
|
|
60
|
+
"jwt-decode": "^4.0.0",
|
|
56
61
|
"pino": "^9.6.0",
|
|
57
62
|
"pino-pretty": "^13.0.0",
|
|
58
|
-
"
|
|
63
|
+
"file-type": "^20.4.1",
|
|
64
|
+
"bson-objectid": "^2.0.4"
|
|
59
65
|
},
|
|
60
66
|
"devDependencies": {
|
|
61
67
|
"@babel/core": "^7.26.10",
|
|
62
68
|
"@babel/preset-env": "^7.26.9",
|
|
63
69
|
"@eslint/js": "^9.23.0",
|
|
70
|
+
"@segment/ajv-human-errors": "^2.15.0",
|
|
64
71
|
"ajv": "^8.17.1",
|
|
65
72
|
"ajv-formats": "^3.0.1",
|
|
66
73
|
"axios": "^1.4.0",
|
|
67
74
|
"axios-retry": "^4.5.0",
|
|
68
|
-
"
|
|
75
|
+
"file-type": "^20.4.1",
|
|
76
|
+
"bson-objectid": "^2.0.4",
|
|
69
77
|
"babel-jest": "^29.7.0",
|
|
70
78
|
"babel-loader": "^10.0.0",
|
|
71
79
|
"ejson": "^2.2.3",
|
|
@@ -74,6 +82,7 @@
|
|
|
74
82
|
"events": "^3.3.0",
|
|
75
83
|
"globals": "^16.0.0",
|
|
76
84
|
"jest": "^29.7.0",
|
|
85
|
+
"jwt-decode": "^4.0.0",
|
|
77
86
|
"nodemon": "^3.1.9",
|
|
78
87
|
"pino": "^9.6.0",
|
|
79
88
|
"pino-pretty": "^13.0.0",
|