@communecter/cocolight-api-client 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cocolight-api-client.browser.js +2 -2
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/package.json +2 -1
- package/src/Api.js +158 -0
- package/src/ApiClient.js +28 -3
- package/src/api/EntityMixin.js +43 -0
- package/src/api/Organization.js +79 -0
- package/src/api/Project.js +79 -0
- package/src/api/User.js +89 -0
- package/src/api/UserApi.js +48 -0
- package/src/endpoints.module.js +2 -2
- package/src/error.js +41 -4
- package/src/index.js +4 -0
|
@@ -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 a from"pino";var s={d:(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},m={};s.d(m,{A:()=>k});const c=(p={EventEmitter:()=>e.EventEmitter},d={},s.d(d,p),d);var p,d;const l=(e=>{var t={};return s.d(t,e),t})({default:()=>t.default}),u=(e=>{var t={};return s.d(t,e),t})({default:()=>o.default}),y=(e=>{var t={};return s.d(t,e),t})({default:()=>n.default}),f=(e=>{var t={};return s.d(t,e),t})({default:()=>r.default}),h=(e=>{var t={};return s.d(t,e),t})({default:()=>i.default});class g extends Error{}g.prototype.name="InvalidTokenError";const b=(e=>{var t={};return s.d(t,e),t})({default:()=>a.default}),T={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!T._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof T.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new T.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()}}},w=T,P={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{default:"@userId",type:"string"},common5:{id:{default:"@userId",type:"string"}},common6:{default:"",type:"string"},common7:{const:"citoyens"},common8:{properties:{value:{type:"boolean"}}},common9:{value:{type:"boolean"}},common10:{},common11:{if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",type:"string"}}}},common12:{properties:{typeElement:{const:"citoyens"}}},common13:{typeElement:{const:"citoyens"}},common14:{properties:{id:{default:"@userId",type:"string"}}},common15:{not:{type:"null"}},common16:{type:"null"},common17:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common18:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common19:{items:{type:"string"},type:"array"},common20:{enum:[""],type:"string"},common21:{format:"uri",type:"string"},common22:{properties:{name:{not:{type:"null"}}},required:["name"]},common23:{name:{not:{type:"null"}}},common24:{properties:{url:{not:{type:"null"}}},required:["url"]},common25:{url:{not:{type:"null"}}},common26:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common27:{tags:{not:{type:"null"}}},common28:{properties:{email:{not:{type:"null"}}},required:["email"]},common29:{email:{not:{type:"null"}}},common30:{const:"info",default:"info",type:"string"},common31:{$ref:"#/$defs/sharedFields/email"},common32:{$ref:"#/$defs/sharedFields/name"},common33:{$ref:"#/$defs/sharedFields/tags"},common34:{$ref:"#/$defs/sharedFields/url"},common35:{const:"projects"},common36:{const:"organizations"},common37:{$ref:"#/$defs/socialField"},common38:{minLength:0,type:"string"},common39:{type:["string","number"]},common40:{type:"number"},common41:{const:!0,default:!0,type:"boolean"},common42:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common43:{properties:{type:{const:"citoyens"}}},common44:{type:{const:"citoyens"}},common45:{additionalProperties:!1,allOf:[{if:{properties:{folder:{const:"citoyens"}}},then:{properties:{ownerId:{default:"@userId"}}}}],properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],type:"object"},common46:{if:{properties:{folder:{const:"citoyens"}}},then:{properties:{ownerId:{default:"@userId"}}}},common47:{properties:{folder:{const:"citoyens"}}},common48:{folder:{const:"citoyens"}},common49:{properties:{ownerId:{default:"@userId"}}},common50:{ownerId:{default:"@userId"}},common51:{default:"@userId"},common52:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common53:{if:{properties:{type:{const:"citoyens"}}},then:{properties:{id:{default:"@userId"}}}},common54:{properties:{id:{default:"@userId"}}},common55:{id:{default:"@userId"}},common56:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{parentId:{default:"@userId",type:"string"}}}},common57:{properties:{parentType:{const:"citoyens"}}},common58:{parentType:{const:"citoyens"}},common59:{properties:{parentId:{default:"@userId",type:"string"}}},common60:{parentId:{default:"@userId",type:"string"}},common61:{default:!0,type:"boolean"},common62:{required:["text"]},common63:{required:["mediaImg"]},common64:{required:["mediaFile"]},common65:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common66:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common67:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common68:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common69:{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"},common70:{"^[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"}},common71:{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"},common72:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common73:{default:"public",enum:["public","private","restricted"],type:"string"},common74:{const:"news",default:"news",type:"string"},common75:{additionalProperties:!1,properties:{id:{type:"string"}},required:["id"],type:"object"},common76:{id:{type:"string"}},common77:{default:!1,type:"boolean"},common78:{additionalProperties:!1,properties:{id:{type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common79:{id:{type:"string"},type:{default:"news",enum:["news"],type:"string"}},common80:{default:"news",enum:["news"],type:"string"},common81:{items:{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:"array"},common82:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common83:{const:!1,default:!1,type:"boolean"},common84:{const:"",default:"",type:"string"},common85:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common86:{indexMax:{type:"number"},indexMin:{type:"number"}},common87:{default:0,minimum:0,type:"integer"},common88:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common89:{enum:["projects"],type:"string"},common90:{$exists:!0},common91:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common92:{$exists:{const:!0}},common93:{const:!0},common94:{default:30,type:"integer"},common95:{additionalProperties:!1,allOf:[{if:{properties:{type:{const:"citoyens"}}},then:{properties:{id:{default:"@userId"}}}}],properties:{id:{pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],type:"object"},common96:{id:{pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common97:{pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common98:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common99:{enum:["poi"],type:"string"},common100:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common101:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common102:{$exists:!1},common103:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common104:{$exists:{const:!1}},common105:{const:!1},common106:{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"},common107:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common108:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common109:{$exists:{default:!1,type:"boolean"}},common110:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common111:{$in:{items:{type:"string"},minItems:1,type:"array"}},common112:{items:{type:"string"},minItems:1,type:"array"},common113:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common114:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common115:{pattern:"^[a-f0-9]{24}$",type:"string"},common116:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common117:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common118:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common119:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common120:{enum:["citoyens"],type:"string"},common121:{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"},common122:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common123:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common124:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common125:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common126:{"^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"}},common127:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common128:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common129:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common130:{properties:{id:{pattern:"^@userId$"}}},common131:{id:{pattern:"^@userId$"}},common132:{pattern:"^@userId$"},common133:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common134:{enum:["badges"],type:"string"},common135:{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"},common136:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common137:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common138:{$exists:{const:!0,type:"boolean"}},common139:{const:!0,type:"boolean"},common140:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common141:{$exists:{const:!1,type:"boolean"}},common142:{const:!1,type:"boolean"},common143:{"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"}},common144:{indexMax:30,indexMin:0},common145:{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"},common146:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common147:{properties:{connectType:{const:"friend",default:"friend"}}},common148:{connectType:{const:"friend",default:"friend"}},common149:{const:"friend",default:"friend"},common150:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common151:{properties:{parentType:{const:"organizations"}}},common152:{parentType:{const:"organizations"}},common153:{properties:{connectType:{enum:["admin","member"]}}},common154:{connectType:{enum:["admin","member"]}},common155:{enum:["admin","member"]},common156:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common157:{properties:{parentType:{const:"projects"}}},common158:{parentType:{const:"projects"}},common159:{properties:{connectType:{enum:["admin","contributor"]}}},common160:{connectType:{enum:["admin","contributor"]}},common161:{enum:["admin","contributor"]},common162:{if:{properties:{parentType:{const:"events"}}},then:{properties:{connectType:{const:"attendee",default:"attendee"}}}},common163:{properties:{parentType:{const:"events"}}},common164:{parentType:{const:"events"}},common165:{const:"events"},common166:{properties:{connectType:{const:"attendee",default:"attendee"}}},common167:{connectType:{const:"attendee",default:"attendee"}},common168:{const:"attendee",default:"attendee"},common169:{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"}},common170:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common171:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common172:{enum:["admin","member","contributor","attendee","friend"],type:"string"},common173:{enum:["citoyens","organizations","projects","events"],type:"string"}},_=[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:P.common1,email:P.common2,isInvitation:P.common3,mode:P.common1,name:P.common1,pendingUserId:P.common1,pwd:P.common1,username:P.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",payloadPath:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:P.common2,password:P.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:P.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",method:"POST",path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:P.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:P.common1},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:P.common1,newPassword2:P.common1,oldPassword:P.common1,scope:{default:"",type:["string"]},userId:P.common4},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:{additionalProperties:!1,properties:P.common5,required:["id"],type:"object"},postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:{additionalProperties:!1,properties:{reason:P.common6},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:[{if:{properties:{typeEntity:P.common7}},then:{properties:{idEntity:P.common4}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:P.common7}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:P.common7}},then:P.common8},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:P.common7}}},then:P.common8}],properties:{idEntity:P.common1,type:P.common1,typeEntity:{default:"citoyens",type:"string"},value:P.common10},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:[P.common11,{anyOf:[{properties:{description:P.common15},required:["description"]},{properties:{shortDescription:P.common15},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:P.common6,description:P.common1,id:P.common1,scope:{default:"",type:["string","null"]},shortDescription:P.common1,typeElement:P.common17},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:P.common2,name:P.common1,tags:P.common18,url:P.common21}},allOf:[{if:P.common12,then:{additionalProperties:!1,anyOf:[P.common22,{properties:{birthDate:P.common15},required:["birthDate"]},{properties:{fixe:P.common15},required:["fixe"]},{properties:{mobile:P.common15},required:["mobile"]},P.common24,P.common26,P.common28],properties:{birthDate:{format:"date",type:"string"},block:P.common30,email:P.common31,fixe:P.common1,id:P.common4,mobile:P.common1,name:P.common32,scope:P.common6,tags:P.common33,typeElement:P.common17,url:P.common34}}},{if:{properties:{typeElement:P.common35}},then:{additionalProperties:!1,anyOf:[P.common22,P.common24,P.common26,P.common28,{properties:{avancement:P.common15},required:["avancement"]},{properties:{parent:P.common15},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:P.common30,email:P.common31,id:P.common1,name:P.common32,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":{additionalProperties:!1,properties:{name:P.common1,type:P.common1},required:["type","name"],type:"object"}},type:"object"},scope:P.common6,tags:P.common33,typeElement:P.common17,url:P.common34}}},{if:{properties:{typeElement:P.common36}},then:{additionalProperties:!1,anyOf:[P.common22,P.common24,P.common26,P.common28,{properties:{type:P.common15},required:["type"]}],properties:{block:P.common30,email:P.common31,id:P.common1,name:P.common32,scope:P.common6,tags:P.common33,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:P.common17,url:P.common34}}}],properties:{block:P.common30,id:P.common1,scope:P.common6,typeElement:P.common17},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:[P.common20,P.common21]}},allOf:[P.common11,{anyOf:[{properties:{gitlab:P.common15},required:["gitlab"]},{properties:{github:P.common15},required:["github"]},{properties:{twitter:P.common15},required:["twitter"]},{properties:{facebook:P.common15},required:["facebook"]},{properties:{instagram:P.common15},required:["instagram"]},{properties:{diaspora:P.common15},required:["diaspora"]},{properties:{mastodon:P.common15},required:["mastodon"]},{properties:{telegram:P.common15},required:["telegram"]},{properties:{signal:P.common15},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:P.common37,facebook:P.common37,github:P.common37,gitlab:P.common37,id:P.common1,instagram:P.common37,mastodon:P.common37,scope:P.common6,signal:P.common37,telegram:P.common37,twitter:P.common37,typeElement:P.common17},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:{allOf:[P.common11],properties:{address:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:P.common1,addressLocality:P.common1,codeInsee:P.common1,level1:P.common1,level1Name:P.common1,level3:P.common38,level3Name:P.common38,level4:P.common38,level4Name:P.common38,localityId:P.common1,postalCode:P.common1,streetAddress:P.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:P.common39,longitude:P.common39},required:["latitude","longitude"],type:"object"},geoPosition:{additionalProperties:!0,properties:{coordinates:{items:P.common40,maxItems:2,minItems:2,type:"array"},float:P.common41,type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},id:P.common1,scope:P.common6,typeElement:P.common17},required:["block","typeElement","id","address"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{allOf:[P.common11],properties:{block:P.common30,id:P.common1,scope:P.common6,slug:P.common42,typeElement:P.common17},required:["block","typeElement","id","slug"],type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,allOf:[{if:P.common43,then:P.common14}],properties:{block:P.common30,id:P.common1,slug:P.common42,type:P.common17},required:["block","type","id","slug"],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:P.common45,request:{additionalProperties:!1,properties:{profil_avatar:P.common10},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:{additionalProperties:!1,allOf:[P.common53],properties:{id:P.common1,type:P.common17},required:["type","id"],type:"object"},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,allOf:[P.common56],properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:P.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:P.common1,parentType:P.common17},required:["parentId","parentType","listInvite"],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/{json}",pathParams:{additionalProperties:!1,allOf:[P.common53],properties:{id:P.common1,isLive:P.common61,json:P.common61,type:P.common17},required:["isLive","type","id","json"],type:"object"},request:{additionalProperties:!1,properties:{dateLimit:{default:0,type:"integer"},indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:P.common6},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:P.common19},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,allOf:[P.common56],anyOf:[P.common62,P.common63,P.common64],properties:{json:P.common41,markdownActive:P.common61,mediaFile:P.common65,mediaImg:P.common67,mentions:P.common69,parentId:P.common1,parentType:P.common17,scope:P.common73,tags:P.common18,text:P.common1,type:P.common74},required:["scope","markdownActive","parentId","parentType","type","json"],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:P.common45,request:{additionalProperties:!1,properties:{newsImage:P.common10},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:P.common45,request:{additionalProperties:!1,properties:{newsFile:P.common10},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:P.common75,request:{additionalProperties:!1,properties:{isLive:P.common77},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,allOf:[P.common56],anyOf:[P.common62,P.common63,P.common64],properties:{idNews:P.common1,markdownActive:P.common61,mediaFile:P.common65,mediaImg:P.common67,mentions:P.common69,parentId:P.common1,parentType:P.common17,scope:P.common73,tags:P.common18,text:P.common1,type:P.common74},required:["idNews","scope","markdownActive","parentId","parentType","type"],type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,allOf:[{if:{properties:{childType:P.common7}},then:{properties:{childId:P.common4}}}],properties:{childId:P.common1,childType:P.common17,comment:P.common1,connectType:{const:"share",default:"share",type:"string"},parentId:P.common1,parentType:P.common74},required:["parentId","parentType","childId","childType","connectType"],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:P.common78},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:P.common6,contextId:P.common1,contextType:P.common80,mentions:P.common81,parentCommentId:P.common6,path:P.common6,text:P.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:P.common75},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:P.common1,params:{properties:{mentions:P.common81,text:P.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:P.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:P.common78},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:P.common41,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:P.common82,type:"array"},fediverse:P.common83,filters:P.common84,indexMin:{const:0,default:0,type:"number"},indexStep:P.common40,initType:P.common84,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:P.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:P.common1,notSourceKey:P.common41,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":P.common85},type:"object"},searchTags:P.common19,searchType:{items:P.common82,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:P.common84,name:P.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:P.common87,name:P.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:P.common41,countType:P.common88,fediverse:P.common83,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":P.common90,"parent.@userId":P.common90},"links.contributors.@userId":P.common90},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":P.common91},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":P.common91,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":P.common91},type:"object"}},required:["$or"],type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common88},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:P.common95,request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common88,fediverse:P.common83,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":P.common90,"parent.@{pathParams.id}":P.common90},"links.contributors.@{pathParams.id}":P.common90},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91},type:"object"}},required:["$or"],type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common88},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:P.common41,countType:P.common98,fediverse:P.common83,filters:{additionalProperties:!1,default:{"parent.@userId":P.common90},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":P.common91},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common98},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:P.common95,request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common98,fediverse:P.common83,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":P.common90},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common98},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:P.common41,countType:P.common100,fediverse:P.common83,filters:{additionalProperties:!1,default:{"links.members.@userId":P.common90,"links.members.@userId.isInviting":P.common102,"links.members.@userId.toBeValidated":P.common102},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":P.common91,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":P.common103,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":P.common103},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common100},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,allOf:[P.common53],properties:{id:P.common97,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common100,fediverse:P.common83,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":P.common90,"links.members.@{pathParams.id}.isInviting":P.common102,"links.members.@{pathParams.id}.toBeValidated":P.common102},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":P.common103,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":P.common103},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common100},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:P.common41,countType:P.common106,fediverse:P.common83,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+)$":P.common91,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":P.common91,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":P.common108,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":P.common110,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":P.common103},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common106},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:P.common113,request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common106,fediverse:P.common83,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}":P.common90,"links.memberOf.@{pathParams.id}.isInviting":P.common102,"links.memberOf.@{pathParams.id}.toBeValidated":P.common102},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":P.common91,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":P.common108,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":P.common110,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":P.common108},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common106},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:P.common116,request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common119,fediverse:P.common83,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}":P.common90,"links.friends.@{pathParams.id}.isInviting":P.common102,"links.friends.@{pathParams.id}.toBeValidated":P.common102},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":P.common108,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":P.common108},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common119},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:P.common41,countType:P.common121,fediverse:P.common83,filters:{additionalProperties:!1,allOf:[P.common123],default:{"links.followers.@userId":P.common90,"links.followers.@{userId}.isInviting":P.common102,"links.followers.@{userId}.toBeValidated":P.common102},patternProperties:P.common126,type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common121},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:P.common116,request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common121,fediverse:P.common83,filters:{additionalProperties:!1,allOf:[P.common123],default:{"links.followers.@{pathParams.id}":P.common90,"links.followers.@{pathParams.id}.isInviting":P.common102,"links.followers.@{pathParams.id}.toBeValidated":P.common102},patternProperties:P.common126,type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common121},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:P.common41,countType:P.common119,fediverse:P.common83,filters:{additionalProperties:!1,allOf:[P.common127],default:{"links.follows.@userId":P.common90,"links.follows.@{userId}.isInviting":P.common102,"links.follows.@{userId}.toBeValidated":P.common102},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":P.common103,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":P.common103},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common119},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:[P.common53,{if:{properties:{type:P.common36}},then:P.common130},{if:{properties:{type:P.common35}},then:P.common130}],properties:{id:P.common97,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common119,fediverse:P.common83,filters:{additionalProperties:!1,allOf:[P.common127],default:{"links.follows.@{pathParams.id}":P.common90},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common119},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:P.common41,countType:P.common106,fediverse:P.common83,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+)$":P.common91,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":P.common91,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":P.common108,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":P.common110,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":P.common103},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common106},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:P.common113,request:{additionalProperties:!1,properties:{count:P.common41,countType:P.common106,fediverse:P.common83,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}":P.common90,"links.projects.@{pathParams.id}.isInviting":P.common102,"links.projects.@{pathParams.id}.toBeValidated":P.common102},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":P.common91,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":P.common91,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":P.common108,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":P.common110,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":P.common108},type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common106},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:P.common41,countType:P.common133,fediverse:P.common83,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":P.common91},type:"object"},isParcours:P.common3,"preferences.private":P.common83},required:["preferences.private"],type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,searchType:P.common133},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:P.common41,countType:P.common135,fediverse:P.common83,fields:P.common133,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":P.common137}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":P.common137,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":P.common140,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":P.common140}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:P.common143},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:P.common143,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":P.common139}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":P.common137}}],type:"object"},indexMin:P.common87,indexStep:P.common94,initType:P.common84,locality:P.common84,name:P.common1,notSourceKey:P.common41,ranges:{additionalProperties:!1,default:{Cooperative:P.common144,GovernmentOrganization:P.common144,Group:P.common144,LocalBusiness:P.common144,NGO:P.common144,citoyens:P.common144,projects:P.common144},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":P.common85},type:"object"},searchType:P.common135},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:P.common145},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:P.common145}];class O extends Error{constructor(e,t,o){super(e),this.name="ApiClientError",this.status=t,this.details=o}}class j extends Error{constructor(e){super(e),this.name="CircuitBreakerError"}}h.default.addType("oid",(e=>new w.ObjectID(e)));class k extends c.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:r=_,timeout:i=3e4,debug:a=!1,maxRetries:s=0,circuitBreakerThreshold:m=5,circuitBreakerResetTime:c=6e4,fromJSONValue:p=!0}={}){if(super(),!e)throw new O('Le paramètre "baseURL" est obligatoire.',500);this._baseURL=e,this._refreshToken=o,this._refreshUrl=n,this._endpoints=r,this._debug=a;let d=null;this._fromJSONValue=p,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 l.default({strict:!1,useDefaults:!0}),(0,u.default)(this._ajv),this._logger=(0,b.default)({transport:{target:"pino-pretty",options:{colorize:!0}},level:a?"debug":"info"}),this._client=y.default.create({baseURL:e,timeout:i}),s>0&&((0,f.default)(this._client,{retries:s,retryDelay:f.default.exponentialDelay,retryCondition:e=>f.default.isNetworkError(e)||f.default.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${s} 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 O(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}_getIdFromToken(e){if(!e)return null;try{const t=function(e,t){if("string"!=typeof e)throw new g("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 g(`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 g(`Invalid token specified: invalid base64 for part #${o+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new g(`Invalid token specified: invalid json for part #${o+1} (${e.message})`)}}(e);return this._logger.log("[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.message),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._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]&&k.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]&&k.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 callEndpoint(e,t={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new j("Le circuit breaker est activé, impossible d'appeler l'API");const r=this._endpoints.find((t=>t.constant===e));if(!r)throw new O(`Endpoint introuvable : ${e}`,404);const{path:i,method:a,contentType:s,auth:m,pathParams:c,request:p,responses:d}=r,l=(a||"GET").toLowerCase(),u=s||"application/json",y={"Content-Type":u};if(this._accessToken)"bearer"===m?y.Authorization=`Bearer ${this._accessToken}`:m&&"none"!==m||y.Authorization||(y.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===m)throw new O(`Token requis pour l'endpoint sécurisé : ${e}`,401);let f,h=i,g={};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 O("Path parameter validation failed.",400,n.errors);g=this._resolveSpecialValuesInPlace(o),h=h.replace(/\{(\w+)\}/g,((e,t)=>{const o=g[t];if(void 0!==o)return encodeURIComponent(o);throw new O(`Path param manquant ou non résolu : {${t}}`,400)}))}if(p){let e=p;"none"===m&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(p));const o={...t};delete o.pathParams;const n=k.stripNullsInPlace(o),r=this._ajv.compile(e);if(!r(n))throw this.emit("validationError",{stage:"request",errors:r.errors}),new O("Request validation failed.",400,r.errors);t=this._resolveSpecialValuesInPlace(n,g)}"application/json"===u||"multipart/form-data"===u?f=t:"application/x-www-form-urlencoded"===u&&(f=k.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${h}, method=${l}`);try{const e=await this._client.request({url:h,method:l,headers:y,["get"===l?"params":"data"]:f});if(n){const t=e.status.toString(),o=d?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data))throw this.emit("validationError",{stage:"response",errors:n.errors}),new O("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(e){throw this._updateCircuitBreakerError(),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,a=[];function s(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,d=[]){null==o||a.includes(o)||(a.push(o),Object.entries(o).forEach((([o,a])=>{void 0!==a&&function(e,o,a){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=i?o:o.slice(0,-2),t.append(c(a,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(s)||o.endsWith("[]"))return o=m(o),e.forEach(((e,i)=>{if(null!=e){const s=r?c(a.concat(o),i,n):`${c(a,o,n)}[]`;t.append(s,p(e))}})),!1}return!!s(e)||(t.append(c(a,o,n),p(e)),!1)}(a,o.trim(),d)&&e(a,d.concat(m(o)))})),a.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?h.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}}var v=m.A;export{v as default};
|
|
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};
|
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.7",
|
|
4
4
|
"description": "Client Axios simplifié pour l'API cocolight",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "node --experimental-vm-modules ./node_modules/.bin/jest --config jest.config.js",
|
|
19
19
|
"exemple": "node exemple/exemple.js",
|
|
20
|
+
"exemple-api": "node exemple/exemple-api.js",
|
|
20
21
|
"lint": "eslint ./src ./exemple ./scripts --ext .js",
|
|
21
22
|
"lint:fix": "eslint ./src ./scripts --ext .js --fix",
|
|
22
23
|
"build:browser": "webpack --config webpack.config.standalone.js",
|
package/src/Api.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Api.js
|
|
2
|
+
import { Organization } from "./api/Organization.js";
|
|
3
|
+
import { Project } from "./api/Project.js";
|
|
4
|
+
import { User } from "./api/User.js";
|
|
5
|
+
import { UserApi } from "./api/UserApi.js";
|
|
6
|
+
import { ApiAuthenticationError, ApiClientError } from "./error.js";
|
|
7
|
+
|
|
8
|
+
export default class Api {
|
|
9
|
+
/**
|
|
10
|
+
* Authentifie l'utilisateur et retourne une instance d'Api.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} email - L'adresse email.
|
|
13
|
+
* @param {string} password - Le mot de passe.
|
|
14
|
+
* @param {Object} options - Options pour l'ApiClient (baseURL, debug, etc.)
|
|
15
|
+
* @returns {Promise<Api>}
|
|
16
|
+
*/
|
|
17
|
+
static async userLogin(email, password, options) {
|
|
18
|
+
const userApi = Api.userApi(options);
|
|
19
|
+
return await Api.userApiLogin(userApi, email, password);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of the UserApi class with the provided options.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} options - Configuration options for initializing the UserApi instance.
|
|
26
|
+
* @returns {UserApi} An instance of the UserApi class.
|
|
27
|
+
* @throws {Error} Throws an error if the UserApi instance cannot be created.
|
|
28
|
+
*/
|
|
29
|
+
static userApi(options) {
|
|
30
|
+
try {
|
|
31
|
+
const userApi = new UserApi(options);
|
|
32
|
+
return userApi;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :", error.message);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Logs in a user using the provided userApi instance, email, and password.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} userApi - The API instance used for user authentication.
|
|
43
|
+
* @param {string} email - The email address of the user.
|
|
44
|
+
* @param {string} password - The password of the user.
|
|
45
|
+
* @returns {Promise<Api>} A promise that resolves to an instance of the Api class
|
|
46
|
+
* initialized with the logged-in user and the API client.
|
|
47
|
+
* @throws {ApiAuthenticationError} If the login fails due to authentication issues.
|
|
48
|
+
* @throws {Error} If an unexpected error occurs during the login process.
|
|
49
|
+
*/
|
|
50
|
+
static async userApiLogin(userApi, email, password) {
|
|
51
|
+
try {
|
|
52
|
+
const loggedUser = await userApi.login(email, password);
|
|
53
|
+
return new Api(loggedUser, userApi.client);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if(error instanceof ApiClientError) {
|
|
56
|
+
if(error?.details?.error) {
|
|
57
|
+
throw new ApiAuthenticationError(error.details.error, error.status, error.details);
|
|
58
|
+
} else {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Construit une instance d'Api.
|
|
67
|
+
*
|
|
68
|
+
* @param {User|null} loggedUser - L'utilisateur connecté ou null.
|
|
69
|
+
* @param {ApiClient} client - L'instance d'ApiClient.
|
|
70
|
+
*/
|
|
71
|
+
constructor(loggedUser, client) {
|
|
72
|
+
this._loggedUser = loggedUser;
|
|
73
|
+
this._client = client;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Retourne l'utilisateur connecté.
|
|
78
|
+
*
|
|
79
|
+
* @returns {User} L'utilisateur connecté.
|
|
80
|
+
*/
|
|
81
|
+
me() {
|
|
82
|
+
if (!this._loggedUser) {
|
|
83
|
+
throw new Error("Accès refusé : utilisateur non authentifié.");
|
|
84
|
+
}
|
|
85
|
+
return this._loggedUser;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Crée une instance User pour un utilisateur donné (autre que le connecté).
|
|
90
|
+
*
|
|
91
|
+
* @param {Object} userData - Les données de l'utilisateur public.
|
|
92
|
+
* @returns {User}
|
|
93
|
+
*/
|
|
94
|
+
user(userData) {
|
|
95
|
+
try {
|
|
96
|
+
return new User(this._client, userData);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :", error.message);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Creates an Organization object and optionally retrieves its profile.
|
|
106
|
+
*
|
|
107
|
+
* @param {Object} organizationData - The data required to initialize the Organization object.
|
|
108
|
+
* @param {Object} [options={ getProfile: true }] - Additional options for the organization creation.
|
|
109
|
+
* @param {boolean} [options.getProfile=true] - Whether to fetch the organization's profile after creation.
|
|
110
|
+
* @returns {Promise<Organization>} A promise that resolves to the created Organization object.
|
|
111
|
+
* @throws {Error} Throws an error if the organization creation or profile retrieval fails.
|
|
112
|
+
*/
|
|
113
|
+
async organization(organizationData, options = { getProfile: true }) {
|
|
114
|
+
try {
|
|
115
|
+
const oraganization = new Organization(this._client, organizationData);
|
|
116
|
+
if (options.getProfile) {
|
|
117
|
+
await oraganization.getProfile();
|
|
118
|
+
}
|
|
119
|
+
return oraganization;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("[Api.organization] Erreur lors de la création d'un objet organisation :", error.message);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new Project instance and optionally retrieves its profile.
|
|
128
|
+
*
|
|
129
|
+
* @param {Object} projectData - The data used to initialize the Project instance.
|
|
130
|
+
* @param {Object} [options={ getProfile: true }] - Additional options for project creation.
|
|
131
|
+
* @param {boolean} [options.getProfile=true] - Whether to retrieve the project's profile after creation.
|
|
132
|
+
* @returns {Promise<Project>} A promise that resolves to the created Project instance.
|
|
133
|
+
* @throws {Error} If an error occurs during project creation or profile retrieval.
|
|
134
|
+
*/
|
|
135
|
+
async project(projectData, options = { getProfile: true }) {
|
|
136
|
+
try {
|
|
137
|
+
const project = new Project(this._client, projectData);
|
|
138
|
+
if (options.getProfile) {
|
|
139
|
+
await project.getProfile();
|
|
140
|
+
}
|
|
141
|
+
return project;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error("[Api.project] Erreur lors de la création d'un objet projet :", error.message);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Retourne l'instance d'ApiClient.
|
|
150
|
+
*
|
|
151
|
+
* @returns {ApiClient}
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
get client() {
|
|
155
|
+
return this._client;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|