ec.fdk 0.1.9 → 0.2.0
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.d.mts +4 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +254 -183
- package/dist/lib/actions.d.mts +4 -0
- package/dist/lib/actions.d.mts.map +1 -0
- package/dist/lib/api.d.mts +114 -0
- package/dist/lib/api.d.mts.map +1 -0
- package/dist/lib/assets.d.mts +21 -0
- package/dist/lib/assets.d.mts.map +1 -0
- package/dist/lib/auth.d.mts +11 -0
- package/dist/lib/auth.d.mts.map +1 -0
- package/dist/lib/entries.d.mts +35 -0
- package/dist/lib/entries.d.mts.map +1 -0
- package/dist/lib/util.d.mts +5 -0
- package/dist/lib/util.d.mts.map +1 -0
- package/dist/storage.d.mts +2 -0
- package/dist/storage.d.mts.map +1 -0
- package/package.json +3 -2
- package/tsconfig.json +21 -0
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var M=Object.defineProperty,F=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,H=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,a=(n,t)=>{for(var e in t||(t={}))v.call(t,e)&&T(n,e,t[e]);if(A)for(var e of A(t))H.call(t,e)&&T(n,e,t[e]);return n},y=(n,t)=>F(n,G(t));var c=(n,t,e)=>new Promise((s,r)=>{var o=h=>{try{u(e.next(h))}catch(f){r(f)}},i=h=>{try{u(e.throw(h))}catch(f){r(f)}},u=h=>h.done?s(h.value):Promise.resolve(h.value).then(o,i);u((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return c(this,arguments,function*(n,t={},e={}){const{token:r,rawRes:o}=t;r&&(e.headers=y(a({},e.headers||{}),{Authorization:`Bearer ${r}`}));const i=yield fetch(n,e);if(!i.ok)throw new Error(i.statusText);return o?i:yield i.json()})}const P={production:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function d(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 l(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/",production:"https://accounts.cachena.entrecode.de/"};function _(n){return c(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;l({env:t,dmShortID:e,email:s,password:r});const o=d(`api/${e}/_auth/login?clientID=rest`,t);return yield g(o,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function L(n){return c(this,null,function*(){let{env:t,email:e,password:s}=n;l({env:t,email:e,password:s});const r=`${O[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function S(n){return c(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;l({dmShortID:t,env:e,token:s});const r=d(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function K(n){return c(this,null,function*(){let{env:t,token:e}=n;l({env:t,token:e});const s=`${O[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function D({dmShortID:n}){return l({dmShortID:n}),n}function q({env:n}){return l({env:n}),n}function B(n){return c(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;l({env:t,dmShortID:e,model:s}),r=a({size:50,page:1,_list:!0},r);const o=p(r),i=d(`api/${e}/${s}?${o}`,t),{count:u,total:h,_embedded:f}=yield g(i,n),$=f?f[`${e}:${s}`]:[];return{count:u,total:h,items:$}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:r}){l({env:n,dmShortID:t,model:e,entryID:s});const o=p({_id:s}),i=d(`api/${t}/${e}?${o}`,n);return g(i,{dmShortID:t,token:r})}function R(o){return c(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){l({env:n,dmShortID:t,model:e,value:s}),console.log("create entry",t,e,s);const i=d(`api/${t}/${e}`,n);return console.log("url",i),yield g(i,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function x(i){return c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:o}){l({env:n,dmShortID:t,model:e,entryID:s,value:r});const u=d(`api/${t}/${e}?_id=${s}`,n);return yield g(u,{token:o},{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}})})}function z(o){return c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:r}){l({env:n,dmShortID:t,model:e,entryID:s});const i=d(`api/${t}/${e}?_id=${s}`,n);return yield g(i,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function I(o){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){l({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=p({assetID:s}),u=d(`a/${t}/${e}?${i}`,n);return(yield g(u,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function J(n){return c(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:o={}}=n;l({env:t,dmShortID:e,assetGroup:s}),o=a({size:50,page:1,_list:!0},o);const i=p(o),u=d(`a/${e}/${s}?${i}`,t),{count:h,total:f,_embedded:$}=yield g(u,{dmShortID:e,token:r}),U=$?$["ec:dm-asset"]:[];return{count:h,total:f,items:U}})}function N(i){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:o}){l({env:n,dmShortID:t,assetGroup:e,file:r});const u=d(`a/${t}/${e}`,n),h=new FormData;return h.append("file",r,o),(yield g(u,{token:s},{method:"POST",body:h}))._embedded["ec:dm-asset"]})}const E=Object.freeze(Object.defineProperty({__proto__:null,assetList:J,createAsset:N,createEntry:R,deleteEntry:z,editEntry:x,entryList:B,getAsset:I,getEcAuthKey:q,getEntry:C,getPublicAuthKey:D,loginEc:L,loginPublic:_,logoutEc:K,logoutPublic:S},Symbol.toStringTag,{value:"Module"})),{entryList:Q,getEntry:V,getAsset:W,assetList:X,createAsset:Y,createEntry:m,editEntry:j,deleteEntry:Z,loginPublic:tt,loginEc:et,logoutEc:nt,logoutPublic:st,getEcAuthKey:b,getPublicAuthKey:k}=E;function rt(n){const{action:t}=n;if(l({action:t}),!E[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(E).join(", ")}`);return E[t](n)}class w{constructor(t){this.config=t}set(t){return new w(a(a({},this.config),t))}handle(t){return c(this,null,function*(){const e=Object.keys(this.config),s=yield this.getBestToken(),[r,o]=Object.entries(t).find(([i,u])=>e.includes(i))||[];if(!o)throw new Error(`you need to first set ${Object.keys(t).join(" | ")}`);return o(y(a({},this.config),{token:s}))})}entries(t){return c(this,null,function*(){const e=yield this.getBestToken();return Q(y(a({},this.config),{options:t,token:e}))})}entryList(t){return c(this,null,function*(){return this.entries(t)})}assets(t){return c(this,null,function*(){const e=yield this.getBestToken();return X(y(a({},this.config),{options:t,token:e}))})}assetList(t){return c(this,null,function*(){return this.assets(t)})}createAsset(){return c(this,arguments,function*({file:t,name:e}={}){const s=yield this.getBestToken();return Y(y(a({},this.config),{file:t,name:e,token:s}))})}get(){return this.handle({assetID:W,entryID:V})}del(){return this.handle({entryID:Z})}createEntry(t){return m(y(a({},this.config),{value:t}))}editEntry(t){return j(y(a({},this.config),{value:t}))}create(t){return this.set({value:t}).handle({model:m})}edit(t){return this.set({value:t}).handle({entryID:j})}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(a(a({},this.config),t)).then(this.setAuth(b(this.config)))}loginPublic(t){return tt(a(a({},this.config),t)).then(this.setAuth(k(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),st(y(a({},this.config),{token:t})).then(this.unsetAuth(k(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),nt(y(a({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}getPublicToken(){return this.config.token||this.getAuth(k(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)}entryID(t){return this.set({entryID:t})}entry(t){return this.entryID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}assetID(t){return this.set({assetID:t})}asset(t){return this.assetID(t)}}const ot=n=>new w({env:n});exports.act=rt;exports.apiURL=d;exports.assetList=J;exports.createAsset=N;exports.createEntry=R;exports.deleteEntry=z;exports.editEntry=x;exports.entryList=B;exports.expect=l;exports.fetcher=g;exports.getAsset=I;exports.getEcAuthKey=q;exports.getEntry=C;exports.getPublicAuthKey=D;exports.loginEc=L;exports.loginPublic=_;exports.logoutEc=K;exports.logoutPublic=S;exports.query=p;exports.sdk=ot;
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mjs"],"names":[],"mappings":""}
|
package/dist/index.mjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var L = Object.defineProperty, K = Object.defineProperties;
|
|
2
|
+
var S = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var A = Object.getOwnPropertySymbols;
|
|
4
|
+
var D = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var T = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, a = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
D.call(t, e) && T(n, e, t[e]);
|
|
8
|
+
if (A)
|
|
9
|
+
for (var e of A(t))
|
|
10
|
+
B.call(t, e) && T(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
}, d = (n, t) =>
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, d = (n, t) => K(n, S(t));
|
|
13
|
+
var c = (n, t, e) => new Promise((s, r) => {
|
|
14
|
+
var o = (h) => {
|
|
15
15
|
try {
|
|
16
16
|
u(e.next(h));
|
|
17
17
|
} catch (f) {
|
|
18
|
-
|
|
18
|
+
r(f);
|
|
19
19
|
}
|
|
20
20
|
}, i = (h) => {
|
|
21
21
|
try {
|
|
22
22
|
u(e.throw(h));
|
|
23
23
|
} catch (f) {
|
|
24
|
-
|
|
24
|
+
r(f);
|
|
25
25
|
}
|
|
26
|
-
}, u = (h) => h.done ? s(h.value) : Promise.resolve(h.value).then(
|
|
26
|
+
}, u = (h) => h.done ? s(h.value) : Promise.resolve(h.value).then(o, i);
|
|
27
27
|
u((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
29
|
function g(s) {
|
|
30
|
-
return
|
|
31
|
-
const { token:
|
|
32
|
-
|
|
33
|
-
Authorization: `Bearer ${
|
|
30
|
+
return c(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
|
+
const { token: r, rawRes: o } = t;
|
|
32
|
+
r && (e.headers = d(a({}, e.headers || {}), {
|
|
33
|
+
Authorization: `Bearer ${r}`
|
|
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 o ? i : yield i.json();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
const
|
|
41
|
+
const P = {
|
|
42
42
|
production: "https://datamanager.entrecode.de/",
|
|
43
43
|
stage: "https://datamanager.cachena.entrecode.de/"
|
|
44
44
|
};
|
|
45
45
|
function y(n, t = "stage") {
|
|
46
|
-
const e =
|
|
46
|
+
const e = P[t];
|
|
47
47
|
if (!e)
|
|
48
48
|
throw new Error(
|
|
49
|
-
`env "${t}" not found. Try one of ${Object.keys(
|
|
49
|
+
`env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`
|
|
50
50
|
);
|
|
51
51
|
return e + n;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function E(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 l(n) {
|
|
@@ -59,21 +59,21 @@ function l(n) {
|
|
|
59
59
|
throw new Error(`expected ${t} to be set!`);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const O = {
|
|
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
|
-
l({ env: t, dmShortID: e, email: s, password:
|
|
70
|
-
const
|
|
66
|
+
function C(n) {
|
|
67
|
+
return c(this, null, function* () {
|
|
68
|
+
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
69
|
+
l({ env: t, dmShortID: e, email: s, password: r });
|
|
70
|
+
const o = y(`api/${e}/_auth/login?clientID=rest`, t);
|
|
71
71
|
return yield g(
|
|
72
|
-
|
|
72
|
+
o,
|
|
73
73
|
{},
|
|
74
74
|
{
|
|
75
75
|
method: "POST",
|
|
76
|
-
body: JSON.stringify({ email: s, password:
|
|
76
|
+
body: JSON.stringify({ email: s, password: r }),
|
|
77
77
|
headers: {
|
|
78
78
|
"Content-Type": "application/json"
|
|
79
79
|
}
|
|
@@ -81,13 +81,13 @@ function R(n) {
|
|
|
81
81
|
);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
84
|
+
function q(n) {
|
|
85
|
+
return c(this, null, function* () {
|
|
86
86
|
let { env: t, email: e, password: s } = n;
|
|
87
87
|
l({ env: t, email: e, password: s });
|
|
88
|
-
const
|
|
88
|
+
const r = `${O[t]}auth/login?clientID=rest`;
|
|
89
89
|
return yield g(
|
|
90
|
-
|
|
90
|
+
r,
|
|
91
91
|
{},
|
|
92
92
|
{
|
|
93
93
|
method: "POST",
|
|
@@ -99,16 +99,16 @@ function z(n) {
|
|
|
99
99
|
);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
102
|
+
function x(n) {
|
|
103
|
+
return c(this, null, function* () {
|
|
104
104
|
let { dmShortID: t, env: e, token: s } = n;
|
|
105
105
|
l({ dmShortID: t, env: e, token: s });
|
|
106
|
-
const
|
|
106
|
+
const r = y(
|
|
107
107
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
108
108
|
e
|
|
109
109
|
);
|
|
110
110
|
return yield g(
|
|
111
|
-
|
|
111
|
+
r,
|
|
112
112
|
{ dmShortID: t, rawRes: !0 },
|
|
113
113
|
{
|
|
114
114
|
method: "POST"
|
|
@@ -116,11 +116,11 @@ function D(n) {
|
|
|
116
116
|
);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
119
|
+
function R(n) {
|
|
120
|
+
return c(this, null, function* () {
|
|
121
121
|
let { env: t, token: e } = n;
|
|
122
122
|
l({ env: t, token: e });
|
|
123
|
-
const s = `${
|
|
123
|
+
const s = `${O[t]}auth/logout?clientID=rest`;
|
|
124
124
|
return yield g(
|
|
125
125
|
s,
|
|
126
126
|
{
|
|
@@ -133,32 +133,32 @@ function J(n) {
|
|
|
133
133
|
);
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function z({ dmShortID: n }) {
|
|
137
137
|
return l({ dmShortID: n }), n;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function I({ env: n }) {
|
|
140
140
|
return l({ env: n }), n;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
return
|
|
144
|
-
let { env: t, dmShortID: e, model: s, options:
|
|
145
|
-
l({ env: t, dmShortID: e, model: s }),
|
|
146
|
-
const
|
|
147
|
-
return { count: u, total: h, items:
|
|
142
|
+
function J(n) {
|
|
143
|
+
return c(this, null, function* () {
|
|
144
|
+
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
145
|
+
l({ env: t, dmShortID: e, model: s }), r = a({ size: 50, page: 1, _list: !0 }, r);
|
|
146
|
+
const o = E(r), i = y(`api/${e}/${s}?${o}`, t), { count: u, total: h, _embedded: f } = yield g(i, n), p = f ? f[`${e}:${s}`] : [];
|
|
147
|
+
return { count: u, total: h, items: p };
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function N({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
151
151
|
l({ env: n, dmShortID: t, model: e, entryID: s });
|
|
152
|
-
const
|
|
153
|
-
return g(i, { dmShortID: t, token:
|
|
152
|
+
const o = E({ _id: s }), i = y(`api/${t}/${e}?${o}`, n);
|
|
153
|
+
return g(i, { dmShortID: t, token: r });
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
return
|
|
155
|
+
function U(o) {
|
|
156
|
+
return c(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
|
|
157
157
|
l({ 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
159
|
return console.log("url", i), yield g(
|
|
160
160
|
i,
|
|
161
|
-
{ env: n, dmShortID: t, token:
|
|
161
|
+
{ env: n, dmShortID: t, token: r },
|
|
162
162
|
{
|
|
163
163
|
method: "POST",
|
|
164
164
|
body: JSON.stringify(s),
|
|
@@ -169,23 +169,23 @@ function I(r) {
|
|
|
169
169
|
);
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
172
|
+
function F(i) {
|
|
173
|
+
return c(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: r,
|
|
179
|
+
token: o
|
|
180
180
|
}) {
|
|
181
|
-
l({ env: n, dmShortID: t, model: e, entryID: s, value:
|
|
181
|
+
l({ env: n, dmShortID: t, model: e, entryID: s, value: r });
|
|
182
182
|
const u = y(`api/${t}/${e}?_id=${s}`, n);
|
|
183
183
|
return yield g(
|
|
184
184
|
u,
|
|
185
|
-
{ token:
|
|
185
|
+
{ token: o },
|
|
186
186
|
{
|
|
187
187
|
method: "PUT",
|
|
188
|
-
body: JSON.stringify(
|
|
188
|
+
body: JSON.stringify(r),
|
|
189
189
|
headers: {
|
|
190
190
|
"Content-Type": "application/json"
|
|
191
191
|
}
|
|
@@ -193,13 +193,13 @@ function M(i) {
|
|
|
193
193
|
);
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
return
|
|
196
|
+
function G(o) {
|
|
197
|
+
return c(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
198
198
|
l({ env: n, dmShortID: t, model: e, entryID: s });
|
|
199
199
|
const i = y(`api/${t}/${e}?_id=${s}`, n);
|
|
200
200
|
return yield g(
|
|
201
201
|
i,
|
|
202
|
-
{ token:
|
|
202
|
+
{ token: r, rawRes: !0 },
|
|
203
203
|
{
|
|
204
204
|
method: "DELETE",
|
|
205
205
|
headers: {
|
|
@@ -209,33 +209,33 @@ function H(r) {
|
|
|
209
209
|
);
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
return
|
|
212
|
+
function M(o) {
|
|
213
|
+
return c(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
|
|
214
214
|
l({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
215
|
-
const i =
|
|
216
|
-
return (yield g(u, { dmShortID: t, token:
|
|
215
|
+
const i = E({ assetID: s }), u = y(`a/${t}/${e}?${i}`, n);
|
|
216
|
+
return (yield g(u, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return
|
|
221
|
-
let { env: t, dmShortID: e, assetGroup: s, token:
|
|
222
|
-
l({ env: t, dmShortID: e, assetGroup: s }),
|
|
223
|
-
const i =
|
|
224
|
-
return { count: h, total: f, items:
|
|
219
|
+
function H(n) {
|
|
220
|
+
return c(this, null, function* () {
|
|
221
|
+
let { env: t, dmShortID: e, assetGroup: s, token: r, options: o = {} } = n;
|
|
222
|
+
l({ env: t, dmShortID: e, assetGroup: s }), o = a({ size: 50, page: 1, _list: !0 }, o);
|
|
223
|
+
const i = E(o), u = y(`a/${e}/${s}?${i}`, t), { count: h, total: f, _embedded: p } = yield g(u, { dmShortID: e, token: r }), _ = p ? p["ec:dm-asset"] : [];
|
|
224
|
+
return { count: h, total: f, items: _ };
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
return
|
|
227
|
+
function Q(i) {
|
|
228
|
+
return c(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: r,
|
|
234
|
+
name: o
|
|
235
235
|
}) {
|
|
236
|
-
l({ env: n, dmShortID: t, assetGroup: e, file:
|
|
236
|
+
l({ env: n, dmShortID: t, assetGroup: e, file: r });
|
|
237
237
|
const u = y(`a/${t}/${e}`, n), h = new FormData();
|
|
238
|
-
return h.append("file",
|
|
238
|
+
return h.append("file", r, o), (yield g(
|
|
239
239
|
u,
|
|
240
240
|
{ token: s },
|
|
241
241
|
{
|
|
@@ -245,111 +245,121 @@ function W(i) {
|
|
|
245
245
|
))._embedded["ec:dm-asset"];
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
|
-
const
|
|
248
|
+
const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
249
249
|
__proto__: null,
|
|
250
|
-
assetList:
|
|
251
|
-
createAsset:
|
|
252
|
-
createEntry:
|
|
253
|
-
deleteEntry:
|
|
254
|
-
editEntry:
|
|
255
|
-
entryList:
|
|
256
|
-
getAsset:
|
|
257
|
-
getEcAuthKey:
|
|
258
|
-
getEntry:
|
|
259
|
-
getPublicAuthKey:
|
|
260
|
-
loginEc:
|
|
261
|
-
loginPublic:
|
|
262
|
-
logoutEc:
|
|
263
|
-
logoutPublic:
|
|
250
|
+
assetList: H,
|
|
251
|
+
createAsset: Q,
|
|
252
|
+
createEntry: U,
|
|
253
|
+
deleteEntry: G,
|
|
254
|
+
editEntry: F,
|
|
255
|
+
entryList: J,
|
|
256
|
+
getAsset: M,
|
|
257
|
+
getEcAuthKey: I,
|
|
258
|
+
getEntry: N,
|
|
259
|
+
getPublicAuthKey: z,
|
|
260
|
+
loginEc: q,
|
|
261
|
+
loginPublic: C,
|
|
262
|
+
logoutEc: R,
|
|
263
|
+
logoutPublic: x
|
|
264
264
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
265
|
-
entryList:
|
|
266
|
-
getEntry:
|
|
267
|
-
getAsset:
|
|
268
|
-
assetList:
|
|
269
|
-
createAsset:
|
|
270
|
-
createEntry:
|
|
271
|
-
editEntry:
|
|
272
|
-
deleteEntry:
|
|
273
|
-
loginPublic:
|
|
274
|
-
loginEc:
|
|
275
|
-
logoutEc:
|
|
276
|
-
logoutPublic:
|
|
277
|
-
getEcAuthKey:
|
|
278
|
-
getPublicAuthKey:
|
|
279
|
-
} =
|
|
280
|
-
function
|
|
265
|
+
entryList: V,
|
|
266
|
+
getEntry: W,
|
|
267
|
+
getAsset: X,
|
|
268
|
+
assetList: Y,
|
|
269
|
+
createAsset: Z,
|
|
270
|
+
createEntry: m,
|
|
271
|
+
editEntry: j,
|
|
272
|
+
deleteEntry: v,
|
|
273
|
+
loginPublic: tt,
|
|
274
|
+
loginEc: et,
|
|
275
|
+
logoutEc: nt,
|
|
276
|
+
logoutPublic: st,
|
|
277
|
+
getEcAuthKey: k,
|
|
278
|
+
getPublicAuthKey: w
|
|
279
|
+
} = $;
|
|
280
|
+
function ot(n) {
|
|
281
281
|
const { action: t } = n;
|
|
282
|
-
if (l({ action: t }),
|
|
282
|
+
if (l({ action: t }), !$[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($).join(
|
|
285
285
|
", "
|
|
286
286
|
)}`
|
|
287
287
|
);
|
|
288
|
-
return
|
|
288
|
+
return $[t](n);
|
|
289
289
|
}
|
|
290
|
-
class
|
|
290
|
+
class b {
|
|
291
291
|
constructor(t) {
|
|
292
292
|
this.config = t;
|
|
293
293
|
}
|
|
294
294
|
set(t) {
|
|
295
|
-
return new
|
|
295
|
+
return new b(a(a({}, this.config), t));
|
|
296
296
|
}
|
|
297
297
|
handle(t) {
|
|
298
|
-
return
|
|
299
|
-
const e = Object.keys(this.config), s = yield this.getBestToken(), [
|
|
300
|
-
if (!
|
|
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
301
|
throw new Error(
|
|
302
302
|
`you need to first set ${Object.keys(t).join(" | ")}`
|
|
303
303
|
);
|
|
304
|
-
return
|
|
304
|
+
return o(d(a({}, this.config), { token: s }));
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
///
|
|
308
308
|
entries(t) {
|
|
309
|
-
return
|
|
309
|
+
return c(this, null, function* () {
|
|
310
310
|
const e = yield this.getBestToken();
|
|
311
|
-
return
|
|
311
|
+
return V(d(a({}, this.config), { options: t, token: e }));
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
entryList(t) {
|
|
315
|
+
return c(this, null, function* () {
|
|
316
|
+
return this.entries(t);
|
|
312
317
|
});
|
|
313
318
|
}
|
|
314
319
|
assets(t) {
|
|
315
|
-
return
|
|
320
|
+
return c(this, null, function* () {
|
|
316
321
|
const e = yield this.getBestToken();
|
|
317
|
-
return
|
|
322
|
+
return Y(d(a({}, this.config), { options: t, token: e }));
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
assetList(t) {
|
|
326
|
+
return c(this, null, function* () {
|
|
327
|
+
return this.assets(t);
|
|
318
328
|
});
|
|
319
329
|
}
|
|
320
330
|
createAsset() {
|
|
321
|
-
return
|
|
331
|
+
return c(this, arguments, function* ({ file: t, name: e } = {}) {
|
|
322
332
|
const s = yield this.getBestToken();
|
|
323
|
-
return
|
|
333
|
+
return Z(d(a({}, this.config), { file: t, name: e, token: s }));
|
|
324
334
|
});
|
|
325
335
|
}
|
|
326
336
|
get() {
|
|
327
337
|
return this.handle({
|
|
328
|
-
assetID:
|
|
329
|
-
entryID:
|
|
338
|
+
assetID: X,
|
|
339
|
+
entryID: W
|
|
330
340
|
});
|
|
331
341
|
}
|
|
332
342
|
del() {
|
|
333
343
|
return this.handle({
|
|
334
|
-
entryID:
|
|
344
|
+
entryID: v
|
|
335
345
|
});
|
|
336
346
|
}
|
|
337
347
|
createEntry(t) {
|
|
338
|
-
return
|
|
348
|
+
return m(d(a({}, this.config), { value: t }));
|
|
339
349
|
}
|
|
340
350
|
editEntry(t) {
|
|
341
|
-
return
|
|
351
|
+
return j(d(a({}, this.config), { value: t }));
|
|
342
352
|
}
|
|
343
353
|
create(t) {
|
|
344
354
|
return this.set({ value: t }).handle({
|
|
345
355
|
//assetID: createAsset,
|
|
346
|
-
model:
|
|
356
|
+
model: m
|
|
347
357
|
});
|
|
348
358
|
}
|
|
349
359
|
edit(t) {
|
|
350
360
|
return this.set({ value: t }).handle({
|
|
351
361
|
//assetID: createAsset,
|
|
352
|
-
entryID:
|
|
362
|
+
entryID: j
|
|
353
363
|
});
|
|
354
364
|
}
|
|
355
365
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -379,32 +389,32 @@ class p {
|
|
|
379
389
|
return e(t);
|
|
380
390
|
}
|
|
381
391
|
loginEc(t) {
|
|
382
|
-
return
|
|
383
|
-
this.setAuth(
|
|
392
|
+
return et(a(a({}, this.config), t)).then(
|
|
393
|
+
this.setAuth(k(this.config))
|
|
384
394
|
);
|
|
385
395
|
}
|
|
386
396
|
loginPublic(t) {
|
|
387
|
-
return
|
|
388
|
-
this.setAuth(
|
|
397
|
+
return tt(a(a({}, this.config), t)).then(
|
|
398
|
+
this.setAuth(w(this.config))
|
|
389
399
|
);
|
|
390
400
|
}
|
|
391
401
|
logoutPublic() {
|
|
392
402
|
const t = this.getPublicToken();
|
|
393
|
-
return console.log("token", t),
|
|
394
|
-
this.unsetAuth(
|
|
403
|
+
return console.log("token", t), st(d(a({}, this.config), { token: t })).then(
|
|
404
|
+
this.unsetAuth(w(this.config))
|
|
395
405
|
);
|
|
396
406
|
}
|
|
397
407
|
logoutEc() {
|
|
398
408
|
const t = this.getEcToken();
|
|
399
|
-
return console.log("token", t),
|
|
400
|
-
this.unsetAuth(
|
|
409
|
+
return console.log("token", t), nt(d(a({}, this.config), { token: t })).then(
|
|
410
|
+
this.unsetAuth(k(this.config))
|
|
401
411
|
);
|
|
402
412
|
}
|
|
403
413
|
getPublicToken() {
|
|
404
|
-
return this.config.token || this.getAuth(
|
|
414
|
+
return this.config.token || this.getAuth(w(this.config));
|
|
405
415
|
}
|
|
406
416
|
getEcToken() {
|
|
407
|
-
return this.config.token || this.getAuth(
|
|
417
|
+
return this.config.token || this.getAuth(k(this.config));
|
|
408
418
|
}
|
|
409
419
|
hasPublicToken() {
|
|
410
420
|
return !!this.getPublicToken();
|
|
@@ -422,46 +432,107 @@ class p {
|
|
|
422
432
|
return;
|
|
423
433
|
}
|
|
424
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Sets the given model to use
|
|
437
|
+
* @param {string} model name of the model
|
|
438
|
+
* @returns Sdk
|
|
439
|
+
*/
|
|
440
|
+
model(t) {
|
|
441
|
+
return this.set({ model: t });
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Sets the token to use in requests
|
|
445
|
+
* @param {string} token
|
|
446
|
+
* @returns Sdk
|
|
447
|
+
*/
|
|
448
|
+
token(t) {
|
|
449
|
+
return this.set({ token: t });
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Sets the short ID of the datamanager to use
|
|
453
|
+
* @param {string} dmShortID
|
|
454
|
+
* @returns Sdk
|
|
455
|
+
*/
|
|
456
|
+
dmShortID(t) {
|
|
457
|
+
return this.set({ dmShortID: t });
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Sets the short ID of the datamanager to use. Alias for `dmShortID`
|
|
461
|
+
* @param {string} dmShortID
|
|
462
|
+
* @returns Sdk
|
|
463
|
+
*/
|
|
464
|
+
dm(t) {
|
|
465
|
+
return this.dmShortID(t);
|
|
466
|
+
}
|
|
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
|
+
/**
|
|
484
|
+
* Sets the name of the asset group to use.
|
|
485
|
+
* @param {string} assetGroup name of the asset group
|
|
486
|
+
* @returns Sdk
|
|
487
|
+
*/
|
|
488
|
+
assetGroup(t) {
|
|
489
|
+
return this.set({ assetGroup: t });
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Sets the name of the asset group to use. Alias for `assetGroup`
|
|
493
|
+
* @param {string} assetGroup name of the asset group
|
|
494
|
+
* @returns Sdk
|
|
495
|
+
*/
|
|
496
|
+
assetgroup(t) {
|
|
497
|
+
return this.assetGroup(t);
|
|
498
|
+
}
|
|
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
|
+
}
|
|
425
515
|
}
|
|
426
|
-
const
|
|
427
|
-
const [t] = n;
|
|
428
|
-
n.forEach((e) => {
|
|
429
|
-
p.prototype[e] = function(s) {
|
|
430
|
-
return this.set({ [t]: s });
|
|
431
|
-
};
|
|
432
|
-
});
|
|
433
|
-
}, T = (n, t) => {
|
|
434
|
-
p.prototype[n] = p.prototype[t];
|
|
435
|
-
};
|
|
436
|
-
$("dmShortID", "dm", "dmshortid");
|
|
437
|
-
$("model");
|
|
438
|
-
$("token");
|
|
439
|
-
$("entryID", "entry");
|
|
440
|
-
$("assetGroup");
|
|
441
|
-
$("assetID", "asset");
|
|
442
|
-
T("assetgroup", "assetGroup");
|
|
443
|
-
T("entryList", "entries");
|
|
444
|
-
T("assetList", "assets");
|
|
445
|
-
const at = (n) => new p({ env: n });
|
|
516
|
+
const it = (n) => new b({ env: n });
|
|
446
517
|
export {
|
|
447
|
-
|
|
518
|
+
ot as act,
|
|
448
519
|
y as apiURL,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
520
|
+
H as assetList,
|
|
521
|
+
Q as createAsset,
|
|
522
|
+
U as createEntry,
|
|
523
|
+
G as deleteEntry,
|
|
524
|
+
F as editEntry,
|
|
525
|
+
J as entryList,
|
|
455
526
|
l as expect,
|
|
456
527
|
g as fetcher,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
528
|
+
M as getAsset,
|
|
529
|
+
I as getEcAuthKey,
|
|
530
|
+
N as getEntry,
|
|
531
|
+
z as getPublicAuthKey,
|
|
532
|
+
q as loginEc,
|
|
533
|
+
C as loginPublic,
|
|
534
|
+
R as logoutEc,
|
|
535
|
+
x as logoutPublic,
|
|
536
|
+
E as query,
|
|
537
|
+
it as sdk
|
|
467
538
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.mts","sourceRoot":"","sources":["../../src/lib/actions.mjs"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export function act(config: any): any;
|
|
2
|
+
export * from "./util.mjs";
|
|
3
|
+
export function sdk(env: any): Sdk;
|
|
4
|
+
declare class Sdk {
|
|
5
|
+
constructor(config: any);
|
|
6
|
+
config: any;
|
|
7
|
+
set(obj: any): Sdk;
|
|
8
|
+
handle(handlers: any): Promise<any>;
|
|
9
|
+
entries(options: any): Promise<{
|
|
10
|
+
count: any;
|
|
11
|
+
total: any;
|
|
12
|
+
items: any;
|
|
13
|
+
}>;
|
|
14
|
+
entryList(options: any): Promise<{
|
|
15
|
+
count: any;
|
|
16
|
+
total: any;
|
|
17
|
+
items: any;
|
|
18
|
+
}>;
|
|
19
|
+
assets(options: any): Promise<{
|
|
20
|
+
count: any;
|
|
21
|
+
total: any;
|
|
22
|
+
items: any;
|
|
23
|
+
}>;
|
|
24
|
+
assetList(options: any): Promise<{
|
|
25
|
+
count: any;
|
|
26
|
+
total: any;
|
|
27
|
+
items: any;
|
|
28
|
+
}>;
|
|
29
|
+
createAsset({ file, name }?: {
|
|
30
|
+
file: any;
|
|
31
|
+
name: any;
|
|
32
|
+
}): Promise<any>;
|
|
33
|
+
get(): Promise<any>;
|
|
34
|
+
del(): Promise<any>;
|
|
35
|
+
createEntry(value: any): Promise<any>;
|
|
36
|
+
editEntry(value: any): Promise<any>;
|
|
37
|
+
create(value: any): Promise<any>;
|
|
38
|
+
edit(value: any): Promise<any>;
|
|
39
|
+
authAdapter(authAdapter: any): Sdk;
|
|
40
|
+
setAuth(key: any): (auth: any) => any;
|
|
41
|
+
unsetAuth(key: any): (auth: any) => any;
|
|
42
|
+
getAuth(key: any): any;
|
|
43
|
+
loginEc(config: any): Promise<any>;
|
|
44
|
+
loginPublic(config: any): Promise<any>;
|
|
45
|
+
logoutPublic(): Promise<any>;
|
|
46
|
+
logoutEc(): Promise<any>;
|
|
47
|
+
getPublicToken(): any;
|
|
48
|
+
getEcToken(): any;
|
|
49
|
+
hasPublicToken(): boolean;
|
|
50
|
+
hasEcToken(): boolean;
|
|
51
|
+
hasAnyToken(): boolean;
|
|
52
|
+
getBestToken(): any;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the given model to use
|
|
55
|
+
* @param {string} model name of the model
|
|
56
|
+
* @returns Sdk
|
|
57
|
+
*/
|
|
58
|
+
model(model: string): Sdk;
|
|
59
|
+
/**
|
|
60
|
+
* Sets the token to use in requests
|
|
61
|
+
* @param {string} token
|
|
62
|
+
* @returns Sdk
|
|
63
|
+
*/
|
|
64
|
+
token(token: string): Sdk;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the short ID of the datamanager to use
|
|
67
|
+
* @param {string} dmShortID
|
|
68
|
+
* @returns Sdk
|
|
69
|
+
*/
|
|
70
|
+
dmShortID(dmShortID: string): Sdk;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the short ID of the datamanager to use. Alias for `dmShortID`
|
|
73
|
+
* @param {string} dmShortID
|
|
74
|
+
* @returns Sdk
|
|
75
|
+
*/
|
|
76
|
+
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
|
+
/**
|
|
90
|
+
* Sets the name of the asset group to use.
|
|
91
|
+
* @param {string} assetGroup name of the asset group
|
|
92
|
+
* @returns Sdk
|
|
93
|
+
*/
|
|
94
|
+
assetGroup(assetGroup: string): Sdk;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the name of the asset group to use. Alias for `assetGroup`
|
|
97
|
+
* @param {string} assetGroup name of the asset group
|
|
98
|
+
* @returns Sdk
|
|
99
|
+
*/
|
|
100
|
+
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
|
+
}
|
|
114
|
+
//# sourceMappingURL=api.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAqBA,sCAWC;;AAyPM,mCAAqC;AAvP5C;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED,oCAWC;IAGD;;;;OAGC;IACD;;;;OAEC;IAED;;;;OAGC;IACD;;;;OAEC;IAED;;;qBAGC;IAED,oBAKC;IAED,oBAIC;IAED,sCAEC;IACD,oCAEC;IAED,iCAKC;IAED,+BAKC;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,iBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,eAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,iBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,eAHW,MAAM,OAKhB;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function getAsset({ env, dmShortID, assetGroup, assetID, token }: {
|
|
2
|
+
env: any;
|
|
3
|
+
dmShortID: any;
|
|
4
|
+
assetGroup: any;
|
|
5
|
+
assetID: any;
|
|
6
|
+
token: any;
|
|
7
|
+
}): Promise<any>;
|
|
8
|
+
export function assetList(config: any): Promise<{
|
|
9
|
+
count: any;
|
|
10
|
+
total: any;
|
|
11
|
+
items: any;
|
|
12
|
+
}>;
|
|
13
|
+
export function createAsset({ env, dmShortID, assetGroup, token, file, name, }: {
|
|
14
|
+
env: any;
|
|
15
|
+
dmShortID: any;
|
|
16
|
+
assetGroup: any;
|
|
17
|
+
token: any;
|
|
18
|
+
file: any;
|
|
19
|
+
name: any;
|
|
20
|
+
}): Promise<any>;
|
|
21
|
+
//# sourceMappingURL=assets.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.mts","sourceRoot":"","sources":["../../src/lib/assets.mjs"],"names":[],"mappings":"AAEA;;;;;;iBAMC;AAED;;;;GAUC;AAED;;;;;;;iBAqBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function loginPublic(config: any): Promise<any>;
|
|
2
|
+
export function loginEc(config: any): Promise<any>;
|
|
3
|
+
export function logoutPublic(config: any): Promise<any>;
|
|
4
|
+
export function logoutEc(config: any): Promise<any>;
|
|
5
|
+
export function getPublicAuthKey({ dmShortID }: {
|
|
6
|
+
dmShortID: any;
|
|
7
|
+
}): any;
|
|
8
|
+
export function getEcAuthKey({ env }: {
|
|
9
|
+
env: any;
|
|
10
|
+
}): any;
|
|
11
|
+
//# sourceMappingURL=auth.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["../../src/lib/auth.mjs"],"names":[],"mappings":"AAOA,uDAiBC;AAED,mDAgBC;AAED,wDAeC;AAED,oDAeC;AAED;;QAGC;AACD;;QAGC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function entryList(config: any): Promise<{
|
|
2
|
+
count: any;
|
|
3
|
+
total: any;
|
|
4
|
+
items: any;
|
|
5
|
+
}>;
|
|
6
|
+
export function getEntry({ env, dmShortID, model, entryID, token }: {
|
|
7
|
+
env: any;
|
|
8
|
+
dmShortID: any;
|
|
9
|
+
model: any;
|
|
10
|
+
entryID: any;
|
|
11
|
+
token: any;
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
export function createEntry({ env, dmShortID, model, value, token }: {
|
|
14
|
+
env: any;
|
|
15
|
+
dmShortID: any;
|
|
16
|
+
model: any;
|
|
17
|
+
value: any;
|
|
18
|
+
token: any;
|
|
19
|
+
}): Promise<any>;
|
|
20
|
+
export function editEntry({ env, dmShortID, model, entryID, value, token, }: {
|
|
21
|
+
env: any;
|
|
22
|
+
dmShortID: any;
|
|
23
|
+
model: any;
|
|
24
|
+
entryID: any;
|
|
25
|
+
value: any;
|
|
26
|
+
token: any;
|
|
27
|
+
}): Promise<any>;
|
|
28
|
+
export function deleteEntry({ env, dmShortID, model, entryID, token }: {
|
|
29
|
+
env: any;
|
|
30
|
+
dmShortID: any;
|
|
31
|
+
model: any;
|
|
32
|
+
entryID: any;
|
|
33
|
+
token: any;
|
|
34
|
+
}): Promise<any>;
|
|
35
|
+
//# sourceMappingURL=entries.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.d.mts","sourceRoot":"","sources":["../../src/lib/entries.mjs"],"names":[],"mappings":"AAEA;;;;GAWC;AAED;;;;;;iBAKC;AAED;;;;;;iBAiBC;AAED;;;;;;;iBAuBC;AAED;;;;;;iBAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAiBC;AAOD,sDAQC;AAED,wDAKC;AAED,uCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.mts","sourceRoot":"","sources":["../src/storage.mjs"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ec.fdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "ec frontend sdk",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"directories": {
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
"nanostores": "^0.9.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"typescript": "^5.3.3",
|
|
27
28
|
"vite": "^4.4.9"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
|
-
"build": "vite build"
|
|
31
|
+
"build": "vite build && tsc"
|
|
31
32
|
},
|
|
32
33
|
"module": "dist/index.mjs"
|
|
33
34
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Change this to match your project
|
|
3
|
+
"include": ["src/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
// Tells TypeScript to read JS files, as
|
|
6
|
+
// normally they are ignored as source files
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
// Generate d.ts files
|
|
9
|
+
"declaration": true,
|
|
10
|
+
// This compiler run should
|
|
11
|
+
// only output d.ts files
|
|
12
|
+
"emitDeclarationOnly": true,
|
|
13
|
+
// Types should go into this directory.
|
|
14
|
+
// Removing this would place the .d.ts files
|
|
15
|
+
// next to the .js files
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
// go to js file when using IDE functions like
|
|
18
|
+
// "Go to Definition" in VSCode
|
|
19
|
+
"declarationMap": true
|
|
20
|
+
}
|
|
21
|
+
}
|