ec.fdk 0.2.30 → 0.3.0
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 +282 -189
- package/dist/lib/admin.d.mts +6 -0
- package/dist/lib/admin.d.mts.map +1 -1
- package/dist/lib/api.d.mts +44 -0
- package/dist/lib/api.d.mts.map +1 -1
- package/dist/lib/util.d.mts +1 -1
- package/dist/lib/util.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
${
|
|
3
|
-
${o.verbose}`;throw new Error(l)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return a?i:yield i.json()})}const j={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function y(n,t="stage"){const e=j[t];if(!e)throw new Error(`env "${t}" not found. Try one of ${Object.keys(j).join(", ")}`);return e+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 K(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 x(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 J({dmShortID:n}){return d({dmShortID:n}),n}function N({env:n}){return d({env:n}),n}let it=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function R(n){let t={};for(let e in n)it.includes(e)||(t[e]=n[e]);return t}function ot(n){return JSON.parse(JSON.stringify(n))}function z(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 C(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),i=y(`api/${e}/${s}?${a}`,t),{count:h,total:o,_embedded:l}=yield g(i,n);let $=l?l[`${e}:${s}`]:[];return $=Array.isArray($)?$:[$],{count:h,total:o,items:$}})}function F({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const a=w({_id:s}),i=y(`api/${t}/${e}?${a}`,n);return g(i,{dmShortID:t,token:r})}function M(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 i=y(`api/${t}/${e}`,n);return yield g(i,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function U(i){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=ot(r),r=R(r),yield g(h,{token:a},{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}})})}function v(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 i=y(`api/${t}/${e}?_id=${s}`,n);yield g(i,{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,$,m,P,_;d({env:n,dmShortID:t,model:e});const r=y(`api/schema/${t}/${e}`,n),a=yield g(r),i=(l=a==null?void 0:a.allOf)==null?void 0:l[1];if(typeof i.properties!="object")throw new Error(`getSchema: ${r} returned unexpected format: ${JSON.stringify(a)}`);const{properties:h}=i,o=R(h);for(let A in o){let p=o[A];if(p.required=i.required.includes(A),($=o[A])!=null&&$.oneOf&&((m=o[A])==null||delete m.oneOf),(P=p.title)!=null&&P.includes("<")&&((_=p.title)!=null&&_.includes(">"))){const O=p.title.split("<")[1].slice(0,-1),Z=p.title.split("<")[0];p.type=Z,p.resource.includes(":")?p.resource=O.split(":")[1]:p.resource=O}else["asset","entry","assets","entries"].includes(p.title)?(p.type=p.title,p.resource=null):p.type=p.title;delete o[A].title}return o})}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 i=w({assetID:s}),h=y(`a/${t}/${e}?${i}`,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 i=w(a),h=y(`a/${e}/${s}?${i}`,t),{count:o,total:l,_embedded:$}=yield g(h,{dmShortID:e,token:r});let m=$?$["ec:dm-asset"]:[];return m=Array.isArray(m)?m:[m],{count:o,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:i}){d({env:n,dmShortID:t,assetGroup:e,file:r});const o=y(`a/${t}/${e}`,n),l=new FormData;return l.append("file",r,a),i&&Object.keys(i).forEach(m=>{l.append(m,i[m])}),(yield g(o,{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 i=y(`a/${t}/${e}/${s}`,n);yield g(i,{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:i,_embedded:h}=yield g(r,n);let o=h?h["ec:datamanager"]:[];return o=Array.isArray(o)?o:[o],{count:a,total:i,items:o}})}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:i,total:h,_embedded:o}=yield g(a,n);let l=o?o["ec:model"]:[];return l=Array.isArray(l)?l:[l],{count:i,total:h,items:l}})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:H,createAsset:I,createEntry:M,deleteAsset:Q,deleteEntry:v,dmList:X,editEntry:U,entryList:C,getAsset:G,getDatamanager:W,getEcAuthKey:N,getEntry:F,getPublicAuthKey:J,getSchema:V,loginEc:D,loginPublic:q,logoutEc:x,logoutPublic:K,modelList:Y,publicApi:z},Symbol.toStringTag,{value:"Module"})),{entryList:ct,getEntry:at,getAsset:ut,assetList:lt,createAsset:ht,deleteAsset:dt,createEntry:gt,editEntry:yt,deleteEntry:ft,getSchema:pt,loginPublic:$t,loginEc:mt,logoutEc:wt,logoutPublic:At,getEcAuthKey:b,getPublicAuthKey:T,dmList:kt,modelList:Et,publicApi:bt,getDatamanager:Tt}=k;function Pt(n){const{action:t}=n;if(d({action:t}),!k[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(k).join(", ")}`);return k[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 ct(f(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 at(f(u({},this.config),{entryID:t,token:e}))})}getSchema(){return c(this,null,function*(){return pt(this.config)})}assets(t){return c(this,null,function*(){const e=yield this.getBestToken();return lt(f(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 ht(f(u({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return dt(f(u({},this.config),{token:e,assetID:t}))})}getAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return ut(f(u({},this.config),{assetID:t,token:e}))})}createEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return gt(f(u({},this.config),{token:e,value:t}))})}editEntry(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return yt(f(u({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return ft(f(u({},this.config),{token:e,entryID:t}))})}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 mt(u(u({},this.config),t)).then(this.setAuth(b(this.config)))}loginPublic(t){return $t(u(u({},this.config),t)).then(this.setAuth(T(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),At(f(u({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),wt(f(u({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}getPublicToken(){return this.config.token||this.getAuth(T(this.config))}getEcToken(){return this.config.token||this.getAuth(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})}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)}publicApi(){return bt(this.config)}getDatamanager(t){return c(this,null,function*(){const e=yield this.getBestToken();return Tt(f(u({},this.config),{dmID:t,token:e}))})}dmList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return kt(f(u({},this.config),{options:t,token:e}))})}modelList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return Et(f(u({},this.config),{options:t,token:e}))})}}const _t=n=>new E({env:n});exports.Sdk=E;exports.act=Pt;exports.apiURL=y;exports.assetList=H;exports.createAsset=I;exports.createEntry=M;exports.deleteAsset=Q;exports.deleteEntry=v;exports.dmList=X;exports.editEntry=U;exports.entryList=C;exports.expect=d;exports.fetcher=g;exports.getAsset=G;exports.getDatamanager=W;exports.getEcAuthKey=N;exports.getEntry=F;exports.getPublicAuthKey=J;exports.getSchema=V;exports.loginEc=D;exports.loginPublic=q;exports.logoutEc=x;exports.logoutPublic=K;exports.modelList=Y;exports.publicApi=z;exports.query=w;exports.sdk=_t;
|
|
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 i=(n,t,e)=>new Promise((s,r)=>{var a=c=>{try{h(e.next(c))}catch(l){r(l)}},o=c=>{try{h(e.throw(c))}catch(l){r(l)}},h=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,o);h((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return i(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 c=yield o.json(),l=`${c.title}
|
|
2
|
+
${c.detail}
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,62 +1,77 @@
|
|
|
1
|
-
var K = Object.defineProperty,
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
1
|
+
var K = Object.defineProperty, v = Object.defineProperties;
|
|
2
|
+
var x = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var O = Object.getOwnPropertySymbols;
|
|
4
|
+
var z = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var j = (n, t, e) => t in n ? K(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, u = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
z.call(t, e) && j(n, e, t[e]);
|
|
8
|
+
if (O)
|
|
9
|
+
for (var e of O(t))
|
|
10
|
+
J.call(t, e) && j(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
}, f = (n, t) =>
|
|
13
|
-
var
|
|
14
|
-
var c = (
|
|
12
|
+
}, f = (n, t) => v(n, x(t));
|
|
13
|
+
var i = (n, t, e) => new Promise((s, r) => {
|
|
14
|
+
var c = (a) => {
|
|
15
15
|
try {
|
|
16
|
-
h(e.next(
|
|
16
|
+
h(e.next(a));
|
|
17
17
|
} catch (l) {
|
|
18
18
|
r(l);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, o = (a) => {
|
|
21
21
|
try {
|
|
22
|
-
h(e.throw(
|
|
22
|
+
h(e.throw(a));
|
|
23
23
|
} catch (l) {
|
|
24
24
|
r(l);
|
|
25
25
|
}
|
|
26
|
-
}, h = (
|
|
26
|
+
}, h = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(c, o);
|
|
27
27
|
h((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
29
|
function g(s) {
|
|
30
|
-
return
|
|
30
|
+
return i(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 || {}), {
|
|
34
34
|
Authorization: `Bearer ${r}`
|
|
35
35
|
}));
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
if ((h =
|
|
39
|
-
const
|
|
40
|
-
${
|
|
41
|
-
${
|
|
36
|
+
const o = yield fetch(n, e);
|
|
37
|
+
if (!o.ok) {
|
|
38
|
+
if ((h = o.headers.get("content-type")) != null && h.includes("application/json")) {
|
|
39
|
+
const a = yield o.json(), l = `${a.title}
|
|
40
|
+
${a.detail}
|
|
41
|
+
${a.verbose}`;
|
|
42
42
|
throw new Error(l);
|
|
43
43
|
}
|
|
44
|
-
throw new Error(`unexpected fetch error: ${
|
|
44
|
+
throw new Error(`unexpected fetch error: ${o.statusText}`);
|
|
45
45
|
}
|
|
46
|
-
return c ?
|
|
46
|
+
return c ? o : yield o.json();
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
const S = {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
datamanager: {
|
|
51
|
+
live: "https://datamanager.entrecode.de/",
|
|
52
|
+
stage: "https://datamanager.cachena.entrecode.de/"
|
|
53
|
+
},
|
|
54
|
+
accounts: {
|
|
55
|
+
live: "https://accounts.entrecode.de/",
|
|
56
|
+
stage: "https://accounts.cachena.entrecode.de/"
|
|
57
|
+
},
|
|
58
|
+
appserver: {
|
|
59
|
+
live: "https://appserver.entrecode.de/",
|
|
60
|
+
stage: "https://appserver.cachena.entrecode.de/"
|
|
61
|
+
}
|
|
52
62
|
};
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
63
|
+
function p(n, t = "stage", e = "datamanager") {
|
|
64
|
+
const s = S[e];
|
|
65
|
+
if (!s)
|
|
66
|
+
throw new Error(
|
|
67
|
+
`subdomain "${e}" not found. Try one of ${Object.keys(S).join(", ")}`
|
|
68
|
+
);
|
|
69
|
+
const r = s[t];
|
|
70
|
+
if (!r)
|
|
56
71
|
throw new Error(
|
|
57
|
-
`env "${t}" not found. Try one of ${Object.keys(
|
|
72
|
+
`env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`
|
|
58
73
|
);
|
|
59
|
-
return
|
|
74
|
+
return r + n;
|
|
60
75
|
}
|
|
61
76
|
function w(n, t = !0) {
|
|
62
77
|
return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
|
|
@@ -71,11 +86,11 @@ const B = {
|
|
|
71
86
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
72
87
|
live: "https://accounts.entrecode.de/"
|
|
73
88
|
};
|
|
74
|
-
function
|
|
75
|
-
return
|
|
89
|
+
function N(n) {
|
|
90
|
+
return i(this, null, function* () {
|
|
76
91
|
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
77
92
|
d({ env: t, dmShortID: e, email: s, password: r });
|
|
78
|
-
const c =
|
|
93
|
+
const c = p(`api/${e}/_auth/login?clientID=rest`, t);
|
|
79
94
|
return yield g(
|
|
80
95
|
c,
|
|
81
96
|
{},
|
|
@@ -89,8 +104,8 @@ function C(n) {
|
|
|
89
104
|
);
|
|
90
105
|
});
|
|
91
106
|
}
|
|
92
|
-
function
|
|
93
|
-
return
|
|
107
|
+
function C(n) {
|
|
108
|
+
return i(this, null, function* () {
|
|
94
109
|
let { env: t, email: e, password: s } = n;
|
|
95
110
|
d({ env: t, email: e, password: s });
|
|
96
111
|
const r = `${B[t]}auth/login?clientID=rest`;
|
|
@@ -107,11 +122,11 @@ function R(n) {
|
|
|
107
122
|
);
|
|
108
123
|
});
|
|
109
124
|
}
|
|
110
|
-
function
|
|
111
|
-
return
|
|
125
|
+
function R(n) {
|
|
126
|
+
return i(this, null, function* () {
|
|
112
127
|
let { dmShortID: t, env: e, token: s } = n;
|
|
113
128
|
d({ dmShortID: t, env: e, token: s });
|
|
114
|
-
const r =
|
|
129
|
+
const r = p(
|
|
115
130
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
116
131
|
e
|
|
117
132
|
);
|
|
@@ -124,8 +139,8 @@ function F(n) {
|
|
|
124
139
|
);
|
|
125
140
|
});
|
|
126
141
|
}
|
|
127
|
-
function
|
|
128
|
-
return
|
|
142
|
+
function F(n) {
|
|
143
|
+
return i(this, null, function* () {
|
|
129
144
|
let { env: t, token: e } = n;
|
|
130
145
|
d({ env: t, token: e });
|
|
131
146
|
const s = `${B[t]}auth/logout?clientID=rest`;
|
|
@@ -141,10 +156,10 @@ function M(n) {
|
|
|
141
156
|
);
|
|
142
157
|
});
|
|
143
158
|
}
|
|
144
|
-
function
|
|
159
|
+
function M({ dmShortID: n }) {
|
|
145
160
|
return d({ dmShortID: n }), n;
|
|
146
161
|
}
|
|
147
|
-
function
|
|
162
|
+
function U({ env: n }) {
|
|
148
163
|
return d({ env: n }), n;
|
|
149
164
|
}
|
|
150
165
|
let V = [
|
|
@@ -173,33 +188,33 @@ function G(n) {
|
|
|
173
188
|
return JSON.parse(JSON.stringify(n));
|
|
174
189
|
}
|
|
175
190
|
function H(n) {
|
|
176
|
-
return
|
|
191
|
+
return i(this, null, function* () {
|
|
177
192
|
let { env: t, dmShortID: e } = n;
|
|
178
193
|
d({ env: t, dmShortID: e });
|
|
179
|
-
const s =
|
|
194
|
+
const s = p(`api/${e}`, t);
|
|
180
195
|
return g(s, n);
|
|
181
196
|
});
|
|
182
197
|
}
|
|
183
198
|
function I(n) {
|
|
184
|
-
return
|
|
199
|
+
return i(this, null, function* () {
|
|
185
200
|
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
186
201
|
d({ env: t, dmShortID: e, model: s }), r = u({ size: 50, page: 1, _list: !0 }, r);
|
|
187
|
-
const c = w(r),
|
|
188
|
-
let
|
|
189
|
-
return
|
|
202
|
+
const c = w(r), o = p(`api/${e}/${s}?${c}`, t), { count: h, total: a, _embedded: l } = yield g(o, n);
|
|
203
|
+
let y = l ? l[`${e}:${s}`] : [];
|
|
204
|
+
return y = Array.isArray(y) ? y : [y], { count: h, total: a, items: y };
|
|
190
205
|
});
|
|
191
206
|
}
|
|
192
207
|
function Q({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
193
208
|
d({ env: n, dmShortID: t, model: e, entryID: s });
|
|
194
|
-
const c = w({ _id: s }),
|
|
195
|
-
return g(
|
|
209
|
+
const c = w({ _id: s }), o = p(`api/${t}/${e}?${c}`, n);
|
|
210
|
+
return g(o, { dmShortID: t, token: r });
|
|
196
211
|
}
|
|
197
212
|
function W(c) {
|
|
198
|
-
return
|
|
213
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
|
|
199
214
|
d({ env: n, dmShortID: t, model: e, value: s });
|
|
200
|
-
const
|
|
215
|
+
const o = p(`api/${t}/${e}`, n);
|
|
201
216
|
return yield g(
|
|
202
|
-
|
|
217
|
+
o,
|
|
203
218
|
{ env: n, dmShortID: t, token: r },
|
|
204
219
|
{
|
|
205
220
|
method: "POST",
|
|
@@ -211,8 +226,8 @@ function W(c) {
|
|
|
211
226
|
);
|
|
212
227
|
});
|
|
213
228
|
}
|
|
214
|
-
function X(
|
|
215
|
-
return
|
|
229
|
+
function X(o) {
|
|
230
|
+
return i(this, arguments, function* ({
|
|
216
231
|
env: n,
|
|
217
232
|
dmShortID: t,
|
|
218
233
|
model: e,
|
|
@@ -221,7 +236,7 @@ function X(i) {
|
|
|
221
236
|
token: c
|
|
222
237
|
}) {
|
|
223
238
|
d({ env: n, dmShortID: t, model: e, entryID: s, value: r });
|
|
224
|
-
const h =
|
|
239
|
+
const h = p(`api/${t}/${e}?_id=${s}`, n);
|
|
225
240
|
return r = G(r), r = q(r), yield g(
|
|
226
241
|
h,
|
|
227
242
|
{ token: c },
|
|
@@ -236,11 +251,11 @@ function X(i) {
|
|
|
236
251
|
});
|
|
237
252
|
}
|
|
238
253
|
function Y(c) {
|
|
239
|
-
return
|
|
254
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
240
255
|
d({ env: n, dmShortID: t, model: e, entryID: s });
|
|
241
|
-
const
|
|
256
|
+
const o = p(`api/${t}/${e}?_id=${s}`, n);
|
|
242
257
|
yield g(
|
|
243
|
-
|
|
258
|
+
o,
|
|
244
259
|
{ token: r, rawRes: !0 },
|
|
245
260
|
{
|
|
246
261
|
method: "DELETE",
|
|
@@ -252,59 +267,59 @@ function Y(c) {
|
|
|
252
267
|
});
|
|
253
268
|
}
|
|
254
269
|
function Z(s) {
|
|
255
|
-
return
|
|
256
|
-
var l,
|
|
270
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e }) {
|
|
271
|
+
var l, y, m, P, L;
|
|
257
272
|
d({ env: n, dmShortID: t, model: e });
|
|
258
|
-
const r =
|
|
259
|
-
if (typeof
|
|
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];
|
|
274
|
+
if (typeof o.properties != "object")
|
|
260
275
|
throw new Error(
|
|
261
276
|
`getSchema: ${r} returned unexpected format: ${JSON.stringify(c)}`
|
|
262
277
|
);
|
|
263
|
-
const { properties: h } =
|
|
264
|
-
for (let
|
|
265
|
-
let
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
|
|
278
|
+
const { properties: h } = o, a = q(h);
|
|
279
|
+
for (let k in a) {
|
|
280
|
+
let $ = a[k];
|
|
281
|
+
if ($.required = o.required.includes(k), (y = a[k]) != null && y.oneOf && ((m = a[k]) == null || delete m.oneOf), (P = $.title) != null && P.includes("<") && ((L = $.title) != null && L.includes(">"))) {
|
|
282
|
+
const E = $.title.split("<")[1].slice(0, -1), D = $.title.split("<")[0];
|
|
283
|
+
$.type = D, E.includes(":") ? $.resource = E.split(":")[1] : $.resource = E;
|
|
269
284
|
} else
|
|
270
|
-
["asset", "entry", "assets", "entries"].includes(
|
|
271
|
-
delete
|
|
285
|
+
["asset", "entry", "assets", "entries"].includes($.title) ? ($.type = $.title, $.resource = null) : $.type = $.title;
|
|
286
|
+
delete a[k].title;
|
|
272
287
|
}
|
|
273
|
-
return
|
|
288
|
+
return a;
|
|
274
289
|
});
|
|
275
290
|
}
|
|
276
291
|
function tt(c) {
|
|
277
|
-
return
|
|
292
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
|
|
278
293
|
d({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
279
|
-
const
|
|
294
|
+
const o = w({ assetID: s }), h = p(`a/${t}/${e}?${o}`, n);
|
|
280
295
|
return (yield g(h, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
|
|
281
296
|
});
|
|
282
297
|
}
|
|
283
298
|
function et(n) {
|
|
284
|
-
return
|
|
299
|
+
return i(this, null, function* () {
|
|
285
300
|
let { env: t, dmShortID: e, assetGroup: s, token: r, options: c = {} } = n;
|
|
286
301
|
d({ env: t, dmShortID: e, assetGroup: s }), c = u({ size: 50, page: 1, _list: !0 }, c);
|
|
287
|
-
const
|
|
288
|
-
let m =
|
|
289
|
-
return m = Array.isArray(m) ? m : [m], { count:
|
|
302
|
+
const o = w(c), h = p(`a/${e}/${s}?${o}`, t), { count: a, total: l, _embedded: y } = yield g(h, { dmShortID: e, token: r });
|
|
303
|
+
let m = y ? y["ec:dm-asset"] : [];
|
|
304
|
+
return m = Array.isArray(m) ? m : [m], { count: a, total: l, items: m };
|
|
290
305
|
});
|
|
291
306
|
}
|
|
292
307
|
function nt(h) {
|
|
293
|
-
return
|
|
308
|
+
return i(this, arguments, function* ({
|
|
294
309
|
env: n,
|
|
295
310
|
dmShortID: t,
|
|
296
311
|
assetGroup: e,
|
|
297
312
|
token: s,
|
|
298
313
|
file: r,
|
|
299
314
|
name: c,
|
|
300
|
-
options:
|
|
315
|
+
options: o
|
|
301
316
|
}) {
|
|
302
317
|
d({ env: n, dmShortID: t, assetGroup: e, file: r });
|
|
303
|
-
const
|
|
304
|
-
return l.append("file", r, c),
|
|
305
|
-
l.append(m,
|
|
318
|
+
const a = p(`a/${t}/${e}`, n), l = new FormData();
|
|
319
|
+
return l.append("file", r, c), o && Object.keys(o).forEach((m) => {
|
|
320
|
+
l.append(m, o[m]);
|
|
306
321
|
}), (yield g(
|
|
307
|
-
|
|
322
|
+
a,
|
|
308
323
|
{ token: s },
|
|
309
324
|
{
|
|
310
325
|
method: "POST",
|
|
@@ -314,7 +329,7 @@ function nt(h) {
|
|
|
314
329
|
});
|
|
315
330
|
}
|
|
316
331
|
function st(c) {
|
|
317
|
-
return
|
|
332
|
+
return i(this, arguments, function* ({
|
|
318
333
|
env: n,
|
|
319
334
|
dmShortID: t,
|
|
320
335
|
assetGroup: e,
|
|
@@ -322,9 +337,9 @@ function st(c) {
|
|
|
322
337
|
token: r
|
|
323
338
|
}) {
|
|
324
339
|
d({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
325
|
-
const
|
|
340
|
+
const o = p(`a/${t}/${e}/${s}`, n);
|
|
326
341
|
yield g(
|
|
327
|
-
|
|
342
|
+
o,
|
|
328
343
|
{ token: r, rawRes: !0 },
|
|
329
344
|
{
|
|
330
345
|
method: "DELETE"
|
|
@@ -333,91 +348,112 @@ function st(c) {
|
|
|
333
348
|
});
|
|
334
349
|
}
|
|
335
350
|
function rt(n) {
|
|
336
|
-
return
|
|
351
|
+
return i(this, null, function* () {
|
|
337
352
|
let { env: t, dmID: e, token: s } = n;
|
|
338
353
|
d({ env: t, dmID: e });
|
|
339
|
-
const r =
|
|
354
|
+
const r = p(`?dataManagerID=${e}`, t);
|
|
340
355
|
return g(r, { token: s });
|
|
341
356
|
});
|
|
342
357
|
}
|
|
343
|
-
function
|
|
344
|
-
return
|
|
358
|
+
function ot(n) {
|
|
359
|
+
return i(this, null, function* () {
|
|
345
360
|
let { env: t, options: e = {} } = n;
|
|
346
361
|
d({ env: t }), e = u({ size: 25, page: 1, _list: !0 }, e);
|
|
347
|
-
const s = w(e), r =
|
|
348
|
-
let
|
|
349
|
-
return
|
|
362
|
+
const s = w(e), r = p(`?${s}`, t), { count: c, total: o, _embedded: h } = yield g(r, n);
|
|
363
|
+
let a = h ? h["ec:datamanager"] : [];
|
|
364
|
+
return a = Array.isArray(a) ? a : [a], { count: c, total: o, items: a };
|
|
350
365
|
});
|
|
351
366
|
}
|
|
352
|
-
function
|
|
353
|
-
return
|
|
367
|
+
function it(n) {
|
|
368
|
+
return i(this, null, function* () {
|
|
354
369
|
let { env: t, dmID: e, options: s = {} } = n;
|
|
355
370
|
d({ env: t, dmID: e }), s = u({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
|
|
356
|
-
const r = w(s), c =
|
|
357
|
-
let l =
|
|
358
|
-
return l = Array.isArray(l) ? l : [l], { count:
|
|
371
|
+
const r = w(s), c = p(`model?${r}`, t), { count: o, total: h, _embedded: a } = yield g(c, n);
|
|
372
|
+
let l = a ? a["ec:model"] : [];
|
|
373
|
+
return l = Array.isArray(l) ? l : [l], { count: o, total: h, items: l };
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
function at(n) {
|
|
377
|
+
return i(this, null, function* () {
|
|
378
|
+
let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
|
|
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: a, _embedded: l } = yield g(o, n);
|
|
381
|
+
let y = l ? l[Object.keys(l)[0]] : [];
|
|
382
|
+
return y = Array.isArray(y) ? y : [y], { count: h, total: a, items: y };
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
function ct(n) {
|
|
386
|
+
return i(this, null, function* () {
|
|
387
|
+
let { env: t, route: e, options: s = {}, subdomain: r = "datamanager" } = n;
|
|
388
|
+
d({ env: t, subdomain: r, route: e }), s = u({}, s);
|
|
389
|
+
const c = w(s), o = p(`${e}?${c}`, t, r);
|
|
390
|
+
return g(o, n);
|
|
359
391
|
});
|
|
360
392
|
}
|
|
361
|
-
const
|
|
393
|
+
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
362
394
|
__proto__: null,
|
|
363
395
|
assetList: et,
|
|
364
396
|
createAsset: nt,
|
|
365
397
|
createEntry: W,
|
|
366
398
|
deleteAsset: st,
|
|
367
399
|
deleteEntry: Y,
|
|
368
|
-
dmList:
|
|
400
|
+
dmList: ot,
|
|
369
401
|
editEntry: X,
|
|
370
402
|
entryList: I,
|
|
371
403
|
getAsset: tt,
|
|
372
404
|
getDatamanager: rt,
|
|
373
|
-
getEcAuthKey:
|
|
405
|
+
getEcAuthKey: U,
|
|
374
406
|
getEntry: Q,
|
|
375
|
-
getPublicAuthKey:
|
|
407
|
+
getPublicAuthKey: M,
|
|
376
408
|
getSchema: Z,
|
|
377
|
-
loginEc:
|
|
378
|
-
loginPublic:
|
|
379
|
-
logoutEc:
|
|
380
|
-
logoutPublic:
|
|
381
|
-
modelList:
|
|
382
|
-
publicApi: H
|
|
409
|
+
loginEc: C,
|
|
410
|
+
loginPublic: N,
|
|
411
|
+
logoutEc: F,
|
|
412
|
+
logoutPublic: R,
|
|
413
|
+
modelList: it,
|
|
414
|
+
publicApi: H,
|
|
415
|
+
raw: ct,
|
|
416
|
+
resourceList: at
|
|
383
417
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
384
|
-
entryList:
|
|
385
|
-
getEntry:
|
|
386
|
-
getAsset:
|
|
387
|
-
assetList:
|
|
388
|
-
createAsset:
|
|
389
|
-
deleteAsset:
|
|
390
|
-
createEntry:
|
|
391
|
-
editEntry:
|
|
392
|
-
deleteEntry:
|
|
393
|
-
getSchema:
|
|
394
|
-
loginPublic:
|
|
395
|
-
loginEc:
|
|
396
|
-
logoutEc:
|
|
397
|
-
logoutPublic:
|
|
398
|
-
getEcAuthKey:
|
|
399
|
-
getPublicAuthKey:
|
|
400
|
-
dmList:
|
|
401
|
-
modelList:
|
|
402
|
-
publicApi:
|
|
403
|
-
getDatamanager:
|
|
404
|
-
|
|
405
|
-
|
|
418
|
+
entryList: ut,
|
|
419
|
+
getEntry: lt,
|
|
420
|
+
getAsset: ht,
|
|
421
|
+
assetList: dt,
|
|
422
|
+
createAsset: gt,
|
|
423
|
+
deleteAsset: yt,
|
|
424
|
+
createEntry: ft,
|
|
425
|
+
editEntry: pt,
|
|
426
|
+
deleteEntry: $t,
|
|
427
|
+
getSchema: mt,
|
|
428
|
+
loginPublic: wt,
|
|
429
|
+
loginEc: kt,
|
|
430
|
+
logoutEc: At,
|
|
431
|
+
logoutPublic: Et,
|
|
432
|
+
getEcAuthKey: b,
|
|
433
|
+
getPublicAuthKey: T,
|
|
434
|
+
dmList: bt,
|
|
435
|
+
modelList: Tt,
|
|
436
|
+
publicApi: _t,
|
|
437
|
+
getDatamanager: Pt,
|
|
438
|
+
resourceList: Lt,
|
|
439
|
+
raw: Ot
|
|
440
|
+
} = A;
|
|
441
|
+
function St(n) {
|
|
406
442
|
const { action: t } = n;
|
|
407
|
-
if (d({ action: t }), !
|
|
443
|
+
if (d({ action: t }), !A[t])
|
|
408
444
|
throw new Error(
|
|
409
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
445
|
+
`"${t}" does not exist! try one of ${Object.keys(A).join(
|
|
410
446
|
", "
|
|
411
447
|
)}`
|
|
412
448
|
);
|
|
413
|
-
return
|
|
449
|
+
return A[t](n);
|
|
414
450
|
}
|
|
415
|
-
class
|
|
451
|
+
class _ {
|
|
416
452
|
constructor(t) {
|
|
417
453
|
this.config = t;
|
|
418
454
|
}
|
|
419
455
|
set(t) {
|
|
420
|
-
return new
|
|
456
|
+
return new _(u(u({}, this.config), t));
|
|
421
457
|
}
|
|
422
458
|
/**
|
|
423
459
|
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
@@ -433,13 +469,13 @@ class T {
|
|
|
433
469
|
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
434
470
|
*/
|
|
435
471
|
entries() {
|
|
436
|
-
return
|
|
472
|
+
return i(this, arguments, function* (t = {}) {
|
|
437
473
|
const e = yield this.getBestToken();
|
|
438
|
-
return
|
|
474
|
+
return ut(f(u({}, this.config), { options: t, token: e }));
|
|
439
475
|
});
|
|
440
476
|
}
|
|
441
477
|
entryList(t) {
|
|
442
|
-
return
|
|
478
|
+
return i(this, null, function* () {
|
|
443
479
|
return this.entries(t);
|
|
444
480
|
});
|
|
445
481
|
}
|
|
@@ -453,9 +489,9 @@ class T {
|
|
|
453
489
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
454
490
|
*/
|
|
455
491
|
getEntry(t) {
|
|
456
|
-
return
|
|
492
|
+
return i(this, null, function* () {
|
|
457
493
|
const e = yield this.getBestToken();
|
|
458
|
-
return
|
|
494
|
+
return lt(f(u({}, this.config), { entryID: t, token: e }));
|
|
459
495
|
});
|
|
460
496
|
}
|
|
461
497
|
/**
|
|
@@ -467,8 +503,8 @@ class T {
|
|
|
467
503
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
468
504
|
*/
|
|
469
505
|
getSchema() {
|
|
470
|
-
return
|
|
471
|
-
return
|
|
506
|
+
return i(this, null, function* () {
|
|
507
|
+
return mt(this.config);
|
|
472
508
|
});
|
|
473
509
|
}
|
|
474
510
|
/**
|
|
@@ -485,13 +521,13 @@ class T {
|
|
|
485
521
|
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
486
522
|
*/
|
|
487
523
|
assets(t) {
|
|
488
|
-
return
|
|
524
|
+
return i(this, null, function* () {
|
|
489
525
|
const e = yield this.getBestToken();
|
|
490
|
-
return
|
|
526
|
+
return dt(f(u({}, this.config), { options: t, token: e }));
|
|
491
527
|
});
|
|
492
528
|
}
|
|
493
529
|
assetList(t) {
|
|
494
|
-
return
|
|
530
|
+
return i(this, null, function* () {
|
|
495
531
|
return this.assets(t);
|
|
496
532
|
});
|
|
497
533
|
}
|
|
@@ -517,9 +553,9 @@ class T {
|
|
|
517
553
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
518
554
|
*/
|
|
519
555
|
createAsset() {
|
|
520
|
-
return
|
|
556
|
+
return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
521
557
|
const r = yield this.getBestToken();
|
|
522
|
-
return
|
|
558
|
+
return gt(f(u({}, this.config), { file: t, name: e, options: s, token: r }));
|
|
523
559
|
});
|
|
524
560
|
}
|
|
525
561
|
/**
|
|
@@ -532,9 +568,9 @@ class T {
|
|
|
532
568
|
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
533
569
|
*/
|
|
534
570
|
deleteAsset(t) {
|
|
535
|
-
return
|
|
571
|
+
return i(this, null, function* () {
|
|
536
572
|
const e = yield this.getBestToken();
|
|
537
|
-
return
|
|
573
|
+
return yt(f(u({}, this.config), { token: e, assetID: t }));
|
|
538
574
|
});
|
|
539
575
|
}
|
|
540
576
|
/**
|
|
@@ -547,9 +583,9 @@ class T {
|
|
|
547
583
|
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
548
584
|
*/
|
|
549
585
|
getAsset(t) {
|
|
550
|
-
return
|
|
586
|
+
return i(this, null, function* () {
|
|
551
587
|
const e = yield this.getBestToken();
|
|
552
|
-
return
|
|
588
|
+
return ht(f(u({}, this.config), { assetID: t, token: e }));
|
|
553
589
|
});
|
|
554
590
|
}
|
|
555
591
|
/**
|
|
@@ -562,9 +598,9 @@ class T {
|
|
|
562
598
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
563
599
|
*/
|
|
564
600
|
createEntry(t) {
|
|
565
|
-
return
|
|
601
|
+
return i(this, null, function* () {
|
|
566
602
|
const e = yield this.getBestToken();
|
|
567
|
-
return
|
|
603
|
+
return ft(f(u({}, this.config), { token: e, value: t }));
|
|
568
604
|
});
|
|
569
605
|
}
|
|
570
606
|
/**
|
|
@@ -578,9 +614,9 @@ class T {
|
|
|
578
614
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
579
615
|
*/
|
|
580
616
|
editEntry(t, e) {
|
|
581
|
-
return
|
|
617
|
+
return i(this, null, function* () {
|
|
582
618
|
const s = yield this.getBestToken();
|
|
583
|
-
return
|
|
619
|
+
return pt(f(u({}, this.config), { entryID: t, token: s, value: e }));
|
|
584
620
|
});
|
|
585
621
|
}
|
|
586
622
|
/**
|
|
@@ -593,9 +629,40 @@ class T {
|
|
|
593
629
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
594
630
|
*/
|
|
595
631
|
deleteEntry(t) {
|
|
596
|
-
return
|
|
632
|
+
return i(this, null, function* () {
|
|
633
|
+
const e = yield this.getBestToken();
|
|
634
|
+
return $t(f(u({}, this.config), { token: e, entryID: t }));
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Fetches resource list. Expects `resource` to be set. `subdomain` defaults to "datamanager".
|
|
639
|
+
* Fetches `https://<subdomain>.entrecode.de/<resource>?_list=true&size=<options.size ?? 25>`
|
|
640
|
+
*
|
|
641
|
+
* @param {object=} options options for list request.
|
|
642
|
+
* @returns {Promise<ResourceList>}
|
|
643
|
+
* @example
|
|
644
|
+
* const res = await sdk("stage").resource("template").resourceList()
|
|
645
|
+
*/
|
|
646
|
+
resourceList(t) {
|
|
647
|
+
return i(this, null, function* () {
|
|
597
648
|
const e = yield this.getBestToken();
|
|
598
|
-
return
|
|
649
|
+
return Lt(f(u({}, this.config), { options: t, token: e }));
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Fetches raw route. Expects `route` to be set. `subdomain` defaults to "datamanager".
|
|
654
|
+
* Fetches `https://<subdomain>.entrecode.de/<route>?<options>`
|
|
655
|
+
* Use this when no other fdk method can give you your request.
|
|
656
|
+
*
|
|
657
|
+
* @param {object=} options options for list request.
|
|
658
|
+
* @returns {Promise<any>}
|
|
659
|
+
* @example
|
|
660
|
+
* const res = await sdk("stage").route("stats").raw()
|
|
661
|
+
*/
|
|
662
|
+
raw(t) {
|
|
663
|
+
return i(this, null, function* () {
|
|
664
|
+
const e = yield this.getBestToken();
|
|
665
|
+
return Ot(f(u({}, this.config), { options: t, token: e }));
|
|
599
666
|
});
|
|
600
667
|
}
|
|
601
668
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -625,32 +692,32 @@ class T {
|
|
|
625
692
|
return e(t);
|
|
626
693
|
}
|
|
627
694
|
loginEc(t) {
|
|
628
|
-
return
|
|
629
|
-
this.setAuth(
|
|
695
|
+
return kt(u(u({}, this.config), t)).then(
|
|
696
|
+
this.setAuth(b(this.config))
|
|
630
697
|
);
|
|
631
698
|
}
|
|
632
699
|
loginPublic(t) {
|
|
633
|
-
return
|
|
634
|
-
this.setAuth(
|
|
700
|
+
return wt(u(u({}, this.config), t)).then(
|
|
701
|
+
this.setAuth(T(this.config))
|
|
635
702
|
);
|
|
636
703
|
}
|
|
637
704
|
logoutPublic() {
|
|
638
705
|
const t = this.getPublicToken();
|
|
639
|
-
return console.log("token", t),
|
|
640
|
-
this.unsetAuth(
|
|
706
|
+
return console.log("token", t), Et(f(u({}, this.config), { token: t })).then(
|
|
707
|
+
this.unsetAuth(T(this.config))
|
|
641
708
|
);
|
|
642
709
|
}
|
|
643
710
|
logoutEc() {
|
|
644
711
|
const t = this.getEcToken();
|
|
645
|
-
return console.log("token", t),
|
|
646
|
-
this.unsetAuth(
|
|
712
|
+
return console.log("token", t), At(f(u({}, this.config), { token: t })).then(
|
|
713
|
+
this.unsetAuth(b(this.config))
|
|
647
714
|
);
|
|
648
715
|
}
|
|
649
716
|
getPublicToken() {
|
|
650
|
-
return this.config.token || this.getAuth(
|
|
717
|
+
return this.config.token || this.getAuth(T(this.config));
|
|
651
718
|
}
|
|
652
719
|
getEcToken() {
|
|
653
|
-
return this.config.token || this.getAuth(
|
|
720
|
+
return this.config.token || this.getAuth(b(this.config));
|
|
654
721
|
}
|
|
655
722
|
hasPublicToken() {
|
|
656
723
|
return !!this.getPublicToken();
|
|
@@ -724,21 +791,45 @@ class T {
|
|
|
724
791
|
assetgroup(t) {
|
|
725
792
|
return this.assetGroup(t);
|
|
726
793
|
}
|
|
794
|
+
/**
|
|
795
|
+
* Sets the subdomain to use.
|
|
796
|
+
* @param {string} subdomain subdomain
|
|
797
|
+
* @returns Sdk
|
|
798
|
+
*/
|
|
799
|
+
subdomain(t) {
|
|
800
|
+
return this.set({ subdomain: t });
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Sets the name of the resource to use.
|
|
804
|
+
* @param {string} resource name of the resource
|
|
805
|
+
* @returns Sdk
|
|
806
|
+
*/
|
|
807
|
+
resource(t) {
|
|
808
|
+
return this.set({ resource: t });
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Sets the route to use.
|
|
812
|
+
* @param {string} route route
|
|
813
|
+
* @returns Sdk
|
|
814
|
+
*/
|
|
815
|
+
route(t) {
|
|
816
|
+
return this.set({ route: t });
|
|
817
|
+
}
|
|
727
818
|
/**
|
|
728
819
|
* Returns the public api root endpoint. Expects dmShortID to be set.
|
|
729
820
|
* @returns any
|
|
730
821
|
*/
|
|
731
822
|
publicApi() {
|
|
732
|
-
return
|
|
823
|
+
return _t(this.config);
|
|
733
824
|
}
|
|
734
825
|
/**
|
|
735
826
|
* Loads a DatamanagerResource by its long id. Requires token.
|
|
736
827
|
* @returns any
|
|
737
828
|
*/
|
|
738
829
|
getDatamanager(t) {
|
|
739
|
-
return
|
|
830
|
+
return i(this, null, function* () {
|
|
740
831
|
const e = yield this.getBestToken();
|
|
741
|
-
return
|
|
832
|
+
return Pt(f(u({}, this.config), { dmID: t, token: e }));
|
|
742
833
|
});
|
|
743
834
|
}
|
|
744
835
|
/**
|
|
@@ -750,9 +841,9 @@ class T {
|
|
|
750
841
|
* const dms = await sdk("stage").dmList()
|
|
751
842
|
*/
|
|
752
843
|
dmList() {
|
|
753
|
-
return
|
|
844
|
+
return i(this, arguments, function* (t = {}) {
|
|
754
845
|
const e = yield this.getBestToken();
|
|
755
|
-
return
|
|
846
|
+
return bt(f(u({}, this.config), { options: t, token: e }));
|
|
756
847
|
});
|
|
757
848
|
}
|
|
758
849
|
/**
|
|
@@ -764,39 +855,41 @@ class T {
|
|
|
764
855
|
* const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
765
856
|
*/
|
|
766
857
|
modelList() {
|
|
767
|
-
return
|
|
858
|
+
return i(this, arguments, function* (t = {}) {
|
|
768
859
|
const e = yield this.getBestToken();
|
|
769
|
-
return
|
|
860
|
+
return Tt(f(u({}, this.config), { options: t, token: e }));
|
|
770
861
|
});
|
|
771
862
|
}
|
|
772
863
|
}
|
|
773
|
-
const
|
|
864
|
+
const Bt = (n) => new _({ env: n });
|
|
774
865
|
export {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
866
|
+
_ as Sdk,
|
|
867
|
+
St as act,
|
|
868
|
+
p as apiURL,
|
|
778
869
|
et as assetList,
|
|
779
870
|
nt as createAsset,
|
|
780
871
|
W as createEntry,
|
|
781
872
|
st as deleteAsset,
|
|
782
873
|
Y as deleteEntry,
|
|
783
|
-
|
|
874
|
+
ot as dmList,
|
|
784
875
|
X as editEntry,
|
|
785
876
|
I as entryList,
|
|
786
877
|
d as expect,
|
|
787
878
|
g as fetcher,
|
|
788
879
|
tt as getAsset,
|
|
789
880
|
rt as getDatamanager,
|
|
790
|
-
|
|
881
|
+
U as getEcAuthKey,
|
|
791
882
|
Q as getEntry,
|
|
792
|
-
|
|
883
|
+
M as getPublicAuthKey,
|
|
793
884
|
Z as getSchema,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
885
|
+
C as loginEc,
|
|
886
|
+
N as loginPublic,
|
|
887
|
+
F as logoutEc,
|
|
888
|
+
R as logoutPublic,
|
|
889
|
+
it as modelList,
|
|
799
890
|
H as publicApi,
|
|
800
891
|
w as query,
|
|
801
|
-
|
|
892
|
+
ct as raw,
|
|
893
|
+
at as resourceList,
|
|
894
|
+
Bt as sdk
|
|
802
895
|
};
|
package/dist/lib/admin.d.mts
CHANGED
|
@@ -9,4 +9,10 @@ export function modelList(config: any): Promise<{
|
|
|
9
9
|
total: any;
|
|
10
10
|
items: any;
|
|
11
11
|
}>;
|
|
12
|
+
export function resourceList(config: any): Promise<{
|
|
13
|
+
count: any;
|
|
14
|
+
total: any;
|
|
15
|
+
items: any;
|
|
16
|
+
}>;
|
|
17
|
+
export function raw(config: any): Promise<any>;
|
|
12
18
|
//# sourceMappingURL=admin.d.mts.map
|
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"}
|
|
1
|
+
{"version":3,"file":"admin.d.mts","sourceRoot":"","sources":["../../src/lib/admin.mjs"],"names":[],"mappings":"AAEA,0DAMC;AAED;;;;GAYC;AAED;;;;GAWC;AAED;;;;GAWC;AAED,+CAQC"}
|
package/dist/lib/api.d.mts
CHANGED
|
@@ -133,6 +133,27 @@ export class Sdk {
|
|
|
133
133
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
134
134
|
*/
|
|
135
135
|
deleteEntry(entryID: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Fetches resource list. Expects `resource` to be set. `subdomain` defaults to "datamanager".
|
|
138
|
+
* Fetches `https://<subdomain>.entrecode.de/<resource>?_list=true&size=<options.size ?? 25>`
|
|
139
|
+
*
|
|
140
|
+
* @param {object=} options options for list request.
|
|
141
|
+
* @returns {Promise<ResourceList>}
|
|
142
|
+
* @example
|
|
143
|
+
* const res = await sdk("stage").resource("template").resourceList()
|
|
144
|
+
*/
|
|
145
|
+
resourceList(options?: object | undefined): Promise<ResourceList>;
|
|
146
|
+
/**
|
|
147
|
+
* Fetches raw route. Expects `route` to be set. `subdomain` defaults to "datamanager".
|
|
148
|
+
* Fetches `https://<subdomain>.entrecode.de/<route>?<options>`
|
|
149
|
+
* Use this when no other fdk method can give you your request.
|
|
150
|
+
*
|
|
151
|
+
* @param {object=} options options for list request.
|
|
152
|
+
* @returns {Promise<any>}
|
|
153
|
+
* @example
|
|
154
|
+
* const res = await sdk("stage").route("stats").raw()
|
|
155
|
+
*/
|
|
156
|
+
raw(options?: object | undefined): Promise<any>;
|
|
136
157
|
authAdapter(authAdapter: any): Sdk;
|
|
137
158
|
setAuth(key: any): (auth: any) => any;
|
|
138
159
|
unsetAuth(key: any): (auth: any) => any;
|
|
@@ -189,6 +210,24 @@ export class Sdk {
|
|
|
189
210
|
* @returns Sdk
|
|
190
211
|
*/
|
|
191
212
|
assetgroup(assetGroup: string): Sdk;
|
|
213
|
+
/**
|
|
214
|
+
* Sets the subdomain to use.
|
|
215
|
+
* @param {string} subdomain subdomain
|
|
216
|
+
* @returns Sdk
|
|
217
|
+
*/
|
|
218
|
+
subdomain(subdomain: string): Sdk;
|
|
219
|
+
/**
|
|
220
|
+
* Sets the name of the resource to use.
|
|
221
|
+
* @param {string} resource name of the resource
|
|
222
|
+
* @returns Sdk
|
|
223
|
+
*/
|
|
224
|
+
resource(resource: string): Sdk;
|
|
225
|
+
/**
|
|
226
|
+
* Sets the route to use.
|
|
227
|
+
* @param {string} route route
|
|
228
|
+
* @returns Sdk
|
|
229
|
+
*/
|
|
230
|
+
route(route: string): Sdk;
|
|
192
231
|
/**
|
|
193
232
|
* Returns the public api root endpoint. Expects dmShortID to be set.
|
|
194
233
|
* @returns any
|
|
@@ -340,6 +379,11 @@ export type AssetList = {
|
|
|
340
379
|
total: number;
|
|
341
380
|
items: AssetResource[];
|
|
342
381
|
};
|
|
382
|
+
export type ResourceList = {
|
|
383
|
+
count: number;
|
|
384
|
+
total: number;
|
|
385
|
+
items: any[];
|
|
386
|
+
};
|
|
343
387
|
/**
|
|
344
388
|
* // config: {} ?
|
|
345
389
|
*/
|
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":"
|
|
1
|
+
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"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"}
|
package/dist/lib/util.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function fetcher(url: any, config?: {}, options?: {}): Promise<any>;
|
|
2
|
-
export function apiURL(route: any, env?: string): any;
|
|
2
|
+
export function apiURL(route: any, env?: string, subdomain?: string): any;
|
|
3
3
|
export function query(params: any, sort?: boolean): any;
|
|
4
4
|
export function expect(obj: any): void;
|
|
5
5
|
//# sourceMappingURL=util.d.mts.map
|
package/dist/lib/util.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;
|
|
1
|
+
{"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAiBD,0EAcC;AAED,wDAKC;AAED,uCAMC"}
|