@fairmint/captable-ai 0.1.15 → 0.1.16
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 +22 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -170,8 +170,11 @@ function parsePortals(body) {
|
|
|
170
170
|
if (!portals.every(isStoredPortal)) return null;
|
|
171
171
|
return portals;
|
|
172
172
|
}
|
|
173
|
+
function cachedPortalsNeedNameRefresh(portals) {
|
|
174
|
+
return portals.some((portal) => typeof portal.name !== "string" || portal.name.trim() === "");
|
|
175
|
+
}
|
|
173
176
|
async function refreshPortalsIfStale(creds, force = false) {
|
|
174
|
-
if (!force && creds.portalsLastFetchedAt && Date.now() - Date.parse(creds.portalsLastFetchedAt) < PORTALS_TTL_MS) {
|
|
177
|
+
if (!force && !cachedPortalsNeedNameRefresh(creds.portals) && creds.portalsLastFetchedAt && Date.now() - Date.parse(creds.portalsLastFetchedAt) < PORTALS_TTL_MS) {
|
|
175
178
|
return creds;
|
|
176
179
|
}
|
|
177
180
|
if (isTokenExpired(creds.accessToken)) {
|
|
@@ -205,6 +208,22 @@ async function markPortalsFetched(creds) {
|
|
|
205
208
|
creds.portalsLastFetchedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
206
209
|
await writeCredentials(creds);
|
|
207
210
|
}
|
|
211
|
+
async function refreshCachedPortalNames() {
|
|
212
|
+
try {
|
|
213
|
+
const creds = await readCredentials();
|
|
214
|
+
if (!creds) return;
|
|
215
|
+
const updated = await refreshPortalsIfStale(creds, true);
|
|
216
|
+
const config2 = await readConfig();
|
|
217
|
+
const activeId = config2.activePortal?.id;
|
|
218
|
+
if (!activeId) return;
|
|
219
|
+
const portal = updated.portals.find((candidate) => candidate.id === activeId);
|
|
220
|
+
if (portal) await setActivePortal(portal);
|
|
221
|
+
} catch {
|
|
222
|
+
process.stderr.write(
|
|
223
|
+
"Warning: Could not refresh company name after updating the company list.\n"
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
208
227
|
|
|
209
228
|
// src/output.ts
|
|
210
229
|
import { renameSync, rmSync, writeFileSync } from "fs";
|
|
@@ -17971,6 +17990,7 @@ Committing ${countCopy}...
|
|
|
17971
17990
|
exitWithError("Unexpected empty response from server.");
|
|
17972
17991
|
}
|
|
17973
17992
|
const data = res.data;
|
|
17993
|
+
await refreshCachedPortalNames();
|
|
17974
17994
|
if (isJsonMode()) {
|
|
17975
17995
|
printJson({ data });
|
|
17976
17996
|
return;
|
|
@@ -20592,6 +20612,7 @@ Reverting ${selection.objectIds.length} selected draft object(s)...
|
|
|
20592
20612
|
if (!res.data) {
|
|
20593
20613
|
exitWithError("Unexpected empty response from server.");
|
|
20594
20614
|
}
|
|
20615
|
+
await refreshCachedPortalNames();
|
|
20595
20616
|
if (isJsonMode()) {
|
|
20596
20617
|
printJson({ data: res.data });
|
|
20597
20618
|
return;
|
package/package.json
CHANGED