ec.fdk 0.2.12 → 0.2.14
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 +3 -1
- package/dist/index.mjs +141 -131
- package/dist/lib/assets.d.mts.map +1 -1
- package/dist/lib/util.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var v=Object.defineProperty,M=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var P=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))G.call(t,e)&&P(n,e,t[e]);if(T)for(var e of T(t))H.call(t,e)&&P(n,e,t[e]);return n},y=(n,t)=>M(n,F(t));var i=(n,t,e)=>new Promise((s,o)=>{var a=u=>{try{g(e.next(u))}catch(l){o(l)}},r=u=>{try{g(e.throw(u))}catch(l){o(l)}},g=u=>u.done?s(u.value):Promise.resolve(u.value).then(a,r);g((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 g;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((g=r.headers.get("content-type"))!=null&&g.includes("application/json")){const u=yield r.json(),l=`${u.title}
|
|
2
|
+
${u.detail}
|
|
3
|
+
${u.verbose}`;throw new Error(l)}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 $(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 S(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 B({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=$(o),r=f(`api/${e}/${s}?${a}`,t),{count:g,total:u,_embedded:l}=yield d(r,n),p=l?l[`${e}:${s}`]:[];return{count:g,total:u,items:p}})}function x({env:n,dmShortID:t,model:e,entryID:s,token:o}){h({env:n,dmShortID:t,model:e,entryID:s});const a=$({_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 g=f(`api/${t}/${e}?_id=${s}`,n);return yield d(g,{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=$({assetID:s}),g=f(`a/${t}/${e}?${r}`,n);return(yield d(g,{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=$(a),g=f(`a/${e}/${s}?${r}`,t),{count:u,total:l,_embedded:p}=yield d(g,{dmShortID:e,token:o}),E=p?p["ec:dm-asset"]:[];return{count:u,total:l,items:E}})}function U(g){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),l=new FormData;return l.append("file",o,a),r&&Object.keys(r).forEach(E=>{l.append(E,r[E])}),(yield d(u,{token:s},{method:"POST",body:l}))._embedded["ec:dm-asset"]})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:U,createEntry:C,deleteEntry:z,editEntry:R,entryList:q,getAsset:J,getEcAuthKey:K,getEntry:x,getPublicAuthKey:B,loginEc:_,loginPublic:O,logoutEc:S,logoutPublic:L},Symbol.toStringTag,{value:"Module"})),{entryList:Q,getEntry:V,getAsset:W,assetList:X,createAsset:Y,createEntry:Z,editEntry:D,deleteEntry:I,loginPublic:tt,loginEc:et,logoutEc:nt,logoutPublic:st,getEcAuthKey:b,getPublicAuthKey:A}=k;function ot(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 w{constructor(t){this.config=t}set(t){return new w(c(c({},this.config),t))}entries(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return Q(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 V(y(c({},this.config),{entryID:t,token:e}))})}assets(t){return i(this,null,function*(){const e=yield this.getBestToken();return X(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 Y(y(c({},this.config),{file:t,name:e,options:s,token:o}))})}getAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return W(y(c({},this.config),{assetID:t,token:e}))})}createEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return Z(y(c({},this.config),{token:e,value:t}))})}editEntry(t,e){return i(this,null,function*(){const s=yield this.getBestToken();return D(y(c({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return I(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 et(c(c({},this.config),t)).then(this.setAuth(b(this.config)))}loginPublic(t){return tt(c(c({},this.config),t)).then(this.setAuth(A(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(y(c({},this.config),{token:t})).then(this.unsetAuth(A(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(y(c({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}getPublicToken(){return this.config.token||this.getAuth(A(this.config))}getEcToken(){return this.config.token||this.getAuth(b(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 w({env:n});exports.Sdk=w;exports.act=ot;exports.apiURL=f;exports.assetList=N;exports.createAsset=U;exports.createEntry=C;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=B;exports.loginEc=_;exports.loginPublic=O;exports.logoutEc=S;exports.logoutPublic=L;exports.query=$;exports.sdk=rt;
|
package/dist/index.mjs
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O = Object.defineProperty, _ = Object.defineProperties;
|
|
2
2
|
var L = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var T = Object.getOwnPropertySymbols;
|
|
4
4
|
var B = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var P = (n, t, e) => t in n ?
|
|
5
|
+
var P = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, c = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
7
|
B.call(t, e) && P(n, e, t[e]);
|
|
8
8
|
if (T)
|
|
9
9
|
for (var e of T(t))
|
|
10
10
|
K.call(t, e) && P(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, d = (n, t) => _(n, L(t));
|
|
13
|
+
var i = (n, t, e) => new Promise((s, o) => {
|
|
14
14
|
var a = (u) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
o(
|
|
16
|
+
h(e.next(u));
|
|
17
|
+
} catch (l) {
|
|
18
|
+
o(l);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, r = (u) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
o(
|
|
22
|
+
h(e.throw(u));
|
|
23
|
+
} catch (l) {
|
|
24
|
+
o(l);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, h = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(a, r);
|
|
27
|
+
h((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
|
-
function
|
|
30
|
-
return
|
|
29
|
+
function y(s) {
|
|
30
|
+
return i(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
|
+
var h;
|
|
31
32
|
const { token: o, rawRes: a } = t;
|
|
32
|
-
o && (e.headers =
|
|
33
|
+
o && (e.headers = d(c({}, e.headers || {}), {
|
|
33
34
|
Authorization: `Bearer ${o}`
|
|
34
35
|
}));
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const r = yield fetch(n, e);
|
|
37
|
+
if (!r.ok) {
|
|
38
|
+
if ((h = r.headers.get("content-type")) != null && h.includes("application/json")) {
|
|
39
|
+
const u = yield r.json(), l = `${u.title}
|
|
40
|
+
${u.detail}
|
|
41
|
+
${u.verbose}`;
|
|
42
|
+
throw new Error(l);
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`unexpected fetch error: ${r.statusText}`);
|
|
45
|
+
}
|
|
46
|
+
return a ? r : yield r.json();
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
const m = {
|
|
@@ -50,25 +58,25 @@ function f(n, t = "stage") {
|
|
|
50
58
|
);
|
|
51
59
|
return e + n;
|
|
52
60
|
}
|
|
53
|
-
function
|
|
61
|
+
function k(n, t = !0) {
|
|
54
62
|
return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
|
|
55
63
|
}
|
|
56
|
-
function
|
|
64
|
+
function g(n) {
|
|
57
65
|
Object.entries(n).forEach(([t, e]) => {
|
|
58
66
|
if (e === void 0)
|
|
59
67
|
throw new Error(`expected ${t} to be set!`);
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
|
-
const
|
|
70
|
+
const j = {
|
|
63
71
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
64
72
|
live: "https://accounts.entrecode.de/"
|
|
65
73
|
};
|
|
66
74
|
function S(n) {
|
|
67
|
-
return
|
|
75
|
+
return i(this, null, function* () {
|
|
68
76
|
let { env: t, dmShortID: e, email: s, password: o } = n;
|
|
69
|
-
|
|
77
|
+
g({ env: t, dmShortID: e, email: s, password: o });
|
|
70
78
|
const a = f(`api/${e}/_auth/login?clientID=rest`, t);
|
|
71
|
-
return yield
|
|
79
|
+
return yield y(
|
|
72
80
|
a,
|
|
73
81
|
{},
|
|
74
82
|
{
|
|
@@ -81,12 +89,12 @@ function S(n) {
|
|
|
81
89
|
);
|
|
82
90
|
});
|
|
83
91
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
92
|
+
function x(n) {
|
|
93
|
+
return i(this, null, function* () {
|
|
86
94
|
let { env: t, email: e, password: s } = n;
|
|
87
|
-
|
|
88
|
-
const o = `${
|
|
89
|
-
return yield
|
|
95
|
+
g({ env: t, email: e, password: s });
|
|
96
|
+
const o = `${j[t]}auth/login?clientID=rest`;
|
|
97
|
+
return yield y(
|
|
90
98
|
o,
|
|
91
99
|
{},
|
|
92
100
|
{
|
|
@@ -100,14 +108,14 @@ function q(n) {
|
|
|
100
108
|
});
|
|
101
109
|
}
|
|
102
110
|
function C(n) {
|
|
103
|
-
return
|
|
111
|
+
return i(this, null, function* () {
|
|
104
112
|
let { dmShortID: t, env: e, token: s } = n;
|
|
105
|
-
|
|
113
|
+
g({ dmShortID: t, env: e, token: s });
|
|
106
114
|
const o = f(
|
|
107
115
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
108
116
|
e
|
|
109
117
|
);
|
|
110
|
-
return yield
|
|
118
|
+
return yield y(
|
|
111
119
|
o,
|
|
112
120
|
{ dmShortID: t, rawRes: !0 },
|
|
113
121
|
{
|
|
@@ -116,12 +124,12 @@ function C(n) {
|
|
|
116
124
|
);
|
|
117
125
|
});
|
|
118
126
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
127
|
+
function q(n) {
|
|
128
|
+
return i(this, null, function* () {
|
|
121
129
|
let { env: t, token: e } = n;
|
|
122
|
-
|
|
123
|
-
const s = `${
|
|
124
|
-
return yield
|
|
130
|
+
g({ env: t, token: e });
|
|
131
|
+
const s = `${j[t]}auth/logout?clientID=rest`;
|
|
132
|
+
return yield y(
|
|
125
133
|
s,
|
|
126
134
|
{
|
|
127
135
|
rawRes: !0,
|
|
@@ -134,30 +142,30 @@ function x(n) {
|
|
|
134
142
|
});
|
|
135
143
|
}
|
|
136
144
|
function R({ dmShortID: n }) {
|
|
137
|
-
return
|
|
145
|
+
return g({ dmShortID: n }), n;
|
|
138
146
|
}
|
|
139
147
|
function z({ env: n }) {
|
|
140
|
-
return
|
|
148
|
+
return g({ env: n }), n;
|
|
141
149
|
}
|
|
142
150
|
function J(n) {
|
|
143
|
-
return
|
|
151
|
+
return i(this, null, function* () {
|
|
144
152
|
let { env: t, dmShortID: e, model: s, options: o = {} } = n;
|
|
145
|
-
|
|
146
|
-
const a =
|
|
147
|
-
return { count:
|
|
153
|
+
g({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
|
|
154
|
+
const a = k(o), r = f(`api/${e}/${s}?${a}`, t), { count: h, total: u, _embedded: l } = yield y(r, n), p = l ? l[`${e}:${s}`] : [];
|
|
155
|
+
return { count: h, total: u, items: p };
|
|
148
156
|
});
|
|
149
157
|
}
|
|
150
158
|
function N({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
|
|
151
|
-
|
|
152
|
-
const a =
|
|
153
|
-
return
|
|
159
|
+
g({ env: n, dmShortID: t, model: e, entryID: s });
|
|
160
|
+
const a = k({ _id: s }), r = f(`api/${t}/${e}?${a}`, n);
|
|
161
|
+
return y(r, { dmShortID: t, token: o });
|
|
154
162
|
}
|
|
155
163
|
function U(a) {
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
return console.log("url",
|
|
160
|
-
|
|
164
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: o }) {
|
|
165
|
+
g({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
|
|
166
|
+
const r = f(`api/${t}/${e}`, n);
|
|
167
|
+
return console.log("url", r), yield y(
|
|
168
|
+
r,
|
|
161
169
|
{ env: n, dmShortID: t, token: o },
|
|
162
170
|
{
|
|
163
171
|
method: "POST",
|
|
@@ -169,8 +177,8 @@ function U(a) {
|
|
|
169
177
|
);
|
|
170
178
|
});
|
|
171
179
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
180
|
+
function v(r) {
|
|
181
|
+
return i(this, arguments, function* ({
|
|
174
182
|
env: n,
|
|
175
183
|
dmShortID: t,
|
|
176
184
|
model: e,
|
|
@@ -178,10 +186,10 @@ function F(i) {
|
|
|
178
186
|
value: o,
|
|
179
187
|
token: a
|
|
180
188
|
}) {
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
return yield
|
|
184
|
-
|
|
189
|
+
g({ env: n, dmShortID: t, model: e, entryID: s, value: o });
|
|
190
|
+
const h = f(`api/${t}/${e}?_id=${s}`, n);
|
|
191
|
+
return yield y(
|
|
192
|
+
h,
|
|
185
193
|
{ token: a },
|
|
186
194
|
{
|
|
187
195
|
method: "PUT",
|
|
@@ -193,12 +201,12 @@ function F(i) {
|
|
|
193
201
|
);
|
|
194
202
|
});
|
|
195
203
|
}
|
|
196
|
-
function
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
yield
|
|
201
|
-
|
|
204
|
+
function F(a) {
|
|
205
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
|
|
206
|
+
g({ env: n, dmShortID: t, model: e, entryID: s });
|
|
207
|
+
const r = f(`api/${t}/${e}?_id=${s}`, n);
|
|
208
|
+
yield y(
|
|
209
|
+
r,
|
|
202
210
|
{ token: o, rawRes: !0 },
|
|
203
211
|
{
|
|
204
212
|
method: "DELETE",
|
|
@@ -209,58 +217,60 @@ function G(a) {
|
|
|
209
217
|
);
|
|
210
218
|
});
|
|
211
219
|
}
|
|
212
|
-
function
|
|
213
|
-
return
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
return (yield
|
|
220
|
+
function G(a) {
|
|
221
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: o }) {
|
|
222
|
+
g({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
223
|
+
const r = k({ assetID: s }), h = f(`a/${t}/${e}?${r}`, n);
|
|
224
|
+
return (yield y(h, { dmShortID: t, token: o }))._embedded["ec:dm-asset"];
|
|
217
225
|
});
|
|
218
226
|
}
|
|
219
|
-
function
|
|
220
|
-
return
|
|
227
|
+
function M(n) {
|
|
228
|
+
return i(this, null, function* () {
|
|
221
229
|
let { env: t, dmShortID: e, assetGroup: s, token: o, options: a = {} } = n;
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
return { count: u, total:
|
|
230
|
+
g({ env: t, dmShortID: e, assetGroup: s }), a = c({ size: 50, page: 1, _list: !0 }, a);
|
|
231
|
+
const r = k(a), h = f(`a/${e}/${s}?${r}`, t), { count: u, total: l, _embedded: p } = yield y(h, { dmShortID: e, token: o }), $ = p ? p["ec:dm-asset"] : [];
|
|
232
|
+
return { count: u, total: l, items: $ };
|
|
225
233
|
});
|
|
226
234
|
}
|
|
227
|
-
function H(
|
|
228
|
-
return
|
|
235
|
+
function H(h) {
|
|
236
|
+
return i(this, arguments, function* ({
|
|
229
237
|
env: n,
|
|
230
238
|
dmShortID: t,
|
|
231
239
|
assetGroup: e,
|
|
232
240
|
token: s,
|
|
233
241
|
file: o,
|
|
234
242
|
name: a,
|
|
235
|
-
options:
|
|
243
|
+
options: r
|
|
236
244
|
}) {
|
|
237
|
-
|
|
238
|
-
const u =
|
|
239
|
-
return
|
|
240
|
-
|
|
245
|
+
g({ env: n, dmShortID: t, assetGroup: e, file: o });
|
|
246
|
+
const u = f(`a/${t}/${e}`, n), l = new FormData();
|
|
247
|
+
return l.append("file", o, a), r && Object.keys(r).forEach(($) => {
|
|
248
|
+
l.append($, r[$]);
|
|
249
|
+
}), (yield y(
|
|
250
|
+
u,
|
|
241
251
|
{ token: s },
|
|
242
252
|
{
|
|
243
253
|
method: "POST",
|
|
244
|
-
body:
|
|
254
|
+
body: l
|
|
245
255
|
}
|
|
246
256
|
))._embedded["ec:dm-asset"];
|
|
247
257
|
});
|
|
248
258
|
}
|
|
249
259
|
const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
250
260
|
__proto__: null,
|
|
251
|
-
assetList:
|
|
261
|
+
assetList: M,
|
|
252
262
|
createAsset: H,
|
|
253
263
|
createEntry: U,
|
|
254
|
-
deleteEntry:
|
|
255
|
-
editEntry:
|
|
264
|
+
deleteEntry: F,
|
|
265
|
+
editEntry: v,
|
|
256
266
|
entryList: J,
|
|
257
|
-
getAsset:
|
|
267
|
+
getAsset: G,
|
|
258
268
|
getEcAuthKey: z,
|
|
259
269
|
getEntry: N,
|
|
260
270
|
getPublicAuthKey: R,
|
|
261
|
-
loginEc:
|
|
271
|
+
loginEc: x,
|
|
262
272
|
loginPublic: S,
|
|
263
|
-
logoutEc:
|
|
273
|
+
logoutEc: q,
|
|
264
274
|
logoutPublic: C
|
|
265
275
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
266
276
|
entryList: Q,
|
|
@@ -275,12 +285,12 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
275
285
|
loginEc: et,
|
|
276
286
|
logoutEc: nt,
|
|
277
287
|
logoutPublic: st,
|
|
278
|
-
getEcAuthKey:
|
|
279
|
-
getPublicAuthKey:
|
|
288
|
+
getEcAuthKey: w,
|
|
289
|
+
getPublicAuthKey: A
|
|
280
290
|
} = E;
|
|
281
291
|
function rt(n) {
|
|
282
292
|
const { action: t } = n;
|
|
283
|
-
if (
|
|
293
|
+
if (g({ action: t }), !E[t])
|
|
284
294
|
throw new Error(
|
|
285
295
|
`"${t}" does not exist! try one of ${Object.keys(E).join(
|
|
286
296
|
", "
|
|
@@ -288,12 +298,12 @@ function rt(n) {
|
|
|
288
298
|
);
|
|
289
299
|
return E[t](n);
|
|
290
300
|
}
|
|
291
|
-
class
|
|
301
|
+
class b {
|
|
292
302
|
constructor(t) {
|
|
293
303
|
this.config = t;
|
|
294
304
|
}
|
|
295
305
|
set(t) {
|
|
296
|
-
return new
|
|
306
|
+
return new b(c(c({}, this.config), t));
|
|
297
307
|
}
|
|
298
308
|
/**
|
|
299
309
|
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
@@ -309,13 +319,13 @@ class A {
|
|
|
309
319
|
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
310
320
|
*/
|
|
311
321
|
entries() {
|
|
312
|
-
return
|
|
322
|
+
return i(this, arguments, function* (t = {}) {
|
|
313
323
|
const e = yield this.getBestToken();
|
|
314
|
-
return Q(
|
|
324
|
+
return Q(d(c({}, this.config), { options: t, token: e }));
|
|
315
325
|
});
|
|
316
326
|
}
|
|
317
327
|
entryList(t) {
|
|
318
|
-
return
|
|
328
|
+
return i(this, null, function* () {
|
|
319
329
|
return this.entries(t);
|
|
320
330
|
});
|
|
321
331
|
}
|
|
@@ -329,9 +339,9 @@ class A {
|
|
|
329
339
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
330
340
|
*/
|
|
331
341
|
getEntry(t) {
|
|
332
|
-
return
|
|
342
|
+
return i(this, null, function* () {
|
|
333
343
|
const e = yield this.getBestToken();
|
|
334
|
-
return V(
|
|
344
|
+
return V(d(c({}, this.config), { entryID: t, token: e }));
|
|
335
345
|
});
|
|
336
346
|
}
|
|
337
347
|
/**
|
|
@@ -348,13 +358,13 @@ class A {
|
|
|
348
358
|
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
349
359
|
*/
|
|
350
360
|
assets(t) {
|
|
351
|
-
return
|
|
361
|
+
return i(this, null, function* () {
|
|
352
362
|
const e = yield this.getBestToken();
|
|
353
|
-
return X(
|
|
363
|
+
return X(d(c({}, this.config), { options: t, token: e }));
|
|
354
364
|
});
|
|
355
365
|
}
|
|
356
366
|
assetList(t) {
|
|
357
|
-
return
|
|
367
|
+
return i(this, null, function* () {
|
|
358
368
|
return this.assets(t);
|
|
359
369
|
});
|
|
360
370
|
}
|
|
@@ -380,9 +390,9 @@ class A {
|
|
|
380
390
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
381
391
|
*/
|
|
382
392
|
createAsset() {
|
|
383
|
-
return
|
|
393
|
+
return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
384
394
|
const o = yield this.getBestToken();
|
|
385
|
-
return Y(
|
|
395
|
+
return Y(d(c({}, this.config), { file: t, name: e, options: s, token: o }));
|
|
386
396
|
});
|
|
387
397
|
}
|
|
388
398
|
/**
|
|
@@ -395,9 +405,9 @@ class A {
|
|
|
395
405
|
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
396
406
|
*/
|
|
397
407
|
getAsset(t) {
|
|
398
|
-
return
|
|
408
|
+
return i(this, null, function* () {
|
|
399
409
|
const e = yield this.getBestToken();
|
|
400
|
-
return W(
|
|
410
|
+
return W(d(c({}, this.config), { assetID: t, token: e }));
|
|
401
411
|
});
|
|
402
412
|
}
|
|
403
413
|
/**
|
|
@@ -410,9 +420,9 @@ class A {
|
|
|
410
420
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
411
421
|
*/
|
|
412
422
|
createEntry(t) {
|
|
413
|
-
return
|
|
423
|
+
return i(this, null, function* () {
|
|
414
424
|
const e = yield this.getBestToken();
|
|
415
|
-
return Z(
|
|
425
|
+
return Z(d(c({}, this.config), { token: e, value: t }));
|
|
416
426
|
});
|
|
417
427
|
}
|
|
418
428
|
/**
|
|
@@ -426,9 +436,9 @@ class A {
|
|
|
426
436
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
427
437
|
*/
|
|
428
438
|
editEntry(t, e) {
|
|
429
|
-
return
|
|
439
|
+
return i(this, null, function* () {
|
|
430
440
|
const s = yield this.getBestToken();
|
|
431
|
-
return D(
|
|
441
|
+
return D(d(c({}, this.config), { entryID: t, token: s, value: e }));
|
|
432
442
|
});
|
|
433
443
|
}
|
|
434
444
|
/**
|
|
@@ -441,9 +451,9 @@ class A {
|
|
|
441
451
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
442
452
|
*/
|
|
443
453
|
deleteEntry(t) {
|
|
444
|
-
return
|
|
454
|
+
return i(this, null, function* () {
|
|
445
455
|
const e = yield this.getBestToken();
|
|
446
|
-
return I(
|
|
456
|
+
return I(d(c({}, this.config), { token: e, entryID: t }));
|
|
447
457
|
});
|
|
448
458
|
}
|
|
449
459
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -474,31 +484,31 @@ class A {
|
|
|
474
484
|
}
|
|
475
485
|
loginEc(t) {
|
|
476
486
|
return et(c(c({}, this.config), t)).then(
|
|
477
|
-
this.setAuth(
|
|
487
|
+
this.setAuth(w(this.config))
|
|
478
488
|
);
|
|
479
489
|
}
|
|
480
490
|
loginPublic(t) {
|
|
481
491
|
return tt(c(c({}, this.config), t)).then(
|
|
482
|
-
this.setAuth(
|
|
492
|
+
this.setAuth(A(this.config))
|
|
483
493
|
);
|
|
484
494
|
}
|
|
485
495
|
logoutPublic() {
|
|
486
496
|
const t = this.getPublicToken();
|
|
487
|
-
return console.log("token", t), st(
|
|
488
|
-
this.unsetAuth(
|
|
497
|
+
return console.log("token", t), st(d(c({}, this.config), { token: t })).then(
|
|
498
|
+
this.unsetAuth(A(this.config))
|
|
489
499
|
);
|
|
490
500
|
}
|
|
491
501
|
logoutEc() {
|
|
492
502
|
const t = this.getEcToken();
|
|
493
|
-
return console.log("token", t), nt(
|
|
494
|
-
this.unsetAuth(
|
|
503
|
+
return console.log("token", t), nt(d(c({}, this.config), { token: t })).then(
|
|
504
|
+
this.unsetAuth(w(this.config))
|
|
495
505
|
);
|
|
496
506
|
}
|
|
497
507
|
getPublicToken() {
|
|
498
|
-
return this.config.token || this.getAuth(
|
|
508
|
+
return this.config.token || this.getAuth(A(this.config));
|
|
499
509
|
}
|
|
500
510
|
getEcToken() {
|
|
501
|
-
return this.config.token || this.getAuth(
|
|
511
|
+
return this.config.token || this.getAuth(w(this.config));
|
|
502
512
|
}
|
|
503
513
|
hasPublicToken() {
|
|
504
514
|
return !!this.getPublicToken();
|
|
@@ -565,27 +575,27 @@ class A {
|
|
|
565
575
|
return this.assetGroup(t);
|
|
566
576
|
}
|
|
567
577
|
}
|
|
568
|
-
const it = (n) => new
|
|
578
|
+
const it = (n) => new b({ env: n });
|
|
569
579
|
export {
|
|
570
|
-
|
|
580
|
+
b as Sdk,
|
|
571
581
|
rt as act,
|
|
572
582
|
f as apiURL,
|
|
573
|
-
|
|
583
|
+
M as assetList,
|
|
574
584
|
H as createAsset,
|
|
575
585
|
U as createEntry,
|
|
576
|
-
|
|
577
|
-
|
|
586
|
+
F as deleteEntry,
|
|
587
|
+
v as editEntry,
|
|
578
588
|
J as entryList,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
589
|
+
g as expect,
|
|
590
|
+
y as fetcher,
|
|
591
|
+
G as getAsset,
|
|
582
592
|
z as getEcAuthKey,
|
|
583
593
|
N as getEntry,
|
|
584
594
|
R as getPublicAuthKey,
|
|
585
|
-
|
|
595
|
+
x as loginEc,
|
|
586
596
|
S as loginPublic,
|
|
587
|
-
|
|
597
|
+
q as logoutEc,
|
|
588
598
|
C as logoutPublic,
|
|
589
|
-
|
|
599
|
+
k as query,
|
|
590
600
|
it as sdk
|
|
591
601
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAUC;AAED;;;;;;;;
|
|
1
|
+
{"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAUC;AAED;;;;;;;;iBA6BC"}
|
package/dist/lib/util.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAOD,sDAQC;AAED,wDAKC;AAED,uCAMC"}
|