@flatkey-ai/cli 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/cli.js +14 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -636,7 +636,8 @@ async function waitForVideoResult(response, options) {
|
|
|
636
636
|
|
|
637
637
|
while (Date.now() <= deadline) {
|
|
638
638
|
last = await options.getVideo(options, taskId);
|
|
639
|
-
if (hasArtifact(last)
|
|
639
|
+
if (hasArtifact(last)) return last;
|
|
640
|
+
if (isVideoDone(last)) return withVideoContentFallback(last, options, taskId);
|
|
640
641
|
if (isVideoFailed(last)) {
|
|
641
642
|
const message = last?.error?.message ?? last?.message ?? `Video generation failed: ${taskId}`;
|
|
642
643
|
throw new Error(message);
|
|
@@ -647,6 +648,18 @@ async function waitForVideoResult(response, options) {
|
|
|
647
648
|
throw new Error(`Video task still processing after ${Math.round(timeoutMs / 1000)}s: ${taskId}`);
|
|
648
649
|
}
|
|
649
650
|
|
|
651
|
+
function withVideoContentFallback(response, options, taskId) {
|
|
652
|
+
const baseUrl = String(options.baseUrl ?? "").replace(/\/$/, "");
|
|
653
|
+
if (!baseUrl || !taskId) return response;
|
|
654
|
+
return {
|
|
655
|
+
...response,
|
|
656
|
+
metadata: {
|
|
657
|
+
...(response.metadata ?? {}),
|
|
658
|
+
url: `${baseUrl}/v1/videos/${encodeURIComponent(taskId)}/content`,
|
|
659
|
+
},
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
|
|
650
663
|
function hasArtifact(response) {
|
|
651
664
|
return Boolean(
|
|
652
665
|
response?.metadata?.url
|