cspell-lib 9.6.1 → 9.6.3

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.
@@ -1,364 +0,0 @@
1
- import { AbortRPCRequestError, CanceledRPCRequestError, TimeoutRPCRequestError } from './errors.js';
2
- import { Future } from './Future.js';
3
- import { MessagePortNotifyEvents } from './MessagePortEvents.js';
4
- import { createRPCCancelRequest, createRPCMethodRequest, createRPCOkRequest, createRPCReadyRequest, isBaseResponse, isRPCCanceledResponse, isRPCErrorResponse, isRPCReadyResponse, isRPCResponse, } from './modelsHelpers.js';
5
- const DefaultOkOptions = {
6
- timeoutMs: 200,
7
- };
8
- /**
9
- * The RPC Client.
10
- */
11
- class RPCClientImpl {
12
- #port;
13
- #count = 0;
14
- #options;
15
- #pendingRequests = new Map();
16
- #pendingRequestsByPromise = new WeakMap();
17
- #defaultTimeoutMs;
18
- #isReady;
19
- #ready;
20
- /**
21
- * Create an RPC Client.
22
- * @param config - The client configuration.
23
- */
24
- constructor(config) {
25
- this.#port = new MessagePortNotifyEvents(config.port);
26
- this.#options = config;
27
- this.#defaultTimeoutMs = config.timeoutMs;
28
- this.#isReady = false;
29
- this.#ready = new Future();
30
- this.#port.onMessage((msg) => this.#processMessageFromServer(msg));
31
- this.#port.start();
32
- }
33
- /**
34
- * Make a request to the RPC server.
35
- *
36
- * It is unlikely you need to use this method directly. Consider using `call` or `getApi` instead.
37
- *
38
- * @param method - The method name.
39
- * @param params - The method parameters.
40
- * @param options - Request options including abort signal and timeout.
41
- * @returns The pending client request.
42
- */
43
- request(method, params, options) {
44
- // Register the request.
45
- const id = this.#calcId(method);
46
- const request = createRPCMethodRequest(id, method, params);
47
- const pendingRequest = this.#sendRequest(request, options);
48
- const response = pendingRequest.response.then(handleResponse);
49
- // Record the promise to request ID mapping.
50
- this.#pendingRequestsByPromise.set(response, id);
51
- const clientRequest = {
52
- id,
53
- method,
54
- response,
55
- abort: pendingRequest.abort,
56
- cancel: pendingRequest.cancel,
57
- get isResolved() {
58
- return pendingRequest.isResolved;
59
- },
60
- get isCanceled() {
61
- return pendingRequest.isCanceled;
62
- },
63
- };
64
- return clientRequest;
65
- function handleResponse(res) {
66
- if (isRPCErrorResponse(res)) {
67
- throw res.error;
68
- }
69
- if (isRPCCanceledResponse(res)) {
70
- throw new CanceledRPCRequestError(`Request ${id} was canceled`);
71
- }
72
- if (isRPCResponse(res)) {
73
- return res.result;
74
- }
75
- throw new Error(`Malformed response for request ${id}`); // Should not happen.
76
- }
77
- }
78
- #sendRequest(request, options = {}) {
79
- // Register the request.
80
- const id = request.id;
81
- const requestType = request.type;
82
- let isResolved = false;
83
- let isCanceled = false;
84
- const timeoutMs = options.timeoutMs ?? this.#defaultTimeoutMs;
85
- const timeoutSignal = timeoutMs ? AbortSignal.timeout(timeoutMs) : undefined;
86
- const future = new Future();
87
- options.signal?.addEventListener('abort', abort);
88
- timeoutSignal?.addEventListener('abort', timeoutHandler);
89
- const response = future.promise;
90
- const cancelRequest = () => this.#port.postMessage(createRPCCancelRequest(id));
91
- const cancel = async () => {
92
- if (isResolved || isCanceled)
93
- return isCanceled;
94
- cancelRequest();
95
- await response.catch(() => { });
96
- return isCanceled;
97
- };
98
- const pendingRequest = {
99
- id,
100
- request,
101
- response,
102
- handleResponse,
103
- abort,
104
- cancel,
105
- get isResolved() {
106
- return isResolved;
107
- },
108
- get isCanceled() {
109
- return isCanceled;
110
- },
111
- };
112
- this.#pendingRequests.set(id, pendingRequest);
113
- this.#pendingRequestsByPromise.set(response, id);
114
- const cleanup = () => {
115
- options.signal?.removeEventListener('abort', abort);
116
- timeoutSignal?.removeEventListener('abort', timeoutHandler);
117
- this.#cleanupPendingRequest(pendingRequest);
118
- };
119
- this.#port.postMessage(request);
120
- return pendingRequest;
121
- function timeoutHandler() {
122
- abort(new TimeoutRPCRequestError(`Request ${requestType} ${id} timed out after ${timeoutMs} ms`));
123
- }
124
- function abort(reason) {
125
- if (isResolved || isCanceled)
126
- return;
127
- isCanceled = true;
128
- cancelRequest();
129
- reason = reason instanceof Event ? undefined : reason;
130
- reason ??= `Request ${id} aborted`;
131
- reason = typeof reason === 'string' ? new AbortRPCRequestError(reason) : reason;
132
- cleanup();
133
- future.reject(reason);
134
- }
135
- function handleResponse(res) {
136
- // Do not process anything if already resolved or canceled.
137
- if (isResolved || isCanceled)
138
- return;
139
- isResolved = true;
140
- if (isRPCCanceledResponse(res)) {
141
- isCanceled = true;
142
- }
143
- cleanup();
144
- future.resolve(res);
145
- }
146
- }
147
- /**
148
- * Check the health of the RPC server.
149
- * @param options - used to set timeout and abort signal.
150
- * @returns resolves to true if the server is OK, false on timeout.
151
- */
152
- async isOK(options = DefaultOkOptions) {
153
- try {
154
- const req = this.#sendRequest(createRPCOkRequest(this.#calcId('isOK')), options);
155
- const res = await req.response;
156
- return isBaseResponse(res) && res.type === 'ok' && res.code === 200;
157
- }
158
- catch {
159
- return false;
160
- }
161
- }
162
- /**
163
- * The current known ready state of the RPC server.
164
- * - `true` - The server is ready.
165
- * - `false` - The server is not ready.
166
- */
167
- get isReady() {
168
- return this.#isReady;
169
- }
170
- /**
171
- * Check if the RPC server is ready. If already ready, returns true immediately.
172
- * If not ready, sends a 'ready' request to the server.
173
- * @param options - used to set timeout and abort signal.
174
- * @returns resolves to true when the server is ready, rejects if the request times out or fails.
175
- */
176
- async ready(options) {
177
- if (this.#isReady)
178
- return true;
179
- // We send the request, but we do not care about the result other than it succeeded.
180
- await this.#sendRequest(createRPCReadyRequest(this.#calcId('ready')), options).response;
181
- return this.#isReady; // We are returning the current state.
182
- }
183
- /**
184
- * Call a method on the RPC server.
185
- * @param method - The method name.
186
- * @param params - The method parameters.
187
- * @param options - Call options including abort signal.
188
- * @returns A Promise with the method result.
189
- */
190
- call(method, params, options) {
191
- const req = this.request(method, params, options);
192
- return req.response;
193
- }
194
- /**
195
- * Get the API for the given method names.
196
- *
197
- * This is useful passing the API to other parts of the code that do not need to know about the RPCClient.
198
- *
199
- * @param methods - The method names to include in the API.
200
- * @returns A partial API with the requested methods.
201
- */
202
- getApi(methods) {
203
- const apiEntries = methods.map((method) => [method, ((...params) => this.call(method, params))]);
204
- return Object.fromEntries(apiEntries);
205
- }
206
- /**
207
- * Get info about a pending request by its RequestID.
208
- * @param id - The RequestID of the pending request.
209
- * @returns The found pending request or undefined if not found.
210
- */
211
- getPendingRequestById(id) {
212
- return this.#pendingRequests.get(id);
213
- }
214
- /**
215
- * Get info about a pending request by the promise returned using `call` or an api method.
216
- * @param id - The RequestID of the pending request.
217
- * @returns The found pending request or undefined if not found.
218
- */
219
- getPendingRequestByPromise(promise) {
220
- const requestId = this.#pendingRequestsByPromise.get(promise);
221
- if (!requestId)
222
- return undefined;
223
- return this.getPendingRequestById(requestId);
224
- }
225
- /**
226
- * Get the number of pending requests.
227
- */
228
- get length() {
229
- return this.#pendingRequests.size;
230
- }
231
- #calcId(method) {
232
- const suffix = this.#options.randomUUID ? this.#options.randomUUID() : `${performance.now()}`;
233
- return `${method}-${++this.#count}-${suffix}`;
234
- }
235
- #cleanupPendingRequest(request) {
236
- this.#pendingRequests.delete(request.id);
237
- this.#pendingRequestsByPromise.delete(request.response);
238
- }
239
- #processMessageFromServer(msg) {
240
- // Ignore messages that are not RPC messages
241
- if (!isBaseResponse(msg))
242
- return;
243
- this.#handleReadyResponse(msg);
244
- const pendingRequest = this.#pendingRequests.get(msg.id);
245
- if (!pendingRequest)
246
- return;
247
- pendingRequest.handleResponse(msg);
248
- }
249
- /**
250
- * Handle possible ready response messages.
251
- * @param msg - The message to handle.
252
- */
253
- #handleReadyResponse(msg) {
254
- if (!isRPCReadyResponse(msg))
255
- return;
256
- if (this.#ready.isResolved)
257
- return;
258
- this.#isReady = msg.code === 200;
259
- this.#ready.resolve(this.#isReady);
260
- }
261
- /**
262
- * Abort a pending request by its promise.
263
- *
264
- * Note: the request promise will be rejected with an AbortRequestError.
265
- * @param promise - The promise returned by the request.
266
- * @param reason - The reason for aborting the request.
267
- * @returns True if the request was found and aborted, false otherwise.
268
- */
269
- abortPromise(promise, reason) {
270
- const pendingRequest = this.getPendingRequestByPromise(promise);
271
- if (!pendingRequest)
272
- return false;
273
- return this.abortRequest(pendingRequest.id, reason);
274
- }
275
- /**
276
- * Abort a pending request by its RequestId.
277
- *
278
- * Note: the request promise will be rejected with an AbortRequestError.
279
- * @param requestId - The RequestID of the request to abort.
280
- * @param reason - The reason for aborting the request.
281
- * @returns True if the request was found and aborted, false otherwise.
282
- */
283
- abortRequest(requestId, reason) {
284
- const pendingRequest = this.getPendingRequestById(requestId);
285
- if (!pendingRequest)
286
- return false;
287
- pendingRequest.abort(reason);
288
- return true;
289
- }
290
- /**
291
- * Abort all pending requests.
292
- *
293
- * Note: each request promise will be rejected with an AbortRequestError.
294
- *
295
- * @param reason - The reason for aborting the request.
296
- */
297
- abortAllRequests(reason) {
298
- for (const pendingRequest of this.#pendingRequests.values()) {
299
- try {
300
- pendingRequest.abort(reason);
301
- }
302
- catch {
303
- // ignore
304
- }
305
- }
306
- }
307
- /**
308
- * Cancel a pending request by its RequestID.
309
- *
310
- * Tries to cancel the request by sending a cancel request to the server and waiting for the response.
311
- * @param id - The RequestID of the request to cancel.
312
- * @returns resolves to true if the request was found and canceled, false otherwise.
313
- */
314
- async cancelRequest(id) {
315
- const pendingRequest = this.getPendingRequestById(id);
316
- if (!pendingRequest)
317
- return false;
318
- return await pendingRequest.cancel();
319
- }
320
- /**
321
- * Cancel a pending request by its Promise.
322
- *
323
- * Tries to cancel the request by sending a cancel request to the server and waiting for the response.
324
- * @param id - The RequestID of the request to cancel.
325
- * @returns resolves to true if the request was found and canceled, false otherwise.
326
- */
327
- async cancelPromise(promise) {
328
- const request = this.getPendingRequestByPromise(promise);
329
- if (!request)
330
- return false;
331
- return this.cancelRequest(request.id);
332
- }
333
- /**
334
- * Set the default timeout for requests. Requests can override this value.
335
- * @param timeoutMs - the timeout in milliseconds
336
- */
337
- setTimeout(timeoutMs) {
338
- this.#defaultTimeoutMs = timeoutMs;
339
- }
340
- /**
341
- * Dispose of the RPC client, aborting all pending requests and closing the port if specified in options.
342
- */
343
- [Symbol.dispose]() {
344
- this.abortAllRequests(new Error('RPC Client disposed'));
345
- this.#pendingRequests.clear();
346
- if (this.#options.closePortOnDispose) {
347
- this.#port.close();
348
- }
349
- this.#port[Symbol.dispose]();
350
- }
351
- }
352
- /**
353
- * The RPC Client.
354
- */
355
- export class RPCClient extends RPCClientImpl {
356
- /**
357
- * Create an RPC Client.
358
- * @param config - The client configuration.
359
- */
360
- constructor(config) {
361
- super(config);
362
- }
363
- }
364
- //# sourceMappingURL=client.js.map
@@ -1,24 +0,0 @@
1
- export declare class RPCRequestError extends Error {
2
- constructor(message: string);
3
- }
4
- export declare class AbortRPCRequestError extends RPCRequestError {
5
- constructor(message: string);
6
- }
7
- export declare class TimeoutRPCRequestError extends RPCRequestError {
8
- constructor(message: string);
9
- }
10
- export declare class UnknownMethodRPCRequestError extends RPCRequestError {
11
- method: string;
12
- constructor(method: string, message?: string);
13
- }
14
- export declare class MalformedRPCRequestError extends RPCRequestError {
15
- request?: unknown;
16
- constructor(message: string, request?: unknown);
17
- }
18
- export declare class CanceledRPCRequestError extends RPCRequestError {
19
- constructor(message?: string);
20
- }
21
- export declare class AlreadyDisposedError extends Error {
22
- constructor();
23
- }
24
- //# sourceMappingURL=errors.d.ts.map
@@ -1,47 +0,0 @@
1
- export class RPCRequestError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'RPCRequestError';
5
- }
6
- }
7
- export class AbortRPCRequestError extends RPCRequestError {
8
- constructor(message) {
9
- super(message);
10
- this.name = 'AbortRPCRequestError';
11
- }
12
- }
13
- export class TimeoutRPCRequestError extends RPCRequestError {
14
- constructor(message) {
15
- super(message);
16
- this.name = 'TimeoutRPCRequestError';
17
- }
18
- }
19
- export class UnknownMethodRPCRequestError extends RPCRequestError {
20
- method;
21
- constructor(method, message) {
22
- super(message || `Unknown method: ${method}`);
23
- this.name = 'UnknownMethodRPCRequestError';
24
- this.method = method;
25
- }
26
- }
27
- export class MalformedRPCRequestError extends RPCRequestError {
28
- request;
29
- constructor(message, request) {
30
- super(message);
31
- this.name = 'MalformedRPCRequestError';
32
- this.request = request;
33
- }
34
- }
35
- export class CanceledRPCRequestError extends RPCRequestError {
36
- constructor(message) {
37
- super(message ?? 'The RPC request was canceled');
38
- this.name = 'CanceledRPCRequestError';
39
- }
40
- }
41
- export class AlreadyDisposedError extends Error {
42
- constructor() {
43
- super('NotifyEmitter has been disposed.');
44
- this.name = 'AlreadyDisposedError';
45
- }
46
- }
47
- //# sourceMappingURL=errors.js.map
@@ -1,11 +0,0 @@
1
- export type { RPCClientConfiguration, RPCClientOptions } from './client.js';
2
- export { RPCClient } from './client.js';
3
- export { AbortRPCRequestError, CanceledRPCRequestError, RPCRequestError, TimeoutRPCRequestError, UnknownMethodRPCRequestError, } from './errors.js';
4
- export type { MessagePortLike } from './messagePort.js';
5
- export type { NotifyEvent, NotifyHandler, NotifyOnceEvent } from './notify.js';
6
- export { NotifyEmitter, notifyEventOnce, notifyEventToPromise } from './notify.js';
7
- export type { RPCProtocol, RPCProtocolMethods } from './protocol.js';
8
- export { protocolDefinition, protocolMethods } from './protocol.js';
9
- export type { RPCServerConfiguration, RPCServerOptions } from './server.js';
10
- export { RPCServer } from './server.js';
11
- //# sourceMappingURL=index.d.ts.map
package/dist/rpc/index.js DELETED
@@ -1,6 +0,0 @@
1
- export { RPCClient } from './client.js';
2
- export { AbortRPCRequestError, CanceledRPCRequestError, RPCRequestError, TimeoutRPCRequestError, UnknownMethodRPCRequestError, } from './errors.js';
3
- export { NotifyEmitter, notifyEventOnce, notifyEventToPromise } from './notify.js';
4
- export { protocolDefinition, protocolMethods } from './protocol.js';
5
- export { RPCServer } from './server.js';
6
- //# sourceMappingURL=index.js.map
@@ -1,34 +0,0 @@
1
- export interface MessagePortLike {
2
- /**
3
- * Sends a message to the port.
4
- * @param message - anything supported by postMessage
5
- */
6
- postMessage(message: unknown): void;
7
- /**
8
- * Sets a function to handle the 'close' event.
9
- */
10
- addListener(event: 'close', listener: (ev: Event) => void): this;
11
- /**
12
- * Sets a function to handle messages received on the port.
13
- * Set to undefined to remove the handler.
14
- */
15
- addListener(event: 'message', listener: (value: unknown) => void): this;
16
- /**
17
- * Sets a function to handle message errors received on the port.
18
- * Set to undefined to remove the handler.
19
- */
20
- addListener(event: 'messageerror', listener: (error: Error) => void): this;
21
- removeListener(event: 'close', listener: (ev: Event) => void, options?: EventListenerOptions): this;
22
- removeListener(event: 'message', listener: (value: unknown) => void, options?: EventListenerOptions): this;
23
- removeListener(event: 'messageerror', listener: (error: Error) => void, options?: EventListenerOptions): this;
24
- /**
25
- * Closes the port and stops it from receiving messages.
26
- */
27
- close?: () => void;
28
- /**
29
- * Start receiving messages on the port.
30
- * Note: Some MessagePort implementations may start automatically.
31
- */
32
- start?: () => void;
33
- }
34
- //# sourceMappingURL=messagePort.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=messagePort.js.map
@@ -1,134 +0,0 @@
1
- /**
2
- * A Unique identifier for the request/response.
3
- */
4
- export type RequestID = number | string;
5
- export type ResponseCode = 0 | 200 | 400 | 408 | 500 | 503;
6
- /**
7
- * A base RPC Message.
8
- */
9
- export interface RPCMessage {
10
- /**
11
- * A signature to identify the message as an RPC message.
12
- */
13
- sig: 'RPC0';
14
- /**
15
- * The server Identifier used to identify the server instance.
16
- * This allows multiple servers with different protocols to share the same communication channel.
17
- */
18
- sid?: string;
19
- /**
20
- * A Unique identifier for the request/response.
21
- */
22
- id: RequestID;
23
- /**
24
- * The type of message being sent.
25
- */
26
- type: 'request' | 'response' | 'cancel' | 'canceled' | 'ok' | 'ready';
27
- }
28
- export interface RCPBaseRequest extends RPCMessage {
29
- /**
30
- * The type of message being sent.
31
- */
32
- type: 'request' | 'cancel' | 'ok' | 'ready';
33
- }
34
- export interface RPCResponse extends RPCMessage {
35
- /**
36
- * The type of message being sent.
37
- */
38
- type: 'response' | 'canceled' | 'ok' | 'ready';
39
- code: ResponseCode;
40
- result?: unknown;
41
- error?: RPCError | undefined;
42
- }
43
- /**
44
- * A message to check if the server is running.
45
- */
46
- export interface RPCOkRequestMessage extends RCPBaseRequest {
47
- /**
48
- * The type of message being sent.
49
- */
50
- type: 'ok';
51
- }
52
- /**
53
- * A message to check if the server is running.
54
- */
55
- export interface RPCOkResponseMessage extends RPCResponse {
56
- type: 'ok';
57
- }
58
- /**
59
- * A message send from a client to request if the server is ready.
60
- * This can be sent once or multiple times. It allows for multiple clients
61
- * to wait for the server to be ready. When the server is ready it will respond
62
- * with a `RPCReadyResponseMessage`.
63
- *
64
- * This is useful when the server takes some time to initialize and clients
65
- * need to wait for it to be ready before sending other requests.
66
- *
67
- */
68
- export interface RPCReadyRequestMessage extends RCPBaseRequest {
69
- /**
70
- * The type of message being sent.
71
- */
72
- type: 'ready';
73
- }
74
- /**
75
- * A response message send to the client when the server is ready.
76
- * This is sent once when the server is initialized or upon request.
77
- *
78
- * This allows clients to know when the server is ready to accept requests.
79
- */
80
- export interface RPCReadyResponseMessage extends RPCResponse {
81
- type: 'ready';
82
- }
83
- /**
84
- * A message to request a method call.
85
- */
86
- export interface RPCRequestMessage<TParams = unknown> extends RCPBaseRequest {
87
- type: 'request';
88
- method: string;
89
- params: TParams;
90
- }
91
- /**
92
- * A message to cancel a request.
93
- */
94
- export interface RPCCancelRequestMessage extends RCPBaseRequest {
95
- type: 'cancel';
96
- }
97
- /**
98
- * The response to a cancel request.
99
- */
100
- export interface RPCCanceledResponseMessage extends RPCResponse {
101
- type: 'canceled';
102
- }
103
- /**
104
- * The response message for a request from the server.
105
- */
106
- export interface RPCResponseMessage<TResult = unknown> extends RPCResponse {
107
- type: 'response';
108
- result: TResult;
109
- error?: undefined;
110
- }
111
- /**
112
- * The error information for a failed request.
113
- */
114
- export interface RequestError {
115
- message: string;
116
- cause?: unknown;
117
- }
118
- export type RPCError = RequestError | Error;
119
- export interface RPCErrorResponseMessage extends RPCResponse {
120
- id: RequestID;
121
- type: 'response';
122
- error: RPCError;
123
- }
124
- export interface RPCPendingClientRequest<Method extends string, TResult extends Promise<unknown>> {
125
- readonly id: RequestID;
126
- readonly response: TResult;
127
- readonly isResolved: boolean;
128
- readonly isCanceled: boolean;
129
- /** calling abort will cancel the request if it has not already been resolved. */
130
- abort: AbortController['abort'];
131
- cancel: () => Promise<boolean>;
132
- readonly method: Method;
133
- }
134
- //# sourceMappingURL=models.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=models.js.map
@@ -1,56 +0,0 @@
1
- import type { RCPBaseRequest, RequestID, ResponseCode, RPCCanceledResponseMessage, RPCCancelRequestMessage, RPCError, RPCErrorResponseMessage, RPCMessage, RPCOkRequestMessage, RPCOkResponseMessage, RPCReadyRequestMessage, RPCReadyResponseMessage, RPCRequestMessage, RPCResponse, RPCResponseMessage } from './models.js';
2
- export declare function isRPCBaseMessage(message: unknown): message is RPCMessage;
3
- export declare function isBaseRequest(message: RPCMessage): message is RCPBaseRequest;
4
- export declare function isBaseResponse(message: unknown): message is RPCResponse;
5
- export declare function isRPCErrorResponse(response: unknown): response is RPCErrorResponseMessage;
6
- export declare function isRPCCancelRequest(request: RPCMessage): request is RPCCancelRequestMessage;
7
- export declare function isRPCCanceledResponse(response: RPCResponse): response is RPCCanceledResponseMessage;
8
- export declare function isRPCOkRequest(request: RPCMessage): request is RPCOkRequestMessage;
9
- export declare function isRPCOkResponse(response: RPCMessage): response is RPCOkResponseMessage;
10
- export declare function isRPCReadyRequest(request: RPCMessage): request is RPCReadyRequestMessage;
11
- export declare function isRPCReadyResponse(response: RPCMessage): response is RPCReadyResponseMessage;
12
- export declare function isRPCResponse<TResult>(response: RPCMessage): response is RPCResponseMessage<TResult>;
13
- export declare function isRPCRequest<P>(message: RPCMessage): message is RPCRequestMessage<P>;
14
- /**
15
- * Creates a RPC Request Message.
16
- * @param id - The unique request identifier.
17
- * @param method - The method name.
18
- * @param params - The parameters for the request.
19
- * @returns A RPC Request Message.
20
- */
21
- export declare function createRPCMethodRequest<P>(id: RequestID, method: string, params: P): RPCRequestMessage<P>;
22
- /**
23
- * Creates a cancel request message.
24
- * @param id - The request ID to be canceled.
25
- * @returns A cancel request message.
26
- */
27
- export declare function createRPCCancelRequest(id: RequestID): RPCCancelRequestMessage;
28
- /**
29
- * Creates a cancel request message.
30
- * @param id - The request ID to be canceled.
31
- * @param code - The response code
32
- * - 200 (ok) - if canceled successfully upon request.
33
- * - 408 (timeout) - if the cancellation was initiated by the server.
34
- * - 503 (unavailable) - if the server is shutting down.
35
- * @returns A cancel request message.
36
- */
37
- export declare function createRPCCanceledResponse(id: RequestID, code: ResponseCode): RPCCanceledResponseMessage;
38
- /**
39
- * Creates a RPC Response Message.
40
- * @param id - The matching request ID.
41
- * @param result - the result of the request.
42
- * @returns A RPC Response Message.
43
- */
44
- export declare function createRPCResponse<TResult>(id: RequestID, result: TResult, code: ResponseCode): RPCResponseMessage<TResult>;
45
- /**
46
- * Creates a RPC Error Message.
47
- * @param id - The matching request ID for which the error occurred.
48
- * @param error - The error information.
49
- * @returns A RPC Error Message.
50
- */
51
- export declare function createRPCError(id: RequestID, error: RPCError, code: ResponseCode): RPCErrorResponseMessage;
52
- export declare function createRPCOkRequest(id: RequestID): RPCOkRequestMessage;
53
- export declare function createRPCOkResponse(id: RequestID, code: ResponseCode): RPCOkResponseMessage;
54
- export declare function createRPCReadyRequest(id: RequestID): RPCReadyRequestMessage;
55
- export declare function createRPCReadyResponse(id: RequestID, code: ResponseCode): RPCReadyResponseMessage;
56
- //# sourceMappingURL=modelsHelpers.d.ts.map