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 CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var tt=Object.defineProperty,et=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var S=(n,t,e)=>t in n?tt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,u=(n,t)=>{for(var e in t||(t={}))st.call(t,e)&&S(n,e,t[e]);if(L)for(var e of L(t))rt.call(t,e)&&S(n,e,t[e]);return n},f=(n,t)=>et(n,nt(t));var c=(n,t,e)=>new Promise((s,r)=>{var a=o=>{try{h(e.next(o))}catch(l){r(l)}},i=o=>{try{h(e.throw(o))}catch(l){r(l)}},h=o=>o.done?s(o.value):Promise.resolve(o.value).then(a,i);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=f(u({},e.headers||{}),{Authorization:`Bearer ${r}`}));const i=yield fetch(n,e);if(!i.ok){if((h=i.headers.get("content-type"))!=null&&h.includes("application/json")){const o=yield i.json(),l=`${o.title}
2
- ${o.detail}
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, x = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
3
- var L = Object.getOwnPropertySymbols;
4
- var N = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
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
- N.call(t, e) && j(n, e, t[e]);
8
- if (L)
9
- for (var e of L(t))
10
- z.call(t, e) && j(n, e, t[e]);
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) => x(n, J(t));
13
- var a = (n, t, e) => new Promise((s, r) => {
14
- var c = (o) => {
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(o));
16
+ h(e.next(a));
17
17
  } catch (l) {
18
18
  r(l);
19
19
  }
20
- }, i = (o) => {
20
+ }, o = (a) => {
21
21
  try {
22
- h(e.throw(o));
22
+ h(e.throw(a));
23
23
  } catch (l) {
24
24
  r(l);
25
25
  }
26
- }, h = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(c, i);
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 a(this, arguments, function* (n, t = {}, e = {}) {
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 i = yield fetch(n, e);
37
- if (!i.ok) {
38
- if ((h = i.headers.get("content-type")) != null && h.includes("application/json")) {
39
- const o = yield i.json(), l = `${o.title}
40
- ${o.detail}
41
- ${o.verbose}`;
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: ${i.statusText}`);
44
+ throw new Error(`unexpected fetch error: ${o.statusText}`);
45
45
  }
46
- return c ? i : yield i.json();
46
+ return c ? o : yield o.json();
47
47
  });
48
48
  }
49
49
  const S = {
50
- live: "https://datamanager.entrecode.de/",
51
- stage: "https://datamanager.cachena.entrecode.de/"
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 y(n, t = "stage") {
54
- const e = S[t];
55
- if (!e)
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(S).join(", ")}`
72
+ `env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`
58
73
  );
59
- return e + n;
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 C(n) {
75
- return a(this, null, function* () {
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 = y(`api/${e}/_auth/login?clientID=rest`, t);
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 R(n) {
93
- return a(this, null, function* () {
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 F(n) {
111
- return a(this, null, function* () {
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 = y(
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 M(n) {
128
- return a(this, null, function* () {
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 U({ dmShortID: n }) {
159
+ function M({ dmShortID: n }) {
145
160
  return d({ dmShortID: n }), n;
146
161
  }
147
- function v({ env: n }) {
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 a(this, null, function* () {
191
+ return i(this, null, function* () {
177
192
  let { env: t, dmShortID: e } = n;
178
193
  d({ env: t, dmShortID: e });
179
- const s = y(`api/${e}`, t);
194
+ const s = p(`api/${e}`, t);
180
195
  return g(s, n);
181
196
  });
182
197
  }
183
198
  function I(n) {
184
- return a(this, null, function* () {
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), i = y(`api/${e}/${s}?${c}`, t), { count: h, total: o, _embedded: l } = yield g(i, n);
188
- let $ = l ? l[`${e}:${s}`] : [];
189
- return $ = Array.isArray($) ? $ : [$], { count: h, total: o, items: $ };
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 }), i = y(`api/${t}/${e}?${c}`, n);
195
- return g(i, { dmShortID: t, token: r });
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 a(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
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 i = y(`api/${t}/${e}`, n);
215
+ const o = p(`api/${t}/${e}`, n);
201
216
  return yield g(
202
- i,
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(i) {
215
- return a(this, arguments, function* ({
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 = y(`api/${t}/${e}?_id=${s}`, n);
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 a(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
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 i = y(`api/${t}/${e}?_id=${s}`, n);
256
+ const o = p(`api/${t}/${e}?_id=${s}`, n);
242
257
  yield g(
243
- i,
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 a(this, arguments, function* ({ env: n, dmShortID: t, model: e }) {
256
- var l, $, m, P, _;
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 = y(`api/schema/${t}/${e}`, n), c = yield g(r), i = (l = c == null ? void 0 : c.allOf) == null ? void 0 : l[1];
259
- if (typeof i.properties != "object")
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 } = i, o = q(h);
264
- for (let A in o) {
265
- let p = o[A];
266
- 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(">"))) {
267
- const O = p.title.split("<")[1].slice(0, -1), D = p.title.split("<")[0];
268
- p.type = D, p.resource.includes(":") ? p.resource = O.split(":")[1] : p.resource = O;
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(p.title) ? (p.type = p.title, p.resource = null) : p.type = p.title;
271
- delete o[A].title;
285
+ ["asset", "entry", "assets", "entries"].includes($.title) ? ($.type = $.title, $.resource = null) : $.type = $.title;
286
+ delete a[k].title;
272
287
  }
273
- return o;
288
+ return a;
274
289
  });
275
290
  }
276
291
  function tt(c) {
277
- return a(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
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 i = w({ assetID: s }), h = y(`a/${t}/${e}?${i}`, n);
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 a(this, null, function* () {
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 i = w(c), h = y(`a/${e}/${s}?${i}`, t), { count: o, total: l, _embedded: $ } = yield g(h, { dmShortID: e, token: r });
288
- let m = $ ? $["ec:dm-asset"] : [];
289
- return m = Array.isArray(m) ? m : [m], { count: o, total: l, items: m };
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 a(this, arguments, function* ({
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: i
315
+ options: o
301
316
  }) {
302
317
  d({ env: n, dmShortID: t, assetGroup: e, file: r });
303
- const o = y(`a/${t}/${e}`, n), l = new FormData();
304
- return l.append("file", r, c), i && Object.keys(i).forEach((m) => {
305
- l.append(m, i[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
- o,
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 a(this, arguments, function* ({
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 i = y(`a/${t}/${e}/${s}`, n);
340
+ const o = p(`a/${t}/${e}/${s}`, n);
326
341
  yield g(
327
- i,
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 a(this, null, function* () {
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 = y(`?dataManagerID=${e}`, t);
354
+ const r = p(`?dataManagerID=${e}`, t);
340
355
  return g(r, { token: s });
341
356
  });
342
357
  }
343
- function it(n) {
344
- return a(this, null, function* () {
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 = y(`?${s}`, t), { count: c, total: i, _embedded: h } = yield g(r, n);
348
- let o = h ? h["ec:datamanager"] : [];
349
- return o = Array.isArray(o) ? o : [o], { count: c, total: i, items: o };
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 ot(n) {
353
- return a(this, null, function* () {
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 = y(`model?${r}`, t), { count: i, total: h, _embedded: o } = yield g(c, n);
357
- let l = o ? o["ec:model"] : [];
358
- return l = Array.isArray(l) ? l : [l], { count: i, total: h, items: l };
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 E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
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: it,
400
+ dmList: ot,
369
401
  editEntry: X,
370
402
  entryList: I,
371
403
  getAsset: tt,
372
404
  getDatamanager: rt,
373
- getEcAuthKey: v,
405
+ getEcAuthKey: U,
374
406
  getEntry: Q,
375
- getPublicAuthKey: U,
407
+ getPublicAuthKey: M,
376
408
  getSchema: Z,
377
- loginEc: R,
378
- loginPublic: C,
379
- logoutEc: M,
380
- logoutPublic: F,
381
- modelList: ot,
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: at,
385
- getEntry: ct,
386
- getAsset: ut,
387
- assetList: lt,
388
- createAsset: ht,
389
- deleteAsset: dt,
390
- createEntry: gt,
391
- editEntry: ft,
392
- deleteEntry: yt,
393
- getSchema: pt,
394
- loginPublic: $t,
395
- loginEc: mt,
396
- logoutEc: wt,
397
- logoutPublic: At,
398
- getEcAuthKey: k,
399
- getPublicAuthKey: b,
400
- dmList: Et,
401
- modelList: kt,
402
- publicApi: bt,
403
- getDatamanager: Tt
404
- } = E;
405
- function _t(n) {
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 }), !E[t])
443
+ if (d({ action: t }), !A[t])
408
444
  throw new Error(
409
- `"${t}" does not exist! try one of ${Object.keys(E).join(
445
+ `"${t}" does not exist! try one of ${Object.keys(A).join(
410
446
  ", "
411
447
  )}`
412
448
  );
413
- return E[t](n);
449
+ return A[t](n);
414
450
  }
415
- class T {
451
+ class _ {
416
452
  constructor(t) {
417
453
  this.config = t;
418
454
  }
419
455
  set(t) {
420
- return new T(u(u({}, this.config), t));
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 a(this, arguments, function* (t = {}) {
472
+ return i(this, arguments, function* (t = {}) {
437
473
  const e = yield this.getBestToken();
438
- return at(f(u({}, this.config), { options: t, token: e }));
474
+ return ut(f(u({}, this.config), { options: t, token: e }));
439
475
  });
440
476
  }
441
477
  entryList(t) {
442
- return a(this, null, function* () {
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 a(this, null, function* () {
492
+ return i(this, null, function* () {
457
493
  const e = yield this.getBestToken();
458
- return ct(f(u({}, this.config), { entryID: t, token: e }));
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 a(this, null, function* () {
471
- return pt(this.config);
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 a(this, null, function* () {
524
+ return i(this, null, function* () {
489
525
  const e = yield this.getBestToken();
490
- return lt(f(u({}, this.config), { options: t, token: e }));
526
+ return dt(f(u({}, this.config), { options: t, token: e }));
491
527
  });
492
528
  }
493
529
  assetList(t) {
494
- return a(this, null, function* () {
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 a(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
556
+ return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
521
557
  const r = yield this.getBestToken();
522
- return ht(f(u({}, this.config), { file: t, name: e, options: s, token: r }));
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 a(this, null, function* () {
571
+ return i(this, null, function* () {
536
572
  const e = yield this.getBestToken();
537
- return dt(f(u({}, this.config), { token: e, assetID: t }));
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 a(this, null, function* () {
586
+ return i(this, null, function* () {
551
587
  const e = yield this.getBestToken();
552
- return ut(f(u({}, this.config), { assetID: t, token: e }));
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 a(this, null, function* () {
601
+ return i(this, null, function* () {
566
602
  const e = yield this.getBestToken();
567
- return gt(f(u({}, this.config), { token: e, value: t }));
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 a(this, null, function* () {
617
+ return i(this, null, function* () {
582
618
  const s = yield this.getBestToken();
583
- return ft(f(u({}, this.config), { entryID: t, token: s, value: e }));
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 a(this, null, function* () {
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 yt(f(u({}, this.config), { token: e, entryID: t }));
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 mt(u(u({}, this.config), t)).then(
629
- this.setAuth(k(this.config))
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 $t(u(u({}, this.config), t)).then(
634
- this.setAuth(b(this.config))
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), At(f(u({}, this.config), { token: t })).then(
640
- this.unsetAuth(b(this.config))
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), wt(f(u({}, this.config), { token: t })).then(
646
- this.unsetAuth(k(this.config))
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(b(this.config));
717
+ return this.config.token || this.getAuth(T(this.config));
651
718
  }
652
719
  getEcToken() {
653
- return this.config.token || this.getAuth(k(this.config));
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 bt(this.config);
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 a(this, null, function* () {
830
+ return i(this, null, function* () {
740
831
  const e = yield this.getBestToken();
741
- return Tt(f(u({}, this.config), { dmID: t, token: e }));
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 a(this, arguments, function* (t = {}) {
844
+ return i(this, arguments, function* (t = {}) {
754
845
  const e = yield this.getBestToken();
755
- return Et(f(u({}, this.config), { options: t, token: e }));
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 a(this, arguments, function* (t = {}) {
858
+ return i(this, arguments, function* (t = {}) {
768
859
  const e = yield this.getBestToken();
769
- return kt(f(u({}, this.config), { options: t, token: e }));
860
+ return Tt(f(u({}, this.config), { options: t, token: e }));
770
861
  });
771
862
  }
772
863
  }
773
- const Ot = (n) => new T({ env: n });
864
+ const Bt = (n) => new _({ env: n });
774
865
  export {
775
- T as Sdk,
776
- _t as act,
777
- y as apiURL,
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
- it as dmList,
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
- v as getEcAuthKey,
881
+ U as getEcAuthKey,
791
882
  Q as getEntry,
792
- U as getPublicAuthKey,
883
+ M as getPublicAuthKey,
793
884
  Z as getSchema,
794
- R as loginEc,
795
- C as loginPublic,
796
- M as logoutEc,
797
- F as logoutPublic,
798
- ot as modelList,
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
- Ot as sdk
892
+ ct as raw,
893
+ at as resourceList,
894
+ Bt as sdk
802
895
  };
@@ -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
@@ -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"}
@@ -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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"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"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAOD,sDAQC;AAED,wDAKC;AAED,uCAMC"}
1
+ {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAiBD,0EAcC;AAED,wDAKC;AAED,uCAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.2.30",
3
+ "version": "0.3.0",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {