arri 0.25.0 → 0.26.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/README.md +13 -11
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts +4 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +2 -2
- package/dist/shared/{arri.ba3f283e.mjs → arri.21567b92.mjs} +4 -2
- package/dist/shared/{arri.65113bc6.cjs → arri.593bcad9.cjs} +4 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -259,22 +259,24 @@ export default defineEventStreamRpc({
|
|
|
259
259
|
createdAt: a.timestamp(),
|
|
260
260
|
updatedAt: a.timestamp(),
|
|
261
261
|
}),
|
|
262
|
-
handler({ params,
|
|
262
|
+
handler({ params, stream }) {
|
|
263
|
+
// initialize the stream and send it to the client
|
|
264
|
+
stream.init();
|
|
265
|
+
|
|
263
266
|
// send a message every second
|
|
264
267
|
const interval = setInterval(async () => {
|
|
265
|
-
await
|
|
268
|
+
await stream.push({
|
|
266
269
|
id: "1",
|
|
267
270
|
name: "John Doe",
|
|
268
271
|
createdAt: new Date(),
|
|
269
272
|
updatedAt: new Date(),
|
|
270
273
|
});
|
|
271
274
|
}, 1000);
|
|
275
|
+
|
|
272
276
|
// cleanup when the client disconnects
|
|
273
|
-
|
|
277
|
+
stream.on("close", () => {
|
|
274
278
|
clearInterval(interval);
|
|
275
279
|
});
|
|
276
|
-
// start streaming events to the client
|
|
277
|
-
connection.start();
|
|
278
280
|
},
|
|
279
281
|
});
|
|
280
282
|
```
|
|
@@ -282,11 +284,11 @@ export default defineEventStreamRpc({
|
|
|
282
284
|
#### EventStreamConnection methods
|
|
283
285
|
|
|
284
286
|
```ts
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
stream.push(data: Data, eventId?: string)
|
|
288
|
+
stream.pushError(error: ArriRequestError, eventId?: string)
|
|
289
|
+
stream.init()
|
|
290
|
+
stream.end()
|
|
291
|
+
stream.on(e: 'request:close' | 'close', callback: () => any)
|
|
290
292
|
```
|
|
291
293
|
|
|
292
294
|
### Adding Non-RPC Routes
|
|
@@ -491,7 +493,7 @@ arri build [flags]
|
|
|
491
493
|
arri init [dir]
|
|
492
494
|
```
|
|
493
495
|
|
|
494
|
-
##
|
|
496
|
+
## Development
|
|
495
497
|
|
|
496
498
|
### Building
|
|
497
499
|
|
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.
|
|
15
|
+
const config = require('./shared/arri.593bcad9.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.
|
|
14
|
+
import { n as defaultConfig, m as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.21567b92.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,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('./shared/arri.
|
|
3
|
+
const config = require('./shared/arri.593bcad9.cjs');
|
|
4
4
|
const h3 = require('h3');
|
|
5
|
+
const h3Sse = require('h3-sse');
|
|
5
6
|
require('arri-validate');
|
|
6
|
-
require('h3-sse');
|
|
7
7
|
require('arri-codegen-utils');
|
|
8
8
|
require('scule');
|
|
9
9
|
|
|
@@ -41,3 +41,6 @@ exports.defineMiddleware = defineMiddleware;
|
|
|
41
41
|
Object.keys(h3).forEach(function (k) {
|
|
42
42
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = h3[k];
|
|
43
43
|
});
|
|
44
|
+
Object.keys(h3Sse).forEach(function (k) {
|
|
45
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = h3Sse[k];
|
|
46
|
+
});
|
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ import { AObjectSchema, ASchema, InferType, a, ValidationError, ValueError, ARec
|
|
|
3
3
|
import { H3EventContext, H3Event, Router, H3Error, App } from 'h3';
|
|
4
4
|
export * from 'h3';
|
|
5
5
|
import { EventStream } from 'h3-sse';
|
|
6
|
+
export * from 'h3-sse';
|
|
6
7
|
import { BuildOptions } from 'esbuild';
|
|
7
8
|
|
|
8
9
|
interface MiddlewareEventContext extends H3EventContext {
|
|
@@ -76,6 +77,7 @@ interface EventStreamConnectionOptions<TData> {
|
|
|
76
77
|
pingInterval?: number;
|
|
77
78
|
}
|
|
78
79
|
declare class EventStreamConnection<TData> {
|
|
80
|
+
readonly lastEventId?: string;
|
|
79
81
|
private readonly h3Event;
|
|
80
82
|
private readonly validationErrors;
|
|
81
83
|
private readonly validator;
|
|
@@ -85,9 +87,9 @@ declare class EventStreamConnection<TData> {
|
|
|
85
87
|
readonly eventStream: EventStream;
|
|
86
88
|
constructor(event: H3Event, opts: EventStreamConnectionOptions<TData>);
|
|
87
89
|
/**
|
|
88
|
-
*
|
|
90
|
+
* Initialize the stream. This must be called before sending any events.
|
|
89
91
|
*/
|
|
90
|
-
|
|
92
|
+
init(): void;
|
|
91
93
|
/**
|
|
92
94
|
* Publish a new event. Events published with this hook will trigger the `onData()` hooks of any connected clients.
|
|
93
95
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { AObjectSchema, ASchema, InferType, a, ValidationError, ValueError, ARec
|
|
|
3
3
|
import { H3EventContext, H3Event, Router, H3Error, App } from 'h3';
|
|
4
4
|
export * from 'h3';
|
|
5
5
|
import { EventStream } from 'h3-sse';
|
|
6
|
+
export * from 'h3-sse';
|
|
6
7
|
import { BuildOptions } from 'esbuild';
|
|
7
8
|
|
|
8
9
|
interface MiddlewareEventContext extends H3EventContext {
|
|
@@ -76,6 +77,7 @@ interface EventStreamConnectionOptions<TData> {
|
|
|
76
77
|
pingInterval?: number;
|
|
77
78
|
}
|
|
78
79
|
declare class EventStreamConnection<TData> {
|
|
80
|
+
readonly lastEventId?: string;
|
|
79
81
|
private readonly h3Event;
|
|
80
82
|
private readonly validationErrors;
|
|
81
83
|
private readonly validator;
|
|
@@ -85,9 +87,9 @@ declare class EventStreamConnection<TData> {
|
|
|
85
87
|
readonly eventStream: EventStream;
|
|
86
88
|
constructor(event: H3Event, opts: EventStreamConnectionOptions<TData>);
|
|
87
89
|
/**
|
|
88
|
-
*
|
|
90
|
+
* Initialize the stream. This must be called before sending any events.
|
|
89
91
|
*/
|
|
90
|
-
|
|
92
|
+
init(): void;
|
|
91
93
|
/**
|
|
92
94
|
* Publish a new event. Events published with this hook will trigger the `onData()` hooks of any connected clients.
|
|
93
95
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AObjectSchema, ASchema, InferType, a, ValidationError, ValueError, ARec
|
|
|
3
3
|
import { H3EventContext, H3Event, Router, H3Error, App } from 'h3';
|
|
4
4
|
export * from 'h3';
|
|
5
5
|
import { EventStream } from 'h3-sse';
|
|
6
|
+
export * from 'h3-sse';
|
|
6
7
|
import { BuildOptions } from 'esbuild';
|
|
7
8
|
|
|
8
9
|
interface MiddlewareEventContext extends H3EventContext {
|
|
@@ -76,6 +77,7 @@ interface EventStreamConnectionOptions<TData> {
|
|
|
76
77
|
pingInterval?: number;
|
|
77
78
|
}
|
|
78
79
|
declare class EventStreamConnection<TData> {
|
|
80
|
+
readonly lastEventId?: string;
|
|
79
81
|
private readonly h3Event;
|
|
80
82
|
private readonly validationErrors;
|
|
81
83
|
private readonly validator;
|
|
@@ -85,9 +87,9 @@ declare class EventStreamConnection<TData> {
|
|
|
85
87
|
readonly eventStream: EventStream;
|
|
86
88
|
constructor(event: H3Event, opts: EventStreamConnectionOptions<TData>);
|
|
87
89
|
/**
|
|
88
|
-
*
|
|
90
|
+
* Initialize the stream. This must be called before sending any events.
|
|
89
91
|
*/
|
|
90
|
-
|
|
92
|
+
init(): void;
|
|
91
93
|
/**
|
|
92
94
|
* Publish a new event. Events published with this hook will trigger the `onData()` hooks of any connected clients.
|
|
93
95
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, x as EventStreamConnection, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, u as defineEventStreamRpc, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, w as isEventStreamRpc, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, y as registerEventStreamRpc, s as registerRoute, r as registerRpc, v as validateRpcRequestInput } from './shared/arri.
|
|
1
|
+
export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, x as EventStreamConnection, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, u as defineEventStreamRpc, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, w as isEventStreamRpc, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, y as registerEventStreamRpc, s as registerRoute, r as registerRpc, v as validateRpcRequestInput } from './shared/arri.21567b92.mjs';
|
|
2
2
|
export * from 'h3';
|
|
3
|
+
export * from 'h3-sse';
|
|
3
4
|
import 'arri-validate';
|
|
4
|
-
import 'h3-sse';
|
|
5
5
|
import 'arri-codegen-utils';
|
|
6
6
|
import 'scule';
|
|
7
7
|
|
|
@@ -443,6 +443,7 @@ function isEventStreamRpc(input) {
|
|
|
443
443
|
}
|
|
444
444
|
class EventStreamConnection {
|
|
445
445
|
constructor(event, opts) {
|
|
446
|
+
__publicField$2(this, "lastEventId");
|
|
446
447
|
__publicField$2(this, "h3Event");
|
|
447
448
|
__publicField$2(this, "validationErrors");
|
|
448
449
|
__publicField$2(this, "validator");
|
|
@@ -453,6 +454,7 @@ class EventStreamConnection {
|
|
|
453
454
|
__publicField$2(this, "eventStream");
|
|
454
455
|
this.h3Event = event;
|
|
455
456
|
this.eventStream = createEventStream(event, true);
|
|
457
|
+
this.lastEventId = this.eventStream.lastEventId;
|
|
456
458
|
this.pingIntervalMs = opts.pingInterval ?? 6e4;
|
|
457
459
|
this.serializer = opts.serializer;
|
|
458
460
|
this.validator = opts.validator;
|
|
@@ -462,9 +464,9 @@ class EventStreamConnection {
|
|
|
462
464
|
});
|
|
463
465
|
}
|
|
464
466
|
/**
|
|
465
|
-
*
|
|
467
|
+
* Initialize the stream. This must be called before sending any events.
|
|
466
468
|
*/
|
|
467
|
-
|
|
469
|
+
init() {
|
|
468
470
|
void sendEventStream(this.h3Event, this.eventStream);
|
|
469
471
|
this.pingInterval = setInterval(async () => {
|
|
470
472
|
await this.eventStream.push({
|
|
@@ -445,6 +445,7 @@ function isEventStreamRpc(input) {
|
|
|
445
445
|
}
|
|
446
446
|
class EventStreamConnection {
|
|
447
447
|
constructor(event, opts) {
|
|
448
|
+
__publicField$2(this, "lastEventId");
|
|
448
449
|
__publicField$2(this, "h3Event");
|
|
449
450
|
__publicField$2(this, "validationErrors");
|
|
450
451
|
__publicField$2(this, "validator");
|
|
@@ -455,6 +456,7 @@ class EventStreamConnection {
|
|
|
455
456
|
__publicField$2(this, "eventStream");
|
|
456
457
|
this.h3Event = event;
|
|
457
458
|
this.eventStream = h3Sse.createEventStream(event, true);
|
|
459
|
+
this.lastEventId = this.eventStream.lastEventId;
|
|
458
460
|
this.pingIntervalMs = opts.pingInterval ?? 6e4;
|
|
459
461
|
this.serializer = opts.serializer;
|
|
460
462
|
this.validator = opts.validator;
|
|
@@ -464,9 +466,9 @@ class EventStreamConnection {
|
|
|
464
466
|
});
|
|
465
467
|
}
|
|
466
468
|
/**
|
|
467
|
-
*
|
|
469
|
+
* Initialize the stream. This must be called before sending any events.
|
|
468
470
|
*/
|
|
469
|
-
|
|
471
|
+
init() {
|
|
470
472
|
void h3Sse.sendEventStream(this.h3Event, this.eventStream);
|
|
471
473
|
this.pingInterval = setInterval(async () => {
|
|
472
474
|
await this.eventStream.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"esbuild-plugin-replace": "^1.4.0",
|
|
36
36
|
"globby": "^14.0.1",
|
|
37
37
|
"h3": "^1.10.2",
|
|
38
|
-
"h3-sse": "^0.0.
|
|
38
|
+
"h3-sse": "^0.0.9",
|
|
39
39
|
"jiti": "^1.21.0",
|
|
40
40
|
"ofetch": "^1.3.3",
|
|
41
41
|
"pathe": "^1.1.2",
|
|
42
42
|
"prettier": "^3.2.5",
|
|
43
43
|
"scule": "^1.3.0",
|
|
44
44
|
"uncrypto": "^0.1.3",
|
|
45
|
-
"arri-codegen-
|
|
46
|
-
"arri-
|
|
47
|
-
"arri-
|
|
48
|
-
"arri-codegen-
|
|
45
|
+
"arri-codegen-dart": "0.26.0",
|
|
46
|
+
"arri-validate": "0.26.0",
|
|
47
|
+
"arri-codegen-ts": "0.26.0",
|
|
48
|
+
"arri-codegen-utils": "0.26.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/degit": "^2.8.6",
|