ec.fdk 0.2.17 → 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 -59
- 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,19 +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
|
-
|
|
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 };
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
237
|
function H(h) {
|
|
@@ -245,8 +246,8 @@ function H(h) {
|
|
|
245
246
|
}) {
|
|
246
247
|
g({ env: n, dmShortID: t, assetGroup: e, file: o });
|
|
247
248
|
const u = f(`a/${t}/${e}`, n), l = new FormData();
|
|
248
|
-
return l.append("file", o, a), r && Object.keys(r).forEach((
|
|
249
|
-
l.append(
|
|
249
|
+
return l.append("file", o, a), r && Object.keys(r).forEach((p) => {
|
|
250
|
+
l.append(p, r[p]);
|
|
250
251
|
}), (yield y(
|
|
251
252
|
u,
|
|
252
253
|
{ token: s },
|
|
@@ -257,15 +258,35 @@ function H(h) {
|
|
|
257
258
|
))._embedded["ec:dm-asset"];
|
|
258
259
|
});
|
|
259
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
|
+
}
|
|
260
280
|
const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
261
281
|
__proto__: null,
|
|
262
|
-
assetList:
|
|
282
|
+
assetList: G,
|
|
263
283
|
createAsset: H,
|
|
264
284
|
createEntry: U,
|
|
265
|
-
|
|
266
|
-
|
|
285
|
+
deleteAsset: Q,
|
|
286
|
+
deleteEntry: M,
|
|
287
|
+
editEntry: F,
|
|
267
288
|
entryList: J,
|
|
268
|
-
getAsset:
|
|
289
|
+
getAsset: v,
|
|
269
290
|
getEcAuthKey: z,
|
|
270
291
|
getEntry: N,
|
|
271
292
|
getPublicAuthKey: R,
|
|
@@ -274,22 +295,23 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
274
295
|
logoutEc: q,
|
|
275
296
|
logoutPublic: C
|
|
276
297
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
277
|
-
entryList:
|
|
278
|
-
getEntry:
|
|
279
|
-
getAsset:
|
|
280
|
-
assetList:
|
|
281
|
-
createAsset:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
|
291
313
|
} = E;
|
|
292
|
-
function
|
|
314
|
+
function ct(n) {
|
|
293
315
|
const { action: t } = n;
|
|
294
316
|
if (g({ action: t }), !E[t])
|
|
295
317
|
throw new Error(
|
|
@@ -322,7 +344,7 @@ class b {
|
|
|
322
344
|
entries() {
|
|
323
345
|
return i(this, arguments, function* (t = {}) {
|
|
324
346
|
const e = yield this.getBestToken();
|
|
325
|
-
return
|
|
347
|
+
return V(d(c({}, this.config), { options: t, token: e }));
|
|
326
348
|
});
|
|
327
349
|
}
|
|
328
350
|
entryList(t) {
|
|
@@ -342,7 +364,7 @@ class b {
|
|
|
342
364
|
getEntry(t) {
|
|
343
365
|
return i(this, null, function* () {
|
|
344
366
|
const e = yield this.getBestToken();
|
|
345
|
-
return
|
|
367
|
+
return W(d(c({}, this.config), { entryID: t, token: e }));
|
|
346
368
|
});
|
|
347
369
|
}
|
|
348
370
|
/**
|
|
@@ -361,7 +383,7 @@ class b {
|
|
|
361
383
|
assets(t) {
|
|
362
384
|
return i(this, null, function* () {
|
|
363
385
|
const e = yield this.getBestToken();
|
|
364
|
-
return
|
|
386
|
+
return Y(d(c({}, this.config), { options: t, token: e }));
|
|
365
387
|
});
|
|
366
388
|
}
|
|
367
389
|
assetList(t) {
|
|
@@ -393,7 +415,22 @@ class b {
|
|
|
393
415
|
createAsset() {
|
|
394
416
|
return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
395
417
|
const o = yield this.getBestToken();
|
|
396
|
-
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 }));
|
|
397
434
|
});
|
|
398
435
|
}
|
|
399
436
|
/**
|
|
@@ -408,7 +445,7 @@ class b {
|
|
|
408
445
|
getAsset(t) {
|
|
409
446
|
return i(this, null, function* () {
|
|
410
447
|
const e = yield this.getBestToken();
|
|
411
|
-
return
|
|
448
|
+
return X(d(c({}, this.config), { assetID: t, token: e }));
|
|
412
449
|
});
|
|
413
450
|
}
|
|
414
451
|
/**
|
|
@@ -423,7 +460,7 @@ class b {
|
|
|
423
460
|
createEntry(t) {
|
|
424
461
|
return i(this, null, function* () {
|
|
425
462
|
const e = yield this.getBestToken();
|
|
426
|
-
return
|
|
463
|
+
return I(d(c({}, this.config), { token: e, value: t }));
|
|
427
464
|
});
|
|
428
465
|
}
|
|
429
466
|
/**
|
|
@@ -439,7 +476,7 @@ class b {
|
|
|
439
476
|
editEntry(t, e) {
|
|
440
477
|
return i(this, null, function* () {
|
|
441
478
|
const s = yield this.getBestToken();
|
|
442
|
-
return
|
|
479
|
+
return tt(d(c({}, this.config), { entryID: t, token: s, value: e }));
|
|
443
480
|
});
|
|
444
481
|
}
|
|
445
482
|
/**
|
|
@@ -454,7 +491,7 @@ class b {
|
|
|
454
491
|
deleteEntry(t) {
|
|
455
492
|
return i(this, null, function* () {
|
|
456
493
|
const e = yield this.getBestToken();
|
|
457
|
-
return
|
|
494
|
+
return et(d(c({}, this.config), { token: e, entryID: t }));
|
|
458
495
|
});
|
|
459
496
|
}
|
|
460
497
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -484,32 +521,32 @@ class b {
|
|
|
484
521
|
return e(t);
|
|
485
522
|
}
|
|
486
523
|
loginEc(t) {
|
|
487
|
-
return
|
|
488
|
-
this.setAuth(
|
|
524
|
+
return st(c(c({}, this.config), t)).then(
|
|
525
|
+
this.setAuth(k(this.config))
|
|
489
526
|
);
|
|
490
527
|
}
|
|
491
528
|
loginPublic(t) {
|
|
492
|
-
return
|
|
493
|
-
this.setAuth(
|
|
529
|
+
return nt(c(c({}, this.config), t)).then(
|
|
530
|
+
this.setAuth(w(this.config))
|
|
494
531
|
);
|
|
495
532
|
}
|
|
496
533
|
logoutPublic() {
|
|
497
534
|
const t = this.getPublicToken();
|
|
498
|
-
return console.log("token", t),
|
|
499
|
-
this.unsetAuth(
|
|
535
|
+
return console.log("token", t), rt(d(c({}, this.config), { token: t })).then(
|
|
536
|
+
this.unsetAuth(w(this.config))
|
|
500
537
|
);
|
|
501
538
|
}
|
|
502
539
|
logoutEc() {
|
|
503
540
|
const t = this.getEcToken();
|
|
504
|
-
return console.log("token", t),
|
|
505
|
-
this.unsetAuth(
|
|
541
|
+
return console.log("token", t), ot(d(c({}, this.config), { token: t })).then(
|
|
542
|
+
this.unsetAuth(k(this.config))
|
|
506
543
|
);
|
|
507
544
|
}
|
|
508
545
|
getPublicToken() {
|
|
509
|
-
return this.config.token || this.getAuth(
|
|
546
|
+
return this.config.token || this.getAuth(w(this.config));
|
|
510
547
|
}
|
|
511
548
|
getEcToken() {
|
|
512
|
-
return this.config.token || this.getAuth(
|
|
549
|
+
return this.config.token || this.getAuth(k(this.config));
|
|
513
550
|
}
|
|
514
551
|
hasPublicToken() {
|
|
515
552
|
return !!this.getPublicToken();
|
|
@@ -576,20 +613,21 @@ class b {
|
|
|
576
613
|
return this.assetGroup(t);
|
|
577
614
|
}
|
|
578
615
|
}
|
|
579
|
-
const
|
|
616
|
+
const at = (n) => new b({ env: n });
|
|
580
617
|
export {
|
|
581
618
|
b as Sdk,
|
|
582
|
-
|
|
619
|
+
ct as act,
|
|
583
620
|
f as apiURL,
|
|
584
|
-
|
|
621
|
+
G as assetList,
|
|
585
622
|
H as createAsset,
|
|
586
623
|
U as createEntry,
|
|
587
|
-
|
|
588
|
-
|
|
624
|
+
Q as deleteAsset,
|
|
625
|
+
M as deleteEntry,
|
|
626
|
+
F as editEntry,
|
|
589
627
|
J as entryList,
|
|
590
628
|
g as expect,
|
|
591
629
|
y as fetcher,
|
|
592
|
-
|
|
630
|
+
v as getAsset,
|
|
593
631
|
z as getEcAuthKey,
|
|
594
632
|
N as getEntry,
|
|
595
633
|
R as getPublicAuthKey,
|
|
@@ -597,6 +635,6 @@ export {
|
|
|
597
635
|
S as loginPublic,
|
|
598
636
|
q as logoutEc,
|
|
599
637
|
C as logoutPublic,
|
|
600
|
-
|
|
601
|
-
|
|
638
|
+
A as query,
|
|
639
|
+
at as sdk
|
|
602
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;;;;
|
|
1
|
+
{"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAWC;AAED;;;;;;;;iBA6BC;AAED;;;;;;iBAiBC"}
|