ec.fdk 0.4.1 → 0.4.2

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 CHANGED
@@ -493,3 +493,18 @@ const dms = await sdk("stage").dmList()
493
493
  ```js
494
494
  const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
495
495
  ```
496
+ <a name="module_api.sdkOptions"></a>
497
+
498
+ ### api.sdkOptions(options) ⇒ <code>Promise.&lt;any&gt;</code>
499
+ <p>Takes <a href="https://entrecode.github.io/ec.sdk/#filteroptions">ec.sdk filterOptions</a>, outputs an <a href="https://doc.entrecode.de/api-basics/#filtering">entrecode filter</a></p>
500
+
501
+ **Kind**: static method of [<code>api</code>](#module_api)
502
+
503
+ | Param | Type | Description |
504
+ | --- | --- | --- |
505
+ | options | <code>SdkFilterOptions</code> | <p>sdk filterOptions</p> |
506
+
507
+ **Example**
508
+ ```js
509
+ const res = await sdk("stage").route("stats").raw()
510
+ ```
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
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;
1
+ "use strict";var rt=Object.defineProperty,it=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ct=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var S=(n,t,e)=>t in n?rt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,o=(n,t)=>{for(var e in t||(t={}))ct.call(t,e)&&S(n,e,t[e]);if(j)for(var e of j(t))at.call(t,e)&&S(n,e,t[e]);return n},y=(n,t)=>it(n,ot(t));var c=(n,t,e)=>new Promise((s,r)=>{var l=a=>{try{d(e.next(a))}catch(u){r(u)}},i=a=>{try{d(e.throw(a))}catch(u){r(u)}},d=a=>a.done?s(a.value):Promise.resolve(a.value).then(l,i);d((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return c(this,arguments,function*(n,t={},e={}){var d;const{token:r,rawRes:l}=t;r&&(e.headers=y(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 a=yield i.json(),u=`${a.title}
2
+ ${a.detail}
3
+ ${a.verbose}`;throw new Error(u)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return l?i:yield i.json()})}const B={datamanager:{live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"},accounts:{live:"https://accounts.entrecode.de/",stage:"https://accounts.cachena.entrecode.de/"},appserver:{live:"https://appserver.entrecode.de/",stage:"https://appserver.cachena.entrecode.de/"}};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 c(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;h({env:t,dmShortID:e,email:s,password:r});const l=p(`api/${e}/_auth/login?clientID=rest`,t);return yield g(l,{},{method:"POST",body:JSON.stringify({email:s,password:r}),headers:{"Content-Type":"application/json"}})})}function K(n){return c(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 N(n){return c(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 z(n){return c(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 C({dmShortID:n}){return h({dmShortID:n}),n}function F({env:n}){return h({env:n}),n}let ut=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function J(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 R(n){return c(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 v(n){return c(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;h({env:t,dmShortID:e,model:s}),r=o({size:50,page:1,_list:!0},r);const l=w(r),i=p(`api/${e}/${s}?${l}`,t),{count:d,total:a,_embedded:u}=yield g(i,n);let f=u?u[`${e}:${s}`]:[];return f=Array.isArray(f)?f:[f],{count:d,total:a,items:f}})}function U({env:n,dmShortID:t,model:e,entryID:s,token:r}){h({env:n,dmShortID:t,model:e,entryID:s});const l=w({_id:s}),i=p(`api/${t}/${e}?${l}`,n);return g(i,{dmShortID:t,token:r})}function M(l){return c(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 c(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:l,safePut:i=!1}){h({env:n,dmShortID:t,model:e,entryID:s,value:r});const a={"Content-Type":"application/json"};if(i){if(!("_modified"in r))throw new Error("expected _modified to be set!");a["If-Unmodified-Since"]=new Date(r._modified).toUTCString()}const u=p(`api/${t}/${e}?_id=${s}`,n);return r=lt(r),r=J(r),yield g(u,{token:l},{method:"PUT",headers:a,body:JSON.stringify(r)})})}function V(l){return c(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 c(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var f,$,P,O,L;h({env:n,dmShortID:t,model:e});const l=p(`api/schema/${t}/${e}`,n),i=yield g(l),d=(f=i==null?void 0:i.allOf)==null?void 0:f[1];if(typeof d.properties!="object")throw new Error(`getSchema: ${l} returned unexpected format: ${JSON.stringify(i)}`);const{properties:a}=d,u=J(a);for(let A in u){let m=u[A];if(m.required=d.required.includes(A),($=u[A])!=null&&$.oneOf&&((P=u[A])==null||delete P.oneOf),(O=m.title)!=null&&O.includes("<")&&((L=m.title)!=null&&L.includes(">"))){const E=m.title.split("<")[1].slice(0,-1),st=m.title.split("<")[0];m.type=st,E.includes(":")?m.resource=E.split(":")[1]:m.resource=E}else["asset","entry","assets","entries"].includes(m.title)?(m.type=m.title,m.resource=null):m.type=m.title;delete u[A].title}if(s){const A=a._modelTitle.title,m=a._modelTitleField.title;return{properties:u,meta:{modelTitleField:m,modelTitle:A}}}return u})}function H(l){return c(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 c(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:l={}}=n;h({env:t,dmShortID:e,assetGroup:s}),l=o({size:50,page:1,_list:!0},l);const i=w(l),d=p(`a/${e}/${s}?${i}`,t),{count:a,total:u,_embedded:f}=yield g(d,{dmShortID:e,token:r});let $=f?f["ec:dm-asset"]:[];return $=Array.isArray($)?$:[$],{count:a,total:u,items:$}})}function W(d){return c(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:l,options:i}){h({env:n,dmShortID:t,assetGroup:e,file:r});const a=p(`a/${t}/${e}`,n),u=new FormData;return u.append("file",r,l),i&&Object.keys(i).forEach($=>{u.append($,i[$])}),(yield g(a,{token:s},{method:"POST",body:u}))._embedded["ec:dm-asset"]})}function X(l){return c(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 c(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 c(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:l,total:i,_embedded:d}=yield g(r,n);let a=d?d["ec:datamanager"]:[];return a=Array.isArray(a)?a:[a],{count:l,total:i,items:a}})}function tt(n){return c(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),l=p(`model?${r}`,t),{count:i,total:d,_embedded:a}=yield g(l,n);let u=a?a["ec:model"]:[];return u=Array.isArray(u)?u:[u],{count:i,total:d,items:u}})}function et(n){return c(this,null,function*(){let{env:t,resource:e,options:s={},subdomain:r="datamanager"}=n;h({env:t,subdomain:r,resource:e}),s=o({size:25,page:1,_list:!0},s);const l=w(s),i=p(`${e}?${l}`,t,r),{count:d,total:a,_embedded:u}=yield g(i,n);let f=u?u[Object.keys(u)[0]]:[];return f=Array.isArray(f)?f:[f],{count:d,total:a,items:f}})}function nt(e){return c(this,arguments,function*(n,t={}){let{env:s,route:r,options:l={},subdomain:i="datamanager"}=n;h({env:s,subdomain:i,route:r}),l=o({},l);const d=w(l),a=p(`${r}?${d}`,s,i);return g(a,n,t)})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:Q,createAsset:W,createEntry:M,deleteAsset:X,deleteEntry:V,dmList:Z,editEntry:I,entryList:v,getAsset:H,getDatamanager:Y,getEcAuthKey:F,getEntry:U,getPublicAuthKey:C,getSchema:G,loginEc:K,loginPublic:x,logoutEc:z,logoutPublic:N,modelList:tt,publicApi:R,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:At,loginEc:kt,logoutEc:bt,logoutPublic:Et,getEcAuthKey:T,getPublicAuthKey:_,dmList:Tt,modelList:_t,publicApi:Pt,getDatamanager:Ot,resourceList:Lt,raw:jt}=k;function St(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 b{constructor(t){this.config=t}set(t){return new b(o(o({},this.config),t))}entries(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return dt(y(o({},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 ht(y(o({},this.config),{entryID:t,token:e}))})}editEntrySafe(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return q(y(o({},this.config),{entryID:t,token:s,value:e,safePut:!0}))})}getSchema(){return c(this,null,function*(){return wt(this.config)})}assets(t){return c(this,null,function*(){const e=yield this.getBestToken();return ft(y(o({},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 yt(y(o({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return pt(y(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return gt(y(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return mt(y(o({},this.config),{token:e,value:t}))})}editEntry(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return q(y(o({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return $t(y(o({},this.config),{token:e,entryID:t}))})}resourceList(t){return c(this,null,function*(){const e=yield this.getBestToken();return Lt(y(o({},this.config),{options:t,token:e}))})}raw(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return jt(y(o({},this.config),{options:t,token:s}),e)})}authAdapter(t){return this.set({authAdapter:t})}setAuth(t){return e=>{if(!this.config.authAdapter)throw new Error("cannot setAuth: no authAdapter defined!");const{set:s}=this.config.authAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(console.log("unset auth",e),!this.config.authAdapter)throw new Error("cannot unsetAuth: no authAdapter defined!");const{remove:s}=this.config.authAdapter;return s(t),e}}getAuth(t){if(!this.config.authAdapter)throw new Error("cannot getAuth: no authAdapter defined!");const{get:e}=this.config.authAdapter;return e(t)}loginEc(t){return kt(o(o({},this.config),t)).then(this.setAuth(T(this.config)))}loginPublic(t){return At(o(o({},this.config),t)).then(this.setAuth(_(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Et(y(o({},this.config),{token:t})).then(this.unsetAuth(_(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),bt(y(o({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}getPublicToken(){return this.config.token||this.getAuth(_(this.config))}getEcToken(){return this.config.token||this.getAuth(T(this.config))}hasPublicToken(){return!!this.getPublicToken()}hasEcToken(){return!!this.getEcToken()}hasAnyToken(){return!!this.getEcToken()||!!this.getPublicToken()}getBestToken(){try{return this.getEcToken()||this.getPublicToken()}catch(t){return}}model(t){return this.set({model:t})}token(t){return this.set({token:t})}dmShortID(t){return this.set({dmShortID:t})}dmID(t){return this.set({dmID:t})}dm(t){return this.dmShortID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}subdomain(t){return this.set({subdomain:t})}resource(t){return this.set({resource:t})}route(t){return this.set({route:t})}publicApi(){return Pt(this.config)}getDatamanager(t){return c(this,null,function*(){const e=yield this.getBestToken();return Ot(y(o({},this.config),{dmID:t,token:e}))})}dmList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return Tt(y(o({},this.config),{options:t,token:e}))})}modelList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return _t(y(o({},this.config),{options:t,token:e}))})}}const Bt=n=>new b({env:n});function qt(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),{})}exports.Sdk=b;exports.act=St;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=v;exports.expect=h;exports.fetcher=g;exports.getAsset=H;exports.getDatamanager=Y;exports.getEcAuthKey=F;exports.getEntry=U;exports.getPublicAuthKey=C;exports.getSchema=G;exports.loginEc=K;exports.loginPublic=x;exports.logoutEc=z;exports.logoutPublic=N;exports.modelList=tt;exports.publicApi=R;exports.query=w;exports.raw=nt;exports.resourceList=et;exports.sdk=Bt;exports.sdkOptions=qt;
package/dist/index.mjs CHANGED
@@ -1,49 +1,49 @@
1
- var z = Object.defineProperty, C = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
1
+ var N = Object.defineProperty, z = Object.defineProperties;
2
+ var C = Object.getOwnPropertyDescriptors;
3
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) => {
4
+ var F = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable;
5
+ var S = (n, t, e) => t in n ? N(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, o = (n, t) => {
6
6
  for (var e in t || (t = {}))
7
- N.call(t, e) && S(n, e, t[e]);
7
+ F.call(t, e) && S(n, e, t[e]);
8
8
  if (j)
9
9
  for (var e of j(t))
10
- F.call(t, e) && S(n, e, t[e]);
10
+ J.call(t, e) && S(n, e, t[e]);
11
11
  return n;
12
- }, y = (n, t) => C(n, J(t));
13
- var o = (n, t, e) => new Promise((s, r) => {
14
- var u = (a) => {
12
+ }, y = (n, t) => z(n, C(t));
13
+ var a = (n, t, e) => new Promise((s, r) => {
14
+ var l = (c) => {
15
15
  try {
16
- d(e.next(a));
17
- } catch (c) {
18
- r(c);
16
+ d(e.next(c));
17
+ } catch (u) {
18
+ r(u);
19
19
  }
20
- }, i = (a) => {
20
+ }, i = (c) => {
21
21
  try {
22
- d(e.throw(a));
23
- } catch (c) {
24
- r(c);
22
+ d(e.throw(c));
23
+ } catch (u) {
24
+ r(u);
25
25
  }
26
- }, d = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(u, i);
26
+ }, d = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(l, i);
27
27
  d((e = e.apply(n, t)).next());
28
28
  });
29
29
  function g(s) {
30
- return o(this, arguments, function* (n, t = {}, e = {}) {
30
+ return a(this, arguments, function* (n, t = {}, e = {}) {
31
31
  var d;
32
- const { token: r, rawRes: u } = t;
33
- r && (e.headers = y(l({}, e.headers || {}), {
32
+ const { token: r, rawRes: l } = t;
33
+ r && (e.headers = y(o({}, e.headers || {}), {
34
34
  Authorization: `Bearer ${r}`
35
35
  }));
36
36
  const i = yield fetch(n, e);
37
37
  if (!i.ok) {
38
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);
39
+ const c = yield i.json(), u = `${c.title}
40
+ ${c.detail}
41
+ ${c.verbose}`;
42
+ throw new Error(u);
43
43
  }
44
44
  throw new Error(`unexpected fetch error: ${i.statusText}`);
45
45
  }
46
- return u ? i : yield i.json();
46
+ return l ? i : yield i.json();
47
47
  });
48
48
  }
49
49
  const B = {
@@ -64,7 +64,9 @@ function p(n, t = "stage", e = "datamanager") {
64
64
  const s = B[e];
65
65
  if (!s)
66
66
  throw new Error(
67
- `subdomain "${e}" not found. Try one of ${Object.keys(B).join(", ")}`
67
+ `subdomain "${e}" not found. Try one of ${Object.keys(B).join(
68
+ ", "
69
+ )}`
68
70
  );
69
71
  const r = s[t];
70
72
  if (!r)
@@ -87,12 +89,12 @@ const D = {
87
89
  live: "https://accounts.entrecode.de/"
88
90
  };
89
91
  function R(n) {
90
- return o(this, null, function* () {
92
+ return a(this, null, function* () {
91
93
  let { env: t, dmShortID: e, email: s, password: r } = n;
92
94
  h({ env: t, dmShortID: e, email: s, password: r });
93
- const u = p(`api/${e}/_auth/login?clientID=rest`, t);
95
+ const l = p(`api/${e}/_auth/login?clientID=rest`, t);
94
96
  return yield g(
95
- u,
97
+ l,
96
98
  {},
97
99
  {
98
100
  method: "POST",
@@ -105,7 +107,7 @@ function R(n) {
105
107
  });
106
108
  }
107
109
  function v(n) {
108
- return o(this, null, function* () {
110
+ return a(this, null, function* () {
109
111
  let { env: t, email: e, password: s } = n;
110
112
  h({ env: t, email: e, password: s });
111
113
  const r = `${D[t]}auth/login?clientID=rest`;
@@ -123,7 +125,7 @@ function v(n) {
123
125
  });
124
126
  }
125
127
  function U(n) {
126
- return o(this, null, function* () {
128
+ return a(this, null, function* () {
127
129
  let { dmShortID: t, env: e, token: s } = n;
128
130
  h({ dmShortID: t, env: e, token: s });
129
131
  const r = p(
@@ -140,7 +142,7 @@ function U(n) {
140
142
  });
141
143
  }
142
144
  function M(n) {
143
- return o(this, null, function* () {
145
+ return a(this, null, function* () {
144
146
  let { env: t, token: e } = n;
145
147
  h({ env: t, token: e });
146
148
  const s = `${D[t]}auth/logout?clientID=rest`;
@@ -188,7 +190,7 @@ function H(n) {
188
190
  return JSON.parse(JSON.stringify(n));
189
191
  }
190
192
  function Q(n) {
191
- return o(this, null, function* () {
193
+ return a(this, null, function* () {
192
194
  let { env: t, dmShortID: e } = n;
193
195
  h({ env: t, dmShortID: e });
194
196
  const s = p(`api/${e}`, t);
@@ -196,21 +198,21 @@ function Q(n) {
196
198
  });
197
199
  }
198
200
  function W(n) {
199
- return o(this, null, function* () {
201
+ return a(this, null, function* () {
200
202
  let { env: t, dmShortID: e, model: s, options: r = {} } = n;
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 };
203
+ h({ env: t, dmShortID: e, model: s }), r = o({ size: 50, page: 1, _list: !0 }, r);
204
+ const l = w(r), i = p(`api/${e}/${s}?${l}`, t), { count: d, total: c, _embedded: u } = yield g(i, n);
205
+ let f = u ? u[`${e}:${s}`] : [];
206
+ return f = Array.isArray(f) ? f : [f], { count: d, total: c, items: f };
205
207
  });
206
208
  }
207
209
  function X({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
208
210
  h({ env: n, dmShortID: t, model: e, entryID: s });
209
- const u = w({ _id: s }), i = p(`api/${t}/${e}?${u}`, n);
211
+ const l = w({ _id: s }), i = p(`api/${t}/${e}?${l}`, n);
210
212
  return g(i, { dmShortID: t, token: r });
211
213
  }
212
- function Y(u) {
213
- return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
214
+ function Y(l) {
215
+ return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
214
216
  h({ env: n, dmShortID: t, model: e, value: s });
215
217
  const i = p(`api/${t}/${e}`, n);
216
218
  return yield g(
@@ -227,38 +229,38 @@ function Y(u) {
227
229
  });
228
230
  }
229
231
  function Z(d) {
230
- return o(this, arguments, function* ({
232
+ return a(this, arguments, function* ({
231
233
  env: n,
232
234
  dmShortID: t,
233
235
  model: e,
234
236
  entryID: s,
235
237
  value: r,
236
- token: u,
238
+ token: l,
237
239
  safePut: i = !1
238
240
  }) {
239
241
  h({ env: n, dmShortID: t, model: e, entryID: s, value: r });
240
- const a = {
242
+ const c = {
241
243
  "Content-Type": "application/json"
242
244
  };
243
245
  if (i) {
244
246
  if (!("_modified" in r))
245
247
  throw new Error("expected _modified to be set!");
246
- a["If-Unmodified-Since"] = new Date(r._modified).toUTCString();
248
+ c["If-Unmodified-Since"] = new Date(r._modified).toUTCString();
247
249
  }
248
- const c = p(`api/${t}/${e}?_id=${s}`, n);
250
+ const u = p(`api/${t}/${e}?_id=${s}`, n);
249
251
  return r = H(r), r = x(r), yield g(
250
- c,
251
- { token: u },
252
+ u,
253
+ { token: l },
252
254
  {
253
255
  method: "PUT",
254
- headers: a,
256
+ headers: c,
255
257
  body: JSON.stringify(r)
256
258
  }
257
259
  );
258
260
  });
259
261
  }
260
- function tt(u) {
261
- return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
262
+ function tt(l) {
263
+ return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
262
264
  h({ env: n, dmShortID: t, model: e, entryID: s });
263
265
  const i = p(`api/${t}/${e}?_id=${s}`, n);
264
266
  yield g(
@@ -274,73 +276,73 @@ function tt(u) {
274
276
  });
275
277
  }
276
278
  function et(r) {
277
- return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
279
+ return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
278
280
  var f, $, P, L, O;
279
281
  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];
282
+ const l = p(`api/schema/${t}/${e}`, n), i = yield g(l), d = (f = i == null ? void 0 : i.allOf) == null ? void 0 : f[1];
281
283
  if (typeof d.properties != "object")
282
284
  throw new Error(
283
- `getSchema: ${u} returned unexpected format: ${JSON.stringify(i)}`
285
+ `getSchema: ${l} returned unexpected format: ${JSON.stringify(i)}`
284
286
  );
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;
287
+ const { properties: c } = d, u = x(c);
288
+ for (let A in u) {
289
+ let m = u[A];
290
+ if (m.required = d.required.includes(A), ($ = u[A]) != null && $.oneOf && ((P = u[A]) == null || delete P.oneOf), (L = m.title) != null && L.includes("<") && ((O = m.title) != null && O.includes(">"))) {
291
+ const k = m.title.split("<")[1].slice(0, -1), K = m.title.split("<")[0];
292
+ m.type = K, k.includes(":") ? m.resource = k.split(":")[1] : m.resource = k;
291
293
  } else
292
294
  ["asset", "entry", "assets", "entries"].includes(m.title) ? (m.type = m.title, m.resource = null) : m.type = m.title;
293
- delete c[k].title;
295
+ delete u[A].title;
294
296
  }
295
297
  if (s) {
296
- const k = a._modelTitle.title, m = a._modelTitleField.title;
297
- return { properties: c, meta: { modelTitleField: m, modelTitle: k } };
298
+ const A = c._modelTitle.title, m = c._modelTitleField.title;
299
+ return { properties: u, meta: { modelTitleField: m, modelTitle: A } };
298
300
  }
299
- return c;
301
+ return u;
300
302
  });
301
303
  }
302
- function nt(u) {
303
- return o(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
304
+ function nt(l) {
305
+ return a(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
304
306
  h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
305
307
  const i = w({ assetID: s }), d = p(`a/${t}/${e}?${i}`, n);
306
308
  return (yield g(d, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
307
309
  });
308
310
  }
309
311
  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 });
312
+ return a(this, null, function* () {
313
+ let { env: t, dmShortID: e, assetGroup: s, token: r, options: l = {} } = n;
314
+ h({ env: t, dmShortID: e, assetGroup: s }), l = o({ size: 50, page: 1, _list: !0 }, l);
315
+ const i = w(l), d = p(`a/${e}/${s}?${i}`, t), { count: c, total: u, _embedded: f } = yield g(d, { dmShortID: e, token: r });
314
316
  let $ = f ? f["ec:dm-asset"] : [];
315
- return $ = Array.isArray($) ? $ : [$], { count: a, total: c, items: $ };
317
+ return $ = Array.isArray($) ? $ : [$], { count: c, total: u, items: $ };
316
318
  });
317
319
  }
318
320
  function rt(d) {
319
- return o(this, arguments, function* ({
321
+ return a(this, arguments, function* ({
320
322
  env: n,
321
323
  dmShortID: t,
322
324
  assetGroup: e,
323
325
  token: s,
324
326
  file: r,
325
- name: u,
327
+ name: l,
326
328
  options: i
327
329
  }) {
328
330
  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[$]);
331
+ const c = p(`a/${t}/${e}`, n), u = new FormData();
332
+ return u.append("file", r, l), i && Object.keys(i).forEach(($) => {
333
+ u.append($, i[$]);
332
334
  }), (yield g(
333
- a,
335
+ c,
334
336
  { token: s },
335
337
  {
336
338
  method: "POST",
337
- body: c
339
+ body: u
338
340
  }
339
341
  ))._embedded["ec:dm-asset"];
340
342
  });
341
343
  }
342
- function it(u) {
343
- return o(this, arguments, function* ({
344
+ function it(l) {
345
+ return a(this, arguments, function* ({
344
346
  env: n,
345
347
  dmShortID: t,
346
348
  assetGroup: e,
@@ -359,7 +361,7 @@ function it(u) {
359
361
  });
360
362
  }
361
363
  function ot(n) {
362
- return o(this, null, function* () {
364
+ return a(this, null, function* () {
363
365
  let { env: t, dmID: e, token: s } = n;
364
366
  h({ env: t, dmID: e });
365
367
  const r = p(`?dataManagerID=${e}`, t);
@@ -367,41 +369,41 @@ function ot(n) {
367
369
  });
368
370
  }
369
371
  function at(n) {
370
- return o(this, null, function* () {
372
+ return a(this, null, function* () {
371
373
  let { env: t, options: e = {} } = n;
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 };
374
+ h({ env: t }), e = o({ size: 25, page: 1, _list: !0 }, e);
375
+ const s = w(e), r = p(`?${s}`, t), { count: l, total: i, _embedded: d } = yield g(r, n);
376
+ let c = d ? d["ec:datamanager"] : [];
377
+ return c = Array.isArray(c) ? c : [c], { count: l, total: i, items: c };
376
378
  });
377
379
  }
378
380
  function ct(n) {
379
- return o(this, null, function* () {
381
+ return a(this, null, function* () {
380
382
  let { env: t, dmID: e, options: s = {} } = n;
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 };
383
+ h({ env: t, dmID: e }), s = o({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
384
+ const r = w(s), l = p(`model?${r}`, t), { count: i, total: d, _embedded: c } = yield g(l, n);
385
+ let u = c ? c["ec:model"] : [];
386
+ return u = Array.isArray(u) ? u : [u], { count: i, total: d, items: u };
385
387
  });
386
388
  }
387
389
  function ut(n) {
388
- return o(this, null, function* () {
390
+ return a(this, null, function* () {
389
391
  let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
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 };
392
+ h({ env: t, subdomain: r, resource: e }), s = o({ size: 25, page: 1, _list: !0 }, s);
393
+ const l = w(s), i = p(`${e}?${l}`, t, r), { count: d, total: c, _embedded: u } = yield g(i, n);
394
+ let f = u ? u[Object.keys(u)[0]] : [];
395
+ return f = Array.isArray(f) ? f : [f], { count: d, total: c, items: f };
394
396
  });
395
397
  }
396
398
  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);
399
+ return a(this, arguments, function* (n, t = {}) {
400
+ let { env: s, route: r, options: l = {}, subdomain: i = "datamanager" } = n;
401
+ h({ env: s, subdomain: i, route: r }), l = o({}, l);
402
+ const d = w(l), c = p(`${r}?${d}`, s, i);
403
+ return g(c, n, t);
402
404
  });
403
405
  }
404
- const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
406
+ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
405
407
  __proto__: null,
406
408
  assetList: st,
407
409
  createAsset: rt,
@@ -436,9 +438,9 @@ const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
436
438
  editEntry: q,
437
439
  deleteEntry: $t,
438
440
  getSchema: wt,
439
- loginPublic: kt,
440
- loginEc: At,
441
- logoutEc: Et,
441
+ loginPublic: At,
442
+ loginEc: Et,
443
+ logoutEc: kt,
442
444
  logoutPublic: bt,
443
445
  getEcAuthKey: b,
444
446
  getPublicAuthKey: T,
@@ -448,23 +450,23 @@ const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
448
450
  getDatamanager: Lt,
449
451
  resourceList: Ot,
450
452
  raw: jt
451
- } = A;
453
+ } = E;
452
454
  function Bt(n) {
453
455
  const { action: t } = n;
454
- if (h({ action: t }), !A[t])
456
+ if (h({ action: t }), !E[t])
455
457
  throw new Error(
456
- `"${t}" does not exist! try one of ${Object.keys(A).join(
458
+ `"${t}" does not exist! try one of ${Object.keys(E).join(
457
459
  ", "
458
460
  )}`
459
461
  );
460
- return A[t](n);
462
+ return E[t](n);
461
463
  }
462
464
  class _ {
463
465
  constructor(t) {
464
466
  this.config = t;
465
467
  }
466
468
  set(t) {
467
- return new _(l(l({}, this.config), t));
469
+ return new _(o(o({}, this.config), t));
468
470
  }
469
471
  /**
470
472
  * Loads entry list. Expects `dmShortID` / `model` to be set.
@@ -480,13 +482,13 @@ class _ {
480
482
  * const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
481
483
  */
482
484
  entries() {
483
- return o(this, arguments, function* (t = {}) {
485
+ return a(this, arguments, function* (t = {}) {
484
486
  const e = yield this.getBestToken();
485
- return dt(y(l({}, this.config), { options: t, token: e }));
487
+ return dt(y(o({}, this.config), { options: t, token: e }));
486
488
  });
487
489
  }
488
490
  entryList(t) {
489
- return o(this, null, function* () {
491
+ return a(this, null, function* () {
490
492
  return this.entries(t);
491
493
  });
492
494
  }
@@ -500,9 +502,9 @@ class _ {
500
502
  * const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
501
503
  */
502
504
  getEntry(t) {
503
- return o(this, null, function* () {
505
+ return a(this, null, function* () {
504
506
  const e = yield this.getBestToken();
505
- return ht(y(l({}, this.config), { entryID: t, token: e }));
507
+ return ht(y(o({}, this.config), { entryID: t, token: e }));
506
508
  });
507
509
  }
508
510
  /**
@@ -520,9 +522,9 @@ class _ {
520
522
  * .editEntrySafe("1gOtzWvrdq", { name: "test", _modified: "2020-01-01T00:00:00.000Z"})
521
523
  */
522
524
  editEntrySafe(t, e) {
523
- return o(this, null, function* () {
525
+ return a(this, null, function* () {
524
526
  const s = yield this.getBestToken();
525
- return q(y(l({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
527
+ return q(y(o({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
526
528
  });
527
529
  }
528
530
  /**
@@ -534,7 +536,7 @@ class _ {
534
536
  * const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
535
537
  */
536
538
  getSchema() {
537
- return o(this, null, function* () {
539
+ return a(this, null, function* () {
538
540
  return wt(this.config);
539
541
  });
540
542
  }
@@ -552,13 +554,13 @@ class _ {
552
554
  * const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
553
555
  */
554
556
  assets(t) {
555
- return o(this, null, function* () {
557
+ return a(this, null, function* () {
556
558
  const e = yield this.getBestToken();
557
- return ft(y(l({}, this.config), { options: t, token: e }));
559
+ return ft(y(o({}, this.config), { options: t, token: e }));
558
560
  });
559
561
  }
560
562
  assetList(t) {
561
- return o(this, null, function* () {
563
+ return a(this, null, function* () {
562
564
  return this.assets(t);
563
565
  });
564
566
  }
@@ -584,9 +586,9 @@ class _ {
584
586
  * .createAsset({ file, name: "venndiagram.png" });
585
587
  */
586
588
  createAsset() {
587
- return o(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
589
+ return a(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
588
590
  const r = yield this.getBestToken();
589
- return yt(y(l({}, this.config), { file: t, name: e, options: s, token: r }));
591
+ return yt(y(o({}, this.config), { file: t, name: e, options: s, token: r }));
590
592
  });
591
593
  }
592
594
  /**
@@ -599,9 +601,9 @@ class _ {
599
601
  * await ecadmin.assetgroup("test").deleteAsset('xxxx');
600
602
  */
601
603
  deleteAsset(t) {
602
- return o(this, null, function* () {
604
+ return a(this, null, function* () {
603
605
  const e = yield this.getBestToken();
604
- return pt(y(l({}, this.config), { token: e, assetID: t }));
606
+ return pt(y(o({}, this.config), { token: e, assetID: t }));
605
607
  });
606
608
  }
607
609
  /**
@@ -614,9 +616,9 @@ class _ {
614
616
  * const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
615
617
  */
616
618
  getAsset(t) {
617
- return o(this, null, function* () {
619
+ return a(this, null, function* () {
618
620
  const e = yield this.getBestToken();
619
- return gt(y(l({}, this.config), { assetID: t, token: e }));
621
+ return gt(y(o({}, this.config), { assetID: t, token: e }));
620
622
  });
621
623
  }
622
624
  /**
@@ -629,9 +631,9 @@ class _ {
629
631
  * const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
630
632
  */
631
633
  createEntry(t) {
632
- return o(this, null, function* () {
634
+ return a(this, null, function* () {
633
635
  const e = yield this.getBestToken();
634
- return mt(y(l({}, this.config), { token: e, value: t }));
636
+ return mt(y(o({}, this.config), { token: e, value: t }));
635
637
  });
636
638
  }
637
639
  /**
@@ -645,9 +647,9 @@ class _ {
645
647
  * const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
646
648
  */
647
649
  editEntry(t, e) {
648
- return o(this, null, function* () {
650
+ return a(this, null, function* () {
649
651
  const s = yield this.getBestToken();
650
- return q(y(l({}, this.config), { entryID: t, token: s, value: e }));
652
+ return q(y(o({}, this.config), { entryID: t, token: s, value: e }));
651
653
  });
652
654
  }
653
655
  /**
@@ -660,9 +662,9 @@ class _ {
660
662
  * await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
661
663
  */
662
664
  deleteEntry(t) {
663
- return o(this, null, function* () {
665
+ return a(this, null, function* () {
664
666
  const e = yield this.getBestToken();
665
- return $t(y(l({}, this.config), { token: e, entryID: t }));
667
+ return $t(y(o({}, this.config), { token: e, entryID: t }));
666
668
  });
667
669
  }
668
670
  /**
@@ -675,9 +677,9 @@ class _ {
675
677
  * const res = await sdk("stage").resource("template").resourceList()
676
678
  */
677
679
  resourceList(t) {
678
- return o(this, null, function* () {
680
+ return a(this, null, function* () {
679
681
  const e = yield this.getBestToken();
680
- return Ot(y(l({}, this.config), { options: t, token: e }));
682
+ return Ot(y(o({}, this.config), { options: t, token: e }));
681
683
  });
682
684
  }
683
685
  /**
@@ -692,9 +694,9 @@ class _ {
692
694
  * const res = await sdk("stage").route("stats").raw()
693
695
  */
694
696
  raw(t, e) {
695
- return o(this, null, function* () {
697
+ return a(this, null, function* () {
696
698
  const s = yield this.getBestToken();
697
- return jt(y(l({}, this.config), { options: t, token: s }), e);
699
+ return jt(y(o({}, this.config), { options: t, token: s }), e);
698
700
  });
699
701
  }
700
702
  // TODO: rename authAdapter -> storageAdapter
@@ -724,24 +726,24 @@ class _ {
724
726
  return e(t);
725
727
  }
726
728
  loginEc(t) {
727
- return At(l(l({}, this.config), t)).then(
729
+ return Et(o(o({}, this.config), t)).then(
728
730
  this.setAuth(b(this.config))
729
731
  );
730
732
  }
731
733
  loginPublic(t) {
732
- return kt(l(l({}, this.config), t)).then(
734
+ return At(o(o({}, this.config), t)).then(
733
735
  this.setAuth(T(this.config))
734
736
  );
735
737
  }
736
738
  logoutPublic() {
737
739
  const t = this.getPublicToken();
738
- return console.log("token", t), bt(y(l({}, this.config), { token: t })).then(
740
+ return console.log("token", t), bt(y(o({}, this.config), { token: t })).then(
739
741
  this.unsetAuth(T(this.config))
740
742
  );
741
743
  }
742
744
  logoutEc() {
743
745
  const t = this.getEcToken();
744
- return console.log("token", t), Et(y(l({}, this.config), { token: t })).then(
746
+ return console.log("token", t), kt(y(o({}, this.config), { token: t })).then(
745
747
  this.unsetAuth(b(this.config))
746
748
  );
747
749
  }
@@ -859,9 +861,9 @@ class _ {
859
861
  * @returns any
860
862
  */
861
863
  getDatamanager(t) {
862
- return o(this, null, function* () {
864
+ return a(this, null, function* () {
863
865
  const e = yield this.getBestToken();
864
- return Lt(y(l({}, this.config), { dmID: t, token: e }));
866
+ return Lt(y(o({}, this.config), { dmID: t, token: e }));
865
867
  });
866
868
  }
867
869
  /**
@@ -873,9 +875,9 @@ class _ {
873
875
  * const dms = await sdk("stage").dmList()
874
876
  */
875
877
  dmList() {
876
- return o(this, arguments, function* (t = {}) {
878
+ return a(this, arguments, function* (t = {}) {
877
879
  const e = yield this.getBestToken();
878
- return Tt(y(l({}, this.config), { options: t, token: e }));
880
+ return Tt(y(o({}, this.config), { options: t, token: e }));
879
881
  });
880
882
  }
881
883
  /**
@@ -887,13 +889,16 @@ class _ {
887
889
  * const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
888
890
  */
889
891
  modelList() {
890
- return o(this, arguments, function* (t = {}) {
892
+ return a(this, arguments, function* (t = {}) {
891
893
  const e = yield this.getBestToken();
892
- return _t(y(l({}, this.config), { options: t, token: e }));
894
+ return _t(y(o({}, this.config), { options: t, token: e }));
893
895
  });
894
896
  }
895
897
  }
896
898
  const qt = (n) => new _({ env: n });
899
+ function Dt(n) {
900
+ 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), {});
901
+ }
897
902
  export {
898
903
  _ as Sdk,
899
904
  Bt as act,
@@ -923,5 +928,6 @@ export {
923
928
  w as query,
924
929
  lt as raw,
925
930
  ut as resourceList,
926
- qt as sdk
931
+ qt as sdk,
932
+ Dt as sdkOptions
927
933
  };
@@ -1,4 +1,13 @@
1
1
  export function act(config: any): any;
2
+ /**
3
+ * Takes [ec.sdk filterOptions](https://entrecode.github.io/ec.sdk/#filteroptions), outputs an [entrecode filter](https://doc.entrecode.de/api-basics/#filtering)
4
+ *
5
+ * @param {SdkFilterOptions} options sdk filterOptions
6
+ * @returns {Record<string, string>}
7
+ * @example
8
+ * const res = await sdk("stage").route("stats").raw()
9
+ */
10
+ export function sdkOptions(options: SdkFilterOptions): Record<string, string>;
2
11
  export * from "./util.mjs";
3
12
  /**
4
13
  * SDK
@@ -286,6 +295,8 @@ export type AssetResource = {
286
295
  tags: Array<string | any>;
287
296
  title: string;
288
297
  type: string;
298
+ mimetype: string;
299
+ duplicates: number;
289
300
  file: AssetFile;
290
301
  };
291
302
  export type EntryResource = {
@@ -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;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,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"}
@@ -2,4 +2,19 @@ export function fetcher(url: any, config?: {}, options?: {}): Promise<any>;
2
2
  export function apiURL(route: any, env?: string, subdomain?: string): any;
3
3
  export function query(params: any, sort?: boolean): any;
4
4
  export function expect(obj: any): void;
5
+ export type SdkFilter = {
6
+ sort: string | string[];
7
+ search: string;
8
+ notNull: boolean;
9
+ null: boolean;
10
+ any: any[][];
11
+ from: string;
12
+ to: string;
13
+ };
14
+ export type SdkFilterOptions = {
15
+ sort: SdkFilter;
16
+ _count: number;
17
+ page: number;
18
+ key?: Record<string, SdkFilter> | string | boolean;
19
+ };
5
20
  //# sourceMappingURL=util.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAiBD,0EAcC;AAED,wDAKC;AAED,uCAMC"}
1
+ {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAiBD,0EAgBC;AAED,wDAKC;AAED,uCAMC;;UAIa,MAAM,GAAG,MAAM,EAAE;YACjB,MAAM;aACN,OAAO;UACP,OAAO;SACP,OAAO;UACP,MAAM;QACN,MAAM;;;UAKN,SAAS;YACT,MAAM;UACN,MAAM;UACN,OAAO,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,GAAG,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {