@remit/imap-worker 0.0.87 → 0.0.88

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/imap-worker",
3
- "version": "0.0.87",
3
+ "version": "0.0.88",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -8,15 +8,11 @@ import {
8
8
  MailboxCursorState,
9
9
  } from "@remit/domain-enums";
10
10
  import {
11
- AccountRepo,
12
- AddressRepo,
13
- DrizzleEnvelopeRepository,
14
- DrizzleMessageRepository,
15
- DrizzleThreadMessageRepository,
16
- MailboxRepo,
17
- MailboxSpecialUseRepo,
18
- SearchIndex,
19
- SyncWarningRepo,
11
+ createSqliteRepositories,
12
+ type DrizzleMessageRepository,
13
+ type DrizzleThreadMessageRepository,
14
+ type MailboxRepo,
15
+ type SqliteRepositories,
20
16
  } from "@remit/drizzle-service";
21
17
  import { createShippedSqliteDb } from "@remit/drizzle-service/test-sqlite";
22
18
  import {
@@ -81,7 +77,7 @@ const serverWithInbox = (message: ImapMessage): IImapConnection =>
81
77
 
82
78
  describe("the Message-ID the move, delete and copy probes ask with", () => {
83
79
  let close: () => void;
84
- let db: never;
80
+ let repos: SqliteRepositories;
85
81
  let accountId: string;
86
82
  let mailboxes: MailboxRepo;
87
83
  let messages: DrizzleMessageRepository;
@@ -119,12 +115,12 @@ describe("the Message-ID the move, delete and copy probes ask with", () => {
119
115
  await new MessageSyncService(
120
116
  factory,
121
117
  mailboxes,
122
- new MailboxSpecialUseRepo(db, db),
118
+ repos.mailboxSpecialUse,
123
119
  messages,
124
- new DrizzleEnvelopeRepository(db),
125
- new AddressRepo(db),
120
+ repos.envelope,
121
+ repos.address,
126
122
  threadMessages,
127
- new SyncWarningService(new SyncWarningRepo(db)),
123
+ new SyncWarningService(repos.syncWarning),
128
124
  ).syncMessages(inbox.mailboxId, accountId, ACCOUNT_CONFIG_ID);
129
125
  const [synced] = await messages.listAllByMailbox(inbox.mailboxId);
130
126
  if (!synced) throw new Error("sync stored no message");
@@ -137,14 +133,15 @@ describe("the Message-ID the move, delete and copy probes ask with", () => {
137
133
  beforeEach(async () => {
138
134
  const store = createShippedSqliteDb();
139
135
  close = store.close;
140
- db = store.db as never;
141
- mailboxes = new MailboxRepo(db, new SearchIndex(db, db));
142
- messages = new DrizzleMessageRepository(db, new SearchIndex(db, db));
143
- threadMessages = new DrizzleThreadMessageRepository(
144
- db,
145
- new SearchIndex(db, db),
146
- );
147
- const account = await new AccountRepo(db, db).create({
136
+ repos = createSqliteRepositories({
137
+ app: store.db,
138
+ mail: store.db,
139
+ search: store.db,
140
+ });
141
+ mailboxes = repos.mailbox;
142
+ messages = repos.message;
143
+ threadMessages = repos.threadMessage;
144
+ const account = await repos.account.create({
148
145
  accountConfigId: ACCOUNT_CONFIG_ID,
149
146
  username: "person@example.com",
150
147
  email: "person@example.com",
@@ -179,9 +176,9 @@ describe("the Message-ID the move, delete and copy probes ask with", () => {
179
176
  const copyId = await new MessageMoveService({
180
177
  messageService: messages,
181
178
  mailboxService: mailboxes,
182
- mailboxSpecialUseService: new MailboxSpecialUseRepo(db, db),
179
+ mailboxSpecialUseService: repos.mailboxSpecialUse,
183
180
  threadMessageService: threadMessages,
184
- addressService: new AddressRepo(db),
181
+ addressService: repos.address,
185
182
  sqsQueueUrl: "https://queue.test/messages",
186
183
  }).copyMessage(ACCOUNT_CONFIG_ID, sourceId, archive.mailboxId, accountId);
187
184
 
@@ -15,11 +15,11 @@ import {
15
15
  MailboxCursorState,
16
16
  } from "@remit/domain-enums";
17
17
  import {
18
- AccountRepo,
19
- DrizzleMessageRepository,
18
+ type AccountRepo,
19
+ createSqliteRepositories,
20
+ type DrizzleMessageRepository,
20
21
  MailboxLockRepo,
21
- MailboxRepo,
22
- SearchIndex,
22
+ type MailboxRepo,
23
23
  } from "@remit/drizzle-service";
24
24
  import { createShippedSqliteDb } from "@remit/drizzle-service/test-sqlite";
25
25
  import type { Logger } from "@remit/logger";
@@ -53,12 +53,14 @@ let close: () => void;
53
53
  beforeEach(() => {
54
54
  const store = createShippedSqliteDb();
55
55
  close = store.close;
56
- accounts = new AccountRepo(store.db, store.db);
57
- mailboxes = new MailboxRepo(store.db, new SearchIndex(store.db, store.db));
58
- messages = new DrizzleMessageRepository(
59
- store.db as never,
60
- new SearchIndex(store.db as never, store.db as never),
61
- );
56
+ const repos = createSqliteRepositories({
57
+ app: store.db,
58
+ mail: store.db,
59
+ search: store.db,
60
+ });
61
+ accounts = repos.account;
62
+ mailboxes = repos.mailbox;
63
+ messages = repos.message;
62
64
  locks = new MailboxLockRepo(store.db);
63
65
  client = {
64
66
  account: accounts,
@@ -7,7 +7,10 @@ import {
7
7
  AccountService,
8
8
  ConnectionState,
9
9
  } from "@remit/domain-enums";
10
- import { AccountRepo } from "@remit/drizzle-service";
10
+ import {
11
+ type AccountRepo,
12
+ createSqliteRepositories,
13
+ } from "@remit/drizzle-service";
11
14
  import { createShippedSqliteDb } from "@remit/drizzle-service/test-sqlite";
12
15
  import { capturingLogger, type LogLine } from "../test-helpers/test-world.js";
13
16
  import { runSchedulerTick } from "./run-tick.js";
@@ -22,7 +25,11 @@ let close: () => void;
22
25
  beforeEach(() => {
23
26
  const store = createShippedSqliteDb();
24
27
  close = store.close;
25
- accounts = new AccountRepo(store.db, store.db);
28
+ accounts = createSqliteRepositories({
29
+ app: store.db,
30
+ mail: store.db,
31
+ search: store.db,
32
+ }).account;
26
33
  });
27
34
 
28
35
  afterEach(() => close());
@@ -6,14 +6,7 @@ import type {
6
6
  MailboxItem,
7
7
  } from "@remit/data-ports";
8
8
  import { deriveThreadId } from "@remit/data-ports/id";
9
- import {
10
- AddressRepo,
11
- DrizzleEnvelopeRepository,
12
- DrizzleMessageRepository,
13
- DrizzleThreadMessageRepository,
14
- SearchIndex,
15
- SyncWarningRepo,
16
- } from "@remit/drizzle-service";
9
+ import { createSqliteRepositories } from "@remit/drizzle-service";
17
10
  import { createShippedSqliteDb } from "@remit/drizzle-service/test-sqlite";
18
11
  import { MessageSyncService, SyncWarningService } from "@remit/mailbox-service";
19
12
  import type { ImapMessage } from "@remit/mailbox-service/types";
@@ -63,18 +56,16 @@ const syncInOrder = async (
63
56
  messages: ImapMessage[],
64
57
  ): Promise<{ threadIds: (messageId: string) => string[] }> => {
65
58
  const { db, sqlite } = createShippedSqliteDb();
66
- const typed = db as unknown as ConstructorParameters<
67
- typeof DrizzleMessageRepository
68
- >[0];
59
+ const repos = createSqliteRepositories({ app: db, mail: db, search: db });
69
60
  const service = new MessageSyncService(
70
61
  {} as never,
71
62
  {} as IMailboxRepository,
72
63
  {} as IMailboxSpecialUseRepository,
73
- new DrizzleMessageRepository(typed, new SearchIndex(typed, typed)),
74
- new DrizzleEnvelopeRepository(typed),
75
- new AddressRepo(db as never),
76
- new DrizzleThreadMessageRepository(db, new SearchIndex(db, db)),
77
- new SyncWarningService(new SyncWarningRepo(db as never)),
64
+ repos.message,
65
+ repos.envelope,
66
+ repos.address,
67
+ repos.threadMessage,
68
+ new SyncWarningService(repos.syncWarning),
78
69
  );
79
70
  const save = (
80
71
  service as unknown as {
@@ -12,7 +12,10 @@ import assert from "node:assert/strict";
12
12
  import { after, before, describe, it } from "node:test";
13
13
  import type { AccountItem } from "@remit/data-ports";
14
14
  import { AccountAuthType, ConnectionState } from "@remit/domain-enums";
15
- import { AccountRepo } from "@remit/drizzle-service";
15
+ import {
16
+ type AccountRepo,
17
+ createSqliteRepositories,
18
+ } from "@remit/drizzle-service";
16
19
  import { createShippedSqliteDb } from "@remit/drizzle-service/test-sqlite";
17
20
  import { noopLogger } from "@remit/logger";
18
21
  import { RefreshTokenError } from "@remit/mail-oauth-service";
@@ -67,7 +70,11 @@ const account = async (): Promise<AccountItem> =>
67
70
  before(() => {
68
71
  const db = createShippedSqliteDb();
69
72
  close = db.close;
70
- repo = new AccountRepo(db.db, db.db);
73
+ repo = createSqliteRepositories({
74
+ app: db.db,
75
+ mail: db.db,
76
+ search: db.db,
77
+ }).account;
71
78
  });
72
79
 
73
80
  after(() => {