@remit/data-ports 0.0.47 → 0.0.49
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 +1 -5
- package/src/errors.ts +24 -0
- package/src/folder-role.ts +15 -0
- package/src/interfaces/address.ts +10 -1
- package/src/interfaces/mailbox-special-use.ts +11 -1
- package/src/mailbox-role.ts +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/data-ports",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -25,10 +25,6 @@
|
|
|
25
25
|
"types": "./src/account-settings.ts",
|
|
26
26
|
"default": "./src/account-settings.ts"
|
|
27
27
|
},
|
|
28
|
-
"./mailbox-role": {
|
|
29
|
-
"types": "./src/mailbox-role.ts",
|
|
30
|
-
"default": "./src/mailbox-role.ts"
|
|
31
|
-
},
|
|
32
28
|
"./display-name": {
|
|
33
29
|
"types": "./src/display-name.ts",
|
|
34
30
|
"default": "./src/display-name.ts"
|
package/src/errors.ts
CHANGED
|
@@ -98,6 +98,30 @@ export class MailboxNotSettledError extends ConflictError {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Why the row's folder and uid do not name the same message. `in_flight` clears
|
|
103
|
+
* on its own, so the client words a wait; `unverified` does not, so it words a
|
|
104
|
+
* resync instead.
|
|
105
|
+
*/
|
|
106
|
+
export type MessagePlacementUnsettledReason = "in_flight" | "unverified";
|
|
107
|
+
|
|
108
|
+
export class MessagePlacementUnsettledError extends ConflictError {
|
|
109
|
+
name = "MessagePlacementUnsettledError";
|
|
110
|
+
|
|
111
|
+
constructor(
|
|
112
|
+
message: string,
|
|
113
|
+
accountId: string,
|
|
114
|
+
messageId: string,
|
|
115
|
+
reason: MessagePlacementUnsettledReason,
|
|
116
|
+
) {
|
|
117
|
+
super(message);
|
|
118
|
+
this.publicApiError = {
|
|
119
|
+
code: "message_placement_unsettled",
|
|
120
|
+
details: { accountId, messageId, reason },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
101
125
|
/**
|
|
102
126
|
* A message exists but its body could not be fetched/parsed after every
|
|
103
127
|
* body-sync retry was spent (issue #1270 / epic #1281 invariant 3). This is
|
package/src/folder-role.ts
CHANGED
|
@@ -168,6 +168,21 @@ export const STALE_TRASH_FOLDER_REASON = `The folder appointed as this account's
|
|
|
168
168
|
*/
|
|
169
169
|
export const UNCONFIRMED_TRASH_FOLDER_REASON = `Nobody has confirmed which folder is this account's Trash, so nothing was deleted. Appoint one under ${FOLDER_ROLES_SETTINGS_PATH}, then try again.`;
|
|
170
170
|
|
|
171
|
+
/**
|
|
172
|
+
* The mailboxes holding Junk and Trash across a set of accounts, as ids. The
|
|
173
|
+
* shape a SQL predicate needs when it must ask "is this message in Junk"
|
|
174
|
+
* without spelling the rule a second time: resolution happens once, here, and
|
|
175
|
+
* SQL compares mailbox ids.
|
|
176
|
+
*
|
|
177
|
+
* A role resolves to at most one mailbox per account, so each list holds one id
|
|
178
|
+
* per account that has that folder — and no entry at all for an account that
|
|
179
|
+
* has none.
|
|
180
|
+
*/
|
|
181
|
+
export interface JunkRoleMailboxes {
|
|
182
|
+
readonly junkMailboxIds: readonly string[];
|
|
183
|
+
readonly trashMailboxIds: readonly string[];
|
|
184
|
+
}
|
|
185
|
+
|
|
171
186
|
/** The minimal mailbox shape role resolution reads. */
|
|
172
187
|
export interface RoleMailboxCandidate extends MailboxNameCandidate {
|
|
173
188
|
specialUse?: readonly string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JunkRoleMailboxes } from "../folder-role.js";
|
|
1
2
|
import type {
|
|
2
3
|
AddressItem,
|
|
3
4
|
CreateAddressInput,
|
|
@@ -13,7 +14,15 @@ export interface IAddressRepository {
|
|
|
13
14
|
upsertAddress(input: CreateAddressInput): Promise<AddressItem>;
|
|
14
15
|
upsertCorrespondentAddress(input: CreateAddressInput): Promise<AddressItem>;
|
|
15
16
|
upsertJunkAddress(input: CreateAddressInput): Promise<AddressItem>;
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* `roles` covers every account under the message's config, resolved by the
|
|
19
|
+
* caller once per batch: this runs inside the per-message sync loop, and
|
|
20
|
+
* role resolution is deliberately uncached.
|
|
21
|
+
*/
|
|
22
|
+
reconcileJunkOnlyForMessage(
|
|
23
|
+
messageId: string,
|
|
24
|
+
roles: JunkRoleMailboxes,
|
|
25
|
+
): Promise<void>;
|
|
17
26
|
getAddress(accountConfigId: string, addressId: string): Promise<AddressItem>;
|
|
18
27
|
getAddress(
|
|
19
28
|
accountConfigId: string,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RoleResolution } from "../folder-role.js";
|
|
1
|
+
import type { JunkRoleMailboxes, RoleResolution } from "../folder-role.js";
|
|
2
2
|
import type {
|
|
3
3
|
MailboxSpecialUseItem,
|
|
4
4
|
MailboxSpecialUseValue,
|
|
@@ -47,4 +47,14 @@ export interface IMailboxSpecialUseRepository {
|
|
|
47
47
|
findJunkMailbox(
|
|
48
48
|
accountId: string,
|
|
49
49
|
): Promise<{ mailboxId: string; fullPath: string } | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Junk and Trash for every account under one config, as mailbox ids. The
|
|
52
|
+
* address book is keyed by config and an address carries sightings from all
|
|
53
|
+
* of them, so a predicate over an address must weigh every account's Junk —
|
|
54
|
+
* resolving only the account in hand withholds a sender on one and restores
|
|
55
|
+
* it on the next.
|
|
56
|
+
*/
|
|
57
|
+
resolveJunkRolesForConfig(
|
|
58
|
+
accountConfigId: string,
|
|
59
|
+
): Promise<JunkRoleMailboxes>;
|
|
50
60
|
}
|
package/src/mailbox-role.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CanonicalMailboxRole } from "@remit/domain-enums";
|
|
2
|
-
import { ROLE_NAME_HINTS } from "./folder-role.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The conventional names for a role, taken from the one table every
|
|
6
|
-
* special-folder lookup shares (`folder-role.ts`). Exported so the SQLite junk
|
|
7
|
-
* repair can spell the same rule; a second list here is how `INBOX/Sent` and
|
|
8
|
-
* `INBOX/Spam` came to be resolvable in one place and not another.
|
|
9
|
-
*/
|
|
10
|
-
export const JUNK_FOLDER_NAMES: readonly string[] =
|
|
11
|
-
ROLE_NAME_HINTS[CanonicalMailboxRole.Junk] ?? [];
|
|
12
|
-
|
|
13
|
-
export const TRASH_FOLDER_NAMES: readonly string[] =
|
|
14
|
-
ROLE_NAME_HINTS[CanonicalMailboxRole.Trash] ?? [];
|