@remit/data-ports 0.0.33 → 0.0.34

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.33",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -25,6 +25,10 @@
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
+ },
28
32
  "./display-name": {
29
33
  "types": "./src/display-name.ts",
30
34
  "default": "./src/display-name.ts"
@@ -11,6 +11,9 @@ import type {
11
11
  export interface IAddressRepository {
12
12
  createAddress(input: CreateAddressInput): Promise<AddressItem>;
13
13
  upsertAddress(input: CreateAddressInput): Promise<AddressItem>;
14
+ upsertCorrespondentAddress(input: CreateAddressInput): Promise<AddressItem>;
15
+ upsertJunkAddress(input: CreateAddressInput): Promise<AddressItem>;
16
+ reconcileJunkOnlyForMessage(messageId: string): Promise<void>;
14
17
  getAddress(accountConfigId: string, addressId: string): Promise<AddressItem>;
15
18
  getAddress(
16
19
  accountConfigId: string,
@@ -0,0 +1,46 @@
1
+ import { MailboxSpecialUse } from "@remit/domain-enums";
2
+ import { resolveMailboxByLeafName } from "./mailbox-name.js";
3
+
4
+ export const JUNK_FOLDER_NAMES: readonly string[] = [
5
+ "junk",
6
+ "spam",
7
+ "junk e-mail",
8
+ "junk email",
9
+ "bulk mail",
10
+ ];
11
+
12
+ export const TRASH_FOLDER_NAMES: readonly string[] = [
13
+ "trash",
14
+ "deleted items",
15
+ "deleted",
16
+ "bin",
17
+ ];
18
+
19
+ export interface MailboxRole {
20
+ readonly fullPath: string;
21
+ readonly hierarchyDelimiter?: string;
22
+ readonly specialUse?: readonly string[];
23
+ }
24
+
25
+ const carriesRole = (
26
+ mailbox: MailboxRole,
27
+ specialUse: string,
28
+ namesWhenServerDoesNotSaySo: readonly string[],
29
+ ): boolean =>
30
+ mailbox.specialUse?.includes(specialUse) === true ||
31
+ resolveMailboxByLeafName(
32
+ [
33
+ {
34
+ mailboxId: "",
35
+ fullPath: mailbox.fullPath,
36
+ hierarchyDelimiter: mailbox.hierarchyDelimiter ?? "",
37
+ },
38
+ ],
39
+ namesWhenServerDoesNotSaySo,
40
+ ) !== null;
41
+
42
+ export const isJunkMailbox = (mailbox: MailboxRole): boolean =>
43
+ carriesRole(mailbox, MailboxSpecialUse.Junk, JUNK_FOLDER_NAMES);
44
+
45
+ export const isTrashMailbox = (mailbox: MailboxRole): boolean =>
46
+ carriesRole(mailbox, MailboxSpecialUse.Trash, TRASH_FOLDER_NAMES);