@remit/mailbox-service 0.0.113 → 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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mailbox-queue.d.ts +6 -3
- package/dist/mailbox-queue.js +9 -7
- package/dist/outbox-queue.d.ts +2 -2
- package/dist/outbox-queue.js +1 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { type CursorRebuildMatch, type CursorRebuildMatchResult, type CursorRebu
|
|
|
34
34
|
export { folderInFlight } from "./mailbox-intent.js";
|
|
35
35
|
export { type CreateMailboxInput, type DeleteMailboxInput, type MailboxManagementLogger, MailboxManagementService, type MailboxManagementSyncResult, parseMailboxPath, type RenameMailboxInput, validateMailboxOperation, validateMailboxPath, } from "./mailbox-management.js";
|
|
36
36
|
export { EVERY_MAILBOX_STATE, isFolderMutationInFlight, isMailboxMutationInFlight, } from "./mailbox-presence.js";
|
|
37
|
-
export { type CreateMailboxQueueInput, type MailboxManagementEvent, type MailboxQueueConfig, type MailboxQueueLogger, MailboxQueueService, } from "./mailbox-queue.js";
|
|
37
|
+
export { type CreateMailboxQueueInput, type EnqueueMailboxManagement, fifoMailboxManagement, type MailboxManagementEvent, type MailboxQueueConfig, type MailboxQueueLogger, MailboxQueueService, standardMailboxManagement, } from "./mailbox-queue.js";
|
|
38
38
|
export { MailboxSyncService, type SyncAccountInfo, } from "./mailbox-sync.js";
|
|
39
39
|
export { FolderGoneUpstreamError, FolderRenameSettleError, isMailboxAbsentUpstream, isMailboxPresentUpstream, isMailboxRefusedUpstream, upstreamFailureReason, } from "./mailbox-upstream.js";
|
|
40
40
|
export { denormalizeMessageCategory, type MessageCategoryDenormalizeDeps, type MessageCategoryDenormalizeInput, type MessageCategoryValue, } from "./message-category.js";
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export { matchCursorRebuild, } from "./mailbox-cursor-rebuild.js";
|
|
|
37
37
|
export { folderInFlight } from "./mailbox-intent.js";
|
|
38
38
|
export { MailboxManagementService, parseMailboxPath, validateMailboxOperation, validateMailboxPath, } from "./mailbox-management.js";
|
|
39
39
|
export { EVERY_MAILBOX_STATE, isFolderMutationInFlight, isMailboxMutationInFlight, } from "./mailbox-presence.js";
|
|
40
|
-
export { MailboxQueueService, } from "./mailbox-queue.js";
|
|
40
|
+
export { fifoMailboxManagement, MailboxQueueService, standardMailboxManagement, } from "./mailbox-queue.js";
|
|
41
41
|
export { MailboxSyncService, } from "./mailbox-sync.js";
|
|
42
42
|
export { FolderGoneUpstreamError, FolderRenameSettleError, isMailboxAbsentUpstream, isMailboxPresentUpstream, isMailboxRefusedUpstream, upstreamFailureReason, } from "./mailbox-upstream.js";
|
|
43
43
|
export { denormalizeMessageCategory, } from "./message-category.js";
|
package/dist/mailbox-queue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateMailboxInput, CreateMailboxResult, FifoQueueProducer, IMailboxRepository, MailboxItem } from "@remit/data-ports";
|
|
1
|
+
import type { CreateMailboxInput, CreateMailboxResult, FifoQueueProducer, IMailboxRepository, MailboxItem, QueueProducer } from "@remit/data-ports";
|
|
2
2
|
/**
|
|
3
3
|
* MAILBOX_CREATE event structure (matches remit-imap-worker/events.ts)
|
|
4
4
|
*/
|
|
@@ -42,6 +42,9 @@ export interface MailboxQueueLogger {
|
|
|
42
42
|
info(obj: Record<string, unknown>, msg: string): void;
|
|
43
43
|
error(obj: Record<string, unknown>, msg: string): void;
|
|
44
44
|
}
|
|
45
|
+
export type EnqueueMailboxManagement = (event: MailboxManagementEvent) => Promise<void>;
|
|
46
|
+
export declare const fifoMailboxManagement: (queue: FifoQueueProducer<MailboxManagementEvent>) => EnqueueMailboxManagement;
|
|
47
|
+
export declare const standardMailboxManagement: (queue: QueueProducer<MailboxManagementEvent>) => EnqueueMailboxManagement;
|
|
45
48
|
/**
|
|
46
49
|
* Input for creating a mailbox via the queue service
|
|
47
50
|
*/
|
|
@@ -51,7 +54,7 @@ export type CreateMailboxQueueInput = Omit<CreateMailboxInput, "syncStatus">;
|
|
|
51
54
|
*/
|
|
52
55
|
export interface MailboxQueueConfig {
|
|
53
56
|
mailboxService: IMailboxRepository;
|
|
54
|
-
|
|
57
|
+
enqueue: EnqueueMailboxManagement;
|
|
55
58
|
logger?: MailboxQueueLogger;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
@@ -65,7 +68,7 @@ export interface MailboxQueueConfig {
|
|
|
65
68
|
*/
|
|
66
69
|
export declare class MailboxQueueService {
|
|
67
70
|
private mailboxService;
|
|
68
|
-
private
|
|
71
|
+
private enqueue;
|
|
69
72
|
private log;
|
|
70
73
|
constructor(config: MailboxQueueConfig);
|
|
71
74
|
/**
|
package/dist/mailbox-queue.js
CHANGED
|
@@ -6,6 +6,12 @@ const noopLogger = {
|
|
|
6
6
|
info: () => { },
|
|
7
7
|
error: () => { },
|
|
8
8
|
};
|
|
9
|
+
export const fifoMailboxManagement = (queue) => (event) => queue.send({
|
|
10
|
+
body: event,
|
|
11
|
+
groupId: event.accountId,
|
|
12
|
+
deduplicationId: `${event.type}:${event.mailboxId}:${event.eventId}`,
|
|
13
|
+
});
|
|
14
|
+
export const standardMailboxManagement = (queue) => (event) => queue.send({ body: event });
|
|
9
15
|
/**
|
|
10
16
|
* Service for mailbox management with automatic IMAP sync queueing.
|
|
11
17
|
*
|
|
@@ -17,11 +23,11 @@ const noopLogger = {
|
|
|
17
23
|
*/
|
|
18
24
|
export class MailboxQueueService {
|
|
19
25
|
mailboxService;
|
|
20
|
-
|
|
26
|
+
enqueue;
|
|
21
27
|
log;
|
|
22
28
|
constructor(config) {
|
|
23
29
|
this.mailboxService = config.mailboxService;
|
|
24
|
-
this.
|
|
30
|
+
this.enqueue = config.enqueue;
|
|
25
31
|
this.log = config.logger ?? noopLogger;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
@@ -204,11 +210,7 @@ export class MailboxQueueService {
|
|
|
204
210
|
* different accounts can be processed in parallel.
|
|
205
211
|
*/
|
|
206
212
|
enqueueEvent = async (event) => {
|
|
207
|
-
await this.
|
|
208
|
-
body: event,
|
|
209
|
-
groupId: event.accountId,
|
|
210
|
-
deduplicationId: `${event.type}:${event.mailboxId}:${event.eventId}`,
|
|
211
|
-
});
|
|
213
|
+
await this.enqueue(event);
|
|
212
214
|
this.log.info({ eventId: event.eventId, type: event.type, mailboxId: event.mailboxId }, `Enqueued ${event.type} event`);
|
|
213
215
|
};
|
|
214
216
|
}
|
package/dist/outbox-queue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IAccountRepository, IOutboxMessageRepository, OutboxMessageItem, QueueProducer } from "@remit/data-ports";
|
|
2
2
|
import type { OutboxAttachmentService } from "./outbox-attachment.js";
|
|
3
3
|
export interface SendMessageEvent {
|
|
4
4
|
type: "SEND_MESSAGE";
|
|
@@ -15,7 +15,7 @@ export interface OutboxQueueConfig {
|
|
|
15
15
|
outboxMessageService: IOutboxMessageRepository;
|
|
16
16
|
outboxAttachmentService: OutboxAttachmentService;
|
|
17
17
|
accountService: IAccountRepository;
|
|
18
|
-
queue:
|
|
18
|
+
queue: QueueProducer<SendMessageEvent>;
|
|
19
19
|
logger?: OutboxQueueLogger;
|
|
20
20
|
}
|
|
21
21
|
export interface CreateDraftInput {
|
package/dist/outbox-queue.js
CHANGED
|
@@ -274,11 +274,7 @@ export class OutboxQueueService {
|
|
|
274
274
|
accountId,
|
|
275
275
|
outboxMessageId,
|
|
276
276
|
};
|
|
277
|
-
await this.queue.send({
|
|
278
|
-
body: event,
|
|
279
|
-
groupId: accountId,
|
|
280
|
-
deduplicationId: event.eventId,
|
|
281
|
-
});
|
|
277
|
+
await this.queue.send({ body: event });
|
|
282
278
|
this.log.info({ eventId: event.eventId, accountId, outboxMessageId }, "Enqueued SEND_MESSAGE event");
|
|
283
279
|
};
|
|
284
280
|
}
|