@milaboratories/pl-client 2.7.13 → 2.7.14

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 (116) 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 +1 -1
  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.map +1 -1
  10. package/dist/core/ll_transaction.d.ts.map +1 -1
  11. package/dist/core/transaction.d.ts +1 -1
  12. package/dist/core/transaction.d.ts.map +1 -1
  13. package/dist/core/type_conversion.d.ts.map +1 -1
  14. package/dist/core/types.d.ts +1 -1
  15. package/dist/core/types.d.ts.map +1 -1
  16. package/dist/core/unauth_client.d.ts.map +1 -1
  17. package/dist/helpers/pl.d.ts.map +1 -1
  18. package/dist/helpers/poll.d.ts.map +1 -1
  19. package/dist/helpers/state_helpers.d.ts.map +1 -1
  20. package/dist/helpers/tx_helpers.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +4069 -4075
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +15 -15
  26. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -1
  27. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +4 -4
  28. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -1
  29. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +16 -16
  30. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -1
  31. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +4 -4
  32. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +1 -1
  33. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +59 -59
  34. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +1 -1
  35. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +8 -8
  36. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -1
  37. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +22 -22
  38. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -1
  39. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +72 -72
  40. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +1 -1
  41. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +152 -152
  42. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +1 -1
  43. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +156 -156
  44. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -1
  45. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +773 -773
  46. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
  47. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +163 -163
  48. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -1
  49. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +22 -22
  50. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -1
  51. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +32 -32
  52. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +1 -1
  53. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +78 -78
  54. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -1
  55. package/dist/proto/google/api/http.d.ts +89 -89
  56. package/dist/proto/google/api/http.d.ts.map +1 -1
  57. package/dist/proto/google/protobuf/any.d.ts +52 -52
  58. package/dist/proto/google/protobuf/any.d.ts.map +1 -1
  59. package/dist/proto/google/protobuf/descriptor.d.ts +1151 -1151
  60. package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -1
  61. package/dist/proto/google/protobuf/duration.d.ts +19 -19
  62. package/dist/proto/google/protobuf/duration.d.ts.map +1 -1
  63. package/dist/proto/google/protobuf/empty.d.ts.map +1 -1
  64. package/dist/proto/google/protobuf/struct.d.ts +56 -56
  65. package/dist/proto/google/protobuf/struct.d.ts.map +1 -1
  66. package/dist/proto/google/protobuf/timestamp.d.ts +25 -25
  67. package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -1
  68. package/dist/proto/google/protobuf/wrappers.d.ts +72 -72
  69. package/dist/proto/google/protobuf/wrappers.d.ts.map +1 -1
  70. package/dist/test/test_config.d.ts.map +1 -1
  71. package/dist/util/util.d.ts.map +1 -1
  72. package/package.json +7 -3
  73. package/src/core/auth.ts +3 -3
  74. package/src/core/cache.ts +1 -1
  75. package/src/core/client.ts +39 -31
  76. package/src/core/config.ts +21 -21
  77. package/src/core/default_client.ts +15 -14
  78. package/src/core/driver.ts +4 -4
  79. package/src/core/errors.ts +3 -3
  80. package/src/core/final.ts +7 -4
  81. package/src/core/ll_client.ts +31 -27
  82. package/src/core/ll_transaction.ts +17 -17
  83. package/src/core/stat.ts +2 -2
  84. package/src/core/transaction.ts +93 -95
  85. package/src/core/type_conversion.ts +11 -8
  86. package/src/core/types.ts +25 -26
  87. package/src/core/unauth_client.ts +6 -6
  88. package/src/helpers/pl.ts +8 -7
  89. package/src/helpers/poll.ts +25 -21
  90. package/src/helpers/state_helpers.ts +2 -1
  91. package/src/helpers/tx_helpers.ts +4 -3
  92. package/src/proto/github.com/googleapis/googleapis/google/rpc/status.ts +74 -71
  93. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.ts +21 -20
  94. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.ts +240 -225
  95. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.ts +21 -20
  96. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts +290 -275
  97. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.ts +32 -30
  98. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.ts +388 -364
  99. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.ts +58 -53
  100. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.ts +490 -469
  101. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +262 -237
  102. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api.ts +11751 -11032
  103. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +1155 -1114
  104. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.ts +131 -125
  105. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/import.ts +203 -200
  106. package/src/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.ts +559 -540
  107. package/src/proto/google/api/http.ts +280 -271
  108. package/src/proto/google/protobuf/any.ts +149 -139
  109. package/src/proto/google/protobuf/descriptor.ts +2952 -2853
  110. package/src/proto/google/protobuf/duration.ts +107 -102
  111. package/src/proto/google/protobuf/empty.ts +41 -38
  112. package/src/proto/google/protobuf/struct.ts +336 -322
  113. package/src/proto/google/protobuf/timestamp.ts +131 -123
  114. package/src/proto/google/protobuf/wrappers.ts +536 -491
  115. package/src/test/test_config.ts +21 -19
  116. package/src/util/util.ts +1 -0
@@ -108,7 +108,7 @@ type PlConfigOverrides = Partial<
108
108
  function parseInt(s: string | null | undefined): number | undefined {
109
109
  if (!s) return undefined;
110
110
  const num = Number(s);
111
- if (num === Number.NaN) throw new Error(`Can't parse number: ${s}`);
111
+ if (Number.isNaN(num)) throw new Error(`Can't parse number: ${s}`);
112
112
  return num;
113
113
  }
114
114
 
@@ -116,7 +116,7 @@ function parseInt(s: string | null | undefined): number | undefined {
116
116
  * {@link PlClient} of {@link UnauthenticatedPlClient}. */
117
117
  export function plAddressToConfig(
118
118
  address: string,
119
- overrides: PlConfigOverrides = {}
119
+ overrides: PlConfigOverrides = {},
120
120
  ): PlClientConfig {
121
121
  if (address.indexOf('://') === -1)
122
122
  // non-url address
@@ -140,16 +140,16 @@ export function plAddressToConfig(
140
140
  retryLinearBackoffStep: DEFAULT_RETRY_LINEAR_BACKOFF_STEP,
141
141
  retryJitter: DEFAULT_RETRY_JITTER,
142
142
 
143
- ...overrides
143
+ ...overrides,
144
144
  };
145
145
 
146
146
  const url = new URL(address);
147
147
 
148
148
  if (
149
- url.protocol !== 'https:' &&
150
- url.protocol !== 'http:' &&
151
- url.protocol !== 'grpc:' &&
152
- url.protocol !== 'tls:'
149
+ url.protocol !== 'https:'
150
+ && url.protocol !== 'http:'
151
+ && url.protocol !== 'grpc:'
152
+ && url.protocol !== 'tls:'
153
153
  )
154
154
  throw new Error(`Unexpected URL schema: ${url.protocol}`);
155
155
 
@@ -163,13 +163,13 @@ export function plAddressToConfig(
163
163
  defaultRequestTimeout:
164
164
  parseInt(url.searchParams.get('request-timeout')) ?? DEFAULT_REQUEST_TIMEOUT,
165
165
  defaultROTransactionTimeout:
166
- parseInt(url.searchParams.get('ro-tx-timeout')) ??
167
- parseInt(url.searchParams.get('tx-timeout')) ??
168
- DEFAULT_RO_TX_TIMEOUT,
166
+ parseInt(url.searchParams.get('ro-tx-timeout'))
167
+ ?? parseInt(url.searchParams.get('tx-timeout'))
168
+ ?? DEFAULT_RO_TX_TIMEOUT,
169
169
  defaultRWTransactionTimeout:
170
- parseInt(url.searchParams.get('rw-tx-timeout')) ??
171
- parseInt(url.searchParams.get('tx-timeout')) ??
172
- DEFAULT_RW_TX_TIMEOUT,
170
+ parseInt(url.searchParams.get('rw-tx-timeout'))
171
+ ?? parseInt(url.searchParams.get('tx-timeout'))
172
+ ?? DEFAULT_RW_TX_TIMEOUT,
173
173
  authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,
174
174
  authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,
175
175
  grpcProxy: url.searchParams.get('grpc-proxy') ?? undefined,
@@ -177,25 +177,25 @@ export function plAddressToConfig(
177
177
  user: url.username === '' ? undefined : url.username,
178
178
  password: url.password === '' ? undefined : url.password,
179
179
  txDelay: parseInt(url.searchParams.get('tx-delay')) ?? 0,
180
- forceSync: Boolean(url.searchParams.get('force-sync')) ?? false,
180
+ forceSync: Boolean(url.searchParams.get('force-sync')),
181
181
 
182
182
  maxCacheBytes: parseInt(url.searchParams.get('max-cache-bytes')) ?? DEFAULT_MAX_CACHE_BYTES,
183
183
 
184
- retryBackoffAlgorithm: (url.searchParams.get('retry-backoff-algorithm') ??
185
- DEFAULT_RETRY_BACKOFF_ALGORITHM) as any,
184
+ retryBackoffAlgorithm: (url.searchParams.get('retry-backoff-algorithm')
185
+ ?? DEFAULT_RETRY_BACKOFF_ALGORITHM) as any,
186
186
  retryMaxAttempts:
187
187
  parseInt(url.searchParams.get('retry-max-attempts')) ?? DEFAULT_RETRY_MAX_ATTEMPTS,
188
188
  retryInitialDelay:
189
189
  parseInt(url.searchParams.get('retry-initial-delay')) ?? DEFAULT_RETRY_INITIAL_DELAY,
190
190
  retryExponentialBackoffMultiplier:
191
- parseInt(url.searchParams.get('retry-exp-backoff-multiplier')) ??
192
- DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,
191
+ parseInt(url.searchParams.get('retry-exp-backoff-multiplier'))
192
+ ?? DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,
193
193
  retryLinearBackoffStep:
194
- parseInt(url.searchParams.get('retry-linear-backoff-step')) ??
195
- DEFAULT_RETRY_LINEAR_BACKOFF_STEP,
194
+ parseInt(url.searchParams.get('retry-linear-backoff-step'))
195
+ ?? DEFAULT_RETRY_LINEAR_BACKOFF_STEP,
196
196
  retryJitter: parseInt(url.searchParams.get('retry-backoff-jitter')) ?? DEFAULT_RETRY_JITTER,
197
197
 
198
- ...overrides
198
+ ...overrides,
199
199
  };
200
200
  }
201
201
 
@@ -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,26 @@
1
1
  import { PlatformClient } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api.client';
2
+ import type {
3
+ Interceptor } from '@grpc/grpc-js';
2
4
  import {
3
5
  ChannelCredentials,
4
6
  InterceptingCall,
5
- Interceptor,
6
- status as GrpcStatus
7
+ status as GrpcStatus,
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 {
17
+ plAddressToConfig,
18
+ } from './config';
19
+ import type { GrpcOptions } from '@protobuf-ts/grpc-transport';
20
+ import { GrpcTransport } from '@protobuf-ts/grpc-transport';
17
21
  import { LLPlTransaction } from './ll_transaction';
18
22
  import { parsePlJwt } from '../util/pl';
19
- import { Dispatcher } from 'undici';
23
+ import type { Dispatcher } from 'undici';
20
24
  import { inferAuthRefreshTime } from './auth';
21
25
  import { defaultHttpDispatcher } from '@milaboratories/pl-http';
22
26
 
@@ -53,10 +57,10 @@ export class LLPlClient {
53
57
  ops: {
54
58
  auth?: AuthOps;
55
59
  statusListener?: PlConnectionStatusListener;
56
- } = {}
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
65
  const grpcInterceptors: Interceptor[] = [];
62
66
 
@@ -65,7 +69,7 @@ export class LLPlClient {
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
74
  grpcInterceptors.push(this.createAuthInterceptor());
71
75
  this.authInformation = auth.authInformation;
@@ -91,8 +95,8 @@ export class LLPlClient {
91
95
  : ChannelCredentials.createInsecure(),
92
96
  clientOptions: {
93
97
  'grpc.keepalive_time_ms': 30_000, // 30 seconds
94
- interceptors: grpcInterceptors
95
- }
98
+ 'interceptors': grpcInterceptors,
99
+ },
96
100
  };
97
101
 
98
102
  if (this.conf.grpcProxy) process.env.grpc_proxy = this.conf.grpcProxy;
@@ -142,27 +146,27 @@ export class LLPlClient {
142
146
 
143
147
  private refreshAuthInformationIfNeeded(): void {
144
148
  if (
145
- this.refreshTimestamp === undefined ||
146
- Date.now() < this.refreshTimestamp ||
147
- this.authRefreshInProgress ||
148
- this._status === 'Unauthenticated'
149
+ this.refreshTimestamp === undefined
150
+ || Date.now() < this.refreshTimestamp
151
+ || this.authRefreshInProgress
152
+ || this._status === 'Unauthenticated'
149
153
  )
150
154
  return;
151
155
 
152
- // Running refresh in background
156
+ // Running refresh in background`
153
157
  this.authRefreshInProgress = true;
154
- (async () => {
158
+ void (async () => {
155
159
  try {
156
160
  const response = await this.grpcPl.getJWTToken({
157
161
  expiration: {
158
162
  seconds: BigInt(this.conf.authTTLSeconds),
159
- nanos: 0
160
- }
163
+ nanos: 0,
164
+ },
161
165
  }).response;
162
166
  this.authInformation = { jwtToken: response.token };
163
167
  this.refreshTimestamp = inferAuthRefreshTime(
164
168
  this.authInformation,
165
- this.conf.authMaxRefreshSeconds
169
+ this.conf.authMaxRefreshSeconds,
166
170
  );
167
171
  if (this.onAuthUpdate) this.onAuthUpdate(this.authInformation);
168
172
  } catch (e: unknown) {
@@ -187,9 +191,9 @@ export class LLPlClient {
187
191
  // (!!!) don't change to "==="
188
192
  this.updateStatus('Disconnected');
189
193
  next(status);
190
- }
194
+ },
191
195
  });
192
- }
196
+ },
193
197
  });
194
198
  };
195
199
  }
@@ -206,7 +210,7 @@ export class LLPlClient {
206
210
  } else {
207
211
  next(metadata, listener);
208
212
  }
209
- }
213
+ },
210
214
  });
211
215
  };
212
216
  }
@@ -218,8 +222,8 @@ export class LLPlClient {
218
222
  return this.grpcPl.tx({
219
223
  abort: totalAbortSignal,
220
224
  timeout:
221
- ops.timeout ??
222
- (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout)
225
+ ops.timeout
226
+ ?? (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout),
223
227
  });
224
228
  });
225
229
  }
@@ -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