@le-space/core 0.3.12 → 0.3.13
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/index.d.ts +23 -1
- package/index.js +35 -10
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -627,7 +627,16 @@ declare function fetchUcGoPeerMetadata(args: {
|
|
|
627
627
|
delayMs?: number;
|
|
628
628
|
timeoutMs?: number;
|
|
629
629
|
sleep?: (ms: number) => Promise<void>;
|
|
630
|
-
onAttempt?: (
|
|
630
|
+
onAttempt?: (result: {
|
|
631
|
+
payload: unknown;
|
|
632
|
+
ready: boolean;
|
|
633
|
+
attempt: number;
|
|
634
|
+
attempts: number;
|
|
635
|
+
requestUrl: string;
|
|
636
|
+
ok: boolean;
|
|
637
|
+
status: number | null;
|
|
638
|
+
error?: string | null;
|
|
639
|
+
}) => void;
|
|
631
640
|
}): Promise<unknown>;
|
|
632
641
|
declare function verifyUcGoPeerReachability(args: {
|
|
633
642
|
hostIpv4?: string | null;
|
|
@@ -784,6 +793,19 @@ declare function fetchRelayMetadataForRuntime(args: {
|
|
|
784
793
|
attempts?: number;
|
|
785
794
|
delayMs?: number;
|
|
786
795
|
timeoutMs?: number;
|
|
796
|
+
onAttempt?: (result: {
|
|
797
|
+
payload: unknown;
|
|
798
|
+
ready: boolean;
|
|
799
|
+
attempt: number;
|
|
800
|
+
attempts: number;
|
|
801
|
+
requestUrl: string;
|
|
802
|
+
ok: boolean;
|
|
803
|
+
status: number | null;
|
|
804
|
+
error?: string | null;
|
|
805
|
+
metadataUrl: string | null;
|
|
806
|
+
hostIpv4: string | null;
|
|
807
|
+
setupPort: number;
|
|
808
|
+
}) => void;
|
|
787
809
|
}): Promise<RelayMetadataShape | null>;
|
|
788
810
|
declare function reconcileOwnerRelayBootstrapRegistrations(args: {
|
|
789
811
|
instanceOwnerAddress: string;
|
package/index.js
CHANGED
|
@@ -1982,8 +1982,8 @@ async function fetchUcGoPeerMetadata(args) {
|
|
|
1982
1982
|
() => controller.abort(),
|
|
1983
1983
|
Number(args.timeoutMs ?? 18e4)
|
|
1984
1984
|
);
|
|
1985
|
+
const requestUrl = args.metadataUrl && args.metadataUrl.trim() ? args.metadataUrl : `http://${args.hostIpv4}:${args.setupPort}/metadata`;
|
|
1985
1986
|
try {
|
|
1986
|
-
const requestUrl = args.metadataUrl && args.metadataUrl.trim() ? args.metadataUrl : `http://${args.hostIpv4}:${args.setupPort}/metadata`;
|
|
1987
1987
|
const response = await args.fetch(
|
|
1988
1988
|
requestUrl,
|
|
1989
1989
|
{
|
|
@@ -1992,15 +1992,20 @@ async function fetchUcGoPeerMetadata(args) {
|
|
|
1992
1992
|
);
|
|
1993
1993
|
const payload = await response.json().catch(() => null);
|
|
1994
1994
|
lastPayload = payload;
|
|
1995
|
-
|
|
1996
|
-
payload
|
|
1997
|
-
Boolean(
|
|
1998
|
-
response.ok && payload && typeof payload === "object" && payload.status === "ready"
|
|
1999
|
-
),
|
|
2000
|
-
attempt + 1,
|
|
2001
|
-
attempts
|
|
1995
|
+
const ready = Boolean(
|
|
1996
|
+
response.ok && payload && typeof payload === "object" && payload.status === "ready"
|
|
2002
1997
|
);
|
|
2003
|
-
|
|
1998
|
+
args.onAttempt?.({
|
|
1999
|
+
payload,
|
|
2000
|
+
ready,
|
|
2001
|
+
attempt: attempt + 1,
|
|
2002
|
+
attempts,
|
|
2003
|
+
requestUrl,
|
|
2004
|
+
ok: response.ok,
|
|
2005
|
+
status: response.status,
|
|
2006
|
+
error: null
|
|
2007
|
+
});
|
|
2008
|
+
if (ready) {
|
|
2004
2009
|
return payload;
|
|
2005
2010
|
}
|
|
2006
2011
|
if (response.status >= 500) {
|
|
@@ -2008,6 +2013,18 @@ async function fetchUcGoPeerMetadata(args) {
|
|
|
2008
2013
|
`Relay metadata request failed: ${response.status} ${typeof payload === "string" ? payload : JSON.stringify(payload ?? {})}`
|
|
2009
2014
|
);
|
|
2010
2015
|
}
|
|
2016
|
+
} catch (error) {
|
|
2017
|
+
args.onAttempt?.({
|
|
2018
|
+
payload: null,
|
|
2019
|
+
ready: false,
|
|
2020
|
+
attempt: attempt + 1,
|
|
2021
|
+
attempts,
|
|
2022
|
+
requestUrl,
|
|
2023
|
+
ok: false,
|
|
2024
|
+
status: null,
|
|
2025
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2026
|
+
});
|
|
2027
|
+
throw error;
|
|
2011
2028
|
} finally {
|
|
2012
2029
|
clearTimeout(timeout);
|
|
2013
2030
|
}
|
|
@@ -2746,7 +2763,15 @@ async function fetchRelayMetadataForRuntime(args) {
|
|
|
2746
2763
|
fetch: args.fetch,
|
|
2747
2764
|
attempts: args.attempts,
|
|
2748
2765
|
delayMs: args.delayMs,
|
|
2749
|
-
timeoutMs: args.timeoutMs
|
|
2766
|
+
timeoutMs: args.timeoutMs,
|
|
2767
|
+
onAttempt: (result) => {
|
|
2768
|
+
args.onAttempt?.({
|
|
2769
|
+
...result,
|
|
2770
|
+
metadataUrl,
|
|
2771
|
+
hostIpv4: args.runtime.hostIpv4 ?? null,
|
|
2772
|
+
setupPort
|
|
2773
|
+
});
|
|
2774
|
+
}
|
|
2750
2775
|
}).catch(() => null);
|
|
2751
2776
|
return extractRelayMetadata(payload);
|
|
2752
2777
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@le-space/aleph-bootstrap": "0.3.
|
|
20
|
-
"@le-space/shared-types": "0.3.
|
|
19
|
+
"@le-space/aleph-bootstrap": "0.3.13",
|
|
20
|
+
"@le-space/shared-types": "0.3.13"
|
|
21
21
|
}
|
|
22
22
|
}
|