arri 0.26.0 → 0.27.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 +2 -2
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +2 -5
- package/dist/index.d.cts +3 -6
- package/dist/index.d.mts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.mjs +2 -2
- package/dist/shared/{arri.593bcad9.cjs → arri.22a9d5c0.cjs} +8 -17
- package/dist/shared/{arri.21567b92.mjs → arri.8cfc63cb.mjs} +9 -18
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -261,7 +261,7 @@ export default defineEventStreamRpc({
|
|
|
261
261
|
}),
|
|
262
262
|
handler({ params, stream }) {
|
|
263
263
|
// initialize the stream and send it to the client
|
|
264
|
-
stream.
|
|
264
|
+
stream.send();
|
|
265
265
|
|
|
266
266
|
// send a message every second
|
|
267
267
|
const interval = setInterval(async () => {
|
|
@@ -286,7 +286,7 @@ export default defineEventStreamRpc({
|
|
|
286
286
|
```ts
|
|
287
287
|
stream.push(data: Data, eventId?: string)
|
|
288
288
|
stream.pushError(error: ArriRequestError, eventId?: string)
|
|
289
|
-
stream.
|
|
289
|
+
stream.send()
|
|
290
290
|
stream.end()
|
|
291
291
|
stream.on(e: 'request:close' | 'close', callback: () => any)
|
|
292
292
|
```
|
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.22a9d5c0.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.8cfc63cb.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.22a9d5c0.cjs');
|
|
4
4
|
const h3 = require('h3');
|
|
5
|
-
const h3Sse = require('h3-sse');
|
|
6
5
|
require('arri-validate');
|
|
6
|
+
require('h3-sse');
|
|
7
7
|
require('arri-codegen-utils');
|
|
8
8
|
require('scule');
|
|
9
9
|
|
|
@@ -41,6 +41,3 @@ 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,7 +3,6 @@ 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';
|
|
7
6
|
import { BuildOptions } from 'esbuild';
|
|
8
7
|
|
|
9
8
|
interface MiddlewareEventContext extends H3EventContext {
|
|
@@ -78,7 +77,6 @@ interface EventStreamConnectionOptions<TData> {
|
|
|
78
77
|
}
|
|
79
78
|
declare class EventStreamConnection<TData> {
|
|
80
79
|
readonly lastEventId?: string;
|
|
81
|
-
private readonly h3Event;
|
|
82
80
|
private readonly validationErrors;
|
|
83
81
|
private readonly validator;
|
|
84
82
|
private readonly serializer;
|
|
@@ -87,9 +85,9 @@ declare class EventStreamConnection<TData> {
|
|
|
87
85
|
readonly eventStream: EventStream;
|
|
88
86
|
constructor(event: H3Event, opts: EventStreamConnectionOptions<TData>);
|
|
89
87
|
/**
|
|
90
|
-
*
|
|
88
|
+
* Send the stream to the client. This must be called before sending any events.
|
|
91
89
|
*/
|
|
92
|
-
|
|
90
|
+
send(): void;
|
|
93
91
|
/**
|
|
94
92
|
* Publish a new event. Events published with this hook will trigger the `onData()` hooks of any connected clients.
|
|
95
93
|
*/
|
|
@@ -104,8 +102,7 @@ declare class EventStreamConnection<TData> {
|
|
|
104
102
|
* Tell clients that the stream has ended and close the connection.
|
|
105
103
|
*/
|
|
106
104
|
close(): Promise<void>;
|
|
107
|
-
|
|
108
|
-
on(event: "request:close", callback: () => any): void;
|
|
105
|
+
onClose(cb: () => any): void;
|
|
109
106
|
}
|
|
110
107
|
declare function registerEventStreamRpc(router: Router, path: string, procedure: EventStreamRpc<any, any> & {
|
|
111
108
|
name: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ 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';
|
|
7
6
|
import { BuildOptions } from 'esbuild';
|
|
8
7
|
|
|
9
8
|
interface MiddlewareEventContext extends H3EventContext {
|
|
@@ -78,7 +77,6 @@ interface EventStreamConnectionOptions<TData> {
|
|
|
78
77
|
}
|
|
79
78
|
declare class EventStreamConnection<TData> {
|
|
80
79
|
readonly lastEventId?: string;
|
|
81
|
-
private readonly h3Event;
|
|
82
80
|
private readonly validationErrors;
|
|
83
81
|
private readonly validator;
|
|
84
82
|
private readonly serializer;
|
|
@@ -87,9 +85,9 @@ declare class EventStreamConnection<TData> {
|
|
|
87
85
|
readonly eventStream: EventStream;
|
|
88
86
|
constructor(event: H3Event, opts: EventStreamConnectionOptions<TData>);
|
|
89
87
|
/**
|
|
90
|
-
*
|
|
88
|
+
* Send the stream to the client. This must be called before sending any events.
|
|
91
89
|
*/
|
|
92
|
-
|
|
90
|
+
send(): void;
|
|
93
91
|
/**
|
|
94
92
|
* Publish a new event. Events published with this hook will trigger the `onData()` hooks of any connected clients.
|
|
95
93
|
*/
|
|
@@ -104,8 +102,7 @@ declare class EventStreamConnection<TData> {
|
|
|
104
102
|
* Tell clients that the stream has ended and close the connection.
|
|
105
103
|
*/
|
|
106
104
|
close(): Promise<void>;
|
|
107
|
-
|
|
108
|
-
on(event: "request:close", callback: () => any): void;
|
|
105
|
+
onClose(cb: () => any): void;
|
|
109
106
|
}
|
|
110
107
|
declare function registerEventStreamRpc(router: Router, path: string, procedure: EventStreamRpc<any, any> & {
|
|
111
108
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ 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';
|
|
7
6
|
import { BuildOptions } from 'esbuild';
|
|
8
7
|
|
|
9
8
|
interface MiddlewareEventContext extends H3EventContext {
|
|
@@ -78,7 +77,6 @@ interface EventStreamConnectionOptions<TData> {
|
|
|
78
77
|
}
|
|
79
78
|
declare class EventStreamConnection<TData> {
|
|
80
79
|
readonly lastEventId?: string;
|
|
81
|
-
private readonly h3Event;
|
|
82
80
|
private readonly validationErrors;
|
|
83
81
|
private readonly validator;
|
|
84
82
|
private readonly serializer;
|
|
@@ -87,9 +85,9 @@ declare class EventStreamConnection<TData> {
|
|
|
87
85
|
readonly eventStream: EventStream;
|
|
88
86
|
constructor(event: H3Event, opts: EventStreamConnectionOptions<TData>);
|
|
89
87
|
/**
|
|
90
|
-
*
|
|
88
|
+
* Send the stream to the client. This must be called before sending any events.
|
|
91
89
|
*/
|
|
92
|
-
|
|
90
|
+
send(): void;
|
|
93
91
|
/**
|
|
94
92
|
* Publish a new event. Events published with this hook will trigger the `onData()` hooks of any connected clients.
|
|
95
93
|
*/
|
|
@@ -104,8 +102,7 @@ declare class EventStreamConnection<TData> {
|
|
|
104
102
|
* Tell clients that the stream has ended and close the connection.
|
|
105
103
|
*/
|
|
106
104
|
close(): Promise<void>;
|
|
107
|
-
|
|
108
|
-
on(event: "request:close", callback: () => any): void;
|
|
105
|
+
onClose(cb: () => any): void;
|
|
109
106
|
}
|
|
110
107
|
declare function registerEventStreamRpc(router: Router, path: string, procedure: EventStreamRpc<any, any> & {
|
|
111
108
|
name: string;
|
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.8cfc63cb.mjs';
|
|
2
2
|
export * from 'h3';
|
|
3
|
-
export * from 'h3-sse';
|
|
4
3
|
import 'arri-validate';
|
|
4
|
+
import 'h3-sse';
|
|
5
5
|
import 'arri-codegen-utils';
|
|
6
6
|
import 'scule';
|
|
7
7
|
|
|
@@ -446,7 +446,6 @@ function isEventStreamRpc(input) {
|
|
|
446
446
|
class EventStreamConnection {
|
|
447
447
|
constructor(event, opts) {
|
|
448
448
|
__publicField$2(this, "lastEventId");
|
|
449
|
-
__publicField$2(this, "h3Event");
|
|
450
449
|
__publicField$2(this, "validationErrors");
|
|
451
450
|
__publicField$2(this, "validator");
|
|
452
451
|
__publicField$2(this, "serializer");
|
|
@@ -454,22 +453,21 @@ class EventStreamConnection {
|
|
|
454
453
|
__publicField$2(this, "pingInterval");
|
|
455
454
|
__publicField$2(this, "pingIntervalMs");
|
|
456
455
|
__publicField$2(this, "eventStream");
|
|
457
|
-
this.
|
|
458
|
-
this.eventStream = h3Sse.createEventStream(event, true);
|
|
456
|
+
this.eventStream = h3Sse.createEventStream(event);
|
|
459
457
|
this.lastEventId = this.eventStream.lastEventId;
|
|
460
458
|
this.pingIntervalMs = opts.pingInterval ?? 6e4;
|
|
461
459
|
this.serializer = opts.serializer;
|
|
462
460
|
this.validator = opts.validator;
|
|
463
461
|
this.validationErrors = opts.validationErrors;
|
|
464
|
-
this.eventStream.
|
|
462
|
+
this.eventStream.onClose(() => {
|
|
465
463
|
this.cleanup();
|
|
466
464
|
});
|
|
467
465
|
}
|
|
468
466
|
/**
|
|
469
|
-
*
|
|
467
|
+
* Send the stream to the client. This must be called before sending any events.
|
|
470
468
|
*/
|
|
471
|
-
|
|
472
|
-
void
|
|
469
|
+
send() {
|
|
470
|
+
void this.eventStream.send();
|
|
473
471
|
this.pingInterval = setInterval(async () => {
|
|
474
472
|
await this.eventStream.push({
|
|
475
473
|
event: "ping",
|
|
@@ -565,15 +563,8 @@ class EventStreamConnection {
|
|
|
565
563
|
}).catch();
|
|
566
564
|
await this.eventStream.close();
|
|
567
565
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
case "close":
|
|
571
|
-
this.eventStream.on("close", callback);
|
|
572
|
-
break;
|
|
573
|
-
case "request:close":
|
|
574
|
-
this.eventStream.on("request:close", callback);
|
|
575
|
-
break;
|
|
576
|
-
}
|
|
566
|
+
onClose(cb) {
|
|
567
|
+
this.eventStream.onClose(cb);
|
|
577
568
|
}
|
|
578
569
|
}
|
|
579
570
|
function registerEventStreamRpc(router, path, procedure, opts) {
|
|
@@ -626,7 +617,7 @@ function registerEventStreamRpc(router, path, procedure, opts) {
|
|
|
626
617
|
event
|
|
627
618
|
);
|
|
628
619
|
if (!event.handled && !stream.eventStream._handled) {
|
|
629
|
-
|
|
620
|
+
stream.send();
|
|
630
621
|
}
|
|
631
622
|
} catch (err) {
|
|
632
623
|
await handleH3Error(err, event, opts.onError);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createError, isError, setResponseStatus, send, eventHandler, isPreflightRequest, setResponseHeader, readRawBody, getValidatedQuery, defineEventHandler, getQuery, setHeader, createRouter, createApp, sendError } from 'h3';
|
|
2
2
|
import { a, isAObjectSchema, isARecordSchema, isADiscriminatorSchema } from 'arri-validate';
|
|
3
|
-
import { createEventStream
|
|
3
|
+
import { createEventStream } from 'h3-sse';
|
|
4
4
|
import { isRpcHttpMethod, removeDisallowedChars } from 'arri-codegen-utils';
|
|
5
5
|
import { kebabCase, pascalCase } from 'scule';
|
|
6
6
|
|
|
@@ -444,7 +444,6 @@ function isEventStreamRpc(input) {
|
|
|
444
444
|
class EventStreamConnection {
|
|
445
445
|
constructor(event, opts) {
|
|
446
446
|
__publicField$2(this, "lastEventId");
|
|
447
|
-
__publicField$2(this, "h3Event");
|
|
448
447
|
__publicField$2(this, "validationErrors");
|
|
449
448
|
__publicField$2(this, "validator");
|
|
450
449
|
__publicField$2(this, "serializer");
|
|
@@ -452,22 +451,21 @@ class EventStreamConnection {
|
|
|
452
451
|
__publicField$2(this, "pingInterval");
|
|
453
452
|
__publicField$2(this, "pingIntervalMs");
|
|
454
453
|
__publicField$2(this, "eventStream");
|
|
455
|
-
this.
|
|
456
|
-
this.eventStream = createEventStream(event, true);
|
|
454
|
+
this.eventStream = createEventStream(event);
|
|
457
455
|
this.lastEventId = this.eventStream.lastEventId;
|
|
458
456
|
this.pingIntervalMs = opts.pingInterval ?? 6e4;
|
|
459
457
|
this.serializer = opts.serializer;
|
|
460
458
|
this.validator = opts.validator;
|
|
461
459
|
this.validationErrors = opts.validationErrors;
|
|
462
|
-
this.eventStream.
|
|
460
|
+
this.eventStream.onClose(() => {
|
|
463
461
|
this.cleanup();
|
|
464
462
|
});
|
|
465
463
|
}
|
|
466
464
|
/**
|
|
467
|
-
*
|
|
465
|
+
* Send the stream to the client. This must be called before sending any events.
|
|
468
466
|
*/
|
|
469
|
-
|
|
470
|
-
void
|
|
467
|
+
send() {
|
|
468
|
+
void this.eventStream.send();
|
|
471
469
|
this.pingInterval = setInterval(async () => {
|
|
472
470
|
await this.eventStream.push({
|
|
473
471
|
event: "ping",
|
|
@@ -563,15 +561,8 @@ class EventStreamConnection {
|
|
|
563
561
|
}).catch();
|
|
564
562
|
await this.eventStream.close();
|
|
565
563
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
case "close":
|
|
569
|
-
this.eventStream.on("close", callback);
|
|
570
|
-
break;
|
|
571
|
-
case "request:close":
|
|
572
|
-
this.eventStream.on("request:close", callback);
|
|
573
|
-
break;
|
|
574
|
-
}
|
|
564
|
+
onClose(cb) {
|
|
565
|
+
this.eventStream.onClose(cb);
|
|
575
566
|
}
|
|
576
567
|
}
|
|
577
568
|
function registerEventStreamRpc(router, path, procedure, opts) {
|
|
@@ -624,7 +615,7 @@ function registerEventStreamRpc(router, path, procedure, opts) {
|
|
|
624
615
|
event
|
|
625
616
|
);
|
|
626
617
|
if (!event.handled && !stream.eventStream._handled) {
|
|
627
|
-
|
|
618
|
+
stream.send();
|
|
628
619
|
}
|
|
629
620
|
} catch (err) {
|
|
630
621
|
await handleH3Error(err, event, opts.onError);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,21 +34,21 @@
|
|
|
34
34
|
"esbuild": "^0.20.1",
|
|
35
35
|
"esbuild-plugin-replace": "^1.4.0",
|
|
36
36
|
"globby": "^14.0.1",
|
|
37
|
-
"h3": "^1.
|
|
38
|
-
"h3-sse": "^0.0.
|
|
37
|
+
"h3": "^1.11.1",
|
|
38
|
+
"h3-sse": "^0.0.12",
|
|
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-dart": "0.
|
|
46
|
-
"arri-
|
|
47
|
-
"arri-
|
|
48
|
-
"arri-codegen-
|
|
45
|
+
"arri-codegen-dart": "0.27.0",
|
|
46
|
+
"arri-codegen-utils": "0.27.0",
|
|
47
|
+
"arri-validate": "0.27.0",
|
|
48
|
+
"arri-codegen-ts": "0.27.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/degit": "^2.8.6",
|
|
52
|
-
"bun-types": "^1.0.
|
|
52
|
+
"bun-types": "^1.0.29"
|
|
53
53
|
}
|
|
54
54
|
}
|