@milaboratories/pl-client 2.17.7 → 2.17.9
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/_virtual/_rolldown/runtime.cjs +43 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/core/PromiseTracker.cjs +33 -33
- package/dist/core/PromiseTracker.cjs.map +1 -1
- package/dist/core/PromiseTracker.d.ts +10 -7
- package/dist/core/PromiseTracker.js +33 -31
- package/dist/core/PromiseTracker.js.map +1 -1
- package/dist/core/StatefulPromise.cjs +60 -61
- package/dist/core/StatefulPromise.cjs.map +1 -1
- package/dist/core/StatefulPromise.js +60 -60
- package/dist/core/StatefulPromise.js.map +1 -1
- package/dist/core/abstract_stream.d.ts +18 -15
- package/dist/core/advisory_locks.cjs +42 -49
- package/dist/core/advisory_locks.cjs.map +1 -1
- package/dist/core/advisory_locks.js +42 -48
- package/dist/core/advisory_locks.js.map +1 -1
- package/dist/core/auth.cjs +10 -15
- package/dist/core/auth.cjs.map +1 -1
- package/dist/core/auth.d.ts +7 -3
- package/dist/core/auth.js +10 -13
- package/dist/core/auth.js.map +1 -1
- package/dist/core/cache.d.ts +11 -7
- package/dist/core/client.cjs +255 -306
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +72 -68
- package/dist/core/client.js +253 -285
- package/dist/core/client.js.map +1 -1
- package/dist/core/config.cjs +81 -99
- package/dist/core/config.cjs.map +1 -1
- package/dist/core/config.d.ts +93 -90
- package/dist/core/config.js +81 -98
- package/dist/core/config.js.map +1 -1
- package/dist/core/default_client.cjs +84 -125
- package/dist/core/default_client.cjs.map +1 -1
- package/dist/core/default_client.d.ts +9 -6
- package/dist/core/default_client.js +78 -103
- package/dist/core/default_client.js.map +1 -1
- package/dist/core/driver.cjs +12 -16
- package/dist/core/driver.cjs.map +1 -1
- package/dist/core/driver.d.ts +18 -14
- package/dist/core/driver.js +12 -15
- package/dist/core/driver.js.map +1 -1
- package/dist/core/error_resource.cjs +5 -4
- package/dist/core/error_resource.cjs.map +1 -1
- package/dist/core/error_resource.js +5 -3
- package/dist/core/error_resource.js.map +1 -1
- package/dist/core/errors.cjs +104 -140
- package/dist/core/errors.cjs.map +1 -1
- package/dist/core/errors.d.ts +34 -30
- package/dist/core/errors.js +102 -137
- package/dist/core/errors.js.map +1 -1
- package/dist/core/final.cjs +63 -89
- package/dist/core/final.cjs.map +1 -1
- package/dist/core/final.d.ts +8 -4
- package/dist/core/final.js +63 -87
- package/dist/core/final.js.map +1 -1
- package/dist/core/ll_client.cjs +416 -521
- package/dist/core/ll_client.cjs.map +1 -1
- package/dist/core/ll_client.d.ts +100 -97
- package/dist/core/ll_client.js +415 -519
- package/dist/core/ll_client.js.map +1 -1
- package/dist/core/ll_transaction.cjs +206 -240
- package/dist/core/ll_transaction.cjs.map +1 -1
- package/dist/core/ll_transaction.d.ts +50 -52
- package/dist/core/ll_transaction.js +205 -238
- package/dist/core/ll_transaction.js.map +1 -1
- package/dist/core/stat.cjs +64 -63
- package/dist/core/stat.cjs.map +1 -1
- package/dist/core/stat.d.ts +35 -36
- package/dist/core/stat.js +64 -62
- package/dist/core/stat.js.map +1 -1
- package/dist/core/transaction.cjs +613 -650
- package/dist/core/transaction.cjs.map +1 -1
- package/dist/core/transaction.d.ts +165 -162
- package/dist/core/transaction.js +612 -648
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/type_conversion.cjs +62 -83
- package/dist/core/type_conversion.cjs.map +1 -1
- package/dist/core/type_conversion.js +61 -81
- package/dist/core/type_conversion.js.map +1 -1
- package/dist/core/types.cjs +56 -86
- package/dist/core/types.cjs.map +1 -1
- package/dist/core/types.d.ts +63 -62
- package/dist/core/types.js +54 -83
- package/dist/core/types.js.map +1 -1
- package/dist/core/unauth_client.cjs +35 -41
- package/dist/core/unauth_client.cjs.map +1 -1
- package/dist/core/unauth_client.d.ts +18 -14
- package/dist/core/unauth_client.js +34 -39
- package/dist/core/unauth_client.js.map +1 -1
- package/dist/core/websocket_stream.cjs +280 -349
- package/dist/core/websocket_stream.cjs.map +1 -1
- package/dist/core/websocket_stream.js +278 -347
- package/dist/core/websocket_stream.js.map +1 -1
- package/dist/core/wire.d.ts +21 -17
- package/dist/helpers/pl.cjs +71 -73
- package/dist/helpers/pl.cjs.map +1 -1
- package/dist/helpers/pl.d.ts +40 -41
- package/dist/helpers/pl.js +66 -46
- package/dist/helpers/pl.js.map +1 -1
- package/dist/helpers/poll.cjs +99 -134
- package/dist/helpers/poll.cjs.map +1 -1
- package/dist/helpers/poll.d.ts +37 -34
- package/dist/helpers/poll.js +97 -113
- package/dist/helpers/poll.js.map +1 -1
- package/dist/helpers/retry_strategy.cjs +82 -87
- package/dist/helpers/retry_strategy.cjs.map +1 -1
- package/dist/helpers/retry_strategy.js +83 -86
- package/dist/helpers/retry_strategy.js.map +1 -1
- package/dist/helpers/tx_helpers.cjs +21 -20
- package/dist/helpers/tx_helpers.cjs.map +1 -1
- package/dist/helpers/tx_helpers.d.ts +11 -7
- package/dist/helpers/tx_helpers.js +20 -18
- package/dist/helpers/tx_helpers.js.map +1 -1
- package/dist/index.cjs +117 -106
- package/dist/index.d.ts +17 -17
- package/dist/index.js +17 -19
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +72 -66
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts +35 -37
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js +71 -64
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +12611 -12866
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +226 -226
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +281 -330
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +225 -224
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +2640 -4294
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +12608 -12706
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +1230 -1089
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +393 -420
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +1228 -1083
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +142 -143
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +62 -64
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +140 -141
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +572 -487
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +125 -228
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +572 -485
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.cjs +131 -146
- package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.d.ts +78 -84
- package/dist/proto-grpc/google/protobuf/any.js +130 -144
- package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.cjs +92 -100
- package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.d.ts +38 -43
- package/dist/proto-grpc/google/protobuf/duration.js +91 -98
- package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.cjs +117 -128
- package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.d.ts +50 -55
- package/dist/proto-grpc/google/protobuf/timestamp.js +116 -126
- package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto-grpc/google/rpc/code.cjs +223 -238
- package/dist/proto-grpc/google/rpc/code.cjs.map +1 -1
- package/dist/proto-grpc/google/rpc/code.d.ts +209 -206
- package/dist/proto-grpc/google/rpc/code.js +221 -237
- package/dist/proto-grpc/google/rpc/code.js.map +1 -1
- package/dist/proto-rest/index.cjs +67 -66
- package/dist/proto-rest/index.cjs.map +1 -1
- package/dist/proto-rest/index.d.ts +24 -18
- package/dist/proto-rest/index.js +61 -65
- package/dist/proto-rest/index.js.map +1 -1
- package/dist/proto-rest/plapi.d.ts +1400 -1477
- package/dist/test/tcp-proxy.cjs +100 -126
- package/dist/test/tcp-proxy.cjs.map +1 -1
- package/dist/test/tcp-proxy.d.ts +17 -13
- package/dist/test/tcp-proxy.js +97 -104
- package/dist/test/tcp-proxy.js.map +1 -1
- package/dist/test/test_config.cjs +145 -194
- package/dist/test/test_config.cjs.map +1 -1
- package/dist/test/test_config.d.ts +34 -30
- package/dist/test/test_config.js +138 -166
- package/dist/test/test_config.js.map +1 -1
- package/dist/util/pl.cjs +4 -3
- package/dist/util/pl.cjs.map +1 -1
- package/dist/util/pl.js +4 -2
- package/dist/util/pl.js.map +1 -1
- package/dist/util/util.cjs +7 -10
- package/dist/util/util.cjs.map +1 -1
- package/dist/util/util.js +7 -9
- package/dist/util/util.js.map +1 -1
- package/package.json +8 -8
- package/src/core/errors.ts +1 -1
- package/src/core/transaction.ts +123 -133
- package/src/core/websocket_stream.ts +10 -1
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs +0 -61
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs.map +0 -1
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js +0 -58
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js.map +0 -1
- package/dist/core/PromiseTracker.d.ts.map +0 -1
- package/dist/core/StatefulPromise.d.ts +0 -39
- package/dist/core/StatefulPromise.d.ts.map +0 -1
- package/dist/core/abstract_stream.d.ts.map +0 -1
- package/dist/core/advisory_locks.d.ts +0 -10
- package/dist/core/advisory_locks.d.ts.map +0 -1
- package/dist/core/auth.d.ts.map +0 -1
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/client.d.ts.map +0 -1
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/default_client.d.ts.map +0 -1
- package/dist/core/driver.d.ts.map +0 -1
- package/dist/core/error_resource.d.ts +0 -6
- package/dist/core/error_resource.d.ts.map +0 -1
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/final.d.ts.map +0 -1
- package/dist/core/ll_client.d.ts.map +0 -1
- package/dist/core/ll_transaction.d.ts.map +0 -1
- package/dist/core/stat.d.ts.map +0 -1
- package/dist/core/transaction.d.ts.map +0 -1
- package/dist/core/type_conversion.d.ts +0 -8
- package/dist/core/type_conversion.d.ts.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/unauth_client.d.ts.map +0 -1
- package/dist/core/websocket_stream.d.ts +0 -67
- package/dist/core/websocket_stream.d.ts.map +0 -1
- package/dist/core/wire.d.ts.map +0 -1
- package/dist/helpers/pl.d.ts.map +0 -1
- package/dist/helpers/poll.d.ts.map +0 -1
- package/dist/helpers/retry_strategy.d.ts +0 -24
- package/dist/helpers/retry_strategy.d.ts.map +0 -1
- package/dist/helpers/state_helpers.d.ts +0 -3
- package/dist/helpers/state_helpers.d.ts.map +0 -1
- package/dist/helpers/tx_helpers.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -106
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts +0 -73
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts.map +0 -1
- package/dist/proto-grpc/google/api/http.d.ts +0 -456
- package/dist/proto-grpc/google/api/http.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/any.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/descriptor.d.ts +0 -2340
- package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/duration.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/empty.d.ts +0 -32
- package/dist/proto-grpc/google/protobuf/empty.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/struct.d.ts +0 -187
- package/dist/proto-grpc/google/protobuf/struct.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/wrappers.d.ts +0 -308
- package/dist/proto-grpc/google/protobuf/wrappers.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/code.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/error_details.d.ts +0 -654
- package/dist/proto-grpc/google/rpc/error_details.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/http.d.ts +0 -121
- package/dist/proto-grpc/google/rpc/http.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/status.d.ts +0 -55
- package/dist/proto-grpc/google/rpc/status.d.ts.map +0 -1
- package/dist/proto-rest/index.d.ts.map +0 -1
- package/dist/proto-rest/plapi.d.ts.map +0 -1
- package/dist/test/tcp-proxy.d.ts.map +0 -1
- package/dist/test/test_config.d.ts.map +0 -1
- package/dist/util/branding.d.ts +0 -7
- package/dist/util/branding.d.ts.map +0 -1
- package/dist/util/pl.d.ts +0 -9
- package/dist/util/pl.d.ts.map +0 -1
- package/dist/util/util.d.ts +0 -2
- package/dist/util/util.d.ts.map +0 -1
package/dist/core/config.js
CHANGED
|
@@ -1,110 +1,93 @@
|
|
|
1
|
+
//#region src/core/config.ts
|
|
1
2
|
const SUPPORTED_WIRE_PROTOCOLS = ["grpc", "rest"];
|
|
2
|
-
const DEFAULT_REQUEST_TIMEOUT =
|
|
3
|
-
const DEFAULT_RO_TX_TIMEOUT =
|
|
4
|
-
const DEFAULT_RW_TX_TIMEOUT =
|
|
5
|
-
const DEFAULT_TOKEN_TTL_SECONDS =
|
|
6
|
-
const DEFAULT_AUTH_MAX_REFRESH =
|
|
7
|
-
const DEFAULT_MAX_CACHE_BYTES =
|
|
3
|
+
const DEFAULT_REQUEST_TIMEOUT = 5e3;
|
|
4
|
+
const DEFAULT_RO_TX_TIMEOUT = 3e5;
|
|
5
|
+
const DEFAULT_RW_TX_TIMEOUT = 6e4;
|
|
6
|
+
const DEFAULT_TOKEN_TTL_SECONDS = 744 * 60 * 60;
|
|
7
|
+
const DEFAULT_AUTH_MAX_REFRESH = 288 * 60 * 60;
|
|
8
|
+
const DEFAULT_MAX_CACHE_BYTES = 128e6;
|
|
8
9
|
const DEFAULT_RETRY_BACKOFF_ALGORITHM = "exponential";
|
|
9
|
-
const DEFAULT_RETRY_MAX_ATTEMPTS = 21;
|
|
10
|
-
const DEFAULT_RETRY_INITIAL_DELAY = 20;
|
|
11
|
-
const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 1.5;
|
|
12
|
-
const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50;
|
|
13
|
-
const DEFAULT_RETRY_JITTER =
|
|
10
|
+
const DEFAULT_RETRY_MAX_ATTEMPTS = 21;
|
|
11
|
+
const DEFAULT_RETRY_INITIAL_DELAY = 20;
|
|
12
|
+
const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 1.5;
|
|
13
|
+
const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50;
|
|
14
|
+
const DEFAULT_RETRY_JITTER = .3;
|
|
14
15
|
const DefaultRetryOptions = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
type: "exponentialBackoff",
|
|
17
|
+
maxAttempts: DEFAULT_RETRY_MAX_ATTEMPTS,
|
|
18
|
+
initialDelay: DEFAULT_RETRY_INITIAL_DELAY,
|
|
19
|
+
backoffMultiplier: DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,
|
|
20
|
+
jitter: DEFAULT_RETRY_JITTER
|
|
20
21
|
};
|
|
21
22
|
function parseInt(s) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throw new Error(`Can't parse number: ${s}`);
|
|
27
|
-
return num;
|
|
23
|
+
if (!s) return void 0;
|
|
24
|
+
const num = Number(s);
|
|
25
|
+
if (Number.isNaN(num)) throw new Error(`Can't parse number: ${s}`);
|
|
26
|
+
return num;
|
|
28
27
|
}
|
|
29
28
|
/** Parses pl url and creates a config object that can be passed to
|
|
30
|
-
|
|
29
|
+
* {@link PlClient} of {@link UnauthenticatedPlClient}. */
|
|
31
30
|
function plAddressToConfig(address, overrides = {}) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
httpProxy: url.searchParams.get("http-proxy") ?? undefined,
|
|
90
|
-
user: url.username === "" ? undefined : url.username,
|
|
91
|
-
password: url.password === "" ? undefined : url.password,
|
|
92
|
-
txDelay: parseInt(url.searchParams.get("tx-delay")) ?? 0,
|
|
93
|
-
forceSync: Boolean(url.searchParams.get("force-sync")),
|
|
94
|
-
maxCacheBytes: parseInt(url.searchParams.get("max-cache-bytes")) ?? DEFAULT_MAX_CACHE_BYTES,
|
|
95
|
-
retryBackoffAlgorithm: (url.searchParams.get("retry-backoff-algorithm") ??
|
|
96
|
-
DEFAULT_RETRY_BACKOFF_ALGORITHM),
|
|
97
|
-
retryMaxAttempts: parseInt(url.searchParams.get("retry-max-attempts")) ?? DEFAULT_RETRY_MAX_ATTEMPTS,
|
|
98
|
-
retryInitialDelay: parseInt(url.searchParams.get("retry-initial-delay")) ?? DEFAULT_RETRY_INITIAL_DELAY,
|
|
99
|
-
retryExponentialBackoffMultiplier: parseInt(url.searchParams.get("retry-exp-backoff-multiplier")) ??
|
|
100
|
-
DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,
|
|
101
|
-
retryLinearBackoffStep: parseInt(url.searchParams.get("retry-linear-backoff-step")) ??
|
|
102
|
-
DEFAULT_RETRY_LINEAR_BACKOFF_STEP,
|
|
103
|
-
retryJitter: parseInt(url.searchParams.get("retry-backoff-jitter")) ?? DEFAULT_RETRY_JITTER,
|
|
104
|
-
...overrides,
|
|
105
|
-
};
|
|
31
|
+
if (address.indexOf("://") === -1) return {
|
|
32
|
+
hostAndPort: address,
|
|
33
|
+
ssl: false,
|
|
34
|
+
defaultRequestTimeout: DEFAULT_REQUEST_TIMEOUT,
|
|
35
|
+
defaultROTransactionTimeout: DEFAULT_RO_TX_TIMEOUT,
|
|
36
|
+
defaultRWTransactionTimeout: DEFAULT_RW_TX_TIMEOUT,
|
|
37
|
+
authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,
|
|
38
|
+
authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,
|
|
39
|
+
txDelay: 0,
|
|
40
|
+
forceSync: false,
|
|
41
|
+
maxCacheBytes: DEFAULT_MAX_CACHE_BYTES,
|
|
42
|
+
retryBackoffAlgorithm: DEFAULT_RETRY_BACKOFF_ALGORITHM,
|
|
43
|
+
retryMaxAttempts: DEFAULT_RETRY_MAX_ATTEMPTS,
|
|
44
|
+
retryInitialDelay: DEFAULT_RETRY_INITIAL_DELAY,
|
|
45
|
+
retryExponentialBackoffMultiplier: DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,
|
|
46
|
+
retryLinearBackoffStep: DEFAULT_RETRY_LINEAR_BACKOFF_STEP,
|
|
47
|
+
retryJitter: DEFAULT_RETRY_JITTER,
|
|
48
|
+
...overrides
|
|
49
|
+
};
|
|
50
|
+
const url = new URL(address);
|
|
51
|
+
if (url.protocol !== "https:" && url.protocol !== "http:" && url.protocol !== "grpc:" && url.protocol !== "tls:") throw new Error(`Unexpected URL schema: ${url.protocol}`);
|
|
52
|
+
if (url.pathname !== "/" && url.pathname !== "") throw new Error(`Unexpected URL path: ${url.pathname}`);
|
|
53
|
+
let port = url.port;
|
|
54
|
+
if (!port) switch (url.protocol) {
|
|
55
|
+
case "http:":
|
|
56
|
+
port = "80";
|
|
57
|
+
break;
|
|
58
|
+
case "https:":
|
|
59
|
+
port = "443";
|
|
60
|
+
break;
|
|
61
|
+
default: throw new Error(`Port must be specified explicitly for ${url.protocol} protocol.`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
hostAndPort: `${url.hostname}:${port}`,
|
|
65
|
+
alternativeRoot: url.searchParams.get("alternative-root") ?? void 0,
|
|
66
|
+
ssl: url.protocol === "https:" || url.protocol === "tls:",
|
|
67
|
+
wireProtocol: url.searchParams.get("wire-protocol") ?? void 0,
|
|
68
|
+
defaultRequestTimeout: parseInt(url.searchParams.get("request-timeout")) ?? DEFAULT_REQUEST_TIMEOUT,
|
|
69
|
+
defaultROTransactionTimeout: parseInt(url.searchParams.get("ro-tx-timeout")) ?? parseInt(url.searchParams.get("tx-timeout")) ?? DEFAULT_RO_TX_TIMEOUT,
|
|
70
|
+
defaultRWTransactionTimeout: parseInt(url.searchParams.get("rw-tx-timeout")) ?? parseInt(url.searchParams.get("tx-timeout")) ?? DEFAULT_RW_TX_TIMEOUT,
|
|
71
|
+
authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,
|
|
72
|
+
authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,
|
|
73
|
+
grpcProxy: url.searchParams.get("grpc-proxy") ?? void 0,
|
|
74
|
+
httpProxy: url.searchParams.get("http-proxy") ?? void 0,
|
|
75
|
+
user: url.username === "" ? void 0 : url.username,
|
|
76
|
+
password: url.password === "" ? void 0 : url.password,
|
|
77
|
+
txDelay: parseInt(url.searchParams.get("tx-delay")) ?? 0,
|
|
78
|
+
forceSync: Boolean(url.searchParams.get("force-sync")),
|
|
79
|
+
maxCacheBytes: parseInt(url.searchParams.get("max-cache-bytes")) ?? DEFAULT_MAX_CACHE_BYTES,
|
|
80
|
+
retryBackoffAlgorithm: url.searchParams.get("retry-backoff-algorithm") ?? DEFAULT_RETRY_BACKOFF_ALGORITHM,
|
|
81
|
+
retryMaxAttempts: parseInt(url.searchParams.get("retry-max-attempts")) ?? DEFAULT_RETRY_MAX_ATTEMPTS,
|
|
82
|
+
retryInitialDelay: parseInt(url.searchParams.get("retry-initial-delay")) ?? DEFAULT_RETRY_INITIAL_DELAY,
|
|
83
|
+
retryExponentialBackoffMultiplier: parseInt(url.searchParams.get("retry-exp-backoff-multiplier")) ?? DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,
|
|
84
|
+
retryLinearBackoffStep: parseInt(url.searchParams.get("retry-linear-backoff-step")) ?? DEFAULT_RETRY_LINEAR_BACKOFF_STEP,
|
|
85
|
+
retryJitter: parseInt(url.searchParams.get("retry-backoff-jitter")) ?? DEFAULT_RETRY_JITTER,
|
|
86
|
+
...overrides
|
|
87
|
+
};
|
|
106
88
|
}
|
|
107
89
|
const AnonymousAuthInformation = {};
|
|
108
90
|
|
|
91
|
+
//#endregion
|
|
109
92
|
export { AnonymousAuthInformation, DEFAULT_AUTH_MAX_REFRESH, DEFAULT_MAX_CACHE_BYTES, DEFAULT_REQUEST_TIMEOUT, DEFAULT_RETRY_BACKOFF_ALGORITHM, DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY, DEFAULT_RETRY_JITTER, DEFAULT_RETRY_LINEAR_BACKOFF_STEP, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultRetryOptions, SUPPORTED_WIRE_PROTOCOLS, plAddressToConfig };
|
|
110
|
-
//# sourceMappingURL=config.js.map
|
|
93
|
+
//# sourceMappingURL=config.js.map
|
package/dist/core/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/core/config.ts"],"sourcesContent":["import type { ProxySettings } from \"@milaboratories/pl-http\";\nimport type { ExponentialBackoffRetryOptions } from \"@milaboratories/ts-helpers\";\n\nexport const SUPPORTED_WIRE_PROTOCOLS = [\"grpc\", \"rest\"] as const;\nexport type wireProtocol = (typeof SUPPORTED_WIRE_PROTOCOLS)[number];\n\n/** Base configuration structure for PL client */\nexport interface PlClientConfig {\n /** Port and host of remote pl server */\n hostAndPort: string;\n\n /** Type of wire connection (protocol server uses for communication) */\n wireProtocol?: wireProtocol;\n\n /** If set, client will expose a nested object under a field with name `alternative_root_${alternativeRoot}` as a\n * client root. */\n alternativeRoot?: string;\n\n /** If true, client will establish tls connection to the server, using default\n * CA of node instance. */\n // Not implementing custom ssl validation logic for now.\n // Implementing it in a correct way is really nontrivial thing,\n // real use-cases should be considered.\n ssl: boolean;\n\n /** Default timeout in milliseconds for unary calls, like ping and login. */\n defaultRequestTimeout: number;\n\n /** Default timeout in milliseconds for read-write transaction, should be\n * adjusted for long round-trip or low bandwidth connections. */\n defaultRWTransactionTimeout: number;\n /** Default timeout in milliseconds for read-only transaction, should be\n * adjusted for long round-trip or low bandwidth connections. */\n defaultROTransactionTimeout: number;\n\n /** Controls what TTL will be requested from the server, when new JWT token\n * is requested. */\n authTTLSeconds: number;\n /** If token is older than this time, it will be refreshed regardless of its\n * expiration time. */\n authMaxRefreshSeconds: number;\n\n /** Proxy server config to use for pl connection. */\n grpcProxy?: string | ProxySettings;\n /** Proxy server config to use for http connections of pl drivers, like file\n * downloading. */\n httpProxy?: string | ProxySettings;\n\n /** Username extracted from pl URL. Ignored by {@link PlClient}, picked up by {@link defaultPlClient}. */\n user?: string;\n /** Password extracted from pl URL. Ignored by {@link PlClient}, picked up by {@link defaultPlClient}. */\n password?: string;\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n forceSync: boolean;\n\n /** Maximal number of bytes of resource state to cache */\n maxCacheBytes: number;\n\n //\n // Retry\n //\n\n /**\n * What type of backoff strategy to use in transaction retries\n * (pl uses optimistic transaction model with regular retries in write transactions)\n */\n retryBackoffAlgorithm: \"exponential\" | \"linear\";\n\n /** Maximal number of attempts in */\n retryMaxAttempts: number;\n\n /** Delay after first failed attempt, in ms. */\n retryInitialDelay: number;\n\n /** Each time delay will be multiplied by this number (1.5 means plus on 50% each attempt) */\n retryExponentialBackoffMultiplier: number;\n\n /** [used only for ] This value will be added to the delay from the previous step, in ms */\n retryLinearBackoffStep: number;\n\n /** Value from 0 to 1, determine level of randomness to introduce to the backoff delays sequence. (0 meaning no randomness) */\n retryJitter: number;\n}\n\nexport const DEFAULT_REQUEST_TIMEOUT = 5_000;\nexport const DEFAULT_RO_TX_TIMEOUT = 300_000;\nexport const DEFAULT_RW_TX_TIMEOUT = 60_000;\nexport const DEFAULT_TOKEN_TTL_SECONDS = 31 * 24 * 60 * 60;\nexport const DEFAULT_AUTH_MAX_REFRESH = 12 * 24 * 60 * 60;\n\nexport const DEFAULT_MAX_CACHE_BYTES = 128_000_000; // 128 Mb\n\nexport const DEFAULT_RETRY_BACKOFF_ALGORITHM = \"exponential\";\nexport const DEFAULT_RETRY_MAX_ATTEMPTS = 21; // 1st attempt + 20 retries\nexport const DEFAULT_RETRY_INITIAL_DELAY = 20; // 20 ms * <jitter> of sleep after first failure\nexport const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 1.5; // + 50% on each round\nexport const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50; // + 50 ms\nexport const DEFAULT_RETRY_JITTER = 0.3; // 30%\n\nexport const DefaultRetryOptions: ExponentialBackoffRetryOptions = {\n type: \"exponentialBackoff\",\n maxAttempts: DEFAULT_RETRY_MAX_ATTEMPTS,\n initialDelay: DEFAULT_RETRY_INITIAL_DELAY,\n backoffMultiplier: DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,\n jitter: DEFAULT_RETRY_JITTER,\n};\n\ntype PlConfigOverrides = Partial<\n Pick<\n PlClientConfig,\n | \"ssl\"\n | \"defaultRequestTimeout\"\n | \"defaultROTransactionTimeout\"\n | \"defaultRWTransactionTimeout\"\n | \"httpProxy\"\n | \"grpcProxy\"\n >\n>;\n\nfunction parseInt(s: string | null | undefined): number | undefined {\n if (!s) return undefined;\n const num = Number(s);\n if (Number.isNaN(num)) throw new Error(`Can't parse number: ${s}`);\n return num;\n}\n\n/** Parses pl url and creates a config object that can be passed to\n * {@link PlClient} of {@link UnauthenticatedPlClient}. */\nexport function plAddressToConfig(\n address: string,\n overrides: PlConfigOverrides = {},\n): PlClientConfig {\n if (address.indexOf(\"://\") === -1)\n // non-url address\n return {\n hostAndPort: address,\n ssl: false,\n defaultRequestTimeout: DEFAULT_REQUEST_TIMEOUT,\n defaultROTransactionTimeout: DEFAULT_RO_TX_TIMEOUT,\n defaultRWTransactionTimeout: DEFAULT_RW_TX_TIMEOUT,\n authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,\n authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,\n txDelay: 0,\n forceSync: false,\n\n maxCacheBytes: DEFAULT_MAX_CACHE_BYTES,\n\n retryBackoffAlgorithm: DEFAULT_RETRY_BACKOFF_ALGORITHM,\n retryMaxAttempts: DEFAULT_RETRY_MAX_ATTEMPTS,\n retryInitialDelay: DEFAULT_RETRY_INITIAL_DELAY,\n retryExponentialBackoffMultiplier: DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,\n retryLinearBackoffStep: DEFAULT_RETRY_LINEAR_BACKOFF_STEP,\n retryJitter: DEFAULT_RETRY_JITTER,\n\n ...overrides,\n };\n\n const url = new URL(address);\n\n if (\n url.protocol !== \"https:\" &&\n url.protocol !== \"http:\" &&\n url.protocol !== \"grpc:\" &&\n url.protocol !== \"tls:\"\n )\n throw new Error(`Unexpected URL schema: ${url.protocol}`);\n\n if (url.pathname !== \"/\" && url.pathname !== \"\")\n throw new Error(`Unexpected URL path: ${url.pathname}`);\n\n let port = url.port;\n if (!port) {\n switch (url.protocol) {\n case \"http:\":\n port = \"80\";\n break;\n case \"https:\":\n port = \"443\";\n break;\n default:\n throw new Error(`Port must be specified explicitly for ${url.protocol} protocol.`);\n }\n }\n\n return {\n hostAndPort: `${url.hostname}:${port}`,\n alternativeRoot: url.searchParams.get(\"alternative-root\") ?? undefined,\n ssl: url.protocol === \"https:\" || url.protocol === \"tls:\",\n\n wireProtocol: (url.searchParams.get(\"wire-protocol\") as wireProtocol) ?? undefined,\n\n defaultRequestTimeout:\n parseInt(url.searchParams.get(\"request-timeout\")) ?? DEFAULT_REQUEST_TIMEOUT,\n defaultROTransactionTimeout:\n parseInt(url.searchParams.get(\"ro-tx-timeout\")) ??\n parseInt(url.searchParams.get(\"tx-timeout\")) ??\n DEFAULT_RO_TX_TIMEOUT,\n defaultRWTransactionTimeout:\n parseInt(url.searchParams.get(\"rw-tx-timeout\")) ??\n parseInt(url.searchParams.get(\"tx-timeout\")) ??\n DEFAULT_RW_TX_TIMEOUT,\n authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,\n authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,\n grpcProxy: url.searchParams.get(\"grpc-proxy\") ?? undefined,\n httpProxy: url.searchParams.get(\"http-proxy\") ?? undefined,\n user: url.username === \"\" ? undefined : url.username,\n password: url.password === \"\" ? undefined : url.password,\n txDelay: parseInt(url.searchParams.get(\"tx-delay\")) ?? 0,\n forceSync: Boolean(url.searchParams.get(\"force-sync\")),\n\n maxCacheBytes: parseInt(url.searchParams.get(\"max-cache-bytes\")) ?? DEFAULT_MAX_CACHE_BYTES,\n\n retryBackoffAlgorithm: (url.searchParams.get(\"retry-backoff-algorithm\") ??\n DEFAULT_RETRY_BACKOFF_ALGORITHM) as any,\n retryMaxAttempts:\n parseInt(url.searchParams.get(\"retry-max-attempts\")) ?? DEFAULT_RETRY_MAX_ATTEMPTS,\n retryInitialDelay:\n parseInt(url.searchParams.get(\"retry-initial-delay\")) ?? DEFAULT_RETRY_INITIAL_DELAY,\n retryExponentialBackoffMultiplier:\n parseInt(url.searchParams.get(\"retry-exp-backoff-multiplier\")) ??\n DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,\n retryLinearBackoffStep:\n parseInt(url.searchParams.get(\"retry-linear-backoff-step\")) ??\n DEFAULT_RETRY_LINEAR_BACKOFF_STEP,\n retryJitter: parseInt(url.searchParams.get(\"retry-backoff-jitter\")) ?? DEFAULT_RETRY_JITTER,\n\n ...overrides,\n };\n}\n\n/**\n * Authorization data / JWT Token.\n * Absent JWT Token tells the client to connect as anonymous user.\n */\nexport interface AuthInformation {\n /** Absent token means anonymous access */\n jwtToken?: string;\n}\n\nexport const AnonymousAuthInformation: AuthInformation = {};\n\n/** Authorization related settings to pass to {@link PlClient}. */\nexport interface AuthOps {\n /** Initial authorization information */\n authInformation: AuthInformation;\n /** Will be executed after successful authorization information refresh */\n readonly onUpdate?: (newInfo: AuthInformation) => void;\n /** Will be executed if auth-related error happens during normal client operation */\n readonly onAuthError?: () => void;\n /** Will be executed if error encountered during token update */\n readonly onUpdateError?: (error: unknown) => void;\n}\n\n/** Connection status. */\nexport type PlConnectionStatus = \"OK\" | \"Disconnected\" | \"Unauthenticated\";\n\n/** Listener that will be called each time connection status changes. */\nexport type PlConnectionStatusListener = (status: PlConnectionStatus) => void;\n"],"names":[],"mappings":"MAGa,wBAAwB,GAAG,CAAC,MAAM,EAAE,MAAM;AAsFhD,MAAM,uBAAuB,GAAG;AAChC,MAAM,qBAAqB,GAAG;AAC9B,MAAM,qBAAqB,GAAG;AAC9B,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;AACjD,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;AAEhD,MAAM,uBAAuB,GAAG,YAAY;AAE5C,MAAM,+BAA+B,GAAG;AACxC,MAAM,0BAA0B,GAAG,GAAG;AACtC,MAAM,2BAA2B,GAAG,GAAG;AACvC,MAAM,4CAA4C,GAAG,IAAI;AACzD,MAAM,iCAAiC,GAAG,GAAG;AAC7C,MAAM,oBAAoB,GAAG,IAAI;AAEjC,MAAM,mBAAmB,GAAmC;AACjE,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,WAAW,EAAE,0BAA0B;AACvC,IAAA,YAAY,EAAE,2BAA2B;AACzC,IAAA,iBAAiB,EAAE,4CAA4C;AAC/D,IAAA,MAAM,EAAE,oBAAoB;;AAe9B,SAAS,QAAQ,CAAC,CAA4B,EAAA;AAC5C,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,SAAS;AACxB,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;AACrB,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AAAE,QAAA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W,EAAE,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,IAAI,oBAAoB;AAE3F,QAAA,GAAG,SAAS;KACb;AACH;AAWO,MAAM,wBAAwB,GAAoB;;;;"}
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../src/core/config.ts"],"sourcesContent":["import type { ProxySettings } from \"@milaboratories/pl-http\";\nimport type { ExponentialBackoffRetryOptions } from \"@milaboratories/ts-helpers\";\n\nexport const SUPPORTED_WIRE_PROTOCOLS = [\"grpc\", \"rest\"] as const;\nexport type wireProtocol = (typeof SUPPORTED_WIRE_PROTOCOLS)[number];\n\n/** Base configuration structure for PL client */\nexport interface PlClientConfig {\n /** Port and host of remote pl server */\n hostAndPort: string;\n\n /** Type of wire connection (protocol server uses for communication) */\n wireProtocol?: wireProtocol;\n\n /** If set, client will expose a nested object under a field with name `alternative_root_${alternativeRoot}` as a\n * client root. */\n alternativeRoot?: string;\n\n /** If true, client will establish tls connection to the server, using default\n * CA of node instance. */\n // Not implementing custom ssl validation logic for now.\n // Implementing it in a correct way is really nontrivial thing,\n // real use-cases should be considered.\n ssl: boolean;\n\n /** Default timeout in milliseconds for unary calls, like ping and login. */\n defaultRequestTimeout: number;\n\n /** Default timeout in milliseconds for read-write transaction, should be\n * adjusted for long round-trip or low bandwidth connections. */\n defaultRWTransactionTimeout: number;\n /** Default timeout in milliseconds for read-only transaction, should be\n * adjusted for long round-trip or low bandwidth connections. */\n defaultROTransactionTimeout: number;\n\n /** Controls what TTL will be requested from the server, when new JWT token\n * is requested. */\n authTTLSeconds: number;\n /** If token is older than this time, it will be refreshed regardless of its\n * expiration time. */\n authMaxRefreshSeconds: number;\n\n /** Proxy server config to use for pl connection. */\n grpcProxy?: string | ProxySettings;\n /** Proxy server config to use for http connections of pl drivers, like file\n * downloading. */\n httpProxy?: string | ProxySettings;\n\n /** Username extracted from pl URL. Ignored by {@link PlClient}, picked up by {@link defaultPlClient}. */\n user?: string;\n /** Password extracted from pl URL. Ignored by {@link PlClient}, picked up by {@link defaultPlClient}. */\n password?: string;\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n forceSync: boolean;\n\n /** Maximal number of bytes of resource state to cache */\n maxCacheBytes: number;\n\n //\n // Retry\n //\n\n /**\n * What type of backoff strategy to use in transaction retries\n * (pl uses optimistic transaction model with regular retries in write transactions)\n */\n retryBackoffAlgorithm: \"exponential\" | \"linear\";\n\n /** Maximal number of attempts in */\n retryMaxAttempts: number;\n\n /** Delay after first failed attempt, in ms. */\n retryInitialDelay: number;\n\n /** Each time delay will be multiplied by this number (1.5 means plus on 50% each attempt) */\n retryExponentialBackoffMultiplier: number;\n\n /** [used only for ] This value will be added to the delay from the previous step, in ms */\n retryLinearBackoffStep: number;\n\n /** Value from 0 to 1, determine level of randomness to introduce to the backoff delays sequence. (0 meaning no randomness) */\n retryJitter: number;\n}\n\nexport const DEFAULT_REQUEST_TIMEOUT = 5_000;\nexport const DEFAULT_RO_TX_TIMEOUT = 300_000;\nexport const DEFAULT_RW_TX_TIMEOUT = 60_000;\nexport const DEFAULT_TOKEN_TTL_SECONDS = 31 * 24 * 60 * 60;\nexport const DEFAULT_AUTH_MAX_REFRESH = 12 * 24 * 60 * 60;\n\nexport const DEFAULT_MAX_CACHE_BYTES = 128_000_000; // 128 Mb\n\nexport const DEFAULT_RETRY_BACKOFF_ALGORITHM = \"exponential\";\nexport const DEFAULT_RETRY_MAX_ATTEMPTS = 21; // 1st attempt + 20 retries\nexport const DEFAULT_RETRY_INITIAL_DELAY = 20; // 20 ms * <jitter> of sleep after first failure\nexport const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 1.5; // + 50% on each round\nexport const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50; // + 50 ms\nexport const DEFAULT_RETRY_JITTER = 0.3; // 30%\n\nexport const DefaultRetryOptions: ExponentialBackoffRetryOptions = {\n type: \"exponentialBackoff\",\n maxAttempts: DEFAULT_RETRY_MAX_ATTEMPTS,\n initialDelay: DEFAULT_RETRY_INITIAL_DELAY,\n backoffMultiplier: DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,\n jitter: DEFAULT_RETRY_JITTER,\n};\n\ntype PlConfigOverrides = Partial<\n Pick<\n PlClientConfig,\n | \"ssl\"\n | \"defaultRequestTimeout\"\n | \"defaultROTransactionTimeout\"\n | \"defaultRWTransactionTimeout\"\n | \"httpProxy\"\n | \"grpcProxy\"\n >\n>;\n\nfunction parseInt(s: string | null | undefined): number | undefined {\n if (!s) return undefined;\n const num = Number(s);\n if (Number.isNaN(num)) throw new Error(`Can't parse number: ${s}`);\n return num;\n}\n\n/** Parses pl url and creates a config object that can be passed to\n * {@link PlClient} of {@link UnauthenticatedPlClient}. */\nexport function plAddressToConfig(\n address: string,\n overrides: PlConfigOverrides = {},\n): PlClientConfig {\n if (address.indexOf(\"://\") === -1)\n // non-url address\n return {\n hostAndPort: address,\n ssl: false,\n defaultRequestTimeout: DEFAULT_REQUEST_TIMEOUT,\n defaultROTransactionTimeout: DEFAULT_RO_TX_TIMEOUT,\n defaultRWTransactionTimeout: DEFAULT_RW_TX_TIMEOUT,\n authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,\n authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,\n txDelay: 0,\n forceSync: false,\n\n maxCacheBytes: DEFAULT_MAX_CACHE_BYTES,\n\n retryBackoffAlgorithm: DEFAULT_RETRY_BACKOFF_ALGORITHM,\n retryMaxAttempts: DEFAULT_RETRY_MAX_ATTEMPTS,\n retryInitialDelay: DEFAULT_RETRY_INITIAL_DELAY,\n retryExponentialBackoffMultiplier: DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,\n retryLinearBackoffStep: DEFAULT_RETRY_LINEAR_BACKOFF_STEP,\n retryJitter: DEFAULT_RETRY_JITTER,\n\n ...overrides,\n };\n\n const url = new URL(address);\n\n if (\n url.protocol !== \"https:\" &&\n url.protocol !== \"http:\" &&\n url.protocol !== \"grpc:\" &&\n url.protocol !== \"tls:\"\n )\n throw new Error(`Unexpected URL schema: ${url.protocol}`);\n\n if (url.pathname !== \"/\" && url.pathname !== \"\")\n throw new Error(`Unexpected URL path: ${url.pathname}`);\n\n let port = url.port;\n if (!port) {\n switch (url.protocol) {\n case \"http:\":\n port = \"80\";\n break;\n case \"https:\":\n port = \"443\";\n break;\n default:\n throw new Error(`Port must be specified explicitly for ${url.protocol} protocol.`);\n }\n }\n\n return {\n hostAndPort: `${url.hostname}:${port}`,\n alternativeRoot: url.searchParams.get(\"alternative-root\") ?? undefined,\n ssl: url.protocol === \"https:\" || url.protocol === \"tls:\",\n\n wireProtocol: (url.searchParams.get(\"wire-protocol\") as wireProtocol) ?? undefined,\n\n defaultRequestTimeout:\n parseInt(url.searchParams.get(\"request-timeout\")) ?? DEFAULT_REQUEST_TIMEOUT,\n defaultROTransactionTimeout:\n parseInt(url.searchParams.get(\"ro-tx-timeout\")) ??\n parseInt(url.searchParams.get(\"tx-timeout\")) ??\n DEFAULT_RO_TX_TIMEOUT,\n defaultRWTransactionTimeout:\n parseInt(url.searchParams.get(\"rw-tx-timeout\")) ??\n parseInt(url.searchParams.get(\"tx-timeout\")) ??\n DEFAULT_RW_TX_TIMEOUT,\n authTTLSeconds: DEFAULT_TOKEN_TTL_SECONDS,\n authMaxRefreshSeconds: DEFAULT_AUTH_MAX_REFRESH,\n grpcProxy: url.searchParams.get(\"grpc-proxy\") ?? undefined,\n httpProxy: url.searchParams.get(\"http-proxy\") ?? undefined,\n user: url.username === \"\" ? undefined : url.username,\n password: url.password === \"\" ? undefined : url.password,\n txDelay: parseInt(url.searchParams.get(\"tx-delay\")) ?? 0,\n forceSync: Boolean(url.searchParams.get(\"force-sync\")),\n\n maxCacheBytes: parseInt(url.searchParams.get(\"max-cache-bytes\")) ?? DEFAULT_MAX_CACHE_BYTES,\n\n retryBackoffAlgorithm: (url.searchParams.get(\"retry-backoff-algorithm\") ??\n DEFAULT_RETRY_BACKOFF_ALGORITHM) as any,\n retryMaxAttempts:\n parseInt(url.searchParams.get(\"retry-max-attempts\")) ?? DEFAULT_RETRY_MAX_ATTEMPTS,\n retryInitialDelay:\n parseInt(url.searchParams.get(\"retry-initial-delay\")) ?? DEFAULT_RETRY_INITIAL_DELAY,\n retryExponentialBackoffMultiplier:\n parseInt(url.searchParams.get(\"retry-exp-backoff-multiplier\")) ??\n DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER,\n retryLinearBackoffStep:\n parseInt(url.searchParams.get(\"retry-linear-backoff-step\")) ??\n DEFAULT_RETRY_LINEAR_BACKOFF_STEP,\n retryJitter: parseInt(url.searchParams.get(\"retry-backoff-jitter\")) ?? DEFAULT_RETRY_JITTER,\n\n ...overrides,\n };\n}\n\n/**\n * Authorization data / JWT Token.\n * Absent JWT Token tells the client to connect as anonymous user.\n */\nexport interface AuthInformation {\n /** Absent token means anonymous access */\n jwtToken?: string;\n}\n\nexport const AnonymousAuthInformation: AuthInformation = {};\n\n/** Authorization related settings to pass to {@link PlClient}. */\nexport interface AuthOps {\n /** Initial authorization information */\n authInformation: AuthInformation;\n /** Will be executed after successful authorization information refresh */\n readonly onUpdate?: (newInfo: AuthInformation) => void;\n /** Will be executed if auth-related error happens during normal client operation */\n readonly onAuthError?: () => void;\n /** Will be executed if error encountered during token update */\n readonly onUpdateError?: (error: unknown) => void;\n}\n\n/** Connection status. */\nexport type PlConnectionStatus = \"OK\" | \"Disconnected\" | \"Unauthenticated\";\n\n/** Listener that will be called each time connection status changes. */\nexport type PlConnectionStatusListener = (status: PlConnectionStatus) => void;\n"],"mappings":";AAGA,MAAa,2BAA2B,CAAC,QAAQ,OAAO;AAsFxD,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,4BAA4B,MAAU,KAA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|
|
2
|
+
const require_config = require('./config.cjs');
|
|
3
|
+
const require_auth = require('./auth.cjs');
|
|
4
|
+
const require_client = require('./client.cjs');
|
|
5
|
+
const require_unauth_client = require('./unauth_client.cjs');
|
|
6
|
+
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
7
|
+
let node_crypto = require("node:crypto");
|
|
8
|
+
let node_fs = require("node:fs");
|
|
9
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
10
|
+
let canonicalize = require("canonicalize");
|
|
11
|
+
canonicalize = require_runtime.__toESM(canonicalize);
|
|
12
|
+
let yaml = require("yaml");
|
|
13
|
+
yaml = require_runtime.__toESM(yaml);
|
|
14
|
+
let node_os = require("node:os");
|
|
15
|
+
node_os = require_runtime.__toESM(node_os);
|
|
16
|
+
let node_path = require("node:path");
|
|
17
|
+
node_path = require_runtime.__toESM(node_path);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
var config = require('./config.cjs');
|
|
5
|
-
var canonicalize = require('canonicalize');
|
|
6
|
-
var YAML = require('yaml');
|
|
7
|
-
var os = require('node:os');
|
|
8
|
-
var path = require('node:path');
|
|
9
|
-
var tsHelpers = require('@milaboratories/ts-helpers');
|
|
10
|
-
var unauth_client = require('./unauth_client.cjs');
|
|
11
|
-
var client = require('./client.cjs');
|
|
12
|
-
var node_crypto = require('node:crypto');
|
|
13
|
-
var auth = require('./auth.cjs');
|
|
14
|
-
|
|
15
|
-
function _interopNamespaceDefault(e) {
|
|
16
|
-
var n = Object.create(null);
|
|
17
|
-
if (e) {
|
|
18
|
-
Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default') {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
n.default = e;
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
|
|
33
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
34
|
-
|
|
35
|
-
const CONFIG_FILE_LOCAL_JSON = "pl.json";
|
|
36
|
-
const CONFIG_FILE_USER_JSON = path__namespace.join(os__namespace.homedir(), ".pl.json");
|
|
37
|
-
const CONFIG_FILE_LOCAL_YAML = "pl.yaml";
|
|
38
|
-
const CONFIG_FILE_USER_YAML = path__namespace.join(os__namespace.homedir(), ".pl.yaml");
|
|
19
|
+
//#region src/core/default_client.ts
|
|
39
20
|
const CONF_FILE_SEQUENCE = [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
"pl.json",
|
|
22
|
+
"pl.yaml",
|
|
23
|
+
node_path.join(node_os.homedir(), ".pl.json"),
|
|
24
|
+
node_path.join(node_os.homedir(), ".pl.yaml")
|
|
44
25
|
];
|
|
45
26
|
const AUTH_DATA_FILE = ".pl_auth.json";
|
|
46
27
|
const FILE_CONFIG_OVERRIDE_FIELDS = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
28
|
+
"grpcProxy",
|
|
29
|
+
"httpProxy",
|
|
30
|
+
"user",
|
|
31
|
+
"password",
|
|
32
|
+
"alternativeRoot",
|
|
33
|
+
"defaultROTransactionTimeout",
|
|
34
|
+
"defaultRWTransactionTimeout",
|
|
35
|
+
"defaultRequestTimeout",
|
|
36
|
+
"authTTLSeconds",
|
|
37
|
+
"authMaxRefreshSeconds"
|
|
57
38
|
];
|
|
58
39
|
function tryGetFileConfig() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
else
|
|
65
|
-
return [YAML.parse(fileContent), confPath];
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
40
|
+
for (const confPath of CONF_FILE_SEQUENCE) if (node_fs.default.existsSync(confPath)) {
|
|
41
|
+
const fileContent = node_fs.default.readFileSync(confPath, { encoding: "utf-8" });
|
|
42
|
+
if (confPath.endsWith("json")) return [JSON.parse(fileContent), confPath];
|
|
43
|
+
else return [yaml.default.parse(fileContent), confPath];
|
|
44
|
+
}
|
|
68
45
|
}
|
|
69
46
|
function saveAuthInfoCallback(confHash, authMaxRefreshSeconds) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
return (newAuthInfo) => {
|
|
48
|
+
node_fs.default.writeFileSync(AUTH_DATA_FILE, Buffer.from(JSON.stringify({
|
|
49
|
+
confHash,
|
|
50
|
+
authInformation: newAuthInfo,
|
|
51
|
+
expiration: require_auth.inferAuthRefreshTime(newAuthInfo, authMaxRefreshSeconds)
|
|
52
|
+
})), "utf8");
|
|
53
|
+
};
|
|
77
54
|
}
|
|
78
55
|
const cleanAuthInfoCallback = () => {
|
|
79
|
-
|
|
56
|
+
node_fs.default.rmSync(AUTH_DATA_FILE);
|
|
80
57
|
};
|
|
81
58
|
/** Uses default algorithm to construct a pl client from the environment */
|
|
82
59
|
async function defaultPlClient() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
authInformation = await client.login(config$1.user, config$1.password);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// No authorization is required
|
|
124
|
-
authInformation = {};
|
|
125
|
-
}
|
|
126
|
-
// saving cache
|
|
127
|
-
fs.writeFileSync(AUTH_DATA_FILE, Buffer.from(JSON.stringify({
|
|
128
|
-
confHash,
|
|
129
|
-
authInformation,
|
|
130
|
-
expiration: auth.inferAuthRefreshTime(authInformation, config$1.authMaxRefreshSeconds),
|
|
131
|
-
})), "utf8");
|
|
132
|
-
}
|
|
133
|
-
return await client.PlClient.init(config$1, {
|
|
134
|
-
authInformation,
|
|
135
|
-
onUpdate: (_newAuthInfo) => saveAuthInfoCallback(confHash, config$1.authMaxRefreshSeconds),
|
|
136
|
-
onUpdateError: cleanAuthInfoCallback,
|
|
137
|
-
onAuthError: cleanAuthInfoCallback,
|
|
138
|
-
});
|
|
60
|
+
let config = void 0;
|
|
61
|
+
if (process.env.PL_ADDRESS !== void 0) config = require_config.plAddressToConfig(process.env.PL_ADDRESS);
|
|
62
|
+
else {
|
|
63
|
+
const fromFile = tryGetFileConfig();
|
|
64
|
+
if (fromFile !== void 0) {
|
|
65
|
+
const [fileConfig, configPath] = fromFile;
|
|
66
|
+
config = require_config.plAddressToConfig((0, _milaboratories_ts_helpers.notEmpty)(fileConfig.address, `no pl address in file: ${configPath}`));
|
|
67
|
+
for (const field of FILE_CONFIG_OVERRIDE_FIELDS) if (fileConfig[field] !== void 0) config[field] = fileConfig[field];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (config === void 0) throw new Error("Can't find configuration to create default platform client.");
|
|
71
|
+
if (process.env.PL_USER !== void 0) config.user = process.env.PL_USER;
|
|
72
|
+
if (process.env.PL_PASSWORD !== void 0) config.user = process.env.PL_PASSWORD;
|
|
73
|
+
const confHash = (0, node_crypto.createHash)("sha256").update(Buffer.from((0, canonicalize.default)(config))).digest("base64");
|
|
74
|
+
let authInformation = void 0;
|
|
75
|
+
if (node_fs.default.existsSync(AUTH_DATA_FILE)) {
|
|
76
|
+
const cache = JSON.parse(node_fs.default.readFileSync(AUTH_DATA_FILE, { encoding: "utf-8" }));
|
|
77
|
+
if (cache.confHash === confHash && cache.expiration > Date.now()) authInformation = cache.authInformation;
|
|
78
|
+
}
|
|
79
|
+
if (authInformation === void 0) {
|
|
80
|
+
const client = await require_unauth_client.UnauthenticatedPlClient.build(config);
|
|
81
|
+
if (await client.requireAuth()) {
|
|
82
|
+
if (config.user === void 0 || config.password === void 0) throw new Error(`No auth information for found to authenticate with PL server.`);
|
|
83
|
+
authInformation = await client.login(config.user, config.password);
|
|
84
|
+
} else authInformation = {};
|
|
85
|
+
node_fs.default.writeFileSync(AUTH_DATA_FILE, Buffer.from(JSON.stringify({
|
|
86
|
+
confHash,
|
|
87
|
+
authInformation,
|
|
88
|
+
expiration: require_auth.inferAuthRefreshTime(authInformation, config.authMaxRefreshSeconds)
|
|
89
|
+
})), "utf8");
|
|
90
|
+
}
|
|
91
|
+
return await require_client.PlClient.init(config, {
|
|
92
|
+
authInformation,
|
|
93
|
+
onUpdate: (_newAuthInfo) => saveAuthInfoCallback(confHash, config.authMaxRefreshSeconds),
|
|
94
|
+
onUpdateError: cleanAuthInfoCallback,
|
|
95
|
+
onAuthError: cleanAuthInfoCallback
|
|
96
|
+
});
|
|
139
97
|
}
|
|
140
98
|
|
|
99
|
+
//#endregion
|
|
141
100
|
exports.defaultPlClient = defaultPlClient;
|
|
142
101
|
exports.tryGetFileConfig = tryGetFileConfig;
|
|
143
|
-
//# sourceMappingURL=default_client.cjs.map
|
|
102
|
+
//# sourceMappingURL=default_client.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default_client.cjs","sources":["../../src/core/default_client.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { AuthInformation, PlClientConfig } from \"./config\";\nimport { plAddressToConfig } from \"./config\";\nimport canonicalize from \"canonicalize\";\nimport YAML from \"yaml\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport { UnauthenticatedPlClient } from \"./unauth_client\";\nimport { PlClient } from \"./client\";\nimport { createHash } from \"node:crypto\";\nimport { inferAuthRefreshTime } from \"./auth\";\n\nconst CONFIG_FILE_LOCAL_JSON = \"pl.json\";\nconst CONFIG_FILE_USER_JSON = path.join(os.homedir(), \".pl.json\");\nconst CONFIG_FILE_LOCAL_YAML = \"pl.yaml\";\nconst CONFIG_FILE_USER_YAML = path.join(os.homedir(), \".pl.yaml\");\nconst CONF_FILE_SEQUENCE = [\n CONFIG_FILE_LOCAL_JSON,\n CONFIG_FILE_LOCAL_YAML,\n CONFIG_FILE_USER_JSON,\n CONFIG_FILE_USER_YAML,\n];\n\nconst AUTH_DATA_FILE = \".pl_auth.json\";\n\ntype FileConfigOverrideFields =\n | \"grpcProxy\"\n | \"httpProxy\"\n | \"user\"\n | \"password\"\n | \"alternativeRoot\"\n | \"defaultROTransactionTimeout\"\n | \"defaultRWTransactionTimeout\"\n | \"defaultRequestTimeout\"\n | \"authTTLSeconds\"\n | \"authMaxRefreshSeconds\";\nconst FILE_CONFIG_OVERRIDE_FIELDS: FileConfigOverrideFields[] = [\n \"grpcProxy\",\n \"httpProxy\",\n \"user\",\n \"password\",\n \"alternativeRoot\",\n \"defaultROTransactionTimeout\",\n \"defaultRWTransactionTimeout\",\n \"defaultRequestTimeout\",\n \"authTTLSeconds\",\n \"authMaxRefreshSeconds\",\n];\n\ntype PlConfigFile = {\n address: string;\n} & Partial<Pick<PlClientConfig, FileConfigOverrideFields>>;\n\ninterface AuthCache {\n /** To check if config changed */\n confHash: string;\n expiration: number;\n authInformation: AuthInformation;\n}\n\nexport function tryGetFileConfig(): [PlConfigFile, string] | undefined {\n for (const confPath of CONF_FILE_SEQUENCE)\n if (fs.existsSync(confPath)) {\n const fileContent = fs.readFileSync(confPath, { encoding: \"utf-8\" });\n if (confPath.endsWith(\"json\")) return [JSON.parse(fileContent) as PlConfigFile, confPath];\n else return [YAML.parse(fileContent) as PlConfigFile, confPath];\n }\n return undefined;\n}\n\nfunction saveAuthInfoCallback(\n confHash: string,\n authMaxRefreshSeconds: number,\n): (newAuthInfo: AuthInformation) => void {\n return (newAuthInfo) => {\n fs.writeFileSync(\n AUTH_DATA_FILE,\n Buffer.from(\n JSON.stringify({\n confHash,\n authInformation: newAuthInfo,\n expiration: inferAuthRefreshTime(newAuthInfo, authMaxRefreshSeconds),\n } as AuthCache),\n ),\n \"utf8\",\n );\n };\n}\n\nconst cleanAuthInfoCallback = () => {\n fs.rmSync(AUTH_DATA_FILE);\n};\n\n/** Uses default algorithm to construct a pl client from the environment */\nexport async function defaultPlClient(): Promise<PlClient> {\n let config: PlClientConfig | undefined = undefined;\n if (process.env.PL_ADDRESS !== undefined) {\n config = plAddressToConfig(process.env.PL_ADDRESS);\n } else {\n const fromFile = tryGetFileConfig();\n if (fromFile !== undefined) {\n const [fileConfig, configPath] = fromFile;\n const address = notEmpty(fileConfig.address, `no pl address in file: ${configPath}`);\n config = plAddressToConfig(address);\n // applying overrides\n for (const field of FILE_CONFIG_OVERRIDE_FIELDS)\n if (fileConfig[field] !== undefined) (config as any)[field] = fileConfig[field];\n }\n }\n\n if (config === undefined)\n throw new Error(\"Can't find configuration to create default platform client.\");\n\n if (process.env.PL_USER !== undefined) config.user = process.env.PL_USER;\n\n if (process.env.PL_PASSWORD !== undefined) config.user = process.env.PL_PASSWORD;\n\n const confHash = createHash(\"sha256\")\n .update(Buffer.from(canonicalize(config)!))\n .digest(\"base64\");\n\n let authInformation: AuthInformation | undefined = undefined;\n\n // try recover auth information from cache\n if (fs.existsSync(AUTH_DATA_FILE)) {\n const cache: AuthCache = JSON.parse(fs.readFileSync(AUTH_DATA_FILE, { encoding: \"utf-8\" }));\n if (cache.confHash === confHash && cache.expiration > Date.now())\n authInformation = cache.authInformation;\n }\n\n if (authInformation === undefined) {\n const client = await UnauthenticatedPlClient.build(config);\n\n if (await client.requireAuth()) {\n if (config.user === undefined || config.password === undefined)\n throw new Error(`No auth information for found to authenticate with PL server.`);\n authInformation = await client.login(config.user, config.password);\n } else {\n // No authorization is required\n authInformation = {};\n }\n\n // saving cache\n fs.writeFileSync(\n AUTH_DATA_FILE,\n Buffer.from(\n JSON.stringify({\n confHash,\n authInformation,\n expiration: inferAuthRefreshTime(authInformation, config.authMaxRefreshSeconds),\n } as AuthCache),\n ),\n \"utf8\",\n );\n }\n\n return await PlClient.init(config, {\n authInformation,\n onUpdate: (_newAuthInfo) => saveAuthInfoCallback(confHash, config.authMaxRefreshSeconds),\n onUpdateError: cleanAuthInfoCallback,\n onAuthError: cleanAuthInfoCallback,\n });\n}\n"],"
|
|
1
|
+
{"version":3,"file":"default_client.cjs","names":["path","os","fs","YAML","inferAuthRefreshTime","plAddressToConfig","UnauthenticatedPlClient","PlClient"],"sources":["../../src/core/default_client.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { AuthInformation, PlClientConfig } from \"./config\";\nimport { plAddressToConfig } from \"./config\";\nimport canonicalize from \"canonicalize\";\nimport YAML from \"yaml\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport { UnauthenticatedPlClient } from \"./unauth_client\";\nimport { PlClient } from \"./client\";\nimport { createHash } from \"node:crypto\";\nimport { inferAuthRefreshTime } from \"./auth\";\n\nconst CONFIG_FILE_LOCAL_JSON = \"pl.json\";\nconst CONFIG_FILE_USER_JSON = path.join(os.homedir(), \".pl.json\");\nconst CONFIG_FILE_LOCAL_YAML = \"pl.yaml\";\nconst CONFIG_FILE_USER_YAML = path.join(os.homedir(), \".pl.yaml\");\nconst CONF_FILE_SEQUENCE = [\n CONFIG_FILE_LOCAL_JSON,\n CONFIG_FILE_LOCAL_YAML,\n CONFIG_FILE_USER_JSON,\n CONFIG_FILE_USER_YAML,\n];\n\nconst AUTH_DATA_FILE = \".pl_auth.json\";\n\ntype FileConfigOverrideFields =\n | \"grpcProxy\"\n | \"httpProxy\"\n | \"user\"\n | \"password\"\n | \"alternativeRoot\"\n | \"defaultROTransactionTimeout\"\n | \"defaultRWTransactionTimeout\"\n | \"defaultRequestTimeout\"\n | \"authTTLSeconds\"\n | \"authMaxRefreshSeconds\";\nconst FILE_CONFIG_OVERRIDE_FIELDS: FileConfigOverrideFields[] = [\n \"grpcProxy\",\n \"httpProxy\",\n \"user\",\n \"password\",\n \"alternativeRoot\",\n \"defaultROTransactionTimeout\",\n \"defaultRWTransactionTimeout\",\n \"defaultRequestTimeout\",\n \"authTTLSeconds\",\n \"authMaxRefreshSeconds\",\n];\n\ntype PlConfigFile = {\n address: string;\n} & Partial<Pick<PlClientConfig, FileConfigOverrideFields>>;\n\ninterface AuthCache {\n /** To check if config changed */\n confHash: string;\n expiration: number;\n authInformation: AuthInformation;\n}\n\nexport function tryGetFileConfig(): [PlConfigFile, string] | undefined {\n for (const confPath of CONF_FILE_SEQUENCE)\n if (fs.existsSync(confPath)) {\n const fileContent = fs.readFileSync(confPath, { encoding: \"utf-8\" });\n if (confPath.endsWith(\"json\")) return [JSON.parse(fileContent) as PlConfigFile, confPath];\n else return [YAML.parse(fileContent) as PlConfigFile, confPath];\n }\n return undefined;\n}\n\nfunction saveAuthInfoCallback(\n confHash: string,\n authMaxRefreshSeconds: number,\n): (newAuthInfo: AuthInformation) => void {\n return (newAuthInfo) => {\n fs.writeFileSync(\n AUTH_DATA_FILE,\n Buffer.from(\n JSON.stringify({\n confHash,\n authInformation: newAuthInfo,\n expiration: inferAuthRefreshTime(newAuthInfo, authMaxRefreshSeconds),\n } as AuthCache),\n ),\n \"utf8\",\n );\n };\n}\n\nconst cleanAuthInfoCallback = () => {\n fs.rmSync(AUTH_DATA_FILE);\n};\n\n/** Uses default algorithm to construct a pl client from the environment */\nexport async function defaultPlClient(): Promise<PlClient> {\n let config: PlClientConfig | undefined = undefined;\n if (process.env.PL_ADDRESS !== undefined) {\n config = plAddressToConfig(process.env.PL_ADDRESS);\n } else {\n const fromFile = tryGetFileConfig();\n if (fromFile !== undefined) {\n const [fileConfig, configPath] = fromFile;\n const address = notEmpty(fileConfig.address, `no pl address in file: ${configPath}`);\n config = plAddressToConfig(address);\n // applying overrides\n for (const field of FILE_CONFIG_OVERRIDE_FIELDS)\n if (fileConfig[field] !== undefined) (config as any)[field] = fileConfig[field];\n }\n }\n\n if (config === undefined)\n throw new Error(\"Can't find configuration to create default platform client.\");\n\n if (process.env.PL_USER !== undefined) config.user = process.env.PL_USER;\n\n if (process.env.PL_PASSWORD !== undefined) config.user = process.env.PL_PASSWORD;\n\n const confHash = createHash(\"sha256\")\n .update(Buffer.from(canonicalize(config)!))\n .digest(\"base64\");\n\n let authInformation: AuthInformation | undefined = undefined;\n\n // try recover auth information from cache\n if (fs.existsSync(AUTH_DATA_FILE)) {\n const cache: AuthCache = JSON.parse(fs.readFileSync(AUTH_DATA_FILE, { encoding: \"utf-8\" }));\n if (cache.confHash === confHash && cache.expiration > Date.now())\n authInformation = cache.authInformation;\n }\n\n if (authInformation === undefined) {\n const client = await UnauthenticatedPlClient.build(config);\n\n if (await client.requireAuth()) {\n if (config.user === undefined || config.password === undefined)\n throw new Error(`No auth information for found to authenticate with PL server.`);\n authInformation = await client.login(config.user, config.password);\n } else {\n // No authorization is required\n authInformation = {};\n }\n\n // saving cache\n fs.writeFileSync(\n AUTH_DATA_FILE,\n Buffer.from(\n JSON.stringify({\n confHash,\n authInformation,\n expiration: inferAuthRefreshTime(authInformation, config.authMaxRefreshSeconds),\n } as AuthCache),\n ),\n \"utf8\",\n );\n }\n\n return await PlClient.init(config, {\n authInformation,\n onUpdate: (_newAuthInfo) => saveAuthInfoCallback(confHash, config.authMaxRefreshSeconds),\n onUpdateError: cleanAuthInfoCallback,\n onAuthError: cleanAuthInfoCallback,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAM,qBAAqB;C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;CAErE,MAAM,uCAAsB,SAAS,CAClC,OAAO,OAAO,+BAAkB,OAAO,CAAE,CAAC,CAC1C,OAAO,SAAS;CAEnB,IAAI,kBAA+C;AAGnD,KAAIH,gBAAG,WAAW,eAAe,EAAE;EACjC,MAAM,QAAmB,KAAK,MAAMA,gBAAG,aAAa,gBAAgB,EAAE,UAAU,SAAS,CAAC,CAAC;AAC3F,MAAI,MAAM,aAAa,YAAY,MAAM,aAAa,KAAK,KAAK,CAC9D,mBAAkB,MAAM;;AAG5B,KAAI,oBAAoB,QAAW;EACjC,MAAM,SAAS,MAAMI,8CAAwB,MAAM,OAAO;AAE1D,MAAI,MAAM,OAAO,aAAa,EAAE;AAC9B,OAAI,OAAO,SAAS,UAAa,OAAO,aAAa,OACnD,OAAM,IAAI,MAAM,gEAAgE;AAClF,qBAAkB,MAAM,OAAO,MAAM,OAAO,MAAM,OAAO,SAAS;QAGlE,mBAAkB,EAAE;AAItB,kBAAG,cACD,gBACA,OAAO,KACL,KAAK,UAAU;GACb;GACA;GACA,YAAYF,kCAAqB,iBAAiB,OAAO,sBAAsB;GAChF,CAAc,CAChB,EACD,OACD;;AAGH,QAAO,MAAMG,wBAAS,KAAK,QAAQ;EACjC;EACA,WAAW,iBAAiB,qBAAqB,UAAU,OAAO,sBAAsB;EACxF,eAAe;EACf,aAAa;EACd,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PlClient } from "./client";
|
|
1
|
+
import { PlClientConfig } from "./config.js";
|
|
2
|
+
import { PlClient } from "./client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/core/default_client.d.ts
|
|
3
5
|
type FileConfigOverrideFields = "grpcProxy" | "httpProxy" | "user" | "password" | "alternativeRoot" | "defaultROTransactionTimeout" | "defaultRWTransactionTimeout" | "defaultRequestTimeout" | "authTTLSeconds" | "authMaxRefreshSeconds";
|
|
4
6
|
type PlConfigFile = {
|
|
5
|
-
|
|
7
|
+
address: string;
|
|
6
8
|
} & Partial<Pick<PlClientConfig, FileConfigOverrideFields>>;
|
|
7
|
-
|
|
9
|
+
declare function tryGetFileConfig(): [PlConfigFile, string] | undefined;
|
|
8
10
|
/** Uses default algorithm to construct a pl client from the environment */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
declare function defaultPlClient(): Promise<PlClient>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { defaultPlClient, tryGetFileConfig };
|
|
11
14
|
//# sourceMappingURL=default_client.d.ts.map
|