arri 0.38.1 → 0.39.0

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/cli.cjs CHANGED
@@ -11,7 +11,7 @@ const esbuild = require('esbuild');
11
11
  const esbuildPluginReplace = require('esbuild-plugin-replace');
12
12
  const path = require('pathe');
13
13
  const prettier = require('prettier');
14
- const config = require('./shared/arri.bba0eea2.cjs');
14
+ const config = require('./shared/arri.ebe44c73.cjs');
15
15
  const consola = require('consola');
16
16
  const globby = require('globby');
17
17
  const scule = require('scule');
package/dist/cli.mjs CHANGED
@@ -10,7 +10,7 @@ import { build as build$1 } from 'esbuild';
10
10
  import { replace } from 'esbuild-plugin-replace';
11
11
  import path from 'pathe';
12
12
  import prettier from 'prettier';
13
- import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.37a5d932.mjs';
13
+ import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.1fc3f099.mjs';
14
14
  import { createConsola } from 'consola';
15
15
  import { globby } from 'globby';
16
16
  import { camelCase, kebabCase } from 'scule';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const config = require('./shared/arri.bba0eea2.cjs');
3
+ const config = require('./shared/arri.ebe44c73.cjs');
4
4
  const h3 = require('h3');
5
5
  require('arri-codegen-utils');
6
6
  require('arri-validate');
package/dist/index.d.cts CHANGED
@@ -128,7 +128,7 @@ interface WebsocketRpc<TParams extends RpcParamSchema | undefined = undefined, T
128
128
  params: TParams;
129
129
  response: TResponse;
130
130
  pingInterval?: boolean;
131
- handler: WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
131
+ handler: WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined> | (() => WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>);
132
132
  }
133
133
  interface WsPeerOpts<TResponse> {
134
134
  validator?: CompiledValidator<ASchema<TResponse>>;
package/dist/index.d.mts CHANGED
@@ -128,7 +128,7 @@ interface WebsocketRpc<TParams extends RpcParamSchema | undefined = undefined, T
128
128
  params: TParams;
129
129
  response: TResponse;
130
130
  pingInterval?: boolean;
131
- handler: WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
131
+ handler: WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined> | (() => WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>);
132
132
  }
133
133
  interface WsPeerOpts<TResponse> {
134
134
  validator?: CompiledValidator<ASchema<TResponse>>;
package/dist/index.d.ts CHANGED
@@ -128,7 +128,7 @@ interface WebsocketRpc<TParams extends RpcParamSchema | undefined = undefined, T
128
128
  params: TParams;
129
129
  response: TResponse;
130
130
  pingInterval?: boolean;
131
- handler: WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
131
+ handler: WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined> | (() => WebSocketRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>);
132
132
  }
133
133
  interface WsPeerOpts<TResponse> {
134
134
  validator?: CompiledValidator<ASchema<TResponse>>;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, W as WsPeer, c as createAppDefinition, e as createHttpRpcDefinition, G as createWsRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, C as defineWebsocketRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, F as registerWebsocketRpc, v as validateRpcRequestInput } from './shared/arri.37a5d932.mjs';
1
+ export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, W as WsPeer, c as createAppDefinition, e as createHttpRpcDefinition, G as createWsRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, C as defineWebsocketRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, F as registerWebsocketRpc, v as validateRpcRequestInput } from './shared/arri.1fc3f099.mjs';
2
2
  export * from 'h3';
3
3
  import 'arri-codegen-utils';
4
4
  import 'arri-validate';
@@ -876,11 +876,11 @@ class WsPeer {
876
876
  return;
877
877
  }
878
878
  const payload = this._validator.serialize(data);
879
- return this._peer.send(`type: message
879
+ return this._peer.send(`event: message
880
880
  data: ${payload}`);
881
881
  }
882
882
  sendError(err) {
883
- return this._peer.send(`type: error
883
+ return this._peer.send(`event: error
884
884
  data: ${JSON.stringify(err)}`);
885
885
  }
886
886
  close() {
@@ -931,6 +931,7 @@ function registerWebsocketRpc(router, path, rpc) {
931
931
  } catch (err) {
932
932
  console.error("ERROR COMPILING PARAMS", err);
933
933
  }
934
+ const rpcHandler = typeof rpc.handler === "function" ? rpc.handler() : rpc.handler;
934
935
  const handler = defineWebSocketHandler({
935
936
  upgrade(req) {
936
937
  },
@@ -954,7 +955,7 @@ function registerWebsocketRpc(router, path, rpc) {
954
955
  context
955
956
  });
956
957
  peer.ctx.__wsPeer = wsPeer;
957
- rpc.handler.onOpen(peer.ctx.__wsPeer);
958
+ rpcHandler.onOpen(peer.ctx.__wsPeer);
958
959
  },
959
960
  message(peer, message) {
960
961
  if (!paramValidator) {
@@ -971,10 +972,10 @@ function registerWebsocketRpc(router, path, rpc) {
971
972
  peer.ctx.__wsPeer.sendError(errorResponse);
972
973
  return;
973
974
  }
974
- rpc.handler.onMessage(peer.ctx.__wsPeer, data.value);
975
+ rpcHandler.onMessage(peer.ctx.__wsPeer, data.value);
975
976
  },
976
977
  close(peer, details) {
977
- rpc.handler.onClose(peer.ctx.__wsPeer, details);
978
+ rpcHandler.onClose(peer.ctx.__wsPeer, details);
978
979
  }
979
980
  });
980
981
  router.use(path, handler);
@@ -878,11 +878,11 @@ class WsPeer {
878
878
  return;
879
879
  }
880
880
  const payload = this._validator.serialize(data);
881
- return this._peer.send(`type: message
881
+ return this._peer.send(`event: message
882
882
  data: ${payload}`);
883
883
  }
884
884
  sendError(err) {
885
- return this._peer.send(`type: error
885
+ return this._peer.send(`event: error
886
886
  data: ${JSON.stringify(err)}`);
887
887
  }
888
888
  close() {
@@ -933,6 +933,7 @@ function registerWebsocketRpc(router, path, rpc) {
933
933
  } catch (err) {
934
934
  console.error("ERROR COMPILING PARAMS", err);
935
935
  }
936
+ const rpcHandler = typeof rpc.handler === "function" ? rpc.handler() : rpc.handler;
936
937
  const handler = h3.defineWebSocketHandler({
937
938
  upgrade(req) {
938
939
  },
@@ -956,7 +957,7 @@ function registerWebsocketRpc(router, path, rpc) {
956
957
  context
957
958
  });
958
959
  peer.ctx.__wsPeer = wsPeer;
959
- rpc.handler.onOpen(peer.ctx.__wsPeer);
960
+ rpcHandler.onOpen(peer.ctx.__wsPeer);
960
961
  },
961
962
  message(peer, message) {
962
963
  if (!paramValidator) {
@@ -973,10 +974,10 @@ function registerWebsocketRpc(router, path, rpc) {
973
974
  peer.ctx.__wsPeer.sendError(errorResponse);
974
975
  return;
975
976
  }
976
- rpc.handler.onMessage(peer.ctx.__wsPeer, data.value);
977
+ rpcHandler.onMessage(peer.ctx.__wsPeer, data.value);
977
978
  },
978
979
  close(peer, details) {
979
- rpc.handler.onClose(peer.ctx.__wsPeer, details);
980
+ rpcHandler.onClose(peer.ctx.__wsPeer, details);
980
981
  }
981
982
  });
982
983
  router.use(path, handler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.38.1",
3
+ "version": "0.39.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -44,10 +44,10 @@
44
44
  "prettier": "^3.2.5",
45
45
  "scule": "^1.3.0",
46
46
  "uncrypto": "^0.1.3",
47
- "arri-codegen-dart": "0.38.1",
48
- "arri-codegen-utils": "0.38.1",
49
- "arri-validate": "0.38.1",
50
- "arri-codegen-ts": "0.38.1"
47
+ "arri-codegen-dart": "0.39.0",
48
+ "arri-codegen-utils": "0.39.0",
49
+ "arri-validate": "0.39.0",
50
+ "arri-codegen-ts": "0.39.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/degit": "^2.8.6",