ec.fdk 0.2.18 → 0.2.19
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 +17 -0
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +97 -60
- package/dist/lib/api.d.mts +10 -0
- package/dist/lib/api.d.mts.map +1 -1
- package/dist/lib/assets.d.mts +7 -0
- package/dist/lib/assets.d.mts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ Now what follows is the autogenerated doc from source:
|
|
|
62
62
|
* [.getEntry(entryID)](#module_api.Sdk+getEntry) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
63
63
|
* [.assets([options])](#module_api.Sdk+assets) ⇒ [<code>Promise.<AssetList></code>](#AssetList)
|
|
64
64
|
* [.createAsset(options)](#module_api.Sdk+createAsset) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
|
65
|
+
* [.deleteAsset(assetID)](#module_api.Sdk+deleteAsset) ⇒ <code>Promise.<void></code>
|
|
65
66
|
* [.getAsset(assetID)](#module_api.Sdk+getAsset) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
|
66
67
|
* [.createEntry(value)](#module_api.Sdk+createEntry) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
67
68
|
* [.editEntry(entryID, value)](#module_api.Sdk+editEntry) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
@@ -163,6 +164,22 @@ const upload = await sdk("stage")
|
|
|
163
164
|
.assetgroup("test")
|
|
164
165
|
.createAsset({ file, name: "venndiagram.png" });
|
|
165
166
|
```
|
|
167
|
+
<a name="module_api.Sdk+deleteAsset"></a>
|
|
168
|
+
|
|
169
|
+
#### sdk.deleteAsset(assetID) ⇒ <code>Promise.<void></code>
|
|
170
|
+
<p>Deletes an asset. Expects <code>dmShortID</code> / <code>assetGroup</code> / <code>assetID</code> to be set.
|
|
171
|
+
You probably also need to provide a <code>token</code>.</p>
|
|
172
|
+
|
|
173
|
+
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
174
|
+
|
|
175
|
+
| Param | Type |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| assetID | <code>string</code> |
|
|
178
|
+
|
|
179
|
+
**Example**
|
|
180
|
+
```js
|
|
181
|
+
await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
182
|
+
```
|
|
166
183
|
<a name="module_api.Sdk+getAsset"></a>
|
|
167
184
|
|
|
168
185
|
#### sdk.getAsset(assetID) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty,
|
|
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
2
|
${u.detail}
|
|
3
|
-
${u.verbose}`;throw new Error(
|
|
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 q(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 x({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 C(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 R(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},{method:"DELETE"}))._embedded["ec:dm-asset"]})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:U,createEntry:C,deleteAsset:M,deleteEntry:z,editEntry:R,entryList:q,getAsset:J,getEcAuthKey:K,getEntry:x,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(){return i(this,arguments,function*({assetID:t}={}){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=C;exports.deleteAsset=M;exports.deleteEntry=z;exports.editEntry=R;exports.entryList=q;exports.expect=h;exports.fetcher=d;exports.getAsset=J;exports.getEcAuthKey=K;exports.getEntry=x;exports.getPublicAuthKey=S;exports.loginEc=_;exports.loginPublic=O;exports.logoutEc=B;exports.logoutPublic=L;exports.query=E;exports.sdk=ct;
|
package/dist/index.mjs
CHANGED
|
@@ -58,7 +58,7 @@ function f(n, t = "stage") {
|
|
|
58
58
|
);
|
|
59
59
|
return e + n;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function A(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) {
|
|
@@ -151,14 +151,14 @@ function J(n) {
|
|
|
151
151
|
return i(this, null, function* () {
|
|
152
152
|
let { env: t, dmShortID: e, model: s, options: o = {} } = n;
|
|
153
153
|
g({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
|
|
154
|
-
const a =
|
|
155
|
-
let
|
|
156
|
-
return
|
|
154
|
+
const a = A(o), r = f(`api/${e}/${s}?${a}`, t), { count: h, total: u, _embedded: l } = yield y(r, n);
|
|
155
|
+
let $ = l ? l[`${e}:${s}`] : [];
|
|
156
|
+
return $ = Array.isArray($) ? $ : [$], { count: h, total: u, 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 =
|
|
161
|
+
const a = A({ _id: s }), r = f(`api/${t}/${e}?${a}`, n);
|
|
162
162
|
return y(r, { dmShortID: t, token: o });
|
|
163
163
|
}
|
|
164
164
|
function U(a) {
|
|
@@ -178,7 +178,7 @@ function U(a) {
|
|
|
178
178
|
);
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function F(r) {
|
|
182
182
|
return i(this, arguments, function* ({
|
|
183
183
|
env: n,
|
|
184
184
|
dmShortID: t,
|
|
@@ -202,7 +202,7 @@ function v(r) {
|
|
|
202
202
|
);
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function M(a) {
|
|
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 F(a) {
|
|
|
218
218
|
);
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function v(a) {
|
|
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 =
|
|
224
|
+
const r = A({ 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
|
-
function
|
|
228
|
+
function G(n) {
|
|
229
229
|
return i(this, null, function* () {
|
|
230
230
|
let { env: t, dmShortID: e, assetGroup: s, token: o, options: a = {} } = n;
|
|
231
231
|
g({ env: t, dmShortID: e, assetGroup: s }), a = c({ size: 50, page: 1, _list: !0 }, a);
|
|
232
|
-
const r =
|
|
233
|
-
let
|
|
234
|
-
return
|
|
232
|
+
const r = A(a), h = f(`a/${e}/${s}?${r}`, t), { count: u, total: l, _embedded: $ } = yield y(h, { dmShortID: e, token: o });
|
|
233
|
+
let p = $ ? $["ec:dm-asset"] : [];
|
|
234
|
+
return p = Array.isArray(p) ? p : [p], { count: u, total: l, items: p };
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
function H(h) {
|
|
@@ -246,8 +246,8 @@ function H(h) {
|
|
|
246
246
|
}) {
|
|
247
247
|
g({ env: n, dmShortID: t, assetGroup: e, file: o });
|
|
248
248
|
const u = f(`a/${t}/${e}`, n), l = new FormData();
|
|
249
|
-
return l.append("file", o, a), r && Object.keys(r).forEach((
|
|
250
|
-
l.append(
|
|
249
|
+
return l.append("file", o, a), r && Object.keys(r).forEach((p) => {
|
|
250
|
+
l.append(p, r[p]);
|
|
251
251
|
}), (yield y(
|
|
252
252
|
u,
|
|
253
253
|
{ token: s },
|
|
@@ -258,15 +258,35 @@ function H(h) {
|
|
|
258
258
|
))._embedded["ec:dm-asset"];
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
+
function Q(a) {
|
|
262
|
+
return i(this, arguments, function* ({
|
|
263
|
+
env: n,
|
|
264
|
+
dmShortID: t,
|
|
265
|
+
assetGroup: e,
|
|
266
|
+
assetID: s,
|
|
267
|
+
token: o
|
|
268
|
+
}) {
|
|
269
|
+
g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
270
|
+
const r = f(`a/${t}/${e}/${s}`, n);
|
|
271
|
+
return (yield y(
|
|
272
|
+
r,
|
|
273
|
+
{ token: o },
|
|
274
|
+
{
|
|
275
|
+
method: "DELETE"
|
|
276
|
+
}
|
|
277
|
+
))._embedded["ec:dm-asset"];
|
|
278
|
+
});
|
|
279
|
+
}
|
|
261
280
|
const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
262
281
|
__proto__: null,
|
|
263
|
-
assetList:
|
|
282
|
+
assetList: G,
|
|
264
283
|
createAsset: H,
|
|
265
284
|
createEntry: U,
|
|
266
|
-
|
|
267
|
-
|
|
285
|
+
deleteAsset: Q,
|
|
286
|
+
deleteEntry: M,
|
|
287
|
+
editEntry: F,
|
|
268
288
|
entryList: J,
|
|
269
|
-
getAsset:
|
|
289
|
+
getAsset: v,
|
|
270
290
|
getEcAuthKey: z,
|
|
271
291
|
getEntry: N,
|
|
272
292
|
getPublicAuthKey: R,
|
|
@@ -275,22 +295,23 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
275
295
|
logoutEc: q,
|
|
276
296
|
logoutPublic: C
|
|
277
297
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
278
|
-
entryList:
|
|
279
|
-
getEntry:
|
|
280
|
-
getAsset:
|
|
281
|
-
assetList:
|
|
282
|
-
createAsset:
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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,
|
|
311
|
+
getEcAuthKey: k,
|
|
312
|
+
getPublicAuthKey: w
|
|
292
313
|
} = E;
|
|
293
|
-
function
|
|
314
|
+
function ct(n) {
|
|
294
315
|
const { action: t } = n;
|
|
295
316
|
if (g({ action: t }), !E[t])
|
|
296
317
|
throw new Error(
|
|
@@ -323,7 +344,7 @@ class b {
|
|
|
323
344
|
entries() {
|
|
324
345
|
return i(this, arguments, function* (t = {}) {
|
|
325
346
|
const e = yield this.getBestToken();
|
|
326
|
-
return
|
|
347
|
+
return V(d(c({}, this.config), { options: t, token: e }));
|
|
327
348
|
});
|
|
328
349
|
}
|
|
329
350
|
entryList(t) {
|
|
@@ -343,7 +364,7 @@ class b {
|
|
|
343
364
|
getEntry(t) {
|
|
344
365
|
return i(this, null, function* () {
|
|
345
366
|
const e = yield this.getBestToken();
|
|
346
|
-
return
|
|
367
|
+
return W(d(c({}, this.config), { entryID: t, token: e }));
|
|
347
368
|
});
|
|
348
369
|
}
|
|
349
370
|
/**
|
|
@@ -362,7 +383,7 @@ class b {
|
|
|
362
383
|
assets(t) {
|
|
363
384
|
return i(this, null, function* () {
|
|
364
385
|
const e = yield this.getBestToken();
|
|
365
|
-
return
|
|
386
|
+
return Y(d(c({}, this.config), { options: t, token: e }));
|
|
366
387
|
});
|
|
367
388
|
}
|
|
368
389
|
assetList(t) {
|
|
@@ -394,7 +415,22 @@ class b {
|
|
|
394
415
|
createAsset() {
|
|
395
416
|
return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
396
417
|
const o = yield this.getBestToken();
|
|
397
|
-
return
|
|
418
|
+
return Z(d(c({}, this.config), { file: t, name: e, options: s, token: o }));
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Deletes an asset. Expects `dmShortID` / `assetGroup` / `assetID` to be set.
|
|
423
|
+
* You probably also need to provide a `token`.
|
|
424
|
+
*
|
|
425
|
+
* @param {string} assetID
|
|
426
|
+
* @returns {Promise<void>}
|
|
427
|
+
* @example
|
|
428
|
+
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
429
|
+
*/
|
|
430
|
+
deleteAsset() {
|
|
431
|
+
return i(this, arguments, function* ({ assetID: t } = {}) {
|
|
432
|
+
const e = yield this.getBestToken();
|
|
433
|
+
return D(d(c({}, this.config), { token: e, assetID: t }));
|
|
398
434
|
});
|
|
399
435
|
}
|
|
400
436
|
/**
|
|
@@ -409,7 +445,7 @@ class b {
|
|
|
409
445
|
getAsset(t) {
|
|
410
446
|
return i(this, null, function* () {
|
|
411
447
|
const e = yield this.getBestToken();
|
|
412
|
-
return
|
|
448
|
+
return X(d(c({}, this.config), { assetID: t, token: e }));
|
|
413
449
|
});
|
|
414
450
|
}
|
|
415
451
|
/**
|
|
@@ -424,7 +460,7 @@ class b {
|
|
|
424
460
|
createEntry(t) {
|
|
425
461
|
return i(this, null, function* () {
|
|
426
462
|
const e = yield this.getBestToken();
|
|
427
|
-
return
|
|
463
|
+
return I(d(c({}, this.config), { token: e, value: t }));
|
|
428
464
|
});
|
|
429
465
|
}
|
|
430
466
|
/**
|
|
@@ -440,7 +476,7 @@ class b {
|
|
|
440
476
|
editEntry(t, e) {
|
|
441
477
|
return i(this, null, function* () {
|
|
442
478
|
const s = yield this.getBestToken();
|
|
443
|
-
return
|
|
479
|
+
return tt(d(c({}, this.config), { entryID: t, token: s, value: e }));
|
|
444
480
|
});
|
|
445
481
|
}
|
|
446
482
|
/**
|
|
@@ -455,7 +491,7 @@ class b {
|
|
|
455
491
|
deleteEntry(t) {
|
|
456
492
|
return i(this, null, function* () {
|
|
457
493
|
const e = yield this.getBestToken();
|
|
458
|
-
return
|
|
494
|
+
return et(d(c({}, this.config), { token: e, entryID: t }));
|
|
459
495
|
});
|
|
460
496
|
}
|
|
461
497
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -485,32 +521,32 @@ class b {
|
|
|
485
521
|
return e(t);
|
|
486
522
|
}
|
|
487
523
|
loginEc(t) {
|
|
488
|
-
return
|
|
489
|
-
this.setAuth(
|
|
524
|
+
return st(c(c({}, this.config), t)).then(
|
|
525
|
+
this.setAuth(k(this.config))
|
|
490
526
|
);
|
|
491
527
|
}
|
|
492
528
|
loginPublic(t) {
|
|
493
|
-
return
|
|
494
|
-
this.setAuth(
|
|
529
|
+
return nt(c(c({}, this.config), t)).then(
|
|
530
|
+
this.setAuth(w(this.config))
|
|
495
531
|
);
|
|
496
532
|
}
|
|
497
533
|
logoutPublic() {
|
|
498
534
|
const t = this.getPublicToken();
|
|
499
|
-
return console.log("token", t),
|
|
500
|
-
this.unsetAuth(
|
|
535
|
+
return console.log("token", t), rt(d(c({}, this.config), { token: t })).then(
|
|
536
|
+
this.unsetAuth(w(this.config))
|
|
501
537
|
);
|
|
502
538
|
}
|
|
503
539
|
logoutEc() {
|
|
504
540
|
const t = this.getEcToken();
|
|
505
|
-
return console.log("token", t),
|
|
506
|
-
this.unsetAuth(
|
|
541
|
+
return console.log("token", t), ot(d(c({}, this.config), { token: t })).then(
|
|
542
|
+
this.unsetAuth(k(this.config))
|
|
507
543
|
);
|
|
508
544
|
}
|
|
509
545
|
getPublicToken() {
|
|
510
|
-
return this.config.token || this.getAuth(
|
|
546
|
+
return this.config.token || this.getAuth(w(this.config));
|
|
511
547
|
}
|
|
512
548
|
getEcToken() {
|
|
513
|
-
return this.config.token || this.getAuth(
|
|
549
|
+
return this.config.token || this.getAuth(k(this.config));
|
|
514
550
|
}
|
|
515
551
|
hasPublicToken() {
|
|
516
552
|
return !!this.getPublicToken();
|
|
@@ -577,20 +613,21 @@ class b {
|
|
|
577
613
|
return this.assetGroup(t);
|
|
578
614
|
}
|
|
579
615
|
}
|
|
580
|
-
const
|
|
616
|
+
const at = (n) => new b({ env: n });
|
|
581
617
|
export {
|
|
582
618
|
b as Sdk,
|
|
583
|
-
|
|
619
|
+
ct as act,
|
|
584
620
|
f as apiURL,
|
|
585
|
-
|
|
621
|
+
G as assetList,
|
|
586
622
|
H as createAsset,
|
|
587
623
|
U as createEntry,
|
|
588
|
-
|
|
589
|
-
|
|
624
|
+
Q as deleteAsset,
|
|
625
|
+
M as deleteEntry,
|
|
626
|
+
F as editEntry,
|
|
590
627
|
J as entryList,
|
|
591
628
|
g as expect,
|
|
592
629
|
y as fetcher,
|
|
593
|
-
|
|
630
|
+
v as getAsset,
|
|
594
631
|
z as getEcAuthKey,
|
|
595
632
|
N as getEntry,
|
|
596
633
|
R as getPublicAuthKey,
|
|
@@ -598,6 +635,6 @@ export {
|
|
|
598
635
|
S as loginPublic,
|
|
599
636
|
q as logoutEc,
|
|
600
637
|
C as logoutPublic,
|
|
601
|
-
|
|
602
|
-
|
|
638
|
+
A as query,
|
|
639
|
+
at as sdk
|
|
603
640
|
};
|
package/dist/lib/api.d.mts
CHANGED
|
@@ -73,6 +73,16 @@ export class Sdk {
|
|
|
73
73
|
name: string;
|
|
74
74
|
options: object;
|
|
75
75
|
}): Promise<AssetResource>;
|
|
76
|
+
/**
|
|
77
|
+
* Deletes an asset. Expects `dmShortID` / `assetGroup` / `assetID` to be set.
|
|
78
|
+
* You probably also need to provide a `token`.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} assetID
|
|
81
|
+
* @returns {Promise<void>}
|
|
82
|
+
* @example
|
|
83
|
+
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
84
|
+
*/
|
|
85
|
+
deleteAsset({ assetID }?: string): Promise<void>;
|
|
76
86
|
/**
|
|
77
87
|
* Loads a single asset. Expects `dmShortID` / `assetGroup` to be set.
|
|
78
88
|
* If the asset group is not public, you also need to provide a `token`.
|
package/dist/lib/api.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"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,0BALW,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"}
|
package/dist/lib/assets.d.mts
CHANGED
|
@@ -19,4 +19,11 @@ export function createAsset({ env, dmShortID, assetGroup, token, file, name, opt
|
|
|
19
19
|
name: any;
|
|
20
20
|
options: any;
|
|
21
21
|
}): Promise<any>;
|
|
22
|
+
export function deleteAsset({ env, dmShortID, assetGroup, assetID, token, }: {
|
|
23
|
+
env: any;
|
|
24
|
+
dmShortID: any;
|
|
25
|
+
assetGroup: any;
|
|
26
|
+
assetID: any;
|
|
27
|
+
token: any;
|
|
28
|
+
}): Promise<any>;
|
|
22
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"}
|
|
1
|
+
{"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAWC;AAED;;;;;;;;iBA6BC;AAED;;;;;;iBAiBC"}
|