@remit/imap-worker 2.0.7 → 2.0.8
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 +1 -1
- package/README.md +0 -103
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# @remit/imap-worker
|
|
2
|
-
|
|
3
|
-
SQS-driven Lambda worker for handling IMAP lifecycle events in the Remit system.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Event Driven**: Processes events from SQS (`SYNC_MAILBOXES`, `SYNC_MESSAGES`, etc.)
|
|
8
|
-
- **CLI Tool**: Includes a CLI for manually triggering events during development
|
|
9
|
-
- **Bundled**: Built with esbuild for optimal Lambda performance
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install
|
|
15
|
-
npm run bundle
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
### Lambda Handler
|
|
21
|
-
|
|
22
|
-
The package exports a standard AWS Lambda SQS handler:
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { handler } from "@remit/imap-worker";
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### CLI (Local Development)
|
|
29
|
-
|
|
30
|
-
Trigger events manually using the included CLI:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# Sync all mailboxes for an account
|
|
34
|
-
npm run cli -- -t SYNC_MAILBOXES -a <accountId>
|
|
35
|
-
|
|
36
|
-
# Sync messages in a mailbox
|
|
37
|
-
npm run cli -- -t SYNC_MESSAGES -a <accountId> -m <mailboxId>
|
|
38
|
-
|
|
39
|
-
# Force full sync (ignore lastSyncUid)
|
|
40
|
-
npm run cli -- -t SYNC_MESSAGES -a <accountId> -m <mailboxId> --fullSync
|
|
41
|
-
|
|
42
|
-
# Sync message bodies for specific messages
|
|
43
|
-
npm run cli -- -t SYNC_MESSAGE_BODY -a <accountId> -m <mailboxId> --messageIds id1,id2,id3
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Environment Variables
|
|
47
|
-
|
|
48
|
-
| Variable | Required | Description |
|
|
49
|
-
| ----------------------------- | -------- | -------------------------------------------------------- |
|
|
50
|
-
| `DATA_BACKEND` | Yes | Relational backend to run against (`sqlite`) |
|
|
51
|
-
| `SQLITE_APP_DB_PATH` | Yes | Path to the app SQLite database |
|
|
52
|
-
| `SQLITE_MAIL_DB_PATH` | Yes | Path to the tenant mail SQLite database |
|
|
53
|
-
| `SQLITE_SEARCH_DB_PATH` | Yes | Path to the tenant search SQLite database |
|
|
54
|
-
| `SQS_QUEUE_URL_MAILBOXES` | Yes | FIFO queue URL for `SYNC_MAILBOXES` events |
|
|
55
|
-
| `SQS_QUEUE_URL_MESSAGES` | Yes | FIFO queue URL for `SYNC_MESSAGES` events |
|
|
56
|
-
| `SQS_QUEUE_URL_BODY` | Yes | FIFO queue URL for `SYNC_MESSAGE_BODY` events |
|
|
57
|
-
| `SQS_QUEUE_URL_FLAGS` | Yes | FIFO queue URL for `SYNC_FLAGS` events |
|
|
58
|
-
| `SQS_QUEUE_URL_MAILBOX_MGMT` | Yes | Standard queue URL for mailbox management events |
|
|
59
|
-
| `SQS_QUEUE_URL_MESSAGE_MGMT` | Yes | Standard queue URL for message management events |
|
|
60
|
-
| `S3_BUCKET` | Yes | S3 bucket for storing raw message content |
|
|
61
|
-
| `NODE_ENV` | No | Set to `development` for local execution |
|
|
62
|
-
| `LOG_LEVEL` | No | Logging level (default: `info`) |
|
|
63
|
-
|
|
64
|
-
## Event Types
|
|
65
|
-
|
|
66
|
-
| Event | Description | Required Fields |
|
|
67
|
-
| ------------------- | ---------------------------------------------- | --------------------------------------- |
|
|
68
|
-
| `SYNC_MAILBOXES` | Discovers and syncs mailboxes for an account | `accountId` |
|
|
69
|
-
| `SYNC_MESSAGES` | Fetches new messages for a mailbox (one batch) | `accountId`, `mailboxId` |
|
|
70
|
-
| `SYNC_MESSAGE_BODY` | Fetches and stores message bodies in batch | `accountId`, `mailboxId`, `messageIds` |
|
|
71
|
-
|
|
72
|
-
### Event Schema
|
|
73
|
-
|
|
74
|
-
All events share a base schema:
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
interface BaseEvent {
|
|
78
|
-
accountId: string;
|
|
79
|
-
eventId: string; // Idempotency key
|
|
80
|
-
timestamp: number; // Unix timestamp
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Architecture
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
SQS Queue
|
|
88
|
-
│
|
|
89
|
-
▼
|
|
90
|
-
┌───────────────┐
|
|
91
|
-
│ Lambda/CLI │
|
|
92
|
-
│ (index.ts) │
|
|
93
|
-
└───────┬───────┘
|
|
94
|
-
│
|
|
95
|
-
▼
|
|
96
|
-
┌───────────────┐
|
|
97
|
-
│ processor │ ─── Routes events to handlers
|
|
98
|
-
└───────┬───────┘
|
|
99
|
-
│
|
|
100
|
-
├──► syncMailboxes
|
|
101
|
-
├──► syncMessages
|
|
102
|
-
└──► syncMessageBody
|
|
103
|
-
```
|