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