@orpc/standard-server 0.0.0-next.d0e429d → 0.0.0-next.e7ee5a9
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 +1 -1
- package/dist/index.d.mts +79 -0
- package/dist/index.d.ts +79 -0
- package/dist/{index.js → index.mjs} +15 -38
- package/package.json +6 -11
- package/dist/src/event-source/decoder.d.ts +0 -16
- package/dist/src/event-source/encoder.d.ts +0 -9
- package/dist/src/event-source/errors.d.ts +0 -13
- package/dist/src/event-source/index.d.ts +0 -6
- package/dist/src/event-source/meta.d.ts +0 -5
- package/dist/src/event-source/types.d.ts +0 -11
- package/dist/src/index.d.ts +0 -4
- package/dist/src/types.d.ts +0 -25
- package/dist/src/utils.d.ts +0 -2
package/README.md
CHANGED
package/dist/index.d.mts
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
2
|
+
|
3
|
+
interface EventMessage {
|
4
|
+
event: string | undefined;
|
5
|
+
id: string | undefined;
|
6
|
+
data: string | undefined;
|
7
|
+
/**
|
8
|
+
* The number of milliseconds to wait before retrying the event source if error occurs.
|
9
|
+
*/
|
10
|
+
retry: number | undefined;
|
11
|
+
comments: string[];
|
12
|
+
}
|
13
|
+
|
14
|
+
declare function decodeEventMessage(encoded: string): EventMessage;
|
15
|
+
interface EventDecoderOptions {
|
16
|
+
onEvent?: (event: EventMessage) => void;
|
17
|
+
}
|
18
|
+
declare class EventDecoder {
|
19
|
+
private options;
|
20
|
+
private incomplete;
|
21
|
+
constructor(options?: EventDecoderOptions);
|
22
|
+
feed(chunk: string): void;
|
23
|
+
end(): void;
|
24
|
+
}
|
25
|
+
declare class EventDecoderStream extends TransformStream<string, EventMessage> {
|
26
|
+
constructor();
|
27
|
+
}
|
28
|
+
|
29
|
+
declare function assertEventId(id: string): void;
|
30
|
+
declare function assertEventName(event: string): void;
|
31
|
+
declare function assertEventRetry(retry: number): void;
|
32
|
+
declare function assertEventComment(comment: string): void;
|
33
|
+
declare function encodeEventData(data: string | undefined): string;
|
34
|
+
declare function encodeEventComments(comments: string[] | undefined): string;
|
35
|
+
declare function encodeEventMessage(message: Partial<EventMessage>): string;
|
36
|
+
|
37
|
+
declare class EventEncoderError extends TypeError {
|
38
|
+
}
|
39
|
+
declare class EventDecoderError extends TypeError {
|
40
|
+
}
|
41
|
+
interface ErrorEventOptions extends ErrorOptions {
|
42
|
+
message?: string;
|
43
|
+
data?: unknown;
|
44
|
+
}
|
45
|
+
declare class ErrorEvent extends Error {
|
46
|
+
data: unknown;
|
47
|
+
constructor(options?: ErrorEventOptions);
|
48
|
+
}
|
49
|
+
|
50
|
+
type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
|
51
|
+
declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
52
|
+
declare function getEventMeta(container: unknown): EventMeta | undefined;
|
53
|
+
|
54
|
+
interface StandardHeaders {
|
55
|
+
[key: string]: string | string[] | undefined;
|
56
|
+
}
|
57
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
58
|
+
interface StandardRequest {
|
59
|
+
/**
|
60
|
+
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
61
|
+
*/
|
62
|
+
raw: Record<string, unknown>;
|
63
|
+
method: string;
|
64
|
+
url: URL;
|
65
|
+
headers: StandardHeaders;
|
66
|
+
/**
|
67
|
+
* The body has been parsed base on the content-type header.
|
68
|
+
* This method can safely call multiple times (cached).
|
69
|
+
*/
|
70
|
+
body: () => Promise<StandardBody>;
|
71
|
+
signal: AbortSignal | undefined;
|
72
|
+
}
|
73
|
+
interface StandardResponse {
|
74
|
+
status: number;
|
75
|
+
headers: StandardHeaders;
|
76
|
+
body: StandardBody;
|
77
|
+
}
|
78
|
+
|
79
|
+
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta, type StandardBody, type StandardHeaders, type StandardRequest, type StandardResponse, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, getEventMeta, withEventMeta };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
2
|
+
|
3
|
+
interface EventMessage {
|
4
|
+
event: string | undefined;
|
5
|
+
id: string | undefined;
|
6
|
+
data: string | undefined;
|
7
|
+
/**
|
8
|
+
* The number of milliseconds to wait before retrying the event source if error occurs.
|
9
|
+
*/
|
10
|
+
retry: number | undefined;
|
11
|
+
comments: string[];
|
12
|
+
}
|
13
|
+
|
14
|
+
declare function decodeEventMessage(encoded: string): EventMessage;
|
15
|
+
interface EventDecoderOptions {
|
16
|
+
onEvent?: (event: EventMessage) => void;
|
17
|
+
}
|
18
|
+
declare class EventDecoder {
|
19
|
+
private options;
|
20
|
+
private incomplete;
|
21
|
+
constructor(options?: EventDecoderOptions);
|
22
|
+
feed(chunk: string): void;
|
23
|
+
end(): void;
|
24
|
+
}
|
25
|
+
declare class EventDecoderStream extends TransformStream<string, EventMessage> {
|
26
|
+
constructor();
|
27
|
+
}
|
28
|
+
|
29
|
+
declare function assertEventId(id: string): void;
|
30
|
+
declare function assertEventName(event: string): void;
|
31
|
+
declare function assertEventRetry(retry: number): void;
|
32
|
+
declare function assertEventComment(comment: string): void;
|
33
|
+
declare function encodeEventData(data: string | undefined): string;
|
34
|
+
declare function encodeEventComments(comments: string[] | undefined): string;
|
35
|
+
declare function encodeEventMessage(message: Partial<EventMessage>): string;
|
36
|
+
|
37
|
+
declare class EventEncoderError extends TypeError {
|
38
|
+
}
|
39
|
+
declare class EventDecoderError extends TypeError {
|
40
|
+
}
|
41
|
+
interface ErrorEventOptions extends ErrorOptions {
|
42
|
+
message?: string;
|
43
|
+
data?: unknown;
|
44
|
+
}
|
45
|
+
declare class ErrorEvent extends Error {
|
46
|
+
data: unknown;
|
47
|
+
constructor(options?: ErrorEventOptions);
|
48
|
+
}
|
49
|
+
|
50
|
+
type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
|
51
|
+
declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
52
|
+
declare function getEventMeta(container: unknown): EventMeta | undefined;
|
53
|
+
|
54
|
+
interface StandardHeaders {
|
55
|
+
[key: string]: string | string[] | undefined;
|
56
|
+
}
|
57
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
58
|
+
interface StandardRequest {
|
59
|
+
/**
|
60
|
+
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
61
|
+
*/
|
62
|
+
raw: Record<string, unknown>;
|
63
|
+
method: string;
|
64
|
+
url: URL;
|
65
|
+
headers: StandardHeaders;
|
66
|
+
/**
|
67
|
+
* The body has been parsed base on the content-type header.
|
68
|
+
* This method can safely call multiple times (cached).
|
69
|
+
*/
|
70
|
+
body: () => Promise<StandardBody>;
|
71
|
+
signal: AbortSignal | undefined;
|
72
|
+
}
|
73
|
+
interface StandardResponse {
|
74
|
+
status: number;
|
75
|
+
headers: StandardHeaders;
|
76
|
+
body: StandardBody;
|
77
|
+
}
|
78
|
+
|
79
|
+
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta, type StandardBody, type StandardHeaders, type StandardRequest, type StandardResponse, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, getEventMeta, withEventMeta };
|
@@ -1,17 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
1
|
+
import { isTypescriptObject } from '@orpc/shared';
|
2
|
+
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
3
|
+
|
4
|
+
class EventEncoderError extends TypeError {
|
5
|
+
}
|
6
|
+
class EventDecoderError extends TypeError {
|
7
|
+
}
|
8
|
+
class ErrorEvent extends Error {
|
7
9
|
data;
|
8
10
|
constructor(options) {
|
9
11
|
super(options?.message ?? "An error event was received", options);
|
10
12
|
this.data = options?.data;
|
11
13
|
}
|
12
|
-
}
|
14
|
+
}
|
13
15
|
|
14
|
-
// src/event-source/decoder.ts
|
15
16
|
function decodeEventMessage(encoded) {
|
16
17
|
const lines = encoded.replace(/\n+$/, "").split(/\n/);
|
17
18
|
const message = {
|
@@ -45,7 +46,7 @@ function decodeEventMessage(encoded) {
|
|
45
46
|
message.data = message.data?.replace(/\n$/, "");
|
46
47
|
return message;
|
47
48
|
}
|
48
|
-
|
49
|
+
class EventDecoder {
|
49
50
|
constructor(options = {}) {
|
50
51
|
this.options = options;
|
51
52
|
}
|
@@ -73,8 +74,8 @@ var EventDecoder = class {
|
|
73
74
|
throw new EventDecoderError("EventSource ended before complete");
|
74
75
|
}
|
75
76
|
}
|
76
|
-
}
|
77
|
-
|
77
|
+
}
|
78
|
+
class EventDecoderStream extends TransformStream {
|
78
79
|
constructor() {
|
79
80
|
let decoder;
|
80
81
|
super({
|
@@ -93,9 +94,8 @@ var EventDecoderStream = class extends TransformStream {
|
|
93
94
|
}
|
94
95
|
});
|
95
96
|
}
|
96
|
-
}
|
97
|
+
}
|
97
98
|
|
98
|
-
// src/event-source/encoder.ts
|
99
99
|
function assertEventId(id) {
|
100
100
|
if (id.includes("\n")) {
|
101
101
|
throw new EventEncoderError("Event-source id must not contain a newline character");
|
@@ -157,9 +157,7 @@ function encodeEventMessage(message) {
|
|
157
157
|
return output;
|
158
158
|
}
|
159
159
|
|
160
|
-
|
161
|
-
import { isTypescriptObject } from "@orpc/shared";
|
162
|
-
var EVENT_SOURCE_META_SYMBOL = Symbol("ORPC_EVENT_SOURCE_META");
|
160
|
+
const EVENT_SOURCE_META_SYMBOL = Symbol("ORPC_EVENT_SOURCE_META");
|
163
161
|
function withEventMeta(container, meta) {
|
164
162
|
if (meta.id !== void 0) {
|
165
163
|
assertEventId(meta.id);
|
@@ -185,25 +183,4 @@ function getEventMeta(container) {
|
|
185
183
|
return isTypescriptObject(container) ? Reflect.get(container, EVENT_SOURCE_META_SYMBOL) : void 0;
|
186
184
|
}
|
187
185
|
|
188
|
-
|
189
|
-
import { contentDisposition, parse } from "@tinyhttp/content-disposition";
|
190
|
-
export {
|
191
|
-
ErrorEvent,
|
192
|
-
EventDecoder,
|
193
|
-
EventDecoderError,
|
194
|
-
EventDecoderStream,
|
195
|
-
EventEncoderError,
|
196
|
-
assertEventComment,
|
197
|
-
assertEventId,
|
198
|
-
assertEventName,
|
199
|
-
assertEventRetry,
|
200
|
-
contentDisposition,
|
201
|
-
decodeEventMessage,
|
202
|
-
encodeEventComments,
|
203
|
-
encodeEventData,
|
204
|
-
encodeEventMessage,
|
205
|
-
getEventMeta,
|
206
|
-
parse as parseContentDisposition,
|
207
|
-
withEventMeta
|
208
|
-
};
|
209
|
-
//# sourceMappingURL=index.js.map
|
186
|
+
export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, getEventMeta, withEventMeta };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/standard-server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.e7ee5a9",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://unnoq.com",
|
7
7
|
"repository": {
|
@@ -14,25 +14,20 @@
|
|
14
14
|
],
|
15
15
|
"exports": {
|
16
16
|
".": {
|
17
|
-
"types": "./dist/
|
18
|
-
"import": "./dist/index.
|
19
|
-
"default": "./dist/index.
|
20
|
-
},
|
21
|
-
"./🔒/*": {
|
22
|
-
"types": "./dist/src/*.d.ts"
|
17
|
+
"types": "./dist/index.d.mts",
|
18
|
+
"import": "./dist/index.mjs",
|
19
|
+
"default": "./dist/index.mjs"
|
23
20
|
}
|
24
21
|
},
|
25
22
|
"files": [
|
26
|
-
"!**/*.map",
|
27
|
-
"!**/*.tsbuildinfo",
|
28
23
|
"dist"
|
29
24
|
],
|
30
25
|
"dependencies": {
|
31
26
|
"@tinyhttp/content-disposition": "^2.2.2",
|
32
|
-
"@orpc/shared": "0.0.0-next.
|
27
|
+
"@orpc/shared": "0.0.0-next.e7ee5a9"
|
33
28
|
},
|
34
29
|
"scripts": {
|
35
|
-
"build": "
|
30
|
+
"build": "unbuild",
|
36
31
|
"build:watch": "pnpm run build --watch",
|
37
32
|
"type:check": "tsc -b"
|
38
33
|
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { EventMessage } from './types';
|
2
|
-
export declare function decodeEventMessage(encoded: string): EventMessage;
|
3
|
-
export interface EventDecoderOptions {
|
4
|
-
onEvent?: (event: EventMessage) => void;
|
5
|
-
}
|
6
|
-
export declare class EventDecoder {
|
7
|
-
private options;
|
8
|
-
private incomplete;
|
9
|
-
constructor(options?: EventDecoderOptions);
|
10
|
-
feed(chunk: string): void;
|
11
|
-
end(): void;
|
12
|
-
}
|
13
|
-
export declare class EventDecoderStream extends TransformStream<string, EventMessage> {
|
14
|
-
constructor();
|
15
|
-
}
|
16
|
-
//# sourceMappingURL=decoder.d.ts.map
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import type { EventMessage } from './types';
|
2
|
-
export declare function assertEventId(id: string): void;
|
3
|
-
export declare function assertEventName(event: string): void;
|
4
|
-
export declare function assertEventRetry(retry: number): void;
|
5
|
-
export declare function assertEventComment(comment: string): void;
|
6
|
-
export declare function encodeEventData(data: string | undefined): string;
|
7
|
-
export declare function encodeEventComments(comments: string[] | undefined): string;
|
8
|
-
export declare function encodeEventMessage(message: Partial<EventMessage>): string;
|
9
|
-
//# sourceMappingURL=encoder.d.ts.map
|
@@ -1,13 +0,0 @@
|
|
1
|
-
export declare class EventEncoderError extends TypeError {
|
2
|
-
}
|
3
|
-
export declare class EventDecoderError extends TypeError {
|
4
|
-
}
|
5
|
-
export interface ErrorEventOptions extends ErrorOptions {
|
6
|
-
message?: string;
|
7
|
-
data?: unknown;
|
8
|
-
}
|
9
|
-
export declare class ErrorEvent extends Error {
|
10
|
-
data: unknown;
|
11
|
-
constructor(options?: ErrorEventOptions);
|
12
|
-
}
|
13
|
-
//# sourceMappingURL=errors.d.ts.map
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import type { EventMessage } from './types';
|
2
|
-
export type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
|
3
|
-
export declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
4
|
-
export declare function getEventMeta(container: unknown): EventMeta | undefined;
|
5
|
-
//# sourceMappingURL=meta.d.ts.map
|
@@ -1,11 +0,0 @@
|
|
1
|
-
export interface EventMessage {
|
2
|
-
event: string | undefined;
|
3
|
-
id: string | undefined;
|
4
|
-
data: string | undefined;
|
5
|
-
/**
|
6
|
-
* The number of milliseconds to wait before retrying the event source if error occurs.
|
7
|
-
*/
|
8
|
-
retry: number | undefined;
|
9
|
-
comments: string[];
|
10
|
-
}
|
11
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/index.d.ts
DELETED
package/dist/src/types.d.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
export interface StandardHeaders {
|
2
|
-
[key: string]: string | string[] | undefined;
|
3
|
-
}
|
4
|
-
export type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
5
|
-
export interface StandardRequest {
|
6
|
-
/**
|
7
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
8
|
-
*/
|
9
|
-
raw: Record<string, unknown>;
|
10
|
-
method: string;
|
11
|
-
url: URL;
|
12
|
-
headers: StandardHeaders;
|
13
|
-
/**
|
14
|
-
* The body has been parsed base on the content-type header.
|
15
|
-
* This method can safely call multiple times (cached).
|
16
|
-
*/
|
17
|
-
body: () => Promise<StandardBody>;
|
18
|
-
signal: AbortSignal | undefined;
|
19
|
-
}
|
20
|
-
export interface StandardResponse {
|
21
|
-
status: number;
|
22
|
-
headers: StandardHeaders;
|
23
|
-
body: StandardBody;
|
24
|
-
}
|
25
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/utils.d.ts
DELETED