@happyvertical/smrt-messages 0.30.0
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/AGENTS.md +31 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +103 -0
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/collections/AccountCollection.d.ts +42 -0
- package/dist/collections/AccountCollection.d.ts.map +1 -0
- package/dist/collections/AttachmentCollection.d.ts +67 -0
- package/dist/collections/AttachmentCollection.d.ts.map +1 -0
- package/dist/collections/BlacklistCollection.d.ts +14 -0
- package/dist/collections/BlacklistCollection.d.ts.map +1 -0
- package/dist/collections/EmailAccountCollection.d.ts +74 -0
- package/dist/collections/EmailAccountCollection.d.ts.map +1 -0
- package/dist/collections/EmailAttachmentCollection.d.ts +38 -0
- package/dist/collections/EmailAttachmentCollection.d.ts.map +1 -0
- package/dist/collections/EmailCollection.d.ts +81 -0
- package/dist/collections/EmailCollection.d.ts.map +1 -0
- package/dist/collections/EmailFolderCollection.d.ts +85 -0
- package/dist/collections/EmailFolderCollection.d.ts.map +1 -0
- package/dist/collections/MessageCollection.d.ts +74 -0
- package/dist/collections/MessageCollection.d.ts.map +1 -0
- package/dist/collections/WhitelistCollection.d.ts +18 -0
- package/dist/collections/WhitelistCollection.d.ts.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3068 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.json +10576 -0
- package/dist/models/Account.d.ts +47 -0
- package/dist/models/Account.d.ts.map +1 -0
- package/dist/models/Attachment.d.ts +48 -0
- package/dist/models/Attachment.d.ts.map +1 -0
- package/dist/models/Blacklist.d.ts +21 -0
- package/dist/models/Blacklist.d.ts.map +1 -0
- package/dist/models/Email.d.ts +98 -0
- package/dist/models/Email.d.ts.map +1 -0
- package/dist/models/EmailAccount.d.ts +65 -0
- package/dist/models/EmailAccount.d.ts.map +1 -0
- package/dist/models/EmailAttachment.d.ts +19 -0
- package/dist/models/EmailAttachment.d.ts.map +1 -0
- package/dist/models/EmailFolder.d.ts +65 -0
- package/dist/models/EmailFolder.d.ts.map +1 -0
- package/dist/models/Message.d.ts +105 -0
- package/dist/models/Message.d.ts.map +1 -0
- package/dist/models/SlackAccount.d.ts +13 -0
- package/dist/models/SlackAccount.d.ts.map +1 -0
- package/dist/models/SlackMessage.d.ts +34 -0
- package/dist/models/SlackMessage.d.ts.map +1 -0
- package/dist/models/Tweet.d.ts +31 -0
- package/dist/models/Tweet.d.ts.map +1 -0
- package/dist/models/TwitterAccount.d.ts +12 -0
- package/dist/models/TwitterAccount.d.ts.map +1 -0
- package/dist/models/Whitelist.d.ts +21 -0
- package/dist/models/Whitelist.d.ts.map +1 -0
- package/dist/playground.d.ts +2 -0
- package/dist/playground.d.ts.map +1 -0
- package/dist/playground.js +176 -0
- package/dist/playground.js.map +1 -0
- package/dist/senders/EmailSender.d.ts +13 -0
- package/dist/senders/EmailSender.d.ts.map +1 -0
- package/dist/senders/SlackSender.d.ts +11 -0
- package/dist/senders/SlackSender.d.ts.map +1 -0
- package/dist/senders/TweetSender.d.ts +11 -0
- package/dist/senders/TweetSender.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +4234 -0
- package/dist/svelte/components/AccountAvatar.svelte +107 -0
- package/dist/svelte/components/AccountAvatar.svelte.d.ts +12 -0
- package/dist/svelte/components/AccountAvatar.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AccountCard.svelte +173 -0
- package/dist/svelte/components/AccountCard.svelte.d.ts +12 -0
- package/dist/svelte/components/AccountCard.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AccountList.svelte +90 -0
- package/dist/svelte/components/AccountList.svelte.d.ts +12 -0
- package/dist/svelte/components/AccountList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AttachmentChip.svelte +99 -0
- package/dist/svelte/components/AttachmentChip.svelte.d.ts +12 -0
- package/dist/svelte/components/AttachmentChip.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AttachmentUpload.svelte +160 -0
- package/dist/svelte/components/AttachmentUpload.svelte.d.ts +11 -0
- package/dist/svelte/components/AttachmentUpload.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ComposeForm.svelte +387 -0
- package/dist/svelte/components/ComposeForm.svelte.d.ts +13 -0
- package/dist/svelte/components/ComposeForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/EmailAccountManager.svelte +690 -0
- package/dist/svelte/components/EmailAccountManager.svelte.d.ts +15 -0
- package/dist/svelte/components/EmailAccountManager.svelte.d.ts.map +1 -0
- package/dist/svelte/components/EmailFilterManager.svelte +687 -0
- package/dist/svelte/components/EmailFilterManager.svelte.d.ts +14 -0
- package/dist/svelte/components/EmailFilterManager.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FolderNav.svelte +171 -0
- package/dist/svelte/components/FolderNav.svelte.d.ts +11 -0
- package/dist/svelte/components/FolderNav.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ForwardForm.svelte +166 -0
- package/dist/svelte/components/ForwardForm.svelte.d.ts +10 -0
- package/dist/svelte/components/ForwardForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageCard.svelte +336 -0
- package/dist/svelte/components/MessageCard.svelte.d.ts +20 -0
- package/dist/svelte/components/MessageCard.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageDetail.svelte +309 -0
- package/dist/svelte/components/MessageDetail.svelte.d.ts +18 -0
- package/dist/svelte/components/MessageDetail.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageFilters.svelte +228 -0
- package/dist/svelte/components/MessageFilters.svelte.d.ts +13 -0
- package/dist/svelte/components/MessageFilters.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageList.svelte +101 -0
- package/dist/svelte/components/MessageList.svelte.d.ts +23 -0
- package/dist/svelte/components/MessageList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageStatusIndicator.svelte +82 -0
- package/dist/svelte/components/MessageStatusIndicator.svelte.d.ts +11 -0
- package/dist/svelte/components/MessageStatusIndicator.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageToolbar.svelte +131 -0
- package/dist/svelte/components/MessageToolbar.svelte.d.ts +14 -0
- package/dist/svelte/components/MessageToolbar.svelte.d.ts.map +1 -0
- package/dist/svelte/components/MessageTypeBadge.svelte +59 -0
- package/dist/svelte/components/MessageTypeBadge.svelte.d.ts +9 -0
- package/dist/svelte/components/MessageTypeBadge.svelte.d.ts.map +1 -0
- package/dist/svelte/components/RecipientInput.svelte +150 -0
- package/dist/svelte/components/RecipientInput.svelte.d.ts +11 -0
- package/dist/svelte/components/RecipientInput.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ReplyForm.svelte +159 -0
- package/dist/svelte/components/ReplyForm.svelte.d.ts +11 -0
- package/dist/svelte/components/ReplyForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SendStatusBadge.svelte +64 -0
- package/dist/svelte/components/SendStatusBadge.svelte.d.ts +8 -0
- package/dist/svelte/components/SendStatusBadge.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ThreadView.svelte +240 -0
- package/dist/svelte/components/ThreadView.svelte.d.ts +12 -0
- package/dist/svelte/components/ThreadView.svelte.d.ts.map +1 -0
- package/dist/svelte/i18n.d.ts +42 -0
- package/dist/svelte/i18n.d.ts.map +1 -0
- package/dist/svelte/i18n.js +60 -0
- package/dist/svelte/i18n.messages.d.ts +32 -0
- package/dist/svelte/i18n.messages.d.ts.map +1 -0
- package/dist/svelte/i18n.messages.js +46 -0
- package/dist/svelte/index.d.ts +54 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +44 -0
- package/dist/svelte/playground.d.ts +341 -0
- package/dist/svelte/playground.d.ts.map +1 -0
- package/dist/svelte/playground.js +171 -0
- package/dist/svelte/types.d.ts +195 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +6 -0
- package/dist/types.d.ts +316 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui.d.ts +4 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +103 -0
- package/dist/ui.js.map +1 -0
- package/package.json +104 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @happyvertical/smrt-messages
|
|
2
|
+
|
|
3
|
+
Multi-channel messaging with STI hierarchies for both messages and accounts. Credential encryption via smrt-secrets.
|
|
4
|
+
|
|
5
|
+
## STI Hierarchies
|
|
6
|
+
|
|
7
|
+
**Messages** (share `messages` table):
|
|
8
|
+
- `Message` (base): accountId, threadId, subject, body, fromAddress, toAddresses (JSON), sendStatus (draft/sending/sent/failed), retryCount
|
|
9
|
+
- `Email`: messageId (RFC 822), inReplyTo, ccAddresses, bccAddresses, htmlBody, textBody, folderId, labels, headers
|
|
10
|
+
- `Tweet`: tweetId, retweetCount, likeCount, mediaUrls, hashtags, mentions
|
|
11
|
+
- `SlackMessage`: channelId, slackTs, slackThreadTs, reactions, blocks
|
|
12
|
+
|
|
13
|
+
**Accounts** (share `accounts` table):
|
|
14
|
+
- `Account` (base): providerType, credentialSecretId, isActive, lastSyncAt, settings
|
|
15
|
+
- `EmailAccount`, `TwitterAccount`, `SlackAccount`: provider-specific fields + sync methods
|
|
16
|
+
|
|
17
|
+
## Credential Security
|
|
18
|
+
|
|
19
|
+
Account credentials stored via `credentialSecretId` → smrt-secrets. Use `setCredentials()`/`getCredentials()` — never store passwords directly.
|
|
20
|
+
|
|
21
|
+
## Send Lifecycle
|
|
22
|
+
|
|
23
|
+
`message.send()`: resolves account → creates provider sender → updates sendStatus. Retry support with `maxRetries` budget.
|
|
24
|
+
|
|
25
|
+
## Gotchas
|
|
26
|
+
|
|
27
|
+
- **STI `_meta_type`**: qualified format `@happyvertical/smrt-messages:Email`
|
|
28
|
+
- **JSON fields**: all address/metadata fields are JSON strings with `getX()`/`setX()` helpers
|
|
29
|
+
- **RFC 822 threading**: Email uses `inReplyTo`/`messageId`/`references` — manual management required
|
|
30
|
+
- **Attachment.messageId**: use this field (not `emailId`); old getter/setter mapped via deprecation wrapper
|
|
31
|
+
- **Optional tenancy**: `@TenantScoped({ mode: 'optional' })` on Message, Account, Attachment
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright <2025> <Happy Vertical Corporation>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @happyvertical/smrt-messages
|
|
2
|
+
|
|
3
|
+
Unified multi-channel messaging with STI-based channel hierarchies for the SMRT framework. Supports email, Slack, and Twitter as message subtypes, with per-channel sender implementations and encrypted credential storage.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @happyvertical/smrt-messages
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
Email, EmailCollection,
|
|
16
|
+
EmailAccount, EmailAccountCollection,
|
|
17
|
+
EmailSender,
|
|
18
|
+
MessageCollection,
|
|
19
|
+
} from '@happyvertical/smrt-messages';
|
|
20
|
+
|
|
21
|
+
// Create an email account with encrypted credentials
|
|
22
|
+
const accounts = new EmailAccountCollection(db);
|
|
23
|
+
const account = await accounts.create({
|
|
24
|
+
name: 'Support',
|
|
25
|
+
providerType: 'smtp',
|
|
26
|
+
});
|
|
27
|
+
await account.setCredentials({
|
|
28
|
+
host: 'smtp.example.com',
|
|
29
|
+
user: 'support@example.com',
|
|
30
|
+
pass: process.env.SMTP_PASSWORD,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Send an email through the send lifecycle
|
|
34
|
+
const emails = new EmailCollection(db);
|
|
35
|
+
const email = await emails.create({
|
|
36
|
+
accountId: account.id,
|
|
37
|
+
subject: 'Welcome',
|
|
38
|
+
toAddresses: JSON.stringify([{ address: 'user@example.com' }]),
|
|
39
|
+
textBody: 'Thanks for signing up!',
|
|
40
|
+
});
|
|
41
|
+
const result = await email.send();
|
|
42
|
+
// sendStatus transitions: draft -> sending -> sent (or failed)
|
|
43
|
+
|
|
44
|
+
// Retry a failed message (respects maxRetries budget)
|
|
45
|
+
if (!result.success) {
|
|
46
|
+
await email.retrySend();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Query messages across all channels via base collection
|
|
50
|
+
const messages = new MessageCollection(db);
|
|
51
|
+
const recent = await messages.list({ orderBy: 'createdAt DESC', limit: 20 });
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
### Models (STI Hierarchy)
|
|
57
|
+
|
|
58
|
+
Messages and accounts each use single-table inheritance. STI discriminators use qualified names (e.g., `@happyvertical/smrt-messages:Email`).
|
|
59
|
+
|
|
60
|
+
| Export | Description |
|
|
61
|
+
|--------|------------|
|
|
62
|
+
| `Message` | Base message with send lifecycle (draft/sending/sent/failed) |
|
|
63
|
+
| `Email` | Email with RFC 822 threading, cc/bcc, htmlBody/textBody, folders |
|
|
64
|
+
| `SlackMessage` | Slack message with channelId, slackTs, reactions, blocks |
|
|
65
|
+
| `Tweet` | Twitter message with tweetId, retweetCount, likeCount, hashtags |
|
|
66
|
+
| `Account` | Base account with `setCredentials()`/`getCredentials()` via smrt-secrets |
|
|
67
|
+
| `EmailAccount` | Email account (SMTP/IMAP provider) |
|
|
68
|
+
| `SlackAccount` | Slack workspace account |
|
|
69
|
+
| `TwitterAccount` | Twitter API account |
|
|
70
|
+
| `Attachment` | Message attachment |
|
|
71
|
+
| `EmailAttachment` | Email-specific attachment |
|
|
72
|
+
| `EmailFolder` | Email folder/label |
|
|
73
|
+
|
|
74
|
+
### Collections
|
|
75
|
+
|
|
76
|
+
`MessageCollection`, `EmailCollection`, `AccountCollection`, `EmailAccountCollection`, `AttachmentCollection`, `EmailAttachmentCollection`, `EmailFolderCollection`
|
|
77
|
+
|
|
78
|
+
### Senders
|
|
79
|
+
|
|
80
|
+
Each channel has a dedicated sender implementing `MessageSenderInterface`.
|
|
81
|
+
|
|
82
|
+
| Export | Description |
|
|
83
|
+
|--------|------------|
|
|
84
|
+
| `EmailSender` | Send emails via `@happyvertical/email` client |
|
|
85
|
+
| `SlackSender` | Send Slack messages via API |
|
|
86
|
+
| `TweetSender` | Post tweets via Twitter API |
|
|
87
|
+
|
|
88
|
+
### Credential Security
|
|
89
|
+
|
|
90
|
+
Account credentials are stored via `credentialSecretId` pointing to smrt-secrets envelope encryption. Use `account.setCredentials()` and `account.getCredentials()` -- never store passwords as plain fields.
|
|
91
|
+
|
|
92
|
+
### Key Types
|
|
93
|
+
|
|
94
|
+
`MessageType`, `ProviderType`, `SendStatus`, `SendMessageOptions`, `SendEmailOptions`, `SendSlackOptions`, `SendTweetOptions`, `MessageSendResult`, `MessageSenderInterface`, `SyncOptions`, `SyncResult`, `SyncProgress`
|
|
95
|
+
|
|
96
|
+
## Dependencies
|
|
97
|
+
|
|
98
|
+
- `@happyvertical/smrt-core` -- ORM and code generation
|
|
99
|
+
- `@happyvertical/smrt-secrets` -- credential encryption (envelope encryption)
|
|
100
|
+
- `@happyvertical/smrt-tenancy` -- optional multi-tenant scoping
|
|
101
|
+
- `@happyvertical/smrt-types` -- shared type definitions
|
|
102
|
+
- `@happyvertical/email` -- SMTP/IMAP email client
|
|
103
|
+
- Peer: `@happyvertical/smrt-svelte` (optional)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__smrt-register__.d.ts","sourceRoot":"","sources":["../src/__smrt-register__.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { Account } from '../models/Account';
|
|
3
|
+
import { AccountSearchFilters } from '../types';
|
|
4
|
+
export declare class AccountCollection extends SmrtCollection<Account> {
|
|
5
|
+
static readonly _itemClass: typeof Account;
|
|
6
|
+
/**
|
|
7
|
+
* Get active accounts
|
|
8
|
+
*/
|
|
9
|
+
getActive(): Promise<Account[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Get inactive accounts
|
|
12
|
+
*/
|
|
13
|
+
getInactive(): Promise<Account[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get accounts by provider type
|
|
16
|
+
*/
|
|
17
|
+
getByProviderType(providerType: string): Promise<Account[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get accounts by STI type.
|
|
20
|
+
*
|
|
21
|
+
* Accepts either the full discriminator (e.g. "@happyvertical/smrt-messages:EmailAccount")
|
|
22
|
+
* or the short type name (e.g. "EmailAccount").
|
|
23
|
+
*/
|
|
24
|
+
getByType(accountType: string): Promise<Account[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Search accounts with filters
|
|
27
|
+
*/
|
|
28
|
+
search(query: string, filters?: AccountSearchFilters): Promise<Account[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Get account statistics
|
|
31
|
+
*/
|
|
32
|
+
getStats(): Promise<{
|
|
33
|
+
total: number;
|
|
34
|
+
active: number;
|
|
35
|
+
inactive: number;
|
|
36
|
+
byType: Record<string, number>;
|
|
37
|
+
}>;
|
|
38
|
+
findByTenant(tenantId: string): Promise<Account[]>;
|
|
39
|
+
findGlobal(): Promise<Account[]>;
|
|
40
|
+
findWithGlobals(tenantId: string): Promise<Account[]>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=AccountCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountCollection.d.ts","sourceRoot":"","sources":["../../src/collections/AccountCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,CAAC;IAC5D,MAAM,CAAC,QAAQ,CAAC,UAAU,iBAAW;IAErC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIrC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC;;OAEG;IACG,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIjE;;;;;OAKG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAWxD;;OAEG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,OAAO,EAAE,CAAC;IA8BrB;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IAsBI,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIlD,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIhC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAM5D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { Attachment } from '../models/Attachment';
|
|
3
|
+
export declare class AttachmentCollection extends SmrtCollection<Attachment> {
|
|
4
|
+
static readonly _itemClass: typeof Attachment;
|
|
5
|
+
/**
|
|
6
|
+
* Get attachments for a message
|
|
7
|
+
*/
|
|
8
|
+
getByMessage(messageId: string): Promise<Attachment[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Get attachments by content type
|
|
11
|
+
*/
|
|
12
|
+
getByContentType(contentType: string): Promise<Attachment[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Get image attachments
|
|
15
|
+
*/
|
|
16
|
+
getImages(messageId?: string): Promise<Attachment[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Get PDF attachments
|
|
19
|
+
*/
|
|
20
|
+
getPdfs(messageId?: string): Promise<Attachment[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Get inline attachments (embedded in message body)
|
|
23
|
+
*/
|
|
24
|
+
getInline(messageId: string): Promise<Attachment[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get regular attachments (not inline)
|
|
27
|
+
*/
|
|
28
|
+
getRegular(messageId: string): Promise<Attachment[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Get attachments with external files
|
|
31
|
+
*/
|
|
32
|
+
getWithExternalFiles(): Promise<Attachment[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get total size of attachments for a message
|
|
35
|
+
*/
|
|
36
|
+
getTotalSize(messageId: string): Promise<number>;
|
|
37
|
+
/**
|
|
38
|
+
* Get largest attachments
|
|
39
|
+
*/
|
|
40
|
+
getLargest(limit?: number): Promise<Attachment[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Search attachments by filename
|
|
43
|
+
*/
|
|
44
|
+
searchByFilename(query: string): Promise<Attachment[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get attachments by extension
|
|
47
|
+
*/
|
|
48
|
+
getByExtension(extension: string): Promise<Attachment[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Get attachment statistics
|
|
51
|
+
*/
|
|
52
|
+
getStats(): Promise<{
|
|
53
|
+
total: number;
|
|
54
|
+
totalSize: number;
|
|
55
|
+
byType: Record<string, number>;
|
|
56
|
+
inline: number;
|
|
57
|
+
regular: number;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Delete all attachments for a message
|
|
61
|
+
*/
|
|
62
|
+
deleteByMessage(messageId: string): Promise<number>;
|
|
63
|
+
findByTenant(tenantId: string): Promise<Attachment[]>;
|
|
64
|
+
findGlobal(): Promise<Attachment[]>;
|
|
65
|
+
findWithGlobals(tenantId: string): Promise<Attachment[]>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=AttachmentCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentCollection.d.ts","sourceRoot":"","sources":["../../src/collections/AttachmentCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,qBAAa,oBAAqB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAClE,MAAM,CAAC,QAAQ,CAAC,UAA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AC,MAAM,CAAC;IAgBnD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIrD,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAInC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAM/D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { Blacklist } from '../models/Blacklist.js';
|
|
3
|
+
export declare class BlacklistCollection extends SmrtCollection<Blacklist> {
|
|
4
|
+
static readonly _itemClass: typeof Blacklist;
|
|
5
|
+
/**
|
|
6
|
+
* Check if an email is blacklisted
|
|
7
|
+
*/
|
|
8
|
+
isBlacklisted(email: string): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Get the matching blacklist entry for an email
|
|
11
|
+
*/
|
|
12
|
+
getMatchingEntry(email: string): Promise<Blacklist | null>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=BlacklistCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlacklistCollection.d.ts","sourceRoot":"","sources":["../../src/collections/BlacklistCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,SAAS,CAAC;IAChE,MAAM,CAAC,QAAQ,CAAC,UAAU,mBAAa;IAEvC;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpD;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;CAWjE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { EmailAccount } from '../models/EmailAccount';
|
|
2
|
+
import { EmailAccountSearchFilters, ProviderType } from '../types';
|
|
3
|
+
import { AccountCollection } from './AccountCollection';
|
|
4
|
+
export declare class EmailAccountCollection extends AccountCollection {
|
|
5
|
+
static readonly _itemClass: typeof EmailAccount;
|
|
6
|
+
/**
|
|
7
|
+
* Get account by email address
|
|
8
|
+
*/
|
|
9
|
+
getByEmail(email: string): Promise<EmailAccount | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Get accounts by email provider type
|
|
12
|
+
*/
|
|
13
|
+
getByEmailProviderType(providerType: ProviderType): Promise<EmailAccount[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get active email accounts
|
|
16
|
+
*/
|
|
17
|
+
getActive(): Promise<EmailAccount[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get inactive email accounts
|
|
20
|
+
*/
|
|
21
|
+
getInactive(): Promise<EmailAccount[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Get accounts that need syncing
|
|
24
|
+
*/
|
|
25
|
+
getNeedingSync(maxAgeMinutes?: number): Promise<EmailAccount[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Search email accounts with filters.
|
|
28
|
+
* Alias: `search()` for backward compatibility.
|
|
29
|
+
*/
|
|
30
|
+
search(query: string, filters?: EmailAccountSearchFilters): Promise<EmailAccount[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Get accounts by email provider type.
|
|
33
|
+
* Alias: `getByProviderType()` for backward compatibility.
|
|
34
|
+
*/
|
|
35
|
+
getByProviderType(providerType: string): Promise<EmailAccount[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Get email account statistics.
|
|
38
|
+
* Alias: `getStats()` for backward compatibility.
|
|
39
|
+
*/
|
|
40
|
+
getStats(): Promise<{
|
|
41
|
+
total: number;
|
|
42
|
+
active: number;
|
|
43
|
+
inactive: number;
|
|
44
|
+
byType: Record<string, number>;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Search email accounts with filters
|
|
48
|
+
*/
|
|
49
|
+
searchEmailAccounts(query: string, filters?: EmailAccountSearchFilters): Promise<EmailAccount[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Sync all active email accounts
|
|
52
|
+
*/
|
|
53
|
+
syncAll(options?: Record<string, any>): Promise<Map<string, {
|
|
54
|
+
success: boolean;
|
|
55
|
+
error?: Error;
|
|
56
|
+
}>>;
|
|
57
|
+
/**
|
|
58
|
+
* Get total unread count across all email accounts
|
|
59
|
+
*/
|
|
60
|
+
getTotalUnreadCount(): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Get email account statistics
|
|
63
|
+
*/
|
|
64
|
+
getEmailStats(): Promise<{
|
|
65
|
+
total: number;
|
|
66
|
+
active: number;
|
|
67
|
+
inactive: number;
|
|
68
|
+
byProvider: Record<ProviderType, number>;
|
|
69
|
+
}>;
|
|
70
|
+
findByTenant(tenantId: string): Promise<EmailAccount[]>;
|
|
71
|
+
findGlobal(): Promise<EmailAccount[]>;
|
|
72
|
+
findWithGlobals(tenantId: string): Promise<EmailAccount[]>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=EmailAccountCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailAccountCollection.d.ts","sourceRoot":"","sources":["../../src/collections/EmailAccountCollection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D,gBAAyB,UAAU,sBAAgB;IAEnD;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAK7D;;OAEG;IACG,sBAAsB,CAC1B,YAAY,EAAE,YA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CAAC;KAC1C,CAAC;IA6Ba,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAIvD,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAIrC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAM1E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { EmailAttachment } from '../models/EmailAttachment';
|
|
2
|
+
import { AttachmentCollection } from './AttachmentCollection';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use AttachmentCollection instead
|
|
5
|
+
*/
|
|
6
|
+
export declare class EmailAttachmentCollection extends AttachmentCollection {
|
|
7
|
+
static readonly _itemClass: typeof EmailAttachment;
|
|
8
|
+
/**
|
|
9
|
+
* Get attachments for an email
|
|
10
|
+
* @deprecated Use getByMessage() instead
|
|
11
|
+
*/
|
|
12
|
+
getByEmail(emailId: string): Promise<EmailAttachment[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Get image attachments
|
|
15
|
+
*/
|
|
16
|
+
getImages(emailId?: string): Promise<EmailAttachment[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Get PDF attachments
|
|
19
|
+
*/
|
|
20
|
+
getPdfs(emailId?: string): Promise<EmailAttachment[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Get inline attachments
|
|
23
|
+
*/
|
|
24
|
+
getInline(emailId: string): Promise<EmailAttachment[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get regular attachments
|
|
27
|
+
*/
|
|
28
|
+
getRegular(emailId: string): Promise<EmailAttachment[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete all attachments for an email
|
|
31
|
+
* @deprecated Use deleteByMessage() instead
|
|
32
|
+
*/
|
|
33
|
+
deleteByEmail(emailId: string): Promise<number>;
|
|
34
|
+
findByTenant(tenantId: string): Promise<EmailAttachment[]>;
|
|
35
|
+
findGlobal(): Promise<EmailAttachment[]>;
|
|
36
|
+
findWithGlobals(tenantId: string): Promise<EmailAttachment[]>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=EmailAttachmentCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailAttachmentCollection.d.ts","sourceRoot":"","sources":["../../src/collections/EmailAttachmentCollection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,oBAAoB;IACjE,gBAAyB,UAAU,yBAAmB;IAEtD;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAI7D;;OAEG;IACY,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAItE;;OAEG;IACY,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAIpE;;OAEG;IACY,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAIrE;;OAEG;IACY,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAItE;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAI1D,UAAU,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAMxC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAM7E"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Email } from '../models/Email';
|
|
2
|
+
import { EmailSearchFilters } from '../types';
|
|
3
|
+
import { MessageCollection } from './MessageCollection';
|
|
4
|
+
export declare class EmailCollection extends MessageCollection {
|
|
5
|
+
static readonly _itemClass: typeof Email;
|
|
6
|
+
/**
|
|
7
|
+
* Get email by RFC 822 Message-ID
|
|
8
|
+
*/
|
|
9
|
+
getByMessageId(accountId: string, messageId: string): Promise<Email | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Get emails by account
|
|
12
|
+
*/
|
|
13
|
+
getByAccount(accountId: string): Promise<Email[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get emails by folder
|
|
16
|
+
*/
|
|
17
|
+
getByFolder(folderId: string): Promise<Email[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get emails by thread
|
|
20
|
+
*/
|
|
21
|
+
getByThread(threadId: string): Promise<Email[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Get unread emails
|
|
24
|
+
*/
|
|
25
|
+
getUnread(accountId?: string): Promise<Email[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Get flagged emails
|
|
28
|
+
*/
|
|
29
|
+
getFlagged(accountId?: string): Promise<Email[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Get emails with attachments
|
|
32
|
+
*/
|
|
33
|
+
getWithAttachments(accountId?: string): Promise<Email[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Get recent emails
|
|
36
|
+
*/
|
|
37
|
+
getRecent(limit?: number, accountId?: string): Promise<Email[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Count emails in a folder
|
|
40
|
+
*/
|
|
41
|
+
countByFolder(folderId: string): Promise<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Count unread emails in a folder
|
|
44
|
+
*/
|
|
45
|
+
countUnreadByFolder(folderId: string): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Count unread emails for an account
|
|
48
|
+
*/
|
|
49
|
+
countUnreadByAccount(accountId: string): Promise<number>;
|
|
50
|
+
/**
|
|
51
|
+
* Search emails with email-specific filters.
|
|
52
|
+
* Alias: `search()` for backward compatibility.
|
|
53
|
+
*/
|
|
54
|
+
search(query: string, filters?: EmailSearchFilters): Promise<Email[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Search emails with email-specific filters
|
|
57
|
+
*/
|
|
58
|
+
searchEmails(query: string, filters?: EmailSearchFilters): Promise<Email[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Mark all emails in a folder as read
|
|
61
|
+
*/
|
|
62
|
+
markFolderRead(folderId: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete emails by folder
|
|
65
|
+
*/
|
|
66
|
+
deleteByFolder(folderId: string): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Get email statistics for an account
|
|
69
|
+
*/
|
|
70
|
+
getAccountStats(accountId: string): Promise<{
|
|
71
|
+
total: number;
|
|
72
|
+
unread: number;
|
|
73
|
+
flagged: number;
|
|
74
|
+
withAttachments: number;
|
|
75
|
+
byType: Record<string, number>;
|
|
76
|
+
}>;
|
|
77
|
+
findByTenant(tenantId: string): Promise<Email[]>;
|
|
78
|
+
findGlobal(): Promise<Email[]>;
|
|
79
|
+
findWithGlobals(tenantId: string): Promise<Email[]>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=EmailCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailCollection.d.ts","sourceRoot":"","sources":["../../src/collections/EmailCollection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,eAAgB,SAAQ,iBAAiB;IACpD,gBAAyB,UAAU,eAAS;IAE5C;;OAEG;IACG,cAAc,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,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AI,CAAC;IASrD;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYvD;;OAEG;IACY,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACzD,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IAgBa,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAIhD,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAI9B,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAMnE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { EmailFolder } from '../models/EmailFolder';
|
|
3
|
+
import { EmailFolderSearchFilters } from '../types';
|
|
4
|
+
export declare class EmailFolderCollection extends SmrtCollection<EmailFolder> {
|
|
5
|
+
static readonly _itemClass: typeof EmailFolder;
|
|
6
|
+
/**
|
|
7
|
+
* Get folder by path for an account
|
|
8
|
+
*/
|
|
9
|
+
getByPath(accountId: string, path: string): Promise<EmailFolder | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Get folders by account
|
|
12
|
+
*/
|
|
13
|
+
getByAccount(accountId: string): Promise<EmailFolder[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get inbox folder for an account
|
|
16
|
+
*/
|
|
17
|
+
getInbox(accountId: string): Promise<EmailFolder | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Get sent folder for an account
|
|
20
|
+
*/
|
|
21
|
+
getSent(accountId: string): Promise<EmailFolder | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Get drafts folder for an account
|
|
24
|
+
*/
|
|
25
|
+
getDrafts(accountId: string): Promise<EmailFolder | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Get trash folder for an account
|
|
28
|
+
*/
|
|
29
|
+
getTrash(accountId: string): Promise<EmailFolder | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Get spam folder for an account
|
|
32
|
+
*/
|
|
33
|
+
getSpam(accountId: string): Promise<EmailFolder | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Get system folders for an account
|
|
36
|
+
*/
|
|
37
|
+
getSystemFolders(accountId: string): Promise<EmailFolder[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Get user-created folders for an account
|
|
40
|
+
*/
|
|
41
|
+
getUserFolders(accountId: string): Promise<EmailFolder[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Get subscribed folders
|
|
44
|
+
*/
|
|
45
|
+
getSubscribed(accountId?: string): Promise<EmailFolder[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Get folders with unread messages
|
|
48
|
+
*/
|
|
49
|
+
getWithUnread(accountId?: string): Promise<EmailFolder[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Search folders with filters
|
|
52
|
+
*/
|
|
53
|
+
search(query: string, filters?: EmailFolderSearchFilters): Promise<EmailFolder[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Refresh counts for all folders in an account
|
|
56
|
+
*/
|
|
57
|
+
refreshAllCounts(accountId: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Get folder statistics for an account
|
|
60
|
+
*/
|
|
61
|
+
getAccountStats(accountId: string): Promise<{
|
|
62
|
+
totalFolders: number;
|
|
63
|
+
totalMessages: number;
|
|
64
|
+
totalUnread: number;
|
|
65
|
+
systemFolders: number;
|
|
66
|
+
userFolders: number;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Create standard system folders for an account
|
|
70
|
+
*/
|
|
71
|
+
createSystemFolders(accountId: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Find all email folders belonging to a specific tenant
|
|
74
|
+
*/
|
|
75
|
+
findByTenant(tenantId: string): Promise<EmailFolder[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Find all global email folders (no tenant)
|
|
78
|
+
*/
|
|
79
|
+
findGlobal(): Promise<EmailFolder[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Find email folders for a tenant including global folders
|
|
82
|
+
*/
|
|
83
|
+
findWithGlobals(tenantId: string): Promise<EmailFolder[]>;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=EmailFolderCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailFolderCollection.d.ts","sourceRoot":"","sources":["../../src/collections/EmailFolderCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEzD,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,WAAW,CAAC;IACpE,MAAM,CAAC,QAAQ,CAAC,UAAU,qBAAe;IAEzC;;OAEG;IACG,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAK9B;;OAEG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAI7D;;OAEG;IACG,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAK9D;;OAEG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAK7D;;OAEG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAK/D;;OAEG;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