ec.fdk 0.4.1 → 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/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 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
+ ${a.detail}
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,49 +1,49 @@
1
1
  var z = Object.defineProperty, C = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
2
+ var F = 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 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
- N.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
- F.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) => C(n, J(t));
13
- var o = (n, t, e) => new Promise((s, r) => {
14
- var u = (a) => {
12
+ }, p = (n, t) => C(n, F(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 = p(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 = {
@@ -60,11 +60,13 @@ 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(
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)
@@ -82,17 +84,17 @@ function h(n) {
82
84
  throw new Error(`expected ${t} to be set!`);
83
85
  });
84
86
  }
85
- const D = {
87
+ const q = {
86
88
  stage: "https://accounts.cachena.entrecode.de/",
87
89
  live: "https://accounts.entrecode.de/"
88
90
  };
89
- function R(n) {
90
- return o(this, null, function* () {
91
+ function v(n) {
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 = y(`api/${e}/_auth/login?clientID=rest`, t);
94
96
  return yield g(
95
- u,
97
+ l,
96
98
  {},
97
99
  {
98
100
  method: "POST",
@@ -104,11 +106,11 @@ function R(n) {
104
106
  );
105
107
  });
106
108
  }
107
- function v(n) {
108
- return o(this, null, function* () {
109
+ function U(n) {
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
- const r = `${D[t]}auth/login?clientID=rest`;
113
+ const r = `${q[t]}auth/login?clientID=rest`;
112
114
  return yield g(
113
115
  r,
114
116
  {},
@@ -122,11 +124,11 @@ function v(n) {
122
124
  );
123
125
  });
124
126
  }
125
- function U(n) {
126
- return o(this, null, function* () {
127
+ function I(n) {
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
- const r = p(
131
+ const r = y(
130
132
  `api/${t}/_auth/logout?clientID=rest&token=${s}`,
131
133
  e
132
134
  );
@@ -140,10 +142,10 @@ 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
- const s = `${D[t]}auth/logout?clientID=rest`;
148
+ const s = `${q[t]}auth/logout?clientID=rest`;
147
149
  return yield g(
148
150
  s,
149
151
  {
@@ -156,13 +158,13 @@ function M(n) {
156
158
  );
157
159
  });
158
160
  }
159
- function I({ dmShortID: n }) {
161
+ function V({ dmShortID: n }) {
160
162
  return h({ dmShortID: n }), n;
161
163
  }
162
- function V({ env: n }) {
164
+ function G({ env: n }) {
163
165
  return h({ env: n }), n;
164
166
  }
165
- let G = [
167
+ let H = [
166
168
  "created",
167
169
  "creator",
168
170
  "id",
@@ -181,38 +183,38 @@ let G = [
181
183
  function x(n) {
182
184
  let t = {};
183
185
  for (let e in n)
184
- G.includes(e) || (t[e] = n[e]);
186
+ H.includes(e) || (t[e] = n[e]);
185
187
  return t;
186
188
  }
187
- function H(n) {
189
+ function Q(n) {
188
190
  return JSON.parse(JSON.stringify(n));
189
191
  }
190
- function Q(n) {
191
- return o(this, null, function* () {
192
+ function W(n) {
193
+ return a(this, null, function* () {
192
194
  let { env: t, dmShortID: e } = n;
193
195
  h({ env: t, dmShortID: e });
194
- const s = p(`api/${e}`, t);
196
+ const s = y(`api/${e}`, t);
195
197
  return g(s, n);
196
198
  });
197
199
  }
198
- function W(n) {
199
- return o(this, null, function* () {
200
+ function X(n) {
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 = y(`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
- 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 }) {
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 = y(`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 Z(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
- const i = p(`api/${t}/${e}`, n);
217
+ const i = y(`api/${t}/${e}`, n);
216
218
  return yield g(
217
219
  i,
218
220
  { env: n, dmShortID: t, token: r },
@@ -226,41 +228,41 @@ function Y(u) {
226
228
  );
227
229
  });
228
230
  }
229
- function Z(d) {
230
- return o(this, arguments, function* ({
231
+ function tt(d) {
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);
249
- return r = H(r), r = x(r), yield g(
250
- c,
251
- { token: u },
250
+ const u = y(`api/${t}/${e}?_id=${s}`, n);
251
+ return r = Q(r), r = x(r), yield g(
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 et(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
- const i = p(`api/${t}/${e}?_id=${s}`, n);
265
+ const i = y(`api/${t}/${e}?_id=${s}`, n);
264
266
  yield g(
265
267
  i,
266
268
  { token: r, rawRes: !0 },
@@ -273,74 +275,84 @@ function tt(u) {
273
275
  );
274
276
  });
275
277
  }
276
- function et(r) {
277
- return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, withMetadata: s }) {
278
+ function nt(r) {
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 = y(`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), N = m.title.split("<")[0];
292
+ m.type = N, 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 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) {
315
+ return a(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
304
316
  h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
305
- 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);
306
318
  return (yield g(d, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
307
319
  });
308
320
  }
309
- function st(n) {
310
- return o(this, null, function* () {
311
- let { env: t, dmShortID: e, assetGroup: s, token: r, options: u = {} } = n;
312
- h({ env: t, dmShortID: e, assetGroup: s }), u = l({ size: 50, page: 1, _list: !0 }, u);
313
- const i = w(u), d = p(`a/${e}/${s}?${i}`, t), { count: a, total: c, _embedded: f } = yield g(d, { dmShortID: e, token: r });
321
+ function ot(n) {
322
+ return a(this, null, function* () {
323
+ let { env: t, dmShortID: e, assetGroup: s, token: r, options: l = {} } = n;
324
+ h({ env: t, dmShortID: e, assetGroup: s }), l = o({ size: 50, page: 1, _list: !0 }, l);
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 });
314
326
  let $ = f ? f["ec:dm-asset"] : [];
315
- return $ = Array.isArray($) ? $ : [$], { count: a, total: c, items: $ };
327
+ return $ = Array.isArray($) ? $ : [$], { count: c, total: u, items: $ };
316
328
  });
317
329
  }
318
- function rt(d) {
319
- return o(this, arguments, function* ({
330
+ function at(d) {
331
+ return a(this, arguments, function* ({
320
332
  env: n,
321
333
  dmShortID: t,
322
334
  assetGroup: e,
323
335
  token: s,
324
336
  file: r,
325
- name: u,
337
+ name: l,
326
338
  options: i
327
339
  }) {
328
340
  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[$]);
341
+ const c = y(`a/${t}/${e}`, n), u = new FormData();
342
+ return u.append("file", r, l), i && Object.keys(i).forEach(($) => {
343
+ u.append($, i[$]);
332
344
  }), (yield g(
333
- a,
345
+ c,
334
346
  { token: s },
335
347
  {
336
348
  method: "POST",
337
- body: c
349
+ body: u
338
350
  }
339
351
  ))._embedded["ec:dm-asset"];
340
352
  });
341
353
  }
342
- function it(u) {
343
- return o(this, arguments, function* ({
354
+ function ct(l) {
355
+ return a(this, arguments, function* ({
344
356
  env: n,
345
357
  dmShortID: t,
346
358
  assetGroup: e,
@@ -348,7 +360,7 @@ function it(u) {
348
360
  token: r
349
361
  }) {
350
362
  h({ env: n, dmShortID: t, assetGroup: e, assetID: s });
351
- const i = p(`a/${t}/${e}/${s}`, n);
363
+ const i = y(`a/${t}/${e}/${s}`, n);
352
364
  yield g(
353
365
  i,
354
366
  { token: r, rawRes: !0 },
@@ -358,113 +370,116 @@ function it(u) {
358
370
  );
359
371
  });
360
372
  }
361
- function ot(n) {
362
- return o(this, null, function* () {
373
+ function ut(n) {
374
+ return a(this, null, function* () {
363
375
  let { env: t, dmID: e, token: s } = n;
364
376
  h({ env: t, dmID: e });
365
- const r = p(`?dataManagerID=${e}`, t);
377
+ const r = y(`?dataManagerID=${e}`, t);
366
378
  return g(r, { token: s });
367
379
  });
368
380
  }
369
- function at(n) {
370
- return o(this, null, function* () {
381
+ function lt(n) {
382
+ return a(this, null, function* () {
371
383
  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 };
384
+ h({ env: t }), e = o({ size: 25, page: 1, _list: !0 }, e);
385
+ const s = w(e), r = y(`?${s}`, t), { count: l, total: i, _embedded: d } = yield g(r, n);
386
+ let c = d ? d["ec:datamanager"] : [];
387
+ return c = Array.isArray(c) ? c : [c], { count: l, total: i, items: c };
376
388
  });
377
389
  }
378
- function ct(n) {
379
- return o(this, null, function* () {
390
+ function dt(n) {
391
+ return a(this, null, function* () {
380
392
  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 };
393
+ h({ env: t, dmID: e }), s = o({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
394
+ const r = w(s), l = y(`model?${r}`, t), { count: i, total: d, _embedded: c } = yield g(l, n);
395
+ let u = c ? c["ec:model"] : [];
396
+ return u = Array.isArray(u) ? u : [u], { count: i, total: d, items: u };
385
397
  });
386
398
  }
387
- function ut(n) {
388
- return o(this, null, function* () {
399
+ function ht(n) {
400
+ return a(this, null, function* () {
389
401
  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 };
402
+ h({ env: t, subdomain: r, resource: e }), s = o({ size: 25, page: 1, _list: !0 }, s);
403
+ const l = w(s), i = y(`${e}?${l}`, t, r), { count: d, total: c, _embedded: u } = yield g(i, n);
404
+ let f = u ? u[Object.keys(u)[0]] : [];
405
+ return f = Array.isArray(f) ? f : [f], { count: d, total: c, items: f };
394
406
  });
395
407
  }
396
- function lt(e) {
397
- return o(this, arguments, function* (n, t = {}) {
398
- let { env: s, route: r, options: u = {}, subdomain: i = "datamanager" } = n;
399
- h({ env: s, subdomain: i, route: r }), u = l({}, u);
400
- const d = w(u), a = p(`${r}?${d}`, s, i);
401
- return g(a, n, t);
408
+ function gt(e) {
409
+ return a(this, arguments, function* (n, t = {}) {
410
+ let { env: s, route: r, options: l = {}, subdomain: i = "datamanager" } = n;
411
+ h({ env: s, subdomain: i, route: r }), l = o({}, l);
412
+ const d = w(l), c = y(`${r}?${d}`, s, i);
413
+ return g(c, n, t);
402
414
  });
403
415
  }
404
- const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
416
+ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
405
417
  __proto__: null,
406
- assetList: st,
407
- createAsset: rt,
408
- createEntry: Y,
409
- deleteAsset: it,
410
- deleteEntry: tt,
411
- dmList: at,
412
- editEntry: Z,
413
- entryList: W,
414
- getAsset: nt,
415
- getDatamanager: ot,
416
- getEcAuthKey: V,
417
- getEntry: X,
418
- getPublicAuthKey: I,
419
- getSchema: et,
420
- loginEc: v,
421
- 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,
422
436
  logoutEc: M,
423
- logoutPublic: U,
424
- modelList: ct,
425
- publicApi: Q,
426
- raw: lt,
427
- resourceList: ut
437
+ logoutPublic: I,
438
+ modelList: dt,
439
+ publicApi: W,
440
+ raw: gt,
441
+ resourceList: ht,
442
+ sdkOptions: st
428
443
  }, Symbol.toStringTag, { value: "Module" })), {
429
- entryList: dt,
430
- getEntry: ht,
431
- getAsset: gt,
432
- assetList: ft,
433
- createAsset: yt,
434
- deleteAsset: pt,
435
- createEntry: mt,
436
- editEntry: q,
437
- deleteEntry: $t,
438
- getSchema: wt,
439
- loginPublic: kt,
440
- loginEc: At,
441
- logoutEc: Et,
442
- 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,
443
458
  getEcAuthKey: b,
444
459
  getPublicAuthKey: T,
445
- dmList: Tt,
446
- modelList: _t,
447
- publicApi: Pt,
448
- getDatamanager: Lt,
449
- resourceList: Ot,
450
- raw: jt
451
- } = A;
452
- function Bt(n) {
460
+ dmList: Lt,
461
+ modelList: Ot,
462
+ publicApi: jt,
463
+ getDatamanager: St,
464
+ resourceList: Bt,
465
+ raw: Dt
466
+ } = E;
467
+ function xt(n) {
453
468
  const { action: t } = n;
454
- if (h({ action: t }), !A[t])
469
+ if (h({ action: t }), !E[t])
455
470
  throw new Error(
456
- `"${t}" does not exist! try one of ${Object.keys(A).join(
471
+ `"${t}" does not exist! try one of ${Object.keys(E).join(
457
472
  ", "
458
473
  )}`
459
474
  );
460
- return A[t](n);
475
+ return E[t](n);
461
476
  }
462
477
  class _ {
463
478
  constructor(t) {
464
479
  this.config = t;
465
480
  }
466
481
  set(t) {
467
- return new _(l(l({}, this.config), t));
482
+ return new _(o(o({}, this.config), t));
468
483
  }
469
484
  /**
470
485
  * Loads entry list. Expects `dmShortID` / `model` to be set.
@@ -480,13 +495,13 @@ class _ {
480
495
  * const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
481
496
  */
482
497
  entries() {
483
- return o(this, arguments, function* (t = {}) {
498
+ return a(this, arguments, function* (t = {}) {
484
499
  const e = yield this.getBestToken();
485
- return dt(y(l({}, this.config), { options: t, token: e }));
500
+ return ft(p(o({}, this.config), { options: t, token: e }));
486
501
  });
487
502
  }
488
503
  entryList(t) {
489
- return o(this, null, function* () {
504
+ return a(this, null, function* () {
490
505
  return this.entries(t);
491
506
  });
492
507
  }
@@ -500,9 +515,9 @@ class _ {
500
515
  * const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
501
516
  */
502
517
  getEntry(t) {
503
- return o(this, null, function* () {
518
+ return a(this, null, function* () {
504
519
  const e = yield this.getBestToken();
505
- return ht(y(l({}, this.config), { entryID: t, token: e }));
520
+ return pt(p(o({}, this.config), { entryID: t, token: e }));
506
521
  });
507
522
  }
508
523
  /**
@@ -520,9 +535,9 @@ class _ {
520
535
  * .editEntrySafe("1gOtzWvrdq", { name: "test", _modified: "2020-01-01T00:00:00.000Z"})
521
536
  */
522
537
  editEntrySafe(t, e) {
523
- return o(this, null, function* () {
538
+ return a(this, null, function* () {
524
539
  const s = yield this.getBestToken();
525
- return q(y(l({}, 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 }));
526
541
  });
527
542
  }
528
543
  /**
@@ -534,8 +549,8 @@ class _ {
534
549
  * const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
535
550
  */
536
551
  getSchema() {
537
- return o(this, null, function* () {
538
- return wt(this.config);
552
+ return a(this, null, function* () {
553
+ return kt(this.config);
539
554
  });
540
555
  }
541
556
  /**
@@ -552,13 +567,13 @@ class _ {
552
567
  * const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
553
568
  */
554
569
  assets(t) {
555
- return o(this, null, function* () {
570
+ return a(this, null, function* () {
556
571
  const e = yield this.getBestToken();
557
- return ft(y(l({}, this.config), { options: t, token: e }));
572
+ return mt(p(o({}, this.config), { options: t, token: e }));
558
573
  });
559
574
  }
560
575
  assetList(t) {
561
- return o(this, null, function* () {
576
+ return a(this, null, function* () {
562
577
  return this.assets(t);
563
578
  });
564
579
  }
@@ -584,9 +599,9 @@ class _ {
584
599
  * .createAsset({ file, name: "venndiagram.png" });
585
600
  */
586
601
  createAsset() {
587
- return o(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
602
+ return a(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
588
603
  const r = yield this.getBestToken();
589
- return yt(y(l({}, 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 }));
590
605
  });
591
606
  }
592
607
  /**
@@ -599,9 +614,9 @@ class _ {
599
614
  * await ecadmin.assetgroup("test").deleteAsset('xxxx');
600
615
  */
601
616
  deleteAsset(t) {
602
- return o(this, null, function* () {
617
+ return a(this, null, function* () {
603
618
  const e = yield this.getBestToken();
604
- return pt(y(l({}, this.config), { token: e, assetID: t }));
619
+ return wt(p(o({}, this.config), { token: e, assetID: t }));
605
620
  });
606
621
  }
607
622
  /**
@@ -614,9 +629,9 @@ class _ {
614
629
  * const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
615
630
  */
616
631
  getAsset(t) {
617
- return o(this, null, function* () {
632
+ return a(this, null, function* () {
618
633
  const e = yield this.getBestToken();
619
- return gt(y(l({}, this.config), { assetID: t, token: e }));
634
+ return yt(p(o({}, this.config), { assetID: t, token: e }));
620
635
  });
621
636
  }
622
637
  /**
@@ -629,9 +644,9 @@ class _ {
629
644
  * const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
630
645
  */
631
646
  createEntry(t) {
632
- return o(this, null, function* () {
647
+ return a(this, null, function* () {
633
648
  const e = yield this.getBestToken();
634
- return mt(y(l({}, this.config), { token: e, value: t }));
649
+ return At(p(o({}, this.config), { token: e, value: t }));
635
650
  });
636
651
  }
637
652
  /**
@@ -645,9 +660,9 @@ class _ {
645
660
  * const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
646
661
  */
647
662
  editEntry(t, e) {
648
- return o(this, null, function* () {
663
+ return a(this, null, function* () {
649
664
  const s = yield this.getBestToken();
650
- return q(y(l({}, this.config), { entryID: t, token: s, value: e }));
665
+ return D(p(o({}, this.config), { entryID: t, token: s, value: e }));
651
666
  });
652
667
  }
653
668
  /**
@@ -660,9 +675,9 @@ class _ {
660
675
  * await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
661
676
  */
662
677
  deleteEntry(t) {
663
- return o(this, null, function* () {
678
+ return a(this, null, function* () {
664
679
  const e = yield this.getBestToken();
665
- return $t(y(l({}, this.config), { token: e, entryID: t }));
680
+ return Et(p(o({}, this.config), { token: e, entryID: t }));
666
681
  });
667
682
  }
668
683
  /**
@@ -675,9 +690,9 @@ class _ {
675
690
  * const res = await sdk("stage").resource("template").resourceList()
676
691
  */
677
692
  resourceList(t) {
678
- return o(this, null, function* () {
693
+ return a(this, null, function* () {
679
694
  const e = yield this.getBestToken();
680
- return Ot(y(l({}, this.config), { options: t, token: e }));
695
+ return Bt(p(o({}, this.config), { options: t, token: e }));
681
696
  });
682
697
  }
683
698
  /**
@@ -692,9 +707,9 @@ class _ {
692
707
  * const res = await sdk("stage").route("stats").raw()
693
708
  */
694
709
  raw(t, e) {
695
- return o(this, null, function* () {
710
+ return a(this, null, function* () {
696
711
  const s = yield this.getBestToken();
697
- return jt(y(l({}, this.config), { options: t, token: s }), e);
712
+ return Dt(p(o({}, this.config), { options: t, token: s }), e);
698
713
  });
699
714
  }
700
715
  // TODO: rename authAdapter -> storageAdapter
@@ -724,24 +739,24 @@ class _ {
724
739
  return e(t);
725
740
  }
726
741
  loginEc(t) {
727
- return At(l(l({}, this.config), t)).then(
742
+ return Tt(o(o({}, this.config), t)).then(
728
743
  this.setAuth(b(this.config))
729
744
  );
730
745
  }
731
746
  loginPublic(t) {
732
- return kt(l(l({}, this.config), t)).then(
747
+ return bt(o(o({}, this.config), t)).then(
733
748
  this.setAuth(T(this.config))
734
749
  );
735
750
  }
736
751
  logoutPublic() {
737
752
  const t = this.getPublicToken();
738
- return console.log("token", t), bt(y(l({}, this.config), { token: t })).then(
753
+ return console.log("token", t), Pt(p(o({}, this.config), { token: t })).then(
739
754
  this.unsetAuth(T(this.config))
740
755
  );
741
756
  }
742
757
  logoutEc() {
743
758
  const t = this.getEcToken();
744
- return console.log("token", t), Et(y(l({}, this.config), { token: t })).then(
759
+ return console.log("token", t), _t(p(o({}, this.config), { token: t })).then(
745
760
  this.unsetAuth(b(this.config))
746
761
  );
747
762
  }
@@ -852,16 +867,16 @@ class _ {
852
867
  * @returns any
853
868
  */
854
869
  publicApi() {
855
- return Pt(this.config);
870
+ return jt(this.config);
856
871
  }
857
872
  /**
858
873
  * Loads a DatamanagerResource by its long id. Requires token.
859
874
  * @returns any
860
875
  */
861
876
  getDatamanager(t) {
862
- return o(this, null, function* () {
877
+ return a(this, null, function* () {
863
878
  const e = yield this.getBestToken();
864
- return Lt(y(l({}, this.config), { dmID: t, token: e }));
879
+ return St(p(o({}, this.config), { dmID: t, token: e }));
865
880
  });
866
881
  }
867
882
  /**
@@ -873,9 +888,9 @@ class _ {
873
888
  * const dms = await sdk("stage").dmList()
874
889
  */
875
890
  dmList() {
876
- return o(this, arguments, function* (t = {}) {
891
+ return a(this, arguments, function* (t = {}) {
877
892
  const e = yield this.getBestToken();
878
- return Tt(y(l({}, this.config), { options: t, token: e }));
893
+ return Lt(p(o({}, this.config), { options: t, token: e }));
879
894
  });
880
895
  }
881
896
  /**
@@ -887,41 +902,44 @@ class _ {
887
902
  * const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
888
903
  */
889
904
  modelList() {
890
- return o(this, arguments, function* (t = {}) {
905
+ return a(this, arguments, function* (t = {}) {
891
906
  const e = yield this.getBestToken();
892
- return _t(y(l({}, this.config), { options: t, token: e }));
907
+ return Ot(p(o({}, this.config), { options: t, token: e }));
893
908
  });
894
909
  }
895
910
  }
896
- const qt = (n) => new _({ env: n });
911
+ const Kt = (n) => new _({ env: n });
897
912
  export {
898
913
  _ as Sdk,
899
- Bt as act,
900
- p as apiURL,
901
- st as assetList,
902
- rt as createAsset,
903
- Y as createEntry,
904
- it as deleteAsset,
905
- tt as deleteEntry,
906
- at as dmList,
907
- Z as editEntry,
908
- W as entryList,
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,
909
924
  h as expect,
910
925
  g as fetcher,
911
- nt as getAsset,
912
- ot as getDatamanager,
913
- V as getEcAuthKey,
914
- X as getEntry,
915
- I as getPublicAuthKey,
916
- et as getSchema,
917
- v as loginEc,
918
- 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,
919
936
  M as logoutEc,
920
- U as logoutPublic,
921
- ct as modelList,
922
- Q as publicApi,
937
+ I as logoutPublic,
938
+ dt as modelList,
939
+ W as publicApi,
923
940
  w as query,
924
- lt as raw,
925
- ut as resourceList,
926
- qt as sdk
941
+ gt as raw,
942
+ ht as resourceList,
943
+ Kt as sdk,
944
+ st as sdkOptions
927
945
  };
@@ -286,6 +286,8 @@ export type AssetResource = {
286
286
  tags: Array<string | any>;
287
287
  title: string;
288
288
  type: string;
289
+ mimetype: string;
290
+ duplicates: number;
289
291
  file: AssetFile;
290
292
  };
291
293
  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;I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AKT,MAAM;;;;cACN,IAAI;;;;cACJ,MAAM;;;;eACN,GAAG;;;;YACH,GAAG;;;;iBACH,MAAM;;;;sBACN,MAAM;;;;eACN,IAAI;;;;aACJ,IAAI;;;;cACJ,IAAI;;;;UACJ,GAAG;;;;;;aAOH,GAAG;;;;iBACH,MAAM;;;;cACN,OAAO;;;;cACP,OAAO;;;;UACP,MAAM;;;;cACN,MAAM;;;QAIC,MAAM,GAAE,gBAAgB;;;WAK/B,MAAM;WACN,MAAM;WACN,aAAa,EAAE;;;aAKf,MAAM;mBACN,MAAM;mBACN,MAAM;iBACN,MAAM;YACN,GAAG;cACH,MAAM;aACN,MAAM,EAAE;YACR,MAAM,EAAE;uBACR,MAAM,EAAE;aACR,MAAM;WACN,MAAM;;;;YACN,GAAG;;;WAKH,MAAM;WACN,MAAM;WACN,mBAAmB,EAAE;;;WAKrB,MAAM;WACN,MAAM;WACN,aAAa,EAAE;;;WAKf,MAAM;WACN,MAAM;WACN,GAAG,EAAE;;;;;;aAML,GAAG;iBACH,MAAM;iBACN,OAAO;aACP,OAAO;cACP,OAAO;cACP,OAAO;YACP,OAAO;WACP,MAAM;UACN,MAAM;gBACN,MAAM,GAAG,IAAI;;;YAKb,GAAG;aACH,MAAM;iBACN,MAAM;YACN,gBAAgB,EAAE;gBAClB,OAAO;cACP,MAAM;WACN,GAAG,EAAE;eACL,GAAG,EAAE;aACL,MAAM,EAAE;aACR,MAAM;cACN,MAAM;cACN,GAAG,EAAE;UACL,GAAG;WACH,MAAM;gBACN,MAAM;YACN,GAAG;;;WAMH,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
@@ -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"}
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ec.fdk",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "ec frontend sdk",
5
5
  "main": "dist/index.cjs",
6
6
  "directories": {