@remit/mailbox-service 0.0.112 → 0.0.114

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.
Files changed (270) hide show
  1. package/dist/account-credentials.d.ts +83 -0
  2. package/dist/account-credentials.js +104 -0
  3. package/dist/attribute-mapper.d.ts +36 -0
  4. package/dist/attribute-mapper.js +119 -0
  5. package/dist/body-parse.d.ts +28 -0
  6. package/{src/body-parse.ts → dist/body-parse.js} +18 -26
  7. package/dist/body-part-mapper.d.ts +92 -0
  8. package/dist/body-part-mapper.js +301 -0
  9. package/dist/body-sync-queue.d.ts +59 -0
  10. package/dist/body-sync-queue.js +56 -0
  11. package/dist/body-sync-terminal.d.ts +58 -0
  12. package/dist/body-sync-terminal.js +95 -0
  13. package/dist/body-sync.d.ts +351 -0
  14. package/dist/body-sync.js +1204 -0
  15. package/dist/calendar-parts.d.ts +23 -0
  16. package/dist/calendar-parts.js +18 -0
  17. package/dist/classification-backfill.d.ts +91 -0
  18. package/dist/classification-backfill.js +180 -0
  19. package/dist/classify-message.d.ts +31 -0
  20. package/dist/classify-message.js +89 -0
  21. package/dist/connection-factory.d.ts +54 -0
  22. package/dist/connection-factory.js +54 -0
  23. package/dist/connection-test.d.ts +41 -0
  24. package/dist/connection-test.js +152 -0
  25. package/dist/external-move.d.ts +94 -0
  26. package/dist/external-move.js +173 -0
  27. package/dist/filter-operations.d.ts +42 -0
  28. package/dist/filter-operations.js +211 -0
  29. package/dist/filters/filter-config.d.ts +14 -0
  30. package/dist/filters/filter-config.js +10 -0
  31. package/{src/filters/list-id.ts → dist/filters/list-id.d.ts} +2 -16
  32. package/dist/filters/list-id.js +26 -0
  33. package/dist/filters/match.d.ts +69 -0
  34. package/dist/filters/match.js +165 -0
  35. package/dist/filters/pipeline.d.ts +64 -0
  36. package/dist/filters/pipeline.js +100 -0
  37. package/{src/flag-push-terminal.ts → dist/flag-push-terminal.d.ts} +16 -72
  38. package/dist/flag-push-terminal.js +63 -0
  39. package/dist/flag-push.d.ts +69 -0
  40. package/dist/flag-push.js +111 -0
  41. package/dist/flag-queue.d.ts +175 -0
  42. package/dist/flag-queue.js +291 -0
  43. package/dist/folder-operations.d.ts +39 -0
  44. package/dist/folder-operations.js +112 -0
  45. package/dist/folder-placement.d.ts +13 -0
  46. package/dist/folder-placement.js +23 -0
  47. package/dist/heuristics/authenticationResults.d.ts +10 -0
  48. package/dist/heuristics/authenticationResults.js +187 -0
  49. package/dist/heuristics/classifyByHeaders.d.ts +82 -0
  50. package/dist/heuristics/classifyByHeaders.js +365 -0
  51. package/dist/heuristics/classifyPlacement.d.ts +67 -0
  52. package/dist/heuristics/classifyPlacement.js +153 -0
  53. package/dist/heuristics/machineSenders.d.ts +21 -0
  54. package/{src/heuristics/machineSenders.ts → dist/heuristics/machineSenders.js} +34 -40
  55. package/dist/heuristics/senderMismatch.d.ts +81 -0
  56. package/dist/heuristics/senderMismatch.js +192 -0
  57. package/dist/heuristics/socialDomains.d.ts +14 -0
  58. package/{src/heuristics/socialDomains.ts → dist/heuristics/socialDomains.js} +9 -9
  59. package/dist/heuristics/transactionalDomains.d.ts +18 -0
  60. package/{src/heuristics/transactionalDomains.ts → dist/heuristics/transactionalDomains.js} +8 -8
  61. package/dist/imapflow-connection.d.ts +377 -0
  62. package/dist/imapflow-connection.js +1147 -0
  63. package/dist/index.d.ts +63 -0
  64. package/dist/index.js +65 -0
  65. package/dist/list-id-backfill.d.ts +83 -0
  66. package/dist/list-id-backfill.js +132 -0
  67. package/dist/mailbox-cursor-rebuild.d.ts +74 -0
  68. package/dist/mailbox-cursor-rebuild.js +71 -0
  69. package/{src/mailbox-cursor.ts → dist/mailbox-cursor.d.ts} +20 -98
  70. package/dist/mailbox-cursor.js +102 -0
  71. package/dist/mailbox-intent.d.ts +41 -0
  72. package/{src/mailbox-intent.ts → dist/mailbox-intent.js} +38 -64
  73. package/dist/mailbox-management.d.ts +240 -0
  74. package/dist/mailbox-management.js +576 -0
  75. package/dist/mailbox-presence.d.ts +52 -0
  76. package/{src/mailbox-presence.ts → dist/mailbox-presence.js} +19 -30
  77. package/dist/mailbox-queue.d.ts +129 -0
  78. package/dist/mailbox-queue.js +216 -0
  79. package/dist/mailbox-sync.d.ts +93 -0
  80. package/dist/mailbox-sync.js +490 -0
  81. package/dist/mailbox-upstream.d.ts +38 -0
  82. package/{src/mailbox-upstream.ts → dist/mailbox-upstream.js} +37 -47
  83. package/dist/message-category.d.ts +51 -0
  84. package/{src/message-category.ts → dist/message-category.js} +28 -71
  85. package/dist/message-move.d.ts +285 -0
  86. package/dist/message-move.js +858 -0
  87. package/dist/message-parser.d.ts +14 -0
  88. package/dist/message-parser.js +17 -0
  89. package/{src/message-presence.ts → dist/message-presence.d.ts} +1 -13
  90. package/dist/message-presence.js +29 -0
  91. package/dist/message-read.d.ts +51 -0
  92. package/dist/message-read.js +31 -0
  93. package/dist/message-sync.d.ts +345 -0
  94. package/dist/message-sync.js +1358 -0
  95. package/dist/mime-walker.d.ts +102 -0
  96. package/dist/mime-walker.js +198 -0
  97. package/dist/organize-job.d.ts +20 -0
  98. package/dist/organize-job.js +37 -0
  99. package/dist/outbox-attachment-content.d.ts +37 -0
  100. package/dist/outbox-attachment-content.js +50 -0
  101. package/dist/outbox-attachment-filename.d.ts +19 -0
  102. package/dist/outbox-attachment-filename.js +64 -0
  103. package/dist/outbox-attachment.d.ts +148 -0
  104. package/dist/outbox-attachment.js +273 -0
  105. package/dist/outbox-queue.d.ts +73 -0
  106. package/dist/outbox-queue.js +280 -0
  107. package/{src/outbox-status.ts → dist/outbox-status.d.ts} +1 -6
  108. package/dist/outbox-status.js +18 -0
  109. package/dist/ownership.d.ts +24 -0
  110. package/dist/ownership.js +83 -0
  111. package/dist/placement-move-terminal.d.ts +67 -0
  112. package/dist/placement-move-terminal.js +88 -0
  113. package/dist/placement-move.d.ts +83 -0
  114. package/dist/placement-move.js +216 -0
  115. package/{src/placement-settled.ts → dist/placement-settled.d.ts} +13 -68
  116. package/dist/placement-settled.js +75 -0
  117. package/dist/quarantine.d.ts +95 -0
  118. package/dist/quarantine.js +131 -0
  119. package/dist/refusal.d.ts +31 -0
  120. package/dist/refusal.js +3 -0
  121. package/{src/restore-source-placement.ts → dist/restore-source-placement.d.ts} +29 -97
  122. package/dist/restore-source-placement.js +79 -0
  123. package/dist/search-text-backfill.d.ts +15 -0
  124. package/dist/search-text-backfill.js +33 -0
  125. package/dist/snippet.d.ts +61 -0
  126. package/dist/snippet.js +129 -0
  127. package/dist/spam-report.d.ts +86 -0
  128. package/dist/spam-report.js +241 -0
  129. package/dist/sync-warning.d.ts +21 -0
  130. package/dist/sync-warning.js +26 -0
  131. package/dist/sync-watermarks.d.ts +138 -0
  132. package/dist/sync-watermarks.js +205 -0
  133. package/dist/test-helpers/fake-imap.d.ts +151 -0
  134. package/dist/test-helpers/fake-imap.js +508 -0
  135. package/dist/test-helpers/folder-roles.d.ts +34 -0
  136. package/dist/test-helpers/folder-roles.js +47 -0
  137. package/dist/test-helpers/mime-tree-generator.d.ts +82 -0
  138. package/dist/test-helpers/mime-tree-generator.js +329 -0
  139. package/dist/test-helpers/test-store.d.ts +69 -0
  140. package/dist/test-helpers/test-store.js +193 -0
  141. package/dist/text/normalizer.d.ts +20 -0
  142. package/dist/text/normalizer.js +102 -0
  143. package/dist/thread-message-rows.d.ts +69 -0
  144. package/dist/thread-message-rows.js +40 -0
  145. package/dist/thread-root.d.ts +7 -0
  146. package/dist/thread-root.js +25 -0
  147. package/dist/types.d.ts +343 -0
  148. package/dist/types.js +19 -0
  149. package/package.json +86 -88
  150. package/src/account-credentials.ts +0 -210
  151. package/src/attribute-mapper.test.ts +0 -104
  152. package/src/attribute-mapper.ts +0 -148
  153. package/src/body-parse.test.ts +0 -55
  154. package/src/body-part-mapper.property.test.ts +0 -354
  155. package/src/body-part-mapper.ts +0 -410
  156. package/src/body-sync-queue.test.ts +0 -64
  157. package/src/body-sync-queue.ts +0 -131
  158. package/src/body-sync-terminal.test.ts +0 -148
  159. package/src/body-sync-terminal.ts +0 -174
  160. package/src/body-sync.test.ts +0 -925
  161. package/src/body-sync.ts +0 -1891
  162. package/src/calendar-parts.ts +0 -41
  163. package/src/classification-backfill.test.ts +0 -285
  164. package/src/classification-backfill.ts +0 -363
  165. package/src/classify-message.test.ts +0 -142
  166. package/src/classify-message.ts +0 -116
  167. package/src/connection-factory.ts +0 -102
  168. package/src/connection-test.ts +0 -208
  169. package/src/credentials.test.ts +0 -181
  170. package/src/external-move.test.ts +0 -262
  171. package/src/external-move.ts +0 -285
  172. package/src/filter-operations.test.ts +0 -319
  173. package/src/filter-operations.ts +0 -377
  174. package/src/filter-update.test.ts +0 -313
  175. package/src/filters/filter-config.test.ts +0 -87
  176. package/src/filters/filter-config.ts +0 -34
  177. package/src/filters/list-id.test.ts +0 -50
  178. package/src/filters/match.test.ts +0 -392
  179. package/src/filters/match.ts +0 -225
  180. package/src/filters/pipeline.test.ts +0 -199
  181. package/src/filters/pipeline.ts +0 -170
  182. package/src/flag-push.test.ts +0 -112
  183. package/src/flag-push.ts +0 -198
  184. package/src/flag-queue.test.ts +0 -197
  185. package/src/flag-queue.ts +0 -509
  186. package/src/folder-operations.test.ts +0 -273
  187. package/src/folder-operations.ts +0 -217
  188. package/src/folder-placement.ts +0 -56
  189. package/src/forwarded-message.test.ts +0 -122
  190. package/src/heuristics/authenticationResults.test.ts +0 -189
  191. package/src/heuristics/authenticationResults.ts +0 -212
  192. package/src/heuristics/classifyByHeaders.test.ts +0 -889
  193. package/src/heuristics/classifyByHeaders.ts +0 -467
  194. package/src/heuristics/classifyPlacement.test.ts +0 -366
  195. package/src/heuristics/classifyPlacement.ts +0 -211
  196. package/src/heuristics/classifyRealMail.test.ts +0 -242
  197. package/src/heuristics/machineSenders.test.ts +0 -101
  198. package/src/heuristics/senderMismatch.test.ts +0 -346
  199. package/src/heuristics/senderMismatch.ts +0 -259
  200. package/src/imapflow-connect-retry.test.ts +0 -97
  201. package/src/imapflow-connection.test.ts +0 -503
  202. package/src/imapflow-connection.ts +0 -1476
  203. package/src/index.ts +0 -397
  204. package/src/list-id-backfill.test.ts +0 -207
  205. package/src/list-id-backfill.ts +0 -274
  206. package/src/mailbox-cursor-rebuild.test.ts +0 -171
  207. package/src/mailbox-cursor-rebuild.ts +0 -146
  208. package/src/mailbox-cursor.test.ts +0 -141
  209. package/src/mailbox-delete-intent.test.ts +0 -119
  210. package/src/mailbox-management.test.ts +0 -243
  211. package/src/mailbox-management.ts +0 -838
  212. package/src/mailbox-presence.test.ts +0 -74
  213. package/src/mailbox-queue.ts +0 -397
  214. package/src/mailbox-rename-intent.test.ts +0 -220
  215. package/src/mailbox-rename-subtree.test.ts +0 -287
  216. package/src/mailbox-sync.test.ts +0 -286
  217. package/src/mailbox-sync.ts +0 -724
  218. package/src/message-move.test.ts +0 -726
  219. package/src/message-move.ts +0 -1518
  220. package/src/message-parser.ts +0 -26
  221. package/src/message-presence.test.ts +0 -50
  222. package/src/message-read.ts +0 -87
  223. package/src/message-save-retry.test.ts +0 -90
  224. package/src/message-sync-flags.test.ts +0 -167
  225. package/src/message-sync.test.ts +0 -762
  226. package/src/message-sync.ts +0 -2133
  227. package/src/mime-walker.test.ts +0 -311
  228. package/src/mime-walker.ts +0 -306
  229. package/src/organize-job.ts +0 -93
  230. package/src/outbox-attachment-content.test.ts +0 -153
  231. package/src/outbox-attachment-content.ts +0 -104
  232. package/src/outbox-attachment-filename.test.ts +0 -132
  233. package/src/outbox-attachment-filename.ts +0 -76
  234. package/src/outbox-attachment.test.ts +0 -626
  235. package/src/outbox-attachment.ts +0 -536
  236. package/src/outbox-failed-recovery.test.ts +0 -299
  237. package/src/outbox-queue.test.ts +0 -315
  238. package/src/outbox-queue.ts +0 -525
  239. package/src/ownership.ts +0 -140
  240. package/src/placement-move-terminal.ts +0 -145
  241. package/src/placement-move.ts +0 -363
  242. package/src/placement-settled.test.ts +0 -147
  243. package/src/placement.test.ts +0 -404
  244. package/src/quarantine.test.ts +0 -133
  245. package/src/quarantine.ts +0 -229
  246. package/src/refusal.ts +0 -29
  247. package/src/snippet.test.ts +0 -213
  248. package/src/snippet.ts +0 -152
  249. package/src/spam-report.test.ts +0 -329
  250. package/src/spam-report.ts +0 -357
  251. package/src/sync-warning.test.ts +0 -213
  252. package/src/sync-warning.ts +0 -56
  253. package/src/sync-watermarks.test.ts +0 -409
  254. package/src/sync-watermarks.ts +0 -319
  255. package/src/system-flag-wire-format.test.ts +0 -77
  256. package/src/test-helpers/fake-imap.ts +0 -690
  257. package/src/test-helpers/folder-roles.ts +0 -66
  258. package/src/test-helpers/mime-tree-generator.ts +0 -461
  259. package/src/test-helpers/test-queue.ts +0 -56
  260. package/src/test-helpers/test-store.ts +0 -299
  261. package/src/text/normalizer.test.ts +0 -223
  262. package/src/text/normalizer.ts +0 -140
  263. package/src/thread-message-rows.ts +0 -77
  264. package/src/thread-root.test.ts +0 -29
  265. package/src/thread-root.ts +0 -51
  266. package/src/types/mailparser-augment.d.ts +0 -23
  267. package/src/types/natural-porter-stemmer.d.ts +0 -50
  268. package/src/types/stopword.d.ts +0 -69
  269. package/src/types.ts +0 -371
  270. package/tsconfig.json +0 -8
@@ -1,77 +0,0 @@
1
- import type { ThreadMessageItem } from "@remit/data-ports";
2
-
3
- /**
4
- * Build the `set` and `composites` payload for the ThreadMessage update on a
5
- * MESSAGE_DELETE move-to-trash.
6
- *
7
- * The CURRENT row state goes in `composites`; the NEW values go in `set`.
8
- * ElectroDB uses `composites` to run the conditional check on the existing row
9
- * AND to compute the previous sort-key values needed to recompute the new ones.
10
- * Passing the NEW values in `composites` makes the conditional check fail with
11
- * ConditionalCheckFailedException, which ElectroDB wraps as NotFoundError, and
12
- * the caller silently drops the update. Same root cause as PR #186 fixed for
13
- * `flag-queue.ts`.
14
- */
15
- export type ThreadMessageRowState = Pick<
16
- ThreadMessageItem,
17
- | "sentDate"
18
- | "mailboxId"
19
- | "isRead"
20
- | "isDeleted"
21
- | "hasStars"
22
- | "hasAttachment"
23
- >;
24
-
25
- const currentComposites = (threadMessage: ThreadMessageRowState) => ({
26
- sentDate: threadMessage.sentDate,
27
- mailboxId: threadMessage.mailboxId,
28
- isRead: threadMessage.isRead,
29
- isDeleted: threadMessage.isDeleted,
30
- hasStars: threadMessage.hasStars,
31
- hasAttachment: threadMessage.hasAttachment,
32
- });
33
-
34
- export const buildThreadMessageTrashUpdate = (
35
- threadMessage: ThreadMessageRowState,
36
- newUid: number,
37
- destinationMailboxId: string,
38
- ) => ({
39
- set: {
40
- uid: newUid,
41
- mailboxId: destinationMailboxId,
42
- isDeleted: true,
43
- },
44
- composites: currentComposites(threadMessage),
45
- });
46
-
47
- /**
48
- * The inverse payload: put the thread row back where the message still is on
49
- * the server. The delete was recorded optimistically, so a delete that gives up
50
- * with the message still at its source has to hand the row back rather than
51
- * leave it claiming Trash — an invisible `failed` on a row the user cannot see
52
- * is the shape of the incident this whole change is about.
53
- */
54
- export const buildThreadMessageMoveRevert = (
55
- threadMessage: ThreadMessageRowState,
56
- sourceUid: number,
57
- sourceMailboxId: string,
58
- ) => ({
59
- set: {
60
- uid: sourceUid,
61
- mailboxId: sourceMailboxId,
62
- isDeleted: false,
63
- },
64
- composites: currentComposites(threadMessage),
65
- });
66
-
67
- /**
68
- * Hand a row back after an abandoned expunge. The mail never left Trash, so
69
- * only the deletion mark reverts — the uid and mailbox on the row are still
70
- * where the server has it.
71
- */
72
- export const buildThreadMessageUndelete = (
73
- threadMessage: ThreadMessageRowState,
74
- ) => ({
75
- set: { isDeleted: false },
76
- composites: currentComposites(threadMessage),
77
- });
@@ -1,29 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { describe, it } from "node:test";
3
- import { threadRootOf } from "./thread-root.js";
4
-
5
- const headers = (inReplyTo = "") => ({
6
- messageId: "<self@example.com>",
7
- inReplyTo,
8
- });
9
-
10
- describe("threadRootOf", () => {
11
- it("reads a doubled References root in its wire spelling", () => {
12
- assert.equal(
13
- threadRootOf(headers("<p@example.com>"), ["<<root@example.com>>"], "m"),
14
- "<root@example.com>",
15
- );
16
- });
17
-
18
- it("falls back to a doubled In-Reply-To, then to the message itself", () => {
19
- assert.equal(
20
- threadRootOf(headers("<<p@example.com>>"), undefined, "m"),
21
- "<p@example.com>",
22
- );
23
- assert.equal(threadRootOf(headers(), undefined, "m"), "<self@example.com>");
24
- assert.equal(
25
- threadRootOf({ messageId: "<>", inReplyTo: "" }, [], "m"),
26
- "m",
27
- );
28
- });
29
- });
@@ -1,51 +0,0 @@
1
- import type { MessageReferenceInput } from "@remit/data-ports";
2
- import {
3
- bareMessageId,
4
- isValidMessageId,
5
- wireMessageId,
6
- } from "@remit/data-ports/id";
7
- import { ReferenceType } from "@remit/domain-enums";
8
- import type { ImapEnvelope } from "./types.js";
9
-
10
- type ThreadingHeaders = Pick<ImapEnvelope, "messageId" | "inReplyTo">;
11
-
12
- const firstUsable = (
13
- candidates: readonly (string | undefined)[],
14
- ): string | undefined => {
15
- const found = candidates.find(isValidMessageId);
16
- return found === undefined ? undefined : wireMessageId(found);
17
- };
18
-
19
- export const threadRootOf = (
20
- envelope: ThreadingHeaders,
21
- references: readonly string[] | undefined,
22
- messageId: string,
23
- ): string =>
24
- firstUsable([references?.[0], envelope.inReplyTo, envelope.messageId]) ??
25
- messageId;
26
-
27
- export const parentOf = (
28
- envelope: ThreadingHeaders,
29
- references: readonly string[] | undefined,
30
- ): string | undefined =>
31
- firstUsable([envelope.inReplyTo, references?.[references.length - 1]]);
32
-
33
- export const messageReferencesOf = (
34
- envelope: ThreadingHeaders,
35
- references: readonly string[] | undefined,
36
- ): MessageReferenceInput[] => [
37
- ...(isValidMessageId(envelope.inReplyTo)
38
- ? [
39
- {
40
- messageIdValue: bareMessageId(envelope.inReplyTo),
41
- referenceType: ReferenceType.InReplyTo,
42
- referenceOrder: 0,
43
- },
44
- ]
45
- : []),
46
- ...(references ?? []).filter(isValidMessageId).map((reference, index) => ({
47
- messageIdValue: bareMessageId(reference),
48
- referenceType: ReferenceType.References,
49
- referenceOrder: index,
50
- })),
51
- ];
@@ -1,23 +0,0 @@
1
- /**
2
- * `mailparser`'s `simpleParser` populates `partId` on every entry in
3
- * `parsed.attachments[]` at runtime (set inside `mail-parser.js:860`), but
4
- * the field is missing from `@types/mailparser`. Format is the IMAP
5
- * dot-numbered path (`"1"`, `"2.2.2"`, `"3"`) — the same shape mime-walker
6
- * writes to `BodyPart.partPath`. The body-part mapper uses it as the
7
- * primary structural pairing signal.
8
- */
9
- declare module "mailparser" {
10
- interface Attachment {
11
- partId?: string;
12
- }
13
- /**
14
- * Not a mailparser option: mailparser hands its options to its MIME
15
- * splitter, mailsplit, whose `ignoreEmbedded` keeps a message/rfc822 part
16
- * one leaf.
17
- */
18
- interface MailParserOptions {
19
- ignoreEmbedded?: boolean;
20
- }
21
- }
22
-
23
- export {};
@@ -1,50 +0,0 @@
1
- // `natural` ships no per-file type declarations for its stemmer submodules —
2
- // only the package-root barrel (`natural/lib/natural/index.d.ts`) and the
3
- // `stemmers` submodule barrel (`natural/lib/natural/stemmers/index.d.ts`) are
4
- // typed. Both barrels are CommonJS, so importing either unconditionally
5
- // requires every stemmer they list — including Japanese (`stemmer_ja.js`,
6
- // which pulls in its own `tokenizer_ja.js`) and Indonesian
7
- // (`indonesian/stemmer_id.js`) — even when unused. Importing each Porter
8
- // stemmer file this module actually uses, directly, avoids that; these
9
- // ambient declarations cover the resulting import paths. Referenced via a
10
- // triple-slash directive from normalizer.ts so tsc includes it in any
11
- // program that type-checks normalizer.ts, even a consuming package's (whose
12
- // own tsconfig `include` doesn't reach into this package's src/types).
13
- interface NaturalStemmer {
14
- stem: (token: string) => string;
15
- }
16
-
17
- declare module "natural/lib/natural/stemmers/porter_stemmer.js" {
18
- const stemmer: NaturalStemmer;
19
- export default stemmer;
20
- }
21
-
22
- declare module "natural/lib/natural/stemmers/porter_stemmer_de.js" {
23
- const stemmer: NaturalStemmer;
24
- export default stemmer;
25
- }
26
-
27
- declare module "natural/lib/natural/stemmers/porter_stemmer_es.js" {
28
- const stemmer: NaturalStemmer;
29
- export default stemmer;
30
- }
31
-
32
- declare module "natural/lib/natural/stemmers/porter_stemmer_fr.js" {
33
- const stemmer: NaturalStemmer;
34
- export default stemmer;
35
- }
36
-
37
- declare module "natural/lib/natural/stemmers/porter_stemmer_it.js" {
38
- const stemmer: NaturalStemmer;
39
- export default stemmer;
40
- }
41
-
42
- declare module "natural/lib/natural/stemmers/porter_stemmer_nl.js" {
43
- const stemmer: NaturalStemmer;
44
- export default stemmer;
45
- }
46
-
47
- declare module "natural/lib/natural/stemmers/porter_stemmer_pt.js" {
48
- const stemmer: NaturalStemmer;
49
- export default stemmer;
50
- }
@@ -1,69 +0,0 @@
1
- declare module "stopword" {
2
- export function removeStopwords(
3
- words: string[],
4
- stopwords?: string[],
5
- ): string[];
6
-
7
- export const afr: string[];
8
- export const ara: string[];
9
- export const ben: string[];
10
- export const bre: string[];
11
- export const bul: string[];
12
- export const cat: string[];
13
- export const ces: string[];
14
- export const dan: string[];
15
- export const deu: string[];
16
- export const ell: string[];
17
- export const eng: string[];
18
- export const epo: string[];
19
- export const est: string[];
20
- export const eus: string[];
21
- export const fas: string[];
22
- export const fin: string[];
23
- export const fra: string[];
24
- export const glg: string[];
25
- export const guj: string[];
26
- export const hau: string[];
27
- export const heb: string[];
28
- export const hin: string[];
29
- export const hrv: string[];
30
- export const hun: string[];
31
- export const hye: string[];
32
- export const ind: string[];
33
- export const ita: string[];
34
- export const jpn: string[];
35
- export const kor: string[];
36
- export const kur: string[];
37
- export const lat: string[];
38
- export const lav: string[];
39
- export const lit: string[];
40
- export const lgg: string[];
41
- export const lggNd: string[];
42
- export const mar: string[];
43
- export const msa: string[];
44
- export const mya: string[];
45
- export const nld: string[];
46
- export const nob: string[];
47
- export const pan: string[];
48
- export const pol: string[];
49
- export const por: string[];
50
- export const porBr: string[];
51
- export const ron: string[];
52
- export const rus: string[];
53
- export const slk: string[];
54
- export const slv: string[];
55
- export const som: string[];
56
- export const sot: string[];
57
- export const spa: string[];
58
- export const swa: string[];
59
- export const swe: string[];
60
- export const tgl: string[];
61
- export const tha: string[];
62
- export const tur: string[];
63
- export const ukr: string[];
64
- export const urd: string[];
65
- export const vie: string[];
66
- export const yor: string[];
67
- export const zho: string[];
68
- export const zul: string[];
69
- }
package/src/types.ts DELETED
@@ -1,371 +0,0 @@
1
- /**
2
- * Types for the remit-mailbox-service
3
- */
4
-
5
- import type { Readable } from "node:stream";
6
-
7
- /**
8
- * Discriminated union of mail authentication credentials.
9
- *
10
- * Exactly one credential kind can be present at a time — the union makes
11
- * "both password and accessToken simultaneously" unrepresentable.
12
- */
13
- export type MailCredentials =
14
- | { kind: "password"; password: string }
15
- | { kind: "accessToken"; accessToken: string };
16
-
17
- /**
18
- * Classification of mail connection errors.
19
- */
20
- export type MailConnectionErrorKind = "auth" | "network";
21
-
22
- /**
23
- * Typed error for IMAP/SMTP connection failures.
24
- *
25
- * `kind: "auth"` — authentication rejected (bad credentials / token expired).
26
- * `kind: "network"` — transport-level failure (ECONNREFUSED, ETIMEDOUT, etc.).
27
- *
28
- * IMPORTANT: access tokens must NEVER appear in error messages or causes.
29
- */
30
- export class MailConnectionError extends Error {
31
- readonly kind: MailConnectionErrorKind;
32
-
33
- constructor(kind: MailConnectionErrorKind, message: string, cause?: unknown) {
34
- super(message, { cause });
35
- this.name = "MailConnectionError";
36
- this.kind = kind;
37
- }
38
- }
39
-
40
- /**
41
- * IMAP connection configuration
42
- */
43
- export interface ImapConnectionConfig {
44
- host: string;
45
- port: number;
46
- user: string;
47
- credentials: MailCredentials;
48
- tls: boolean;
49
- tlsOptions?: {
50
- rejectUnauthorized?: boolean;
51
- servername?: string;
52
- };
53
- /** Connection timeout in milliseconds */
54
- connTimeout?: number;
55
- /** Authentication timeout in milliseconds */
56
- authTimeout?: number;
57
- }
58
-
59
- /**
60
- * IMAP connection state
61
- */
62
- export type ImapConnectionState =
63
- | "disconnected"
64
- | "connecting"
65
- | "connected"
66
- | "authenticated"
67
- | "error";
68
-
69
- /**
70
- * Namespace structure from IMAP NAMESPACE command
71
- */
72
- export interface ImapNamespace {
73
- prefix: string;
74
- delimiter: string | false;
75
- extensions?: Array<{
76
- name: string;
77
- params: string[] | null;
78
- }>;
79
- }
80
-
81
- /**
82
- * IMAP namespaces grouped by type
83
- */
84
- export interface ImapNamespaces {
85
- personal: ImapNamespace[];
86
- other: ImapNamespace[];
87
- shared: ImapNamespace[];
88
- }
89
-
90
- /**
91
- * IMAP mailbox status after opening
92
- */
93
- export interface ImapBoxStatus {
94
- name: string;
95
- readOnly: boolean;
96
- uidvalidity: number;
97
- uidnext: number;
98
- flags: string[];
99
- permFlags: string[];
100
- persistentUIDs: boolean;
101
- messages: {
102
- total: number;
103
- new: number;
104
- };
105
- newKeywords: boolean;
106
- }
107
-
108
- /**
109
- * IMAP mailbox status from STATUS command
110
- */
111
- export interface ImapMailboxStatus {
112
- messages: number;
113
- recent: number;
114
- unseen: number;
115
- uidNext: number;
116
- uidValidity: number;
117
- /** Highest modification sequence (CONDSTORE) as decimal digits of an unsigned 64-bit value. "0" if the server does not support CONDSTORE. */
118
- highestModseq: string;
119
- /** Count of messages flagged \Deleted but not yet expunged. */
120
- deletedCount: number;
121
- }
122
-
123
- /**
124
- * Flattened mailbox info for processing
125
- */
126
- export interface FlatMailboxInfo {
127
- fullPath: string;
128
- name: string;
129
- delimiter: string;
130
- attributes: string[];
131
- parentPath: string | null;
132
- }
133
-
134
- export interface ImapAddress {
135
- name?: string;
136
- mailbox: string;
137
- host: string;
138
- }
139
-
140
- export interface ImapEnvelope {
141
- date: string;
142
- subject: string;
143
- from: ImapAddress[];
144
- sender: ImapAddress[];
145
- replyTo: ImapAddress[];
146
- to: ImapAddress[];
147
- cc: ImapAddress[];
148
- bcc: ImapAddress[];
149
- inReplyTo: string;
150
- messageId: string;
151
- }
152
-
153
- /**
154
- * Subset of imapflow's `MessageStructureObject` we depend on. Restated
155
- * here so non-imapflow code (and tests) can build fixtures without pulling
156
- * the imapflow types in.
157
- */
158
- export interface ImapBodyStructure {
159
- /** Dot-numbered MIME path; absent on the root node. */
160
- part?: string;
161
- /** Full Content-Type, e.g. "text/plain" or "multipart/mixed". */
162
- type: string;
163
- parameters?: Record<string, string>;
164
- id?: string;
165
- description?: string;
166
- encoding?: string;
167
- size?: number;
168
- lineCount?: number;
169
- md5?: string;
170
- disposition?: string;
171
- dispositionParameters?: Record<string, string>;
172
- language?: string[];
173
- location?: string;
174
- childNodes?: ImapBodyStructure[];
175
- }
176
-
177
- /**
178
- * One server message from the cheap envelope-only FETCH the UIDVALIDITY
179
- * cursor rebuild uses (#1272): UID + Message-ID + INTERNALDATE, nothing
180
- * else — no flags, no BODYSTRUCTURE, no body fetch.
181
- */
182
- export interface ImapEnvelopeSnapshot {
183
- uid: number;
184
- /** Raw RFC 822 Message-ID header; empty string when absent/unparseable. */
185
- messageId: string;
186
- internalDate: Date;
187
- }
188
-
189
- export interface ImapMessage {
190
- uid: number;
191
- seq: number;
192
- flags: string[];
193
- internalDate: Date;
194
- size: number;
195
- envelope?: ImapEnvelope;
196
- /**
197
- * References header from RFC 2822.
198
- * Contains Message-IDs of ancestor messages, with the first being the thread root.
199
- */
200
- references?: string[];
201
- /** Parsed BODYSTRUCTURE tree (RFC 9051 Section 7.5.2). */
202
- bodyStructure?: ImapBodyStructure;
203
- /**
204
- * Per-message MODSEQ (RFC 7162) as decimal digits of an unsigned 64-bit
205
- * value. Absent when the session has no CONDSTORE.
206
- */
207
- modseq?: string;
208
- }
209
-
210
- /**
211
- * Result of a mailbox sync operation
212
- */
213
- export interface MailboxSyncResult {
214
- created: number;
215
- updated: number;
216
- deleted: number;
217
- }
218
-
219
- /**
220
- * Common interface for IMAP connections
221
- */
222
- export interface IImapConnection {
223
- readonly state: ImapConnectionState;
224
- readonly isConnected: boolean;
225
- connect(): Promise<void>;
226
- disconnect(): Promise<void>;
227
- getNamespaces(): Promise<ImapNamespaces>;
228
- listMailboxes(nsPrefix?: string): Promise<FlatMailboxInfo[]>;
229
- openBox(mailboxPath: string, readOnly?: boolean): Promise<ImapBoxStatus>;
230
- closeBox(expunge?: boolean): Promise<void>;
231
- search(criteria: unknown[]): Promise<number[]>;
232
- fetchMessages(uids: number[]): Promise<ImapMessage[]>;
233
- /**
234
- * True when the session negotiated CONDSTORE (RFC 7162) AND the currently
235
- * open mailbox keeps persistent mod-sequences. A mailbox that answered
236
- * NOMODSEQ on SELECT reports false, as does any server that never
237
- * advertised the extension. Requires a mailbox to be open.
238
- */
239
- supportsCondstore(): boolean;
240
- /**
241
- * FETCH every message in the open mailbox whose MODSEQ is strictly greater
242
- * than `sinceModseq` (RFC 7162 CHANGEDSINCE) — both messages that arrived
243
- * and messages whose metadata changed. Requires a mailbox to be open.
244
- *
245
- * Throws when CONDSTORE is unavailable: the underlying client drops the
246
- * modifier in that case, which would silently turn the call into a fetch of
247
- * the entire mailbox.
248
- */
249
- fetchMessagesChangedSince(sinceModseq: bigint): Promise<ImapMessage[]>;
250
- /**
251
- * Cheap envelope-only pass for the UIDVALIDITY cursor rebuild (#1272): UID
252
- * + Message-ID + INTERNALDATE for every UID, no BODYSTRUCTURE, no flags,
253
- * no body. Requires a mailbox to be open.
254
- */
255
- fetchEnvelopeSnapshots(uids: number[]): Promise<ImapEnvelopeSnapshot[]>;
256
- fetchMessageBody(uid: number): Promise<Buffer | null>;
257
- /**
258
- * Fetch full message bodies for many UIDs in ONE pipelined ranged UID FETCH.
259
- * Yields `{ uid, source }` per message; `source` is a readable stream the
260
- * caller must consume before requesting the next item. Requires a mailbox to
261
- * be open (one SELECT for the whole batch).
262
- */
263
- fetchMessageBodies(
264
- uids: number[],
265
- ): AsyncGenerator<{ uid: number; source: Readable }>;
266
- /**
267
- * Add flags to messages by UID.
268
- * Requires mailbox to be open.
269
- */
270
- addFlags(uids: number[], flags: string[]): Promise<void>;
271
- /**
272
- * Remove flags from messages by UID.
273
- * Requires mailbox to be open.
274
- */
275
- removeFlags(uids: number[], flags: string[]): Promise<void>;
276
- /**
277
- * Replace all flags on messages by UID.
278
- * Requires mailbox to be open.
279
- */
280
- setFlags(uids: number[], flags: string[]): Promise<void>;
281
- /**
282
- * Create a new mailbox.
283
- */
284
- createMailbox(path: string): Promise<{ path: string; created: boolean }>;
285
- /**
286
- * Delete a mailbox.
287
- */
288
- deleteMailbox(path: string): Promise<{ path: string }>;
289
- /**
290
- * Rename a mailbox.
291
- */
292
- renameMailbox(
293
- oldPath: string,
294
- newPath: string,
295
- ): Promise<{ path: string; newPath: string }>;
296
- /**
297
- * Subscribe to a mailbox.
298
- */
299
- subscribeMailbox(path: string): Promise<void>;
300
- /**
301
- * Unsubscribe from a mailbox.
302
- */
303
- unsubscribeMailbox(path: string): Promise<void>;
304
- /**
305
- * Move messages to another mailbox.
306
- * Returns mapping of source UIDs to destination UIDs.
307
- * Requires mailbox to be open.
308
- *
309
- * @param uids - Array of message UIDs to move
310
- * @param destination - Destination mailbox path
311
- * @returns Object with destination path, uidValidity, and uidMap
312
- */
313
- moveMessages(
314
- uids: number[],
315
- destination: string,
316
- ): Promise<{
317
- destination: string;
318
- uidValidity: number;
319
- uidMap: Map<number, number>;
320
- }>;
321
- /**
322
- * Copy messages to another mailbox.
323
- * Returns mapping of source UIDs to destination UIDs.
324
- * Requires mailbox to be open.
325
- *
326
- * @param uids - Array of message UIDs to copy
327
- * @param destination - Destination mailbox path
328
- * @returns Object with destination path, uidValidity, and uidMap
329
- */
330
- copyMessages(
331
- uids: number[],
332
- destination: string,
333
- ): Promise<{
334
- destination: string;
335
- uidValidity: number;
336
- uidMap: Map<number, number>;
337
- }>;
338
- /**
339
- * Permanently delete messages (mark \Deleted + expunge).
340
- * Requires mailbox to be open.
341
- *
342
- * @param uids - Array of message UIDs to delete
343
- * @returns Number of messages deleted
344
- */
345
- deleteMessages(uids: number[]): Promise<number>;
346
- /**
347
- * Get mailbox status without opening it.
348
- * Uses IMAP STATUS command to get message counts.
349
- *
350
- * @param mailboxPath - Full path to the mailbox
351
- * @returns Mailbox status including unseen count
352
- */
353
- getMailboxStatus(mailboxPath: string): Promise<ImapMailboxStatus>;
354
- /**
355
- * Append a message to a mailbox via IMAP APPEND command.
356
- *
357
- * @param mailbox - Full path of the target mailbox
358
- * @param message - RFC 822 message content
359
- * @param flags - Optional flags to set on the message
360
- * @returns Object with destination path, uidValidity, and uid of the appended message
361
- */
362
- append(
363
- mailbox: string,
364
- message: string | Buffer,
365
- flags?: string[],
366
- ): Promise<{
367
- destination: string;
368
- uidValidity: number;
369
- uid: number;
370
- }>;
371
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src"
6
- },
7
- "include": ["src/**/*.ts"]
8
- }