ec.fdk 0.2.21 → 0.2.23

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/README.md CHANGED
@@ -73,6 +73,7 @@ Now what follows is the autogenerated doc from source:
73
73
  * [.dm(dmShortID)](#module_api.Sdk+dm) ⇒
74
74
  * [.assetGroup(assetGroup)](#module_api.Sdk+assetGroup) ⇒
75
75
  * [.assetgroup(assetGroup)](#module_api.Sdk+assetgroup) ⇒
76
+ * [.dmList([options])](#module_api.Sdk+dmList) ⇒ [<code>Promise.&lt;DatamanagerList&gt;</code>](#DatamanagerList)
76
77
 
77
78
  <a name="module_api.Sdk+entries"></a>
78
79
 
@@ -317,3 +318,24 @@ await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
317
318
  | --- | --- | --- |
318
319
  | assetGroup | <code>string</code> | <p>name of the asset group</p> |
319
320
 
321
+ <a name="module_api.Sdk+dmList"></a>
322
+
323
+ #### sdk.dmList([options]) ⇒ [<code>Promise.&lt;DatamanagerList&gt;</code>](#DatamanagerList)
324
+ <p>Loads datamanager list. Make sure to provide an ec.admin <code>token</code> intercept one.</p>
325
+
326
+ **Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
327
+
328
+ | Param | Type | Description |
329
+ | --- | --- | --- |
330
+ | [options] | <code>object</code> | <p>options for entry list request.</p> |
331
+
332
+ **Example**
333
+ ```js
334
+ // public model
335
+ const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
336
+ ```
337
+ **Example**
338
+ ```js
339
+ // non-public model
340
+ const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
341
+ ```
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var v=Object.defineProperty,F=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var P=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))H.call(t,e)&&P(n,e,t[e]);if(T)for(var e of T(t))Q.call(t,e)&&P(n,e,t[e]);return n},y=(n,t)=>F(n,G(t));var i=(n,t,e)=>new Promise((s,o)=>{var a=u=>{try{l(e.next(u))}catch(g){o(g)}},r=u=>{try{l(e.throw(u))}catch(g){o(g)}},l=u=>u.done?s(u.value):Promise.resolve(u.value).then(a,r);l((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function d(s){return i(this,arguments,function*(n,t={},e={}){var l;const{token:o,rawRes:a}=t;o&&(e.headers=y(c({},e.headers||{}),{Authorization:`Bearer ${o}`}));const r=yield fetch(n,e);if(!r.ok){if((l=r.headers.get("content-type"))!=null&&l.includes("application/json")){const u=yield r.json(),g=`${u.title}
2
- ${u.detail}
3
- ${u.verbose}`;throw new Error(g)}throw new Error(`unexpected fetch error: ${r.statusText}`)}return a?r:yield r.json()})}const m={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function f(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 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 j={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function O(n){return i(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;h({env:t,dmShortID:e,email:s,password:o});const a=f(`api/${e}/_auth/login?clientID=rest`,t);return yield d(a,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function _(n){return i(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const o=`${j[t]}auth/login?clientID=rest`;return yield d(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function L(n){return i(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const o=f(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield d(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function B(n){return i(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${j[t]}auth/logout?clientID=rest`;return yield d(s,{rawRes:!0,token:e},{method:"POST"})})}function S({dmShortID:n}){return h({dmShortID:n}),n}function K({env:n}){return h({env:n}),n}function R(n){return i(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=E(o),r=f(`api/${e}/${s}?${a}`,t),{count:l,total:u,_embedded:g}=yield d(r,n);let $=g?g[`${e}:${s}`]:[];return $=Array.isArray($)?$:[$],{count:l,total:u,items:$}})}function q({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const a=E({_id:s}),r=f(`api/${t}/${e}?${a}`,n);return d(r,{dmShortID:t,token:o})}function x(a){return i(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=f(`api/${t}/${e}`,n);return console.log("url",r),yield d(r,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function C(r){return i(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=f(`api/${t}/${e}?_id=${s}`,n);return yield d(l,{token:a},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function z(a){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const r=f(`api/${t}/${e}?_id=${s}`,n);yield d(r,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function J(a){return i(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}),l=f(`a/${t}/${e}?${r}`,n);return(yield d(l,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function N(n){return i(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 r=E(a),l=f(`a/${e}/${s}?${r}`,t),{count:u,total:g,_embedded:$}=yield d(l,{dmShortID:e,token:o});let p=$?$["ec:dm-asset"]:[];return p=Array.isArray(p)?p:[p],{count:u,total:g,items:p}})}function U(l){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:a,options:r}){h({env:n,dmShortID:t,assetGroup:e,file:o});const u=f(`a/${t}/${e}`,n),g=new FormData;return g.append("file",o,a),r&&Object.keys(r).forEach(p=>{g.append(p,r[p])}),(yield d(u,{token:s},{method:"POST",body:g}))._embedded["ec:dm-asset"]})}function M(a){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=f(`a/${t}/${e}/${s}`,n);return(yield d(r,{token:o,rawRes:!0},{method:"DELETE"}))._embedded["ec:dm-asset"]})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:U,createEntry:x,deleteAsset:M,deleteEntry:z,editEntry:C,entryList:R,getAsset:J,getEcAuthKey:K,getEntry:q,getPublicAuthKey:S,loginEc:_,loginPublic:O,logoutEc:B,logoutPublic:L},Symbol.toStringTag,{value:"Module"})),{entryList:V,getEntry:W,getAsset:X,assetList:Y,createAsset:Z,deleteAsset:D,createEntry:I,editEntry:tt,deleteEntry:et,loginPublic:nt,loginEc:st,logoutEc:ot,logoutPublic:rt,getEcAuthKey:w,getPublicAuthKey:b}=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 A{constructor(t){this.config=t}set(t){return new A(c(c({},this.config),t))}entries(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return V(y(c({},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 W(y(c({},this.config),{entryID:t,token:e}))})}assets(t){return i(this,null,function*(){const e=yield this.getBestToken();return Y(y(c({},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 o=yield this.getBestToken();return Z(y(c({},this.config),{file:t,name:e,options:s,token:o}))})}deleteAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return D(y(c({},this.config),{token:e,assetID:t}))})}getAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return X(y(c({},this.config),{assetID:t,token:e}))})}createEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return I(y(c({},this.config),{token:e,value:t}))})}editEntry(t,e){return i(this,null,function*(){const s=yield this.getBestToken();return tt(y(c({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return et(y(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 st(c(c({},this.config),t)).then(this.setAuth(w(this.config)))}loginPublic(t){return nt(c(c({},this.config),t)).then(this.setAuth(b(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),rt(y(c({},this.config),{token:t})).then(this.unsetAuth(b(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(b(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 ct=n=>new A({env:n});exports.Sdk=A;exports.act=it;exports.apiURL=f;exports.assetList=N;exports.createAsset=U;exports.createEntry=x;exports.deleteAsset=M;exports.deleteEntry=z;exports.editEntry=C;exports.entryList=R;exports.expect=h;exports.fetcher=d;exports.getAsset=J;exports.getEcAuthKey=K;exports.getEntry=q;exports.getPublicAuthKey=S;exports.loginEc=_;exports.loginPublic=O;exports.logoutEc=B;exports.logoutPublic=L;exports.query=E;exports.sdk=ct;
1
+ "use strict";var F=Object.defineProperty,G=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var m=(n,t,e)=>t in n?F(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,a=(n,t)=>{for(var e in t||(t={}))Q.call(t,e)&&m(n,e,t[e]);if(T)for(var e of T(t))V.call(t,e)&&m(n,e,t[e]);return n},y=(n,t)=>G(n,H(t));var i=(n,t,e)=>new Promise((s,o)=>{var u=c=>{try{h(e.next(c))}catch(d){o(d)}},r=c=>{try{h(e.throw(c))}catch(d){o(d)}},h=c=>c.done?s(c.value):Promise.resolve(c.value).then(u,r);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:o,rawRes:u}=t;o&&(e.headers=y(a({},e.headers||{}),{Authorization:`Bearer ${o}`}));const r=yield fetch(n,e);if(!r.ok){if((h=r.headers.get("content-type"))!=null&&h.includes("application/json")){const c=yield r.json(),d=`${c.title}
2
+ ${c.detail}
3
+ ${c.verbose}`;throw new Error(d)}throw new Error(`unexpected fetch error: ${r.statusText}`)}return u?r:yield r.json()})}const P={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function f(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 E(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 j={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function L(n){return i(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;l({env:t,dmShortID:e,email:s,password:o});const u=f(`api/${e}/_auth/login?clientID=rest`,t);return yield g(u,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function O(n){return i(this,null,function*(){let{env:t,email:e,password:s}=n;l({env:t,email:e,password:s});const o=`${j[t]}auth/login?clientID=rest`;return yield g(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function _(n){return i(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;l({dmShortID:t,env:e,token:s});const o=f(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function B(n){return i(this,null,function*(){let{env:t,token:e}=n;l({env:t,token:e});const s=`${j[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function S({dmShortID:n}){return l({dmShortID:n}),n}function K({env:n}){return l({env:n}),n}function q(n){return i(this,null,function*(){let{env:t,dmShortID:e,model:s,options:o={}}=n;l({env:t,dmShortID:e,model:s}),o=a({size:50,page:1,_list:!0},o);const u=E(o),r=f(`api/${e}/${s}?${u}`,t),{count:h,total:c,_embedded:d}=yield g(r,n);let $=d?d[`${e}:${s}`]:[];return $=Array.isArray($)?$:[$],{count:h,total:c,items:$}})}function R({env:n,dmShortID:t,model:e,entryID:s,token:o}){l({env:n,dmShortID:t,model:e,entryID:s});const u=E({_id:s}),r=f(`api/${t}/${e}?${u}`,n);return g(r,{dmShortID:t,token:o})}function x(u){return i(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:o}){l({env:n,dmShortID:t,model:e,value:s}),console.log("create entry",t,e,s);const r=f(`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 C(r){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:u}){l({env:n,dmShortID:t,model:e,entryID:s,value:o});const h=f(`api/${t}/${e}?_id=${s}`,n);return yield g(h,{token:u},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function z(u){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){l({env:n,dmShortID:t,model:e,entryID:s});const r=f(`api/${t}/${e}?_id=${s}`,n);yield g(r,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function J(u){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){l({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=E({assetID:s}),h=f(`a/${t}/${e}?${r}`,n);return(yield g(h,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function N(n){return i(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:o,options:u={}}=n;l({env:t,dmShortID:e,assetGroup:s}),u=a({size:50,page:1,_list:!0},u);const r=E(u),h=f(`a/${e}/${s}?${r}`,t),{count:c,total:d,_embedded:$}=yield g(h,{dmShortID:e,token:o});let p=$?$["ec:dm-asset"]:[];return p=Array.isArray(p)?p:[p],{count:c,total:d,items:p}})}function U(h){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:u,options:r}){l({env:n,dmShortID:t,assetGroup:e,file:o});const c=f(`a/${t}/${e}`,n),d=new FormData;return d.append("file",o,u),r&&Object.keys(r).forEach(p=>{d.append(p,r[p])}),(yield g(c,{token:s},{method:"POST",body:d}))._embedded["ec:dm-asset"]})}function v(u){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){l({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=f(`a/${t}/${e}/${s}`,n);yield g(r,{token:o,rawRes:!0},{method:"DELETE"})})}function M(n){return i(this,null,function*(){let{env:t,options:e={}}=n;l({env:t}),e=a({size:25,page:1,_list:!0},e);const s=E(e),o=f(`?${s}`,t),{count:u,total:r,_embedded:h}=yield g(o,n);let c=h?h["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:u,total:r,items:c}})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:U,createEntry:x,deleteAsset:v,deleteEntry:z,dmList:M,editEntry:C,entryList:q,getAsset:J,getEcAuthKey:K,getEntry:R,getPublicAuthKey:S,loginEc:O,loginPublic:L,logoutEc:B,logoutPublic:_},Symbol.toStringTag,{value:"Module"})),{entryList:W,getEntry:X,getAsset:Y,assetList:Z,createAsset:D,deleteAsset:I,createEntry:tt,editEntry:et,deleteEntry:nt,loginPublic:st,loginEc:ot,logoutEc:rt,logoutPublic:it,getEcAuthKey:w,getPublicAuthKey:b,dmList:ct}=k;function at(n){const{action:t}=n;if(l({action:t}),!k[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(k).join(", ")}`);return k[t](n)}class A{constructor(t){this.config=t}set(t){return new A(a(a({},this.config),t))}entries(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return W(y(a({},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 X(y(a({},this.config),{entryID:t,token:e}))})}assets(t){return i(this,null,function*(){const e=yield this.getBestToken();return Z(y(a({},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 o=yield this.getBestToken();return D(y(a({},this.config),{file:t,name:e,options:s,token:o}))})}deleteAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return I(y(a({},this.config),{token:e,assetID:t}))})}getAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return Y(y(a({},this.config),{assetID:t,token:e}))})}createEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return tt(y(a({},this.config),{token:e,value:t}))})}editEntry(t,e){return i(this,null,function*(){const s=yield this.getBestToken();return et(y(a({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return nt(y(a({},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 ot(a(a({},this.config),t)).then(this.setAuth(w(this.config)))}loginPublic(t){return st(a(a({},this.config),t)).then(this.setAuth(b(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),it(y(a({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),rt(y(a({},this.config),{token:t})).then(this.unsetAuth(w(this.config)))}getPublicToken(){return this.config.token||this.getAuth(b(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)}dmList(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return ct(y(a({},this.config),{options:t,token:e}))})}}const ut=n=>new A({env:n});exports.Sdk=A;exports.act=at;exports.apiURL=f;exports.assetList=N;exports.createAsset=U;exports.createEntry=x;exports.deleteAsset=v;exports.deleteEntry=z;exports.dmList=M;exports.editEntry=C;exports.entryList=q;exports.expect=l;exports.fetcher=g;exports.getAsset=J;exports.getEcAuthKey=K;exports.getEntry=R;exports.getPublicAuthKey=S;exports.loginEc=O;exports.loginPublic=L;exports.logoutEc=B;exports.logoutPublic=_;exports.query=E;exports.sdk=ut;
package/dist/index.mjs CHANGED
@@ -1,64 +1,64 @@
1
- var O = Object.defineProperty, _ = Object.defineProperties;
2
- var L = Object.getOwnPropertyDescriptors;
1
+ var L = Object.defineProperty, O = Object.defineProperties;
2
+ var _ = Object.getOwnPropertyDescriptors;
3
3
  var T = Object.getOwnPropertySymbols;
4
4
  var B = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
5
- var P = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
5
+ var m = (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
- B.call(t, e) && P(n, e, t[e]);
7
+ B.call(t, e) && m(n, e, t[e]);
8
8
  if (T)
9
9
  for (var e of T(t))
10
- K.call(t, e) && P(n, e, t[e]);
10
+ K.call(t, e) && m(n, e, t[e]);
11
11
  return n;
12
- }, d = (n, t) => _(n, L(t));
12
+ }, d = (n, t) => O(n, _(t));
13
13
  var i = (n, t, e) => new Promise((s, o) => {
14
- var a = (u) => {
14
+ var u = (c) => {
15
15
  try {
16
- h(e.next(u));
16
+ h(e.next(c));
17
17
  } catch (l) {
18
18
  o(l);
19
19
  }
20
- }, r = (u) => {
20
+ }, r = (c) => {
21
21
  try {
22
- h(e.throw(u));
22
+ h(e.throw(c));
23
23
  } catch (l) {
24
24
  o(l);
25
25
  }
26
- }, h = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(a, r);
26
+ }, h = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(u, r);
27
27
  h((e = e.apply(n, t)).next());
28
28
  });
29
29
  function y(s) {
30
30
  return i(this, arguments, function* (n, t = {}, e = {}) {
31
31
  var h;
32
- const { token: o, rawRes: a } = t;
33
- o && (e.headers = d(c({}, e.headers || {}), {
32
+ const { token: o, rawRes: u } = t;
33
+ o && (e.headers = d(a({}, e.headers || {}), {
34
34
  Authorization: `Bearer ${o}`
35
35
  }));
36
36
  const r = yield fetch(n, e);
37
37
  if (!r.ok) {
38
38
  if ((h = r.headers.get("content-type")) != null && h.includes("application/json")) {
39
- const u = yield r.json(), l = `${u.title}
40
- ${u.detail}
41
- ${u.verbose}`;
39
+ const c = yield r.json(), l = `${c.title}
40
+ ${c.detail}
41
+ ${c.verbose}`;
42
42
  throw new Error(l);
43
43
  }
44
44
  throw new Error(`unexpected fetch error: ${r.statusText}`);
45
45
  }
46
- return a ? r : yield r.json();
46
+ return u ? r : yield r.json();
47
47
  });
48
48
  }
49
- const m = {
49
+ const P = {
50
50
  live: "https://datamanager.entrecode.de/",
51
51
  stage: "https://datamanager.cachena.entrecode.de/"
52
52
  };
53
53
  function f(n, t = "stage") {
54
- const e = m[t];
54
+ const e = P[t];
55
55
  if (!e)
56
56
  throw new Error(
57
- `env "${t}" not found. Try one of ${Object.keys(m).join(", ")}`
57
+ `env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`
58
58
  );
59
59
  return e + n;
60
60
  }
61
- function A(n, t = !0) {
61
+ function E(n, t = !0) {
62
62
  return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
63
63
  }
64
64
  function g(n) {
@@ -75,9 +75,9 @@ function S(n) {
75
75
  return i(this, null, function* () {
76
76
  let { env: t, dmShortID: e, email: s, password: o } = n;
77
77
  g({ env: t, dmShortID: e, email: s, password: o });
78
- const a = f(`api/${e}/_auth/login?clientID=rest`, t);
78
+ const u = f(`api/${e}/_auth/login?clientID=rest`, t);
79
79
  return yield y(
80
- a,
80
+ u,
81
81
  {},
82
82
  {
83
83
  method: "POST",
@@ -89,7 +89,7 @@ function S(n) {
89
89
  );
90
90
  });
91
91
  }
92
- function x(n) {
92
+ function q(n) {
93
93
  return i(this, null, function* () {
94
94
  let { env: t, email: e, password: s } = n;
95
95
  g({ env: t, email: e, password: s });
@@ -107,7 +107,7 @@ function x(n) {
107
107
  );
108
108
  });
109
109
  }
110
- function C(n) {
110
+ function x(n) {
111
111
  return i(this, null, function* () {
112
112
  let { dmShortID: t, env: e, token: s } = n;
113
113
  g({ dmShortID: t, env: e, token: s });
@@ -124,7 +124,7 @@ function C(n) {
124
124
  );
125
125
  });
126
126
  }
127
- function R(n) {
127
+ function C(n) {
128
128
  return i(this, null, function* () {
129
129
  let { env: t, token: e } = n;
130
130
  g({ env: t, token: e });
@@ -141,7 +141,7 @@ function R(n) {
141
141
  );
142
142
  });
143
143
  }
144
- function q({ dmShortID: n }) {
144
+ function R({ dmShortID: n }) {
145
145
  return g({ dmShortID: n }), n;
146
146
  }
147
147
  function z({ env: n }) {
@@ -150,18 +150,18 @@ function z({ env: n }) {
150
150
  function J(n) {
151
151
  return i(this, null, function* () {
152
152
  let { env: t, dmShortID: e, model: s, options: o = {} } = n;
153
- g({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
154
- const a = A(o), r = f(`api/${e}/${s}?${a}`, t), { count: h, total: u, _embedded: l } = yield y(r, n);
153
+ g({ env: t, dmShortID: e, model: s }), o = a({ size: 50, page: 1, _list: !0 }, o);
154
+ const u = E(o), r = f(`api/${e}/${s}?${u}`, t), { count: h, total: c, _embedded: l } = yield y(r, n);
155
155
  let $ = l ? l[`${e}:${s}`] : [];
156
- return $ = Array.isArray($) ? $ : [$], { count: h, total: u, items: $ };
156
+ return $ = Array.isArray($) ? $ : [$], { count: h, total: c, items: $ };
157
157
  });
158
158
  }
159
159
  function N({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
160
160
  g({ env: n, dmShortID: t, model: e, entryID: s });
161
- const a = A({ _id: s }), r = f(`api/${t}/${e}?${a}`, n);
161
+ const u = E({ _id: s }), r = f(`api/${t}/${e}?${u}`, n);
162
162
  return y(r, { dmShortID: t, token: o });
163
163
  }
164
- function U(a) {
164
+ function U(u) {
165
165
  return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: o }) {
166
166
  g({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
167
167
  const r = f(`api/${t}/${e}`, n);
@@ -178,20 +178,20 @@ function U(a) {
178
178
  );
179
179
  });
180
180
  }
181
- function F(r) {
181
+ function v(r) {
182
182
  return i(this, arguments, function* ({
183
183
  env: n,
184
184
  dmShortID: t,
185
185
  model: e,
186
186
  entryID: s,
187
187
  value: o,
188
- token: a
188
+ token: u
189
189
  }) {
190
190
  g({ env: n, dmShortID: t, model: e, entryID: s, value: o });
191
191
  const h = f(`api/${t}/${e}?_id=${s}`, n);
192
192
  return yield y(
193
193
  h,
194
- { token: a },
194
+ { token: u },
195
195
  {
196
196
  method: "PUT",
197
197
  body: JSON.stringify(o),
@@ -202,7 +202,7 @@ function F(r) {
202
202
  );
203
203
  });
204
204
  }
205
- function M(a) {
205
+ function F(u) {
206
206
  return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
207
207
  g({ env: n, dmShortID: t, model: e, entryID: s });
208
208
  const r = f(`api/${t}/${e}?_id=${s}`, n);
@@ -218,20 +218,20 @@ function M(a) {
218
218
  );
219
219
  });
220
220
  }
221
- function v(a) {
221
+ function M(u) {
222
222
  return i(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: o }) {
223
223
  g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
224
- const r = A({ assetID: s }), h = f(`a/${t}/${e}?${r}`, n);
224
+ const r = E({ assetID: s }), h = f(`a/${t}/${e}?${r}`, n);
225
225
  return (yield y(h, { dmShortID: t, token: o }))._embedded["ec:dm-asset"];
226
226
  });
227
227
  }
228
228
  function G(n) {
229
229
  return i(this, null, function* () {
230
- let { env: t, dmShortID: e, assetGroup: s, token: o, options: a = {} } = n;
231
- g({ env: t, dmShortID: e, assetGroup: s }), a = c({ size: 50, page: 1, _list: !0 }, a);
232
- const r = A(a), h = f(`a/${e}/${s}?${r}`, t), { count: u, total: l, _embedded: $ } = yield y(h, { dmShortID: e, token: o });
230
+ let { env: t, dmShortID: e, assetGroup: s, token: o, options: u = {} } = n;
231
+ g({ env: t, dmShortID: e, assetGroup: s }), u = a({ size: 50, page: 1, _list: !0 }, u);
232
+ const r = E(u), h = f(`a/${e}/${s}?${r}`, t), { count: c, total: l, _embedded: $ } = yield y(h, { dmShortID: e, token: o });
233
233
  let p = $ ? $["ec:dm-asset"] : [];
234
- return p = Array.isArray(p) ? p : [p], { count: u, total: l, items: p };
234
+ return p = Array.isArray(p) ? p : [p], { count: c, total: l, items: p };
235
235
  });
236
236
  }
237
237
  function H(h) {
@@ -241,15 +241,15 @@ function H(h) {
241
241
  assetGroup: e,
242
242
  token: s,
243
243
  file: o,
244
- name: a,
244
+ name: u,
245
245
  options: r
246
246
  }) {
247
247
  g({ env: n, dmShortID: t, assetGroup: e, file: o });
248
- const u = f(`a/${t}/${e}`, n), l = new FormData();
249
- return l.append("file", o, a), r && Object.keys(r).forEach((p) => {
248
+ const c = f(`a/${t}/${e}`, n), l = new FormData();
249
+ return l.append("file", o, u), r && Object.keys(r).forEach((p) => {
250
250
  l.append(p, r[p]);
251
251
  }), (yield y(
252
- u,
252
+ c,
253
253
  { token: s },
254
254
  {
255
255
  method: "POST",
@@ -258,7 +258,7 @@ function H(h) {
258
258
  ))._embedded["ec:dm-asset"];
259
259
  });
260
260
  }
261
- function Q(a) {
261
+ function Q(u) {
262
262
  return i(this, arguments, function* ({
263
263
  env: n,
264
264
  dmShortID: t,
@@ -268,65 +268,76 @@ function Q(a) {
268
268
  }) {
269
269
  g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
270
270
  const r = f(`a/${t}/${e}/${s}`, n);
271
- return (yield y(
271
+ yield y(
272
272
  r,
273
273
  { token: o, rawRes: !0 },
274
274
  {
275
275
  method: "DELETE"
276
276
  }
277
- ))._embedded["ec:dm-asset"];
277
+ );
278
+ });
279
+ }
280
+ function V(n) {
281
+ return i(this, null, function* () {
282
+ let { env: t, options: e = {} } = n;
283
+ g({ env: t }), e = a({ size: 25, page: 1, _list: !0 }, e);
284
+ const s = E(e), o = f(`?${s}`, t), { count: u, total: r, _embedded: h } = yield y(o, n);
285
+ let c = h ? h["ec:datamanager"] : [];
286
+ return c = Array.isArray(c) ? c : [c], { count: u, total: r, items: c };
278
287
  });
279
288
  }
280
- const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
289
+ const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
281
290
  __proto__: null,
282
291
  assetList: G,
283
292
  createAsset: H,
284
293
  createEntry: U,
285
294
  deleteAsset: Q,
286
- deleteEntry: M,
287
- editEntry: F,
295
+ deleteEntry: F,
296
+ dmList: V,
297
+ editEntry: v,
288
298
  entryList: J,
289
- getAsset: v,
299
+ getAsset: M,
290
300
  getEcAuthKey: z,
291
301
  getEntry: N,
292
- getPublicAuthKey: q,
293
- loginEc: x,
302
+ getPublicAuthKey: R,
303
+ loginEc: q,
294
304
  loginPublic: S,
295
- logoutEc: R,
296
- logoutPublic: C
305
+ logoutEc: C,
306
+ logoutPublic: x
297
307
  }, Symbol.toStringTag, { value: "Module" })), {
298
- entryList: V,
299
- getEntry: W,
300
- getAsset: X,
301
- assetList: Y,
302
- createAsset: Z,
303
- deleteAsset: D,
304
- createEntry: I,
305
- editEntry: tt,
306
- deleteEntry: et,
307
- loginPublic: nt,
308
- loginEc: st,
309
- logoutEc: ot,
310
- logoutPublic: rt,
308
+ entryList: W,
309
+ getEntry: X,
310
+ getAsset: Y,
311
+ assetList: Z,
312
+ createAsset: D,
313
+ deleteAsset: I,
314
+ createEntry: tt,
315
+ editEntry: et,
316
+ deleteEntry: nt,
317
+ loginPublic: st,
318
+ loginEc: ot,
319
+ logoutEc: rt,
320
+ logoutPublic: it,
311
321
  getEcAuthKey: w,
312
- getPublicAuthKey: k
313
- } = E;
314
- function ct(n) {
322
+ getPublicAuthKey: k,
323
+ dmList: ct
324
+ } = A;
325
+ function ut(n) {
315
326
  const { action: t } = n;
316
- if (g({ action: t }), !E[t])
327
+ if (g({ action: t }), !A[t])
317
328
  throw new Error(
318
- `"${t}" does not exist! try one of ${Object.keys(E).join(
329
+ `"${t}" does not exist! try one of ${Object.keys(A).join(
319
330
  ", "
320
331
  )}`
321
332
  );
322
- return E[t](n);
333
+ return A[t](n);
323
334
  }
324
335
  class b {
325
336
  constructor(t) {
326
337
  this.config = t;
327
338
  }
328
339
  set(t) {
329
- return new b(c(c({}, this.config), t));
340
+ return new b(a(a({}, this.config), t));
330
341
  }
331
342
  /**
332
343
  * Loads entry list. Expects `dmShortID` / `model` to be set.
@@ -344,7 +355,7 @@ class b {
344
355
  entries() {
345
356
  return i(this, arguments, function* (t = {}) {
346
357
  const e = yield this.getBestToken();
347
- return V(d(c({}, this.config), { options: t, token: e }));
358
+ return W(d(a({}, this.config), { options: t, token: e }));
348
359
  });
349
360
  }
350
361
  entryList(t) {
@@ -364,7 +375,7 @@ class b {
364
375
  getEntry(t) {
365
376
  return i(this, null, function* () {
366
377
  const e = yield this.getBestToken();
367
- return W(d(c({}, this.config), { entryID: t, token: e }));
378
+ return X(d(a({}, this.config), { entryID: t, token: e }));
368
379
  });
369
380
  }
370
381
  /**
@@ -383,7 +394,7 @@ class b {
383
394
  assets(t) {
384
395
  return i(this, null, function* () {
385
396
  const e = yield this.getBestToken();
386
- return Y(d(c({}, this.config), { options: t, token: e }));
397
+ return Z(d(a({}, this.config), { options: t, token: e }));
387
398
  });
388
399
  }
389
400
  assetList(t) {
@@ -415,7 +426,7 @@ class b {
415
426
  createAsset() {
416
427
  return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
417
428
  const o = yield this.getBestToken();
418
- return Z(d(c({}, this.config), { file: t, name: e, options: s, token: o }));
429
+ return D(d(a({}, this.config), { file: t, name: e, options: s, token: o }));
419
430
  });
420
431
  }
421
432
  /**
@@ -430,7 +441,7 @@ class b {
430
441
  deleteAsset(t) {
431
442
  return i(this, null, function* () {
432
443
  const e = yield this.getBestToken();
433
- return D(d(c({}, this.config), { token: e, assetID: t }));
444
+ return I(d(a({}, this.config), { token: e, assetID: t }));
434
445
  });
435
446
  }
436
447
  /**
@@ -445,7 +456,7 @@ class b {
445
456
  getAsset(t) {
446
457
  return i(this, null, function* () {
447
458
  const e = yield this.getBestToken();
448
- return X(d(c({}, this.config), { assetID: t, token: e }));
459
+ return Y(d(a({}, this.config), { assetID: t, token: e }));
449
460
  });
450
461
  }
451
462
  /**
@@ -460,7 +471,7 @@ class b {
460
471
  createEntry(t) {
461
472
  return i(this, null, function* () {
462
473
  const e = yield this.getBestToken();
463
- return I(d(c({}, this.config), { token: e, value: t }));
474
+ return tt(d(a({}, this.config), { token: e, value: t }));
464
475
  });
465
476
  }
466
477
  /**
@@ -476,7 +487,7 @@ class b {
476
487
  editEntry(t, e) {
477
488
  return i(this, null, function* () {
478
489
  const s = yield this.getBestToken();
479
- return tt(d(c({}, this.config), { entryID: t, token: s, value: e }));
490
+ return et(d(a({}, this.config), { entryID: t, token: s, value: e }));
480
491
  });
481
492
  }
482
493
  /**
@@ -491,7 +502,7 @@ class b {
491
502
  deleteEntry(t) {
492
503
  return i(this, null, function* () {
493
504
  const e = yield this.getBestToken();
494
- return et(d(c({}, this.config), { token: e, entryID: t }));
505
+ return nt(d(a({}, this.config), { token: e, entryID: t }));
495
506
  });
496
507
  }
497
508
  // TODO: rename authAdapter -> storageAdapter
@@ -521,24 +532,24 @@ class b {
521
532
  return e(t);
522
533
  }
523
534
  loginEc(t) {
524
- return st(c(c({}, this.config), t)).then(
535
+ return ot(a(a({}, this.config), t)).then(
525
536
  this.setAuth(w(this.config))
526
537
  );
527
538
  }
528
539
  loginPublic(t) {
529
- return nt(c(c({}, this.config), t)).then(
540
+ return st(a(a({}, this.config), t)).then(
530
541
  this.setAuth(k(this.config))
531
542
  );
532
543
  }
533
544
  logoutPublic() {
534
545
  const t = this.getPublicToken();
535
- return console.log("token", t), rt(d(c({}, this.config), { token: t })).then(
546
+ return console.log("token", t), it(d(a({}, this.config), { token: t })).then(
536
547
  this.unsetAuth(k(this.config))
537
548
  );
538
549
  }
539
550
  logoutEc() {
540
551
  const t = this.getEcToken();
541
- return console.log("token", t), ot(d(c({}, this.config), { token: t })).then(
552
+ return console.log("token", t), rt(d(a({}, this.config), { token: t })).then(
542
553
  this.unsetAuth(w(this.config))
543
554
  );
544
555
  }
@@ -612,29 +623,48 @@ class b {
612
623
  assetgroup(t) {
613
624
  return this.assetGroup(t);
614
625
  }
626
+ /**
627
+ * Loads datamanager list. Make sure to provide an ec.admin `token` intercept one.
628
+ *
629
+ * @param {object=} options options for entry list request.
630
+ * @returns {Promise<DatamanagerList>}
631
+ * @example
632
+ * // public model
633
+ * const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
634
+ * @example
635
+ * // non-public model
636
+ * const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
637
+ */
638
+ dmList() {
639
+ return i(this, arguments, function* (t = {}) {
640
+ const e = yield this.getBestToken();
641
+ return ct(d(a({}, this.config), { options: t, token: e }));
642
+ });
643
+ }
615
644
  }
616
- const at = (n) => new b({ env: n });
645
+ const ht = (n) => new b({ env: n });
617
646
  export {
618
647
  b as Sdk,
619
- ct as act,
648
+ ut as act,
620
649
  f as apiURL,
621
650
  G as assetList,
622
651
  H as createAsset,
623
652
  U as createEntry,
624
653
  Q as deleteAsset,
625
- M as deleteEntry,
626
- F as editEntry,
654
+ F as deleteEntry,
655
+ V as dmList,
656
+ v as editEntry,
627
657
  J as entryList,
628
658
  g as expect,
629
659
  y as fetcher,
630
- v as getAsset,
660
+ M as getAsset,
631
661
  z as getEcAuthKey,
632
662
  N as getEntry,
633
- q as getPublicAuthKey,
634
- x as loginEc,
663
+ R as getPublicAuthKey,
664
+ q as loginEc,
635
665
  S as loginPublic,
636
- R as logoutEc,
637
- C as logoutPublic,
638
- A as query,
639
- at as sdk
666
+ C as logoutEc,
667
+ x as logoutPublic,
668
+ E as query,
669
+ ht as sdk
640
670
  };
@@ -1,4 +1,5 @@
1
1
  export * from "./auth.mjs";
2
2
  export * from "./entries.mjs";
3
3
  export * from "./assets.mjs";
4
+ export * from "./admin.mjs";
4
5
  //# sourceMappingURL=actions.d.mts.map
@@ -0,0 +1,6 @@
1
+ export function dmList(config: any): Promise<{
2
+ count: any;
3
+ total: any;
4
+ items: any;
5
+ }>;
6
+ //# sourceMappingURL=admin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.mts","sourceRoot":"","sources":["../../src/lib/admin.mjs"],"names":[],"mappings":"AAEA;;;;GAWC"}
@@ -174,6 +174,19 @@ export class Sdk {
174
174
  * @returns Sdk
175
175
  */
176
176
  assetgroup(assetGroup: string): Sdk;
177
+ /**
178
+ * Loads datamanager list. Make sure to provide an ec.admin `token` intercept one.
179
+ *
180
+ * @param {object=} options options for entry list request.
181
+ * @returns {Promise<DatamanagerList>}
182
+ * @example
183
+ * // public model
184
+ * const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
185
+ * @example
186
+ * // non-public model
187
+ * const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
188
+ */
189
+ dmList(options?: object | undefined): Promise<DatamanagerList>;
177
190
  }
178
191
  export function sdk(env: any): Sdk;
179
192
  export type AssetFile = {
@@ -241,6 +254,28 @@ export type EntryList = {
241
254
  total: number;
242
255
  items: EntryResource[];
243
256
  };
257
+ export type DatamanagerResource = {
258
+ created: string;
259
+ dataManagerID: string;
260
+ defaultLocale: string;
261
+ description: string;
262
+ config: any;
263
+ hexColor: string;
264
+ locales: string[];
265
+ rights: string[];
266
+ publicAssetRights: string[];
267
+ shortID: string;
268
+ title: string;
269
+ /**
270
+ * - Any associated links.
271
+ */
272
+ _links: any;
273
+ };
274
+ export type DatamanagerList = {
275
+ count: number;
276
+ total: number;
277
+ items: DatamanagerResource[];
278
+ };
244
279
  export type AssetList = {
245
280
  count: number;
246
281
  total: number;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAyBA,sCAWC;;AAED;;GAEG;AACH;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sCAjBW;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAClD,QAAQ,aAAa,CAAC,CAmBlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAOzB;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IAED;;;;;;;;OAQG;IACH,mBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;OASG;IACH,mBANW,MAAM,SACN,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,IAAI,CAOhB;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,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;;;;;;QAKT,MAAM;;;;cACN,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"}
1
+ {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AA0BA,sCAWC;;AAED;;GAEG;AACH;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sCAjBW;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAClD,QAAQ,aAAa,CAAC,CAmBlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAOzB;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IAED;;;;;;;;OAQG;IACH,mBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;OASG;IACH,mBANW,MAAM,SACN,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,IAAI,CAOhB;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,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IAED;;;;;;;;;;;OAWG;IACH,iBATW,MAAM,eACJ,QAAQ,eAAe,CAAC,CAWpC;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;;;;;;QAKT,MAAM;;;;cACN,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;;;aAKf,MAAM;mBACN,MAAM;mBACN,MAAM;iBACN,MAAM;YACN,GAAG;cACH,MAAM;aACN,MAAM,EAAE;YACR,MAAM,EAAE;uBACR,MAAM,EAAE;aACR,MAAM;WACN,MAAM;;;;YACN,GAAG;;;WAKH,MAAM;WACN,MAAM;WACN,mBAAmB,EAAE;;;WAKrB,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
@@ -25,5 +25,5 @@ export function deleteAsset({ env, dmShortID, assetGroup, assetID, token, }: {
25
25
  assetGroup: any;
26
26
  assetID: any;
27
27
  token: any;
28
- }): Promise<any>;
28
+ }): Promise<void>;
29
29
  //# 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;;;;GAWC;AAED;;;;;;;;iBA6BC;AAED;;;;;;iBAiBC"}
1
+ {"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAWC;AAED;;;;;;;;iBA6BC;AAED;;;;;;kBAgBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {