Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dappworks/urpc

Package Overview
Dependencies
Maintainers
4
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dappworks/urpc - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

22

dist/index.d.ts

@@ -10,3 +10,3 @@ // Generated by dts-bundle-generator v9.5.1

type?: "func";
key?: string;
name?: string;
path?: string;

@@ -20,3 +20,3 @@ input: T;

type?: "var";
key?: string;
name?: string;
path?: string;

@@ -38,4 +38,3 @@ get: T;

type: "func";
name: string;
key: string | undefined;
name: string | undefined;
input: any;

@@ -45,4 +44,3 @@ value?: undefined;

type: "var";
name: string;
key: string | undefined;
name: string | undefined;
value: any;

@@ -53,3 +51,2 @@ input?: undefined;

name: string;
key?: undefined;
input?: undefined;

@@ -59,3 +56,3 @@ value?: undefined;

loadVars(): {
name: string;
name: string | undefined;
value: any;

@@ -101,4 +98,3 @@ get: any;

type: "func";
name: string;
key: string | undefined;
name: string | undefined;
input: any;

@@ -108,4 +104,3 @@ value?: undefined;

type: "var";
name: string;
key: string | undefined;
name: string | undefined;
value: any;

@@ -116,3 +111,2 @@ input?: undefined;

name: string;
key?: undefined;
input?: undefined;

@@ -122,3 +116,3 @@ value?: undefined;

loadVars(): Promise<{
name: string;
name: string | undefined;
value: any;

@@ -125,0 +119,0 @@ get: any;

@@ -1,1 +0,1 @@

var VR=Object.create;var{defineProperty:d,getPrototypeOf:wR,getOwnPropertyNames:qR}=Object;var KR=Object.prototype.hasOwnProperty;var p=(R,U,P)=>{P=R!=null?VR(wR(R)):{};const _=U||!R||!R.__esModule?d(P,"default",{value:R,enumerable:!0}):P;for(let Z of qR(R))if(!KR.call(_,Z))d(_,Z,{get:()=>R[Z],enumerable:!0});return _};var g=(R,U)=>()=>(U||R((U={exports:{}}).exports,U),U.exports);var t=g((wP,l)=>{var IR=function(R,U){return R==null?void 0:R[U]},nR=function(R){var U=!1;if(R!=null&&typeof R.toString!="function")try{U=!!(R+"")}catch(P){}return U},T=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},bR=function(){this.__data__=V?V(null):{}},hR=function(R){return this.has(R)&&delete this.__data__[R]},iR=function(R){var U=this.__data__;if(V){var P=U[R];return P===i?void 0:P}return E.call(U,R)?U[R]:void 0},yR=function(R){var U=this.__data__;return V?U[R]!==void 0:E.call(U,R)},cR=function(R,U){var P=this.__data__;return P[R]=V&&U===void 0?i:U,this},X=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},oR=function(){this.__data__=[]},rR=function(R){var U=this.__data__,P=A(U,R);if(P<0)return!1;var _=U.length-1;if(P==_)U.pop();else jR.call(U,P,1);return!0},sR=function(R){var U=this.__data__,P=A(U,R);return P<0?void 0:U[P][1]},vR=function(R){return A(this.__data__,R)>-1},uR=function(R,U){var P=this.__data__,_=A(P,R);if(_<0)P.push([R,U]);else P[_][1]=U;return this},B=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},lR=function(){this.__data__={hash:new T,map:new(kR||X),string:new T}},tR=function(R){return L(this,R).delete(R)},aR=function(R){return L(this,R).get(R)},eR=function(R){return L(this,R).has(R)},RU=function(R,U){return L(this,R).set(R,U),this},UU=function(R,U,P){var _=R[U];if(!(E.call(R,U)&&v(_,P))||P===void 0&&!(U in R))R[U]=P},A=function(R,U){var P=R.length;while(P--)if(v(R[P][0],U))return P;return-1},PU=function(R){if(!G(R)||QU(R))return!1;var U=YU(R)||nR(R)?gR:HR;return U.test(XU(R))},_U=function(R,U,P,_){if(!G(R))return R;U=TU(U,R)?[U]:$U(U);var Z=-1,$=U.length,F=$-1,W=R;while(W!=null&&++Z<$){var q=WU(U[Z]),K=P;if(Z!=F){var f=W[q];if(K=_?_(f,q,W):void 0,K===void 0)K=G(f)?f:FU(U[Z+1])?[]:{}}UU(W,q,K),W=W[q]}return R},ZU=function(R){if(typeof R=="string")return R;if(H(R))return h?h.call(R):"";var U=R+"";return U=="0"&&1/R==-y?"-0":U},$U=function(R){return u(R)?R:JU(R)},L=function(R,U){var P=R.__data__;return BU(U)?P[typeof U=="string"?"string":"hash"]:P.map},s=function(R,U){var P=IR(R,U);return PU(P)?P:void 0},FU=function(R,U){return U=U==null?ER:U,!!U&&(typeof R=="number"||CR.test(R))&&(R>-1&&R%1==0&&R<U)},TU=function(R,U){if(u(R))return!1;var P=typeof R;if(P=="number"||P=="symbol"||P=="boolean"||R==null||H(R))return!0;return SR.test(R)||!zR.test(R)||U!=null&&R in Object(U)},BU=function(R){var U=typeof R;return U=="string"||U=="number"||U=="symbol"||U=="boolean"?R!=="__proto__":R===null},QU=function(R){return!!j&&j in R},WU=function(R){if(typeof R=="string"||H(R))return R;var U=R+"";return U=="0"&&1/R==-y?"-0":U},XU=function(R){if(R!=null){try{return o.call(R)}catch(U){}try{return R+""}catch(U){}}return""},D=function(R,U){if(typeof R!="function"||U&&typeof U!="function")throw new TypeError(GR);var P=function(){var _=arguments,Z=U?U.apply(this,_):_[0],$=P.cache;if($.has(Z))return $.get(Z);var F=R.apply(this,_);return P.cache=$.set(Z,F),F};return P.cache=new(D.Cache||B),P},v=function(R,U){return R===U||R!==R&&U!==U},YU=function(R){var U=G(R)?r.call(R):"";return U==AR||U==LR},G=function(R){var U=typeof R;return!!R&&(U=="object"||U=="function")},VU=function(R){return!!R&&typeof R=="object"},H=function(R){return typeof R=="symbol"||VU(R)&&r.call(R)==OR},wU=function(R){return R==null?"":ZU(R)},qU=function(R,U,P){return R==null?R:_U(R,U,P)},GR="Expected a function",i="__lodash_hash_undefined__",y=Infinity,ER=9007199254740991,AR="[object Function]",LR="[object GeneratorFunction]",OR="[object Symbol]",zR=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,SR=/^\w*$/,fR=/^\./,NR=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,MR=/[\\^$.*+?()[\]{}|]/g,DR=/\\(\\)?/g,HR=/^\[object .+?Constructor\]$/,CR=/^(?:0|[1-9]\d*)$/,xR=typeof global=="object"&&global&&global.Object===Object&&global,mR=typeof self=="object"&&self&&self.Object===Object&&self,M=xR||mR||Function("return this")(),dR=Array.prototype,pR=Function.prototype,c=Object.prototype,N=M["__core-js_shared__"],j=function(){var R=/[^.]+$/.exec(N&&N.keys&&N.keys.IE_PROTO||"");return R?"Symbol(src)_1."+R:""}(),o=pR.toString,E=c.hasOwnProperty,r=c.toString,gR=RegExp("^"+o.call(E).replace(MR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),k=M.Symbol,jR=dR.splice,kR=s(M,"Map"),V=s(Object,"create"),b=k?k.prototype:void 0,h=b?b.toString:void 0;T.prototype.clear=bR;T.prototype.delete=hR;T.prototype.get=iR;T.prototype.has=yR;T.prototype.set=cR;X.prototype.clear=oR;X.prototype.delete=rR;X.prototype.get=sR;X.prototype.has=vR;X.prototype.set=uR;B.prototype.clear=lR;B.prototype.delete=tR;B.prototype.get=aR;B.prototype.has=eR;B.prototype.set=RU;var JU=D(function(R){R=wU(R);var U=[];if(fR.test(R))U.push("");return R.replace(NR,function(P,_,Z,$){U.push(Z?$.replace(DR,"$1"):_||P)}),U});D.Cache=B;var u=Array.isArray;l.exports=qU});var XR=g((EP,WR)=>{var xU=function(R,U){return R==null?void 0:R[U]},mU=function(R){var U=!1;if(R!=null&&typeof R.toString!="function")try{U=!!(R+"")}catch(P){}return U},Q=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},jU=function(){this.__data__=w?w(null):{}},kU=function(R){return this.has(R)&&delete this.__data__[R]},bU=function(R){var U=this.__data__;if(w){var P=U[R];return P===_R?void 0:P}return m.call(U,R)?U[R]:void 0},hU=function(R){var U=this.__data__;return w?U[R]!==void 0:m.call(U,R)},iU=function(R,U){var P=this.__data__;return P[R]=w&&U===void 0?_R:U,this},Y=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},yU=function(){this.__data__=[]},cU=function(R){var U=this.__data__,P=z(U,R);if(P<0)return!1;var _=U.length-1;if(P==_)U.pop();else pU.call(U,P,1);return!0},oU=function(R){var U=this.__data__,P=z(U,R);return P<0?void 0:U[P][1]},rU=function(R){return z(this.__data__,R)>-1},sU=function(R,U){var P=this.__data__,_=z(P,R);if(_<0)P.push([R,U]);else P[_][1]=U;return this},J=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},vU=function(){this.__data__={hash:new Q,map:new(gU||Y),string:new Q}},uU=function(R){return S(this,R).delete(R)},lU=function(R){return S(this,R).get(R)},tU=function(R){return S(this,R).has(R)},aU=function(R,U){return S(this,R).set(R,U),this},z=function(R,U){var P=R.length;while(P--)if(QP(R[P][0],U))return P;return-1},eU=function(R,U){U=_P(U,R)?[U]:PP(U);var P=0,_=U.length;while(R!=null&&P<_)R=R[TP(U[P++])];return P&&P==_?R:void 0},RP=function(R){if(!JR(R)||$P(R))return!1;var U=JP(R)||mU(R)?dU:DU;return U.test(BP(R))},UP=function(R){if(typeof R=="string")return R;if(n(R))return PR?PR.call(R):"";var U=R+"";return U=="0"&&1/R==-ZR?"-0":U},PP=function(R){return QR(R)?R:FP(R)},S=function(R,U){var P=R.__data__;return ZP(U)?P[typeof U=="string"?"string":"hash"]:P.map},BR=function(R,U){var P=xU(R,U);return RP(P)?P:void 0},_P=function(R,U){if(QR(R))return!1;var P=typeof R;if(P=="number"||P=="symbol"||P=="boolean"||R==null||n(R))return!0;return zU.test(R)||!OU.test(R)||U!=null&&R in Object(U)},ZP=function(R){var U=typeof R;return U=="string"||U=="number"||U=="symbol"||U=="boolean"?R!=="__proto__":R===null},$P=function(R){return!!e&&e in R},TP=function(R){if(typeof R=="string"||n(R))return R;var U=R+"";return U=="0"&&1/R==-ZR?"-0":U},BP=function(R){if(R!=null){try{return FR.call(R)}catch(U){}try{return R+""}catch(U){}}return""},I=function(R,U){if(typeof R!="function"||U&&typeof U!="function")throw new TypeError(GU);var P=function(){var _=arguments,Z=U?U.apply(this,_):_[0],$=P.cache;if($.has(Z))return $.get(Z);var F=R.apply(this,_);return P.cache=$.set(Z,F),F};return P.cache=new(I.Cache||J),P},QP=function(R,U){return R===U||R!==R&&U!==U},JP=function(R){var U=JR(R)?TR.call(R):"";return U==EU||U==AU},JR=function(R){var U=typeof R;return!!R&&(U=="object"||U=="function")},WP=function(R){return!!R&&typeof R=="object"},n=function(R){return typeof R=="symbol"||WP(R)&&TR.call(R)==LU},XP=function(R){return R==null?"":UP(R)},YP=function(R,U,P){var _=R==null?void 0:eU(R,U);return _===void 0?P:_},GU="Expected a function",_R="__lodash_hash_undefined__",ZR=Infinity,EU="[object Function]",AU="[object GeneratorFunction]",LU="[object Symbol]",OU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zU=/^\w*$/,SU=/^\./,fU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,NU=/[\\^$.*+?()[\]{}|]/g,MU=/\\(\\)?/g,DU=/^\[object .+?Constructor\]$/,HU=typeof global=="object"&&global&&global.Object===Object&&global,CU=typeof self=="object"&&self&&self.Object===Object&&self,x=HU||CU||Function("return this")(),IU=Array.prototype,nU=Function.prototype,$R=Object.prototype,C=x["__core-js_shared__"],e=function(){var R=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||"");return R?"Symbol(src)_1."+R:""}(),FR=nU.toString,m=$R.hasOwnProperty,TR=$R.toString,dU=RegExp("^"+FR.call(m).replace(NU,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),RR=x.Symbol,pU=IU.splice,gU=BR(x,"Map"),w=BR(Object,"create"),UR=RR?RR.prototype:void 0,PR=UR?UR.toString:void 0;Q.prototype.clear=jU;Q.prototype.delete=kU;Q.prototype.get=bU;Q.prototype.has=hU;Q.prototype.set=iU;Y.prototype.clear=yU;Y.prototype.delete=cU;Y.prototype.get=oU;Y.prototype.has=rU;Y.prototype.set=sU;J.prototype.clear=vU;J.prototype.delete=uU;J.prototype.get=lU;J.prototype.has=tU;J.prototype.set=aU;var FP=I(function(R){R=XP(R);var U=[];if(SU.test(R))U.push("");return R.replace(fU,function(P,_,Z,$){U.push(Z?$.replace(MU,"$1"):_||P)}),U});I.Cache=J;var QR=Array.isArray;WR.exports=YP});var a=p(t(),1),O={isNamespace:(R)=>R&&!R.type,flattenSchema(R,U){return Object.entries(R).reduce((P,[_,Z])=>{if(O.isNamespace(Z))P={...P,...O.flattenSchema(Z,_)};else{const $=U?`${U}.${_}`:_;Object.assign(Z,{key:_,path:$}),P[$]=Z}return P},{})},wrapSchema(R){return Object.values(R).reduce((U,P)=>{return a.default(U,P.path,P),U},{})}};class KU{schemas;falttenSchema;static Var(R){return{...R,type:"var"}}static Func(R){return{...R,type:"func"}}constructor(R={}){Object.assign(this,R),this.falttenSchema=O.flattenSchema(this.schemas)}loadFull(){return Object.entries(this.falttenSchema).map(([R,U])=>{if(U.type=="func"){const{type:P,input:_,key:Z}=U;return{type:P,name:R,key:Z,input:_}}if(U.type=="var"){const{type:P,get:_,key:Z}=U;return{type:P,name:R,key:Z,value:_()}}return{type:"unknown",name:R}})}loadVars(){return Object.entries(this.falttenSchema).filter(([R,U])=>U.type=="var").map(([R,U])=>{const{get:P,set:_}=U;return{name:R,value:P(),get:P,set:_}})}}var YR=p(XR(),1),AP=(R)=>{return{schema:{async loadFull(){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadFull"})}).then((U)=>U.json())},async loadVars(){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadVars"})}).then((U)=>U.json())}},func:{async call(U){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"func.call",params:U})}).then((P)=>P.json())}},var:{async set(U){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.set",params:U})}).then((P)=>P.json())},async patch(U){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.patch",params:U})}).then((P)=>P.json())}}}},LP=({urpc:R})=>{const U={urpc:R,handle({name:P,params:_}){const Z=YR.default(U,P);if(!Z)throw new Error("invalid name");return Z(_)},schema:{async loadFull(){return R.loadFull()},async loadVars(){return R.loadVars()}},func:{async call(P){const _=R.falttenSchema[P.method];if(!_)throw new Error("invalid func name");return _.func({input:P.input})}},var:{async set(P){const _=R.falttenSchema[P.name];if(!_)throw new Error("invalid var name");if(!_.set)throw new Error("variable can't be set");return _.set(P.value)},async patch(P){throw new Error("TBD")}}};return U};export{O as utils,AP as createSimpleHttpClient,LP as createServerClient,KU as URPC};
var VR=Object.create;var{defineProperty:d,getPrototypeOf:wR,getOwnPropertyNames:qR}=Object;var KR=Object.prototype.hasOwnProperty;var p=(R,U,P)=>{P=R!=null?VR(wR(R)):{};const _=U||!R||!R.__esModule?d(P,"default",{value:R,enumerable:!0}):P;for(let Z of qR(R))if(!KR.call(_,Z))d(_,Z,{get:()=>R[Z],enumerable:!0});return _};var g=(R,U)=>()=>(U||R((U={exports:{}}).exports,U),U.exports);var t=g((wP,l)=>{var IR=function(R,U){return R==null?void 0:R[U]},nR=function(R){var U=!1;if(R!=null&&typeof R.toString!="function")try{U=!!(R+"")}catch(P){}return U},T=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},bR=function(){this.__data__=V?V(null):{}},hR=function(R){return this.has(R)&&delete this.__data__[R]},iR=function(R){var U=this.__data__;if(V){var P=U[R];return P===i?void 0:P}return E.call(U,R)?U[R]:void 0},yR=function(R){var U=this.__data__;return V?U[R]!==void 0:E.call(U,R)},cR=function(R,U){var P=this.__data__;return P[R]=V&&U===void 0?i:U,this},X=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},oR=function(){this.__data__=[]},rR=function(R){var U=this.__data__,P=A(U,R);if(P<0)return!1;var _=U.length-1;if(P==_)U.pop();else jR.call(U,P,1);return!0},sR=function(R){var U=this.__data__,P=A(U,R);return P<0?void 0:U[P][1]},vR=function(R){return A(this.__data__,R)>-1},uR=function(R,U){var P=this.__data__,_=A(P,R);if(_<0)P.push([R,U]);else P[_][1]=U;return this},B=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},lR=function(){this.__data__={hash:new T,map:new(kR||X),string:new T}},tR=function(R){return L(this,R).delete(R)},aR=function(R){return L(this,R).get(R)},eR=function(R){return L(this,R).has(R)},RU=function(R,U){return L(this,R).set(R,U),this},UU=function(R,U,P){var _=R[U];if(!(E.call(R,U)&&v(_,P))||P===void 0&&!(U in R))R[U]=P},A=function(R,U){var P=R.length;while(P--)if(v(R[P][0],U))return P;return-1},PU=function(R){if(!G(R)||QU(R))return!1;var U=YU(R)||nR(R)?gR:HR;return U.test(XU(R))},_U=function(R,U,P,_){if(!G(R))return R;U=TU(U,R)?[U]:$U(U);var Z=-1,$=U.length,F=$-1,W=R;while(W!=null&&++Z<$){var q=WU(U[Z]),K=P;if(Z!=F){var f=W[q];if(K=_?_(f,q,W):void 0,K===void 0)K=G(f)?f:FU(U[Z+1])?[]:{}}UU(W,q,K),W=W[q]}return R},ZU=function(R){if(typeof R=="string")return R;if(H(R))return h?h.call(R):"";var U=R+"";return U=="0"&&1/R==-y?"-0":U},$U=function(R){return u(R)?R:JU(R)},L=function(R,U){var P=R.__data__;return BU(U)?P[typeof U=="string"?"string":"hash"]:P.map},s=function(R,U){var P=IR(R,U);return PU(P)?P:void 0},FU=function(R,U){return U=U==null?ER:U,!!U&&(typeof R=="number"||CR.test(R))&&(R>-1&&R%1==0&&R<U)},TU=function(R,U){if(u(R))return!1;var P=typeof R;if(P=="number"||P=="symbol"||P=="boolean"||R==null||H(R))return!0;return SR.test(R)||!zR.test(R)||U!=null&&R in Object(U)},BU=function(R){var U=typeof R;return U=="string"||U=="number"||U=="symbol"||U=="boolean"?R!=="__proto__":R===null},QU=function(R){return!!j&&j in R},WU=function(R){if(typeof R=="string"||H(R))return R;var U=R+"";return U=="0"&&1/R==-y?"-0":U},XU=function(R){if(R!=null){try{return o.call(R)}catch(U){}try{return R+""}catch(U){}}return""},D=function(R,U){if(typeof R!="function"||U&&typeof U!="function")throw new TypeError(GR);var P=function(){var _=arguments,Z=U?U.apply(this,_):_[0],$=P.cache;if($.has(Z))return $.get(Z);var F=R.apply(this,_);return P.cache=$.set(Z,F),F};return P.cache=new(D.Cache||B),P},v=function(R,U){return R===U||R!==R&&U!==U},YU=function(R){var U=G(R)?r.call(R):"";return U==AR||U==LR},G=function(R){var U=typeof R;return!!R&&(U=="object"||U=="function")},VU=function(R){return!!R&&typeof R=="object"},H=function(R){return typeof R=="symbol"||VU(R)&&r.call(R)==OR},wU=function(R){return R==null?"":ZU(R)},qU=function(R,U,P){return R==null?R:_U(R,U,P)},GR="Expected a function",i="__lodash_hash_undefined__",y=Infinity,ER=9007199254740991,AR="[object Function]",LR="[object GeneratorFunction]",OR="[object Symbol]",zR=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,SR=/^\w*$/,fR=/^\./,NR=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,MR=/[\\^$.*+?()[\]{}|]/g,DR=/\\(\\)?/g,HR=/^\[object .+?Constructor\]$/,CR=/^(?:0|[1-9]\d*)$/,xR=typeof global=="object"&&global&&global.Object===Object&&global,mR=typeof self=="object"&&self&&self.Object===Object&&self,M=xR||mR||Function("return this")(),dR=Array.prototype,pR=Function.prototype,c=Object.prototype,N=M["__core-js_shared__"],j=function(){var R=/[^.]+$/.exec(N&&N.keys&&N.keys.IE_PROTO||"");return R?"Symbol(src)_1."+R:""}(),o=pR.toString,E=c.hasOwnProperty,r=c.toString,gR=RegExp("^"+o.call(E).replace(MR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),k=M.Symbol,jR=dR.splice,kR=s(M,"Map"),V=s(Object,"create"),b=k?k.prototype:void 0,h=b?b.toString:void 0;T.prototype.clear=bR;T.prototype.delete=hR;T.prototype.get=iR;T.prototype.has=yR;T.prototype.set=cR;X.prototype.clear=oR;X.prototype.delete=rR;X.prototype.get=sR;X.prototype.has=vR;X.prototype.set=uR;B.prototype.clear=lR;B.prototype.delete=tR;B.prototype.get=aR;B.prototype.has=eR;B.prototype.set=RU;var JU=D(function(R){R=wU(R);var U=[];if(fR.test(R))U.push("");return R.replace(NR,function(P,_,Z,$){U.push(Z?$.replace(DR,"$1"):_||P)}),U});D.Cache=B;var u=Array.isArray;l.exports=qU});var XR=g((EP,WR)=>{var xU=function(R,U){return R==null?void 0:R[U]},mU=function(R){var U=!1;if(R!=null&&typeof R.toString!="function")try{U=!!(R+"")}catch(P){}return U},Q=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},jU=function(){this.__data__=w?w(null):{}},kU=function(R){return this.has(R)&&delete this.__data__[R]},bU=function(R){var U=this.__data__;if(w){var P=U[R];return P===_R?void 0:P}return m.call(U,R)?U[R]:void 0},hU=function(R){var U=this.__data__;return w?U[R]!==void 0:m.call(U,R)},iU=function(R,U){var P=this.__data__;return P[R]=w&&U===void 0?_R:U,this},Y=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},yU=function(){this.__data__=[]},cU=function(R){var U=this.__data__,P=z(U,R);if(P<0)return!1;var _=U.length-1;if(P==_)U.pop();else pU.call(U,P,1);return!0},oU=function(R){var U=this.__data__,P=z(U,R);return P<0?void 0:U[P][1]},rU=function(R){return z(this.__data__,R)>-1},sU=function(R,U){var P=this.__data__,_=z(P,R);if(_<0)P.push([R,U]);else P[_][1]=U;return this},J=function(R){var U=-1,P=R?R.length:0;this.clear();while(++U<P){var _=R[U];this.set(_[0],_[1])}},vU=function(){this.__data__={hash:new Q,map:new(gU||Y),string:new Q}},uU=function(R){return S(this,R).delete(R)},lU=function(R){return S(this,R).get(R)},tU=function(R){return S(this,R).has(R)},aU=function(R,U){return S(this,R).set(R,U),this},z=function(R,U){var P=R.length;while(P--)if(QP(R[P][0],U))return P;return-1},eU=function(R,U){U=_P(U,R)?[U]:PP(U);var P=0,_=U.length;while(R!=null&&P<_)R=R[TP(U[P++])];return P&&P==_?R:void 0},RP=function(R){if(!JR(R)||$P(R))return!1;var U=JP(R)||mU(R)?dU:DU;return U.test(BP(R))},UP=function(R){if(typeof R=="string")return R;if(n(R))return PR?PR.call(R):"";var U=R+"";return U=="0"&&1/R==-ZR?"-0":U},PP=function(R){return QR(R)?R:FP(R)},S=function(R,U){var P=R.__data__;return ZP(U)?P[typeof U=="string"?"string":"hash"]:P.map},BR=function(R,U){var P=xU(R,U);return RP(P)?P:void 0},_P=function(R,U){if(QR(R))return!1;var P=typeof R;if(P=="number"||P=="symbol"||P=="boolean"||R==null||n(R))return!0;return zU.test(R)||!OU.test(R)||U!=null&&R in Object(U)},ZP=function(R){var U=typeof R;return U=="string"||U=="number"||U=="symbol"||U=="boolean"?R!=="__proto__":R===null},$P=function(R){return!!e&&e in R},TP=function(R){if(typeof R=="string"||n(R))return R;var U=R+"";return U=="0"&&1/R==-ZR?"-0":U},BP=function(R){if(R!=null){try{return FR.call(R)}catch(U){}try{return R+""}catch(U){}}return""},I=function(R,U){if(typeof R!="function"||U&&typeof U!="function")throw new TypeError(GU);var P=function(){var _=arguments,Z=U?U.apply(this,_):_[0],$=P.cache;if($.has(Z))return $.get(Z);var F=R.apply(this,_);return P.cache=$.set(Z,F),F};return P.cache=new(I.Cache||J),P},QP=function(R,U){return R===U||R!==R&&U!==U},JP=function(R){var U=JR(R)?TR.call(R):"";return U==EU||U==AU},JR=function(R){var U=typeof R;return!!R&&(U=="object"||U=="function")},WP=function(R){return!!R&&typeof R=="object"},n=function(R){return typeof R=="symbol"||WP(R)&&TR.call(R)==LU},XP=function(R){return R==null?"":UP(R)},YP=function(R,U,P){var _=R==null?void 0:eU(R,U);return _===void 0?P:_},GU="Expected a function",_R="__lodash_hash_undefined__",ZR=Infinity,EU="[object Function]",AU="[object GeneratorFunction]",LU="[object Symbol]",OU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zU=/^\w*$/,SU=/^\./,fU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,NU=/[\\^$.*+?()[\]{}|]/g,MU=/\\(\\)?/g,DU=/^\[object .+?Constructor\]$/,HU=typeof global=="object"&&global&&global.Object===Object&&global,CU=typeof self=="object"&&self&&self.Object===Object&&self,x=HU||CU||Function("return this")(),IU=Array.prototype,nU=Function.prototype,$R=Object.prototype,C=x["__core-js_shared__"],e=function(){var R=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||"");return R?"Symbol(src)_1."+R:""}(),FR=nU.toString,m=$R.hasOwnProperty,TR=$R.toString,dU=RegExp("^"+FR.call(m).replace(NU,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),RR=x.Symbol,pU=IU.splice,gU=BR(x,"Map"),w=BR(Object,"create"),UR=RR?RR.prototype:void 0,PR=UR?UR.toString:void 0;Q.prototype.clear=jU;Q.prototype.delete=kU;Q.prototype.get=bU;Q.prototype.has=hU;Q.prototype.set=iU;Y.prototype.clear=yU;Y.prototype.delete=cU;Y.prototype.get=oU;Y.prototype.has=rU;Y.prototype.set=sU;J.prototype.clear=vU;J.prototype.delete=uU;J.prototype.get=lU;J.prototype.has=tU;J.prototype.set=aU;var FP=I(function(R){R=XP(R);var U=[];if(SU.test(R))U.push("");return R.replace(fU,function(P,_,Z,$){U.push(Z?$.replace(MU,"$1"):_||P)}),U});I.Cache=J;var QR=Array.isArray;WR.exports=YP});var a=p(t(),1),O={isNamespace:(R)=>R&&!R.type,flattenSchema(R,U){return Object.entries(R).reduce((P,[_,Z])=>{if(O.isNamespace(Z))P={...P,...O.flattenSchema(Z,_)};else{const $=U?`${U}.${_}`:_;Object.assign(Z,{name:$}),P[$]=Z}return P},{})},wrapSchema(R){return Object.values(R).reduce((U,P)=>{return a.default(U,P.path,P),U},{})}};class KU{schemas;falttenSchema;static Var(R){return{...R,type:"var"}}static Func(R){return{...R,type:"func"}}constructor(R={}){Object.assign(this,R),this.falttenSchema=O.flattenSchema(this.schemas)}loadFull(){return Object.entries(this.falttenSchema).map(([R,U])=>{if(U.type=="func"){const{type:P,input:_,name:Z}=U;return{type:P,name:Z,input:_}}if(U.type=="var"){const{type:P,get:_,name:Z}=U;return{type:P,name:Z,value:_()}}return{type:"unknown",name:R}})}loadVars(){return Object.entries(this.falttenSchema).filter(([R,U])=>U.type=="var").map(([R,U])=>{const{get:P,set:_,name:Z}=U;return{name:Z,value:P(),get:P,set:_}})}}var YR=p(XR(),1),AP=(R)=>{return{schema:{async loadFull(){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadFull"})}).then((U)=>U.json())},async loadVars(){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadVars"})}).then((U)=>U.json())}},func:{async call(U){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"func.call",params:U})}).then((P)=>P.json())}},var:{async set(U){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.set",params:U})}).then((P)=>P.json())},async patch(U){return fetch(`${R.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.patch",params:U})}).then((P)=>P.json())}}}},LP=({urpc:R})=>{const U={urpc:R,handle({name:P,params:_}){const Z=YR.default(U,P);if(!Z)throw new Error("invalid name");return Z(_)},schema:{async loadFull(){return R.loadFull()},async loadVars(){return R.loadVars()}},func:{async call(P){const _=R.falttenSchema[P.method];if(!_)throw new Error("invalid func name");return _.func({input:P.input})}},var:{async set(P){const _=R.falttenSchema[P.name];if(!_)throw new Error("invalid var name");if(!_.set)throw new Error("variable can't be set");return _.set(P.value)},async patch(P){throw new Error("TBD")}}};return U};export{O as utils,AP as createSimpleHttpClient,LP as createServerClient,KU as URPC};
{
"name": "@dappworks/urpc",
"version": "0.0.5",
"version": "0.0.6",
"module": "index.ts",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc