@milaboratories/pl-client 2.17.7 → 2.17.8
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 +277 -349
- package/dist/core/websocket_stream.cjs.map +1 -1
- package/dist/core/websocket_stream.js +275 -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/transaction.ts +123 -133
- 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
|
@@ -1,55 +1,48 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
const m = new Map();
|
|
2
|
+
//#region src/core/advisory_locks.ts
|
|
3
|
+
var AwaitLock = class {
|
|
4
|
+
acquired = false;
|
|
5
|
+
resolvers = [];
|
|
6
|
+
acquireAsync() {
|
|
7
|
+
if (!this.acquired) {
|
|
8
|
+
this.acquired = true;
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
}
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
this.resolvers.push(resolve);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).
|
|
17
|
+
*/
|
|
18
|
+
release() {
|
|
19
|
+
if (!this.acquired) throw new Error("Cannot release an unacquired lock");
|
|
20
|
+
if (this.resolvers.length) {
|
|
21
|
+
this.resolvers.shift()?.();
|
|
22
|
+
return false;
|
|
23
|
+
} else {
|
|
24
|
+
this.acquired = false;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const m = /* @__PURE__ */ new Map();
|
|
33
30
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
* Acquire a process-local async lock for the given id and return a release function.
|
|
32
|
+
* Ensures only one concurrent operation per id within this process.
|
|
33
|
+
*/
|
|
37
34
|
async function advisoryLock(id) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
released = true;
|
|
48
|
-
const nowIdle = lock.release();
|
|
49
|
-
if (nowIdle)
|
|
50
|
-
m.delete(id);
|
|
51
|
-
};
|
|
35
|
+
if (!m.has(id)) m.set(id, new AwaitLock());
|
|
36
|
+
const lock = m.get(id);
|
|
37
|
+
await lock.acquireAsync();
|
|
38
|
+
let released = false;
|
|
39
|
+
return () => {
|
|
40
|
+
if (released) return;
|
|
41
|
+
released = true;
|
|
42
|
+
if (lock.release()) m.delete(id);
|
|
43
|
+
};
|
|
52
44
|
}
|
|
53
45
|
|
|
46
|
+
//#endregion
|
|
54
47
|
exports.advisoryLock = advisoryLock;
|
|
55
|
-
//# sourceMappingURL=advisory_locks.cjs.map
|
|
48
|
+
//# sourceMappingURL=advisory_locks.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advisory_locks.cjs","sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"advisory_locks.cjs","names":[],"sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"mappings":";;AAAA,IAAM,YAAN,MAAgB;CACd,AAAQ,WAAW;CACnB,AAAQ,YAA4B,EAAE;CAEtC,eAA8B;AAC5B,MAAI,CAAC,KAAK,UAAU;AAClB,QAAK,WAAW;AAChB,UAAO,QAAQ,SAAS;;AAG1B,SAAO,IAAI,SAAS,YAAY;AAC9B,QAAK,UAAU,KAAK,QAAQ;IAC5B;;;;;CAMJ,UAAmB;AACjB,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,oCAAoC;AAGtD,MAAI,KAAK,UAAU,QAAQ;AACzB,QAAK,UAAU,OAAO,IAAI;AAC1B,UAAO;SACF;AACL,QAAK,WAAW;AAChB,UAAO;;;;AAKb,MAAM,oBAAI,IAAI,KAAwB;;;;;AAMtC,eAAsB,aAAa,IAAY;AAC7C,KAAI,CAAC,EAAE,IAAI,GAAG,CACZ,GAAE,IAAI,IAAI,IAAI,WAAW,CAAC;CAG5B,MAAM,OAAO,EAAE,IAAI,GAAG;AACtB,OAAM,KAAK,cAAc;CAEzB,IAAI,WAAW;AACf,cAAa;AACX,MAAI,SAAU;AACd,aAAW;AAEX,MADgB,KAAK,SAAS,CACjB,GAAE,OAAO,GAAG"}
|
|
@@ -1,53 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const m = new Map();
|
|
1
|
+
//#region src/core/advisory_locks.ts
|
|
2
|
+
var AwaitLock = class {
|
|
3
|
+
acquired = false;
|
|
4
|
+
resolvers = [];
|
|
5
|
+
acquireAsync() {
|
|
6
|
+
if (!this.acquired) {
|
|
7
|
+
this.acquired = true;
|
|
8
|
+
return Promise.resolve();
|
|
9
|
+
}
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
this.resolvers.push(resolve);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).
|
|
16
|
+
*/
|
|
17
|
+
release() {
|
|
18
|
+
if (!this.acquired) throw new Error("Cannot release an unacquired lock");
|
|
19
|
+
if (this.resolvers.length) {
|
|
20
|
+
this.resolvers.shift()?.();
|
|
21
|
+
return false;
|
|
22
|
+
} else {
|
|
23
|
+
this.acquired = false;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const m = /* @__PURE__ */ new Map();
|
|
31
29
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
* Acquire a process-local async lock for the given id and return a release function.
|
|
31
|
+
* Ensures only one concurrent operation per id within this process.
|
|
32
|
+
*/
|
|
35
33
|
async function advisoryLock(id) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
released = true;
|
|
46
|
-
const nowIdle = lock.release();
|
|
47
|
-
if (nowIdle)
|
|
48
|
-
m.delete(id);
|
|
49
|
-
};
|
|
34
|
+
if (!m.has(id)) m.set(id, new AwaitLock());
|
|
35
|
+
const lock = m.get(id);
|
|
36
|
+
await lock.acquireAsync();
|
|
37
|
+
let released = false;
|
|
38
|
+
return () => {
|
|
39
|
+
if (released) return;
|
|
40
|
+
released = true;
|
|
41
|
+
if (lock.release()) m.delete(id);
|
|
42
|
+
};
|
|
50
43
|
}
|
|
51
44
|
|
|
45
|
+
//#endregion
|
|
52
46
|
export { advisoryLock };
|
|
53
|
-
//# sourceMappingURL=advisory_locks.js.map
|
|
47
|
+
//# sourceMappingURL=advisory_locks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advisory_locks.js","sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"advisory_locks.js","names":[],"sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"mappings":";AAAA,IAAM,YAAN,MAAgB;CACd,AAAQ,WAAW;CACnB,AAAQ,YAA4B,EAAE;CAEtC,eAA8B;AAC5B,MAAI,CAAC,KAAK,UAAU;AAClB,QAAK,WAAW;AAChB,UAAO,QAAQ,SAAS;;AAG1B,SAAO,IAAI,SAAS,YAAY;AAC9B,QAAK,UAAU,KAAK,QAAQ;IAC5B;;;;;CAMJ,UAAmB;AACjB,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,oCAAoC;AAGtD,MAAI,KAAK,UAAU,QAAQ;AACzB,QAAK,UAAU,OAAO,IAAI;AAC1B,UAAO;SACF;AACL,QAAK,WAAW;AAChB,UAAO;;;;AAKb,MAAM,oBAAI,IAAI,KAAwB;;;;;AAMtC,eAAsB,aAAa,IAAY;AAC7C,KAAI,CAAC,EAAE,IAAI,GAAG,CACZ,GAAE,IAAI,IAAI,IAAI,WAAW,CAAC;CAG5B,MAAM,OAAO,EAAE,IAAI,GAAG;AACtB,OAAM,KAAK,cAAc;CAEzB,IAAI,WAAW;AACf,cAAa;AACX,MAAI,SAAU;AACd,aAAW;AAEX,MADgB,KAAK,SAAS,CACjB,GAAE,OAAO,GAAG"}
|
package/dist/core/auth.cjs
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var pl = require('../util/pl.cjs');
|
|
1
|
+
const require_pl = require('../util/pl.cjs');
|
|
4
2
|
|
|
3
|
+
//#region src/core/auth.ts
|
|
5
4
|
/** Returns a timestamp when current authorization information should be refreshed.
|
|
6
|
-
|
|
5
|
+
* Compare the value with Date.now(). */
|
|
7
6
|
function inferAuthRefreshTime(info, maxRefreshSeconds) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (Math.min(
|
|
12
|
-
// in the middle between issue and expiration time points
|
|
13
|
-
(iat + exp) / 2, iat + maxRefreshSeconds) * 1000);
|
|
7
|
+
if (info.jwtToken === void 0) return void 0;
|
|
8
|
+
const { exp, iat } = require_pl.parsePlJwt(info.jwtToken);
|
|
9
|
+
return Math.min((iat + exp) / 2, iat + maxRefreshSeconds) * 1e3;
|
|
14
10
|
}
|
|
15
11
|
function expirationFromAuthInformation(authInfo) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const parsed = pl.parsePlJwt(authInfo.jwtToken);
|
|
19
|
-
return parsed.exp * 1000;
|
|
12
|
+
if (authInfo.jwtToken === void 0) return void 0;
|
|
13
|
+
return require_pl.parsePlJwt(authInfo.jwtToken).exp * 1e3;
|
|
20
14
|
}
|
|
21
15
|
|
|
16
|
+
//#endregion
|
|
22
17
|
exports.expirationFromAuthInformation = expirationFromAuthInformation;
|
|
23
18
|
exports.inferAuthRefreshTime = inferAuthRefreshTime;
|
|
24
|
-
//# sourceMappingURL=auth.cjs.map
|
|
19
|
+
//# sourceMappingURL=auth.cjs.map
|
package/dist/core/auth.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.cjs","sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"auth.cjs","names":["parsePlJwt"],"sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"mappings":";;;;;AAKA,SAAgB,qBACd,MACA,mBACoB;AACpB,KAAI,KAAK,aAAa,OAAW,QAAO;CAExC,MAAM,EAAE,KAAK,QAAQA,sBAAW,KAAK,SAAS;AAE9C,QACE,KAAK,KAEF,MAAM,OAAO,GACd,MAAM,kBACP,GAAG;;AAIR,SAAgB,8BAA8B,UAA+C;AAC3F,KAAI,SAAS,aAAa,OAAW,QAAO;AAE5C,QADeA,sBAAW,SAAS,SAAS,CAC9B,MAAM"}
|
package/dist/core/auth.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AuthInformation } from "./config.js";
|
|
2
|
+
|
|
3
|
+
//#region src/core/auth.d.ts
|
|
2
4
|
/** Returns a timestamp when current authorization information should be refreshed.
|
|
3
5
|
* Compare the value with Date.now(). */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
declare function inferAuthRefreshTime(info: AuthInformation, maxRefreshSeconds: number): number | undefined;
|
|
7
|
+
declare function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { expirationFromAuthInformation, inferAuthRefreshTime };
|
|
6
10
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/core/auth.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { parsePlJwt } from
|
|
1
|
+
import { parsePlJwt } from "../util/pl.js";
|
|
2
2
|
|
|
3
|
+
//#region src/core/auth.ts
|
|
3
4
|
/** Returns a timestamp when current authorization information should be refreshed.
|
|
4
|
-
|
|
5
|
+
* Compare the value with Date.now(). */
|
|
5
6
|
function inferAuthRefreshTime(info, maxRefreshSeconds) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return (Math.min(
|
|
10
|
-
// in the middle between issue and expiration time points
|
|
11
|
-
(iat + exp) / 2, iat + maxRefreshSeconds) * 1000);
|
|
7
|
+
if (info.jwtToken === void 0) return void 0;
|
|
8
|
+
const { exp, iat } = parsePlJwt(info.jwtToken);
|
|
9
|
+
return Math.min((iat + exp) / 2, iat + maxRefreshSeconds) * 1e3;
|
|
12
10
|
}
|
|
13
11
|
function expirationFromAuthInformation(authInfo) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const parsed = parsePlJwt(authInfo.jwtToken);
|
|
17
|
-
return parsed.exp * 1000;
|
|
12
|
+
if (authInfo.jwtToken === void 0) return void 0;
|
|
13
|
+
return parsePlJwt(authInfo.jwtToken).exp * 1e3;
|
|
18
14
|
}
|
|
19
15
|
|
|
16
|
+
//#endregion
|
|
20
17
|
export { expirationFromAuthInformation, inferAuthRefreshTime };
|
|
21
|
-
//# sourceMappingURL=auth.js.map
|
|
18
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/core/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"auth.js","names":[],"sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"mappings":";;;;;AAKA,SAAgB,qBACd,MACA,mBACoB;AACpB,KAAI,KAAK,aAAa,OAAW,QAAO;CAExC,MAAM,EAAE,KAAK,QAAQ,WAAW,KAAK,SAAS;AAE9C,QACE,KAAK,KAEF,MAAM,OAAO,GACd,MAAM,kBACP,GAAG;;AAIR,SAAgB,8BAA8B,UAA+C;AAC3F,KAAI,SAAS,aAAa,OAAW,QAAO;AAE5C,QADe,WAAW,SAAS,SAAS,CAC9B,MAAM"}
|
package/dist/core/cache.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BasicResourceData, ResourceData } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/core/cache.d.ts
|
|
4
|
+
type ResourceDataCacheRecord = {
|
|
5
|
+
/** There is a slight chance of inconsistent data retrieval from tx if we allow later transactions to leak resource data into earlier transactions.
|
|
6
|
+
* This field allows to prevent this. */
|
|
7
|
+
cacheTxOpenTimestamp: number;
|
|
8
|
+
data: ResourceData | undefined;
|
|
9
|
+
readonly basicData: BasicResourceData;
|
|
8
10
|
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ResourceDataCacheRecord };
|
|
9
13
|
//# sourceMappingURL=cache.d.ts.map
|