ec.fdk 0.3.1 → 0.4.1
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/README.hbs +2 -0
- package/README.md +158 -4
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +307 -276
- package/dist/lib/api.d.mts +17 -2
- package/dist/lib/api.d.mts.map +1 -1
- package/dist/lib/entries.d.mts +4 -2
- package/dist/lib/entries.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var z = Object.defineProperty, C = Object.defineProperties;
|
|
2
|
+
var J = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var j = Object.getOwnPropertySymbols;
|
|
4
|
+
var N = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var S = (n, t, e) => t in n ? z(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, l = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
N.call(t, e) && S(n, e, t[e]);
|
|
8
|
+
if (j)
|
|
9
|
+
for (var e of j(t))
|
|
10
|
+
F.call(t, e) && S(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, y = (n, t) => C(n, J(t));
|
|
13
|
+
var o = (n, t, e) => new Promise((s, r) => {
|
|
14
|
+
var u = (a) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
r(
|
|
16
|
+
d(e.next(a));
|
|
17
|
+
} catch (c) {
|
|
18
|
+
r(c);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, i = (a) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
r(
|
|
22
|
+
d(e.throw(a));
|
|
23
|
+
} catch (c) {
|
|
24
|
+
r(c);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, d = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(u, i);
|
|
27
|
+
d((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
29
|
function g(s) {
|
|
30
|
-
return
|
|
31
|
-
var
|
|
32
|
-
const { token: r, rawRes:
|
|
33
|
-
r && (e.headers =
|
|
30
|
+
return o(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
|
+
var d;
|
|
32
|
+
const { token: r, rawRes: u } = t;
|
|
33
|
+
r && (e.headers = y(l({}, e.headers || {}), {
|
|
34
34
|
Authorization: `Bearer ${r}`
|
|
35
35
|
}));
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
if ((
|
|
39
|
-
const
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
throw new Error(
|
|
36
|
+
const i = yield fetch(n, e);
|
|
37
|
+
if (!i.ok) {
|
|
38
|
+
if ((d = i.headers.get("content-type")) != null && d.includes("application/json")) {
|
|
39
|
+
const a = yield i.json(), c = `${a.title}
|
|
40
|
+
${a.detail}
|
|
41
|
+
${a.verbose}`;
|
|
42
|
+
throw new Error(c);
|
|
43
43
|
}
|
|
44
|
-
throw new Error(`unexpected fetch error: ${
|
|
44
|
+
throw new Error(`unexpected fetch error: ${i.statusText}`);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return u ? i : yield i.json();
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const B = {
|
|
50
50
|
datamanager: {
|
|
51
51
|
live: "https://datamanager.entrecode.de/",
|
|
52
52
|
stage: "https://datamanager.cachena.entrecode.de/"
|
|
@@ -61,10 +61,10 @@ const S = {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
function p(n, t = "stage", e = "datamanager") {
|
|
64
|
-
const s =
|
|
64
|
+
const s = B[e];
|
|
65
65
|
if (!s)
|
|
66
66
|
throw new Error(
|
|
67
|
-
`subdomain "${e}" not found. Try one of ${Object.keys(
|
|
67
|
+
`subdomain "${e}" not found. Try one of ${Object.keys(B).join(", ")}`
|
|
68
68
|
);
|
|
69
69
|
const r = s[t];
|
|
70
70
|
if (!r)
|
|
@@ -76,23 +76,23 @@ function p(n, t = "stage", e = "datamanager") {
|
|
|
76
76
|
function w(n, t = !0) {
|
|
77
77
|
return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function h(n) {
|
|
80
80
|
Object.entries(n).forEach(([t, e]) => {
|
|
81
81
|
if (e === void 0)
|
|
82
82
|
throw new Error(`expected ${t} to be set!`);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const D = {
|
|
86
86
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
87
87
|
live: "https://accounts.entrecode.de/"
|
|
88
88
|
};
|
|
89
|
-
function
|
|
90
|
-
return
|
|
89
|
+
function R(n) {
|
|
90
|
+
return o(this, null, function* () {
|
|
91
91
|
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
92
|
-
|
|
93
|
-
const
|
|
92
|
+
h({ env: t, dmShortID: e, email: s, password: r });
|
|
93
|
+
const u = p(`api/${e}/_auth/login?clientID=rest`, t);
|
|
94
94
|
return yield g(
|
|
95
|
-
|
|
95
|
+
u,
|
|
96
96
|
{},
|
|
97
97
|
{
|
|
98
98
|
method: "POST",
|
|
@@ -104,11 +104,11 @@ function N(n) {
|
|
|
104
104
|
);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
107
|
+
function v(n) {
|
|
108
|
+
return o(this, null, function* () {
|
|
109
109
|
let { env: t, email: e, password: s } = n;
|
|
110
|
-
|
|
111
|
-
const r = `${
|
|
110
|
+
h({ env: t, email: e, password: s });
|
|
111
|
+
const r = `${D[t]}auth/login?clientID=rest`;
|
|
112
112
|
return yield g(
|
|
113
113
|
r,
|
|
114
114
|
{},
|
|
@@ -122,10 +122,10 @@ function C(n) {
|
|
|
122
122
|
);
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
return
|
|
125
|
+
function U(n) {
|
|
126
|
+
return o(this, null, function* () {
|
|
127
127
|
let { dmShortID: t, env: e, token: s } = n;
|
|
128
|
-
|
|
128
|
+
h({ dmShortID: t, env: e, token: s });
|
|
129
129
|
const r = p(
|
|
130
130
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
131
131
|
e
|
|
@@ -139,11 +139,11 @@ function R(n) {
|
|
|
139
139
|
);
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
return
|
|
142
|
+
function M(n) {
|
|
143
|
+
return o(this, null, function* () {
|
|
144
144
|
let { env: t, token: e } = n;
|
|
145
|
-
|
|
146
|
-
const s = `${
|
|
145
|
+
h({ env: t, token: e });
|
|
146
|
+
const s = `${D[t]}auth/logout?clientID=rest`;
|
|
147
147
|
return yield g(
|
|
148
148
|
s,
|
|
149
149
|
{
|
|
@@ -156,13 +156,13 @@ function F(n) {
|
|
|
156
156
|
);
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
159
|
+
function I({ dmShortID: n }) {
|
|
160
|
+
return h({ dmShortID: n }), n;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
return
|
|
162
|
+
function V({ env: n }) {
|
|
163
|
+
return h({ env: n }), n;
|
|
164
164
|
}
|
|
165
|
-
let
|
|
165
|
+
let G = [
|
|
166
166
|
"created",
|
|
167
167
|
"creator",
|
|
168
168
|
"id",
|
|
@@ -178,43 +178,43 @@ let V = [
|
|
|
178
178
|
"_modelTitleField",
|
|
179
179
|
"_modified"
|
|
180
180
|
];
|
|
181
|
-
function
|
|
181
|
+
function x(n) {
|
|
182
182
|
let t = {};
|
|
183
183
|
for (let e in n)
|
|
184
|
-
|
|
184
|
+
G.includes(e) || (t[e] = n[e]);
|
|
185
185
|
return t;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function H(n) {
|
|
188
188
|
return JSON.parse(JSON.stringify(n));
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
return
|
|
190
|
+
function Q(n) {
|
|
191
|
+
return o(this, null, function* () {
|
|
192
192
|
let { env: t, dmShortID: e } = n;
|
|
193
|
-
|
|
193
|
+
h({ env: t, dmShortID: e });
|
|
194
194
|
const s = p(`api/${e}`, t);
|
|
195
195
|
return g(s, n);
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
198
|
+
function W(n) {
|
|
199
|
+
return o(this, null, function* () {
|
|
200
200
|
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
let
|
|
204
|
-
return
|
|
201
|
+
h({ env: t, dmShortID: e, model: s }), r = l({ size: 50, page: 1, _list: !0 }, r);
|
|
202
|
+
const u = w(r), i = p(`api/${e}/${s}?${u}`, t), { count: d, total: a, _embedded: c } = yield g(i, n);
|
|
203
|
+
let f = c ? c[`${e}:${s}`] : [];
|
|
204
|
+
return f = Array.isArray(f) ? f : [f], { count: d, total: a, items: f };
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
return g(
|
|
207
|
+
function X({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
208
|
+
h({ env: n, dmShortID: t, model: e, entryID: s });
|
|
209
|
+
const u = w({ _id: s }), i = p(`api/${t}/${e}?${u}`, n);
|
|
210
|
+
return g(i, { dmShortID: t, token: r });
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
return
|
|
214
|
-
|
|
215
|
-
const
|
|
212
|
+
function Y(u) {
|
|
213
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
|
|
214
|
+
h({ env: n, dmShortID: t, model: e, value: s });
|
|
215
|
+
const i = p(`api/${t}/${e}`, n);
|
|
216
216
|
return yield g(
|
|
217
|
-
|
|
217
|
+
i,
|
|
218
218
|
{ env: n, dmShortID: t, token: r },
|
|
219
219
|
{
|
|
220
220
|
method: "POST",
|
|
@@ -226,36 +226,43 @@ function W(c) {
|
|
|
226
226
|
);
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
return
|
|
229
|
+
function Z(d) {
|
|
230
|
+
return o(this, arguments, function* ({
|
|
231
231
|
env: n,
|
|
232
232
|
dmShortID: t,
|
|
233
233
|
model: e,
|
|
234
234
|
entryID: s,
|
|
235
235
|
value: r,
|
|
236
|
-
token:
|
|
236
|
+
token: u,
|
|
237
|
+
safePut: i = !1
|
|
237
238
|
}) {
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
h({ env: n, dmShortID: t, model: e, entryID: s, value: r });
|
|
240
|
+
const a = {
|
|
241
|
+
"Content-Type": "application/json"
|
|
242
|
+
};
|
|
243
|
+
if (i) {
|
|
244
|
+
if (!("_modified" in r))
|
|
245
|
+
throw new Error("expected _modified to be set!");
|
|
246
|
+
a["If-Unmodified-Since"] = new Date(r._modified).toUTCString();
|
|
247
|
+
}
|
|
248
|
+
const c = p(`api/${t}/${e}?_id=${s}`, n);
|
|
249
|
+
return r = H(r), r = x(r), yield g(
|
|
250
|
+
c,
|
|
251
|
+
{ token: u },
|
|
243
252
|
{
|
|
244
253
|
method: "PUT",
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
"Content-Type": "application/json"
|
|
248
|
-
}
|
|
254
|
+
headers: a,
|
|
255
|
+
body: JSON.stringify(r)
|
|
249
256
|
}
|
|
250
257
|
);
|
|
251
258
|
});
|
|
252
259
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
255
|
-
|
|
256
|
-
const
|
|
260
|
+
function tt(u) {
|
|
261
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
262
|
+
h({ env: n, dmShortID: t, model: e, entryID: s });
|
|
263
|
+
const i = p(`api/${t}/${e}?_id=${s}`, n);
|
|
257
264
|
yield g(
|
|
258
|
-
|
|
265
|
+
i,
|
|
259
266
|
{ token: r, rawRes: !0 },
|
|
260
267
|
{
|
|
261
268
|
method: "DELETE",
|
|
@@ -266,80 +273,84 @@ function Y(c) {
|
|
|
266
273
|
);
|
|
267
274
|
});
|
|
268
275
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
if (typeof
|
|
276
|
+
function et(r) {
|
|
277
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
|
|
278
|
+
var f, $, P, L, O;
|
|
279
|
+
h({ env: n, dmShortID: t, model: e });
|
|
280
|
+
const u = p(`api/schema/${t}/${e}`, n), i = yield g(u), d = (f = i == null ? void 0 : i.allOf) == null ? void 0 : f[1];
|
|
281
|
+
if (typeof d.properties != "object")
|
|
275
282
|
throw new Error(
|
|
276
|
-
`getSchema: ${
|
|
283
|
+
`getSchema: ${u} returned unexpected format: ${JSON.stringify(i)}`
|
|
277
284
|
);
|
|
278
|
-
const { properties:
|
|
279
|
-
for (let k in
|
|
280
|
-
let
|
|
281
|
-
if (
|
|
282
|
-
const E =
|
|
283
|
-
|
|
285
|
+
const { properties: a } = d, c = x(a);
|
|
286
|
+
for (let k in c) {
|
|
287
|
+
let m = c[k];
|
|
288
|
+
if (m.required = d.required.includes(k), ($ = c[k]) != null && $.oneOf && ((P = c[k]) == null || delete P.oneOf), (L = m.title) != null && L.includes("<") && ((O = m.title) != null && O.includes(">"))) {
|
|
289
|
+
const E = m.title.split("<")[1].slice(0, -1), K = m.title.split("<")[0];
|
|
290
|
+
m.type = K, E.includes(":") ? m.resource = E.split(":")[1] : m.resource = E;
|
|
284
291
|
} else
|
|
285
|
-
["asset", "entry", "assets", "entries"].includes(
|
|
286
|
-
delete
|
|
292
|
+
["asset", "entry", "assets", "entries"].includes(m.title) ? (m.type = m.title, m.resource = null) : m.type = m.title;
|
|
293
|
+
delete c[k].title;
|
|
287
294
|
}
|
|
288
|
-
|
|
295
|
+
if (s) {
|
|
296
|
+
const k = a._modelTitle.title, m = a._modelTitleField.title;
|
|
297
|
+
return { properties: c, meta: { modelTitleField: m, modelTitle: k } };
|
|
298
|
+
}
|
|
299
|
+
return c;
|
|
289
300
|
});
|
|
290
301
|
}
|
|
291
|
-
function
|
|
292
|
-
return
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
return (yield g(
|
|
302
|
+
function nt(u) {
|
|
303
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
|
|
304
|
+
h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
305
|
+
const i = w({ assetID: s }), d = p(`a/${t}/${e}?${i}`, n);
|
|
306
|
+
return (yield g(d, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
|
|
296
307
|
});
|
|
297
308
|
}
|
|
298
|
-
function
|
|
299
|
-
return
|
|
300
|
-
let { env: t, dmShortID: e, assetGroup: s, token: r, options:
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
let
|
|
304
|
-
return
|
|
309
|
+
function st(n) {
|
|
310
|
+
return o(this, null, function* () {
|
|
311
|
+
let { env: t, dmShortID: e, assetGroup: s, token: r, options: u = {} } = n;
|
|
312
|
+
h({ env: t, dmShortID: e, assetGroup: s }), u = l({ size: 50, page: 1, _list: !0 }, u);
|
|
313
|
+
const i = w(u), d = p(`a/${e}/${s}?${i}`, t), { count: a, total: c, _embedded: f } = yield g(d, { dmShortID: e, token: r });
|
|
314
|
+
let $ = f ? f["ec:dm-asset"] : [];
|
|
315
|
+
return $ = Array.isArray($) ? $ : [$], { count: a, total: c, items: $ };
|
|
305
316
|
});
|
|
306
317
|
}
|
|
307
|
-
function
|
|
308
|
-
return
|
|
318
|
+
function rt(d) {
|
|
319
|
+
return o(this, arguments, function* ({
|
|
309
320
|
env: n,
|
|
310
321
|
dmShortID: t,
|
|
311
322
|
assetGroup: e,
|
|
312
323
|
token: s,
|
|
313
324
|
file: r,
|
|
314
|
-
name:
|
|
315
|
-
options:
|
|
325
|
+
name: u,
|
|
326
|
+
options: i
|
|
316
327
|
}) {
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
return
|
|
320
|
-
|
|
328
|
+
h({ env: n, dmShortID: t, assetGroup: e, file: r });
|
|
329
|
+
const a = p(`a/${t}/${e}`, n), c = new FormData();
|
|
330
|
+
return c.append("file", r, u), i && Object.keys(i).forEach(($) => {
|
|
331
|
+
c.append($, i[$]);
|
|
321
332
|
}), (yield g(
|
|
322
|
-
|
|
333
|
+
a,
|
|
323
334
|
{ token: s },
|
|
324
335
|
{
|
|
325
336
|
method: "POST",
|
|
326
|
-
body:
|
|
337
|
+
body: c
|
|
327
338
|
}
|
|
328
339
|
))._embedded["ec:dm-asset"];
|
|
329
340
|
});
|
|
330
341
|
}
|
|
331
|
-
function
|
|
332
|
-
return
|
|
342
|
+
function it(u) {
|
|
343
|
+
return o(this, arguments, function* ({
|
|
333
344
|
env: n,
|
|
334
345
|
dmShortID: t,
|
|
335
346
|
assetGroup: e,
|
|
336
347
|
assetID: s,
|
|
337
348
|
token: r
|
|
338
349
|
}) {
|
|
339
|
-
|
|
340
|
-
const
|
|
350
|
+
h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
351
|
+
const i = p(`a/${t}/${e}/${s}`, n);
|
|
341
352
|
yield g(
|
|
342
|
-
|
|
353
|
+
i,
|
|
343
354
|
{ token: r, rawRes: !0 },
|
|
344
355
|
{
|
|
345
356
|
method: "DELETE"
|
|
@@ -347,100 +358,100 @@ function st(c) {
|
|
|
347
358
|
);
|
|
348
359
|
});
|
|
349
360
|
}
|
|
350
|
-
function
|
|
351
|
-
return
|
|
361
|
+
function ot(n) {
|
|
362
|
+
return o(this, null, function* () {
|
|
352
363
|
let { env: t, dmID: e, token: s } = n;
|
|
353
|
-
|
|
364
|
+
h({ env: t, dmID: e });
|
|
354
365
|
const r = p(`?dataManagerID=${e}`, t);
|
|
355
366
|
return g(r, { token: s });
|
|
356
367
|
});
|
|
357
368
|
}
|
|
358
|
-
function
|
|
359
|
-
return
|
|
369
|
+
function at(n) {
|
|
370
|
+
return o(this, null, function* () {
|
|
360
371
|
let { env: t, options: e = {} } = n;
|
|
361
|
-
|
|
362
|
-
const s = w(e), r = p(`?${s}`, t), { count:
|
|
363
|
-
let
|
|
364
|
-
return
|
|
372
|
+
h({ env: t }), e = l({ size: 25, page: 1, _list: !0 }, e);
|
|
373
|
+
const s = w(e), r = p(`?${s}`, t), { count: u, total: i, _embedded: d } = yield g(r, n);
|
|
374
|
+
let a = d ? d["ec:datamanager"] : [];
|
|
375
|
+
return a = Array.isArray(a) ? a : [a], { count: u, total: i, items: a };
|
|
365
376
|
});
|
|
366
377
|
}
|
|
367
|
-
function
|
|
368
|
-
return
|
|
378
|
+
function ct(n) {
|
|
379
|
+
return o(this, null, function* () {
|
|
369
380
|
let { env: t, dmID: e, options: s = {} } = n;
|
|
370
|
-
|
|
371
|
-
const r = w(s),
|
|
372
|
-
let
|
|
373
|
-
return
|
|
381
|
+
h({ env: t, dmID: e }), s = l({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
|
|
382
|
+
const r = w(s), u = p(`model?${r}`, t), { count: i, total: d, _embedded: a } = yield g(u, n);
|
|
383
|
+
let c = a ? a["ec:model"] : [];
|
|
384
|
+
return c = Array.isArray(c) ? c : [c], { count: i, total: d, items: c };
|
|
374
385
|
});
|
|
375
386
|
}
|
|
376
|
-
function
|
|
377
|
-
return
|
|
387
|
+
function ut(n) {
|
|
388
|
+
return o(this, null, function* () {
|
|
378
389
|
let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
let
|
|
382
|
-
return
|
|
390
|
+
h({ env: t, subdomain: r, resource: e }), s = l({ size: 25, page: 1, _list: !0 }, s);
|
|
391
|
+
const u = w(s), i = p(`${e}?${u}`, t, r), { count: d, total: a, _embedded: c } = yield g(i, n);
|
|
392
|
+
let f = c ? c[Object.keys(c)[0]] : [];
|
|
393
|
+
return f = Array.isArray(f) ? f : [f], { count: d, total: a, items: f };
|
|
383
394
|
});
|
|
384
395
|
}
|
|
385
|
-
function
|
|
386
|
-
return
|
|
387
|
-
let { env: s, route: r, options:
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
return g(
|
|
396
|
+
function lt(e) {
|
|
397
|
+
return o(this, arguments, function* (n, t = {}) {
|
|
398
|
+
let { env: s, route: r, options: u = {}, subdomain: i = "datamanager" } = n;
|
|
399
|
+
h({ env: s, subdomain: i, route: r }), u = l({}, u);
|
|
400
|
+
const d = w(u), a = p(`${r}?${d}`, s, i);
|
|
401
|
+
return g(a, n, t);
|
|
391
402
|
});
|
|
392
403
|
}
|
|
393
404
|
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
394
405
|
__proto__: null,
|
|
395
|
-
assetList:
|
|
396
|
-
createAsset:
|
|
397
|
-
createEntry:
|
|
398
|
-
deleteAsset:
|
|
399
|
-
deleteEntry:
|
|
400
|
-
dmList:
|
|
401
|
-
editEntry:
|
|
402
|
-
entryList:
|
|
403
|
-
getAsset:
|
|
404
|
-
getDatamanager:
|
|
405
|
-
getEcAuthKey:
|
|
406
|
-
getEntry:
|
|
407
|
-
getPublicAuthKey:
|
|
408
|
-
getSchema:
|
|
409
|
-
loginEc:
|
|
410
|
-
loginPublic:
|
|
411
|
-
logoutEc:
|
|
412
|
-
logoutPublic:
|
|
413
|
-
modelList:
|
|
414
|
-
publicApi:
|
|
415
|
-
raw:
|
|
416
|
-
resourceList:
|
|
406
|
+
assetList: st,
|
|
407
|
+
createAsset: rt,
|
|
408
|
+
createEntry: Y,
|
|
409
|
+
deleteAsset: it,
|
|
410
|
+
deleteEntry: tt,
|
|
411
|
+
dmList: at,
|
|
412
|
+
editEntry: Z,
|
|
413
|
+
entryList: W,
|
|
414
|
+
getAsset: nt,
|
|
415
|
+
getDatamanager: ot,
|
|
416
|
+
getEcAuthKey: V,
|
|
417
|
+
getEntry: X,
|
|
418
|
+
getPublicAuthKey: I,
|
|
419
|
+
getSchema: et,
|
|
420
|
+
loginEc: v,
|
|
421
|
+
loginPublic: R,
|
|
422
|
+
logoutEc: M,
|
|
423
|
+
logoutPublic: U,
|
|
424
|
+
modelList: ct,
|
|
425
|
+
publicApi: Q,
|
|
426
|
+
raw: lt,
|
|
427
|
+
resourceList: ut
|
|
417
428
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
418
|
-
entryList:
|
|
419
|
-
getEntry:
|
|
420
|
-
getAsset:
|
|
421
|
-
assetList:
|
|
422
|
-
createAsset:
|
|
423
|
-
deleteAsset:
|
|
424
|
-
createEntry:
|
|
425
|
-
editEntry:
|
|
429
|
+
entryList: dt,
|
|
430
|
+
getEntry: ht,
|
|
431
|
+
getAsset: gt,
|
|
432
|
+
assetList: ft,
|
|
433
|
+
createAsset: yt,
|
|
434
|
+
deleteAsset: pt,
|
|
435
|
+
createEntry: mt,
|
|
436
|
+
editEntry: q,
|
|
426
437
|
deleteEntry: $t,
|
|
427
|
-
getSchema:
|
|
428
|
-
loginPublic:
|
|
429
|
-
loginEc:
|
|
430
|
-
logoutEc:
|
|
431
|
-
logoutPublic:
|
|
438
|
+
getSchema: wt,
|
|
439
|
+
loginPublic: kt,
|
|
440
|
+
loginEc: At,
|
|
441
|
+
logoutEc: Et,
|
|
442
|
+
logoutPublic: bt,
|
|
432
443
|
getEcAuthKey: b,
|
|
433
444
|
getPublicAuthKey: T,
|
|
434
|
-
dmList:
|
|
435
|
-
modelList:
|
|
436
|
-
publicApi:
|
|
437
|
-
getDatamanager:
|
|
438
|
-
resourceList:
|
|
439
|
-
raw:
|
|
445
|
+
dmList: Tt,
|
|
446
|
+
modelList: _t,
|
|
447
|
+
publicApi: Pt,
|
|
448
|
+
getDatamanager: Lt,
|
|
449
|
+
resourceList: Ot,
|
|
450
|
+
raw: jt
|
|
440
451
|
} = A;
|
|
441
|
-
function
|
|
452
|
+
function Bt(n) {
|
|
442
453
|
const { action: t } = n;
|
|
443
|
-
if (
|
|
454
|
+
if (h({ action: t }), !A[t])
|
|
444
455
|
throw new Error(
|
|
445
456
|
`"${t}" does not exist! try one of ${Object.keys(A).join(
|
|
446
457
|
", "
|
|
@@ -453,7 +464,7 @@ class _ {
|
|
|
453
464
|
this.config = t;
|
|
454
465
|
}
|
|
455
466
|
set(t) {
|
|
456
|
-
return new _(
|
|
467
|
+
return new _(l(l({}, this.config), t));
|
|
457
468
|
}
|
|
458
469
|
/**
|
|
459
470
|
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
@@ -469,13 +480,13 @@ class _ {
|
|
|
469
480
|
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
470
481
|
*/
|
|
471
482
|
entries() {
|
|
472
|
-
return
|
|
483
|
+
return o(this, arguments, function* (t = {}) {
|
|
473
484
|
const e = yield this.getBestToken();
|
|
474
|
-
return
|
|
485
|
+
return dt(y(l({}, this.config), { options: t, token: e }));
|
|
475
486
|
});
|
|
476
487
|
}
|
|
477
488
|
entryList(t) {
|
|
478
|
-
return
|
|
489
|
+
return o(this, null, function* () {
|
|
479
490
|
return this.entries(t);
|
|
480
491
|
});
|
|
481
492
|
}
|
|
@@ -484,14 +495,34 @@ class _ {
|
|
|
484
495
|
* If the model is not public, you also need to provide a `token`.
|
|
485
496
|
*
|
|
486
497
|
* @param {string} entryID
|
|
487
|
-
* @returns {Promise<EntryResource
|
|
498
|
+
* @returns {Promise<EntryResource>}
|
|
488
499
|
* @example
|
|
489
500
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
490
501
|
*/
|
|
491
502
|
getEntry(t) {
|
|
492
|
-
return
|
|
503
|
+
return o(this, null, function* () {
|
|
493
504
|
const e = yield this.getBestToken();
|
|
494
|
-
return
|
|
505
|
+
return ht(y(l({}, this.config), { entryID: t, token: e }));
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Edits an entry with safe put. Expects `dmShortID` / `model` to be set.
|
|
510
|
+
* Expects a `_modified` field in the value. Will only update if the entry has not been changed since.
|
|
511
|
+
* If model PUT is not public, you also need to provide a `token`.
|
|
512
|
+
*
|
|
513
|
+
* @param {string} entryID id of entry to edit
|
|
514
|
+
* @param {object} value values to set. undefined fields are ignored
|
|
515
|
+
* @returns {Promise<EntryResource>}
|
|
516
|
+
* @example
|
|
517
|
+
* const entry = await sdk("stage")
|
|
518
|
+
* .dm("83cc6374")
|
|
519
|
+
* .model("muffin")
|
|
520
|
+
* .editEntrySafe("1gOtzWvrdq", { name: "test", _modified: "2020-01-01T00:00:00.000Z"})
|
|
521
|
+
*/
|
|
522
|
+
editEntrySafe(t, e) {
|
|
523
|
+
return o(this, null, function* () {
|
|
524
|
+
const s = yield this.getBestToken();
|
|
525
|
+
return q(y(l({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
|
|
495
526
|
});
|
|
496
527
|
}
|
|
497
528
|
/**
|
|
@@ -503,8 +534,8 @@ class _ {
|
|
|
503
534
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
504
535
|
*/
|
|
505
536
|
getSchema() {
|
|
506
|
-
return
|
|
507
|
-
return
|
|
537
|
+
return o(this, null, function* () {
|
|
538
|
+
return wt(this.config);
|
|
508
539
|
});
|
|
509
540
|
}
|
|
510
541
|
/**
|
|
@@ -521,13 +552,13 @@ class _ {
|
|
|
521
552
|
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
522
553
|
*/
|
|
523
554
|
assets(t) {
|
|
524
|
-
return
|
|
555
|
+
return o(this, null, function* () {
|
|
525
556
|
const e = yield this.getBestToken();
|
|
526
|
-
return
|
|
557
|
+
return ft(y(l({}, this.config), { options: t, token: e }));
|
|
527
558
|
});
|
|
528
559
|
}
|
|
529
560
|
assetList(t) {
|
|
530
|
-
return
|
|
561
|
+
return o(this, null, function* () {
|
|
531
562
|
return this.assets(t);
|
|
532
563
|
});
|
|
533
564
|
}
|
|
@@ -553,9 +584,9 @@ class _ {
|
|
|
553
584
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
554
585
|
*/
|
|
555
586
|
createAsset() {
|
|
556
|
-
return
|
|
587
|
+
return o(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
557
588
|
const r = yield this.getBestToken();
|
|
558
|
-
return
|
|
589
|
+
return yt(y(l({}, this.config), { file: t, name: e, options: s, token: r }));
|
|
559
590
|
});
|
|
560
591
|
}
|
|
561
592
|
/**
|
|
@@ -568,9 +599,9 @@ class _ {
|
|
|
568
599
|
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
569
600
|
*/
|
|
570
601
|
deleteAsset(t) {
|
|
571
|
-
return
|
|
602
|
+
return o(this, null, function* () {
|
|
572
603
|
const e = yield this.getBestToken();
|
|
573
|
-
return
|
|
604
|
+
return pt(y(l({}, this.config), { token: e, assetID: t }));
|
|
574
605
|
});
|
|
575
606
|
}
|
|
576
607
|
/**
|
|
@@ -583,9 +614,9 @@ class _ {
|
|
|
583
614
|
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
584
615
|
*/
|
|
585
616
|
getAsset(t) {
|
|
586
|
-
return
|
|
617
|
+
return o(this, null, function* () {
|
|
587
618
|
const e = yield this.getBestToken();
|
|
588
|
-
return
|
|
619
|
+
return gt(y(l({}, this.config), { assetID: t, token: e }));
|
|
589
620
|
});
|
|
590
621
|
}
|
|
591
622
|
/**
|
|
@@ -598,9 +629,9 @@ class _ {
|
|
|
598
629
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
599
630
|
*/
|
|
600
631
|
createEntry(t) {
|
|
601
|
-
return
|
|
632
|
+
return o(this, null, function* () {
|
|
602
633
|
const e = yield this.getBestToken();
|
|
603
|
-
return
|
|
634
|
+
return mt(y(l({}, this.config), { token: e, value: t }));
|
|
604
635
|
});
|
|
605
636
|
}
|
|
606
637
|
/**
|
|
@@ -614,9 +645,9 @@ class _ {
|
|
|
614
645
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
615
646
|
*/
|
|
616
647
|
editEntry(t, e) {
|
|
617
|
-
return
|
|
648
|
+
return o(this, null, function* () {
|
|
618
649
|
const s = yield this.getBestToken();
|
|
619
|
-
return
|
|
650
|
+
return q(y(l({}, this.config), { entryID: t, token: s, value: e }));
|
|
620
651
|
});
|
|
621
652
|
}
|
|
622
653
|
/**
|
|
@@ -629,9 +660,9 @@ class _ {
|
|
|
629
660
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
630
661
|
*/
|
|
631
662
|
deleteEntry(t) {
|
|
632
|
-
return
|
|
663
|
+
return o(this, null, function* () {
|
|
633
664
|
const e = yield this.getBestToken();
|
|
634
|
-
return $t(
|
|
665
|
+
return $t(y(l({}, this.config), { token: e, entryID: t }));
|
|
635
666
|
});
|
|
636
667
|
}
|
|
637
668
|
/**
|
|
@@ -644,9 +675,9 @@ class _ {
|
|
|
644
675
|
* const res = await sdk("stage").resource("template").resourceList()
|
|
645
676
|
*/
|
|
646
677
|
resourceList(t) {
|
|
647
|
-
return
|
|
678
|
+
return o(this, null, function* () {
|
|
648
679
|
const e = yield this.getBestToken();
|
|
649
|
-
return
|
|
680
|
+
return Ot(y(l({}, this.config), { options: t, token: e }));
|
|
650
681
|
});
|
|
651
682
|
}
|
|
652
683
|
/**
|
|
@@ -661,9 +692,9 @@ class _ {
|
|
|
661
692
|
* const res = await sdk("stage").route("stats").raw()
|
|
662
693
|
*/
|
|
663
694
|
raw(t, e) {
|
|
664
|
-
return
|
|
695
|
+
return o(this, null, function* () {
|
|
665
696
|
const s = yield this.getBestToken();
|
|
666
|
-
return
|
|
697
|
+
return jt(y(l({}, this.config), { options: t, token: s }), e);
|
|
667
698
|
});
|
|
668
699
|
}
|
|
669
700
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -693,24 +724,24 @@ class _ {
|
|
|
693
724
|
return e(t);
|
|
694
725
|
}
|
|
695
726
|
loginEc(t) {
|
|
696
|
-
return
|
|
727
|
+
return At(l(l({}, this.config), t)).then(
|
|
697
728
|
this.setAuth(b(this.config))
|
|
698
729
|
);
|
|
699
730
|
}
|
|
700
731
|
loginPublic(t) {
|
|
701
|
-
return
|
|
732
|
+
return kt(l(l({}, this.config), t)).then(
|
|
702
733
|
this.setAuth(T(this.config))
|
|
703
734
|
);
|
|
704
735
|
}
|
|
705
736
|
logoutPublic() {
|
|
706
737
|
const t = this.getPublicToken();
|
|
707
|
-
return console.log("token", t),
|
|
738
|
+
return console.log("token", t), bt(y(l({}, this.config), { token: t })).then(
|
|
708
739
|
this.unsetAuth(T(this.config))
|
|
709
740
|
);
|
|
710
741
|
}
|
|
711
742
|
logoutEc() {
|
|
712
743
|
const t = this.getEcToken();
|
|
713
|
-
return console.log("token", t),
|
|
744
|
+
return console.log("token", t), Et(y(l({}, this.config), { token: t })).then(
|
|
714
745
|
this.unsetAuth(b(this.config))
|
|
715
746
|
);
|
|
716
747
|
}
|
|
@@ -821,16 +852,16 @@ class _ {
|
|
|
821
852
|
* @returns any
|
|
822
853
|
*/
|
|
823
854
|
publicApi() {
|
|
824
|
-
return
|
|
855
|
+
return Pt(this.config);
|
|
825
856
|
}
|
|
826
857
|
/**
|
|
827
858
|
* Loads a DatamanagerResource by its long id. Requires token.
|
|
828
859
|
* @returns any
|
|
829
860
|
*/
|
|
830
861
|
getDatamanager(t) {
|
|
831
|
-
return
|
|
862
|
+
return o(this, null, function* () {
|
|
832
863
|
const e = yield this.getBestToken();
|
|
833
|
-
return
|
|
864
|
+
return Lt(y(l({}, this.config), { dmID: t, token: e }));
|
|
834
865
|
});
|
|
835
866
|
}
|
|
836
867
|
/**
|
|
@@ -842,9 +873,9 @@ class _ {
|
|
|
842
873
|
* const dms = await sdk("stage").dmList()
|
|
843
874
|
*/
|
|
844
875
|
dmList() {
|
|
845
|
-
return
|
|
876
|
+
return o(this, arguments, function* (t = {}) {
|
|
846
877
|
const e = yield this.getBestToken();
|
|
847
|
-
return
|
|
878
|
+
return Tt(y(l({}, this.config), { options: t, token: e }));
|
|
848
879
|
});
|
|
849
880
|
}
|
|
850
881
|
/**
|
|
@@ -856,41 +887,41 @@ class _ {
|
|
|
856
887
|
* const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
857
888
|
*/
|
|
858
889
|
modelList() {
|
|
859
|
-
return
|
|
890
|
+
return o(this, arguments, function* (t = {}) {
|
|
860
891
|
const e = yield this.getBestToken();
|
|
861
|
-
return
|
|
892
|
+
return _t(y(l({}, this.config), { options: t, token: e }));
|
|
862
893
|
});
|
|
863
894
|
}
|
|
864
895
|
}
|
|
865
|
-
const
|
|
896
|
+
const qt = (n) => new _({ env: n });
|
|
866
897
|
export {
|
|
867
898
|
_ as Sdk,
|
|
868
|
-
|
|
899
|
+
Bt as act,
|
|
869
900
|
p as apiURL,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
901
|
+
st as assetList,
|
|
902
|
+
rt as createAsset,
|
|
903
|
+
Y as createEntry,
|
|
904
|
+
it as deleteAsset,
|
|
905
|
+
tt as deleteEntry,
|
|
906
|
+
at as dmList,
|
|
907
|
+
Z as editEntry,
|
|
908
|
+
W as entryList,
|
|
909
|
+
h as expect,
|
|
879
910
|
g as fetcher,
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
911
|
+
nt as getAsset,
|
|
912
|
+
ot as getDatamanager,
|
|
913
|
+
V as getEcAuthKey,
|
|
914
|
+
X as getEntry,
|
|
915
|
+
I as getPublicAuthKey,
|
|
916
|
+
et as getSchema,
|
|
917
|
+
v as loginEc,
|
|
918
|
+
R as loginPublic,
|
|
919
|
+
M as logoutEc,
|
|
920
|
+
U as logoutPublic,
|
|
921
|
+
ct as modelList,
|
|
922
|
+
Q as publicApi,
|
|
892
923
|
w as query,
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
924
|
+
lt as raw,
|
|
925
|
+
ut as resourceList,
|
|
926
|
+
qt as sdk
|
|
896
927
|
};
|