frappe-react-sdk 1.0.11 → 1.0.12

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.
@@ -2857,7 +2857,7 @@ const Ai = (t, n, e = !1, i = !1, a) => {
2857
2857
  };
2858
2858
  }, Li = (t, n, e = [], i = 20, a = 250) => {
2859
2859
  const r = gi(n, a);
2860
- return Ri("/api/method/frappe.desk.search.search_link", {
2860
+ return Ri("frappe.desk.search.search_link", {
2861
2861
  doctype: t,
2862
2862
  page_length: i,
2863
2863
  txt: r,
@@ -38,4 +38,4 @@ Check the render method of \``+u+"`."}return""}}function Ri(u){{if(u!==void 0){v
38
38
 
39
39
  Check your code at `+p+":"+v+"."}return""}}var hn={};function Ci(u){{var p=pn();if(!p){var v=typeof u=="string"?u:u.displayName||u.name;v&&(p=`
40
40
 
41
- Check the top-level render call using <`+v+">.")}return p}}function vn(u,p){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var v=Ci(p);if(hn[v])return;hn[v]=!0;var _="";u&&u._owner&&u._owner!==Zt.current&&(_=" It was passed a child from "+$(u._owner.type)+"."),je(u),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,_),je(null)}}function mn(u,p){{if(typeof u!="object")return;if(Ae(u))for(var v=0;v<u.length;v++){var _=u[v];er(_)&&vn(_,p)}else if(er(u))u._store&&(u._store.validated=!0);else if(u){var E=C(u);if(typeof E=="function"&&E!==u.entries)for(var T=E.call(u),g;!(g=T.next()).done;)er(g.value)&&vn(g.value,p)}}}function gi(u){{var p=u.type;if(p==null||typeof p=="string")return;var v;if(typeof p=="function")v=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===f))v=p.propTypes;else return;if(v){var _=$(p);ze(v,u.props,"prop",_,u)}else if(p.PropTypes!==void 0&&!$t){$t=!0;var E=$(p);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Si(u){{for(var p=Object.keys(u.props),v=0;v<p.length;v++){var _=p[v];if(_!=="children"&&_!=="key"){je(u),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",_),je(null);break}}u.ref!==null&&(je(u),S("Invalid attribute `ref` supplied to `React.Fragment`."),je(null))}}function wn(u,p,v,_,E,T){{var g=L(u);if(!g){var R="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var H=Ri(E);H?R+=H:R+=pn();var j;u===null?j="null":Ae(u)?j="array":u!==void 0&&u.$$typeof===n?(j="<"+($(u.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):j=typeof u,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,R)}var P=_i(u,p,v,E,T);if(P==null)return P;if(g){var ae=p.children;if(ae!==void 0)if(_)if(Ae(ae)){for(var Pe=0;Pe<ae.length;Pe++)mn(ae[Pe],u);Object.freeze&&Object.freeze(ae)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else mn(ae,u)}return u===i?Si(P):gi(P),P}}function Ei(u,p,v){return wn(u,p,v,!0)}function Ti(u,p,v){return wn(u,p,v,!1)}var xi=Ti,Oi=Ei;Xe.Fragment=i,Xe.jsx=xi,Xe.jsxs=Oi}()),Xe}(function(t){process.env.NODE_ENV==="production"?t.exports=qa():t.exports=za()})(tn);const Ka=tn.exports.jsx,G=h.createContext(null),Qa=({url:t="",children:n})=>{const e=h.useMemo(()=>{const i=new Ca.FrappeApp(t);return{url:t,app:i,auth:i.auth(),db:i.db(),call:i.call(),file:i.file()}},[t]);return Ka(G.Provider,{value:e,children:n})},Za=t=>{const{url:n,auth:e}=h.useContext(G),{data:i,error:a,isValidating:r,mutate:s}=Je(`${n}/api/method/frappe.auth.get_logged_user`,()=>e.getLoggedInUser(),t),l=h.useCallback(async(o,c)=>e.loginWithUsernamePassword({username:o,password:c}).then(f=>{console.log(f),s()}),[]),d=h.useCallback(async()=>e.logout().then(()=>s(null)),[]);return{currentUser:i,isValidating:r,error:a,login:l,logout:d,updateCurrentUser:s}},$a=(t,n,e)=>{const{db:i}=h.useContext(G);return{...Je(i.getRequestURL(t,n),()=>i.getDoc(t,n),e)}},an=t=>{var e,i,a;let n="";if(t!=null&&t.fields&&(n+="fields="+JSON.stringify(t==null?void 0:t.fields)+"&"),t!=null&&t.filters&&(n+="filters="+JSON.stringify(t==null?void 0:t.filters)+"&"),t!=null&&t.orFilters&&(n+="or_filters="+JSON.stringify(t==null?void 0:t.orFilters)+"&"),t!=null&&t.limit_start&&(n+="limit_start="+JSON.stringify(t==null?void 0:t.limit_start)+"&"),t!=null&&t.limit&&(n+="limit="+JSON.stringify(t==null?void 0:t.limit)+"&"),t!=null&&t.orderBy){const r=`${(e=t.orderBy)==null?void 0:e.field} ${(a=(i=t.orderBy)==null?void 0:i.order)!=null?a:"asc"}`;n+="order_by="+r+"&"}return t!=null&&t.asDict&&(n+="as_dict="+t.asDict),n},ei=(t,n,e)=>{const{db:i}=h.useContext(G);return{...Je(`${i.getRequestURL(t)}?${an(n)}`,()=>i.getDocList(t,n),e)}},ti=()=>{const{db:t}=h.useContext(G),[n,e]=h.useState(!1),[i,a]=h.useState(null),[r,s]=h.useState(!1),l=h.useCallback(()=>{e(!1),a(null),s(!1)},[]);return{createDoc:h.useCallback(async(o,c)=>(a(null),s(!1),e(!0),t.createDoc(o,c).then(f=>(e(!1),s(!0),f)).catch(f=>{throw e(!1),s(!1),a(f),f})),[]),loading:n,error:i,isCompleted:r,reset:l}},ri=()=>{const{db:t}=h.useContext(G),[n,e]=h.useState(!1),[i,a]=h.useState(null),[r,s]=h.useState(!1),l=h.useCallback(()=>{e(!1),a(null),s(!1)},[]);return{updateDoc:h.useCallback(async(o,c,f)=>(a(null),s(!1),e(!0),t.updateDoc(o,c,f).then(m=>(e(!1),s(!0),m)).catch(m=>{throw e(!1),s(!1),a(m),m})),[]),loading:n,error:i,reset:l,isCompleted:r}},ni=()=>{const{db:t}=h.useContext(G),[n,e]=h.useState(!1),[i,a]=h.useState(null),[r,s]=h.useState(!1),l=h.useCallback(()=>{e(!1),a(null),s(!1)},[]);return{deleteDoc:h.useCallback(async(o,c)=>(a(null),s(!1),e(!0),t.deleteDoc(o,c).then(f=>(e(!1),s(!0),f)).catch(f=>{throw e(!1),s(!1),a(f),f})),[]),loading:n,error:i,reset:l,isCompleted:r}};function on(t){const n=[];for(let e in t)n.push(encodeURIComponent(e)+"="+encodeURIComponent(t[e]));return n.join("&")}const ai=(t,n,e=!1,i=!1,a)=>{const{url:r,db:s}=h.useContext(G);return{...Je((()=>{const o=on({filters:n!=null?n:[],cache:e,debug:i});return`${r}/api/method/frappe.client.get_count?${o}`})(),()=>s.getCount(t,n,e,i),a)}},sn=(t,n,e,i)=>{const{call:a}=h.useContext(G),r=on(n!=null?n:{}),s=`${t}?${r}`;return{...Je(e!=null?e:s,()=>a.get(t,n),i)}},ii=t=>{const{call:n}=h.useContext(G),[e,i]=h.useState(null),[a,r]=h.useState(!1),[s,l]=h.useState(null),[d,o]=h.useState(!1),c=h.useCallback(()=>{i(null),r(!1),l(null),o(!1)},[]);return{call:h.useCallback(async m=>(l(null),o(!1),r(!0),i(null),n.post(t,m).then(w=>(i(w),r(!1),o(!0),w)).catch(w=>{throw r(!1),o(!1),l(w),w})),[]),result:e,loading:a,error:s,reset:c,isCompleted:d}},oi=t=>{const{call:n}=h.useContext(G),[e,i]=h.useState(null),[a,r]=h.useState(!1),[s,l]=h.useState(null),[d,o]=h.useState(!1),c=h.useCallback(()=>{i(null),r(!1),l(null),o(!1)},[]);return{call:h.useCallback(async m=>(l(null),o(!1),r(!0),i(null),n.put(t,m).then(w=>(i(w),r(!1),o(!0),w)).catch(w=>{throw r(!1),o(!1),l(w),w})),[]),result:e,loading:a,error:s,reset:c,isCompleted:d}},si=t=>{const{call:n}=h.useContext(G),[e,i]=h.useState(null),[a,r]=h.useState(!1),[s,l]=h.useState(null),[d,o]=h.useState(!1),c=h.useCallback(()=>{i(null),r(!1),l(null),o(!1)},[]);return{call:h.useCallback(async m=>(l(null),o(!1),r(!0),i(null),n.delete(t,m).then(w=>(i(w),r(!1),o(!0),w)).catch(w=>{throw r(!1),o(!1),l(w),w})),[]),result:e,loading:a,error:s,reset:c,isCompleted:d}},ui=()=>{const{file:t}=h.useContext(G),[n,e]=h.useState(0),[i,a]=h.useState(!1),[r,s]=h.useState(null),[l,d]=h.useState(!1),o=h.useCallback(async(f,m)=>(c(),a(!0),t.uploadFile(f,m,(w,O)=>e(Math.round(w/O*100))).then(w=>(d(!0),e(100),a(!1),w.data.message)).catch(w=>{throw console.error(w),s(w),a(!1),w})),[]),c=h.useCallback(()=>{e(0),a(!1),s(null),d(!1)},[]);return{upload:o,progress:n,loading:i,isCompleted:l,error:r,reset:c}},li=(t,n,e=[],i=20,a=250)=>{const r=ci(n,a);return sn("/api/method/frappe.desk.search.search_link",{doctype:t,page_length:i,txt:r,filters:e!=null?e:[]})},ci=(t,n)=>{const[e,i]=h.useState(t);return h.useEffect(()=>{const a=setTimeout(()=>{i(t)},n);return()=>{clearTimeout(a)}},[t,n]),e};F.FrappeContext=G,F.FrappeProvider=Qa,F.getDocListQueryString=an,F.useFrappeAuth=Za,F.useFrappeCreateDoc=ti,F.useFrappeDeleteCall=si,F.useFrappeDeleteDoc=ni,F.useFrappeFileUpload=ui,F.useFrappeGetCall=sn,F.useFrappeGetDoc=$a,F.useFrappeGetDocCount=ai,F.useFrappeGetDocList=ei,F.useFrappePostCall=ii,F.useFrappePutCall=oi,F.useFrappeUpdateDoc=ri,F.useSearch=li,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
41
+ Check the top-level render call using <`+v+">.")}return p}}function vn(u,p){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var v=Ci(p);if(hn[v])return;hn[v]=!0;var _="";u&&u._owner&&u._owner!==Zt.current&&(_=" It was passed a child from "+$(u._owner.type)+"."),je(u),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,_),je(null)}}function mn(u,p){{if(typeof u!="object")return;if(Ae(u))for(var v=0;v<u.length;v++){var _=u[v];er(_)&&vn(_,p)}else if(er(u))u._store&&(u._store.validated=!0);else if(u){var E=C(u);if(typeof E=="function"&&E!==u.entries)for(var T=E.call(u),g;!(g=T.next()).done;)er(g.value)&&vn(g.value,p)}}}function gi(u){{var p=u.type;if(p==null||typeof p=="string")return;var v;if(typeof p=="function")v=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===f))v=p.propTypes;else return;if(v){var _=$(p);ze(v,u.props,"prop",_,u)}else if(p.PropTypes!==void 0&&!$t){$t=!0;var E=$(p);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Si(u){{for(var p=Object.keys(u.props),v=0;v<p.length;v++){var _=p[v];if(_!=="children"&&_!=="key"){je(u),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",_),je(null);break}}u.ref!==null&&(je(u),S("Invalid attribute `ref` supplied to `React.Fragment`."),je(null))}}function wn(u,p,v,_,E,T){{var g=L(u);if(!g){var R="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var H=Ri(E);H?R+=H:R+=pn();var j;u===null?j="null":Ae(u)?j="array":u!==void 0&&u.$$typeof===n?(j="<"+($(u.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):j=typeof u,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,R)}var P=_i(u,p,v,E,T);if(P==null)return P;if(g){var ae=p.children;if(ae!==void 0)if(_)if(Ae(ae)){for(var Pe=0;Pe<ae.length;Pe++)mn(ae[Pe],u);Object.freeze&&Object.freeze(ae)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else mn(ae,u)}return u===i?Si(P):gi(P),P}}function Ei(u,p,v){return wn(u,p,v,!0)}function Ti(u,p,v){return wn(u,p,v,!1)}var xi=Ti,Oi=Ei;Xe.Fragment=i,Xe.jsx=xi,Xe.jsxs=Oi}()),Xe}(function(t){process.env.NODE_ENV==="production"?t.exports=qa():t.exports=za()})(tn);const Ka=tn.exports.jsx,G=h.createContext(null),Qa=({url:t="",children:n})=>{const e=h.useMemo(()=>{const i=new Ca.FrappeApp(t);return{url:t,app:i,auth:i.auth(),db:i.db(),call:i.call(),file:i.file()}},[t]);return Ka(G.Provider,{value:e,children:n})},Za=t=>{const{url:n,auth:e}=h.useContext(G),{data:i,error:a,isValidating:r,mutate:s}=Je(`${n}/api/method/frappe.auth.get_logged_user`,()=>e.getLoggedInUser(),t),l=h.useCallback(async(o,c)=>e.loginWithUsernamePassword({username:o,password:c}).then(f=>{console.log(f),s()}),[]),d=h.useCallback(async()=>e.logout().then(()=>s(null)),[]);return{currentUser:i,isValidating:r,error:a,login:l,logout:d,updateCurrentUser:s}},$a=(t,n,e)=>{const{db:i}=h.useContext(G);return{...Je(i.getRequestURL(t,n),()=>i.getDoc(t,n),e)}},an=t=>{var e,i,a;let n="";if(t!=null&&t.fields&&(n+="fields="+JSON.stringify(t==null?void 0:t.fields)+"&"),t!=null&&t.filters&&(n+="filters="+JSON.stringify(t==null?void 0:t.filters)+"&"),t!=null&&t.orFilters&&(n+="or_filters="+JSON.stringify(t==null?void 0:t.orFilters)+"&"),t!=null&&t.limit_start&&(n+="limit_start="+JSON.stringify(t==null?void 0:t.limit_start)+"&"),t!=null&&t.limit&&(n+="limit="+JSON.stringify(t==null?void 0:t.limit)+"&"),t!=null&&t.orderBy){const r=`${(e=t.orderBy)==null?void 0:e.field} ${(a=(i=t.orderBy)==null?void 0:i.order)!=null?a:"asc"}`;n+="order_by="+r+"&"}return t!=null&&t.asDict&&(n+="as_dict="+t.asDict),n},ei=(t,n,e)=>{const{db:i}=h.useContext(G);return{...Je(`${i.getRequestURL(t)}?${an(n)}`,()=>i.getDocList(t,n),e)}},ti=()=>{const{db:t}=h.useContext(G),[n,e]=h.useState(!1),[i,a]=h.useState(null),[r,s]=h.useState(!1),l=h.useCallback(()=>{e(!1),a(null),s(!1)},[]);return{createDoc:h.useCallback(async(o,c)=>(a(null),s(!1),e(!0),t.createDoc(o,c).then(f=>(e(!1),s(!0),f)).catch(f=>{throw e(!1),s(!1),a(f),f})),[]),loading:n,error:i,isCompleted:r,reset:l}},ri=()=>{const{db:t}=h.useContext(G),[n,e]=h.useState(!1),[i,a]=h.useState(null),[r,s]=h.useState(!1),l=h.useCallback(()=>{e(!1),a(null),s(!1)},[]);return{updateDoc:h.useCallback(async(o,c,f)=>(a(null),s(!1),e(!0),t.updateDoc(o,c,f).then(m=>(e(!1),s(!0),m)).catch(m=>{throw e(!1),s(!1),a(m),m})),[]),loading:n,error:i,reset:l,isCompleted:r}},ni=()=>{const{db:t}=h.useContext(G),[n,e]=h.useState(!1),[i,a]=h.useState(null),[r,s]=h.useState(!1),l=h.useCallback(()=>{e(!1),a(null),s(!1)},[]);return{deleteDoc:h.useCallback(async(o,c)=>(a(null),s(!1),e(!0),t.deleteDoc(o,c).then(f=>(e(!1),s(!0),f)).catch(f=>{throw e(!1),s(!1),a(f),f})),[]),loading:n,error:i,reset:l,isCompleted:r}};function on(t){const n=[];for(let e in t)n.push(encodeURIComponent(e)+"="+encodeURIComponent(t[e]));return n.join("&")}const ai=(t,n,e=!1,i=!1,a)=>{const{url:r,db:s}=h.useContext(G);return{...Je((()=>{const o=on({filters:n!=null?n:[],cache:e,debug:i});return`${r}/api/method/frappe.client.get_count?${o}`})(),()=>s.getCount(t,n,e,i),a)}},sn=(t,n,e,i)=>{const{call:a}=h.useContext(G),r=on(n!=null?n:{}),s=`${t}?${r}`;return{...Je(e!=null?e:s,()=>a.get(t,n),i)}},ii=t=>{const{call:n}=h.useContext(G),[e,i]=h.useState(null),[a,r]=h.useState(!1),[s,l]=h.useState(null),[d,o]=h.useState(!1),c=h.useCallback(()=>{i(null),r(!1),l(null),o(!1)},[]);return{call:h.useCallback(async m=>(l(null),o(!1),r(!0),i(null),n.post(t,m).then(w=>(i(w),r(!1),o(!0),w)).catch(w=>{throw r(!1),o(!1),l(w),w})),[]),result:e,loading:a,error:s,reset:c,isCompleted:d}},oi=t=>{const{call:n}=h.useContext(G),[e,i]=h.useState(null),[a,r]=h.useState(!1),[s,l]=h.useState(null),[d,o]=h.useState(!1),c=h.useCallback(()=>{i(null),r(!1),l(null),o(!1)},[]);return{call:h.useCallback(async m=>(l(null),o(!1),r(!0),i(null),n.put(t,m).then(w=>(i(w),r(!1),o(!0),w)).catch(w=>{throw r(!1),o(!1),l(w),w})),[]),result:e,loading:a,error:s,reset:c,isCompleted:d}},si=t=>{const{call:n}=h.useContext(G),[e,i]=h.useState(null),[a,r]=h.useState(!1),[s,l]=h.useState(null),[d,o]=h.useState(!1),c=h.useCallback(()=>{i(null),r(!1),l(null),o(!1)},[]);return{call:h.useCallback(async m=>(l(null),o(!1),r(!0),i(null),n.delete(t,m).then(w=>(i(w),r(!1),o(!0),w)).catch(w=>{throw r(!1),o(!1),l(w),w})),[]),result:e,loading:a,error:s,reset:c,isCompleted:d}},ui=()=>{const{file:t}=h.useContext(G),[n,e]=h.useState(0),[i,a]=h.useState(!1),[r,s]=h.useState(null),[l,d]=h.useState(!1),o=h.useCallback(async(f,m)=>(c(),a(!0),t.uploadFile(f,m,(w,O)=>e(Math.round(w/O*100))).then(w=>(d(!0),e(100),a(!1),w.data.message)).catch(w=>{throw console.error(w),s(w),a(!1),w})),[]),c=h.useCallback(()=>{e(0),a(!1),s(null),d(!1)},[]);return{upload:o,progress:n,loading:i,isCompleted:l,error:r,reset:c}},li=(t,n,e=[],i=20,a=250)=>{const r=ci(n,a);return sn("frappe.desk.search.search_link",{doctype:t,page_length:i,txt:r,filters:e!=null?e:[]})},ci=(t,n)=>{const[e,i]=h.useState(t);return h.useEffect(()=>{const a=setTimeout(()=>{i(t)},n);return()=>{clearTimeout(a)}},[t,n]),e};F.FrappeContext=G,F.FrappeProvider=Qa,F.getDocListQueryString=an,F.useFrappeAuth=Za,F.useFrappeCreateDoc=ti,F.useFrappeDeleteCall=si,F.useFrappeDeleteDoc=ni,F.useFrappeFileUpload=ui,F.useFrappeGetCall=sn,F.useFrappeGetDoc=$a,F.useFrappeGetDocCount=ai,F.useFrappeGetDocList=ei,F.useFrappePostCall=ii,F.useFrappePutCall=oi,F.useFrappeUpdateDoc=ri,F.useSearch=li,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "frappe-react-sdk",
3
3
  "description": "React hooks for Frappe Framework",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Nikhil Kothari",