@remit/imap-worker 0.0.2 → 0.0.4
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.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -27,15 +27,6 @@
|
|
|
27
27
|
"@aws-sdk/client-sqs": "*",
|
|
28
28
|
"@aws-sdk/client-ssm": "*",
|
|
29
29
|
"@aws-sdk/core": "*",
|
|
30
|
-
"@remit/backend": "*",
|
|
31
|
-
"@remit/data-ports": "*",
|
|
32
|
-
"@remit/domain-enums": "*",
|
|
33
|
-
"@remit/logger-lambda": "*",
|
|
34
|
-
"@remit/mail-oauth-service": "*",
|
|
35
|
-
"@remit/mailbox-service": "*",
|
|
36
|
-
"@remit/search-index-worker": "*",
|
|
37
|
-
"@remit/secrets-service": "*",
|
|
38
|
-
"@remit/sqs-client": "*",
|
|
39
30
|
"@remit/storage-service": "*",
|
|
40
31
|
"@types/aws-lambda": "*",
|
|
41
32
|
"@types/nodemailer": "*",
|
|
@@ -46,7 +37,16 @@
|
|
|
46
37
|
},
|
|
47
38
|
"dependencies": {
|
|
48
39
|
"@aws-sdk/client-s3": "^3.1055.0",
|
|
49
|
-
"nodemailer": "^9.0.3"
|
|
40
|
+
"nodemailer": "^9.0.3",
|
|
41
|
+
"@remit/data-ports": "*",
|
|
42
|
+
"@remit/logger-lambda": "*",
|
|
43
|
+
"@remit/mailbox-service": "*",
|
|
44
|
+
"@remit/search-index-worker": "*",
|
|
45
|
+
"@remit/sqs-client": "*",
|
|
46
|
+
"@remit/backend": "*",
|
|
47
|
+
"@remit/domain-enums": "*",
|
|
48
|
+
"@remit/mail-oauth-service": "*",
|
|
49
|
+
"@remit/secrets-service": "*"
|
|
50
50
|
},
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"publishConfig": {
|
|
@@ -3,12 +3,10 @@ import cluster from "node:cluster";
|
|
|
3
3
|
import {
|
|
4
4
|
DeleteMessageCommand,
|
|
5
5
|
ReceiveMessageCommand,
|
|
6
|
-
SQSClient,
|
|
7
6
|
} from "@aws-sdk/client-sqs";
|
|
8
|
-
import { AwsQueryProtocol } from "@aws-sdk/core/protocols";
|
|
9
7
|
import { createLogger } from "@remit/logger-lambda";
|
|
10
8
|
import { handler as searchIndexHandler } from "@remit/search-index-worker";
|
|
11
|
-
import {
|
|
9
|
+
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
12
10
|
import type {
|
|
13
11
|
Context,
|
|
14
12
|
SQSBatchResponse,
|
|
@@ -117,12 +115,7 @@ if (cluster.isPrimary) {
|
|
|
117
115
|
|
|
118
116
|
const maxMessages = 10; // SQS API limit
|
|
119
117
|
|
|
120
|
-
const
|
|
121
|
-
const sqs = new SQSClient({
|
|
122
|
-
endpoint: isLocal ? new URL(queueUrl).origin : undefined,
|
|
123
|
-
...(isLocal && { protocol: AwsQueryProtocol }),
|
|
124
|
-
credentials: resolveSqsCredentials(),
|
|
125
|
-
});
|
|
118
|
+
const sqs = createQueueProducer({ queueUrl });
|
|
126
119
|
|
|
127
120
|
let isShuttingDown = false;
|
|
128
121
|
|
package/src/emit.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { SendMessageCommand
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { SendMessageCommand } from "@aws-sdk/client-sqs";
|
|
3
|
+
import {
|
|
4
|
+
createQueueProducer,
|
|
5
|
+
isLocalEndpoint,
|
|
6
|
+
} from "@remit/sqs-client/producer";
|
|
5
7
|
import { env } from "expect-env";
|
|
6
8
|
import type {
|
|
7
9
|
ImapEvent,
|
|
@@ -21,13 +23,9 @@ const flagsQueueUrl = env.SQS_QUEUE_URL_FLAGS;
|
|
|
21
23
|
const mailboxMgmtQueueUrl = env.SQS_QUEUE_URL_MAILBOX_MGMT;
|
|
22
24
|
const messageMgmtQueueUrl = env.SQS_QUEUE_URL_MESSAGE_MGMT;
|
|
23
25
|
|
|
24
|
-
const isLocal = mailboxesQueueUrl
|
|
26
|
+
const isLocal = isLocalEndpoint(mailboxesQueueUrl);
|
|
25
27
|
|
|
26
|
-
const sqs =
|
|
27
|
-
endpoint: isLocal ? new URL(mailboxesQueueUrl).origin : undefined,
|
|
28
|
-
...(isLocal && { protocol: AwsQueryProtocol }),
|
|
29
|
-
credentials: resolveSqsCredentials(),
|
|
30
|
-
});
|
|
28
|
+
const sqs = createQueueProducer({ queueUrl: mailboxesQueueUrl });
|
|
31
29
|
|
|
32
30
|
const queueUrlMap: Record<ImapEvent["type"], string> = {
|
|
33
31
|
SYNC_MAILBOXES: mailboxesQueueUrl,
|
|
@@ -3,10 +3,9 @@ import {
|
|
|
3
3
|
ListObjectsV2Command,
|
|
4
4
|
S3Client,
|
|
5
5
|
} from "@aws-sdk/client-s3";
|
|
6
|
-
import { SendMessageCommand
|
|
7
|
-
import { AwsQueryProtocol } from "@aws-sdk/core/protocols";
|
|
6
|
+
import { SendMessageCommand } from "@aws-sdk/client-sqs";
|
|
8
7
|
import type { Logger } from "@remit/logger-lambda";
|
|
9
|
-
import {
|
|
8
|
+
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
10
9
|
import { env } from "expect-env";
|
|
11
10
|
|
|
12
11
|
export interface DeleteAccountObjectsEvent {
|
|
@@ -18,13 +17,7 @@ export interface DeleteAccountObjectsEvent {
|
|
|
18
17
|
const s3 = new S3Client({});
|
|
19
18
|
|
|
20
19
|
const sqsQueueUrl = env.SQS_QUEUE_URL_MESSAGE_MGMT;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const sqs = new SQSClient({
|
|
24
|
-
endpoint: isLocal ? new URL(sqsQueueUrl).origin : undefined,
|
|
25
|
-
...(isLocal && { protocol: AwsQueryProtocol }),
|
|
26
|
-
credentials: resolveSqsCredentials(),
|
|
27
|
-
});
|
|
20
|
+
const sqs = createQueueProducer({ queueUrl: sqsQueueUrl });
|
|
28
21
|
|
|
29
22
|
const BATCH_SIZE = 1_000;
|
|
30
23
|
const MIN_REMAINING_MS = 30_000;
|
package/src/scheduler/handler.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { SQSClient } from "@aws-sdk/client-sqs";
|
|
2
|
-
import { AwsQueryProtocol } from "@aws-sdk/core/protocols";
|
|
3
1
|
import { getClient } from "@remit/backend/client";
|
|
4
2
|
import { createLogger, withTelemetry } from "@remit/logger-lambda";
|
|
5
|
-
import {
|
|
3
|
+
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
6
4
|
import type { ScheduledHandler } from "aws-lambda";
|
|
7
5
|
import { env } from "expect-env";
|
|
8
6
|
import { getOfflineIntervalMs, getTickIntervalMs } from "./config.js";
|
|
@@ -11,13 +9,7 @@ import { runSchedulerTick } from "./run-tick.js";
|
|
|
11
9
|
const log = createLogger();
|
|
12
10
|
|
|
13
11
|
const mailboxesQueueUrl = env.SQS_QUEUE_URL_MAILBOXES;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const sqsClient = new SQSClient({
|
|
17
|
-
endpoint: isLocal ? new URL(mailboxesQueueUrl).origin : undefined,
|
|
18
|
-
...(isLocal && { protocol: AwsQueryProtocol }),
|
|
19
|
-
credentials: resolveSqsCredentials(),
|
|
20
|
-
});
|
|
12
|
+
const sqsClient = createQueueProducer({ queueUrl: mailboxesQueueUrl });
|
|
21
13
|
|
|
22
14
|
/**
|
|
23
15
|
* EventBridge-scheduled entry point for the periodic mailbox-sync tick
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
|
-
import { SQSClient } from "@aws-sdk/client-sqs";
|
|
4
|
-
import { AwsQueryProtocol } from "@aws-sdk/core/protocols";
|
|
5
3
|
import { getClient } from "@remit/backend/client";
|
|
6
4
|
import { createLogger } from "@remit/logger-lambda";
|
|
7
|
-
import {
|
|
5
|
+
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
8
6
|
import { env } from "expect-env";
|
|
9
7
|
import { getOfflineIntervalMs, getTickIntervalMs } from "./config.js";
|
|
10
8
|
import { runSchedulerTick } from "./run-tick.js";
|
|
@@ -27,13 +25,7 @@ import { runSchedulerTick } from "./run-tick.js";
|
|
|
27
25
|
const log = createLogger();
|
|
28
26
|
|
|
29
27
|
const mailboxesQueueUrl = env.SQS_QUEUE_URL_MAILBOXES;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const sqsClient = new SQSClient({
|
|
33
|
-
endpoint: isLocal ? new URL(mailboxesQueueUrl).origin : undefined,
|
|
34
|
-
...(isLocal && { protocol: AwsQueryProtocol }),
|
|
35
|
-
credentials: resolveSqsCredentials(),
|
|
36
|
-
});
|
|
28
|
+
const sqsClient = createQueueProducer({ queueUrl: mailboxesQueueUrl });
|
|
37
29
|
|
|
38
30
|
const tickIntervalMs = getTickIntervalMs();
|
|
39
31
|
const offlineIntervalMs = getOfflineIntervalMs();
|