@le-space/core 0.1.0 → 0.1.2
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 +4 -0
- package/index.js +12 -0
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -179,6 +179,7 @@ declare function waitForDeploymentResult(itemHash: string, options: {
|
|
|
179
179
|
attempts?: number;
|
|
180
180
|
delayMs?: number;
|
|
181
181
|
sleep?: (ms: number) => Promise<void>;
|
|
182
|
+
onAttempt?: (result: DeploymentInspectionResult, attempt: number, attempts: number) => void;
|
|
182
183
|
}): Promise<DeploymentInspectionResult>;
|
|
183
184
|
|
|
184
185
|
interface JsonFetchLikeResponse {
|
|
@@ -451,6 +452,7 @@ declare function waitForVmRuntime(args: {
|
|
|
451
452
|
attempts?: number;
|
|
452
453
|
delayMs?: number;
|
|
453
454
|
sleep?: (ms: number) => Promise<void>;
|
|
455
|
+
onAttempt?: (runtime: Omit<InstanceRuntimeDetails, 'messageStatus'>, attempt: number, attempts: number) => void;
|
|
454
456
|
}): Promise<Omit<InstanceRuntimeDetails, 'messageStatus'>>;
|
|
455
457
|
|
|
456
458
|
type TcpProbeResult = {
|
|
@@ -480,6 +482,7 @@ declare function waitForSetupEndpoint(args: {
|
|
|
480
482
|
delayMs?: number;
|
|
481
483
|
httpTimeoutMs?: number;
|
|
482
484
|
sleep?: (ms: number) => Promise<void>;
|
|
485
|
+
onAttempt?: (result: HttpProbeResult, attempt: number, attempts: number) => void;
|
|
483
486
|
}): Promise<HttpProbeResult>;
|
|
484
487
|
declare function configureUcGoPeer(args: {
|
|
485
488
|
hostIpv4: string;
|
|
@@ -502,6 +505,7 @@ declare function fetchUcGoPeerMetadata(args: {
|
|
|
502
505
|
delayMs?: number;
|
|
503
506
|
timeoutMs?: number;
|
|
504
507
|
sleep?: (ms: number) => Promise<void>;
|
|
508
|
+
onAttempt?: (payload: unknown, ready: boolean, attempt: number, attempts: number) => void;
|
|
505
509
|
}): Promise<unknown>;
|
|
506
510
|
declare function verifyUcGoPeerReachability(args: {
|
|
507
511
|
hostIpv4?: string | null;
|
package/index.js
CHANGED
|
@@ -654,12 +654,14 @@ async function waitForDeploymentResult(itemHash, options) {
|
|
|
654
654
|
const delayMs = Math.max(0, Number(options.delayMs ?? 2e3));
|
|
655
655
|
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
656
656
|
let lastResult = await inspectDeploymentResult(itemHash, options);
|
|
657
|
+
options.onAttempt?.(lastResult, 1, attempts);
|
|
657
658
|
for (let attempt = 1; attempt < attempts; attempt += 1) {
|
|
658
659
|
if (lastResult.status === "processed" || lastResult.status === "rejected") {
|
|
659
660
|
return lastResult;
|
|
660
661
|
}
|
|
661
662
|
await sleep(delayMs);
|
|
662
663
|
lastResult = await inspectDeploymentResult(itemHash, options);
|
|
664
|
+
options.onAttempt?.(lastResult, attempt + 1, attempts);
|
|
663
665
|
}
|
|
664
666
|
return lastResult;
|
|
665
667
|
}
|
|
@@ -1364,12 +1366,14 @@ async function waitForVmRuntime(args) {
|
|
|
1364
1366
|
const delayMs = Math.max(0, Number(args.delayMs ?? 4e3));
|
|
1365
1367
|
const sleep = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1366
1368
|
let lastRuntime = await fetchVmRuntime(args);
|
|
1369
|
+
args.onAttempt?.(lastRuntime, 1, attempts);
|
|
1367
1370
|
for (let attempt = 0; attempt < attempts - 1; attempt += 1) {
|
|
1368
1371
|
if (lastRuntime.hostIpv4 && Object.keys(lastRuntime.mappedPorts ?? {}).length > 0) {
|
|
1369
1372
|
return lastRuntime;
|
|
1370
1373
|
}
|
|
1371
1374
|
await sleep(delayMs);
|
|
1372
1375
|
lastRuntime = await fetchVmRuntime(args);
|
|
1376
|
+
args.onAttempt?.(lastRuntime, attempt + 2, attempts);
|
|
1373
1377
|
}
|
|
1374
1378
|
if (lastRuntime.diagnostics) {
|
|
1375
1379
|
lastRuntime.diagnostics.timedOut = true;
|
|
@@ -1448,10 +1452,12 @@ async function waitForSetupEndpoint(args) {
|
|
|
1448
1452
|
const sleep = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1449
1453
|
const url = `http://${args.hostIpv4}:${args.setupPort}/health`;
|
|
1450
1454
|
let result = await defaultHttpProbe(args.fetch, url, Number(args.httpTimeoutMs ?? 1e4));
|
|
1455
|
+
args.onAttempt?.(result, 1, attempts);
|
|
1451
1456
|
for (let attempt = 1; attempt < attempts; attempt += 1) {
|
|
1452
1457
|
if (result.ok) return result;
|
|
1453
1458
|
await sleep(delayMs);
|
|
1454
1459
|
result = await defaultHttpProbe(args.fetch, url, Number(args.httpTimeoutMs ?? 1e4));
|
|
1460
|
+
args.onAttempt?.(result, attempt + 1, attempts);
|
|
1455
1461
|
}
|
|
1456
1462
|
return result;
|
|
1457
1463
|
}
|
|
@@ -1502,6 +1508,12 @@ async function fetchUcGoPeerMetadata(args) {
|
|
|
1502
1508
|
});
|
|
1503
1509
|
const payload = await response.json().catch(() => null);
|
|
1504
1510
|
lastPayload = payload;
|
|
1511
|
+
args.onAttempt?.(
|
|
1512
|
+
payload,
|
|
1513
|
+
Boolean(response.ok && payload && typeof payload === "object" && payload.status === "ready"),
|
|
1514
|
+
attempt + 1,
|
|
1515
|
+
attempts
|
|
1516
|
+
);
|
|
1505
1517
|
if (response.ok && payload && typeof payload === "object" && payload.status === "ready") {
|
|
1506
1518
|
return payload;
|
|
1507
1519
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@le-space/shared-types": "0.1.
|
|
19
|
+
"@le-space/shared-types": "0.1.2"
|
|
20
20
|
}
|
|
21
21
|
}
|