ardent-cli 0.0.23 → 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 +57 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -665,6 +665,35 @@ branchCommand.command("diff [name]", { hidden: true }).description("(removed) Sh
|
|
|
665
665
|
// src/commands/connector/index.ts
|
|
666
666
|
import { Command as Command2 } from "commander";
|
|
667
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
|
+
|
|
668
697
|
// src/lib/onboarding.ts
|
|
669
698
|
var BANNER = `
|
|
670
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
|
|
@@ -782,43 +811,54 @@ var EngineSetupTimeoutError = class extends Error {
|
|
|
782
811
|
}
|
|
783
812
|
};
|
|
784
813
|
async function runEngineSetupWithPolling(connectorId) {
|
|
814
|
+
let dispatch;
|
|
785
815
|
try {
|
|
786
|
-
await api.post(
|
|
787
|
-
|
|
816
|
+
dispatch = await api.post(
|
|
817
|
+
`/v1/connectors/${connectorId}/engine-setup`,
|
|
818
|
+
{}
|
|
819
|
+
);
|
|
788
820
|
} catch (err) {
|
|
789
|
-
if (
|
|
790
|
-
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
|
+
);
|
|
791
825
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
826
|
+
throw err;
|
|
827
|
+
}
|
|
828
|
+
const operationId = dispatch?.operation_id;
|
|
829
|
+
if (!operationId) {
|
|
830
|
+
return;
|
|
795
831
|
}
|
|
796
832
|
const startedAt = Date.now();
|
|
797
833
|
const maxWaitMs = 20 * 60 * 1e3;
|
|
798
|
-
const pollIntervalMs =
|
|
834
|
+
const pollIntervalMs = 5 * 1e3;
|
|
835
|
+
let lastStage = null;
|
|
799
836
|
while (Date.now() - startedAt < maxWaitMs) {
|
|
800
837
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
801
|
-
let
|
|
838
|
+
let op;
|
|
802
839
|
try {
|
|
803
|
-
|
|
840
|
+
op = await api.get(`/v1/operations/${operationId}`);
|
|
804
841
|
} catch (pollErr) {
|
|
805
842
|
if (isGatewayTimeoutError(pollErr)) continue;
|
|
806
843
|
throw pollErr;
|
|
807
844
|
}
|
|
808
|
-
|
|
809
|
-
|
|
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 });
|
|
810
852
|
return;
|
|
811
853
|
}
|
|
812
|
-
if (
|
|
854
|
+
if (op.status === "failed") {
|
|
813
855
|
throw new Error(
|
|
814
|
-
`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.`
|
|
815
857
|
);
|
|
816
858
|
}
|
|
817
|
-
const elapsedSec = Math.round((Date.now() - startedAt) / 1e3);
|
|
818
|
-
console.log(` Still setting up... (${elapsedSec}s elapsed, status=${engineStatus ?? "unknown"})`);
|
|
819
859
|
}
|
|
820
860
|
throw new EngineSetupTimeoutError(
|
|
821
|
-
`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})`
|
|
822
862
|
);
|
|
823
863
|
}
|
|
824
864
|
function parsePostgresUrl(url) {
|