@milaboratories/pl-client 2.7.13 → 2.8.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.
Files changed (86) hide show
  1. package/dist/core/auth.d.ts.map +1 -1
  2. package/dist/core/cache.d.ts.map +1 -1
  3. package/dist/core/client.d.ts +5 -2
  4. package/dist/core/client.d.ts.map +1 -1
  5. package/dist/core/default_client.d.ts.map +1 -1
  6. package/dist/core/driver.d.ts.map +1 -1
  7. package/dist/core/errors.d.ts.map +1 -1
  8. package/dist/core/final.d.ts.map +1 -1
  9. package/dist/core/ll_client.d.ts +12 -2
  10. package/dist/core/ll_client.d.ts.map +1 -1
  11. package/dist/core/ll_transaction.d.ts.map +1 -1
  12. package/dist/core/transaction.d.ts +1 -1
  13. package/dist/core/transaction.d.ts.map +1 -1
  14. package/dist/core/type_conversion.d.ts.map +1 -1
  15. package/dist/core/types.d.ts +1 -1
  16. package/dist/core/types.d.ts.map +1 -1
  17. package/dist/core/unauth_client.d.ts.map +1 -1
  18. package/dist/helpers/pl.d.ts.map +1 -1
  19. package/dist/helpers/poll.d.ts.map +1 -1
  20. package/dist/helpers/state_helpers.d.ts.map +1 -1
  21. package/dist/helpers/tx_helpers.d.ts.map +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +2361 -2342
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +4 -4
  27. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -1
  28. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +16 -16
  29. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -1
  30. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +8 -8
  31. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -1
  32. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +22 -22
  33. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -1
  34. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +17 -0
  35. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
  36. package/dist/proto/google/api/http.d.ts +89 -89
  37. package/dist/proto/google/api/http.d.ts.map +1 -1
  38. package/dist/proto/google/protobuf/descriptor.d.ts +1151 -1151
  39. package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -1
  40. package/dist/test/test_config.d.ts.map +1 -1
  41. package/dist/util/util.d.ts.map +1 -1
  42. package/package.json +7 -3
  43. package/src/core/auth.ts +3 -3
  44. package/src/core/cache.ts +1 -1
  45. package/src/core/client.ts +63 -59
  46. package/src/core/config.ts +21 -21
  47. package/src/core/default_client.ts +15 -14
  48. package/src/core/driver.ts +4 -4
  49. package/src/core/errors.ts +3 -3
  50. package/src/core/final.ts +7 -4
  51. package/src/core/ll_client.ts +72 -43
  52. package/src/core/ll_transaction.ts +17 -17
  53. package/src/core/stat.ts +2 -2
  54. package/src/core/transaction.ts +93 -95
  55. package/src/core/type_conversion.ts +11 -8
  56. package/src/core/types.ts +25 -26
  57. package/src/core/unauth_client.ts +6 -6
  58. package/src/helpers/pl.ts +8 -7
  59. package/src/helpers/poll.ts +25 -21
  60. package/src/helpers/state_helpers.ts +2 -1
  61. package/src/helpers/tx_helpers.ts +4 -3
  62. package/src/proto/github.com/googleapis/googleapis/google/rpc/status.ts +1 -1
  63. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.ts +21 -20
  64. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.ts +240 -225
  65. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.ts +1 -1
  66. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts +1 -1
  67. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.ts +32 -30
  68. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.ts +388 -364
  69. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.ts +1 -1
  70. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.ts +1 -1
  71. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +1 -1
  72. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api.ts +27 -2
  73. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +1 -1
  74. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.ts +1 -1
  75. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/import.ts +1 -1
  76. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.ts +1 -1
  77. package/src/proto/google/api/http.ts +280 -271
  78. package/src/proto/google/protobuf/any.ts +1 -1
  79. package/src/proto/google/protobuf/descriptor.ts +2952 -2853
  80. package/src/proto/google/protobuf/duration.ts +1 -1
  81. package/src/proto/google/protobuf/empty.ts +1 -1
  82. package/src/proto/google/protobuf/struct.ts +1 -1
  83. package/src/proto/google/protobuf/timestamp.ts +2 -2
  84. package/src/proto/google/protobuf/wrappers.ts +1 -1
  85. package/src/test/test_config.ts +21 -19
  86. package/src/util/util.ts +1 -0
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
- import { AuthInformation, plAddressToConfig, PlClientConfig } from './config';
2
+ import type { AuthInformation, PlClientConfig } from './config';
3
+ import { plAddressToConfig } from './config';
3
4
  import canonicalize from 'canonicalize';
4
5
  import YAML from 'yaml';
5
6
  import * as os from 'node:os';
@@ -7,7 +8,7 @@ import * as path from 'node:path';
7
8
  import { notEmpty } from '@milaboratories/ts-helpers';
8
9
  import { UnauthenticatedPlClient } from './unauth_client';
9
10
  import { PlClient } from './client';
10
- import { createHash } from 'crypto';
11
+ import { createHash } from 'node:crypto';
11
12
  import { inferAuthRefreshTime } from './auth';
12
13
 
13
14
  const CONFIG_FILE_LOCAL_JSON = 'pl.json';
@@ -18,7 +19,7 @@ const CONF_FILE_SEQUENCE = [
18
19
  CONFIG_FILE_LOCAL_JSON,
19
20
  CONFIG_FILE_LOCAL_YAML,
20
21
  CONFIG_FILE_USER_JSON,
21
- CONFIG_FILE_USER_YAML
22
+ CONFIG_FILE_USER_YAML,
22
23
  ];
23
24
 
24
25
  const AUTH_DATA_FILE = '.pl_auth.json';
@@ -44,7 +45,7 @@ const FILE_CONFIG_OVERRIDE_FIELDS: FileConfigOverrideFields[] = [
44
45
  'defaultRWTransactionTimeout',
45
46
  'defaultRequestTimeout',
46
47
  'authTTLSeconds',
47
- 'authMaxRefreshSeconds'
48
+ 'authMaxRefreshSeconds',
48
49
  ];
49
50
 
50
51
  type PlConfigFile = {
@@ -70,7 +71,7 @@ export function tryGetFileConfig(): [PlConfigFile, string] | undefined {
70
71
 
71
72
  function saveAuthInfoCallback(
72
73
  confHash: string,
73
- authMaxRefreshSeconds: number
74
+ authMaxRefreshSeconds: number,
74
75
  ): (newAuthInfo: AuthInformation) => void {
75
76
  return (newAuthInfo) => {
76
77
  fs.writeFileSync(
@@ -79,10 +80,10 @@ function saveAuthInfoCallback(
79
80
  JSON.stringify({
80
81
  confHash,
81
82
  authInformation: newAuthInfo,
82
- expiration: inferAuthRefreshTime(newAuthInfo, authMaxRefreshSeconds)
83
- } as AuthCache)
83
+ expiration: inferAuthRefreshTime(newAuthInfo, authMaxRefreshSeconds),
84
+ } as AuthCache),
84
85
  ),
85
- 'utf8'
86
+ 'utf8',
86
87
  );
87
88
  };
88
89
  }
@@ -109,7 +110,7 @@ export async function defaultPlClient(): Promise<PlClient> {
109
110
  }
110
111
 
111
112
  if (config === undefined)
112
- throw new Error("Can't find configuration to create default platform client.");
113
+ throw new Error('Can\'t find configuration to create default platform client.');
113
114
 
114
115
  if (process.env.PL_USER !== undefined) config.user = process.env.PL_USER;
115
116
 
@@ -147,17 +148,17 @@ export async function defaultPlClient(): Promise<PlClient> {
147
148
  JSON.stringify({
148
149
  confHash,
149
150
  authInformation,
150
- expiration: inferAuthRefreshTime(authInformation, config.authMaxRefreshSeconds)
151
- } as AuthCache)
151
+ expiration: inferAuthRefreshTime(authInformation, config.authMaxRefreshSeconds),
152
+ } as AuthCache),
152
153
  ),
153
- 'utf8'
154
+ 'utf8',
154
155
  );
155
156
  }
156
157
 
157
158
  return await PlClient.init(config, {
158
159
  authInformation,
159
- onUpdate: (newAuthInfo) => saveAuthInfoCallback(confHash, config!.authMaxRefreshSeconds),
160
+ onUpdate: (_newAuthInfo) => saveAuthInfoCallback(confHash, config.authMaxRefreshSeconds),
160
161
  onUpdateError: cleanAuthInfoCallback,
161
- onAuthError: cleanAuthInfoCallback
162
+ onAuthError: cleanAuthInfoCallback,
162
163
  });
163
164
  }
@@ -1,8 +1,8 @@
1
- import { PlClient } from './client';
2
- import { GrpcTransport } from '@protobuf-ts/grpc-transport';
1
+ import type { PlClient } from './client';
2
+ import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
3
3
  import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
4
- import { Dispatcher } from 'undici';
5
- import { ResourceType } from './types';
4
+ import type { Dispatcher } from 'undici';
5
+ import type { ResourceType } from './types';
6
6
 
7
7
  /** Drivers must implement this interface */
8
8
  export interface PlDriver {
@@ -1,4 +1,4 @@
1
- import { Status } from '../proto/github.com/googleapis/googleapis/google/rpc/status';
1
+ import type { Status } from '../proto/github.com/googleapis/googleapis/google/rpc/status';
2
2
  import { Aborted } from '@milaboratories/ts-helpers';
3
3
 
4
4
  export function isConnectionProblem(err: unknown, nested: boolean = false): boolean {
@@ -23,8 +23,8 @@ export function isTimeoutOrCancelError(err: unknown, nested: boolean = false): b
23
23
  if (err instanceof Aborted || (err as any).name == 'AbortError') return true;
24
24
  if ((err as any).code == 'ABORT_ERR') return true;
25
25
  if (
26
- (err as any).name == 'RpcError' &&
27
- ((err as any).code == 'CANCELLED' || (err as any).code == 'DEADLINE_EXCEEDED')
26
+ (err as any).name == 'RpcError'
27
+ && ((err as any).code == 'CANCELLED' || (err as any).code == 'DEADLINE_EXCEEDED')
28
28
  )
29
29
  return true;
30
30
  if ((err as any).cause !== undefined && !nested)
package/src/core/final.ts CHANGED
@@ -1,10 +1,12 @@
1
- import { Optional } from 'utility-types';
2
- import {
1
+ import type { Optional } from 'utility-types';
2
+ import type {
3
3
  BasicResourceData,
4
+ ResourceData,
5
+ } from './types';
6
+ import {
4
7
  getField,
5
8
  isNotNullResourceId,
6
9
  isNullResourceId,
7
- ResourceData
8
10
  } from './types';
9
11
 
10
12
  /**
@@ -41,13 +43,14 @@ const unknownResourceTypeNames = new Set<string>();
41
43
  /** Default implementation, defining behaviour for built-in resource types. */
42
44
  export const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {
43
45
  switch (r.type.name) {
44
- case 'StreamManager':
46
+ case 'StreamManager': {
45
47
  if (!readyOrDuplicateOrError(r)) return false;
46
48
  if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future
47
49
  if (isNotNullResourceId(r.error)) return true;
48
50
  const downloadable = getField(r as ResourceData, 'downloadable');
49
51
  const stream = getField(r as ResourceData, 'stream');
50
52
  return stream.value === downloadable.value;
53
+ }
51
54
  case 'StdMap':
52
55
  case 'std/map':
53
56
  case 'EphStdMap':
@@ -1,22 +1,24 @@
1
1
  import { PlatformClient } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api.client';
2
+ import type { ClientOptions, Interceptor } from '@grpc/grpc-js';
2
3
  import {
3
4
  ChannelCredentials,
4
5
  InterceptingCall,
5
- Interceptor,
6
- status as GrpcStatus
6
+ status as GrpcStatus,
7
+ compressionAlgorithms,
7
8
  } from '@grpc/grpc-js';
8
- import {
9
+ import type {
9
10
  AuthInformation,
10
11
  AuthOps,
11
- plAddressToConfig,
12
12
  PlClientConfig,
13
13
  PlConnectionStatus,
14
- PlConnectionStatusListener
14
+ PlConnectionStatusListener,
15
15
  } from './config';
16
- import { GrpcOptions, GrpcTransport } from '@protobuf-ts/grpc-transport';
16
+ import { plAddressToConfig } from './config';
17
+ import type { GrpcOptions } from '@protobuf-ts/grpc-transport';
18
+ import { GrpcTransport } from '@protobuf-ts/grpc-transport';
17
19
  import { LLPlTransaction } from './ll_transaction';
18
20
  import { parsePlJwt } from '../util/pl';
19
- import { Dispatcher } from 'undici';
21
+ import type { Dispatcher } from 'undici';
20
22
  import { inferAuthRefreshTime } from './auth';
21
23
  import { defaultHttpDispatcher } from '@milaboratories/pl-http';
22
24
 
@@ -43,38 +45,63 @@ export class LLPlClient {
43
45
  private _status: PlConnectionStatus = 'OK';
44
46
  private readonly statusListener?: PlConnectionStatusListener;
45
47
 
46
- public readonly grpcTransport: GrpcTransport;
47
- public readonly grpcPl: PlatformClient;
48
+ private readonly grpcInterceptors: Interceptor[];
49
+ private _grpcTransport!: GrpcTransport;
50
+ private _grpcPl!: PlatformClient;
48
51
 
49
52
  public readonly httpDispatcher: Dispatcher;
50
53
 
51
54
  constructor(
52
55
  configOrAddress: PlClientConfig | string,
53
- ops: {
56
+ private readonly ops: {
54
57
  auth?: AuthOps;
55
58
  statusListener?: PlConnectionStatusListener;
56
- } = {}
59
+ shouldUseGzip?: boolean;
60
+ } = {},
57
61
  ) {
58
- this.conf =
59
- typeof configOrAddress === 'string' ? plAddressToConfig(configOrAddress) : configOrAddress;
62
+ this.conf
63
+ = typeof configOrAddress === 'string' ? plAddressToConfig(configOrAddress) : configOrAddress;
60
64
 
61
- const grpcInterceptors: Interceptor[] = [];
65
+ this.grpcInterceptors = [];
62
66
 
63
- const { auth, statusListener } = ops;
67
+ const { auth, statusListener, shouldUseGzip } = ops;
64
68
 
65
69
  if (auth !== undefined) {
66
70
  this.refreshTimestamp = inferAuthRefreshTime(
67
71
  auth.authInformation,
68
- this.conf.authMaxRefreshSeconds
72
+ this.conf.authMaxRefreshSeconds,
69
73
  );
70
- grpcInterceptors.push(this.createAuthInterceptor());
74
+ this.grpcInterceptors.push(this.createAuthInterceptor());
71
75
  this.authInformation = auth.authInformation;
72
76
  this.onAuthUpdate = auth.onUpdate;
73
77
  this.onAuthRefreshProblem = auth.onUpdateError;
74
78
  this.onAuthError = auth.onAuthError;
75
79
  }
76
80
 
77
- grpcInterceptors.push(this.createErrorInterceptor());
81
+ this.grpcInterceptors.push(this.createErrorInterceptor());
82
+
83
+ // initialize _grpcTransport and _grpcPl
84
+ this.initGrpc(shouldUseGzip ?? false);
85
+
86
+ this.httpDispatcher = defaultHttpDispatcher(this.conf.httpProxy);
87
+
88
+ if (statusListener !== undefined) {
89
+ this.statusListener = statusListener;
90
+ statusListener(this._status);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Initializes (or reinitializes) _grpcTransport and _grpcPl
96
+ * @param gzip - whether to enable gzip compression
97
+ */
98
+ private initGrpc(gzip: boolean) {
99
+ const clientOptions: ClientOptions = {
100
+ 'grpc.keepalive_time_ms': 30_000, // 30 seconds
101
+ 'interceptors': this.grpcInterceptors,
102
+ };
103
+
104
+ if (gzip) clientOptions['grpc.default_compression_algorithm'] = compressionAlgorithms.gzip;
78
105
 
79
106
  //
80
107
  // Leaving it here for now
@@ -89,24 +116,26 @@ export class LLPlClient {
89
116
  channelCredentials: this.conf.ssl
90
117
  ? ChannelCredentials.createSsl()
91
118
  : ChannelCredentials.createInsecure(),
92
- clientOptions: {
93
- 'grpc.keepalive_time_ms': 30_000, // 30 seconds
94
- interceptors: grpcInterceptors
95
- }
119
+ clientOptions,
96
120
  };
97
121
 
98
122
  if (this.conf.grpcProxy) process.env.grpc_proxy = this.conf.grpcProxy;
99
123
  else delete process.env.grpc_proxy;
100
124
 
101
- this.grpcTransport = new GrpcTransport(grpcOptions);
102
- this.grpcPl = new PlatformClient(this.grpcTransport);
125
+ const oldTransport = this._grpcTransport;
103
126
 
104
- this.httpDispatcher = defaultHttpDispatcher(this.conf.httpProxy);
127
+ this._grpcTransport = new GrpcTransport(grpcOptions);
128
+ this._grpcPl = new PlatformClient(this._grpcTransport);
105
129
 
106
- if (statusListener !== undefined) {
107
- this.statusListener = statusListener;
108
- statusListener(this._status);
109
- }
130
+ if (oldTransport !== undefined) oldTransport.close();
131
+ }
132
+
133
+ public get grpcTransport(): GrpcTransport {
134
+ return this._grpcTransport;
135
+ }
136
+
137
+ public get grpcPl(): PlatformClient {
138
+ return this._grpcPl;
110
139
  }
111
140
 
112
141
  /** Returns true if client is authenticated. Even with anonymous auth information
@@ -142,27 +171,27 @@ export class LLPlClient {
142
171
 
143
172
  private refreshAuthInformationIfNeeded(): void {
144
173
  if (
145
- this.refreshTimestamp === undefined ||
146
- Date.now() < this.refreshTimestamp ||
147
- this.authRefreshInProgress ||
148
- this._status === 'Unauthenticated'
174
+ this.refreshTimestamp === undefined
175
+ || Date.now() < this.refreshTimestamp
176
+ || this.authRefreshInProgress
177
+ || this._status === 'Unauthenticated'
149
178
  )
150
179
  return;
151
180
 
152
- // Running refresh in background
181
+ // Running refresh in background`
153
182
  this.authRefreshInProgress = true;
154
- (async () => {
183
+ void (async () => {
155
184
  try {
156
185
  const response = await this.grpcPl.getJWTToken({
157
186
  expiration: {
158
187
  seconds: BigInt(this.conf.authTTLSeconds),
159
- nanos: 0
160
- }
188
+ nanos: 0,
189
+ },
161
190
  }).response;
162
191
  this.authInformation = { jwtToken: response.token };
163
192
  this.refreshTimestamp = inferAuthRefreshTime(
164
193
  this.authInformation,
165
- this.conf.authMaxRefreshSeconds
194
+ this.conf.authMaxRefreshSeconds,
166
195
  );
167
196
  if (this.onAuthUpdate) this.onAuthUpdate(this.authInformation);
168
197
  } catch (e: unknown) {
@@ -187,9 +216,9 @@ export class LLPlClient {
187
216
  // (!!!) don't change to "==="
188
217
  this.updateStatus('Disconnected');
189
218
  next(status);
190
- }
219
+ },
191
220
  });
192
- }
221
+ },
193
222
  });
194
223
  };
195
224
  }
@@ -206,7 +235,7 @@ export class LLPlClient {
206
235
  } else {
207
236
  next(metadata, listener);
208
237
  }
209
- }
238
+ },
210
239
  });
211
240
  };
212
241
  }
@@ -218,8 +247,8 @@ export class LLPlClient {
218
247
  return this.grpcPl.tx({
219
248
  abort: totalAbortSignal,
220
249
  timeout:
221
- ops.timeout ??
222
- (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout)
250
+ ops.timeout
251
+ ?? (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout),
223
252
  });
224
253
  });
225
254
  }
@@ -1,15 +1,15 @@
1
- import {
1
+ import type {
2
2
  TxAPI_ClientMessage,
3
- TxAPI_ServerMessage
3
+ TxAPI_ServerMessage,
4
4
  } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
5
- import { DuplexStreamingCall } from '@protobuf-ts/runtime-rpc';
5
+ import type { DuplexStreamingCall } from '@protobuf-ts/runtime-rpc';
6
6
  import Denque from 'denque';
7
- import { Status } from '../proto/github.com/googleapis/googleapis/google/rpc/status';
7
+ import type { Status } from '../proto/github.com/googleapis/googleapis/google/rpc/status';
8
8
  import {
9
9
  PlErrorCodeNotFound,
10
10
  RecoverablePlError,
11
11
  rethrowMeaningfulError,
12
- UnrecoverablePlError
12
+ UnrecoverablePlError,
13
13
  } from './errors';
14
14
 
15
15
  export type ClientMessageRequest = TxAPI_ClientMessage['request'];
@@ -51,7 +51,7 @@ function createResponseHandler<Kind extends ServerMessageResponse['oneofKind']>(
51
51
  resolve:
52
52
  | ((v: OneOfKind<ServerMessageResponse, Kind>) => void)
53
53
  | ((v: OneOfKind<ServerMessageResponse, Kind>[]) => void),
54
- reject: (e: Error) => void
54
+ reject: (e: Error) => void,
55
55
  ): AnyResponseHandler {
56
56
  return { kind, expectMultiResponse, resolve, reject } as AnyResponseHandler;
57
57
  }
@@ -108,7 +108,7 @@ export class LLPlTransaction {
108
108
 
109
109
  private assignErrorFactoryIfNotSet(
110
110
  errorFactory: () => never,
111
- reject?: (e: Error) => void
111
+ reject?: (e: Error) => void,
112
112
  ): () => never {
113
113
  if (reject !== undefined) reject(new RethrowError(errorFactory));
114
114
  if (this.errorFactory) return errorFactory;
@@ -158,7 +158,7 @@ export class LLPlTransaction {
158
158
  currentHandler.reject(
159
159
  new RethrowError(() => {
160
160
  throw new RecoverablePlError(status);
161
- })
161
+ }),
162
162
  );
163
163
  currentHandler = undefined;
164
164
 
@@ -183,10 +183,10 @@ export class LLPlTransaction {
183
183
  }
184
184
 
185
185
  if (
186
- currentHandler!.kind !== message.response.oneofKind &&
187
- message?.multiMessage?.isEmpty !== true
186
+ currentHandler.kind !== message.response.oneofKind
187
+ && message?.multiMessage?.isEmpty !== true
188
188
  ) {
189
- const errorMessage = `inconsistent request response types: ${currentHandler!.kind} !== ${message.response.oneofKind}`;
189
+ const errorMessage = `inconsistent request response types: ${currentHandler.kind} !== ${message.response.oneofKind}`;
190
190
 
191
191
  this.assignErrorFactoryIfNotSet(() => {
192
192
  throw new Error(errorMessage);
@@ -196,8 +196,8 @@ export class LLPlTransaction {
196
196
  break;
197
197
  }
198
198
 
199
- if (currentHandler!.expectMultiResponse !== (message.multiMessage !== undefined)) {
200
- const errorMessage = `inconsistent multi state: ${currentHandler!.expectMultiResponse} !== ${message.multiMessage !== undefined}`;
199
+ if (currentHandler.expectMultiResponse !== (message.multiMessage !== undefined)) {
200
+ const errorMessage = `inconsistent multi state: ${currentHandler.expectMultiResponse} !== ${message.multiMessage !== undefined}`;
201
201
 
202
202
  this.assignErrorFactoryIfNotSet(() => {
203
203
  throw new Error(errorMessage);
@@ -252,7 +252,7 @@ export class LLPlTransaction {
252
252
  this.closed = true;
253
253
 
254
254
  // Rejecting all messages
255
- let handler: AnyResponseHandler | undefined = undefined;
255
+
256
256
  while (true) {
257
257
  const handler = this.responseHandlerQueue.shift();
258
258
  if (!handler) break;
@@ -294,7 +294,7 @@ export class LLPlTransaction {
294
294
  /** Generate proper client message and send it to the server, and returns a promise of future response. */
295
295
  public async send<Kind extends ClientMessageRequest['oneofKind']>(
296
296
  r: OneOfKind<ClientMessageRequest, Kind>,
297
- expectMultiResponse: boolean
297
+ expectMultiResponse: boolean,
298
298
  ): Promise<OneOfKind<ServerMessageResponse, Kind> | OneOfKind<ServerMessageResponse, Kind>[]> {
299
299
  if (this.errorFactory) return Promise.reject(new RethrowError(this.errorFactory));
300
300
 
@@ -303,7 +303,7 @@ export class LLPlTransaction {
303
303
  // Note: Promise synchronously executes a callback passed to a constructor
304
304
  const result = new Promise<OneOfKind<ServerMessageResponse, Kind>>((resolve, reject) => {
305
305
  this.responseHandlerQueue.push(
306
- createResponseHandler(r.oneofKind, expectMultiResponse, resolve, reject)
306
+ createResponseHandler(r.oneofKind, expectMultiResponse, resolve, reject),
307
307
  );
308
308
  });
309
309
 
@@ -311,7 +311,7 @@ export class LLPlTransaction {
311
311
  // There is no hurry, we are not going to receive a response until message is sent.
312
312
  await this.stream.requests.send({
313
313
  requestId: this.requestIdxCounter++,
314
- request: r
314
+ request: r,
315
315
  });
316
316
 
317
317
  try {
package/src/core/stat.ts CHANGED
@@ -60,7 +60,7 @@ export function initialTxStat(): TxStat {
60
60
  kvListEntries: 0,
61
61
  kvListBytes: 0,
62
62
  kvGetRequests: 0,
63
- kvGetBytes: 0
63
+ kvGetBytes: 0,
64
64
  };
65
65
  }
66
66
 
@@ -91,7 +91,7 @@ export function addStat(a: TxStat, b: TxStat): TxStat {
91
91
  kvListEntries: a.kvListEntries + b.kvListEntries,
92
92
  kvListBytes: a.kvListBytes + b.kvListBytes,
93
93
  kvGetRequests: a.kvGetRequests + b.kvGetRequests,
94
- kvGetBytes: a.kvGetBytes + b.kvGetBytes
94
+ kvGetBytes: a.kvGetBytes + b.kvGetBytes,
95
95
  };
96
96
  }
97
97