@rigxyz/tapd 0.6.3 → 0.6.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/dist/bin.js +19 -3
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-54AIKODH.js → chunk-F3HYZR2Y.js} +53 -7
- package/dist/chunk-F3HYZR2Y.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-54AIKODH.js.map +0 -1
|
@@ -27,6 +27,25 @@ function writeBindingConfig(rootDir, config) {
|
|
|
27
27
|
mkdirSync(dirname(path), { recursive: true });
|
|
28
28
|
writeFileSync(path, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
|
|
29
29
|
}
|
|
30
|
+
var SYNC_PAUSED_PATH = ".rig/sync-paused.json";
|
|
31
|
+
function syncPausedFile(rootDir) {
|
|
32
|
+
return join(rootDir, SYNC_PAUSED_PATH);
|
|
33
|
+
}
|
|
34
|
+
function isSyncPaused(rootDir) {
|
|
35
|
+
const path = syncPausedFile(rootDir);
|
|
36
|
+
if (!existsSync(path)) return false;
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
39
|
+
return parsed.paused === true;
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function writeSyncPaused(rootDir, reason) {
|
|
45
|
+
const path = syncPausedFile(rootDir);
|
|
46
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
47
|
+
writeFileSync(path, JSON.stringify({ paused: true, reason }, null, 2) + "\n");
|
|
48
|
+
}
|
|
30
49
|
var NotInitializedError = class extends Error {
|
|
31
50
|
constructor(rootDir) {
|
|
32
51
|
super(`not initialized \u2014 no binding config at ${rootDir}/${BINDING_CONFIG_PATH}`);
|
|
@@ -61,6 +80,12 @@ var RelayError = class extends Error {
|
|
|
61
80
|
status;
|
|
62
81
|
body;
|
|
63
82
|
};
|
|
83
|
+
function isRecord(v) {
|
|
84
|
+
return typeof v === "object" && v !== null;
|
|
85
|
+
}
|
|
86
|
+
function isBindingDeletedError(err) {
|
|
87
|
+
return err instanceof RelayError && err.status === 410 && isRecord(err.body) && err.body.error === "binding_deleted";
|
|
88
|
+
}
|
|
64
89
|
async function readJson(res) {
|
|
65
90
|
const ct = res.headers.get("content-type") ?? "";
|
|
66
91
|
if (!ct.includes("application/json")) return void 0;
|
|
@@ -662,7 +687,7 @@ async function mapPool(items, limit, fn) {
|
|
|
662
687
|
function sha256OfBuffer(bytes) {
|
|
663
688
|
return `sha256:${createHash2("sha256").update(bytes).digest("hex")}`;
|
|
664
689
|
}
|
|
665
|
-
function
|
|
690
|
+
function isRecord2(v) {
|
|
666
691
|
return typeof v === "object" && v !== null;
|
|
667
692
|
}
|
|
668
693
|
var UPLOAD_CONCURRENCY = 8;
|
|
@@ -704,7 +729,7 @@ async function init(opts) {
|
|
|
704
729
|
fetch: opts.fetch
|
|
705
730
|
});
|
|
706
731
|
} catch (err) {
|
|
707
|
-
if (err instanceof RelayError &&
|
|
732
|
+
if (err instanceof RelayError && isRecord2(err.body) && err.body.error === "org_forbidden" && opts.org) {
|
|
708
733
|
throw new OrgForbiddenError(opts.org);
|
|
709
734
|
}
|
|
710
735
|
throw err;
|
|
@@ -1105,7 +1130,7 @@ var ImportTokenScopeError = class extends Error {
|
|
|
1105
1130
|
}
|
|
1106
1131
|
ops;
|
|
1107
1132
|
};
|
|
1108
|
-
function
|
|
1133
|
+
function isRecord3(v) {
|
|
1109
1134
|
return typeof v === "object" && v !== null;
|
|
1110
1135
|
}
|
|
1111
1136
|
function deriveName(canonicalPath) {
|
|
@@ -1151,7 +1176,7 @@ async function addImport(opts) {
|
|
|
1151
1176
|
fetch: opts.fetch
|
|
1152
1177
|
});
|
|
1153
1178
|
} catch (err) {
|
|
1154
|
-
if (err instanceof RelayError &&
|
|
1179
|
+
if (err instanceof RelayError && isRecord3(err.body) && err.body.reason === "import_requires_read_subscribe") {
|
|
1155
1180
|
throw new ImportTokenScopeError();
|
|
1156
1181
|
}
|
|
1157
1182
|
throw err;
|
|
@@ -1681,7 +1706,21 @@ async function startSubscription(opts) {
|
|
|
1681
1706
|
mode
|
|
1682
1707
|
});
|
|
1683
1708
|
} catch (err) {
|
|
1684
|
-
|
|
1709
|
+
if (isBindingDeletedError(err)) {
|
|
1710
|
+
const { deletedAt, deletedBy } = err.body;
|
|
1711
|
+
const by = deletedBy?.name ?? deletedBy?.email ?? "someone";
|
|
1712
|
+
console.error(
|
|
1713
|
+
`tapd: binding ${opts.config.bindingId} was deleted by ${by} at ${deletedAt} \u2014 pausing sync and stopping.`
|
|
1714
|
+
);
|
|
1715
|
+
writeSyncPaused(opts.rootDir, "deleted");
|
|
1716
|
+
stopped = true;
|
|
1717
|
+
if (pollTimer) clearTimeout(pollTimer);
|
|
1718
|
+
if (sseApplyTimer) clearTimeout(sseApplyTimer);
|
|
1719
|
+
if (sseSubscriber) await sseSubscriber.stop();
|
|
1720
|
+
opts.onBindingDeleted?.({ deletedAt });
|
|
1721
|
+
} else {
|
|
1722
|
+
console.error("tapd apply error:", err);
|
|
1723
|
+
}
|
|
1685
1724
|
}
|
|
1686
1725
|
} while (rerunRequested && !stopped);
|
|
1687
1726
|
return lastApplyResult;
|
|
@@ -2316,7 +2355,13 @@ async function start(opts) {
|
|
|
2316
2355
|
fetch: opts.fetch,
|
|
2317
2356
|
pollSeconds,
|
|
2318
2357
|
noSse: opts.noSse,
|
|
2319
|
-
sseHeartbeatTimeoutMs: opts.sseHeartbeatTimeoutMs
|
|
2358
|
+
sseHeartbeatTimeoutMs: opts.sseHeartbeatTimeoutMs,
|
|
2359
|
+
onBindingDeleted: (info) => {
|
|
2360
|
+
stopped = true;
|
|
2361
|
+
if (scanTimer) clearTimeout(scanTimer);
|
|
2362
|
+
if (watcher) void watcher.close();
|
|
2363
|
+
opts.onBindingDeleted?.({ bindingId: config.bindingId, deletedAt: info.deletedAt });
|
|
2364
|
+
}
|
|
2320
2365
|
});
|
|
2321
2366
|
}
|
|
2322
2367
|
const primaryTrackedPaths = primary ? primary.stateDb.listPaths() : [];
|
|
@@ -2449,6 +2494,7 @@ export {
|
|
|
2449
2494
|
bindingConfigFile,
|
|
2450
2495
|
readBindingConfig,
|
|
2451
2496
|
writeBindingConfig,
|
|
2497
|
+
isSyncPaused,
|
|
2452
2498
|
NotInitializedError,
|
|
2453
2499
|
RelayError,
|
|
2454
2500
|
createBinding,
|
|
@@ -2495,4 +2541,4 @@ export {
|
|
|
2495
2541
|
scanAndPush,
|
|
2496
2542
|
start
|
|
2497
2543
|
};
|
|
2498
|
-
//# sourceMappingURL=chunk-
|
|
2544
|
+
//# sourceMappingURL=chunk-F3HYZR2Y.js.map
|