@milaboratories/pl-client 2.4.10 → 2.4.11
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.
- package/dist/core/auth.d.ts +6 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/client.d.ts +50 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/config.d.ts +91 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/default_client.d.ts +11 -0
- package/dist/core/default_client.d.ts.map +1 -0
- package/dist/core/driver.d.ts +18 -0
- package/dist/core/driver.d.ts.map +1 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/http.d.ts +1 -0
- package/dist/core/http.d.ts.map +1 -0
- package/dist/core/ll_client.d.ts +50 -0
- package/dist/core/ll_client.d.ts.map +1 -0
- package/dist/core/ll_transaction.d.ts +55 -0
- package/dist/core/ll_transaction.d.ts.map +1 -0
- package/dist/core/transaction.d.ts +152 -0
- package/dist/core/transaction.d.ts.map +1 -0
- package/dist/core/type_conversion.d.ts +8 -0
- package/dist/core/type_conversion.d.ts.map +1 -0
- package/dist/core/types.d.ts +77 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/unauth_client.d.ts +13 -0
- package/dist/core/unauth_client.d.ts.map +1 -0
- package/dist/helpers/pl.d.ts +34 -0
- package/dist/helpers/pl.d.ts.map +1 -0
- package/dist/helpers/poll.d.ts +39 -0
- package/dist/helpers/poll.d.ts.map +1 -0
- package/dist/helpers/rich_resource_types.d.ts +1 -0
- package/dist/helpers/rich_resource_types.d.ts.map +1 -0
- package/dist/helpers/smart_accessors.d.ts +1 -0
- package/dist/helpers/smart_accessors.d.ts.map +1 -0
- package/dist/helpers/state_helpers.d.ts +3 -0
- package/dist/helpers/state_helpers.d.ts.map +1 -0
- package/dist/helpers/tx_helpers.d.ts +9 -0
- package/dist/helpers/tx_helpers.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -14425
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12126 -0
- package/dist/index.mjs.map +1 -0
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +48 -0
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +36 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +103 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +42 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +165 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +44 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +171 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +122 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +315 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +276 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +5045 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +499 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +82 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +91 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +251 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -0
- package/dist/proto/google/api/http.d.ts +451 -0
- package/dist/proto/google/api/http.d.ts.map +1 -0
- package/dist/proto/google/protobuf/any.d.ts +172 -0
- package/dist/proto/google/protobuf/any.d.ts.map +1 -0
- package/dist/proto/google/protobuf/descriptor.d.ts +2258 -0
- package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -0
- package/dist/proto/google/protobuf/duration.d.ts +105 -0
- package/dist/proto/google/protobuf/duration.d.ts.map +1 -0
- package/dist/proto/google/protobuf/empty.d.ts +27 -0
- package/dist/proto/google/protobuf/empty.d.ts.map +1 -0
- package/dist/proto/google/protobuf/struct.d.ts +177 -0
- package/dist/proto/google/protobuf/struct.d.ts.map +1 -0
- package/dist/proto/google/protobuf/timestamp.d.ts +148 -0
- package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -0
- package/dist/proto/google/protobuf/wrappers.d.ts +300 -0
- package/dist/proto/google/protobuf/wrappers.d.ts.map +1 -0
- package/dist/test/test_config.d.ts +18 -0
- package/dist/test/test_config.d.ts.map +1 -0
- package/dist/util/branding.d.ts +7 -0
- package/dist/util/branding.d.ts.map +1 -0
- package/dist/util/pl.d.ts +9 -0
- package/dist/util/pl.d.ts.map +1 -0
- package/dist/util/util.d.ts +2 -0
- package/dist/util/util.d.ts.map +1 -0
- package/package.json +10 -14
- package/dist/index.cjs +0 -14527
- package/dist/index.cjs.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthInformation } from './config';
|
|
2
|
+
/** Returns a timestamp when current authorization information should be refreshed.
|
|
3
|
+
* Compare the value with Date.now(). */
|
|
4
|
+
export declare function inferAuthRefreshTime(info: AuthInformation, maxRefreshSeconds: number): number | undefined;
|
|
5
|
+
export declare function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined;
|
|
6
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/core/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;wCACwC;AACxC,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,eAAe,EACrB,iBAAiB,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAI3F"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AuthOps, PlClientConfig, PlConnectionStatusListener } from './config';
|
|
2
|
+
import { PlCallOps } from './ll_client';
|
|
3
|
+
import { PlTransaction } from './transaction';
|
|
4
|
+
import { ResourceId } from './types';
|
|
5
|
+
import { RetryOptions } from '@milaboratories/ts-helpers';
|
|
6
|
+
import { PlDriver, PlDriverDefinition } from './driver';
|
|
7
|
+
import { MaintenanceAPI_Ping_Response } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
|
|
8
|
+
import { Dispatcher } from 'undici';
|
|
9
|
+
export type TxOps = PlCallOps & {
|
|
10
|
+
sync?: boolean;
|
|
11
|
+
retryOptions?: RetryOptions;
|
|
12
|
+
};
|
|
13
|
+
/** Client to access core PL API. */
|
|
14
|
+
export declare class PlClient {
|
|
15
|
+
private readonly ll;
|
|
16
|
+
private readonly drivers;
|
|
17
|
+
/** Artificial delay introduced after write transactions completion, to
|
|
18
|
+
* somewhat throttle the load on pl. Delay introduced after sync, if requested. */
|
|
19
|
+
private readonly txDelay;
|
|
20
|
+
/** Last resort measure to solve complicated race conditions in pl. */
|
|
21
|
+
private readonly forceSync;
|
|
22
|
+
/** Last resort measure to solve complicated race conditions in pl. */
|
|
23
|
+
private readonly defaultRetryOptions;
|
|
24
|
+
/** Stores client root (this abstraction is intended for future implementation of the security model)*/
|
|
25
|
+
private _clientRoot;
|
|
26
|
+
private _serverInfo;
|
|
27
|
+
private constructor();
|
|
28
|
+
ping(): Promise<MaintenanceAPI_Ping_Response>;
|
|
29
|
+
get conf(): PlClientConfig;
|
|
30
|
+
get httpDispatcher(): Dispatcher;
|
|
31
|
+
private get initialized();
|
|
32
|
+
private checkInitialized;
|
|
33
|
+
get clientRoot(): ResourceId;
|
|
34
|
+
get serverInfo(): MaintenanceAPI_Ping_Response;
|
|
35
|
+
/** Currently implements custom logic to emulate future behaviour with single root. */
|
|
36
|
+
init(): Promise<void>;
|
|
37
|
+
/** Returns true if field existed */
|
|
38
|
+
deleteAlternativeRoot(alternativeRootName: string): Promise<boolean>;
|
|
39
|
+
private _withTx;
|
|
40
|
+
private withTx;
|
|
41
|
+
withWriteTx<T>(name: string, body: (tx: PlTransaction) => Promise<T>, ops?: Partial<TxOps>): Promise<T>;
|
|
42
|
+
withReadTx<T>(name: string, body: (tx: PlTransaction) => Promise<T>, ops?: Partial<TxOps>): Promise<T>;
|
|
43
|
+
getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv;
|
|
44
|
+
/** Closes underlying transport */
|
|
45
|
+
close(): void;
|
|
46
|
+
static init(configOrAddress: PlClientConfig | string, auth: AuthOps, ops?: {
|
|
47
|
+
statusListener?: PlConnectionStatusListener;
|
|
48
|
+
}): Promise<PlClient>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAc,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAkB,aAAa,EAAwC,MAAM,eAAe,CAAC;AAEpG,OAAO,EAKL,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAIL,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0DAA0D,CAAC;AAExG,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAYF,oCAAoC;AACpC,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IAEvD;sFACkF;IAClF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IAEpC,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAe;IAEnD,uGAAuG;IACvG,O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|
+
hostAndPort: string;
|
|
5
|
+
/** If set, client will expose a nested object under a field with name `alternative_root_${alternativeRoot}` as a
|
|
6
|
+
* client root. */
|
|
7
|
+
alternativeRoot?: string;
|
|
8
|
+
/** If true, client will establish tls connection to the server, using default
|
|
9
|
+
* CA of node instance. */
|
|
10
|
+
ssl: boolean;
|
|
11
|
+
/** Default timeout in milliseconds for unary calls, like ping and login. */
|
|
12
|
+
defaultRequestTimeout: number;
|
|
13
|
+
/** Default timeout in milliseconds for transaction, should be adjusted for
|
|
14
|
+
* long round-trip connections. */
|
|
15
|
+
defaultTransactionTimeout: number;
|
|
16
|
+
/** Controls what TTL will be requested from the server, when new JWT token
|
|
17
|
+
* is requested. */
|
|
18
|
+
authTTLSeconds: number;
|
|
19
|
+
/** If token is older than this time, it will be refreshed regardless of its
|
|
20
|
+
* expiration time. */
|
|
21
|
+
authMaxRefreshSeconds: number;
|
|
22
|
+
/** Proxy server URL to use for pl connection. */
|
|
23
|
+
grpcProxy?: string;
|
|
24
|
+
/** Proxy server URL to use for http connections of pl drivers, like file
|
|
25
|
+
* downloading. */
|
|
26
|
+
httpProxy?: string;
|
|
27
|
+
/** Username extracted from pl URL. Ignored by {@link PlClient}, picked up by {@link defaultPlClient}. */
|
|
28
|
+
user?: string;
|
|
29
|
+
/** Password extracted from pl URL. Ignored by {@link PlClient}, picked up by {@link defaultPlClient}. */
|
|
30
|
+
password?: string;
|
|
31
|
+
/** Artificial delay introduced after write transactions completion, to
|
|
32
|
+
* somewhat throttle the load on pl. Delay introduced after sync, if requested. */
|
|
33
|
+
txDelay: number;
|
|
34
|
+
/** Last resort measure to solve complicated race conditions in pl. */
|
|
35
|
+
forceSync: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* What type of backoff strategy to use in transaction retries
|
|
38
|
+
* (pl uses optimistic transaction model with regular retries in write transactions)
|
|
39
|
+
* */
|
|
40
|
+
retryBackoffAlgorithm: 'exponential' | 'linear';
|
|
41
|
+
/** Maximal number of attempts in */
|
|
42
|
+
retryMaxAttempts: number;
|
|
43
|
+
/** Delay after first failed attempt, in ms. */
|
|
44
|
+
retryInitialDelay: number;
|
|
45
|
+
/** Each time delay will be multiplied by this number (1.5 means plus on 50% each attempt) */
|
|
46
|
+
retryExponentialBackoffMultiplier: number;
|
|
47
|
+
/** [used only for ] This value will be added to the delay from the previous step, in ms */
|
|
48
|
+
retryLinearBackoffStep: number;
|
|
49
|
+
/** Value from 0 to 1, determine level of randomness to introduce to the backoff delays sequence. (0 meaning no randomness) */
|
|
50
|
+
retryJitter: number;
|
|
51
|
+
}
|
|
52
|
+
export declare const DEFAULT_REQUEST_TIMEOUT = 1000;
|
|
53
|
+
export declare const DEFAULT_TX_TIMEOUT = 10000;
|
|
54
|
+
export declare const DEFAULT_TOKEN_TTL_SECONDS: number;
|
|
55
|
+
export declare const DEFAULT_AUTH_MAX_REFRESH: number;
|
|
56
|
+
export declare const DEFAULT_RETRY_BACKOFF_ALGORITHM = "exponential";
|
|
57
|
+
export declare const DEFAULT_RETRY_MAX_ATTEMPTS = 10;
|
|
58
|
+
export declare const DEFAULT_RETRY_INITIAL_DELAY = 4;
|
|
59
|
+
export declare const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 2;
|
|
60
|
+
export declare const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50;
|
|
61
|
+
export declare const DEFAULT_RETRY_JITTER = 0.3;
|
|
62
|
+
type PlConfigOverrides = Partial<Pick<PlClientConfig, 'ssl' | 'defaultRequestTimeout' | 'defaultTransactionTimeout' | 'httpProxy' | 'grpcProxy'>>;
|
|
63
|
+
/** Parses pl url and creates a config object that can be passed to
|
|
64
|
+
* {@link PlClient} of {@link UnauthenticatedPlClient}. */
|
|
65
|
+
export declare function plAddressToConfig(address: string, overrides?: PlConfigOverrides): PlClientConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Authorization data / JWT Token.
|
|
68
|
+
* Absent JWT Token tells the client to connect as anonymous user.
|
|
69
|
+
* */
|
|
70
|
+
export interface AuthInformation {
|
|
71
|
+
/** Absent token means anonymous access */
|
|
72
|
+
jwtToken?: string;
|
|
73
|
+
}
|
|
74
|
+
export declare const AnonymousAuthInformation: AuthInformation;
|
|
75
|
+
/** Authorization related settings to pass to {@link PlClient}. */
|
|
76
|
+
export interface AuthOps {
|
|
77
|
+
/** Initial authorization information */
|
|
78
|
+
authInformation: AuthInformation;
|
|
79
|
+
/** Will be executed after successful authorization information refresh */
|
|
80
|
+
readonly onUpdate?: (newInfo: AuthInformation) => void;
|
|
81
|
+
/** Will be executed if auth-related error happens during normal client operation */
|
|
82
|
+
readonly onAuthError?: () => void;
|
|
83
|
+
/** Will be executed if error encountered during token update */
|
|
84
|
+
readonly onUpdateError?: (error: unknown) => void;
|
|
85
|
+
}
|
|
86
|
+
/** Connection status. */
|
|
87
|
+
export type PlConnectionStatus = 'OK' | 'Disconnected' | 'Unauthenticated';
|
|
88
|
+
/** Listener that will be called each time connection status changes. */
|
|
89
|
+
export type PlConnectionStatusListener = (status: PlConnectionStatus) => void;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IAEpB;sBACkB;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;8BAC0B;IAI1B,GAAG,EAAE,OAAO,CAAC;IAEb,4EAA4E;IAC5E,qBAAqB,EAAE,MAAM,CAAC;IAC9B;sCACkC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAElC;uBACmB;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB;0BACsB;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAE9B,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;sBACkB;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C1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,wBAAwB,EAAE,eAAoB,CAAC;AAE5D,kEAAkE;AAClE,MAAM,WAAW,OAAO;IACtB,wCAAwC;IACxC,eAAe,EAAE,eAAe,CAAC;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACvD,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,gEAAgE;IAChE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AAED,yBAAyB;AACzB,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAE3E,wEAAwE;AACxE,MAAM,MAAM,0BAA0B,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PlClientConfig } from './config';
|
|
2
|
+
import { PlClient } from './client';
|
|
3
|
+
type FileConfigOverrideFields = 'grpcProxy' | 'httpProxy' | 'user' | 'password' | 'alternativeRoot' | 'defaultTransactionTimeout' | 'defaultRequestTimeout' | 'authTTLSeconds' | 'authMaxRefreshSeconds';
|
|
4
|
+
type PlConfigFile = {
|
|
5
|
+
address: string;
|
|
6
|
+
} & Partial<Pick<PlClientConfig, FileConfigOverrideFields>>;
|
|
7
|
+
export declare function tryGetFileConfig(): [PlConfigFile, string] | undefined;
|
|
8
|
+
/** Uses default algorithm to construct a pl client from the environment */
|
|
9
|
+
export declare function defaultPlClient(): Promise<PlClient>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=default_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default_client.d.ts","sourceRoot":"","sources":["../../src/core/default_client.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,cAAc,EAAE,MAAM,UAAU,CAAC;AAO9E,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAiBpC,KAAK,wBAAwB,GACzB,WAAW,GACX,WAAW,GACX,MAAM,GACN,UAAU,GACV,iBAAiB,GACjB,2BAA2B,GAC3B,uBAAuB,GACvB,gBAAgB,GAChB,uBAAuB,CAAC;AAa5B,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC,CAAC;AAS5D,wBAAgB,gBAAgB,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,SAAS,CAQrE;AAyBD,2EAA2E;AAC3E,wBAAsB,eAAe,IAAI,OAAO,CAAC,QAAQ,CAAC,CAoEzD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PlClient } from './client';
|
|
2
|
+
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
3
|
+
import { RpcOptions } from '@protobuf-ts/runtime-rpc';
|
|
4
|
+
import { Dispatcher } from 'undici';
|
|
5
|
+
import { ResourceType } from './types';
|
|
6
|
+
/** Drivers must implement this interface */
|
|
7
|
+
export interface PlDriver {
|
|
8
|
+
close(): void;
|
|
9
|
+
}
|
|
10
|
+
/** Definition to use driver via {@link PlClient} */
|
|
11
|
+
export interface PlDriverDefinition<Drv extends PlDriver> {
|
|
12
|
+
/** Used as key to only once instantiate specific drivers */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/** Initialization routine, will be executed only once for each driver in a specific client */
|
|
15
|
+
init(pl: PlClient, grpcTransport: GrpcTransport, httpDispatcher: Dispatcher): Drv;
|
|
16
|
+
}
|
|
17
|
+
export declare function addRTypeToMetadata(rType: ResourceType, options?: RpcOptions): RpcOptions;
|
|
18
|
+
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/core/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,4CAA4C;AAC5C,MAAM,WAAW,QAAQ;IACvB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,oDAAoD;AACpD,MAAM,WAAW,kBAAkB,CAAC,GAAG,SAAS,QAAQ;IACtD,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,8FAA8F;IAC9F,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,GAAG,GAAG,CAAC;CACnF;AAKD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,UAAU,cAM3E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Status } from '../proto/github.com/googleapis/googleapis/google/rpc/status';
|
|
2
|
+
export declare function isConnectionProblem(err: unknown, nested?: boolean): boolean;
|
|
3
|
+
export declare function isUnauthenticated(err: unknown, nested?: boolean): boolean;
|
|
4
|
+
export declare function isTimeoutOrCancelError(err: unknown, nested?: boolean): boolean;
|
|
5
|
+
export declare const PlErrorCodeNotFound = 5;
|
|
6
|
+
export declare class PlError extends Error {
|
|
7
|
+
readonly status: Status;
|
|
8
|
+
constructor(status: Status);
|
|
9
|
+
}
|
|
10
|
+
export declare function throwPlNotFoundError(message: string): never;
|
|
11
|
+
export declare class RecoverablePlError extends PlError {
|
|
12
|
+
constructor(status: Status);
|
|
13
|
+
}
|
|
14
|
+
export declare class UnrecoverablePlError extends PlError {
|
|
15
|
+
constructor(status: Status);
|
|
16
|
+
}
|
|
17
|
+
export declare function isNotFoundError(err: unknown, nested?: boolean): boolean;
|
|
18
|
+
export declare class UnauthenticatedError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class DisconnectedError extends Error {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
export declare function rethrowMeaningfulError(error: any, wrapIfUnknown?: boolean): never;
|
|
25
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6DAA6D,CAAC;AAGrF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAOlF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAOhF;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAYrF;AAED,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,qBAAa,OAAQ,SAAQ,KAAK;aACJ,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;CAG3C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE3D;AAED,qBAAa,kBAAmB,SAAQ,OAAO;gBACjC,MAAM,EAAE,MAAM;CAG3B;AAED,qBAAa,oBAAqB,SAAQ,OAAO;gBACnC,MAAM,EAAE,MAAM;CAG3B;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAI9E;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,aAAa,GAAE,OAAe,GAAG,KAAK,CAMxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PlatformClient } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api.client';
|
|
2
|
+
import { AuthOps, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener } from './config';
|
|
3
|
+
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
4
|
+
import { LLPlTransaction } from './ll_transaction';
|
|
5
|
+
import { Dispatcher } from 'undici';
|
|
6
|
+
export interface PlCallOps {
|
|
7
|
+
timeout?: number;
|
|
8
|
+
abortSignal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/** Abstract out low level networking and authorization details */
|
|
11
|
+
export declare class LLPlClient {
|
|
12
|
+
readonly conf: PlClientConfig;
|
|
13
|
+
/** Initial authorization information */
|
|
14
|
+
private authInformation?;
|
|
15
|
+
/** Will be executed by the client when it is required */
|
|
16
|
+
private readonly onAuthUpdate?;
|
|
17
|
+
/** Will be executed if auth-related error happens during normal client operation */
|
|
18
|
+
private readonly onAuthError?;
|
|
19
|
+
/** Will be executed by the client when it is required */
|
|
20
|
+
private readonly onAuthRefreshProblem?;
|
|
21
|
+
/** Threshold after which auth info refresh is required */
|
|
22
|
+
private refreshTimestamp?;
|
|
23
|
+
private _status;
|
|
24
|
+
private readonly statusListener?;
|
|
25
|
+
readonly grpcTransport: GrpcTransport;
|
|
26
|
+
readonly grpcPl: PlatformClient;
|
|
27
|
+
readonly httpDispatcher: Dispatcher;
|
|
28
|
+
constructor(configOrAddress: PlClientConfig | string, ops?: {
|
|
29
|
+
auth?: AuthOps;
|
|
30
|
+
statusListener?: PlConnectionStatusListener;
|
|
31
|
+
});
|
|
32
|
+
/** Returns true if client is authenticated. Even with anonymous auth information
|
|
33
|
+
* connection is considered authenticated. Unauthenticated clients are used for
|
|
34
|
+
* login and similar tasks, see {@link UnauthenticatedPlClient}. */
|
|
35
|
+
get authenticated(): boolean;
|
|
36
|
+
/** null means anonymous connection */
|
|
37
|
+
get authUser(): string | null;
|
|
38
|
+
private updateStatus;
|
|
39
|
+
get status(): PlConnectionStatus;
|
|
40
|
+
private authRefreshInProgress;
|
|
41
|
+
private refreshAuthInformationIfNeeded;
|
|
42
|
+
/** Detects certain errors and update client status accordingly */
|
|
43
|
+
private createErrorInterceptor;
|
|
44
|
+
/** Injects authentication information if needed */
|
|
45
|
+
private createAuthInterceptor;
|
|
46
|
+
createTx(ops?: PlCallOps): LLPlTransaction;
|
|
47
|
+
/** Closes underlying transport */
|
|
48
|
+
close(): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=ll_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ll_client.d.ts","sourceRoot":"","sources":["../../src/core/ll_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iEAAiE,CAAC;AAOjG,OAAO,EAEL,OAAO,EAEP,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAe,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAS,UAAU,EAAc,MAAM,QAAQ,CAAC;AAGvD,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,kEAAkE;AAClE,qBAAa,UAAU;IACrB,SAAgB,IA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rpc';
|
|
3
|
+
export type ClientMessageRequest = TxAPI_ClientMessage['request'];
|
|
4
|
+
export type ServerMessageResponse = TxAPI_ServerMessage['response'];
|
|
5
|
+
type TxStream = DuplexStreamingCall<TxAPI_ClientMessage, TxAPI_ServerMessage>;
|
|
6
|
+
export type OneOfKind<T extends {
|
|
7
|
+
oneofKind: unknown;
|
|
8
|
+
}, Kind extends T['oneofKind']> = Extract<T, {
|
|
9
|
+
oneofKind: Kind;
|
|
10
|
+
}>;
|
|
11
|
+
export declare class RethrowError extends Error {
|
|
12
|
+
readonly rethrowLambda: () => never;
|
|
13
|
+
constructor(rethrowLambda: () => never);
|
|
14
|
+
}
|
|
15
|
+
export declare class LLPlTransaction {
|
|
16
|
+
/** Bidirectional channel through which transaction communicates with the server */
|
|
17
|
+
private readonly stream;
|
|
18
|
+
/** Used to abort ongoing transaction stream */
|
|
19
|
+
private readonly abortController;
|
|
20
|
+
/** Counter of sent requests, used to calculate which future response will correspond to this request.
|
|
21
|
+
* Incremented on each sent request. */
|
|
22
|
+
private requestIdxCounter;
|
|
23
|
+
/** Queue from which incoming message processor takes handlers to which pass incoming messages */
|
|
24
|
+
private readonly responseHandlerQueue;
|
|
25
|
+
/** Each new resource, created by the transaction, is assigned with virtual (local) resource id, to make it possible
|
|
26
|
+
* to populate its fields without awaiting actual resource id. This counter tracks those ids on client side, the
|
|
27
|
+
* same way it is tracked on the server, so client can synchronously return such ids to the user. */
|
|
28
|
+
private localResourceIdCounter;
|
|
29
|
+
/** Switches to true, when this transaction closes due to normal or exceptional conditions. Prevents any new messages
|
|
30
|
+
* to be sent to the stream. */
|
|
31
|
+
private closed;
|
|
32
|
+
/** Whether the outgoing stream was already closed. */
|
|
33
|
+
private completed;
|
|
34
|
+
/** If this transaction was terminated due to error, this is a generator to create new errors if corresponding response is required. */
|
|
35
|
+
private errorFactory?;
|
|
36
|
+
/** Timestamp when transaction was opened */
|
|
37
|
+
private readonly openTimestamp;
|
|
38
|
+
private readonly incomingProcessorResult;
|
|
39
|
+
constructor(streamFactory: (abortSignal: AbortSignal) => TxStream);
|
|
40
|
+
private assignErrorFactoryIfNotSet;
|
|
41
|
+
private incomingEventProcessor;
|
|
42
|
+
/** Executed after termination of incoming message processor */
|
|
43
|
+
private close;
|
|
44
|
+
/** Forcefully close the transaction, terminate all connections and reject all pending requests */
|
|
45
|
+
abort(cause?: Error): void;
|
|
46
|
+
/** Await incoming message loop termination and throw any leftover errors if it was unsuccessful */
|
|
47
|
+
await(): Promise<void>;
|
|
48
|
+
send<Kind extends ClientMessageRequest['oneofKind']>(r: OneOfKind<ClientMessageRequest, Kind>, expectMultiResponse: false): Promise<OneOfKind<ServerMessageResponse, Kind>>;
|
|
49
|
+
send<Kind extends ClientMessageRequest['oneofKind']>(r: OneOfKind<ClientMessageRequest, Kind>, expectMultiResponse: true): Promise<OneOfKind<ServerMessageResponse, Kind>[]>;
|
|
50
|
+
private _completed;
|
|
51
|
+
/** Safe to call multiple times */
|
|
52
|
+
complete(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=ll_transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ll_transaction.d.ts","sourceRoot":"","sources":["../../src/core/ll_transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAU/D,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAEpE,KAAK,QAAQ,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;AAE9E,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAAE,IAAI,SAAS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AS,oBAAoB,CAAC,WAAW,CAAC,EAC9D,CAAC,EAAE,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,EACxC,mBAAmB,EAAE,IAAI,GACxB,OAAO,CAAC,SAAS,CAAC,qBAAqB,EAAE,IAAI,CAAC,EAAE,CAAC;IAgCpD,OAAO,CAAC,UAAU,CAAS;IAE3B,kCAAkC;IACrB,QAAQ;CAKtB"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { AnyResourceId, LocalResourceId, OptionalResourceId, BasicResourceData, FieldData, FieldType, ResourceData, ResourceId, ResourceType, FutureFieldType } from './types';
|
|
2
|
+
import { LLPlTransaction } from './ll_transaction';
|
|
3
|
+
/** Reference to resource, used only within transaction */
|
|
4
|
+
export interface ResourceRef {
|
|
5
|
+
/** Global resource id of newly created resources, become available only
|
|
6
|
+
* after response for the corresponding creation request is received. */
|
|
7
|
+
readonly globalId: Promise<ResourceId>;
|
|
8
|
+
/** Transaction-local resource id is assigned right after resource creation
|
|
9
|
+
* request is sent, and can be used right away */
|
|
10
|
+
readonly localId: LocalResourceId;
|
|
11
|
+
}
|
|
12
|
+
/** Key-Value pair from resource-attached KV storage */
|
|
13
|
+
export interface KeyValue {
|
|
14
|
+
key: string;
|
|
15
|
+
value: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
/** Key-Value pair from resource-attached KV storage */
|
|
18
|
+
export interface KeyValueString {
|
|
19
|
+
key: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
interface _FieldId<RId> {
|
|
23
|
+
/** Parent resource id */
|
|
24
|
+
resourceId: RId;
|
|
25
|
+
/** Field name */
|
|
26
|
+
fieldName: string;
|
|
27
|
+
}
|
|
28
|
+
export type FieldId = _FieldId<ResourceId>;
|
|
29
|
+
export type FieldRef = _FieldId<ResourceRef>;
|
|
30
|
+
export type LocalFieldId = _FieldId<LocalResourceId>;
|
|
31
|
+
export type AnyFieldId = FieldId | LocalFieldId;
|
|
32
|
+
export type AnyResourceRef = ResourceRef | ResourceId;
|
|
33
|
+
export type AnyFieldRef = _FieldId<AnyResourceRef>;
|
|
34
|
+
export type AnyRef = AnyResourceRef | AnyFieldRef;
|
|
35
|
+
export declare function isField(ref: AnyRef): ref is AnyFieldRef;
|
|
36
|
+
export declare function isResource(ref: AnyRef): ref is AnyResourceRef;
|
|
37
|
+
export declare function isFieldRef(ref: AnyFieldRef): ref is FieldRef;
|
|
38
|
+
export declare function isResourceRef(ref: AnyResourceRef): ref is ResourceRef;
|
|
39
|
+
export declare function toFieldId(ref: AnyFieldRef): AnyFieldId;
|
|
40
|
+
export declare function toGlobalFieldId(ref: AnyFieldRef): Promise<FieldId>;
|
|
41
|
+
export declare function toResourceId(ref: AnyResourceRef): AnyResourceId;
|
|
42
|
+
export declare function toGlobalResourceId(ref: AnyResourceRef): Promise<ResourceId>;
|
|
43
|
+
export declare function field(resourceId: AnyResourceRef, fieldName: string): AnyFieldRef;
|
|
44
|
+
/** If transaction commit failed due to write conflicts */
|
|
45
|
+
export declare class TxCommitConflict extends Error {
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Each platform transaction has 3 stages:
|
|
49
|
+
* - initialization (txOpen message -> txInfo response)
|
|
50
|
+
* - communication (create resources, fields, references and so on)
|
|
51
|
+
* - finalization (txCommit or txDiscard message)
|
|
52
|
+
*
|
|
53
|
+
* This class encapsulates finalization stage and provides ready-to-communication transaction object.
|
|
54
|
+
* */
|
|
55
|
+
export declare class PlTransaction {
|
|
56
|
+
private readonly ll;
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly writable: boolean;
|
|
59
|
+
private readonly _clientRoot;
|
|
60
|
+
private readonly globalTxId;
|
|
61
|
+
private readonly localTxId;
|
|
62
|
+
private localResourceIdCounter;
|
|
63
|
+
/** Store logical tx open / closed state to prevent invalid sequence of requests.
|
|
64
|
+
* True means output stream was completed.
|
|
65
|
+
* Contract: there must be no async operations between setting this field to true and sending complete signal to stream.*/
|
|
66
|
+
private _completed;
|
|
67
|
+
/** Void operation futures are placed into this pool, and corresponding method return immediately.
|
|
68
|
+
* This is done to save number of round-trips. Next operation producing result will also await those
|
|
69
|
+
* pending ops, to throw any pending errors. */
|
|
70
|
+
private pendingVoidOps;
|
|
71
|
+
constructor(ll: LLPlTransaction, name: string, writable: boolean, _clientRoot: OptionalResourceId);
|
|
72
|
+
private drainAndAwaitPendingOps;
|
|
73
|
+
private sendSingleAndParse;
|
|
74
|
+
private sendMultiAndParse;
|
|
75
|
+
private sendVoidSync;
|
|
76
|
+
/** Requests sent with this method should never produce recoverable errors */
|
|
77
|
+
private sendVoidAsync;
|
|
78
|
+
private checkTxOpen;
|
|
79
|
+
get completed(): boolean;
|
|
80
|
+
/** Commit & closes transaction. {@link TxCommitConflict} is thrown on
|
|
81
|
+
* commit conflicts. */
|
|
82
|
+
commit(): Promise<void>;
|
|
83
|
+
discard(): Promise<void>;
|
|
84
|
+
get clientRoot(): ResourceId;
|
|
85
|
+
createSingleton(name: string, type: ResourceType, errorIfExists?: boolean): ResourceRef;
|
|
86
|
+
getSingleton(name: string, loadFields: true): Promise<ResourceData>;
|
|
87
|
+
getSingleton(name: string, loadFields: false): Promise<BasicResourceData>;
|
|
88
|
+
private createResource;
|
|
89
|
+
createRoot(type: ResourceType): ResourceRef;
|
|
90
|
+
createStruct(type: ResourceType, data?: Uint8Array | string): ResourceRef;
|
|
91
|
+
createEphemeral(type: ResourceType, data?: Uint8Array | string): ResourceRef;
|
|
92
|
+
createValue(type: ResourceType, data: Uint8Array | string, errorIfExists?: boolean): ResourceRef;
|
|
93
|
+
setResourceName(name: string, rId: AnyResourceRef): void;
|
|
94
|
+
deleteResourceName(name: string): void;
|
|
95
|
+
getResourceByName(name: string): Promise<ResourceId>;
|
|
96
|
+
checkResourceNameExists(name: string): Promise<boolean>;
|
|
97
|
+
removeResource(rId: ResourceId): void;
|
|
98
|
+
resourceExists(rId: ResourceId): Promise<boolean>;
|
|
99
|
+
getResourceData(rId: AnyResourceRef, loadFields: true): Promise<ResourceData>;
|
|
100
|
+
getResourceData(rId: AnyResourceRef, loadFields: false): Promise<BasicResourceData>;
|
|
101
|
+
getResourceData(rId: AnyResourceRef, loadFields: boolean): Promise<BasicResourceData | ResourceData>;
|
|
102
|
+
getResourceDataIfExists(rId: AnyResourceRef, loadFields: true): Promise<ResourceData | undefined>;
|
|
103
|
+
getResourceDataIfExists(rId: AnyResourceRef, loadFields: false): Promise<BasicResourceData | undefined>;
|
|
104
|
+
getResourceDataIfExists(rId: AnyResourceRef, loadFields: boolean): Promise<BasicResourceData | ResourceData | undefined>;
|
|
105
|
+
/**
|
|
106
|
+
* Inform platform that resource will not get any new input fields.
|
|
107
|
+
* This is required, when client creates resource without schema and wants
|
|
108
|
+
* controller to start calculations.
|
|
109
|
+
* Most controllers will not start calculations even when all inputs
|
|
110
|
+
* have their values, if inputs list is not locked.
|
|
111
|
+
*/
|
|
112
|
+
lockInputs(rId: AnyResourceRef): void;
|
|
113
|
+
/**
|
|
114
|
+
* Inform platform that resource will not get any new output fields.
|
|
115
|
+
* This is required for resource to pass deduplication.
|
|
116
|
+
*/
|
|
117
|
+
lockOutputs(rId: AnyResourceRef): void;
|
|
118
|
+
lock(rID: AnyResourceRef): void;
|
|
119
|
+
createField(fId: AnyFieldRef, fieldType: FieldType, value?: AnyRef): void;
|
|
120
|
+
fieldExists(fId: AnyFieldRef): Promise<boolean>;
|
|
121
|
+
setField(fId: AnyFieldRef, ref: AnyRef): void;
|
|
122
|
+
setFieldError(fId: AnyFieldRef, ref: AnyResourceRef): void;
|
|
123
|
+
getField(fId: AnyFieldRef): Promise<FieldData>;
|
|
124
|
+
getFieldIfExists(fId: AnyFieldRef): Promise<FieldData | undefined>;
|
|
125
|
+
resetField(fId: AnyFieldRef): void;
|
|
126
|
+
removeField(fId: AnyFieldRef): void;
|
|
127
|
+
listKeyValues(rId: AnyResourceRef): Promise<KeyValue[]>;
|
|
128
|
+
listKeyValuesString(rId: AnyResourceRef): Promise<KeyValueString[]>;
|
|
129
|
+
listKeyValuesIfResourceExists(rId: AnyResourceRef): Promise<KeyValue[] | undefined>;
|
|
130
|
+
listKeyValuesStringIfResourceExists(rId: AnyResourceRef): Promise<KeyValueString[] | undefined>;
|
|
131
|
+
setKValue(rId: AnyResourceRef, key: string, value: Uint8Array | string): void;
|
|
132
|
+
deleteKValue(rId: AnyResourceRef, key: string): void;
|
|
133
|
+
getKValue(rId: AnyResourceRef, key: string): Promise<Uint8Array>;
|
|
134
|
+
getKValueString(rId: AnyResourceRef, key: string): Promise<string>;
|
|
135
|
+
getKValueJson<T>(rId: AnyResourceRef, key: string): Promise<T>;
|
|
136
|
+
getKValueIfExists(rId: AnyResourceRef, key: string): Promise<Uint8Array | undefined>;
|
|
137
|
+
getKValueStringIfExists(rId: AnyResourceRef, key: string): Promise<string | undefined>;
|
|
138
|
+
getKValueJsonIfExists<T>(rId: AnyResourceRef, key: string): Promise<T | undefined>;
|
|
139
|
+
/** Resolves existing or create first level resource from */
|
|
140
|
+
getFutureFieldValue(rId: AnyRef, fieldName: string, fieldType: FutureFieldType): FieldRef;
|
|
141
|
+
getGlobalTxId(): Promise<bigint>;
|
|
142
|
+
/** Closes output event stream */
|
|
143
|
+
complete(): Promise<void>;
|
|
144
|
+
/** Await incoming message loop termination and throw
|
|
145
|
+
* any leftover errors if it was unsuccessful */
|
|
146
|
+
await(): Promise<void>;
|
|
147
|
+
private nextLocalResourceId;
|
|
148
|
+
private static localTxIdCounter;
|
|
149
|
+
private static nextLocalTxId;
|
|
150
|
+
}
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/core/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGb,eAAe,EAEf,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,YAAY,EAC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nC,KAAK;IAQlB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAK;IAEpC,OAAO,CAAC,MAAM,CAAC,aAAa;CAK7B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Field, Resource } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';
|
|
2
|
+
import { FieldType as GrpcFieldType } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/base_types';
|
|
3
|
+
import { FieldData, FieldType, ResourceData } from './types';
|
|
4
|
+
/** Throws "native" pl not found error, if resource is marked as deleted. */
|
|
5
|
+
export declare function protoToResource(proto: Resource): ResourceData;
|
|
6
|
+
export declare function protoToField(proto: Field): FieldData;
|
|
7
|
+
export declare function fieldTypeToProto(type: FieldType): GrpcFieldType;
|
|
8
|
+
//# sourceMappingURL=type_conversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_conversion.d.ts","sourceRoot":"","sources":["../../src/core/type_conversion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,QAAQ,EAET,MAAM,gEAAgE,CAAC;AACxE,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,iEAAiE,CAAC;AAC7G,OAAO,EACL,SAAS,EAIT,SAAS,EACT,YAAY,EAGb,MAAM,SAAS,CAAC;AAUjB,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAe7D;AAkBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CASpD;AAkCD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,CAiB/D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
declare const __resource_id_type__: unique symbol;
|
|
2
|
+
type BrandResourceId<B> = bigint & {
|
|
3
|
+
[__resource_id_type__]: B;
|
|
4
|
+
};
|
|
5
|
+
/** Global resource id */
|
|
6
|
+
export type ResourceId = BrandResourceId<'global'>;
|
|
7
|
+
/** Null resource id */
|
|
8
|
+
export type NullResourceId = BrandResourceId<'null'>;
|
|
9
|
+
/** Local resource id */
|
|
10
|
+
export type LocalResourceId = BrandResourceId<'local'>;
|
|
11
|
+
/** Any non-null resource id */
|
|
12
|
+
export type AnyResourceId = ResourceId | LocalResourceId;
|
|
13
|
+
/** Any resource id */
|
|
14
|
+
export type OptionalResourceId = NullResourceId | ResourceId;
|
|
15
|
+
/** All possible resource flavours */
|
|
16
|
+
export type OptionalAnyResourceId = NullResourceId | ResourceId | LocalResourceId;
|
|
17
|
+
export declare const NullResourceId: NullResourceId;
|
|
18
|
+
export declare function isNullResourceId(resourceId: bigint): resourceId is NullResourceId;
|
|
19
|
+
export declare function isNotNullResourceId(resourceId: OptionalResourceId): resourceId is ResourceId;
|
|
20
|
+
export declare function ensureResourceIdNotNull(resourceId: OptionalResourceId): ResourceId;
|
|
21
|
+
export declare function isAnyResourceId(resourceId: bigint): resourceId is AnyResourceId;
|
|
22
|
+
export type ResourceKind = 'Structural' | 'Value';
|
|
23
|
+
export type FieldType = 'Input' | 'Output' | 'Service' | 'OTW' | 'Dynamic' | 'MTW';
|
|
24
|
+
export type FutureFieldType = 'Output' | 'Input' | 'Service';
|
|
25
|
+
export type FieldStatus = 'Empty' | 'Assigned' | 'Resolved';
|
|
26
|
+
export interface ResourceType {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly version: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function resourceType(name: string, version: string): ResourceType;
|
|
31
|
+
export declare function resourceTypeToString(rt: ResourceType): string;
|
|
32
|
+
export declare function resourceTypesEqual(type1: ResourceType, type2: ResourceType): boolean;
|
|
33
|
+
/** Readonly fields here marks properties of resource that can't change according to pl's state machine. */
|
|
34
|
+
export interface BasicResourceData {
|
|
35
|
+
readonly id: ResourceId;
|
|
36
|
+
readonly originalResourceId: OptionalResourceId;
|
|
37
|
+
readonly kind: ResourceKind;
|
|
38
|
+
readonly type: ResourceType;
|
|
39
|
+
readonly data?: Uint8Array;
|
|
40
|
+
readonly error: OptionalResourceId;
|
|
41
|
+
readonly inputsLocked: boolean;
|
|
42
|
+
readonly outputsLocked: boolean;
|
|
43
|
+
readonly resourceReady: boolean;
|
|
44
|
+
/** This value is derived from resource state by the server and can be used as
|
|
45
|
+
* a robust criteria to determine resource is in final state. */
|
|
46
|
+
readonly final: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare const jsonToData: (data: unknown) => Buffer;
|
|
49
|
+
export declare const resDataToJson: (res: ResourceData) => any;
|
|
50
|
+
export interface ResourceData extends BasicResourceData {
|
|
51
|
+
fields: FieldData[];
|
|
52
|
+
}
|
|
53
|
+
export declare function getField(r: ResourceData, name: string): FieldData;
|
|
54
|
+
export interface FieldData {
|
|
55
|
+
name: string;
|
|
56
|
+
type: FieldType;
|
|
57
|
+
status: FieldStatus;
|
|
58
|
+
value: OptionalResourceId;
|
|
59
|
+
error: OptionalResourceId;
|
|
60
|
+
/** True if value the fields points to is in final state. */
|
|
61
|
+
valueIsFinal: boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare const MaxLocalId = 16777215;
|
|
64
|
+
export declare const MaxTxId = 4294967295;
|
|
65
|
+
export declare function isRootResourceId(id: bigint): boolean;
|
|
66
|
+
export declare function isLocalResourceId(id: bigint): id is LocalResourceId;
|
|
67
|
+
export declare function createLocalResourceId(isRoot: boolean, localCounterValue: number, localTxId: number): LocalResourceId;
|
|
68
|
+
export declare function createGlobalResourceId(isRoot: boolean, unmaskedId: bigint): ResourceId;
|
|
69
|
+
export declare function extractTxId(localResourceId: LocalResourceId): number;
|
|
70
|
+
export declare function checkLocalityOfResourceId(resourceId: AnyResourceId, expectedTxId: number): void;
|
|
71
|
+
export declare function resourceIdToString(resourceId: OptionalAnyResourceId): string;
|
|
72
|
+
export declare function resourceIdFromString(str: string): OptionalAnyResourceId | undefined;
|
|
73
|
+
/** Converts bigint to global resource id */
|
|
74
|
+
export declare function bigintToResourceId(resourceId: bigint): ResourceId;
|
|
75
|
+
export declare function stringifyWithResourceId(object: unknown | undefined): string;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,oBAAoB,EAAE,OAAO,MAAM,CAAC;AAClD,KAAK,eAAe,CAAC,CAAC,IAAI,MAAM,GAAG;IAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEjE,yBAAyB;AACzB,MAAM,MAAM,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AAEnD,uBAAuB;AACvB,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAErD,wBAAwB;AACxB,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AAEvD,+BAA+B;AAC/B,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,eAAe,CAAC;AAEzD,sBAAsB;AACtB,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,UAAU,CAAC;AAE7D,qCAAqC;AACrC,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,CAAC;AAElF,eAAO,MAAM,cAAc,EAAS,cAAc,CAAC;AAEnD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,IAAI,cAAc,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,GAAG,UAAU,IAAI,UAAU,CAE5F;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,GAAG,UAAU,CAGlF;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,IAAI,aAAa,CAE/E;AAID,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,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