@graphorin/protocol 0.5.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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/client-message.d.ts +478 -0
- package/dist/client-message.d.ts.map +1 -0
- package/dist/client-message.js +128 -0
- package/dist/client-message.js.map +1 -0
- package/dist/close-codes.d.ts +49 -0
- package/dist/close-codes.d.ts.map +1 -0
- package/dist/close-codes.js +41 -0
- package/dist/close-codes.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/server-message.d.ts +459 -0
- package/dist/server-message.d.ts.map +1 -0
- package/dist/server-message.js +185 -0
- package/dist/server-message.js.map +1 -0
- package/dist/subprotocol.d.ts +70 -0
- package/dist/subprotocol.d.ts.map +1 -0
- package/dist/subprotocol.js +87 -0
- package/dist/subprotocol.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/server-message.d.ts
|
|
4
|
+
|
|
5
|
+
declare const RpcSuccess: z.ZodObject<{
|
|
6
|
+
v: z.ZodLiteral<"1">;
|
|
7
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
8
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
9
|
+
result: z.ZodUnknown;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
v: "1";
|
|
12
|
+
jsonrpc: "2.0";
|
|
13
|
+
id: string | number;
|
|
14
|
+
result?: unknown;
|
|
15
|
+
}, {
|
|
16
|
+
v: "1";
|
|
17
|
+
jsonrpc: "2.0";
|
|
18
|
+
id: string | number;
|
|
19
|
+
result?: unknown;
|
|
20
|
+
}>;
|
|
21
|
+
declare const RpcFailure: z.ZodObject<{
|
|
22
|
+
v: z.ZodLiteral<"1">;
|
|
23
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
24
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
25
|
+
error: z.ZodObject<{
|
|
26
|
+
code: z.ZodNumber;
|
|
27
|
+
message: z.ZodString;
|
|
28
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
29
|
+
}, "strict", z.ZodTypeAny, {
|
|
30
|
+
code: number;
|
|
31
|
+
message: string;
|
|
32
|
+
data?: unknown;
|
|
33
|
+
}, {
|
|
34
|
+
code: number;
|
|
35
|
+
message: string;
|
|
36
|
+
data?: unknown;
|
|
37
|
+
}>;
|
|
38
|
+
}, "strict", z.ZodTypeAny, {
|
|
39
|
+
v: "1";
|
|
40
|
+
jsonrpc: "2.0";
|
|
41
|
+
id: string | number;
|
|
42
|
+
error: {
|
|
43
|
+
code: number;
|
|
44
|
+
message: string;
|
|
45
|
+
data?: unknown;
|
|
46
|
+
};
|
|
47
|
+
}, {
|
|
48
|
+
v: "1";
|
|
49
|
+
jsonrpc: "2.0";
|
|
50
|
+
id: string | number;
|
|
51
|
+
error: {
|
|
52
|
+
code: number;
|
|
53
|
+
message: string;
|
|
54
|
+
data?: unknown;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
declare const SubscribedFrame: z.ZodObject<{
|
|
58
|
+
v: z.ZodLiteral<"1">;
|
|
59
|
+
kind: z.ZodLiteral<"subscribed">;
|
|
60
|
+
subscriptionId: z.ZodString;
|
|
61
|
+
subject: z.ZodString;
|
|
62
|
+
snapshotEventId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, "strict", z.ZodTypeAny, {
|
|
64
|
+
v: "1";
|
|
65
|
+
subject: string;
|
|
66
|
+
subscriptionId: string;
|
|
67
|
+
kind: "subscribed";
|
|
68
|
+
snapshotEventId?: string | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
v: "1";
|
|
71
|
+
subject: string;
|
|
72
|
+
subscriptionId: string;
|
|
73
|
+
kind: "subscribed";
|
|
74
|
+
snapshotEventId?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
declare const UnsubscribedFrame: z.ZodObject<{
|
|
77
|
+
v: z.ZodLiteral<"1">;
|
|
78
|
+
kind: z.ZodLiteral<"unsubscribed">;
|
|
79
|
+
subscriptionId: z.ZodString;
|
|
80
|
+
}, "strict", z.ZodTypeAny, {
|
|
81
|
+
v: "1";
|
|
82
|
+
subscriptionId: string;
|
|
83
|
+
kind: "unsubscribed";
|
|
84
|
+
}, {
|
|
85
|
+
v: "1";
|
|
86
|
+
subscriptionId: string;
|
|
87
|
+
kind: "unsubscribed";
|
|
88
|
+
}>;
|
|
89
|
+
declare const EventFrame: z.ZodObject<{
|
|
90
|
+
v: z.ZodLiteral<"1">;
|
|
91
|
+
kind: z.ZodLiteral<"event">;
|
|
92
|
+
eventId: z.ZodString;
|
|
93
|
+
subscriptionId: z.ZodString;
|
|
94
|
+
subject: z.ZodString;
|
|
95
|
+
type: z.ZodString;
|
|
96
|
+
payload: z.ZodUnknown;
|
|
97
|
+
}, "strict", z.ZodTypeAny, {
|
|
98
|
+
v: "1";
|
|
99
|
+
type: string;
|
|
100
|
+
subject: string;
|
|
101
|
+
subscriptionId: string;
|
|
102
|
+
kind: "event";
|
|
103
|
+
eventId: string;
|
|
104
|
+
payload?: unknown;
|
|
105
|
+
}, {
|
|
106
|
+
v: "1";
|
|
107
|
+
type: string;
|
|
108
|
+
subject: string;
|
|
109
|
+
subscriptionId: string;
|
|
110
|
+
kind: "event";
|
|
111
|
+
eventId: string;
|
|
112
|
+
payload?: unknown;
|
|
113
|
+
}>;
|
|
114
|
+
declare const LifecycleFrame: z.ZodObject<{
|
|
115
|
+
v: z.ZodLiteral<"1">;
|
|
116
|
+
kind: z.ZodLiteral<"lifecycle">;
|
|
117
|
+
subscriptionId: z.ZodString;
|
|
118
|
+
status: z.ZodEnum<["running", "paused", "completed", "aborted", "failed"]>;
|
|
119
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, "strict", z.ZodTypeAny, {
|
|
121
|
+
v: "1";
|
|
122
|
+
status: "aborted" | "running" | "paused" | "completed" | "failed";
|
|
123
|
+
subscriptionId: string;
|
|
124
|
+
kind: "lifecycle";
|
|
125
|
+
reason?: string | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
v: "1";
|
|
128
|
+
status: "aborted" | "running" | "paused" | "completed" | "failed";
|
|
129
|
+
subscriptionId: string;
|
|
130
|
+
kind: "lifecycle";
|
|
131
|
+
reason?: string | undefined;
|
|
132
|
+
}>;
|
|
133
|
+
declare const ErrorFrame: z.ZodObject<{
|
|
134
|
+
v: z.ZodLiteral<"1">;
|
|
135
|
+
kind: z.ZodLiteral<"error">;
|
|
136
|
+
code: z.ZodString;
|
|
137
|
+
message: z.ZodString;
|
|
138
|
+
fatal: z.ZodOptional<z.ZodBoolean>;
|
|
139
|
+
subscriptionId: z.ZodOptional<z.ZodString>;
|
|
140
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
141
|
+
}, "strict", z.ZodTypeAny, {
|
|
142
|
+
v: "1";
|
|
143
|
+
code: string;
|
|
144
|
+
message: string;
|
|
145
|
+
kind: "error";
|
|
146
|
+
subscriptionId?: string | undefined;
|
|
147
|
+
data?: unknown;
|
|
148
|
+
fatal?: boolean | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
v: "1";
|
|
151
|
+
code: string;
|
|
152
|
+
message: string;
|
|
153
|
+
kind: "error";
|
|
154
|
+
subscriptionId?: string | undefined;
|
|
155
|
+
data?: unknown;
|
|
156
|
+
fatal?: boolean | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
declare const PongFrame: z.ZodObject<{
|
|
159
|
+
v: z.ZodLiteral<"1">;
|
|
160
|
+
kind: z.ZodLiteral<"pong">;
|
|
161
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strict", z.ZodTypeAny, {
|
|
163
|
+
v: "1";
|
|
164
|
+
kind: "pong";
|
|
165
|
+
nonce?: string | undefined;
|
|
166
|
+
}, {
|
|
167
|
+
v: "1";
|
|
168
|
+
kind: "pong";
|
|
169
|
+
nonce?: string | undefined;
|
|
170
|
+
}>;
|
|
171
|
+
declare const ReplayMarkerFrame: z.ZodObject<{
|
|
172
|
+
v: z.ZodLiteral<"1">;
|
|
173
|
+
kind: z.ZodLiteral<"replay-marker">;
|
|
174
|
+
subscriptionId: z.ZodString;
|
|
175
|
+
eventId: z.ZodString;
|
|
176
|
+
droppedCount: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
note: z.ZodOptional<z.ZodString>;
|
|
178
|
+
}, "strict", z.ZodTypeAny, {
|
|
179
|
+
v: "1";
|
|
180
|
+
subscriptionId: string;
|
|
181
|
+
kind: "replay-marker";
|
|
182
|
+
eventId: string;
|
|
183
|
+
droppedCount?: number | undefined;
|
|
184
|
+
note?: string | undefined;
|
|
185
|
+
}, {
|
|
186
|
+
v: "1";
|
|
187
|
+
subscriptionId: string;
|
|
188
|
+
kind: "replay-marker";
|
|
189
|
+
eventId: string;
|
|
190
|
+
droppedCount?: number | undefined;
|
|
191
|
+
note?: string | undefined;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Zod schema for every legal server → client frame. Validation runs
|
|
195
|
+
* twice in the server pipeline: first when a route handler enqueues
|
|
196
|
+
* the frame onto the dispatcher's send queue (so a malformed frame
|
|
197
|
+
* never escapes the process), then again on the client side to
|
|
198
|
+
* defend against protocol drift.
|
|
199
|
+
*
|
|
200
|
+
* @stable
|
|
201
|
+
*/
|
|
202
|
+
declare const ServerMessageSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
|
|
203
|
+
v: z.ZodLiteral<"1">;
|
|
204
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
205
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
206
|
+
result: z.ZodUnknown;
|
|
207
|
+
}, "strict", z.ZodTypeAny, {
|
|
208
|
+
v: "1";
|
|
209
|
+
jsonrpc: "2.0";
|
|
210
|
+
id: string | number;
|
|
211
|
+
result?: unknown;
|
|
212
|
+
}, {
|
|
213
|
+
v: "1";
|
|
214
|
+
jsonrpc: "2.0";
|
|
215
|
+
id: string | number;
|
|
216
|
+
result?: unknown;
|
|
217
|
+
}>, z.ZodObject<{
|
|
218
|
+
v: z.ZodLiteral<"1">;
|
|
219
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
220
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
221
|
+
error: z.ZodObject<{
|
|
222
|
+
code: z.ZodNumber;
|
|
223
|
+
message: z.ZodString;
|
|
224
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
225
|
+
}, "strict", z.ZodTypeAny, {
|
|
226
|
+
code: number;
|
|
227
|
+
message: string;
|
|
228
|
+
data?: unknown;
|
|
229
|
+
}, {
|
|
230
|
+
code: number;
|
|
231
|
+
message: string;
|
|
232
|
+
data?: unknown;
|
|
233
|
+
}>;
|
|
234
|
+
}, "strict", z.ZodTypeAny, {
|
|
235
|
+
v: "1";
|
|
236
|
+
jsonrpc: "2.0";
|
|
237
|
+
id: string | number;
|
|
238
|
+
error: {
|
|
239
|
+
code: number;
|
|
240
|
+
message: string;
|
|
241
|
+
data?: unknown;
|
|
242
|
+
};
|
|
243
|
+
}, {
|
|
244
|
+
v: "1";
|
|
245
|
+
jsonrpc: "2.0";
|
|
246
|
+
id: string | number;
|
|
247
|
+
error: {
|
|
248
|
+
code: number;
|
|
249
|
+
message: string;
|
|
250
|
+
data?: unknown;
|
|
251
|
+
};
|
|
252
|
+
}>]>, z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
253
|
+
v: z.ZodLiteral<"1">;
|
|
254
|
+
kind: z.ZodLiteral<"subscribed">;
|
|
255
|
+
subscriptionId: z.ZodString;
|
|
256
|
+
subject: z.ZodString;
|
|
257
|
+
snapshotEventId: z.ZodOptional<z.ZodString>;
|
|
258
|
+
}, "strict", z.ZodTypeAny, {
|
|
259
|
+
v: "1";
|
|
260
|
+
subject: string;
|
|
261
|
+
subscriptionId: string;
|
|
262
|
+
kind: "subscribed";
|
|
263
|
+
snapshotEventId?: string | undefined;
|
|
264
|
+
}, {
|
|
265
|
+
v: "1";
|
|
266
|
+
subject: string;
|
|
267
|
+
subscriptionId: string;
|
|
268
|
+
kind: "subscribed";
|
|
269
|
+
snapshotEventId?: string | undefined;
|
|
270
|
+
}>, z.ZodObject<{
|
|
271
|
+
v: z.ZodLiteral<"1">;
|
|
272
|
+
kind: z.ZodLiteral<"unsubscribed">;
|
|
273
|
+
subscriptionId: z.ZodString;
|
|
274
|
+
}, "strict", z.ZodTypeAny, {
|
|
275
|
+
v: "1";
|
|
276
|
+
subscriptionId: string;
|
|
277
|
+
kind: "unsubscribed";
|
|
278
|
+
}, {
|
|
279
|
+
v: "1";
|
|
280
|
+
subscriptionId: string;
|
|
281
|
+
kind: "unsubscribed";
|
|
282
|
+
}>, z.ZodObject<{
|
|
283
|
+
v: z.ZodLiteral<"1">;
|
|
284
|
+
kind: z.ZodLiteral<"event">;
|
|
285
|
+
eventId: z.ZodString;
|
|
286
|
+
subscriptionId: z.ZodString;
|
|
287
|
+
subject: z.ZodString;
|
|
288
|
+
type: z.ZodString;
|
|
289
|
+
payload: z.ZodUnknown;
|
|
290
|
+
}, "strict", z.ZodTypeAny, {
|
|
291
|
+
v: "1";
|
|
292
|
+
type: string;
|
|
293
|
+
subject: string;
|
|
294
|
+
subscriptionId: string;
|
|
295
|
+
kind: "event";
|
|
296
|
+
eventId: string;
|
|
297
|
+
payload?: unknown;
|
|
298
|
+
}, {
|
|
299
|
+
v: "1";
|
|
300
|
+
type: string;
|
|
301
|
+
subject: string;
|
|
302
|
+
subscriptionId: string;
|
|
303
|
+
kind: "event";
|
|
304
|
+
eventId: string;
|
|
305
|
+
payload?: unknown;
|
|
306
|
+
}>, z.ZodObject<{
|
|
307
|
+
v: z.ZodLiteral<"1">;
|
|
308
|
+
kind: z.ZodLiteral<"lifecycle">;
|
|
309
|
+
subscriptionId: z.ZodString;
|
|
310
|
+
status: z.ZodEnum<["running", "paused", "completed", "aborted", "failed"]>;
|
|
311
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
312
|
+
}, "strict", z.ZodTypeAny, {
|
|
313
|
+
v: "1";
|
|
314
|
+
status: "aborted" | "running" | "paused" | "completed" | "failed";
|
|
315
|
+
subscriptionId: string;
|
|
316
|
+
kind: "lifecycle";
|
|
317
|
+
reason?: string | undefined;
|
|
318
|
+
}, {
|
|
319
|
+
v: "1";
|
|
320
|
+
status: "aborted" | "running" | "paused" | "completed" | "failed";
|
|
321
|
+
subscriptionId: string;
|
|
322
|
+
kind: "lifecycle";
|
|
323
|
+
reason?: string | undefined;
|
|
324
|
+
}>, z.ZodObject<{
|
|
325
|
+
v: z.ZodLiteral<"1">;
|
|
326
|
+
kind: z.ZodLiteral<"error">;
|
|
327
|
+
code: z.ZodString;
|
|
328
|
+
message: z.ZodString;
|
|
329
|
+
fatal: z.ZodOptional<z.ZodBoolean>;
|
|
330
|
+
subscriptionId: z.ZodOptional<z.ZodString>;
|
|
331
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
332
|
+
}, "strict", z.ZodTypeAny, {
|
|
333
|
+
v: "1";
|
|
334
|
+
code: string;
|
|
335
|
+
message: string;
|
|
336
|
+
kind: "error";
|
|
337
|
+
subscriptionId?: string | undefined;
|
|
338
|
+
data?: unknown;
|
|
339
|
+
fatal?: boolean | undefined;
|
|
340
|
+
}, {
|
|
341
|
+
v: "1";
|
|
342
|
+
code: string;
|
|
343
|
+
message: string;
|
|
344
|
+
kind: "error";
|
|
345
|
+
subscriptionId?: string | undefined;
|
|
346
|
+
data?: unknown;
|
|
347
|
+
fatal?: boolean | undefined;
|
|
348
|
+
}>, z.ZodObject<{
|
|
349
|
+
v: z.ZodLiteral<"1">;
|
|
350
|
+
kind: z.ZodLiteral<"pong">;
|
|
351
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
352
|
+
}, "strict", z.ZodTypeAny, {
|
|
353
|
+
v: "1";
|
|
354
|
+
kind: "pong";
|
|
355
|
+
nonce?: string | undefined;
|
|
356
|
+
}, {
|
|
357
|
+
v: "1";
|
|
358
|
+
kind: "pong";
|
|
359
|
+
nonce?: string | undefined;
|
|
360
|
+
}>, z.ZodObject<{
|
|
361
|
+
v: z.ZodLiteral<"1">;
|
|
362
|
+
kind: z.ZodLiteral<"replay-marker">;
|
|
363
|
+
subscriptionId: z.ZodString;
|
|
364
|
+
eventId: z.ZodString;
|
|
365
|
+
droppedCount: z.ZodOptional<z.ZodNumber>;
|
|
366
|
+
note: z.ZodOptional<z.ZodString>;
|
|
367
|
+
}, "strict", z.ZodTypeAny, {
|
|
368
|
+
v: "1";
|
|
369
|
+
subscriptionId: string;
|
|
370
|
+
kind: "replay-marker";
|
|
371
|
+
eventId: string;
|
|
372
|
+
droppedCount?: number | undefined;
|
|
373
|
+
note?: string | undefined;
|
|
374
|
+
}, {
|
|
375
|
+
v: "1";
|
|
376
|
+
subscriptionId: string;
|
|
377
|
+
kind: "replay-marker";
|
|
378
|
+
eventId: string;
|
|
379
|
+
droppedCount?: number | undefined;
|
|
380
|
+
note?: string | undefined;
|
|
381
|
+
}>]>]>;
|
|
382
|
+
/**
|
|
383
|
+
* Inferred TypeScript union for the `ServerMessage` discriminator.
|
|
384
|
+
*
|
|
385
|
+
* @stable
|
|
386
|
+
*/
|
|
387
|
+
type ServerMessage = z.infer<typeof ServerMessageSchema>;
|
|
388
|
+
/**
|
|
389
|
+
* Convenience type aliases for callers that want to reference an
|
|
390
|
+
* individual variant without `z.infer<typeof X>`.
|
|
391
|
+
*
|
|
392
|
+
* @stable
|
|
393
|
+
*/
|
|
394
|
+
type ServerEventFrame = z.infer<typeof EventFrame>;
|
|
395
|
+
/** @stable */
|
|
396
|
+
type ServerLifecycleFrame = z.infer<typeof LifecycleFrame>;
|
|
397
|
+
/** @stable */
|
|
398
|
+
type ServerErrorFrame = z.infer<typeof ErrorFrame>;
|
|
399
|
+
/** @stable */
|
|
400
|
+
type ServerSubscribedFrame = z.infer<typeof SubscribedFrame>;
|
|
401
|
+
/** @stable */
|
|
402
|
+
type ServerUnsubscribedFrame = z.infer<typeof UnsubscribedFrame>;
|
|
403
|
+
/** @stable */
|
|
404
|
+
type ServerPongFrame = z.infer<typeof PongFrame>;
|
|
405
|
+
/** @stable */
|
|
406
|
+
type ServerReplayMarkerFrame = z.infer<typeof ReplayMarkerFrame>;
|
|
407
|
+
/** @stable */
|
|
408
|
+
type ServerRpcSuccess = z.infer<typeof RpcSuccess>;
|
|
409
|
+
/** @stable */
|
|
410
|
+
type ServerRpcFailure = z.infer<typeof RpcFailure>;
|
|
411
|
+
/**
|
|
412
|
+
* Type guard helpers, one per discriminator. The narrow over the
|
|
413
|
+
* `ServerMessage` union without forcing consumers to memorize the
|
|
414
|
+
* exact field names.
|
|
415
|
+
*
|
|
416
|
+
* @stable
|
|
417
|
+
*/
|
|
418
|
+
declare function isEventFrame(message: ServerMessage): message is ServerEventFrame;
|
|
419
|
+
/** @stable */
|
|
420
|
+
declare function isLifecycleFrame(message: ServerMessage): message is ServerLifecycleFrame;
|
|
421
|
+
/** @stable */
|
|
422
|
+
declare function isErrorFrame(message: ServerMessage): message is ServerErrorFrame;
|
|
423
|
+
/** @stable */
|
|
424
|
+
declare function isSubscribedFrame(message: ServerMessage): message is ServerSubscribedFrame;
|
|
425
|
+
/** @stable */
|
|
426
|
+
declare function isUnsubscribedFrame(message: ServerMessage): message is ServerUnsubscribedFrame;
|
|
427
|
+
/** @stable */
|
|
428
|
+
declare function isPongFrame(message: ServerMessage): message is ServerPongFrame;
|
|
429
|
+
/** @stable */
|
|
430
|
+
declare function isReplayMarkerFrame(message: ServerMessage): message is ServerReplayMarkerFrame;
|
|
431
|
+
/** @stable */
|
|
432
|
+
declare function isRpcSuccess(message: ServerMessage): message is ServerRpcSuccess;
|
|
433
|
+
/** @stable */
|
|
434
|
+
declare function isRpcFailure(message: ServerMessage): message is ServerRpcFailure;
|
|
435
|
+
/**
|
|
436
|
+
* Stable JSON-RPC error code catalogue used by the server when
|
|
437
|
+
* surfacing routine failures (per JSON-RPC 2.0 § 5.1 + Graphorin
|
|
438
|
+
* extensions). Application-level errors use codes in the
|
|
439
|
+
* implementation-defined range (`-32000` … `-32099`).
|
|
440
|
+
*
|
|
441
|
+
* @stable
|
|
442
|
+
*/
|
|
443
|
+
declare const RPC_ERROR_CODES: Readonly<{
|
|
444
|
+
readonly PARSE_ERROR: -32700;
|
|
445
|
+
readonly INVALID_REQUEST: -32600;
|
|
446
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
447
|
+
readonly INVALID_PARAMS: -32602;
|
|
448
|
+
readonly INTERNAL_ERROR: -32603;
|
|
449
|
+
readonly AUTH_REQUIRED: -32001;
|
|
450
|
+
readonly AUTH_INVALID: -32002;
|
|
451
|
+
readonly SCOPE_DENIED: -32003;
|
|
452
|
+
readonly RATE_LIMITED: -32004;
|
|
453
|
+
readonly PROTOCOL_VIOLATION: -32005;
|
|
454
|
+
readonly RUN_NOT_FOUND: -32010;
|
|
455
|
+
readonly SUBSCRIPTION_NOT_FOUND: -32011;
|
|
456
|
+
}>;
|
|
457
|
+
//#endregion
|
|
458
|
+
export { RPC_ERROR_CODES, ServerErrorFrame, ServerEventFrame, ServerLifecycleFrame, ServerMessage, ServerMessageSchema, ServerPongFrame, ServerReplayMarkerFrame, ServerRpcFailure, ServerRpcSuccess, ServerSubscribedFrame, ServerUnsubscribedFrame, isErrorFrame, isEventFrame, isLifecycleFrame, isPongFrame, isReplayMarkerFrame, isRpcFailure, isRpcSuccess, isSubscribedFrame, isUnsubscribedFrame };
|
|
459
|
+
//# sourceMappingURL=server-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-message.d.ts","names":[],"sources":["../src/server-message.ts"],"sourcesContent":[],"mappings":";;;;cAiCM,YAAU,CAAA,CAAA;;;;;C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,UAA2B,2BAA2B;;iBAKtD,mBAAA,UAA6B,2BAA2B;;iBAKxD,WAAA,UAAqB,2BAA2B;;iBAKhD,mBAAA,UAA6B,2BAA2B;;iBAKxD,YAAA,UAAsB,2BAA2B;;iBAKjD,YAAA,UAAsB,2BAA2B;;;;;;;;;cAYpD,iBAAe"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/server-message.ts
|
|
4
|
+
/**
|
|
5
|
+
* `ServerMessage` — discriminated union of every frame a Graphorin
|
|
6
|
+
* server may push to a client. Three families share the channel:
|
|
7
|
+
*
|
|
8
|
+
* 1. **RPC responses** (`{ jsonrpc, id, result | error }`) —
|
|
9
|
+
* correlate with a previously-issued client request.
|
|
10
|
+
* 2. **Typed push events** (`{ kind: 'event', subject, type,
|
|
11
|
+
* payload, eventId }`) — the streaming-first data plane;
|
|
12
|
+
* consumers ignore unknown `type` strings per the agent-event
|
|
13
|
+
* extensibility convention.
|
|
14
|
+
* 3. **Asynchronous server frames** (`{ kind: 'lifecycle' | 'error'
|
|
15
|
+
* | 'pong' | 'subscribed' | 'unsubscribed' | 'replay-marker' }`)
|
|
16
|
+
* — server-initiated messages that do not correlate with a
|
|
17
|
+
* single client RPC id.
|
|
18
|
+
*
|
|
19
|
+
* Every frame carries the `v: '1'` literal so future revisions can
|
|
20
|
+
* negotiate forward-compatible additions without a subprotocol bump.
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
const RpcId = z.union([z.string().min(1), z.number().int()]);
|
|
25
|
+
const RpcError = z.object({
|
|
26
|
+
code: z.number().int(),
|
|
27
|
+
message: z.string().min(1),
|
|
28
|
+
data: z.unknown().optional()
|
|
29
|
+
}).strict();
|
|
30
|
+
const RpcSuccess = z.object({
|
|
31
|
+
v: z.literal("1"),
|
|
32
|
+
jsonrpc: z.literal("2.0"),
|
|
33
|
+
id: RpcId,
|
|
34
|
+
result: z.unknown()
|
|
35
|
+
}).strict();
|
|
36
|
+
const RpcFailure = z.object({
|
|
37
|
+
v: z.literal("1"),
|
|
38
|
+
jsonrpc: z.literal("2.0"),
|
|
39
|
+
id: RpcId,
|
|
40
|
+
error: RpcError
|
|
41
|
+
}).strict();
|
|
42
|
+
const SubscribedFrame = z.object({
|
|
43
|
+
v: z.literal("1"),
|
|
44
|
+
kind: z.literal("subscribed"),
|
|
45
|
+
subscriptionId: z.string().min(1),
|
|
46
|
+
subject: z.string().min(1),
|
|
47
|
+
snapshotEventId: z.string().min(1).optional()
|
|
48
|
+
}).strict();
|
|
49
|
+
const UnsubscribedFrame = z.object({
|
|
50
|
+
v: z.literal("1"),
|
|
51
|
+
kind: z.literal("unsubscribed"),
|
|
52
|
+
subscriptionId: z.string().min(1)
|
|
53
|
+
}).strict();
|
|
54
|
+
const EventFrame = z.object({
|
|
55
|
+
v: z.literal("1"),
|
|
56
|
+
kind: z.literal("event"),
|
|
57
|
+
eventId: z.string().min(1),
|
|
58
|
+
subscriptionId: z.string().min(1),
|
|
59
|
+
subject: z.string().min(1),
|
|
60
|
+
type: z.string().min(1),
|
|
61
|
+
payload: z.unknown()
|
|
62
|
+
}).strict();
|
|
63
|
+
const LifecycleFrame = z.object({
|
|
64
|
+
v: z.literal("1"),
|
|
65
|
+
kind: z.literal("lifecycle"),
|
|
66
|
+
subscriptionId: z.string().min(1),
|
|
67
|
+
status: z.enum([
|
|
68
|
+
"running",
|
|
69
|
+
"paused",
|
|
70
|
+
"completed",
|
|
71
|
+
"aborted",
|
|
72
|
+
"failed"
|
|
73
|
+
]),
|
|
74
|
+
reason: z.string().min(1).optional()
|
|
75
|
+
}).strict();
|
|
76
|
+
const ErrorFrame = z.object({
|
|
77
|
+
v: z.literal("1"),
|
|
78
|
+
kind: z.literal("error"),
|
|
79
|
+
code: z.string().min(1),
|
|
80
|
+
message: z.string().min(1),
|
|
81
|
+
fatal: z.boolean().optional(),
|
|
82
|
+
subscriptionId: z.string().min(1).optional(),
|
|
83
|
+
data: z.unknown().optional()
|
|
84
|
+
}).strict();
|
|
85
|
+
const PongFrame = z.object({
|
|
86
|
+
v: z.literal("1"),
|
|
87
|
+
kind: z.literal("pong"),
|
|
88
|
+
nonce: z.string().min(1).optional()
|
|
89
|
+
}).strict();
|
|
90
|
+
const ReplayMarkerFrame = z.object({
|
|
91
|
+
v: z.literal("1"),
|
|
92
|
+
kind: z.literal("replay-marker"),
|
|
93
|
+
subscriptionId: z.string().min(1),
|
|
94
|
+
eventId: z.string().min(1),
|
|
95
|
+
droppedCount: z.number().int().nonnegative().optional(),
|
|
96
|
+
note: z.string().min(1).optional()
|
|
97
|
+
}).strict();
|
|
98
|
+
const KindedFrame = z.discriminatedUnion("kind", [
|
|
99
|
+
SubscribedFrame,
|
|
100
|
+
UnsubscribedFrame,
|
|
101
|
+
EventFrame,
|
|
102
|
+
LifecycleFrame,
|
|
103
|
+
ErrorFrame,
|
|
104
|
+
PongFrame,
|
|
105
|
+
ReplayMarkerFrame
|
|
106
|
+
]);
|
|
107
|
+
const RpcFrame = z.union([RpcSuccess, RpcFailure]);
|
|
108
|
+
/**
|
|
109
|
+
* Zod schema for every legal server → client frame. Validation runs
|
|
110
|
+
* twice in the server pipeline: first when a route handler enqueues
|
|
111
|
+
* the frame onto the dispatcher's send queue (so a malformed frame
|
|
112
|
+
* never escapes the process), then again on the client side to
|
|
113
|
+
* defend against protocol drift.
|
|
114
|
+
*
|
|
115
|
+
* @stable
|
|
116
|
+
*/
|
|
117
|
+
const ServerMessageSchema = z.union([RpcFrame, KindedFrame]);
|
|
118
|
+
/**
|
|
119
|
+
* Type guard helpers, one per discriminator. The narrow over the
|
|
120
|
+
* `ServerMessage` union without forcing consumers to memorize the
|
|
121
|
+
* exact field names.
|
|
122
|
+
*
|
|
123
|
+
* @stable
|
|
124
|
+
*/
|
|
125
|
+
function isEventFrame(message) {
|
|
126
|
+
return "kind" in message && message.kind === "event";
|
|
127
|
+
}
|
|
128
|
+
/** @stable */
|
|
129
|
+
function isLifecycleFrame(message) {
|
|
130
|
+
return "kind" in message && message.kind === "lifecycle";
|
|
131
|
+
}
|
|
132
|
+
/** @stable */
|
|
133
|
+
function isErrorFrame(message) {
|
|
134
|
+
return "kind" in message && message.kind === "error";
|
|
135
|
+
}
|
|
136
|
+
/** @stable */
|
|
137
|
+
function isSubscribedFrame(message) {
|
|
138
|
+
return "kind" in message && message.kind === "subscribed";
|
|
139
|
+
}
|
|
140
|
+
/** @stable */
|
|
141
|
+
function isUnsubscribedFrame(message) {
|
|
142
|
+
return "kind" in message && message.kind === "unsubscribed";
|
|
143
|
+
}
|
|
144
|
+
/** @stable */
|
|
145
|
+
function isPongFrame(message) {
|
|
146
|
+
return "kind" in message && message.kind === "pong";
|
|
147
|
+
}
|
|
148
|
+
/** @stable */
|
|
149
|
+
function isReplayMarkerFrame(message) {
|
|
150
|
+
return "kind" in message && message.kind === "replay-marker";
|
|
151
|
+
}
|
|
152
|
+
/** @stable */
|
|
153
|
+
function isRpcSuccess(message) {
|
|
154
|
+
return "jsonrpc" in message && message.jsonrpc === "2.0" && "result" in message;
|
|
155
|
+
}
|
|
156
|
+
/** @stable */
|
|
157
|
+
function isRpcFailure(message) {
|
|
158
|
+
return "jsonrpc" in message && message.jsonrpc === "2.0" && "error" in message;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Stable JSON-RPC error code catalogue used by the server when
|
|
162
|
+
* surfacing routine failures (per JSON-RPC 2.0 § 5.1 + Graphorin
|
|
163
|
+
* extensions). Application-level errors use codes in the
|
|
164
|
+
* implementation-defined range (`-32000` … `-32099`).
|
|
165
|
+
*
|
|
166
|
+
* @stable
|
|
167
|
+
*/
|
|
168
|
+
const RPC_ERROR_CODES = Object.freeze({
|
|
169
|
+
PARSE_ERROR: -32700,
|
|
170
|
+
INVALID_REQUEST: -32600,
|
|
171
|
+
METHOD_NOT_FOUND: -32601,
|
|
172
|
+
INVALID_PARAMS: -32602,
|
|
173
|
+
INTERNAL_ERROR: -32603,
|
|
174
|
+
AUTH_REQUIRED: -32001,
|
|
175
|
+
AUTH_INVALID: -32002,
|
|
176
|
+
SCOPE_DENIED: -32003,
|
|
177
|
+
RATE_LIMITED: -32004,
|
|
178
|
+
PROTOCOL_VIOLATION: -32005,
|
|
179
|
+
RUN_NOT_FOUND: -32010,
|
|
180
|
+
SUBSCRIPTION_NOT_FOUND: -32011
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
export { RPC_ERROR_CODES, ServerMessageSchema, isErrorFrame, isEventFrame, isLifecycleFrame, isPongFrame, isReplayMarkerFrame, isRpcFailure, isRpcSuccess, isSubscribedFrame, isUnsubscribedFrame };
|
|
185
|
+
//# sourceMappingURL=server-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-message.js","names":[],"sources":["../src/server-message.ts"],"sourcesContent":["/**\n * `ServerMessage` — discriminated union of every frame a Graphorin\n * server may push to a client. Three families share the channel:\n *\n * 1. **RPC responses** (`{ jsonrpc, id, result | error }`) —\n * correlate with a previously-issued client request.\n * 2. **Typed push events** (`{ kind: 'event', subject, type,\n * payload, eventId }`) — the streaming-first data plane;\n * consumers ignore unknown `type` strings per the agent-event\n * extensibility convention.\n * 3. **Asynchronous server frames** (`{ kind: 'lifecycle' | 'error'\n * | 'pong' | 'subscribed' | 'unsubscribed' | 'replay-marker' }`)\n * — server-initiated messages that do not correlate with a\n * single client RPC id.\n *\n * Every frame carries the `v: '1'` literal so future revisions can\n * negotiate forward-compatible additions without a subprotocol bump.\n *\n * @packageDocumentation\n */\n\nimport { z } from 'zod';\n\nconst RpcId = z.union([z.string().min(1), z.number().int()]);\n\nconst RpcError = z\n .object({\n code: z.number().int(),\n message: z.string().min(1),\n data: z.unknown().optional(),\n })\n .strict();\n\nconst RpcSuccess = z\n .object({\n v: z.literal('1'),\n jsonrpc: z.literal('2.0'),\n id: RpcId,\n result: z.unknown(),\n })\n .strict();\n\nconst RpcFailure = z\n .object({\n v: z.literal('1'),\n jsonrpc: z.literal('2.0'),\n id: RpcId,\n error: RpcError,\n })\n .strict();\n\nconst SubscribedFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('subscribed'),\n subscriptionId: z.string().min(1),\n subject: z.string().min(1),\n snapshotEventId: z.string().min(1).optional(),\n })\n .strict();\n\nconst UnsubscribedFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('unsubscribed'),\n subscriptionId: z.string().min(1),\n })\n .strict();\n\nconst EventFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('event'),\n eventId: z.string().min(1),\n subscriptionId: z.string().min(1),\n subject: z.string().min(1),\n type: z.string().min(1),\n payload: z.unknown(),\n })\n .strict();\n\nconst LifecycleFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('lifecycle'),\n subscriptionId: z.string().min(1),\n status: z.enum(['running', 'paused', 'completed', 'aborted', 'failed']),\n reason: z.string().min(1).optional(),\n })\n .strict();\n\nconst ErrorFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('error'),\n code: z.string().min(1),\n message: z.string().min(1),\n fatal: z.boolean().optional(),\n subscriptionId: z.string().min(1).optional(),\n data: z.unknown().optional(),\n })\n .strict();\n\nconst PongFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('pong'),\n nonce: z.string().min(1).optional(),\n })\n .strict();\n\nconst ReplayMarkerFrame = z\n .object({\n v: z.literal('1'),\n kind: z.literal('replay-marker'),\n subscriptionId: z.string().min(1),\n eventId: z.string().min(1),\n droppedCount: z.number().int().nonnegative().optional(),\n note: z.string().min(1).optional(),\n })\n .strict();\n\nconst KindedFrame = z.discriminatedUnion('kind', [\n SubscribedFrame,\n UnsubscribedFrame,\n EventFrame,\n LifecycleFrame,\n ErrorFrame,\n PongFrame,\n ReplayMarkerFrame,\n]);\n\nconst RpcFrame = z.union([RpcSuccess, RpcFailure]);\n\n/**\n * Zod schema for every legal server → client frame. Validation runs\n * twice in the server pipeline: first when a route handler enqueues\n * the frame onto the dispatcher's send queue (so a malformed frame\n * never escapes the process), then again on the client side to\n * defend against protocol drift.\n *\n * @stable\n */\nexport const ServerMessageSchema = z.union([RpcFrame, KindedFrame]);\n\n/**\n * Inferred TypeScript union for the `ServerMessage` discriminator.\n *\n * @stable\n */\nexport type ServerMessage = z.infer<typeof ServerMessageSchema>;\n\n/**\n * Convenience type aliases for callers that want to reference an\n * individual variant without `z.infer<typeof X>`.\n *\n * @stable\n */\nexport type ServerEventFrame = z.infer<typeof EventFrame>;\n/** @stable */\nexport type ServerLifecycleFrame = z.infer<typeof LifecycleFrame>;\n/** @stable */\nexport type ServerErrorFrame = z.infer<typeof ErrorFrame>;\n/** @stable */\nexport type ServerSubscribedFrame = z.infer<typeof SubscribedFrame>;\n/** @stable */\nexport type ServerUnsubscribedFrame = z.infer<typeof UnsubscribedFrame>;\n/** @stable */\nexport type ServerPongFrame = z.infer<typeof PongFrame>;\n/** @stable */\nexport type ServerReplayMarkerFrame = z.infer<typeof ReplayMarkerFrame>;\n/** @stable */\nexport type ServerRpcSuccess = z.infer<typeof RpcSuccess>;\n/** @stable */\nexport type ServerRpcFailure = z.infer<typeof RpcFailure>;\n\n/**\n * Type guard helpers, one per discriminator. The narrow over the\n * `ServerMessage` union without forcing consumers to memorize the\n * exact field names.\n *\n * @stable\n */\nexport function isEventFrame(message: ServerMessage): message is ServerEventFrame {\n return 'kind' in message && message.kind === 'event';\n}\n\n/** @stable */\nexport function isLifecycleFrame(message: ServerMessage): message is ServerLifecycleFrame {\n return 'kind' in message && message.kind === 'lifecycle';\n}\n\n/** @stable */\nexport function isErrorFrame(message: ServerMessage): message is ServerErrorFrame {\n return 'kind' in message && message.kind === 'error';\n}\n\n/** @stable */\nexport function isSubscribedFrame(message: ServerMessage): message is ServerSubscribedFrame {\n return 'kind' in message && message.kind === 'subscribed';\n}\n\n/** @stable */\nexport function isUnsubscribedFrame(message: ServerMessage): message is ServerUnsubscribedFrame {\n return 'kind' in message && message.kind === 'unsubscribed';\n}\n\n/** @stable */\nexport function isPongFrame(message: ServerMessage): message is ServerPongFrame {\n return 'kind' in message && message.kind === 'pong';\n}\n\n/** @stable */\nexport function isReplayMarkerFrame(message: ServerMessage): message is ServerReplayMarkerFrame {\n return 'kind' in message && message.kind === 'replay-marker';\n}\n\n/** @stable */\nexport function isRpcSuccess(message: ServerMessage): message is ServerRpcSuccess {\n return 'jsonrpc' in message && message.jsonrpc === '2.0' && 'result' in message;\n}\n\n/** @stable */\nexport function isRpcFailure(message: ServerMessage): message is ServerRpcFailure {\n return 'jsonrpc' in message && message.jsonrpc === '2.0' && 'error' in message;\n}\n\n/**\n * Stable JSON-RPC error code catalogue used by the server when\n * surfacing routine failures (per JSON-RPC 2.0 § 5.1 + Graphorin\n * extensions). Application-level errors use codes in the\n * implementation-defined range (`-32000` … `-32099`).\n *\n * @stable\n */\nexport const RPC_ERROR_CODES = Object.freeze({\n PARSE_ERROR: -32700,\n INVALID_REQUEST: -32600,\n METHOD_NOT_FOUND: -32601,\n INVALID_PARAMS: -32602,\n INTERNAL_ERROR: -32603,\n AUTH_REQUIRED: -32001,\n AUTH_INVALID: -32002,\n SCOPE_DENIED: -32003,\n RATE_LIMITED: -32004,\n PROTOCOL_VIOLATION: -32005,\n RUN_NOT_FOUND: -32010,\n SUBSCRIPTION_NOT_FOUND: -32011,\n} as const);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;AAE5D,MAAM,WAAW,EACd,OAAO;CACN,MAAM,EAAE,QAAQ,CAAC,KAAK;CACtB,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC1B,MAAM,EAAE,SAAS,CAAC,UAAU;CAC7B,CAAC,CACD,QAAQ;AAEX,MAAM,aAAa,EAChB,OAAO;CACN,GAAG,EAAE,QAAQ,IAAI;CACjB,SA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