@remit/data-ports 0.0.40 → 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 +5 -1
- package/src/errors.ts +18 -0
- package/src/folder-role.test.ts +23 -1
- package/src/mutation-events.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/data-ports",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"types": "./src/folder-role.ts",
|
|
38
38
|
"default": "./src/folder-role.ts"
|
|
39
39
|
},
|
|
40
|
+
"./mutation-events": {
|
|
41
|
+
"types": "./src/mutation-events.ts",
|
|
42
|
+
"default": "./src/mutation-events.ts"
|
|
43
|
+
},
|
|
40
44
|
"./mailbox-name": {
|
|
41
45
|
"types": "./src/mailbox-name.ts",
|
|
42
46
|
"default": "./src/mailbox-name.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
|
package/src/folder-role.test.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
|
-
import {
|
|
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,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract version the mail-destroying queue events are minted under.
|
|
3
|
+
*
|
|
4
|
+
* It lives here because the producer (`MessageMoveService`) and the consumer
|
|
5
|
+
* (the imap-worker's handlers) sit in packages that cannot import each other,
|
|
6
|
+
* and a version the two sides disagree about is worse than no version at all.
|
|
7
|
+
* Bump it whenever a handler starts relying on a field an older producer never
|
|
8
|
+
* set.
|
|
9
|
+
*/
|
|
10
|
+
export const MUTATION_EVENT_SCHEMA_VERSION = 2;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Queue payloads are `JSON.parse`d and cast with no validation, so the declared
|
|
14
|
+
* type is a promise the queue cannot keep. A handler that cannot vouch for an
|
|
15
|
+
* event's shape abandons it — treating a missing field as "skip the check"
|
|
16
|
+
* makes the unverified expunge the default for every event we cannot vouch for,
|
|
17
|
+
* including any future producer that forgets the field.
|
|
18
|
+
*/
|
|
19
|
+
export const isCurrentSchemaVersion = (value: unknown): boolean =>
|
|
20
|
+
value === MUTATION_EVENT_SCHEMA_VERSION;
|