ec.fdk 0.4.2 → 0.4.3

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,18 +493,3 @@ 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 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}
1
+ "use strict";var ct=Object.defineProperty,at=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var B=(n,t,e)=>t in n?ct(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,o=(n,t)=>{for(var e in t||(t={}))lt.call(t,e)&&B(n,e,t[e]);if(S)for(var e of S(t))dt.call(t,e)&&B(n,e,t[e]);return n},y=(n,t)=>at(n,ut(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
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;
3
+ ${a.verbose}`;throw new Error(u)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return l?i:yield i.json()})}const D={datamanager:{live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"},accounts:{live:"https://accounts.entrecode.de/",stage:"https://accounts.cachena.entrecode.de/"},appserver:{live:"https://appserver.entrecode.de/",stage:"https://appserver.cachena.entrecode.de/"}};function p(n,t="stage",e="datamanager"){const s=D[e];if(!s)throw new Error(`subdomain "${e}" not found. Try one of ${Object.keys(D).join(", ")}`);const r=s[t];if(!r)throw new Error(`env "${t}" not found. Try one of ${Object.keys(s[t]).join(", ")}`);return r+n}function w(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function h(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const x={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function K(n){return 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 N(n){return c(this,null,function*(){let{env:t,email:e,password:s}=n;h({env:t,email:e,password:s});const r=`${x[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function z(n){return 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 C(n){return c(this,null,function*(){let{env:t,token:e}=n;h({env:t,token:e});const s=`${x[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function F({dmShortID:n}){return h({dmShortID:n}),n}function J({env:n}){return h({env:n}),n}let ht=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];function R(n){let t={};for(let e in n)ht.includes(e)||(t[e]=n[e]);return t}function gt(n){return JSON.parse(JSON.stringify(n))}function v(n){return 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 U(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 I({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 V(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=gt(r),r=R(r),yield g(u,{token:l},{method:"PUT",headers:a,body:JSON.stringify(r)})})}function G(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 H(r){return c(this,arguments,function*({env:n,dmShortID:t,model:e,withMetadata:s}){var f,$,O,L,j;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=R(a);for(let A in u){let m=u[A];if(m.required=d.required.includes(A),($=u[A])!=null&&$.oneOf&&((O=u[A])==null||delete O.oneOf),(L=m.title)!=null&&L.includes("<")&&((j=m.title)!=null&&j.includes(">"))){const b=m.title.split("<")[1].slice(0,-1),ot=m.title.split("<")[0];m.type=ot,b.includes(":")?m.resource=b.split(":")[1]:m.resource=b}else["asset","entry","assets","entries"].includes(m.title)?(m.type=m.title,m.resource=null):m.type=m.title;delete 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 Q(n){return Object.entries(n).map(([t,e])=>typeof e!="object"?{[t]:String(e)}:o(o(o(o(o(o(o({},e.sort&&{sort:Array.isArray(e)?e.join(","):e}),e.search&&{[t+"~"]:e.search}),e.notNull&&{[t+"!"]:""}),e.null&&{[t]:""}),e.any&&{[t]:e.any.join(",")}),e.from&&{[t+"From"]:e.from}),e.to&&{[t+"To"]:e.to})).reduce((t,e)=>o(o({},t),e),{})}function P(n){return n._links.collection.href.split("/").slice(-2)[0]}function W(n,t){const e=P(t);return t._embedded[`${e}:${t._modelTitle}/${n}/asset`]}function X(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 Y(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 Z(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 tt(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 et(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 nt(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 st(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 rt(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 it(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 E=Object.freeze(Object.defineProperty({__proto__:null,assetList:Y,createAsset:Z,createEntry:M,deleteAsset:tt,deleteEntry:G,dmList:nt,editEntry:V,entryList:U,getAsset:X,getDatamanager:et,getEcAuthKey:J,getEntry:I,getEntryAsset:W,getEntryShortID:P,getPublicAuthKey:F,getSchema:H,loginEc:N,loginPublic:K,logoutEc:C,logoutPublic:z,modelList:st,publicApi:v,raw:it,resourceList:rt,sdkOptions:Q},Symbol.toStringTag,{value:"Module"})),{entryList:ft,getEntry:yt,getAsset:pt,assetList:mt,createAsset:$t,deleteAsset:wt,createEntry:At,editEntry:q,deleteEntry:Et,getSchema:kt,loginPublic:bt,loginEc:Tt,logoutEc:_t,logoutPublic:Pt,getEcAuthKey:T,getPublicAuthKey:_,dmList:Ot,modelList:Lt,publicApi:jt,getDatamanager:St,resourceList:Bt,raw:Dt}=E;function qt(n){const{action:t}=n;if(h({action:t}),!E[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(E).join(", ")}`);return E[t](n)}class k{constructor(t){this.config=t}set(t){return new k(o(o({},this.config),t))}entries(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return ft(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 yt(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 kt(this.config)})}assets(t){return c(this,null,function*(){const e=yield this.getBestToken();return mt(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 $t(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 wt(y(o({},this.config),{token:e,assetID:t}))})}getAsset(t){return c(this,null,function*(){const e=yield this.getBestToken();return pt(y(o({},this.config),{assetID:t,token:e}))})}createEntry(t){return c(this,null,function*(){const e=yield this.getBestToken();return At(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 Et(y(o({},this.config),{token:e,entryID:t}))})}resourceList(t){return c(this,null,function*(){const e=yield this.getBestToken();return Bt(y(o({},this.config),{options:t,token:e}))})}raw(t,e){return c(this,null,function*(){const s=yield this.getBestToken();return Dt(y(o({},this.config),{options:t,token:s}),e)})}authAdapter(t){return this.set({authAdapter:t})}setAuth(t){return e=>{if(!this.config.authAdapter)throw new Error("cannot setAuth: no authAdapter defined!");const{set:s}=this.config.authAdapter;return s(t,e.token),e}}unsetAuth(t){return e=>{if(console.log("unset auth",e),!this.config.authAdapter)throw new Error("cannot unsetAuth: no authAdapter defined!");const{remove:s}=this.config.authAdapter;return s(t),e}}getAuth(t){if(!this.config.authAdapter)throw new Error("cannot getAuth: no authAdapter defined!");const{get:e}=this.config.authAdapter;return e(t)}loginEc(t){return Tt(o(o({},this.config),t)).then(this.setAuth(T(this.config)))}loginPublic(t){return bt(o(o({},this.config),t)).then(this.setAuth(_(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),Pt(y(o({},this.config),{token:t})).then(this.unsetAuth(_(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),_t(y(o({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}getPublicToken(){return this.config.token||this.getAuth(_(this.config))}getEcToken(){return this.config.token||this.getAuth(T(this.config))}hasPublicToken(){return!!this.getPublicToken()}hasEcToken(){return!!this.getEcToken()}hasAnyToken(){return!!this.getEcToken()||!!this.getPublicToken()}getBestToken(){try{return this.getEcToken()||this.getPublicToken()}catch(t){return}}model(t){return this.set({model:t})}token(t){return this.set({token:t})}dmShortID(t){return this.set({dmShortID:t})}dmID(t){return this.set({dmID:t})}dm(t){return this.dmShortID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}subdomain(t){return this.set({subdomain:t})}resource(t){return this.set({resource:t})}route(t){return this.set({route:t})}publicApi(){return jt(this.config)}getDatamanager(t){return c(this,null,function*(){const e=yield this.getBestToken();return St(y(o({},this.config),{dmID:t,token:e}))})}dmList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return Ot(y(o({},this.config),{options:t,token:e}))})}modelList(){return c(this,arguments,function*(t={}){const e=yield this.getBestToken();return Lt(y(o({},this.config),{options:t,token:e}))})}}const xt=n=>new k({env:n});exports.Sdk=k;exports.act=qt;exports.apiURL=p;exports.assetList=Y;exports.createAsset=Z;exports.createEntry=M;exports.deleteAsset=tt;exports.deleteEntry=G;exports.dmList=nt;exports.editEntry=V;exports.entryList=U;exports.expect=h;exports.fetcher=g;exports.getAsset=X;exports.getDatamanager=et;exports.getEcAuthKey=J;exports.getEntry=I;exports.getEntryAsset=W;exports.getEntryShortID=P;exports.getPublicAuthKey=F;exports.getSchema=H;exports.loginEc=N;exports.loginPublic=K;exports.logoutEc=C;exports.logoutPublic=z;exports.modelList=st;exports.publicApi=v;exports.query=w;exports.raw=it;exports.resourceList=rt;exports.sdk=xt;exports.sdkOptions=Q;
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- var N = Object.defineProperty, z = Object.defineProperties;
2
- var C = Object.getOwnPropertyDescriptors;
1
+ var z = Object.defineProperty, C = Object.defineProperties;
2
+ var F = Object.getOwnPropertyDescriptors;
3
3
  var j = Object.getOwnPropertySymbols;
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) => {
4
+ var J = Object.prototype.hasOwnProperty, R = 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, o = (n, t) => {
6
6
  for (var e in t || (t = {}))
7
- F.call(t, e) && S(n, e, t[e]);
7
+ J.call(t, e) && S(n, e, t[e]);
8
8
  if (j)
9
9
  for (var e of j(t))
10
- J.call(t, e) && S(n, e, t[e]);
10
+ R.call(t, e) && S(n, e, t[e]);
11
11
  return n;
12
- }, y = (n, t) => z(n, C(t));
12
+ }, p = (n, t) => C(n, F(t));
13
13
  var a = (n, t, e) => new Promise((s, r) => {
14
14
  var l = (c) => {
15
15
  try {
@@ -30,7 +30,7 @@ function g(s) {
30
30
  return a(this, arguments, function* (n, t = {}, e = {}) {
31
31
  var d;
32
32
  const { token: r, rawRes: l } = t;
33
- r && (e.headers = y(o({}, e.headers || {}), {
33
+ r && (e.headers = p(o({}, e.headers || {}), {
34
34
  Authorization: `Bearer ${r}`
35
35
  }));
36
36
  const i = yield fetch(n, e);
@@ -60,7 +60,7 @@ const B = {
60
60
  stage: "https://appserver.cachena.entrecode.de/"
61
61
  }
62
62
  };
63
- function p(n, t = "stage", e = "datamanager") {
63
+ function y(n, t = "stage", e = "datamanager") {
64
64
  const s = B[e];
65
65
  if (!s)
66
66
  throw new Error(
@@ -84,15 +84,15 @@ function h(n) {
84
84
  throw new Error(`expected ${t} to be set!`);
85
85
  });
86
86
  }
87
- const D = {
87
+ const q = {
88
88
  stage: "https://accounts.cachena.entrecode.de/",
89
89
  live: "https://accounts.entrecode.de/"
90
90
  };
91
- function R(n) {
91
+ function v(n) {
92
92
  return a(this, null, function* () {
93
93
  let { env: t, dmShortID: e, email: s, password: r } = n;
94
94
  h({ env: t, dmShortID: e, email: s, password: r });
95
- const l = p(`api/${e}/_auth/login?clientID=rest`, t);
95
+ const l = y(`api/${e}/_auth/login?clientID=rest`, t);
96
96
  return yield g(
97
97
  l,
98
98
  {},
@@ -106,11 +106,11 @@ function R(n) {
106
106
  );
107
107
  });
108
108
  }
109
- function v(n) {
109
+ function U(n) {
110
110
  return a(this, null, function* () {
111
111
  let { env: t, email: e, password: s } = n;
112
112
  h({ env: t, email: e, password: s });
113
- const r = `${D[t]}auth/login?clientID=rest`;
113
+ const r = `${q[t]}auth/login?clientID=rest`;
114
114
  return yield g(
115
115
  r,
116
116
  {},
@@ -124,11 +124,11 @@ function v(n) {
124
124
  );
125
125
  });
126
126
  }
127
- function U(n) {
127
+ function I(n) {
128
128
  return a(this, null, function* () {
129
129
  let { dmShortID: t, env: e, token: s } = n;
130
130
  h({ dmShortID: t, env: e, token: s });
131
- const r = p(
131
+ const r = y(
132
132
  `api/${t}/_auth/logout?clientID=rest&token=${s}`,
133
133
  e
134
134
  );
@@ -145,7 +145,7 @@ function M(n) {
145
145
  return a(this, null, function* () {
146
146
  let { env: t, token: e } = n;
147
147
  h({ env: t, token: e });
148
- const s = `${D[t]}auth/logout?clientID=rest`;
148
+ const s = `${q[t]}auth/logout?clientID=rest`;
149
149
  return yield g(
150
150
  s,
151
151
  {
@@ -158,13 +158,13 @@ function M(n) {
158
158
  );
159
159
  });
160
160
  }
161
- function I({ dmShortID: n }) {
161
+ function V({ dmShortID: n }) {
162
162
  return h({ dmShortID: n }), n;
163
163
  }
164
- function V({ env: n }) {
164
+ function G({ env: n }) {
165
165
  return h({ env: n }), n;
166
166
  }
167
- let G = [
167
+ let H = [
168
168
  "created",
169
169
  "creator",
170
170
  "id",
@@ -183,38 +183,38 @@ let G = [
183
183
  function x(n) {
184
184
  let t = {};
185
185
  for (let e in n)
186
- G.includes(e) || (t[e] = n[e]);
186
+ H.includes(e) || (t[e] = n[e]);
187
187
  return t;
188
188
  }
189
- function H(n) {
189
+ function Q(n) {
190
190
  return JSON.parse(JSON.stringify(n));
191
191
  }
192
- function Q(n) {
192
+ function W(n) {
193
193
  return a(this, null, function* () {
194
194
  let { env: t, dmShortID: e } = n;
195
195
  h({ env: t, dmShortID: e });
196
- const s = p(`api/${e}`, t);
196
+ const s = y(`api/${e}`, t);
197
197
  return g(s, n);
198
198
  });
199
199
  }
200
- function W(n) {
200
+ function X(n) {
201
201
  return a(this, null, function* () {
202
202
  let { env: t, dmShortID: e, model: s, options: r = {} } = n;
203
203
  h({ env: t, dmShortID: e, model: s }), r = o({ size: 50, page: 1, _list: !0 }, r);
204
- const l = w(r), i = p(`api/${e}/${s}?${l}`, t), { count: d, total: c, _embedded: u } = yield g(i, n);
204
+ const l = w(r), i = y(`api/${e}/${s}?${l}`, t), { count: d, total: c, _embedded: u } = yield g(i, n);
205
205
  let f = u ? u[`${e}:${s}`] : [];
206
206
  return f = Array.isArray(f) ? f : [f], { count: d, total: c, items: f };
207
207
  });
208
208
  }
209
- function X({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
209
+ function Y({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
210
210
  h({ env: n, dmShortID: t, model: e, entryID: s });
211
- const l = w({ _id: s }), i = p(`api/${t}/${e}?${l}`, n);
211
+ const l = w({ _id: s }), i = y(`api/${t}/${e}?${l}`, n);
212
212
  return g(i, { dmShortID: t, token: r });
213
213
  }
214
- function Y(l) {
214
+ function Z(l) {
215
215
  return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
216
216
  h({ env: n, dmShortID: t, model: e, value: s });
217
- const i = p(`api/${t}/${e}`, n);
217
+ const i = y(`api/${t}/${e}`, n);
218
218
  return yield g(
219
219
  i,
220
220
  { env: n, dmShortID: t, token: r },
@@ -228,7 +228,7 @@ function Y(l) {
228
228
  );
229
229
  });
230
230
  }
231
- function Z(d) {
231
+ function tt(d) {
232
232
  return a(this, arguments, function* ({
233
233
  env: n,
234
234
  dmShortID: t,
@@ -247,8 +247,8 @@ function Z(d) {
247
247
  throw new Error("expected _modified to be set!");
248
248
  c["If-Unmodified-Since"] = new Date(r._modified).toUTCString();
249
249
  }
250
- const u = p(`api/${t}/${e}?_id=${s}`, n);
251
- return r = H(r), r = x(r), yield g(
250
+ const u = y(`api/${t}/${e}?_id=${s}`, n);
251
+ return r = Q(r), r = x(r), yield g(
252
252
  u,
253
253
  { token: l },
254
254
  {
@@ -259,10 +259,10 @@ function Z(d) {
259
259
  );
260
260
  });
261
261
  }
262
- function tt(l) {
262
+ function et(l) {
263
263
  return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
264
264
  h({ env: n, dmShortID: t, model: e, entryID: s });
265
- const i = p(`api/${t}/${e}?_id=${s}`, n);
265
+ const i = y(`api/${t}/${e}?_id=${s}`, n);
266
266
  yield g(
267
267
  i,
268
268
  { token: r, rawRes: !0 },
@@ -275,11 +275,11 @@ function tt(l) {
275
275
  );
276
276
  });
277
277
  }
278
- function et(r) {
278
+ function nt(r) {
279
279
  return a(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
280
280
  var f, $, P, L, O;
281
281
  h({ env: n, dmShortID: t, model: e });
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];
282
+ const l = y(`api/schema/${t}/${e}`, n), i = yield g(l), d = (f = i == null ? void 0 : i.allOf) == null ? void 0 : f[1];
283
283
  if (typeof d.properties != "object")
284
284
  throw new Error(
285
285
  `getSchema: ${l} returned unexpected format: ${JSON.stringify(i)}`
@@ -288,8 +288,8 @@ function et(r) {
288
288
  for (let A in u) {
289
289
  let m = u[A];
290
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
+ const k = m.title.split("<")[1].slice(0, -1), N = m.title.split("<")[0];
292
+ m.type = N, k.includes(":") ? m.resource = k.split(":")[1] : m.resource = k;
293
293
  } else
294
294
  ["asset", "entry", "assets", "entries"].includes(m.title) ? (m.type = m.title, m.resource = null) : m.type = m.title;
295
295
  delete u[A].title;
@@ -301,23 +301,33 @@ function et(r) {
301
301
  return u;
302
302
  });
303
303
  }
304
- function nt(l) {
304
+ function st(n) {
305
+ 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), {});
306
+ }
307
+ function K(n) {
308
+ return n._links.collection.href.split("/").slice(-2)[0];
309
+ }
310
+ function rt(n, t) {
311
+ const e = K(t);
312
+ return t._embedded[`${e}:${t._modelTitle}/${n}/asset`];
313
+ }
314
+ function it(l) {
305
315
  return a(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
306
316
  h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
307
- const i = w({ assetID: s }), d = p(`a/${t}/${e}?${i}`, n);
317
+ const i = w({ assetID: s }), d = y(`a/${t}/${e}?${i}`, n);
308
318
  return (yield g(d, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
309
319
  });
310
320
  }
311
- function st(n) {
321
+ function ot(n) {
312
322
  return a(this, null, function* () {
313
323
  let { env: t, dmShortID: e, assetGroup: s, token: r, options: l = {} } = n;
314
324
  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 });
325
+ const i = w(l), d = y(`a/${e}/${s}?${i}`, t), { count: c, total: u, _embedded: f } = yield g(d, { dmShortID: e, token: r });
316
326
  let $ = f ? f["ec:dm-asset"] : [];
317
327
  return $ = Array.isArray($) ? $ : [$], { count: c, total: u, items: $ };
318
328
  });
319
329
  }
320
- function rt(d) {
330
+ function at(d) {
321
331
  return a(this, arguments, function* ({
322
332
  env: n,
323
333
  dmShortID: t,
@@ -328,7 +338,7 @@ function rt(d) {
328
338
  options: i
329
339
  }) {
330
340
  h({ env: n, dmShortID: t, assetGroup: e, file: r });
331
- const c = p(`a/${t}/${e}`, n), u = new FormData();
341
+ const c = y(`a/${t}/${e}`, n), u = new FormData();
332
342
  return u.append("file", r, l), i && Object.keys(i).forEach(($) => {
333
343
  u.append($, i[$]);
334
344
  }), (yield g(
@@ -341,7 +351,7 @@ function rt(d) {
341
351
  ))._embedded["ec:dm-asset"];
342
352
  });
343
353
  }
344
- function it(l) {
354
+ function ct(l) {
345
355
  return a(this, arguments, function* ({
346
356
  env: n,
347
357
  dmShortID: t,
@@ -350,7 +360,7 @@ function it(l) {
350
360
  token: r
351
361
  }) {
352
362
  h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
353
- const i = p(`a/${t}/${e}/${s}`, n);
363
+ const i = y(`a/${t}/${e}/${s}`, n);
354
364
  yield g(
355
365
  i,
356
366
  { token: r, rawRes: !0 },
@@ -360,98 +370,101 @@ function it(l) {
360
370
  );
361
371
  });
362
372
  }
363
- function ot(n) {
373
+ function ut(n) {
364
374
  return a(this, null, function* () {
365
375
  let { env: t, dmID: e, token: s } = n;
366
376
  h({ env: t, dmID: e });
367
- const r = p(`?dataManagerID=${e}`, t);
377
+ const r = y(`?dataManagerID=${e}`, t);
368
378
  return g(r, { token: s });
369
379
  });
370
380
  }
371
- function at(n) {
381
+ function lt(n) {
372
382
  return a(this, null, function* () {
373
383
  let { env: t, options: e = {} } = n;
374
384
  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);
385
+ const s = w(e), r = y(`?${s}`, t), { count: l, total: i, _embedded: d } = yield g(r, n);
376
386
  let c = d ? d["ec:datamanager"] : [];
377
387
  return c = Array.isArray(c) ? c : [c], { count: l, total: i, items: c };
378
388
  });
379
389
  }
380
- function ct(n) {
390
+ function dt(n) {
381
391
  return a(this, null, function* () {
382
392
  let { env: t, dmID: e, options: s = {} } = n;
383
393
  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);
394
+ const r = w(s), l = y(`model?${r}`, t), { count: i, total: d, _embedded: c } = yield g(l, n);
385
395
  let u = c ? c["ec:model"] : [];
386
396
  return u = Array.isArray(u) ? u : [u], { count: i, total: d, items: u };
387
397
  });
388
398
  }
389
- function ut(n) {
399
+ function ht(n) {
390
400
  return a(this, null, function* () {
391
401
  let { env: t, resource: e, options: s = {}, subdomain: r = "datamanager" } = n;
392
402
  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);
403
+ const l = w(s), i = y(`${e}?${l}`, t, r), { count: d, total: c, _embedded: u } = yield g(i, n);
394
404
  let f = u ? u[Object.keys(u)[0]] : [];
395
405
  return f = Array.isArray(f) ? f : [f], { count: d, total: c, items: f };
396
406
  });
397
407
  }
398
- function lt(e) {
408
+ function gt(e) {
399
409
  return a(this, arguments, function* (n, t = {}) {
400
410
  let { env: s, route: r, options: l = {}, subdomain: i = "datamanager" } = n;
401
411
  h({ env: s, subdomain: i, route: r }), l = o({}, l);
402
- const d = w(l), c = p(`${r}?${d}`, s, i);
412
+ const d = w(l), c = y(`${r}?${d}`, s, i);
403
413
  return g(c, n, t);
404
414
  });
405
415
  }
406
416
  const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
407
417
  __proto__: null,
408
- assetList: st,
409
- createAsset: rt,
410
- createEntry: Y,
411
- deleteAsset: it,
412
- deleteEntry: tt,
413
- dmList: at,
414
- editEntry: Z,
415
- entryList: W,
416
- getAsset: nt,
417
- getDatamanager: ot,
418
- getEcAuthKey: V,
419
- getEntry: X,
420
- getPublicAuthKey: I,
421
- getSchema: et,
422
- loginEc: v,
423
- loginPublic: R,
418
+ assetList: ot,
419
+ createAsset: at,
420
+ createEntry: Z,
421
+ deleteAsset: ct,
422
+ deleteEntry: et,
423
+ dmList: lt,
424
+ editEntry: tt,
425
+ entryList: X,
426
+ getAsset: it,
427
+ getDatamanager: ut,
428
+ getEcAuthKey: G,
429
+ getEntry: Y,
430
+ getEntryAsset: rt,
431
+ getEntryShortID: K,
432
+ getPublicAuthKey: V,
433
+ getSchema: nt,
434
+ loginEc: U,
435
+ loginPublic: v,
424
436
  logoutEc: M,
425
- logoutPublic: U,
426
- modelList: ct,
427
- publicApi: Q,
428
- raw: lt,
429
- resourceList: ut
437
+ logoutPublic: I,
438
+ modelList: dt,
439
+ publicApi: W,
440
+ raw: gt,
441
+ resourceList: ht,
442
+ sdkOptions: st
430
443
  }, Symbol.toStringTag, { value: "Module" })), {
431
- entryList: dt,
432
- getEntry: ht,
433
- getAsset: gt,
434
- assetList: ft,
435
- createAsset: yt,
436
- deleteAsset: pt,
437
- createEntry: mt,
438
- editEntry: q,
439
- deleteEntry: $t,
440
- getSchema: wt,
441
- loginPublic: At,
442
- loginEc: Et,
443
- logoutEc: kt,
444
- logoutPublic: bt,
444
+ entryList: ft,
445
+ getEntry: pt,
446
+ getAsset: yt,
447
+ assetList: mt,
448
+ createAsset: $t,
449
+ deleteAsset: wt,
450
+ createEntry: At,
451
+ editEntry: D,
452
+ deleteEntry: Et,
453
+ getSchema: kt,
454
+ loginPublic: bt,
455
+ loginEc: Tt,
456
+ logoutEc: _t,
457
+ logoutPublic: Pt,
445
458
  getEcAuthKey: b,
446
459
  getPublicAuthKey: T,
447
- dmList: Tt,
448
- modelList: _t,
449
- publicApi: Pt,
450
- getDatamanager: Lt,
451
- resourceList: Ot,
452
- raw: jt
460
+ dmList: Lt,
461
+ modelList: Ot,
462
+ publicApi: jt,
463
+ getDatamanager: St,
464
+ resourceList: Bt,
465
+ raw: Dt
453
466
  } = E;
454
- function Bt(n) {
467
+ function xt(n) {
455
468
  const { action: t } = n;
456
469
  if (h({ action: t }), !E[t])
457
470
  throw new Error(
@@ -484,7 +497,7 @@ class _ {
484
497
  entries() {
485
498
  return a(this, arguments, function* (t = {}) {
486
499
  const e = yield this.getBestToken();
487
- return dt(y(o({}, this.config), { options: t, token: e }));
500
+ return ft(p(o({}, this.config), { options: t, token: e }));
488
501
  });
489
502
  }
490
503
  entryList(t) {
@@ -504,7 +517,7 @@ class _ {
504
517
  getEntry(t) {
505
518
  return a(this, null, function* () {
506
519
  const e = yield this.getBestToken();
507
- return ht(y(o({}, this.config), { entryID: t, token: e }));
520
+ return pt(p(o({}, this.config), { entryID: t, token: e }));
508
521
  });
509
522
  }
510
523
  /**
@@ -524,7 +537,7 @@ class _ {
524
537
  editEntrySafe(t, e) {
525
538
  return a(this, null, function* () {
526
539
  const s = yield this.getBestToken();
527
- return q(y(o({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
540
+ return D(p(o({}, this.config), { entryID: t, token: s, value: e, safePut: !0 }));
528
541
  });
529
542
  }
530
543
  /**
@@ -537,7 +550,7 @@ class _ {
537
550
  */
538
551
  getSchema() {
539
552
  return a(this, null, function* () {
540
- return wt(this.config);
553
+ return kt(this.config);
541
554
  });
542
555
  }
543
556
  /**
@@ -556,7 +569,7 @@ class _ {
556
569
  assets(t) {
557
570
  return a(this, null, function* () {
558
571
  const e = yield this.getBestToken();
559
- return ft(y(o({}, this.config), { options: t, token: e }));
572
+ return mt(p(o({}, this.config), { options: t, token: e }));
560
573
  });
561
574
  }
562
575
  assetList(t) {
@@ -588,7 +601,7 @@ class _ {
588
601
  createAsset() {
589
602
  return a(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
590
603
  const r = yield this.getBestToken();
591
- return yt(y(o({}, this.config), { file: t, name: e, options: s, token: r }));
604
+ return $t(p(o({}, this.config), { file: t, name: e, options: s, token: r }));
592
605
  });
593
606
  }
594
607
  /**
@@ -603,7 +616,7 @@ class _ {
603
616
  deleteAsset(t) {
604
617
  return a(this, null, function* () {
605
618
  const e = yield this.getBestToken();
606
- return pt(y(o({}, this.config), { token: e, assetID: t }));
619
+ return wt(p(o({}, this.config), { token: e, assetID: t }));
607
620
  });
608
621
  }
609
622
  /**
@@ -618,7 +631,7 @@ class _ {
618
631
  getAsset(t) {
619
632
  return a(this, null, function* () {
620
633
  const e = yield this.getBestToken();
621
- return gt(y(o({}, this.config), { assetID: t, token: e }));
634
+ return yt(p(o({}, this.config), { assetID: t, token: e }));
622
635
  });
623
636
  }
624
637
  /**
@@ -633,7 +646,7 @@ class _ {
633
646
  createEntry(t) {
634
647
  return a(this, null, function* () {
635
648
  const e = yield this.getBestToken();
636
- return mt(y(o({}, this.config), { token: e, value: t }));
649
+ return At(p(o({}, this.config), { token: e, value: t }));
637
650
  });
638
651
  }
639
652
  /**
@@ -649,7 +662,7 @@ class _ {
649
662
  editEntry(t, e) {
650
663
  return a(this, null, function* () {
651
664
  const s = yield this.getBestToken();
652
- return q(y(o({}, this.config), { entryID: t, token: s, value: e }));
665
+ return D(p(o({}, this.config), { entryID: t, token: s, value: e }));
653
666
  });
654
667
  }
655
668
  /**
@@ -664,7 +677,7 @@ class _ {
664
677
  deleteEntry(t) {
665
678
  return a(this, null, function* () {
666
679
  const e = yield this.getBestToken();
667
- return $t(y(o({}, this.config), { token: e, entryID: t }));
680
+ return Et(p(o({}, this.config), { token: e, entryID: t }));
668
681
  });
669
682
  }
670
683
  /**
@@ -679,7 +692,7 @@ class _ {
679
692
  resourceList(t) {
680
693
  return a(this, null, function* () {
681
694
  const e = yield this.getBestToken();
682
- return Ot(y(o({}, this.config), { options: t, token: e }));
695
+ return Bt(p(o({}, this.config), { options: t, token: e }));
683
696
  });
684
697
  }
685
698
  /**
@@ -696,7 +709,7 @@ class _ {
696
709
  raw(t, e) {
697
710
  return a(this, null, function* () {
698
711
  const s = yield this.getBestToken();
699
- return jt(y(o({}, this.config), { options: t, token: s }), e);
712
+ return Dt(p(o({}, this.config), { options: t, token: s }), e);
700
713
  });
701
714
  }
702
715
  // TODO: rename authAdapter -> storageAdapter
@@ -726,24 +739,24 @@ class _ {
726
739
  return e(t);
727
740
  }
728
741
  loginEc(t) {
729
- return Et(o(o({}, this.config), t)).then(
742
+ return Tt(o(o({}, this.config), t)).then(
730
743
  this.setAuth(b(this.config))
731
744
  );
732
745
  }
733
746
  loginPublic(t) {
734
- return At(o(o({}, this.config), t)).then(
747
+ return bt(o(o({}, this.config), t)).then(
735
748
  this.setAuth(T(this.config))
736
749
  );
737
750
  }
738
751
  logoutPublic() {
739
752
  const t = this.getPublicToken();
740
- return console.log("token", t), bt(y(o({}, this.config), { token: t })).then(
753
+ return console.log("token", t), Pt(p(o({}, this.config), { token: t })).then(
741
754
  this.unsetAuth(T(this.config))
742
755
  );
743
756
  }
744
757
  logoutEc() {
745
758
  const t = this.getEcToken();
746
- return console.log("token", t), kt(y(o({}, this.config), { token: t })).then(
759
+ return console.log("token", t), _t(p(o({}, this.config), { token: t })).then(
747
760
  this.unsetAuth(b(this.config))
748
761
  );
749
762
  }
@@ -854,7 +867,7 @@ class _ {
854
867
  * @returns any
855
868
  */
856
869
  publicApi() {
857
- return Pt(this.config);
870
+ return jt(this.config);
858
871
  }
859
872
  /**
860
873
  * Loads a DatamanagerResource by its long id. Requires token.
@@ -863,7 +876,7 @@ class _ {
863
876
  getDatamanager(t) {
864
877
  return a(this, null, function* () {
865
878
  const e = yield this.getBestToken();
866
- return Lt(y(o({}, this.config), { dmID: t, token: e }));
879
+ return St(p(o({}, this.config), { dmID: t, token: e }));
867
880
  });
868
881
  }
869
882
  /**
@@ -877,7 +890,7 @@ class _ {
877
890
  dmList() {
878
891
  return a(this, arguments, function* (t = {}) {
879
892
  const e = yield this.getBestToken();
880
- return Tt(y(o({}, this.config), { options: t, token: e }));
893
+ return Lt(p(o({}, this.config), { options: t, token: e }));
881
894
  });
882
895
  }
883
896
  /**
@@ -891,43 +904,42 @@ class _ {
891
904
  modelList() {
892
905
  return a(this, arguments, function* (t = {}) {
893
906
  const e = yield this.getBestToken();
894
- return _t(y(o({}, this.config), { options: t, token: e }));
907
+ return Ot(p(o({}, this.config), { options: t, token: e }));
895
908
  });
896
909
  }
897
910
  }
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
- }
911
+ const Kt = (n) => new _({ env: n });
902
912
  export {
903
913
  _ as Sdk,
904
- Bt as act,
905
- p as apiURL,
906
- st as assetList,
907
- rt as createAsset,
908
- Y as createEntry,
909
- it as deleteAsset,
910
- tt as deleteEntry,
911
- at as dmList,
912
- Z as editEntry,
913
- W as entryList,
914
+ xt as act,
915
+ y as apiURL,
916
+ ot as assetList,
917
+ at as createAsset,
918
+ Z as createEntry,
919
+ ct as deleteAsset,
920
+ et as deleteEntry,
921
+ lt as dmList,
922
+ tt as editEntry,
923
+ X as entryList,
914
924
  h as expect,
915
925
  g as fetcher,
916
- nt as getAsset,
917
- ot as getDatamanager,
918
- V as getEcAuthKey,
919
- X as getEntry,
920
- I as getPublicAuthKey,
921
- et as getSchema,
922
- v as loginEc,
923
- R as loginPublic,
926
+ it as getAsset,
927
+ ut as getDatamanager,
928
+ G as getEcAuthKey,
929
+ Y as getEntry,
930
+ rt as getEntryAsset,
931
+ K as getEntryShortID,
932
+ V as getPublicAuthKey,
933
+ nt as getSchema,
934
+ U as loginEc,
935
+ v as loginPublic,
924
936
  M as logoutEc,
925
- U as logoutPublic,
926
- ct as modelList,
927
- Q as publicApi,
937
+ I as logoutPublic,
938
+ dt as modelList,
939
+ W as publicApi,
928
940
  w as query,
929
- lt as raw,
930
- ut as resourceList,
931
- qt as sdk,
932
- Dt as sdkOptions
941
+ gt as raw,
942
+ ht as resourceList,
943
+ Kt as sdk,
944
+ st as sdkOptions
933
945
  };
@@ -1,13 +1,4 @@
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>;
11
2
  export * from "./util.mjs";
12
3
  /**
13
4
  * SDK
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAgCA,sCAWC;AAgbD;;;;;;;GAOG;AACH,uDAJa,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AM;YACN,GAAG;cACH,MAAM;aACN,MAAM,EAAE;YACR,MAAM,EAAE;uBACR,MAAM,EAAE;aACR,MAAM;WACN,MAAM;;;;YACN,GAAG;;;WAKH,MAAM;WACN,MAAM;WACN,mBAAmB,EAAE;;;WAKrB,MAAM;WACN,MAAM;WACN,aAAa,EAAE;;;WAKf,MAAM;WACN,MAAM;WACN,GAAG,EAAE;;;;;;aAML,GAAG;iBACH,MAAM;iBACN,OAAO;aACP,OAAO;cACP,OAAO;cACP,OAAO;YACP,OAAO;WACP,MAAM;UACN,MAAM;gBACN,MAAM,GAAG,IAAI;;;YAKb,GAAG;aACH,MAAM;iBACN,MAAM;YACN,gBAAgB,EAAE;gBAClB,OAAO;cACP,MAAM;WACN,GAAG,EAAE;eACL,GAAG,EAAE;aACL,MAAM,EAAE;aACR,MAAM;cACN,MAAM;cACN,GAAG,EAAE;UACL,GAAG;WACH,MAAM;gBACN,MAAM;YACN,GAAG;;;WAMH,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
1
+ {"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AAgCA,sCAWC;;AAED;;GAEG;AACH;IACE,yBAEC;IADC,YAAoB;IAGtB,mBAGC;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;;;;;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,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,MAAM;gBACN,MAAM;YACN,GAAG;;;WAMH,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
@@ -40,4 +40,62 @@ export function getSchema({ env, dmShortID, model, withMetadata }: {
40
40
  model: any;
41
41
  withMetadata: any;
42
42
  }): Promise<{}>;
43
+ /**
44
+ * @typedef {Object} SdkFilter
45
+ * @property {string | string[]} sort
46
+ * @property {string} search
47
+ * @property {boolean} notNull
48
+ * @property {boolean} null
49
+ * @property {Array[]} any
50
+ * @property {string} from
51
+ * @property {string} to
52
+ *
53
+ */
54
+ /**
55
+ * @typedef {Object} SdkFilterOptions
56
+ * @property {SdkFilter} sort
57
+ * @property {number} _count
58
+ * @property {number} page
59
+ * @property {Record<string, SdkFilter> | string | boolean} [key]
60
+ *
61
+ */
62
+ /**
63
+ * Takes [ec.sdk filterOptions](https://entrecode.github.io/ec.sdk/#filteroptions), outputs an [entrecode filter](https://doc.entrecode.de/api-basics/#filtering)
64
+ *
65
+ * @param {SdkFilterOptions} options sdk filterOptions
66
+ * @returns {Record<string, string>}
67
+ *
68
+ */
69
+ export function sdkOptions(options: SdkFilterOptions): Record<string, string>;
70
+ /**
71
+ * Returns the shortID of the given EntryResource
72
+ *
73
+ * @param {EntryResource} entry EntryResource
74
+ * @returns {string}
75
+ *
76
+ */
77
+ export function getEntryShortID(entry: EntryResource): string;
78
+ /**
79
+ * Returns the embedded asset from the given field name and EntryResource
80
+ *
81
+ * @param {EntryResource} entry EntryResource
82
+ * @returns {string}
83
+ *
84
+ */
85
+ export function getEntryAsset(field: any, entry: EntryResource): string;
86
+ export type SdkFilter = {
87
+ sort: string | string[];
88
+ search: string;
89
+ notNull: boolean;
90
+ null: boolean;
91
+ any: any[][];
92
+ from: string;
93
+ to: string;
94
+ };
95
+ export type SdkFilterOptions = {
96
+ sort: SdkFilter;
97
+ _count: number;
98
+ page: number;
99
+ key?: Record<string, SdkFilter> | string | boolean;
100
+ };
43
101
  //# 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;;;;;gBA4CC"}
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;AAED;;;;;;;;;;GAUG;AACH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAJW,gBAAgB,GACd,OAAO,MAAM,EAAE,MAAM,CAAC,CAoBlC;AACD;;;;;;GAMG;AACH,uDAHa,MAAM,CAKlB;AAED;;;;;;GAMG;AACH,iEAHa,MAAM,CAMlB;;UAhEa,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"}
@@ -2,19 +2,4 @@ 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
- };
20
5
  //# 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,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"}
1
+ {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../src/lib/util.mjs"],"names":[],"mappings":"AAAA,2EAsBC;AAiBD,0EAgBC;AAED,wDAKC;AAED,uCAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {