@postalsys/ee-client 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Postal Systems OÜ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # @postalsys/ee-client
2
+
3
+ EmailEngine client library for browser and Node.js applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @postalsys/ee-client
9
+ ```
10
+
11
+ For Node.js environments, you may also need to install `node-fetch`:
12
+
13
+ ```bash
14
+ npm install node-fetch
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Browser
20
+
21
+ ```javascript
22
+ import { EmailEngineClient } from '@postalsys/ee-client';
23
+
24
+ // Create client with UI container
25
+ const client = new EmailEngineClient({
26
+ apiUrl: 'https://your-emailengine-server.com',
27
+ account: 'your-account-id',
28
+ accessToken: 'your-access-token',
29
+ container: document.getElementById('email-client')
30
+ });
31
+ ```
32
+
33
+ ### Node.js
34
+
35
+ ```javascript
36
+ import { EmailEngineClient } from '@postalsys/ee-client';
37
+
38
+ // Create client for API-only usage
39
+ const client = new EmailEngineClient({
40
+ apiUrl: 'https://your-emailengine-server.com',
41
+ account: 'your-account-id',
42
+ accessToken: 'your-access-token'
43
+ });
44
+
45
+ // Load folders
46
+ const folders = await client.loadFolders();
47
+
48
+ // Load messages from INBOX
49
+ const { messages } = await client.loadMessages('INBOX');
50
+
51
+ // Load a specific message
52
+ const message = await client.loadMessage(messages[0].id);
53
+ ```
54
+
55
+ ### CommonJS
56
+
57
+ ```javascript
58
+ const { EmailEngineClient } = require('@postalsys/ee-client');
59
+
60
+ const client = new EmailEngineClient({
61
+ apiUrl: 'https://your-emailengine-server.com',
62
+ account: 'your-account-id',
63
+ accessToken: 'your-access-token'
64
+ });
65
+ ```
66
+
67
+ ## API
68
+
69
+ ### Constructor Options
70
+
71
+ - `apiUrl` (string, optional): EmailEngine API URL. Defaults to `http://127.0.0.1:3000`
72
+ - `account` (string, required): Account identifier
73
+ - `accessToken` (string, optional): Access token for authentication
74
+ - `container` (HTMLElement, optional): DOM container for UI components (browser only)
75
+
76
+ ### Methods
77
+
78
+ #### `loadFolders(): Promise<Folder[]>`
79
+
80
+ Load all folders/mailboxes for the account.
81
+
82
+ #### `loadMessages(path: string, cursor?: string): Promise<MessageListResponse>`
83
+
84
+ Load messages from a specific folder.
85
+
86
+ #### `loadMessage(messageId: string): Promise<Message>`
87
+
88
+ Load a specific message by ID.
89
+
90
+ #### `markAsRead(messageId: string, seen?: boolean): Promise<boolean>`
91
+
92
+ Mark a message as read or unread.
93
+
94
+ #### `deleteMessage(messageId: string): Promise<boolean>`
95
+
96
+ Delete a message.
97
+
98
+ #### `moveMessage(messageId: string, targetPath: string): Promise<boolean>`
99
+
100
+ Move a message to another folder.
101
+
102
+ ## Browser UI
103
+
104
+ When used in a browser with a container element, the client automatically creates a full email interface with:
105
+
106
+ - Folder tree navigation
107
+ - Message list with pagination
108
+ - Message viewer with actions (mark as read/unread, delete, move)
109
+ - Responsive design
110
+
111
+ ```html
112
+ <div id="email-client" style="height: 600px;"></div>
113
+ <script type="module">
114
+ import { EmailEngineClient } from '@postalsys/ee-client';
115
+
116
+ new EmailEngineClient({
117
+ apiUrl: 'https://your-emailengine-server.com',
118
+ account: 'your-account-id',
119
+ accessToken: 'your-access-token',
120
+ container: document.getElementById('email-client')
121
+ });
122
+ </script>
123
+ ```
124
+
125
+ ## License
126
+
127
+ MIT © Postal Systems OÜ