jamespot-user-api 1.0.102 → 1.0.104
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/documentation/assets/search.js +1 -1
- package/documentation/classes/AdminLicenseApi.html +58 -0
- package/documentation/classes/AdminStoreApi.html +1 -1
- package/documentation/classes/AdminUtilsApi.html +3 -0
- package/documentation/classes/JApplicationApi.html +8 -8
- package/documentation/classes/JArticleApi.html +1 -1
- package/documentation/classes/JAssetReservation.html +1 -1
- package/documentation/classes/JAudienceApi.html +1 -1
- package/documentation/classes/JBaseApi.html +1 -1
- package/documentation/classes/JBookmarkApi.html +1 -1
- package/documentation/classes/JCommunityApi.html +1 -1
- package/documentation/classes/JDiapazoneApi.html +1 -1
- package/documentation/classes/JFileApi.html +5 -5
- package/documentation/classes/JFilebankApi.html +1 -1
- package/documentation/classes/JGroupApi.html +9 -9
- package/documentation/classes/JLandApi.html +1 -1
- package/documentation/classes/JMessengerApi.html +1 -1
- package/documentation/classes/JSearchApi.html +6 -6
- package/documentation/classes/JShareApi.html +1 -1
- package/documentation/classes/JTaxonomyApi.html +2 -2
- package/documentation/classes/JUserApi.html +5 -5
- package/documentation/classes/JWedocApi.html +1 -1
- package/documentation/classes/JamespotUserApi.html +1 -1
- package/documentation/classes/Network.html +1 -1
- package/documentation/classes/WindowBrowser.html +1 -1
- package/documentation/enums/StudioApplicationStatus.html +1 -1
- package/documentation/index.html +1 -1
- package/documentation/interfaces/AccessRightObject.html +1 -1
- package/documentation/interfaces/AdminLicenseUser.html +1 -0
- package/documentation/interfaces/ApiDefaultWrapper.html +1 -1
- package/documentation/interfaces/ApiError.html +1 -1
- package/documentation/interfaces/ApiWrapper.html +1 -1
- package/documentation/interfaces/BaseAutocomplete.html +1 -1
- package/documentation/interfaces/BaseMessage.html +1 -1
- package/documentation/interfaces/Category.html +1 -1
- package/documentation/interfaces/FileBankProps.html +1 -1
- package/documentation/interfaces/FolderProps.html +1 -1
- package/documentation/interfaces/ListFilterSpec.html +1 -1
- package/documentation/interfaces/OF.html +1 -1
- package/documentation/interfaces/ObjectListProps.html +1 -1
- package/documentation/interfaces/PagingResults.html +1 -1
- package/documentation/interfaces/RootFolderProps.html +1 -1
- package/documentation/interfaces/SearchCategoryModel.html +1 -1
- package/documentation/interfaces/SearchCategoryValue.html +1 -1
- package/documentation/interfaces/SearchConfig.html +1 -1
- package/documentation/interfaces/SearchFacetModel.html +1 -1
- package/documentation/interfaces/SearchFacetValueModel.html +1 -1
- package/documentation/interfaces/SearchQuery.html +1 -1
- package/documentation/interfaces/SearchQueryFilterModel.html +1 -1
- package/documentation/interfaces/SearchQueryOption.html +1 -1
- package/documentation/interfaces/SearchQueryResult.html +1 -1
- package/documentation/interfaces/SearchQuerySortModel.html +1 -1
- package/documentation/interfaces/SearchResultCatProps.html +1 -1
- package/documentation/interfaces/SearchResultPropsApp.html +1 -1
- package/documentation/interfaces/SearchResultPropsObject.html +1 -1
- package/documentation/interfaces/SpotProps.html +1 -1
- package/documentation/interfaces/Taxonomy.html +1 -1
- package/documentation/interfaces/TaxonomyCreate.html +1 -1
- package/documentation/interfaces/WindowInterface.html +1 -1
- package/documentation/modules.html +17 -3
- package/lib/jamespot-user-api.js +1 -1
- package/lib/jamespot-user-api.js.map +1 -1
- package/lib/src/apis/admin/index.d.ts +3 -0
- package/lib/src/apis/admin/license.d.ts +74 -0
- package/lib/src/apis/{Licenses → admin}/licenses.mock.d.ts +3 -4
- package/lib/src/apis/{adminStore.d.ts → admin/store.d.ts} +2 -3
- package/lib/src/apis/admin/utils.d.ts +8 -0
- package/lib/src/apis/bookmark.d.ts +19 -1
- package/lib/src/apis/group.d.ts +50 -5
- package/lib/src/apis/index.d.ts +1 -2
- package/lib/src/apis/jamespotUserApi.d.ts +3 -3
- package/lib/src/apis/jland/jland.d.ts +2 -3
- package/lib/src/apis/user/user.d.ts +0 -1
- package/lib/src/types/adminLicence.d.ts +43 -0
- package/lib/src/types/adminUtils.d.ts +18 -0
- package/lib/src/types/index.d.ts +3 -0
- package/lib/src/types/model.d.ts +3 -1
- package/lib/src/types/spot.d.ts +5 -0
- package/lib/src/types/tvDisplay.d.ts +32 -0
- package/lib/src/types/user.d.ts +4 -0
- package/lib/src/types/utils.d.ts +26 -3
- package/lib/src/util/Test.d.ts +21 -2
- package/package.json +1 -1
- package/phpunitMock/objectListJamespotUserQueryList-rawList.json +25 -14
- package/documentation/classes/JLicenseApi.html +0 -18
- package/lib/src/apis/Licenses/licenses.d.ts +0 -44
- /package/lib/src/apis/{Licenses → admin}/licences.test.d.ts +0 -0
package/lib/jamespot-user-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var t,e={d:(t,s)=>{for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},s={};e.r(s),e.d(s,{AdminStoreApi:()=>r,JApplicationApi:()=>n,JArticleApi:()=>i,JAssetReservation:()=>c,JAudienceApi:()=>u,JBaseApi:()=>o,JBookmarkApi:()=>p,JCommunityApi:()=>l,JDiapazoneApi:()=>d,JFileApi:()=>h,JFilebankApi:()=>m,JGroupApi:()=>w,JLandApi:()=>b,JLicenseApi:()=>x,JMessengerApi:()=>y,JSearchApi:()=>O,JShareApi:()=>S,JTaxonomyApi:()=>v,JUserApi:()=>j,JWedocApi:()=>A,JamespotUserApi:()=>F,JamespotUserApiInstance:()=>$,Network:()=>C,StudioApplicationStatus:()=>t,UserLevel:()=>U,WindowBrowser:()=>R,allowedFileExtensions:()=>J,api:()=>Q,apiFileToWidgetFile:()=>I,default:()=>z,getExtensionFromName:()=>B,getFileFamily:()=>T,getMimetypeFromExtension:()=>M,jEnsure:()=>E,mimetypeMap:()=>P,network:()=>N});class o{constructor(t){this.network=t}}class r extends o{getItem(t){return this.network.post({o:"adminStore",f:"getItem",uri:t})}checkoutBilling(t){return this.network.postCSRF({o:"adminStore",f:"checkoutBilling",uri:t})}checkoutFinalize(t){return this.network.postCSRF({o:"adminStore",f:"checkoutFinalize",uri:t})}}!function(t){t.local="local",t.installed="installed",t.autosaved="autosaved",t.saved="saved"}(t||(t={}));class n extends o{list(){return this.network.post({o:"studio",f:"list"})}get(t,e){return this.network.post({o:"studio",f:"get",idApp:t,status:e})}install(t){return this.network.postCSRF({o:"studio",f:"install",value:t})}suspend(t){return this.network.postCSRF({o:"studio",f:"suspend",idApp:t})}restart(t){return this.network.postCSRF({o:"studio",f:"restart",idApp:t})}save(e,s,o){if(o===t.saved||o===t.autosaved)return this.network.postCSRF({o:"studio",f:"save",idApp:e,value:s,status:o});throw"Invalid status value"}delete(t,e){return s=this,o=void 0,n=function*(){return this.network.postCSRF({o:"studio",f:"delete",idApp:t,status:e}).then((t=>{if(0===t.error)return t.messages;throw t.messages}))},new((r=void 0)||(r=Promise))((function(t,e){function i(t){try{c(n.next(t))}catch(t){e(t)}}function a(t){try{c(n.throw(t))}catch(t){e(t)}}function c(e){var s;e.done?t(e.value):(s=e.value,s instanceof r?s:new r((function(t){t(s)}))).then(i,a)}c((n=n.apply(s,o||[])).next())}));var s,o,r,n}cssClassList(){return this.network.post({o:"studio",f:"icons"})}}class i extends o{list(t){return this.network.post(Object.assign({o:"objectList",f:"jamespotArticleQueryList"},t))}get(t){return this.network.post(Object.assign({o:"article",f:"get"},t))}create(t,e){return this.network.maybePostToken(Object.assign({o:"article",f:"create",format:null!=e?e:"raw-list"},t))}update(t){return this.network.post(Object.assign({o:"article",f:"update"},t))}delete(t){return this.network.postCSRF({o:"article",f:"delete",idArticle:t})}count(t){return this.network.post({o:"article",f:"count",type:t})}}var a=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(s[o[r]]=t[o[r]])}return s};class c extends o{configuration(){return this.network.post({o:"assetReservation",f:"configuration"})}createReservation(t){return this.network.postCSRF(Object.assign({o:"assetReservation",f:"createReservation",format:"raw-list"},t))}getReservations(t){var{format:e="raw-list"}=t,s=a(t,["format"]);return this.network.post(Object.assign({o:"assetReservation",f:"getReservations",format:e},s))}cancelReservation(t){return this.network.post({o:"assetReservation",f:"cancelReservation",format:"raw-list",idArticle:t})}bookByDate(t){var{format:e="raw-list"}=t,s=a(t,["format"]);return this.network.post(Object.assign({o:"assetReservation",f:"BookByDate",format:e},s))}getList(t){var{format:e="raw-list"}=t,s=a(t,["format"]);return this.network.post(Object.assign({o:"objectList",f:"assetReservationList",format:e},s))}}class u extends o{autocomplete(t){return this.network.post({o:"autocomplete",f:"audience",q:t}).then((t=>{if(Array.isArray(t.result))return t.result;throw"Bad response from backend"}))}}class p extends o{getFormattedList(t,e){return this.network.post(Object.assign({o:"objectList",f:"bookmarksList",format:e},t))}addFormattedLink(t,e,s){const o=null!=s?s:"list";return this.network.post({o:"custom",f:"actionAdd",type:"bookmarkLink",targetId:t,targetType:e,format:o})}addBookmark(t,e){return this.network.postCSRF(Object.assign({o:"bookmarks",f:"add"},t))}delete(t){return this.network.postCSRF({o:"bookmarks",f:"delete",bookmarkID:t})}rename(t,e,s){return this.network.postCSRF({o:"bookmarks",f:"rename",bookmarkID:t,bookmarkLabel:e,bookmarkUrl:s})}move(t,e,s){return this.network.postCSRF({o:"bookmarks",f:"move",bookmarkID:t,bookmarkReference:e,bookmarkPosition:s})}}class l extends o{sendRequest(t,e){return this.network.post({o:"community",f:"sendRequest",message:t,idUserTo:e})}autocomplete(t){return this.network.post({o:"autocomplete",f:"community",q:t}).then((t=>t.result))}}class d extends o{create(t,e,s,o,r){return this.network.post({o:"article",f:"create",type:t,token:e,title:s,dateStart:o,publishTo:r})}getList(t="",e=[],s=[],o=1,r="list"){return this.network.post({o:"objectList",f:"diapazoneQueryList",query:t,filters:e,orders:s,page:o,format:r}).then((t=>{const e=t.result;if(Array.isArray(e.data))return e;throw{error:t.error,messages:t.messages}}))}}var f=function(t,e,s,o){return new(s||(s=Promise))((function(r,n){function i(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};class h extends o{upload(t){const e=new FormData;return e.append("attrName",t.attrName),t.file?e.append(t.attrName,t.file):t.url&&e.append("url",t.url),e.append("token",t.token),this.network.postFile(e)}uploadMany(t){return f(this,void 0,void 0,(function*(){return Promise.all(t.map((t=>this.upload(t))))}))}update(t,e,s){return f(this,void 0,void 0,(function*(){return this.network.post({o:"file",f:"update",idFile:t,type:e,cropDatas:{w:s.width,h:s.height,x:s.x,y:s.y,rotation:s.rotation,rotateBeforeCrop:!0},killSize:s.killSize}).then((t=>{if(!t.result.crop)return t;const e=JSON.parse(t.result.crop);return Object.assign(Object.assign({},t),{result:Object.assign(Object.assign({},t.result),{crop:{width:e.w,height:e.h,x:e.x,y:e.y,rotation:e.rotation}})})}))}))}deleteFile(t,e,s){return f(this,void 0,void 0,(function*(){return this.network.post({o:"file",f:"delete",idFile:t,attrName:e,token:s})}))}deleteImage(t,e){return f(this,void 0,void 0,(function*(){return this.network.post({o:"file",f:"deleteImage",id:t,type:e})}))}}class m extends o{getBanks(t="list"){return this.network.post({o:"fileBank",f:"getBanks",format:t}).then((t=>t.result))}getFolders(t){return this.network.post({o:"fileBank",f:"getFolders",parentURI:t}).then((t=>t.result))}}class w extends o{create(t,e){return this.network.post(Object.assign(Object.assign({o:"spot",f:"create"},t),{format:e}))}update(t,e){const{spotBanner:s}=t,o=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(s[o[r]]=t[o[r]])}return s}(t,["spotBanner"]);return this.network.postCSRF(Object.assign(Object.assign({o:"spot",f:"update"},o),{format:e}))}getSpot(t,e){return this.network.post({o:"spot",f:"getSpot",idSpot:t,format:e})}getProperties(t){return this.network.post({o:"spot",f:"getProperties",idSpot:t})}getApplications(){return this.network.post({o:"spot",f:"get-available-widget"})}getCategories(){return this.network.post({o:"spot",f:"get-categories"})}getObjectListJamespotSpotMembers(t,e,s,o=1){return this.network.post({o:"objectListJamespot",f:"SpotMembers",idSpot:t,limit:s,page:o,format:"raw-little",query:e})}}class g extends o{list(t,e,s,o=[{name:"dateCreation",sort:"DESC"}]){return new i(this.network).list({type:"aseiClearanceTicket",format:"raw-view",limit:e,page:t,orders:o,filters:s})}requestStatus(t,e,s){return this.network.post({o:"asei",f:"setStatus",uri:t,requestedStatus:e,audience:s}).then((t=>{if(t&&t.result)return t.result;throw"Bad response from backend"}))}getDedicatedGroups(){return this.network.post({o:"asei",f:"getDedicatedGroups"}).then((t=>{if(t&&t.result)return t.result;throw"Bad response from backend"}))}getConfiguration(){return this.network.post({o:"asei",f:"configuration"}).then((t=>{if(t&&t.result)return t.result.right;throw"Bad response from backend"}))}}class k extends o{GetUnclassifiedFiles(t="raw-list"){return this.network.post({o:"objectListMediaLibrary",f:"GetUnclassifiedFiles",format:t})}}class b extends o{getLogs({dateEnd:t,idLogMax:e}){return this.network.post({o:"jLand",f:"adminLogs",dateEnd:t,idLogMax:e})}getStats({map:t,dateStart:e,dateEnd:s}){return this.network.post({o:"jLand",f:"adminStats",map:t,dateStart:e,dateEnd:s})}getAllMapsAsAdmin(t="raw-list,licenses"){return this.network.post({o:"objectListJLand",f:"jLandList",format:t})}createMap(t,e="raw-list"){return this.network.maybePostToken(Object.assign(Object.assign({},t),{o:"article",f:"create",format:e,type:"jlandmap"}))}}class y extends o{sendMessage(t,e){return this.network.post({o:"messenger",f:"newMessage",idDiscussion:e,msg:{description:t}})}getOrCreateDiscussion(t,e){const s=t<e?`${t}.${e}`:`${e}.${t}`;return this.network.post({o:"messenger",f:"getDiscussion",idDiscussion:s,type:"messengerUser",idUserTo:e})}}class O extends o{getConfig(){return this.network.post({o:"search",f:"getConfig"})}proposition({query:t,format:e},s){return this.network.post({o:"search",f:"proposition",query:t,format:e||"little"},s)}searchQuery(t,e){const{keywords:s,category:o,facetCategories:r,filters:n,page:i,limit:a,sort:c,options:u}=t;return this.network.post({o:"search",f:"query",keywords:s,category:o,facetCategories:r,filters:n,page:i,limit:a,sort:c,options:u},e)}getLastQueries(){return this.network.post({o:"search",f:"getLastQueries"})}getAdminConfig(){return this.network.post({o:"search",f:"getAdminConfig"})}setAdminConfig(t){return this.network.post({o:"search",f:"setAdminConfig",config:t})}}class v extends o{list(){return this.network.post({o:"taxonomy",f:"list"}).then((t=>{if(Array.isArray(t.result))return t.result;throw"Bad response from backend"}))}create(t){return this.network.post(Object.assign({o:"taxonomy",f:"create"},t))}autocomplete(t,e){return this.network.post({o:"autocomplete",f:"taxonomy",q:e,idTaxonomy:t,idToUri:!1})}autocompleteList(t){return this.network.post(Object.assign({o:"objectListTaxonomy",f:"concept"},t))}autocompleteHierarchy(t){return this.network.post(Object.assign({o:"objectListTaxonomyHierarchy",f:"concept"},t))}}class j extends o{autocomplete(t){return this.network.post({o:"autocomplete",f:"user",q:t,idToUri:!1}).then((t=>t.result))}get(t,e="little"){return this.network.post({o:"user",f:"get",uri:t,format:e})}configuration(){return this.network.post({o:"userDirectory",f:"configuration"})}userQueryList(t){return this.network.post(Object.assign({o:"objectList",f:"JamespotUserQueryList"},t))}userMap(t){return this.network.post(Object.assign({o:"objectListJamespot",f:"userMap"},t))}userBusinessContactQueryList(t){return this.network.post(Object.assign({o:"businessContact",f:"queryList"},t))}userCreateBusinessContact(t){const e=Object.assign(Object.assign({},t),{pseudo:t.title,firstName:t.firstname,lastName:t.lastname,champ1:t.field1,champ2:t.field2,champ3:t.field3,champ4:t.field4,champ5:t.field5}),s=Object.assign(Object.assign({},e),{type:"businessContactCard",publishTo:"networkPublic/1"});return window.JamespotUserApi.article.create(s)}userUpdateBusinessContact(t){const e=Object.assign(Object.assign({},t),{pseudo:t.title,firstName:t.firstname,lastName:t.lastname,champ1:t.field1,champ2:t.field2,champ3:t.field3,champ4:t.field4,champ5:t.field5}),s=Object.assign(Object.assign({},e),{uri:t.uri,publishTo:"networkPublic/1"});return window.JamespotUserApi.article.update(s)}userDeleteBusinessContact(t){return window.JamespotUserApi.article.delete(t)}userAddContact(t){return this.network.post({o:"user",f:"addContact",idUser:t})}userRemoveContact(t){return this.network.post({o:"user",f:"removeContact",idUser:t})}signIn(t,e){return this.network.post({o:"user",f:"signIn",mail:t,password:e})}}class A extends o{getFiles(t){return this.network.post(Object.assign({o:"onlyOffice",f:"getFiles"},t)).then((t=>{const e=t.result;if(Array.isArray(e.data))return{page:e.page,cnt:e.cnt,limit:e.limit,data:e.data};throw{error:t.error,messages:t.messages}}))}getFile(t,e){return this.network.post({o:"onlyOffice",f:"getFile",idFile:t,hash:e}).then((t=>t.result))}getTemplates(){return this.network.post({o:"onlyOffice",f:"getTemplates"}).then((t=>t.result))}duplicateFile(t,e,s){return this.network.post({o:"onlyOffice",f:"duplicateFile",idFile:t,title:e,publishTo:s})}deleteFile(t){return this.network.post({o:"onlyOffice",f:"deleteFile",idFile:t})}createFile(t,e,s){return this.network.post({o:"onlyOffice",f:"createFile",title:t,type:e,publishTo:s}).then((t=>t.result))}updateFile(t,e){return this.network.post({o:"onlyOffice",f:"updateFile",idFile:t,title:e})}getFileInfo(t,e){return this.network.post({o:"onlyOffice",f:"GetFileInfo",idFile:t,mode:e})}}class S extends o{setObjectAccessRequest(t,e,s,o){return this.network.post({o:"onlyOffice",f:"setObjectAccessRequest",uri:t,idUser:e,requestAccessValue:s,requestResponseMessage:o})}getObjectAccessRequest(t,e){return this.network.post({o:"onlyOffice",f:"getObjectAccessRequest",uri:t,idUser:e}).then((t=>t.result))}getObject(t){return this.network.post({o:"onlyOffice",f:"getObject",uri:t}).then((t=>t.result))}askObjectAccess(t,e,s){return this.network.post({o:"onlyOffice",f:"askObjectAccess",uri:t,askAccess:e,askMessage:s}).then((t=>t.result))}setObjectAccess(t,e,s,o){return this.network.post({o:"onlyOffice",f:"setObjectAccess",uri:t,access:e,message:s,generalAccessRule:o}).then((t=>t.result))}getObjectAccess(t){return this.network.post({o:"onlyOffice",f:"getObjectAccess",uri:t}).then((t=>({audience:t.result.audience,read:t.result.read,write:t.result.write})))}}class x extends o{getLicensesAssigned(t){return this.network.post({o:"licenseManager",f:"getLicensesAssigned",type:t})}countLicenseNotAssigned(t){return this.network.post({o:"licenseManager",f:"countLicensesNotAssigned",type:t})}assignLicense(t){return this.network.post({o:"licenseManager",f:"assignLicense",uri:t})}unassignLicense(t){return this.network.post({o:"licenseManager",f:"unassignLicense",uri:t})}}class F{constructor(t){this.version="1.0",this.network=t,this.admin={store:new r(this.network)},this.application=new n(this.network),this.article=new i(this.network),this.asei=new g(this.network),this.assetReservation=new c(this.network),this.audience=new u(this.network),this.bookmark=new p(this.network),this.community=new l(this.network),this.diapazone=new d(this.network),this.file=new h(this.network),this.filebank=new m(this.network),this.group=new w(this.network),this.jland=new b(this.network),this.mediaLibrary=new k(this.network),this.license=new x(this.network),this.messenger=new y(this.network),this.search=new O(this.network),this.share=new S(this.network),this.taxonomy=new v(this.network),this.user=new j(this.network),this.wedoc=new A(this.network)}}var L=function(t,e,s,o){return new(s||(s=Promise))((function(r,n){function i(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};class C{constructor(t,e="api-front"){this.window=t,this.action=e}static _formatPostOptions(t){const e=t?{body:JSON.stringify(t)}:void 0;return Object.assign({method:"POST",credentials:"same-origin"},e)}static _formatQueryOptions(t){return Object.entries(t).reduce(((t,[e,s])=>(t.append(e,s.toString()),t)),new URLSearchParams).toString()}getUrl(t,e){return L(this,void 0,void 0,(function*(){const s=yield this.window.getBackendUrl();let o;try{o=new URL(`/${this.action}/${t}/${e}`,s).href}catch(r){o=`${s}/${this.action}/${t}/${e}`}return o}))}getHostname(){return L(this,void 0,void 0,(function*(){const t=(yield this.window.getBackendUrl()).split("//");return t.length>1?t[1]:t[0]}))}fetch(t,e){var{o:s,f:o}=t,r=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(s[o[r]]=t[o[r]])}return s}(t,["o","f"]);return L(this,void 0,void 0,(function*(){void 0===e&&(e=null);const t=yield this.getUrl(s,o);return this.window.fetch(t,Object.assign(Object.assign({},C._formatPostOptions(r)),{signal:e}))}))}post(t,e){return this.fetch(t,e).then((t=>t.json())).then((t=>{if(0===t.error)return t;throw{error:t.error,errorMsg:t.errorMsg,messages:t.messages}})).catch((t=>{if(e&&e.aborted)throw{error:-1,aborted:!0};throw t}))}postFile(t){return L(this,void 0,void 0,(function*(){const e=yield this.getUrl("file","create");if(!t.get("token")){const{result:e}=yield this.token();t.append("token",e)}return this.window.fetch(e,{method:"POST",credentials:"same-origin",body:t}).then((t=>t.json()))}))}postCSRF(t){return this.tokenCSRF().then((e=>this.post(Object.assign(t,{tokenCSRF:e.result}))))}maybePostCSRF(t){return"tokenCSRF"in t&&t.tokenCSRF?this.post(t):this.postCSRF(t)}postToken(t){return this.token().then((e=>this.post(Object.assign(t,{token:e.result}))))}maybePostToken(t){return"token"in t&&t.token?this.post(t):this.postToken(t)}token(){return this.post({o:"misc",f:"token"})}tokenCSRF(){return this.post({o:"misc",f:"tokenCSRF"})}}class R{getBackendUrl(){return t=this,e=void 0,o=function*(){const t=window.location;return`${t.protocol}//${t.host}`},new((s=void 0)||(s=Promise))((function(r,n){function i(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}));var t,e,s,o}fetch(t,e){return window.fetch(t,e)}}const U={ADMIN:9,USER:5,EXTERNAL:3,GUEST:0},J=["docx","xlsx","pptx","pdf","jpeg","png","zip","mp3","mp4","jpg","txt"],P={docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",pdf:"application/pdf",jpeg:"image/jpeg",jpg:"image/jpg",png:"image/png",zip:"application/zip",mp3:"audio/mp3",mp4:"video/mp4"};function B(t){const e=String(t).split(".").pop();if(void 0!==e&&J.find((t=>t===e.toLocaleLowerCase())))return e}function T(t){return t&&t.startsWith("application/")?"application":t&&t.startsWith("image/")?"image":t&&t.startsWith("video/")?"video":t&&t.startsWith("audio/")?"audio":void 0}function M(t){var e;const s=void 0!==t?String(t).toLocaleLowerCase():"noExt";return null!==(e=P[s])&&void 0!==e?e:"txt"}function I(t){const e=M(B(t.name));return{id:parseInt(t.id),filename:t.name,mimetype:e,dimension:t.imagesize}}function q(t){const e=t;return e&&"number"==typeof e.id&&"number"==typeof e.targetId}const D={bookmarkLink:q},E={isBookmarkLink:function(t){return"targetId"in t&&!!t.targetId},isBookmarkCustom:function(t){const e=t;return void 0!==e.bookmarkLabel||void 0!==e.bookmarkMeta||void 0!==e.bookmarkUrl},isBookmarkRawList:q,objectIsType:function(t,e){return null!=e&&D[t](e)}},N=new C(new R),$=new F(N);window.JamespotUserApi=$;const z=$,Q=F;module.exports=s})();
|
|
1
|
+
(()=>{"use strict";var t,e={d:(t,s)=>{for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},s={};e.r(s),e.d(s,{AdminLicenseApi:()=>r,AdminStoreApi:()=>n,AdminUtilsApi:()=>i,JApplicationApi:()=>a,JArticleApi:()=>c,JAssetReservation:()=>p,JAudienceApi:()=>l,JBaseApi:()=>o,JBookmarkApi:()=>d,JCommunityApi:()=>f,JDiapazoneApi:()=>h,JFileApi:()=>g,JFilebankApi:()=>w,JGroupApi:()=>k,JLandApi:()=>O,JMessengerApi:()=>v,JSearchApi:()=>j,JShareApi:()=>F,JTaxonomyApi:()=>A,JUserApi:()=>S,JWedocApi:()=>L,JamespotUserApi:()=>x,JamespotUserApiInstance:()=>$,Network:()=>R,StudioApplicationStatus:()=>t,UserLevel:()=>U,WindowBrowser:()=>M,allowedFileExtensions:()=>P,api:()=>W,apiFileToWidgetFile:()=>q,default:()=>Q,getExtensionFromName:()=>J,getFileFamily:()=>T,getMimetypeFromExtension:()=>I,jEnsure:()=>N,mimetypeMap:()=>B,network:()=>z});class o{constructor(t){this.network=t}}class r extends o{getLicenseUserStatistics(){return this.network.post({o:"licenseManager",f:"userStatistics"})}assignLicense(t){return this.network.postCSRF({o:"licenseManager",f:"assignLicense",uri:t})}unAssignLicense(t){return this.network.postCSRF({o:"licenseManager",f:"unassignLicense",uri:t})}getAssignmentMode(t){return this.network.post({o:"licenseManager",f:"getAssignmentMode",type:t})}setAssignmentMode(t,e){return this.network.postCSRF({o:"licenseManager",f:"setAssignmentMode",value:e,type:t})}assignPossiblesLicenses(t){return this.network.postCSRF({o:"licenseManager",f:"assignPossiblesLicenses",type:t})}unAssignUnusedLicenses(t){return this.network.postCSRF({o:"licenseManager",f:"unassignUnusedLicenses",type:t})}optimizeLicenses(t){return this.network.postCSRF({o:"licenseManager",f:"optimizeLicenses",type:t})}getObjectsWithoutLicense(t,e){return this.network.post({o:"licenseManager",f:"countObjectsWithoutLicense",type:t,filter:e})}getLicensesNotAssigned(t){return this.network.post({o:"licenseManager",f:"countLicensesNotAssigned",type:t})}getLicensesAssigned(t){return this.network.post({o:"licenseManager",f:"getLicensesAssigned",type:t})}}class n extends o{getItem(t){return this.network.post({o:"adminStore",f:"getItem",uri:t})}checkoutBilling(t){return this.network.postCSRF({o:"adminStore",f:"checkoutBilling",uri:t})}checkoutFinalize(t){return this.network.postCSRF({o:"adminStore",f:"checkoutFinalize",uri:t})}}class i extends o{getApps(){return this.network.post({o:"admin",f:"apps"})}}!function(t){t.local="local",t.installed="installed",t.autosaved="autosaved",t.saved="saved"}(t||(t={}));class a extends o{list(){return this.network.post({o:"studio",f:"list"})}get(t,e){return this.network.post({o:"studio",f:"get",idApp:t,status:e})}install(t){return this.network.postCSRF({o:"studio",f:"install",value:t})}suspend(t){return this.network.postCSRF({o:"studio",f:"suspend",idApp:t})}restart(t){return this.network.postCSRF({o:"studio",f:"restart",idApp:t})}save(e,s,o){if(o===t.saved||o===t.autosaved)return this.network.postCSRF({o:"studio",f:"save",idApp:e,value:s,status:o});throw"Invalid status value"}delete(t,e){return s=this,o=void 0,n=function*(){return this.network.postCSRF({o:"studio",f:"delete",idApp:t,status:e}).then((t=>{if(0===t.error)return t.messages;throw t.messages}))},new((r=void 0)||(r=Promise))((function(t,e){function i(t){try{c(n.next(t))}catch(t){e(t)}}function a(t){try{c(n.throw(t))}catch(t){e(t)}}function c(e){var s;e.done?t(e.value):(s=e.value,s instanceof r?s:new r((function(t){t(s)}))).then(i,a)}c((n=n.apply(s,o||[])).next())}));var s,o,r,n}cssClassList(){return this.network.post({o:"studio",f:"icons"})}}class c extends o{list(t){return this.network.post(Object.assign({o:"objectList",f:"jamespotArticleQueryList"},t))}get(t){return this.network.post(Object.assign({o:"article",f:"get"},t))}create(t,e){return this.network.maybePostToken(Object.assign({o:"article",f:"create",format:null!=e?e:"raw-list"},t))}update(t){return this.network.post(Object.assign({o:"article",f:"update"},t))}delete(t){return this.network.postCSRF({o:"article",f:"delete",idArticle:t})}count(t){return this.network.post({o:"article",f:"count",type:t})}}var u=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(s[o[r]]=t[o[r]])}return s};class p extends o{configuration(){return this.network.post({o:"assetReservation",f:"configuration"})}createReservation(t){return this.network.postCSRF(Object.assign({o:"assetReservation",f:"createReservation",format:"raw-list"},t))}getReservations(t){var{format:e="raw-list"}=t,s=u(t,["format"]);return this.network.post(Object.assign({o:"assetReservation",f:"getReservations",format:e},s))}cancelReservation(t){return this.network.post({o:"assetReservation",f:"cancelReservation",format:"raw-list",idArticle:t})}bookByDate(t){var{format:e="raw-list"}=t,s=u(t,["format"]);return this.network.post(Object.assign({o:"assetReservation",f:"BookByDate",format:e},s))}getList(t){var{format:e="raw-list"}=t,s=u(t,["format"]);return this.network.post(Object.assign({o:"objectList",f:"assetReservationList",format:e},s))}}class l extends o{autocomplete(t){return this.network.post({o:"autocomplete",f:"audience",q:t}).then((t=>{if(Array.isArray(t.result))return t.result;throw"Bad response from backend"}))}}class d extends o{getFormattedList(t,e){return this.network.post(Object.assign({o:"objectList",f:"bookmarksList",format:e},t))}addFormattedLink(t,e,s){const o=null!=s?s:"list";return this.network.post({o:"custom",f:"actionAdd",type:"bookmarkLink",targetId:t,targetType:e,format:o})}addBookmark(t,e){return this.network.postCSRF(Object.assign({o:"bookmarks",f:"add"},t))}delete(t){return this.network.postCSRF({o:"bookmarks",f:"delete",bookmarkID:t})}rename(t,e,s){return this.network.postCSRF({o:"bookmarks",f:"rename",bookmarkID:t,bookmarkLabel:e,bookmarkUrl:s})}move(t,e,s){return this.network.postCSRF({o:"bookmarks",f:"move",bookmarkID:t,bookmarkReference:e,bookmarkPosition:s})}}class f extends o{sendRequest(t,e){return this.network.post({o:"community",f:"sendRequest",message:t,idUserTo:e})}autocomplete(t){return this.network.post({o:"autocomplete",f:"community",q:t}).then((t=>t.result))}}class h extends o{create(t,e,s,o,r){return this.network.post({o:"article",f:"create",type:t,token:e,title:s,dateStart:o,publishTo:r})}getList(t="",e=[],s=[],o=1,r="list"){return this.network.post({o:"objectList",f:"diapazoneQueryList",query:t,filters:e,orders:s,page:o,format:r}).then((t=>{const e=t.result;if(Array.isArray(e.data))return e;throw{error:t.error,messages:t.messages}}))}}var m=function(t,e,s,o){return new(s||(s=Promise))((function(r,n){function i(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};class g extends o{upload(t){const e=new FormData;return e.append("attrName",t.attrName),t.file?e.append(t.attrName,t.file):t.url&&e.append("url",t.url),e.append("token",t.token),this.network.postFile(e)}uploadMany(t){return m(this,void 0,void 0,(function*(){return Promise.all(t.map((t=>this.upload(t))))}))}update(t,e,s){return m(this,void 0,void 0,(function*(){return this.network.post({o:"file",f:"update",idFile:t,type:e,cropDatas:{w:s.width,h:s.height,x:s.x,y:s.y,rotation:s.rotation,rotateBeforeCrop:!0},killSize:s.killSize}).then((t=>{if(!t.result.crop)return t;const e=JSON.parse(t.result.crop);return Object.assign(Object.assign({},t),{result:Object.assign(Object.assign({},t.result),{crop:{width:e.w,height:e.h,x:e.x,y:e.y,rotation:e.rotation}})})}))}))}deleteFile(t,e,s){return m(this,void 0,void 0,(function*(){return this.network.post({o:"file",f:"delete",idFile:t,attrName:e,token:s})}))}deleteImage(t,e){return m(this,void 0,void 0,(function*(){return this.network.post({o:"file",f:"deleteImage",id:t,type:e})}))}}class w extends o{getBanks(t="list"){return this.network.post({o:"fileBank",f:"getBanks",format:t}).then((t=>t.result))}getFolders(t){return this.network.post({o:"fileBank",f:"getFolders",parentURI:t}).then((t=>t.result))}}class k extends o{create(t,e){return this.network.post(Object.assign(Object.assign({o:"spot",f:"create"},t),{format:e}))}update(t,e){const{spotBanner:s}=t,o=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(s[o[r]]=t[o[r]])}return s}(t,["spotBanner"]);return this.network.postCSRF(Object.assign(Object.assign({o:"spot",f:"update"},o),{format:e}))}getSpot(t,e){return this.network.post({o:"spot",f:"getSpot",idSpot:t,format:e})}getProperties(t){return this.network.post({o:"spot",f:"getProperties",idSpot:t})}getApplications(){return this.network.post({o:"spot",f:"get-available-widget"})}getCategories(){return this.network.post({o:"spot",f:"get-categories"})}getObjectListJamespotSpotMembers(t,e,s,o=1){return this.network.post({o:"objectListJamespot",f:"SpotMembers",idSpot:t,limit:s,page:o,format:"raw-little",query:e})}}class b extends o{list(t,e,s,o=[{name:"dateCreation",sort:"DESC"}]){return new c(this.network).list({type:"aseiClearanceTicket",format:"raw-view",limit:e,page:t,orders:o,filters:s})}requestStatus(t,e,s){return this.network.post({o:"asei",f:"setStatus",uri:t,requestedStatus:e,audience:s}).then((t=>{if(t&&t.result)return t.result;throw"Bad response from backend"}))}getDedicatedGroups(){return this.network.post({o:"asei",f:"getDedicatedGroups"}).then((t=>{if(t&&t.result)return t.result;throw"Bad response from backend"}))}getConfiguration(){return this.network.post({o:"asei",f:"configuration"}).then((t=>{if(t&&t.result)return t.result.right;throw"Bad response from backend"}))}}class y extends o{GetUnclassifiedFiles(t="raw-list"){return this.network.post({o:"objectListMediaLibrary",f:"GetUnclassifiedFiles",format:t})}}class O extends o{getLogs({dateEnd:t,idLogMax:e}){return this.network.post({o:"jLand",f:"adminLogs",dateEnd:t,idLogMax:e})}getStats({map:t,dateStart:e,dateEnd:s}){return this.network.post({o:"jLand",f:"adminStats",map:t,dateStart:e,dateEnd:s})}getAllMapsAsAdmin(t="raw-list,licenses"){return this.network.post({o:"objectListJLand",f:"jLandList",format:t})}createMap(t,e="raw-list"){return this.network.maybePostToken(Object.assign(Object.assign({},t),{o:"article",f:"create",format:e,type:"jlandmap"}))}}class v extends o{sendMessage(t,e){return this.network.post({o:"messenger",f:"newMessage",idDiscussion:e,msg:{description:t}})}getOrCreateDiscussion(t,e){const s=t<e?`${t}.${e}`:`${e}.${t}`;return this.network.post({o:"messenger",f:"getDiscussion",idDiscussion:s,type:"messengerUser",idUserTo:e})}}class j extends o{getConfig(){return this.network.post({o:"search",f:"getConfig"})}proposition({query:t,format:e},s){return this.network.post({o:"search",f:"proposition",query:t,format:e||"little"},s)}searchQuery(t,e){const{keywords:s,category:o,facetCategories:r,filters:n,page:i,limit:a,sort:c,options:u}=t;return this.network.post({o:"search",f:"query",keywords:s,category:o,facetCategories:r,filters:n,page:i,limit:a,sort:c,options:u},e)}getLastQueries(){return this.network.post({o:"search",f:"getLastQueries"})}getAdminConfig(){return this.network.post({o:"search",f:"getAdminConfig"})}setAdminConfig(t){return this.network.post({o:"search",f:"setAdminConfig",config:t})}}class A extends o{list(){return this.network.post({o:"taxonomy",f:"list"}).then((t=>{if(Array.isArray(t.result))return t.result;throw"Bad response from backend"}))}create(t){return this.network.post(Object.assign({o:"taxonomy",f:"create"},t))}autocomplete(t,e){return this.network.post({o:"autocomplete",f:"taxonomy",q:e,idTaxonomy:t,idToUri:!1})}autocompleteList(t){return this.network.post(Object.assign({o:"objectListTaxonomy",f:"concept"},t))}autocompleteHierarchy(t){return this.network.post(Object.assign({o:"objectListTaxonomyHierarchy",f:"concept"},t))}}class S extends o{autocomplete(t){return this.network.post({o:"autocomplete",f:"user",q:t,idToUri:!1}).then((t=>t.result))}get(t,e="little"){return this.network.post({o:"user",f:"get",uri:t,format:e})}configuration(){return this.network.post({o:"userDirectory",f:"configuration"})}userQueryList(t){return this.network.post(Object.assign({o:"objectList",f:"JamespotUserQueryList"},t))}userMap(t){return this.network.post(Object.assign({o:"objectListJamespot",f:"userMap"},t))}userBusinessContactQueryList(t){return this.network.post(Object.assign({o:"businessContact",f:"queryList"},t))}userCreateBusinessContact(t){const e=Object.assign(Object.assign({},t),{pseudo:t.title,firstName:t.firstname,lastName:t.lastname,champ1:t.field1,champ2:t.field2,champ3:t.field3,champ4:t.field4,champ5:t.field5}),s=Object.assign(Object.assign({},e),{type:"businessContactCard",publishTo:"networkPublic/1"});return window.JamespotUserApi.article.create(s)}userUpdateBusinessContact(t){const e=Object.assign(Object.assign({},t),{pseudo:t.title,firstName:t.firstname,lastName:t.lastname,champ1:t.field1,champ2:t.field2,champ3:t.field3,champ4:t.field4,champ5:t.field5}),s=Object.assign(Object.assign({},e),{uri:t.uri,publishTo:"networkPublic/1"});return window.JamespotUserApi.article.update(s)}userDeleteBusinessContact(t){return window.JamespotUserApi.article.delete(t)}userAddContact(t){return this.network.post({o:"user",f:"addContact",idUser:t})}userRemoveContact(t){return this.network.post({o:"user",f:"removeContact",idUser:t})}signIn(t,e){return this.network.post({o:"user",f:"signIn",mail:t,password:e})}}class L extends o{getFiles(t){return this.network.post(Object.assign({o:"onlyOffice",f:"getFiles"},t)).then((t=>{const e=t.result;if(Array.isArray(e.data))return{page:e.page,cnt:e.cnt,limit:e.limit,data:e.data};throw{error:t.error,messages:t.messages}}))}getFile(t,e){return this.network.post({o:"onlyOffice",f:"getFile",idFile:t,hash:e}).then((t=>t.result))}getTemplates(){return this.network.post({o:"onlyOffice",f:"getTemplates"}).then((t=>t.result))}duplicateFile(t,e,s){return this.network.post({o:"onlyOffice",f:"duplicateFile",idFile:t,title:e,publishTo:s})}deleteFile(t){return this.network.post({o:"onlyOffice",f:"deleteFile",idFile:t})}createFile(t,e,s){return this.network.post({o:"onlyOffice",f:"createFile",title:t,type:e,publishTo:s}).then((t=>t.result))}updateFile(t,e){return this.network.post({o:"onlyOffice",f:"updateFile",idFile:t,title:e})}getFileInfo(t,e){return this.network.post({o:"onlyOffice",f:"GetFileInfo",idFile:t,mode:e})}}class F extends o{setObjectAccessRequest(t,e,s,o){return this.network.post({o:"onlyOffice",f:"setObjectAccessRequest",uri:t,idUser:e,requestAccessValue:s,requestResponseMessage:o})}getObjectAccessRequest(t,e){return this.network.post({o:"onlyOffice",f:"getObjectAccessRequest",uri:t,idUser:e}).then((t=>t.result))}getObject(t){return this.network.post({o:"onlyOffice",f:"getObject",uri:t}).then((t=>t.result))}askObjectAccess(t,e,s){return this.network.post({o:"onlyOffice",f:"askObjectAccess",uri:t,askAccess:e,askMessage:s}).then((t=>t.result))}setObjectAccess(t,e,s,o){return this.network.post({o:"onlyOffice",f:"setObjectAccess",uri:t,access:e,message:s,generalAccessRule:o}).then((t=>t.result))}getObjectAccess(t){return this.network.post({o:"onlyOffice",f:"getObjectAccess",uri:t}).then((t=>({audience:t.result.audience,read:t.result.read,write:t.result.write})))}}class x{constructor(t){this.version="1.0",this.network=t,this.admin={license:new r(this.network),store:new n(this.network),utils:new i(this.network)},this.application=new a(this.network),this.article=new c(this.network),this.asei=new b(this.network),this.assetReservation=new p(this.network),this.audience=new l(this.network),this.bookmark=new d(this.network),this.community=new f(this.network),this.diapazone=new h(this.network),this.file=new g(this.network),this.filebank=new w(this.network),this.group=new k(this.network),this.jland=new O(this.network),this.mediaLibrary=new y(this.network),this.messenger=new v(this.network),this.search=new j(this.network),this.share=new F(this.network),this.taxonomy=new A(this.network),this.user=new S(this.network),this.wedoc=new L(this.network)}}var C=function(t,e,s,o){return new(s||(s=Promise))((function(r,n){function i(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};class R{constructor(t,e="api-front"){this.window=t,this.action=e}static _formatPostOptions(t){const e=t?{body:JSON.stringify(t)}:void 0;return Object.assign({method:"POST",credentials:"same-origin"},e)}static _formatQueryOptions(t){return Object.entries(t).reduce(((t,[e,s])=>(t.append(e,s.toString()),t)),new URLSearchParams).toString()}getUrl(t,e){return C(this,void 0,void 0,(function*(){const s=yield this.window.getBackendUrl();let o;try{o=new URL(`/${this.action}/${t}/${e}`,s).href}catch(r){o=`${s}/${this.action}/${t}/${e}`}return o}))}getHostname(){return C(this,void 0,void 0,(function*(){const t=(yield this.window.getBackendUrl()).split("//");return t.length>1?t[1]:t[0]}))}fetch(t,e){var{o:s,f:o}=t,r=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(s[o[r]]=t[o[r]])}return s}(t,["o","f"]);return C(this,void 0,void 0,(function*(){void 0===e&&(e=null);const t=yield this.getUrl(s,o);return this.window.fetch(t,Object.assign(Object.assign({},R._formatPostOptions(r)),{signal:e}))}))}post(t,e){return this.fetch(t,e).then((t=>t.json())).then((t=>{if(0===t.error)return t;throw{error:t.error,errorMsg:t.errorMsg,messages:t.messages}})).catch((t=>{if(e&&e.aborted)throw{error:-1,aborted:!0};throw t}))}postFile(t){return C(this,void 0,void 0,(function*(){const e=yield this.getUrl("file","create");if(!t.get("token")){const{result:e}=yield this.token();t.append("token",e)}return this.window.fetch(e,{method:"POST",credentials:"same-origin",body:t}).then((t=>t.json()))}))}postCSRF(t){return this.tokenCSRF().then((e=>this.post(Object.assign(t,{tokenCSRF:e.result}))))}maybePostCSRF(t){return"tokenCSRF"in t&&t.tokenCSRF?this.post(t):this.postCSRF(t)}postToken(t){return this.token().then((e=>this.post(Object.assign(t,{token:e.result}))))}maybePostToken(t){return"token"in t&&t.token?this.post(t):this.postToken(t)}token(){return this.post({o:"misc",f:"token"})}tokenCSRF(){return this.post({o:"misc",f:"tokenCSRF"})}}class M{getBackendUrl(){return t=this,e=void 0,o=function*(){const t=window.location;return`${t.protocol}//${t.host}`},new((s=void 0)||(s=Promise))((function(r,n){function i(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}));var t,e,s,o}fetch(t,e){return window.fetch(t,e)}}const U={ADMIN:9,USER:5,EXTERNAL:3,GUEST:0},P=["docx","xlsx","pptx","pdf","jpeg","png","zip","mp3","mp4","jpg","txt"],B={docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",pdf:"application/pdf",jpeg:"image/jpeg",jpg:"image/jpg",png:"image/png",zip:"application/zip",mp3:"audio/mp3",mp4:"video/mp4"};function J(t){const e=String(t).split(".").pop();if(void 0!==e&&P.find((t=>t===e.toLocaleLowerCase())))return e}function T(t){return t&&t.startsWith("application/")?"application":t&&t.startsWith("image/")?"image":t&&t.startsWith("video/")?"video":t&&t.startsWith("audio/")?"audio":void 0}function I(t){var e;const s=void 0!==t?String(t).toLocaleLowerCase():"noExt";return null!==(e=B[s])&&void 0!==e?e:"txt"}function q(t){const e=I(J(t.name));return{id:parseInt(t.id),filename:t.name,mimetype:e,dimension:t.imagesize}}function D(t){const e=t;return e&&"number"==typeof e.id&&"number"==typeof e.targetId}const E={bookmarkLink:D},N={isBookmarkLink:function(t){return"targetId"in t&&!!t.targetId},isBookmarkCustom:function(t){const e=t;return void 0!==e.bookmarkLabel||void 0!==e.bookmarkMeta||void 0!==e.bookmarkUrl},isBookmarkRawList:D,objectIsType:function(t,e){return null!=e&&E[t](e)}},z=new R(new M),$=new x(z);window.JamespotUserApi=$;const Q=$,W=x;module.exports=s})();
|
|
2
2
|
//# sourceMappingURL=jamespot-user-api.js.map
|