ec.fdk 0.4.4 → 0.4.5
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 +106 -1
- package/README.md +106 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +215 -193
- package/dist/lib/entries.d.mts +39 -2
- package/dist/lib/entries.d.mts.map +1 -1
- package/dist/lib/util.d.mts +18 -0
- package/package.json +1 -1
package/README.hbs
CHANGED
|
@@ -17,7 +17,7 @@ npm i ec.fdk
|
|
|
17
17
|
3. commit + push
|
|
18
18
|
4. run `pnpm publish`
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
## API
|
|
21
21
|
|
|
22
22
|
Start by calling `sdk` with your environment (`stage` | `live`), then method chain your way to success:
|
|
23
23
|
|
|
@@ -50,8 +50,113 @@ await muffin.createEntry({ name: "new muffin" });
|
|
|
50
50
|
await muffin.editEntrySafe(items[2].id, { _modified: items[2]._modified, name: "safePut!" });
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
|
|
54
|
+
## migration from ec.sdk
|
|
55
|
+
|
|
56
|
+
ec.fdk won't change / decorate data returned from ec APIs. For example, an entry returned from the datamanager will be returned as is.
|
|
57
|
+
Advantages:
|
|
58
|
+
|
|
59
|
+
- The network tab shows what goes into the frontend
|
|
60
|
+
- Resources have the same shape everywhere
|
|
61
|
+
- Resources are serializable
|
|
62
|
+
|
|
63
|
+
### Entry save
|
|
64
|
+
|
|
65
|
+
Instead of mutating an EntryResource and calling `.save()`, we now pass the new `value` directly:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
// this does not exist anymore:
|
|
69
|
+
await entry.save(); // <- DONT
|
|
70
|
+
// use this to update an entry:
|
|
71
|
+
await editEntryObject(entry, value); // <- DO
|
|
72
|
+
// alternatively:
|
|
73
|
+
await fdk.env(env).dm(dmShortID).model(model).updateEntry(entryID, value);
|
|
74
|
+
// or:
|
|
75
|
+
await editEntry({ env, dmShortID, model, entryID, value });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Entry delete
|
|
79
|
+
|
|
80
|
+
Similar to save:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
// this does not exist anymore:
|
|
84
|
+
await entry.del(); // <- DONT
|
|
85
|
+
// use this to delete an entry:
|
|
86
|
+
await deleteEntryObject(entry); // <- DO
|
|
87
|
+
// alternatively:
|
|
88
|
+
await fdk.dm("shortID").model("model").deleteEntry("entryID");
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Entry Asset Fields
|
|
92
|
+
|
|
93
|
+
In ec.fdk, entry asset fields are plain ids:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
// assuming "photo" is an asset field:
|
|
97
|
+
entry.photo; // <-- this used to be an AssetResource. Now it's a plain id string.
|
|
98
|
+
// use this to get the embedded AssetResource:
|
|
99
|
+
getEntryAsset("photo", entry); // (no request goes out)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Entry Date Fields
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
// assuming "lastSeen" is a datetime field:
|
|
106
|
+
entry.lastSeen; // <-- this used to be an instance of Date. Now it's a date ISO string
|
|
107
|
+
// use this to get a Date instance:
|
|
108
|
+
new Date(entry.lastSeen);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Entry List
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// ec.sdk
|
|
115
|
+
const api = new PublicAPI(shortID, env, true);
|
|
116
|
+
const entryList = await api.entryList(model);
|
|
117
|
+
const items = entryList.getAllItems();
|
|
118
|
+
const first = entryList.getFirstItem();
|
|
119
|
+
// ec.fdk
|
|
120
|
+
const api = sdk(env).dm(shortID);
|
|
121
|
+
const entryList = await api.entryList(model);
|
|
122
|
+
const items = entryList.items; // <------- change
|
|
123
|
+
const first = entryList.items[0]; // <------- change
|
|
124
|
+
// or in one line:
|
|
125
|
+
const entryList = await sdk(env).dm(shortID).entryList(model);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Entry List Filter Options
|
|
129
|
+
|
|
130
|
+
By default, the second param of ec.fdk `entryList` will just convert the object to url params:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const entryList = await sdk("stage")
|
|
134
|
+
.dm("83cc6374")
|
|
135
|
+
.entryList({ createdTo: "2021-01-18T09:13:47.605Z" });
|
|
136
|
+
/*
|
|
137
|
+
https://datamanager.cachena.entrecode.de/api/83cc6374/muffin?
|
|
138
|
+
_list=true&
|
|
139
|
+
createdTo=2021-01-18T09:13:47.605Z&
|
|
140
|
+
page=1&
|
|
141
|
+
size=50
|
|
142
|
+
*/
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Read more in the [entrecode filtering doc](https://doc.entrecode.de/api-basics/#filtering)
|
|
146
|
+
|
|
147
|
+
There is some syntax sugar you can use to get the same behavior as [ec.sdk filterOptions](https://entrecode.github.io/ec.sdk/#filteroptions):
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const entryList = await sdk("stage")
|
|
151
|
+
.dm("83cc6374")
|
|
152
|
+
.entryList(filterOptions({ created: { to: "2021-01-18T09:13:47.605Z" } }));
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
|
|
53
156
|
Now what follows is the autogenerated doc from source:
|
|
54
157
|
|
|
158
|
+
## API Reference
|
|
159
|
+
|
|
55
160
|
{{#module name="api"}}
|
|
56
161
|
{{>members}}
|
|
57
162
|
{{/module}}
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ npm i ec.fdk
|
|
|
17
17
|
3. commit + push
|
|
18
18
|
4. run `pnpm publish`
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
## API
|
|
21
21
|
|
|
22
22
|
Start by calling `sdk` with your environment (`stage` | `live`), then method chain your way to success:
|
|
23
23
|
|
|
@@ -50,8 +50,113 @@ await muffin.createEntry({ name: "new muffin" });
|
|
|
50
50
|
await muffin.editEntrySafe(items[2].id, { _modified: items[2]._modified, name: "safePut!" });
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
|
|
54
|
+
## migration from ec.sdk
|
|
55
|
+
|
|
56
|
+
ec.fdk won't change / decorate data returned from ec APIs. For example, an entry returned from the datamanager will be returned as is.
|
|
57
|
+
Advantages:
|
|
58
|
+
|
|
59
|
+
- The network tab shows what goes into the frontend
|
|
60
|
+
- Resources have the same shape everywhere
|
|
61
|
+
- Resources are serializable
|
|
62
|
+
|
|
63
|
+
### Entry save
|
|
64
|
+
|
|
65
|
+
Instead of mutating an EntryResource and calling `.save()`, we now pass the new `value` directly:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
// this does not exist anymore:
|
|
69
|
+
await entry.save(); // <- DONT
|
|
70
|
+
// use this to update an entry:
|
|
71
|
+
await editEntryObject(entry, value); // <- DO
|
|
72
|
+
// alternatively:
|
|
73
|
+
await fdk.env(env).dm(dmShortID).model(model).updateEntry(entryID, value);
|
|
74
|
+
// or:
|
|
75
|
+
await editEntry({ env, dmShortID, model, entryID, value });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Entry delete
|
|
79
|
+
|
|
80
|
+
Similar to save:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
// this does not exist anymore:
|
|
84
|
+
await entry.del(); // <- DONT
|
|
85
|
+
// use this to delete an entry:
|
|
86
|
+
await deleteEntryObject(entry); // <- DO
|
|
87
|
+
// alternatively:
|
|
88
|
+
await fdk.dm("shortID").model("model").deleteEntry("entryID");
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Entry Asset Fields
|
|
92
|
+
|
|
93
|
+
In ec.fdk, entry asset fields are plain ids:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
// assuming "photo" is an asset field:
|
|
97
|
+
entry.photo; // <-- this used to be an AssetResource. Now it's a plain id string.
|
|
98
|
+
// use this to get the embedded AssetResource:
|
|
99
|
+
getEntryAsset("photo", entry); // (no request goes out)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Entry Date Fields
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
// assuming "lastSeen" is a datetime field:
|
|
106
|
+
entry.lastSeen; // <-- this used to be an instance of Date. Now it's a date ISO string
|
|
107
|
+
// use this to get a Date instance:
|
|
108
|
+
new Date(entry.lastSeen);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Entry List
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// ec.sdk
|
|
115
|
+
const api = new PublicAPI(shortID, env, true);
|
|
116
|
+
const entryList = await api.entryList(model);
|
|
117
|
+
const items = entryList.getAllItems();
|
|
118
|
+
const first = entryList.getFirstItem();
|
|
119
|
+
// ec.fdk
|
|
120
|
+
const api = sdk(env).dm(shortID);
|
|
121
|
+
const entryList = await api.entryList(model);
|
|
122
|
+
const items = entryList.items; // <------- change
|
|
123
|
+
const first = entryList.items[0]; // <------- change
|
|
124
|
+
// or in one line:
|
|
125
|
+
const entryList = await sdk(env).dm(shortID).entryList(model);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Entry List Filter Options
|
|
129
|
+
|
|
130
|
+
By default, the second param of ec.fdk `entryList` will just convert the object to url params:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const entryList = await sdk("stage")
|
|
134
|
+
.dm("83cc6374")
|
|
135
|
+
.entryList({ createdTo: "2021-01-18T09:13:47.605Z" });
|
|
136
|
+
/*
|
|
137
|
+
https://datamanager.cachena.entrecode.de/api/83cc6374/muffin?
|
|
138
|
+
_list=true&
|
|
139
|
+
createdTo=2021-01-18T09:13:47.605Z&
|
|
140
|
+
page=1&
|
|
141
|
+
size=50
|
|
142
|
+
*/
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Read more in the [entrecode filtering doc](https://doc.entrecode.de/api-basics/#filtering)
|
|
146
|
+
|
|
147
|
+
There is some syntax sugar you can use to get the same behavior as [ec.sdk filterOptions](https://entrecode.github.io/ec.sdk/#filteroptions):
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const entryList = await sdk("stage")
|
|
151
|
+
.dm("83cc6374")
|
|
152
|
+
.entryList(filterOptions({ created: { to: "2021-01-18T09:13:47.605Z" } }));
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
|
|
53
156
|
Now what follows is the autogenerated doc from source:
|
|
54
157
|
|
|
158
|
+
## API Reference
|
|
159
|
+
|
|
55
160
|
<a name="module_api.Sdk"></a>
|
|
56
161
|
|
|
57
162
|
### api.Sdk
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ht=Object.defineProperty,gt=Object.defineProperties;var ft=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var C=(n,t,e)=>t in n?ht(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,o=(n,t)=>{for(var e in t||(t={}))yt.call(t,e)&&C(n,e,t[e]);if(x)for(var e of x(t))pt.call(t,e)&&C(n,e,t[e]);return n},f=(n,t)=>gt(n,ft(t));var a=(n,t,e)=>new Promise((s,r)=>{var u=c=>{try{d(e.next(c))}catch(l){r(l)}},i=c=>{try{d(e.throw(c))}catch(l){r(l)}},d=c=>c.done?s(c.value):Promise.resolve(c.value).then(u,i);d((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return a(this,arguments,function*(n,t={},e={}){var d;const{token:r,rawRes:u}=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(),l=`${c.title}
|
|
2
2
|
${c.detail}
|
|
3
|
-
${c.verbose}`;throw new Error(l)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return u?i:yield i.json()})}const D={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/"}};function p(n,t="stage",e="datamanager"){const s=D[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(D).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 w(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 x={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function K(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 u=p(`api/${e}/_auth/login?clientID=rest`,t);return yield g(u,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function N(n){return a(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const r=`${x[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function z(n){return a(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;h({dmShortID:t,env:e,token:s});const r=p(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function C(n){return a(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${x[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function F({dmShortID:n}){return h({dmShortID:n}),n}function J({env:n}){return h({env:n}),n}let ht=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function R(n){let t={};for(let e in n)ht.includes(e)||(t[e]=n[e]);return t}function gt(n){return JSON.parse(JSON.stringify(n))}function v(n){return a(this,null,function*(){let{env:t,dmShortID:e}=n;h({env:t,dmShortID:e});const s=p(`api/${e}`,t);return g(s,n)})}function U(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 u=w(r),i=p(`api/${e}/${s}?${u}`,t),{count:d,total:c,_embedded:l}=yield g(i,n);let f=l?l[`${e}:${s}`]:[];return f=Array.isArray(f)?f:[f],{count:d,total:c,items:f}})}function I({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const u=w({_id:s}),i=p(`api/${t}/${e}?${u}`,n);return g(i,{dmShortID:t,token:r})}function M(u){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=p(`api/${t}/${e}`,n);return yield g(i,{env:n,dmShortID:t,token:r},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function V(d){return a(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:u,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 l=p(`api/${t}/${e}?_id=${s}`,n);return r=gt(r),r=R(r),yield g(l,{token:u},{method:"PUT",headers:c,body:JSON.stringify(r)})})}function G({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const u=p(`api/${t}/${e}?_id=${s}`,n);return g(u,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})}function H(r){return a(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var f,$,O,L,j;h({env:n,dmShortID:t,model:e});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];if(typeof d.properties!="object")throw new Error(`getSchema: ${u} returned unexpected format: ${JSON.stringify(i)}`);const{properties:c}=d,l=R(c);for(let A in l){let m=l[A];if(m.required=d.required.includes(A),($=l[A])!=null&&$.oneOf&&((O=l[A])==null||delete O.oneOf),(L=m.title)!=null&&L.includes("<")&&((j=m.title)!=null&&j.includes(">"))){const b=m.title.split("<")[1].slice(0,-1),ot=m.title.split("<")[0];m.type=ot,b.includes(":")?m.resource=b.split(":")[1]:m.resource=b}else["asset","entry","assets","entries"].includes(m.title)?(m.type=m.title,m.resource=null):m.type=m.title;delete l[A].title}if(s){const A=c._modelTitle.title,m=c._modelTitleField.title;return{properties:l,meta:{modelTitleField:m,modelTitle:A}}}return l})}function Q(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),{})}function P(n){return n._links.collection.href.split("/").slice(-2)[0]}function W(n,t){const e=P(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function X(u){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=w({assetID:s}),d=p(`a/${t}/${e}?${i}`,n);return(yield g(d,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function Y(n){return a(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:u={}}=n;h({env:t,dmShortID:e,assetGroup:s}),u=o({size:50,page:1,_list:!0},u);const i=w(u),d=p(`a/${e}/${s}?${i}`,t),{count:c,total:l,_embedded:f}=yield g(d,{dmShortID:e,token:r});let $=f?f["ec:dm-asset"]:[];return $=Array.isArray($)?$:[$],{count:c,total:l,items:$}})}function Z(d){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:u,options:i}){h({env:n,dmShortID:t,assetGroup:e,file:r});const c=p(`a/${t}/${e}`,n),l=new FormData;return l.append("file",r,u),i&&Object.keys(i).forEach($=>{l.append($,i[$])}),(yield g(c,{token:s},{method:"POST",body:l}))._embedded["ec:dm-asset"]})}function tt(u){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=p(`a/${t}/${e}/${s}`,n);yield g(i,{token:r,rawRes:!0},{method:"DELETE"})})}function et(n){return a(this,null,function*(){let{env:t,dmID:e,token:s}=n;h({env:t,dmID:e});const r=p(`?dataManagerID=${e}`,t);return g(r,{token:s})})}function nt(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=w(e),r=p(`?${s}`,t),{count:u,total:i,_embedded:d}=yield g(r,n);let c=d?d["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:u,total:i,items:c}})}function st(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=w(s),u=p(`model?${r}`,t),{count:i,total:d,_embedded:c}=yield g(u,n);let l=c?c["ec:model"]:[];return l=Array.isArray(l)?l:[l],{count:i,total:d,items:l}})}function rt(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 u=w(s),i=p(`${e}?${u}`,t,r),{count:d,total:c,_embedded:l}=yield g(i,n);let f=l?l[Object.keys(l)[0]]:[];return f=Array.isArray(f)?f:[f],{count:d,total:c,items:f}})}function it(e){return a(this,arguments,function*(n,t={}){let{env:s,route:r,options:u={},subdomain:i="datamanager"}=n;h({env:s,subdomain:i,route:r}),u=o({},u);const d=w(u),c=p(`${r}?${d}`,s,i);return g(c,n,t)})}const E=Object.freeze(Object.defineProperty({__proto__:null,assetList:Y,createAsset:Z,createEntry:M,deleteAsset:tt,deleteEntry:G,dmList:nt,editEntry:V,entryList:U,getAsset:X,getDatamanager:et,getEcAuthKey:J,getEntry:I,getEntryAsset:W,getEntryShortID:P,getPublicAuthKey:F,getSchema:H,loginEc:N,loginPublic:K,logoutEc:C,logoutPublic:z,modelList:st,publicApi:v,raw:it,resourceList:rt,sdkOptions:Q},Symbol.toStringTag,{value:"Module"})),{entryList:ft,getEntry:yt,getAsset:pt,assetList:mt,createAsset:$t,deleteAsset:wt,createEntry:At,editEntry:q,deleteEntry:Et,getSchema:kt,loginPublic:bt,loginEc:Tt,logoutEc:_t,logoutPublic:Pt,getEcAuthKey:T,getPublicAuthKey:_,dmList:Ot,modelList:Lt,publicApi:jt,getDatamanager:St,resourceList:Bt,raw:Dt}=E;function qt(n){const{action:t}=n;if(h({action:t}),!E[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(E).join(", ")}`);return E[t](n)}class k{constructor(t){this.config=t}set(t){return new k(o(o({},this.config),t))}entries(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return ft(y(o({},this.config),{options:t,token:e}))})}entryList(t){return a(this,null,function*(){return this.entries(t)})}getEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return yt(y(o({},this.config),{entryID:t,token:e}))})}editEntrySafe(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return q(y(o({},this.config),{entryID:t,token:s,value:e,safePut:!0}))})}getSchema(){return a(this,null,function*(){return kt(this.config)})}assets(t){return a(this,null,function*(){const e=yield this.getBestToken();return mt(y(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 $t(y(o({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return wt(y(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return pt(y(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return At(y(o({},this.config),{token:e,value:t}))})}editEntry(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return q(y(o({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return Et(y(o({},this.config),{token:e,entryID:t}))})}resourceList(t){return a(this,null,function*(){const e=yield this.getBestToken();return Bt(y(o({},this.config),{options:t,token:e}))})}raw(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return Dt(y(o({},this.config),{options:t,token:s}),e)})}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 Tt(o(o({},this.config),t)).then(this.setAuth(T(this.config)))}loginPublic(t){return bt(o(o({},this.config),t)).then(this.setAuth(_(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Pt(y(o({},this.config),{token:t})).then(this.unsetAuth(_(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),_t(y(o({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}getPublicToken(){return this.config.token||this.getAuth(_(this.config))}getEcToken(){return this.config.token||this.getAuth(T(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 jt(this.config)}getDatamanager(t){return a(this,null,function*(){const e=yield this.getBestToken();return St(y(o({},this.config),{dmID:t,token:e}))})}dmList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return Ot(y(o({},this.config),{options:t,token:e}))})}modelList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return Lt(y(o({},this.config),{options:t,token:e}))})}}const xt=n=>new k({env:n});exports.Sdk=k;exports.act=qt;exports.apiURL=p;exports.assetList=Y;exports.createAsset=Z;exports.createEntry=M;exports.deleteAsset=tt;exports.deleteEntry=G;exports.dmList=nt;exports.editEntry=V;exports.entryList=U;exports.expect=h;exports.fetcher=g;exports.getAsset=X;exports.getDatamanager=et;exports.getEcAuthKey=J;exports.getEntry=I;exports.getEntryAsset=W;exports.getEntryShortID=P;exports.getPublicAuthKey=F;exports.getSchema=H;exports.loginEc=N;exports.loginPublic=K;exports.logoutEc=C;exports.logoutPublic=z;exports.modelList=st;exports.publicApi=v;exports.query=w;exports.raw=it;exports.resourceList=rt;exports.sdk=xt;exports.sdkOptions=Q;
|
|
3
|
+
${c.verbose}`;throw new Error(l)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return u?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/"}};function p(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 w(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 z(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 u=p(`api/${e}/_auth/login?clientID=rest`,t);return yield g(u,{},{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=`${N[t]}auth/login?clientID=rest`;return yield g(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=p(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(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 g(s,{rawRes:!0,token:e},{method:"POST"})})}function U({dmShortID:n}){return h({dmShortID:n}),n}function I({env:n}){return h({env:n}),n}let mt=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function M(n){let t={};for(let e in n)mt.includes(e)||(t[e]=n[e]);return t}function $t(n){return JSON.parse(JSON.stringify(n))}function V(n){return a(this,null,function*(){let{env:t,dmShortID:e}=n;h({env:t,dmShortID:e});const s=p(`api/${e}`,t);return g(s,n)})}function G(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 u=w(r),i=p(`api/${e}/${s}?${u}`,t),{count:d,total:c,_embedded:l}=yield g(i,n);let y=l?l[`${e}:${s}`]:[];return y=Array.isArray(y)?y:[y],{count:d,total:c,items:y}})}function H({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const u=w({_id:s}),i=p(`api/${t}/${e}?${u}`,n);return g(i,{dmShortID:t,token:r})}function Q(u){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=p(`api/${t}/${e}`,n);return yield g(i,{env:n,dmShortID:t,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:u,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 l=p(`api/${t}/${e}?_id=${s}`,n);return r=$t(r),r=M(r),yield g(l,{token:u},{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 u=p(`api/${t}/${e}?_id=${s}`,n);return g(u,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})}function W(r){return a(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var y,$,D,q,v;h({env:n,dmShortID:t,model:e});const u=p(`api/schema/${t}/${e}`,n),i=yield g(u),d=(y=i==null?void 0:i.allOf)==null?void 0:y[1];if(typeof d.properties!="object")throw new Error(`getSchema: ${u} returned unexpected format: ${JSON.stringify(i)}`);const{properties:c}=d,l=M(c);for(let E in l){let m=l[E];if(m.required=d.required.includes(E),($=l[E])!=null&&$.oneOf&&((D=l[E])==null||delete D.oneOf),(q=m.title)!=null&&q.includes("<")&&((v=m.title)!=null&&v.includes(">"))){const _=m.title.split("<")[1].slice(0,-1),dt=m.title.split("<")[0];m.type=dt,_.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 l[E].title}if(s){const E=c._modelTitle.title,m=c._modelTitleField.title;return{properties:l,meta:{modelTitleField:m,modelTitle:E}}}return l})}function S(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 X=S;function k(n){return n._links.collection.href.split("/").slice(-2)[0]}function B(n){const t=n._links.collection.href.split("api/")[0];return Object.keys(b.datamanager).find(s=>b.datamanager[s]===t)}const Y=n=>{const t=k(n),e=B(n),s=n._modelTitle,r=n.id;return{dmShortID:t,env:e,model:s,entryID:r}},Z=n=>L(Y(n)),tt=(n,t)=>P(f(o({},Y(n)),{value:t}));function et(n,t){const e=k(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function nt(u){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=w({assetID:s}),d=p(`a/${t}/${e}?${i}`,n);return(yield g(d,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function st(n){return a(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:u={}}=n;h({env:t,dmShortID:e,assetGroup:s}),u=o({size:50,page:1,_list:!0},u);const i=w(u),d=p(`a/${e}/${s}?${i}`,t),{count:c,total:l,_embedded:y}=yield g(d,{dmShortID:e,token:r});let $=y?y["ec:dm-asset"]:[];return $=Array.isArray($)?$:[$],{count:c,total:l,items:$}})}function rt(d){return a(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:u,options:i}){h({env:n,dmShortID:t,assetGroup:e,file:r});const c=p(`a/${t}/${e}`,n),l=new FormData;return l.append("file",r,u),i&&Object.keys(i).forEach($=>{l.append($,i[$])}),(yield g(c,{token:s},{method:"POST",body:l}))._embedded["ec:dm-asset"]})}function it(u){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=p(`a/${t}/${e}/${s}`,n);yield g(i,{token:r,rawRes:!0},{method:"DELETE"})})}function ot(n){return a(this,null,function*(){let{env:t,dmID:e,token:s}=n;h({env:t,dmID:e});const r=p(`?dataManagerID=${e}`,t);return g(r,{token:s})})}function ct(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=w(e),r=p(`?${s}`,t),{count:u,total:i,_embedded:d}=yield g(r,n);let c=d?d["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:u,total:i,items:c}})}function at(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=w(s),u=p(`model?${r}`,t),{count:i,total:d,_embedded:c}=yield g(u,n);let l=c?c["ec:model"]:[];return l=Array.isArray(l)?l:[l],{count:i,total:d,items:l}})}function ut(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 u=w(s),i=p(`${e}?${u}`,t,r),{count:d,total:c,_embedded:l}=yield g(i,n);let y=l?l[Object.keys(l)[0]]:[];return y=Array.isArray(y)?y:[y],{count:d,total:c,items:y}})}function lt(e){return a(this,arguments,function*(n,t={}){let{env:s,route:r,options:u={},subdomain:i="datamanager"}=n;h({env:s,subdomain:i,route:r}),u=o({},u);const d=w(u),c=p(`${r}?${d}`,s,i);return g(c,n,t)})}const A=Object.freeze(Object.defineProperty({__proto__:null,assetList:st,createAsset:rt,createEntry:Q,deleteAsset:it,deleteEntry:L,deleteEntryObject:Z,dmList:ct,editEntry:P,editEntryObject:tt,entryList:G,filterOptions:X,getAsset:nt,getDatamanager:ot,getEcAuthKey:I,getEntry:H,getEntryAsset:et,getEntryEnv:B,getEntryShortID:k,getPublicAuthKey:U,getSchema:W,loginEc:F,loginPublic:z,logoutEc:R,logoutPublic:J,modelList:at,publicApi:V,raw:lt,resourceList:ut,sdkOptions:S},Symbol.toStringTag,{value:"Module"})),{entryList:wt,getEntry:Et,getAsset:bt,assetList:At,createAsset:kt,deleteAsset:Tt,createEntry:_t,editEntry:K,deleteEntry:Ot,getSchema:jt,loginPublic:Pt,loginEc:Lt,logoutEc:St,logoutPublic:Bt,getEcAuthKey:O,getPublicAuthKey:j,dmList:Dt,modelList:qt,publicApi:vt,getDatamanager:xt,resourceList:Ct,raw:Kt}=A;function Nt(n){const{action:t}=n;if(h({action:t}),!A[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(A).join(", ")}`);return A[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 wt(f(o({},this.config),{options:t,token:e}))})}entryList(t){return a(this,null,function*(){return this.entries(t)})}getEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return Et(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 jt(this.config)})}assets(t){return a(this,null,function*(){const e=yield this.getBestToken();return At(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 kt(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 Tt(f(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return bt(f(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return _t(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 Ot(f(o({},this.config),{token:e,entryID:t}))})}resourceList(t){return a(this,null,function*(){const e=yield this.getBestToken();return Ct(f(o({},this.config),{options:t,token:e}))})}raw(t,e){return a(this,null,function*(){const s=yield this.getBestToken();return Kt(f(o({},this.config),{options:t,token:s}),e)})}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 Lt(o(o({},this.config),t)).then(this.setAuth(O(this.config)))}loginPublic(t){return Pt(o(o({},this.config),t)).then(this.setAuth(j(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Bt(f(o({},this.config),{token:t})).then(this.unsetAuth(j(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),St(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 vt(this.config)}getDatamanager(t){return a(this,null,function*(){const e=yield this.getBestToken();return xt(f(o({},this.config),{dmID:t,token:e}))})}dmList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return Dt(f(o({},this.config),{options:t,token:e}))})}modelList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return qt(f(o({},this.config),{options:t,token:e}))})}}const zt=n=>new T({env:n});exports.Sdk=T;exports.act=Nt;exports.apiURL=p;exports.apis=b;exports.assetList=st;exports.createAsset=rt;exports.createEntry=Q;exports.deleteAsset=it;exports.deleteEntry=L;exports.deleteEntryObject=Z;exports.dmList=ct;exports.editEntry=P;exports.editEntryObject=tt;exports.entryList=G;exports.expect=h;exports.fetcher=g;exports.filterOptions=X;exports.getAsset=nt;exports.getDatamanager=ot;exports.getEcAuthKey=I;exports.getEntry=H;exports.getEntryAsset=et;exports.getEntryEnv=B;exports.getEntryShortID=k;exports.getPublicAuthKey=U;exports.getSchema=W;exports.loginEc=F;exports.loginPublic=z;exports.logoutEc=R;exports.logoutPublic=J;exports.modelList=at;exports.publicApi=V;exports.query=w;exports.raw=lt;exports.resourceList=ut;exports.sdk=zt;exports.sdkOptions=S;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var R = Object.defineProperty, U = Object.defineProperties;
|
|
2
|
+
var I = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var B = Object.getOwnPropertySymbols;
|
|
4
|
+
var M = Object.prototype.hasOwnProperty, V = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var D = (n, t, e) => t in n ? R(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, o = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
M.call(t, e) && D(n, e, t[e]);
|
|
8
|
+
if (B)
|
|
9
|
+
for (var e of B(t))
|
|
10
|
+
V.call(t, e) && D(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
},
|
|
12
|
+
}, g = (n, t) => U(n, I(t));
|
|
13
13
|
var c = (n, t, e) => new Promise((s, r) => {
|
|
14
14
|
var u = (a) => {
|
|
15
15
|
try {
|
|
@@ -26,11 +26,11 @@ var c = (n, t, e) => new Promise((s, r) => {
|
|
|
26
26
|
}, d = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(u, i);
|
|
27
27
|
d((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
|
-
function
|
|
29
|
+
function f(s) {
|
|
30
30
|
return c(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
31
|
var d;
|
|
32
32
|
const { token: r, rawRes: u } = t;
|
|
33
|
-
r && (e.headers =
|
|
33
|
+
r && (e.headers = g(o({}, e.headers || {}), {
|
|
34
34
|
Authorization: `Bearer ${r}`
|
|
35
35
|
}));
|
|
36
36
|
const i = yield fetch(n, e);
|
|
@@ -46,7 +46,7 @@ ${a.verbose}`;
|
|
|
46
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 B = {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
function y(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
|
)}`
|
|
70
70
|
);
|
|
@@ -84,16 +84,16 @@ function h(n) {
|
|
|
84
84
|
throw new Error(`expected ${t} to be set!`);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
const
|
|
87
|
+
const v = {
|
|
88
88
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
89
89
|
live: "https://accounts.entrecode.de/"
|
|
90
90
|
};
|
|
91
|
-
function
|
|
91
|
+
function G(n) {
|
|
92
92
|
return c(this, null, function* () {
|
|
93
93
|
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
94
94
|
h({ env: t, dmShortID: e, email: s, password: r });
|
|
95
95
|
const u = y(`api/${e}/_auth/login?clientID=rest`, t);
|
|
96
|
-
return yield
|
|
96
|
+
return yield f(
|
|
97
97
|
u,
|
|
98
98
|
{},
|
|
99
99
|
{
|
|
@@ -106,12 +106,12 @@ function v(n) {
|
|
|
106
106
|
);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function H(n) {
|
|
110
110
|
return c(this, null, function* () {
|
|
111
111
|
let { env: t, email: e, password: s } = n;
|
|
112
112
|
h({ env: t, email: e, password: s });
|
|
113
|
-
const r = `${
|
|
114
|
-
return yield
|
|
113
|
+
const r = `${v[t]}auth/login?clientID=rest`;
|
|
114
|
+
return yield f(
|
|
115
115
|
r,
|
|
116
116
|
{},
|
|
117
117
|
{
|
|
@@ -124,7 +124,7 @@ function U(n) {
|
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function Q(n) {
|
|
128
128
|
return c(this, null, function* () {
|
|
129
129
|
let { dmShortID: t, env: e, token: s } = n;
|
|
130
130
|
h({ dmShortID: t, env: e, token: s });
|
|
@@ -132,7 +132,7 @@ function I(n) {
|
|
|
132
132
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
133
133
|
e
|
|
134
134
|
);
|
|
135
|
-
return yield
|
|
135
|
+
return yield f(
|
|
136
136
|
r,
|
|
137
137
|
{ dmShortID: t, rawRes: !0 },
|
|
138
138
|
{
|
|
@@ -141,12 +141,12 @@ function I(n) {
|
|
|
141
141
|
);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function W(n) {
|
|
145
145
|
return c(this, null, function* () {
|
|
146
146
|
let { env: t, token: e } = n;
|
|
147
147
|
h({ env: t, token: e });
|
|
148
|
-
const s = `${
|
|
149
|
-
return yield
|
|
148
|
+
const s = `${v[t]}auth/logout?clientID=rest`;
|
|
149
|
+
return yield f(
|
|
150
150
|
s,
|
|
151
151
|
{
|
|
152
152
|
rawRes: !0,
|
|
@@ -158,13 +158,13 @@ function M(n) {
|
|
|
158
158
|
);
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function X({ dmShortID: n }) {
|
|
162
162
|
return h({ dmShortID: n }), n;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function Y({ env: n }) {
|
|
165
165
|
return h({ env: n }), n;
|
|
166
166
|
}
|
|
167
|
-
let
|
|
167
|
+
let Z = [
|
|
168
168
|
"created",
|
|
169
169
|
"creator",
|
|
170
170
|
"id",
|
|
@@ -183,39 +183,39 @@ let H = [
|
|
|
183
183
|
function x(n) {
|
|
184
184
|
let t = {};
|
|
185
185
|
for (let e in n)
|
|
186
|
-
|
|
186
|
+
Z.includes(e) || (t[e] = n[e]);
|
|
187
187
|
return t;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function tt(n) {
|
|
190
190
|
return JSON.parse(JSON.stringify(n));
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function et(n) {
|
|
193
193
|
return c(this, null, function* () {
|
|
194
194
|
let { env: t, dmShortID: e } = n;
|
|
195
195
|
h({ env: t, dmShortID: e });
|
|
196
196
|
const s = y(`api/${e}`, t);
|
|
197
|
-
return
|
|
197
|
+
return f(s, n);
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function nt(n) {
|
|
201
201
|
return c(this, null, function* () {
|
|
202
202
|
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
203
203
|
h({ env: t, dmShortID: e, model: s }), r = o({ size: 50, page: 1, _list: !0 }, r);
|
|
204
|
-
const u = w(r), i = y(`api/${e}/${s}?${u}`, t), { count: d, total: a, _embedded: l } = yield
|
|
205
|
-
let
|
|
206
|
-
return
|
|
204
|
+
const u = w(r), i = y(`api/${e}/${s}?${u}`, t), { count: d, total: a, _embedded: l } = yield f(i, n);
|
|
205
|
+
let p = l ? l[`${e}:${s}`] : [];
|
|
206
|
+
return p = Array.isArray(p) ? p : [p], { count: d, total: a, items: p };
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function st({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
210
210
|
h({ env: n, dmShortID: t, model: e, entryID: s });
|
|
211
211
|
const u = w({ _id: s }), i = y(`api/${t}/${e}?${u}`, n);
|
|
212
|
-
return
|
|
212
|
+
return f(i, { dmShortID: t, token: r });
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function rt(u) {
|
|
215
215
|
return c(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
|
|
216
216
|
h({ env: n, dmShortID: t, model: e, value: s });
|
|
217
217
|
const i = y(`api/${t}/${e}`, n);
|
|
218
|
-
return yield
|
|
218
|
+
return yield f(
|
|
219
219
|
i,
|
|
220
220
|
{ env: n, dmShortID: t, token: r },
|
|
221
221
|
{
|
|
@@ -228,7 +228,7 @@ function Z(u) {
|
|
|
228
228
|
);
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function C(d) {
|
|
232
232
|
return c(this, arguments, function* ({
|
|
233
233
|
env: n,
|
|
234
234
|
dmShortID: t,
|
|
@@ -248,7 +248,7 @@ function tt(d) {
|
|
|
248
248
|
a["If-Unmodified-Since"] = new Date(r._modified).toUTCString();
|
|
249
249
|
}
|
|
250
250
|
const l = y(`api/${t}/${e}?_id=${s}`, n);
|
|
251
|
-
return r =
|
|
251
|
+
return r = tt(r), r = x(r), yield f(
|
|
252
252
|
l,
|
|
253
253
|
{ token: u },
|
|
254
254
|
{
|
|
@@ -259,10 +259,10 @@ function tt(d) {
|
|
|
259
259
|
);
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function K({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
263
263
|
h({ env: n, dmShortID: t, model: e, entryID: s });
|
|
264
264
|
const u = y(`api/${t}/${e}?_id=${s}`, n);
|
|
265
|
-
return
|
|
265
|
+
return f(
|
|
266
266
|
u,
|
|
267
267
|
{ token: r, rawRes: !0 },
|
|
268
268
|
{
|
|
@@ -273,59 +273,72 @@ function et({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
|
273
273
|
}
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function it(r) {
|
|
277
277
|
return c(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
|
|
278
|
-
var
|
|
278
|
+
var p, $, P, L, S;
|
|
279
279
|
h({ env: n, dmShortID: t, model: e });
|
|
280
|
-
const u = y(`api/schema/${t}/${e}`, n), i = yield
|
|
280
|
+
const u = y(`api/schema/${t}/${e}`, n), i = yield f(u), d = (p = i == null ? void 0 : i.allOf) == null ? void 0 : p[1];
|
|
281
281
|
if (typeof d.properties != "object")
|
|
282
282
|
throw new Error(
|
|
283
283
|
`getSchema: ${u} returned unexpected format: ${JSON.stringify(i)}`
|
|
284
284
|
);
|
|
285
285
|
const { properties: a } = d, l = x(a);
|
|
286
|
-
for (let
|
|
287
|
-
let m = l[
|
|
288
|
-
if (m.required = d.required.includes(
|
|
289
|
-
const k = m.title.split("<")[1].slice(0, -1),
|
|
290
|
-
m.type =
|
|
286
|
+
for (let E in l) {
|
|
287
|
+
let m = l[E];
|
|
288
|
+
if (m.required = d.required.includes(E), ($ = l[E]) != null && $.oneOf && ((P = l[E]) == null || delete P.oneOf), (L = m.title) != null && L.includes("<") && ((S = m.title) != null && S.includes(">"))) {
|
|
289
|
+
const k = m.title.split("<")[1].slice(0, -1), J = m.title.split("<")[0];
|
|
290
|
+
m.type = J, k.includes(":") ? m.resource = k.split(":")[1] : m.resource = k;
|
|
291
291
|
} else
|
|
292
292
|
["asset", "entry", "assets", "entries"].includes(m.title) ? (m.type = m.title, m.resource = null) : m.type = m.title;
|
|
293
|
-
delete l[
|
|
293
|
+
delete l[E].title;
|
|
294
294
|
}
|
|
295
295
|
if (s) {
|
|
296
|
-
const
|
|
297
|
-
return { properties: l, meta: { modelTitleField: m, modelTitle:
|
|
296
|
+
const E = a._modelTitle.title, m = a._modelTitleField.title;
|
|
297
|
+
return { properties: l, meta: { modelTitleField: m, modelTitle: E } };
|
|
298
298
|
}
|
|
299
299
|
return l;
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function N(n) {
|
|
303
303
|
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), {});
|
|
304
304
|
}
|
|
305
|
-
|
|
305
|
+
const ot = N;
|
|
306
|
+
function O(n) {
|
|
306
307
|
return n._links.collection.href.split("/").slice(-2)[0];
|
|
307
308
|
}
|
|
308
|
-
function
|
|
309
|
-
const
|
|
309
|
+
function z(n) {
|
|
310
|
+
const t = n._links.collection.href.split("api/")[0];
|
|
311
|
+
return Object.keys(b.datamanager).find(
|
|
312
|
+
(s) => b.datamanager[s] === t
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
const F = (n) => {
|
|
316
|
+
const t = O(n), e = z(n), s = n._modelTitle, r = n.id;
|
|
317
|
+
return { dmShortID: t, env: e, model: s, entryID: r };
|
|
318
|
+
}, at = (n) => K(F(n)), ct = (n, t) => C(g(o({}, F(n)), {
|
|
319
|
+
value: t
|
|
320
|
+
}));
|
|
321
|
+
function ut(n, t) {
|
|
322
|
+
const e = O(t);
|
|
310
323
|
return t._embedded[`${e}:${t._modelTitle}/${n}/asset`];
|
|
311
324
|
}
|
|
312
|
-
function
|
|
325
|
+
function lt(u) {
|
|
313
326
|
return c(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
|
|
314
327
|
h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
315
328
|
const i = w({ assetID: s }), d = y(`a/${t}/${e}?${i}`, n);
|
|
316
|
-
return (yield
|
|
329
|
+
return (yield f(d, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
|
|
317
330
|
});
|
|
318
331
|
}
|
|
319
|
-
function
|
|
332
|
+
function dt(n) {
|
|
320
333
|
return c(this, null, function* () {
|
|
321
334
|
let { env: t, dmShortID: e, assetGroup: s, token: r, options: u = {} } = n;
|
|
322
335
|
h({ env: t, dmShortID: e, assetGroup: s }), u = o({ size: 50, page: 1, _list: !0 }, u);
|
|
323
|
-
const i = w(u), d = y(`a/${e}/${s}?${i}`, t), { count: a, total: l, _embedded:
|
|
324
|
-
let $ =
|
|
336
|
+
const i = w(u), d = y(`a/${e}/${s}?${i}`, t), { count: a, total: l, _embedded: p } = yield f(d, { dmShortID: e, token: r });
|
|
337
|
+
let $ = p ? p["ec:dm-asset"] : [];
|
|
325
338
|
return $ = Array.isArray($) ? $ : [$], { count: a, total: l, items: $ };
|
|
326
339
|
});
|
|
327
340
|
}
|
|
328
|
-
function
|
|
341
|
+
function ht(d) {
|
|
329
342
|
return c(this, arguments, function* ({
|
|
330
343
|
env: n,
|
|
331
344
|
dmShortID: t,
|
|
@@ -339,7 +352,7 @@ function at(d) {
|
|
|
339
352
|
const a = y(`a/${t}/${e}`, n), l = new FormData();
|
|
340
353
|
return l.append("file", r, u), i && Object.keys(i).forEach(($) => {
|
|
341
354
|
l.append($, i[$]);
|
|
342
|
-
}), (yield
|
|
355
|
+
}), (yield f(
|
|
343
356
|
a,
|
|
344
357
|
{ token: s },
|
|
345
358
|
{
|
|
@@ -349,7 +362,7 @@ function at(d) {
|
|
|
349
362
|
))._embedded["ec:dm-asset"];
|
|
350
363
|
});
|
|
351
364
|
}
|
|
352
|
-
function
|
|
365
|
+
function gt(u) {
|
|
353
366
|
return c(this, arguments, function* ({
|
|
354
367
|
env: n,
|
|
355
368
|
dmShortID: t,
|
|
@@ -359,7 +372,7 @@ function ct(u) {
|
|
|
359
372
|
}) {
|
|
360
373
|
h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
361
374
|
const i = y(`a/${t}/${e}/${s}`, n);
|
|
362
|
-
yield
|
|
375
|
+
yield f(
|
|
363
376
|
i,
|
|
364
377
|
{ token: r, rawRes: !0 },
|
|
365
378
|
{
|
|
@@ -368,116 +381,120 @@ function ct(u) {
|
|
|
368
381
|
);
|
|
369
382
|
});
|
|
370
383
|
}
|
|
371
|
-
function
|
|
384
|
+
function ft(n) {
|
|
372
385
|
return c(this, null, function* () {
|
|
373
386
|
let { env: t, dmID: e, token: s } = n;
|
|
374
387
|
h({ env: t, dmID: e });
|
|
375
388
|
const r = y(`?dataManagerID=${e}`, t);
|
|
376
|
-
return
|
|
389
|
+
return f(r, { token: s });
|
|
377
390
|
});
|
|
378
391
|
}
|
|
379
|
-
function
|
|
392
|
+
function pt(n) {
|
|
380
393
|
return c(this, null, function* () {
|
|
381
394
|
let { env: t, options: e = {} } = n;
|
|
382
395
|
h({ env: t }), e = o({ size: 25, page: 1, _list: !0 }, e);
|
|
383
|
-
const s = w(e), r = y(`?${s}`, t), { count: u, total: i, _embedded: d } = yield
|
|
396
|
+
const s = w(e), r = y(`?${s}`, t), { count: u, total: i, _embedded: d } = yield f(r, n);
|
|
384
397
|
let a = d ? d["ec:datamanager"] : [];
|
|
385
398
|
return a = Array.isArray(a) ? a : [a], { count: u, total: i, items: a };
|
|
386
399
|
});
|
|
387
400
|
}
|
|
388
|
-
function
|
|
401
|
+
function yt(n) {
|
|
389
402
|
return c(this, null, function* () {
|
|
390
403
|
let { env: t, dmID: e, options: s = {} } = n;
|
|
391
404
|
h({ env: t, dmID: e }), s = o({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
|
|
392
|
-
const r = w(s), u = y(`model?${r}`, t), { count: i, total: d, _embedded: a } = yield
|
|
405
|
+
const r = w(s), u = y(`model?${r}`, t), { count: i, total: d, _embedded: a } = yield f(u, n);
|
|
393
406
|
let l = a ? a["ec:model"] : [];
|
|
394
407
|
return l = Array.isArray(l) ? l : [l], { count: i, total: d, items: l };
|
|
395
408
|
});
|
|
396
409
|
}
|
|
397
|
-
function
|
|
410
|
+
function mt(n) {
|
|
398
411
|
return c(this, null, function* () {
|
|
399
412
|
let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
|
|
400
413
|
h({ env: t, subdomain: r, resource: e }), s = o({ size: 25, page: 1, _list: !0 }, s);
|
|
401
|
-
const u = w(s), i = y(`${e}?${u}`, t, r), { count: d, total: a, _embedded: l } = yield
|
|
402
|
-
let
|
|
403
|
-
return
|
|
414
|
+
const u = w(s), i = y(`${e}?${u}`, t, r), { count: d, total: a, _embedded: l } = yield f(i, n);
|
|
415
|
+
let p = l ? l[Object.keys(l)[0]] : [];
|
|
416
|
+
return p = Array.isArray(p) ? p : [p], { count: d, total: a, items: p };
|
|
404
417
|
});
|
|
405
418
|
}
|
|
406
|
-
function
|
|
419
|
+
function $t(e) {
|
|
407
420
|
return c(this, arguments, function* (n, t = {}) {
|
|
408
421
|
let { env: s, route: r, options: u = {}, subdomain: i = "datamanager" } = n;
|
|
409
422
|
h({ env: s, subdomain: i, route: r }), u = o({}, u);
|
|
410
423
|
const d = w(u), a = y(`${r}?${d}`, s, i);
|
|
411
|
-
return
|
|
424
|
+
return f(a, n, t);
|
|
412
425
|
});
|
|
413
426
|
}
|
|
414
|
-
const
|
|
427
|
+
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
415
428
|
__proto__: null,
|
|
416
|
-
assetList:
|
|
417
|
-
createAsset:
|
|
418
|
-
createEntry:
|
|
419
|
-
deleteAsset:
|
|
420
|
-
deleteEntry:
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
429
|
+
assetList: dt,
|
|
430
|
+
createAsset: ht,
|
|
431
|
+
createEntry: rt,
|
|
432
|
+
deleteAsset: gt,
|
|
433
|
+
deleteEntry: K,
|
|
434
|
+
deleteEntryObject: at,
|
|
435
|
+
dmList: pt,
|
|
436
|
+
editEntry: C,
|
|
437
|
+
editEntryObject: ct,
|
|
438
|
+
entryList: nt,
|
|
439
|
+
filterOptions: ot,
|
|
440
|
+
getAsset: lt,
|
|
441
|
+
getDatamanager: ft,
|
|
442
|
+
getEcAuthKey: Y,
|
|
443
|
+
getEntry: st,
|
|
444
|
+
getEntryAsset: ut,
|
|
445
|
+
getEntryEnv: z,
|
|
446
|
+
getEntryShortID: O,
|
|
447
|
+
getPublicAuthKey: X,
|
|
448
|
+
getSchema: it,
|
|
449
|
+
loginEc: H,
|
|
450
|
+
loginPublic: G,
|
|
451
|
+
logoutEc: W,
|
|
452
|
+
logoutPublic: Q,
|
|
453
|
+
modelList: yt,
|
|
454
|
+
publicApi: et,
|
|
455
|
+
raw: $t,
|
|
456
|
+
resourceList: mt,
|
|
457
|
+
sdkOptions: N
|
|
441
458
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
442
|
-
entryList:
|
|
443
|
-
getEntry:
|
|
444
|
-
getAsset:
|
|
445
|
-
assetList:
|
|
446
|
-
createAsset:
|
|
447
|
-
deleteAsset:
|
|
448
|
-
createEntry:
|
|
449
|
-
editEntry:
|
|
450
|
-
deleteEntry:
|
|
451
|
-
getSchema:
|
|
452
|
-
loginPublic:
|
|
453
|
-
loginEc:
|
|
454
|
-
logoutEc:
|
|
455
|
-
logoutPublic:
|
|
456
|
-
getEcAuthKey:
|
|
457
|
-
getPublicAuthKey:
|
|
458
|
-
dmList:
|
|
459
|
-
modelList:
|
|
460
|
-
publicApi:
|
|
461
|
-
getDatamanager:
|
|
462
|
-
resourceList:
|
|
463
|
-
raw:
|
|
464
|
-
} =
|
|
465
|
-
function
|
|
459
|
+
entryList: wt,
|
|
460
|
+
getEntry: Et,
|
|
461
|
+
getAsset: At,
|
|
462
|
+
assetList: bt,
|
|
463
|
+
createAsset: kt,
|
|
464
|
+
deleteAsset: Tt,
|
|
465
|
+
createEntry: _t,
|
|
466
|
+
editEntry: q,
|
|
467
|
+
deleteEntry: Ot,
|
|
468
|
+
getSchema: jt,
|
|
469
|
+
loginPublic: Pt,
|
|
470
|
+
loginEc: Lt,
|
|
471
|
+
logoutEc: St,
|
|
472
|
+
logoutPublic: Bt,
|
|
473
|
+
getEcAuthKey: T,
|
|
474
|
+
getPublicAuthKey: _,
|
|
475
|
+
dmList: Dt,
|
|
476
|
+
modelList: qt,
|
|
477
|
+
publicApi: vt,
|
|
478
|
+
getDatamanager: xt,
|
|
479
|
+
resourceList: Ct,
|
|
480
|
+
raw: Kt
|
|
481
|
+
} = A;
|
|
482
|
+
function zt(n) {
|
|
466
483
|
const { action: t } = n;
|
|
467
|
-
if (h({ action: t }), !
|
|
484
|
+
if (h({ action: t }), !A[t])
|
|
468
485
|
throw new Error(
|
|
469
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
486
|
+
`"${t}" does not exist! try one of ${Object.keys(A).join(
|
|
470
487
|
", "
|
|
471
488
|
)}`
|
|
472
489
|
);
|
|
473
|
-
return
|
|
490
|
+
return A[t](n);
|
|
474
491
|
}
|
|
475
|
-
class
|
|
492
|
+
class j {
|
|
476
493
|
constructor(t) {
|
|
477
494
|
this.config = t;
|
|
478
495
|
}
|
|
479
496
|
set(t) {
|
|
480
|
-
return new
|
|
497
|
+
return new j(o(o({}, this.config), t));
|
|
481
498
|
}
|
|
482
499
|
/**
|
|
483
500
|
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
@@ -495,7 +512,7 @@ class _ {
|
|
|
495
512
|
entries() {
|
|
496
513
|
return c(this, arguments, function* (t = {}) {
|
|
497
514
|
const e = yield this.getBestToken();
|
|
498
|
-
return
|
|
515
|
+
return wt(g(o({}, this.config), { options: t, token: e }));
|
|
499
516
|
});
|
|
500
517
|
}
|
|
501
518
|
entryList(t) {
|
|
@@ -515,7 +532,7 @@ class _ {
|
|
|
515
532
|
getEntry(t) {
|
|
516
533
|
return c(this, null, function* () {
|
|
517
534
|
const e = yield this.getBestToken();
|
|
518
|
-
return
|
|
535
|
+
return Et(g(o({}, this.config), { entryID: t, token: e }));
|
|
519
536
|
});
|
|
520
537
|
}
|
|
521
538
|
/**
|
|
@@ -535,7 +552,7 @@ class _ {
|
|
|
535
552
|
editEntrySafe(t, e) {
|
|
536
553
|
return c(this, null, function* () {
|
|
537
554
|
const s = yield this.getBestToken();
|
|
538
|
-
return
|
|
555
|
+
return q(g(o({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
|
|
539
556
|
});
|
|
540
557
|
}
|
|
541
558
|
/**
|
|
@@ -548,7 +565,7 @@ class _ {
|
|
|
548
565
|
*/
|
|
549
566
|
getSchema() {
|
|
550
567
|
return c(this, null, function* () {
|
|
551
|
-
return
|
|
568
|
+
return jt(this.config);
|
|
552
569
|
});
|
|
553
570
|
}
|
|
554
571
|
/**
|
|
@@ -567,7 +584,7 @@ class _ {
|
|
|
567
584
|
assets(t) {
|
|
568
585
|
return c(this, null, function* () {
|
|
569
586
|
const e = yield this.getBestToken();
|
|
570
|
-
return
|
|
587
|
+
return bt(g(o({}, this.config), { options: t, token: e }));
|
|
571
588
|
});
|
|
572
589
|
}
|
|
573
590
|
assetList(t) {
|
|
@@ -599,7 +616,7 @@ class _ {
|
|
|
599
616
|
createAsset() {
|
|
600
617
|
return c(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
601
618
|
const r = yield this.getBestToken();
|
|
602
|
-
return
|
|
619
|
+
return kt(g(o({}, this.config), { file: t, name: e, options: s, token: r }));
|
|
603
620
|
});
|
|
604
621
|
}
|
|
605
622
|
/**
|
|
@@ -614,7 +631,7 @@ class _ {
|
|
|
614
631
|
deleteAsset(t) {
|
|
615
632
|
return c(this, null, function* () {
|
|
616
633
|
const e = yield this.getBestToken();
|
|
617
|
-
return
|
|
634
|
+
return Tt(g(o({}, this.config), { token: e, assetID: t }));
|
|
618
635
|
});
|
|
619
636
|
}
|
|
620
637
|
/**
|
|
@@ -629,7 +646,7 @@ class _ {
|
|
|
629
646
|
getAsset(t) {
|
|
630
647
|
return c(this, null, function* () {
|
|
631
648
|
const e = yield this.getBestToken();
|
|
632
|
-
return
|
|
649
|
+
return At(g(o({}, this.config), { assetID: t, token: e }));
|
|
633
650
|
});
|
|
634
651
|
}
|
|
635
652
|
/**
|
|
@@ -644,7 +661,7 @@ class _ {
|
|
|
644
661
|
createEntry(t) {
|
|
645
662
|
return c(this, null, function* () {
|
|
646
663
|
const e = yield this.getBestToken();
|
|
647
|
-
return
|
|
664
|
+
return _t(g(o({}, this.config), { token: e, value: t }));
|
|
648
665
|
});
|
|
649
666
|
}
|
|
650
667
|
/**
|
|
@@ -660,7 +677,7 @@ class _ {
|
|
|
660
677
|
editEntry(t, e) {
|
|
661
678
|
return c(this, null, function* () {
|
|
662
679
|
const s = yield this.getBestToken();
|
|
663
|
-
return
|
|
680
|
+
return q(g(o({}, this.config), { entryID: t, token: s, value: e }));
|
|
664
681
|
});
|
|
665
682
|
}
|
|
666
683
|
/**
|
|
@@ -675,7 +692,7 @@ class _ {
|
|
|
675
692
|
deleteEntry(t) {
|
|
676
693
|
return c(this, null, function* () {
|
|
677
694
|
const e = yield this.getBestToken();
|
|
678
|
-
return
|
|
695
|
+
return Ot(g(o({}, this.config), { token: e, entryID: t }));
|
|
679
696
|
});
|
|
680
697
|
}
|
|
681
698
|
/**
|
|
@@ -690,7 +707,7 @@ class _ {
|
|
|
690
707
|
resourceList(t) {
|
|
691
708
|
return c(this, null, function* () {
|
|
692
709
|
const e = yield this.getBestToken();
|
|
693
|
-
return
|
|
710
|
+
return Ct(g(o({}, this.config), { options: t, token: e }));
|
|
694
711
|
});
|
|
695
712
|
}
|
|
696
713
|
/**
|
|
@@ -707,7 +724,7 @@ class _ {
|
|
|
707
724
|
raw(t, e) {
|
|
708
725
|
return c(this, null, function* () {
|
|
709
726
|
const s = yield this.getBestToken();
|
|
710
|
-
return
|
|
727
|
+
return Kt(g(o({}, this.config), { options: t, token: s }), e);
|
|
711
728
|
});
|
|
712
729
|
}
|
|
713
730
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -737,32 +754,32 @@ class _ {
|
|
|
737
754
|
return e(t);
|
|
738
755
|
}
|
|
739
756
|
loginEc(t) {
|
|
740
|
-
return
|
|
741
|
-
this.setAuth(
|
|
757
|
+
return Lt(o(o({}, this.config), t)).then(
|
|
758
|
+
this.setAuth(T(this.config))
|
|
742
759
|
);
|
|
743
760
|
}
|
|
744
761
|
loginPublic(t) {
|
|
745
|
-
return
|
|
746
|
-
this.setAuth(
|
|
762
|
+
return Pt(o(o({}, this.config), t)).then(
|
|
763
|
+
this.setAuth(_(this.config))
|
|
747
764
|
);
|
|
748
765
|
}
|
|
749
766
|
logoutPublic() {
|
|
750
767
|
const t = this.getPublicToken();
|
|
751
|
-
return console.log("token", t),
|
|
752
|
-
this.unsetAuth(
|
|
768
|
+
return console.log("token", t), Bt(g(o({}, this.config), { token: t })).then(
|
|
769
|
+
this.unsetAuth(_(this.config))
|
|
753
770
|
);
|
|
754
771
|
}
|
|
755
772
|
logoutEc() {
|
|
756
773
|
const t = this.getEcToken();
|
|
757
|
-
return console.log("token", t),
|
|
758
|
-
this.unsetAuth(
|
|
774
|
+
return console.log("token", t), St(g(o({}, this.config), { token: t })).then(
|
|
775
|
+
this.unsetAuth(T(this.config))
|
|
759
776
|
);
|
|
760
777
|
}
|
|
761
778
|
getPublicToken() {
|
|
762
|
-
return this.config.token || this.getAuth(
|
|
779
|
+
return this.config.token || this.getAuth(_(this.config));
|
|
763
780
|
}
|
|
764
781
|
getEcToken() {
|
|
765
|
-
return this.config.token || this.getAuth(
|
|
782
|
+
return this.config.token || this.getAuth(T(this.config));
|
|
766
783
|
}
|
|
767
784
|
hasPublicToken() {
|
|
768
785
|
return !!this.getPublicToken();
|
|
@@ -865,7 +882,7 @@ class _ {
|
|
|
865
882
|
* @returns any
|
|
866
883
|
*/
|
|
867
884
|
publicApi() {
|
|
868
|
-
return
|
|
885
|
+
return vt(this.config);
|
|
869
886
|
}
|
|
870
887
|
/**
|
|
871
888
|
* Loads a DatamanagerResource by its long id. Requires token.
|
|
@@ -874,7 +891,7 @@ class _ {
|
|
|
874
891
|
getDatamanager(t) {
|
|
875
892
|
return c(this, null, function* () {
|
|
876
893
|
const e = yield this.getBestToken();
|
|
877
|
-
return
|
|
894
|
+
return xt(g(o({}, this.config), { dmID: t, token: e }));
|
|
878
895
|
});
|
|
879
896
|
}
|
|
880
897
|
/**
|
|
@@ -888,7 +905,7 @@ class _ {
|
|
|
888
905
|
dmList() {
|
|
889
906
|
return c(this, arguments, function* (t = {}) {
|
|
890
907
|
const e = yield this.getBestToken();
|
|
891
|
-
return
|
|
908
|
+
return Dt(g(o({}, this.config), { options: t, token: e }));
|
|
892
909
|
});
|
|
893
910
|
}
|
|
894
911
|
/**
|
|
@@ -902,42 +919,47 @@ class _ {
|
|
|
902
919
|
modelList() {
|
|
903
920
|
return c(this, arguments, function* (t = {}) {
|
|
904
921
|
const e = yield this.getBestToken();
|
|
905
|
-
return
|
|
922
|
+
return qt(g(o({}, this.config), { options: t, token: e }));
|
|
906
923
|
});
|
|
907
924
|
}
|
|
908
925
|
}
|
|
909
|
-
const
|
|
926
|
+
const Ft = (n) => new j({ env: n });
|
|
910
927
|
export {
|
|
911
|
-
|
|
912
|
-
|
|
928
|
+
j as Sdk,
|
|
929
|
+
zt as act,
|
|
913
930
|
y as apiURL,
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
931
|
+
b as apis,
|
|
932
|
+
dt as assetList,
|
|
933
|
+
ht as createAsset,
|
|
934
|
+
rt as createEntry,
|
|
935
|
+
gt as deleteAsset,
|
|
936
|
+
K as deleteEntry,
|
|
937
|
+
at as deleteEntryObject,
|
|
938
|
+
pt as dmList,
|
|
939
|
+
C as editEntry,
|
|
940
|
+
ct as editEntryObject,
|
|
941
|
+
nt as entryList,
|
|
922
942
|
h as expect,
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
Y as
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
943
|
+
f as fetcher,
|
|
944
|
+
ot as filterOptions,
|
|
945
|
+
lt as getAsset,
|
|
946
|
+
ft as getDatamanager,
|
|
947
|
+
Y as getEcAuthKey,
|
|
948
|
+
st as getEntry,
|
|
949
|
+
ut as getEntryAsset,
|
|
950
|
+
z as getEntryEnv,
|
|
951
|
+
O as getEntryShortID,
|
|
952
|
+
X as getPublicAuthKey,
|
|
953
|
+
it as getSchema,
|
|
954
|
+
H as loginEc,
|
|
955
|
+
G as loginPublic,
|
|
956
|
+
W as logoutEc,
|
|
957
|
+
Q as logoutPublic,
|
|
958
|
+
yt as modelList,
|
|
959
|
+
et as publicApi,
|
|
938
960
|
w as query,
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
961
|
+
$t as raw,
|
|
962
|
+
mt as resourceList,
|
|
963
|
+
Ft as sdk,
|
|
964
|
+
N as sdkOptions
|
|
943
965
|
};
|
package/dist/lib/entries.d.mts
CHANGED
|
@@ -76,13 +76,50 @@ export function sdkOptions(options: SdkFilterOptions): Record<string, string>;
|
|
|
76
76
|
*/
|
|
77
77
|
export function getEntryShortID(entry: EntryResource): string;
|
|
78
78
|
/**
|
|
79
|
-
* Returns the
|
|
79
|
+
* Returns the env of the given EntryResource
|
|
80
80
|
*
|
|
81
81
|
* @param {EntryResource} entry EntryResource
|
|
82
82
|
* @returns {string}
|
|
83
83
|
*
|
|
84
84
|
*/
|
|
85
|
-
export function
|
|
85
|
+
export function getEntryEnv(entry: EntryResource): string;
|
|
86
|
+
/**
|
|
87
|
+
* Returns the embedded asset from the given field name and EntryResource
|
|
88
|
+
*
|
|
89
|
+
* @param {EntryResource} entry EntryResource
|
|
90
|
+
* @returns {AssetResource}
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
export function getEntryAsset(field: any, entry: EntryResource): AssetResource;
|
|
94
|
+
/**
|
|
95
|
+
* @typedef {Object} SdkFilter
|
|
96
|
+
* @property {string | string[]} sort
|
|
97
|
+
* @property {string} search
|
|
98
|
+
* @property {boolean} notNull
|
|
99
|
+
* @property {boolean} null
|
|
100
|
+
* @property {Array[]} any
|
|
101
|
+
* @property {string} from
|
|
102
|
+
* @property {string} to
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* @typedef {Object} SdkFilterOptions
|
|
107
|
+
* @property {SdkFilter} sort
|
|
108
|
+
* @property {number} _count
|
|
109
|
+
* @property {number} page
|
|
110
|
+
* @property {Record<string, SdkFilter> | string | boolean} [key]
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* Takes [ec.sdk filterOptions](https://entrecode.github.io/ec.sdk/#filteroptions), outputs an [entrecode filter](https://doc.entrecode.de/api-basics/#filtering)
|
|
115
|
+
*
|
|
116
|
+
* @param {SdkFilterOptions} options sdk filterOptions
|
|
117
|
+
* @returns {Record<string, string>}
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
export function filterOptions(options: SdkFilterOptions): Record<string, string>;
|
|
121
|
+
export function deleteEntryObject(entry: any): Promise<any>;
|
|
122
|
+
export function editEntryObject(entry: any, value: any): Promise<any>;
|
|
86
123
|
export type SdkFilter = {
|
|
87
124
|
sort: string | string[];
|
|
88
125
|
search: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.d.mts","sourceRoot":"","sources":["../../src/lib/entries.mjs"],"names":[],"mappings":"AAiCA,qDAMC;AAED;;;;GAYC;AAED;;;;;;iBAKC;AAED;;;;;;iBAeC;AAED;;;;;;;;iBAkCC;AAED;;;;;;iBAcC;AAED;;;;;gBA4CC;AAED;;;;;;;;;;GAUG;AACH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAJW,gBAAgB,GACd,OAAO,MAAM,EAAE,MAAM,CAAC,CAoBlC;
|
|
1
|
+
{"version":3,"file":"entries.d.mts","sourceRoot":"","sources":["../../src/lib/entries.mjs"],"names":[],"mappings":"AAiCA,qDAMC;AAED;;;;GAYC;AAED;;;;;;iBAKC;AAED;;;;;;iBAeC;AAED;;;;;;;;iBAkCC;AAED;;;;;;iBAcC;AAED;;;;;gBA4CC;AAED;;;;;;;;;;GAUG;AACH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAJW,gBAAgB,GACd,OAAO,MAAM,EAAE,MAAM,CAAC,CAoBlC;AAED;;;;;;GAMG;AACH,uDAHa,MAAM,CAKlB;AACD;;;;;;GAMG;AACH,mDAHa,MAAM,CASlB;AAkBD;;;;;;GAMG;AACH,+EAGC;AAjGD;;;;;;;;;;GAUG;AACH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,uCAJW,gBAAgB,GACd,OAAO,MAAM,EAAE,MAAM,CAAC,CAoBlC;AAmCM,4DAAuE;AAEvE,sEAIH;;UAnFU,MAAM,GAAG,MAAM,EAAE;YACjB,MAAM;aACN,OAAO;UACP,OAAO;SACP,OAAO;UACP,MAAM;QACN,MAAM;;;UAKN,SAAS;YACT,MAAM;UACN,MAAM;UACN,OAAO,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,GAAG,OAAO"}
|
package/dist/lib/util.d.mts
CHANGED
|
@@ -2,4 +2,22 @@ export function fetcher(url: any, config?: {}, options?: {}): Promise<any>;
|
|
|
2
2
|
export function apiURL(route: any, env?: string, subdomain?: string): any;
|
|
3
3
|
export function query(params: any, sort?: boolean): any;
|
|
4
4
|
export function expect(obj: any): void;
|
|
5
|
+
export namespace apis {
|
|
6
|
+
namespace datamanager {
|
|
7
|
+
let live: string;
|
|
8
|
+
let stage: string;
|
|
9
|
+
}
|
|
10
|
+
namespace accounts {
|
|
11
|
+
let live_1: string;
|
|
12
|
+
export { live_1 as live };
|
|
13
|
+
let stage_1: string;
|
|
14
|
+
export { stage_1 as stage };
|
|
15
|
+
}
|
|
16
|
+
namespace appserver {
|
|
17
|
+
let live_2: string;
|
|
18
|
+
export { live_2 as live };
|
|
19
|
+
let stage_2: string;
|
|
20
|
+
export { stage_2 as stage };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
//# sourceMappingURL=util.d.mts.map
|