@tinycloud/cli 1.3.0-beta.43 → 1.3.0-beta.45
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/courier-entry.js +523 -91
- package/dist/courier-entry.js.map +1 -1
- package/dist/index.js +76 -42
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +35 -11
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +5 -5
- package/skills/courier/SKILL.md +26 -1
- package/skills/tc-cli/REFERENCE.md +2 -0
package/dist/legacy-entry.js
CHANGED
|
@@ -37678,6 +37678,25 @@ var ShareHistoryRetryError = class extends Error {
|
|
|
37678
37678
|
}
|
|
37679
37679
|
code = "SHARE_HISTORY_RETRY";
|
|
37680
37680
|
};
|
|
37681
|
+
var ShareHistoryUnreadableError = class extends Error {
|
|
37682
|
+
constructor() {
|
|
37683
|
+
super("share history is unavailable");
|
|
37684
|
+
this.name = "ShareHistoryUnreadableError";
|
|
37685
|
+
}
|
|
37686
|
+
};
|
|
37687
|
+
var ShareHistoryReadError = class extends Error {
|
|
37688
|
+
constructor() {
|
|
37689
|
+
super("share history could not be read");
|
|
37690
|
+
this.name = "ShareHistoryReadError";
|
|
37691
|
+
}
|
|
37692
|
+
};
|
|
37693
|
+
var HISTORY_WRITE_ERROR_CODES = { EACCES: true, EPERM: true, EROFS: true, ENOSPC: true, EDQUOT: true, EIO: true };
|
|
37694
|
+
function shareHistoryReason(error) {
|
|
37695
|
+
if (error instanceof ShareHistoryUnreadableError) return "HISTORY_UNREADABLE";
|
|
37696
|
+
if (error instanceof ShareHistoryReadError) return "HISTORY_READ_FAILED";
|
|
37697
|
+
const code4 = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
37698
|
+
return typeof code4 === "string" && HISTORY_WRITE_ERROR_CODES[code4] === true ? "HISTORY_WRITE_FAILED" : "HISTORY_UNAVAILABLE";
|
|
37699
|
+
}
|
|
37681
37700
|
|
|
37682
37701
|
// src/commands/share.ts
|
|
37683
37702
|
var SHARE_ORIGIN = "https://share.tinycloud.xyz";
|
|
@@ -37856,16 +37875,18 @@ function expires(value) {
|
|
|
37856
37875
|
}
|
|
37857
37876
|
async function rememberPublishedShare(result) {
|
|
37858
37877
|
const record3 = historyRecordForPublishedShare(result);
|
|
37859
|
-
if (shareServices.records === void 0) return { record: record3, recorded: false };
|
|
37860
37878
|
try {
|
|
37879
|
+
if (shareServices.records === void 0) throw new Error("sender history is not configured");
|
|
37861
37880
|
await shareServices.records.put(record3);
|
|
37862
|
-
return { record: record3, recorded: true };
|
|
37863
|
-
} catch {
|
|
37864
|
-
|
|
37865
|
-
|
|
37881
|
+
return { record: record3, history: { recorded: true } };
|
|
37882
|
+
} catch (error) {
|
|
37883
|
+
const reason = shareHistoryReason(error);
|
|
37884
|
+
process.stderr.write(`Warning: share was published but not recorded in sender history (${reason}); future share list, share notify, and share revoke by ID will not find it. Keep share ID ${result.metadata.shareId} and CID ${result.link.cid}.
|
|
37885
|
+
`);
|
|
37886
|
+
return { record: record3, history: { recorded: false, reason } };
|
|
37866
37887
|
}
|
|
37867
37888
|
}
|
|
37868
|
-
async function notifyRecordedShare(record3, recipient, adapter, storage) {
|
|
37889
|
+
async function notifyRecordedShare(record3, recipient, adapter, storage, published) {
|
|
37869
37890
|
const result = await notifyShare({ shareId: record3.shareId, recipient, record: record3, adapter, checkDeliveryWindow: true });
|
|
37870
37891
|
if (result.state !== "partial-failure" && storage !== void 0) {
|
|
37871
37892
|
const mailbox = canonicalMailbox2(recipient).email;
|
|
@@ -37877,8 +37898,11 @@ async function notifyRecordedShare(record3, recipient, adapter, storage) {
|
|
|
37877
37898
|
deliveredRecipients: current.deliveredRecipients?.includes(mailbox) ? current.deliveredRecipients : [...current.deliveredRecipients ?? [], mailbox]
|
|
37878
37899
|
}));
|
|
37879
37900
|
if (updated === void 0) throw new Error("sender history record was removed");
|
|
37880
|
-
} catch {
|
|
37881
|
-
|
|
37901
|
+
} catch (error) {
|
|
37902
|
+
const reason = shareHistoryReason(error);
|
|
37903
|
+
const identifiers = published === void 0 ? "" : ` Keep share ID ${published.shareId} and CID ${published.cid}.`;
|
|
37904
|
+
process.stderr.write(`Warning: delivery succeeded, but could not record its confirmation in sender history (${reason}).${identifiers}
|
|
37905
|
+
`);
|
|
37882
37906
|
}
|
|
37883
37907
|
}
|
|
37884
37908
|
}
|
|
@@ -37967,17 +37991,17 @@ function registerShareCommand(program) {
|
|
|
37967
37991
|
}
|
|
37968
37992
|
throw new CLIError(result.method === "openkey-device" ? "DEVICE_AUTH_REQUIRED" : "CLAIM_REQUIRED", "recipient authorization is required; continue through the configured authority adapter", 6);
|
|
37969
37993
|
}
|
|
37970
|
-
const { record: record3,
|
|
37994
|
+
const { record: record3, history } = await rememberPublishedShare(result);
|
|
37971
37995
|
let notification;
|
|
37972
37996
|
if (notifyRecipient !== void 0) {
|
|
37973
37997
|
if (shareServices.delivery === void 0) throw new CLIError("AUTH_REQUIRED", "delivery authority is not configured", 3);
|
|
37974
|
-
notification = await notifyRecordedShare(record3, notifyRecipient, shareServices.delivery, recorded ? shareServices.records : void 0);
|
|
37998
|
+
notification = await notifyRecordedShare(record3, notifyRecipient, shareServices.delivery, history.recorded ? shareServices.records : void 0, { shareId: result.metadata.shareId, cid: result.link.cid });
|
|
37975
37999
|
if (notification.state === "partial-failure") process.exitCode = 9;
|
|
37976
38000
|
if (notification.reason === "delivery-window-expired") process.stderr.write(NOTIFY_WINDOW_MESSAGE);
|
|
37977
38001
|
}
|
|
37978
38002
|
if (result.metadata.expiryClamped === true) process.stderr.write(`Share expiry clamped to session expiry (${result.metadata.expiresAt}).
|
|
37979
38003
|
`);
|
|
37980
|
-
if (json) writeJson2({ ...redactPublishedShare(result), expiryClamped: result.metadata.expiryClamped === true, ...artifact === void 0 || result.metadata.artifact === void 0 ? {} : { artifactId: result.metadata.artifact.id, version: result.metadata.artifact.version, mode: result.metadata.artifact.mode }, ...notification === void 0 ? {} : { notification } });
|
|
38004
|
+
if (json) writeJson2({ ...redactPublishedShare(result), history, expiryClamped: result.metadata.expiryClamped === true, ...artifact === void 0 || result.metadata.artifact === void 0 ? {} : { artifactId: result.metadata.artifact.id, version: result.metadata.artifact.version, mode: result.metadata.artifact.mode }, ...notification === void 0 ? {} : { notification } });
|
|
37981
38005
|
else {
|
|
37982
38006
|
if (result.metadata.artifact !== void 0) process.stderr.write(`Artifact ${result.metadata.artifact.id} v${result.metadata.artifact.version} (${result.metadata.artifact.mode})
|
|
37983
38007
|
`);
|