libshv-js 7.0.15 → 7.1.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.
@@ -1,4 +1,4 @@
1
- import { type RpcMessage, type ErrorMap } from './rpcmessage';
1
+ import { type RpcMessage, type RpcRequest, type ErrorMap } from './rpcmessage';
2
2
  import { type RpcValue, type Null, type Int, type IMap, type ShvMap } from './rpcvalue';
3
3
  import { RIGetter } from './utils';
4
4
  type SubscriptionCallback = (path: string, signal: string, param?: RpcValue) => void;
@@ -208,6 +208,7 @@ declare class RpcRequestPromise<Result> extends Promise<Result> {
208
208
  export type CallRpcMethodOptions = {
209
209
  delayCallback?: (progress: number) => void;
210
210
  requestUserId?: boolean;
211
+ beforeSendHook?: (rpcMessage: RpcRequest) => RpcRequest;
211
212
  };
212
213
  declare enum ShvApiVersion {
213
214
  V2 = 0,
package/dist/ws-client.js CHANGED
@@ -391,9 +391,12 @@ class WsClient {
391
391
  [rpcmessage_1.RPC_MESSAGE_SHV_PATH]: shvPath ?? '',
392
392
  ...(options?.requestUserId === true ? { [rpcmessage_1.RPC_MESSAGE_USER_ID]: '' } : {}),
393
393
  }), value);
394
- const rq = makeRq((0, rpcvalue_1.makeIMap)({
394
+ let rq = makeRq((0, rpcvalue_1.makeIMap)({
395
395
  [rpcmessage_1.RPC_MESSAGE_PARAMS]: params,
396
396
  }));
397
+ if (options?.beforeSendHook !== undefined) {
398
+ rq = options.beforeSendHook(rq);
399
+ }
397
400
  this.sendRpcMessage(rq);
398
401
  const promise = new RpcRequestPromise(resolve => {
399
402
  this.rpcHandlers[rqId] = { resolve, timeout_handle: makeTimeout(this.timeout, resolve), delayCallback: options?.delayCallback };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "7.0.15",
3
+ "version": "7.1.0",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",