ardent-cli 0.0.22 → 0.0.24
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/index.js +91 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,6 +72,32 @@ function getCacheEntry(key) {
|
|
|
72
72
|
const config = loadConfig();
|
|
73
73
|
return config.cache?.[key];
|
|
74
74
|
}
|
|
75
|
+
function formatIdle(lastActivityIso) {
|
|
76
|
+
if (!lastActivityIso) {
|
|
77
|
+
return "unknown";
|
|
78
|
+
}
|
|
79
|
+
const last = new Date(lastActivityIso).getTime();
|
|
80
|
+
if (Number.isNaN(last)) {
|
|
81
|
+
return "unknown";
|
|
82
|
+
}
|
|
83
|
+
const diffMs = Date.now() - last;
|
|
84
|
+
const diffSec = Math.floor(diffMs / 1e3);
|
|
85
|
+
if (diffSec < 60) {
|
|
86
|
+
return "just now";
|
|
87
|
+
}
|
|
88
|
+
const minutes = Math.floor(diffSec / 60);
|
|
89
|
+
if (minutes < 60) {
|
|
90
|
+
return `${minutes}m`;
|
|
91
|
+
}
|
|
92
|
+
const hours = Math.floor(minutes / 60);
|
|
93
|
+
if (hours < 24) {
|
|
94
|
+
const remMinutes = minutes - hours * 60;
|
|
95
|
+
return `${hours}h ${remMinutes}m`;
|
|
96
|
+
}
|
|
97
|
+
const days = Math.floor(hours / 24);
|
|
98
|
+
const remHours = hours - days * 24;
|
|
99
|
+
return `${days}d ${remHours}h`;
|
|
100
|
+
}
|
|
75
101
|
function formatCacheTime(isoString) {
|
|
76
102
|
const date = new Date(isoString);
|
|
77
103
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -404,7 +430,8 @@ async function createAction(name, options) {
|
|
|
404
430
|
service_type: apiBranch.service_type,
|
|
405
431
|
branch_url: apiBranch.branch_url || "",
|
|
406
432
|
status: apiBranch.status,
|
|
407
|
-
created_at: apiBranch.created_at
|
|
433
|
+
created_at: apiBranch.created_at,
|
|
434
|
+
last_branch_activity: apiBranch.last_branch_activity
|
|
408
435
|
};
|
|
409
436
|
const cached = getCacheEntry("branches");
|
|
410
437
|
const cachedBranches = cached?.data || [];
|
|
@@ -431,6 +458,9 @@ ${branch.branch_url}`);
|
|
|
431
458
|
}
|
|
432
459
|
|
|
433
460
|
// src/commands/branch/list.ts
|
|
461
|
+
function formatCreatedDate(createdAtIso) {
|
|
462
|
+
return new Date(createdAtIso).toISOString().slice(0, 10);
|
|
463
|
+
}
|
|
434
464
|
async function listAction() {
|
|
435
465
|
let branches = [];
|
|
436
466
|
let fromCache = false;
|
|
@@ -484,13 +514,16 @@ async function listAction() {
|
|
|
484
514
|
for (const branch of branches) {
|
|
485
515
|
const isCurrent = branch.name === current;
|
|
486
516
|
const icon = branch.status === "active" ? "\u25CF" : "\u25CB";
|
|
517
|
+
const metadataLine = `${branch.service_type} \xB7 created ${formatCreatedDate(branch.created_at)} \xB7 idle ${formatIdle(branch.last_branch_activity)} (${branch.status})`;
|
|
487
518
|
if (isCurrent) {
|
|
488
519
|
console.log(`${green2}* ${icon} ${branch.name}${reset2}`);
|
|
520
|
+
console.log(`${green2} ${metadataLine}${reset2}`);
|
|
489
521
|
if (branch.branch_url) {
|
|
490
522
|
console.log(`${green2} ${branch.branch_url}${reset2}`);
|
|
491
523
|
}
|
|
492
524
|
} else {
|
|
493
525
|
console.log(` ${icon} ${branch.name}`);
|
|
526
|
+
console.log(`${dim2} ${metadataLine}${reset2}`);
|
|
494
527
|
if (branch.branch_url) {
|
|
495
528
|
console.log(`${dim2} ${branch.branch_url}${reset2}`);
|
|
496
529
|
}
|
|
@@ -632,6 +665,35 @@ branchCommand.command("diff [name]", { hidden: true }).description("(removed) Sh
|
|
|
632
665
|
// src/commands/connector/index.ts
|
|
633
666
|
import { Command as Command2 } from "commander";
|
|
634
667
|
|
|
668
|
+
// src/lib/engine_setup_result.ts
|
|
669
|
+
var SUCCESS_ENGINE_STATUSES = /* @__PURE__ */ new Set(["healthy", "degraded"]);
|
|
670
|
+
var RETRYABLE_ENGINE_STATUSES = /* @__PURE__ */ new Set(["configuration_verified"]);
|
|
671
|
+
var FAILED_ENGINE_STATUSES = /* @__PURE__ */ new Set(["configuration_failed", "failed_validation"]);
|
|
672
|
+
function assertEngineSetupCompleted(operation) {
|
|
673
|
+
const result = operation.result;
|
|
674
|
+
if (!result) {
|
|
675
|
+
throw new Error("Engine setup completed without a result payload.");
|
|
676
|
+
}
|
|
677
|
+
const engineStatus = result.branching_engine_status;
|
|
678
|
+
if (typeof engineStatus !== "string" || engineStatus.length === 0) {
|
|
679
|
+
throw new Error("Engine setup completed without branching_engine_status in the result.");
|
|
680
|
+
}
|
|
681
|
+
if (SUCCESS_ENGINE_STATUSES.has(engineStatus)) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
if (RETRYABLE_ENGINE_STATUSES.has(engineStatus)) {
|
|
685
|
+
throw new Error(
|
|
686
|
+
`Engine setup needs retry (status: ${engineStatus}). Run \`ardent connector list\` to inspect connector state, then retry engine setup.`
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
if (FAILED_ENGINE_STATUSES.has(engineStatus)) {
|
|
690
|
+
throw new Error(
|
|
691
|
+
`Engine setup failed (status: ${engineStatus}). Run \`ardent connector list\` to inspect connector state.`
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
throw new Error(`Engine setup completed with unexpected status: ${engineStatus}.`);
|
|
695
|
+
}
|
|
696
|
+
|
|
635
697
|
// src/lib/onboarding.ts
|
|
636
698
|
var BANNER = `
|
|
637
699
|
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
|
|
@@ -749,43 +811,54 @@ var EngineSetupTimeoutError = class extends Error {
|
|
|
749
811
|
}
|
|
750
812
|
};
|
|
751
813
|
async function runEngineSetupWithPolling(connectorId) {
|
|
814
|
+
let dispatch;
|
|
752
815
|
try {
|
|
753
|
-
await api.post(
|
|
754
|
-
|
|
816
|
+
dispatch = await api.post(
|
|
817
|
+
`/v1/connectors/${connectorId}/engine-setup`,
|
|
818
|
+
{}
|
|
819
|
+
);
|
|
755
820
|
} catch (err) {
|
|
756
|
-
if (
|
|
757
|
-
throw
|
|
821
|
+
if (isGatewayTimeoutError(err)) {
|
|
822
|
+
throw new Error(
|
|
823
|
+
"Backend dispatch timed out. The engine-setup endpoint is now async and should respond in under a second; this may indicate a backend incident. Try again, or check `ardent connector list` to see if an operation was created anyway."
|
|
824
|
+
);
|
|
758
825
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
826
|
+
throw err;
|
|
827
|
+
}
|
|
828
|
+
const operationId = dispatch?.operation_id;
|
|
829
|
+
if (!operationId) {
|
|
830
|
+
return;
|
|
762
831
|
}
|
|
763
832
|
const startedAt = Date.now();
|
|
764
833
|
const maxWaitMs = 20 * 60 * 1e3;
|
|
765
|
-
const pollIntervalMs =
|
|
834
|
+
const pollIntervalMs = 5 * 1e3;
|
|
835
|
+
let lastStage = null;
|
|
766
836
|
while (Date.now() - startedAt < maxWaitMs) {
|
|
767
837
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
768
|
-
let
|
|
838
|
+
let op;
|
|
769
839
|
try {
|
|
770
|
-
|
|
840
|
+
op = await api.get(`/v1/operations/${operationId}`);
|
|
771
841
|
} catch (pollErr) {
|
|
772
842
|
if (isGatewayTimeoutError(pollErr)) continue;
|
|
773
843
|
throw pollErr;
|
|
774
844
|
}
|
|
775
|
-
|
|
776
|
-
|
|
845
|
+
if (op.stage && op.stage !== lastStage) {
|
|
846
|
+
const progressLabel = op.progress != null ? ` (${op.progress}%)` : "";
|
|
847
|
+
console.log(` ${op.stage}${progressLabel}`);
|
|
848
|
+
lastStage = op.stage;
|
|
849
|
+
}
|
|
850
|
+
if (op.status === "completed") {
|
|
851
|
+
assertEngineSetupCompleted({ status: op.status, result: op.result });
|
|
777
852
|
return;
|
|
778
853
|
}
|
|
779
|
-
if (
|
|
854
|
+
if (op.status === "failed") {
|
|
780
855
|
throw new Error(
|
|
781
|
-
`Engine setup failed
|
|
856
|
+
`Engine setup failed: ${op.error ?? "unknown error"}. Run \`ardent connector list\` to inspect connector state, or re-trigger setup once the underlying issue is resolved.`
|
|
782
857
|
);
|
|
783
858
|
}
|
|
784
|
-
const elapsedSec = Math.round((Date.now() - startedAt) / 1e3);
|
|
785
|
-
console.log(` Still setting up... (${elapsedSec}s elapsed, status=${engineStatus ?? "unknown"})`);
|
|
786
859
|
}
|
|
787
860
|
throw new EngineSetupTimeoutError(
|
|
788
|
-
`Engine setup did not complete within ${maxWaitMs / 6e4} minutes. Setup may still be running server-side \u2014 do NOT delete the connector. Check status with: ardent connector list`
|
|
861
|
+
`Engine setup did not complete within ${maxWaitMs / 6e4} minutes. Setup may still be running server-side \u2014 do NOT delete the connector. Check status with: ardent connector list (operation ${operationId})`
|
|
789
862
|
);
|
|
790
863
|
}
|
|
791
864
|
function parsePostgresUrl(url) {
|