ec.fdk 0.3.0 → 0.3.1
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 +3 -3
- package/dist/index.mjs +73 -72
- package/dist/lib/admin.d.mts +1 -1
- package/dist/lib/admin.d.mts.map +1 -1
- package/dist/lib/api.d.mts +2 -1
- package/dist/lib/api.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var nt=Object.defineProperty,st=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var j=(n,t,e)=>t in n?nt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,u=(n,t)=>{for(var e in t||(t={}))ot.call(t,e)&&j(n,e,t[e]);if(O)for(var e of O(t))it.call(t,e)&&j(n,e,t[e]);return n},p=(n,t)=>st(n,rt(t));var
|
|
2
|
-
${
|
|
3
|
-
${c.verbose}`;throw new Error(l)}throw new Error(`unexpected fetch error: ${o.statusText}`)}return a?o:yield o.json()})}const S={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/"}};function y(n,t="stage",e="datamanager"){const s=S[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(S).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 d(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const B={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function q(n){return i(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;d({env:t,dmShortID:e,email:s,password:r});const a=y(`api/${e}/_auth/login?clientID=rest`,t);return yield g(a,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function D(n){return i(this,null,function*(){let{env:t,email:e,password:s}=n;d({env:t,email:e,password:s});const r=`${B[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function v(n){return i(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;d({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function K(n){return i(this,null,function*(){let{env:t,token:e}=n;d({env:t,token:e});const s=`${B[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function x({dmShortID:n}){return d({dmShortID:n}),n}function z({env:n}){return d({env:n}),n}let ct=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function J(n){let t={};for(let e in n)ct.includes(e)||(t[e]=n[e]);return t}function at(n){return JSON.parse(JSON.stringify(n))}function N(n){return i(this,null,function*(){let{env:t,dmShortID:e}=n;d({env:t,dmShortID:e});const s=y(`api/${e}`,t);return g(s,n)})}function R(n){return i(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;d({env:t,dmShortID:e,model:s}),r=u({size:50,page:1,_list:!0},r);const a=w(r),o=y(`api/${e}/${s}?${a}`,t),{count:h,total:c,_embedded:l}=yield g(o,n);let f=l?l[`${e}:${s}`]:[];return f=Array.isArray(f)?f:[f],{count:h,total:c,items:f}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const a=w({_id:s}),o=y(`api/${t}/${e}?${a}`,n);return g(o,{dmShortID:t,token:r})}function F(a){return i(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){d({env:n,dmShortID:t,model:e,value:s});const o=y(`api/${t}/${e}`,n);return yield g(o,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function M(o){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:a}){d({env:n,dmShortID:t,model:e,entryID:s,value:r});const h=y(`api/${t}/${e}?_id=${s}`,n);return r=at(r),r=J(r),yield g(h,{token:a},{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}})})}function U(a){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const o=y(`api/${t}/${e}?_id=${s}`,n);yield g(o,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function V(s){return i(this,arguments,function*({env:n,dmShortID:t,model:e}){var l,f,m,_,L;d({env:n,dmShortID:t,model:e});const r=y(`api/schema/${t}/${e}`,n),a=yield g(r),o=(l=a==null?void 0:a.allOf)==null?void 0:l[1];if(typeof o.properties!="object")throw new Error(`getSchema: ${r} returned unexpected format: ${JSON.stringify(a)}`);const{properties:h}=o,c=J(h);for(let k in c){let $=c[k];if($.required=o.required.includes(k),(f=c[k])!=null&&f.oneOf&&((m=c[k])==null||delete m.oneOf),(_=$.title)!=null&&_.includes("<")&&((L=$.title)!=null&&L.includes(">"))){const b=$.title.split("<")[1].slice(0,-1),et=$.title.split("<")[0];$.type=et,b.includes(":")?$.resource=b.split(":")[1]:$.resource=b}else["asset","entry","assets","entries"].includes($.title)?($.type=$.title,$.resource=null):$.type=$.title;delete c[k].title}return c})}function G(a){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){d({env:n,dmShortID:t,assetGroup:e,assetID:s});const o=w({assetID:s}),h=y(`a/${t}/${e}?${o}`,n);return(yield g(h,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function H(n){return i(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:a={}}=n;d({env:t,dmShortID:e,assetGroup:s}),a=u({size:50,page:1,_list:!0},a);const o=w(a),h=y(`a/${e}/${s}?${o}`,t),{count:c,total:l,_embedded:f}=yield g(h,{dmShortID:e,token:r});let m=f?f["ec:dm-asset"]:[];return m=Array.isArray(m)?m:[m],{count:c,total:l,items:m}})}function I(h){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:a,options:o}){d({env:n,dmShortID:t,assetGroup:e,file:r});const c=y(`a/${t}/${e}`,n),l=new FormData;return l.append("file",r,a),o&&Object.keys(o).forEach(m=>{l.append(m,o[m])}),(yield g(c,{token:s},{method:"POST",body:l}))._embedded["ec:dm-asset"]})}function Q(a){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){d({env:n,dmShortID:t,assetGroup:e,assetID:s});const o=y(`a/${t}/${e}/${s}`,n);yield g(o,{token:r,rawRes:!0},{method:"DELETE"})})}function W(n){return i(this,null,function*(){let{env:t,dmID:e,token:s}=n;d({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return g(r,{token:s})})}function X(n){return i(this,null,function*(){let{env:t,options:e={}}=n;d({env:t}),e=u({size:25,page:1,_list:!0},e);const s=w(e),r=y(`?${s}`,t),{count:a,total:o,_embedded:h}=yield g(r,n);let c=h?h["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:a,total:o,items:c}})}function Y(n){return i(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;d({env:t,dmID:e}),s=u({size:25,dataManagerID:e,page:1,_list:!0},s);const r=w(s),a=y(`model?${r}`,t),{count:o,total:h,_embedded:c}=yield g(a,n);let l=c?c["ec:model"]:[];return l=Array.isArray(l)?l:[l],{count:o,total:h,items:l}})}function Z(n){return i(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;d({env:t,subdomain:r,resource:e}),s=u({size:25,page:1,_list:!0},s);const a=w(s),o=y(`${e}?${a}`,t,r),{count:h,total:c,_embedded:l}=yield g(o,n);let f=l?l[Object.keys(l)[0]]:[];return f=Array.isArray(f)?f:[f],{count:h,total:c,items:f}})}function tt(n){return i(this,null,function*(){let{env:t,route:e,options:s={},subdomain:r="datamanager"}=n;d({env:t,subdomain:r,route:e}),s=u({},s);const a=w(s),o=y(`${e}?${a}`,t,r);return g(o,n)})}const A=Object.freeze(Object.defineProperty({__proto__:null,assetList:H,createAsset:I,createEntry:F,deleteAsset:Q,deleteEntry:U,dmList:X,editEntry:M,entryList:R,getAsset:G,getDatamanager:W,getEcAuthKey:z,getEntry:C,getPublicAuthKey:x,getSchema:V,loginEc:D,loginPublic:q,logoutEc:K,logoutPublic:v,modelList:Y,publicApi:N,raw:tt,resourceList:Z},Symbol.toStringTag,{value:"Module"})),{entryList:ut,getEntry:lt,getAsset:ht,assetList:dt,createAsset:gt,deleteAsset:yt,createEntry:ft,editEntry:pt,deleteEntry:$t,getSchema:mt,loginPublic:wt,loginEc:kt,logoutEc:At,logoutPublic:Et,getEcAuthKey:T,getPublicAuthKey:P,dmList:bt,modelList:Tt,publicApi:Pt,getDatamanager:_t,resourceList:Lt,raw:Ot}=A;function jt(n){const{action:t}=n;if(d({action:t}),!A[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(A).join(", ")}`);return A[t](n)}class E{constructor(t){this.config=t}set(t){return new E(u(u({},this.config),t))}entries(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return ut(p(u({},this.config),{options:t,token:e}))})}entryList(t){return i(this,null,function*(){return this.entries(t)})}getEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return lt(p(u({},this.config),{entryID:t,token:e}))})}getSchema(){return i(this,null,function*(){return mt(this.config)})}assets(t){return i(this,null,function*(){const e=yield this.getBestToken();return dt(p(u({},this.config),{options:t,token:e}))})}assetList(t){return i(this,null,function*(){return this.assets(t)})}createAsset(){return i(this,arguments,function*({file:t,name:e,options:s}={}){const r=yield this.getBestToken();return gt(p(u({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return yt(p(u({},this.config),{token:e,assetID:t}))})}getAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return ht(p(u({},this.config),{assetID:t,token:e}))})}createEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return ft(p(u({},this.config),{token:e,value:t}))})}editEntry(t,e){return i(this,null,function*(){const s=yield this.getBestToken();return pt(p(u({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return $t(p(u({},this.config),{token:e,entryID:t}))})}resourceList(t){return i(this,null,function*(){const e=yield this.getBestToken();return Lt(p(u({},this.config),{options:t,token:e}))})}raw(t){return i(this,null,function*(){const e=yield this.getBestToken();return Ot(p(u({},this.config),{options:t,token:e}))})}authAdapter(t){return this.set({authAdapter:t})}setAuth(t){return e=>{if(!this.config.authAdapter)throw new Error("cannot setAuth: no authAdapter defined!");const{set:s}=this.config.authAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(console.log("unset auth",e),!this.config.authAdapter)throw new Error("cannot unsetAuth: no authAdapter defined!");const{remove:s}=this.config.authAdapter;return s(t),e}}getAuth(t){if(!this.config.authAdapter)throw new Error("cannot getAuth: no authAdapter defined!");const{get:e}=this.config.authAdapter;return e(t)}loginEc(t){return kt(u(u({},this.config),t)).then(this.setAuth(T(this.config)))}loginPublic(t){return wt(u(u({},this.config),t)).then(this.setAuth(P(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Et(p(u({},this.config),{token:t})).then(this.unsetAuth(P(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),At(p(u({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}getPublicToken(){return this.config.token||this.getAuth(P(this.config))}getEcToken(){return this.config.token||this.getAuth(T(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})}dmID(t){return this.set({dmID:t})}dm(t){return this.dmShortID(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 Pt(this.config)}getDatamanager(t){return i(this,null,function*(){const e=yield this.getBestToken();return _t(p(u({},this.config),{dmID:t,token:e}))})}dmList(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return bt(p(u({},this.config),{options:t,token:e}))})}modelList(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return Tt(p(u({},this.config),{options:t,token:e}))})}}const St=n=>new E({env:n});exports.Sdk=E;exports.act=jt;exports.apiURL=y;exports.assetList=H;exports.createAsset=I;exports.createEntry=F;exports.deleteAsset=Q;exports.deleteEntry=U;exports.dmList=X;exports.editEntry=M;exports.entryList=R;exports.expect=d;exports.fetcher=g;exports.getAsset=G;exports.getDatamanager=W;exports.getEcAuthKey=z;exports.getEntry=C;exports.getPublicAuthKey=x;exports.getSchema=V;exports.loginEc=D;exports.loginPublic=q;exports.logoutEc=K;exports.logoutPublic=v;exports.modelList=Y;exports.publicApi=N;exports.query=w;exports.raw=tt;exports.resourceList=Z;exports.sdk=St;
|
|
1
|
+
"use strict";var nt=Object.defineProperty,st=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var j=(n,t,e)=>t in n?nt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,u=(n,t)=>{for(var e in t||(t={}))ot.call(t,e)&&j(n,e,t[e]);if(O)for(var e of O(t))it.call(t,e)&&j(n,e,t[e]);return n},p=(n,t)=>st(n,rt(t));var c=(n,t,e)=>new Promise((s,r)=>{var a=i=>{try{h(e.next(i))}catch(l){r(l)}},o=i=>{try{h(e.throw(i))}catch(l){r(l)}},h=i=>i.done?s(i.value):Promise.resolve(i.value).then(a,o);h((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return c(this,arguments,function*(n,t={},e={}){var h;const{token:r,rawRes:a}=t;r&&(e.headers=p(u({},e.headers||{}),{Authorization:`Bearer ${r}`}));const o=yield fetch(n,e);if(!o.ok){if((h=o.headers.get("content-type"))!=null&&h.includes("application/json")){const i=yield o.json(),l=`${i.title}
|
|
2
|
+
${i.detail}
|
|
3
|
+
${i.verbose}`;throw new Error(l)}throw new Error(`unexpected fetch error: ${o.statusText}`)}return a?o:yield o.json()})}const S={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/"}};function y(n,t="stage",e="datamanager"){const s=S[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(S).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 d(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const B={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function q(n){return c(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;d({env:t,dmShortID:e,email:s,password:r});const a=y(`api/${e}/_auth/login?clientID=rest`,t);return yield g(a,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function D(n){return c(this,null,function*(){let{env:t,email:e,password:s}=n;d({env:t,email:e,password:s});const r=`${B[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function v(n){return c(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;d({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function K(n){return c(this,null,function*(){let{env:t,token:e}=n;d({env:t,token:e});const s=`${B[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function x({dmShortID:n}){return d({dmShortID:n}),n}function z({env:n}){return d({env:n}),n}let ct=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function J(n){let t={};for(let e in n)ct.includes(e)||(t[e]=n[e]);return t}function at(n){return JSON.parse(JSON.stringify(n))}function N(n){return c(this,null,function*(){let{env:t,dmShortID:e}=n;d({env:t,dmShortID:e});const s=y(`api/${e}`,t);return g(s,n)})}function R(n){return c(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;d({env:t,dmShortID:e,model:s}),r=u({size:50,page:1,_list:!0},r);const a=w(r),o=y(`api/${e}/${s}?${a}`,t),{count:h,total:i,_embedded:l}=yield g(o,n);let f=l?l[`${e}:${s}`]:[];return f=Array.isArray(f)?f:[f],{count:h,total:i,items:f}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const a=w({_id:s}),o=y(`api/${t}/${e}?${a}`,n);return g(o,{dmShortID:t,token:r})}function F(a){return c(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){d({env:n,dmShortID:t,model:e,value:s});const o=y(`api/${t}/${e}`,n);return yield g(o,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function M(o){return c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:a}){d({env:n,dmShortID:t,model:e,entryID:s,value:r});const h=y(`api/${t}/${e}?_id=${s}`,n);return r=at(r),r=J(r),yield g(h,{token:a},{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}})})}function U(a){return c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const o=y(`api/${t}/${e}?_id=${s}`,n);yield g(o,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function V(s){return c(this,arguments,function*({env:n,dmShortID:t,model:e}){var l,f,m,_,L;d({env:n,dmShortID:t,model:e});const r=y(`api/schema/${t}/${e}`,n),a=yield g(r),o=(l=a==null?void 0:a.allOf)==null?void 0:l[1];if(typeof o.properties!="object")throw new Error(`getSchema: ${r} returned unexpected format: ${JSON.stringify(a)}`);const{properties:h}=o,i=J(h);for(let k in i){let $=i[k];if($.required=o.required.includes(k),(f=i[k])!=null&&f.oneOf&&((m=i[k])==null||delete m.oneOf),(_=$.title)!=null&&_.includes("<")&&((L=$.title)!=null&&L.includes(">"))){const b=$.title.split("<")[1].slice(0,-1),et=$.title.split("<")[0];$.type=et,b.includes(":")?$.resource=b.split(":")[1]:$.resource=b}else["asset","entry","assets","entries"].includes($.title)?($.type=$.title,$.resource=null):$.type=$.title;delete i[k].title}return i})}function G(a){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){d({env:n,dmShortID:t,assetGroup:e,assetID:s});const o=w({assetID:s}),h=y(`a/${t}/${e}?${o}`,n);return(yield g(h,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function H(n){return c(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:a={}}=n;d({env:t,dmShortID:e,assetGroup:s}),a=u({size:50,page:1,_list:!0},a);const o=w(a),h=y(`a/${e}/${s}?${o}`,t),{count:i,total:l,_embedded:f}=yield g(h,{dmShortID:e,token:r});let m=f?f["ec:dm-asset"]:[];return m=Array.isArray(m)?m:[m],{count:i,total:l,items:m}})}function I(h){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:a,options:o}){d({env:n,dmShortID:t,assetGroup:e,file:r});const i=y(`a/${t}/${e}`,n),l=new FormData;return l.append("file",r,a),o&&Object.keys(o).forEach(m=>{l.append(m,o[m])}),(yield g(i,{token:s},{method:"POST",body:l}))._embedded["ec:dm-asset"]})}function Q(a){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){d({env:n,dmShortID:t,assetGroup:e,assetID:s});const o=y(`a/${t}/${e}/${s}`,n);yield g(o,{token:r,rawRes:!0},{method:"DELETE"})})}function W(n){return c(this,null,function*(){let{env:t,dmID:e,token:s}=n;d({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return g(r,{token:s})})}function X(n){return c(this,null,function*(){let{env:t,options:e={}}=n;d({env:t}),e=u({size:25,page:1,_list:!0},e);const s=w(e),r=y(`?${s}`,t),{count:a,total:o,_embedded:h}=yield g(r,n);let i=h?h["ec:datamanager"]:[];return i=Array.isArray(i)?i:[i],{count:a,total:o,items:i}})}function Y(n){return c(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;d({env:t,dmID:e}),s=u({size:25,dataManagerID:e,page:1,_list:!0},s);const r=w(s),a=y(`model?${r}`,t),{count:o,total:h,_embedded:i}=yield g(a,n);let l=i?i["ec:model"]:[];return l=Array.isArray(l)?l:[l],{count:o,total:h,items:l}})}function Z(n){return c(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;d({env:t,subdomain:r,resource:e}),s=u({size:25,page:1,_list:!0},s);const a=w(s),o=y(`${e}?${a}`,t,r),{count:h,total:i,_embedded:l}=yield g(o,n);let f=l?l[Object.keys(l)[0]]:[];return f=Array.isArray(f)?f:[f],{count:h,total:i,items:f}})}function tt(e){return c(this,arguments,function*(n,t={}){let{env:s,route:r,options:a={},subdomain:o="datamanager"}=n;d({env:s,subdomain:o,route:r}),a=u({},a);const h=w(a),i=y(`${r}?${h}`,s,o);return g(i,n,t)})}const A=Object.freeze(Object.defineProperty({__proto__:null,assetList:H,createAsset:I,createEntry:F,deleteAsset:Q,deleteEntry:U,dmList:X,editEntry:M,entryList:R,getAsset:G,getDatamanager:W,getEcAuthKey:z,getEntry:C,getPublicAuthKey:x,getSchema:V,loginEc:D,loginPublic:q,logoutEc:K,logoutPublic:v,modelList:Y,publicApi:N,raw:tt,resourceList:Z},Symbol.toStringTag,{value:"Module"})),{entryList:ut,getEntry:lt,getAsset:ht,assetList:dt,createAsset:gt,deleteAsset:yt,createEntry:ft,editEntry:pt,deleteEntry:$t,getSchema:mt,loginPublic:wt,loginEc:kt,logoutEc:At,logoutPublic:Et,getEcAuthKey:T,getPublicAuthKey:P,dmList:bt,modelList:Tt,publicApi:Pt,getDatamanager:_t,resourceList:Lt,raw:Ot}=A;function jt(n){const{action:t}=n;if(d({action:t}),!A[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(A).join(", ")}`);return A[t](n)}class E{constructor(t){this.config=t}set(t){return new E(u(u({},this.config),t))}entries(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return ut(p(u({},this.config),{options:t,token:e}))})}entryList(t){return c(this,null,function*(){return this.entries(t)})}getEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return lt(p(u({},this.config),{entryID:t,token:e}))})}getSchema(){return c(this,null,function*(){return mt(this.config)})}assets(t){return c(this,null,function*(){const e=yield this.getBestToken();return dt(p(u({},this.config),{options:t,token:e}))})}assetList(t){return c(this,null,function*(){return this.assets(t)})}createAsset(){return c(this,arguments,function*({file:t,name:e,options:s}={}){const r=yield this.getBestToken();return gt(p(u({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return yt(p(u({},this.config),{token:e,assetID:t}))})}getAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return ht(p(u({},this.config),{assetID:t,token:e}))})}createEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return ft(p(u({},this.config),{token:e,value:t}))})}editEntry(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return pt(p(u({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return $t(p(u({},this.config),{token:e,entryID:t}))})}resourceList(t){return c(this,null,function*(){const e=yield this.getBestToken();return Lt(p(u({},this.config),{options:t,token:e}))})}raw(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return Ot(p(u({},this.config),{options:t,token:s}),e)})}authAdapter(t){return this.set({authAdapter:t})}setAuth(t){return e=>{if(!this.config.authAdapter)throw new Error("cannot setAuth: no authAdapter defined!");const{set:s}=this.config.authAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(console.log("unset auth",e),!this.config.authAdapter)throw new Error("cannot unsetAuth: no authAdapter defined!");const{remove:s}=this.config.authAdapter;return s(t),e}}getAuth(t){if(!this.config.authAdapter)throw new Error("cannot getAuth: no authAdapter defined!");const{get:e}=this.config.authAdapter;return e(t)}loginEc(t){return kt(u(u({},this.config),t)).then(this.setAuth(T(this.config)))}loginPublic(t){return wt(u(u({},this.config),t)).then(this.setAuth(P(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Et(p(u({},this.config),{token:t})).then(this.unsetAuth(P(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),At(p(u({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}getPublicToken(){return this.config.token||this.getAuth(P(this.config))}getEcToken(){return this.config.token||this.getAuth(T(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})}dmID(t){return this.set({dmID:t})}dm(t){return this.dmShortID(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 Pt(this.config)}getDatamanager(t){return c(this,null,function*(){const e=yield this.getBestToken();return _t(p(u({},this.config),{dmID:t,token:e}))})}dmList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return bt(p(u({},this.config),{options:t,token:e}))})}modelList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return Tt(p(u({},this.config),{options:t,token:e}))})}}const St=n=>new E({env:n});exports.Sdk=E;exports.act=jt;exports.apiURL=y;exports.assetList=H;exports.createAsset=I;exports.createEntry=F;exports.deleteAsset=Q;exports.deleteEntry=U;exports.dmList=X;exports.editEntry=M;exports.entryList=R;exports.expect=d;exports.fetcher=g;exports.getAsset=G;exports.getDatamanager=W;exports.getEcAuthKey=z;exports.getEntry=C;exports.getPublicAuthKey=x;exports.getSchema=V;exports.loginEc=D;exports.loginPublic=q;exports.logoutEc=K;exports.logoutPublic=v;exports.modelList=Y;exports.publicApi=N;exports.query=w;exports.raw=tt;exports.resourceList=Z;exports.sdk=St;
|
package/dist/index.mjs
CHANGED
|
@@ -10,24 +10,24 @@ var j = (n, t, e) => t in n ? K(n, t, { enumerable: !0, configurable: !0, writab
|
|
|
10
10
|
J.call(t, e) && j(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
12
|
}, f = (n, t) => v(n, x(t));
|
|
13
|
-
var
|
|
14
|
-
var c = (
|
|
13
|
+
var a = (n, t, e) => new Promise((s, r) => {
|
|
14
|
+
var c = (i) => {
|
|
15
15
|
try {
|
|
16
|
-
h(e.next(
|
|
16
|
+
h(e.next(i));
|
|
17
17
|
} catch (l) {
|
|
18
18
|
r(l);
|
|
19
19
|
}
|
|
20
|
-
}, o = (
|
|
20
|
+
}, o = (i) => {
|
|
21
21
|
try {
|
|
22
|
-
h(e.throw(
|
|
22
|
+
h(e.throw(i));
|
|
23
23
|
} catch (l) {
|
|
24
24
|
r(l);
|
|
25
25
|
}
|
|
26
|
-
}, h = (
|
|
26
|
+
}, h = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(c, o);
|
|
27
27
|
h((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
29
|
function g(s) {
|
|
30
|
-
return
|
|
30
|
+
return a(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
31
|
var h;
|
|
32
32
|
const { token: r, rawRes: c } = t;
|
|
33
33
|
r && (e.headers = f(u({}, e.headers || {}), {
|
|
@@ -36,9 +36,9 @@ function g(s) {
|
|
|
36
36
|
const o = yield fetch(n, e);
|
|
37
37
|
if (!o.ok) {
|
|
38
38
|
if ((h = o.headers.get("content-type")) != null && h.includes("application/json")) {
|
|
39
|
-
const
|
|
40
|
-
${
|
|
41
|
-
${
|
|
39
|
+
const i = yield o.json(), l = `${i.title}
|
|
40
|
+
${i.detail}
|
|
41
|
+
${i.verbose}`;
|
|
42
42
|
throw new Error(l);
|
|
43
43
|
}
|
|
44
44
|
throw new Error(`unexpected fetch error: ${o.statusText}`);
|
|
@@ -87,7 +87,7 @@ const B = {
|
|
|
87
87
|
live: "https://accounts.entrecode.de/"
|
|
88
88
|
};
|
|
89
89
|
function N(n) {
|
|
90
|
-
return
|
|
90
|
+
return a(this, null, function* () {
|
|
91
91
|
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
92
92
|
d({ env: t, dmShortID: e, email: s, password: r });
|
|
93
93
|
const c = p(`api/${e}/_auth/login?clientID=rest`, t);
|
|
@@ -105,7 +105,7 @@ function N(n) {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
function C(n) {
|
|
108
|
-
return
|
|
108
|
+
return a(this, null, function* () {
|
|
109
109
|
let { env: t, email: e, password: s } = n;
|
|
110
110
|
d({ env: t, email: e, password: s });
|
|
111
111
|
const r = `${B[t]}auth/login?clientID=rest`;
|
|
@@ -123,7 +123,7 @@ function C(n) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
function R(n) {
|
|
126
|
-
return
|
|
126
|
+
return a(this, null, function* () {
|
|
127
127
|
let { dmShortID: t, env: e, token: s } = n;
|
|
128
128
|
d({ dmShortID: t, env: e, token: s });
|
|
129
129
|
const r = p(
|
|
@@ -140,7 +140,7 @@ function R(n) {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
function F(n) {
|
|
143
|
-
return
|
|
143
|
+
return a(this, null, function* () {
|
|
144
144
|
let { env: t, token: e } = n;
|
|
145
145
|
d({ env: t, token: e });
|
|
146
146
|
const s = `${B[t]}auth/logout?clientID=rest`;
|
|
@@ -188,7 +188,7 @@ function G(n) {
|
|
|
188
188
|
return JSON.parse(JSON.stringify(n));
|
|
189
189
|
}
|
|
190
190
|
function H(n) {
|
|
191
|
-
return
|
|
191
|
+
return a(this, null, function* () {
|
|
192
192
|
let { env: t, dmShortID: e } = n;
|
|
193
193
|
d({ env: t, dmShortID: e });
|
|
194
194
|
const s = p(`api/${e}`, t);
|
|
@@ -196,12 +196,12 @@ function H(n) {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
function I(n) {
|
|
199
|
-
return
|
|
199
|
+
return a(this, null, function* () {
|
|
200
200
|
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
201
201
|
d({ env: t, dmShortID: e, model: s }), r = u({ size: 50, page: 1, _list: !0 }, r);
|
|
202
|
-
const c = w(r), o = p(`api/${e}/${s}?${c}`, t), { count: h, total:
|
|
202
|
+
const c = w(r), o = p(`api/${e}/${s}?${c}`, t), { count: h, total: i, _embedded: l } = yield g(o, n);
|
|
203
203
|
let y = l ? l[`${e}:${s}`] : [];
|
|
204
|
-
return y = Array.isArray(y) ? y : [y], { count: h, total:
|
|
204
|
+
return y = Array.isArray(y) ? y : [y], { count: h, total: i, items: y };
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
function Q({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
@@ -210,7 +210,7 @@ function Q({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
|
210
210
|
return g(o, { dmShortID: t, token: r });
|
|
211
211
|
}
|
|
212
212
|
function W(c) {
|
|
213
|
-
return
|
|
213
|
+
return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
|
|
214
214
|
d({ env: n, dmShortID: t, model: e, value: s });
|
|
215
215
|
const o = p(`api/${t}/${e}`, n);
|
|
216
216
|
return yield g(
|
|
@@ -227,7 +227,7 @@ function W(c) {
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
function X(o) {
|
|
230
|
-
return
|
|
230
|
+
return a(this, arguments, function* ({
|
|
231
231
|
env: n,
|
|
232
232
|
dmShortID: t,
|
|
233
233
|
model: e,
|
|
@@ -251,7 +251,7 @@ function X(o) {
|
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
253
|
function Y(c) {
|
|
254
|
-
return
|
|
254
|
+
return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
255
255
|
d({ env: n, dmShortID: t, model: e, entryID: s });
|
|
256
256
|
const o = p(`api/${t}/${e}?_id=${s}`, n);
|
|
257
257
|
yield g(
|
|
@@ -267,7 +267,7 @@ function Y(c) {
|
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
269
|
function Z(s) {
|
|
270
|
-
return
|
|
270
|
+
return a(this, arguments, function* ({ env: n, dmShortID: t, model: e }) {
|
|
271
271
|
var l, y, m, P, L;
|
|
272
272
|
d({ env: n, dmShortID: t, model: e });
|
|
273
273
|
const r = p(`api/schema/${t}/${e}`, n), c = yield g(r), o = (l = c == null ? void 0 : c.allOf) == null ? void 0 : l[1];
|
|
@@ -275,37 +275,37 @@ function Z(s) {
|
|
|
275
275
|
throw new Error(
|
|
276
276
|
`getSchema: ${r} returned unexpected format: ${JSON.stringify(c)}`
|
|
277
277
|
);
|
|
278
|
-
const { properties: h } = o,
|
|
279
|
-
for (let k in
|
|
280
|
-
let $ =
|
|
281
|
-
if ($.required = o.required.includes(k), (y =
|
|
278
|
+
const { properties: h } = o, i = q(h);
|
|
279
|
+
for (let k in i) {
|
|
280
|
+
let $ = i[k];
|
|
281
|
+
if ($.required = o.required.includes(k), (y = i[k]) != null && y.oneOf && ((m = i[k]) == null || delete m.oneOf), (P = $.title) != null && P.includes("<") && ((L = $.title) != null && L.includes(">"))) {
|
|
282
282
|
const E = $.title.split("<")[1].slice(0, -1), D = $.title.split("<")[0];
|
|
283
283
|
$.type = D, E.includes(":") ? $.resource = E.split(":")[1] : $.resource = E;
|
|
284
284
|
} else
|
|
285
285
|
["asset", "entry", "assets", "entries"].includes($.title) ? ($.type = $.title, $.resource = null) : $.type = $.title;
|
|
286
|
-
delete
|
|
286
|
+
delete i[k].title;
|
|
287
287
|
}
|
|
288
|
-
return
|
|
288
|
+
return i;
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
function tt(c) {
|
|
292
|
-
return
|
|
292
|
+
return a(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
|
|
293
293
|
d({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
294
294
|
const o = w({ assetID: s }), h = p(`a/${t}/${e}?${o}`, n);
|
|
295
295
|
return (yield g(h, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
298
|
function et(n) {
|
|
299
|
-
return
|
|
299
|
+
return a(this, null, function* () {
|
|
300
300
|
let { env: t, dmShortID: e, assetGroup: s, token: r, options: c = {} } = n;
|
|
301
301
|
d({ env: t, dmShortID: e, assetGroup: s }), c = u({ size: 50, page: 1, _list: !0 }, c);
|
|
302
|
-
const o = w(c), h = p(`a/${e}/${s}?${o}`, t), { count:
|
|
302
|
+
const o = w(c), h = p(`a/${e}/${s}?${o}`, t), { count: i, total: l, _embedded: y } = yield g(h, { dmShortID: e, token: r });
|
|
303
303
|
let m = y ? y["ec:dm-asset"] : [];
|
|
304
|
-
return m = Array.isArray(m) ? m : [m], { count:
|
|
304
|
+
return m = Array.isArray(m) ? m : [m], { count: i, total: l, items: m };
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
function nt(h) {
|
|
308
|
-
return
|
|
308
|
+
return a(this, arguments, function* ({
|
|
309
309
|
env: n,
|
|
310
310
|
dmShortID: t,
|
|
311
311
|
assetGroup: e,
|
|
@@ -315,11 +315,11 @@ function nt(h) {
|
|
|
315
315
|
options: o
|
|
316
316
|
}) {
|
|
317
317
|
d({ env: n, dmShortID: t, assetGroup: e, file: r });
|
|
318
|
-
const
|
|
318
|
+
const i = p(`a/${t}/${e}`, n), l = new FormData();
|
|
319
319
|
return l.append("file", r, c), o && Object.keys(o).forEach((m) => {
|
|
320
320
|
l.append(m, o[m]);
|
|
321
321
|
}), (yield g(
|
|
322
|
-
|
|
322
|
+
i,
|
|
323
323
|
{ token: s },
|
|
324
324
|
{
|
|
325
325
|
method: "POST",
|
|
@@ -329,7 +329,7 @@ function nt(h) {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
function st(c) {
|
|
332
|
-
return
|
|
332
|
+
return a(this, arguments, function* ({
|
|
333
333
|
env: n,
|
|
334
334
|
dmShortID: t,
|
|
335
335
|
assetGroup: e,
|
|
@@ -348,7 +348,7 @@ function st(c) {
|
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
350
|
function rt(n) {
|
|
351
|
-
return
|
|
351
|
+
return a(this, null, function* () {
|
|
352
352
|
let { env: t, dmID: e, token: s } = n;
|
|
353
353
|
d({ env: t, dmID: e });
|
|
354
354
|
const r = p(`?dataManagerID=${e}`, t);
|
|
@@ -356,38 +356,38 @@ function rt(n) {
|
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
function ot(n) {
|
|
359
|
-
return
|
|
359
|
+
return a(this, null, function* () {
|
|
360
360
|
let { env: t, options: e = {} } = n;
|
|
361
361
|
d({ env: t }), e = u({ size: 25, page: 1, _list: !0 }, e);
|
|
362
362
|
const s = w(e), r = p(`?${s}`, t), { count: c, total: o, _embedded: h } = yield g(r, n);
|
|
363
|
-
let
|
|
364
|
-
return
|
|
363
|
+
let i = h ? h["ec:datamanager"] : [];
|
|
364
|
+
return i = Array.isArray(i) ? i : [i], { count: c, total: o, items: i };
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
367
|
function it(n) {
|
|
368
|
-
return
|
|
368
|
+
return a(this, null, function* () {
|
|
369
369
|
let { env: t, dmID: e, options: s = {} } = n;
|
|
370
370
|
d({ env: t, dmID: e }), s = u({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
|
|
371
|
-
const r = w(s), c = p(`model?${r}`, t), { count: o, total: h, _embedded:
|
|
372
|
-
let l =
|
|
371
|
+
const r = w(s), c = p(`model?${r}`, t), { count: o, total: h, _embedded: i } = yield g(c, n);
|
|
372
|
+
let l = i ? i["ec:model"] : [];
|
|
373
373
|
return l = Array.isArray(l) ? l : [l], { count: o, total: h, items: l };
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
function at(n) {
|
|
377
|
-
return
|
|
377
|
+
return a(this, null, function* () {
|
|
378
378
|
let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
|
|
379
379
|
d({ env: t, subdomain: r, resource: e }), s = u({ size: 25, page: 1, _list: !0 }, s);
|
|
380
|
-
const c = w(s), o = p(`${e}?${c}`, t, r), { count: h, total:
|
|
380
|
+
const c = w(s), o = p(`${e}?${c}`, t, r), { count: h, total: i, _embedded: l } = yield g(o, n);
|
|
381
381
|
let y = l ? l[Object.keys(l)[0]] : [];
|
|
382
|
-
return y = Array.isArray(y) ? y : [y], { count: h, total:
|
|
382
|
+
return y = Array.isArray(y) ? y : [y], { count: h, total: i, items: y };
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
|
-
function ct(
|
|
386
|
-
return
|
|
387
|
-
let { env:
|
|
388
|
-
d({ env:
|
|
389
|
-
const
|
|
390
|
-
return g(
|
|
385
|
+
function ct(e) {
|
|
386
|
+
return a(this, arguments, function* (n, t = {}) {
|
|
387
|
+
let { env: s, route: r, options: c = {}, subdomain: o = "datamanager" } = n;
|
|
388
|
+
d({ env: s, subdomain: o, route: r }), c = u({}, c);
|
|
389
|
+
const h = w(c), i = p(`${r}?${h}`, s, o);
|
|
390
|
+
return g(i, n, t);
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -469,13 +469,13 @@ class _ {
|
|
|
469
469
|
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
470
470
|
*/
|
|
471
471
|
entries() {
|
|
472
|
-
return
|
|
472
|
+
return a(this, arguments, function* (t = {}) {
|
|
473
473
|
const e = yield this.getBestToken();
|
|
474
474
|
return ut(f(u({}, this.config), { options: t, token: e }));
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
entryList(t) {
|
|
478
|
-
return
|
|
478
|
+
return a(this, null, function* () {
|
|
479
479
|
return this.entries(t);
|
|
480
480
|
});
|
|
481
481
|
}
|
|
@@ -489,7 +489,7 @@ class _ {
|
|
|
489
489
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
490
490
|
*/
|
|
491
491
|
getEntry(t) {
|
|
492
|
-
return
|
|
492
|
+
return a(this, null, function* () {
|
|
493
493
|
const e = yield this.getBestToken();
|
|
494
494
|
return lt(f(u({}, this.config), { entryID: t, token: e }));
|
|
495
495
|
});
|
|
@@ -503,7 +503,7 @@ class _ {
|
|
|
503
503
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
504
504
|
*/
|
|
505
505
|
getSchema() {
|
|
506
|
-
return
|
|
506
|
+
return a(this, null, function* () {
|
|
507
507
|
return mt(this.config);
|
|
508
508
|
});
|
|
509
509
|
}
|
|
@@ -521,13 +521,13 @@ class _ {
|
|
|
521
521
|
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
522
522
|
*/
|
|
523
523
|
assets(t) {
|
|
524
|
-
return
|
|
524
|
+
return a(this, null, function* () {
|
|
525
525
|
const e = yield this.getBestToken();
|
|
526
526
|
return dt(f(u({}, this.config), { options: t, token: e }));
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
529
|
assetList(t) {
|
|
530
|
-
return
|
|
530
|
+
return a(this, null, function* () {
|
|
531
531
|
return this.assets(t);
|
|
532
532
|
});
|
|
533
533
|
}
|
|
@@ -553,7 +553,7 @@ class _ {
|
|
|
553
553
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
554
554
|
*/
|
|
555
555
|
createAsset() {
|
|
556
|
-
return
|
|
556
|
+
return a(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
557
557
|
const r = yield this.getBestToken();
|
|
558
558
|
return gt(f(u({}, this.config), { file: t, name: e, options: s, token: r }));
|
|
559
559
|
});
|
|
@@ -568,7 +568,7 @@ class _ {
|
|
|
568
568
|
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
569
569
|
*/
|
|
570
570
|
deleteAsset(t) {
|
|
571
|
-
return
|
|
571
|
+
return a(this, null, function* () {
|
|
572
572
|
const e = yield this.getBestToken();
|
|
573
573
|
return yt(f(u({}, this.config), { token: e, assetID: t }));
|
|
574
574
|
});
|
|
@@ -583,7 +583,7 @@ class _ {
|
|
|
583
583
|
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
584
584
|
*/
|
|
585
585
|
getAsset(t) {
|
|
586
|
-
return
|
|
586
|
+
return a(this, null, function* () {
|
|
587
587
|
const e = yield this.getBestToken();
|
|
588
588
|
return ht(f(u({}, this.config), { assetID: t, token: e }));
|
|
589
589
|
});
|
|
@@ -598,7 +598,7 @@ class _ {
|
|
|
598
598
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
599
599
|
*/
|
|
600
600
|
createEntry(t) {
|
|
601
|
-
return
|
|
601
|
+
return a(this, null, function* () {
|
|
602
602
|
const e = yield this.getBestToken();
|
|
603
603
|
return ft(f(u({}, this.config), { token: e, value: t }));
|
|
604
604
|
});
|
|
@@ -614,7 +614,7 @@ class _ {
|
|
|
614
614
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
615
615
|
*/
|
|
616
616
|
editEntry(t, e) {
|
|
617
|
-
return
|
|
617
|
+
return a(this, null, function* () {
|
|
618
618
|
const s = yield this.getBestToken();
|
|
619
619
|
return pt(f(u({}, this.config), { entryID: t, token: s, value: e }));
|
|
620
620
|
});
|
|
@@ -629,7 +629,7 @@ class _ {
|
|
|
629
629
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
630
630
|
*/
|
|
631
631
|
deleteEntry(t) {
|
|
632
|
-
return
|
|
632
|
+
return a(this, null, function* () {
|
|
633
633
|
const e = yield this.getBestToken();
|
|
634
634
|
return $t(f(u({}, this.config), { token: e, entryID: t }));
|
|
635
635
|
});
|
|
@@ -644,7 +644,7 @@ class _ {
|
|
|
644
644
|
* const res = await sdk("stage").resource("template").resourceList()
|
|
645
645
|
*/
|
|
646
646
|
resourceList(t) {
|
|
647
|
-
return
|
|
647
|
+
return a(this, null, function* () {
|
|
648
648
|
const e = yield this.getBestToken();
|
|
649
649
|
return Lt(f(u({}, this.config), { options: t, token: e }));
|
|
650
650
|
});
|
|
@@ -655,14 +655,15 @@ class _ {
|
|
|
655
655
|
* Use this when no other fdk method can give you your request.
|
|
656
656
|
*
|
|
657
657
|
* @param {object=} options options for list request.
|
|
658
|
+
* @param {object=} fetchOptions (optional) options passed to fetch.
|
|
658
659
|
* @returns {Promise<any>}
|
|
659
660
|
* @example
|
|
660
661
|
* const res = await sdk("stage").route("stats").raw()
|
|
661
662
|
*/
|
|
662
|
-
raw(t) {
|
|
663
|
-
return
|
|
664
|
-
const
|
|
665
|
-
return Ot(f(u({}, this.config), { options: t, token:
|
|
663
|
+
raw(t, e) {
|
|
664
|
+
return a(this, null, function* () {
|
|
665
|
+
const s = yield this.getBestToken();
|
|
666
|
+
return Ot(f(u({}, this.config), { options: t, token: s }), e);
|
|
666
667
|
});
|
|
667
668
|
}
|
|
668
669
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -827,7 +828,7 @@ class _ {
|
|
|
827
828
|
* @returns any
|
|
828
829
|
*/
|
|
829
830
|
getDatamanager(t) {
|
|
830
|
-
return
|
|
831
|
+
return a(this, null, function* () {
|
|
831
832
|
const e = yield this.getBestToken();
|
|
832
833
|
return Pt(f(u({}, this.config), { dmID: t, token: e }));
|
|
833
834
|
});
|
|
@@ -841,7 +842,7 @@ class _ {
|
|
|
841
842
|
* const dms = await sdk("stage").dmList()
|
|
842
843
|
*/
|
|
843
844
|
dmList() {
|
|
844
|
-
return
|
|
845
|
+
return a(this, arguments, function* (t = {}) {
|
|
845
846
|
const e = yield this.getBestToken();
|
|
846
847
|
return bt(f(u({}, this.config), { options: t, token: e }));
|
|
847
848
|
});
|
|
@@ -855,7 +856,7 @@ class _ {
|
|
|
855
856
|
* const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
856
857
|
*/
|
|
857
858
|
modelList() {
|
|
858
|
-
return
|
|
859
|
+
return a(this, arguments, function* (t = {}) {
|
|
859
860
|
const e = yield this.getBestToken();
|
|
860
861
|
return Tt(f(u({}, this.config), { options: t, token: e }));
|
|
861
862
|
});
|
package/dist/lib/admin.d.mts
CHANGED
package/dist/lib/admin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.mts","sourceRoot":"","sources":["../../src/lib/admin.mjs"],"names":[],"mappings":"AAEA,0DAMC;AAED;;;;GAYC;AAED;;;;GAWC;AAED;;;;GAWC;AAED
|
|
1
|
+
{"version":3,"file":"admin.d.mts","sourceRoot":"","sources":["../../src/lib/admin.mjs"],"names":[],"mappings":"AAEA,0DAMC;AAED;;;;GAYC;AAED;;;;GAWC;AAED;;;;GAWC;AAED,kEAQC"}
|
package/dist/lib/api.d.mts
CHANGED
|
@@ -149,11 +149,12 @@ export class Sdk {
|
|
|
149
149
|
* Use this when no other fdk method can give you your request.
|
|
150
150
|
*
|
|
151
151
|
* @param {object=} options options for list request.
|
|
152
|
+
* @param {object=} fetchOptions (optional) options passed to fetch.
|
|
152
153
|
* @returns {Promise<any>}
|
|
153
154
|
* @example
|
|
154
155
|
* const res = await sdk("stage").route("stats").raw()
|
|
155
156
|
*/
|
|
156
|
-
raw(options?: object | undefined): Promise<any>;
|
|
157
|
+
raw(options?: object | undefined, fetchOptions?: object | undefined): Promise<any>;
|
|
157
158
|
authAdapter(authAdapter: any): Sdk;
|
|
158
159
|
setAuth(key: any): (auth: any) => any;
|
|
159
160
|
unsetAuth(key: any): (auth: any) => any;
|
package/dist/lib/api.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAgCA,sCAWC;;AAED;;GAEG;AACH;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,GAAG,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC,CAOxD;IACD;;;;;;;OAOG;IACH,aAJa,QAAQ,WAAW,CAAC,CAMhC;IACD;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sCAjBW;QAAE,IAAI,EAAE,IAAI,GAAG,I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