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.2 to 0.0.3

8

dist/index.d.ts

@@ -60,5 +60,5 @@ // Generated by dts-bundle-generator v9.5.1

var: {
overwrite(params: {
name: string;
value: any;
set<R_1 extends keyof T, V extends T[R_1] extends URPC_Variable<infer Z_2 extends () => any, any> ? Z_2 : never>(params: {
name: R_1;
value: ReturnType<V>;
}): Promise<any>;

@@ -110,3 +110,3 @@ patch(params: {

var: {
overwrite(params: {
set(params: {
name: string;

@@ -113,0 +113,0 @@ value: any;

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

var d=Object.create;var{defineProperty:K,getPrototypeOf:b,getOwnPropertyNames:m}=Object;var g=Object.prototype.hasOwnProperty;var h=(B,Q,W)=>{W=B!=null?d(b(B)):{};const Z=Q||!B||!B.__esModule?K(W,"default",{value:B,enumerable:!0}):W;for(let $ of m(B))if(!g.call(Z,$))K(Z,$,{get:()=>B[$],enumerable:!0});return Z};var k=(B,Q)=>()=>(Q||B((Q={exports:{}}).exports,Q),Q.exports);var j=k((k0,S)=>{var B0=function(B,Q){return B==null?void 0:B[Q]},Q0=function(B){var Q=!1;if(B!=null&&typeof B.toString!="function")try{Q=!!(B+"")}catch(W){}return Q},U=function(B){var Q=-1,W=B?B.length:0;this.clear();while(++Q<W){var Z=B[Q];this.set(Z[0],Z[1])}},Y0=function(){this.__data__=w?w(null):{}},_0=function(B){return this.has(B)&&delete this.__data__[B]},w0=function(B){var Q=this.__data__;if(w){var W=Q[B];return W===N?void 0:W}return A.call(Q,B)?Q[B]:void 0},V0=function(B){var Q=this.__data__;return w?Q[B]!==void 0:A.call(Q,B)},q0=function(B,Q){var W=this.__data__;return W[B]=w&&Q===void 0?N:Q,this},Y=function(B){var Q=-1,W=B?B.length:0;this.clear();while(++Q<W){var Z=B[Q];this.set(Z[0],Z[1])}},J0=function(){this.__data__=[]},R0=function(B){var Q=this.__data__,W=V(Q,B);if(W<0)return!1;var Z=Q.length-1;if(W==Z)Q.pop();else U0.call(Q,W,1);return!0},A0=function(B){var Q=this.__data__,W=V(Q,B);return W<0?void 0:Q[W][1]},G0=function(B){return V(this.__data__,B)>-1},z0=function(B,Q){var W=this.__data__,Z=V(W,B);if(Z<0)W.push([B,Q]);else W[Z][1]=Q;return this},X=function(B){var Q=-1,W=B?B.length:0;this.clear();while(++Q<W){var Z=B[Q];this.set(Z[0],Z[1])}},F0=function(){this.__data__={hash:new U,map:new(X0||Y),string:new U}},K0=function(B){return q(this,B).delete(B)},E0=function(B){return q(this,B).get(B)},L0=function(B){return q(this,B).has(B)},O0=function(B,Q){return q(this,B).set(B,Q),this},V=function(B,Q){var W=B.length;while(W--)if(j0(B[W][0],Q))return W;return-1},T0=function(B,Q){Q=H0(Q,B)?[Q]:P0(Q);var W=0,Z=Q.length;while(B!=null&&W<Z)B=B[x0(Q[W++])];return W&&W==Z?B:void 0},N0=function(B){if(!x(B)||D0(B))return!1;var Q=C0(B)||Q0(B)?$0:t;return Q.test(S0(B))},M0=function(B){if(typeof B=="string")return B;if(z(B))return T?T.call(B):"";var Q=B+"";return Q=="0"&&1/B==-M?"-0":Q},P0=function(B){return f(B)?B:f0(B)},q=function(B,Q){var W=B.__data__;return I0(Q)?W[typeof Q=="string"?"string":"hash"]:W.map},D=function(B,Q){var W=B0(B,Q);return N0(W)?W:void 0},H0=function(B,Q){if(f(B))return!1;var W=typeof B;if(W=="number"||W=="symbol"||W=="boolean"||B==null||z(B))return!0;return v.test(B)||!y.test(B)||Q!=null&&B in Object(Q)},I0=function(B){var Q=typeof B;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?B!=="__proto__":B===null},D0=function(B){return!!E&&E in B},x0=function(B){if(typeof B=="string"||z(B))return B;var Q=B+"";return Q=="0"&&1/B==-M?"-0":Q},S0=function(B){if(B!=null){try{return H.call(B)}catch(Q){}try{return B+""}catch(Q){}}return""},G=function(B,Q){if(typeof B!="function"||Q&&typeof Q!="function")throw new TypeError(n);var W=function(){var Z=arguments,$=Q?Q.apply(this,Z):Z[0],_=W.cache;if(_.has($))return _.get($);var F=B.apply(this,Z);return W.cache=_.set($,F),F};return W.cache=new(G.Cache||X),W},j0=function(B,Q){return B===Q||B!==B&&Q!==Q},C0=function(B){var Q=x(B)?I.call(B):"";return Q==i||Q==o},x=function(B){var Q=typeof B;return!!B&&(Q=="object"||Q=="function")},d0=function(B){return!!B&&typeof B=="object"},z=function(B){return typeof B=="symbol"||d0(B)&&I.call(B)==c},b0=function(B){return B==null?"":M0(B)},m0=function(B,Q,W){var Z=B==null?void 0:T0(B,Q);return Z===void 0?W:Z},n="Expected a function",N="__lodash_hash_undefined__",M=Infinity,i="[object Function]",o="[object GeneratorFunction]",c="[object Symbol]",y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,v=/^\w*$/,s=/^\./,u=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l=/[\\^$.*+?()[\]{}|]/g,r=/\\(\\)?/g,t=/^\[object .+?Constructor\]$/,a=typeof global=="object"&&global&&global.Object===Object&&global,e=typeof self=="object"&&self&&self.Object===Object&&self,R=a||e||Function("return this")(),W0=Array.prototype,Z0=Function.prototype,P=Object.prototype,J=R["__core-js_shared__"],E=function(){var B=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return B?"Symbol(src)_1."+B:""}(),H=Z0.toString,A=P.hasOwnProperty,I=P.toString,$0=RegExp("^"+H.call(A).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),L=R.Symbol,U0=W0.splice,X0=D(R,"Map"),w=D(Object,"create"),O=L?L.prototype:void 0,T=O?O.toString:void 0;U.prototype.clear=Y0;U.prototype.delete=_0;U.prototype.get=w0;U.prototype.has=V0;U.prototype.set=q0;Y.prototype.clear=J0;Y.prototype.delete=R0;Y.prototype.get=A0;Y.prototype.has=G0;Y.prototype.set=z0;X.prototype.clear=F0;X.prototype.delete=K0;X.prototype.get=E0;X.prototype.has=L0;X.prototype.set=O0;var f0=G(function(B){B=b0(B);var Q=[];if(s.test(B))Q.push("");return B.replace(u,function(W,Z,$,_){Q.push($?_.replace(r,"$1"):Z||W)}),Q});G.Cache=X;var f=Array.isArray;S.exports=m0});class p{schemas;static Var(B){return{...B,type:"var"}}static Func(B){return{...B,type:"func"}}constructor(B={}){Object.assign(this,B)}loadFull(){return Object.entries(this.schemas).map(([B,Q])=>{if(Q.type=="func"){const{type:W,input:Z}=Q;return{type:W,name:B,input:Z}}if(Q.type=="var"){const{type:W,get:Z}=Q;return{type:W,name:B,value:Z()}}return{type:"unknown",name:B}})}loadVars(){return Object.entries(this.schemas).filter(([B,Q])=>Q.type=="var").map(([B,Q])=>{const{get:W,set:Z}=Q;return{name:B,value:W(),get:W,set:Z}})}}var C=h(j(),1),p0=(B)=>{return{schema:{async loadFull(){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadFull"})}).then((Q)=>Q.json())},async loadVars(){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadVars"})}).then((Q)=>Q.json())}},func:{async call(Q){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"func.call",params:Q})}).then((W)=>W.json())}},var:{async overwrite(Q){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.overwrite",params:Q})}).then((W)=>W.json())},async patch(Q){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.patch",params:Q})}).then((W)=>W.json())}}}},n0=({urpc:B})=>{const Q={urpc:B,handle({name:W,params:Z}){const $=C.default(Q,W);if(console.log(W,Z),!$)throw new Error("invalid name");return $(Z)},schema:{async loadFull(){return B.loadFull()},async loadVars(){return B.loadVars()}},func:{async call(W){const Z=B.schemas[W.method];if(!Z)throw new Error("invalid func name");return Z.func({input:W.input})}},var:{async overwrite(W){const Z=B.schemas[W.name];if(!Z)throw new Error("invalid var name");if(!Z.set)throw new Error("variable can't be set");return Z.set({value:W.value})},async patch(W){throw new Error("TBD")}}};return Q};export{p0 as createSimpleHttpClient,n0 as createServerClient,p as URPC};
var b=Object.create;var{defineProperty:K,getPrototypeOf:d,getOwnPropertyNames:m}=Object;var g=Object.prototype.hasOwnProperty;var h=(B,Q,W)=>{W=B!=null?b(d(B)):{};const Z=Q||!B||!B.__esModule?K(W,"default",{value:B,enumerable:!0}):W;for(let _ of m(B))if(!g.call(Z,_))K(Z,_,{get:()=>B[_],enumerable:!0});return Z};var k=(B,Q)=>()=>(Q||B((Q={exports:{}}).exports,Q),Q.exports);var j=k((k0,S)=>{var B0=function(B,Q){return B==null?void 0:B[Q]},Q0=function(B){var Q=!1;if(B!=null&&typeof B.toString!="function")try{Q=!!(B+"")}catch(W){}return Q},$=function(B){var Q=-1,W=B?B.length:0;this.clear();while(++Q<W){var Z=B[Q];this.set(Z[0],Z[1])}},X0=function(){this.__data__=w?w(null):{}},Y0=function(B){return this.has(B)&&delete this.__data__[B]},w0=function(B){var Q=this.__data__;if(w){var W=Q[B];return W===N?void 0:W}return A.call(Q,B)?Q[B]:void 0},V0=function(B){var Q=this.__data__;return w?Q[B]!==void 0:A.call(Q,B)},q0=function(B,Q){var W=this.__data__;return W[B]=w&&Q===void 0?N:Q,this},X=function(B){var Q=-1,W=B?B.length:0;this.clear();while(++Q<W){var Z=B[Q];this.set(Z[0],Z[1])}},J0=function(){this.__data__=[]},R0=function(B){var Q=this.__data__,W=V(Q,B);if(W<0)return!1;var Z=Q.length-1;if(W==Z)Q.pop();else $0.call(Q,W,1);return!0},A0=function(B){var Q=this.__data__,W=V(Q,B);return W<0?void 0:Q[W][1]},G0=function(B){return V(this.__data__,B)>-1},z0=function(B,Q){var W=this.__data__,Z=V(W,B);if(Z<0)W.push([B,Q]);else W[Z][1]=Q;return this},U=function(B){var Q=-1,W=B?B.length:0;this.clear();while(++Q<W){var Z=B[Q];this.set(Z[0],Z[1])}},F0=function(){this.__data__={hash:new $,map:new(U0||X),string:new $}},K0=function(B){return q(this,B).delete(B)},E0=function(B){return q(this,B).get(B)},L0=function(B){return q(this,B).has(B)},T0=function(B,Q){return q(this,B).set(B,Q),this},V=function(B,Q){var W=B.length;while(W--)if(j0(B[W][0],Q))return W;return-1},O0=function(B,Q){Q=H0(Q,B)?[Q]:P0(Q);var W=0,Z=Q.length;while(B!=null&&W<Z)B=B[x0(Q[W++])];return W&&W==Z?B:void 0},N0=function(B){if(!x(B)||D0(B))return!1;var Q=C0(B)||Q0(B)?_0:t;return Q.test(S0(B))},M0=function(B){if(typeof B=="string")return B;if(z(B))return O?O.call(B):"";var Q=B+"";return Q=="0"&&1/B==-M?"-0":Q},P0=function(B){return f(B)?B:f0(B)},q=function(B,Q){var W=B.__data__;return I0(Q)?W[typeof Q=="string"?"string":"hash"]:W.map},D=function(B,Q){var W=B0(B,Q);return N0(W)?W:void 0},H0=function(B,Q){if(f(B))return!1;var W=typeof B;if(W=="number"||W=="symbol"||W=="boolean"||B==null||z(B))return!0;return v.test(B)||!c.test(B)||Q!=null&&B in Object(Q)},I0=function(B){var Q=typeof B;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?B!=="__proto__":B===null},D0=function(B){return!!E&&E in B},x0=function(B){if(typeof B=="string"||z(B))return B;var Q=B+"";return Q=="0"&&1/B==-M?"-0":Q},S0=function(B){if(B!=null){try{return H.call(B)}catch(Q){}try{return B+""}catch(Q){}}return""},G=function(B,Q){if(typeof B!="function"||Q&&typeof Q!="function")throw new TypeError(i);var W=function(){var Z=arguments,_=Q?Q.apply(this,Z):Z[0],Y=W.cache;if(Y.has(_))return Y.get(_);var F=B.apply(this,Z);return W.cache=Y.set(_,F),F};return W.cache=new(G.Cache||U),W},j0=function(B,Q){return B===Q||B!==B&&Q!==Q},C0=function(B){var Q=x(B)?I.call(B):"";return Q==n||Q==o},x=function(B){var Q=typeof B;return!!B&&(Q=="object"||Q=="function")},b0=function(B){return!!B&&typeof B=="object"},z=function(B){return typeof B=="symbol"||b0(B)&&I.call(B)==y},d0=function(B){return B==null?"":M0(B)},m0=function(B,Q,W){var Z=B==null?void 0:O0(B,Q);return Z===void 0?W:Z},i="Expected a function",N="__lodash_hash_undefined__",M=Infinity,n="[object Function]",o="[object GeneratorFunction]",y="[object Symbol]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,v=/^\w*$/,s=/^\./,u=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l=/[\\^$.*+?()[\]{}|]/g,r=/\\(\\)?/g,t=/^\[object .+?Constructor\]$/,a=typeof global=="object"&&global&&global.Object===Object&&global,e=typeof self=="object"&&self&&self.Object===Object&&self,R=a||e||Function("return this")(),W0=Array.prototype,Z0=Function.prototype,P=Object.prototype,J=R["__core-js_shared__"],E=function(){var B=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return B?"Symbol(src)_1."+B:""}(),H=Z0.toString,A=P.hasOwnProperty,I=P.toString,_0=RegExp("^"+H.call(A).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),L=R.Symbol,$0=W0.splice,U0=D(R,"Map"),w=D(Object,"create"),T=L?L.prototype:void 0,O=T?T.toString:void 0;$.prototype.clear=X0;$.prototype.delete=Y0;$.prototype.get=w0;$.prototype.has=V0;$.prototype.set=q0;X.prototype.clear=J0;X.prototype.delete=R0;X.prototype.get=A0;X.prototype.has=G0;X.prototype.set=z0;U.prototype.clear=F0;U.prototype.delete=K0;U.prototype.get=E0;U.prototype.has=L0;U.prototype.set=T0;var f0=G(function(B){B=d0(B);var Q=[];if(s.test(B))Q.push("");return B.replace(u,function(W,Z,_,Y){Q.push(_?Y.replace(r,"$1"):Z||W)}),Q});G.Cache=U;var f=Array.isArray;S.exports=m0});class p{schemas;static Var(B){return{...B,type:"var"}}static Func(B){return{...B,type:"func"}}constructor(B={}){Object.assign(this,B)}loadFull(){return Object.entries(this.schemas).map(([B,Q])=>{if(Q.type=="func"){const{type:W,input:Z}=Q;return{type:W,name:B,input:Z}}if(Q.type=="var"){const{type:W,get:Z}=Q;return{type:W,name:B,value:Z()}}return{type:"unknown",name:B}})}loadVars(){return Object.entries(this.schemas).filter(([B,Q])=>Q.type=="var").map(([B,Q])=>{const{get:W,set:Z}=Q;return{name:B,value:W(),get:W,set:Z}})}}var C=h(j(),1),p0=(B)=>{return{schema:{async loadFull(){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadFull"})}).then((Q)=>Q.json())},async loadVars(){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"schema.loadVars"})}).then((Q)=>Q.json())}},func:{async call(Q){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"func.call",params:Q})}).then((W)=>W.json())}},var:{async set(Q){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.set",params:Q})}).then((W)=>W.json())},async patch(Q){return fetch(`${B.url}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"var.patch",params:Q})}).then((W)=>W.json())}}}},i0=({urpc:B})=>{const Q={urpc:B,handle({name:W,params:Z}){const _=C.default(Q,W);if(!_)throw new Error("invalid name");return _(Z)},schema:{async loadFull(){return B.loadFull()},async loadVars(){return B.loadVars()}},func:{async call(W){const Z=B.schemas[W.method];if(!Z)throw new Error("invalid func name");return Z.func({input:W.input})}},var:{async set(W){const Z=B.schemas[W.name];if(!Z)throw new Error("invalid var name");if(!Z.set)throw new Error("variable can't be set");return Z.set(W.value)},async patch(W){throw new Error("TBD")}}};return Q};export{p0 as createSimpleHttpClient,i0 as createServerClient,p as URPC};
{
"name": "@dappworks/urpc",
"version": "0.0.2",
"version": "0.0.3",
"module": "index.ts",

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

@@ -10,3 +10,7 @@ # urpc

```ts
import URPC from "@dappworks/urpc";
import {
URPC,
createServerClient,
createSimpleHttpClient,
} from "@dappworks/urpc";

@@ -23,2 +27,3 @@ const urpc = new URPC({

// server
const serverClient = createServerClient({ urpc });

@@ -37,3 +42,3 @@ const app = new Hono();

client.func.call();
client.var.overwrite();
client.var.set();
client.schema.loadFull();

@@ -40,0 +45,0 @@ client.schema.loadVars();

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