@remit/smtp-worker 0.0.27 → 0.0.28
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 +3 -2
- package/src/data-ports.ts +15 -23
- package/src/e2e-processor-shim.ts +4 -1
- package/src/failure-kind.ts +1 -1
- package/src/handlers/engagement-counters.ts +6 -6
- package/src/handlers/send-message-core.ts +2 -1
- package/src/handlers/send-message.ts +1 -1
- package/src/index.ts +5 -3
- package/src/poller.ts +5 -1
- package/src/processor.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/smtp-worker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"bundle": "node build.mjs",
|
|
18
18
|
"test:typecheck": "tsgo --noEmit",
|
|
19
|
-
"test:run": "node $NODE_TEST_FLAGS --env-file=../../localhost-test-unit.env --experimental-test-module-mocks --experimental-test-coverage --test-coverage-include='src/**' --test-coverage-exclude='src/**/*.test.ts' --test-coverage-exclude='src/**/*.test.tsx' --test-coverage-lines=83 --test 'src/**/*.test.ts'",
|
|
19
|
+
"test:run": "node $NODE_TEST_FLAGS --env-file=../../localhost-test-unit.env --experimental-test-module-mocks --experimental-test-coverage --test-coverage-include='src/**' --test-coverage-exclude='src/**/*.test.ts' --test-coverage-exclude='src/**/*.test.tsx' --test-coverage-exclude='src/handlers/send-message.ts' --test-coverage-lines=83 --test 'src/**/*.test.ts'",
|
|
20
20
|
"test": "npm run test:typecheck && npm run test:run",
|
|
21
21
|
"dev": "node --import tsx src/e2e-processor-shim.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@remit/logger": "*",
|
|
24
25
|
"@remit/data-ports": "*",
|
|
25
26
|
"@remit/drizzle-service": "*",
|
|
26
27
|
"@remit/logger-lambda": "*",
|
package/src/data-ports.ts
CHANGED
|
@@ -26,33 +26,25 @@ export interface SmtpDataPorts {
|
|
|
26
26
|
// marked `external` for the Lambda esbuild build (LAMBDA_ESBUILD_OPTIONS), so
|
|
27
27
|
// esbuild leaves this `import()` unresolved in the bundle. It resolves only
|
|
28
28
|
// where the relational composition actually runs, which has the package
|
|
29
|
-
// installed.
|
|
29
|
+
// installed.
|
|
30
30
|
const buildSqliteDataPorts = async (): Promise<SmtpDataPorts> => {
|
|
31
|
-
const sqliteDbPath = process.env.SQLITE_DB_PATH;
|
|
32
|
-
if (!sqliteDbPath) throw new Error("SQLITE_DB_PATH is required");
|
|
33
|
-
|
|
34
31
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
DrizzleEnvelopeRepository,
|
|
39
|
-
DrizzleMessageRepository,
|
|
40
|
-
messageDataSchema,
|
|
41
|
-
OutboxAttachmentRepo,
|
|
42
|
-
OutboxMessageRepo,
|
|
32
|
+
createSqliteRepositories,
|
|
33
|
+
openSqliteDatabases,
|
|
34
|
+
sqliteDatabasePathsFromEnv,
|
|
43
35
|
} = await import("@remit/drizzle-service");
|
|
44
36
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
const repositories = createSqliteRepositories(
|
|
38
|
+
await openSqliteDatabases(sqliteDatabasePathsFromEnv()),
|
|
39
|
+
);
|
|
48
40
|
|
|
49
41
|
return {
|
|
50
|
-
account:
|
|
51
|
-
outboxMessage:
|
|
52
|
-
outboxAttachment:
|
|
53
|
-
address:
|
|
54
|
-
message:
|
|
55
|
-
envelope:
|
|
42
|
+
account: repositories.account,
|
|
43
|
+
outboxMessage: repositories.outboxMessage,
|
|
44
|
+
outboxAttachment: repositories.outboxAttachment,
|
|
45
|
+
address: repositories.address,
|
|
46
|
+
message: repositories.message,
|
|
47
|
+
envelope: repositories.envelope,
|
|
56
48
|
};
|
|
57
49
|
};
|
|
58
50
|
|
|
@@ -71,12 +63,12 @@ export const setSmtpDataPorts = (ports: SmtpDataPorts): void => {
|
|
|
71
63
|
/**
|
|
72
64
|
* The SMTP data ports for this process: the ones a composition root registered,
|
|
73
65
|
* or — for a process that registered none — the SQLite composition this build
|
|
74
|
-
* contains. `
|
|
66
|
+
* contains. `SQLITE_APP_DB_PATH` is that composition's precondition, not a backend
|
|
75
67
|
* selection.
|
|
76
68
|
*/
|
|
77
69
|
export const buildDataPortsFromEnv = async (): Promise<SmtpDataPorts> => {
|
|
78
70
|
if (injectedDataPorts) return injectedDataPorts;
|
|
79
|
-
if (process.env.
|
|
71
|
+
if (process.env.SQLITE_APP_DB_PATH) return buildSqliteDataPorts();
|
|
80
72
|
throw new Error(
|
|
81
73
|
"no SMTP data ports registered — register them with setSmtpDataPorts() from your composition root",
|
|
82
74
|
);
|
|
@@ -4,12 +4,15 @@ import {
|
|
|
4
4
|
DeleteMessageCommand,
|
|
5
5
|
ReceiveMessageCommand,
|
|
6
6
|
} from "@aws-sdk/client-sqs";
|
|
7
|
-
import { createLogger } from "@remit/logger
|
|
7
|
+
import { createLogger } from "@remit/logger";
|
|
8
|
+
import { installNodeLogger } from "@remit/logger-lambda/node";
|
|
8
9
|
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
9
10
|
import type { Context, SQSBatchResponse, SQSEvent } from "aws-lambda";
|
|
10
11
|
import { env } from "expect-env";
|
|
11
12
|
import { handler } from "./index.js";
|
|
12
13
|
|
|
14
|
+
installNodeLogger();
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* E2E-only queue drainer.
|
|
15
18
|
*
|
package/src/failure-kind.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OutboxMessageItem } from "@remit/data-ports";
|
|
2
|
-
import
|
|
2
|
+
import { bareMessageId, wireMessageId } from "@remit/data-ports/id";
|
|
3
|
+
import type { Logger } from "@remit/logger";
|
|
3
4
|
import type { EngagementCounterDeps, SendTenant } from "./send-message-core.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -119,8 +120,7 @@ const collectReferenceHeaders = (outbox: OutboxMessageItem): string[] => {
|
|
|
119
120
|
return result;
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
const headerVariants = (header: string): string[] =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
123
|
+
const headerVariants = (header: string): string[] => [
|
|
124
|
+
wireMessageId(header),
|
|
125
|
+
bareMessageId(header),
|
|
126
|
+
];
|
|
@@ -5,7 +5,8 @@ import type {
|
|
|
5
5
|
UpdateOutboxMessageInput,
|
|
6
6
|
} from "@remit/data-ports";
|
|
7
7
|
import { AccountAuthType, OutboxMessageStatus } from "@remit/domain-enums";
|
|
8
|
-
import {
|
|
8
|
+
import type { Logger } from "@remit/logger";
|
|
9
|
+
import { recordSmtpFailure } from "@remit/logger-lambda/metrics";
|
|
9
10
|
import { RefreshTokenError } from "@remit/mail-oauth-service";
|
|
10
11
|
import type { CredentialResolution } from "@remit/mailbox-service/account-credentials";
|
|
11
12
|
import { OutboxAttachmentUnavailableError } from "@remit/mailbox-service/outbox-attachment-content";
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { SendMessageCommand } from "@aws-sdk/client-sqs";
|
|
3
3
|
import { deriveAddressId, deriveMessageId } from "@remit/data-ports/id";
|
|
4
4
|
import type { ConnectionState } from "@remit/domain-enums";
|
|
5
|
-
import type { Logger } from "@remit/logger
|
|
5
|
+
import type { Logger } from "@remit/logger";
|
|
6
6
|
import {
|
|
7
7
|
createMailOAuthService,
|
|
8
8
|
microsoftProviderConfig,
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { inspect } from "node:util";
|
|
2
|
+
import { createLogger } from "@remit/logger";
|
|
2
3
|
import {
|
|
3
|
-
createLogger,
|
|
4
4
|
queueNameFromEventSource,
|
|
5
5
|
recordQueueEvent,
|
|
6
6
|
recordSmtpFailure,
|
|
7
|
-
|
|
8
|
-
} from "@remit/logger-lambda";
|
|
7
|
+
} from "@remit/logger-lambda/metrics";
|
|
8
|
+
import { installNodeLogger, withTelemetry } from "@remit/logger-lambda/node";
|
|
9
9
|
import type { SQSBatchResponse, SQSEvent } from "aws-lambda";
|
|
10
10
|
import type { SmtpEvent } from "./events.js";
|
|
11
11
|
import { smtpFailureKind } from "./failure-kind.js";
|
|
12
12
|
import { processEvent } from "./processor.js";
|
|
13
13
|
|
|
14
|
+
installNodeLogger();
|
|
15
|
+
|
|
14
16
|
const log = createLogger();
|
|
15
17
|
|
|
16
18
|
/**
|
package/src/poller.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { createLogger
|
|
1
|
+
import { createLogger } from "@remit/logger";
|
|
2
|
+
import { startMetricsServer } from "@remit/logger-lambda/metrics";
|
|
3
|
+
import { installNodeLogger } from "@remit/logger-lambda/node";
|
|
2
4
|
import { runQueuePoller } from "@remit/sqs-client/poller";
|
|
3
5
|
import { env } from "expect-env";
|
|
4
6
|
import { handler } from "./index.js";
|
|
5
7
|
|
|
8
|
+
installNodeLogger();
|
|
9
|
+
|
|
6
10
|
/** Production queue poller — the deployed form of `e2e-processor-shim.ts`. */
|
|
7
11
|
const log = createLogger();
|
|
8
12
|
|
package/src/processor.ts
CHANGED