ec.fdk 0.2.9 → 0.2.11

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 M=Object.defineProperty,v=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var G=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,c=(n,t)=>{for(var e in t||(t={}))G.call(t,e)&&T(n,e,t[e]);if(b)for(var e of b(t))H.call(t,e)&&T(n,e,t[e]);return n},d=(n,t)=>v(n,F(t));var r=(n,t,e)=>new Promise((s,o)=>{var a=u=>{try{g(e.next(u))}catch(f){o(f)}},i=u=>{try{g(e.throw(u))}catch(f){o(f)}},g=u=>u.done?s(u.value):Promise.resolve(u.value).then(a,i);g((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(s){return r(this,arguments,function*(n,t={},e={}){const{token:o,rawRes:a}=t;o&&(e.headers=d(c({},e.headers||{}),{Authorization:`Bearer ${o}`}));const i=yield fetch(n,e);if(!i.ok)throw new Error(i.statusText);return a?i:yield i.json()})}const P={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function y(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 h(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const m={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function O(n){return r(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;h({env:t,dmShortID:e,email:s,password:o});const a=y(`api/${e}/_auth/login?clientID=rest`,t);return yield l(a,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function j(n){return r(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const o=`${m[t]}auth/login?clientID=rest`;return yield l(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function _(n){return r(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const o=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield l(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function L(n){return r(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${m[t]}auth/logout?clientID=rest`;return yield l(s,{rawRes:!0,token:e},{method:"POST"})})}function S({dmShortID:n}){return h({dmShortID:n}),n}function B({env:n}){return h({env:n}),n}function K(n){return r(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 a=p(o),i=y(`api/${e}/${s}?${a}`,t),{count:g,total:u,_embedded:f}=yield l(i,n),E=f?f[`${e}:${s}`]:[];return{count:g,total:u,items:E}})}function q({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const a=p({_id:s}),i=y(`api/${t}/${e}?${a}`,n);return l(i,{dmShortID:t,token:o})}function C(a){return r(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 i=y(`api/${t}/${e}`,n);return console.log("url",i),yield l(i,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function R(i){return r(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:a}){h({env:n,dmShortID:t,model:e,entryID:s,value:o});const g=y(`api/${t}/${e}?_id=${s}`,n);return yield l(g,{token:a},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function x(a){return r(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const i=y(`api/${t}/${e}?_id=${s}`,n);yield l(i,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function z(a){return r(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=p({assetID:s}),g=y(`a/${t}/${e}?${i}`,n);return(yield l(g,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function J(n){return r(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:o,options:a={}}=n;h({env:t,dmShortID:e,assetGroup:s}),a=c({size:50,page:1,_list:!0},a);const i=p(a),g=y(`a/${e}/${s}?${i}`,t),{count:u,total:f,_embedded:E}=yield l(g,{dmShortID:e,token:o}),U=E?E["ec:dm-asset"]:[];return{count:u,total:f,items:U}})}function N(i){return r(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:a}){h({env:n,dmShortID:t,assetGroup:e,file:o});const g=y(`a/${t}/${e}`,n),u=new FormData;return u.append("file",o,a),(yield l(g,{token:s},{method:"POST",body:u}))._embedded["ec:dm-asset"]})}const $=Object.freeze(Object.defineProperty({__proto__:null,assetList:J,createAsset:N,createEntry:C,deleteEntry:x,editEntry:R,entryList:K,getAsset:z,getEcAuthKey:B,getEntry:q,getPublicAuthKey:S,loginEc:j,loginPublic:O,logoutEc:L,logoutPublic:_},Symbol.toStringTag,{value:"Module"})),{entryList:Q,getEntry:V,getAsset:W,assetList:X,createAsset:Y,createEntry:Z,editEntry:D,deleteEntry:I,loginPublic:tt,loginEc:et,logoutEc:nt,logoutPublic:st,getEcAuthKey:w,getPublicAuthKey:A}=$;function ot(n){const{action:t}=n;if(h({action:t}),!$[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys($).join(", ")}`);return $[t](n)}class k{constructor(t){this.config=t}set(t){return new k(c(c({},this.config),t))}entries(){return r(this,arguments,function*(t={}){const e=yield this.getBestToken();return Q(d(c({},this.config),{options:t,token:e}))})}entryList(t){return r(this,null,function*(){return this.entries(t)})}getEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return V(d(c({},this.config),{entryID:t,token:e}))})}assets(t){return r(this,null,function*(){const e=yield this.getBestToken();return X(d(c({},this.config),{options:t,token:e}))})}assetList(t){return r(this,null,function*(){return this.assets(t)})}createAsset(){return r(this,arguments,function*({file:t,name:e}={}){const s=yield this.getBestToken();return Y(d(c({},this.config),{file:t,name:e,token:s}))})}getAsset(t){return r(this,null,function*(){const e=yield this.getBestToken();return W(d(c({},this.config),{assetID:t,token:e}))})}createEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return Z(d(c({},this.config),{token:e,value:t}))})}editEntry(t,e){return r(this,null,function*(){const s=yield this.getBestToken();return D(d(c({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return I(d(c({},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 et(c(c({},this.config),t)).then(this.setAuth(w(this.config)))}loginPublic(t){return tt(c(c({},this.config),t)).then(this.setAuth(A(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(d(c({},this.config),{token:t})).then(this.unsetAuth(A(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(d(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}}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)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}}const rt=n=>new k({env:n});exports.Sdk=k;exports.act=ot;exports.apiURL=y;exports.assetList=J;exports.createAsset=N;exports.createEntry=C;exports.deleteEntry=x;exports.editEntry=R;exports.entryList=K;exports.expect=h;exports.fetcher=l;exports.getAsset=z;exports.getEcAuthKey=B;exports.getEntry=q;exports.getPublicAuthKey=S;exports.loginEc=j;exports.loginPublic=O;exports.logoutEc=L;exports.logoutPublic=_;exports.query=p;exports.sdk=rt;
1
+ "use strict";var M=Object.defineProperty,v=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var P=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))G.call(t,e)&&P(n,e,t[e]);if(T)for(var e of T(t))H.call(t,e)&&P(n,e,t[e]);return n},d=(n,t)=>v(n,F(t));var r=(n,t,e)=>new Promise((s,o)=>{var a=u=>{try{l(e.next(u))}catch(f){o(f)}},i=u=>{try{l(e.throw(u))}catch(f){o(f)}},l=u=>u.done?s(u.value):Promise.resolve(u.value).then(a,i);l((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return r(this,arguments,function*(n,t={},e={}){const{token:o,rawRes:a}=t;o&&(e.headers=d(c({},e.headers||{}),{Authorization:`Bearer ${o}`}));const i=yield fetch(n,e);if(!i.ok)throw new Error(i.statusText);return a?i:yield i.json()})}const m={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function y(n,t="stage"){const e=m[t];if(!e)throw new Error(`env "${t}" not found. Try one of ${Object.keys(m).join(", ")}`);return e+n}function $(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 O={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function j(n){return r(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;h({env:t,dmShortID:e,email:s,password:o});const a=y(`api/${e}/_auth/login?clientID=rest`,t);return yield g(a,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function _(n){return r(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const o=`${O[t]}auth/login?clientID=rest`;return yield g(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function L(n){return r(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const o=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function S(n){return r(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${O[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function B({dmShortID:n}){return h({dmShortID:n}),n}function K({env:n}){return h({env:n}),n}function q(n){return r(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 a=$(o),i=y(`api/${e}/${s}?${a}`,t),{count:l,total:u,_embedded:f}=yield g(i,n),p=f?f[`${e}:${s}`]:[];return{count:l,total:u,items:p}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const a=$({_id:s}),i=y(`api/${t}/${e}?${a}`,n);return g(i,{dmShortID:t,token:o})}function R(a){return r(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 i=y(`api/${t}/${e}`,n);return console.log("url",i),yield g(i,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function x(i){return r(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:a}){h({env:n,dmShortID:t,model:e,entryID:s,value:o});const l=y(`api/${t}/${e}?_id=${s}`,n);return yield g(l,{token:a},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function z(a){return r(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const i=y(`api/${t}/${e}?_id=${s}`,n);yield g(i,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function J(a){return r(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=$({assetID:s}),l=y(`a/${t}/${e}?${i}`,n);return(yield g(l,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function N(n){return r(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:o,options:a={}}=n;h({env:t,dmShortID:e,assetGroup:s}),a=c({size:50,page:1,_list:!0},a);const i=$(a),l=y(`a/${e}/${s}?${i}`,t),{count:u,total:f,_embedded:p}=yield g(l,{dmShortID:e,token:o}),b=p?p["ec:dm-asset"]:[];return{count:u,total:f,items:b}})}function U(l){return r(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:a,options:i}){h({env:n,dmShortID:t,assetGroup:e,file:o});const u=$(i||{}),f=y(`a/${t}/${e}${u?`?${u}`:""}`,n),p=new FormData;return p.append("file",o,a),(yield g(f,{token:s},{method:"POST",body:p}))._embedded["ec:dm-asset"]})}const E=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:U,createEntry:R,deleteEntry:z,editEntry:x,entryList:q,getAsset:J,getEcAuthKey:K,getEntry:C,getPublicAuthKey:B,loginEc:_,loginPublic:j,logoutEc:S,logoutPublic:L},Symbol.toStringTag,{value:"Module"})),{entryList:Q,getEntry:V,getAsset:W,assetList:X,createAsset:Y,createEntry:Z,editEntry:D,deleteEntry:I,loginPublic:tt,loginEc:et,logoutEc:nt,logoutPublic:st,getEcAuthKey:w,getPublicAuthKey:A}=E;function ot(n){const{action:t}=n;if(h({action:t}),!E[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(E).join(", ")}`);return E[t](n)}class k{constructor(t){this.config=t}set(t){return new k(c(c({},this.config),t))}entries(){return r(this,arguments,function*(t={}){const e=yield this.getBestToken();return Q(d(c({},this.config),{options:t,token:e}))})}entryList(t){return r(this,null,function*(){return this.entries(t)})}getEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return V(d(c({},this.config),{entryID:t,token:e}))})}assets(t){return r(this,null,function*(){const e=yield this.getBestToken();return X(d(c({},this.config),{options:t,token:e}))})}assetList(t){return r(this,null,function*(){return this.assets(t)})}createAsset(){return r(this,arguments,function*({file:t,name:e}={}){const s=yield this.getBestToken();return Y(d(c({},this.config),{file:t,name:e,token:s}))})}getAsset(t){return r(this,null,function*(){const e=yield this.getBestToken();return W(d(c({},this.config),{assetID:t,token:e}))})}createEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return Z(d(c({},this.config),{token:e,value:t}))})}editEntry(t,e){return r(this,null,function*(){const s=yield this.getBestToken();return D(d(c({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return I(d(c({},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 et(c(c({},this.config),t)).then(this.setAuth(w(this.config)))}loginPublic(t){return tt(c(c({},this.config),t)).then(this.setAuth(A(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(d(c({},this.config),{token:t})).then(this.unsetAuth(A(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(d(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}}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)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}}const rt=n=>new k({env:n});exports.Sdk=k;exports.act=ot;exports.apiURL=y;exports.assetList=N;exports.createAsset=U;exports.createEntry=R;exports.deleteEntry=z;exports.editEntry=x;exports.entryList=q;exports.expect=h;exports.fetcher=g;exports.getAsset=J;exports.getEcAuthKey=K;exports.getEntry=C;exports.getPublicAuthKey=B;exports.loginEc=_;exports.loginPublic=j;exports.logoutEc=S;exports.logoutPublic=L;exports.query=$;exports.sdk=rt;
package/dist/index.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  var j = Object.defineProperty, _ = Object.defineProperties;
2
2
  var L = Object.getOwnPropertyDescriptors;
3
- var b = Object.getOwnPropertySymbols;
3
+ var T = Object.getOwnPropertySymbols;
4
4
  var B = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
5
- var T = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
5
+ var P = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
6
6
  for (var e in t || (t = {}))
7
- B.call(t, e) && T(n, e, t[e]);
8
- if (b)
9
- for (var e of b(t))
10
- K.call(t, e) && T(n, e, t[e]);
7
+ B.call(t, e) && P(n, e, t[e]);
8
+ if (T)
9
+ for (var e of T(t))
10
+ K.call(t, e) && P(n, e, t[e]);
11
11
  return n;
12
12
  }, l = (n, t) => _(n, L(t));
13
13
  var r = (n, t, e) => new Promise((s, o) => {
14
14
  var a = (u) => {
15
15
  try {
16
16
  g(e.next(u));
17
- } catch (f) {
18
- o(f);
17
+ } catch (y) {
18
+ o(y);
19
19
  }
20
20
  }, i = (u) => {
21
21
  try {
22
22
  g(e.throw(u));
23
- } catch (f) {
24
- o(f);
23
+ } catch (y) {
24
+ o(y);
25
25
  }
26
26
  }, g = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(a, i);
27
27
  g((e = e.apply(n, t)).next());
@@ -38,15 +38,15 @@ function d(s) {
38
38
  return a ? i : yield i.json();
39
39
  });
40
40
  }
41
- const P = {
41
+ const m = {
42
42
  live: "https://datamanager.entrecode.de/",
43
43
  stage: "https://datamanager.cachena.entrecode.de/"
44
44
  };
45
- function y(n, t = "stage") {
46
- const e = P[t];
45
+ function f(n, t = "stage") {
46
+ const e = m[t];
47
47
  if (!e)
48
48
  throw new Error(
49
- `env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`
49
+ `env "${t}" not found. Try one of ${Object.keys(m).join(", ")}`
50
50
  );
51
51
  return e + n;
52
52
  }
@@ -59,7 +59,7 @@ function h(n) {
59
59
  throw new Error(`expected ${t} to be set!`);
60
60
  });
61
61
  }
62
- const m = {
62
+ const O = {
63
63
  stage: "https://accounts.cachena.entrecode.de/",
64
64
  live: "https://accounts.entrecode.de/"
65
65
  };
@@ -67,7 +67,7 @@ function S(n) {
67
67
  return r(this, null, function* () {
68
68
  let { env: t, dmShortID: e, email: s, password: o } = n;
69
69
  h({ env: t, dmShortID: e, email: s, password: o });
70
- const a = y(`api/${e}/_auth/login?clientID=rest`, t);
70
+ const a = f(`api/${e}/_auth/login?clientID=rest`, t);
71
71
  return yield d(
72
72
  a,
73
73
  {},
@@ -81,11 +81,11 @@ function S(n) {
81
81
  );
82
82
  });
83
83
  }
84
- function C(n) {
84
+ function q(n) {
85
85
  return r(this, null, function* () {
86
86
  let { env: t, email: e, password: s } = n;
87
87
  h({ env: t, email: e, password: s });
88
- const o = `${m[t]}auth/login?clientID=rest`;
88
+ const o = `${O[t]}auth/login?clientID=rest`;
89
89
  return yield d(
90
90
  o,
91
91
  {},
@@ -99,11 +99,11 @@ function C(n) {
99
99
  );
100
100
  });
101
101
  }
102
- function q(n) {
102
+ function C(n) {
103
103
  return r(this, null, function* () {
104
104
  let { dmShortID: t, env: e, token: s } = n;
105
105
  h({ dmShortID: t, env: e, token: s });
106
- const o = y(
106
+ const o = f(
107
107
  `api/${t}/_auth/logout?clientID=rest&token=${s}`,
108
108
  e
109
109
  );
@@ -120,7 +120,7 @@ function x(n) {
120
120
  return r(this, null, function* () {
121
121
  let { env: t, token: e } = n;
122
122
  h({ env: t, token: e });
123
- const s = `${m[t]}auth/logout?clientID=rest`;
123
+ const s = `${O[t]}auth/logout?clientID=rest`;
124
124
  return yield d(
125
125
  s,
126
126
  {
@@ -143,19 +143,19 @@ function J(n) {
143
143
  return r(this, null, function* () {
144
144
  let { env: t, dmShortID: e, model: s, options: o = {} } = n;
145
145
  h({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
146
- const a = $(o), i = y(`api/${e}/${s}?${a}`, t), { count: g, total: u, _embedded: f } = yield d(i, n), p = f ? f[`${e}:${s}`] : [];
146
+ const a = $(o), i = f(`api/${e}/${s}?${a}`, t), { count: g, total: u, _embedded: y } = yield d(i, n), p = y ? y[`${e}:${s}`] : [];
147
147
  return { count: g, total: u, items: p };
148
148
  });
149
149
  }
150
150
  function N({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
151
151
  h({ env: n, dmShortID: t, model: e, entryID: s });
152
- const a = $({ _id: s }), i = y(`api/${t}/${e}?${a}`, n);
152
+ const a = $({ _id: s }), i = f(`api/${t}/${e}?${a}`, n);
153
153
  return d(i, { dmShortID: t, token: o });
154
154
  }
155
155
  function U(a) {
156
156
  return r(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: o }) {
157
157
  h({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
158
- const i = y(`api/${t}/${e}`, n);
158
+ const i = f(`api/${t}/${e}`, n);
159
159
  return console.log("url", i), yield d(
160
160
  i,
161
161
  { env: n, dmShortID: t, token: o },
@@ -179,7 +179,7 @@ function F(i) {
179
179
  token: a
180
180
  }) {
181
181
  h({ env: n, dmShortID: t, model: e, entryID: s, value: o });
182
- const g = y(`api/${t}/${e}?_id=${s}`, n);
182
+ const g = f(`api/${t}/${e}?_id=${s}`, n);
183
183
  return yield d(
184
184
  g,
185
185
  { token: a },
@@ -196,7 +196,7 @@ function F(i) {
196
196
  function G(a) {
197
197
  return r(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
198
198
  h({ env: n, dmShortID: t, model: e, entryID: s });
199
- const i = y(`api/${t}/${e}?_id=${s}`, n);
199
+ const i = f(`api/${t}/${e}?_id=${s}`, n);
200
200
  yield d(
201
201
  i,
202
202
  { token: o, rawRes: !0 },
@@ -212,7 +212,7 @@ function G(a) {
212
212
  function M(a) {
213
213
  return r(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: o }) {
214
214
  h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
215
- const i = $({ assetID: s }), g = y(`a/${t}/${e}?${i}`, n);
215
+ const i = $({ assetID: s }), g = f(`a/${t}/${e}?${i}`, n);
216
216
  return (yield d(g, { dmShortID: t, token: o }))._embedded["ec:dm-asset"];
217
217
  });
218
218
  }
@@ -220,27 +220,28 @@ function v(n) {
220
220
  return r(this, null, function* () {
221
221
  let { env: t, dmShortID: e, assetGroup: s, token: o, options: a = {} } = n;
222
222
  h({ env: t, dmShortID: e, assetGroup: s }), a = c({ size: 50, page: 1, _list: !0 }, a);
223
- const i = $(a), g = y(`a/${e}/${s}?${i}`, t), { count: u, total: f, _embedded: p } = yield d(g, { dmShortID: e, token: o }), O = p ? p["ec:dm-asset"] : [];
224
- return { count: u, total: f, items: O };
223
+ const i = $(a), g = f(`a/${e}/${s}?${i}`, t), { count: u, total: y, _embedded: p } = yield d(g, { dmShortID: e, token: o }), b = p ? p["ec:dm-asset"] : [];
224
+ return { count: u, total: y, items: b };
225
225
  });
226
226
  }
227
- function H(i) {
227
+ function H(g) {
228
228
  return r(this, arguments, function* ({
229
229
  env: n,
230
230
  dmShortID: t,
231
231
  assetGroup: e,
232
232
  token: s,
233
233
  file: o,
234
- name: a
234
+ name: a,
235
+ options: i
235
236
  }) {
236
237
  h({ env: n, dmShortID: t, assetGroup: e, file: o });
237
- const g = y(`a/${t}/${e}`, n), u = new FormData();
238
- return u.append("file", o, a), (yield d(
239
- g,
238
+ const u = $(i || {}), y = f(`a/${t}/${e}${u ? `?${u}` : ""}`, n), p = new FormData();
239
+ return p.append("file", o, a), (yield d(
240
+ y,
240
241
  { token: s },
241
242
  {
242
243
  method: "POST",
243
- body: u
244
+ body: p
244
245
  }
245
246
  ))._embedded["ec:dm-asset"];
246
247
  });
@@ -257,10 +258,10 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
257
258
  getEcAuthKey: z,
258
259
  getEntry: N,
259
260
  getPublicAuthKey: R,
260
- loginEc: C,
261
+ loginEc: q,
261
262
  loginPublic: S,
262
263
  logoutEc: x,
263
- logoutPublic: q
264
+ logoutPublic: C
264
265
  }, Symbol.toStringTag, { value: "Module" })), {
265
266
  entryList: Q,
266
267
  getEntry: V,
@@ -361,7 +362,7 @@ class A {
361
362
  * Uploads an asset. Expects `dmShortID` / `assetGroup` / `file` to be set.
362
363
  * If the assetGroup is not public, you also need to provide a `token`.
363
364
  *
364
- * @param {{ file: File, name: string }} options options for entry list request.
365
+ * @param {{ file: File | Blob, name: string }} options options for entry list request.
365
366
  * @returns {Promise<AssetResource>}
366
367
  * @example
367
368
  * // browser example
@@ -568,7 +569,7 @@ const it = (n) => new A({ env: n });
568
569
  export {
569
570
  A as Sdk,
570
571
  rt as act,
571
- y as apiURL,
572
+ f as apiURL,
572
573
  v as assetList,
573
574
  H as createAsset,
574
575
  U as createEntry,
@@ -581,10 +582,10 @@ export {
581
582
  z as getEcAuthKey,
582
583
  N as getEntry,
583
584
  R as getPublicAuthKey,
584
- C as loginEc,
585
+ q as loginEc,
585
586
  S as loginPublic,
586
587
  x as logoutEc,
587
- q as logoutPublic,
588
+ C as logoutPublic,
588
589
  $ as query,
589
590
  it as sdk
590
591
  };
@@ -51,7 +51,7 @@ export class Sdk {
51
51
  * Uploads an asset. Expects `dmShortID` / `assetGroup` / `file` to be set.
52
52
  * If the assetGroup is not public, you also need to provide a `token`.
53
53
  *
54
- * @param {{ file: File, name: string }} options options for entry list request.
54
+ * @param {{ file: File | Blob, name: string }} options options for entry list request.
55
55
  * @returns {Promise<AssetResource>}
56
56
  * @example
57
57
  * // browser example
@@ -69,7 +69,7 @@ export class Sdk {
69
69
  * .createAsset({ file, name: "venndiagram.png" });
70
70
  */
71
71
  createAsset({ file, name }?: {
72
- file: File;
72
+ file: File | Blob;
73
73
  name: string;
74
74
  }): Promise<AssetResource>;
75
75
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAwBA,sCA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,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,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;CACF;AAEM,mCAAqC;;SAI9B,MAAM;UACN,MAAM;;;;aAMN,MAAM;aACN,IAAI;WACJ,MAAM,GAAG,CAAC;UACV,MAAM,MAAM,GAAG,GAAG,CAAC;WACnB,MAAM;UACN,MAAM;UACN,SAAS;;;;;;cAKT,IAAI;;;;cACJ,MAAM;;;;eACN,GAAG;;;;YACH,GAAG;;;;iBACH,MAAM;;;;sBACN,MAAM;;;;eACN,IAAI;;;;aACJ,IAAI;;;;cACJ,IAAI;;;;UACJ,GAAG;;;WAKH,MAAM;WACN,MAAM;WACN,aAAa,EAAE;;;WAKf,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
@@ -10,12 +10,13 @@ export function assetList(config: any): Promise<{
10
10
  total: any;
11
11
  items: any;
12
12
  }>;
13
- export function createAsset({ env, dmShortID, assetGroup, token, file, name, }: {
13
+ export function createAsset({ env, dmShortID, assetGroup, token, file, name, options, }: {
14
14
  env: any;
15
15
  dmShortID: any;
16
16
  assetGroup: any;
17
17
  token: any;
18
18
  file: any;
19
19
  name: any;
20
+ options: any;
20
21
  }): Promise<any>;
21
22
  //# sourceMappingURL=assets.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAUC;AAED;;;;;;;iBAqBC"}
1
+ {"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAUC;AAED;;;;;;;;iBAwBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {