Start JSON-RPC messages with 'jsonrpc' and 'id' fields, instead of the other way around
This commit is contained in:
parent
ecbcb8d591
commit
8b476ddc85
1 changed files with 35 additions and 23 deletions
20
src/types.ts
20
src/types.ts
|
|
@ -59,17 +59,23 @@ export const RequestIdSchema = z.union([z.string(), z.number().int()]);
|
|||
/**
|
||||
* A request that expects a response.
|
||||
*/
|
||||
export const JSONRPCRequestSchema = RequestSchema.extend({
|
||||
jsonrpc: z.literal(JSONRPC_VERSION),
|
||||
id: RequestIdSchema,
|
||||
}).strict();
|
||||
export const JSONRPCRequestSchema = z
|
||||
.object({
|
||||
jsonrpc: z.literal(JSONRPC_VERSION),
|
||||
id: RequestIdSchema,
|
||||
})
|
||||
.merge(RequestSchema)
|
||||
.strict();
|
||||
|
||||
/**
|
||||
* A notification which does not expect a response.
|
||||
*/
|
||||
export const JSONRPCNotificationSchema = NotificationSchema.extend({
|
||||
jsonrpc: z.literal(JSONRPC_VERSION),
|
||||
}).strict();
|
||||
export const JSONRPCNotificationSchema = z
|
||||
.object({
|
||||
jsonrpc: z.literal(JSONRPC_VERSION),
|
||||
})
|
||||
.merge(NotificationSchema)
|
||||
.strict();
|
||||
|
||||
/**
|
||||
* A successful (non-error) response to a request.
|
||||
|
|
|
|||
Loading…
Reference in a new issue