@remit/data-ports 0.0.41 → 0.0.42

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/data-ports",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/errors.ts CHANGED
@@ -80,6 +80,24 @@ export class FolderRoleUnresolvedError extends ConflictError {
80
80
  }
81
81
  }
82
82
 
83
+ /**
84
+ * A role cannot be appointed to a mailbox the mail server has not settled yet
85
+ * (imap-mutations R2: wait). Its own code, because the role is not unresolved —
86
+ * the target is: the client words a wait, not a retry. Clearing a role is never
87
+ * refused this way.
88
+ */
89
+ export class MailboxNotSettledError extends ConflictError {
90
+ name = "MailboxNotSettledError";
91
+
92
+ constructor(message: string, mailboxId: string, syncStatus: string) {
93
+ super(message);
94
+ this.publicApiError = {
95
+ code: "mailbox_not_settled",
96
+ details: { mailboxId, syncStatus },
97
+ };
98
+ }
99
+ }
100
+
83
101
  /**
84
102
  * A message exists but its body could not be fetched/parsed after every
85
103
  * body-sync retry was spent (issue #1270 / epic #1281 invariant 3). This is
@@ -1,6 +1,10 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { describe, it } from "node:test";
3
- import { CanonicalMailboxRole, MailboxSpecialUse } from "@remit/domain-enums";
3
+ import {
4
+ CanonicalMailboxRole,
5
+ MailboxSpecialUse,
6
+ MailboxSyncStatus,
7
+ } from "@remit/domain-enums";
4
8
  import {
5
9
  composeFolderRoleAppointmentLabelName,
6
10
  composeFolderRoleAppointmentName,
@@ -173,6 +177,24 @@ describe("resolveConfirmedMailboxForRole", () => {
173
177
  });
174
178
 
175
179
  describe("resolveRoleForAccount", () => {
180
+ it("resolves an appointment naming a mailbox whose last sync failed", () => {
181
+ // `failed` has three writers (imap-worker mailbox-management: create :166
182
+ // rolls nothing back, rename :275 restores oldPath, delete :384 leaves the
183
+ // folder) and in two the folder is really at the path the row names.
184
+ const failed: RoleMailboxCandidate & { syncStatus: string } = {
185
+ ...mailbox("mb-trash", "INBOX/Prullenbak"),
186
+ syncStatus: MailboxSyncStatus.failed,
187
+ };
188
+ assert.deepEqual(
189
+ resolveRoleForAccount(
190
+ CanonicalMailboxRole.Trash,
191
+ [mailbox("mb-inbox", "INBOX"), failed],
192
+ "mb-trash",
193
+ ),
194
+ { kind: "appointed", mailbox: failed },
195
+ );
196
+ });
197
+
176
198
  it("answers none when nothing names a Trash folder", () => {
177
199
  // #887 Done item 4: an account whose folders happen to include a Dutch
178
200
  // "Prullenbak" has no Trash reader may act on — no flag, no appointment,