ec.fdk 0.1.1 → 0.1.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 +279 -219
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var M=Object.defineProperty,G=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var _=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,a=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&_(e,n,t[n]);if(L)for(var n of L(t))F.call(t,n)&&_(e,n,t[n]);return e},p=(e,t)=>G(e,U(t));var i=(e,t,n)=>new Promise((o,r)=>{var c=u=>{try{d(n.next(u))}catch(y){r(y)}},s=u=>{try{d(n.throw(u))}catch(y){r(y)}},d=u=>u.done?o(u.value):Promise.resolve(u.value).then(c,s);d((n=n.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("@nanostores/persistent");function g(o){return i(this,arguments,function*(e,t={},n={}){const{token:r,rawRes:c}=t;r&&(n.headers=p(a({},n.headers||{}),{Authorization:`Bearer ${r}`}));const s=yield fetch(e,n);if(console.log("fetch",e,n),!s.ok)throw new Error(s.statusText);return c?s:yield s.json()})}const q={production:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function h(e,t="stage"){const n=q[t];if(!n)throw new Error(`env "${t}" not found. Try one of ${Object.keys(q).join(", ")}`);return n+e}function b(e,t=!0){return Object.entries(e).sort((n,o)=>n[0].localeCompare(o[0])).map(([n,o])=>`${n}=${o}`).join("&")}function l(e){Object.entries(e).forEach(([t,n])=>{if(n===void 0)throw new Error(`expected ${t} to be set!`)})}const v={stage:"https://accounts.cachena.entrecode.de/",production:"https://accounts.cachena.entrecode.de/"};function m(e){return i(this,null,function*(){let{env:t,dmShortID:n,email:o,password:r}=e;l({env:t,dmShortID:n,email:o,password:r});const c=h(`api/${n}/_auth/login?clientID=rest`,t);return yield g(c,{},{method:"POST",body:JSON.stringify({email:o,password:r}),headers:{"Content-Type":"application/json"}})})}function O(e){return i(this,null,function*(){let{env:t,email:n,password:o}=e;l({env:t,email:n,password:o});const r=`${v[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:n,password:o}),headers:{"Content-Type":"application/json"}})})}function j(e){return i(this,null,function*(){let{dmShortID:t,env:n}=e;l({dmShortID:t,env:n,token});const o=h(`api/${t}/_auth/logout?clientID=rest&token=${token}`,n);return yield g(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function T(e){return i(this,null,function*(){let{env:t,token:n}=e;l({env:t});const o=`${v[t]}auth/logout?clientID=rest`;return yield g(o,{rawRes:!0,token:n},{method:"POST"})})}function x(e){return i(this,null,function*(){let{env:t,dmShortID:n,model:o,options:r={}}=e;l({env:t,dmShortID:n,model:o}),r=a({size:50,page:1,_list:!0},r);const c=b(r),s=h(`api/${n}/${o}?${c}`,t),{count:d,total:u,_embedded:y}=yield g(s,e),k=y?y[`${n}:${o}`]:[];return{count:d,total:u,items:k}})}function J({env:e,dmShortID:t,model:n,entryID:o,token:r}){l({env:e,dmShortID:t,model:n,entryID:o});const c=b({_id:o}),s=h(`api/${t}/${n}?${c}`,e);return g(s,{dmShortID:t,token:r})}function N(c){return i(this,arguments,function*({env:e,dmShortID:t,model:n,value:o,token:r}){l({env:e,dmShortID:t,model:n,value:o}),console.log("create entry",t,n,o);const s=h(`api/${t}/${n}`,e);return console.log("url",s),yield g(s,{env:e,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function R(s){return i(this,arguments,function*({env:e,dmShortID:t,model:n,entryID:o,value:r,token:c}){l({env:e,dmShortID:t,model:n,entryID:o,value:r}),console.log("edit entry",t,n,o,r)})}function z(c){return i(this,arguments,function*({env:e,dmShortID:t,assetGroup:n,assetID:o,token:r}){l({env:e,dmShortID:t,assetGroup:n,assetID:o});const s=b({assetID:o}),d=h(`a/${t}/${n}?${s}`,e);return(yield g(d,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function C(e){return i(this,null,function*(){let{env:t,dmShortID:n,assetGroup:o,token:r,options:c={}}=e;l({env:t,dmShortID:n,assetGroup:o}),c=a({size:50,page:1,_list:!0},c);const s=b(c),d=h(`a/${n}/${o}?${s}`,t),{count:u,total:y,_embedded:k}=yield g(d,{dmShortID:n,token:r}),K=k?k["ec:dm-asset"]:[];return{count:u,total:y,items:K}})}const w=Object.freeze(Object.defineProperty({__proto__:null,assetList:C,createEntry:N,editEntry:R,entryList:x,getAsset:z,getEntry:J,loginEc:O,loginPublic:m,logoutEc:T,logoutPublic:j},Symbol.toStringTag,{value:"Module"})),{entryList:Q,getEntry:V,getAsset:W,assetList:X,createEntry:D,editEntry:I,loginPublic:Y,loginEc:Z,logoutEc:tt,logoutPublic:et}=w;function nt(e){const{action:t}=e;if(l({action:t}),!w[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(w).join(", ")}`);return w[t](e)}class ${constructor(t){this.config=t}set(t){return new $(a(a({},this.config),t))}handle(t){const n=Object.keys(this.config),[o,r]=Object.entries(t).find(([c,s])=>n.includes(c))||[];if(!r)throw new Error(`you need to first set ${Object.keys(t).join(" | ")}`);return r(this.config)}entries(t){return Q(p(a({},this.config),{options:t}))}assets(t){return X(p(a({},this.config),{options:t}))}get(){return this.handle({assetID:W,entryID:V})}del(){}createEntry(t){return D(p(a({},this.config),{value:t}))}editEntry(t){return I(p(a({},this.config),{value:t}))}create(t){return this.set({value:t}).handle({model:D})}edit(t){return this.set({value:t}).handle({entryID:I})}loginPublic(t){return Y(a(a({},this.config),t))}logoutPublic(){return et(this.config)}loginEc(t){return Z(a(a({},this.config),t))}logoutEc(){return tt(this.config)}}const E=(...e)=>{const[t]=e;e.forEach(n=>{$.prototype[n]=function(o){return this.set({[t]:o})}})},A=(e,t)=>{$.prototype[e]=$.prototype[t]};E("dmShortID","dm","dmshortid");E("model");E("token");E("entryID","entry");E("assetGroup");E("assetID","asset");A("assetgroup","assetGroup");A("entryList","entries");A("assetList","assets");const ot=e=>new $({env:e}),f=H.persistentMap("fdk.auth",{},{encode:JSON.stringify,decode:JSON.parse});function P(e){var n;let{dmShortID:t}=e;if(t)return(n=f.get())==null?void 0:n[t]}function S(e){var n;let{env:t}=e;if(t)return(n=f.get())==null?void 0:n[t]}function rt(e){return S(e)||P(e)}function st(e){var t,n;return!!((t=S(e))!=null&&t.token)||!!((n=P(e))!=null&&n.token)}function ct(e){var t;return!!((t=S(e))!=null&&t.token)}function it(e){var t;return!!((t=P(e))!=null&&t.token)}function at(e){return i(this,null,function*(){const t=yield m(e);return f.setKey(e.dmShortID,{token:t.token}),t})}function ut(e){return i(this,null,function*(){const t=yield O(e);return f.setKey(e.env,{token:t.token}),t})}function lt(e){return i(this,null,function*(){const t=yield j(e);return f.setKey(e.dmShortID,{}),t})}function dt(e){return i(this,null,function*(){const t=yield T(e);return f.setKey(e.env,{token:t.token}),t})}exports.act=nt;exports.apiURL=h;exports.assetList=C;exports.auth=f;exports.createEntry=N;exports.editEntry=R;exports.entryList=x;exports.expect=l;exports.fetcher=g;exports.getAsset=z;exports.getAuth=rt;exports.getEcAuth=S;exports.getEntry=J;exports.getPublicAuth=P;exports.hasAnyToken=st;exports.hasEcToken=ct;exports.hasPublicToken=it;exports.loginEc=O;exports.loginEcStored=ut;exports.loginPublic=m;exports.loginPublicStored=at;exports.logoutEc=T;exports.logoutEcStored=dt;exports.logoutPublic=j;exports.logoutPublicStored=lt;exports.query=b;exports.sdk=ot;
|
package/dist/index.mjs
CHANGED
|
@@ -1,192 +1,239 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var J = Object.defineProperty, N = Object.defineProperties;
|
|
2
|
+
var z = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var S = Object.getOwnPropertySymbols;
|
|
4
|
+
var C = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var j = (e, t, n) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, a = (e, t) => {
|
|
6
|
+
for (var n in t || (t = {}))
|
|
7
|
+
C.call(t, n) && j(e, n, t[n]);
|
|
8
|
+
if (S)
|
|
9
|
+
for (var n of S(t))
|
|
10
|
+
K.call(t, n) && j(e, n, t[n]);
|
|
11
|
+
return e;
|
|
12
|
+
}, f = (e, t) => N(e, z(t));
|
|
13
|
+
var i = (e, t, n) => new Promise((o, s) => {
|
|
14
|
+
var c = (u) => {
|
|
15
|
+
try {
|
|
16
|
+
d(n.next(u));
|
|
17
|
+
} catch (g) {
|
|
18
|
+
s(g);
|
|
19
|
+
}
|
|
20
|
+
}, r = (u) => {
|
|
21
|
+
try {
|
|
22
|
+
d(n.throw(u));
|
|
23
|
+
} catch (g) {
|
|
24
|
+
s(g);
|
|
25
|
+
}
|
|
26
|
+
}, d = (u) => u.done ? o(u.value) : Promise.resolve(u.value).then(c, r);
|
|
27
|
+
d((n = n.apply(e, t)).next());
|
|
28
|
+
});
|
|
29
|
+
import { persistentMap as R } from "@nanostores/persistent";
|
|
30
|
+
function y(o) {
|
|
31
|
+
return i(this, arguments, function* (e, t = {}, n = {}) {
|
|
32
|
+
const { token: s, rawRes: c } = t;
|
|
33
|
+
s && (n.headers = f(a({}, n.headers || {}), {
|
|
34
|
+
Authorization: `Bearer ${s}`
|
|
35
|
+
}));
|
|
36
|
+
const r = yield fetch(e, n);
|
|
37
|
+
if (console.log("fetch", e, n), !r.ok)
|
|
38
|
+
throw new Error(r.statusText);
|
|
39
|
+
return c ? r : yield r.json();
|
|
7
40
|
});
|
|
8
|
-
const r = await fetch(e, n);
|
|
9
|
-
if (console.log("fetch", e, n), !r.ok)
|
|
10
|
-
throw new Error(r.statusText);
|
|
11
|
-
return s ? r : await r.json();
|
|
12
41
|
}
|
|
13
|
-
const
|
|
42
|
+
const T = {
|
|
14
43
|
production: "https://datamanager.entrecode.de/",
|
|
15
44
|
stage: "https://datamanager.cachena.entrecode.de/"
|
|
16
45
|
};
|
|
17
|
-
function
|
|
18
|
-
const n =
|
|
46
|
+
function h(e, t = "stage") {
|
|
47
|
+
const n = T[t];
|
|
19
48
|
if (!n)
|
|
20
49
|
throw new Error(
|
|
21
|
-
`env "${t}" not found. Try one of ${Object.keys(
|
|
50
|
+
`env "${t}" not found. Try one of ${Object.keys(T).join(", ")}`
|
|
22
51
|
);
|
|
23
52
|
return n + e;
|
|
24
53
|
}
|
|
25
|
-
function
|
|
54
|
+
function k(e, t = !0) {
|
|
26
55
|
return Object.entries(e).sort((n, o) => n[0].localeCompare(o[0])).map(([n, o]) => `${n}=${o}`).join("&");
|
|
27
56
|
}
|
|
28
|
-
function
|
|
57
|
+
function l(e) {
|
|
29
58
|
Object.entries(e).forEach(([t, n]) => {
|
|
30
59
|
if (n === void 0)
|
|
31
60
|
throw new Error(`expected ${t} to be set!`);
|
|
32
61
|
});
|
|
33
62
|
}
|
|
34
|
-
const
|
|
63
|
+
const A = {
|
|
35
64
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
36
65
|
production: "https://accounts.cachena.entrecode.de/"
|
|
37
66
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
function D(e) {
|
|
68
|
+
return i(this, null, function* () {
|
|
69
|
+
let { env: t, dmShortID: n, email: o, password: s } = e;
|
|
70
|
+
l({ env: t, dmShortID: n, email: o, password: s });
|
|
71
|
+
const c = h(`api/${n}/_auth/login?clientID=rest`, t);
|
|
72
|
+
return yield y(
|
|
73
|
+
c,
|
|
74
|
+
{},
|
|
75
|
+
{
|
|
76
|
+
method: "POST",
|
|
77
|
+
body: JSON.stringify({ email: o, password: s }),
|
|
78
|
+
headers: {
|
|
79
|
+
"Content-Type": "application/json"
|
|
80
|
+
}
|
|
50
81
|
}
|
|
51
|
-
|
|
52
|
-
);
|
|
82
|
+
);
|
|
83
|
+
});
|
|
53
84
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
85
|
+
function I(e) {
|
|
86
|
+
return i(this, null, function* () {
|
|
87
|
+
let { env: t, email: n, password: o } = e;
|
|
88
|
+
l({ env: t, email: n, password: o });
|
|
89
|
+
const s = `${A[t]}auth/login?clientID=rest`;
|
|
90
|
+
return yield y(
|
|
91
|
+
s,
|
|
92
|
+
{},
|
|
93
|
+
{
|
|
94
|
+
method: "POST",
|
|
95
|
+
body: JSON.stringify({ email: n, password: o }),
|
|
96
|
+
headers: {
|
|
97
|
+
"Content-Type": "application/json"
|
|
98
|
+
}
|
|
66
99
|
}
|
|
67
|
-
|
|
68
|
-
);
|
|
100
|
+
);
|
|
101
|
+
});
|
|
69
102
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
103
|
+
function q(e) {
|
|
104
|
+
return i(this, null, function* () {
|
|
105
|
+
let { dmShortID: t, env: n } = e;
|
|
106
|
+
l({ dmShortID: t, env: n, token });
|
|
107
|
+
const o = h(
|
|
108
|
+
`api/${t}/_auth/logout?clientID=rest&token=${token}`,
|
|
109
|
+
n
|
|
110
|
+
);
|
|
111
|
+
return yield y(
|
|
112
|
+
o,
|
|
113
|
+
{ dmShortID: t, rawRes: !0 },
|
|
114
|
+
{
|
|
115
|
+
method: "POST"
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
});
|
|
84
119
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
120
|
+
function v(e) {
|
|
121
|
+
return i(this, null, function* () {
|
|
122
|
+
let { env: t, token: n } = e;
|
|
123
|
+
l({ env: t });
|
|
124
|
+
const o = `${A[t]}auth/logout?clientID=rest`;
|
|
125
|
+
return yield y(
|
|
126
|
+
o,
|
|
127
|
+
{
|
|
128
|
+
rawRes: !0,
|
|
129
|
+
token: n
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
method: "POST"
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
});
|
|
99
136
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
137
|
+
function G(e) {
|
|
138
|
+
return i(this, null, function* () {
|
|
139
|
+
let { env: t, dmShortID: n, model: o, options: s = {} } = e;
|
|
140
|
+
l({ env: t, dmShortID: n, model: o }), s = a({ size: 50, page: 1, _list: !0 }, s);
|
|
141
|
+
const c = k(s), r = h(`api/${n}/${o}?${c}`, t), { count: d, total: u, _embedded: g } = yield y(r, e), b = g ? g[`${n}:${o}`] : [];
|
|
142
|
+
return { count: d, total: u, items: b };
|
|
143
|
+
});
|
|
105
144
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
return
|
|
145
|
+
function M({ env: e, dmShortID: t, model: n, entryID: o, token: s }) {
|
|
146
|
+
l({ env: e, dmShortID: t, model: n, entryID: o });
|
|
147
|
+
const c = k({ _id: o }), r = h(`api/${t}/${n}?${c}`, e);
|
|
148
|
+
return y(r, { dmShortID: t, token: s });
|
|
110
149
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
r,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
150
|
+
function B(c) {
|
|
151
|
+
return i(this, arguments, function* ({ env: e, dmShortID: t, model: n, value: o, token: s }) {
|
|
152
|
+
l({ env: e, dmShortID: t, model: n, value: o }), console.log("create entry", t, n, o);
|
|
153
|
+
const r = h(`api/${t}/${n}`, e);
|
|
154
|
+
return console.log("url", r), yield y(
|
|
155
|
+
r,
|
|
156
|
+
{ env: e, dmShortID: t, token: s },
|
|
157
|
+
{
|
|
158
|
+
method: "POST",
|
|
159
|
+
body: JSON.stringify(o),
|
|
160
|
+
headers: {
|
|
161
|
+
"Content-Type": "application/json"
|
|
162
|
+
}
|
|
122
163
|
}
|
|
123
|
-
|
|
124
|
-
);
|
|
164
|
+
);
|
|
165
|
+
});
|
|
125
166
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
167
|
+
function U(r) {
|
|
168
|
+
return i(this, arguments, function* ({
|
|
169
|
+
env: e,
|
|
170
|
+
dmShortID: t,
|
|
171
|
+
model: n,
|
|
172
|
+
entryID: o,
|
|
173
|
+
value: s,
|
|
174
|
+
token: c
|
|
175
|
+
}) {
|
|
176
|
+
l({ env: e, dmShortID: t, model: n, entryID: o, value: s }), console.log("edit entry", t, n, o, s);
|
|
177
|
+
});
|
|
135
178
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
179
|
+
function F(c) {
|
|
180
|
+
return i(this, arguments, function* ({ env: e, dmShortID: t, assetGroup: n, assetID: o, token: s }) {
|
|
181
|
+
l({ env: e, dmShortID: t, assetGroup: n, assetID: o });
|
|
182
|
+
const r = k({ assetID: o }), d = h(`a/${t}/${n}?${r}`, e);
|
|
183
|
+
return (yield y(d, { dmShortID: t, token: s }))._embedded["ec:dm-asset"];
|
|
184
|
+
});
|
|
140
185
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
186
|
+
function H(e) {
|
|
187
|
+
return i(this, null, function* () {
|
|
188
|
+
let { env: t, dmShortID: n, assetGroup: o, token: s, options: c = {} } = e;
|
|
189
|
+
l({ env: t, dmShortID: n, assetGroup: o }), c = a({ size: 50, page: 1, _list: !0 }, c);
|
|
190
|
+
const r = k(c), d = h(`a/${n}/${o}?${r}`, t), { count: u, total: g, _embedded: b } = yield y(d, { dmShortID: n, token: s }), x = b ? b["ec:dm-asset"] : [];
|
|
191
|
+
return { count: u, total: g, items: x };
|
|
192
|
+
});
|
|
146
193
|
}
|
|
147
|
-
const
|
|
194
|
+
const w = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
148
195
|
__proto__: null,
|
|
149
|
-
assetList:
|
|
150
|
-
createEntry:
|
|
151
|
-
editEntry:
|
|
152
|
-
entryList:
|
|
153
|
-
getAsset:
|
|
154
|
-
getEntry:
|
|
155
|
-
loginEc:
|
|
156
|
-
loginPublic:
|
|
157
|
-
logoutEc:
|
|
158
|
-
logoutPublic:
|
|
196
|
+
assetList: H,
|
|
197
|
+
createEntry: B,
|
|
198
|
+
editEntry: U,
|
|
199
|
+
entryList: G,
|
|
200
|
+
getAsset: F,
|
|
201
|
+
getEntry: M,
|
|
202
|
+
loginEc: I,
|
|
203
|
+
loginPublic: D,
|
|
204
|
+
logoutEc: v,
|
|
205
|
+
logoutPublic: q
|
|
159
206
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
160
|
-
entryList:
|
|
161
|
-
getEntry:
|
|
162
|
-
getAsset:
|
|
163
|
-
assetList:
|
|
164
|
-
createEntry:
|
|
165
|
-
editEntry:
|
|
166
|
-
loginPublic:
|
|
167
|
-
loginEc:
|
|
168
|
-
logoutEc:
|
|
169
|
-
logoutPublic:
|
|
170
|
-
} =
|
|
171
|
-
function
|
|
207
|
+
entryList: Q,
|
|
208
|
+
getEntry: V,
|
|
209
|
+
getAsset: W,
|
|
210
|
+
assetList: X,
|
|
211
|
+
createEntry: _,
|
|
212
|
+
editEntry: L,
|
|
213
|
+
loginPublic: Y,
|
|
214
|
+
loginEc: Z,
|
|
215
|
+
logoutEc: tt,
|
|
216
|
+
logoutPublic: et
|
|
217
|
+
} = w;
|
|
218
|
+
function st(e) {
|
|
172
219
|
const { action: t } = e;
|
|
173
|
-
if (
|
|
220
|
+
if (l({ action: t }), !w[t])
|
|
174
221
|
throw new Error(
|
|
175
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
222
|
+
`"${t}" does not exist! try one of ${Object.keys(w).join(
|
|
176
223
|
", "
|
|
177
224
|
)}`
|
|
178
225
|
);
|
|
179
|
-
return
|
|
226
|
+
return w[t](e);
|
|
180
227
|
}
|
|
181
|
-
class
|
|
228
|
+
class p {
|
|
182
229
|
constructor(t) {
|
|
183
230
|
this.config = t;
|
|
184
231
|
}
|
|
185
232
|
set(t) {
|
|
186
|
-
return new
|
|
233
|
+
return new p(a(a({}, this.config), t));
|
|
187
234
|
}
|
|
188
235
|
handle(t) {
|
|
189
|
-
const n = Object.keys(this.config), [o, s] = Object.entries(t).find(([
|
|
236
|
+
const n = Object.keys(this.config), [o, s] = Object.entries(t).find(([c, r]) => n.includes(c)) || [];
|
|
190
237
|
if (!s)
|
|
191
238
|
throw new Error(
|
|
192
239
|
`you need to first set ${Object.keys(t).join(" | ")}`
|
|
@@ -195,71 +242,71 @@ class l {
|
|
|
195
242
|
}
|
|
196
243
|
///
|
|
197
244
|
entries(t) {
|
|
198
|
-
return
|
|
245
|
+
return Q(f(a({}, this.config), { options: t }));
|
|
199
246
|
}
|
|
200
247
|
assets(t) {
|
|
201
|
-
return
|
|
248
|
+
return X(f(a({}, this.config), { options: t }));
|
|
202
249
|
}
|
|
203
250
|
get() {
|
|
204
251
|
return this.handle({
|
|
205
|
-
assetID:
|
|
206
|
-
entryID:
|
|
252
|
+
assetID: W,
|
|
253
|
+
entryID: V
|
|
207
254
|
});
|
|
208
255
|
}
|
|
209
256
|
del() {
|
|
210
257
|
}
|
|
211
258
|
createEntry(t) {
|
|
212
|
-
return
|
|
259
|
+
return _(f(a({}, this.config), { value: t }));
|
|
213
260
|
}
|
|
214
261
|
editEntry(t) {
|
|
215
|
-
return
|
|
262
|
+
return L(f(a({}, this.config), { value: t }));
|
|
216
263
|
}
|
|
217
264
|
create(t) {
|
|
218
265
|
return this.set({ value: t }).handle({
|
|
219
266
|
//assetID: createAsset,
|
|
220
|
-
model:
|
|
267
|
+
model: _
|
|
221
268
|
});
|
|
222
269
|
}
|
|
223
270
|
edit(t) {
|
|
224
271
|
return this.set({ value: t }).handle({
|
|
225
272
|
//assetID: createAsset,
|
|
226
|
-
entryID:
|
|
273
|
+
entryID: L
|
|
227
274
|
});
|
|
228
275
|
}
|
|
229
276
|
//
|
|
230
277
|
loginPublic(t) {
|
|
231
|
-
return
|
|
278
|
+
return Y(a(a({}, this.config), t));
|
|
232
279
|
}
|
|
233
280
|
logoutPublic() {
|
|
234
|
-
return
|
|
281
|
+
return et(this.config);
|
|
235
282
|
}
|
|
236
283
|
loginEc(t) {
|
|
237
|
-
return
|
|
284
|
+
return Z(a(a({}, this.config), t));
|
|
238
285
|
}
|
|
239
286
|
logoutEc() {
|
|
240
|
-
return
|
|
287
|
+
return tt(this.config);
|
|
241
288
|
}
|
|
242
289
|
}
|
|
243
|
-
const
|
|
290
|
+
const $ = (...e) => {
|
|
244
291
|
const [t] = e;
|
|
245
292
|
e.forEach((n) => {
|
|
246
|
-
|
|
293
|
+
p.prototype[n] = function(o) {
|
|
247
294
|
return this.set({ [t]: o });
|
|
248
295
|
};
|
|
249
296
|
});
|
|
250
|
-
},
|
|
251
|
-
|
|
297
|
+
}, m = (e, t) => {
|
|
298
|
+
p.prototype[e] = p.prototype[t];
|
|
252
299
|
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const
|
|
300
|
+
$("dmShortID", "dm", "dmshortid");
|
|
301
|
+
$("model");
|
|
302
|
+
$("token");
|
|
303
|
+
$("entryID", "entry");
|
|
304
|
+
$("assetGroup");
|
|
305
|
+
$("assetID", "asset");
|
|
306
|
+
m("assetgroup", "assetGroup");
|
|
307
|
+
m("entryList", "entries");
|
|
308
|
+
m("assetList", "assets");
|
|
309
|
+
const rt = (e) => new p({ env: e }), E = R(
|
|
263
310
|
"fdk.auth",
|
|
264
311
|
{},
|
|
265
312
|
{
|
|
@@ -267,70 +314,83 @@ const Q = (e) => new l({ env: e }), y = D(
|
|
|
267
314
|
decode: JSON.parse
|
|
268
315
|
}
|
|
269
316
|
);
|
|
270
|
-
function
|
|
317
|
+
function P(e) {
|
|
318
|
+
var n;
|
|
271
319
|
let { dmShortID: t } = e;
|
|
272
320
|
if (t)
|
|
273
|
-
return
|
|
321
|
+
return (n = E.get()) == null ? void 0 : n[t];
|
|
274
322
|
}
|
|
275
|
-
function
|
|
323
|
+
function O(e) {
|
|
324
|
+
var n;
|
|
276
325
|
let { env: t } = e;
|
|
277
326
|
if (t)
|
|
278
|
-
return
|
|
327
|
+
return (n = E.get()) == null ? void 0 : n[t];
|
|
279
328
|
}
|
|
280
|
-
function
|
|
281
|
-
return
|
|
329
|
+
function ct(e) {
|
|
330
|
+
return O(e) || P(e);
|
|
282
331
|
}
|
|
283
|
-
function
|
|
284
|
-
|
|
332
|
+
function it(e) {
|
|
333
|
+
var t, n;
|
|
334
|
+
return !!((t = O(e)) != null && t.token) || !!((n = P(e)) != null && n.token);
|
|
285
335
|
}
|
|
286
|
-
function
|
|
287
|
-
|
|
336
|
+
function at(e) {
|
|
337
|
+
var t;
|
|
338
|
+
return !!((t = O(e)) != null && t.token);
|
|
288
339
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
340
|
+
function ut(e) {
|
|
341
|
+
var t;
|
|
342
|
+
return !!((t = P(e)) != null && t.token);
|
|
291
343
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
344
|
+
function lt(e) {
|
|
345
|
+
return i(this, null, function* () {
|
|
346
|
+
const t = yield D(e);
|
|
347
|
+
return E.setKey(e.dmShortID, { token: t.token }), t;
|
|
348
|
+
});
|
|
295
349
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
350
|
+
function dt(e) {
|
|
351
|
+
return i(this, null, function* () {
|
|
352
|
+
const t = yield I(e);
|
|
353
|
+
return E.setKey(e.env, { token: t.token }), t;
|
|
354
|
+
});
|
|
299
355
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
356
|
+
function yt(e) {
|
|
357
|
+
return i(this, null, function* () {
|
|
358
|
+
const t = yield q(e);
|
|
359
|
+
return E.setKey(e.dmShortID, {}), t;
|
|
360
|
+
});
|
|
303
361
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
362
|
+
function gt(e) {
|
|
363
|
+
return i(this, null, function* () {
|
|
364
|
+
const t = yield v(e);
|
|
365
|
+
return E.setKey(e.env, { token: t.token }), t;
|
|
366
|
+
});
|
|
307
367
|
}
|
|
308
368
|
export {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
369
|
+
st as act,
|
|
370
|
+
h as apiURL,
|
|
371
|
+
H as assetList,
|
|
372
|
+
E as auth,
|
|
373
|
+
B as createEntry,
|
|
374
|
+
U as editEntry,
|
|
375
|
+
G as entryList,
|
|
376
|
+
l as expect,
|
|
377
|
+
y as fetcher,
|
|
378
|
+
F as getAsset,
|
|
379
|
+
ct as getAuth,
|
|
380
|
+
O as getEcAuth,
|
|
381
|
+
M as getEntry,
|
|
382
|
+
P as getPublicAuth,
|
|
383
|
+
it as hasAnyToken,
|
|
384
|
+
at as hasEcToken,
|
|
385
|
+
ut as hasPublicToken,
|
|
386
|
+
I as loginEc,
|
|
387
|
+
dt as loginEcStored,
|
|
388
|
+
D as loginPublic,
|
|
389
|
+
lt as loginPublicStored,
|
|
390
|
+
v as logoutEc,
|
|
391
|
+
gt as logoutEcStored,
|
|
392
|
+
q as logoutPublic,
|
|
393
|
+
yt as logoutPublicStored,
|
|
394
|
+
k as query,
|
|
395
|
+
rt as sdk
|
|
336
396
|
};
|