arri 0.16.3 → 0.16.4

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/README.md CHANGED
@@ -9,8 +9,10 @@ Typescript implementation of Arri RPC. It's built on top of [H3](https://github.
9
9
  - [Install Dependencies](#install-dependencies)
10
10
  - [Scaffold Your Project](#scaffold-your-project)
11
11
  - [Usage](#usage)
12
- - [File-Based Routing](#file-based-routing)
13
- - [Manual Routing](#manual-routing)
12
+ - [Creating Procedures](#creating-procedures)
13
+ - [File-Based Routing](#file-based-routing)
14
+ - [Manual Routing](#manual-routing)
15
+ - [Creating Event Stream Procedures](#creating-event-stream-procedures)
14
16
  - [Adding Non-RPC Routes](#adding-non-rpc-routes)
15
17
  - [Adding Middleware](#adding-middleware)
16
18
  - [Key Concepts](#key-concepts)
@@ -151,7 +153,7 @@ Setup your npm scripts:
151
153
 
152
154
  ### Creating Procedures
153
155
 
154
- #### File Based Routing
156
+ #### File Based Router
155
157
 
156
158
  Arri RPC comes with an optional file based router that will automatically register functions in the `./procedures` directory that end with the `.rpc.ts` file extension.
157
159
 
@@ -198,6 +200,8 @@ export default defineConfig({
198
200
 
199
201
  #### Manual Routing
200
202
 
203
+ For those that want to opt out of the file-based routing system you can manually register procedures like so.
204
+
201
205
  ```ts
202
206
  // using the app instance
203
207
  const app = new ArriApp()
@@ -214,10 +218,15 @@ app.use(router)
214
218
 
215
219
  Event stream procedures make use of [Server Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) to stream events to clients.
216
220
 
217
- Normal events will have the event type `message`. Error events will have the event type `error`, and a `done` event will be sent when closing the connection. Additionally the `EventStreamConnection` will periodically since a `ping` event to keep the connection alive
221
+ Arri Event streams sent the following event types:
222
+
223
+ - `message` - A standard message with the response data serialized as JSON
224
+ - `error` - An error message with an `ArriRequestError` sent as JSON
225
+ - `done` - A message to tell clients that there will be no more events
226
+ - `ping` - A message periodically sent by the server to keep the connection alive.
218
227
 
219
228
  ```ts
220
- /// standard event ///
229
+ /// message event ///
221
230
  id: string | undefined;
222
231
  event: "message";
223
232
  data: Response; // whatever you have specified as the response serialized to json
package/dist/cli.cjs CHANGED
@@ -12,7 +12,7 @@ const esbuild = require('esbuild');
12
12
  const esbuildPluginReplace = require('esbuild-plugin-replace');
13
13
  const path = require('pathe');
14
14
  const prettier = require('prettier');
15
- const config = require('./shared/arri.beaf548c.cjs');
15
+ const config = require('./shared/arri.9c3d197c.cjs');
16
16
  const globby = require('globby');
17
17
  const scule = require('scule');
18
18
  const arriCodegenDart = require('arri-codegen-dart');
package/dist/cli.mjs CHANGED
@@ -11,7 +11,7 @@ import { build as build$1 } from 'esbuild';
11
11
  import { replace } from 'esbuild-plugin-replace';
12
12
  import path from 'pathe';
13
13
  import prettier from 'prettier';
14
- import { n as defaultConfig, m as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.ff70fe08.mjs';
14
+ import { n as defaultConfig, m as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.883e4574.mjs';
15
15
  import { globby } from 'globby';
16
16
  import { camelCase, kebabCase } from 'scule';
17
17
  import { dartClientGenerator } from 'arri-codegen-dart';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const config = require('./shared/arri.beaf548c.cjs');
3
+ const config = require('./shared/arri.9c3d197c.cjs');
4
4
  const h3 = require('h3');
5
5
  require('arri-validate');
6
6
  require('arri-codegen-utils');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, B as EventStreamConnection, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, w as defineEventStreamRpc, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, y as formatSse, z as formatSseList, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, x as isEventStreamRpc, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, C as registerEventStreamRpc, s as registerRoute, r as registerRpc, u as setSseHeaders, v as validateRpcRequestInput } from './shared/arri.ff70fe08.mjs';
1
+ export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, B as EventStreamConnection, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, w as defineEventStreamRpc, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, y as formatSse, z as formatSseList, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, x as isEventStreamRpc, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, C as registerEventStreamRpc, s as registerRoute, r as registerRpc, u as setSseHeaders, v as validateRpcRequestInput } from './shared/arri.883e4574.mjs';
2
2
  export * from 'h3';
3
3
  import 'arri-validate';
4
4
  import 'arri-codegen-utils';
@@ -1,4 +1,4 @@
1
- import { createError, isError, setResponseStatus, send, eventHandler, isPreflightRequest, setResponseHeader, readRawBody, getValidatedQuery, setHeaders, getHeader, sendStream, defineEventHandler, getQuery, setHeader, createRouter, createApp, sendError } from 'h3';
1
+ import { createError, isError, setResponseStatus, send, eventHandler, isPreflightRequest, setResponseHeader, readRawBody, getValidatedQuery, setHeaders, getHeader, defineEventHandler, getQuery, setHeader, createRouter, createApp, sendError } from 'h3';
2
2
  import { a, isAObjectSchema, isARecordSchema, isADiscriminatorSchema } from 'arri-validate';
3
3
  import { isRpcHttpMethod, removeDisallowedChars } from 'arri-codegen-utils';
4
4
  import { kebabCase, pascalCase } from 'scule';
@@ -482,7 +482,6 @@ class EventStreamConnection {
482
482
  */
483
483
  start() {
484
484
  this.h3Event._handled = true;
485
- void sendStream(this.h3Event, this.readable);
486
485
  this.pingInterval = setInterval(async () => {
487
486
  await this.publishEvent({
488
487
  id: this.lastEventId,
@@ -538,11 +537,11 @@ class EventStreamConnection {
538
537
  }
539
538
  async publishEvents(events) {
540
539
  const payload = formatSseList(events);
541
- await this.writer.write(this.encoder.encode(payload));
540
+ this.h3Event.node.res.write(payload);
542
541
  }
543
542
  async publishEvent(event) {
544
543
  const payload = formatSse(event);
545
- await this.writer.write(this.encoder.encode(payload));
544
+ this.h3Event.node.res.write(payload);
546
545
  }
547
546
  async cleanup() {
548
547
  if (this.pingInterval) {
@@ -484,7 +484,6 @@ class EventStreamConnection {
484
484
  */
485
485
  start() {
486
486
  this.h3Event._handled = true;
487
- void h3.sendStream(this.h3Event, this.readable);
488
487
  this.pingInterval = setInterval(async () => {
489
488
  await this.publishEvent({
490
489
  id: this.lastEventId,
@@ -540,11 +539,11 @@ class EventStreamConnection {
540
539
  }
541
540
  async publishEvents(events) {
542
541
  const payload = formatSseList(events);
543
- await this.writer.write(this.encoder.encode(payload));
542
+ this.h3Event.node.res.write(payload);
544
543
  }
545
544
  async publishEvent(event) {
546
545
  const payload = formatSse(event);
547
- await this.writer.write(this.encoder.encode(payload));
546
+ this.h3Event.node.res.write(payload);
548
547
  }
549
548
  async cleanup() {
550
549
  if (this.pingInterval) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -40,10 +40,10 @@
40
40
  "prettier": "^3.1.0",
41
41
  "scule": "^1.1.1",
42
42
  "uncrypto": "^0.1.3",
43
- "arri-codegen-dart": "0.16.3",
44
- "arri-validate": "0.16.3",
45
- "arri-codegen-ts": "0.16.3",
46
- "arri-codegen-utils": "0.16.3"
43
+ "arri-codegen-dart": "0.16.4",
44
+ "arri-codegen-utils": "0.16.4",
45
+ "arri-codegen-ts": "0.16.4",
46
+ "arri-validate": "0.16.4"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "listhen": "1.x"