@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,7 +1,7 @@
1
- import { AuthInformation, PlClientConfig } from './config';
2
- import {
1
+ import type { AuthInformation, PlClientConfig } from './config';
2
+ import type {
3
3
  AuthAPI_ListMethods_Response,
4
- MaintenanceAPI_Ping_Response
4
+ MaintenanceAPI_Ping_Response,
5
5
  } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
6
6
  import { LLPlClient } from './ll_client';
7
7
  import { notEmpty } from '@milaboratories/ts-helpers';
@@ -33,9 +33,9 @@ export class UnauthenticatedPlClient {
33
33
  { expiration: { seconds: BigInt(this.ll.conf.authTTLSeconds), nanos: 0 } },
34
34
  {
35
35
  meta: {
36
- authorization: 'Basic ' + Buffer.from(user + ':' + password).toString('base64')
37
- }
38
- }
36
+ authorization: 'Basic ' + Buffer.from(user + ':' + password).toString('base64'),
37
+ },
38
+ },
39
39
  ).response;
40
40
  const jwtToken = notEmpty(response.token);
41
41
  if (jwtToken === '') throw new Error('empty token');
package/src/helpers/pl.ts CHANGED
@@ -7,8 +7,9 @@
7
7
  *
8
8
  */
9
9
 
10
- import { FutureFieldType, ResourceType } from '../core/types';
11
- import { AnyRef, field, FieldRef, PlTransaction, ResourceRef } from '../core/transaction';
10
+ import type { FutureFieldType, ResourceType } from '../core/types';
11
+ import type { AnyRef, FieldRef, PlTransaction, ResourceRef } from '../core/transaction';
12
+ import { field } from '../core/transaction';
12
13
 
13
14
  function rt(name: string, version: string): ResourceType {
14
15
  return { name, version };
@@ -69,14 +70,14 @@ export type PlRecord<Key extends string = string, Ref extends AnyRef = AnyRef> =
69
70
 
70
71
  export function plEntry<Key extends string = string, Ref extends AnyRef = AnyRef>(
71
72
  key: Key,
72
- ref: Ref
73
+ ref: Ref,
73
74
  ): PlRecordEntry<Key, Ref> {
74
75
  return [key, ref];
75
76
  }
76
77
 
77
78
  export function plEntries<Key extends string = string, Ref extends AnyRef = AnyRef>(
78
79
  record: PlRecord<Key, Ref>,
79
- fields?: Key[]
80
+ fields?: Key[],
80
81
  ): PlRecordEntry<Key, Ref>[] {
81
82
  return fields === undefined
82
83
  ? (Object.entries(record) as PlRecordEntry<Key, Ref>[])
@@ -88,7 +89,7 @@ export function createPlMap(
88
89
  tx: PlTransaction,
89
90
  entries: PlRecordEntry[] | PlRecord,
90
91
  ephemeral: boolean,
91
- type?: ResourceType
92
+ type?: ResourceType,
92
93
  ): ResourceRef {
93
94
  const actualType = type ?? (ephemeral ? EphStdMap : StdMap);
94
95
  const rId = ephemeral ? tx.createEphemeral(actualType) : tx.createStruct(actualType);
@@ -106,10 +107,10 @@ export function futureRecord<Key extends string>(
106
107
  rId: AnyRef,
107
108
  keys: Key[],
108
109
  fieldType: FutureFieldType,
109
- prefix: string = ''
110
+ prefix: string = '',
110
111
  ): PlRecord<Key, FieldRef> {
111
112
  return Object.fromEntries(
112
- keys.map((k) => plEntry(k, tx.getFutureFieldValue(rId, `${prefix}${k}`, fieldType)))
113
+ keys.map((k) => plEntry(k, tx.getFutureFieldValue(rId, `${prefix}${k}`, fieldType))),
113
114
  ) as PlRecord<Key, FieldRef>;
114
115
  }
115
116
 
@@ -1,20 +1,23 @@
1
- import { PlClient } from '../core/client';
1
+ import type { PlClient } from '../core/client';
2
+ import type {
3
+ RetryOptions,
4
+ } from '@milaboratories/ts-helpers';
2
5
  import {
3
6
  createRetryState,
4
7
  nextRetryStateOrError,
5
8
  notEmpty,
6
- RetryOptions
7
9
  } from '@milaboratories/ts-helpers';
8
- import {
10
+ import type {
9
11
  FieldData,
10
12
  FieldType,
13
+ ResourceData,
14
+ ResourceId } from '../core/types';
15
+ import {
11
16
  isNotNullResourceId,
12
17
  isNullResourceId,
13
- ResourceData,
14
- ResourceId,
15
- resourceIdToString
18
+ resourceIdToString,
16
19
  } from '../core/types';
17
- import { PlTransaction } from '../core/transaction';
20
+ import type { PlTransaction } from '../core/transaction';
18
21
  import * as tp from 'node:timers/promises';
19
22
 
20
23
  /** This error tells state assertion mechanism that required state is not yet ready */
@@ -31,14 +34,14 @@ export type PollFieldTraverseOps = {
31
34
 
32
35
  const DefaultPollFieldTraverseOps: PollFieldTraverseOps = {
33
36
  failOnError: true,
34
- onlyFinal: false
37
+ onlyFinal: false,
35
38
  };
36
39
 
37
40
  export class PollResourceAccessor {
38
41
  constructor(
39
42
  public readonly tx: PollTxAccessor,
40
43
  public readonly data: ResourceData,
41
- public readonly path: string[]
44
+ public readonly path: string[],
42
45
  ) {}
43
46
 
44
47
  public final(): PollResourceAccessor {
@@ -63,11 +66,12 @@ export class PollResourceAccessor {
63
66
  }
64
67
 
65
68
  if (
66
- ((expectedType === 'Input' || expectedType === 'Service') && this.data.inputsLocked) ||
67
- (expectedType === 'Output' && this.data.outputsLocked)
69
+ ((expectedType === 'Input' || expectedType === 'Service') && this.data.inputsLocked)
70
+ || (expectedType === 'Output' && this.data.outputsLocked)
68
71
  )
69
72
  throw new Error(
70
- `Field "${name}" not found. Expected type: ${expectedType}, state: ${this.data}`
73
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions
74
+ `Field "${name}" not found. Expected type: ${expectedType}, state: ${this.data}`,
71
75
  );
72
76
 
73
77
  throw new ContinuePolling();
@@ -75,9 +79,9 @@ export class PollResourceAccessor {
75
79
 
76
80
  public async get(
77
81
  name: string,
78
- ops: Partial<PollFieldTraverseOps> = {}
82
+ ops: Partial<PollFieldTraverseOps> = {},
79
83
  ): Promise<PollResourceAccessor> {
80
- const { expectedType, failOnError, onlyFinal } = { ...DefaultPollFieldTraverseOps, ...ops };
84
+ const { expectedType, failOnError } = { ...DefaultPollFieldTraverseOps, ...ops };
81
85
  const path = [...this.path, name];
82
86
 
83
87
  const fieldData = this.getFieldData(name, expectedType);
@@ -101,18 +105,18 @@ export class PollResourceAccessor {
101
105
  ...names: Key[]
102
106
  ): Promise<Record<Key, PollResourceAccessor>> {
103
107
  return Object.fromEntries(
104
- await Promise.all(names.map(async (name) => [name, await this.get(name, ops)]))
108
+ await Promise.all(names.map(async (name) => [name, await this.get(name, ops)])),
105
109
  );
106
110
  }
107
111
 
108
112
  public async getAllFinal(
109
- ops: Partial<PollFieldTraverseOps> = {}
113
+ ops: Partial<PollFieldTraverseOps> = {},
110
114
  ): Promise<Record<string, PollResourceAccessor>> {
111
115
  return await this.getMultiObj(
112
116
  ops,
113
117
  ...this.data.fields
114
118
  .filter((f) => f.valueIsFinal || isNotNullResourceId(f.error))
115
- .map((f) => f.name)
119
+ .map((f) => f.name),
116
120
  );
117
121
  }
118
122
 
@@ -133,7 +137,7 @@ export class PollTxAccessor {
133
137
  public async get(
134
138
  rid: ResourceId,
135
139
  failOnError: boolean = true,
136
- path: string[] = []
140
+ path: string[] = [],
137
141
  ): Promise<PollResourceAccessor> {
138
142
  const data = await this.tx.getResourceData(rid, true);
139
143
  const accessor = new PollResourceAccessor(this, data, [...path, resourceIdToString(rid)]);
@@ -143,7 +147,7 @@ export class PollTxAccessor {
143
147
 
144
148
  async throwError(error: ResourceId, path: string[] = []): Promise<never> {
145
149
  const errorRes = await this.get(error);
146
- let errorText = Buffer.from(notEmpty(errorRes.data.data)).toString();
150
+ const errorText = Buffer.from(notEmpty(errorRes.data.data)).toString();
147
151
  throw new Error(`${path.join(' -> ')} = ${errorText}`);
148
152
  }
149
153
  }
@@ -153,14 +157,14 @@ export const DefaultPollingRetryOptions: RetryOptions = {
153
157
  jitter: 0,
154
158
  maxAttempts: 100,
155
159
  backoffStep: 10,
156
- initialDelay: 10
160
+ initialDelay: 10,
157
161
  };
158
162
 
159
163
  export async function poll<T>(
160
164
  cl: PlClient,
161
165
  cb: (tx: PollTxAccessor) => Promise<T>,
162
166
  retryOptions: RetryOptions = DefaultPollingRetryOptions,
163
- txName: string = 'polling'
167
+ txName: string = 'polling',
164
168
  ): Promise<T> {
165
169
  let retryState = createRetryState(retryOptions);
166
170
  while (true) {
@@ -1,4 +1,5 @@
1
- import { FieldData, isNotNullResourceId } from '../core/types';
1
+ import type { FieldData } from '../core/types';
2
+ import { isNotNullResourceId } from '../core/types';
2
3
 
3
4
  export function fieldResolved(data: Pick<FieldData, 'value' | 'error'>) {
4
5
  return isNotNullResourceId(data.error) || isNotNullResourceId(data.value);
@@ -1,5 +1,6 @@
1
- import { PlTransaction } from '../core/transaction';
2
- import { FieldData, OptionalResourceId, isNotNullResourceId } from '../core/types';
1
+ import type { PlTransaction } from '../core/transaction';
2
+ import type { FieldData, OptionalResourceId } from '../core/types';
3
+ import { isNotNullResourceId } from '../core/types';
3
4
  import { notEmpty } from '@milaboratories/ts-helpers';
4
5
 
5
6
  export interface ValErr {
@@ -12,7 +13,7 @@ export async function valErr(tx: PlTransaction, f: FieldData): Promise<ValErr> {
12
13
  const result = {
13
14
  valueId: f.value,
14
15
  errorId: f.error,
15
- error: ''
16
+ error: '',
16
17
  };
17
18
 
18
19
  if (isNotNullResourceId(f.error)) {
@@ -1,4 +1,4 @@
1
- // @generated by protobuf-ts 2.9.5 with parameter client_generic,optimize_speed,generate_dependencies,force_server_none
1
+ // @generated by protobuf-ts 2.9.6 with parameter client_generic,optimize_speed,generate_dependencies,force_server_none
2
2
  // @generated from protobuf file "github.com/googleapis/googleapis/google/rpc/status.proto" (package "google.rpc", syntax proto3)
3
3
  // tslint:disable
4
4
  //
@@ -1,14 +1,14 @@
1
1
  // @generated by protobuf-ts 2.9.5 with parameter client_generic,optimize_speed,generate_dependencies,force_server_none
2
2
  // @generated from protobuf file "github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.proto" (package "MiLaboratories.Controller.Shared", syntax proto3)
3
3
  // tslint:disable
4
- import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
5
- import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
6
- import { Download } from "./protocol";
7
- import { stackIntercept } from "@protobuf-ts/runtime-rpc";
8
- import type { DownloadAPI_GetDownloadURL_Response } from "./protocol";
9
- import type { DownloadAPI_GetDownloadURL_Request } from "./protocol";
10
- import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
11
- import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
4
+ import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
5
+ import type { ServiceInfo } from '@protobuf-ts/runtime-rpc';
6
+ import { Download } from './protocol';
7
+ import { stackIntercept } from '@protobuf-ts/runtime-rpc';
8
+ import type { DownloadAPI_GetDownloadURL_Response } from './protocol';
9
+ import type { DownloadAPI_GetDownloadURL_Request } from './protocol';
10
+ import type { UnaryCall } from '@protobuf-ts/runtime-rpc';
11
+ import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
12
12
  /**
13
13
  *
14
14
  * Download provides access to any data, that can be downloaded via network.
@@ -17,10 +17,10 @@ import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
17
17
  * @generated from protobuf service MiLaboratories.Controller.Shared.Download
18
18
  */
19
19
  export interface IDownloadClient {
20
- /**
20
+ /**
21
21
  * @generated from protobuf rpc: GetDownloadURL(MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request) returns (MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response);
22
22
  */
23
- getDownloadURL(input: DownloadAPI_GetDownloadURL_Request, options?: RpcOptions): UnaryCall<DownloadAPI_GetDownloadURL_Request, DownloadAPI_GetDownloadURL_Response>;
23
+ getDownloadURL(input: DownloadAPI_GetDownloadURL_Request, options?: RpcOptions): UnaryCall<DownloadAPI_GetDownloadURL_Request, DownloadAPI_GetDownloadURL_Response>;
24
24
  }
25
25
  /**
26
26
  *
@@ -30,16 +30,17 @@ export interface IDownloadClient {
30
30
  * @generated from protobuf service MiLaboratories.Controller.Shared.Download
31
31
  */
32
32
  export class DownloadClient implements IDownloadClient, ServiceInfo {
33
- typeName = Download.typeName;
34
- methods = Download.methods;
35
- options = Download.options;
36
- constructor(private readonly _transport: RpcTransport) {
37
- }
38
- /**
33
+ typeName = Download.typeName;
34
+ methods = Download.methods;
35
+ options = Download.options;
36
+ constructor(private readonly _transport: RpcTransport) {
37
+ }
38
+
39
+ /**
39
40
  * @generated from protobuf rpc: GetDownloadURL(MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request) returns (MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response);
40
41
  */
41
- getDownloadURL(input: DownloadAPI_GetDownloadURL_Request, options?: RpcOptions): UnaryCall<DownloadAPI_GetDownloadURL_Request, DownloadAPI_GetDownloadURL_Response> {
42
- const method = this.methods[0], opt = this._transport.mergeOptions(options);
43
- return stackIntercept<DownloadAPI_GetDownloadURL_Request, DownloadAPI_GetDownloadURL_Response>("unary", this._transport, method, opt, input);
44
- }
42
+ getDownloadURL(input: DownloadAPI_GetDownloadURL_Request, options?: RpcOptions): UnaryCall<DownloadAPI_GetDownloadURL_Request, DownloadAPI_GetDownloadURL_Response> {
43
+ const method = this.methods[0], opt = this._transport.mergeOptions(options);
44
+ return stackIntercept<DownloadAPI_GetDownloadURL_Request, DownloadAPI_GetDownloadURL_Response>('unary', this._transport, method, opt, input);
45
+ }
45
46
  }