@remit/account-worker 0.0.22 → 0.0.24
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/cascade-enumerate.test.ts +5 -15
- package/src/compose-relational.test.ts +7 -17
- package/src/handlers/account-export.test.ts +4 -14
- package/src/handlers/account-fanout.test.ts +3 -13
- package/src/handlers/account-purge.test.ts +7 -17
- package/src/handlers/organize-job.test.ts +3 -13
- package/src/poller.ts +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/account-worker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"bundle": "esbuild src/index.ts --sourcemap --bundle --platform=node --format=esm --outfile=dist/index.js",
|
|
30
30
|
"test:typecheck": "tsgo --noEmit",
|
|
31
31
|
"test:run": "node $NODE_TEST_FLAGS --env-file=../../localhost-test-unit.env --experimental-test-coverage --test-coverage-include='src/**' --test-coverage-exclude='src/**/*.test.ts' --test-coverage-exclude='src/**/*.test.tsx' --test-coverage-lines=91 --test 'src/**/*.test.ts'",
|
|
32
|
-
"test": "npm run test:typecheck && npm run test:run"
|
|
32
|
+
"test": "npm run test:typecheck && npm run test:run",
|
|
33
|
+
"dev": "node --import tsx src/poller.ts"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@remit/data-ports": "*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
3
|
import type { MessageDescription } from "@remit/data-ports";
|
|
4
|
-
import
|
|
4
|
+
import { noopLogger } from "@remit/logger-lambda/noop-logger";
|
|
5
5
|
import {
|
|
6
6
|
type CascadeEntity,
|
|
7
7
|
type CascadeServices,
|
|
@@ -9,16 +9,6 @@ import {
|
|
|
9
9
|
enumerateCascadeEntities,
|
|
10
10
|
} from "./cascade.js";
|
|
11
11
|
|
|
12
|
-
const noopLog = {
|
|
13
|
-
info: () => {},
|
|
14
|
-
warn: () => {},
|
|
15
|
-
error: () => {},
|
|
16
|
-
debug: () => {},
|
|
17
|
-
fatal: () => {},
|
|
18
|
-
trace: () => {},
|
|
19
|
-
child: () => noopLog,
|
|
20
|
-
} as unknown as Logger;
|
|
21
|
-
|
|
22
12
|
const messageWithChildren = {
|
|
23
13
|
messageFlag: [{ messageFlagId: "flag-1" }],
|
|
24
14
|
envelope: [{ envelopeId: "env-1" }],
|
|
@@ -127,7 +117,7 @@ describe("enumerateCascadeEntities", () => {
|
|
|
127
117
|
const { entities, messageIds } = await enumerateCascadeEntities(
|
|
128
118
|
"cfg-1",
|
|
129
119
|
fullServices(),
|
|
130
|
-
|
|
120
|
+
noopLogger,
|
|
131
121
|
);
|
|
132
122
|
|
|
133
123
|
assert.deepEqual(messageIds, ["msg-1"]);
|
|
@@ -166,7 +156,7 @@ describe("enumerateCascadeEntities", () => {
|
|
|
166
156
|
const { entities } = await enumerateCascadeEntities(
|
|
167
157
|
"cfg-1",
|
|
168
158
|
services,
|
|
169
|
-
|
|
159
|
+
noopLogger,
|
|
170
160
|
);
|
|
171
161
|
|
|
172
162
|
assert.equal(entities.filter((e) => e.entityType === "Filter").length, 1);
|
|
@@ -183,7 +173,7 @@ describe("enumerateCascadeEntities", () => {
|
|
|
183
173
|
const { entities } = await enumerateCascadeEntities(
|
|
184
174
|
"cfg-1",
|
|
185
175
|
services,
|
|
186
|
-
|
|
176
|
+
noopLogger,
|
|
187
177
|
);
|
|
188
178
|
|
|
189
179
|
assert.equal(
|
|
@@ -204,7 +194,7 @@ describe("enumerateCascadeEntities", () => {
|
|
|
204
194
|
const { entities, messageIds } = await enumerateCascadeEntities(
|
|
205
195
|
"cfg-empty",
|
|
206
196
|
services,
|
|
207
|
-
|
|
197
|
+
noopLogger,
|
|
208
198
|
);
|
|
209
199
|
|
|
210
200
|
assert.equal(messageIds.length, 0);
|
|
@@ -3,19 +3,9 @@ import { mkdir, mkdtemp, stat, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
6
|
-
import
|
|
6
|
+
import { noopLogger } from "@remit/logger-lambda/noop-logger";
|
|
7
7
|
import { buildRelationalDeletionCapabilities } from "./compose-relational.js";
|
|
8
8
|
|
|
9
|
-
const noopLog = {
|
|
10
|
-
info: () => {},
|
|
11
|
-
warn: () => {},
|
|
12
|
-
error: () => {},
|
|
13
|
-
debug: () => {},
|
|
14
|
-
fatal: () => {},
|
|
15
|
-
trace: () => {},
|
|
16
|
-
child: () => noopLog,
|
|
17
|
-
} as unknown as Logger;
|
|
18
|
-
|
|
19
9
|
const exists = (path: string): Promise<boolean> =>
|
|
20
10
|
stat(path)
|
|
21
11
|
.then(() => true)
|
|
@@ -54,7 +44,7 @@ describe("relational deletion capabilities — filesystem storage cleanup", () =
|
|
|
54
44
|
"accounts/cfg-2/acc-9/messages/m9/body.eml",
|
|
55
45
|
);
|
|
56
46
|
|
|
57
|
-
await caps.deleteStoragePrefix("accounts/cfg-1/",
|
|
47
|
+
await caps.deleteStoragePrefix("accounts/cfg-1/", noopLogger);
|
|
58
48
|
|
|
59
49
|
for (const path of deleted) {
|
|
60
50
|
assert.equal(await exists(path), false, `${path} must be deleted`);
|
|
@@ -74,7 +64,7 @@ describe("relational deletion capabilities — filesystem storage cleanup", () =
|
|
|
74
64
|
"accounts/cfg-1/acc-2/messages/m2/body.eml",
|
|
75
65
|
);
|
|
76
66
|
|
|
77
|
-
await caps.deleteStoragePrefix("accounts/cfg-1/acc-1/",
|
|
67
|
+
await caps.deleteStoragePrefix("accounts/cfg-1/acc-1/", noopLogger);
|
|
78
68
|
|
|
79
69
|
assert.equal(await exists(deleted), false);
|
|
80
70
|
assert.equal(
|
|
@@ -86,19 +76,19 @@ describe("relational deletion capabilities — filesystem storage cleanup", () =
|
|
|
86
76
|
|
|
87
77
|
it("is replay-safe — deleting a missing prefix does not throw", async () => {
|
|
88
78
|
const caps = buildRelationalDeletionCapabilities();
|
|
89
|
-
await caps.deleteStoragePrefix("accounts/never-existed/",
|
|
79
|
+
await caps.deleteStoragePrefix("accounts/never-existed/", noopLogger);
|
|
90
80
|
});
|
|
91
81
|
});
|
|
92
82
|
|
|
93
83
|
describe("relational deletion capabilities — CDN and sign-out are no-ops", () => {
|
|
94
84
|
it("invalidateContent resolves without a CDN", async () => {
|
|
95
85
|
const caps = buildRelationalDeletionCapabilities();
|
|
96
|
-
await caps.invalidateContent("cfg-1",
|
|
97
|
-
await caps.invalidateContent("cfg-1/acc-1",
|
|
86
|
+
await caps.invalidateContent("cfg-1", noopLogger);
|
|
87
|
+
await caps.invalidateContent("cfg-1/acc-1", noopLogger);
|
|
98
88
|
});
|
|
99
89
|
|
|
100
90
|
it("signOut resolves without a federated session store", async () => {
|
|
101
91
|
const caps = buildRelationalDeletionCapabilities();
|
|
102
|
-
await caps.signOut("user-123",
|
|
92
|
+
await caps.signOut("user-123", noopLogger);
|
|
103
93
|
});
|
|
104
94
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { Readable } from "node:stream";
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
|
-
import
|
|
4
|
+
import { noopLogger } from "@remit/logger-lambda/noop-logger";
|
|
5
5
|
import type { StorageService } from "@remit/storage-service";
|
|
6
6
|
import type { CascadeServices } from "../cascade.js";
|
|
7
7
|
import type { AccountExportEvent } from "../events.js";
|
|
@@ -10,16 +10,6 @@ import {
|
|
|
10
10
|
processAccountExport,
|
|
11
11
|
} from "./account-export.js";
|
|
12
12
|
|
|
13
|
-
const noopLog = {
|
|
14
|
-
info: () => {},
|
|
15
|
-
warn: () => {},
|
|
16
|
-
error: () => {},
|
|
17
|
-
debug: () => {},
|
|
18
|
-
fatal: () => {},
|
|
19
|
-
trace: () => {},
|
|
20
|
-
child: () => noopLog,
|
|
21
|
-
} as unknown as Logger;
|
|
22
|
-
|
|
23
13
|
interface Update {
|
|
24
14
|
state: string;
|
|
25
15
|
objectKey?: string;
|
|
@@ -84,7 +74,7 @@ const event: AccountExportEvent = {
|
|
|
84
74
|
describe("processAccountExport", () => {
|
|
85
75
|
it("drives the request Processing then Ready and stores the archive key", async () => {
|
|
86
76
|
const updates: Update[] = [];
|
|
87
|
-
await processAccountExport(event,
|
|
77
|
+
await processAccountExport(event, noopLogger, buildDeps(updates));
|
|
88
78
|
|
|
89
79
|
assert.deepEqual(
|
|
90
80
|
updates.map((u) => u.state),
|
|
@@ -103,7 +93,7 @@ describe("processAccountExport", () => {
|
|
|
103
93
|
let retrieved = 0;
|
|
104
94
|
await processAccountExport(
|
|
105
95
|
event,
|
|
106
|
-
|
|
96
|
+
noopLogger,
|
|
107
97
|
buildDeps(updates, {
|
|
108
98
|
retrieveMessageBodyStream: async (
|
|
109
99
|
_cfg: string,
|
|
@@ -125,7 +115,7 @@ describe("processAccountExport", () => {
|
|
|
125
115
|
await assert.rejects(
|
|
126
116
|
processAccountExport(
|
|
127
117
|
event,
|
|
128
|
-
|
|
118
|
+
noopLogger,
|
|
129
119
|
buildDeps(updates, {
|
|
130
120
|
storeExportArchiveStream: async (
|
|
131
121
|
_cfg: string,
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { afterEach, describe, it } from "node:test";
|
|
3
3
|
import type { SQSClient } from "@aws-sdk/client-sqs";
|
|
4
|
-
import
|
|
4
|
+
import { noopLogger } from "@remit/logger-lambda/noop-logger";
|
|
5
5
|
import type { CascadeServices } from "../cascade.js";
|
|
6
6
|
import type { AccountDeleteEvent } from "../events.js";
|
|
7
7
|
import { processAccountFanout } from "./account-fanout.js";
|
|
8
8
|
|
|
9
|
-
const noopLog = {
|
|
10
|
-
info: () => {},
|
|
11
|
-
warn: () => {},
|
|
12
|
-
error: () => {},
|
|
13
|
-
debug: () => {},
|
|
14
|
-
fatal: () => {},
|
|
15
|
-
trace: () => {},
|
|
16
|
-
child: () => noopLog,
|
|
17
|
-
} as unknown as Logger;
|
|
18
|
-
|
|
19
9
|
// A CascadeServices fake with one account and no data: enough for
|
|
20
10
|
// enumerateCascadeEntities to yield a single Account row (so the stop-signal
|
|
21
11
|
// loop has one accountId to iterate) without standing up a database.
|
|
@@ -81,7 +71,7 @@ describe("processAccountFanout — imap-worker stop signal on account delete", (
|
|
|
81
71
|
delete process.env.SQS_QUEUE_URL_IMAP_WORKER;
|
|
82
72
|
const sent: SentMessage[] = [];
|
|
83
73
|
|
|
84
|
-
await processAccountFanout(deleteEvent,
|
|
74
|
+
await processAccountFanout(deleteEvent, noopLogger, {
|
|
85
75
|
services: buildServices(),
|
|
86
76
|
sqs: recordingSqs(sent),
|
|
87
77
|
signOut: async () => {},
|
|
@@ -99,7 +89,7 @@ describe("processAccountFanout — imap-worker stop signal on account delete", (
|
|
|
99
89
|
it("enqueues one stop signal per account when a queue is configured", async () => {
|
|
100
90
|
const sent: SentMessage[] = [];
|
|
101
91
|
|
|
102
|
-
await processAccountFanout(deleteEvent,
|
|
92
|
+
await processAccountFanout(deleteEvent, noopLogger, {
|
|
103
93
|
services: buildServices(),
|
|
104
94
|
sqs: recordingSqs(sent),
|
|
105
95
|
signOut: async () => {},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
3
|
import type { SQSClient } from "@aws-sdk/client-sqs";
|
|
4
|
-
import
|
|
4
|
+
import { noopLogger } from "@remit/logger-lambda/noop-logger";
|
|
5
5
|
import type { CascadeServices } from "../cascade.js";
|
|
6
6
|
import type { AccountDataPurgeEvent } from "../events.js";
|
|
7
7
|
import {
|
|
@@ -9,16 +9,6 @@ import {
|
|
|
9
9
|
processAccountDataPurge,
|
|
10
10
|
} from "./account-purge.js";
|
|
11
11
|
|
|
12
|
-
const noopLog = {
|
|
13
|
-
info: () => {},
|
|
14
|
-
warn: () => {},
|
|
15
|
-
error: () => {},
|
|
16
|
-
debug: () => {},
|
|
17
|
-
fatal: () => {},
|
|
18
|
-
trace: () => {},
|
|
19
|
-
child: () => noopLog,
|
|
20
|
-
} as unknown as Logger;
|
|
21
|
-
|
|
22
12
|
interface Sent {
|
|
23
13
|
queueUrl: string | undefined;
|
|
24
14
|
body: Record<string, unknown>;
|
|
@@ -91,7 +81,7 @@ const baseDeps = (
|
|
|
91
81
|
describe("processAccountDataPurge", () => {
|
|
92
82
|
it("enqueues vector deletes then a subtrees batch and one container leftover", async () => {
|
|
93
83
|
const sent: Sent[] = [];
|
|
94
|
-
await processAccountDataPurge(event,
|
|
84
|
+
await processAccountDataPurge(event, noopLogger, baseDeps(sent));
|
|
95
85
|
|
|
96
86
|
const vectorBatch = sent.find((m) => m.queueUrl === "http://queue/search");
|
|
97
87
|
assert.equal(vectorBatch?.entries?.length, 2, "one entry per message");
|
|
@@ -110,7 +100,7 @@ describe("processAccountDataPurge", () => {
|
|
|
110
100
|
const sent: Sent[] = [];
|
|
111
101
|
await processAccountDataPurge(
|
|
112
102
|
event,
|
|
113
|
-
|
|
103
|
+
noopLogger,
|
|
114
104
|
baseDeps(sent, { dataBackend: "sqlite" }),
|
|
115
105
|
);
|
|
116
106
|
|
|
@@ -129,7 +119,7 @@ describe("processAccountDataPurge", () => {
|
|
|
129
119
|
|
|
130
120
|
it("drops manifest rows outside the account's mailbox set", async () => {
|
|
131
121
|
const sent: Sent[] = [];
|
|
132
|
-
await processAccountDataPurge(event,
|
|
122
|
+
await processAccountDataPurge(event, noopLogger, {
|
|
133
123
|
...baseDeps(sent),
|
|
134
124
|
services: buildServices([
|
|
135
125
|
{ threadMessageId: "tm-1", messageId: "msg-1", mailboxId: "mbx-1" },
|
|
@@ -143,7 +133,7 @@ describe("processAccountDataPurge", () => {
|
|
|
143
133
|
|
|
144
134
|
it("no-ops when the account is already gone", async () => {
|
|
145
135
|
const sent: Sent[] = [];
|
|
146
|
-
await processAccountDataPurge(event,
|
|
136
|
+
await processAccountDataPurge(event, noopLogger, {
|
|
147
137
|
...baseDeps(sent),
|
|
148
138
|
services: {
|
|
149
139
|
accountService: {
|
|
@@ -163,7 +153,7 @@ describe("processAccountDataPurge", () => {
|
|
|
163
153
|
it("rethrows a non-NotFound describe error", async () => {
|
|
164
154
|
const sent: Sent[] = [];
|
|
165
155
|
await assert.rejects(
|
|
166
|
-
processAccountDataPurge(event,
|
|
156
|
+
processAccountDataPurge(event, noopLogger, {
|
|
167
157
|
...baseDeps(sent),
|
|
168
158
|
services: {
|
|
169
159
|
accountService: {
|
|
@@ -181,7 +171,7 @@ describe("processAccountDataPurge", () => {
|
|
|
181
171
|
it("throws when a vector-delete batch reports failed entries", async () => {
|
|
182
172
|
const sent: Sent[] = [];
|
|
183
173
|
await assert.rejects(
|
|
184
|
-
processAccountDataPurge(event,
|
|
174
|
+
processAccountDataPurge(event, noopLogger, {
|
|
185
175
|
...baseDeps(sent),
|
|
186
176
|
sqs: recordingSqs(sent, true),
|
|
187
177
|
}),
|
|
@@ -2,20 +2,10 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
3
|
import type { RemitClient } from "@remit/backend/client";
|
|
4
4
|
import type { OrganizeMatchDeps } from "@remit/backend/organize";
|
|
5
|
-
import
|
|
5
|
+
import { noopLogger } from "@remit/logger-lambda/noop-logger";
|
|
6
6
|
import type { OrganizeJobEvent } from "../events.js";
|
|
7
7
|
import { processOrganizeJob } from "./organize-job.js";
|
|
8
8
|
|
|
9
|
-
const noopLog = {
|
|
10
|
-
info: () => {},
|
|
11
|
-
warn: () => {},
|
|
12
|
-
error: () => {},
|
|
13
|
-
debug: () => {},
|
|
14
|
-
fatal: () => {},
|
|
15
|
-
trace: () => {},
|
|
16
|
-
child: () => noopLog,
|
|
17
|
-
} as unknown as Logger;
|
|
18
|
-
|
|
19
9
|
interface Update {
|
|
20
10
|
state: string;
|
|
21
11
|
errorMessage?: string;
|
|
@@ -77,7 +67,7 @@ describe("processOrganizeJob (reader #463)", () => {
|
|
|
77
67
|
it("fails the job on a refused rule and acknowledges the record", async () => {
|
|
78
68
|
const updates: Update[] = [];
|
|
79
69
|
|
|
80
|
-
await processOrganizeJob(event,
|
|
70
|
+
await processOrganizeJob(event, noopLogger, {
|
|
81
71
|
client: jobClient(updates, [{ field: "HasWords", value: "invoice" }]),
|
|
82
72
|
matchDeps: explodingMatchDeps(),
|
|
83
73
|
});
|
|
@@ -97,7 +87,7 @@ describe("processOrganizeJob (reader #463)", () => {
|
|
|
97
87
|
const updates: Update[] = [];
|
|
98
88
|
|
|
99
89
|
await assert.rejects(
|
|
100
|
-
processOrganizeJob(event,
|
|
90
|
+
processOrganizeJob(event, noopLogger, {
|
|
101
91
|
client: jobClient(updates, [
|
|
102
92
|
{ field: "Subject", value: "reservation" },
|
|
103
93
|
]),
|
package/src/poller.ts
CHANGED
|
@@ -4,10 +4,13 @@ import { env } from "expect-env";
|
|
|
4
4
|
import { fanoutHandler, finalizeHandler } from "./index.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Production queue poller
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Production queue poller, and the standalone entrypoint for the dedicated
|
|
8
|
+
* image. The sibling workers carry a separate `e2e-processor-shim.ts` because
|
|
9
|
+
* they predate `runQueuePoller`; this one has no shim and needs none — the
|
|
10
|
+
* poller drains an SQS-compatible endpoint (the queue sidecar) exactly as it
|
|
11
|
+
* drains SQS, which is what deploy/vps/docker-compose.sqlite.yml already does,
|
|
12
|
+
* so the source-built e2e stack runs this same file (`npm run dev -w
|
|
13
|
+
* @remit/account-worker`, wired in npm-scripts/e2e-dev-up.sh).
|
|
11
14
|
*
|
|
12
15
|
* The deployment-specific steps of the cascade — sign-out, content
|
|
13
16
|
* invalidation, storage cleanup, and the row cascade — resolve through the
|