@remit/data-ports 0.0.35 → 0.0.36

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.36",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
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
  /**
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"