ec.fdk 0.4.5 → 0.4.6

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 CHANGED
@@ -1,7 +1,6 @@
1
1
  # ec.fdk
2
2
 
3
- Lightweight SDK for entrecode APIs.
4
- Currently supports only most common PublicAPI functions.
3
+ *F*eatherweight *D*evelopment *K*it for entrecode APIs.
5
4
 
6
5
  ## Install
7
6
 
@@ -9,22 +8,21 @@ Currently supports only most common PublicAPI functions.
9
8
  npm i ec.fdk
10
9
  ```
11
10
 
12
- ## Publish
11
+ ## Getting Started
13
12
 
14
- 0. `cd packages/ec.fdk`
15
- 1. bump version in `packages/ec.fdk/package.json`
16
- 2. run `pnpm readme`
17
- 3. commit + push
18
- 4. run `pnpm publish`
13
+ There are 2 ways to use ec.fdk:
14
+
15
+ - method chaining
16
+ - act
19
17
 
20
- ## API
18
+ ### Method Chaining
21
19
 
22
- Start by calling `sdk` with your environment (`stage` | `live`), then method chain your way to success:
20
+ Start by calling `fdk` with your environment (`stage` | `live`), then method chain your way to success:
23
21
 
24
22
  ```js
25
- import { sdk } from "ec.fdk";
23
+ import { fdk } from "ec.fdk";
26
24
 
27
- sdk("stage") // choose stage environment
25
+ fdk("stage") // choose stage environment
28
26
  .dm("83cc6374") // select datamanager via short id
29
27
  .model("muffin") // select model muffin
30
28
  .entries() // load entry list
@@ -37,7 +35,7 @@ You can also reuse parts of the chain with variables:
37
35
 
38
36
  ```js
39
37
  // we want to do stuff with model muffin here
40
- const muffin = sdk("stage").dm("83cc6374").model("muffin");
38
+ const muffin = fdk("stage").dm("83cc6374").model("muffin");
41
39
  // load entry list
42
40
  const { items } = await muffin.entries();
43
41
  // edit first entry
@@ -50,6 +48,65 @@ await muffin.createEntry({ name: "new muffin" });
50
48
  await muffin.editEntrySafe(items[2].id, { _modified: items[2]._modified, name: "safePut!" });
51
49
  ```
52
50
 
51
+ ### act
52
+
53
+ The act function converts a single object param into a fetch request:
54
+
55
+ ```js
56
+ const muffins = await act({
57
+ action: "entryList",
58
+ env: "stage",
59
+ dmShortID: "83cc6374",
60
+ model: "muffin",
61
+ })
62
+ ```
63
+
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
+ + 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.
67
+ For example, this is how the `entryList` function looks:
68
+
69
+ ```js
70
+ export async function entryList(config) {
71
+ let { env, dmShortID, model, options = {} } = config;
72
+ expect({ env, dmShortID, model });
73
+ /* more stuff */
74
+ }
75
+ ```
76
+
77
+ here you can clearly see the available params.
78
+
79
+ ### Using act with swr / react-query
80
+
81
+ The act function is good to be used with swr or react-query:
82
+
83
+ ```js
84
+ import { act } from "ec.fdk";
85
+ import useSWR from "swr";
86
+
87
+ export function useFdk(config) {
88
+ const key = config ? JSON.stringify(config) : null;
89
+ return useSWR([key], () => act(config));
90
+ }
91
+ ```
92
+
93
+ Then use the hook:
94
+
95
+ ```js
96
+ const config = {
97
+ env: "stage",
98
+ dmShortID: "83cc6374",
99
+ };
100
+
101
+ function App() {
102
+ const { data: entryList } = useFdk({
103
+ ...config,
104
+ action: "entryList",
105
+ model: "muffin",
106
+ });
107
+ /* more stuff */
108
+ }
109
+ ```
53
110
 
54
111
  ## migration from ec.sdk
55
112
 
@@ -117,12 +174,12 @@ const entryList = await api.entryList(model);
117
174
  const items = entryList.getAllItems();
118
175
  const first = entryList.getFirstItem();
119
176
  // ec.fdk
120
- const api = sdk(env).dm(shortID);
177
+ const api = fdk(env).dm(shortID);
121
178
  const entryList = await api.entryList(model);
122
179
  const items = entryList.items; // <------- change
123
180
  const first = entryList.items[0]; // <------- change
124
181
  // or in one line:
125
- const entryList = await sdk(env).dm(shortID).entryList(model);
182
+ const entryList = await fdk(env).dm(shortID).entryList(model);
126
183
  ```
127
184
 
128
185
  ### Entry List Filter Options
@@ -130,7 +187,7 @@ const entryList = await sdk(env).dm(shortID).entryList(model);
130
187
  By default, the second param of ec.fdk `entryList` will just convert the object to url params:
131
188
 
132
189
  ```js
133
- const entryList = await sdk("stage")
190
+ const entryList = await fdk("stage")
134
191
  .dm("83cc6374")
135
192
  .entryList({ createdTo: "2021-01-18T09:13:47.605Z" });
136
193
  /*
@@ -147,16 +204,23 @@ Read more in the [entrecode filtering doc](https://doc.entrecode.de/api-basics/#
147
204
  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
205
 
149
206
  ```js
150
- const entryList = await sdk("stage")
207
+ const entryList = await fdk("stage")
151
208
  .dm("83cc6374")
152
209
  .entryList(filterOptions({ created: { to: "2021-01-18T09:13:47.605Z" } }));
153
210
  ```
154
211
 
212
+ ## Publish
155
213
 
156
- Now what follows is the autogenerated doc from source:
214
+ 0. `cd packages/ec.fdk`
215
+ 1. bump version in `packages/ec.fdk/package.json`
216
+ 2. run `pnpm readme`
217
+ 3. commit + push
218
+ 4. run `pnpm publish`
157
219
 
158
220
  ## API Reference
159
221
 
222
+ Now what follows is the autogenerated doc from source:
223
+
160
224
  {{#module name="api"}}
161
225
  {{>members}}
162
226
  {{/module}}
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # ec.fdk
2
2
 
3
- Lightweight SDK for entrecode APIs.
4
- Currently supports only most common PublicAPI functions.
3
+ *F*eatherweight *D*evelopment *K*it for entrecode APIs.
5
4
 
6
5
  ## Install
7
6
 
@@ -9,22 +8,21 @@ Currently supports only most common PublicAPI functions.
9
8
  npm i ec.fdk
10
9
  ```
11
10
 
12
- ## Publish
11
+ ## Getting Started
13
12
 
14
- 0. `cd packages/ec.fdk`
15
- 1. bump version in `packages/ec.fdk/package.json`
16
- 2. run `pnpm readme`
17
- 3. commit + push
18
- 4. run `pnpm publish`
13
+ There are 2 ways to use ec.fdk:
14
+
15
+ - method chaining
16
+ - act
19
17
 
20
- ## API
18
+ ### Method Chaining
21
19
 
22
- Start by calling `sdk` with your environment (`stage` | `live`), then method chain your way to success:
20
+ Start by calling `fdk` with your environment (`stage` | `live`), then method chain your way to success:
23
21
 
24
22
  ```js
25
- import { sdk } from "ec.fdk";
23
+ import { fdk } from "ec.fdk";
26
24
 
27
- sdk("stage") // choose stage environment
25
+ fdk("stage") // choose stage environment
28
26
  .dm("83cc6374") // select datamanager via short id
29
27
  .model("muffin") // select model muffin
30
28
  .entries() // load entry list
@@ -37,7 +35,7 @@ You can also reuse parts of the chain with variables:
37
35
 
38
36
  ```js
39
37
  // we want to do stuff with model muffin here
40
- const muffin = sdk("stage").dm("83cc6374").model("muffin");
38
+ const muffin = fdk("stage").dm("83cc6374").model("muffin");
41
39
  // load entry list
42
40
  const { items } = await muffin.entries();
43
41
  // edit first entry
@@ -50,6 +48,65 @@ await muffin.createEntry({ name: "new muffin" });
50
48
  await muffin.editEntrySafe(items[2].id, { _modified: items[2]._modified, name: "safePut!" });
51
49
  ```
52
50
 
51
+ ### act
52
+
53
+ The act function converts a single object param into a fetch request:
54
+
55
+ ```js
56
+ const muffins = await act({
57
+ action: "entryList",
58
+ env: "stage",
59
+ dmShortID: "83cc6374",
60
+ model: "muffin",
61
+ })
62
+ ```
63
+
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
+ + 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.
67
+ For example, this is how the `entryList` function looks:
68
+
69
+ ```js
70
+ export async function entryList(config) {
71
+ let { env, dmShortID, model, options = {} } = config;
72
+ expect({ env, dmShortID, model });
73
+ /* more stuff */
74
+ }
75
+ ```
76
+
77
+ here you can clearly see the available params.
78
+
79
+ ### Using act with swr / react-query
80
+
81
+ The act function is good to be used with swr or react-query:
82
+
83
+ ```js
84
+ import { act } from "ec.fdk";
85
+ import useSWR from "swr";
86
+
87
+ export function useFdk(config) {
88
+ const key = config ? JSON.stringify(config) : null;
89
+ return useSWR([key], () => act(config));
90
+ }
91
+ ```
92
+
93
+ Then use the hook:
94
+
95
+ ```js
96
+ const config = {
97
+ env: "stage",
98
+ dmShortID: "83cc6374",
99
+ };
100
+
101
+ function App() {
102
+ const { data: entryList } = useFdk({
103
+ ...config,
104
+ action: "entryList",
105
+ model: "muffin",
106
+ });
107
+ /* more stuff */
108
+ }
109
+ ```
53
110
 
54
111
  ## migration from ec.sdk
55
112
 
@@ -117,12 +174,12 @@ const entryList = await api.entryList(model);
117
174
  const items = entryList.getAllItems();
118
175
  const first = entryList.getFirstItem();
119
176
  // ec.fdk
120
- const api = sdk(env).dm(shortID);
177
+ const api = fdk(env).dm(shortID);
121
178
  const entryList = await api.entryList(model);
122
179
  const items = entryList.items; // <------- change
123
180
  const first = entryList.items[0]; // <------- change
124
181
  // or in one line:
125
- const entryList = await sdk(env).dm(shortID).entryList(model);
182
+ const entryList = await fdk(env).dm(shortID).entryList(model);
126
183
  ```
127
184
 
128
185
  ### Entry List Filter Options
@@ -130,7 +187,7 @@ const entryList = await sdk(env).dm(shortID).entryList(model);
130
187
  By default, the second param of ec.fdk `entryList` will just convert the object to url params:
131
188
 
132
189
  ```js
133
- const entryList = await sdk("stage")
190
+ const entryList = await fdk("stage")
134
191
  .dm("83cc6374")
135
192
  .entryList({ createdTo: "2021-01-18T09:13:47.605Z" });
136
193
  /*
@@ -147,16 +204,23 @@ Read more in the [entrecode filtering doc](https://doc.entrecode.de/api-basics/#
147
204
  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
205
 
149
206
  ```js
150
- const entryList = await sdk("stage")
207
+ const entryList = await fdk("stage")
151
208
  .dm("83cc6374")
152
209
  .entryList(filterOptions({ created: { to: "2021-01-18T09:13:47.605Z" } }));
153
210
  ```
154
211
 
212
+ ## Publish
155
213
 
156
- Now what follows is the autogenerated doc from source:
214
+ 0. `cd packages/ec.fdk`
215
+ 1. bump version in `packages/ec.fdk/package.json`
216
+ 2. run `pnpm readme`
217
+ 3. commit + push
218
+ 4. run `pnpm publish`
157
219
 
158
220
  ## API Reference
159
221
 
222
+ Now what follows is the autogenerated doc from source:
223
+
160
224
  <a name="module_api.Sdk"></a>
161
225
 
162
226
  ### api.Sdk
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
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}
1
+ "use strict";var gt=Object.defineProperty,ft=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var C=(n,t,e)=>t in n?gt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,o=(n,t)=>{for(var e in t||(t={}))pt.call(t,e)&&C(n,e,t[e]);if(x)for(var e of x(t))mt.call(t,e)&&C(n,e,t[e]);return n},f=(n,t)=>ft(n,yt(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 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;
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 $t=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function M(n){let t={};for(let e in n)$t.includes(e)||(t[e]=n[e]);return t}function wt(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=wt(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),ht=m.title.split("<")[0];m.type=ht,_.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 A(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=A(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=A(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 k=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:A,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:Et,getEntry:bt,getAsset:kt,assetList:At,createAsset:Tt,deleteAsset:_t,createEntry:Ot,editEntry:K,deleteEntry:jt,getSchema:Pt,loginPublic:Lt,loginEc:St,logoutEc:Bt,logoutPublic:Dt,getEcAuthKey:O,getPublicAuthKey:j,dmList:qt,modelList:vt,publicApi:xt,getDatamanager:Ct,resourceList:Kt,raw:Nt}=k;function zt(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 Et(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 bt(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 Pt(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 Tt(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 _t(f(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return a(this,null,function*(){const e=yield this.getBestToken();return kt(f(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return a(this,null,function*(){const e=yield this.getBestToken();return Ot(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 jt(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)})}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 St(o(o({},this.config),t)).then(this.setAuth(O(this.config)))}loginPublic(t){return Lt(o(o({},this.config),t)).then(this.setAuth(j(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Dt(f(o({},this.config),{token:t})).then(this.unsetAuth(j(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),Bt(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 xt(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 qt(f(o({},this.config),{options:t,token:e}))})}modelList(){return a(this,arguments,function*(t={}){const e=yield this.getBestToken();return vt(f(o({},this.config),{options:t,token:e}))})}}const dt=n=>new T({env:n}),Ft=dt;exports.Sdk=T;exports.act=zt;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.fdk=Ft;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=A;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=dt;exports.sdkOptions=S;
package/dist/index.mjs CHANGED
@@ -479,7 +479,7 @@ const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
479
479
  resourceList: Ct,
480
480
  raw: Kt
481
481
  } = A;
482
- function zt(n) {
482
+ function Ft(n) {
483
483
  const { action: t } = n;
484
484
  if (h({ action: t }), !A[t])
485
485
  throw new Error(
@@ -923,10 +923,10 @@ class j {
923
923
  });
924
924
  }
925
925
  }
926
- const Ft = (n) => new j({ env: n });
926
+ const Nt = (n) => new j({ env: n }), Jt = Nt;
927
927
  export {
928
928
  j as Sdk,
929
- zt as act,
929
+ Ft as act,
930
930
  y as apiURL,
931
931
  b as apis,
932
932
  dt as assetList,
@@ -940,6 +940,7 @@ export {
940
940
  ct as editEntryObject,
941
941
  nt as entryList,
942
942
  h as expect,
943
+ Jt as fdk,
943
944
  f as fetcher,
944
945
  ot as filterOptions,
945
946
  lt as getAsset,
@@ -960,6 +961,6 @@ export {
960
961
  w as query,
961
962
  $t as raw,
962
963
  mt as resourceList,
963
- Ft as sdk,
964
+ Nt as sdk,
964
965
  N as sdkOptions
965
966
  };
@@ -274,6 +274,7 @@ export class Sdk {
274
274
  modelList(options?: object | undefined): Promise<ModelList>;
275
275
  }
276
276
  export function sdk(env: any): Sdk;
277
+ export function fdk(env: any): Sdk;
277
278
  export type AssetFile = {
278
279
  url: string;
279
280
  size: number;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAgCA,sCAWC;;AAED;;GAEG;AACH;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;;;;;OAaG;IACH,uBATW,MAAM,SACN,MAAM,GACJ,QAAQ,aAAa,CAAC,CAUlC;IACD;;;;;;;OAOG;IACH,aAJa,QAAQ,WAAW,CAAC,CAMhC;IACD;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sCAjBW;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAClD,QAAQ,aAAa,CAAC,CAmBlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAOzB;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IAED;;;;;;;;OAQG;IACH,mBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;OASG;IACH,mBANW,MAAM,SACN,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;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;;;sBACN,MAAM;;;;eACN,IAAI;;;;aACJ,IAAI;;;;cACJ,IAAI;;;;UACJ,GAAG;;;;;;aAOH,GAAG;;;;iBACH,MAAM;;;;cACN,OAAO;;;;cACP,OAAO;;;;UACP,MAAM;;;;cACN,MAAM;;;QAIC,MAAM,GAAE,gBAAgB;;;WAK/B,MAAM;WACN,MAAM;WACN,aAAa,EAAE;;;aAKf,MAAM;mBACN,MAAM;mBACN,MAAM;iBACN,MAAM;YACN,GAAG;cACH,MAAM;aACN,MAAM,EAAE;YACR,MAAM,EAAE;uBACR,MAAM,EAAE;aACR,MAAM;WACN,MAAM;;;;YACN,GAAG;;;WAKH,MAAM;WACN,MAAM;WACN,mBAAmB,EAAE;;;WAKrB,MAAM;WACN,MAAM;WACN,aAAa,EAAE;;;WAKf,MAAM;WACN,MAAM;WACN,GAAG,EAAE;;;;;;aAML,GAAG;iBACH,MAAM;iBACN,OAAO;aACP,OAAO;cACP,OAAO;cACP,OAAO;YACP,OAAO;WACP,MAAM;UACN,MAAM;gBACN,MAAM,GAAG,IAAI;;;YAKb,GAAG;aACH,MAAM;iBACN,MAAM;YACN,gBAAgB,EAAE;gBAClB,OAAO;cACP,MAAM;WACN,GAAG,EAAE;eACL,GAAG,EAAE;aACL,MAAM,EAAE;aACR,MAAM;cACN,MAAM;cACN,GAAG,EAAE;UACL,GAAG;WACH,MAAM;gBACN,MAAM;YACN,GAAG;;;WAMH,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
1
+ {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAgCA,sCAWC;;AAED;;GAEG;AACH;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;;;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;;;;;;aAML,GAAG;iBACH,MAAM;iBACN,OAAO;aACP,OAAO;cACP,OAAO;cACP,OAAO;YACP,OAAO;WACP,MAAM;UACN,MAAM;gBACN,MAAM,GAAG,IAAI;;;YAKb,GAAG;aACH,MAAM;iBACN,MAAM;YACN,gBAAgB,EAAE;gBAClB,OAAO;cACP,MAAM;WACN,GAAG,EAAE;eACL,GAAG,EAAE;aACL,MAAM,EAAE;aACR,MAAM;cACN,MAAM;cACN,GAAG,EAAE;UACL,GAAG;WACH,MAAM;gBACN,MAAM;YACN,GAAG;;;WAMH,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {