@milaboratories/pl-client 2.11.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/driver.d.ts +2 -2
- package/dist/core/driver.d.ts.map +1 -1
- package/dist/core/grpc.d.ts +16 -0
- package/dist/core/grpc.d.ts.map +1 -0
- package/dist/core/ll_client.d.ts +11 -3
- package/dist/core/ll_client.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -88
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/client.test.ts +2 -2
- package/src/core/client.ts +3 -3
- package/src/core/driver.ts +2 -2
- package/src/core/grpc.ts +17 -0
- package/src/core/ll_client.ts +65 -9
- package/src/core/unauth_client.ts +3 -3
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -28,16 +28,16 @@ function In(l) {
|
|
|
28
28
|
if (!C(l)) throw new Error("null resource id");
|
|
29
29
|
return l;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function sf(l) {
|
|
32
32
|
return l !== 0n;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function of(l, e) {
|
|
35
35
|
return { name: l, version: e };
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function af(l) {
|
|
38
38
|
return `${l.name}:${l.version}`;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function lf(l, e) {
|
|
41
41
|
return l.name === e.name && l.version === e.version;
|
|
42
42
|
}
|
|
43
43
|
function cr(l) {
|
|
@@ -66,7 +66,7 @@ function cr(l) {
|
|
|
66
66
|
final: u
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
const
|
|
69
|
+
const cf = (l) => Buffer.from(JSON.stringify(l)), uf = (l) => yi(R(l.data));
|
|
70
70
|
function Hn(l, e) {
|
|
71
71
|
return R(l.fields.find((t) => t.name === e));
|
|
72
72
|
}
|
|
@@ -88,7 +88,7 @@ function hr(l, e) {
|
|
|
88
88
|
function Li(l) {
|
|
89
89
|
return Number(l >> Pi & fr);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function ff(l, e) {
|
|
92
92
|
if (x(l) && Li(l) !== e)
|
|
93
93
|
throw Error(
|
|
94
94
|
"local id from another transaction, globalize id before leaking it from the transaction"
|
|
@@ -98,19 +98,19 @@ function we(l) {
|
|
|
98
98
|
return B(l) ? "XX:0x0" : x(l) ? (Yn(l) ? "R" : "N") + "L:0x" + (dr & l).toString(16) + "[0x" + Li(l).toString(16) + "]" : (Yn(l) ? "R" : "N") + "G:0x" + (ur & l).toString(16);
|
|
99
99
|
}
|
|
100
100
|
const pr = /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\[0x(?<txid>[0-9a-fA-F]+)])?$/;
|
|
101
|
-
function
|
|
101
|
+
function df(l) {
|
|
102
102
|
const e = l.match(pr);
|
|
103
103
|
if (e === null) return;
|
|
104
104
|
const { xx: t, rn: i, lg: n, rid: r, txid: c } = e.groups;
|
|
105
105
|
return t ? S : n === "L" ? _i(i === "R", Number.parseInt(r, 16), Number.parseInt(c, 16)) : hr(i === "R", BigInt("0x" + r));
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function hf(l) {
|
|
108
108
|
if (x(l))
|
|
109
109
|
throw new Error(`Local resource id: ${we(l)}`);
|
|
110
110
|
if (B(l)) throw new Error("Null resource id.");
|
|
111
111
|
return l;
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function pf(l) {
|
|
114
114
|
return JSON.stringify(
|
|
115
115
|
l,
|
|
116
116
|
(e, t) => typeof t == "bigint" ? we(t) : t
|
|
@@ -12452,13 +12452,13 @@ const ou = {
|
|
|
12452
12452
|
name: "json/resourceError",
|
|
12453
12453
|
version: "1"
|
|
12454
12454
|
};
|
|
12455
|
-
function
|
|
12455
|
+
function yf(l) {
|
|
12456
12456
|
return l.hasOwnProperty("resourceId") && l.hasOwnProperty("fieldName");
|
|
12457
12457
|
}
|
|
12458
12458
|
function au(l) {
|
|
12459
12459
|
return typeof l == "bigint" || l.hasOwnProperty("globalId") && l.hasOwnProperty("localId");
|
|
12460
12460
|
}
|
|
12461
|
-
function
|
|
12461
|
+
function wf(l) {
|
|
12462
12462
|
return typeof l == "bigint" && !x(l) && !B(l);
|
|
12463
12463
|
}
|
|
12464
12464
|
function Ci(l) {
|
|
@@ -12470,7 +12470,7 @@ function M(l) {
|
|
|
12470
12470
|
function A(l) {
|
|
12471
12471
|
return Ci(l) ? { resourceId: l.resourceId.localId, fieldName: l.fieldName } : l;
|
|
12472
12472
|
}
|
|
12473
|
-
async function
|
|
12473
|
+
async function mf(l) {
|
|
12474
12474
|
return Ci(l) ? { resourceId: await l.resourceId.globalId, fieldName: l.fieldName } : l;
|
|
12475
12475
|
}
|
|
12476
12476
|
function T(l) {
|
|
@@ -13020,7 +13020,7 @@ function Tu(l, e) {
|
|
|
13020
13020
|
function Ru(l, e) {
|
|
13021
13021
|
return l.getFutureFieldValue(e, me, "Input");
|
|
13022
13022
|
}
|
|
13023
|
-
const
|
|
13023
|
+
const gf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
13024
13024
|
__proto__: null,
|
|
13025
13025
|
ClientRoot: Nn,
|
|
13026
13026
|
EphHolder: Ji,
|
|
@@ -13110,7 +13110,7 @@ function ye(l, e = {}) {
|
|
|
13110
13110
|
...e
|
|
13111
13111
|
};
|
|
13112
13112
|
}
|
|
13113
|
-
const
|
|
13113
|
+
const kf = {};
|
|
13114
13114
|
class Iu {
|
|
13115
13115
|
constructor(e) {
|
|
13116
13116
|
y(this, "typeName", gn.typeName);
|
|
@@ -13504,9 +13504,21 @@ function Q(l, e) {
|
|
|
13504
13504
|
i + e
|
|
13505
13505
|
) * 1e3;
|
|
13506
13506
|
}
|
|
13507
|
-
function
|
|
13507
|
+
function bf(l) {
|
|
13508
13508
|
return l.jwtToken === void 0 ? void 0 : vn(l.jwtToken).exp * 1e3;
|
|
13509
13509
|
}
|
|
13510
|
+
class Lu {
|
|
13511
|
+
constructor(e, t) {
|
|
13512
|
+
y(this, "client");
|
|
13513
|
+
this.grpcTransport = e, this.clientConstructor = t;
|
|
13514
|
+
}
|
|
13515
|
+
reset() {
|
|
13516
|
+
this.client = void 0;
|
|
13517
|
+
}
|
|
13518
|
+
get() {
|
|
13519
|
+
return this.client === void 0 && (this.client = this.clientConstructor(this.grpcTransport())), this.client;
|
|
13520
|
+
}
|
|
13521
|
+
}
|
|
13510
13522
|
class On {
|
|
13511
13523
|
constructor(e, t = {}) {
|
|
13512
13524
|
y(this, "conf");
|
|
@@ -13524,15 +13536,17 @@ class On {
|
|
|
13524
13536
|
y(this, "statusListener");
|
|
13525
13537
|
y(this, "grpcInterceptors");
|
|
13526
13538
|
y(this, "_grpcTransport");
|
|
13527
|
-
y(this, "
|
|
13539
|
+
y(this, "providers", []);
|
|
13540
|
+
y(this, "grpcPl");
|
|
13528
13541
|
y(this, "httpDispatcher");
|
|
13542
|
+
y(this, "providerCleanupCounter", 0);
|
|
13529
13543
|
y(this, "authRefreshInProgress", !1);
|
|
13530
13544
|
this.ops = t, this.conf = typeof e == "string" ? ye(e) : e, this.grpcInterceptors = [];
|
|
13531
13545
|
const { auth: i, statusListener: n, shouldUseGzip: r } = t;
|
|
13532
13546
|
i !== void 0 && (this.refreshTimestamp = Q(
|
|
13533
13547
|
i.authInformation,
|
|
13534
13548
|
this.conf.authMaxRefreshSeconds
|
|
13535
|
-
), this.grpcInterceptors.push(this.createAuthInterceptor()), this.authInformation = i.authInformation, this.onAuthUpdate = i.onUpdate, this.onAuthRefreshProblem = i.onUpdateError, this.onAuthError = i.onAuthError), this.grpcInterceptors.push(this.createErrorInterceptor()), this.initGrpc(r ?? !1), this.httpDispatcher = sr(this.conf.httpProxy), n !== void 0 && (this.statusListener = n, n(this._status));
|
|
13549
|
+
), this.grpcInterceptors.push(this.createAuthInterceptor()), this.authInformation = i.authInformation, this.onAuthUpdate = i.onUpdate, this.onAuthRefreshProblem = i.onUpdateError, this.onAuthError = i.onAuthError), this.grpcInterceptors.push(this.createErrorInterceptor()), this.initGrpc(r ?? !1), this.httpDispatcher = sr(this.conf.httpProxy), n !== void 0 && (this.statusListener = n, n(this._status)), this.grpcPl = this.createGrpcClientProvider((c) => new Iu(c));
|
|
13536
13550
|
}
|
|
13537
13551
|
/**
|
|
13538
13552
|
* Initializes (or reinitializes) _grpcTransport and _grpcPl
|
|
@@ -13553,14 +13567,30 @@ class On {
|
|
|
13553
13567
|
};
|
|
13554
13568
|
this.conf.grpcProxy ? process.env.grpc_proxy = this.conf.grpcProxy : delete process.env.grpc_proxy;
|
|
13555
13569
|
const n = this._grpcTransport;
|
|
13556
|
-
this._grpcTransport = new ir(i)
|
|
13570
|
+
this._grpcTransport = new ir(i);
|
|
13571
|
+
for (let r = 0; r < this.providers.length; r++) {
|
|
13572
|
+
const c = this.providers[r].deref();
|
|
13573
|
+
c === void 0 ? (this.providers.splice(r, 1), r--) : c.reset();
|
|
13574
|
+
}
|
|
13575
|
+
n !== void 0 && n.close();
|
|
13576
|
+
}
|
|
13577
|
+
/**
|
|
13578
|
+
* Creates a provider for a grpc client. Returned provider will create fresh client whenever the underlying transport is reset.
|
|
13579
|
+
*
|
|
13580
|
+
* @param clientConstructor - a factory function that creates a grpc client
|
|
13581
|
+
*/
|
|
13582
|
+
createGrpcClientProvider(e) {
|
|
13583
|
+
if (this.providerCleanupCounter++, this.providerCleanupCounter >= 16) {
|
|
13584
|
+
for (let i = 0; i < this.providers.length; i++)
|
|
13585
|
+
this.providers[i].deref() === void 0 && (this.providers.splice(i, 1), i--);
|
|
13586
|
+
this.providerCleanupCounter = 0;
|
|
13587
|
+
}
|
|
13588
|
+
const t = new Lu(() => this._grpcTransport, e);
|
|
13589
|
+
return this.providers.push(new WeakRef(t)), t;
|
|
13557
13590
|
}
|
|
13558
13591
|
get grpcTransport() {
|
|
13559
13592
|
return this._grpcTransport;
|
|
13560
13593
|
}
|
|
13561
|
-
get grpcPl() {
|
|
13562
|
-
return this._grpcPl;
|
|
13563
|
-
}
|
|
13564
13594
|
/** Returns true if client is authenticated. Even with anonymous auth information
|
|
13565
13595
|
* connection is considered authenticated. Unauthenticated clients are used for
|
|
13566
13596
|
* login and similar tasks, see {@link UnauthenticatedPlClient}. */
|
|
@@ -13584,7 +13614,7 @@ class On {
|
|
|
13584
13614
|
refreshAuthInformationIfNeeded() {
|
|
13585
13615
|
this.refreshTimestamp === void 0 || Date.now() < this.refreshTimestamp || this.authRefreshInProgress || this._status === "Unauthenticated" || (this.authRefreshInProgress = !0, (async () => {
|
|
13586
13616
|
try {
|
|
13587
|
-
const e = await this.grpcPl.getJWTToken({
|
|
13617
|
+
const e = await this.grpcPl.get().getJWTToken({
|
|
13588
13618
|
expiration: {
|
|
13589
13619
|
seconds: BigInt(this.conf.authTTLSeconds),
|
|
13590
13620
|
nanos: 0
|
|
@@ -13625,7 +13655,7 @@ class On {
|
|
|
13625
13655
|
createTx(e, t = {}) {
|
|
13626
13656
|
return new _u((i) => {
|
|
13627
13657
|
let n = i;
|
|
13628
|
-
return t.abortSignal && (n = AbortSignal.any([n, t.abortSignal])), this.grpcPl.tx({
|
|
13658
|
+
return t.abortSignal && (n = AbortSignal.any([n, t.abortSignal])), this.grpcPl.get().tx({
|
|
13629
13659
|
abort: n,
|
|
13630
13660
|
timeout: t.timeout ?? (e ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout)
|
|
13631
13661
|
});
|
|
@@ -13639,14 +13669,14 @@ class On {
|
|
|
13639
13669
|
function z(l) {
|
|
13640
13670
|
return l.resourceReady || C(l.originalResourceId) || C(l.error);
|
|
13641
13671
|
}
|
|
13642
|
-
function
|
|
13672
|
+
function Au(l) {
|
|
13643
13673
|
if (!z(l) || !l.outputsLocked) return !1;
|
|
13644
13674
|
if (l.fields === void 0) return !0;
|
|
13645
13675
|
for (const e of l.fields)
|
|
13646
13676
|
if (B(e.error) && (B(e.value) || !e.valueIsFinal)) return !1;
|
|
13647
13677
|
return !0;
|
|
13648
13678
|
}
|
|
13649
|
-
const ui = /* @__PURE__ */ new Set(),
|
|
13679
|
+
const ui = /* @__PURE__ */ new Set(), Bu = (l) => {
|
|
13650
13680
|
switch (l.type.name) {
|
|
13651
13681
|
case "StreamManager": {
|
|
13652
13682
|
if (!z(l)) return !1;
|
|
@@ -13694,7 +13724,7 @@ const ui = /* @__PURE__ */ new Set(), Au = (l) => {
|
|
|
13694
13724
|
default:
|
|
13695
13725
|
if (l.type.name.startsWith("Blob/")) return !0;
|
|
13696
13726
|
if (l.type.name.startsWith("BlobUpload/") || l.type.name.startsWith("BlobIndex/"))
|
|
13697
|
-
return
|
|
13727
|
+
return Au(l);
|
|
13698
13728
|
if (l.type.name.startsWith("PColumnData/"))
|
|
13699
13729
|
return z(l);
|
|
13700
13730
|
if (l.type.name.startsWith("StreamWorkdir/"))
|
|
@@ -13704,7 +13734,7 @@ const ui = /* @__PURE__ */ new Set(), Au = (l) => {
|
|
|
13704
13734
|
return !1;
|
|
13705
13735
|
}, bn = {
|
|
13706
13736
|
sync: !1
|
|
13707
|
-
},
|
|
13737
|
+
}, $u = "AnonymousRoot";
|
|
13708
13738
|
function fi(l) {
|
|
13709
13739
|
return `alternative_root_${l}`;
|
|
13710
13740
|
}
|
|
@@ -13735,7 +13765,7 @@ class ge {
|
|
|
13735
13765
|
y(this, "resourceDataCache");
|
|
13736
13766
|
this.buildLLPlClient = (r) => new On(e, { auth: t, ...i, shouldUseGzip: r }), this._ll = this.buildLLPlClient(!1);
|
|
13737
13767
|
const n = this._ll.conf;
|
|
13738
|
-
switch (this.txDelay = n.txDelay, this.forceSync = n.forceSync, this.finalPredicate = i.finalPredicate ??
|
|
13768
|
+
switch (this.txDelay = n.txDelay, this.forceSync = n.forceSync, this.finalPredicate = i.finalPredicate ?? Bu, this.resourceDataCache = new or({
|
|
13739
13769
|
maxSize: n.maxCacheBytes,
|
|
13740
13770
|
sizeCalculation: (r) => {
|
|
13741
13771
|
var c;
|
|
@@ -13784,7 +13814,7 @@ class ge {
|
|
|
13784
13814
|
};
|
|
13785
13815
|
}
|
|
13786
13816
|
async ping() {
|
|
13787
|
-
return (await this._ll.grpcPl.ping({})).response;
|
|
13817
|
+
return (await this._ll.grpcPl.get().ping({})).response;
|
|
13788
13818
|
}
|
|
13789
13819
|
get conf() {
|
|
13790
13820
|
return this._ll.conf;
|
|
@@ -13810,7 +13840,7 @@ class ge {
|
|
|
13810
13840
|
/** Currently implements custom logic to emulate future behaviour with single root. */
|
|
13811
13841
|
async init() {
|
|
13812
13842
|
if (this.initialized) throw new Error("Already initialized");
|
|
13813
|
-
const e = this._ll.authUser, t = e === null ?
|
|
13843
|
+
const e = this._ll.authUser, t = e === null ? $u : bi("sha256").update(e).digest("hex");
|
|
13814
13844
|
this._serverInfo = await this.ping(), this._serverInfo.compression === Un.GZIP && (await this._ll.close(), this._ll = this.buildLLPlClient(!0)), this._clientRoot = await this._withTx("initialization", !0, S, async (i) => {
|
|
13815
13845
|
let n;
|
|
13816
13846
|
if (await i.checkResourceNameExists(t) ? n = await i.getResourceByName(t) : (n = i.createRoot(Nn), i.setResourceName(t, n)), this.conf.alternativeRoot === void 0)
|
|
@@ -13859,7 +13889,7 @@ class ge {
|
|
|
13859
13889
|
await o.complete(), await o.await(), Kn = await o.getGlobalTxId();
|
|
13860
13890
|
}
|
|
13861
13891
|
if (s)
|
|
13862
|
-
return ((r == null ? void 0 : r.sync) === void 0 ? this.forceSync : r != null && r.sync) && await this._ll.grpcPl.txSync({ txId: Kn }), t && this.txDelay > 0 && await Rn.setTimeout(this.txDelay, void 0, { signal: r == null ? void 0 : r.abortSignal }), u;
|
|
13892
|
+
return ((r == null ? void 0 : r.sync) === void 0 ? this.forceSync : r != null && r.sync) && await this._ll.grpcPl.get().txSync({ txId: Kn }), t && this.txDelay > 0 && await Rn.setTimeout(this.txDelay, void 0, { signal: r == null ? void 0 : r.abortSignal }), u;
|
|
13863
13893
|
await Rn.setTimeout(c.nextDelay, void 0, { signal: r == null ? void 0 : r.abortSignal }), c = ki(c);
|
|
13864
13894
|
}
|
|
13865
13895
|
}
|
|
@@ -13875,7 +13905,7 @@ class ge {
|
|
|
13875
13905
|
getDriver(e) {
|
|
13876
13906
|
const t = this.drivers.get(e.name);
|
|
13877
13907
|
if (t !== void 0) return t;
|
|
13878
|
-
const i = e.init(this, this.
|
|
13908
|
+
const i = e.init(this, this._ll, this.httpDispatcher);
|
|
13879
13909
|
return this.drivers.set(e.name, i), i;
|
|
13880
13910
|
}
|
|
13881
13911
|
/** Closes underlying transport */
|
|
@@ -13887,7 +13917,7 @@ class ge {
|
|
|
13887
13917
|
return await n.init(), n;
|
|
13888
13918
|
}
|
|
13889
13919
|
}
|
|
13890
|
-
function
|
|
13920
|
+
function Tf(l, e) {
|
|
13891
13921
|
return e = e ?? {}, e.meta = e.meta ?? {}, e.meta.resourceType = `${l.name}:${l.version}`, e;
|
|
13892
13922
|
}
|
|
13893
13923
|
class zi {
|
|
@@ -13896,17 +13926,17 @@ class zi {
|
|
|
13896
13926
|
this.ll = new On(e);
|
|
13897
13927
|
}
|
|
13898
13928
|
async ping() {
|
|
13899
|
-
return (await this.ll.grpcPl.ping({})).response;
|
|
13929
|
+
return (await this.ll.grpcPl.get().ping({})).response;
|
|
13900
13930
|
}
|
|
13901
13931
|
async authMethods() {
|
|
13902
|
-
return (await this.ll.grpcPl.authMethods({})).response;
|
|
13932
|
+
return (await this.ll.grpcPl.get().authMethods({})).response;
|
|
13903
13933
|
}
|
|
13904
13934
|
async requireAuth() {
|
|
13905
13935
|
return (await this.authMethods()).methods.length > 0;
|
|
13906
13936
|
}
|
|
13907
13937
|
async login(e, t) {
|
|
13908
13938
|
try {
|
|
13909
|
-
const i = await this.ll.grpcPl.getJWTToken(
|
|
13939
|
+
const i = await this.ll.grpcPl.get().getJWTToken(
|
|
13910
13940
|
{ expiration: { seconds: BigInt(this.ll.conf.authTTLSeconds), nanos: 0 } },
|
|
13911
13941
|
{
|
|
13912
13942
|
meta: {
|
|
@@ -13921,12 +13951,12 @@ class zi {
|
|
|
13921
13951
|
}
|
|
13922
13952
|
}
|
|
13923
13953
|
}
|
|
13924
|
-
const
|
|
13925
|
-
$u,
|
|
13926
|
-
Fu,
|
|
13954
|
+
const Uu = "pl.json", Fu = An.join(Ri.homedir(), ".pl.json"), Eu = "pl.yaml", xu = An.join(Ri.homedir(), ".pl.yaml"), Wu = [
|
|
13927
13955
|
Uu,
|
|
13928
|
-
Eu
|
|
13929
|
-
|
|
13956
|
+
Eu,
|
|
13957
|
+
Fu,
|
|
13958
|
+
xu
|
|
13959
|
+
], Z = ".pl_auth.json", Su = [
|
|
13930
13960
|
"grpcProxy",
|
|
13931
13961
|
"httpProxy",
|
|
13932
13962
|
"user",
|
|
@@ -13938,14 +13968,14 @@ const $u = "pl.json", Uu = An.join(Ri.homedir(), ".pl.json"), Fu = "pl.yaml", Eu
|
|
|
13938
13968
|
"authTTLSeconds",
|
|
13939
13969
|
"authMaxRefreshSeconds"
|
|
13940
13970
|
];
|
|
13941
|
-
function
|
|
13942
|
-
for (const l of
|
|
13971
|
+
function Cu() {
|
|
13972
|
+
for (const l of Wu)
|
|
13943
13973
|
if (E.existsSync(l)) {
|
|
13944
13974
|
const e = E.readFileSync(l, { encoding: "utf-8" });
|
|
13945
13975
|
return l.endsWith("json") ? [JSON.parse(e), l] : [lr.parse(e), l];
|
|
13946
13976
|
}
|
|
13947
13977
|
}
|
|
13948
|
-
function
|
|
13978
|
+
function Du(l, e) {
|
|
13949
13979
|
return (t) => {
|
|
13950
13980
|
E.writeFileSync(
|
|
13951
13981
|
Z,
|
|
@@ -13963,16 +13993,16 @@ function Cu(l, e) {
|
|
|
13963
13993
|
const di = () => {
|
|
13964
13994
|
E.rmSync(Z);
|
|
13965
13995
|
};
|
|
13966
|
-
async function
|
|
13996
|
+
async function Rf() {
|
|
13967
13997
|
let l;
|
|
13968
13998
|
if (process.env.PL_ADDRESS !== void 0)
|
|
13969
13999
|
l = ye(process.env.PL_ADDRESS);
|
|
13970
14000
|
else {
|
|
13971
|
-
const i =
|
|
14001
|
+
const i = Cu();
|
|
13972
14002
|
if (i !== void 0) {
|
|
13973
14003
|
const [n, r] = i, c = R(n.address, `no pl address in file: ${r}`);
|
|
13974
14004
|
l = ye(c);
|
|
13975
|
-
for (const a of
|
|
14005
|
+
for (const a of Su)
|
|
13976
14006
|
n[a] !== void 0 && (l[a] = n[a]);
|
|
13977
14007
|
}
|
|
13978
14008
|
}
|
|
@@ -14007,12 +14037,12 @@ async function Tf() {
|
|
|
14007
14037
|
}
|
|
14008
14038
|
return await ge.init(l, {
|
|
14009
14039
|
authInformation: t,
|
|
14010
|
-
onUpdate: (i) =>
|
|
14040
|
+
onUpdate: (i) => Du(e, l.authMaxRefreshSeconds),
|
|
14011
14041
|
onUpdateError: di,
|
|
14012
14042
|
onAuthError: di
|
|
14013
14043
|
});
|
|
14014
14044
|
}
|
|
14015
|
-
async function
|
|
14045
|
+
async function If(l, e) {
|
|
14016
14046
|
const t = {
|
|
14017
14047
|
valueId: e.value,
|
|
14018
14048
|
errorId: e.error,
|
|
@@ -14034,11 +14064,11 @@ class H extends Error {
|
|
|
14034
14064
|
y(this, "name", "ContinuePolling");
|
|
14035
14065
|
}
|
|
14036
14066
|
}
|
|
14037
|
-
const
|
|
14067
|
+
const vu = {
|
|
14038
14068
|
failOnError: !0,
|
|
14039
14069
|
onlyFinal: !1
|
|
14040
14070
|
};
|
|
14041
|
-
class
|
|
14071
|
+
class Ou {
|
|
14042
14072
|
constructor(e, t, i) {
|
|
14043
14073
|
this.tx = e, this.data = t, this.path = i;
|
|
14044
14074
|
}
|
|
@@ -14062,7 +14092,7 @@ class vu {
|
|
|
14062
14092
|
) : new H();
|
|
14063
14093
|
}
|
|
14064
14094
|
async get(e, t = {}) {
|
|
14065
|
-
const { expectedType: i, failOnError: n } = { ...
|
|
14095
|
+
const { expectedType: i, failOnError: n } = { ...vu, ...t }, r = [...this.path, e], c = this.getFieldData(e, i);
|
|
14066
14096
|
if (C(c.error) && (n || B(c.value)) && await this.tx.throwError(c.error, r), B(c.value)) throw new H();
|
|
14067
14097
|
return await this.tx.get(c.value, n, r);
|
|
14068
14098
|
}
|
|
@@ -14089,12 +14119,12 @@ class vu {
|
|
|
14089
14119
|
return JSON.parse(await this.getKValue(e));
|
|
14090
14120
|
}
|
|
14091
14121
|
}
|
|
14092
|
-
class
|
|
14122
|
+
class qu {
|
|
14093
14123
|
constructor(e) {
|
|
14094
14124
|
this.tx = e;
|
|
14095
14125
|
}
|
|
14096
14126
|
async get(e, t = !0, i = []) {
|
|
14097
|
-
const n = await this.tx.getResourceData(e, !0), r = new
|
|
14127
|
+
const n = await this.tx.getResourceData(e, !0), r = new Ou(this, n, [...i, we(e)]);
|
|
14098
14128
|
return t && await r.requireNoError(), r;
|
|
14099
14129
|
}
|
|
14100
14130
|
async throwError(e, t = []) {
|
|
@@ -14102,18 +14132,18 @@ class Ou {
|
|
|
14102
14132
|
throw new Error(`${t.join(" -> ")} = ${n}`);
|
|
14103
14133
|
}
|
|
14104
14134
|
}
|
|
14105
|
-
const
|
|
14135
|
+
const Ku = {
|
|
14106
14136
|
type: "linearBackoff",
|
|
14107
14137
|
jitter: 0,
|
|
14108
14138
|
maxAttempts: 100,
|
|
14109
14139
|
backoffStep: 10,
|
|
14110
14140
|
initialDelay: 10
|
|
14111
14141
|
};
|
|
14112
|
-
async function
|
|
14142
|
+
async function Pf(l, e, t = Ku, i = "polling") {
|
|
14113
14143
|
let n = gi(t);
|
|
14114
14144
|
for (; ; ) {
|
|
14115
14145
|
try {
|
|
14116
|
-
return await l.withReadTx(i, async (r) => await e(new
|
|
14146
|
+
return await l.withReadTx(i, async (r) => await e(new qu(r)));
|
|
14117
14147
|
} catch (r) {
|
|
14118
14148
|
if (!(r instanceof H)) throw r;
|
|
14119
14149
|
}
|
|
@@ -14183,7 +14213,7 @@ async function qn() {
|
|
|
14183
14213
|
}
|
|
14184
14214
|
};
|
|
14185
14215
|
}
|
|
14186
|
-
async function
|
|
14216
|
+
async function ju(l = {}) {
|
|
14187
14217
|
const { conf: e, auth: t } = await qn();
|
|
14188
14218
|
return new On({ ...e, ...l }, { auth: t });
|
|
14189
14219
|
}
|
|
@@ -14193,7 +14223,7 @@ async function _n(l) {
|
|
|
14193
14223
|
throw new Error("test pl address configured with alternative root");
|
|
14194
14224
|
return await ge.init({ ...e, alternativeRoot: l }, t);
|
|
14195
14225
|
}
|
|
14196
|
-
async function
|
|
14226
|
+
async function Vu(l) {
|
|
14197
14227
|
const e = `test_${Date.now()}_${Ti()}`;
|
|
14198
14228
|
let t = S;
|
|
14199
14229
|
try {
|
|
@@ -14205,16 +14235,16 @@ async function ju(l) {
|
|
|
14205
14235
|
throw console.log(`ALTERNATIVE ROOT: ${e} (${we(t)})`), new Error(i.message, { cause: i });
|
|
14206
14236
|
}
|
|
14207
14237
|
}
|
|
14208
|
-
const
|
|
14238
|
+
const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
14209
14239
|
__proto__: null,
|
|
14210
14240
|
getTestClient: _n,
|
|
14211
14241
|
getTestClientConf: qn,
|
|
14212
14242
|
getTestConfig: Hi,
|
|
14213
|
-
getTestLLClient:
|
|
14214
|
-
withTempRoot:
|
|
14243
|
+
getTestLLClient: ju,
|
|
14244
|
+
withTempRoot: Vu
|
|
14215
14245
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
14216
14246
|
export {
|
|
14217
|
-
|
|
14247
|
+
kf as AnonymousAuthInformation,
|
|
14218
14248
|
H as ContinuePolling,
|
|
14219
14249
|
ni as DEFAULT_AUTH_MAX_REFRESH,
|
|
14220
14250
|
ii as DEFAULT_MAX_CACHE_BYTES,
|
|
@@ -14228,69 +14258,69 @@ export {
|
|
|
14228
14258
|
Qn as DEFAULT_RO_TX_TIMEOUT,
|
|
14229
14259
|
ei as DEFAULT_RW_TX_TIMEOUT,
|
|
14230
14260
|
ti as DEFAULT_TOKEN_TTL_SECONDS,
|
|
14231
|
-
|
|
14232
|
-
|
|
14261
|
+
Bu as DefaultFinalResourceDataPredicate,
|
|
14262
|
+
Ku as DefaultPollingRetryOptions,
|
|
14233
14263
|
Ei as DisconnectedError,
|
|
14234
14264
|
Ni as MaxLocalId,
|
|
14235
14265
|
$n as MaxTxId,
|
|
14236
14266
|
S as NullResourceId,
|
|
14237
|
-
|
|
14267
|
+
gf as Pl,
|
|
14238
14268
|
ge as PlClient,
|
|
14239
14269
|
Ui as PlError,
|
|
14240
14270
|
Fn as PlErrorCodeNotFound,
|
|
14241
14271
|
Pn as PlTransaction,
|
|
14242
|
-
|
|
14243
|
-
|
|
14272
|
+
Ou as PollResourceAccessor,
|
|
14273
|
+
qu as PollTxAccessor,
|
|
14244
14274
|
En as RecoverablePlError,
|
|
14245
|
-
|
|
14275
|
+
Nf as TestHelpers,
|
|
14246
14276
|
Di as TxCommitConflict,
|
|
14247
14277
|
xn as UnauthenticatedError,
|
|
14248
14278
|
zi as UnauthenticatedPlClient,
|
|
14249
14279
|
Xc as UnrecoverablePlError,
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14280
|
+
Tf as addRTypeToMetadata,
|
|
14281
|
+
hf as bigintToResourceId,
|
|
14282
|
+
ff as checkLocalityOfResourceId,
|
|
14253
14283
|
hr as createGlobalResourceId,
|
|
14254
14284
|
_i as createLocalResourceId,
|
|
14255
|
-
|
|
14285
|
+
Rf as defaultPlClient,
|
|
14256
14286
|
In as ensureResourceIdNotNull,
|
|
14257
|
-
|
|
14287
|
+
bf as expirationFromAuthInformation,
|
|
14258
14288
|
cr as extractBasicResourceData,
|
|
14259
14289
|
Li as extractTxId,
|
|
14260
14290
|
Wn as field,
|
|
14261
14291
|
Hn as getField,
|
|
14262
14292
|
Q as inferAuthRefreshTime,
|
|
14263
|
-
|
|
14293
|
+
sf as isAnyResourceId,
|
|
14264
14294
|
Ai as isConnectionProblem,
|
|
14265
|
-
|
|
14295
|
+
yf as isField,
|
|
14266
14296
|
Ci as isFieldRef,
|
|
14267
14297
|
x as isLocalResourceId,
|
|
14268
14298
|
Fi as isNotFoundError,
|
|
14269
14299
|
C as isNotNullResourceId,
|
|
14270
14300
|
B as isNullResourceId,
|
|
14271
14301
|
au as isResource,
|
|
14272
|
-
|
|
14302
|
+
wf as isResourceId,
|
|
14273
14303
|
M as isResourceRef,
|
|
14274
14304
|
Yn as isRootResourceId,
|
|
14275
14305
|
$i as isTimeoutOrCancelError,
|
|
14276
14306
|
Bi as isUnauthenticated,
|
|
14277
|
-
|
|
14307
|
+
cf as jsonToData,
|
|
14278
14308
|
ye as plAddressToConfig,
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14309
|
+
Pf as poll,
|
|
14310
|
+
uf as resDataToJson,
|
|
14311
|
+
df as resourceIdFromString,
|
|
14282
14312
|
we as resourceIdToString,
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14313
|
+
of as resourceType,
|
|
14314
|
+
af as resourceTypeToString,
|
|
14315
|
+
lf as resourceTypesEqual,
|
|
14286
14316
|
Qc as rethrowMeaningfulError,
|
|
14287
|
-
|
|
14317
|
+
pf as stringifyWithResourceId,
|
|
14288
14318
|
Zc as throwPlNotFoundError,
|
|
14289
14319
|
A as toFieldId,
|
|
14290
|
-
|
|
14320
|
+
mf as toGlobalFieldId,
|
|
14291
14321
|
lu as toGlobalResourceId,
|
|
14292
14322
|
T as toResourceId,
|
|
14293
|
-
|
|
14294
|
-
|
|
14323
|
+
Cu as tryGetFileConfig,
|
|
14324
|
+
If as valErr
|
|
14295
14325
|
};
|
|
14296
14326
|
//# sourceMappingURL=index.mjs.map
|