@arrirpc/server 0.69.2 → 0.70.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,17 +5,11 @@ const h3 = require('h3');
5
5
  const schema = require('@arrirpc/schema');
6
6
  const scule = require('scule');
7
7
 
8
- var __defProp$5 = Object.defineProperty;
9
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __publicField$5 = (obj, key, value) => {
11
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
12
- return value;
13
- };
14
8
  class arriError extends Error {
9
+ code;
10
+ data;
15
11
  constructor(err) {
16
12
  super(err.message);
17
- __publicField$5(this, "code");
18
- __publicField$5(this, "data");
19
13
  this.code = err.code;
20
14
  this.data = err.data;
21
15
  if (err.stack) {
@@ -479,12 +473,6 @@ function getSchemaValidator(rpcName, type, schema$1) {
479
473
  }
480
474
  }
481
475
 
482
- var __defProp$4 = Object.defineProperty;
483
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
484
- var __publicField$4 = (obj, key, value) => {
485
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
486
- return value;
487
- };
488
476
  function defineEventStreamRpc(config) {
489
477
  return {
490
478
  ...config,
@@ -497,15 +485,15 @@ function isEventStreamRpc(input) {
497
485
  return isRpc(input) && "isEventStream" in input && input.isEventStream === true;
498
486
  }
499
487
  class EventStreamConnection {
488
+ lastEventId;
489
+ validationErrors;
490
+ validator;
491
+ serializer;
492
+ // for some reason Rollup cannot output DTS when this is set to NodeJS.Timeout
493
+ pingInterval = void 0;
494
+ pingIntervalMs;
495
+ eventStream;
500
496
  constructor(event, opts) {
501
- __publicField$4(this, "lastEventId");
502
- __publicField$4(this, "validationErrors");
503
- __publicField$4(this, "validator");
504
- __publicField$4(this, "serializer");
505
- // for some reason Rollup cannot output DTS when this is set to NodeJS.Timeout
506
- __publicField$4(this, "pingInterval");
507
- __publicField$4(this, "pingIntervalMs");
508
- __publicField$4(this, "eventStream");
509
497
  this.eventStream = h3.createEventStream(event);
510
498
  this.lastEventId = h3.getHeader(event, "Last-Event-Id");
511
499
  this.pingIntervalMs = opts.pingInterval ?? 6e4;
@@ -615,12 +603,9 @@ function registerEventStreamRpc(router, path, procedure, opts) {
615
603
  validator: responseValidator?.validate ?? function() {
616
604
  return true;
617
605
  },
618
- serializer: (
619
- // eslint-disable-next-line @typescript-eslint/unbound-method
620
- responseValidator?.serialize ?? function(_) {
621
- return "";
622
- }
623
- ),
606
+ serializer: responseValidator?.serialize ?? function(_) {
607
+ return "";
608
+ },
624
609
  validationErrors(input) {
625
610
  if (procedure.response) {
626
611
  return schema.a.errors(procedure.response, input);
@@ -782,17 +767,11 @@ function handleRoute(router, method, route, opts) {
782
767
  }
783
768
  }
784
769
 
785
- var __defProp$3 = Object.defineProperty;
786
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
787
- var __publicField$3 = (obj, key, value) => {
788
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
789
- return value;
790
- };
791
770
  class ArriRouter {
771
+ routes = [];
772
+ definitions = {};
773
+ prefix;
792
774
  constructor(routePrefix = "") {
793
- __publicField$3(this, "routes", []);
794
- __publicField$3(this, "definitions", {});
795
- __publicField$3(this, "prefix");
796
775
  this.prefix = routePrefix;
797
776
  }
798
777
  route(route) {
@@ -812,19 +791,13 @@ class ArriRouter {
812
791
  }
813
792
  }
814
793
 
815
- var __defProp$2 = Object.defineProperty;
816
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
817
- var __publicField$2 = (obj, key, value) => {
818
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
819
- return value;
820
- };
821
794
  class ArriService {
795
+ name;
822
796
  constructor(name) {
823
- __publicField$2(this, "name");
824
- __publicField$2(this, "procedures", []);
825
- __publicField$2(this, "definitions", {});
826
797
  this.name = name;
827
798
  }
799
+ procedures = [];
800
+ definitions = {};
828
801
  rpc(name, procedure) {
829
802
  procedure.name = `${this.name}.${name}`;
830
803
  this.procedures.push(procedure);
@@ -849,18 +822,12 @@ function defineService(name, procedures) {
849
822
  return service;
850
823
  }
851
824
 
852
- var __defProp$1 = Object.defineProperty;
853
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
854
- var __publicField$1 = (obj, key, value) => {
855
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
856
- return value;
857
- };
858
825
  class WsPeer {
826
+ _peer;
827
+ _validator;
828
+ context;
829
+ url;
859
830
  constructor(peer, opts) {
860
- __publicField$1(this, "_peer");
861
- __publicField$1(this, "_validator");
862
- __publicField$1(this, "context");
863
- __publicField$1(this, "url");
864
831
  this._peer = peer;
865
832
  this._validator = opts.validator;
866
833
  this.url = peer.websocket.url ?? "";
@@ -937,30 +904,24 @@ function createWsRpcDefinition(rpcName, path, rpc) {
937
904
  };
938
905
  }
939
906
 
940
- var __defProp = Object.defineProperty;
941
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
942
- var __publicField = (obj, key, value) => {
943
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
944
- return value;
945
- };
946
907
  const createAppDefinition = (def) => def;
947
908
  class ArriApp {
909
+ __isArri__ = true;
910
+ h3App;
911
+ h3Router = h3.createRouter();
912
+ _rpcDefinitionPath;
913
+ _rpcRoutePrefix;
914
+ appInfo;
915
+ _procedures = {};
916
+ _definitions = {};
917
+ _middlewares = [];
918
+ _onRequest;
919
+ _onAfterResponse;
920
+ _onBeforeResponse;
921
+ _onError;
922
+ _debug;
923
+ definitionPath;
948
924
  constructor(opts = {}) {
949
- __publicField(this, "__isArri__", true);
950
- __publicField(this, "h3App");
951
- __publicField(this, "h3Router", h3.createRouter());
952
- __publicField(this, "_rpcDefinitionPath");
953
- __publicField(this, "_rpcRoutePrefix");
954
- __publicField(this, "appInfo");
955
- __publicField(this, "_procedures", {});
956
- __publicField(this, "_definitions", {});
957
- __publicField(this, "_middlewares", []);
958
- __publicField(this, "_onRequest");
959
- __publicField(this, "_onAfterResponse");
960
- __publicField(this, "_onBeforeResponse");
961
- __publicField(this, "_onError");
962
- __publicField(this, "_debug");
963
- __publicField(this, "definitionPath");
964
925
  this.appInfo = opts?.appInfo;
965
926
  this.h3App = h3.createApp({
966
927
  debug: opts?.debug
@@ -1158,6 +1119,13 @@ exports.registerRoute = registerRoute;
1158
1119
  exports.registerRpc = registerRpc;
1159
1120
  exports.registerWebsocketRpc = registerWebsocketRpc;
1160
1121
  exports.validateRpcRequestInput = validateRpcRequestInput;
1122
+ Object.prototype.hasOwnProperty.call(h3, '__proto__') &&
1123
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
1124
+ Object.defineProperty(exports, '__proto__', {
1125
+ enumerable: true,
1126
+ value: h3['__proto__']
1127
+ });
1128
+
1161
1129
  Object.keys(h3).forEach(function (k) {
1162
1130
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = h3[k];
1163
1131
  });
package/dist/index.mjs CHANGED
@@ -4,17 +4,11 @@ export * from 'h3';
4
4
  import { a, isAObjectSchema, isADiscriminatorSchema, isAdaptedSchema, validatorFromAdaptedSchema } from '@arrirpc/schema';
5
5
  import { kebabCase, pascalCase } from 'scule';
6
6
 
7
- var __defProp$5 = Object.defineProperty;
8
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __publicField$5 = (obj, key, value) => {
10
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
11
- return value;
12
- };
13
7
  class arriError extends Error {
8
+ code;
9
+ data;
14
10
  constructor(err) {
15
11
  super(err.message);
16
- __publicField$5(this, "code");
17
- __publicField$5(this, "data");
18
12
  this.code = err.code;
19
13
  this.data = err.data;
20
14
  if (err.stack) {
@@ -478,12 +472,6 @@ function getSchemaValidator(rpcName, type, schema) {
478
472
  }
479
473
  }
480
474
 
481
- var __defProp$4 = Object.defineProperty;
482
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
483
- var __publicField$4 = (obj, key, value) => {
484
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
485
- return value;
486
- };
487
475
  function defineEventStreamRpc(config) {
488
476
  return {
489
477
  ...config,
@@ -496,15 +484,15 @@ function isEventStreamRpc(input) {
496
484
  return isRpc(input) && "isEventStream" in input && input.isEventStream === true;
497
485
  }
498
486
  class EventStreamConnection {
487
+ lastEventId;
488
+ validationErrors;
489
+ validator;
490
+ serializer;
491
+ // for some reason Rollup cannot output DTS when this is set to NodeJS.Timeout
492
+ pingInterval = void 0;
493
+ pingIntervalMs;
494
+ eventStream;
499
495
  constructor(event, opts) {
500
- __publicField$4(this, "lastEventId");
501
- __publicField$4(this, "validationErrors");
502
- __publicField$4(this, "validator");
503
- __publicField$4(this, "serializer");
504
- // for some reason Rollup cannot output DTS when this is set to NodeJS.Timeout
505
- __publicField$4(this, "pingInterval");
506
- __publicField$4(this, "pingIntervalMs");
507
- __publicField$4(this, "eventStream");
508
496
  this.eventStream = createEventStream(event);
509
497
  this.lastEventId = getHeader(event, "Last-Event-Id");
510
498
  this.pingIntervalMs = opts.pingInterval ?? 6e4;
@@ -614,12 +602,9 @@ function registerEventStreamRpc(router, path, procedure, opts) {
614
602
  validator: responseValidator?.validate ?? function() {
615
603
  return true;
616
604
  },
617
- serializer: (
618
- // eslint-disable-next-line @typescript-eslint/unbound-method
619
- responseValidator?.serialize ?? function(_) {
620
- return "";
621
- }
622
- ),
605
+ serializer: responseValidator?.serialize ?? function(_) {
606
+ return "";
607
+ },
623
608
  validationErrors(input) {
624
609
  if (procedure.response) {
625
610
  return a.errors(procedure.response, input);
@@ -781,17 +766,11 @@ function handleRoute(router, method, route, opts) {
781
766
  }
782
767
  }
783
768
 
784
- var __defProp$3 = Object.defineProperty;
785
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
786
- var __publicField$3 = (obj, key, value) => {
787
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
788
- return value;
789
- };
790
769
  class ArriRouter {
770
+ routes = [];
771
+ definitions = {};
772
+ prefix;
791
773
  constructor(routePrefix = "") {
792
- __publicField$3(this, "routes", []);
793
- __publicField$3(this, "definitions", {});
794
- __publicField$3(this, "prefix");
795
774
  this.prefix = routePrefix;
796
775
  }
797
776
  route(route) {
@@ -811,19 +790,13 @@ class ArriRouter {
811
790
  }
812
791
  }
813
792
 
814
- var __defProp$2 = Object.defineProperty;
815
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
816
- var __publicField$2 = (obj, key, value) => {
817
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
818
- return value;
819
- };
820
793
  class ArriService {
794
+ name;
821
795
  constructor(name) {
822
- __publicField$2(this, "name");
823
- __publicField$2(this, "procedures", []);
824
- __publicField$2(this, "definitions", {});
825
796
  this.name = name;
826
797
  }
798
+ procedures = [];
799
+ definitions = {};
827
800
  rpc(name, procedure) {
828
801
  procedure.name = `${this.name}.${name}`;
829
802
  this.procedures.push(procedure);
@@ -848,18 +821,12 @@ function defineService(name, procedures) {
848
821
  return service;
849
822
  }
850
823
 
851
- var __defProp$1 = Object.defineProperty;
852
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
853
- var __publicField$1 = (obj, key, value) => {
854
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
855
- return value;
856
- };
857
824
  class WsPeer {
825
+ _peer;
826
+ _validator;
827
+ context;
828
+ url;
858
829
  constructor(peer, opts) {
859
- __publicField$1(this, "_peer");
860
- __publicField$1(this, "_validator");
861
- __publicField$1(this, "context");
862
- __publicField$1(this, "url");
863
830
  this._peer = peer;
864
831
  this._validator = opts.validator;
865
832
  this.url = peer.websocket.url ?? "";
@@ -936,30 +903,24 @@ function createWsRpcDefinition(rpcName, path, rpc) {
936
903
  };
937
904
  }
938
905
 
939
- var __defProp = Object.defineProperty;
940
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
941
- var __publicField = (obj, key, value) => {
942
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
943
- return value;
944
- };
945
906
  const createAppDefinition = (def) => def;
946
907
  class ArriApp {
908
+ __isArri__ = true;
909
+ h3App;
910
+ h3Router = createRouter();
911
+ _rpcDefinitionPath;
912
+ _rpcRoutePrefix;
913
+ appInfo;
914
+ _procedures = {};
915
+ _definitions = {};
916
+ _middlewares = [];
917
+ _onRequest;
918
+ _onAfterResponse;
919
+ _onBeforeResponse;
920
+ _onError;
921
+ _debug;
922
+ definitionPath;
947
923
  constructor(opts = {}) {
948
- __publicField(this, "__isArri__", true);
949
- __publicField(this, "h3App");
950
- __publicField(this, "h3Router", createRouter());
951
- __publicField(this, "_rpcDefinitionPath");
952
- __publicField(this, "_rpcRoutePrefix");
953
- __publicField(this, "appInfo");
954
- __publicField(this, "_procedures", {});
955
- __publicField(this, "_definitions", {});
956
- __publicField(this, "_middlewares", []);
957
- __publicField(this, "_onRequest");
958
- __publicField(this, "_onAfterResponse");
959
- __publicField(this, "_onBeforeResponse");
960
- __publicField(this, "_onError");
961
- __publicField(this, "_debug");
962
- __publicField(this, "definitionPath");
963
924
  this.appInfo = opts?.appInfo;
964
925
  this.h3App = createApp({
965
926
  debug: opts?.debug
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/server",
3
- "version": "0.69.2",
3
+ "version": "0.70.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -28,14 +28,11 @@
28
28
  "scule": "^1.3.0",
29
29
  "source-map-support": "^0.5.21",
30
30
  "uncrypto": "^0.1.3",
31
- "@arrirpc/codegen-dart": "0.69.2",
32
- "@arrirpc/codegen-kotlin": "0.69.2",
33
- "@arrirpc/codegen-ts": "0.69.2",
34
- "@arrirpc/codegen-utils": "0.69.2",
35
- "arri": "0.69.2",
36
- "@arrirpc/schema": "0.69.2"
31
+ "@arrirpc/codegen-utils": "0.70.1",
32
+ "arri": "0.70.1",
33
+ "@arrirpc/schema": "0.70.1"
37
34
  },
38
35
  "devDependencies": {
39
- "bun-types": "^1.1.37"
36
+ "bun-types": "^1.1.42"
40
37
  }
41
38
  }