ec.fdk 0.5.3 → 0.6.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/README.md +19 -479
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +112 -106
- package/dist/lib/actions.d.ts +5 -0
- package/dist/lib/actions.d.ts.map +1 -0
- package/dist/lib/admin.d.ts +18 -0
- package/dist/lib/admin.d.ts.map +1 -0
- package/dist/lib/{api.d.mts → api.d.ts} +63 -205
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/{assets.d.mts → assets.d.ts} +5 -5
- package/dist/lib/assets.d.ts.map +1 -0
- package/dist/lib/auth.d.ts +11 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/entries.d.ts +99 -0
- package/dist/lib/entries.d.ts.map +1 -0
- package/dist/lib/util.d.ts +26 -0
- package/dist/lib/util.d.ts.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +85 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1610 -0
- package/docs/classes/Sdk.html +181 -0
- package/docs/functions/act.html +1 -0
- package/docs/functions/apiURL.html +1 -0
- package/docs/functions/assetList.html +1 -0
- package/docs/functions/createAsset.html +1 -0
- package/docs/functions/createEntry.html +1 -0
- package/docs/functions/deleteAsset.html +1 -0
- package/docs/functions/deleteEntry.html +1 -0
- package/docs/functions/deleteEntryObject.html +1 -0
- package/docs/functions/dmList.html +1 -0
- package/docs/functions/editEntry.html +1 -0
- package/docs/functions/editEntryObject.html +1 -0
- package/docs/functions/entryList.html +1 -0
- package/docs/functions/expect.html +1 -0
- package/docs/functions/fdk.html +1 -0
- package/docs/functions/fetcher.html +1 -0
- package/docs/functions/filterOptions.html +3 -0
- package/docs/functions/getAsset.html +1 -0
- package/docs/functions/getDatamanager.html +1 -0
- package/docs/functions/getEcAuthKey.html +1 -0
- package/docs/functions/getEntry.html +1 -0
- package/docs/functions/getEntryAsset.html +3 -0
- package/docs/functions/getEntryEnv.html +2 -0
- package/docs/functions/getEntryShortID.html +2 -0
- package/docs/functions/getPublicAuthKey.html +1 -0
- package/docs/functions/getSchema.html +1 -0
- package/docs/functions/loginEc.html +1 -0
- package/docs/functions/loginPublic.html +1 -0
- package/docs/functions/logoutEc.html +1 -0
- package/docs/functions/logoutPublic.html +1 -0
- package/docs/functions/mapEntries.html +1 -0
- package/docs/functions/modelList.html +1 -0
- package/docs/functions/publicApi.html +1 -0
- package/docs/functions/query.html +1 -0
- package/docs/functions/raw.html +1 -0
- package/docs/functions/resourceList.html +1 -0
- package/docs/functions/sdk-1.html +1 -0
- package/docs/functions/sdkOptions.html +3 -0
- package/docs/index.html +80 -0
- package/docs/modules.html +1 -0
- package/docs/variables/apis.html +1 -0
- package/package.json +4 -3
- package/README.hbs +0 -228
- package/dist/index.d.mts +0 -4
- package/dist/index.d.mts.map +0 -1
- package/dist/lib/actions.d.mts +0 -5
- package/dist/lib/actions.d.mts.map +0 -1
- package/dist/lib/admin.d.mts +0 -18
- package/dist/lib/admin.d.mts.map +0 -1
- package/dist/lib/api.d.mts.map +0 -1
- package/dist/lib/assets.d.mts.map +0 -1
- package/dist/lib/auth.d.mts +0 -11
- package/dist/lib/auth.d.mts.map +0 -1
- package/dist/lib/entries.d.mts +0 -141
- package/dist/lib/entries.d.mts.map +0 -1
- package/dist/lib/util.d.mts +0 -23
- package/dist/lib/util.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
*F*eatherweight *D*evelopment *K*it for entrecode APIs.
|
|
4
4
|
|
|
5
|
+
[ec.fdk docs](https://entrecode.github.io/ec.fdk)
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```sh
|
|
@@ -23,12 +25,12 @@ Start by calling `fdk` with your environment (`stage` | `live`), then method cha
|
|
|
23
25
|
import { fdk } from "ec.fdk";
|
|
24
26
|
|
|
25
27
|
fdk("stage") // choose stage environment
|
|
26
|
-
.dm("83cc6374") // select datamanager via short id
|
|
27
|
-
.model("muffin") // select model muffin
|
|
28
|
-
.entries() // load entry list
|
|
29
|
-
.then(list => {
|
|
30
|
-
|
|
31
|
-
})
|
|
28
|
+
.dm("83cc6374") // select datamanager via short id
|
|
29
|
+
.model("muffin") // select model muffin
|
|
30
|
+
.entries() // load entry list
|
|
31
|
+
.then((list) => {
|
|
32
|
+
console.log(list);
|
|
33
|
+
});
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
You can also reuse parts of the chain with variables:
|
|
@@ -45,7 +47,10 @@ await muffin.deleteEntry(items[1].id);
|
|
|
45
47
|
// create a new muffin
|
|
46
48
|
await muffin.createEntry({ name: "new muffin" });
|
|
47
49
|
// edit third entry with safePut
|
|
48
|
-
await muffin.editEntrySafe(items[2].id, {
|
|
50
|
+
await muffin.editEntrySafe(items[2].id, {
|
|
51
|
+
_modified: items[2]._modified,
|
|
52
|
+
name: "safePut!",
|
|
53
|
+
});
|
|
49
54
|
```
|
|
50
55
|
|
|
51
56
|
### act
|
|
@@ -58,12 +63,12 @@ const muffins = await act({
|
|
|
58
63
|
env: "stage",
|
|
59
64
|
dmShortID: "83cc6374",
|
|
60
65
|
model: "muffin",
|
|
61
|
-
})
|
|
66
|
+
});
|
|
62
67
|
```
|
|
63
68
|
|
|
64
|
-
The object passed to `act` expects an `action` ([available actions](https://github.com/entrecode/ec.fdk/blob/main/packages/ec.fdk/src/lib/api.mjs))
|
|
65
|
-
and additional keys that are required to perform the action.
|
|
66
|
-
If you don't know the required keys for an action, either call `act` without additional keys or look it up in the source.
|
|
69
|
+
The object passed to `act` expects an `action` ([available actions](https://github.com/entrecode/ec.fdk/blob/main/packages/ec.fdk/src/lib/api.mjs))
|
|
70
|
+
and additional keys that are required to perform the action.
|
|
71
|
+
If you don't know the required keys for an action, either call `act` without additional keys or look it up in the source.
|
|
67
72
|
For example, this is how the `entryList` function looks:
|
|
68
73
|
|
|
69
74
|
```js
|
|
@@ -129,7 +134,7 @@ await editEntryObject(entry, value); // <- DO
|
|
|
129
134
|
// alternatively:
|
|
130
135
|
await fdk.env(env).dm(dmShortID).model(model).updateEntry(entryID, value);
|
|
131
136
|
// or:
|
|
132
|
-
await act({ action:
|
|
137
|
+
await act({ action: "editEntry", env, dmShortID, model, entryID, value });
|
|
133
138
|
```
|
|
134
139
|
|
|
135
140
|
### Entry delete
|
|
@@ -144,7 +149,7 @@ await deleteEntryObject(entry); // <- DO
|
|
|
144
149
|
// alternatively:
|
|
145
150
|
await fdk.dm("shortID").model("model").deleteEntry("entryID");
|
|
146
151
|
// or:
|
|
147
|
-
await act({ action:
|
|
152
|
+
await act({ action: "deleteEntry", env, dmShortID, model, entryID });
|
|
148
153
|
```
|
|
149
154
|
|
|
150
155
|
### Entry Asset Fields
|
|
@@ -215,471 +220,6 @@ const entryList = await fdk("stage")
|
|
|
215
220
|
|
|
216
221
|
0. `cd packages/ec.fdk`
|
|
217
222
|
1. bump version in `packages/ec.fdk/package.json`
|
|
218
|
-
2. run `pnpm
|
|
223
|
+
2. run `pnpm docs` to regenerate docs folder
|
|
219
224
|
3. commit + push
|
|
220
225
|
4. run `pnpm publish`
|
|
221
|
-
|
|
222
|
-
## API Reference
|
|
223
|
-
|
|
224
|
-
Now what follows is the autogenerated doc from source:
|
|
225
|
-
|
|
226
|
-
<a name="module_api.Sdk"></a>
|
|
227
|
-
|
|
228
|
-
### api.Sdk
|
|
229
|
-
<p>SDK</p>
|
|
230
|
-
|
|
231
|
-
**Kind**: static class of [<code>api</code>](#module_api)
|
|
232
|
-
|
|
233
|
-
* [.Sdk](#module_api.Sdk)
|
|
234
|
-
* [.entries([options])](#module_api.Sdk+entries) ⇒ [<code>Promise.<EntryList></code>](#EntryList)
|
|
235
|
-
* [.mapEntries([options])](#module_api.Sdk+mapEntries) ⇒ [<code>Promise.<EntryList></code>](#EntryList)
|
|
236
|
-
* [.getEntry(entryID)](#module_api.Sdk+getEntry) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
237
|
-
* [.editEntrySafe(entryID, value)](#module_api.Sdk+editEntrySafe) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
238
|
-
* [.getSchema(entryID)](#module_api.Sdk+getSchema) ⇒ [<code>Promise.<EntrySchema></code>](#EntrySchema)
|
|
239
|
-
* [.assets([options])](#module_api.Sdk+assets) ⇒ [<code>Promise.<AssetList></code>](#AssetList)
|
|
240
|
-
* [.createAsset(options)](#module_api.Sdk+createAsset) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
|
241
|
-
* [.deleteAsset(assetID)](#module_api.Sdk+deleteAsset) ⇒ <code>Promise.<void></code>
|
|
242
|
-
* [.getAsset(assetID)](#module_api.Sdk+getAsset) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
|
243
|
-
* [.createEntry(value)](#module_api.Sdk+createEntry) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
244
|
-
* [.editEntry(entryID, value)](#module_api.Sdk+editEntry) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
245
|
-
* [.deleteEntry(entryID)](#module_api.Sdk+deleteEntry) ⇒ <code>Promise.<void></code>
|
|
246
|
-
* [.resourceList([options])](#module_api.Sdk+resourceList) ⇒ [<code>Promise.<ResourceList></code>](#ResourceList)
|
|
247
|
-
* [.raw([options], [fetchOptions])](#module_api.Sdk+raw) ⇒ <code>Promise.<any></code>
|
|
248
|
-
* [.model(model)](#module_api.Sdk+model) ⇒
|
|
249
|
-
* [.token(token)](#module_api.Sdk+token) ⇒
|
|
250
|
-
* [.dmShortID(dmShortID)](#module_api.Sdk+dmShortID) ⇒
|
|
251
|
-
* [.dmID(dmID)](#module_api.Sdk+dmID) ⇒
|
|
252
|
-
* [.dm(dmShortID)](#module_api.Sdk+dm) ⇒
|
|
253
|
-
* [.assetGroup(assetGroup)](#module_api.Sdk+assetGroup) ⇒
|
|
254
|
-
* [.assetgroup(assetGroup)](#module_api.Sdk+assetgroup) ⇒
|
|
255
|
-
* [.subdomain(subdomain)](#module_api.Sdk+subdomain) ⇒
|
|
256
|
-
* [.resource(resource)](#module_api.Sdk+resource) ⇒
|
|
257
|
-
* [.route(route)](#module_api.Sdk+route) ⇒
|
|
258
|
-
* [.publicApi()](#module_api.Sdk+publicApi) ⇒
|
|
259
|
-
* [.getDatamanager()](#module_api.Sdk+getDatamanager) ⇒
|
|
260
|
-
* [.dmList([options])](#module_api.Sdk+dmList) ⇒ [<code>Promise.<DatamanagerList></code>](#DatamanagerList)
|
|
261
|
-
* [.modelList([options])](#module_api.Sdk+modelList) ⇒ [<code>Promise.<ModelList></code>](#ModelList)
|
|
262
|
-
|
|
263
|
-
<a name="module_api.Sdk+entries"></a>
|
|
264
|
-
|
|
265
|
-
#### sdk.entries([options]) ⇒ [<code>Promise.<EntryList></code>](#EntryList)
|
|
266
|
-
<p>Loads entry list. Expects <code>dmShortID</code> / <code>model</code> to be set.
|
|
267
|
-
If the model is not public, you also need to provide a <code>token</code>.</p>
|
|
268
|
-
|
|
269
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
270
|
-
|
|
271
|
-
| Param | Type | Description |
|
|
272
|
-
| --- | --- | --- |
|
|
273
|
-
| [options] | <code>object</code> | <p>options for entry list request.</p> |
|
|
274
|
-
|
|
275
|
-
**Example**
|
|
276
|
-
```js
|
|
277
|
-
// public model
|
|
278
|
-
const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
|
|
279
|
-
```
|
|
280
|
-
**Example**
|
|
281
|
-
```js
|
|
282
|
-
// non-public model
|
|
283
|
-
const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
284
|
-
```
|
|
285
|
-
<a name="module_api.Sdk+mapEntries"></a>
|
|
286
|
-
|
|
287
|
-
#### sdk.mapEntries([options]) ⇒ [<code>Promise.<EntryList></code>](#EntryList)
|
|
288
|
-
<p>Maps over entry list.</p>
|
|
289
|
-
|
|
290
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
291
|
-
|
|
292
|
-
| Param | Type | Description |
|
|
293
|
-
| --- | --- | --- |
|
|
294
|
-
| [options] | <code>object</code> | <p>options for entry list request.</p> |
|
|
295
|
-
|
|
296
|
-
**Example**
|
|
297
|
-
```js
|
|
298
|
-
// public model
|
|
299
|
-
const muffins = sdk("stage").dm("83cc6374").model("muffin")
|
|
300
|
-
const res = await muffin.mapEntries((entry) => muffin.editEntry(entry.id, { name: entry.name + "!" }));
|
|
301
|
-
console.log("res", res);
|
|
302
|
-
```
|
|
303
|
-
<a name="module_api.Sdk+getEntry"></a>
|
|
304
|
-
|
|
305
|
-
#### sdk.getEntry(entryID) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
306
|
-
<p>Loads a single entry. Expects <code>dmShortID</code> / <code>model</code> to be set.
|
|
307
|
-
If the model is not public, you also need to provide a <code>token</code>.</p>
|
|
308
|
-
|
|
309
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
310
|
-
|
|
311
|
-
| Param | Type |
|
|
312
|
-
| --- | --- |
|
|
313
|
-
| entryID | <code>string</code> |
|
|
314
|
-
|
|
315
|
-
**Example**
|
|
316
|
-
```js
|
|
317
|
-
const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
318
|
-
```
|
|
319
|
-
<a name="module_api.Sdk+editEntrySafe"></a>
|
|
320
|
-
|
|
321
|
-
#### sdk.editEntrySafe(entryID, value) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
322
|
-
<p>Edits an entry with safe put. Expects <code>dmShortID</code> / <code>model</code> to be set.
|
|
323
|
-
Expects a <code>_modified</code> field in the value. Will only update if the entry has not been changed since.
|
|
324
|
-
If model PUT is not public, you also need to provide a <code>token</code>.</p>
|
|
325
|
-
|
|
326
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
327
|
-
|
|
328
|
-
| Param | Type | Description |
|
|
329
|
-
| --- | --- | --- |
|
|
330
|
-
| entryID | <code>string</code> | <p>id of entry to edit</p> |
|
|
331
|
-
| value | <code>object</code> | <p>values to set. undefined fields are ignored</p> |
|
|
332
|
-
|
|
333
|
-
**Example**
|
|
334
|
-
```js
|
|
335
|
-
const entry = await sdk("stage")
|
|
336
|
-
.dm("83cc6374")
|
|
337
|
-
.model("muffin")
|
|
338
|
-
.editEntrySafe("1gOtzWvrdq", { name: "test", _modified: "2020-01-01T00:00:00.000Z"})
|
|
339
|
-
```
|
|
340
|
-
<a name="module_api.Sdk+getSchema"></a>
|
|
341
|
-
|
|
342
|
-
#### sdk.getSchema(entryID) ⇒ [<code>Promise.<EntrySchema></code>](#EntrySchema)
|
|
343
|
-
<p>Loads the schema of a model. Expects <code>dmShortID</code> / <code>model</code> to be set.</p>
|
|
344
|
-
|
|
345
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
346
|
-
|
|
347
|
-
| Param | Type |
|
|
348
|
-
| --- | --- |
|
|
349
|
-
| entryID | <code>string</code> |
|
|
350
|
-
|
|
351
|
-
**Example**
|
|
352
|
-
```js
|
|
353
|
-
const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
354
|
-
```
|
|
355
|
-
<a name="module_api.Sdk+assets"></a>
|
|
356
|
-
|
|
357
|
-
#### sdk.assets([options]) ⇒ [<code>Promise.<AssetList></code>](#AssetList)
|
|
358
|
-
<p>Loads asset list. Expects <code>dmShortID</code> / <code>assetGroup</code> to be set.
|
|
359
|
-
If the assetGroup is not public, you also need to provide a <code>token</code>.</p>
|
|
360
|
-
|
|
361
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
362
|
-
|
|
363
|
-
| Param | Type | Description |
|
|
364
|
-
| --- | --- | --- |
|
|
365
|
-
| [options] | <code>object</code> | <p>options for entry list request.</p> |
|
|
366
|
-
|
|
367
|
-
**Example**
|
|
368
|
-
```js
|
|
369
|
-
// public assetGroup
|
|
370
|
-
const files = await sdk("stage").dm("83cc6374").assetGroup("avatars").assets()
|
|
371
|
-
```
|
|
372
|
-
**Example**
|
|
373
|
-
```js
|
|
374
|
-
// non-public assetGroup
|
|
375
|
-
const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
376
|
-
```
|
|
377
|
-
<a name="module_api.Sdk+createAsset"></a>
|
|
378
|
-
|
|
379
|
-
#### sdk.createAsset(options) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
|
380
|
-
<p>Uploads an asset. Expects <code>dmShortID</code> / <code>assetGroup</code> / <code>file</code> to be set.
|
|
381
|
-
If the assetGroup is not public, you also need to provide a <code>token</code>.</p>
|
|
382
|
-
|
|
383
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
384
|
-
|
|
385
|
-
| Param | Type | Description |
|
|
386
|
-
| --- | --- | --- |
|
|
387
|
-
| options | <code>Object</code> | <p>options for entry list request.</p> |
|
|
388
|
-
|
|
389
|
-
**Example**
|
|
390
|
-
```js
|
|
391
|
-
// browser example
|
|
392
|
-
document.getElementById("file").addEventListener("input", async (e) => {
|
|
393
|
-
const [file] = e.target.files;
|
|
394
|
-
const asset = await ecadmin.assetgroup("test").createAsset({ file })
|
|
395
|
-
});
|
|
396
|
-
```
|
|
397
|
-
**Example**
|
|
398
|
-
```js
|
|
399
|
-
// node example
|
|
400
|
-
const buf = fs.readFileSync("venndiagram.png");
|
|
401
|
-
const file = new Blob([buf]);
|
|
402
|
-
const upload = await sdk("stage")
|
|
403
|
-
.dm("83cc6374")
|
|
404
|
-
.assetgroup("test")
|
|
405
|
-
.createAsset({ file, name: "venndiagram.png" });
|
|
406
|
-
```
|
|
407
|
-
<a name="module_api.Sdk+deleteAsset"></a>
|
|
408
|
-
|
|
409
|
-
#### sdk.deleteAsset(assetID) ⇒ <code>Promise.<void></code>
|
|
410
|
-
<p>Deletes an asset. Expects <code>dmShortID</code> / <code>assetGroup</code> / <code>assetID</code> to be set.
|
|
411
|
-
You probably also need to provide a <code>token</code>.</p>
|
|
412
|
-
|
|
413
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
414
|
-
|
|
415
|
-
| Param | Type |
|
|
416
|
-
| --- | --- |
|
|
417
|
-
| assetID | <code>string</code> |
|
|
418
|
-
|
|
419
|
-
**Example**
|
|
420
|
-
```js
|
|
421
|
-
await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
422
|
-
```
|
|
423
|
-
<a name="module_api.Sdk+getAsset"></a>
|
|
424
|
-
|
|
425
|
-
#### sdk.getAsset(assetID) ⇒ [<code>Promise.<AssetResource></code>](#AssetResource)
|
|
426
|
-
<p>Loads a single asset. Expects <code>dmShortID</code> / <code>assetGroup</code> to be set.
|
|
427
|
-
If the asset group is not public, you also need to provide a <code>token</code>.</p>
|
|
428
|
-
|
|
429
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
430
|
-
|
|
431
|
-
| Param | Type |
|
|
432
|
-
| --- | --- |
|
|
433
|
-
| assetID | <code>string</code> |
|
|
434
|
-
|
|
435
|
-
**Example**
|
|
436
|
-
```js
|
|
437
|
-
const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
438
|
-
```
|
|
439
|
-
<a name="module_api.Sdk+createEntry"></a>
|
|
440
|
-
|
|
441
|
-
#### sdk.createEntry(value) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
442
|
-
<p>Creates a new entry. Expects <code>dmShortID</code> / <code>model</code> to be set.
|
|
443
|
-
If model POST is not public, you also need to provide a <code>token</code>.</p>
|
|
444
|
-
|
|
445
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
446
|
-
|
|
447
|
-
| Param | Type | Description |
|
|
448
|
-
| --- | --- | --- |
|
|
449
|
-
| value | <code>object</code> | <p>values to set.</p> |
|
|
450
|
-
|
|
451
|
-
**Example**
|
|
452
|
-
```js
|
|
453
|
-
const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
454
|
-
```
|
|
455
|
-
<a name="module_api.Sdk+editEntry"></a>
|
|
456
|
-
|
|
457
|
-
#### sdk.editEntry(entryID, value) ⇒ [<code>Promise.<EntryResource></code>](#EntryResource)
|
|
458
|
-
<p>Edits an entry. Expects <code>dmShortID</code> / <code>model</code> to be set.
|
|
459
|
-
If model PUT is not public, you also need to provide a <code>token</code>.</p>
|
|
460
|
-
|
|
461
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
462
|
-
|
|
463
|
-
| Param | Type | Description |
|
|
464
|
-
| --- | --- | --- |
|
|
465
|
-
| entryID | <code>string</code> | <p>id of entry to edit</p> |
|
|
466
|
-
| value | <code>object</code> | <p>values to set. undefined fields are ignored</p> |
|
|
467
|
-
|
|
468
|
-
**Example**
|
|
469
|
-
```js
|
|
470
|
-
const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
471
|
-
```
|
|
472
|
-
<a name="module_api.Sdk+deleteEntry"></a>
|
|
473
|
-
|
|
474
|
-
#### sdk.deleteEntry(entryID) ⇒ <code>Promise.<void></code>
|
|
475
|
-
<p>Deletes an entry. Expects <code>dmShortID</code> / <code>model</code> to be set.
|
|
476
|
-
If model DELETE is not public, you also need to provide a <code>token</code>.</p>
|
|
477
|
-
|
|
478
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
479
|
-
|
|
480
|
-
| Param | Type | Description |
|
|
481
|
-
| --- | --- | --- |
|
|
482
|
-
| entryID | <code>string</code> | <p>id of entry to delete</p> |
|
|
483
|
-
|
|
484
|
-
**Example**
|
|
485
|
-
```js
|
|
486
|
-
await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
487
|
-
```
|
|
488
|
-
<a name="module_api.Sdk+resourceList"></a>
|
|
489
|
-
|
|
490
|
-
#### sdk.resourceList([options]) ⇒ [<code>Promise.<ResourceList></code>](#ResourceList)
|
|
491
|
-
<p>Fetches resource list. Expects <code>resource</code> to be set. <code>subdomain</code> defaults to "datamanager".
|
|
492
|
-
Fetches <code>https://<subdomain>.entrecode.de/<resource>?_list=true&size=<options.size ?? 25></code></p>
|
|
493
|
-
|
|
494
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
495
|
-
|
|
496
|
-
| Param | Type | Description |
|
|
497
|
-
| --- | --- | --- |
|
|
498
|
-
| [options] | <code>object</code> | <p>options for list request.</p> |
|
|
499
|
-
|
|
500
|
-
**Example**
|
|
501
|
-
```js
|
|
502
|
-
const res = await sdk("stage").resource("template").resourceList()
|
|
503
|
-
```
|
|
504
|
-
<a name="module_api.Sdk+raw"></a>
|
|
505
|
-
|
|
506
|
-
#### sdk.raw([options], [fetchOptions]) ⇒ <code>Promise.<any></code>
|
|
507
|
-
<p>Fetches raw route. Expects <code>route</code> to be set. <code>subdomain</code> defaults to "datamanager".
|
|
508
|
-
Fetches <code>https://<subdomain>.entrecode.de/<route>?<options></code>
|
|
509
|
-
Use this when no other fdk method can give you your request.</p>
|
|
510
|
-
|
|
511
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
512
|
-
|
|
513
|
-
| Param | Type | Description |
|
|
514
|
-
| --- | --- | --- |
|
|
515
|
-
| [options] | <code>object</code> | <p>options for list request.</p> |
|
|
516
|
-
| [fetchOptions] | <code>object</code> | <p>(optional) options passed to fetch.</p> |
|
|
517
|
-
|
|
518
|
-
**Example**
|
|
519
|
-
```js
|
|
520
|
-
const res = await sdk("stage").route("stats").raw()
|
|
521
|
-
```
|
|
522
|
-
<a name="module_api.Sdk+model"></a>
|
|
523
|
-
|
|
524
|
-
#### sdk.model(model) ⇒
|
|
525
|
-
<p>Sets the given model to use</p>
|
|
526
|
-
|
|
527
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
528
|
-
**Returns**: <p>Sdk</p>
|
|
529
|
-
|
|
530
|
-
| Param | Type | Description |
|
|
531
|
-
| --- | --- | --- |
|
|
532
|
-
| model | <code>string</code> | <p>name of the model</p> |
|
|
533
|
-
|
|
534
|
-
<a name="module_api.Sdk+token"></a>
|
|
535
|
-
|
|
536
|
-
#### sdk.token(token) ⇒
|
|
537
|
-
<p>Sets the token to use in requests</p>
|
|
538
|
-
|
|
539
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
540
|
-
**Returns**: <p>Sdk</p>
|
|
541
|
-
|
|
542
|
-
| Param | Type |
|
|
543
|
-
| --- | --- |
|
|
544
|
-
| token | <code>string</code> |
|
|
545
|
-
|
|
546
|
-
<a name="module_api.Sdk+dmShortID"></a>
|
|
547
|
-
|
|
548
|
-
#### sdk.dmShortID(dmShortID) ⇒
|
|
549
|
-
<p>Sets the short ID of the datamanager to use</p>
|
|
550
|
-
|
|
551
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
552
|
-
**Returns**: <p>Sdk</p>
|
|
553
|
-
|
|
554
|
-
| Param | Type |
|
|
555
|
-
| --- | --- |
|
|
556
|
-
| dmShortID | <code>string</code> |
|
|
557
|
-
|
|
558
|
-
<a name="module_api.Sdk+dmID"></a>
|
|
559
|
-
|
|
560
|
-
#### sdk.dmID(dmID) ⇒
|
|
561
|
-
<p>Sets the (long) ID of the datamanager to use</p>
|
|
562
|
-
|
|
563
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
564
|
-
**Returns**: <p>Sdk</p>
|
|
565
|
-
|
|
566
|
-
| Param | Type |
|
|
567
|
-
| --- | --- |
|
|
568
|
-
| dmID | <code>string</code> |
|
|
569
|
-
|
|
570
|
-
<a name="module_api.Sdk+dm"></a>
|
|
571
|
-
|
|
572
|
-
#### sdk.dm(dmShortID) ⇒
|
|
573
|
-
<p>Sets the short ID of the datamanager to use. Alias for <code>dmShortID</code></p>
|
|
574
|
-
|
|
575
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
576
|
-
**Returns**: <p>Sdk</p>
|
|
577
|
-
|
|
578
|
-
| Param | Type |
|
|
579
|
-
| --- | --- |
|
|
580
|
-
| dmShortID | <code>string</code> |
|
|
581
|
-
|
|
582
|
-
<a name="module_api.Sdk+assetGroup"></a>
|
|
583
|
-
|
|
584
|
-
#### sdk.assetGroup(assetGroup) ⇒
|
|
585
|
-
<p>Sets the name of the asset group to use.</p>
|
|
586
|
-
|
|
587
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
588
|
-
**Returns**: <p>Sdk</p>
|
|
589
|
-
|
|
590
|
-
| Param | Type | Description |
|
|
591
|
-
| --- | --- | --- |
|
|
592
|
-
| assetGroup | <code>string</code> | <p>name of the asset group</p> |
|
|
593
|
-
|
|
594
|
-
<a name="module_api.Sdk+assetgroup"></a>
|
|
595
|
-
|
|
596
|
-
#### sdk.assetgroup(assetGroup) ⇒
|
|
597
|
-
<p>Sets the name of the asset group to use. Alias for <code>assetGroup</code></p>
|
|
598
|
-
|
|
599
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
600
|
-
**Returns**: <p>Sdk</p>
|
|
601
|
-
|
|
602
|
-
| Param | Type | Description |
|
|
603
|
-
| --- | --- | --- |
|
|
604
|
-
| assetGroup | <code>string</code> | <p>name of the asset group</p> |
|
|
605
|
-
|
|
606
|
-
<a name="module_api.Sdk+subdomain"></a>
|
|
607
|
-
|
|
608
|
-
#### sdk.subdomain(subdomain) ⇒
|
|
609
|
-
<p>Sets the subdomain to use.</p>
|
|
610
|
-
|
|
611
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
612
|
-
**Returns**: <p>Sdk</p>
|
|
613
|
-
|
|
614
|
-
| Param | Type | Description |
|
|
615
|
-
| --- | --- | --- |
|
|
616
|
-
| subdomain | <code>string</code> | <p>subdomain</p> |
|
|
617
|
-
|
|
618
|
-
<a name="module_api.Sdk+resource"></a>
|
|
619
|
-
|
|
620
|
-
#### sdk.resource(resource) ⇒
|
|
621
|
-
<p>Sets the name of the resource to use.</p>
|
|
622
|
-
|
|
623
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
624
|
-
**Returns**: <p>Sdk</p>
|
|
625
|
-
|
|
626
|
-
| Param | Type | Description |
|
|
627
|
-
| --- | --- | --- |
|
|
628
|
-
| resource | <code>string</code> | <p>name of the resource</p> |
|
|
629
|
-
|
|
630
|
-
<a name="module_api.Sdk+route"></a>
|
|
631
|
-
|
|
632
|
-
#### sdk.route(route) ⇒
|
|
633
|
-
<p>Sets the route to use.</p>
|
|
634
|
-
|
|
635
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
636
|
-
**Returns**: <p>Sdk</p>
|
|
637
|
-
|
|
638
|
-
| Param | Type | Description |
|
|
639
|
-
| --- | --- | --- |
|
|
640
|
-
| route | <code>string</code> | <p>route</p> |
|
|
641
|
-
|
|
642
|
-
<a name="module_api.Sdk+publicApi"></a>
|
|
643
|
-
|
|
644
|
-
#### sdk.publicApi() ⇒
|
|
645
|
-
<p>Returns the public api root endpoint. Expects dmShortID to be set.</p>
|
|
646
|
-
|
|
647
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
648
|
-
**Returns**: <p>any</p>
|
|
649
|
-
<a name="module_api.Sdk+getDatamanager"></a>
|
|
650
|
-
|
|
651
|
-
#### sdk.getDatamanager() ⇒
|
|
652
|
-
<p>Loads a DatamanagerResource by its long id. Requires token.</p>
|
|
653
|
-
|
|
654
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
655
|
-
**Returns**: <p>any</p>
|
|
656
|
-
<a name="module_api.Sdk+dmList"></a>
|
|
657
|
-
|
|
658
|
-
#### sdk.dmList([options]) ⇒ [<code>Promise.<DatamanagerList></code>](#DatamanagerList)
|
|
659
|
-
<p>Loads datamanager list. Make sure to provide an ec.admin <code>token</code> intercept one.</p>
|
|
660
|
-
|
|
661
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
662
|
-
|
|
663
|
-
| Param | Type | Description |
|
|
664
|
-
| --- | --- | --- |
|
|
665
|
-
| [options] | <code>object</code> | <p>options for entry list request.</p> |
|
|
666
|
-
|
|
667
|
-
**Example**
|
|
668
|
-
```js
|
|
669
|
-
const dms = await sdk("stage").dmList()
|
|
670
|
-
```
|
|
671
|
-
<a name="module_api.Sdk+modelList"></a>
|
|
672
|
-
|
|
673
|
-
#### sdk.modelList([options]) ⇒ [<code>Promise.<ModelList></code>](#ModelList)
|
|
674
|
-
<p>Loads model list. Expects dmID to be set. Make sure to provide an ec.admin <code>token</code> intercept one.</p>
|
|
675
|
-
|
|
676
|
-
**Kind**: instance method of [<code>Sdk</code>](#module_api.Sdk)
|
|
677
|
-
|
|
678
|
-
| Param | Type | Description |
|
|
679
|
-
| --- | --- | --- |
|
|
680
|
-
| [options] | <code>object</code> | <p>options for entry list request.</p> |
|
|
681
|
-
|
|
682
|
-
**Example**
|
|
683
|
-
```js
|
|
684
|
-
const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
685
|
-
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var ft=Object.defineProperty,pt=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var
|
|
1
|
+
"use strict";var ft=Object.defineProperty,pt=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var z=(n,t,e)=>t in n?ft(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,o=(n,t)=>{for(var e in t||(t={}))mt.call(t,e)&&z(n,e,t[e]);if(x)for(var e of x(t))$t.call(t,e)&&z(n,e,t[e]);return n},f=(n,t)=>pt(n,yt(t));var a=(n,t,e)=>new Promise((s,r)=>{var l=c=>{try{d(e.next(c))}catch(u){r(u)}},i=c=>{try{d(e.throw(c))}catch(u){r(u)}},d=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,i);d((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(s){return a(this,arguments,function*(n,t={},e={}){var d;const{token:r,rawRes:l}=t;r&&(e.headers=f(o({},e.headers||{}),{Authorization:`Bearer ${r}`}));const i=yield fetch(n,e);if(!i.ok){if((d=i.headers.get("content-type"))!=null&&d.includes("application/json")){const c=yield i.json(),u=`${c.title}
|
|
2
2
|
${c.detail}
|
|
3
|
-
${c.verbose}`;throw new Error(u)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return l?i:yield i.json()})}const b={datamanager:{live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"},accounts:{live:"https://accounts.entrecode.de/",stage:"https://accounts.cachena.entrecode.de/"},appserver:{live:"https://appserver.entrecode.de/",stage:"https://appserver.cachena.entrecode.de/"},"dm-history":{live:"https://dm-history.entrecode.de/",stage:"https://dm-history.cachena.entrecode.de/"}};function y(n,t="stage",e="datamanager"){const s=b[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(b).join(", ")}`);const r=s[t];if(!r)throw new Error(`env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`);return r+n}function E(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function h(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const N={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function F(n){return a(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;h({env:t,dmShortID:e,email:s,password:r});const l=y(`api/${e}/_auth/login?clientID=rest`,t);return yield p(l,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function I(n){return a(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const r=`${N[t]}auth/login?clientID=rest`;return yield p(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function J(n){return a(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield p(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function R(n){return a(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${N[t]}auth/logout?clientID=rest`;return yield p(s,{rawRes:!0,token:e},{method:"POST"})})}function U({dmShortID:n}){return h({dmShortID:n}),n}function M({env:n}){return h({env:n}),n}let Et=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function V(n){let t={};for(let e in n)Et.includes(e)||(t[e]=n[e]);return t}function wt(n){return JSON.parse(JSON.stringify(n))}function G(n){return a(this,null,function*(){let{env:t,dmShortID:e}=n;h({env:t,dmShortID:e});const s=y(`api/${e}`,t);return p(s,n)})}function P(n){return a(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;h({env:t,dmShortID:e,model:s}),r=o({size:50,page:1,_list:!0},r);const l=E(r),i=y(`api/${e}/${s}?${l}`,t),{count:d,total:c,_embedded:u}=yield p(i,n);let g=u?u[`${e}:${s}`]:[];return g=Array.isArray(g)?g:[g],{count:d,total:c,items:g}})}function H({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const l=E({_id:s}),i=y(`api/${t}/${e}?${l}`,n);return p(i,{dmShortID:t,token:r})}function Q(l){return a(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){h({env:n,dmShortID:t,model:e,value:s});const i=y(`api/${t}/${e}`,n);return yield p(i,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function S(d){return a(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:l,safePut:i=!1}){h({env:n,dmShortID:t,model:e,entryID:s,value:r});const c={"Content-Type":"application/json"};if(i){if(!("_modified"in r))throw new Error("expected _modified to be set!");c["If-Unmodified-Since"]=new Date(r._modified).toUTCString()}const u=y(`api/${t}/${e}?_id=${s}`,n);return r=wt(r),r=V(r),yield p(u,{token:l},{method:"PUT",headers:c,body:JSON.stringify(r)})})}function L({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const l=y(`api/${t}/${e}?_id=${s}`,n);return p(l,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})}function W(n,t){return a(this,null,function*(){let{env:e,dmShortID:s,model:r,options:l={}}=n;h({env:e,dmShortID:s,model:r}),n.options=o({size:50,page:1,_list:!0},l);let i=0,d,c=[];for(;d===void 0||i<d;){const u=yield P(n);for(let g of u.items)c.push(yield t(g));i+=u.items.length,d=u.total,n.options.page++}return c})}function X(r){return a(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var g,$,v,q,x;h({env:n,dmShortID:t,model:e});const l=y(`api/schema/${t}/${e}`,n),i=yield p(l),d=(g=i==null?void 0:i.allOf)==null?void 0:g[1];if(typeof d.properties!="object")throw new Error(`getSchema: ${l} returned unexpected format: ${JSON.stringify(i)}`);const{properties:c}=d,u=V(c);for(let w in u){let m=u[w];if(m.required=d.required.includes(w),($=u[w])!=null&&$.oneOf&&((v=u[w])==null||delete v.oneOf),(q=m.title)!=null&&q.includes("<")&&((x=m.title)!=null&&x.includes(">"))){const _=m.title.split("<")[1].slice(0,-1),gt=m.title.split("<")[0];m.type=gt,_.includes(":")?m.resource=_.split(":")[1]:m.resource=_}else["asset","entry","assets","entries"].includes(m.title)?(m.type=m.title,m.resource=null):m.type=m.title;delete u[w].title}if(s){const w=c._modelTitle.title,m=c._modelTitleField.title;return{properties:u,meta:{modelTitleField:m,modelTitle:w}}}return u})}function B(n){return Object.entries(n).map(([t,e])=>typeof e!="object"?{[t]:String(e)}:o(o(o(o(o(o(o({},e.sort&&{sort:Array.isArray(e)?e.join(","):e}),e.search&&{[t+"~"]:e.search}),e.notNull&&{[t+"!"]:""}),e.null&&{[t]:""}),e.any&&{[t]:e.any.join(",")}),e.from&&{[t+"From"]:e.from}),e.to&&{[t+"To"]:e.to})).reduce((t,e)=>o(o({},t),e),{})}const Y=B;function A(n){return n._links.collection.href.split("/").slice(-2)[0]}function D(n){const t=n._links.collection.href.split("api/")[0];return Object.keys(b.datamanager).find(s=>b.datamanager[s]===t)}const Z=n=>{const t=A(n),e=D(n),s=n._modelTitle,r=n.id;return{dmShortID:t,env:e,model:s,entryID:r}},tt=n=>L(Z(n)),et=(n,t)=>S(f(o({},Z(n)),{value:t}));function nt(n,t){const e=A(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function st(l){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=E({assetID:s}),d=y(`a/${t}/${e}?${i}`,n);return(yield p(d,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function rt(n){return a(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:l={}}=n;h({env:t,dmShortID:e,assetGroup:s}),l=o({size:50,page:1,_list:!0},l);const i=E(l),d=y(`a/${e}/${s}?${i}`,t),{count:c,total:u,_embedded:g}=yield p(d,{dmShortID:e,token:r});let $=g?g["ec:dm-asset"]:[];return $=Array.isArray($)?$:[$],{count:c,total:u,items:$}})}function it(d){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:l,options:i}){h({env:n,dmShortID:t,assetGroup:e,file:r});const c=y(`a/${t}/${e}`,n),u=new FormData;return u.append("file",r,l),i&&Object.keys(i).forEach($=>{u.append($,i[$])}),(yield p(c,{token:s},{method:"POST",body:u}))._embedded["ec:dm-asset"]})}function ot(l){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=y(`a/${t}/${e}/${s}`,n);yield p(i,{token:r,rawRes:!0},{method:"DELETE"})})}function ct(n){return a(this,null,function*(){let{env:t,dmID:e,token:s}=n;h({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return p(r,{token:s})})}function at(n){return a(this,null,function*(){let{env:t,options:e={}}=n;h({env:t}),e=o({size:25,page:1,_list:!0},e);const s=E(e),r=y(`?${s}`,t),{count:l,total:i,_embedded:d}=yield p(r,n);let c=d?d["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:l,total:i,items:c}})}function ut(n){return a(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;h({env:t,dmID:e}),s=o({size:25,dataManagerID:e,page:1,_list:!0},s);const r=E(s),l=y(`model?${r}`,t),{count:i,total:d,_embedded:c}=yield p(l,n);let u=c?c["ec:model"]:[];return u=Array.isArray(u)?u:[u],{count:i,total:d,items:u}})}function lt(n){return a(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;h({env:t,subdomain:r,resource:e}),s=o({size:25,page:1,_list:!0},s);const l=E(s),i=y(`${e}?${l}`,t,r),{count:d,total:c,_embedded:u}=yield p(i,n);let g=u?u[Object.keys(u)[0]]:[];return g=Array.isArray(g)?g:[g],{count:d,total:c,items:g}})}function dt(e){return a(this,arguments,function*(n,t={}){let{env:s,route:r,options:l={},subdomain:i="datamanager"}=n;h({env:s,subdomain:i,route:r}),l=o({},l);const d=E(l),c=y(`${r}?${d}`,s,i);return p(c,n,t)})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:rt,createAsset:it,createEntry:Q,deleteAsset:ot,deleteEntry:L,deleteEntryObject:tt,dmList:at,editEntry:S,editEntryObject:et,entryList:P,filterOptions:Y,getAsset:st,getDatamanager:ct,getEcAuthKey:M,getEntry:H,getEntryAsset:nt,getEntryEnv:D,getEntryShortID:A,getPublicAuthKey:U,getSchema:X,loginEc:I,loginPublic:F,logoutEc:R,logoutPublic:J,mapEntries:W,modelList:ut,publicApi:G,raw:dt,resourceList:lt,sdkOptions:B},Symbol.toStringTag,{value:"Module"})),{entryList:bt,mapEntries:kt,getEntry:At,getAsset:Tt,assetList:_t,createAsset:Ot,deleteAsset:jt,createEntry:Pt,editEntry:K,deleteEntry:St,getSchema:Lt,loginPublic:Bt,loginEc:Dt,logoutEc:vt,logoutPublic:qt,getEcAuthKey:O,getPublicAuthKey:j,dmList:xt,modelList:zt,publicApi:Ct,getDatamanager:Kt,resourceList:Nt,raw:Ft}=k;function It(n){const{action:t}=n;if(h({action:t}),!k[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(k).join(", ")}`);return k[t](n)}class T{constructor(t){this.config=t}set(t){return new T(o(o({},this.config),t))}entries(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return bt(f(o({},this.config),{options:t,token:e}))})}entryList(t){return a(this,null,function*(){return this.entries(t)})}mapEntries(s){return a(this,arguments,function*(t,e={}){const r=yield this.getBestToken();return kt(f(o({},this.config),{options:e,token:r}),t)})}getEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return At(f(o({},this.config),{entryID:t,token:e}))})}editEntrySafe(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return K(f(o({},this.config),{entryID:t,token:s,value:e,safePut:!0}))})}getSchema(){return a(this,null,function*(){return Lt(this.config)})}assets(t){return a(this,null,function*(){const e=yield this.getBestToken();return _t(f(o({},this.config),{options:t,token:e}))})}assetList(t){return a(this,null,function*(){return this.assets(t)})}createAsset(){return a(this,arguments,function*({file:t,name:e,options:s}={}){const r=yield this.getBestToken();return Ot(f(o({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return jt(f(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return Tt(f(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return Pt(f(o({},this.config),{token:e,value:t}))})}editEntry(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return K(f(o({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return St(f(o({},this.config),{token:e,entryID:t}))})}resourceList(t){return a(this,null,function*(){const e=yield this.getBestToken();return Nt(f(o({},this.config),{options:t,token:e}))})}raw(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return Ft(f(o({},this.config),{options:t,token:s}),e)})}storageAdapter(t){return this.set({storageAdapter:t})}setAuth(t){return e=>{if(!this.config.storageAdapter)throw new Error("cannot setAuth: no storageAdapter defined!");const{set:s}=this.config.storageAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(!this.config.storageAdapter)throw new Error("cannot unsetAuth: no storageAdapter defined!");const{remove:s}=this.config.storageAdapter;return s(t),e}}getAuth(t){if(!this.config.storageAdapter)throw new Error("cannot getAuth: no storageAdapter defined!");const{get:e}=this.config.storageAdapter;return e(t)}loginEc(t){return Dt(o(o({},this.config),t)).then(this.setAuth(O(this.config)))}loginPublic(t){return Bt(o(o({},this.config),t)).then(this.setAuth(j(this.config)))}logoutPublic(){const t=this.getPublicToken();return qt(f(o({},this.config),{token:t})).then(this.unsetAuth(j(this.config)))}logoutEc(){const t=this.getEcToken();return vt(f(o({},this.config),{token:t})).then(this.unsetAuth(O(this.config)))}getPublicToken(){return this.config.token||this.getAuth(j(this.config))}getEcToken(){return this.config.token||this.getAuth(O(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})}dmID(t){return this.set({dmID:t})}dm(t){return this.dmShortID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}subdomain(t){return this.set({subdomain:t})}resource(t){return this.set({resource:t})}route(t){return this.set({route:t})}publicApi(){return Ct(this.config)}getDatamanager(t){return a(this,null,function*(){const e=yield this.getBestToken();return Kt(f(o({},this.config),{dmID:t,token:e}))})}dmList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return xt(f(o({},this.config),{options:t,token:e}))})}modelList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return zt(f(o({},this.config),{options:t,token:e}))})}}const ht=n=>new T({env:n}),Jt=ht;exports.Sdk=T;exports.act=It;exports.apiURL=y;exports.apis=b;exports.assetList=rt;exports.createAsset=it;exports.createEntry=Q;exports.deleteAsset=ot;exports.deleteEntry=L;exports.deleteEntryObject=tt;exports.dmList=at;exports.editEntry=S;exports.editEntryObject=et;exports.entryList=P;exports.expect=h;exports.fdk=Jt;exports.fetcher=p;exports.filterOptions=Y;exports.getAsset=st;exports.getDatamanager=ct;exports.getEcAuthKey=M;exports.getEntry=H;exports.getEntryAsset=nt;exports.getEntryEnv=D;exports.getEntryShortID=A;exports.getPublicAuthKey=U;exports.getSchema=X;exports.loginEc=I;exports.loginPublic=F;exports.logoutEc=R;exports.logoutPublic=J;exports.mapEntries=W;exports.modelList=ut;exports.publicApi=G;exports.query=E;exports.raw=dt;exports.resourceList=lt;exports.sdk=ht;exports.sdkOptions=B;
|
|
3
|
+
${c.verbose}`;throw new Error(u)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return l?i:yield i.json()})}const b={datamanager:{live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"},accounts:{live:"https://accounts.entrecode.de/",stage:"https://accounts.cachena.entrecode.de/"},appserver:{live:"https://appserver.entrecode.de/",stage:"https://appserver.cachena.entrecode.de/"},"dm-history":{live:"https://dm-history.entrecode.de/",stage:"https://dm-history.cachena.entrecode.de/"}};function y(n,t="stage",e="datamanager"){const s=b[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(b).join(", ")}`);const r=s[t];if(!r)throw new Error(`env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`);return r+n}function E(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function h(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const K={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function N(n){return a(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;h({env:t,dmShortID:e,email:s,password:r});const l=y(`api/${e}/_auth/login?clientID=rest`,t);return yield p(l,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function F(n){return a(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const r=`${K[t]}auth/login?clientID=rest`;return yield p(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function J(n){return a(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield p(r,{rawRes:!0},{method:"POST"})})}function R(n){return a(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${K[t]}auth/logout?clientID=rest`;return yield p(s,{rawRes:!0,token:e},{method:"POST"})})}function U({dmShortID:n}){return h({dmShortID:n}),n}function M({env:n}){return h({env:n}),n}let Et=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function V(n){let t={};for(let e in n)Et.includes(e)||(t[e]=n[e]);return t}function wt(n){return JSON.parse(JSON.stringify(n))}function G(n){return a(this,null,function*(){let{env:t,dmShortID:e}=n;h({env:t,dmShortID:e});const s=y(`api/${e}`,t);return p(s,n)})}function S(n){return a(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;h({env:t,dmShortID:e,model:s}),r=o({size:50,page:1,_list:!0},r);const l=E(r),i=y(`api/${e}/${s}?${l}`,t),{count:d,total:c,_embedded:u}=yield p(i,n);let g=u?u[`${e}:${s}`]:[];return g=Array.isArray(g)?g:[g],{count:d,total:c,items:g}})}function H({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const l=E({_id:s}),i=y(`api/${t}/${e}?${l}`,n);return p(i,{token:r})}function Q(l){return a(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){h({env:n,dmShortID:t,model:e,value:s});const i=y(`api/${t}/${e}`,n);return yield p(i,{token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function P(d){return a(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:l,safePut:i=!1}){h({env:n,dmShortID:t,model:e,entryID:s,value:r});const c={"Content-Type":"application/json"};if(i){if(!("_modified"in r))throw new Error("expected _modified to be set!");c["If-Unmodified-Since"]=new Date(r._modified).toUTCString()}const u=y(`api/${t}/${e}?_id=${s}`,n);return r=wt(r),r=V(r),yield p(u,{token:l},{method:"PUT",headers:c,body:JSON.stringify(r)})})}function L({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const l=y(`api/${t}/${e}?_id=${s}`,n);return p(l,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})}function W(n,t){return a(this,null,function*(){let{env:e,dmShortID:s,model:r,options:l={}}=n;h({env:e,dmShortID:s,model:r}),n.options=o({size:50,page:1,_list:!0},l);let i=0,d,c=[];for(;d===void 0||i<d;){const u=yield S(n);for(let g of u.items)c.push(yield t(g));i+=u.items.length,d=u.total,n.options.page++}return c})}function X(r){return a(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var g,$,v,q,I;h({env:n,dmShortID:t,model:e});const l=y(`api/schema/${t}/${e}`,n),i=yield p(l),d=(g=i==null?void 0:i.allOf)==null?void 0:g[1];if(typeof d.properties!="object")throw new Error(`getSchema: ${l} returned unexpected format: ${JSON.stringify(i)}`);const{properties:c}=d,u=V(c);for(let w in u){let m=u[w];if(m.required=d.required.includes(w),($=u[w])!=null&&$.oneOf&&((v=u[w])==null||delete v.oneOf),(q=m.title)!=null&&q.includes("<")&&((I=m.title)!=null&&I.includes(">"))){const _=m.title.split("<")[1].slice(0,-1),gt=m.title.split("<")[0];m.type=gt,_.includes(":")?m.resource=_.split(":")[1]:m.resource=_}else["asset","entry","assets","entries"].includes(m.title)?(m.type=m.title,m.resource=null):m.type=m.title;delete u[w].title}if(s){const w=c._modelTitle.title,m=c._modelTitleField.title;return{properties:u,meta:{modelTitleField:m,modelTitle:w}}}return u})}function B(n){return Object.entries(n).map(([t,e])=>typeof e!="object"?{[t]:String(e)}:o(o(o(o(o(o(o({},e.sort&&{sort:Array.isArray(e)?e.join(","):e}),e.search&&{[t+"~"]:e.search}),e.notNull&&{[t+"!"]:""}),e.null&&{[t]:""}),e.any&&{[t]:e.any.join(",")}),e.from&&{[t+"From"]:e.from}),e.to&&{[t+"To"]:e.to})).reduce((t,e)=>o(o({},t),e),{})}const Y=B;function A(n){return n._links.collection.href.split("/").slice(-2)[0]}function D(n){const t=n._links.collection.href.split("api/")[0];return Object.keys(b.datamanager).find(s=>b.datamanager[s]===t)}const Z=n=>{const t=A(n),e=D(n),s=n._modelTitle,r=n.id;return{dmShortID:t,env:e,model:s,entryID:r}},tt=n=>L(Z(n)),et=(n,t)=>P(f(o({},Z(n)),{value:t}));function nt(n,t){const e=A(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function st(l){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=E({assetID:s}),d=y(`a/${t}/${e}?${i}`,n);return(yield p(d,{token:r}))._embedded["ec:dm-asset"]})}function rt(n){return a(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:l={}}=n;h({env:t,dmShortID:e,assetGroup:s}),l=o({size:50,page:1,_list:!0},l);const i=E(l),d=y(`a/${e}/${s}?${i}`,t),{count:c,total:u,_embedded:g}=yield p(d,{token:r});let $=g?g["ec:dm-asset"]:[];return $=Array.isArray($)?$:[$],{count:c,total:u,items:$}})}function it(d){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:l,options:i}){h({env:n,dmShortID:t,assetGroup:e,file:r});const c=y(`a/${t}/${e}`,n),u=new FormData;return u.append("file",r,l),i&&Object.keys(i).forEach($=>{u.append($,i[$])}),(yield p(c,{token:s},{method:"POST",body:u}))._embedded["ec:dm-asset"]})}function ot(l){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){h({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=y(`a/${t}/${e}/${s}`,n);yield p(i,{token:r,rawRes:!0},{method:"DELETE"})})}function ct(n){return a(this,null,function*(){let{env:t,dmID:e,token:s}=n;h({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return p(r,{token:s})})}function at(n){return a(this,null,function*(){let{env:t,options:e={}}=n;h({env:t}),e=o({size:25,page:1,_list:!0},e);const s=E(e),r=y(`?${s}`,t),{count:l,total:i,_embedded:d}=yield p(r,n);let c=d?d["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:l,total:i,items:c}})}function ut(n){return a(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;h({env:t,dmID:e}),s=o({size:25,dataManagerID:e,page:1,_list:!0},s);const r=E(s),l=y(`model?${r}`,t),{count:i,total:d,_embedded:c}=yield p(l,n);let u=c?c["ec:model"]:[];return u=Array.isArray(u)?u:[u],{count:i,total:d,items:u}})}function lt(n){return a(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;h({env:t,subdomain:r,resource:e}),s=o({size:25,page:1,_list:!0},s);const l=E(s),i=y(`${e}?${l}`,t,r),{count:d,total:c,_embedded:u}=yield p(i,n);let g=u?u[Object.keys(u)[0]]:[];return g=Array.isArray(g)?g:[g],{count:d,total:c,items:g}})}function dt(e){return a(this,arguments,function*(n,t={}){let{env:s,route:r,options:l={},subdomain:i="datamanager"}=n;h({env:s,subdomain:i,route:r}),l=o({},l);const d=E(l),c=y(`${r}?${d}`,s,i);return p(c,n,t)})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:rt,createAsset:it,createEntry:Q,deleteAsset:ot,deleteEntry:L,deleteEntryObject:tt,dmList:at,editEntry:P,editEntryObject:et,entryList:S,filterOptions:Y,getAsset:st,getDatamanager:ct,getEcAuthKey:M,getEntry:H,getEntryAsset:nt,getEntryEnv:D,getEntryShortID:A,getPublicAuthKey:U,getSchema:X,loginEc:F,loginPublic:N,logoutEc:R,logoutPublic:J,mapEntries:W,modelList:ut,publicApi:G,raw:dt,resourceList:lt,sdkOptions:B},Symbol.toStringTag,{value:"Module"})),{entryList:bt,mapEntries:kt,getEntry:At,getAsset:Tt,assetList:_t,createAsset:Ot,deleteAsset:jt,createEntry:St,editEntry:C,deleteEntry:Pt,getSchema:Lt,loginPublic:Bt,loginEc:Dt,logoutEc:vt,logoutPublic:qt,getEcAuthKey:O,getPublicAuthKey:j,dmList:It,modelList:xt,publicApi:zt,getDatamanager:Ct,resourceList:Kt,raw:Nt}=k;function Ft(n){const{action:t}=n;if(h({action:t}),!k[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(k).join(", ")}`);return k[t](n)}class T{constructor(t){this.config=t}set(t){return new T(o(o({},this.config),t))}entries(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return bt(f(o({},this.config),{options:t,token:e}))})}entryList(t){return a(this,null,function*(){return this.entries(t)})}mapEntries(s){return a(this,arguments,function*(t,e={}){const r=yield this.getBestToken();return kt(f(o({},this.config),{options:e,token:r}),t)})}getEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return At(f(o({},this.config),{entryID:t,token:e}))})}editEntrySafe(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return C(f(o({},this.config),{entryID:t,token:s,value:e,safePut:!0}))})}getSchema(){return a(this,null,function*(){return Lt(this.config)})}assets(t){return a(this,null,function*(){const e=yield this.getBestToken();return _t(f(o({},this.config),{options:t,token:e}))})}assetList(t){return a(this,null,function*(){return this.assets(t)})}createAsset(){return a(this,arguments,function*({file:t,name:e,options:s}={}){const r=yield this.getBestToken();return Ot(f(o({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return jt(f(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return Tt(f(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return St(f(o({},this.config),{token:e,value:t}))})}editEntry(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return C(f(o({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return Pt(f(o({},this.config),{token:e,entryID:t}))})}resourceList(t){return a(this,null,function*(){const e=yield this.getBestToken();return Kt(f(o({},this.config),{options:t,token:e}))})}raw(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return Nt(f(o({},this.config),{options:t,token:s}),e)})}storageAdapter(t){return this.set({storageAdapter:t})}setAuth(t){return e=>{if(!this.config.storageAdapter)throw new Error("cannot setAuth: no storageAdapter defined!");const{set:s}=this.config.storageAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(!this.config.storageAdapter)throw new Error("cannot unsetAuth: no storageAdapter defined!");const{remove:s}=this.config.storageAdapter;return s(t),e}}getAuth(t){if(!this.config.storageAdapter)throw new Error("cannot getAuth: no storageAdapter defined!");const{get:e}=this.config.storageAdapter;return e(t)}loginEc(t){return Dt(o(o({},this.config),t)).then(this.setAuth(O(this.config)))}loginPublic(t){return Bt(o(o({},this.config),t)).then(this.setAuth(j(this.config)))}logoutPublic(){const t=this.getPublicToken();return qt(f(o({},this.config),{token:t})).then(this.unsetAuth(j(this.config)))}logoutEc(){const t=this.getEcToken();return vt(f(o({},this.config),{token:t})).then(this.unsetAuth(O(this.config)))}getPublicToken(){return this.config.token||this.getAuth(j(this.config))}getEcToken(){return this.config.token||this.getAuth(O(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})}dmID(t){return this.set({dmID:t})}dm(t){return this.dmShortID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}subdomain(t){return this.set({subdomain:t})}resource(t){return this.set({resource:t})}route(t){return this.set({route:t})}publicApi(){return zt(this.config)}getDatamanager(t){return a(this,null,function*(){const e=yield this.getBestToken();return Ct(f(o({},this.config),{dmID:t,token:e}))})}dmList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return It(f(o({},this.config),{options:t,token:e}))})}modelList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return xt(f(o({},this.config),{options:t,token:e}))})}}const ht=n=>new T({env:n}),Jt=ht;exports.Sdk=T;exports.act=Ft;exports.apiURL=y;exports.apis=b;exports.assetList=rt;exports.createAsset=it;exports.createEntry=Q;exports.deleteAsset=ot;exports.deleteEntry=L;exports.deleteEntryObject=tt;exports.dmList=at;exports.editEntry=P;exports.editEntryObject=et;exports.entryList=S;exports.expect=h;exports.fdk=Jt;exports.fetcher=p;exports.filterOptions=Y;exports.getAsset=st;exports.getDatamanager=ct;exports.getEcAuthKey=M;exports.getEntry=H;exports.getEntryAsset=nt;exports.getEntryEnv=D;exports.getEntryShortID=A;exports.getPublicAuthKey=U;exports.getSchema=X;exports.loginEc=F;exports.loginPublic=N;exports.logoutEc=R;exports.logoutPublic=J;exports.mapEntries=W;exports.modelList=ut;exports.publicApi=G;exports.query=E;exports.raw=dt;exports.resourceList=lt;exports.sdk=ht;exports.sdkOptions=B;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|