ec.fdk 0.2.12 → 0.2.13
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 +98 -96
- package/dist/lib/assets.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty,v=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?M(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},
|
|
1
|
+
"use strict";var M=Object.defineProperty,v=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?M(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)=>v(n,F(t));var i=(n,t,e)=>new Promise((s,o)=>{var a=h=>{try{l(e.next(h))}catch(d){o(d)}},r=h=>{try{l(e.throw(h))}catch(d){o(d)}},l=h=>h.done?s(h.value):Promise.resolve(h.value).then(a,r);l((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return i(this,arguments,function*(n,t={},e={}){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)throw new 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 u(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const O={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function j(n){return i(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;u({env:t,dmShortID:e,email:s,password:o});const a=f(`api/${e}/_auth/login?clientID=rest`,t);return yield g(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;u({env:t,email:e,password:s});const o=`${O[t]}auth/login?clientID=rest`;return yield g(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;u({dmShortID:t,env:e,token:s});const o=f(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function S(n){return i(this,null,function*(){let{env:t,token:e}=n;u({env:t,token:e});const s=`${O[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function B({dmShortID:n}){return u({dmShortID:n}),n}function K({env:n}){return u({env:n}),n}function q(n){return i(this,null,function*(){let{env:t,dmShortID:e,model:s,options:o={}}=n;u({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:h,_embedded:d}=yield g(r,n),p=d?d[`${e}:${s}`]:[];return{count:l,total:h,items:p}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:o}){u({env:n,dmShortID:t,model:e,entryID:s});const a=E({_id:s}),r=f(`api/${t}/${e}?${a}`,n);return g(r,{dmShortID:t,token:o})}function R(a){return i(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:o}){u({env:n,dmShortID:t,model:e,value:s}),console.log("create entry",t,e,s);const r=f(`api/${t}/${e}`,n);return console.log("url",r),yield g(r,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function x(r){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:a}){u({env:n,dmShortID:t,model:e,entryID:s,value:o});const l=f(`api/${t}/${e}?_id=${s}`,n);return yield g(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}){u({env:n,dmShortID:t,model:e,entryID:s});const r=f(`api/${t}/${e}?_id=${s}`,n);yield g(r,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function J(a){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){u({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=E({assetID:s}),l=f(`a/${t}/${e}?${r}`,n);return(yield g(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;u({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:h,total:d,_embedded:p}=yield g(l,{dmShortID:e,token:o}),$=p?p["ec:dm-asset"]:[];return{count:h,total:d,items:$}})}function U(l){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:a,options:r}){u({env:n,dmShortID:t,assetGroup:e,file:o});const h=f(`a/${t}/${e}`,n),d=new FormData;return d.append("file",o,a),r&&Object.keys(r).forEach($=>{d.append($,r[$])}),(yield g(h,{token:s},{method:"POST",body:d}))._embedded["ec:dm-asset"]})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:U,createEntry:R,deleteEntry:z,editEntry:x,entryList:q,getAsset:J,getEcAuthKey:K,getEntry:C,getPublicAuthKey:B,loginEc:_,loginPublic:j,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:A,getPublicAuthKey:b}=k;function ot(n){const{action:t}=n;if(u({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(A(this.config)))}loginPublic(t){return tt(c(c({},this.config),t)).then(this.setAuth(b(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(y(c({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(y(c({},this.config),{token:t})).then(this.unsetAuth(A(this.config)))}getPublicToken(){return this.config.token||this.getAuth(b(this.config))}getEcToken(){return this.config.token||this.getAuth(A(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=R;exports.deleteEntry=z;exports.editEntry=x;exports.entryList=q;exports.expect=u;exports.fetcher=g;exports.getAsset=J;exports.getEcAuthKey=K;exports.getEntry=C;exports.getPublicAuthKey=B;exports.loginEc=_;exports.loginPublic=j;exports.logoutEc=S;exports.logoutPublic=L;exports.query=E;exports.sdk=rt;
|
package/dist/index.mjs
CHANGED
|
@@ -9,33 +9,33 @@ var P = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writab
|
|
|
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
16
|
g(e.next(u));
|
|
17
|
-
} catch (
|
|
18
|
-
o(
|
|
17
|
+
} catch (l) {
|
|
18
|
+
o(l);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, r = (u) => {
|
|
21
21
|
try {
|
|
22
22
|
g(e.throw(u));
|
|
23
|
-
} catch (
|
|
24
|
-
o(
|
|
23
|
+
} catch (l) {
|
|
24
|
+
o(l);
|
|
25
25
|
}
|
|
26
|
-
}, g = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(a,
|
|
26
|
+
}, g = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(a, r);
|
|
27
27
|
g((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
31
|
const { token: o, rawRes: a } = t;
|
|
32
|
-
o && (e.headers =
|
|
32
|
+
o && (e.headers = d(c({}, e.headers || {}), {
|
|
33
33
|
Authorization: `Bearer ${o}`
|
|
34
34
|
}));
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error(
|
|
38
|
-
return a ?
|
|
35
|
+
const r = yield fetch(n, e);
|
|
36
|
+
if (!r.ok)
|
|
37
|
+
throw new Error(r.statusText);
|
|
38
|
+
return a ? r : yield r.json();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
const m = {
|
|
@@ -50,7 +50,7 @@ function f(n, t = "stage") {
|
|
|
50
50
|
);
|
|
51
51
|
return e + n;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function k(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
56
|
function h(n) {
|
|
@@ -64,11 +64,11 @@ const O = {
|
|
|
64
64
|
live: "https://accounts.entrecode.de/"
|
|
65
65
|
};
|
|
66
66
|
function S(n) {
|
|
67
|
-
return
|
|
67
|
+
return i(this, null, function* () {
|
|
68
68
|
let { env: t, dmShortID: e, email: s, password: o } = n;
|
|
69
69
|
h({ env: t, dmShortID: e, email: s, password: o });
|
|
70
70
|
const a = f(`api/${e}/_auth/login?clientID=rest`, t);
|
|
71
|
-
return yield
|
|
71
|
+
return yield y(
|
|
72
72
|
a,
|
|
73
73
|
{},
|
|
74
74
|
{
|
|
@@ -81,12 +81,12 @@ function S(n) {
|
|
|
81
81
|
);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
84
|
+
function C(n) {
|
|
85
|
+
return i(this, null, function* () {
|
|
86
86
|
let { env: t, email: e, password: s } = n;
|
|
87
87
|
h({ env: t, email: e, password: s });
|
|
88
88
|
const o = `${O[t]}auth/login?clientID=rest`;
|
|
89
|
-
return yield
|
|
89
|
+
return yield y(
|
|
90
90
|
o,
|
|
91
91
|
{},
|
|
92
92
|
{
|
|
@@ -99,15 +99,15 @@ function q(n) {
|
|
|
99
99
|
);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
102
|
+
function q(n) {
|
|
103
|
+
return i(this, null, function* () {
|
|
104
104
|
let { dmShortID: t, env: e, token: s } = n;
|
|
105
105
|
h({ dmShortID: t, env: e, token: s });
|
|
106
106
|
const o = f(
|
|
107
107
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
108
108
|
e
|
|
109
109
|
);
|
|
110
|
-
return yield
|
|
110
|
+
return yield y(
|
|
111
111
|
o,
|
|
112
112
|
{ dmShortID: t, rawRes: !0 },
|
|
113
113
|
{
|
|
@@ -117,11 +117,11 @@ function C(n) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
function x(n) {
|
|
120
|
-
return
|
|
120
|
+
return i(this, null, function* () {
|
|
121
121
|
let { env: t, token: e } = n;
|
|
122
122
|
h({ env: t, token: e });
|
|
123
123
|
const s = `${O[t]}auth/logout?clientID=rest`;
|
|
124
|
-
return yield
|
|
124
|
+
return yield y(
|
|
125
125
|
s,
|
|
126
126
|
{
|
|
127
127
|
rawRes: !0,
|
|
@@ -140,24 +140,24 @@ function z({ env: n }) {
|
|
|
140
140
|
return h({ env: n }), n;
|
|
141
141
|
}
|
|
142
142
|
function J(n) {
|
|
143
|
-
return
|
|
143
|
+
return i(this, null, function* () {
|
|
144
144
|
let { env: t, dmShortID: e, model: s, options: o = {} } = n;
|
|
145
145
|
h({ env: t, dmShortID: e, model: s }), o = c({ size: 50, page: 1, _list: !0 }, o);
|
|
146
|
-
const a =
|
|
146
|
+
const a = k(o), r = f(`api/${e}/${s}?${a}`, t), { count: g, total: u, _embedded: l } = yield y(r, n), p = l ? l[`${e}:${s}`] : [];
|
|
147
147
|
return { count: g, total: u, items: p };
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
function N({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
|
|
151
151
|
h({ env: n, dmShortID: t, model: e, entryID: s });
|
|
152
|
-
const a =
|
|
153
|
-
return
|
|
152
|
+
const a = k({ _id: s }), r = f(`api/${t}/${e}?${a}`, n);
|
|
153
|
+
return y(r, { dmShortID: t, token: o });
|
|
154
154
|
}
|
|
155
155
|
function U(a) {
|
|
156
|
-
return
|
|
156
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: o }) {
|
|
157
157
|
h({ env: n, dmShortID: t, model: e, value: s }), console.log("create entry", t, e, s);
|
|
158
|
-
const
|
|
159
|
-
return console.log("url",
|
|
160
|
-
|
|
158
|
+
const r = f(`api/${t}/${e}`, n);
|
|
159
|
+
return console.log("url", r), yield y(
|
|
160
|
+
r,
|
|
161
161
|
{ env: n, dmShortID: t, token: o },
|
|
162
162
|
{
|
|
163
163
|
method: "POST",
|
|
@@ -169,8 +169,8 @@ function U(a) {
|
|
|
169
169
|
);
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
function F(
|
|
173
|
-
return
|
|
172
|
+
function F(r) {
|
|
173
|
+
return i(this, arguments, function* ({
|
|
174
174
|
env: n,
|
|
175
175
|
dmShortID: t,
|
|
176
176
|
model: e,
|
|
@@ -180,7 +180,7 @@ function F(i) {
|
|
|
180
180
|
}) {
|
|
181
181
|
h({ env: n, dmShortID: t, model: e, entryID: s, value: o });
|
|
182
182
|
const g = f(`api/${t}/${e}?_id=${s}`, n);
|
|
183
|
-
return yield
|
|
183
|
+
return yield y(
|
|
184
184
|
g,
|
|
185
185
|
{ token: a },
|
|
186
186
|
{
|
|
@@ -194,11 +194,11 @@ function F(i) {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
function G(a) {
|
|
197
|
-
return
|
|
197
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: o }) {
|
|
198
198
|
h({ env: n, dmShortID: t, model: e, entryID: s });
|
|
199
|
-
const
|
|
200
|
-
yield
|
|
201
|
-
|
|
199
|
+
const r = f(`api/${t}/${e}?_id=${s}`, n);
|
|
200
|
+
yield y(
|
|
201
|
+
r,
|
|
202
202
|
{ token: o, rawRes: !0 },
|
|
203
203
|
{
|
|
204
204
|
method: "DELETE",
|
|
@@ -210,43 +210,45 @@ function G(a) {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
function M(a) {
|
|
213
|
-
return
|
|
213
|
+
return i(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: o }) {
|
|
214
214
|
h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
215
|
-
const
|
|
216
|
-
return (yield
|
|
215
|
+
const r = k({ assetID: s }), g = f(`a/${t}/${e}?${r}`, n);
|
|
216
|
+
return (yield y(g, { dmShortID: t, token: o }))._embedded["ec:dm-asset"];
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
function v(n) {
|
|
220
|
-
return
|
|
220
|
+
return i(this, null, function* () {
|
|
221
221
|
let { env: t, dmShortID: e, assetGroup: s, token: o, options: a = {} } = n;
|
|
222
222
|
h({ env: t, dmShortID: e, assetGroup: s }), a = c({ size: 50, page: 1, _list: !0 }, a);
|
|
223
|
-
const
|
|
224
|
-
return { count: u, total:
|
|
223
|
+
const r = k(a), g = f(`a/${e}/${s}?${r}`, t), { count: u, total: l, _embedded: p } = yield y(g, { dmShortID: e, token: o }), E = p ? p["ec:dm-asset"] : [];
|
|
224
|
+
return { count: u, total: l, items: E };
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
function H(g) {
|
|
228
|
-
return
|
|
228
|
+
return i(this, arguments, function* ({
|
|
229
229
|
env: n,
|
|
230
230
|
dmShortID: t,
|
|
231
231
|
assetGroup: e,
|
|
232
232
|
token: s,
|
|
233
233
|
file: o,
|
|
234
234
|
name: a,
|
|
235
|
-
options:
|
|
235
|
+
options: r
|
|
236
236
|
}) {
|
|
237
237
|
h({ env: n, dmShortID: t, assetGroup: e, file: o });
|
|
238
|
-
const u =
|
|
239
|
-
return
|
|
240
|
-
|
|
238
|
+
const u = f(`a/${t}/${e}`, n), l = new FormData();
|
|
239
|
+
return l.append("file", o, a), r && Object.keys(r).forEach((E) => {
|
|
240
|
+
l.append(E, r[E]);
|
|
241
|
+
}), (yield y(
|
|
242
|
+
u,
|
|
241
243
|
{ token: s },
|
|
242
244
|
{
|
|
243
245
|
method: "POST",
|
|
244
|
-
body:
|
|
246
|
+
body: l
|
|
245
247
|
}
|
|
246
248
|
))._embedded["ec:dm-asset"];
|
|
247
249
|
});
|
|
248
250
|
}
|
|
249
|
-
const
|
|
251
|
+
const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
250
252
|
__proto__: null,
|
|
251
253
|
assetList: v,
|
|
252
254
|
createAsset: H,
|
|
@@ -258,10 +260,10 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
258
260
|
getEcAuthKey: z,
|
|
259
261
|
getEntry: N,
|
|
260
262
|
getPublicAuthKey: R,
|
|
261
|
-
loginEc:
|
|
263
|
+
loginEc: C,
|
|
262
264
|
loginPublic: S,
|
|
263
265
|
logoutEc: x,
|
|
264
|
-
logoutPublic:
|
|
266
|
+
logoutPublic: q
|
|
265
267
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
266
268
|
entryList: Q,
|
|
267
269
|
getEntry: V,
|
|
@@ -275,25 +277,25 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
275
277
|
loginEc: et,
|
|
276
278
|
logoutEc: nt,
|
|
277
279
|
logoutPublic: st,
|
|
278
|
-
getEcAuthKey:
|
|
279
|
-
getPublicAuthKey:
|
|
280
|
-
} =
|
|
280
|
+
getEcAuthKey: w,
|
|
281
|
+
getPublicAuthKey: A
|
|
282
|
+
} = $;
|
|
281
283
|
function rt(n) {
|
|
282
284
|
const { action: t } = n;
|
|
283
|
-
if (h({ action: t }),
|
|
285
|
+
if (h({ action: t }), !$[t])
|
|
284
286
|
throw new Error(
|
|
285
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
287
|
+
`"${t}" does not exist! try one of ${Object.keys($).join(
|
|
286
288
|
", "
|
|
287
289
|
)}`
|
|
288
290
|
);
|
|
289
|
-
return
|
|
291
|
+
return $[t](n);
|
|
290
292
|
}
|
|
291
|
-
class
|
|
293
|
+
class b {
|
|
292
294
|
constructor(t) {
|
|
293
295
|
this.config = t;
|
|
294
296
|
}
|
|
295
297
|
set(t) {
|
|
296
|
-
return new
|
|
298
|
+
return new b(c(c({}, this.config), t));
|
|
297
299
|
}
|
|
298
300
|
/**
|
|
299
301
|
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
@@ -309,13 +311,13 @@ class A {
|
|
|
309
311
|
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
310
312
|
*/
|
|
311
313
|
entries() {
|
|
312
|
-
return
|
|
314
|
+
return i(this, arguments, function* (t = {}) {
|
|
313
315
|
const e = yield this.getBestToken();
|
|
314
|
-
return Q(
|
|
316
|
+
return Q(d(c({}, this.config), { options: t, token: e }));
|
|
315
317
|
});
|
|
316
318
|
}
|
|
317
319
|
entryList(t) {
|
|
318
|
-
return
|
|
320
|
+
return i(this, null, function* () {
|
|
319
321
|
return this.entries(t);
|
|
320
322
|
});
|
|
321
323
|
}
|
|
@@ -329,9 +331,9 @@ class A {
|
|
|
329
331
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
330
332
|
*/
|
|
331
333
|
getEntry(t) {
|
|
332
|
-
return
|
|
334
|
+
return i(this, null, function* () {
|
|
333
335
|
const e = yield this.getBestToken();
|
|
334
|
-
return V(
|
|
336
|
+
return V(d(c({}, this.config), { entryID: t, token: e }));
|
|
335
337
|
});
|
|
336
338
|
}
|
|
337
339
|
/**
|
|
@@ -348,13 +350,13 @@ class A {
|
|
|
348
350
|
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
349
351
|
*/
|
|
350
352
|
assets(t) {
|
|
351
|
-
return
|
|
353
|
+
return i(this, null, function* () {
|
|
352
354
|
const e = yield this.getBestToken();
|
|
353
|
-
return X(
|
|
355
|
+
return X(d(c({}, this.config), { options: t, token: e }));
|
|
354
356
|
});
|
|
355
357
|
}
|
|
356
358
|
assetList(t) {
|
|
357
|
-
return
|
|
359
|
+
return i(this, null, function* () {
|
|
358
360
|
return this.assets(t);
|
|
359
361
|
});
|
|
360
362
|
}
|
|
@@ -380,9 +382,9 @@ class A {
|
|
|
380
382
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
381
383
|
*/
|
|
382
384
|
createAsset() {
|
|
383
|
-
return
|
|
385
|
+
return i(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
384
386
|
const o = yield this.getBestToken();
|
|
385
|
-
return Y(
|
|
387
|
+
return Y(d(c({}, this.config), { file: t, name: e, options: s, token: o }));
|
|
386
388
|
});
|
|
387
389
|
}
|
|
388
390
|
/**
|
|
@@ -395,9 +397,9 @@ class A {
|
|
|
395
397
|
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
396
398
|
*/
|
|
397
399
|
getAsset(t) {
|
|
398
|
-
return
|
|
400
|
+
return i(this, null, function* () {
|
|
399
401
|
const e = yield this.getBestToken();
|
|
400
|
-
return W(
|
|
402
|
+
return W(d(c({}, this.config), { assetID: t, token: e }));
|
|
401
403
|
});
|
|
402
404
|
}
|
|
403
405
|
/**
|
|
@@ -410,9 +412,9 @@ class A {
|
|
|
410
412
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
411
413
|
*/
|
|
412
414
|
createEntry(t) {
|
|
413
|
-
return
|
|
415
|
+
return i(this, null, function* () {
|
|
414
416
|
const e = yield this.getBestToken();
|
|
415
|
-
return Z(
|
|
417
|
+
return Z(d(c({}, this.config), { token: e, value: t }));
|
|
416
418
|
});
|
|
417
419
|
}
|
|
418
420
|
/**
|
|
@@ -426,9 +428,9 @@ class A {
|
|
|
426
428
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
427
429
|
*/
|
|
428
430
|
editEntry(t, e) {
|
|
429
|
-
return
|
|
431
|
+
return i(this, null, function* () {
|
|
430
432
|
const s = yield this.getBestToken();
|
|
431
|
-
return D(
|
|
433
|
+
return D(d(c({}, this.config), { entryID: t, token: s, value: e }));
|
|
432
434
|
});
|
|
433
435
|
}
|
|
434
436
|
/**
|
|
@@ -441,9 +443,9 @@ class A {
|
|
|
441
443
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
442
444
|
*/
|
|
443
445
|
deleteEntry(t) {
|
|
444
|
-
return
|
|
446
|
+
return i(this, null, function* () {
|
|
445
447
|
const e = yield this.getBestToken();
|
|
446
|
-
return I(
|
|
448
|
+
return I(d(c({}, this.config), { token: e, entryID: t }));
|
|
447
449
|
});
|
|
448
450
|
}
|
|
449
451
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -474,31 +476,31 @@ class A {
|
|
|
474
476
|
}
|
|
475
477
|
loginEc(t) {
|
|
476
478
|
return et(c(c({}, this.config), t)).then(
|
|
477
|
-
this.setAuth(
|
|
479
|
+
this.setAuth(w(this.config))
|
|
478
480
|
);
|
|
479
481
|
}
|
|
480
482
|
loginPublic(t) {
|
|
481
483
|
return tt(c(c({}, this.config), t)).then(
|
|
482
|
-
this.setAuth(
|
|
484
|
+
this.setAuth(A(this.config))
|
|
483
485
|
);
|
|
484
486
|
}
|
|
485
487
|
logoutPublic() {
|
|
486
488
|
const t = this.getPublicToken();
|
|
487
|
-
return console.log("token", t), st(
|
|
488
|
-
this.unsetAuth(
|
|
489
|
+
return console.log("token", t), st(d(c({}, this.config), { token: t })).then(
|
|
490
|
+
this.unsetAuth(A(this.config))
|
|
489
491
|
);
|
|
490
492
|
}
|
|
491
493
|
logoutEc() {
|
|
492
494
|
const t = this.getEcToken();
|
|
493
|
-
return console.log("token", t), nt(
|
|
494
|
-
this.unsetAuth(
|
|
495
|
+
return console.log("token", t), nt(d(c({}, this.config), { token: t })).then(
|
|
496
|
+
this.unsetAuth(w(this.config))
|
|
495
497
|
);
|
|
496
498
|
}
|
|
497
499
|
getPublicToken() {
|
|
498
|
-
return this.config.token || this.getAuth(
|
|
500
|
+
return this.config.token || this.getAuth(A(this.config));
|
|
499
501
|
}
|
|
500
502
|
getEcToken() {
|
|
501
|
-
return this.config.token || this.getAuth(
|
|
503
|
+
return this.config.token || this.getAuth(w(this.config));
|
|
502
504
|
}
|
|
503
505
|
hasPublicToken() {
|
|
504
506
|
return !!this.getPublicToken();
|
|
@@ -565,9 +567,9 @@ class A {
|
|
|
565
567
|
return this.assetGroup(t);
|
|
566
568
|
}
|
|
567
569
|
}
|
|
568
|
-
const it = (n) => new
|
|
570
|
+
const it = (n) => new b({ env: n });
|
|
569
571
|
export {
|
|
570
|
-
|
|
572
|
+
b as Sdk,
|
|
571
573
|
rt as act,
|
|
572
574
|
f as apiURL,
|
|
573
575
|
v as assetList,
|
|
@@ -577,15 +579,15 @@ export {
|
|
|
577
579
|
F as editEntry,
|
|
578
580
|
J as entryList,
|
|
579
581
|
h as expect,
|
|
580
|
-
|
|
582
|
+
y as fetcher,
|
|
581
583
|
M as getAsset,
|
|
582
584
|
z as getEcAuthKey,
|
|
583
585
|
N as getEntry,
|
|
584
586
|
R as getPublicAuthKey,
|
|
585
|
-
|
|
587
|
+
C as loginEc,
|
|
586
588
|
S as loginPublic,
|
|
587
589
|
x as logoutEc,
|
|
588
|
-
|
|
589
|
-
|
|
590
|
+
q as logoutPublic,
|
|
591
|
+
k as query,
|
|
590
592
|
it as sdk
|
|
591
593
|
};
|
|
@@ -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"}
|