ec.fdk 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +259 -208
- package/dist/lib/api.d.mts +119 -51
- package/dist/lib/api.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty,F=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var
|
|
1
|
+
"use strict";var M=Object.defineProperty,F=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var T=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))H.call(t,e)&&T(n,e,t[e]);if(b)for(var e of b(t))Q.call(t,e)&&T(n,e,t[e]);return n},d=(n,t)=>F(n,G(t));var r=(n,t,e)=>new Promise((s,o)=>{var a=u=>{try{g(e.next(u))}catch(f){o(f)}},i=u=>{try{g(e.throw(u))}catch(f){o(f)}},g=u=>u.done?s(u.value):Promise.resolve(u.value).then(a,i);g((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(s){return r(this,arguments,function*(n,t={},e={}){const{token:o,rawRes:a}=t;o&&(e.headers=d(c({},e.headers||{}),{Authorization:`Bearer ${o}`}));const i=yield fetch(n,e);if(!i.ok)throw new Error(i.statusText);return a?i:yield i.json()})}const P={production:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function y(n,t="stage"){const e=P[t];if(!e)throw new Error(`env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`);return e+n}function p(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function h(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const m={stage:"https://accounts.cachena.entrecode.de/",production:"https://accounts.cachena.entrecode.de/"};function O(n){return r(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;h({env:t,dmShortID:e,email:s,password:o});const a=y(`api/${e}/_auth/login?clientID=rest`,t);return yield l(a,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function j(n){return r(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const o=`${m[t]}auth/login?clientID=rest`;return yield l(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function _(n){return r(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const o=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield l(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function L(n){return r(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${m[t]}auth/logout?clientID=rest`;return yield l(s,{rawRes:!0,token:e},{method:"POST"})})}function B({dmShortID:n}){return h({dmShortID:n}),n}function S({env:n}){return h({env:n}),n}function K(n){return r(this,null,function*(){let{env:t,dmShortID:e,model:s,options:o={}}=n;h({env:t,dmShortID:e,model:s}),o=c({size:50,page:1,_list:!0},o);const a=p(o),i=y(`api/${e}/${s}?${a}`,t),{count:g,total:u,_embedded:f}=yield l(i,n),E=f?f[`${e}:${s}`]:[];return{count:g,total:u,items:E}})}function q({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const a=p({_id:s}),i=y(`api/${t}/${e}?${a}`,n);return l(i,{dmShortID:t,token:o})}function C(a){return r(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:o}){h({env:n,dmShortID:t,model:e,value:s}),console.log("create entry",t,e,s);const i=y(`api/${t}/${e}`,n);return console.log("url",i),yield l(i,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function R(i){return r(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:a}){h({env:n,dmShortID:t,model:e,entryID:s,value:o});const g=y(`api/${t}/${e}?_id=${s}`,n);return yield l(g,{token:a},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function x(a){return r(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const i=y(`api/${t}/${e}?_id=${s}`,n);return yield l(i,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function z(a){return r(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=p({assetID:s}),g=y(`a/${t}/${e}?${i}`,n);return(yield l(g,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function J(n){return r(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:o,options:a={}}=n;h({env:t,dmShortID:e,assetGroup:s}),a=c({size:50,page:1,_list:!0},a);const i=p(a),g=y(`a/${e}/${s}?${i}`,t),{count:u,total:f,_embedded:E}=yield l(g,{dmShortID:e,token:o}),U=E?E["ec:dm-asset"]:[];return{count:u,total:f,items:U}})}function N(i){return r(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:a}){h({env:n,dmShortID:t,assetGroup:e,file:o});const g=y(`a/${t}/${e}`,n),u=new FormData;return u.append("file",o,a),(yield l(g,{token:s},{method:"POST",body:u}))._embedded["ec:dm-asset"]})}const $=Object.freeze(Object.defineProperty({__proto__:null,assetList:J,createAsset:N,createEntry:C,deleteEntry:x,editEntry:R,entryList:K,getAsset:z,getEcAuthKey:S,getEntry:q,getPublicAuthKey:B,loginEc:j,loginPublic:O,logoutEc:L,logoutPublic:_},Symbol.toStringTag,{value:"Module"})),{entryList:V,getEntry:W,getAsset:X,assetList:Y,createAsset:Z,createEntry:v,editEntry:D,deleteEntry:I,loginPublic:tt,loginEc:et,logoutEc:nt,logoutPublic:st,getEcAuthKey:k,getPublicAuthKey:w}=$;function ot(n){const{action:t}=n;if(h({action:t}),!$[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys($).join(", ")}`);return $[t](n)}class A{constructor(t){this.config=t}set(t){return new A(c(c({},this.config),t))}entries(){return r(this,arguments,function*(t={}){const e=yield this.getBestToken();return V(d(c({},this.config),{options:t,token:e}))})}entryList(t){return r(this,null,function*(){return this.entries(t)})}getEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return W(d(c({},this.config),{entryID:t,token:e}))})}assets(t){return r(this,null,function*(){const e=yield this.getBestToken();return Y(d(c({},this.config),{options:t,token:e}))})}assetList(t){return r(this,null,function*(){return this.assets(t)})}createAsset(){return r(this,arguments,function*({file:t,name:e}={}){const s=yield this.getBestToken();return Z(d(c({},this.config),{file:t,name:e,token:s}))})}getAsset(t){return r(this,null,function*(){const e=yield this.getBestToken();return X(d(c({},this.config),{assetID:t,token:e}))})}createEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return v(d(c({},this.config),{token:e,value:t}))})}editEntry(t,e){return r(this,null,function*(){const s=yield this.getBestToken();return D(d(c({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return r(this,null,function*(){const e=yield this.getBestToken();return I(d(c({},this.config),{token:e,entryID:t}))})}authAdapter(t){return this.set({authAdapter:t})}setAuth(t){return e=>{if(!this.config.authAdapter)throw new Error("cannot setAuth: no authAdapter defined!");const{set:s}=this.config.authAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(console.log("unset auth",e),!this.config.authAdapter)throw new Error("cannot unsetAuth: no authAdapter defined!");const{remove:s}=this.config.authAdapter;return s(t),e}}getAuth(t){if(!this.config.authAdapter)throw new Error("cannot getAuth: no authAdapter defined!");const{get:e}=this.config.authAdapter;return e(t)}loginEc(t){return et(c(c({},this.config),t)).then(this.setAuth(k(this.config)))}loginPublic(t){return tt(c(c({},this.config),t)).then(this.setAuth(w(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(d(c({},this.config),{token:t})).then(this.unsetAuth(w(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(d(c({},this.config),{token:t})).then(this.unsetAuth(k(this.config)))}getPublicToken(){return this.config.token||this.getAuth(w(this.config))}getEcToken(){return this.config.token||this.getAuth(k(this.config))}hasPublicToken(){return!!this.getPublicToken()}hasEcToken(){return!!this.getEcToken()}hasAnyToken(){return!!this.getEcToken()||!!this.getPublicToken()}getBestToken(){try{return this.getEcToken()||this.getPublicToken()}catch(t){return}}model(t){return this.set({model:t})}token(t){return this.set({token:t})}dmShortID(t){return this.set({dmShortID:t})}dm(t){return this.dmShortID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}}const rt=n=>new A({env:n});exports.act=ot;exports.apiURL=y;exports.assetList=J;exports.createAsset=N;exports.createEntry=C;exports.deleteEntry=x;exports.editEntry=R;exports.entryList=K;exports.expect=h;exports.fetcher=l;exports.getAsset=z;exports.getEcAuthKey=S;exports.getEntry=q;exports.getPublicAuthKey=B;exports.loginEc=j;exports.loginPublic=O;exports.logoutEc=L;exports.logoutPublic=_;exports.query=p;exports.sdk=rt;
|
package/dist/index.mjs
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var T = (n, t, e) => t in n ?
|
|
1
|
+
var j = Object.defineProperty, _ = Object.defineProperties;
|
|
2
|
+
var L = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var b = Object.getOwnPropertySymbols;
|
|
4
|
+
var B = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var T = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
B.call(t, e) && T(n, e, t[e]);
|
|
8
|
+
if (b)
|
|
9
|
+
for (var e of b(t))
|
|
10
|
+
K.call(t, e) && T(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, l = (n, t) => _(n, L(t));
|
|
13
|
+
var r = (n, t, e) => new Promise((s, o) => {
|
|
14
|
+
var a = (u) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
h(e.next(u));
|
|
17
17
|
} catch (f) {
|
|
18
|
-
|
|
18
|
+
o(f);
|
|
19
19
|
}
|
|
20
|
-
}, i = (
|
|
20
|
+
}, i = (u) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
h(e.throw(u));
|
|
23
23
|
} catch (f) {
|
|
24
|
-
|
|
24
|
+
o(f);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, h = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(a, i);
|
|
27
|
+
h((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
|
-
function
|
|
30
|
-
return
|
|
31
|
-
const { token:
|
|
32
|
-
|
|
33
|
-
Authorization: `Bearer ${
|
|
29
|
+
function d(s) {
|
|
30
|
+
return r(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
|
+
const { token: o, rawRes: a } = t;
|
|
32
|
+
o && (e.headers = l(c({}, e.headers || {}), {
|
|
33
|
+
Authorization: `Bearer ${o}`
|
|
34
34
|
}));
|
|
35
35
|
const i = yield fetch(n, e);
|
|
36
36
|
if (!i.ok)
|
|
37
37
|
throw new Error(i.statusText);
|
|
38
|
-
return
|
|
38
|
+
return a ? i : yield i.json();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
const P = {
|
|
@@ -50,30 +50,30 @@ function y(n, t = "stage") {
|
|
|
50
50
|
);
|
|
51
51
|
return e + n;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function $(n, t = !0) {
|
|
54
54
|
return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function g(n) {
|
|
57
57
|
Object.entries(n).forEach(([t, e]) => {
|
|
58
58
|
if (e === void 0)
|
|
59
59
|
throw new Error(`expected ${t} to be set!`);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const m = {
|
|
63
63
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
64
64
|
production: "https://accounts.cachena.entrecode.de/"
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
return
|
|
68
|
-
let { env: t, dmShortID: e, email: s, password:
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
return yield
|
|
72
|
-
|
|
66
|
+
function S(n) {
|
|
67
|
+
return r(this, null, function* () {
|
|
68
|
+
let { env: t, dmShortID: e, email: s, password: o } = n;
|
|
69
|
+
g({ env: t, dmShortID: e, email: s, password: o });
|
|
70
|
+
const a = y(`api/${e}/_auth/login?clientID=rest`, t);
|
|
71
|
+
return yield d(
|
|
72
|
+
a,
|
|
73
73
|
{},
|
|
74
74
|
{
|
|
75
75
|
method: "POST",
|
|
76
|
-
body: JSON.stringify({ email: s, password:
|
|
76
|
+
body: JSON.stringify({ email: s, password: o }),
|
|
77
77
|
headers: {
|
|
78
78
|
"Content-Type": "application/json"
|
|
79
79
|
}
|
|
@@ -81,13 +81,13 @@ function C(n) {
|
|
|
81
81
|
);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
84
|
+
function C(n) {
|
|
85
|
+
return r(this, null, function* () {
|
|
86
86
|
let { env: t, email: e, password: s } = n;
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
return yield
|
|
90
|
-
|
|
87
|
+
g({ env: t, email: e, password: s });
|
|
88
|
+
const o = `${m[t]}auth/login?clientID=rest`;
|
|
89
|
+
return yield d(
|
|
90
|
+
o,
|
|
91
91
|
{},
|
|
92
92
|
{
|
|
93
93
|
method: "POST",
|
|
@@ -99,16 +99,16 @@ function q(n) {
|
|
|
99
99
|
);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
102
|
+
function q(n) {
|
|
103
|
+
return r(this, null, function* () {
|
|
104
104
|
let { dmShortID: t, env: e, token: s } = n;
|
|
105
|
-
|
|
106
|
-
const
|
|
105
|
+
g({ dmShortID: t, env: e, token: s });
|
|
106
|
+
const o = y(
|
|
107
107
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
108
108
|
e
|
|
109
109
|
);
|
|
110
|
-
return yield
|
|
111
|
-
|
|
110
|
+
return yield d(
|
|
111
|
+
o,
|
|
112
112
|
{ dmShortID: t, rawRes: !0 },
|
|
113
113
|
{
|
|
114
114
|
method: "POST"
|
|
@@ -116,12 +116,12 @@ function x(n) {
|
|
|
116
116
|
);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
119
|
+
function x(n) {
|
|
120
|
+
return r(this, null, function* () {
|
|
121
121
|
let { env: t, token: e } = n;
|
|
122
|
-
|
|
123
|
-
const s = `${
|
|
124
|
-
return yield
|
|
122
|
+
g({ env: t, token: e });
|
|
123
|
+
const s = `${m[t]}auth/logout?clientID=rest`;
|
|
124
|
+
return yield d(
|
|
125
125
|
s,
|
|
126
126
|
{
|
|
127
127
|
rawRes: !0,
|
|
@@ -133,32 +133,32 @@ function R(n) {
|
|
|
133
133
|
);
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
136
|
+
function R({ dmShortID: n }) {
|
|
137
|
+
return g({ dmShortID: n }), n;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
139
|
+
function z({ env: n }) {
|
|
140
|
+
return g({ env: n }), n;
|
|
141
141
|
}
|
|
142
142
|
function J(n) {
|
|
143
|
-
return
|
|
144
|
-
let { env: t, dmShortID: e, model: s, options:
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
return { count:
|
|
143
|
+
return r(this, null, function* () {
|
|
144
|
+
let { env: t, dmShortID: e, model: s, options: o = {} } = n;
|
|
145
|
+
g({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
|
|
146
|
+
const a = $(o), i = y(`api/${e}/${s}?${a}`, t), { count: h, total: u, _embedded: f } = yield d(i, n), p = f ? f[`${e}:${s}`] : [];
|
|
147
|
+
return { count: h, total: u, items: p };
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
function N({ env: n, dmShortID: t, model: e, entryID: s, token:
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
return
|
|
150
|
+
function N({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
|
|
151
|
+
g({ env: n, dmShortID: t, model: e, entryID: s });
|
|
152
|
+
const a = $({ _id: s }), i = y(`api/${t}/${e}?${a}`, n);
|
|
153
|
+
return d(i, { dmShortID: t, token: o });
|
|
154
154
|
}
|
|
155
|
-
function U(
|
|
156
|
-
return
|
|
157
|
-
|
|
155
|
+
function U(a) {
|
|
156
|
+
return r(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: o }) {
|
|
157
|
+
g({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
|
|
158
158
|
const i = y(`api/${t}/${e}`, n);
|
|
159
|
-
return console.log("url", i), yield
|
|
159
|
+
return console.log("url", i), yield d(
|
|
160
160
|
i,
|
|
161
|
-
{ env: n, dmShortID: t, token:
|
|
161
|
+
{ env: n, dmShortID: t, token: o },
|
|
162
162
|
{
|
|
163
163
|
method: "POST",
|
|
164
164
|
body: JSON.stringify(s),
|
|
@@ -170,22 +170,22 @@ function U(o) {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
function F(i) {
|
|
173
|
-
return
|
|
173
|
+
return r(this, arguments, function* ({
|
|
174
174
|
env: n,
|
|
175
175
|
dmShortID: t,
|
|
176
176
|
model: e,
|
|
177
177
|
entryID: s,
|
|
178
|
-
value:
|
|
179
|
-
token:
|
|
178
|
+
value: o,
|
|
179
|
+
token: a
|
|
180
180
|
}) {
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
return yield
|
|
184
|
-
|
|
185
|
-
{ token:
|
|
181
|
+
g({ env: n, dmShortID: t, model: e, entryID: s, value: o });
|
|
182
|
+
const h = y(`api/${t}/${e}?_id=${s}`, n);
|
|
183
|
+
return yield d(
|
|
184
|
+
h,
|
|
185
|
+
{ token: a },
|
|
186
186
|
{
|
|
187
187
|
method: "PUT",
|
|
188
|
-
body: JSON.stringify(
|
|
188
|
+
body: JSON.stringify(o),
|
|
189
189
|
headers: {
|
|
190
190
|
"Content-Type": "application/json"
|
|
191
191
|
}
|
|
@@ -193,13 +193,13 @@ function F(i) {
|
|
|
193
193
|
);
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
-
function G(
|
|
197
|
-
return
|
|
198
|
-
|
|
196
|
+
function G(a) {
|
|
197
|
+
return r(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
|
|
198
|
+
g({ env: n, dmShortID: t, model: e, entryID: s });
|
|
199
199
|
const i = y(`api/${t}/${e}?_id=${s}`, n);
|
|
200
|
-
return yield
|
|
200
|
+
return yield d(
|
|
201
201
|
i,
|
|
202
|
-
{ token:
|
|
202
|
+
{ token: o, rawRes: !0 },
|
|
203
203
|
{
|
|
204
204
|
method: "DELETE",
|
|
205
205
|
headers: {
|
|
@@ -209,43 +209,43 @@ function G(o) {
|
|
|
209
209
|
);
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
function M(
|
|
213
|
-
return
|
|
214
|
-
|
|
215
|
-
const i =
|
|
216
|
-
return (yield
|
|
212
|
+
function M(a) {
|
|
213
|
+
return r(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: o }) {
|
|
214
|
+
g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
215
|
+
const i = $({ assetID: s }), h = y(`a/${t}/${e}?${i}`, n);
|
|
216
|
+
return (yield d(h, { dmShortID: t, token: o }))._embedded["ec:dm-asset"];
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
function H(n) {
|
|
220
|
-
return
|
|
221
|
-
let { env: t, dmShortID: e, assetGroup: s, token:
|
|
222
|
-
|
|
223
|
-
const i =
|
|
224
|
-
return { count:
|
|
220
|
+
return r(this, null, function* () {
|
|
221
|
+
let { env: t, dmShortID: e, assetGroup: s, token: o, options: a = {} } = n;
|
|
222
|
+
g({ env: t, dmShortID: e, assetGroup: s }), a = c({ size: 50, page: 1, _list: !0 }, a);
|
|
223
|
+
const i = $(a), h = y(`a/${e}/${s}?${i}`, t), { count: u, total: f, _embedded: p } = yield d(h, { dmShortID: e, token: o }), O = p ? p["ec:dm-asset"] : [];
|
|
224
|
+
return { count: u, total: f, items: O };
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
function Q(i) {
|
|
228
|
-
return
|
|
228
|
+
return r(this, arguments, function* ({
|
|
229
229
|
env: n,
|
|
230
230
|
dmShortID: t,
|
|
231
231
|
assetGroup: e,
|
|
232
232
|
token: s,
|
|
233
|
-
file:
|
|
234
|
-
name:
|
|
233
|
+
file: o,
|
|
234
|
+
name: a
|
|
235
235
|
}) {
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
return
|
|
239
|
-
|
|
236
|
+
g({ env: n, dmShortID: t, assetGroup: e, file: o });
|
|
237
|
+
const h = y(`a/${t}/${e}`, n), u = new FormData();
|
|
238
|
+
return u.append("file", o, a), (yield d(
|
|
239
|
+
h,
|
|
240
240
|
{ token: s },
|
|
241
241
|
{
|
|
242
242
|
method: "POST",
|
|
243
|
-
body:
|
|
243
|
+
body: u
|
|
244
244
|
}
|
|
245
245
|
))._embedded["ec:dm-asset"];
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
|
-
const
|
|
248
|
+
const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
249
249
|
__proto__: null,
|
|
250
250
|
assetList: H,
|
|
251
251
|
createAsset: Q,
|
|
@@ -254,112 +254,195 @@ const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
254
254
|
editEntry: F,
|
|
255
255
|
entryList: J,
|
|
256
256
|
getAsset: M,
|
|
257
|
-
getEcAuthKey:
|
|
257
|
+
getEcAuthKey: z,
|
|
258
258
|
getEntry: N,
|
|
259
|
-
getPublicAuthKey:
|
|
260
|
-
loginEc:
|
|
261
|
-
loginPublic:
|
|
262
|
-
logoutEc:
|
|
263
|
-
logoutPublic:
|
|
259
|
+
getPublicAuthKey: R,
|
|
260
|
+
loginEc: C,
|
|
261
|
+
loginPublic: S,
|
|
262
|
+
logoutEc: x,
|
|
263
|
+
logoutPublic: q
|
|
264
264
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
265
265
|
entryList: V,
|
|
266
266
|
getEntry: W,
|
|
267
267
|
getAsset: X,
|
|
268
268
|
assetList: Y,
|
|
269
269
|
createAsset: Z,
|
|
270
|
-
createEntry:
|
|
271
|
-
editEntry:
|
|
272
|
-
deleteEntry:
|
|
270
|
+
createEntry: D,
|
|
271
|
+
editEntry: v,
|
|
272
|
+
deleteEntry: I,
|
|
273
273
|
loginPublic: tt,
|
|
274
274
|
loginEc: et,
|
|
275
275
|
logoutEc: nt,
|
|
276
276
|
logoutPublic: st,
|
|
277
277
|
getEcAuthKey: k,
|
|
278
278
|
getPublicAuthKey: w
|
|
279
|
-
} =
|
|
280
|
-
function
|
|
279
|
+
} = E;
|
|
280
|
+
function rt(n) {
|
|
281
281
|
const { action: t } = n;
|
|
282
|
-
if (
|
|
282
|
+
if (g({ action: t }), !E[t])
|
|
283
283
|
throw new Error(
|
|
284
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
284
|
+
`"${t}" does not exist! try one of ${Object.keys(E).join(
|
|
285
285
|
", "
|
|
286
286
|
)}`
|
|
287
287
|
);
|
|
288
|
-
return
|
|
288
|
+
return E[t](n);
|
|
289
289
|
}
|
|
290
|
-
class
|
|
290
|
+
class A {
|
|
291
291
|
constructor(t) {
|
|
292
292
|
this.config = t;
|
|
293
293
|
}
|
|
294
294
|
set(t) {
|
|
295
|
-
return new
|
|
296
|
-
}
|
|
297
|
-
handle(t) {
|
|
298
|
-
return c(this, null, function* () {
|
|
299
|
-
const e = Object.keys(this.config), s = yield this.getBestToken(), [r, o] = Object.entries(t).find(([i, u]) => e.includes(i)) || [];
|
|
300
|
-
if (!o)
|
|
301
|
-
throw new Error(
|
|
302
|
-
`you need to first set ${Object.keys(t).join(" | ")}`
|
|
303
|
-
);
|
|
304
|
-
return o(d(a({}, this.config), { token: s }));
|
|
305
|
-
});
|
|
295
|
+
return new A(c(c({}, this.config), t));
|
|
306
296
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
299
|
+
* If the model is not public, you also need to provide a `token`.
|
|
300
|
+
*
|
|
301
|
+
* @param {object=} options options for entry list request.
|
|
302
|
+
* @returns {{ count: number, total: number, items: object[] }}
|
|
303
|
+
* @example
|
|
304
|
+
* // public model
|
|
305
|
+
* const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
|
|
306
|
+
* @example
|
|
307
|
+
* // non-public model
|
|
308
|
+
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
309
|
+
*/
|
|
310
|
+
entries() {
|
|
311
|
+
return r(this, arguments, function* (t = {}) {
|
|
310
312
|
const e = yield this.getBestToken();
|
|
311
|
-
return V(
|
|
313
|
+
return V(l(c({}, this.config), { options: t, token: e }));
|
|
312
314
|
});
|
|
313
315
|
}
|
|
314
316
|
entryList(t) {
|
|
315
|
-
return
|
|
317
|
+
return r(this, null, function* () {
|
|
316
318
|
return this.entries(t);
|
|
317
319
|
});
|
|
318
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Loads a single entry. Expects `dmShortID` / `model` to be set.
|
|
323
|
+
* If the model is not public, you also need to provide a `token`.
|
|
324
|
+
*
|
|
325
|
+
* @param {string} entryID
|
|
326
|
+
* @returns {object}
|
|
327
|
+
* @example
|
|
328
|
+
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
329
|
+
*/
|
|
330
|
+
getEntry(t) {
|
|
331
|
+
return r(this, null, function* () {
|
|
332
|
+
const e = yield this.getBestToken();
|
|
333
|
+
return W(l(c({}, this.config), { entryID: t, token: e }));
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Loads asset list. Expects `dmShortID` / `assetGroup` to be set.
|
|
338
|
+
* If the assetGroup is not public, you also need to provide a `token`.
|
|
339
|
+
*
|
|
340
|
+
* @param {object=} options options for entry list request.
|
|
341
|
+
* @returns {{ count: number, total: number, items: object[] }}
|
|
342
|
+
* @example
|
|
343
|
+
* // public assetGroup
|
|
344
|
+
* const files = await sdk("stage").dm("83cc6374").assetGroup("avatars").assets()
|
|
345
|
+
* @example
|
|
346
|
+
* // non-public assetGroup
|
|
347
|
+
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
348
|
+
*/
|
|
319
349
|
assets(t) {
|
|
320
|
-
return
|
|
350
|
+
return r(this, null, function* () {
|
|
321
351
|
const e = yield this.getBestToken();
|
|
322
|
-
return Y(
|
|
352
|
+
return Y(l(c({}, this.config), { options: t, token: e }));
|
|
323
353
|
});
|
|
324
354
|
}
|
|
325
355
|
assetList(t) {
|
|
326
|
-
return
|
|
356
|
+
return r(this, null, function* () {
|
|
327
357
|
return this.assets(t);
|
|
328
358
|
});
|
|
329
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Uploads an asset. Expects `dmShortID` / `assetGroup` / `file` to be set.
|
|
362
|
+
* If the assetGroup is not public, you also need to provide a `token`.
|
|
363
|
+
*
|
|
364
|
+
* @param {object=} options options for entry list request.
|
|
365
|
+
* @returns {{ count: number, total: number, items: object[] }}
|
|
366
|
+
* @example
|
|
367
|
+
* // browser example
|
|
368
|
+
* document.getElementById("file").addEventListener("input", async (e) => {
|
|
369
|
+
* const [file] = e.target.files;
|
|
370
|
+
* const asset = await ecadmin.assetgroup("test").createAsset({ file })
|
|
371
|
+
* });
|
|
372
|
+
* @example
|
|
373
|
+
* // node example
|
|
374
|
+
* const buf = fs.readFileSync("venndiagram.png");
|
|
375
|
+
* const file = new Blob([buf]);
|
|
376
|
+
* const upload = await sdk("stage")
|
|
377
|
+
* .dm("83cc6374")
|
|
378
|
+
* .assetgroup("test")
|
|
379
|
+
* .createAsset({ file, name: "venndiagram.png" });
|
|
380
|
+
*/
|
|
330
381
|
createAsset() {
|
|
331
|
-
return
|
|
382
|
+
return r(this, arguments, function* ({ file: t, name: e } = {}) {
|
|
332
383
|
const s = yield this.getBestToken();
|
|
333
|
-
return Z(
|
|
384
|
+
return Z(l(c({}, this.config), { file: t, name: e, token: s }));
|
|
334
385
|
});
|
|
335
386
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
387
|
+
/**
|
|
388
|
+
* Loads a single asset. Expects `dmShortID` / `assetGroup` to be set.
|
|
389
|
+
* If the asset group is not public, you also need to provide a `token`.
|
|
390
|
+
*
|
|
391
|
+
* @param {string} assetID
|
|
392
|
+
* @returns {object}
|
|
393
|
+
* @example
|
|
394
|
+
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
395
|
+
*/
|
|
396
|
+
getAsset(t) {
|
|
397
|
+
return r(this, null, function* () {
|
|
398
|
+
const e = yield this.getBestToken();
|
|
399
|
+
return X(l(c({}, this.config), { assetID: t, token: e }));
|
|
345
400
|
});
|
|
346
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Creates a new entry. Expects `dmShortID` / `model` to be set.
|
|
404
|
+
* If model POST is not public, you also need to provide a `token`.
|
|
405
|
+
*
|
|
406
|
+
* @param {object} value values to set.
|
|
407
|
+
* @returns {object}
|
|
408
|
+
* @example
|
|
409
|
+
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
410
|
+
*/
|
|
347
411
|
createEntry(t) {
|
|
348
|
-
return
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
412
|
+
return r(this, null, function* () {
|
|
413
|
+
const e = yield this.getBestToken();
|
|
414
|
+
return D(l(c({}, this.config), { token: e, value: t }));
|
|
415
|
+
});
|
|
352
416
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
417
|
+
/**
|
|
418
|
+
* Edits an entry. Expects `dmShortID` / `model` to be set.
|
|
419
|
+
* If model PUT is not public, you also need to provide a `token`.
|
|
420
|
+
*
|
|
421
|
+
* @param {string} entryID id of entry to edit
|
|
422
|
+
* @param {object} value values to set. undefined fields are ignored
|
|
423
|
+
* @returns {object}
|
|
424
|
+
* @example
|
|
425
|
+
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
426
|
+
*/
|
|
427
|
+
editEntry(t, e) {
|
|
428
|
+
return r(this, null, function* () {
|
|
429
|
+
const s = yield this.getBestToken();
|
|
430
|
+
return v(l(c({}, this.config), { entryID: t, token: s, value: e }));
|
|
357
431
|
});
|
|
358
432
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
433
|
+
/**
|
|
434
|
+
* Deletes an entry. Expects `dmShortID` / `model` to be set.
|
|
435
|
+
* If model DELETE is not public, you also need to provide a `token`.
|
|
436
|
+
*
|
|
437
|
+
* @param {string} entryID id of entry to delete
|
|
438
|
+
* @returns {object}
|
|
439
|
+
* @example
|
|
440
|
+
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
441
|
+
*/
|
|
442
|
+
deleteEntry(t) {
|
|
443
|
+
return r(this, null, function* () {
|
|
444
|
+
const e = yield this.getBestToken();
|
|
445
|
+
return I(l(c({}, this.config), { token: e, entryID: t }));
|
|
363
446
|
});
|
|
364
447
|
}
|
|
365
448
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -389,24 +472,24 @@ class b {
|
|
|
389
472
|
return e(t);
|
|
390
473
|
}
|
|
391
474
|
loginEc(t) {
|
|
392
|
-
return et(
|
|
475
|
+
return et(c(c({}, this.config), t)).then(
|
|
393
476
|
this.setAuth(k(this.config))
|
|
394
477
|
);
|
|
395
478
|
}
|
|
396
479
|
loginPublic(t) {
|
|
397
|
-
return tt(
|
|
480
|
+
return tt(c(c({}, this.config), t)).then(
|
|
398
481
|
this.setAuth(w(this.config))
|
|
399
482
|
);
|
|
400
483
|
}
|
|
401
484
|
logoutPublic() {
|
|
402
485
|
const t = this.getPublicToken();
|
|
403
|
-
return console.log("token", t), st(
|
|
486
|
+
return console.log("token", t), st(l(c({}, this.config), { token: t })).then(
|
|
404
487
|
this.unsetAuth(w(this.config))
|
|
405
488
|
);
|
|
406
489
|
}
|
|
407
490
|
logoutEc() {
|
|
408
491
|
const t = this.getEcToken();
|
|
409
|
-
return console.log("token", t), nt(
|
|
492
|
+
return console.log("token", t), nt(l(c({}, this.config), { token: t })).then(
|
|
410
493
|
this.unsetAuth(k(this.config))
|
|
411
494
|
);
|
|
412
495
|
}
|
|
@@ -464,22 +547,6 @@ class b {
|
|
|
464
547
|
dm(t) {
|
|
465
548
|
return this.dmShortID(t);
|
|
466
549
|
}
|
|
467
|
-
/**
|
|
468
|
-
* Sets the id of the entry to use
|
|
469
|
-
* @param {string} entryID
|
|
470
|
-
* @returns Sdk
|
|
471
|
-
*/
|
|
472
|
-
entryID(t) {
|
|
473
|
-
return this.set({ entryID: t });
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Sets the id of the entry to use. Alias for `entryID`
|
|
477
|
-
* @param {string} entryID
|
|
478
|
-
* @returns Sdk
|
|
479
|
-
*/
|
|
480
|
-
entry(t) {
|
|
481
|
-
return this.entryID(t);
|
|
482
|
-
}
|
|
483
550
|
/**
|
|
484
551
|
* Sets the name of the asset group to use.
|
|
485
552
|
* @param {string} assetGroup name of the asset group
|
|
@@ -496,26 +563,10 @@ class b {
|
|
|
496
563
|
assetgroup(t) {
|
|
497
564
|
return this.assetGroup(t);
|
|
498
565
|
}
|
|
499
|
-
/**
|
|
500
|
-
* Sets the id of the asset to use
|
|
501
|
-
* @param {string} assetID
|
|
502
|
-
* @returns Sdk
|
|
503
|
-
*/
|
|
504
|
-
assetID(t) {
|
|
505
|
-
return this.set({ assetID: t });
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Sets the id of the asset to use. Alias for `assetID`
|
|
509
|
-
* @param {string} assetID
|
|
510
|
-
* @returns Sdk
|
|
511
|
-
*/
|
|
512
|
-
asset(t) {
|
|
513
|
-
return this.assetID(t);
|
|
514
|
-
}
|
|
515
566
|
}
|
|
516
|
-
const it = (n) => new
|
|
567
|
+
const it = (n) => new A({ env: n });
|
|
517
568
|
export {
|
|
518
|
-
|
|
569
|
+
rt as act,
|
|
519
570
|
y as apiURL,
|
|
520
571
|
H as assetList,
|
|
521
572
|
Q as createAsset,
|
|
@@ -523,16 +574,16 @@ export {
|
|
|
523
574
|
G as deleteEntry,
|
|
524
575
|
F as editEntry,
|
|
525
576
|
J as entryList,
|
|
526
|
-
|
|
527
|
-
|
|
577
|
+
g as expect,
|
|
578
|
+
d as fetcher,
|
|
528
579
|
M as getAsset,
|
|
529
|
-
|
|
580
|
+
z as getEcAuthKey,
|
|
530
581
|
N as getEntry,
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
582
|
+
R as getPublicAuthKey,
|
|
583
|
+
C as loginEc,
|
|
584
|
+
S as loginPublic,
|
|
585
|
+
x as logoutEc,
|
|
586
|
+
q as logoutPublic,
|
|
587
|
+
$ as query,
|
|
537
588
|
it as sdk
|
|
538
589
|
};
|
package/dist/lib/api.d.mts
CHANGED
|
@@ -5,37 +5,129 @@ declare class Sdk {
|
|
|
5
5
|
constructor(config: any);
|
|
6
6
|
config: any;
|
|
7
7
|
set(obj: any): Sdk;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
10
|
+
* If the model is not public, you also need to provide a `token`.
|
|
11
|
+
*
|
|
12
|
+
* @param {object=} options options for entry list request.
|
|
13
|
+
* @returns {{ count: number, total: number, items: object[] }}
|
|
14
|
+
* @example
|
|
15
|
+
* // public model
|
|
16
|
+
* const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
|
|
17
|
+
* @example
|
|
18
|
+
* // non-public model
|
|
19
|
+
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
20
|
+
*/
|
|
21
|
+
entries(options?: object | undefined): {
|
|
22
|
+
count: number;
|
|
23
|
+
total: number;
|
|
24
|
+
items: object[];
|
|
25
|
+
};
|
|
14
26
|
entryList(options: any): Promise<{
|
|
15
|
-
count:
|
|
16
|
-
total:
|
|
17
|
-
items:
|
|
18
|
-
}>;
|
|
19
|
-
assets(options: any): Promise<{
|
|
20
|
-
count: any;
|
|
21
|
-
total: any;
|
|
22
|
-
items: any;
|
|
27
|
+
count: number;
|
|
28
|
+
total: number;
|
|
29
|
+
items: object[];
|
|
23
30
|
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Loads a single entry. Expects `dmShortID` / `model` to be set.
|
|
33
|
+
* If the model is not public, you also need to provide a `token`.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} entryID
|
|
36
|
+
* @returns {object}
|
|
37
|
+
* @example
|
|
38
|
+
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
39
|
+
*/
|
|
40
|
+
getEntry(entryID: string): object;
|
|
41
|
+
/**
|
|
42
|
+
* Loads asset list. Expects `dmShortID` / `assetGroup` to be set.
|
|
43
|
+
* If the assetGroup is not public, you also need to provide a `token`.
|
|
44
|
+
*
|
|
45
|
+
* @param {object=} options options for entry list request.
|
|
46
|
+
* @returns {{ count: number, total: number, items: object[] }}
|
|
47
|
+
* @example
|
|
48
|
+
* // public assetGroup
|
|
49
|
+
* const files = await sdk("stage").dm("83cc6374").assetGroup("avatars").assets()
|
|
50
|
+
* @example
|
|
51
|
+
* // non-public assetGroup
|
|
52
|
+
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
53
|
+
*/
|
|
54
|
+
assets(options?: object | undefined): {
|
|
55
|
+
count: number;
|
|
56
|
+
total: number;
|
|
57
|
+
items: object[];
|
|
58
|
+
};
|
|
24
59
|
assetList(options: any): Promise<{
|
|
25
|
-
count:
|
|
26
|
-
total:
|
|
27
|
-
items:
|
|
60
|
+
count: number;
|
|
61
|
+
total: number;
|
|
62
|
+
items: object[];
|
|
28
63
|
}>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Uploads an asset. Expects `dmShortID` / `assetGroup` / `file` to be set.
|
|
66
|
+
* If the assetGroup is not public, you also need to provide a `token`.
|
|
67
|
+
*
|
|
68
|
+
* @param {object=} options options for entry list request.
|
|
69
|
+
* @returns {{ count: number, total: number, items: object[] }}
|
|
70
|
+
* @example
|
|
71
|
+
* // browser example
|
|
72
|
+
* document.getElementById("file").addEventListener("input", async (e) => {
|
|
73
|
+
* const [file] = e.target.files;
|
|
74
|
+
* const asset = await ecadmin.assetgroup("test").createAsset({ file })
|
|
75
|
+
* });
|
|
76
|
+
* @example
|
|
77
|
+
* // node example
|
|
78
|
+
* const buf = fs.readFileSync("venndiagram.png");
|
|
79
|
+
* const file = new Blob([buf]);
|
|
80
|
+
* const upload = await sdk("stage")
|
|
81
|
+
* .dm("83cc6374")
|
|
82
|
+
* .assetgroup("test")
|
|
83
|
+
* .createAsset({ file, name: "venndiagram.png" });
|
|
84
|
+
*/
|
|
85
|
+
createAsset({ file, name }?: object | undefined): {
|
|
86
|
+
count: number;
|
|
87
|
+
total: number;
|
|
88
|
+
items: object[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Loads a single asset. Expects `dmShortID` / `assetGroup` to be set.
|
|
92
|
+
* If the asset group is not public, you also need to provide a `token`.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} assetID
|
|
95
|
+
* @returns {object}
|
|
96
|
+
* @example
|
|
97
|
+
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
98
|
+
*/
|
|
99
|
+
getAsset(assetID: string): object;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new entry. Expects `dmShortID` / `model` to be set.
|
|
102
|
+
* If model POST is not public, you also need to provide a `token`.
|
|
103
|
+
*
|
|
104
|
+
* @param {object} value values to set.
|
|
105
|
+
* @returns {object}
|
|
106
|
+
* @example
|
|
107
|
+
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
108
|
+
*/
|
|
109
|
+
createEntry(value: object): object;
|
|
110
|
+
/**
|
|
111
|
+
* Edits an entry. Expects `dmShortID` / `model` to be set.
|
|
112
|
+
* If model PUT is not public, you also need to provide a `token`.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} entryID id of entry to edit
|
|
115
|
+
* @param {object} value values to set. undefined fields are ignored
|
|
116
|
+
* @returns {object}
|
|
117
|
+
* @example
|
|
118
|
+
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
119
|
+
*/
|
|
120
|
+
editEntry(entryID: string, value: object): object;
|
|
121
|
+
/**
|
|
122
|
+
* Deletes an entry. Expects `dmShortID` / `model` to be set.
|
|
123
|
+
* If model DELETE is not public, you also need to provide a `token`.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} entryID id of entry to delete
|
|
126
|
+
* @returns {object}
|
|
127
|
+
* @example
|
|
128
|
+
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
129
|
+
*/
|
|
130
|
+
deleteEntry(entryID: string): object;
|
|
39
131
|
authAdapter(authAdapter: any): Sdk;
|
|
40
132
|
setAuth(key: any): (auth: any) => any;
|
|
41
133
|
unsetAuth(key: any): (auth: any) => any;
|
|
@@ -74,18 +166,6 @@ declare class Sdk {
|
|
|
74
166
|
* @returns Sdk
|
|
75
167
|
*/
|
|
76
168
|
dm(dmShortID: string): Sdk;
|
|
77
|
-
/**
|
|
78
|
-
* Sets the id of the entry to use
|
|
79
|
-
* @param {string} entryID
|
|
80
|
-
* @returns Sdk
|
|
81
|
-
*/
|
|
82
|
-
entryID(entryID: string): Sdk;
|
|
83
|
-
/**
|
|
84
|
-
* Sets the id of the entry to use. Alias for `entryID`
|
|
85
|
-
* @param {string} entryID
|
|
86
|
-
* @returns Sdk
|
|
87
|
-
*/
|
|
88
|
-
entry(entryID: string): Sdk;
|
|
89
169
|
/**
|
|
90
170
|
* Sets the name of the asset group to use.
|
|
91
171
|
* @param {string} assetGroup name of the asset group
|
|
@@ -98,17 +178,5 @@ declare class Sdk {
|
|
|
98
178
|
* @returns Sdk
|
|
99
179
|
*/
|
|
100
180
|
assetgroup(assetGroup: string): Sdk;
|
|
101
|
-
/**
|
|
102
|
-
* Sets the id of the asset to use
|
|
103
|
-
* @param {string} assetID
|
|
104
|
-
* @returns Sdk
|
|
105
|
-
*/
|
|
106
|
-
assetID(assetID: string): Sdk;
|
|
107
|
-
/**
|
|
108
|
-
* Sets the id of the asset to use. Alias for `assetID`
|
|
109
|
-
* @param {string} assetID
|
|
110
|
-
* @returns Sdk
|
|
111
|
-
*/
|
|
112
|
-
asset(assetID: string): Sdk;
|
|
113
181
|
}
|
|
114
182
|
//# sourceMappingURL=api.d.mts.map
|
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":"AAqBA,sCAWC;;
|
|
1
|
+
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAqBA,sCAWC;;AAyRM,mCAAqC;AAvR5C;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAW7D;IACD;eAZsB,MAAM;eAAS,MAAM;eAAS,MAAM,EAAE;OAc3D;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,MAAM,CAOlB;IACD;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,eACJ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAW7D;IACD;eAZsB,MAAM;eAAS,MAAM;eAAS,MAAM,EAAE;OAc3D;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,6BAjBW,MAAM,eACJ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAmB7D;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,MAAM,CAOlB;IAED;;;;;;;;OAQG;IACH,mBALW,MAAM,GACJ,MAAM,CAOlB;IACD;;;;;;;;;OASG;IACH,mBANW,MAAM,SACN,MAAM,GACJ,MAAM,CAOlB;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,MAAM,CAOlB;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"}
|