ec.fdk 0.2.24 → 0.2.26
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 +2 -2
- package/dist/index.mjs +366 -240
- package/dist/lib/admin.d.mts +6 -0
- package/dist/lib/admin.d.mts.map +1 -1
- package/dist/lib/api.d.mts +102 -5
- package/dist/lib/api.d.mts.map +1 -1
- package/dist/lib/entries.d.mts +6 -0
- package/dist/lib/entries.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Z=Object.defineProperty,tt=Object.defineProperties;var et=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var O=(n,t,e)=>t in n?Z(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,l=(n,t)=>{for(var e in t||(t={}))nt.call(t,e)&&O(n,e,t[e]);if(L)for(var e of L(t))st.call(t,e)&&O(n,e,t[e]);return n},f=(n,t)=>tt(n,et(t));var o=(n,t,e)=>new Promise((s,r)=>{var u=c=>{try{a(e.next(c))}catch(h){r(h)}},i=c=>{try{a(e.throw(c))}catch(h){r(h)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(u,i);a((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 a;const{token:r,rawRes:u}=t;r&&(e.headers=f(l({},e.headers||{}),{Authorization:`Bearer ${r}`}));const i=yield fetch(n,e);if(!i.ok){if((a=i.headers.get("content-type"))!=null&&a.includes("application/json")){const c=yield i.json(),h=`${c.title}
|
|
2
2
|
${c.detail}
|
|
3
|
-
${c.verbose}`;throw new Error(d)}throw new Error(`unexpected fetch error: ${r.statusText}`)}return u?r:yield r.json()})}const P={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function f(n,t="stage"){const e=P[t];if(!e)throw new Error(`env "${t}" not found. Try one of ${Object.keys(P).join(", ")}`);return e+n}function E(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function g(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const j={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function L(n){return i(this,null,function*(){let{env:t,dmShortID:e,email:s,password:o}=n;g({env:t,dmShortID:e,email:s,password:o});const u=f(`api/${e}/_auth/login?clientID=rest`,t);return yield l(u,{},{method:"POST",body:JSON.stringify({email:s,password:o}),headers:{"Content-Type":"application/json"}})})}function O(n){return i(this,null,function*(){let{env:t,email:e,password:s}=n;g({env:t,email:e,password:s});const o=`${j[t]}auth/login?clientID=rest`;return yield l(o,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function _(n){return i(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;g({dmShortID:t,env:e,token:s});const o=f(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield l(o,{dmShortID:t,rawRes:!0},{method:"POST"})})}function B(n){return i(this,null,function*(){let{env:t,token:e}=n;g({env:t,token:e});const s=`${j[t]}auth/logout?clientID=rest`;return yield l(s,{rawRes:!0,token:e},{method:"POST"})})}function S({dmShortID:n}){return g({dmShortID:n}),n}function K({env:n}){return g({env:n}),n}function q(n){return i(this,null,function*(){let{env:t,dmShortID:e,model:s,options:o={}}=n;g({env:t,dmShortID:e,model:s}),o=a({size:50,page:1,_list:!0},o);const u=E(o),r=f(`api/${e}/${s}?${u}`,t),{count:h,total:c,_embedded:d}=yield l(r,n);let $=d?d[`${e}:${s}`]:[];return $=Array.isArray($)?$:[$],{count:h,total:c,items:$}})}function R({env:n,dmShortID:t,model:e,entryID:s,token:o}){g({env:n,dmShortID:t,model:e,entryID:s});const u=E({_id:s}),r=f(`api/${t}/${e}?${u}`,n);return l(r,{dmShortID:t,token:o})}function x(u){return i(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:o}){g({env:n,dmShortID:t,model:e,value:s});const r=f(`api/${t}/${e}`,n);return yield l(r,{env:n,dmShortID:t,token:o},{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})})}function C(r){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:o,token:u}){g({env:n,dmShortID:t,model:e,entryID:s,value:o});const h=f(`api/${t}/${e}?_id=${s}`,n);return yield l(h,{token:u},{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})})}function z(u){return i(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:o}){g({env:n,dmShortID:t,model:e,entryID:s});const r=f(`api/${t}/${e}?_id=${s}`,n);yield l(r,{token:o,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function J(u){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){g({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=E({assetID:s}),h=f(`a/${t}/${e}?${r}`,n);return(yield l(h,{dmShortID:t,token:o}))._embedded["ec:dm-asset"]})}function N(n){return i(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:o,options:u={}}=n;g({env:t,dmShortID:e,assetGroup:s}),u=a({size:50,page:1,_list:!0},u);const r=E(u),h=f(`a/${e}/${s}?${r}`,t),{count:c,total:d,_embedded:$}=yield l(h,{dmShortID:e,token:o});let p=$?$["ec:dm-asset"]:[];return p=Array.isArray(p)?p:[p],{count:c,total:d,items:p}})}function v(h){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:o,name:u,options:r}){g({env:n,dmShortID:t,assetGroup:e,file:o});const c=f(`a/${t}/${e}`,n),d=new FormData;return d.append("file",o,u),r&&Object.keys(r).forEach(p=>{d.append(p,r[p])}),(yield l(c,{token:s},{method:"POST",body:d}))._embedded["ec:dm-asset"]})}function U(u){return i(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:o}){g({env:n,dmShortID:t,assetGroup:e,assetID:s});const r=f(`a/${t}/${e}/${s}`,n);yield l(r,{token:o,rawRes:!0},{method:"DELETE"})})}function M(n){return i(this,null,function*(){let{env:t,options:e={}}=n;g({env:t}),e=a({size:25,page:1,_list:!0},e);const s=E(e),o=f(`?${s}`,t),{count:u,total:r,_embedded:h}=yield l(o,n);let c=h?h["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:u,total:r,items:c}})}const k=Object.freeze(Object.defineProperty({__proto__:null,assetList:N,createAsset:v,createEntry:x,deleteAsset:U,deleteEntry:z,dmList:M,editEntry:C,entryList:q,getAsset:J,getEcAuthKey:K,getEntry:R,getPublicAuthKey:S,loginEc:O,loginPublic:L,logoutEc:B,logoutPublic:_},Symbol.toStringTag,{value:"Module"})),{entryList:W,getEntry:X,getAsset:Y,assetList:Z,createAsset:D,deleteAsset:I,createEntry:tt,editEntry:et,deleteEntry:nt,loginPublic:st,loginEc:ot,logoutEc:rt,logoutPublic:it,getEcAuthKey:w,getPublicAuthKey:b,dmList:ct}=k;function at(n){const{action:t}=n;if(g({action:t}),!k[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(k).join(", ")}`);return k[t](n)}class A{constructor(t){this.config=t}set(t){return new A(a(a({},this.config),t))}entries(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return W(y(a({},this.config),{options:t,token:e}))})}entryList(t){return i(this,null,function*(){return this.entries(t)})}getEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return X(y(a({},this.config),{entryID:t,token:e}))})}assets(t){return i(this,null,function*(){const e=yield this.getBestToken();return Z(y(a({},this.config),{options:t,token:e}))})}assetList(t){return i(this,null,function*(){return this.assets(t)})}createAsset(){return i(this,arguments,function*({file:t,name:e,options:s}={}){const o=yield this.getBestToken();return D(y(a({},this.config),{file:t,name:e,options:s,token:o}))})}deleteAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return I(y(a({},this.config),{token:e,assetID:t}))})}getAsset(t){return i(this,null,function*(){const e=yield this.getBestToken();return Y(y(a({},this.config),{assetID:t,token:e}))})}createEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return tt(y(a({},this.config),{token:e,value:t}))})}editEntry(t,e){return i(this,null,function*(){const s=yield this.getBestToken();return et(y(a({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return i(this,null,function*(){const e=yield this.getBestToken();return nt(y(a({},this.config),{token:e,entryID:t}))})}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 ot(a(a({},this.config),t)).then(this.setAuth(w(this.config)))}loginPublic(t){return st(a(a({},this.config),t)).then(this.setAuth(b(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),it(y(a({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),rt(y(a({},this.config),{token:t})).then(this.unsetAuth(w(this.config)))}getPublicToken(){return this.config.token||this.getAuth(b(this.config))}getEcToken(){return this.config.token||this.getAuth(w(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})}dm(t){return this.dmShortID(t)}assetGroup(t){return this.set({assetGroup:t})}assetgroup(t){return this.assetGroup(t)}dmList(){return i(this,arguments,function*(t={}){const e=yield this.getBestToken();return ct(y(a({},this.config),{options:t,token:e}))})}}const ut=n=>new A({env:n});exports.Sdk=A;exports.act=at;exports.apiURL=f;exports.assetList=N;exports.createAsset=v;exports.createEntry=x;exports.deleteAsset=U;exports.deleteEntry=z;exports.dmList=M;exports.editEntry=C;exports.entryList=q;exports.expect=g;exports.fetcher=l;exports.getAsset=J;exports.getEcAuthKey=K;exports.getEntry=R;exports.getPublicAuthKey=S;exports.loginEc=O;exports.loginPublic=L;exports.logoutEc=B;exports.logoutPublic=_;exports.query=E;exports.sdk=ut;
|
|
3
|
+
${c.verbose}`;throw new Error(h)}throw new Error(`unexpected fetch error: ${i.statusText}`)}return u?i:yield i.json()})}const j={live:"https://datamanager.entrecode.de/",stage:"https://datamanager.cachena.entrecode.de/"};function y(n,t="stage"){const e=j[t];if(!e)throw new Error(`env "${t}" not found. Try one of ${Object.keys(j).join(", ")}`);return e+n}function k(n,t=!0){return Object.entries(n).sort((e,s)=>e[0].localeCompare(s[0])).map(([e,s])=>`${e}=${s}`).join("&")}function d(n){Object.entries(n).forEach(([t,e])=>{if(e===void 0)throw new Error(`expected ${t} to be set!`)})}const S={stage:"https://accounts.cachena.entrecode.de/",live:"https://accounts.entrecode.de/"};function B(n){return o(this,null,function*(){let{env:t,dmShortID:e,email:s,password:r}=n;d({env:t,dmShortID:e,email:s,password:r});const u=y(`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 q(n){return o(this,null,function*(){let{env:t,email:e,password:s}=n;d({env:t,email:e,password:s});const r=`${S[t]}auth/login?clientID=rest`;return yield g(r,{},{method:"POST",body:JSON.stringify({email:e,password:s}),headers:{"Content-Type":"application/json"}})})}function D(n){return o(this,null,function*(){let{dmShortID:t,env:e,token:s}=n;d({dmShortID:t,env:e,token:s});const r=y(`api/${t}/_auth/logout?clientID=rest&token=${s}`,e);return yield g(r,{dmShortID:t,rawRes:!0},{method:"POST"})})}function K(n){return o(this,null,function*(){let{env:t,token:e}=n;d({env:t,token:e});const s=`${S[t]}auth/logout?clientID=rest`;return yield g(s,{rawRes:!0,token:e},{method:"POST"})})}function x({dmShortID:n}){return d({dmShortID:n}),n}function R({env:n}){return d({env:n}),n}function v(n){return o(this,null,function*(){let{env:t,dmShortID:e}=n;d({env:t,dmShortID:e});const s=y(`api/${e}`,t);return g(s,n)})}function z(n){return o(this,null,function*(){let{env:t,dmShortID:e,model:s,options:r={}}=n;d({env:t,dmShortID:e,model:s}),r=l({size:50,page:1,_list:!0},r);const u=k(r),i=y(`api/${e}/${s}?${u}`,t),{count:a,total:c,_embedded:h}=yield g(i,n);let p=h?h[`${e}:${s}`]:[];return p=Array.isArray(p)?p:[p],{count:a,total:c,items:p}})}function C({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const u=k({_id:s}),i=y(`api/${t}/${e}?${u}`,n);return g(i,{dmShortID:t,token:r})}function J(u){return o(this,arguments,function*({env:n,dmShortID:t,model:e,value:s,token:r}){d({env:n,dmShortID:t,model:e,value:s});const i=y(`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 N(i){return o(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,value:r,token:u}){d({env:n,dmShortID:t,model:e,entryID:s,value:r});const a=y(`api/${t}/${e}?_id=${s}`,n);return yield g(a,{token:u},{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}})})}function M(u){return o(this,arguments,function*({env:n,dmShortID:t,model:e,entryID:s,token:r}){d({env:n,dmShortID:t,model:e,entryID:s});const i=y(`api/${t}/${e}?_id=${s}`,n);yield g(i,{token:r,rawRes:!0},{method:"DELETE",headers:{"Content-Type":"application/json"}})})}function U(s){return o(this,arguments,function*({env:n,dmShortID:t,model:e}){var h,p,$,P,_;d({env:n,dmShortID:t,model:e});const r=y(`api/schema/${t}/${e}`,n),u=yield g(r),i=(h=u==null?void 0:u.allOf)==null?void 0:h[1];if(typeof i.properties!="object")throw new Error(`getSchema: ${r} returned unexpected format: ${JSON.stringify(u)}`);const{properties:a}=i;let c=["created","creator","id","modified","private","_created","_creator","_embedded","_entryTitle","_id","_links","_modelTitle","_modelTitleField","_modified"];for(let A in a){let m=a[A];if(m.required=i.required.includes(A),c.includes(A)){delete a[A];continue}if((p=a[A])!=null&&p.oneOf&&(($=a[A])==null||delete $.oneOf),(P=m.title)!=null&&P.includes("<")&&((_=m.title)!=null&&_.includes(">"))){const X=m.title.split("<")[1].slice(0,-1),Y=m.title.split("<")[0];m.type=Y,m.resource=X,delete a[A].title}["asset","entry","assets","entries"].includes(m.title)&&(m.type=m.title,m.resource=null,delete a[A].title)}return a})}function F(u){return o(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){d({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=k({assetID:s}),a=y(`a/${t}/${e}?${i}`,n);return(yield g(a,{dmShortID:t,token:r}))._embedded["ec:dm-asset"]})}function G(n){return o(this,null,function*(){let{env:t,dmShortID:e,assetGroup:s,token:r,options:u={}}=n;d({env:t,dmShortID:e,assetGroup:s}),u=l({size:50,page:1,_list:!0},u);const i=k(u),a=y(`a/${e}/${s}?${i}`,t),{count:c,total:h,_embedded:p}=yield g(a,{dmShortID:e,token:r});let $=p?p["ec:dm-asset"]:[];return $=Array.isArray($)?$:[$],{count:c,total:h,items:$}})}function H(a){return o(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,token:s,file:r,name:u,options:i}){d({env:n,dmShortID:t,assetGroup:e,file:r});const c=y(`a/${t}/${e}`,n),h=new FormData;return h.append("file",r,u),i&&Object.keys(i).forEach($=>{h.append($,i[$])}),(yield g(c,{token:s},{method:"POST",body:h}))._embedded["ec:dm-asset"]})}function I(u){return o(this,arguments,function*({env:n,dmShortID:t,assetGroup:e,assetID:s,token:r}){d({env:n,dmShortID:t,assetGroup:e,assetID:s});const i=y(`a/${t}/${e}/${s}`,n);yield g(i,{token:r,rawRes:!0},{method:"DELETE"})})}function Q(n){return o(this,null,function*(){let{env:t,dmID:e,token:s}=n;d({env:t,dmID:e});const r=y(`?dataManagerID=${e}`,t);return g(r,{token:s})})}function V(n){return o(this,null,function*(){let{env:t,options:e={}}=n;d({env:t}),e=l({size:25,page:1,_list:!0},e);const s=k(e),r=y(`?${s}`,t),{count:u,total:i,_embedded:a}=yield g(r,n);let c=a?a["ec:datamanager"]:[];return c=Array.isArray(c)?c:[c],{count:u,total:i,items:c}})}function W(n){return o(this,null,function*(){let{env:t,dmID:e,options:s={}}=n;d({env:t,dmID:e}),s=l({size:25,dataManagerID:e,page:1,_list:!0},s);const r=k(s),u=y(`model?${r}`,t),{count:i,total:a,_embedded:c}=yield g(u,n);let h=c?c["ec:model"]:[];return h=Array.isArray(h)?h:[h],{count:i,total:a,items:h}})}const w=Object.freeze(Object.defineProperty({__proto__:null,assetList:G,createAsset:H,createEntry:J,deleteAsset:I,deleteEntry:M,dmList:V,editEntry:N,entryList:z,getAsset:F,getDatamanager:Q,getEcAuthKey:R,getEntry:C,getPublicAuthKey:x,getSchema:U,loginEc:q,loginPublic:B,logoutEc:K,logoutPublic:D,modelList:W,publicApi:v},Symbol.toStringTag,{value:"Module"})),{entryList:rt,getEntry:it,getAsset:ot,assetList:ct,createAsset:at,deleteAsset:ut,createEntry:lt,editEntry:ht,deleteEntry:dt,getSchema:gt,loginPublic:yt,loginEc:ft,logoutEc:pt,logoutPublic:$t,getEcAuthKey:b,getPublicAuthKey:T,dmList:mt,modelList:At,publicApi:kt,getDatamanager:wt}=w;function Et(n){const{action:t}=n;if(d({action:t}),!w[t])throw new Error(`"${t}" does not exist! try one of ${Object.keys(w).join(", ")}`);return w[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 rt(f(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 it(f(l({},this.config),{entryID:t,token:e}))})}getSchema(){return o(this,null,function*(){return gt(this.config)})}assets(t){return o(this,null,function*(){const e=yield this.getBestToken();return ct(f(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 at(f(l({},this.config),{file:t,name:e,options:s,token:r}))})}deleteAsset(t){return o(this,null,function*(){const e=yield this.getBestToken();return ut(f(l({},this.config),{token:e,assetID:t}))})}getAsset(t){return o(this,null,function*(){const e=yield this.getBestToken();return ot(f(l({},this.config),{assetID:t,token:e}))})}createEntry(t){return o(this,null,function*(){const e=yield this.getBestToken();return lt(f(l({},this.config),{token:e,value:t}))})}editEntry(t,e){return o(this,null,function*(){const s=yield this.getBestToken();return ht(f(l({},this.config),{entryID:t,token:s,value:e}))})}deleteEntry(t){return o(this,null,function*(){const e=yield this.getBestToken();return dt(f(l({},this.config),{token:e,entryID:t}))})}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 ft(l(l({},this.config),t)).then(this.setAuth(b(this.config)))}loginPublic(t){return yt(l(l({},this.config),t)).then(this.setAuth(T(this.config)))}logoutPublic(){const t=this.getPublicToken();return console.log("token",t),$t(f(l({},this.config),{token:t})).then(this.unsetAuth(T(this.config)))}logoutEc(){const t=this.getEcToken();return console.log("token",t),pt(f(l({},this.config),{token:t})).then(this.unsetAuth(b(this.config)))}getPublicToken(){return this.config.token||this.getAuth(T(this.config))}getEcToken(){return this.config.token||this.getAuth(b(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)}publicApi(){return kt(this.config)}getDatamanager(t){return o(this,null,function*(){const e=yield this.getBestToken();return wt(f(l({},this.config),{dmID:t,token:e}))})}dmList(){return o(this,arguments,function*(t={}){const e=yield this.getBestToken();return mt(f(l({},this.config),{options:t,token:e}))})}modelList(){return o(this,arguments,function*(t={}){const e=yield this.getBestToken();return At(f(l({},this.config),{options:t,token:e}))})}}const bt=n=>new E({env:n});exports.Sdk=E;exports.act=Et;exports.apiURL=y;exports.assetList=G;exports.createAsset=H;exports.createEntry=J;exports.deleteAsset=I;exports.deleteEntry=M;exports.dmList=V;exports.editEntry=N;exports.entryList=z;exports.expect=d;exports.fetcher=g;exports.getAsset=F;exports.getDatamanager=Q;exports.getEcAuthKey=R;exports.getEntry=C;exports.getPublicAuthKey=x;exports.getSchema=U;exports.loginEc=q;exports.loginPublic=B;exports.logoutEc=K;exports.logoutPublic=D;exports.modelList=W;exports.publicApi=v;exports.query=k;exports.sdk=bt;
|
package/dist/index.mjs
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var D = Object.defineProperty, K = Object.defineProperties;
|
|
2
|
+
var x = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var L = Object.getOwnPropertySymbols;
|
|
4
|
+
var z = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var O = (n, t, e) => t in n ? D(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, l = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
z.call(t, e) && O(n, e, t[e]);
|
|
8
|
+
if (L)
|
|
9
|
+
for (var e of L(t))
|
|
10
|
+
C.call(t, e) && O(n, e, t[e]);
|
|
11
11
|
return n;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var u = (
|
|
12
|
+
}, y = (n, t) => K(n, x(t));
|
|
13
|
+
var o = (n, t, e) => new Promise((s, r) => {
|
|
14
|
+
var u = (a) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
|
|
16
|
+
c(e.next(a));
|
|
17
|
+
} catch (h) {
|
|
18
|
+
r(h);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, i = (a) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
22
|
+
c(e.throw(a));
|
|
23
|
+
} catch (h) {
|
|
24
|
+
r(h);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, c = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(u, i);
|
|
27
|
+
c((e = e.apply(n, t)).next());
|
|
28
28
|
});
|
|
29
|
-
function
|
|
30
|
-
return
|
|
31
|
-
var
|
|
32
|
-
const { token:
|
|
33
|
-
|
|
34
|
-
Authorization: `Bearer ${
|
|
29
|
+
function g(s) {
|
|
30
|
+
return o(this, arguments, function* (n, t = {}, e = {}) {
|
|
31
|
+
var c;
|
|
32
|
+
const { token: r, rawRes: u } = t;
|
|
33
|
+
r && (e.headers = y(l({}, e.headers || {}), {
|
|
34
|
+
Authorization: `Bearer ${r}`
|
|
35
35
|
}));
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
if ((
|
|
39
|
-
const
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
throw new Error(
|
|
36
|
+
const i = yield fetch(n, e);
|
|
37
|
+
if (!i.ok) {
|
|
38
|
+
if ((c = i.headers.get("content-type")) != null && c.includes("application/json")) {
|
|
39
|
+
const a = yield i.json(), h = `${a.title}
|
|
40
|
+
${a.detail}
|
|
41
|
+
${a.verbose}`;
|
|
42
|
+
throw new Error(h);
|
|
43
43
|
}
|
|
44
|
-
throw new Error(`unexpected fetch error: ${
|
|
44
|
+
throw new Error(`unexpected fetch error: ${i.statusText}`);
|
|
45
45
|
}
|
|
46
|
-
return u ?
|
|
46
|
+
return u ? i : yield i.json();
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const j = {
|
|
50
50
|
live: "https://datamanager.entrecode.de/",
|
|
51
51
|
stage: "https://datamanager.cachena.entrecode.de/"
|
|
52
52
|
};
|
|
53
53
|
function f(n, t = "stage") {
|
|
54
|
-
const e =
|
|
54
|
+
const e = j[t];
|
|
55
55
|
if (!e)
|
|
56
56
|
throw new Error(
|
|
57
|
-
`env "${t}" not found. Try one of ${Object.keys(
|
|
57
|
+
`env "${t}" not found. Try one of ${Object.keys(j).join(", ")}`
|
|
58
58
|
);
|
|
59
59
|
return e + n;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function w(n, t = !0) {
|
|
62
62
|
return Object.entries(n).sort((e, s) => e[0].localeCompare(s[0])).map(([e, s]) => `${e}=${s}`).join("&");
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function d(n) {
|
|
65
65
|
Object.entries(n).forEach(([t, e]) => {
|
|
66
66
|
if (e === void 0)
|
|
67
67
|
throw new Error(`expected ${t} to be set!`);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const S = {
|
|
71
71
|
stage: "https://accounts.cachena.entrecode.de/",
|
|
72
72
|
live: "https://accounts.entrecode.de/"
|
|
73
73
|
};
|
|
74
|
-
function
|
|
75
|
-
return
|
|
76
|
-
let { env: t, dmShortID: e, email: s, password:
|
|
77
|
-
|
|
74
|
+
function R(n) {
|
|
75
|
+
return o(this, null, function* () {
|
|
76
|
+
let { env: t, dmShortID: e, email: s, password: r } = n;
|
|
77
|
+
d({ env: t, dmShortID: e, email: s, password: r });
|
|
78
78
|
const u = f(`api/${e}/_auth/login?clientID=rest`, t);
|
|
79
|
-
return yield
|
|
79
|
+
return yield g(
|
|
80
80
|
u,
|
|
81
81
|
{},
|
|
82
82
|
{
|
|
83
83
|
method: "POST",
|
|
84
|
-
body: JSON.stringify({ email: s, password:
|
|
84
|
+
body: JSON.stringify({ email: s, password: r }),
|
|
85
85
|
headers: {
|
|
86
86
|
"Content-Type": "application/json"
|
|
87
87
|
}
|
|
@@ -89,13 +89,13 @@ function S(n) {
|
|
|
89
89
|
);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return
|
|
92
|
+
function v(n) {
|
|
93
|
+
return o(this, null, function* () {
|
|
94
94
|
let { env: t, email: e, password: s } = n;
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
return yield
|
|
98
|
-
|
|
95
|
+
d({ env: t, email: e, password: s });
|
|
96
|
+
const r = `${S[t]}auth/login?clientID=rest`;
|
|
97
|
+
return yield g(
|
|
98
|
+
r,
|
|
99
99
|
{},
|
|
100
100
|
{
|
|
101
101
|
method: "POST",
|
|
@@ -107,16 +107,16 @@ function q(n) {
|
|
|
107
107
|
);
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
return
|
|
110
|
+
function J(n) {
|
|
111
|
+
return o(this, null, function* () {
|
|
112
112
|
let { dmShortID: t, env: e, token: s } = n;
|
|
113
|
-
|
|
114
|
-
const
|
|
113
|
+
d({ dmShortID: t, env: e, token: s });
|
|
114
|
+
const r = f(
|
|
115
115
|
`api/${t}/_auth/logout?clientID=rest&token=${s}`,
|
|
116
116
|
e
|
|
117
117
|
);
|
|
118
|
-
return yield
|
|
119
|
-
|
|
118
|
+
return yield g(
|
|
119
|
+
r,
|
|
120
120
|
{ dmShortID: t, rawRes: !0 },
|
|
121
121
|
{
|
|
122
122
|
method: "POST"
|
|
@@ -124,12 +124,12 @@ function x(n) {
|
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
return
|
|
127
|
+
function N(n) {
|
|
128
|
+
return o(this, null, function* () {
|
|
129
129
|
let { env: t, token: e } = n;
|
|
130
|
-
|
|
131
|
-
const s = `${
|
|
132
|
-
return yield
|
|
130
|
+
d({ env: t, token: e });
|
|
131
|
+
const s = `${S[t]}auth/logout?clientID=rest`;
|
|
132
|
+
return yield g(
|
|
133
133
|
s,
|
|
134
134
|
{
|
|
135
135
|
rawRes: !0,
|
|
@@ -141,33 +141,41 @@ function C(n) {
|
|
|
141
141
|
);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function M({ dmShortID: n }) {
|
|
145
|
+
return d({ dmShortID: n }), n;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
return
|
|
147
|
+
function F({ env: n }) {
|
|
148
|
+
return d({ env: n }), n;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
152
|
-
let { env: t, dmShortID: e
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
function U(n) {
|
|
151
|
+
return o(this, null, function* () {
|
|
152
|
+
let { env: t, dmShortID: e } = n;
|
|
153
|
+
d({ env: t, dmShortID: e });
|
|
154
|
+
const s = f(`api/${e}`, t);
|
|
155
|
+
return g(s, n);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function G(n) {
|
|
159
|
+
return o(this, null, function* () {
|
|
160
|
+
let { env: t, dmShortID: e, model: s, options: r = {} } = n;
|
|
161
|
+
d({ env: t, dmShortID: e, model: s }), r = l({ size: 50, page: 1, _list: !0 }, r);
|
|
162
|
+
const u = w(r), i = f(`api/${e}/${s}?${u}`, t), { count: c, total: a, _embedded: h } = yield g(i, n);
|
|
163
|
+
let p = h ? h[`${e}:${s}`] : [];
|
|
164
|
+
return p = Array.isArray(p) ? p : [p], { count: c, total: a, items: p };
|
|
157
165
|
});
|
|
158
166
|
}
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
const u =
|
|
162
|
-
return
|
|
167
|
+
function H({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
168
|
+
d({ env: n, dmShortID: t, model: e, entryID: s });
|
|
169
|
+
const u = w({ _id: s }), i = f(`api/${t}/${e}?${u}`, n);
|
|
170
|
+
return g(i, { dmShortID: t, token: r });
|
|
163
171
|
}
|
|
164
|
-
function
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
return yield
|
|
169
|
-
|
|
170
|
-
{ env: n, dmShortID: t, token:
|
|
172
|
+
function I(u) {
|
|
173
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, value: s, token: r }) {
|
|
174
|
+
d({ env: n, dmShortID: t, model: e, value: s });
|
|
175
|
+
const i = f(`api/${t}/${e}`, n);
|
|
176
|
+
return yield g(
|
|
177
|
+
i,
|
|
178
|
+
{ env: n, dmShortID: t, token: r },
|
|
171
179
|
{
|
|
172
180
|
method: "POST",
|
|
173
181
|
body: JSON.stringify(s),
|
|
@@ -178,23 +186,23 @@ function v(u) {
|
|
|
178
186
|
);
|
|
179
187
|
});
|
|
180
188
|
}
|
|
181
|
-
function
|
|
182
|
-
return
|
|
189
|
+
function Q(i) {
|
|
190
|
+
return o(this, arguments, function* ({
|
|
183
191
|
env: n,
|
|
184
192
|
dmShortID: t,
|
|
185
193
|
model: e,
|
|
186
194
|
entryID: s,
|
|
187
|
-
value:
|
|
195
|
+
value: r,
|
|
188
196
|
token: u
|
|
189
197
|
}) {
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
return yield
|
|
193
|
-
|
|
198
|
+
d({ env: n, dmShortID: t, model: e, entryID: s, value: r });
|
|
199
|
+
const c = f(`api/${t}/${e}?_id=${s}`, n);
|
|
200
|
+
return yield g(
|
|
201
|
+
c,
|
|
194
202
|
{ token: u },
|
|
195
203
|
{
|
|
196
204
|
method: "PUT",
|
|
197
|
-
body: JSON.stringify(
|
|
205
|
+
body: JSON.stringify(r),
|
|
198
206
|
headers: {
|
|
199
207
|
"Content-Type": "application/json"
|
|
200
208
|
}
|
|
@@ -202,13 +210,13 @@ function U(r) {
|
|
|
202
210
|
);
|
|
203
211
|
});
|
|
204
212
|
}
|
|
205
|
-
function
|
|
206
|
-
return
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
yield
|
|
210
|
-
|
|
211
|
-
{ token:
|
|
213
|
+
function V(u) {
|
|
214
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, model: e, entryID: s, token: r }) {
|
|
215
|
+
d({ env: n, dmShortID: t, model: e, entryID: s });
|
|
216
|
+
const i = f(`api/${t}/${e}?_id=${s}`, n);
|
|
217
|
+
yield g(
|
|
218
|
+
i,
|
|
219
|
+
{ token: r, rawRes: !0 },
|
|
212
220
|
{
|
|
213
221
|
method: "DELETE",
|
|
214
222
|
headers: {
|
|
@@ -218,126 +226,192 @@ function F(u) {
|
|
|
218
226
|
);
|
|
219
227
|
});
|
|
220
228
|
}
|
|
221
|
-
function
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
229
|
+
function W(s) {
|
|
230
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, model: e }) {
|
|
231
|
+
var h, p, $, P, _;
|
|
232
|
+
d({ env: n, dmShortID: t, model: e });
|
|
233
|
+
const r = f(`api/schema/${t}/${e}`, n), u = yield g(r), i = (h = u == null ? void 0 : u.allOf) == null ? void 0 : h[1];
|
|
234
|
+
if (typeof i.properties != "object")
|
|
235
|
+
throw new Error(
|
|
236
|
+
`getSchema: ${r} returned unexpected format: ${JSON.stringify(u)}`
|
|
237
|
+
);
|
|
238
|
+
const { properties: c } = i;
|
|
239
|
+
let a = [
|
|
240
|
+
"created",
|
|
241
|
+
"creator",
|
|
242
|
+
"id",
|
|
243
|
+
"modified",
|
|
244
|
+
"private",
|
|
245
|
+
"_created",
|
|
246
|
+
"_creator",
|
|
247
|
+
"_embedded",
|
|
248
|
+
"_entryTitle",
|
|
249
|
+
"_id",
|
|
250
|
+
"_links",
|
|
251
|
+
"_modelTitle",
|
|
252
|
+
"_modelTitleField",
|
|
253
|
+
"_modified"
|
|
254
|
+
];
|
|
255
|
+
for (let A in c) {
|
|
256
|
+
let m = c[A];
|
|
257
|
+
if (m.required = i.required.includes(A), a.includes(A)) {
|
|
258
|
+
delete c[A];
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if ((p = c[A]) != null && p.oneOf && (($ = c[A]) == null || delete $.oneOf), (P = m.title) != null && P.includes("<") && ((_ = m.title) != null && _.includes(">"))) {
|
|
262
|
+
const B = m.title.split("<")[1].slice(0, -1), q = m.title.split("<")[0];
|
|
263
|
+
m.type = q, m.resource = B, delete c[A].title;
|
|
264
|
+
}
|
|
265
|
+
["asset", "entry", "assets", "entries"].includes(m.title) && (m.type = m.title, m.resource = null, delete c[A].title);
|
|
266
|
+
}
|
|
267
|
+
return c;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function X(u) {
|
|
271
|
+
return o(this, arguments, function* ({ env: n, dmShortID: t, assetGroup: e, assetID: s, token: r }) {
|
|
272
|
+
d({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
273
|
+
const i = w({ assetID: s }), c = f(`a/${t}/${e}?${i}`, n);
|
|
274
|
+
return (yield g(c, { dmShortID: t, token: r }))._embedded["ec:dm-asset"];
|
|
226
275
|
});
|
|
227
276
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
230
|
-
let { env: t, dmShortID: e, assetGroup: s, token:
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
let
|
|
234
|
-
return
|
|
277
|
+
function Y(n) {
|
|
278
|
+
return o(this, null, function* () {
|
|
279
|
+
let { env: t, dmShortID: e, assetGroup: s, token: r, options: u = {} } = n;
|
|
280
|
+
d({ env: t, dmShortID: e, assetGroup: s }), u = l({ size: 50, page: 1, _list: !0 }, u);
|
|
281
|
+
const i = w(u), c = f(`a/${e}/${s}?${i}`, t), { count: a, total: h, _embedded: p } = yield g(c, { dmShortID: e, token: r });
|
|
282
|
+
let $ = p ? p["ec:dm-asset"] : [];
|
|
283
|
+
return $ = Array.isArray($) ? $ : [$], { count: a, total: h, items: $ };
|
|
235
284
|
});
|
|
236
285
|
}
|
|
237
|
-
function
|
|
238
|
-
return
|
|
286
|
+
function Z(c) {
|
|
287
|
+
return o(this, arguments, function* ({
|
|
239
288
|
env: n,
|
|
240
289
|
dmShortID: t,
|
|
241
290
|
assetGroup: e,
|
|
242
291
|
token: s,
|
|
243
|
-
file:
|
|
292
|
+
file: r,
|
|
244
293
|
name: u,
|
|
245
|
-
options:
|
|
294
|
+
options: i
|
|
246
295
|
}) {
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
}), (yield
|
|
252
|
-
|
|
296
|
+
d({ env: n, dmShortID: t, assetGroup: e, file: r });
|
|
297
|
+
const a = f(`a/${t}/${e}`, n), h = new FormData();
|
|
298
|
+
return h.append("file", r, u), i && Object.keys(i).forEach(($) => {
|
|
299
|
+
h.append($, i[$]);
|
|
300
|
+
}), (yield g(
|
|
301
|
+
a,
|
|
253
302
|
{ token: s },
|
|
254
303
|
{
|
|
255
304
|
method: "POST",
|
|
256
|
-
body:
|
|
305
|
+
body: h
|
|
257
306
|
}
|
|
258
307
|
))._embedded["ec:dm-asset"];
|
|
259
308
|
});
|
|
260
309
|
}
|
|
261
|
-
function
|
|
262
|
-
return
|
|
310
|
+
function tt(u) {
|
|
311
|
+
return o(this, arguments, function* ({
|
|
263
312
|
env: n,
|
|
264
313
|
dmShortID: t,
|
|
265
314
|
assetGroup: e,
|
|
266
315
|
assetID: s,
|
|
267
|
-
token:
|
|
316
|
+
token: r
|
|
268
317
|
}) {
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
yield
|
|
272
|
-
|
|
273
|
-
{ token:
|
|
318
|
+
d({ env: n, dmShortID: t, assetGroup: e, assetID: s });
|
|
319
|
+
const i = f(`a/${t}/${e}/${s}`, n);
|
|
320
|
+
yield g(
|
|
321
|
+
i,
|
|
322
|
+
{ token: r, rawRes: !0 },
|
|
274
323
|
{
|
|
275
324
|
method: "DELETE"
|
|
276
325
|
}
|
|
277
326
|
);
|
|
278
327
|
});
|
|
279
328
|
}
|
|
280
|
-
function
|
|
281
|
-
return
|
|
329
|
+
function et(n) {
|
|
330
|
+
return o(this, null, function* () {
|
|
331
|
+
let { env: t, dmID: e, token: s } = n;
|
|
332
|
+
d({ env: t, dmID: e });
|
|
333
|
+
const r = f(`?dataManagerID=${e}`, t);
|
|
334
|
+
return g(r, { token: s });
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function nt(n) {
|
|
338
|
+
return o(this, null, function* () {
|
|
282
339
|
let { env: t, options: e = {} } = n;
|
|
283
|
-
|
|
284
|
-
const s =
|
|
285
|
-
let
|
|
286
|
-
return
|
|
340
|
+
d({ env: t }), e = l({ size: 25, page: 1, _list: !0 }, e);
|
|
341
|
+
const s = w(e), r = f(`?${s}`, t), { count: u, total: i, _embedded: c } = yield g(r, n);
|
|
342
|
+
let a = c ? c["ec:datamanager"] : [];
|
|
343
|
+
return a = Array.isArray(a) ? a : [a], { count: u, total: i, items: a };
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function st(n) {
|
|
347
|
+
return o(this, null, function* () {
|
|
348
|
+
let { env: t, dmID: e, options: s = {} } = n;
|
|
349
|
+
d({ env: t, dmID: e }), s = l({ size: 25, dataManagerID: e, page: 1, _list: !0 }, s);
|
|
350
|
+
const r = w(s), u = f(`model?${r}`, t), { count: i, total: c, _embedded: a } = yield g(u, n);
|
|
351
|
+
let h = a ? a["ec:model"] : [];
|
|
352
|
+
return h = Array.isArray(h) ? h : [h], { count: i, total: c, items: h };
|
|
287
353
|
});
|
|
288
354
|
}
|
|
289
|
-
const
|
|
355
|
+
const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
290
356
|
__proto__: null,
|
|
291
|
-
assetList:
|
|
292
|
-
createAsset:
|
|
293
|
-
createEntry:
|
|
294
|
-
deleteAsset:
|
|
295
|
-
deleteEntry:
|
|
296
|
-
dmList:
|
|
297
|
-
editEntry:
|
|
298
|
-
entryList:
|
|
299
|
-
getAsset:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
357
|
+
assetList: Y,
|
|
358
|
+
createAsset: Z,
|
|
359
|
+
createEntry: I,
|
|
360
|
+
deleteAsset: tt,
|
|
361
|
+
deleteEntry: V,
|
|
362
|
+
dmList: nt,
|
|
363
|
+
editEntry: Q,
|
|
364
|
+
entryList: G,
|
|
365
|
+
getAsset: X,
|
|
366
|
+
getDatamanager: et,
|
|
367
|
+
getEcAuthKey: F,
|
|
368
|
+
getEntry: H,
|
|
369
|
+
getPublicAuthKey: M,
|
|
370
|
+
getSchema: W,
|
|
371
|
+
loginEc: v,
|
|
372
|
+
loginPublic: R,
|
|
373
|
+
logoutEc: N,
|
|
374
|
+
logoutPublic: J,
|
|
375
|
+
modelList: st,
|
|
376
|
+
publicApi: U
|
|
307
377
|
}, Symbol.toStringTag, { value: "Module" })), {
|
|
308
|
-
entryList:
|
|
309
|
-
getEntry:
|
|
310
|
-
getAsset:
|
|
311
|
-
assetList:
|
|
312
|
-
createAsset:
|
|
313
|
-
deleteAsset:
|
|
314
|
-
createEntry:
|
|
315
|
-
editEntry:
|
|
316
|
-
deleteEntry:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
378
|
+
entryList: rt,
|
|
379
|
+
getEntry: it,
|
|
380
|
+
getAsset: ot,
|
|
381
|
+
assetList: at,
|
|
382
|
+
createAsset: ct,
|
|
383
|
+
deleteAsset: ut,
|
|
384
|
+
createEntry: lt,
|
|
385
|
+
editEntry: ht,
|
|
386
|
+
deleteEntry: dt,
|
|
387
|
+
getSchema: gt,
|
|
388
|
+
loginPublic: yt,
|
|
389
|
+
loginEc: ft,
|
|
390
|
+
logoutEc: pt,
|
|
391
|
+
logoutPublic: $t,
|
|
392
|
+
getEcAuthKey: E,
|
|
393
|
+
getPublicAuthKey: b,
|
|
394
|
+
dmList: mt,
|
|
395
|
+
modelList: At,
|
|
396
|
+
publicApi: wt,
|
|
397
|
+
getDatamanager: kt
|
|
398
|
+
} = k;
|
|
399
|
+
function bt(n) {
|
|
326
400
|
const { action: t } = n;
|
|
327
|
-
if (
|
|
401
|
+
if (d({ action: t }), !k[t])
|
|
328
402
|
throw new Error(
|
|
329
|
-
`"${t}" does not exist! try one of ${Object.keys(
|
|
403
|
+
`"${t}" does not exist! try one of ${Object.keys(k).join(
|
|
330
404
|
", "
|
|
331
405
|
)}`
|
|
332
406
|
);
|
|
333
|
-
return
|
|
407
|
+
return k[t](n);
|
|
334
408
|
}
|
|
335
|
-
class
|
|
409
|
+
class T {
|
|
336
410
|
constructor(t) {
|
|
337
411
|
this.config = t;
|
|
338
412
|
}
|
|
339
413
|
set(t) {
|
|
340
|
-
return new
|
|
414
|
+
return new T(l(l({}, this.config), t));
|
|
341
415
|
}
|
|
342
416
|
/**
|
|
343
417
|
* Loads entry list. Expects `dmShortID` / `model` to be set.
|
|
@@ -353,13 +427,13 @@ class b {
|
|
|
353
427
|
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
354
428
|
*/
|
|
355
429
|
entries() {
|
|
356
|
-
return
|
|
430
|
+
return o(this, arguments, function* (t = {}) {
|
|
357
431
|
const e = yield this.getBestToken();
|
|
358
|
-
return
|
|
432
|
+
return rt(y(l({}, this.config), { options: t, token: e }));
|
|
359
433
|
});
|
|
360
434
|
}
|
|
361
435
|
entryList(t) {
|
|
362
|
-
return
|
|
436
|
+
return o(this, null, function* () {
|
|
363
437
|
return this.entries(t);
|
|
364
438
|
});
|
|
365
439
|
}
|
|
@@ -373,9 +447,22 @@ class b {
|
|
|
373
447
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
374
448
|
*/
|
|
375
449
|
getEntry(t) {
|
|
376
|
-
return
|
|
450
|
+
return o(this, null, function* () {
|
|
377
451
|
const e = yield this.getBestToken();
|
|
378
|
-
return
|
|
452
|
+
return it(y(l({}, this.config), { entryID: t, token: e }));
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Loads the schema of a model. Expects `dmShortID` / `model` to be set.
|
|
457
|
+
*
|
|
458
|
+
* @param {string} entryID
|
|
459
|
+
* @returns {Promise<EntrySchema>}
|
|
460
|
+
* @example
|
|
461
|
+
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
462
|
+
*/
|
|
463
|
+
getSchema() {
|
|
464
|
+
return o(this, null, function* () {
|
|
465
|
+
return gt(this.config);
|
|
379
466
|
});
|
|
380
467
|
}
|
|
381
468
|
/**
|
|
@@ -392,13 +479,13 @@ class b {
|
|
|
392
479
|
* const files = await sdk("stage").token(token).dm("83cc6374").assetGroup("avatars").assets()
|
|
393
480
|
*/
|
|
394
481
|
assets(t) {
|
|
395
|
-
return
|
|
482
|
+
return o(this, null, function* () {
|
|
396
483
|
const e = yield this.getBestToken();
|
|
397
|
-
return
|
|
484
|
+
return at(y(l({}, this.config), { options: t, token: e }));
|
|
398
485
|
});
|
|
399
486
|
}
|
|
400
487
|
assetList(t) {
|
|
401
|
-
return
|
|
488
|
+
return o(this, null, function* () {
|
|
402
489
|
return this.assets(t);
|
|
403
490
|
});
|
|
404
491
|
}
|
|
@@ -424,9 +511,9 @@ class b {
|
|
|
424
511
|
* .createAsset({ file, name: "venndiagram.png" });
|
|
425
512
|
*/
|
|
426
513
|
createAsset() {
|
|
427
|
-
return
|
|
428
|
-
const
|
|
429
|
-
return
|
|
514
|
+
return o(this, arguments, function* ({ file: t, name: e, options: s } = {}) {
|
|
515
|
+
const r = yield this.getBestToken();
|
|
516
|
+
return ct(y(l({}, this.config), { file: t, name: e, options: s, token: r }));
|
|
430
517
|
});
|
|
431
518
|
}
|
|
432
519
|
/**
|
|
@@ -439,9 +526,9 @@ class b {
|
|
|
439
526
|
* await ecadmin.assetgroup("test").deleteAsset('xxxx');
|
|
440
527
|
*/
|
|
441
528
|
deleteAsset(t) {
|
|
442
|
-
return
|
|
529
|
+
return o(this, null, function* () {
|
|
443
530
|
const e = yield this.getBestToken();
|
|
444
|
-
return
|
|
531
|
+
return ut(y(l({}, this.config), { token: e, assetID: t }));
|
|
445
532
|
});
|
|
446
533
|
}
|
|
447
534
|
/**
|
|
@@ -454,9 +541,9 @@ class b {
|
|
|
454
541
|
* const asset = await sdk("stage").dm("83cc6374").assetgroup("test").getAsset("tP-ZxpZZTGmbPnET-wArAQ")
|
|
455
542
|
*/
|
|
456
543
|
getAsset(t) {
|
|
457
|
-
return
|
|
544
|
+
return o(this, null, function* () {
|
|
458
545
|
const e = yield this.getBestToken();
|
|
459
|
-
return
|
|
546
|
+
return ot(y(l({}, this.config), { assetID: t, token: e }));
|
|
460
547
|
});
|
|
461
548
|
}
|
|
462
549
|
/**
|
|
@@ -469,9 +556,9 @@ class b {
|
|
|
469
556
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").createEntry({ name: 'test' })
|
|
470
557
|
*/
|
|
471
558
|
createEntry(t) {
|
|
472
|
-
return
|
|
559
|
+
return o(this, null, function* () {
|
|
473
560
|
const e = yield this.getBestToken();
|
|
474
|
-
return
|
|
561
|
+
return lt(y(l({}, this.config), { token: e, value: t }));
|
|
475
562
|
});
|
|
476
563
|
}
|
|
477
564
|
/**
|
|
@@ -485,9 +572,9 @@ class b {
|
|
|
485
572
|
* const entry = await sdk("stage").dm("83cc6374").model("muffin").editEntry("1gOtzWvrdq", { name: "test" })
|
|
486
573
|
*/
|
|
487
574
|
editEntry(t, e) {
|
|
488
|
-
return
|
|
575
|
+
return o(this, null, function* () {
|
|
489
576
|
const s = yield this.getBestToken();
|
|
490
|
-
return
|
|
577
|
+
return ht(y(l({}, this.config), { entryID: t, token: s, value: e }));
|
|
491
578
|
});
|
|
492
579
|
}
|
|
493
580
|
/**
|
|
@@ -500,9 +587,9 @@ class b {
|
|
|
500
587
|
* await sdk("stage").dm("83cc6374").model("muffin").deleteEntry("1gOtzWvrdq")
|
|
501
588
|
*/
|
|
502
589
|
deleteEntry(t) {
|
|
503
|
-
return
|
|
590
|
+
return o(this, null, function* () {
|
|
504
591
|
const e = yield this.getBestToken();
|
|
505
|
-
return
|
|
592
|
+
return dt(y(l({}, this.config), { token: e, entryID: t }));
|
|
506
593
|
});
|
|
507
594
|
}
|
|
508
595
|
// TODO: rename authAdapter -> storageAdapter
|
|
@@ -532,32 +619,32 @@ class b {
|
|
|
532
619
|
return e(t);
|
|
533
620
|
}
|
|
534
621
|
loginEc(t) {
|
|
535
|
-
return
|
|
536
|
-
this.setAuth(
|
|
622
|
+
return ft(l(l({}, this.config), t)).then(
|
|
623
|
+
this.setAuth(E(this.config))
|
|
537
624
|
);
|
|
538
625
|
}
|
|
539
626
|
loginPublic(t) {
|
|
540
|
-
return
|
|
541
|
-
this.setAuth(
|
|
627
|
+
return yt(l(l({}, this.config), t)).then(
|
|
628
|
+
this.setAuth(b(this.config))
|
|
542
629
|
);
|
|
543
630
|
}
|
|
544
631
|
logoutPublic() {
|
|
545
632
|
const t = this.getPublicToken();
|
|
546
|
-
return console.log("token", t),
|
|
547
|
-
this.unsetAuth(
|
|
633
|
+
return console.log("token", t), $t(y(l({}, this.config), { token: t })).then(
|
|
634
|
+
this.unsetAuth(b(this.config))
|
|
548
635
|
);
|
|
549
636
|
}
|
|
550
637
|
logoutEc() {
|
|
551
638
|
const t = this.getEcToken();
|
|
552
|
-
return console.log("token", t),
|
|
553
|
-
this.unsetAuth(
|
|
639
|
+
return console.log("token", t), pt(y(l({}, this.config), { token: t })).then(
|
|
640
|
+
this.unsetAuth(E(this.config))
|
|
554
641
|
);
|
|
555
642
|
}
|
|
556
643
|
getPublicToken() {
|
|
557
|
-
return this.config.token || this.getAuth(
|
|
644
|
+
return this.config.token || this.getAuth(b(this.config));
|
|
558
645
|
}
|
|
559
646
|
getEcToken() {
|
|
560
|
-
return this.config.token || this.getAuth(
|
|
647
|
+
return this.config.token || this.getAuth(E(this.config));
|
|
561
648
|
}
|
|
562
649
|
hasPublicToken() {
|
|
563
650
|
return !!this.getPublicToken();
|
|
@@ -599,6 +686,14 @@ class b {
|
|
|
599
686
|
dmShortID(t) {
|
|
600
687
|
return this.set({ dmShortID: t });
|
|
601
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Sets the (long) ID of the datamanager to use
|
|
691
|
+
* @param {string} dmID
|
|
692
|
+
* @returns Sdk
|
|
693
|
+
*/
|
|
694
|
+
dmID(t) {
|
|
695
|
+
return this.set({ dmID: t });
|
|
696
|
+
}
|
|
602
697
|
/**
|
|
603
698
|
* Sets the short ID of the datamanager to use. Alias for `dmShortID`
|
|
604
699
|
* @param {string} dmShortID
|
|
@@ -623,48 +718,79 @@ class b {
|
|
|
623
718
|
assetgroup(t) {
|
|
624
719
|
return this.assetGroup(t);
|
|
625
720
|
}
|
|
721
|
+
/**
|
|
722
|
+
* Returns the public api root endpoint. Expects dmShortID to be set.
|
|
723
|
+
* @returns any
|
|
724
|
+
*/
|
|
725
|
+
publicApi() {
|
|
726
|
+
return wt(this.config);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Loads a DatamanagerResource by its long id. Requires token.
|
|
730
|
+
* @returns any
|
|
731
|
+
*/
|
|
732
|
+
getDatamanager(t) {
|
|
733
|
+
return o(this, null, function* () {
|
|
734
|
+
const e = yield this.getBestToken();
|
|
735
|
+
return kt(y(l({}, this.config), { dmID: t, token: e }));
|
|
736
|
+
});
|
|
737
|
+
}
|
|
626
738
|
/**
|
|
627
739
|
* Loads datamanager list. Make sure to provide an ec.admin `token` intercept one.
|
|
628
740
|
*
|
|
629
741
|
* @param {object=} options options for entry list request.
|
|
630
742
|
* @returns {Promise<DatamanagerList>}
|
|
631
743
|
* @example
|
|
632
|
-
*
|
|
633
|
-
* const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
|
|
634
|
-
* @example
|
|
635
|
-
* // non-public model
|
|
636
|
-
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
744
|
+
* const dms = await sdk("stage").dmList()
|
|
637
745
|
*/
|
|
638
746
|
dmList() {
|
|
639
|
-
return
|
|
747
|
+
return o(this, arguments, function* (t = {}) {
|
|
748
|
+
const e = yield this.getBestToken();
|
|
749
|
+
return mt(y(l({}, this.config), { options: t, token: e }));
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Loads model list. Expects dmID to be set. Make sure to provide an ec.admin `token` intercept one.
|
|
754
|
+
*
|
|
755
|
+
* @param {object=} options options for entry list request.
|
|
756
|
+
* @returns {Promise<ModelList>}
|
|
757
|
+
* @example
|
|
758
|
+
* const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
759
|
+
*/
|
|
760
|
+
modelList() {
|
|
761
|
+
return o(this, arguments, function* (t = {}) {
|
|
640
762
|
const e = yield this.getBestToken();
|
|
641
|
-
return
|
|
763
|
+
return At(y(l({}, this.config), { options: t, token: e }));
|
|
642
764
|
});
|
|
643
765
|
}
|
|
644
766
|
}
|
|
645
|
-
const
|
|
767
|
+
const Tt = (n) => new T({ env: n });
|
|
646
768
|
export {
|
|
647
|
-
|
|
648
|
-
|
|
769
|
+
T as Sdk,
|
|
770
|
+
bt as act,
|
|
649
771
|
f as apiURL,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
772
|
+
Y as assetList,
|
|
773
|
+
Z as createAsset,
|
|
774
|
+
I as createEntry,
|
|
775
|
+
tt as deleteAsset,
|
|
776
|
+
V as deleteEntry,
|
|
777
|
+
nt as dmList,
|
|
778
|
+
Q as editEntry,
|
|
779
|
+
G as entryList,
|
|
780
|
+
d as expect,
|
|
781
|
+
g as fetcher,
|
|
782
|
+
X as getAsset,
|
|
783
|
+
et as getDatamanager,
|
|
784
|
+
F as getEcAuthKey,
|
|
785
|
+
H as getEntry,
|
|
786
|
+
M as getPublicAuthKey,
|
|
787
|
+
W as getSchema,
|
|
788
|
+
v as loginEc,
|
|
789
|
+
R as loginPublic,
|
|
790
|
+
N as logoutEc,
|
|
791
|
+
J as logoutPublic,
|
|
792
|
+
st as modelList,
|
|
793
|
+
U as publicApi,
|
|
794
|
+
w as query,
|
|
795
|
+
Tt as sdk
|
|
670
796
|
};
|
package/dist/lib/admin.d.mts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
export function getDatamanager(config: any): Promise<any>;
|
|
1
2
|
export function dmList(config: any): Promise<{
|
|
2
3
|
count: any;
|
|
3
4
|
total: any;
|
|
4
5
|
items: any;
|
|
5
6
|
}>;
|
|
7
|
+
export function modelList(config: any): Promise<{
|
|
8
|
+
count: any;
|
|
9
|
+
total: any;
|
|
10
|
+
items: any;
|
|
11
|
+
}>;
|
|
6
12
|
//# sourceMappingURL=admin.d.mts.map
|
package/dist/lib/admin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.mts","sourceRoot":"","sources":["../../src/lib/admin.mjs"],"names":[],"mappings":"AAEA;;;;GAWC"}
|
|
1
|
+
{"version":3,"file":"admin.d.mts","sourceRoot":"","sources":["../../src/lib/admin.mjs"],"names":[],"mappings":"AAEA,0DAMC;AAED;;;;GAYC;AAED;;;;GAWC"}
|
package/dist/lib/api.d.mts
CHANGED
|
@@ -32,6 +32,15 @@ export class Sdk {
|
|
|
32
32
|
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getEntry("1gOtzWvrdq")
|
|
33
33
|
*/
|
|
34
34
|
getEntry(entryID: string): Promise<EntryResource>;
|
|
35
|
+
/**
|
|
36
|
+
* Loads the schema of a model. Expects `dmShortID` / `model` to be set.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} entryID
|
|
39
|
+
* @returns {Promise<EntrySchema>}
|
|
40
|
+
* @example
|
|
41
|
+
* const muffin = await sdk("stage").dm("83cc6374").model("muffin").getSchema()
|
|
42
|
+
*/
|
|
43
|
+
getSchema(): Promise<EntrySchema>;
|
|
35
44
|
/**
|
|
36
45
|
* Loads asset list. Expects `dmShortID` / `assetGroup` to be set.
|
|
37
46
|
* If the assetGroup is not public, you also need to provide a `token`.
|
|
@@ -156,6 +165,12 @@ export class Sdk {
|
|
|
156
165
|
* @returns Sdk
|
|
157
166
|
*/
|
|
158
167
|
dmShortID(dmShortID: string): Sdk;
|
|
168
|
+
/**
|
|
169
|
+
* Sets the (long) ID of the datamanager to use
|
|
170
|
+
* @param {string} dmID
|
|
171
|
+
* @returns Sdk
|
|
172
|
+
*/
|
|
173
|
+
dmID(dmID: string): Sdk;
|
|
159
174
|
/**
|
|
160
175
|
* Sets the short ID of the datamanager to use. Alias for `dmShortID`
|
|
161
176
|
* @param {string} dmShortID
|
|
@@ -174,19 +189,34 @@ export class Sdk {
|
|
|
174
189
|
* @returns Sdk
|
|
175
190
|
*/
|
|
176
191
|
assetgroup(assetGroup: string): Sdk;
|
|
192
|
+
/**
|
|
193
|
+
* Returns the public api root endpoint. Expects dmShortID to be set.
|
|
194
|
+
* @returns any
|
|
195
|
+
*/
|
|
196
|
+
publicApi(): Promise<any>;
|
|
197
|
+
/**
|
|
198
|
+
* Loads a DatamanagerResource by its long id. Requires token.
|
|
199
|
+
* @returns any
|
|
200
|
+
*/
|
|
201
|
+
getDatamanager(dmID: any): Promise<any>;
|
|
177
202
|
/**
|
|
178
203
|
* Loads datamanager list. Make sure to provide an ec.admin `token` intercept one.
|
|
179
204
|
*
|
|
180
205
|
* @param {object=} options options for entry list request.
|
|
181
206
|
* @returns {Promise<DatamanagerList>}
|
|
182
207
|
* @example
|
|
183
|
-
*
|
|
184
|
-
* const muffins = await sdk("stage").dm("83cc6374").model("muffin").entries()
|
|
185
|
-
* @example
|
|
186
|
-
* // non-public model
|
|
187
|
-
* const secrets = await sdk("stage").token(token).dm("83cc6374").model("secret").entries()
|
|
208
|
+
* const dms = await sdk("stage").dmList()
|
|
188
209
|
*/
|
|
189
210
|
dmList(options?: object | undefined): Promise<DatamanagerList>;
|
|
211
|
+
/**
|
|
212
|
+
* Loads model list. Expects dmID to be set. Make sure to provide an ec.admin `token` intercept one.
|
|
213
|
+
*
|
|
214
|
+
* @param {object=} options options for entry list request.
|
|
215
|
+
* @returns {Promise<ModelList>}
|
|
216
|
+
* @example
|
|
217
|
+
* const models = await sdk("stage").dmID("254a03f1-cb76-4f1e-a52a-bbd4180ca10c").modelList()
|
|
218
|
+
*/
|
|
219
|
+
modelList(options?: object | undefined): Promise<ModelList>;
|
|
190
220
|
}
|
|
191
221
|
export function sdk(env: any): Sdk;
|
|
192
222
|
export type AssetFile = {
|
|
@@ -249,6 +279,35 @@ export type EntryResource = {
|
|
|
249
279
|
*/
|
|
250
280
|
key?: any;
|
|
251
281
|
};
|
|
282
|
+
export type EntryFieldSchema = {
|
|
283
|
+
/**
|
|
284
|
+
* - The default value or null
|
|
285
|
+
*/
|
|
286
|
+
default: any;
|
|
287
|
+
/**
|
|
288
|
+
* - The field description
|
|
289
|
+
*/
|
|
290
|
+
description: string;
|
|
291
|
+
/**
|
|
292
|
+
* - If true, the field cannot be changed on PUT
|
|
293
|
+
*/
|
|
294
|
+
readOnly: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* - If true, the field has to be set on POST
|
|
297
|
+
*/
|
|
298
|
+
required: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* - field type
|
|
301
|
+
*/
|
|
302
|
+
type: string;
|
|
303
|
+
/**
|
|
304
|
+
* - If field type is one of entry | entries | asset | assets, this field contains the name of the expected resource or null if all are valid
|
|
305
|
+
*/
|
|
306
|
+
resource: string;
|
|
307
|
+
};
|
|
308
|
+
export type EntrySchema = {
|
|
309
|
+
[x: string]: EntryFieldSchema;
|
|
310
|
+
};
|
|
252
311
|
export type EntryList = {
|
|
253
312
|
count: number;
|
|
254
313
|
total: number;
|
|
@@ -281,4 +340,42 @@ export type AssetList = {
|
|
|
281
340
|
total: number;
|
|
282
341
|
items: AssetResource[];
|
|
283
342
|
};
|
|
343
|
+
/**
|
|
344
|
+
* // config: {} ?
|
|
345
|
+
*/
|
|
346
|
+
export type ModelFieldConfig = {
|
|
347
|
+
default: any;
|
|
348
|
+
description: string;
|
|
349
|
+
localizable: boolean;
|
|
350
|
+
mutable: boolean;
|
|
351
|
+
readOnly: boolean;
|
|
352
|
+
required: boolean;
|
|
353
|
+
unique: boolean;
|
|
354
|
+
title: string;
|
|
355
|
+
type: string;
|
|
356
|
+
validation: string | null;
|
|
357
|
+
};
|
|
358
|
+
export type ModelResource = {
|
|
359
|
+
config: any;
|
|
360
|
+
created: string;
|
|
361
|
+
description: string;
|
|
362
|
+
fields: ModelFieldConfig[];
|
|
363
|
+
hasEntries: boolean;
|
|
364
|
+
hexColor: string;
|
|
365
|
+
hooks: any[];
|
|
366
|
+
lastSyncs: any[];
|
|
367
|
+
locales: string[];
|
|
368
|
+
modelID: string;
|
|
369
|
+
modified: string;
|
|
370
|
+
policies: any[];
|
|
371
|
+
sync: any;
|
|
372
|
+
title: string;
|
|
373
|
+
titleField: string;
|
|
374
|
+
_links: any;
|
|
375
|
+
};
|
|
376
|
+
export type ModelList = {
|
|
377
|
+
count: number;
|
|
378
|
+
total: number;
|
|
379
|
+
items: ModelResource[];
|
|
380
|
+
};
|
|
284
381
|
//# sourceMappingURL=api.d.mts.map
|
package/dist/lib/api.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.mts","sourceRoot":"","sources":["../../src/lib/api.mjs"],"names":[],"mappings":"AA8BA,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;;;;;;;OAOG;IACH,aAJa,QAAQ,WAAW,CAAC,CAMhC;IACD;;;;;;;;;;;;OAYG;IACH,iBATW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAW9B;IACD,4CAEC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sCAjBW;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAClD,QAAQ,aAAa,CAAC,CAmBlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAOzB;IACD;;;;;;;;OAQG;IACH,kBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IAED;;;;;;;;OAQG;IACH,mBALW,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;;OASG;IACH,mBANW,MAAM,SACN,MAAM,GACJ,QAAQ,aAAa,CAAC,CAOlC;IACD;;;;;;;;OAQG;IACH,qBALW,MAAM,GACJ,IAAI,CAOhB;IAID,mCAGC;IAED,sCASC;IACD,wCAUC;IACD,uBAMC;IAED,mCAIC;IACD,uCAKC;IAED,6BAMC;IAED,yBAMC;IAED,sBAEC;IACD,kBAEC;IACD,0BAEC;IACD,sBAEC;IACD,uBAEC;IACD,oBAMC;IACD;;;;OAIG;IACH,aAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,aAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,qBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,WAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,cAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IACD;;;;OAIG;IACH,uBAHW,MAAM,OAKhB;IAED;;;OAGG;IACH,0BAEC;IAED;;;OAGG;IACH,wCAGC;IAED;;;;;;;OAOG;IACH,iBALW,MAAM,eACJ,QAAQ,eAAe,CAAC,CAOpC;IACD;;;;;;;OAOG;IACH,oBALW,MAAM,eACJ,QAAQ,SAAS,CAAC,CAO9B;CACF;AAEM,mCAAqC;;SAI9B,MAAM;UACN,MAAM;;;;aAMN,MAAM;aACN,IAAI;WACJ,MAAM,GAAG,CAAC;UACV,MAAM,MAAM,GAAG,GAAG,CAAC;WACnB,MAAM;UACN,MAAM;UACN,SAAS;;;;;;QAKT,MAAM;;;;cACN,IAAI;;;;cACJ,MAAM;;;;eACN,GAAG;;;;YACH,GAAG;;;;iBACH,MAAM;;;;sBACN,MAAM;;;;eACN,IAAI;;;;aACJ,IAAI;;;;cACJ,IAAI;;;;UACJ,GAAG;;;;;;aAKH,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;;;;;;aAMf,GAAG;iBACH,MAAM;iBACN,OAAO;aACP,OAAO;cACP,OAAO;cACP,OAAO;YACP,OAAO;WACP,MAAM;UACN,MAAM;gBACN,MAAM,GAAG,IAAI;;;YAKb,GAAG;aACH,MAAM;iBACN,MAAM;YACN,gBAAgB,EAAE;gBAClB,OAAO;cACP,MAAM;WACN,GAAG,EAAE;eACL,GAAG,EAAE;aACL,MAAM,EAAE;aACR,MAAM;cACN,MAAM;cACN,GAAG,EAAE;UACL,GAAG;WACH,MAAM;gBACN,MAAM;YACN,GAAG;;;WAMH,MAAM;WACN,MAAM;WACN,aAAa,EAAE"}
|
package/dist/lib/entries.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function publicApi(config: any): Promise<any>;
|
|
1
2
|
export function entryList(config: any): Promise<{
|
|
2
3
|
count: any;
|
|
3
4
|
total: any;
|
|
@@ -32,4 +33,9 @@ export function deleteEntry({ env, dmShortID, model, entryID, token }: {
|
|
|
32
33
|
entryID: any;
|
|
33
34
|
token: any;
|
|
34
35
|
}): Promise<void>;
|
|
36
|
+
export function getSchema({ env, dmShortID, model }: {
|
|
37
|
+
env: any;
|
|
38
|
+
dmShortID: any;
|
|
39
|
+
model: any;
|
|
40
|
+
}): Promise<any>;
|
|
35
41
|
//# sourceMappingURL=entries.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.d.mts","sourceRoot":"","sources":["../../src/lib/entries.mjs"],"names":[],"mappings":"AAEA;;;;GAYC;AAED;;;;;;iBAKC;AAED;;;;;;iBAeC;AAED;;;;;;;iBAuBC;AAED;;;;;;kBAcC"}
|
|
1
|
+
{"version":3,"file":"entries.d.mts","sourceRoot":"","sources":["../../src/lib/entries.mjs"],"names":[],"mappings":"AAEA,qDAMC;AAED;;;;GAYC;AAED;;;;;;iBAKC;AAED;;;;;;iBAeC;AAED;;;;;;;iBAuBC;AAED;;;;;;kBAcC;AAED;;;;iBAsDC"}
|