agendex-cli 0.3.1 → 0.3.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/dist/cli.js +21 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2681,15 +2681,31 @@ function getCloudConfig() {
|
|
|
2681
2681
|
async function syncPlan(plan) {
|
|
2682
2682
|
const { token, convexUrl } = getCloudConfig();
|
|
2683
2683
|
const url = `${convexUrl}/api/cli/sync`;
|
|
2684
|
-
|
|
2684
|
+
let activeToken = token;
|
|
2685
|
+
let res = await requestText(url, {
|
|
2685
2686
|
method: "POST",
|
|
2686
2687
|
headers: {
|
|
2687
|
-
Authorization: `Bearer ${
|
|
2688
|
+
Authorization: `Bearer ${activeToken}`,
|
|
2688
2689
|
Connection: "close",
|
|
2689
2690
|
"Content-Type": "application/json"
|
|
2690
2691
|
},
|
|
2691
2692
|
body: JSON.stringify(plan)
|
|
2692
2693
|
});
|
|
2694
|
+
if (res.status === 401) {
|
|
2695
|
+
const refreshed = await refreshStoredToken(activeToken, convexUrl);
|
|
2696
|
+
if (refreshed) {
|
|
2697
|
+
activeToken = refreshed;
|
|
2698
|
+
res = await requestText(url, {
|
|
2699
|
+
method: "POST",
|
|
2700
|
+
headers: {
|
|
2701
|
+
Authorization: `Bearer ${activeToken}`,
|
|
2702
|
+
Connection: "close",
|
|
2703
|
+
"Content-Type": "application/json"
|
|
2704
|
+
},
|
|
2705
|
+
body: JSON.stringify(plan)
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2693
2709
|
if (res.status < 200 || res.status >= 300) {
|
|
2694
2710
|
return { ok: false, error: `${res.status}: ${res.body}` };
|
|
2695
2711
|
}
|
|
@@ -2868,7 +2884,9 @@ async function runWorker() {
|
|
|
2868
2884
|
if (!result.ok) {
|
|
2869
2885
|
if (result.error?.includes("401")) {
|
|
2870
2886
|
console.error("[agendex] session expired. Run `agendex login` to re-authenticate.");
|
|
2871
|
-
|
|
2887
|
+
batch.length = 0;
|
|
2888
|
+
syncQueue.length = 0;
|
|
2889
|
+
break;
|
|
2872
2890
|
}
|
|
2873
2891
|
failedCount++;
|
|
2874
2892
|
console.error(`[agendex] sync failed for "${payload.title}": ${result.error}`);
|