@remit/data-ports 0.0.35 → 0.0.37

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.35",
3
+ "version": "0.0.37",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/id.ts CHANGED
@@ -7,13 +7,6 @@ const translator = shortUuid.createTranslator(shortUuid.constants.uuid25Base36);
7
7
 
8
8
  export const base36uuid = (): string => translator.generate();
9
9
 
10
- export const fromUUID = (uuid: string): string => translator.fromUUID(uuid);
11
-
12
- export const toUUID = (shortId: string): string => translator.toUUID(shortId);
13
-
14
- export const generateUuidv5 = (name: string, namespace: string): string =>
15
- uuidv5(name, namespace);
16
-
17
10
  export const base36uuidv5 = (name: string, namespace: string): string =>
18
11
  translator.fromUUID(uuidv5(name, namespace));
19
12
 
@@ -118,16 +111,6 @@ export const ROOT_PART_PATH = "0";
118
111
  export const deriveBodyPartId = (messageId: string, partPath: string): string =>
119
112
  base36uuidv5(`bodypart:${messageId}:${partPath}`, REMIT_NAMESPACE);
120
113
 
121
- export const deriveBodyPartParameterId = (
122
- messageId: string,
123
- partPath: string,
124
- parameterName: string,
125
- ): string =>
126
- base36uuidv5(
127
- `bodypartparam:${messageId}:${partPath}:${parameterName.toLowerCase()}`,
128
- REMIT_NAMESPACE,
129
- );
130
-
131
114
  /**
132
115
  * Identity of a quarantined message (issue #72). Derived rather than generated
133
116
  * so re-quarantining the same message rewrites its own row: the sync path can
package/src/index.ts CHANGED
@@ -25,6 +25,11 @@ export type {
25
25
  } from "./interfaces/outbox-attachment.js";
26
26
  export { holdsRoom } from "./interfaces/outbox-attachment.js";
27
27
  export type { IOutboxMessageRepository } from "./interfaces/outbox-message.js";
28
+ export {
29
+ APPENDED_UID_NONE,
30
+ APPENDED_UID_UNREPORTED,
31
+ isSentCopyFiled,
32
+ } from "./interfaces/outbox-message.js";
28
33
  export type { IQuarantineRepository } from "./interfaces/quarantine.js";
29
34
  export type { ISenderSignerStandingRepository } from "./interfaces/sender-signer-standing.js";
30
35
  export type { IThreadMessageRepository } from "./interfaces/thread-message.js";
@@ -5,6 +5,32 @@ import type {
5
5
  UpdateOutboxMessageInput,
6
6
  } from "../types.js";
7
7
 
8
+ /** `appendedUid` when no IMAP APPEND has been confirmed for the row. */
9
+ export const APPENDED_UID_NONE = 0;
10
+
11
+ /**
12
+ * `appendedUid` when an APPEND was confirmed but the server named no uid for
13
+ * it. UIDPLUS is an extension; a server without it files the copy and reports
14
+ * nothing, and "filed" still has to be distinguishable from "not filed".
15
+ */
16
+ export const APPENDED_UID_UNREPORTED = -1;
17
+
18
+ /**
19
+ * Whether the copy in Sent exists. One definition, because the handler deciding
20
+ * whether to APPEND and the repair deciding what a stranded row means both have
21
+ * to agree on it exactly.
22
+ *
23
+ * Only the two values that mean "filed" say so, rather than everything that is
24
+ * not `APPENDED_UID_NONE`. The two mistakes are not each other's equal: reading
25
+ * a filed row as unfiled files a second copy the user then deletes, and reading
26
+ * an unfiled row as filed drops the row of a delivered message that is in no
27
+ * folder — the disappearance the whole repair exists to prevent (#824).
28
+ */
29
+ export const isSentCopyFiled = (
30
+ message: Pick<OutboxMessageItem, "appendedUid">,
31
+ ): boolean =>
32
+ message.appendedUid > 0 || message.appendedUid === APPENDED_UID_UNREPORTED;
33
+
8
34
  export interface IOutboxMessageRepository {
9
35
  create(input: CreateOutboxMessageInput): Promise<OutboxMessageItem>;
10
36
  /**
@@ -1,5 +1,5 @@
1
1
  import { CanonicalMailboxRole } from "@remit/domain-enums";
2
- import { ROLE_NAME_HINTS, resolveMailboxForRole } from "./folder-role.js";
2
+ import { ROLE_NAME_HINTS } from "./folder-role.js";
3
3
 
4
4
  /**
5
5
  * The conventional names for a role, taken from the one table every
@@ -12,34 +12,3 @@ export const JUNK_FOLDER_NAMES: readonly string[] =
12
12
 
13
13
  export const TRASH_FOLDER_NAMES: readonly string[] =
14
14
  ROLE_NAME_HINTS[CanonicalMailboxRole.Trash] ?? [];
15
-
16
- export interface MailboxRole {
17
- readonly fullPath: string;
18
- readonly hierarchyDelimiter?: string;
19
- readonly specialUse?: readonly string[];
20
- }
21
-
22
- /**
23
- * Whether one mailbox, considered alone, carries a role: its SPECIAL-USE flag
24
- * or its conventional name. A single mailbox carries no account context, so
25
- * this cannot see the user's appointment — a caller holding an accountId asks
26
- * `IMailboxSpecialUseRepository` instead, which does.
27
- */
28
- const carriesRole = (
29
- mailbox: MailboxRole,
30
- role: (typeof CanonicalMailboxRole)[keyof typeof CanonicalMailboxRole],
31
- ): boolean =>
32
- resolveMailboxForRole(role, [
33
- {
34
- mailboxId: "",
35
- fullPath: mailbox.fullPath,
36
- hierarchyDelimiter: mailbox.hierarchyDelimiter ?? "",
37
- specialUse: mailbox.specialUse,
38
- },
39
- ]) !== null;
40
-
41
- export const isJunkMailbox = (mailbox: MailboxRole): boolean =>
42
- carriesRole(mailbox, CanonicalMailboxRole.Junk);
43
-
44
- export const isTrashMailbox = (mailbox: MailboxRole): boolean =>
45
- carriesRole(mailbox, CanonicalMailboxRole.Trash);
package/src/types.ts CHANGED
@@ -423,6 +423,7 @@ export type CreateOutboxMessageInput = Omit<
423
423
  | "ccAddresses"
424
424
  | "bccAddresses"
425
425
  | "references"
426
+ | "appendedUid"
426
427
  > & {
427
428
  ccAddresses?: string[];
428
429
  bccAddresses?: string[];
@@ -437,6 +438,7 @@ export type UpdateOutboxMessageInput = Partial<
437
438
  | "lastSmtpCode"
438
439
  | "sentAt"
439
440
  | "smtpMessageId"
441
+ | "appendedUid"
440
442
  | "toAddresses"
441
443
  | "ccAddresses"
442
444
  | "bccAddresses"