ec.fdk 0.8.2 → 0.8.4
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/index.cjs +2 -2
- package/dist/index.mjs +323 -298
- package/dist/lib/assets.d.ts +35 -0
- package/dist/lib/assets.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var $t=Object.defineProperty,kt=Object.defineProperties;var wt=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable;var U=(n,t,e)=>t in n?$t(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))Et.call(t,e)&&U(n,e,t[e]);if(F)for(var e of F(t))Tt.call(t,e)&&U(n,e,t[e]);return n},f=(n,t)=>kt(n,wt(t));var l=(n,t,e)=>new Promise((s,r)=>{var u=o=>{try{d(e.next(o))}catch(i){r(i)}},a=o=>{try{d(e.throw(o))}catch(i){r(i)}},d=o=>o.done?s(o.value):Promise.resolve(o.value).then(u,a);d((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(s){return l(this,arguments,function*(n,t={},e={}){var d;const{token:r,rawRes:u}=t;r&&(e.headers=f(c({},e.headers||{}),{Authorization:`Bearer ${r}`}));const a=yield fetch(n,e);if(!a.ok){if((d=a.headers.get("content-type"))!=null&&d.includes("application/json")){const o=yield a.json(),i=`${o.title}
|
|
2
2
|
${o.detail}
|
|
3
|
-
${o.verbose}`;throw new Error(c)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return d?i:yield i.json()})}const E={datamanager:{live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"},accounts:{live:"https://accounts.entrecode.de/",stage:"https://accounts.cachena.entrecode.de/"},appserver:{live:"https://appserver.entrecode.de/",stage:"https://appserver.cachena.entrecode.de/"},"dm-history":{live:"https://dm-history.entrecode.de/",stage:"https://dm-history.cachena.entrecode.de/"}};function y(n,t="stage",e="datamanager"){const s=E[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(E).join(", ")}`);const r=s[t];if(!r)throw new Error(`env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`);return r+n}function $(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function g(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const N={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function J(n){return u(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;g({env:t,dmShortID:e,email:s,password:r});const d=y(`api/${e}/_auth/login?clientID=rest`,t);return yield f(d,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function R(n){return u(this,null,function*(){let{env:t,email:e,password:s}=n;g({env:t,email:e,password:s});const r=`${N[t]}auth/login?clientID=rest`;return yield f(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function U(n){return u(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;g({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield f(r,{rawRes:!0},{method:"POST"})})}function M(n){return u(this,null,function*(){let{env:t,token:e}=n;g({env:t,token:e});const s=`${N[t]}auth/logout?clientID=rest`;return yield f(s,{rawRes:!0,token:e},{method:"POST"})})}function V({dmShortID:n}){return g({dmShortID:n}),n}function H({env:n}){return g({env:n}),n}let Et=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function Q(n){let t={};for(let e in n)Et.includes(e)||(t[e]=n[e]);return t}function Tt(n){return JSON.parse(JSON.stringify(n))}function W(n){return u(this,null,function*(){let{env:t,dmShortID:e}=n;g({env:t,dmShortID:e});const s=y(`api/${e}`,t);return f(s,n)})}function P(n){return u(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;g({env:t,dmShortID:e,model:s}),r=a({size:50,page:1,_list:!0},r);const d=$(r),i=y(`api/${e}/${s}?${d}`,t),{count:l,total:o,_embedded:c}=yield f(i,n);let p=c?c[`${e}:${s}`]:[];return p=Array.isArray(p)?p:[p],{count:l,total:o,items:p}})}function X({env:n,dmShortID:t,model:e,entryID:s,token:r}){g({env:n,dmShortID:t,model:e,entryID:s});const d=$({_id:s}),i=y(`api/${t}/${e}?${d}`,n);return f(i,{token:r})}function Y(d){return u(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){g({env:n,dmShortID:t,model:e,value:s});const i=y(`api/${t}/${e}`,n);return yield f(i,{token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function S(l){return u(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:d,safePut:i=!1}){g({env:n,dmShortID:t,model:e,entryID:s,value:r});const o={"Content-Type":"application/json"};if(i){if(!("_modified"in r))throw new Error("expected _modified to be set!");o["If-Unmodified-Since"]=new Date(r._modified).toUTCString()}const c=y(`api/${t}/${e}?_id=${s}`,n);return r=Tt(r),r=Q(r),yield f(c,{token:d},{method:"PUT",headers:o,body:JSON.stringify(r)})})}function L({env:n,dmShortID:t,model:e,entryID:s,token:r}){g({env:n,dmShortID:t,model:e,entryID:s});const d=y(`api/${t}/${e}?_id=${s}`,n);return f(d,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})}function Z(n,t){return u(this,null,function*(){let{env:e,dmShortID:s,model:r,options:d={}}=n;g({env:e,dmShortID:s,model:r}),n.options=a({size:50,page:1,_list:!0},d);let i=0,l,o=[];for(;l===void 0||i<l;){const c=yield P(n);for(let p of c.items)o.push(yield t(p));i+=c.items.length,l=c.total,n.options.page++}return o})}function G(r){return u(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var p,k,D,q,F;g({env:n,dmShortID:t,model:e});const d=y(`api/schema/${t}/${e}`,n),i=yield f(d),l=(p=i==null?void 0:i.allOf)==null?void 0:p[1];if(typeof l.properties!="object")throw new Error(`getSchema: ${d} returned unexpected format: ${JSON.stringify(i)}`);const{properties:o}=l,c=Q(o);for(let w in c){let m=c[w];if(m.required=l.required.includes(w),(k=c[w])!=null&&k.oneOf&&((D=c[w])==null||delete D.oneOf),(q=m.title)!=null&&q.includes("<")&&((F=m.title)!=null&&F.includes(">"))){const j=m.title.split("<")[1].slice(0,-1),pt=m.title.split("<")[0];m.type=pt,j.includes(":")?m.resource=j.split(":")[1]:m.resource=j}else["asset","entry","assets","entries"].includes(m.title)?(m.type=m.title,m.resource=null):m.type=m.title;delete c[w].title}if(s){const w=o._modelTitle.title,m=o._modelTitleField.title;return{properties:c,meta:{modelTitleField:m,modelTitle:w}}}return c})}function v(n){return Object.entries(n).map(([t,e])=>typeof e!="object"?{[t]:String(e)}:a(a(a(a(a(a(a({},e.sort&&{sort:Array.isArray(e)?e.join(","):e}),e.search&&{[t+"~"]:e.search}),e.notNull&&{[t+"!"]:""}),e.null&&{[t]:""}),e.any&&{[t]:e.any.join(",")}),e.from&&{[t+"From"]:e.from}),e.to&&{[t+"To"]:e.to})).reduce((t,e)=>a(a({},t),e),{})}const tt=v;function O(n){return n._links.collection.href.split("/").slice(-2)[0]}function B(n){const t=n._links.collection.href.split("api/")[0];return Object.keys(E.datamanager).find(s=>E.datamanager[s]===t)}const et=n=>{const t=O(n),e=B(n),s=n._modelTitle,r=n.id;return{dmShortID:t,env:e,model:s,entryID:r}},nt=n=>L(et(n)),st=(n,t)=>S(h(a({},et(n)),{value:t}));function rt(n,t){const e=O(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function ot(d){return u(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){g({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=$({assetID:s}),l=y(`a/${t}/${e}?${i}`,n),{_embedded:o}=yield f(l,{token:r});return o?o["ec:dm-asset"]:void 0})}function it(n){return u(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:d={}}=n;g({env:t,dmShortID:e,assetGroup:s}),d=a({size:50,page:1,_list:!0},d);const i=$(d),l=y(`a/${e}/${s}?${i}`,t),{count:o,total:c,_embedded:p}=yield f(l,{token:r});let k=p?p["ec:dm-asset"]:[];return k=Array.isArray(k)?k:[k],{count:o,total:c,items:k}})}function at(l){return u(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:d,options:i}){g({env:n,dmShortID:t,assetGroup:e,file:r});const o=y(`a/${t}/${e}`,n),c=new FormData;return c.append("file",r,d),i&&Object.keys(i).forEach(k=>{c.append(k,i[k])}),(yield f(o,{token:s},{method:"POST",body:c}))._embedded["ec:dm-asset"]})}function ct(d){return u(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,files:s,options:r}){g({env:n,dmShortID:t,assetGroup:e,files:s});const i=y(`a/${t}/${e}`,n),l=new FormData;s.forEach(c=>{l.append("file",c)}),r&&Object.keys(r).forEach(c=>{l.append(c,r[c])});const o=yield f(i,{},{method:"POST",body:l});return Array.isArray(o._embedded["ec:dm-asset"])?o._embedded["ec:dm-asset"]:[o._embedded["ec:dm-asset"]]})}function ut(d){return u(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){g({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=y(`a/${t}/${e}/${s}`,n);yield f(i,{token:r,rawRes:!0},{method:"DELETE"})})}function dt(n){return u(this,null,function*(){let{env:t,dmID:e,token:s}=n;g({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return f(r,{token:s})})}function lt(n){return u(this,null,function*(){let{env:t,options:e={}}=n;g({env:t}),e=a({size:25,page:1,_list:!0},e);const s=$(e),r=y(`?${s}`,t),{count:d,total:i,_embedded:l}=yield f(r,n);let o=l?l["ec:datamanager"]:[];return o=Array.isArray(o)?o:[o],{count:d,total:i,items:o}})}function gt(n){return u(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;g({env:t,dmID:e}),s=a({size:25,dataManagerID:e,page:1,_list:!0},s);const r=$(s),d=y(`model?${r}`,t),{count:i,total:l,_embedded:o}=yield f(d,n);let c=o?o["ec:model"]:[];return c=Array.isArray(c)?c:[c],{count:i,total:l,items:c}})}function ht(n){return u(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;g({env:t,subdomain:r,resource:e}),s=a({size:25,page:1,_list:!0},s);const d=$(s),i=y(`${e}?${d}`,t,r),{count:l,total:o,_embedded:c}=yield f(i,n);let p=c?c[Object.keys(c)[0]]:[];return p=Array.isArray(p)?p:[p],{count:l,total:o,items:p}})}function ft(e){return u(this,arguments,function*(n,t={}){let{env:s,route:r,options:d={},subdomain:i="datamanager"}=n;g({env:s,subdomain:i,route:r}),d=a({},d);const l=$(d),o=y(`${r}?${l}`,s,i);return f(o,n,t)})}const _=Object.freeze(Object.defineProperty({__proto__:null,assetList:it,createAsset:at,createAssets:ct,createEntry:Y,deleteAsset:ut,deleteEntry:L,deleteEntryObject:nt,dmList:lt,editEntry:S,editEntryObject:st,entryList:P,filterOptions:tt,getAsset:ot,getDatamanager:dt,getEcAuthKey:H,getEntry:X,getEntryAsset:rt,getEntryEnv:B,getEntryShortID:O,getPublicAuthKey:V,getSchema:G,loginEc:R,loginPublic:J,logoutEc:M,logoutPublic:U,mapEntries:Z,modelList:gt,publicApi:W,raw:ft,resourceList:ht,sdkOptions:v},Symbol.toStringTag,{value:"Module"})),{entryList:C,mapEntries:bt,getEntry:At,getAsset:_t,assetList:I,createAsset:Ot,createAssets:jt,deleteAsset:Pt,createEntry:St,editEntry:K,deleteEntry:Lt,getSchema:vt,loginPublic:Bt,loginEc:Dt,logoutEc:qt,logoutPublic:Ft,getEcAuthKey:b,getPublicAuthKey:A,dmList:xt,modelList:zt,publicApi:Ct,getDatamanager:It,resourceList:Kt,raw:Nt}=_;function Jt(n){const{action:t}=n;if(g({action:t}),!_[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(_).join(", ")}`);return _[t](n)}class T{constructor(t={}){if(!t.storageAdapter){let e=new Map;t.storageAdapter={get:s=>e.get(s),set:(s,r)=>e.set(s,r),remove:s=>e.delete(s)}}this.config=t}set(t){return new T(a(a({},this.config),t))}entries(){return u(this,arguments,function*(t={}){const e=yield this.getBestToken();return C(h(a({},this.config),{options:t,token:e}))})}entryList(t){return u(this,null,function*(){const e=yield this.getBestToken();return C(h(a({},this.config),{options:t,token:e}))})}mapEntries(s){return u(this,arguments,function*(t,e={}){const r=yield this.getBestToken();return bt(h(a({},this.config),{options:e,token:r}),t)})}getEntry(t){return u(this,null,function*(){const e=yield this.getBestToken();return At(h(a({},this.config),{entryID:t,token:e}))})}editEntrySafe(t,e){return u(this,null,function*(){const s=yield this.getBestToken();return K(h(a({},this.config),{entryID:t,token:s,value:e,safePut:!0}))})}getSchema(){return u(this,null,function*(){return vt(this.config)})}assets(t){return u(this,null,function*(){const e=yield this.getBestToken();return I(h(a({},this.config),{options:t,token:e}))})}assetList(t){return u(this,null,function*(){const e=yield this.getBestToken();return I(h(a({},this.config),{options:t,token:e}))})}createAsset(t){return u(this,null,function*(){const{file:e,name:s,options:r}=t,d=yield this.getBestToken();return Ot(h(a({},this.config),{file:e,name:s,options:r,token:d}))})}createAssets(t){return u(this,null,function*(){const{files:e,options:s}=t,r=yield this.getBestToken();return jt(h(a({},this.config),{files:e,options:s,token:r}))})}deleteAsset(t){return u(this,null,function*(){const e=yield this.getBestToken();return Pt(h(a({},this.config),{token:e,assetID:t}))})}getAsset(t){return u(this,null,function*(){const e=yield this.getBestToken();return _t(h(a({},this.config),{assetID:t,token:e}))})}createEntry(t){return u(this,null,function*(){const e=yield this.getBestToken();return St(h(a({},this.config),{token:e,value:t}))})}editEntry(t,e){return u(this,null,function*(){const s=yield this.getBestToken();return K(h(a({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return u(this,null,function*(){const e=yield this.getBestToken();return Lt(h(a({},this.config),{token:e,entryID:t}))})}resourceList(t){return u(this,null,function*(){const e=yield this.getBestToken();return Kt(h(a({},this.config),{options:t,token:e}))})}raw(t,e){return u(this,null,function*(){const s=yield this.getBestToken();return Nt(h(a({},this.config),{options:t,token:s}),e)})}storageAdapter(t){return this.set({storageAdapter:t})}removeToken(t){if(!this.config.storageAdapter)throw new Error("cannot removeToken: no storageAdapter defined!");const{remove:e}=this.config.storageAdapter;e(t)}getToken(t){if(!this.config.storageAdapter)throw new Error("cannot getAuth: no storageAdapter defined!");const{get:e}=this.config.storageAdapter;return e(t)}getPublicToken(){return this.config.token||this.getToken(A(this.config))}getEcToken(){return this.config.token||this.getToken(b(this.config))}setToken(t,e){if(!this.config.storageAdapter)throw new Error("cannot setEcToken: no storageAdapter defined!");return this.config.storageAdapter.set(t,e)}setEcToken(t){this.setToken(b(this.config),t)}setPublicToken(t){this.setToken(A(this.config),t)}loginEc(t){return Dt(a(a({},this.config),t)).then(e=>this.setToken(b(this.config),e.token))}loginPublic(t){return Bt(a(a({},this.config),t)).then(e=>this.setToken(A(this.config),e.token))}logoutPublic(){const t=this.getPublicToken();return Ft(h(a({},this.config),{token:t})).then(()=>this.removeToken(A(this.config)))}logoutEc(){const t=this.getEcToken();return qt(h(a({},this.config),{token:t})).then(()=>this.removeToken(b(this.config)))}hasPublicToken(){return!!this.getPublicToken()}hasEcToken(){return!!this.getEcToken()}hasAnyToken(){return!!this.getEcToken()||!!this.getPublicToken()}getBestToken(){try{return this.getEcToken()||this.getPublicToken()}catch(t){return}}model(t){return this.set({model:t})}token(t){return this.set({token:t})}dmShortID(t){return this.set({dmShortID:t})}dm(t){return this.dmShortID(t)}dmID(t){return this.set({dmID:t})}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}subdomain(t){return this.set({subdomain:t})}resource(t){return this.set({resource:t})}route(t){return this.set({route:t})}publicApi(){return Ct(this.config)}getDatamanager(t){return u(this,null,function*(){const e=yield this.getBestToken();return It(h(a({},this.config),{dmID:t,token:e}))})}dmList(){return u(this,arguments,function*(t={}){const e=yield this.getBestToken();return xt(h(a({},this.config),{options:t,token:e}))})}modelList(){return u(this,arguments,function*(t={}){const e=yield this.getBestToken();return zt(h(a({},this.config),{options:t,token:e}))})}}const Rt=n=>new T({env:n}),Ut=n=>new T({env:n});exports.Fdk=T;exports.act=Jt;exports.apiURL=y;exports.apis=E;exports.assetList=it;exports.createAsset=at;exports.createAssets=ct;exports.createEntry=Y;exports.deleteAsset=ut;exports.deleteEntry=L;exports.deleteEntryObject=nt;exports.dmList=lt;exports.editEntry=S;exports.editEntryObject=st;exports.entryList=P;exports.expect=g;exports.fdk=Rt;exports.fetcher=f;exports.filterOptions=tt;exports.getAsset=ot;exports.getDatamanager=dt;exports.getEcAuthKey=H;exports.getEntry=X;exports.getEntryAsset=rt;exports.getEntryEnv=B;exports.getEntryShortID=O;exports.getPublicAuthKey=V;exports.getSchema=G;exports.loginEc=R;exports.loginPublic=J;exports.logoutEc=M;exports.logoutPublic=U;exports.mapEntries=Z;exports.modelList=gt;exports.publicApi=W;exports.query=$;exports.raw=ft;exports.resourceList=ht;exports.sdk=Ut;exports.sdkOptions=v;
|
|
3
|
+
${o.verbose}`;throw new Error(i)}throw new Error(`unexpected fetch error: ${a.statusText}`)}return u?a:yield a.json()})}const T={datamanager:{live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"},accounts:{live:"https://accounts.entrecode.de/",stage:"https://accounts.cachena.entrecode.de/"},appserver:{live:"https://appserver.entrecode.de/",stage:"https://appserver.cachena.entrecode.de/"},"dm-history":{live:"https://dm-history.entrecode.de/",stage:"https://dm-history.cachena.entrecode.de/"}};function y(n,t="stage",e="datamanager"){const s=T[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(T).join(", ")}`);const r=s[t];if(!r)throw new Error(`env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`);return r+n}function w(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function g(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const K={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function N(n){return l(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;g({env:t,dmShortID:e,email:s,password:r});const u=y(`api/${e}/_auth/login?clientID=rest`,t);return yield p(u,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function J(n){return l(this,null,function*(){let{env:t,email:e,password:s}=n;g({env:t,email:e,password:s});const r=`${K[t]}auth/login?clientID=rest`;return yield p(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function R(n){return l(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;g({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield p(r,{rawRes:!0},{method:"POST"})})}function V(n){return l(this,null,function*(){let{env:t,token:e}=n;g({env:t,token:e});const s=`${K[t]}auth/logout?clientID=rest`;return yield p(s,{rawRes:!0,token:e},{method:"POST"})})}function z({dmShortID:n}){return g({dmShortID:n}),n}function H({env:n}){return g({env:n}),n}let bt=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function Q(n){let t={};for(let e in n)bt.includes(e)||(t[e]=n[e]);return t}function At(n){return JSON.parse(JSON.stringify(n))}function W(n){return l(this,null,function*(){let{env:t,dmShortID:e}=n;g({env:t,dmShortID:e});const s=y(`api/${e}`,t);return p(s,n)})}function P(n){return l(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;g({env:t,dmShortID:e,model:s}),r=c({size:50,page:1,_list:!0},r);const u=w(r),a=y(`api/${e}/${s}?${u}`,t),{count:d,total:o,_embedded:i}=yield p(a,n);let h=i?i[`${e}:${s}`]:[];return h=Array.isArray(h)?h:[h],{count:d,total:o,items:h}})}function X({env:n,dmShortID:t,model:e,entryID:s,token:r}){g({env:n,dmShortID:t,model:e,entryID:s});const u=w({_id:s}),a=y(`api/${t}/${e}?${u}`,n);return p(a,{token:r})}function Y(u){return l(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){g({env:n,dmShortID:t,model:e,value:s});const a=y(`api/${t}/${e}`,n);return yield p(a,{token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function L(d){return l(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:u,safePut:a=!1}){g({env:n,dmShortID:t,model:e,entryID:s,value:r});const o={"Content-Type":"application/json"};if(a){if(!("_modified"in r))throw new Error("expected _modified to be set!");o["If-Unmodified-Since"]=new Date(r._modified).toUTCString()}const i=y(`api/${t}/${e}?_id=${s}`,n);return r=At(r),r=Q(r),yield p(i,{token:u},{method:"PUT",headers:o,body:JSON.stringify(r)})})}function B({env:n,dmShortID:t,model:e,entryID:s,token:r}){g({env:n,dmShortID:t,model:e,entryID:s});const u=y(`api/${t}/${e}?_id=${s}`,n);return p(u,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})}function Z(n,t){return l(this,null,function*(){let{env:e,dmShortID:s,model:r,options:u={}}=n;g({env:e,dmShortID:s,model:r}),n.options=c({size:50,page:1,_list:!0},u);let a=0,d,o=[];for(;d===void 0||a<d;){const i=yield P(n);for(let h of i.items)o.push(yield t(h));a+=i.items.length,d=i.total,n.options.page++}return o})}function G(r){return l(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var h,m,k,q,x;g({env:n,dmShortID:t,model:e});const u=y(`api/schema/${t}/${e}`,n),a=yield p(u),d=(h=a==null?void 0:a.allOf)==null?void 0:h[1];if(typeof d.properties!="object")throw new Error(`getSchema: ${u} returned unexpected format: ${JSON.stringify(a)}`);const{properties:o}=d,i=Q(o);for(let E in i){let $=i[E];if($.required=d.required.includes(E),(m=i[E])!=null&&m.oneOf&&((k=i[E])==null||delete k.oneOf),(q=$.title)!=null&&q.includes("<")&&((x=$.title)!=null&&x.includes(">"))){const j=$.title.split("<")[1].slice(0,-1),mt=$.title.split("<")[0];$.type=mt,j.includes(":")?$.resource=j.split(":")[1]:$.resource=j}else["asset","entry","assets","entries"].includes($.title)?($.type=$.title,$.resource=null):$.type=$.title;delete i[E].title}if(s){const E=o._modelTitle.title,$=o._modelTitleField.title;return{properties:i,meta:{modelTitleField:$,modelTitle:E}}}return i})}function D(n){return Object.entries(n).map(([t,e])=>typeof e!="object"?{[t]:String(e)}:c(c(c(c(c(c(c({},e.sort&&{sort:Array.isArray(e)?e.join(","):e}),e.search&&{[t+"~"]:e.search}),e.notNull&&{[t+"!"]:""}),e.null&&{[t]:""}),e.any&&{[t]:e.any.join(",")}),e.from&&{[t+"From"]:e.from}),e.to&&{[t+"To"]:e.to})).reduce((t,e)=>c(c({},t),e),{})}const tt=D;function S(n){return n._links.collection.href.split("/").slice(-2)[0]}function v(n){const t=n._links.collection.href.split("api/")[0];return Object.keys(T.datamanager).find(s=>T.datamanager[s]===t)}const et=n=>{const t=S(n),e=v(n),s=n._modelTitle,r=n.id;return{dmShortID:t,env:e,model:s,entryID:r}},nt=n=>B(et(n)),st=(n,t)=>L(f(c({},et(n)),{value:t}));function rt(n,t){const e=S(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function ot(u){return l(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){g({env:n,dmShortID:t,assetGroup:e,assetID:s});const a=w({assetID:s}),d=y(`a/${t}/${e}?${a}`,n),{_embedded:o}=yield p(d,{token:r});return o?o["ec:dm-asset"]:void 0})}function it(n){return l(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:u={}}=n;g({env:t,dmShortID:e,assetGroup:s}),u=c({size:50,page:1,_list:!0},u);const a=w(u),d=y(`a/${e}/${s}?${a}`,t),{count:o,total:i,_embedded:h}=yield p(d,{token:r});let m=h?h["ec:dm-asset"]:[];return m=Array.isArray(m)?m:[m],{count:o,total:i,items:m}})}function at(d){return l(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:u,options:a}){g({env:n,dmShortID:t,assetGroup:e,file:r});const o=y(`a/${t}/${e}`,n),i=new FormData;return i.append("file",r,u),a&&Object.keys(a).forEach(m=>{i.append(m,a[m])}),(yield p(o,{token:s},{method:"POST",body:i}))._embedded["ec:dm-asset"]})}function ct(u){return l(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,files:s,options:r}){g({env:n,dmShortID:t,assetGroup:e,files:s});const a=y(`a/${t}/${e}`,n),d=new FormData;s.forEach(i=>{d.append("file",i)}),r&&Object.keys(r).forEach(i=>{d.append(i,r[i])});const o=yield p(a,{},{method:"POST",body:d});return Array.isArray(o._embedded["ec:dm-asset"])?o._embedded["ec:dm-asset"]:[o._embedded["ec:dm-asset"]]})}function ut(u){return l(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){g({env:n,dmShortID:t,assetGroup:e,assetID:s});const a=y(`a/${t}/${e}/${s}`,n);yield p(a,{token:r,rawRes:!0},{method:"DELETE"})})}function lt(n,t,e=!1){var a,d,o;let s,r;const u=e?n==null?void 0:n.thumbnails:n==null?void 0:n.fileVariants;return u==null||u.forEach(i=>{const{resolution:{width:h,height:m}}=i,k=Math.abs(Math.max(h,m)-t);(!r||k<r)&&(r=k,s=i)}),(o=(d=s==null?void 0:s.url)!=null?d:(a=n==null?void 0:n.file)==null?void 0:a.url)!=null?o:null}function dt(n="stage",t,e,s,r=!1){const u=Math.max(s.file.resolution.width,s.file.resolution.height),a=e.filter(o=>o<u),d=`https://datamanager${n==="stage"?".cachena":""}.entrecode.de`;return r?a.map(o=>{const i=s.thumbnails.find(k=>o===k.dimension),h=`${d}/t/${t}/${s.assetID}/${o}`,m=i?i.url:h;return{size:o,url:m,generated:i}}):a.map(o=>{const i=s.fileVariants.find(k=>o===Math.max(k.resolution.width,k.resolution.height)),h=`${d}/f/${t}/${s.assetID}/${o}`,m=i?i.url:h;return{size:o,url:m,generated:i}})}function ht(n){return l(this,null,function*(){let{env:t,dmID:e,token:s}=n;g({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return p(r,{token:s})})}function gt(n){return l(this,null,function*(){let{env:t,options:e={}}=n;g({env:t}),e=c({size:25,page:1,_list:!0},e);const s=w(e),r=y(`?${s}`,t),{count:u,total:a,_embedded:d}=yield p(r,n);let o=d?d["ec:datamanager"]:[];return o=Array.isArray(o)?o:[o],{count:u,total:a,items:o}})}function ft(n){return l(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;g({env:t,dmID:e}),s=c({size:25,dataManagerID:e,page:1,_list:!0},s);const r=w(s),u=y(`model?${r}`,t),{count:a,total:d,_embedded:o}=yield p(u,n);let i=o?o["ec:model"]:[];return i=Array.isArray(i)?i:[i],{count:a,total:d,items:i}})}function pt(n){return l(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;g({env:t,subdomain:r,resource:e}),s=c({size:25,page:1,_list:!0},s);const u=w(s),a=y(`${e}?${u}`,t,r),{count:d,total:o,_embedded:i}=yield p(a,n);let h=i?i[Object.keys(i)[0]]:[];return h=Array.isArray(h)?h:[h],{count:d,total:o,items:h}})}function yt(e){return l(this,arguments,function*(n,t={}){let{env:s,route:r,options:u={},subdomain:a="datamanager"}=n;g({env:s,subdomain:a,route:r}),u=c({},u);const d=w(u),o=y(`${r}?${d}`,s,a);return p(o,n,t)})}const O=Object.freeze(Object.defineProperty({__proto__:null,assetList:it,createAsset:at,createAssets:ct,createEntry:Y,deleteAsset:ut,deleteEntry:B,deleteEntryObject:nt,dmList:gt,editEntry:L,editEntryObject:st,entryList:P,fileVariant:lt,filterOptions:tt,getAsset:ot,getDatamanager:ht,getEcAuthKey:H,getEntry:X,getEntryAsset:rt,getEntryEnv:v,getEntryShortID:S,getFileVariants:dt,getPublicAuthKey:z,getSchema:G,loginEc:J,loginPublic:N,logoutEc:V,logoutPublic:R,mapEntries:Z,modelList:ft,publicApi:W,raw:yt,resourceList:pt,sdkOptions:D},Symbol.toStringTag,{value:"Module"})),{entryList:I,mapEntries:_t,getEntry:Ot,getAsset:St,assetList:M,createAsset:jt,createAssets:Pt,deleteAsset:Lt,createEntry:Bt,editEntry:C,deleteEntry:Dt,getSchema:vt,loginPublic:qt,loginEc:xt,logoutEc:Ft,logoutPublic:Ut,getEcAuthKey:A,getPublicAuthKey:_,dmList:It,modelList:Mt,publicApi:Ct,getDatamanager:Kt,resourceList:Nt,raw:Jt}=O;function Rt(n){const{action:t}=n;if(g({action:t}),!O[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(O).join(", ")}`);return O[t](n)}class b{constructor(t={}){if(!t.storageAdapter){let e=new Map;t.storageAdapter={get:s=>e.get(s),set:(s,r)=>e.set(s,r),remove:s=>e.delete(s)}}this.config=t}set(t){return new b(c(c({},this.config),t))}entries(){return l(this,arguments,function*(t={}){const e=yield this.getBestToken();return I(f(c({},this.config),{options:t,token:e}))})}entryList(t){return l(this,null,function*(){const e=yield this.getBestToken();return I(f(c({},this.config),{options:t,token:e}))})}mapEntries(s){return l(this,arguments,function*(t,e={}){const r=yield this.getBestToken();return _t(f(c({},this.config),{options:e,token:r}),t)})}getEntry(t){return l(this,null,function*(){const e=yield this.getBestToken();return Ot(f(c({},this.config),{entryID:t,token:e}))})}editEntrySafe(t,e){return l(this,null,function*(){const s=yield this.getBestToken();return C(f(c({},this.config),{entryID:t,token:s,value:e,safePut:!0}))})}getSchema(){return l(this,null,function*(){return vt(this.config)})}assets(t){return l(this,null,function*(){const e=yield this.getBestToken();return M(f(c({},this.config),{options:t,token:e}))})}assetList(t){return l(this,null,function*(){const e=yield this.getBestToken();return M(f(c({},this.config),{options:t,token:e}))})}createAsset(t){return l(this,null,function*(){const{file:e,name:s,options:r}=t,u=yield this.getBestToken();return jt(f(c({},this.config),{file:e,name:s,options:r,token:u}))})}createAssets(t){return l(this,null,function*(){const{files:e,options:s}=t,r=yield this.getBestToken();return Pt(f(c({},this.config),{files:e,options:s,token:r}))})}deleteAsset(t){return l(this,null,function*(){const e=yield this.getBestToken();return Lt(f(c({},this.config),{token:e,assetID:t}))})}getAsset(t){return l(this,null,function*(){const e=yield this.getBestToken();return St(f(c({},this.config),{assetID:t,token:e}))})}createEntry(t){return l(this,null,function*(){const e=yield this.getBestToken();return Bt(f(c({},this.config),{token:e,value:t}))})}editEntry(t,e){return l(this,null,function*(){const s=yield this.getBestToken();return C(f(c({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return l(this,null,function*(){const e=yield this.getBestToken();return Dt(f(c({},this.config),{token:e,entryID:t}))})}resourceList(t){return l(this,null,function*(){const e=yield this.getBestToken();return Nt(f(c({},this.config),{options:t,token:e}))})}raw(t,e){return l(this,null,function*(){const s=yield this.getBestToken();return Jt(f(c({},this.config),{options:t,token:s}),e)})}storageAdapter(t){return this.set({storageAdapter:t})}removeToken(t){if(!this.config.storageAdapter)throw new Error("cannot removeToken: no storageAdapter defined!");const{remove:e}=this.config.storageAdapter;e(t)}getToken(t){if(!this.config.storageAdapter)throw new Error("cannot getAuth: no storageAdapter defined!");const{get:e}=this.config.storageAdapter;return e(t)}getPublicToken(){return this.config.token||this.getToken(_(this.config))}getEcToken(){return this.config.token||this.getToken(A(this.config))}setToken(t,e){if(!this.config.storageAdapter)throw new Error("cannot setEcToken: no storageAdapter defined!");return this.config.storageAdapter.set(t,e)}setEcToken(t){this.setToken(A(this.config),t)}setPublicToken(t){this.setToken(_(this.config),t)}loginEc(t){return xt(c(c({},this.config),t)).then(e=>this.setToken(A(this.config),e.token))}loginPublic(t){return qt(c(c({},this.config),t)).then(e=>this.setToken(_(this.config),e.token))}logoutPublic(){const t=this.getPublicToken();return Ut(f(c({},this.config),{token:t})).then(()=>this.removeToken(_(this.config)))}logoutEc(){const t=this.getEcToken();return Ft(f(c({},this.config),{token:t})).then(()=>this.removeToken(A(this.config)))}hasPublicToken(){return!!this.getPublicToken()}hasEcToken(){return!!this.getEcToken()}hasAnyToken(){return!!this.getEcToken()||!!this.getPublicToken()}getBestToken(){try{return this.getEcToken()||this.getPublicToken()}catch(t){return}}model(t){return this.set({model:t})}token(t){return this.set({token:t})}dmShortID(t){return this.set({dmShortID:t})}dm(t){return this.dmShortID(t)}dmID(t){return this.set({dmID:t})}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}subdomain(t){return this.set({subdomain:t})}resource(t){return this.set({resource:t})}route(t){return this.set({route:t})}publicApi(){return Ct(this.config)}getDatamanager(t){return l(this,null,function*(){const e=yield this.getBestToken();return Kt(f(c({},this.config),{dmID:t,token:e}))})}dmList(){return l(this,arguments,function*(t={}){const e=yield this.getBestToken();return It(f(c({},this.config),{options:t,token:e}))})}modelList(){return l(this,arguments,function*(t={}){const e=yield this.getBestToken();return Mt(f(c({},this.config),{options:t,token:e}))})}}const Vt=n=>new b({env:n}),zt=n=>new b({env:n});exports.Fdk=b;exports.act=Rt;exports.apiURL=y;exports.apis=T;exports.assetList=it;exports.createAsset=at;exports.createAssets=ct;exports.createEntry=Y;exports.deleteAsset=ut;exports.deleteEntry=B;exports.deleteEntryObject=nt;exports.dmList=gt;exports.editEntry=L;exports.editEntryObject=st;exports.entryList=P;exports.expect=g;exports.fdk=Vt;exports.fetcher=p;exports.fileVariant=lt;exports.filterOptions=tt;exports.getAsset=ot;exports.getDatamanager=ht;exports.getEcAuthKey=H;exports.getEntry=X;exports.getEntryAsset=rt;exports.getEntryEnv=v;exports.getEntryShortID=S;exports.getFileVariants=dt;exports.getPublicAuthKey=z;exports.getSchema=G;exports.loginEc=J;exports.loginPublic=N;exports.logoutEc=V;exports.logoutPublic=R;exports.mapEntries=Z;exports.modelList=ft;exports.publicApi=W;exports.query=w;exports.raw=yt;exports.resourceList=pt;exports.sdk=zt;exports.sdkOptions=D;
|
package/dist/index.mjs
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
var
|
|
1
|
+
var R = Object.defineProperty, V = Object.defineProperties;
|
|
2
2
|
var H = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var B = Object.getOwnPropertySymbols;
|
|
4
4
|
var Q = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var D = (n, t, e) => t in n ? R(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
Q.call(t, e) &&
|
|
7
|
+
Q.call(t, e) && D(n, e, t[e]);
|
|
8
8
|
if (B)
|
|
9
9
|
for (var e of B(t))
|
|
10
|
-
W.call(t, e) &&
|
|
10
|
+
W.call(t, e) && D(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, f = (n, t) => V(n, H(t));
|
|
13
|
+
var l = (n, t, e) => new Promise((s, r) => {
|
|
14
|
+
var u = (o) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
r(
|
|
16
|
+
d(e.next(o));
|
|
17
|
+
} catch (i) {
|
|
18
|
+
r(i);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, a = (o) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
r(
|
|
22
|
+
d(e.throw(o));
|
|
23
|
+
} catch (i) {
|
|
24
|
+
r(i);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, d = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(u, a);
|
|
27
|
+
d((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
29
|
function p(s) {
|
|
30
|
-
return
|
|
31
|
-
var
|
|
32
|
-
const { token: r, rawRes:
|
|
33
|
-
r && (e.headers =
|
|
30
|
+
return l(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
|
+
var d;
|
|
32
|
+
const { token: r, rawRes: u } = t;
|
|
33
|
+
r && (e.headers = f(c({}, e.headers || {}), {
|
|
34
34
|
Authorization: `Bearer ${r}`
|
|
35
35
|
}));
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
if ((
|
|
39
|
-
const o = yield
|
|
36
|
+
const a = yield fetch(n, e);
|
|
37
|
+
if (!a.ok) {
|
|
38
|
+
if ((d = a.headers.get("content-type")) != null && d.includes("application/json")) {
|
|
39
|
+
const o = yield a.json(), i = `${o.title}
|
|
40
40
|
${o.detail}
|
|
41
41
|
${o.verbose}`;
|
|
42
|
-
throw new Error(
|
|
42
|
+
throw new Error(i);
|
|
43
43
|
}
|
|
44
|
-
throw new Error(`unexpected fetch error: ${
|
|
44
|
+
throw new Error(`unexpected fetch error: ${a.statusText}`);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return u ? a : yield a.json();
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const _ = {
|
|
50
50
|
datamanager: {
|
|
51
51
|
live: "https://datamanager.entrecode.de/",
|
|
52
52
|
stage: "https://datamanager.cachena.entrecode.de/"
|
|
@@ -64,11 +64,11 @@ const A = {
|
|
|
64
64
|
stage: "https://dm-history.cachena.entrecode.de/"
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
function
|
|
68
|
-
const s =
|
|
67
|
+
function m(n, t = "stage", e = "datamanager") {
|
|
68
|
+
const s = _[e];
|
|
69
69
|
if (!s)
|
|
70
70
|
throw new Error(
|
|
71
|
-
`subdomain "${e}" not found. Try one of ${Object.keys(
|
|
71
|
+
`subdomain "${e}" not found. Try one of ${Object.keys(_).join(
|
|
72
72
|
", "
|
|
73
73
|
)}`
|
|
74
74
|
);
|
|
@@ -82,23 +82,23 @@ function y(n, t = "stage", e = "datamanager") {
|
|
|
82
82
|
function k(n, t = !0) {
|
|
83
83
|
return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function g(n) {
|
|
86
86
|
Object.entries(n).forEach(([t, e]) => {
|
|
87
87
|
if (e === void 0)
|
|
88
88
|
throw new Error(`expected ${t} to be set!`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const F = {
|
|
92
92
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
93
93
|
live: "https://accounts.entrecode.de/"
|
|
94
94
|
};
|
|
95
95
|
function X(n) {
|
|
96
|
-
return
|
|
96
|
+
return l(this, null, function* () {
|
|
97
97
|
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
98
|
-
|
|
99
|
-
const
|
|
98
|
+
g({ env: t, dmShortID: e, email: s, password: r });
|
|
99
|
+
const u = m(`api/${e}/_auth/login?clientID=rest`, t);
|
|
100
100
|
return yield p(
|
|
101
|
-
|
|
101
|
+
u,
|
|
102
102
|
{},
|
|
103
103
|
{
|
|
104
104
|
method: "POST",
|
|
@@ -111,10 +111,10 @@ function X(n) {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
function Y(n) {
|
|
114
|
-
return
|
|
114
|
+
return l(this, null, function* () {
|
|
115
115
|
let { env: t, email: e, password: s } = n;
|
|
116
|
-
|
|
117
|
-
const r = `${
|
|
116
|
+
g({ env: t, email: e, password: s });
|
|
117
|
+
const r = `${F[t]}auth/login?clientID=rest`;
|
|
118
118
|
return yield p(
|
|
119
119
|
r,
|
|
120
120
|
{},
|
|
@@ -129,10 +129,10 @@ function Y(n) {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
function Z(n) {
|
|
132
|
-
return
|
|
132
|
+
return l(this, null, function* () {
|
|
133
133
|
let { dmShortID: t, env: e, token: s } = n;
|
|
134
|
-
|
|
135
|
-
const r =
|
|
134
|
+
g({ dmShortID: t, env: e, token: s });
|
|
135
|
+
const r = m(
|
|
136
136
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
137
137
|
e
|
|
138
138
|
);
|
|
@@ -146,10 +146,10 @@ function Z(n) {
|
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
function G(n) {
|
|
149
|
-
return
|
|
149
|
+
return l(this, null, function* () {
|
|
150
150
|
let { env: t, token: e } = n;
|
|
151
|
-
|
|
152
|
-
const s = `${
|
|
151
|
+
g({ env: t, token: e });
|
|
152
|
+
const s = `${F[t]}auth/logout?clientID=rest`;
|
|
153
153
|
return yield p(
|
|
154
154
|
s,
|
|
155
155
|
{
|
|
@@ -163,10 +163,10 @@ function G(n) {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
function tt({ dmShortID: n }) {
|
|
166
|
-
return
|
|
166
|
+
return g({ dmShortID: n }), n;
|
|
167
167
|
}
|
|
168
168
|
function et({ env: n }) {
|
|
169
|
-
return
|
|
169
|
+
return g({ env: n }), n;
|
|
170
170
|
}
|
|
171
171
|
let nt = [
|
|
172
172
|
"created",
|
|
@@ -184,7 +184,7 @@ let nt = [
|
|
|
184
184
|
"_modelTitleField",
|
|
185
185
|
"_modified"
|
|
186
186
|
];
|
|
187
|
-
function
|
|
187
|
+
function U(n) {
|
|
188
188
|
let t = {};
|
|
189
189
|
for (let e in n)
|
|
190
190
|
nt.includes(e) || (t[e] = n[e]);
|
|
@@ -194,20 +194,20 @@ function st(n) {
|
|
|
194
194
|
return JSON.parse(JSON.stringify(n));
|
|
195
195
|
}
|
|
196
196
|
function rt(n) {
|
|
197
|
-
return
|
|
197
|
+
return l(this, null, function* () {
|
|
198
198
|
let { env: t, dmShortID: e } = n;
|
|
199
|
-
|
|
200
|
-
const s =
|
|
199
|
+
g({ env: t, dmShortID: e });
|
|
200
|
+
const s = m(`api/${e}`, t);
|
|
201
201
|
return p(s, n);
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
return
|
|
204
|
+
function C(n) {
|
|
205
|
+
return l(this, null, function* () {
|
|
206
206
|
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
let
|
|
210
|
-
return
|
|
207
|
+
g({ env: t, dmShortID: e, model: s }), r = c({ size: 50, page: 1, _list: !0 }, r);
|
|
208
|
+
const u = k(r), a = m(`api/${e}/${s}?${u}`, t), { count: d, total: o, _embedded: i } = yield p(a, n);
|
|
209
|
+
let h = i ? i[`${e}:${s}`] : [];
|
|
210
|
+
return h = Array.isArray(h) ? h : [h], { count: d, total: o, items: h };
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
function ot({
|
|
@@ -217,22 +217,22 @@ function ot({
|
|
|
217
217
|
entryID: s,
|
|
218
218
|
token: r
|
|
219
219
|
}) {
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
return p(
|
|
220
|
+
g({ env: n, dmShortID: t, model: e, entryID: s });
|
|
221
|
+
const u = k({ _id: s }), a = m(`api/${t}/${e}?${u}`, n);
|
|
222
|
+
return p(a, { token: r });
|
|
223
223
|
}
|
|
224
|
-
function it(
|
|
225
|
-
return
|
|
224
|
+
function it(u) {
|
|
225
|
+
return l(this, arguments, function* ({
|
|
226
226
|
env: n,
|
|
227
227
|
dmShortID: t,
|
|
228
228
|
model: e,
|
|
229
229
|
value: s,
|
|
230
230
|
token: r
|
|
231
231
|
}) {
|
|
232
|
-
|
|
233
|
-
const
|
|
232
|
+
g({ env: n, dmShortID: t, model: e, value: s });
|
|
233
|
+
const a = m(`api/${t}/${e}`, n);
|
|
234
234
|
return yield p(
|
|
235
|
-
|
|
235
|
+
a,
|
|
236
236
|
{ token: r },
|
|
237
237
|
{
|
|
238
238
|
method: "POST",
|
|
@@ -244,29 +244,29 @@ function it(d) {
|
|
|
244
244
|
);
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
247
|
+
function I(d) {
|
|
248
|
+
return l(this, arguments, function* ({
|
|
249
249
|
env: n,
|
|
250
250
|
dmShortID: t,
|
|
251
251
|
model: e,
|
|
252
252
|
entryID: s,
|
|
253
253
|
value: r,
|
|
254
|
-
token:
|
|
255
|
-
safePut:
|
|
254
|
+
token: u,
|
|
255
|
+
safePut: a = !1
|
|
256
256
|
}) {
|
|
257
|
-
|
|
257
|
+
g({ env: n, dmShortID: t, model: e, entryID: s, value: r });
|
|
258
258
|
const o = {
|
|
259
259
|
"Content-Type": "application/json"
|
|
260
260
|
};
|
|
261
|
-
if (
|
|
261
|
+
if (a) {
|
|
262
262
|
if (!("_modified" in r))
|
|
263
263
|
throw new Error("expected _modified to be set!");
|
|
264
264
|
o["If-Unmodified-Since"] = new Date(r._modified).toUTCString();
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
return r = st(r), r =
|
|
268
|
-
|
|
269
|
-
{ token:
|
|
266
|
+
const i = m(`api/${t}/${e}?_id=${s}`, n);
|
|
267
|
+
return r = st(r), r = U(r), yield p(
|
|
268
|
+
i,
|
|
269
|
+
{ token: u },
|
|
270
270
|
{
|
|
271
271
|
method: "PUT",
|
|
272
272
|
headers: o,
|
|
@@ -275,17 +275,17 @@ function K(l) {
|
|
|
275
275
|
);
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
|
-
function
|
|
278
|
+
function K({
|
|
279
279
|
env: n,
|
|
280
280
|
dmShortID: t,
|
|
281
281
|
model: e,
|
|
282
282
|
entryID: s,
|
|
283
283
|
token: r
|
|
284
284
|
}) {
|
|
285
|
-
|
|
286
|
-
const
|
|
285
|
+
g({ env: n, dmShortID: t, model: e, entryID: s });
|
|
286
|
+
const u = m(`api/${t}/${e}?_id=${s}`, n);
|
|
287
287
|
return p(
|
|
288
|
-
|
|
288
|
+
u,
|
|
289
289
|
{ token: r, rawRes: !0 },
|
|
290
290
|
{
|
|
291
291
|
method: "DELETE",
|
|
@@ -296,156 +296,156 @@ function N({
|
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
298
|
function at(n, t) {
|
|
299
|
-
return
|
|
300
|
-
let { env: e, dmShortID: s, model: r, options:
|
|
301
|
-
|
|
302
|
-
let
|
|
303
|
-
for (;
|
|
304
|
-
const
|
|
305
|
-
for (let
|
|
306
|
-
o.push(yield t(
|
|
307
|
-
|
|
299
|
+
return l(this, null, function* () {
|
|
300
|
+
let { env: e, dmShortID: s, model: r, options: u = {} } = n;
|
|
301
|
+
g({ env: e, dmShortID: s, model: r }), n.options = c({ size: 50, page: 1, _list: !0 }, u);
|
|
302
|
+
let a = 0, d, o = [];
|
|
303
|
+
for (; d === void 0 || a < d; ) {
|
|
304
|
+
const i = yield C(n);
|
|
305
|
+
for (let h of i.items)
|
|
306
|
+
o.push(yield t(h));
|
|
307
|
+
a += i.items.length, d = i.total, n.options.page++;
|
|
308
308
|
}
|
|
309
309
|
return o;
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
function ct(r) {
|
|
313
|
-
return
|
|
314
|
-
var
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
if (typeof
|
|
313
|
+
return l(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
|
|
314
|
+
var h, y, w, j, L;
|
|
315
|
+
g({ env: n, dmShortID: t, model: e });
|
|
316
|
+
const u = m(`api/schema/${t}/${e}`, n), a = yield p(u), d = (h = a == null ? void 0 : a.allOf) == null ? void 0 : h[1];
|
|
317
|
+
if (typeof d.properties != "object")
|
|
318
318
|
throw new Error(
|
|
319
|
-
`getSchema: ${
|
|
319
|
+
`getSchema: ${u} returned unexpected format: ${JSON.stringify(a)}`
|
|
320
320
|
);
|
|
321
|
-
const { properties: o } =
|
|
322
|
-
for (let
|
|
323
|
-
let
|
|
324
|
-
if (
|
|
325
|
-
const
|
|
326
|
-
|
|
321
|
+
const { properties: o } = d, i = U(o);
|
|
322
|
+
for (let T in i) {
|
|
323
|
+
let $ = i[T];
|
|
324
|
+
if ($.required = d.required.includes(T), (y = i[T]) != null && y.oneOf && ((w = i[T]) == null || delete w.oneOf), (j = $.title) != null && j.includes("<") && ((L = $.title) != null && L.includes(">"))) {
|
|
325
|
+
const P = $.title.split("<")[1].slice(0, -1), z = $.title.split("<")[0];
|
|
326
|
+
$.type = z, P.includes(":") ? $.resource = P.split(":")[1] : $.resource = P;
|
|
327
327
|
} else
|
|
328
|
-
["asset", "entry", "assets", "entries"].includes(
|
|
329
|
-
delete
|
|
328
|
+
["asset", "entry", "assets", "entries"].includes($.title) ? ($.type = $.title, $.resource = null) : $.type = $.title;
|
|
329
|
+
delete i[T].title;
|
|
330
330
|
}
|
|
331
331
|
if (s) {
|
|
332
|
-
const
|
|
333
|
-
return { properties:
|
|
332
|
+
const T = o._modelTitle.title, $ = o._modelTitleField.title;
|
|
333
|
+
return { properties: i, meta: { modelTitleField: $, modelTitle: T } };
|
|
334
334
|
}
|
|
335
|
-
return
|
|
335
|
+
return i;
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
return Object.entries(n).map(([t, e]) => typeof e != "object" ? { [t]: String(e) } :
|
|
338
|
+
function M(n) {
|
|
339
|
+
return Object.entries(n).map(([t, e]) => typeof e != "object" ? { [t]: String(e) } : c(c(c(c(c(c(c({}, e.sort && { sort: Array.isArray(e) ? e.join(",") : e }), e.search && { [t + "~"]: e.search }), e.notNull && { [t + "!"]: "" }), e.null && { [t]: "" }), e.any && { [t]: e.any.join(",") }), e.from && { [t + "From"]: e.from }), e.to && { [t + "To"]: e.to })).reduce((t, e) => c(c({}, t), e), {});
|
|
340
340
|
}
|
|
341
|
-
const ut =
|
|
342
|
-
function
|
|
341
|
+
const ut = M;
|
|
342
|
+
function S(n) {
|
|
343
343
|
return n._links.collection.href.split("/").slice(-2)[0];
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function N(n) {
|
|
346
346
|
const t = n._links.collection.href.split("api/")[0];
|
|
347
|
-
return Object.keys(
|
|
348
|
-
(s) =>
|
|
347
|
+
return Object.keys(_.datamanager).find(
|
|
348
|
+
(s) => _.datamanager[s] === t
|
|
349
349
|
);
|
|
350
350
|
}
|
|
351
|
-
const
|
|
352
|
-
const t =
|
|
351
|
+
const J = (n) => {
|
|
352
|
+
const t = S(n), e = N(n), s = n._modelTitle, r = n.id;
|
|
353
353
|
return { dmShortID: t, env: e, model: s, entryID: r };
|
|
354
|
-
},
|
|
354
|
+
}, lt = (n) => K(J(n)), dt = (n, t) => I(f(c({}, J(n)), {
|
|
355
355
|
value: t
|
|
356
356
|
}));
|
|
357
357
|
function ht(n, t) {
|
|
358
|
-
const e =
|
|
358
|
+
const e = S(t);
|
|
359
359
|
return t._embedded[`${e}:${t._modelTitle}/${n}/asset`];
|
|
360
360
|
}
|
|
361
|
-
function gt(
|
|
362
|
-
return
|
|
361
|
+
function gt(u) {
|
|
362
|
+
return l(this, arguments, function* ({
|
|
363
363
|
env: n,
|
|
364
364
|
dmShortID: t,
|
|
365
365
|
assetGroup: e,
|
|
366
366
|
assetID: s,
|
|
367
367
|
token: r
|
|
368
368
|
}) {
|
|
369
|
-
|
|
370
|
-
const
|
|
369
|
+
g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
370
|
+
const a = k({ assetID: s }), d = m(`a/${t}/${e}?${a}`, n), { _embedded: o } = yield p(d, { token: r });
|
|
371
371
|
return o ? o["ec:dm-asset"] : void 0;
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
374
|
function ft(n) {
|
|
375
|
-
return
|
|
376
|
-
let { env: t, dmShortID: e, assetGroup: s, token: r, options:
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
let
|
|
380
|
-
return
|
|
375
|
+
return l(this, null, function* () {
|
|
376
|
+
let { env: t, dmShortID: e, assetGroup: s, token: r, options: u = {} } = n;
|
|
377
|
+
g({ env: t, dmShortID: e, assetGroup: s }), u = c({ size: 50, page: 1, _list: !0 }, u);
|
|
378
|
+
const a = k(u), d = m(`a/${e}/${s}?${a}`, t), { count: o, total: i, _embedded: h } = yield p(d, { token: r });
|
|
379
|
+
let y = h ? h["ec:dm-asset"] : [];
|
|
380
|
+
return y = Array.isArray(y) ? y : [y], { count: o, total: i, items: y };
|
|
381
381
|
});
|
|
382
382
|
}
|
|
383
|
-
function pt(
|
|
384
|
-
return
|
|
383
|
+
function pt(d) {
|
|
384
|
+
return l(this, arguments, function* ({
|
|
385
385
|
env: n,
|
|
386
386
|
dmShortID: t,
|
|
387
387
|
assetGroup: e,
|
|
388
388
|
token: s,
|
|
389
389
|
file: r,
|
|
390
|
-
name:
|
|
391
|
-
options:
|
|
390
|
+
name: u,
|
|
391
|
+
options: a
|
|
392
392
|
}) {
|
|
393
|
-
|
|
394
|
-
const o =
|
|
395
|
-
return
|
|
396
|
-
|
|
393
|
+
g({ env: n, dmShortID: t, assetGroup: e, file: r });
|
|
394
|
+
const o = m(`a/${t}/${e}`, n), i = new FormData();
|
|
395
|
+
return i.append("file", r, u), a && Object.keys(a).forEach((y) => {
|
|
396
|
+
i.append(y, a[y]);
|
|
397
397
|
}), (yield p(
|
|
398
398
|
o,
|
|
399
399
|
{ token: s },
|
|
400
400
|
{
|
|
401
401
|
method: "POST",
|
|
402
|
-
body:
|
|
402
|
+
body: i
|
|
403
403
|
}
|
|
404
404
|
))._embedded["ec:dm-asset"];
|
|
405
405
|
});
|
|
406
406
|
}
|
|
407
|
-
function
|
|
408
|
-
return
|
|
407
|
+
function mt(u) {
|
|
408
|
+
return l(this, arguments, function* ({
|
|
409
409
|
env: n,
|
|
410
410
|
dmShortID: t,
|
|
411
411
|
assetGroup: e,
|
|
412
412
|
files: s,
|
|
413
413
|
options: r
|
|
414
414
|
}) {
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
s.forEach((
|
|
418
|
-
|
|
415
|
+
g({ env: n, dmShortID: t, assetGroup: e, files: s });
|
|
416
|
+
const a = m(`a/${t}/${e}`, n), d = new FormData();
|
|
417
|
+
s.forEach((i) => {
|
|
418
|
+
d.append(
|
|
419
419
|
"file",
|
|
420
|
-
|
|
420
|
+
i
|
|
421
421
|
/* , name */
|
|
422
422
|
);
|
|
423
|
-
}), r && Object.keys(r).forEach((
|
|
424
|
-
|
|
423
|
+
}), r && Object.keys(r).forEach((i) => {
|
|
424
|
+
d.append(i, r[i]);
|
|
425
425
|
});
|
|
426
426
|
const o = yield p(
|
|
427
|
-
|
|
427
|
+
a,
|
|
428
428
|
{},
|
|
429
429
|
{
|
|
430
430
|
method: "POST",
|
|
431
|
-
body:
|
|
431
|
+
body: d
|
|
432
432
|
}
|
|
433
433
|
);
|
|
434
434
|
return Array.isArray(o._embedded["ec:dm-asset"]) ? o._embedded["ec:dm-asset"] : [o._embedded["ec:dm-asset"]];
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
|
-
function
|
|
438
|
-
return
|
|
437
|
+
function yt(u) {
|
|
438
|
+
return l(this, arguments, function* ({
|
|
439
439
|
env: n,
|
|
440
440
|
dmShortID: t,
|
|
441
441
|
assetGroup: e,
|
|
442
442
|
assetID: s,
|
|
443
443
|
token: r
|
|
444
444
|
}) {
|
|
445
|
-
|
|
446
|
-
const
|
|
445
|
+
g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
446
|
+
const a = m(`a/${t}/${e}/${s}`, n);
|
|
447
447
|
yield p(
|
|
448
|
-
|
|
448
|
+
a,
|
|
449
449
|
{ token: r, rawRes: !0 },
|
|
450
450
|
{
|
|
451
451
|
method: "DELETE"
|
|
@@ -453,70 +453,93 @@ function mt(d) {
|
|
|
453
453
|
);
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
|
-
function $t(n) {
|
|
457
|
-
|
|
456
|
+
function $t(n, t, e = !1) {
|
|
457
|
+
var a, d, o;
|
|
458
|
+
let s, r;
|
|
459
|
+
const u = e ? n == null ? void 0 : n.thumbnails : n == null ? void 0 : n.fileVariants;
|
|
460
|
+
return u == null || u.forEach((i) => {
|
|
461
|
+
const {
|
|
462
|
+
resolution: { width: h, height: y }
|
|
463
|
+
} = i, w = Math.abs(Math.max(h, y) - t);
|
|
464
|
+
(!r || w < r) && (r = w, s = i);
|
|
465
|
+
}), (o = (d = s == null ? void 0 : s.url) != null ? d : (a = n == null ? void 0 : n.file) == null ? void 0 : a.url) != null ? o : null;
|
|
466
|
+
}
|
|
467
|
+
function wt(n = "stage", t, e, s, r = !1) {
|
|
468
|
+
const u = Math.max(s.file.resolution.width, s.file.resolution.height), a = e.filter((o) => o < u), d = `https://datamanager${n === "stage" ? ".cachena" : ""}.entrecode.de`;
|
|
469
|
+
return r ? a.map((o) => {
|
|
470
|
+
const i = s.thumbnails.find((w) => o === w.dimension), h = `${d}/t/${t}/${s.assetID}/${o}`, y = i ? i.url : h;
|
|
471
|
+
return { size: o, url: y, generated: i };
|
|
472
|
+
}) : a.map((o) => {
|
|
473
|
+
const i = s.fileVariants.find((w) => o === Math.max(w.resolution.width, w.resolution.height)), h = `${d}/f/${t}/${s.assetID}/${o}`, y = i ? i.url : h;
|
|
474
|
+
return { size: o, url: y, generated: i };
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function kt(n) {
|
|
478
|
+
return l(this, null, function* () {
|
|
458
479
|
let { env: t, dmID: e, token: s } = n;
|
|
459
|
-
|
|
460
|
-
const r =
|
|
480
|
+
g({ env: t, dmID: e });
|
|
481
|
+
const r = m(`?dataManagerID=${e}`, t);
|
|
461
482
|
return p(r, { token: s });
|
|
462
483
|
});
|
|
463
484
|
}
|
|
464
|
-
function
|
|
465
|
-
return
|
|
485
|
+
function Tt(n) {
|
|
486
|
+
return l(this, null, function* () {
|
|
466
487
|
let { env: t, options: e = {} } = n;
|
|
467
|
-
|
|
468
|
-
const s = k(e), r =
|
|
469
|
-
let o =
|
|
470
|
-
return o = Array.isArray(o) ? o : [o], { count:
|
|
488
|
+
g({ env: t }), e = c({ size: 25, page: 1, _list: !0 }, e);
|
|
489
|
+
const s = k(e), r = m(`?${s}`, t), { count: u, total: a, _embedded: d } = yield p(r, n);
|
|
490
|
+
let o = d ? d["ec:datamanager"] : [];
|
|
491
|
+
return o = Array.isArray(o) ? o : [o], { count: u, total: a, items: o };
|
|
471
492
|
});
|
|
472
493
|
}
|
|
473
|
-
function
|
|
474
|
-
return
|
|
494
|
+
function Et(n) {
|
|
495
|
+
return l(this, null, function* () {
|
|
475
496
|
let { env: t, dmID: e, options: s = {} } = n;
|
|
476
|
-
|
|
477
|
-
const r = k(s),
|
|
478
|
-
let
|
|
479
|
-
return
|
|
497
|
+
g({ env: t, dmID: e }), s = c({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
|
|
498
|
+
const r = k(s), u = m(`model?${r}`, t), { count: a, total: d, _embedded: o } = yield p(u, n);
|
|
499
|
+
let i = o ? o["ec:model"] : [];
|
|
500
|
+
return i = Array.isArray(i) ? i : [i], { count: a, total: d, items: i };
|
|
480
501
|
});
|
|
481
502
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
503
|
+
function bt(n) {
|
|
504
|
+
return l(this, null, function* () {
|
|
484
505
|
let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
|
|
485
|
-
|
|
486
|
-
const
|
|
487
|
-
let
|
|
488
|
-
return
|
|
506
|
+
g({ env: t, subdomain: r, resource: e }), s = c({ size: 25, page: 1, _list: !0 }, s);
|
|
507
|
+
const u = k(s), a = m(`${e}?${u}`, t, r), { count: d, total: o, _embedded: i } = yield p(a, n);
|
|
508
|
+
let h = i ? i[Object.keys(i)[0]] : [];
|
|
509
|
+
return h = Array.isArray(h) ? h : [h], { count: d, total: o, items: h };
|
|
489
510
|
});
|
|
490
511
|
}
|
|
491
|
-
function
|
|
492
|
-
return
|
|
493
|
-
let { env: s, route: r, options:
|
|
494
|
-
|
|
495
|
-
const
|
|
512
|
+
function At(e) {
|
|
513
|
+
return l(this, arguments, function* (n, t = {}) {
|
|
514
|
+
let { env: s, route: r, options: u = {}, subdomain: a = "datamanager" } = n;
|
|
515
|
+
g({ env: s, subdomain: a, route: r }), u = c({}, u);
|
|
516
|
+
const d = k(u), o = m(`${r}?${d}`, s, a);
|
|
496
517
|
return p(o, n, t);
|
|
497
518
|
});
|
|
498
519
|
}
|
|
499
|
-
const
|
|
520
|
+
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
500
521
|
__proto__: null,
|
|
501
522
|
assetList: ft,
|
|
502
523
|
createAsset: pt,
|
|
503
|
-
createAssets:
|
|
524
|
+
createAssets: mt,
|
|
504
525
|
createEntry: it,
|
|
505
|
-
deleteAsset:
|
|
506
|
-
deleteEntry:
|
|
507
|
-
deleteEntryObject:
|
|
508
|
-
dmList:
|
|
509
|
-
editEntry:
|
|
510
|
-
editEntryObject:
|
|
511
|
-
entryList:
|
|
526
|
+
deleteAsset: yt,
|
|
527
|
+
deleteEntry: K,
|
|
528
|
+
deleteEntryObject: lt,
|
|
529
|
+
dmList: Tt,
|
|
530
|
+
editEntry: I,
|
|
531
|
+
editEntryObject: dt,
|
|
532
|
+
entryList: C,
|
|
533
|
+
fileVariant: $t,
|
|
512
534
|
filterOptions: ut,
|
|
513
535
|
getAsset: gt,
|
|
514
|
-
getDatamanager:
|
|
536
|
+
getDatamanager: kt,
|
|
515
537
|
getEcAuthKey: et,
|
|
516
538
|
getEntry: ot,
|
|
517
539
|
getEntryAsset: ht,
|
|
518
|
-
getEntryEnv:
|
|
519
|
-
getEntryShortID:
|
|
540
|
+
getEntryEnv: N,
|
|
541
|
+
getEntryShortID: S,
|
|
542
|
+
getFileVariants: wt,
|
|
520
543
|
getPublicAuthKey: tt,
|
|
521
544
|
getSchema: ct,
|
|
522
545
|
loginEc: Y,
|
|
@@ -524,48 +547,48 @@ const b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
524
547
|
logoutEc: G,
|
|
525
548
|
logoutPublic: Z,
|
|
526
549
|
mapEntries: at,
|
|
527
|
-
modelList:
|
|
550
|
+
modelList: Et,
|
|
528
551
|
publicApi: rt,
|
|
529
|
-
raw:
|
|
530
|
-
resourceList:
|
|
531
|
-
sdkOptions:
|
|
552
|
+
raw: At,
|
|
553
|
+
resourceList: bt,
|
|
554
|
+
sdkOptions: M
|
|
532
555
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
533
|
-
entryList:
|
|
534
|
-
mapEntries:
|
|
535
|
-
getEntry:
|
|
536
|
-
getAsset:
|
|
556
|
+
entryList: v,
|
|
557
|
+
mapEntries: _t,
|
|
558
|
+
getEntry: Ot,
|
|
559
|
+
getAsset: Pt,
|
|
537
560
|
assetList: q,
|
|
538
|
-
createAsset:
|
|
539
|
-
createAssets:
|
|
540
|
-
deleteAsset:
|
|
541
|
-
createEntry:
|
|
561
|
+
createAsset: St,
|
|
562
|
+
createAssets: jt,
|
|
563
|
+
deleteAsset: Lt,
|
|
564
|
+
createEntry: Bt,
|
|
542
565
|
editEntry: x,
|
|
543
|
-
deleteEntry:
|
|
544
|
-
getSchema:
|
|
545
|
-
loginPublic:
|
|
546
|
-
loginEc:
|
|
547
|
-
logoutEc:
|
|
548
|
-
logoutPublic:
|
|
549
|
-
getEcAuthKey:
|
|
550
|
-
getPublicAuthKey:
|
|
551
|
-
dmList:
|
|
552
|
-
modelList:
|
|
553
|
-
publicApi:
|
|
554
|
-
getDatamanager:
|
|
566
|
+
deleteEntry: Dt,
|
|
567
|
+
getSchema: vt,
|
|
568
|
+
loginPublic: qt,
|
|
569
|
+
loginEc: xt,
|
|
570
|
+
logoutEc: Ft,
|
|
571
|
+
logoutPublic: Ut,
|
|
572
|
+
getEcAuthKey: E,
|
|
573
|
+
getPublicAuthKey: b,
|
|
574
|
+
dmList: Ct,
|
|
575
|
+
modelList: It,
|
|
576
|
+
publicApi: Kt,
|
|
577
|
+
getDatamanager: Mt,
|
|
555
578
|
resourceList: Nt,
|
|
556
|
-
raw:
|
|
557
|
-
} =
|
|
579
|
+
raw: Jt
|
|
580
|
+
} = A;
|
|
558
581
|
function Rt(n) {
|
|
559
582
|
const { action: t } = n;
|
|
560
|
-
if (
|
|
583
|
+
if (g({ action: t }), !A[t])
|
|
561
584
|
throw new Error(
|
|
562
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
585
|
+
`"${t}" does not exist! try one of ${Object.keys(A).join(
|
|
563
586
|
", "
|
|
564
587
|
)}`
|
|
565
588
|
);
|
|
566
|
-
return
|
|
589
|
+
return A[t](n);
|
|
567
590
|
}
|
|
568
|
-
class
|
|
591
|
+
class O {
|
|
569
592
|
/** @ignore */
|
|
570
593
|
constructor(t = {}) {
|
|
571
594
|
if (!t.storageAdapter) {
|
|
@@ -580,13 +603,13 @@ class _ {
|
|
|
580
603
|
}
|
|
581
604
|
/** @ignore */
|
|
582
605
|
set(t) {
|
|
583
|
-
return new
|
|
606
|
+
return new O(c(c({}, this.config), t));
|
|
584
607
|
}
|
|
585
608
|
/** @ignore */
|
|
586
609
|
entries() {
|
|
587
|
-
return
|
|
610
|
+
return l(this, arguments, function* (t = {}) {
|
|
588
611
|
const e = yield this.getBestToken();
|
|
589
|
-
return
|
|
612
|
+
return v(f(c({}, this.config), { options: t, token: e }));
|
|
590
613
|
});
|
|
591
614
|
}
|
|
592
615
|
/**
|
|
@@ -603,9 +626,9 @@ class _ {
|
|
|
603
626
|
* const secrets = await fdk("stage").token(token).dm("83cc6374").model("secret").entryList()
|
|
604
627
|
*/
|
|
605
628
|
entryList(t) {
|
|
606
|
-
return
|
|
629
|
+
return l(this, null, function* () {
|
|
607
630
|
const e = yield this.getBestToken();
|
|
608
|
-
return
|
|
631
|
+
return v(f(c({}, this.config), { options: t, token: e }));
|
|
609
632
|
});
|
|
610
633
|
}
|
|
611
634
|
/**
|
|
@@ -620,9 +643,9 @@ class _ {
|
|
|
620
643
|
* console.log("res", res);
|
|
621
644
|
*/
|
|
622
645
|
mapEntries(s) {
|
|
623
|
-
return
|
|
646
|
+
return l(this, arguments, function* (t, e = {}) {
|
|
624
647
|
const r = yield this.getBestToken();
|
|
625
|
-
return
|
|
648
|
+
return _t(f(c({}, this.config), { options: e, token: r }), t);
|
|
626
649
|
});
|
|
627
650
|
}
|
|
628
651
|
/**
|
|
@@ -633,9 +656,9 @@ class _ {
|
|
|
633
656
|
* const muffin = await fdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
634
657
|
*/
|
|
635
658
|
getEntry(t) {
|
|
636
|
-
return
|
|
659
|
+
return l(this, null, function* () {
|
|
637
660
|
const e = yield this.getBestToken();
|
|
638
|
-
return
|
|
661
|
+
return Ot(f(c({}, this.config), { entryID: t, token: e }));
|
|
639
662
|
});
|
|
640
663
|
}
|
|
641
664
|
/**
|
|
@@ -653,9 +676,9 @@ class _ {
|
|
|
653
676
|
* .editEntrySafe("1gOtzWvrdq", { name: "test", _modified: "2020-01-01T00:00:00.000Z"})
|
|
654
677
|
*/
|
|
655
678
|
editEntrySafe(t, e) {
|
|
656
|
-
return
|
|
679
|
+
return l(this, null, function* () {
|
|
657
680
|
const s = yield this.getBestToken();
|
|
658
|
-
return x(
|
|
681
|
+
return x(f(c({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
|
|
659
682
|
});
|
|
660
683
|
}
|
|
661
684
|
/**
|
|
@@ -666,15 +689,15 @@ class _ {
|
|
|
666
689
|
* const muffin = await fdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
667
690
|
*/
|
|
668
691
|
getSchema() {
|
|
669
|
-
return
|
|
670
|
-
return
|
|
692
|
+
return l(this, null, function* () {
|
|
693
|
+
return vt(this.config);
|
|
671
694
|
});
|
|
672
695
|
}
|
|
673
696
|
/** @ignore */
|
|
674
697
|
assets(t) {
|
|
675
|
-
return
|
|
698
|
+
return l(this, null, function* () {
|
|
676
699
|
const e = yield this.getBestToken();
|
|
677
|
-
return q(
|
|
700
|
+
return q(f(c({}, this.config), { options: t, token: e }));
|
|
678
701
|
});
|
|
679
702
|
}
|
|
680
703
|
/**
|
|
@@ -689,9 +712,9 @@ class _ {
|
|
|
689
712
|
* const files = await fdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assetList()
|
|
690
713
|
*/
|
|
691
714
|
assetList(t) {
|
|
692
|
-
return
|
|
715
|
+
return l(this, null, function* () {
|
|
693
716
|
const e = yield this.getBestToken();
|
|
694
|
-
return q(
|
|
717
|
+
return q(f(c({}, this.config), { options: t, token: e }));
|
|
695
718
|
});
|
|
696
719
|
}
|
|
697
720
|
/**
|
|
@@ -714,9 +737,9 @@ class _ {
|
|
|
714
737
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
715
738
|
*/
|
|
716
739
|
createAsset(t) {
|
|
717
|
-
return
|
|
718
|
-
const { file: e, name: s, options: r } = t,
|
|
719
|
-
return
|
|
740
|
+
return l(this, null, function* () {
|
|
741
|
+
const { file: e, name: s, options: r } = t, u = yield this.getBestToken();
|
|
742
|
+
return St(f(c({}, this.config), { file: e, name: s, options: r, token: u }));
|
|
720
743
|
});
|
|
721
744
|
}
|
|
722
745
|
/**
|
|
@@ -739,9 +762,9 @@ class _ {
|
|
|
739
762
|
* .createAsset({ files });
|
|
740
763
|
*/
|
|
741
764
|
createAssets(t) {
|
|
742
|
-
return
|
|
765
|
+
return l(this, null, function* () {
|
|
743
766
|
const { files: e, options: s } = t, r = yield this.getBestToken();
|
|
744
|
-
return
|
|
767
|
+
return jt(f(c({}, this.config), { files: e, options: s, token: r }));
|
|
745
768
|
});
|
|
746
769
|
}
|
|
747
770
|
/**
|
|
@@ -753,9 +776,9 @@ class _ {
|
|
|
753
776
|
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
754
777
|
*/
|
|
755
778
|
deleteAsset(t) {
|
|
756
|
-
return
|
|
779
|
+
return l(this, null, function* () {
|
|
757
780
|
const e = yield this.getBestToken();
|
|
758
|
-
return
|
|
781
|
+
return Lt(f(c({}, this.config), { token: e, assetID: t }));
|
|
759
782
|
});
|
|
760
783
|
}
|
|
761
784
|
/**
|
|
@@ -766,9 +789,9 @@ class _ {
|
|
|
766
789
|
* const asset = await fdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
767
790
|
*/
|
|
768
791
|
getAsset(t) {
|
|
769
|
-
return
|
|
792
|
+
return l(this, null, function* () {
|
|
770
793
|
const e = yield this.getBestToken();
|
|
771
|
-
return
|
|
794
|
+
return Pt(f(c({}, this.config), { assetID: t, token: e }));
|
|
772
795
|
});
|
|
773
796
|
}
|
|
774
797
|
/**
|
|
@@ -780,9 +803,9 @@ class _ {
|
|
|
780
803
|
* const entry = await fdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
781
804
|
*/
|
|
782
805
|
createEntry(t) {
|
|
783
|
-
return
|
|
806
|
+
return l(this, null, function* () {
|
|
784
807
|
const e = yield this.getBestToken();
|
|
785
|
-
return
|
|
808
|
+
return Bt(f(c({}, this.config), { token: e, value: t }));
|
|
786
809
|
});
|
|
787
810
|
}
|
|
788
811
|
/**
|
|
@@ -795,9 +818,9 @@ class _ {
|
|
|
795
818
|
* const entry = await fdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
796
819
|
*/
|
|
797
820
|
editEntry(t, e) {
|
|
798
|
-
return
|
|
821
|
+
return l(this, null, function* () {
|
|
799
822
|
const s = yield this.getBestToken();
|
|
800
|
-
return x(
|
|
823
|
+
return x(f(c({}, this.config), { entryID: t, token: s, value: e }));
|
|
801
824
|
});
|
|
802
825
|
}
|
|
803
826
|
/**
|
|
@@ -810,9 +833,9 @@ class _ {
|
|
|
810
833
|
* await fdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
811
834
|
*/
|
|
812
835
|
deleteEntry(t) {
|
|
813
|
-
return
|
|
836
|
+
return l(this, null, function* () {
|
|
814
837
|
const e = yield this.getBestToken();
|
|
815
|
-
return
|
|
838
|
+
return Dt(f(c({}, this.config), { token: e, entryID: t }));
|
|
816
839
|
});
|
|
817
840
|
}
|
|
818
841
|
/**
|
|
@@ -824,9 +847,9 @@ class _ {
|
|
|
824
847
|
* const res = await fdk("stage").resource("template").resourceList()
|
|
825
848
|
*/
|
|
826
849
|
resourceList(t) {
|
|
827
|
-
return
|
|
850
|
+
return l(this, null, function* () {
|
|
828
851
|
const e = yield this.getBestToken();
|
|
829
|
-
return Nt(
|
|
852
|
+
return Nt(f(c({}, this.config), { options: t, token: e }));
|
|
830
853
|
});
|
|
831
854
|
}
|
|
832
855
|
/**
|
|
@@ -840,9 +863,9 @@ class _ {
|
|
|
840
863
|
* const res = await fdk("stage").route("stats").raw()
|
|
841
864
|
*/
|
|
842
865
|
raw(t, e) {
|
|
843
|
-
return
|
|
866
|
+
return l(this, null, function* () {
|
|
844
867
|
const s = yield this.getBestToken();
|
|
845
|
-
return
|
|
868
|
+
return Jt(f(c({}, this.config), { options: t, token: s }), e);
|
|
846
869
|
});
|
|
847
870
|
}
|
|
848
871
|
/**
|
|
@@ -876,11 +899,11 @@ class _ {
|
|
|
876
899
|
}
|
|
877
900
|
/** @ignore */
|
|
878
901
|
getPublicToken() {
|
|
879
|
-
return this.config.token || this.getToken(
|
|
902
|
+
return this.config.token || this.getToken(b(this.config));
|
|
880
903
|
}
|
|
881
904
|
/** @ignore */
|
|
882
905
|
getEcToken() {
|
|
883
|
-
return this.config.token || this.getToken(
|
|
906
|
+
return this.config.token || this.getToken(E(this.config));
|
|
884
907
|
}
|
|
885
908
|
/** @ignore */
|
|
886
909
|
setToken(t, e) {
|
|
@@ -894,7 +917,7 @@ class _ {
|
|
|
894
917
|
* @ignore
|
|
895
918
|
*/
|
|
896
919
|
setEcToken(t) {
|
|
897
|
-
this.setToken(
|
|
920
|
+
this.setToken(E(this.config), t);
|
|
898
921
|
}
|
|
899
922
|
/**
|
|
900
923
|
* Manually set public user token on the {@link Fdk.authStorage}. In most cases, you'd want to use {@link Fdk.token} instead!
|
|
@@ -902,15 +925,15 @@ class _ {
|
|
|
902
925
|
* @ignore
|
|
903
926
|
*/
|
|
904
927
|
setPublicToken(t) {
|
|
905
|
-
this.setToken(
|
|
928
|
+
this.setToken(b(this.config), t);
|
|
906
929
|
}
|
|
907
930
|
/**
|
|
908
931
|
* Login with the given ec user. Only needed when using manual auth.
|
|
909
932
|
* @category Auth
|
|
910
933
|
*/
|
|
911
934
|
loginEc(t) {
|
|
912
|
-
return
|
|
913
|
-
(e) => this.setToken(
|
|
935
|
+
return xt(c(c({}, this.config), t)).then(
|
|
936
|
+
(e) => this.setToken(E(this.config), e.token)
|
|
914
937
|
);
|
|
915
938
|
}
|
|
916
939
|
/**
|
|
@@ -918,8 +941,8 @@ class _ {
|
|
|
918
941
|
* @category Auth
|
|
919
942
|
*/
|
|
920
943
|
loginPublic(t) {
|
|
921
|
-
return
|
|
922
|
-
(e) => this.setToken(
|
|
944
|
+
return qt(c(c({}, this.config), t)).then(
|
|
945
|
+
(e) => this.setToken(b(this.config), e.token)
|
|
923
946
|
);
|
|
924
947
|
}
|
|
925
948
|
/**
|
|
@@ -928,8 +951,8 @@ class _ {
|
|
|
928
951
|
*/
|
|
929
952
|
logoutPublic() {
|
|
930
953
|
const t = this.getPublicToken();
|
|
931
|
-
return
|
|
932
|
-
() => this.removeToken(
|
|
954
|
+
return Ut(f(c({}, this.config), { token: t })).then(
|
|
955
|
+
() => this.removeToken(b(this.config))
|
|
933
956
|
);
|
|
934
957
|
}
|
|
935
958
|
/**
|
|
@@ -938,8 +961,8 @@ class _ {
|
|
|
938
961
|
*/
|
|
939
962
|
logoutEc() {
|
|
940
963
|
const t = this.getEcToken();
|
|
941
|
-
return
|
|
942
|
-
() => this.removeToken(
|
|
964
|
+
return Ft(f(c({}, this.config), { token: t })).then(
|
|
965
|
+
() => this.removeToken(E(this.config))
|
|
943
966
|
);
|
|
944
967
|
}
|
|
945
968
|
/** @ignore */
|
|
@@ -1038,16 +1061,16 @@ class _ {
|
|
|
1038
1061
|
* @category Entries
|
|
1039
1062
|
*/
|
|
1040
1063
|
publicApi() {
|
|
1041
|
-
return
|
|
1064
|
+
return Kt(this.config);
|
|
1042
1065
|
}
|
|
1043
1066
|
/**
|
|
1044
1067
|
* Loads a DatamanagerResource by its long id. Requires token.
|
|
1045
1068
|
* @category Admin
|
|
1046
1069
|
*/
|
|
1047
1070
|
getDatamanager(t) {
|
|
1048
|
-
return
|
|
1071
|
+
return l(this, null, function* () {
|
|
1049
1072
|
const e = yield this.getBestToken();
|
|
1050
|
-
return
|
|
1073
|
+
return Mt(f(c({}, this.config), { dmID: t, token: e }));
|
|
1051
1074
|
});
|
|
1052
1075
|
}
|
|
1053
1076
|
/**
|
|
@@ -1059,9 +1082,9 @@ class _ {
|
|
|
1059
1082
|
* const dms = await fdk("stage").dmList()
|
|
1060
1083
|
*/
|
|
1061
1084
|
dmList() {
|
|
1062
|
-
return
|
|
1085
|
+
return l(this, arguments, function* (t = {}) {
|
|
1063
1086
|
const e = yield this.getBestToken();
|
|
1064
|
-
return
|
|
1087
|
+
return Ct(f(c({}, this.config), { options: t, token: e }));
|
|
1065
1088
|
});
|
|
1066
1089
|
}
|
|
1067
1090
|
/**
|
|
@@ -1073,40 +1096,42 @@ class _ {
|
|
|
1073
1096
|
* const models = await fdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
1074
1097
|
*/
|
|
1075
1098
|
modelList() {
|
|
1076
|
-
return
|
|
1099
|
+
return l(this, arguments, function* (t = {}) {
|
|
1077
1100
|
const e = yield this.getBestToken();
|
|
1078
|
-
return
|
|
1101
|
+
return It(f(c({}, this.config), { options: t, token: e }));
|
|
1079
1102
|
});
|
|
1080
1103
|
}
|
|
1081
1104
|
}
|
|
1082
|
-
const
|
|
1105
|
+
const Vt = (n) => new O({ env: n }), Ht = (n) => new O({ env: n });
|
|
1083
1106
|
export {
|
|
1084
|
-
|
|
1107
|
+
O as Fdk,
|
|
1085
1108
|
Rt as act,
|
|
1086
|
-
|
|
1087
|
-
|
|
1109
|
+
m as apiURL,
|
|
1110
|
+
_ as apis,
|
|
1088
1111
|
ft as assetList,
|
|
1089
1112
|
pt as createAsset,
|
|
1090
|
-
|
|
1113
|
+
mt as createAssets,
|
|
1091
1114
|
it as createEntry,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1115
|
+
yt as deleteAsset,
|
|
1116
|
+
K as deleteEntry,
|
|
1117
|
+
lt as deleteEntryObject,
|
|
1118
|
+
Tt as dmList,
|
|
1119
|
+
I as editEntry,
|
|
1120
|
+
dt as editEntryObject,
|
|
1121
|
+
C as entryList,
|
|
1122
|
+
g as expect,
|
|
1123
|
+
Vt as fdk,
|
|
1101
1124
|
p as fetcher,
|
|
1125
|
+
$t as fileVariant,
|
|
1102
1126
|
ut as filterOptions,
|
|
1103
1127
|
gt as getAsset,
|
|
1104
|
-
|
|
1128
|
+
kt as getDatamanager,
|
|
1105
1129
|
et as getEcAuthKey,
|
|
1106
1130
|
ot as getEntry,
|
|
1107
1131
|
ht as getEntryAsset,
|
|
1108
|
-
|
|
1109
|
-
|
|
1132
|
+
N as getEntryEnv,
|
|
1133
|
+
S as getEntryShortID,
|
|
1134
|
+
wt as getFileVariants,
|
|
1110
1135
|
tt as getPublicAuthKey,
|
|
1111
1136
|
ct as getSchema,
|
|
1112
1137
|
Y as loginEc,
|
|
@@ -1114,11 +1139,11 @@ export {
|
|
|
1114
1139
|
G as logoutEc,
|
|
1115
1140
|
Z as logoutPublic,
|
|
1116
1141
|
at as mapEntries,
|
|
1117
|
-
|
|
1142
|
+
Et as modelList,
|
|
1118
1143
|
rt as publicApi,
|
|
1119
1144
|
k as query,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1145
|
+
At as raw,
|
|
1146
|
+
bt as resourceList,
|
|
1147
|
+
Ht as sdk,
|
|
1148
|
+
M as sdkOptions
|
|
1124
1149
|
};
|
package/dist/lib/assets.d.ts
CHANGED
|
@@ -41,4 +41,39 @@ export declare function deleteAsset({ env, dmShortID, assetGroup, assetID, token
|
|
|
41
41
|
assetID: any;
|
|
42
42
|
token: any;
|
|
43
43
|
}): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
46
|
+
* If the model is not public, you also need to provide a `token`.
|
|
47
|
+
*
|
|
48
|
+
* @param {AssetResouce} asset asset in question.
|
|
49
|
+
* @param {number} size in px to find closest match (larger side)
|
|
50
|
+
* @param {boolean} thumb if true, returns a thumbnail (width = height)
|
|
51
|
+
* @category Assets
|
|
52
|
+
* @example
|
|
53
|
+
* const asset = await ecadmin
|
|
54
|
+
* .assetgroup("test")
|
|
55
|
+
* .getAsset("tP-ZxpZZTGmbPnET-wArAQ");
|
|
56
|
+
* const variant = fileVariant(asset, 128, false);
|
|
57
|
+
*/
|
|
58
|
+
export declare function fileVariant(asset: AssetResource, size: number, thumb?: boolean): any;
|
|
59
|
+
/**
|
|
60
|
+
* Returns list of file variants for given asset.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} env env
|
|
63
|
+
* @param {string} shortID dm shortID
|
|
64
|
+
* @param {number[]} allSizes array of dimensions. must match configuration in dm | assetgroup | defaultSizes. see getPossibleSizes in ec.editor4 for details.
|
|
65
|
+
* @param {AssetResouce} asset asset in question.
|
|
66
|
+
* @param {boolean} thumb if true, returns a thumbnail (width = height)
|
|
67
|
+
* @category Assets
|
|
68
|
+
* @example
|
|
69
|
+
* const asset = await ecadmin
|
|
70
|
+
* .assetgroup("test")
|
|
71
|
+
* .getAsset("tP-ZxpZZTGmbPnET-wArAQ");
|
|
72
|
+
* const variants = getFileVariants('stage', '83cc6374', [64, 128, 256, 512, 1024], asset, 128, false);
|
|
73
|
+
*/
|
|
74
|
+
export declare function getFileVariants(env: string, shortID: string, allSizes: number[], asset: AssetResource, thumb?: boolean): {
|
|
75
|
+
size: number;
|
|
76
|
+
url: any;
|
|
77
|
+
generated: any;
|
|
78
|
+
}[];
|
|
44
79
|
//# sourceMappingURL=assets.d.ts.map
|
package/dist/lib/assets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/lib/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrD,cAAc;AACd,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,GACN;;;;;;CAAA,GAAG,OAAO,CAAC,aAAa,CAAC,CAMzB;AAED,cAAc;AACd,wBAAsB,SAAS,CAAC,MAAM,KAAA,GAAG,OAAO,CAAC,SAAS,CAAC,CAW1D;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,EAChC,GAAG,EACH,SAAS,EACT,UAAU,EACV,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,GACR;;;;;;;;CAAA,GAAG,OAAO,CAAC,aAAa,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,EACjC,GAAG,EACH,SAAS,EACT,UAAU,EACV,KAAK,EACL,OAAO,GACR;;;;;;CAAA,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAwB3B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,EAChC,GAAG,EACH,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,GACN;;;;;;CAAA,iBAUA"}
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/lib/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrD,cAAc;AACd,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,GACN;;;;;;CAAA,GAAG,OAAO,CAAC,aAAa,CAAC,CAMzB;AAED,cAAc;AACd,wBAAsB,SAAS,CAAC,MAAM,KAAA,GAAG,OAAO,CAAC,SAAS,CAAC,CAW1D;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,EAChC,GAAG,EACH,SAAS,EACT,UAAU,EACV,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,GACR;;;;;;;;CAAA,GAAG,OAAO,CAAC,aAAa,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,EACjC,GAAG,EACH,SAAS,EACT,UAAU,EACV,KAAK,EACL,OAAO,GACR;;;;;;CAAA,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAwB3B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,EAChC,GAAG,EACH,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,GACN;;;;;;CAAA,iBAUA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ,OAc5E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,GAAG,QAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,UAAQ;;;;IAmBtH"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,IAAI,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|