ec.fdk 0.1.8 → 0.2.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 +1 @@
1
- "use strict";var I=Object.defineProperty,v=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var m=(n,t,e)=>t in n?I(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))Q.call(t,e)&&m(n,e,t[e]);if(P)for(var e of P(t))V.call(t,e)&&m(n,e,t[e]);return n},y=(n,t)=>v(n,H(t));var u=(n,t,e)=>new Promise((s,o)=>{var i=l=>{try{a(e.next(l))}catch(f){o(f)}},r=l=>{try{a(e.throw(l))}catch(f){o(f)}},a=l=>l.done?s(l.value):Promise.resolve(l.value).then(i,r);a((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return u(this,arguments,function*(n,t={},e={}){const{token:o,rawRes:i}=t;o&&(e.headers=y(c({},e.headers||{}),{Authorization:`Bearer ${o}`}));const r=yield fetch(n,e);if(!r.ok)throw new Error(r.statusText);return i?r:yield r.json()})}const j={production:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function d(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 E(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function h(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const L={stage:"https://accounts.cachena.entrecode.de/",production:"https://accounts.cachena.entrecode.de/"};function S(n){return u(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;h({env:t,dmShortID:e,email:s,password:o});const i=d(`api/${e}/_auth/login?clientID=rest`,t);return yield g(i,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function K(n){return u(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const o=`${L[t]}auth/login?clientID=rest`;return yield g(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function q(n){return u(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const o=d(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function B(n){return u(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${L[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function C({dmShortID:n}){return h({dmShortID:n}),n}function R({env:n}){return h({env:n}),n}function x(n){return u(this,null,function*(){let{env:t,dmShortID:e,model:s,options:o={}}=n;h({env:t,dmShortID:e,model:s}),o=c({size:50,page:1,_list:!0},o);const i=E(o),r=d(`api/${e}/${s}?${i}`,t),{count:a,total:l,_embedded:f}=yield g(r,n),b=f?f[`${e}:${s}`]:[];return{count:a,total:l,items:b}})}function z({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const i=E({_id:s}),r=d(`api/${t}/${e}?${i}`,n);return g(r,{dmShortID:t,token:o})}function D(i){return u(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:o}){h({env:n,dmShortID:t,model:e,value:s}),console.log("create entry",t,e,s);const r=d(`api/${t}/${e}`,n);return console.log("url",r),yield g(r,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function J(r){return u(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:i}){h({env:n,dmShortID:t,model:e,entryID:s,value:o});const a=d(`api/${t}/${e}?_id=${s}`,n);return yield g(a,{token:i},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function N(i){return u(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const r=d(`api/${t}/${e}?_id=${s}`,n);return yield g(r,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function U(i){return u(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=E({assetID:s}),a=d(`a/${t}/${e}?${r}`,n);return(yield g(a,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function M(n){return u(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:o,options:i={}}=n;h({env:t,dmShortID:e,assetGroup:s}),i=c({size:50,page:1,_list:!0},i);const r=E(i),a=d(`a/${e}/${s}?${r}`,t),{count:l,total:f,_embedded:b}=yield g(a,{dmShortID:e,token:o}),G=b?b["ec:dm-asset"]:[];return{count:l,total:f,items:G}})}function F(i){return u(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o}){h({env:n,dmShortID:t,assetGroup:e,file:o});const r=d(`a/${t}/${e}`,n),a=new FormData;return a.append("file",o),(yield g(r,{token:s},{method:"POST",body:a}))._embedded["ec:dm-asset"]})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:M,createAsset:F,createEntry:D,deleteEntry:N,editEntry:J,entryList:x,getAsset:U,getEcAuthKey:R,getEntry:z,getPublicAuthKey:C,loginEc:K,loginPublic:S,logoutEc:B,logoutPublic:q},Symbol.toStringTag,{value:"Module"})),{entryList:W,getEntry:X,getAsset:Y,assetList:Z,createAsset:tt,createEntry:O,editEntry:_,deleteEntry:et,loginPublic:nt,loginEc:st,logoutEc:ot,logoutPublic:rt,getEcAuthKey:w,getPublicAuthKey:A}=k;function it(n){const{action:t}=n;if(h({action:t}),!k[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(k).join(", ")}`);return k[t](n)}class p{constructor(t){this.config=t}set(t){return new p(c(c({},this.config),t))}handle(t){return u(this,null,function*(){const e=Object.keys(this.config),s=yield this.getBestToken(),[o,i]=Object.entries(t).find(([r,a])=>e.includes(r))||[];if(!i)throw new Error(`you need to first set ${Object.keys(t).join(" | ")}`);return i(y(c({},this.config),{token:s}))})}entries(t){return u(this,null,function*(){const e=yield this.getBestToken();return W(y(c({},this.config),{options:t,token:e}))})}assets(t){return u(this,null,function*(){const e=yield this.getBestToken();return Z(y(c({},this.config),{options:t,token:e}))})}createAsset(){return u(this,arguments,function*({file:t}={}){const e=yield this.getBestToken();return tt(y(c({},this.config),{file:t,token:e}))})}get(){return this.handle({assetID:Y,entryID:X})}del(){return this.handle({entryID:et})}createEntry(t){return O(y(c({},this.config),{value:t}))}editEntry(t){return _(y(c({},this.config),{value:t}))}create(t){return this.set({value:t}).handle({model:O})}edit(t){return this.set({value:t}).handle({entryID:_})}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 st(c(c({},this.config),t)).then(this.setAuth(w(this.config)))}loginPublic(t){return nt(c(c({},this.config),t)).then(this.setAuth(A(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),rt(y(c({},this.config),{token:t})).then(this.unsetAuth(A(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),ot(y(c({},this.config),{token:t})).then(this.unsetAuth(w(this.config)))}getPublicToken(){return this.config.token||this.getAuth(A(this.config))}getEcToken(){return this.config.token||this.getAuth(w(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}}}const $=(...n)=>{const[t]=n;n.forEach(e=>{p.prototype[e]=function(s){return this.set({[t]:s})}})},T=(n,t)=>{p.prototype[n]=p.prototype[t]};$("dmShortID","dm","dmshortid");$("model");$("token");$("entryID","entry");$("assetGroup");$("assetID","asset");T("assetgroup","assetGroup");T("entryList","entries");T("assetList","assets");const ct=n=>new p({env:n});exports.act=it;exports.apiURL=d;exports.assetList=M;exports.createAsset=F;exports.createEntry=D;exports.deleteEntry=N;exports.editEntry=J;exports.entryList=x;exports.expect=h;exports.fetcher=g;exports.getAsset=U;exports.getEcAuthKey=R;exports.getEntry=z;exports.getPublicAuthKey=C;exports.loginEc=K;exports.loginPublic=S;exports.logoutEc=B;exports.logoutPublic=q;exports.query=E;exports.sdk=ct;
1
+ "use strict";var M=Object.defineProperty,F=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var T=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,a=(n,t)=>{for(var e in t||(t={}))v.call(t,e)&&T(n,e,t[e]);if(A)for(var e of A(t))H.call(t,e)&&T(n,e,t[e]);return n},y=(n,t)=>F(n,G(t));var c=(n,t,e)=>new Promise((s,r)=>{var o=h=>{try{u(e.next(h))}catch(f){r(f)}},i=h=>{try{u(e.throw(h))}catch(f){r(f)}},u=h=>h.done?s(h.value):Promise.resolve(h.value).then(o,i);u((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return c(this,arguments,function*(n,t={},e={}){const{token:r,rawRes:o}=t;r&&(e.headers=y(a({},e.headers||{}),{Authorization:`Bearer ${r}`}));const i=yield fetch(n,e);if(!i.ok)throw new Error(i.statusText);return o?i:yield i.json()})}const P={production:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function d(n,t="stage"){const e=P[t];if(!e)throw new Error(`env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`);return e+n}function p(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function l(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const O={stage:"https://accounts.cachena.entrecode.de/",production:"https://accounts.cachena.entrecode.de/"};function _(n){return c(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;l({env:t,dmShortID:e,email:s,password:r});const o=d(`api/${e}/_auth/login?clientID=rest`,t);return yield g(o,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function L(n){return c(this,null,function*(){let{env:t,email:e,password:s}=n;l({env:t,email:e,password:s});const r=`${O[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function S(n){return c(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;l({dmShortID:t,env:e,token:s});const r=d(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function K(n){return c(this,null,function*(){let{env:t,token:e}=n;l({env:t,token:e});const s=`${O[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function D({dmShortID:n}){return l({dmShortID:n}),n}function q({env:n}){return l({env:n}),n}function B(n){return c(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;l({env:t,dmShortID:e,model:s}),r=a({size:50,page:1,_list:!0},r);const o=p(r),i=d(`api/${e}/${s}?${o}`,t),{count:u,total:h,_embedded:f}=yield g(i,n),$=f?f[`${e}:${s}`]:[];return{count:u,total:h,items:$}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:r}){l({env:n,dmShortID:t,model:e,entryID:s});const o=p({_id:s}),i=d(`api/${t}/${e}?${o}`,n);return g(i,{dmShortID:t,token:r})}function R(o){return c(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){l({env:n,dmShortID:t,model:e,value:s}),console.log("create entry",t,e,s);const i=d(`api/${t}/${e}`,n);return console.log("url",i),yield g(i,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function x(i){return c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:o}){l({env:n,dmShortID:t,model:e,entryID:s,value:r});const u=d(`api/${t}/${e}?_id=${s}`,n);return yield g(u,{token:o},{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}})})}function z(o){return c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:r}){l({env:n,dmShortID:t,model:e,entryID:s});const i=d(`api/${t}/${e}?_id=${s}`,n);return yield g(i,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function I(o){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){l({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=p({assetID:s}),u=d(`a/${t}/${e}?${i}`,n);return(yield g(u,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function J(n){return c(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:o={}}=n;l({env:t,dmShortID:e,assetGroup:s}),o=a({size:50,page:1,_list:!0},o);const i=p(o),u=d(`a/${e}/${s}?${i}`,t),{count:h,total:f,_embedded:$}=yield g(u,{dmShortID:e,token:r}),U=$?$["ec:dm-asset"]:[];return{count:h,total:f,items:U}})}function N(i){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:o}){l({env:n,dmShortID:t,assetGroup:e,file:r});const u=d(`a/${t}/${e}`,n),h=new FormData;return h.append("file",r,o),(yield g(u,{token:s},{method:"POST",body:h}))._embedded["ec:dm-asset"]})}const E=Object.freeze(Object.defineProperty({__proto__:null,assetList:J,createAsset:N,createEntry:R,deleteEntry:z,editEntry:x,entryList:B,getAsset:I,getEcAuthKey:q,getEntry:C,getPublicAuthKey:D,loginEc:L,loginPublic:_,logoutEc:K,logoutPublic:S},Symbol.toStringTag,{value:"Module"})),{entryList:Q,getEntry:V,getAsset:W,assetList:X,createAsset:Y,createEntry:m,editEntry:j,deleteEntry:Z,loginPublic:tt,loginEc:et,logoutEc:nt,logoutPublic:st,getEcAuthKey:b,getPublicAuthKey:k}=E;function rt(n){const{action:t}=n;if(l({action:t}),!E[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(E).join(", ")}`);return E[t](n)}class w{constructor(t){this.config=t}set(t){return new w(a(a({},this.config),t))}handle(t){return c(this,null,function*(){const e=Object.keys(this.config),s=yield this.getBestToken(),[r,o]=Object.entries(t).find(([i,u])=>e.includes(i))||[];if(!o)throw new Error(`you need to first set ${Object.keys(t).join(" | ")}`);return o(y(a({},this.config),{token:s}))})}entries(t){return c(this,null,function*(){const e=yield this.getBestToken();return Q(y(a({},this.config),{options:t,token:e}))})}entryList(t){return c(this,null,function*(){return this.entries(t)})}assets(t){return c(this,null,function*(){const e=yield this.getBestToken();return X(y(a({},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}={}){const s=yield this.getBestToken();return Y(y(a({},this.config),{file:t,name:e,token:s}))})}get(){return this.handle({assetID:W,entryID:V})}del(){return this.handle({entryID:Z})}createEntry(t){return m(y(a({},this.config),{value:t}))}editEntry(t){return j(y(a({},this.config),{value:t}))}create(t){return this.set({value:t}).handle({model:m})}edit(t){return this.set({value:t}).handle({entryID:j})}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 et(a(a({},this.config),t)).then(this.setAuth(b(this.config)))}loginPublic(t){return tt(a(a({},this.config),t)).then(this.setAuth(k(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(y(a({},this.config),{token:t})).then(this.unsetAuth(k(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(y(a({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}getPublicToken(){return this.config.token||this.getAuth(k(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})}dm(t){return this.dmShortID(t)}entryID(t){return this.set({entryID:t})}entry(t){return this.entryID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}assetID(t){return this.set({assetID:t})}asset(t){return this.assetID(t)}}const ot=n=>new w({env:n});exports.act=rt;exports.apiURL=d;exports.assetList=J;exports.createAsset=N;exports.createEntry=R;exports.deleteEntry=z;exports.editEntry=x;exports.entryList=B;exports.expect=l;exports.fetcher=g;exports.getAsset=I;exports.getEcAuthKey=q;exports.getEntry=C;exports.getPublicAuthKey=D;exports.loginEc=L;exports.loginPublic=_;exports.logoutEc=K;exports.logoutPublic=S;exports.query=p;exports.sdk=ot;
@@ -0,0 +1,4 @@
1
+ export * from "./lib/api.mjs";
2
+ export * from "./lib/util.mjs";
3
+ export * from "./lib/actions.mjs";
4
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mjs"],"names":[],"mappings":""}
package/dist/index.mjs CHANGED
@@ -1,79 +1,79 @@
1
- var S = Object.defineProperty, B = Object.defineProperties;
2
- var C = Object.getOwnPropertyDescriptors;
3
- var P = Object.getOwnPropertySymbols;
4
- var q = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
5
- var m = (n, t, e) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
1
+ var L = Object.defineProperty, K = Object.defineProperties;
2
+ var S = Object.getOwnPropertyDescriptors;
3
+ var A = Object.getOwnPropertySymbols;
4
+ var D = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
5
+ var T = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, a = (n, t) => {
6
6
  for (var e in t || (t = {}))
7
- q.call(t, e) && m(n, e, t[e]);
8
- if (P)
9
- for (var e of P(t))
10
- x.call(t, e) && m(n, e, t[e]);
7
+ D.call(t, e) && T(n, e, t[e]);
8
+ if (A)
9
+ for (var e of A(t))
10
+ B.call(t, e) && T(n, e, t[e]);
11
11
  return n;
12
- }, d = (n, t) => B(n, C(t));
13
- var u = (n, t, e) => new Promise((s, o) => {
14
- var i = (l) => {
12
+ }, d = (n, t) => K(n, S(t));
13
+ var c = (n, t, e) => new Promise((s, r) => {
14
+ var o = (h) => {
15
15
  try {
16
- a(e.next(l));
16
+ u(e.next(h));
17
17
  } catch (f) {
18
- o(f);
18
+ r(f);
19
19
  }
20
- }, r = (l) => {
20
+ }, i = (h) => {
21
21
  try {
22
- a(e.throw(l));
22
+ u(e.throw(h));
23
23
  } catch (f) {
24
- o(f);
24
+ r(f);
25
25
  }
26
- }, a = (l) => l.done ? s(l.value) : Promise.resolve(l.value).then(i, r);
27
- a((e = e.apply(n, t)).next());
26
+ }, u = (h) => h.done ? s(h.value) : Promise.resolve(h.value).then(o, i);
27
+ u((e = e.apply(n, t)).next());
28
28
  });
29
29
  function g(s) {
30
- return u(this, arguments, function* (n, t = {}, e = {}) {
31
- const { token: o, rawRes: i } = t;
32
- o && (e.headers = d(c({}, e.headers || {}), {
33
- Authorization: `Bearer ${o}`
30
+ return c(this, arguments, function* (n, t = {}, e = {}) {
31
+ const { token: r, rawRes: o } = t;
32
+ r && (e.headers = d(a({}, e.headers || {}), {
33
+ Authorization: `Bearer ${r}`
34
34
  }));
35
- const r = yield fetch(n, e);
36
- if (!r.ok)
37
- throw new Error(r.statusText);
38
- return i ? r : yield r.json();
35
+ const i = yield fetch(n, e);
36
+ if (!i.ok)
37
+ throw new Error(i.statusText);
38
+ return o ? i : yield i.json();
39
39
  });
40
40
  }
41
- const j = {
41
+ const P = {
42
42
  production: "https://datamanager.entrecode.de/",
43
43
  stage: "https://datamanager.cachena.entrecode.de/"
44
44
  };
45
45
  function y(n, t = "stage") {
46
- const e = j[t];
46
+ const e = P[t];
47
47
  if (!e)
48
48
  throw new Error(
49
- `env "${t}" not found. Try one of ${Object.keys(j).join(", ")}`
49
+ `env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`
50
50
  );
51
51
  return e + n;
52
52
  }
53
- function w(n, t = !0) {
53
+ function E(n, t = !0) {
54
54
  return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
55
55
  }
56
- function h(n) {
56
+ function l(n) {
57
57
  Object.entries(n).forEach(([t, e]) => {
58
58
  if (e === void 0)
59
59
  throw new Error(`expected ${t} to be set!`);
60
60
  });
61
61
  }
62
- const L = {
62
+ const O = {
63
63
  stage: "https://accounts.cachena.entrecode.de/",
64
64
  production: "https://accounts.cachena.entrecode.de/"
65
65
  };
66
- function R(n) {
67
- return u(this, null, function* () {
68
- let { env: t, dmShortID: e, email: s, password: o } = n;
69
- h({ env: t, dmShortID: e, email: s, password: o });
70
- const i = y(`api/${e}/_auth/login?clientID=rest`, t);
66
+ function C(n) {
67
+ return c(this, null, function* () {
68
+ let { env: t, dmShortID: e, email: s, password: r } = n;
69
+ l({ env: t, dmShortID: e, email: s, password: r });
70
+ const o = y(`api/${e}/_auth/login?clientID=rest`, t);
71
71
  return yield g(
72
- i,
72
+ o,
73
73
  {},
74
74
  {
75
75
  method: "POST",
76
- body: JSON.stringify({ email: s, password: o }),
76
+ body: JSON.stringify({ email: s, password: r }),
77
77
  headers: {
78
78
  "Content-Type": "application/json"
79
79
  }
@@ -81,13 +81,13 @@ function R(n) {
81
81
  );
82
82
  });
83
83
  }
84
- function z(n) {
85
- return u(this, null, function* () {
84
+ function q(n) {
85
+ return c(this, null, function* () {
86
86
  let { env: t, email: e, password: s } = n;
87
- h({ env: t, email: e, password: s });
88
- const o = `${L[t]}auth/login?clientID=rest`;
87
+ l({ env: t, email: e, password: s });
88
+ const r = `${O[t]}auth/login?clientID=rest`;
89
89
  return yield g(
90
- o,
90
+ r,
91
91
  {},
92
92
  {
93
93
  method: "POST",
@@ -99,16 +99,16 @@ function z(n) {
99
99
  );
100
100
  });
101
101
  }
102
- function D(n) {
103
- return u(this, null, function* () {
102
+ function x(n) {
103
+ return c(this, null, function* () {
104
104
  let { dmShortID: t, env: e, token: s } = n;
105
- h({ dmShortID: t, env: e, token: s });
106
- const o = y(
105
+ l({ dmShortID: t, env: e, token: s });
106
+ const r = y(
107
107
  `api/${t}/_auth/logout?clientID=rest&token=${s}`,
108
108
  e
109
109
  );
110
110
  return yield g(
111
- o,
111
+ r,
112
112
  { dmShortID: t, rawRes: !0 },
113
113
  {
114
114
  method: "POST"
@@ -116,11 +116,11 @@ function D(n) {
116
116
  );
117
117
  });
118
118
  }
119
- function J(n) {
120
- return u(this, null, function* () {
119
+ function R(n) {
120
+ return c(this, null, function* () {
121
121
  let { env: t, token: e } = n;
122
- h({ env: t, token: e });
123
- const s = `${L[t]}auth/logout?clientID=rest`;
122
+ l({ env: t, token: e });
123
+ const s = `${O[t]}auth/logout?clientID=rest`;
124
124
  return yield g(
125
125
  s,
126
126
  {
@@ -133,32 +133,32 @@ function J(n) {
133
133
  );
134
134
  });
135
135
  }
136
- function N({ dmShortID: n }) {
137
- return h({ dmShortID: n }), n;
136
+ function z({ dmShortID: n }) {
137
+ return l({ dmShortID: n }), n;
138
138
  }
139
- function U({ env: n }) {
140
- return h({ env: n }), n;
139
+ function I({ env: n }) {
140
+ return l({ env: n }), n;
141
141
  }
142
- function F(n) {
143
- return u(this, null, function* () {
144
- let { env: t, dmShortID: e, model: s, options: o = {} } = n;
145
- h({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
146
- const i = w(o), r = y(`api/${e}/${s}?${i}`, t), { count: a, total: l, _embedded: f } = yield g(r, n), E = f ? f[`${e}:${s}`] : [];
147
- return { count: a, total: l, items: E };
142
+ function J(n) {
143
+ return c(this, null, function* () {
144
+ let { env: t, dmShortID: e, model: s, options: r = {} } = n;
145
+ l({ env: t, dmShortID: e, model: s }), r = a({ size: 50, page: 1, _list: !0 }, r);
146
+ const o = E(r), i = y(`api/${e}/${s}?${o}`, t), { count: u, total: h, _embedded: f } = yield g(i, n), p = f ? f[`${e}:${s}`] : [];
147
+ return { count: u, total: h, items: p };
148
148
  });
149
149
  }
150
- function G({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
151
- h({ env: n, dmShortID: t, model: e, entryID: s });
152
- const i = w({ _id: s }), r = y(`api/${t}/${e}?${i}`, n);
153
- return g(r, { dmShortID: t, token: o });
150
+ function N({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
151
+ l({ env: n, dmShortID: t, model: e, entryID: s });
152
+ const o = E({ _id: s }), i = y(`api/${t}/${e}?${o}`, n);
153
+ return g(i, { dmShortID: t, token: r });
154
154
  }
155
- function I(i) {
156
- return u(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: o }) {
157
- h({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
158
- const r = y(`api/${t}/${e}`, n);
159
- return console.log("url", r), yield g(
160
- r,
161
- { env: n, dmShortID: t, token: o },
155
+ function U(o) {
156
+ return c(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
157
+ l({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
158
+ const i = y(`api/${t}/${e}`, n);
159
+ return console.log("url", i), yield g(
160
+ i,
161
+ { env: n, dmShortID: t, token: r },
162
162
  {
163
163
  method: "POST",
164
164
  body: JSON.stringify(s),
@@ -169,23 +169,23 @@ function I(i) {
169
169
  );
170
170
  });
171
171
  }
172
- function M(r) {
173
- return u(this, arguments, function* ({
172
+ function F(i) {
173
+ return c(this, arguments, function* ({
174
174
  env: n,
175
175
  dmShortID: t,
176
176
  model: e,
177
177
  entryID: s,
178
- value: o,
179
- token: i
178
+ value: r,
179
+ token: o
180
180
  }) {
181
- h({ env: n, dmShortID: t, model: e, entryID: s, value: o });
182
- const a = y(`api/${t}/${e}?_id=${s}`, n);
181
+ l({ env: n, dmShortID: t, model: e, entryID: s, value: r });
182
+ const u = y(`api/${t}/${e}?_id=${s}`, n);
183
183
  return yield g(
184
- a,
185
- { token: i },
184
+ u,
185
+ { token: o },
186
186
  {
187
187
  method: "PUT",
188
- body: JSON.stringify(o),
188
+ body: JSON.stringify(r),
189
189
  headers: {
190
190
  "Content-Type": "application/json"
191
191
  }
@@ -193,13 +193,13 @@ function M(r) {
193
193
  );
194
194
  });
195
195
  }
196
- function H(i) {
197
- return u(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
198
- h({ env: n, dmShortID: t, model: e, entryID: s });
199
- const r = y(`api/${t}/${e}?_id=${s}`, n);
196
+ function G(o) {
197
+ return c(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
198
+ l({ env: n, dmShortID: t, model: e, entryID: s });
199
+ const i = y(`api/${t}/${e}?_id=${s}`, n);
200
200
  return yield g(
201
- r,
202
- { token: o, rawRes: !0 },
201
+ i,
202
+ { token: r, rawRes: !0 },
203
203
  {
204
204
  method: "DELETE",
205
205
  headers: {
@@ -209,140 +209,157 @@ function H(i) {
209
209
  );
210
210
  });
211
211
  }
212
- function Q(i) {
213
- return u(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: o }) {
214
- h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
215
- const r = w({ assetID: s }), a = y(`a/${t}/${e}?${r}`, n);
216
- return (yield g(a, { dmShortID: t, token: o }))._embedded["ec:dm-asset"];
212
+ function M(o) {
213
+ return c(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
214
+ l({ env: n, dmShortID: t, assetGroup: e, assetID: s });
215
+ const i = E({ assetID: s }), u = y(`a/${t}/${e}?${i}`, n);
216
+ return (yield g(u, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
217
217
  });
218
218
  }
219
- function V(n) {
220
- return u(this, null, function* () {
221
- let { env: t, dmShortID: e, assetGroup: s, token: o, options: i = {} } = n;
222
- h({ env: t, dmShortID: e, assetGroup: s }), i = c({ size: 50, page: 1, _list: !0 }, i);
223
- const r = w(i), a = y(`a/${e}/${s}?${r}`, t), { count: l, total: f, _embedded: E } = yield g(a, { dmShortID: e, token: o }), K = E ? E["ec:dm-asset"] : [];
224
- return { count: l, total: f, items: K };
219
+ function H(n) {
220
+ return c(this, null, function* () {
221
+ let { env: t, dmShortID: e, assetGroup: s, token: r, options: o = {} } = n;
222
+ l({ env: t, dmShortID: e, assetGroup: s }), o = a({ size: 50, page: 1, _list: !0 }, o);
223
+ const i = E(o), u = y(`a/${e}/${s}?${i}`, t), { count: h, total: f, _embedded: p } = yield g(u, { dmShortID: e, token: r }), _ = p ? p["ec:dm-asset"] : [];
224
+ return { count: h, total: f, items: _ };
225
225
  });
226
226
  }
227
- function W(i) {
228
- return u(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, token: s, file: o }) {
229
- h({ env: n, dmShortID: t, assetGroup: e, file: o });
230
- const r = y(`a/${t}/${e}`, n), a = new FormData();
231
- return a.append("file", o), (yield g(
232
- r,
227
+ function Q(i) {
228
+ return c(this, arguments, function* ({
229
+ env: n,
230
+ dmShortID: t,
231
+ assetGroup: e,
232
+ token: s,
233
+ file: r,
234
+ name: o
235
+ }) {
236
+ l({ env: n, dmShortID: t, assetGroup: e, file: r });
237
+ const u = y(`a/${t}/${e}`, n), h = new FormData();
238
+ return h.append("file", r, o), (yield g(
239
+ u,
233
240
  { token: s },
234
241
  {
235
242
  method: "POST",
236
- body: a
243
+ body: h
237
244
  }
238
245
  ))._embedded["ec:dm-asset"];
239
246
  });
240
247
  }
241
- const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
248
+ const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
242
249
  __proto__: null,
243
- assetList: V,
244
- createAsset: W,
245
- createEntry: I,
246
- deleteEntry: H,
247
- editEntry: M,
248
- entryList: F,
249
- getAsset: Q,
250
- getEcAuthKey: U,
251
- getEntry: G,
252
- getPublicAuthKey: N,
253
- loginEc: z,
254
- loginPublic: R,
255
- logoutEc: J,
256
- logoutPublic: D
250
+ assetList: H,
251
+ createAsset: Q,
252
+ createEntry: U,
253
+ deleteEntry: G,
254
+ editEntry: F,
255
+ entryList: J,
256
+ getAsset: M,
257
+ getEcAuthKey: I,
258
+ getEntry: N,
259
+ getPublicAuthKey: z,
260
+ loginEc: q,
261
+ loginPublic: C,
262
+ logoutEc: R,
263
+ logoutPublic: x
257
264
  }, Symbol.toStringTag, { value: "Module" })), {
258
- entryList: X,
259
- getEntry: Y,
260
- getAsset: Z,
261
- assetList: v,
262
- createAsset: tt,
263
- createEntry: O,
264
- editEntry: _,
265
- deleteEntry: et,
266
- loginPublic: nt,
267
- loginEc: st,
268
- logoutEc: ot,
269
- logoutPublic: rt,
270
- getEcAuthKey: A,
271
- getPublicAuthKey: b
272
- } = k;
273
- function ct(n) {
265
+ entryList: V,
266
+ getEntry: W,
267
+ getAsset: X,
268
+ assetList: Y,
269
+ createAsset: Z,
270
+ createEntry: m,
271
+ editEntry: j,
272
+ deleteEntry: v,
273
+ loginPublic: tt,
274
+ loginEc: et,
275
+ logoutEc: nt,
276
+ logoutPublic: st,
277
+ getEcAuthKey: k,
278
+ getPublicAuthKey: w
279
+ } = $;
280
+ function ot(n) {
274
281
  const { action: t } = n;
275
- if (h({ action: t }), !k[t])
282
+ if (l({ action: t }), !$[t])
276
283
  throw new Error(
277
- `"${t}" does not exist! try one of ${Object.keys(k).join(
284
+ `"${t}" does not exist! try one of ${Object.keys($).join(
278
285
  ", "
279
286
  )}`
280
287
  );
281
- return k[t](n);
288
+ return $[t](n);
282
289
  }
283
- class p {
290
+ class b {
284
291
  constructor(t) {
285
292
  this.config = t;
286
293
  }
287
294
  set(t) {
288
- return new p(c(c({}, this.config), t));
295
+ return new b(a(a({}, this.config), t));
289
296
  }
290
297
  handle(t) {
291
- return u(this, null, function* () {
292
- const e = Object.keys(this.config), s = yield this.getBestToken(), [o, i] = Object.entries(t).find(([r, a]) => e.includes(r)) || [];
293
- if (!i)
298
+ return c(this, null, function* () {
299
+ const e = Object.keys(this.config), s = yield this.getBestToken(), [r, o] = Object.entries(t).find(([i, u]) => e.includes(i)) || [];
300
+ if (!o)
294
301
  throw new Error(
295
302
  `you need to first set ${Object.keys(t).join(" | ")}`
296
303
  );
297
- return i(d(c({}, this.config), { token: s }));
304
+ return o(d(a({}, this.config), { token: s }));
298
305
  });
299
306
  }
300
307
  ///
301
308
  entries(t) {
302
- return u(this, null, function* () {
309
+ return c(this, null, function* () {
303
310
  const e = yield this.getBestToken();
304
- return X(d(c({}, this.config), { options: t, token: e }));
311
+ return V(d(a({}, this.config), { options: t, token: e }));
312
+ });
313
+ }
314
+ entryList(t) {
315
+ return c(this, null, function* () {
316
+ return this.entries(t);
305
317
  });
306
318
  }
307
319
  assets(t) {
308
- return u(this, null, function* () {
320
+ return c(this, null, function* () {
309
321
  const e = yield this.getBestToken();
310
- return v(d(c({}, this.config), { options: t, token: e }));
322
+ return Y(d(a({}, this.config), { options: t, token: e }));
323
+ });
324
+ }
325
+ assetList(t) {
326
+ return c(this, null, function* () {
327
+ return this.assets(t);
311
328
  });
312
329
  }
313
330
  createAsset() {
314
- return u(this, arguments, function* ({ file: t } = {}) {
315
- const e = yield this.getBestToken();
316
- return tt(d(c({}, this.config), { file: t, token: e }));
331
+ return c(this, arguments, function* ({ file: t, name: e } = {}) {
332
+ const s = yield this.getBestToken();
333
+ return Z(d(a({}, this.config), { file: t, name: e, token: s }));
317
334
  });
318
335
  }
319
336
  get() {
320
337
  return this.handle({
321
- assetID: Z,
322
- entryID: Y
338
+ assetID: X,
339
+ entryID: W
323
340
  });
324
341
  }
325
342
  del() {
326
343
  return this.handle({
327
- entryID: et
344
+ entryID: v
328
345
  });
329
346
  }
330
347
  createEntry(t) {
331
- return O(d(c({}, this.config), { value: t }));
348
+ return m(d(a({}, this.config), { value: t }));
332
349
  }
333
350
  editEntry(t) {
334
- return _(d(c({}, this.config), { value: t }));
351
+ return j(d(a({}, this.config), { value: t }));
335
352
  }
336
353
  create(t) {
337
354
  return this.set({ value: t }).handle({
338
355
  //assetID: createAsset,
339
- model: O
356
+ model: m
340
357
  });
341
358
  }
342
359
  edit(t) {
343
360
  return this.set({ value: t }).handle({
344
361
  //assetID: createAsset,
345
- entryID: _
362
+ entryID: j
346
363
  });
347
364
  }
348
365
  // TODO: rename authAdapter -> storageAdapter
@@ -372,32 +389,32 @@ class p {
372
389
  return e(t);
373
390
  }
374
391
  loginEc(t) {
375
- return st(c(c({}, this.config), t)).then(
376
- this.setAuth(A(this.config))
392
+ return et(a(a({}, this.config), t)).then(
393
+ this.setAuth(k(this.config))
377
394
  );
378
395
  }
379
396
  loginPublic(t) {
380
- return nt(c(c({}, this.config), t)).then(
381
- this.setAuth(b(this.config))
397
+ return tt(a(a({}, this.config), t)).then(
398
+ this.setAuth(w(this.config))
382
399
  );
383
400
  }
384
401
  logoutPublic() {
385
402
  const t = this.getPublicToken();
386
- return console.log("token", t), rt(d(c({}, this.config), { token: t })).then(
387
- this.unsetAuth(b(this.config))
403
+ return console.log("token", t), st(d(a({}, this.config), { token: t })).then(
404
+ this.unsetAuth(w(this.config))
388
405
  );
389
406
  }
390
407
  logoutEc() {
391
408
  const t = this.getEcToken();
392
- return console.log("token", t), ot(d(c({}, this.config), { token: t })).then(
393
- this.unsetAuth(A(this.config))
409
+ return console.log("token", t), nt(d(a({}, this.config), { token: t })).then(
410
+ this.unsetAuth(k(this.config))
394
411
  );
395
412
  }
396
413
  getPublicToken() {
397
- return this.config.token || this.getAuth(b(this.config));
414
+ return this.config.token || this.getAuth(w(this.config));
398
415
  }
399
416
  getEcToken() {
400
- return this.config.token || this.getAuth(A(this.config));
417
+ return this.config.token || this.getAuth(k(this.config));
401
418
  }
402
419
  hasPublicToken() {
403
420
  return !!this.getPublicToken();
@@ -415,46 +432,107 @@ class p {
415
432
  return;
416
433
  }
417
434
  }
435
+ /**
436
+ * Sets the given model to use
437
+ * @param {string} model name of the model
438
+ * @returns Sdk
439
+ */
440
+ model(t) {
441
+ return this.set({ model: t });
442
+ }
443
+ /**
444
+ * Sets the token to use in requests
445
+ * @param {string} token
446
+ * @returns Sdk
447
+ */
448
+ token(t) {
449
+ return this.set({ token: t });
450
+ }
451
+ /**
452
+ * Sets the short ID of the datamanager to use
453
+ * @param {string} dmShortID
454
+ * @returns Sdk
455
+ */
456
+ dmShortID(t) {
457
+ return this.set({ dmShortID: t });
458
+ }
459
+ /**
460
+ * Sets the short ID of the datamanager to use. Alias for `dmShortID`
461
+ * @param {string} dmShortID
462
+ * @returns Sdk
463
+ */
464
+ dm(t) {
465
+ return this.dmShortID(t);
466
+ }
467
+ /**
468
+ * Sets the id of the entry to use
469
+ * @param {string} entryID
470
+ * @returns Sdk
471
+ */
472
+ entryID(t) {
473
+ return this.set({ entryID: t });
474
+ }
475
+ /**
476
+ * Sets the id of the entry to use. Alias for `entryID`
477
+ * @param {string} entryID
478
+ * @returns Sdk
479
+ */
480
+ entry(t) {
481
+ return this.entryID(t);
482
+ }
483
+ /**
484
+ * Sets the name of the asset group to use.
485
+ * @param {string} assetGroup name of the asset group
486
+ * @returns Sdk
487
+ */
488
+ assetGroup(t) {
489
+ return this.set({ assetGroup: t });
490
+ }
491
+ /**
492
+ * Sets the name of the asset group to use. Alias for `assetGroup`
493
+ * @param {string} assetGroup name of the asset group
494
+ * @returns Sdk
495
+ */
496
+ assetgroup(t) {
497
+ return this.assetGroup(t);
498
+ }
499
+ /**
500
+ * Sets the id of the asset to use
501
+ * @param {string} assetID
502
+ * @returns Sdk
503
+ */
504
+ assetID(t) {
505
+ return this.set({ assetID: t });
506
+ }
507
+ /**
508
+ * Sets the id of the asset to use. Alias for `assetID`
509
+ * @param {string} assetID
510
+ * @returns Sdk
511
+ */
512
+ asset(t) {
513
+ return this.assetID(t);
514
+ }
418
515
  }
419
- const $ = (...n) => {
420
- const [t] = n;
421
- n.forEach((e) => {
422
- p.prototype[e] = function(s) {
423
- return this.set({ [t]: s });
424
- };
425
- });
426
- }, T = (n, t) => {
427
- p.prototype[n] = p.prototype[t];
428
- };
429
- $("dmShortID", "dm", "dmshortid");
430
- $("model");
431
- $("token");
432
- $("entryID", "entry");
433
- $("assetGroup");
434
- $("assetID", "asset");
435
- T("assetgroup", "assetGroup");
436
- T("entryList", "entries");
437
- T("assetList", "assets");
438
- const at = (n) => new p({ env: n });
516
+ const it = (n) => new b({ env: n });
439
517
  export {
440
- ct as act,
518
+ ot as act,
441
519
  y as apiURL,
442
- V as assetList,
443
- W as createAsset,
444
- I as createEntry,
445
- H as deleteEntry,
446
- M as editEntry,
447
- F as entryList,
448
- h as expect,
520
+ H as assetList,
521
+ Q as createAsset,
522
+ U as createEntry,
523
+ G as deleteEntry,
524
+ F as editEntry,
525
+ J as entryList,
526
+ l as expect,
449
527
  g as fetcher,
450
- Q as getAsset,
451
- U as getEcAuthKey,
452
- G as getEntry,
453
- N as getPublicAuthKey,
454
- z as loginEc,
455
- R as loginPublic,
456
- J as logoutEc,
457
- D as logoutPublic,
458
- w as query,
459
- at as sdk
528
+ M as getAsset,
529
+ I as getEcAuthKey,
530
+ N as getEntry,
531
+ z as getPublicAuthKey,
532
+ q as loginEc,
533
+ C as loginPublic,
534
+ R as logoutEc,
535
+ x as logoutPublic,
536
+ E as query,
537
+ it as sdk
460
538
  };
@@ -0,0 +1,4 @@
1
+ export * from "./auth.mjs";
2
+ export * from "./entries.mjs";
3
+ export * from "./assets.mjs";
4
+ //# sourceMappingURL=actions.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.mts","sourceRoot":"","sources":["../../src/lib/actions.mjs"],"names":[],"mappings":""}
@@ -0,0 +1,114 @@
1
+ export function act(config: any): any;
2
+ export * from "./util.mjs";
3
+ export function sdk(env: any): Sdk;
4
+ declare class Sdk {
5
+ constructor(config: any);
6
+ config: any;
7
+ set(obj: any): Sdk;
8
+ handle(handlers: any): Promise<any>;
9
+ entries(options: any): Promise<{
10
+ count: any;
11
+ total: any;
12
+ items: any;
13
+ }>;
14
+ entryList(options: any): Promise<{
15
+ count: any;
16
+ total: any;
17
+ items: any;
18
+ }>;
19
+ assets(options: any): Promise<{
20
+ count: any;
21
+ total: any;
22
+ items: any;
23
+ }>;
24
+ assetList(options: any): Promise<{
25
+ count: any;
26
+ total: any;
27
+ items: any;
28
+ }>;
29
+ createAsset({ file, name }?: {
30
+ file: any;
31
+ name: any;
32
+ }): Promise<any>;
33
+ get(): Promise<any>;
34
+ del(): Promise<any>;
35
+ createEntry(value: any): Promise<any>;
36
+ editEntry(value: any): Promise<any>;
37
+ create(value: any): Promise<any>;
38
+ edit(value: any): Promise<any>;
39
+ authAdapter(authAdapter: any): Sdk;
40
+ setAuth(key: any): (auth: any) => any;
41
+ unsetAuth(key: any): (auth: any) => any;
42
+ getAuth(key: any): any;
43
+ loginEc(config: any): Promise<any>;
44
+ loginPublic(config: any): Promise<any>;
45
+ logoutPublic(): Promise<any>;
46
+ logoutEc(): Promise<any>;
47
+ getPublicToken(): any;
48
+ getEcToken(): any;
49
+ hasPublicToken(): boolean;
50
+ hasEcToken(): boolean;
51
+ hasAnyToken(): boolean;
52
+ getBestToken(): any;
53
+ /**
54
+ * Sets the given model to use
55
+ * @param {string} model name of the model
56
+ * @returns Sdk
57
+ */
58
+ model(model: string): Sdk;
59
+ /**
60
+ * Sets the token to use in requests
61
+ * @param {string} token
62
+ * @returns Sdk
63
+ */
64
+ token(token: string): Sdk;
65
+ /**
66
+ * Sets the short ID of the datamanager to use
67
+ * @param {string} dmShortID
68
+ * @returns Sdk
69
+ */
70
+ dmShortID(dmShortID: string): Sdk;
71
+ /**
72
+ * Sets the short ID of the datamanager to use. Alias for `dmShortID`
73
+ * @param {string} dmShortID
74
+ * @returns Sdk
75
+ */
76
+ dm(dmShortID: string): Sdk;
77
+ /**
78
+ * Sets the id of the entry to use
79
+ * @param {string} entryID
80
+ * @returns Sdk
81
+ */
82
+ entryID(entryID: string): Sdk;
83
+ /**
84
+ * Sets the id of the entry to use. Alias for `entryID`
85
+ * @param {string} entryID
86
+ * @returns Sdk
87
+ */
88
+ entry(entryID: string): Sdk;
89
+ /**
90
+ * Sets the name of the asset group to use.
91
+ * @param {string} assetGroup name of the asset group
92
+ * @returns Sdk
93
+ */
94
+ assetGroup(assetGroup: string): Sdk;
95
+ /**
96
+ * Sets the name of the asset group to use. Alias for `assetGroup`
97
+ * @param {string} assetGroup name of the asset group
98
+ * @returns Sdk
99
+ */
100
+ assetgroup(assetGroup: string): Sdk;
101
+ /**
102
+ * Sets the id of the asset to use
103
+ * @param {string} assetID
104
+ * @returns Sdk
105
+ */
106
+ assetID(assetID: string): Sdk;
107
+ /**
108
+ * Sets the id of the asset to use. Alias for `assetID`
109
+ * @param {string} assetID
110
+ * @returns Sdk
111
+ */
112
+ asset(assetID: string): Sdk;
113
+ }
114
+ //# sourceMappingURL=api.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAqBA,sCAWC;;AAyPM,mCAAqC;AAvP5C;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED,oCAWC;IAGD;;;;OAGC;IACD;;;;OAEC;IAED;;;;OAGC;IACD;;;;OAEC;IAED;;;qBAGC;IAED,oBAKC;IAED,oBAIC;IAED,sCAEC;IACD,oCAEC;IAED,iCAKC;IAED,+BAKC;IAID,mCAGC;IAED,sCASC;IACD,wCAUC;IACD,uBAMC;IAED,mCAIC;IACD,uCAKC;IAED,6BAMC;IAED,yBAMC;IAED,sBAEC;IACD,kBAEC;IACD,0BAEC;IACD,sBAEC;IACD,uBAEC;IACD,oBAMC;IACD;;;;OAIG;IACH,aAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,aAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,qBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,cAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,iBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,eAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,iBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,eAHW,MAAM,OAKhB;CACF"}
@@ -0,0 +1,21 @@
1
+ export function getAsset({ env, dmShortID, assetGroup, assetID, token }: {
2
+ env: any;
3
+ dmShortID: any;
4
+ assetGroup: any;
5
+ assetID: any;
6
+ token: any;
7
+ }): Promise<any>;
8
+ export function assetList(config: any): Promise<{
9
+ count: any;
10
+ total: any;
11
+ items: any;
12
+ }>;
13
+ export function createAsset({ env, dmShortID, assetGroup, token, file, name, }: {
14
+ env: any;
15
+ dmShortID: any;
16
+ assetGroup: any;
17
+ token: any;
18
+ file: any;
19
+ name: any;
20
+ }): Promise<any>;
21
+ //# sourceMappingURL=assets.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAUC;AAED;;;;;;;iBAqBC"}
@@ -0,0 +1,11 @@
1
+ export function loginPublic(config: any): Promise<any>;
2
+ export function loginEc(config: any): Promise<any>;
3
+ export function logoutPublic(config: any): Promise<any>;
4
+ export function logoutEc(config: any): Promise<any>;
5
+ export function getPublicAuthKey({ dmShortID }: {
6
+ dmShortID: any;
7
+ }): any;
8
+ export function getEcAuthKey({ env }: {
9
+ env: any;
10
+ }): any;
11
+ //# sourceMappingURL=auth.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["../../src/lib/auth.mjs"],"names":[],"mappings":"AAOA,uDAiBC;AAED,mDAgBC;AAED,wDAeC;AAED,oDAeC;AAED;;QAGC;AACD;;QAGC"}
@@ -0,0 +1,35 @@
1
+ export function entryList(config: any): Promise<{
2
+ count: any;
3
+ total: any;
4
+ items: any;
5
+ }>;
6
+ export function getEntry({ env, dmShortID, model, entryID, token }: {
7
+ env: any;
8
+ dmShortID: any;
9
+ model: any;
10
+ entryID: any;
11
+ token: any;
12
+ }): Promise<any>;
13
+ export function createEntry({ env, dmShortID, model, value, token }: {
14
+ env: any;
15
+ dmShortID: any;
16
+ model: any;
17
+ value: any;
18
+ token: any;
19
+ }): Promise<any>;
20
+ export function editEntry({ env, dmShortID, model, entryID, value, token, }: {
21
+ env: any;
22
+ dmShortID: any;
23
+ model: any;
24
+ entryID: any;
25
+ value: any;
26
+ token: any;
27
+ }): Promise<any>;
28
+ export function deleteEntry({ env, dmShortID, model, entryID, token }: {
29
+ env: any;
30
+ dmShortID: any;
31
+ model: any;
32
+ entryID: any;
33
+ token: any;
34
+ }): Promise<any>;
35
+ //# sourceMappingURL=entries.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.d.mts","sourceRoot":"","sources":["../../src/lib/entries.mjs"],"names":[],"mappings":"AAEA;;;;GAWC;AAED;;;;;;iBAKC;AAED;;;;;;iBAiBC;AAED;;;;;;;iBAuBC;AAED;;;;;;iBAeC"}
@@ -0,0 +1,5 @@
1
+ export function fetcher(url: any, config?: {}, options?: {}): Promise<any>;
2
+ export function apiURL(route: any, env?: string): any;
3
+ export function query(params: any, sort?: boolean): any;
4
+ export function expect(obj: any): void;
5
+ //# sourceMappingURL=util.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAiBC;AAOD,sDAQC;AAED,wDAKC;AAED,uCAMC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=storage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.mts","sourceRoot":"","sources":["../src/storage.mjs"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {
@@ -24,10 +24,11 @@
24
24
  "nanostores": "^0.9.3"
25
25
  },
26
26
  "devDependencies": {
27
+ "typescript": "^5.3.3",
27
28
  "vite": "^4.4.9"
28
29
  },
29
30
  "scripts": {
30
- "build": "vite build"
31
+ "build": "vite build && tsc"
31
32
  },
32
33
  "module": "dist/index.mjs"
33
34
  }
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ // Change this to match your project
3
+ "include": ["src/**/*"],
4
+ "compilerOptions": {
5
+ // Tells TypeScript to read JS files, as
6
+ // normally they are ignored as source files
7
+ "allowJs": true,
8
+ // Generate d.ts files
9
+ "declaration": true,
10
+ // This compiler run should
11
+ // only output d.ts files
12
+ "emitDeclarationOnly": true,
13
+ // Types should go into this directory.
14
+ // Removing this would place the .d.ts files
15
+ // next to the .js files
16
+ "outDir": "dist",
17
+ // go to js file when using IDE functions like
18
+ // "Go to Definition" in VSCode
19
+ "declarationMap": true
20
+ }
21
+ }