@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/client.cjs
CHANGED
|
@@ -1,313 +1,262 @@
|
|
|
1
|
-
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_types = require('./types.cjs');
|
|
3
|
+
const require_api = require('../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs');
|
|
4
|
+
const require_stat = require('./stat.cjs');
|
|
5
|
+
const require_transaction = require('./transaction.cjs');
|
|
6
|
+
const require_pl = require('../helpers/pl.cjs');
|
|
7
|
+
const require_config = require('./config.cjs');
|
|
8
|
+
const require_ll_client = require('./ll_client.cjs');
|
|
9
|
+
const require_final = require('./final.cjs');
|
|
10
|
+
const require_advisory_locks = require('./advisory_locks.cjs');
|
|
11
|
+
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
12
|
+
let node_crypto = require("node:crypto");
|
|
13
|
+
let node_timers_promises = require("node:timers/promises");
|
|
14
|
+
node_timers_promises = require_runtime.__toESM(node_timers_promises);
|
|
15
|
+
let lru_cache = require("lru-cache");
|
|
2
16
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var node_crypto = require('node:crypto');
|
|
6
|
-
var types = require('./types.cjs');
|
|
7
|
-
var pl = require('../helpers/pl.cjs');
|
|
8
|
-
var tsHelpers = require('@milaboratories/ts-helpers');
|
|
9
|
-
var api = require('../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs');
|
|
10
|
-
var tp = require('node:timers/promises');
|
|
11
|
-
var lruCache = require('lru-cache');
|
|
12
|
-
var final = require('./final.cjs');
|
|
13
|
-
var stat = require('./stat.cjs');
|
|
14
|
-
var advisory_locks = require('./advisory_locks.cjs');
|
|
15
|
-
var config = require('./config.cjs');
|
|
16
|
-
|
|
17
|
-
function _interopNamespaceDefault(e) {
|
|
18
|
-
var n = Object.create(null);
|
|
19
|
-
if (e) {
|
|
20
|
-
Object.keys(e).forEach(function (k) {
|
|
21
|
-
if (k !== 'default') {
|
|
22
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return e[k]; }
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
n.default = e;
|
|
31
|
-
return Object.freeze(n);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var tp__namespace = /*#__PURE__*/_interopNamespaceDefault(tp);
|
|
35
|
-
|
|
36
|
-
const defaultTxOps = {
|
|
37
|
-
sync: false,
|
|
38
|
-
};
|
|
17
|
+
//#region src/core/client.ts
|
|
18
|
+
const defaultTxOps = { sync: false };
|
|
39
19
|
const AnonymousClientRoot = "AnonymousRoot";
|
|
40
20
|
function alternativeRootFieldName(alternativeRoot) {
|
|
41
|
-
|
|
21
|
+
return `alternative_root_${alternativeRoot}`;
|
|
42
22
|
}
|
|
43
23
|
/** Client to access core PL API. */
|
|
44
|
-
class PlClient {
|
|
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
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
await tp__namespace.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });
|
|
280
|
-
retryState = tsHelpers.nextRetryStateOrError(retryState);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
async withTx(name, writable, body, ops = {}) {
|
|
284
|
-
this.checkInitialized();
|
|
285
|
-
return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });
|
|
286
|
-
}
|
|
287
|
-
async withWriteTx(name, body, ops = {}) {
|
|
288
|
-
return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });
|
|
289
|
-
}
|
|
290
|
-
async withReadTx(name, body, ops = {}) {
|
|
291
|
-
return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });
|
|
292
|
-
}
|
|
293
|
-
getDriver(definition) {
|
|
294
|
-
const attached = this.drivers.get(definition.name);
|
|
295
|
-
if (attached !== undefined)
|
|
296
|
-
return attached;
|
|
297
|
-
const driver = definition.init(this, this.ll, this.httpDispatcher);
|
|
298
|
-
this.drivers.set(definition.name, driver);
|
|
299
|
-
return driver;
|
|
300
|
-
}
|
|
301
|
-
/** Closes underlying transport */
|
|
302
|
-
async close() {
|
|
303
|
-
await this.ll.close();
|
|
304
|
-
}
|
|
305
|
-
static async init(configOrAddress, auth, ops = {}) {
|
|
306
|
-
const pl = new PlClient(configOrAddress, auth, ops);
|
|
307
|
-
await pl.init();
|
|
308
|
-
return pl;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
24
|
+
var PlClient = class PlClient {
|
|
25
|
+
drivers = /* @__PURE__ */ new Map();
|
|
26
|
+
/** Artificial delay introduced after write transactions completion, to
|
|
27
|
+
* somewhat throttle the load on pl. Delay introduced after sync, if requested. */
|
|
28
|
+
txDelay;
|
|
29
|
+
/** Last resort measure to solve complicated race conditions in pl. */
|
|
30
|
+
forceSync;
|
|
31
|
+
/** Last resort measure to solve complicated race conditions in pl. */
|
|
32
|
+
defaultRetryOptions;
|
|
33
|
+
buildLLPlClient;
|
|
34
|
+
_ll;
|
|
35
|
+
get ll() {
|
|
36
|
+
if (this._ll === void 0) throw new Error("LLPlClient not initialized");
|
|
37
|
+
return this._ll;
|
|
38
|
+
}
|
|
39
|
+
/** Stores client root (this abstraction is intended for future implementation of the security model) */
|
|
40
|
+
_clientRoot = require_types.NullResourceId;
|
|
41
|
+
_serverInfo = void 0;
|
|
42
|
+
_txCommittedStat = require_stat.initialTxStat();
|
|
43
|
+
_txConflictStat = require_stat.initialTxStat();
|
|
44
|
+
_txErrorStat = require_stat.initialTxStat();
|
|
45
|
+
/** This function determines whether resource data can be cached */
|
|
46
|
+
finalPredicate;
|
|
47
|
+
/** Resource data cache, to minimize redundant data rereading from remote db */
|
|
48
|
+
resourceDataCache;
|
|
49
|
+
constructor(configOrAddress, auth, ops = {}) {
|
|
50
|
+
const conf = typeof configOrAddress === "string" ? require_config.plAddressToConfig(configOrAddress) : configOrAddress;
|
|
51
|
+
this.buildLLPlClient = async (shouldUseGzip, wireProtocol) => {
|
|
52
|
+
if (wireProtocol) conf.wireProtocol = wireProtocol;
|
|
53
|
+
return await require_ll_client.LLPlClient.build(conf, {
|
|
54
|
+
auth,
|
|
55
|
+
...ops,
|
|
56
|
+
shouldUseGzip
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
this.txDelay = conf.txDelay;
|
|
60
|
+
this.forceSync = conf.forceSync;
|
|
61
|
+
this.finalPredicate = ops.finalPredicate ?? require_final.DefaultFinalResourceDataPredicate;
|
|
62
|
+
this.resourceDataCache = new lru_cache.LRUCache({
|
|
63
|
+
maxSize: conf.maxCacheBytes,
|
|
64
|
+
sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64
|
|
65
|
+
});
|
|
66
|
+
switch (conf.retryBackoffAlgorithm) {
|
|
67
|
+
case "exponential":
|
|
68
|
+
this.defaultRetryOptions = {
|
|
69
|
+
type: "exponentialBackoff",
|
|
70
|
+
initialDelay: conf.retryInitialDelay,
|
|
71
|
+
maxAttempts: conf.retryMaxAttempts,
|
|
72
|
+
backoffMultiplier: conf.retryExponentialBackoffMultiplier,
|
|
73
|
+
jitter: conf.retryJitter
|
|
74
|
+
};
|
|
75
|
+
break;
|
|
76
|
+
case "linear":
|
|
77
|
+
this.defaultRetryOptions = {
|
|
78
|
+
type: "linearBackoff",
|
|
79
|
+
initialDelay: conf.retryInitialDelay,
|
|
80
|
+
maxAttempts: conf.retryMaxAttempts,
|
|
81
|
+
backoffStep: conf.retryLinearBackoffStep,
|
|
82
|
+
jitter: conf.retryJitter
|
|
83
|
+
};
|
|
84
|
+
break;
|
|
85
|
+
default: (0, _milaboratories_ts_helpers.assertNever)(conf.retryBackoffAlgorithm);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
get txCommittedStat() {
|
|
89
|
+
return { ...this._txCommittedStat };
|
|
90
|
+
}
|
|
91
|
+
get txConflictStat() {
|
|
92
|
+
return { ...this._txConflictStat };
|
|
93
|
+
}
|
|
94
|
+
get txErrorStat() {
|
|
95
|
+
return { ...this._txErrorStat };
|
|
96
|
+
}
|
|
97
|
+
get txTotalStat() {
|
|
98
|
+
return require_stat.addStat(require_stat.addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);
|
|
99
|
+
}
|
|
100
|
+
get allTxStat() {
|
|
101
|
+
return {
|
|
102
|
+
committed: this.txCommittedStat,
|
|
103
|
+
conflict: this.txConflictStat,
|
|
104
|
+
error: this.txErrorStat
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async ping() {
|
|
108
|
+
return await this.ll.ping();
|
|
109
|
+
}
|
|
110
|
+
async license() {
|
|
111
|
+
return await this.ll.license();
|
|
112
|
+
}
|
|
113
|
+
get conf() {
|
|
114
|
+
return this.ll.conf;
|
|
115
|
+
}
|
|
116
|
+
get httpDispatcher() {
|
|
117
|
+
return this.ll.httpDispatcher;
|
|
118
|
+
}
|
|
119
|
+
get connectionOpts() {
|
|
120
|
+
return this.ll.wireConnection;
|
|
121
|
+
}
|
|
122
|
+
get initialized() {
|
|
123
|
+
return !require_types.isNullResourceId(this._clientRoot);
|
|
124
|
+
}
|
|
125
|
+
checkInitialized() {
|
|
126
|
+
if (!this.initialized) throw new Error("Client not initialized");
|
|
127
|
+
}
|
|
128
|
+
get clientRoot() {
|
|
129
|
+
this.checkInitialized();
|
|
130
|
+
return require_types.ensureResourceIdNotNull(this._clientRoot);
|
|
131
|
+
}
|
|
132
|
+
get serverInfo() {
|
|
133
|
+
this.checkInitialized();
|
|
134
|
+
return this._serverInfo;
|
|
135
|
+
}
|
|
136
|
+
/** Currently implements custom logic to emulate future behaviour with single root. */
|
|
137
|
+
async init() {
|
|
138
|
+
if (this.initialized) throw new Error("Already initialized");
|
|
139
|
+
this._ll = await this.buildLLPlClient(false);
|
|
140
|
+
const wireProtocol = this._ll.wireProtocol;
|
|
141
|
+
const user = this._ll.authUser;
|
|
142
|
+
const mainRootName = user === null ? AnonymousClientRoot : (0, node_crypto.createHash)("sha256").update(user).digest("hex");
|
|
143
|
+
this._serverInfo = await this.ping();
|
|
144
|
+
if (this._serverInfo.compression === require_api.MaintenanceAPI_Ping_Response_Compression.GZIP) {
|
|
145
|
+
await this._ll.close();
|
|
146
|
+
this._ll = await this.buildLLPlClient(true, wireProtocol);
|
|
147
|
+
}
|
|
148
|
+
this._clientRoot = await this._withTx("initialization", true, require_types.NullResourceId, async (tx) => {
|
|
149
|
+
let mainRoot;
|
|
150
|
+
if (await tx.checkResourceNameExists(mainRootName)) mainRoot = await tx.getResourceByName(mainRootName);
|
|
151
|
+
else {
|
|
152
|
+
mainRoot = tx.createRoot(require_pl.ClientRoot);
|
|
153
|
+
tx.setResourceName(mainRootName, mainRoot);
|
|
154
|
+
}
|
|
155
|
+
if (this.conf.alternativeRoot === void 0) {
|
|
156
|
+
await tx.commit();
|
|
157
|
+
return await require_transaction.toGlobalResourceId(mainRoot);
|
|
158
|
+
} else {
|
|
159
|
+
const aFId = {
|
|
160
|
+
resourceId: mainRoot,
|
|
161
|
+
fieldName: alternativeRootFieldName(this.conf.alternativeRoot)
|
|
162
|
+
};
|
|
163
|
+
const altRoot = tx.createEphemeral(require_pl.ClientRoot);
|
|
164
|
+
tx.lock(altRoot);
|
|
165
|
+
tx.createField(aFId, "Dynamic");
|
|
166
|
+
tx.setField(aFId, altRoot);
|
|
167
|
+
await tx.commit();
|
|
168
|
+
return await altRoot.globalId;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** Returns true if field existed */
|
|
173
|
+
async deleteAlternativeRoot(alternativeRootName) {
|
|
174
|
+
this.checkInitialized();
|
|
175
|
+
if (this.ll.conf.alternativeRoot !== void 0) throw new Error("Initialized with alternative root.");
|
|
176
|
+
return await this.withWriteTx("delete-alternative-root", async (tx) => {
|
|
177
|
+
const fId = {
|
|
178
|
+
resourceId: tx.clientRoot,
|
|
179
|
+
fieldName: alternativeRootFieldName(alternativeRootName)
|
|
180
|
+
};
|
|
181
|
+
const exists = tx.fieldExists(fId);
|
|
182
|
+
tx.removeField(fId);
|
|
183
|
+
await tx.commit();
|
|
184
|
+
return await exists;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
async _withTx(name, writable, clientRoot, body, ops) {
|
|
188
|
+
let retryState = (0, _milaboratories_ts_helpers.createRetryState)(ops?.retryOptions ?? this.defaultRetryOptions);
|
|
189
|
+
while (true) {
|
|
190
|
+
const release = ops?.lockId ? await require_advisory_locks.advisoryLock(ops.lockId) : () => {};
|
|
191
|
+
try {
|
|
192
|
+
const tx = new require_transaction.PlTransaction(this.ll.createTx(writable, ops), name, writable, clientRoot, this.finalPredicate, this.resourceDataCache);
|
|
193
|
+
let ok = false;
|
|
194
|
+
let result = void 0;
|
|
195
|
+
let txId;
|
|
196
|
+
try {
|
|
197
|
+
result = await body(tx);
|
|
198
|
+
this._txCommittedStat = require_stat.addStat(this._txCommittedStat, tx.stat);
|
|
199
|
+
ok = true;
|
|
200
|
+
} catch (e) {
|
|
201
|
+
if (e instanceof require_transaction.TxCommitConflict) this._txConflictStat = require_stat.addStat(this._txConflictStat, tx.stat);
|
|
202
|
+
else {
|
|
203
|
+
this._txErrorStat = require_stat.addStat(this._txErrorStat, tx.stat);
|
|
204
|
+
throw e;
|
|
205
|
+
}
|
|
206
|
+
} finally {
|
|
207
|
+
await tx.complete();
|
|
208
|
+
await tx.await();
|
|
209
|
+
txId = await tx.getGlobalTxId();
|
|
210
|
+
}
|
|
211
|
+
if (ok) {
|
|
212
|
+
if (ops?.sync === void 0 ? this.forceSync : ops?.sync) await this.ll.txSync(txId);
|
|
213
|
+
if (writable && this.txDelay > 0) await node_timers_promises.setTimeout(this.txDelay, void 0, { signal: ops?.abortSignal });
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
} finally {
|
|
217
|
+
release();
|
|
218
|
+
}
|
|
219
|
+
await node_timers_promises.setTimeout(retryState.nextDelay, void 0, { signal: ops?.abortSignal });
|
|
220
|
+
retryState = (0, _milaboratories_ts_helpers.nextRetryStateOrError)(retryState);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async withTx(name, writable, body, ops = {}) {
|
|
224
|
+
this.checkInitialized();
|
|
225
|
+
return await this._withTx(name, writable, this.clientRoot, body, {
|
|
226
|
+
...ops,
|
|
227
|
+
...defaultTxOps
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async withWriteTx(name, body, ops = {}) {
|
|
231
|
+
return await this.withTx(name, true, body, {
|
|
232
|
+
...ops,
|
|
233
|
+
...defaultTxOps
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
async withReadTx(name, body, ops = {}) {
|
|
237
|
+
return await this.withTx(name, false, body, {
|
|
238
|
+
...ops,
|
|
239
|
+
...defaultTxOps
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
getDriver(definition) {
|
|
243
|
+
const attached = this.drivers.get(definition.name);
|
|
244
|
+
if (attached !== void 0) return attached;
|
|
245
|
+
const driver = definition.init(this, this.ll, this.httpDispatcher);
|
|
246
|
+
this.drivers.set(definition.name, driver);
|
|
247
|
+
return driver;
|
|
248
|
+
}
|
|
249
|
+
/** Closes underlying transport */
|
|
250
|
+
async close() {
|
|
251
|
+
await this.ll.close();
|
|
252
|
+
}
|
|
253
|
+
static async init(configOrAddress, auth, ops = {}) {
|
|
254
|
+
const pl = new PlClient(configOrAddress, auth, ops);
|
|
255
|
+
await pl.init();
|
|
256
|
+
return pl;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
311
259
|
|
|
260
|
+
//#endregion
|
|
312
261
|
exports.PlClient = PlClient;
|
|
313
|
-
//# sourceMappingURL=client.cjs.map
|
|
262
|
+
//# sourceMappingURL=client.cjs.map
|