reloop-email 1.0.3
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 +32 -0
- package/README.md +351 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +133 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +49 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +77 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/mail.d.ts +13 -0
- package/dist/services/mail.d.ts.map +1 -0
- package/dist/services/mail.js +15 -0
- package/dist/services/mail.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Copyright (c) 2025 Reloop Labs
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
14
|
+
|
|
15
|
+
----------------------------------------------------------------------
|
|
16
|
+
ADDITIONAL USE RESTRICTIONS (Custom Clause by Reloop Labs)
|
|
17
|
+
----------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
1. You are free to use, copy, modify, and distribute this software for
|
|
20
|
+
personal use and internal company purposes.
|
|
21
|
+
|
|
22
|
+
2. You are NOT permitted to:
|
|
23
|
+
- Sell, sublicense, or otherwise commercially redistribute this software.
|
|
24
|
+
- Offer this software, or any modified version of it, as a hosted service
|
|
25
|
+
(including but not limited to Software-as-a-Service, Platform-as-a-Service,
|
|
26
|
+
or any similar commercial hosting model).
|
|
27
|
+
- Use this software in any product or service whose primary purpose is to
|
|
28
|
+
compete with Reloop Labs.
|
|
29
|
+
|
|
30
|
+
3. For commercial licensing or partnerships, please contact:
|
|
31
|
+
reloop.sh@gmail.com
|
|
32
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# reloop-email
|
|
2
|
+
|
|
3
|
+
Official Reloop Node.js SDK for integrating with Reloop services.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install reloop-email
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import Reloop from 'reloop-email';
|
|
15
|
+
|
|
16
|
+
const reloop = new Reloop({
|
|
17
|
+
url: 'https://reloop.sh',
|
|
18
|
+
key: 'your-api-key'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Send an email
|
|
22
|
+
const result = await reloop.mail.send({
|
|
23
|
+
from: 'sender@example.com',
|
|
24
|
+
to: 'recipient@example.com',
|
|
25
|
+
subject: 'Hello',
|
|
26
|
+
text: 'Hello World!'
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
The Reloop SDK requires two configuration parameters:
|
|
33
|
+
|
|
34
|
+
- `url` - Your Reloop API base URL (e.g., `https://reloop.sh`)
|
|
35
|
+
- `key` - Your API key
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const reloop = new Reloop({
|
|
39
|
+
url: 'https://reloop.sh',
|
|
40
|
+
key: 'your-api-key'
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Services
|
|
45
|
+
|
|
46
|
+
### Mail Service
|
|
47
|
+
|
|
48
|
+
Send emails through the Reloop mail service.
|
|
49
|
+
|
|
50
|
+
#### Send Email
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const result = await reloop.mail.send({
|
|
54
|
+
from: 'sender@example.com',
|
|
55
|
+
to: 'recipient@example.com',
|
|
56
|
+
subject: 'Hello',
|
|
57
|
+
text: 'Plain text content',
|
|
58
|
+
html: '<h1>HTML content</h1>',
|
|
59
|
+
replyTo: 'noreply@example.com',
|
|
60
|
+
cc: 'cc@example.com',
|
|
61
|
+
bcc: ['bcc1@example.com', 'bcc2@example.com']
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(result.messageId);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Domain Service
|
|
68
|
+
|
|
69
|
+
Manage domains and DNS records.
|
|
70
|
+
|
|
71
|
+
#### Create Domain
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const domain = await reloop.domain.create({
|
|
75
|
+
domain: 'send.example.com'
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Get Domain
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const domain = await reloop.domain.get('send.example.com');
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### List Domains
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const domains = await reloop.domain.list({
|
|
89
|
+
page: 1,
|
|
90
|
+
limit: 10,
|
|
91
|
+
status: 'active'
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Delete Domain
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
await reloop.domain.delete('send.example.com');
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### DNS Operations
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Get DNS records
|
|
105
|
+
const records = await reloop.domain.getDNSRecords('send.example.com');
|
|
106
|
+
|
|
107
|
+
// Get DKIM keys
|
|
108
|
+
const dkimKeys = await reloop.domain.getDKIMKeys('send.example.com');
|
|
109
|
+
|
|
110
|
+
// Verify DNS record
|
|
111
|
+
const verification = await reloop.domain.verifyDNSRecord('send.example.com', {
|
|
112
|
+
recordType: 'TXT',
|
|
113
|
+
name: '_reloop',
|
|
114
|
+
value: 'verification-value'
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Generate DNS records
|
|
118
|
+
const generatedRecords = await reloop.domain.generateDNSRecords('send.example.com');
|
|
119
|
+
|
|
120
|
+
// Delete DNS records
|
|
121
|
+
await reloop.domain.deleteDNSRecords('send.example.com');
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Webhook Service
|
|
125
|
+
|
|
126
|
+
Manage webhooks for event notifications.
|
|
127
|
+
|
|
128
|
+
#### Create Webhook
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const webhook = await reloop.webhook.create({
|
|
132
|
+
name: 'My Webhook',
|
|
133
|
+
url: 'https://example.com/webhook',
|
|
134
|
+
secret: 'webhook-secret',
|
|
135
|
+
rateLimitEnabled: true,
|
|
136
|
+
maxRequestsPerMinute: 60
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Get Webhook
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const webhook = await reloop.webhook.get('webhook-id');
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### List Webhooks
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const webhooks = await reloop.webhook.list({
|
|
150
|
+
page: 1,
|
|
151
|
+
limit: 10,
|
|
152
|
+
status: 'active'
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Update Webhook
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const updated = await reloop.webhook.update('webhook-id', {
|
|
160
|
+
name: 'Updated Webhook Name',
|
|
161
|
+
status: 'paused'
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Delete Webhook
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
await reloop.webhook.delete('webhook-id');
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Audience Service
|
|
172
|
+
|
|
173
|
+
Manage audiences and audience groups.
|
|
174
|
+
|
|
175
|
+
#### Create Audience
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
const audience = await reloop.audience.create({
|
|
179
|
+
email: 'user@example.com',
|
|
180
|
+
firstName: 'John',
|
|
181
|
+
lastName: 'Doe',
|
|
182
|
+
audienceGroupId: 'group-id',
|
|
183
|
+
status: 'subscribed'
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Get Audience
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const audience = await reloop.audience.get('audience-id');
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### List Audiences
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const audiences = await reloop.audience.list({
|
|
197
|
+
page: 1,
|
|
198
|
+
limit: 10,
|
|
199
|
+
status: 'subscribed',
|
|
200
|
+
audienceGroupId: 'group-id'
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Update Audience
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const updated = await reloop.audience.update('audience-id', {
|
|
208
|
+
firstName: 'Jane',
|
|
209
|
+
lastName: 'Smith'
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### Delete Audience
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
await reloop.audience.delete('audience-id');
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Bulk Import Audiences
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
const result = await reloop.audience.bulkImport({
|
|
223
|
+
audienceGroupId: 'group-id',
|
|
224
|
+
audiences: [
|
|
225
|
+
{
|
|
226
|
+
email: 'user1@example.com',
|
|
227
|
+
firstName: 'User',
|
|
228
|
+
lastName: 'One'
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
email: 'user2@example.com',
|
|
232
|
+
firstName: 'User',
|
|
233
|
+
lastName: 'Two'
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
console.log(`Imported ${result.successful} audiences`);
|
|
239
|
+
console.log(`Failed: ${result.failed}`);
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### Subscribe/Unsubscribe Audience
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// Subscribe
|
|
246
|
+
await reloop.audience.subscribe('audience-id', {
|
|
247
|
+
reason: 'User opted in'
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Unsubscribe
|
|
251
|
+
await reloop.audience.unsubscribe('audience-id', {
|
|
252
|
+
reason: 'User opted out'
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### Search Audiences
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
const results = await reloop.audience.search({
|
|
260
|
+
query: 'john@example.com',
|
|
261
|
+
page: 1,
|
|
262
|
+
limit: 10
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### Audience Groups
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
// Create audience group
|
|
270
|
+
const group = await reloop.audience.createGroup({
|
|
271
|
+
name: 'My Audience Group',
|
|
272
|
+
description: 'Group description'
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// Get audience group
|
|
276
|
+
const group = await reloop.audience.getGroup('group-id');
|
|
277
|
+
|
|
278
|
+
// List audience groups
|
|
279
|
+
const groups = await reloop.audience.listGroups({
|
|
280
|
+
page: 1,
|
|
281
|
+
limit: 10
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Update audience group
|
|
285
|
+
const updated = await reloop.audience.updateGroup('group-id', {
|
|
286
|
+
name: 'Updated Group Name'
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Delete audience group
|
|
290
|
+
await reloop.audience.deleteGroup('group-id');
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Error Handling
|
|
294
|
+
|
|
295
|
+
The SDK provides custom error classes for better error handling:
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
import {
|
|
299
|
+
ReloopError,
|
|
300
|
+
APIError,
|
|
301
|
+
AuthenticationError,
|
|
302
|
+
NotFoundError,
|
|
303
|
+
RateLimitError,
|
|
304
|
+
ServerError,
|
|
305
|
+
ValidationError
|
|
306
|
+
} from 'reloop-email';
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
await reloop.mail.send({...});
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (error instanceof AuthenticationError) {
|
|
312
|
+
console.error('Authentication failed');
|
|
313
|
+
} else if (error instanceof NotFoundError) {
|
|
314
|
+
console.error('Resource not found');
|
|
315
|
+
} else if (error instanceof RateLimitError) {
|
|
316
|
+
console.error('Rate limit exceeded');
|
|
317
|
+
} else if (error instanceof APIError) {
|
|
318
|
+
console.error(`API error: ${error.message} (${error.statusCode})`);
|
|
319
|
+
} else {
|
|
320
|
+
console.error('Unknown error:', error);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## TypeScript Support
|
|
326
|
+
|
|
327
|
+
The SDK is written in TypeScript and provides full type definitions. All request and response types are exported:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
import type {
|
|
331
|
+
SendEmailRequest,
|
|
332
|
+
SendEmailResponse,
|
|
333
|
+
DomainResponse,
|
|
334
|
+
WebhookResponse,
|
|
335
|
+
AudienceResponse
|
|
336
|
+
} from 'reloop-email';
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Requirements
|
|
340
|
+
|
|
341
|
+
- Node.js >= 18.0.0
|
|
342
|
+
|
|
343
|
+
## License
|
|
344
|
+
|
|
345
|
+
Apache-2.0
|
|
346
|
+
|
|
347
|
+
## Support
|
|
348
|
+
|
|
349
|
+
- Documentation: https://reloop.sh/docs
|
|
350
|
+
- Issues: https://github.com/reloop-labs/reloop/issues
|
|
351
|
+
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ReloopConfig {
|
|
2
|
+
url?: string;
|
|
3
|
+
key: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class HTTPClient {
|
|
6
|
+
private baseURL;
|
|
7
|
+
private apiKey;
|
|
8
|
+
constructor(config: ReloopConfig);
|
|
9
|
+
private getHeaders;
|
|
10
|
+
private handleResponse;
|
|
11
|
+
get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
|
|
12
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
13
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
14
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
15
|
+
delete<T>(path: string): Promise<T>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,qBAAa,UAAU;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,YAAY;IAchC,OAAO,CAAC,UAAU;YAQJ,cAAc;IA6EtB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAyBlE,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAUjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAUhD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAUlD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAQzC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { APIError, AuthenticationError, NotFoundError, RateLimitError, ServerError, } from "./errors.js";
|
|
2
|
+
export class HTTPClient {
|
|
3
|
+
baseURL;
|
|
4
|
+
apiKey;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
// Normalize base URL (remove trailing slash)
|
|
7
|
+
const url = config.url || "https://reloop.sh";
|
|
8
|
+
this.baseURL = url.replace(/\/+$/, "");
|
|
9
|
+
this.apiKey = config.key;
|
|
10
|
+
if (!this.baseURL) {
|
|
11
|
+
throw new Error("Base URL is required");
|
|
12
|
+
}
|
|
13
|
+
if (!this.apiKey) {
|
|
14
|
+
throw new Error("API key is required");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
getHeaders() {
|
|
18
|
+
return {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
21
|
+
"X-API-Key": this.apiKey, // Fallback header
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async handleResponse(response) {
|
|
25
|
+
const contentType = response.headers.get("content-type");
|
|
26
|
+
const isJSON = contentType?.includes("application/json");
|
|
27
|
+
let data;
|
|
28
|
+
try {
|
|
29
|
+
data = isJSON ? await response.json() : await response.text();
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
data = { message: "Failed to parse response" };
|
|
33
|
+
}
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const status = response.status;
|
|
36
|
+
const statusText = response.statusText;
|
|
37
|
+
// Handle specific error cases
|
|
38
|
+
if (status === 401) {
|
|
39
|
+
throw new AuthenticationError(typeof data === "object" &&
|
|
40
|
+
data !== null &&
|
|
41
|
+
"message" in data &&
|
|
42
|
+
typeof data.message === "string"
|
|
43
|
+
? data.message
|
|
44
|
+
: "Authentication failed");
|
|
45
|
+
}
|
|
46
|
+
if (status === 404) {
|
|
47
|
+
throw new NotFoundError(typeof data === "object" &&
|
|
48
|
+
data !== null &&
|
|
49
|
+
"message" in data &&
|
|
50
|
+
typeof data.message === "string"
|
|
51
|
+
? data.message
|
|
52
|
+
: "Resource not found");
|
|
53
|
+
}
|
|
54
|
+
if (status === 429) {
|
|
55
|
+
throw new RateLimitError(typeof data === "object" &&
|
|
56
|
+
data !== null &&
|
|
57
|
+
"message" in data &&
|
|
58
|
+
typeof data.message === "string"
|
|
59
|
+
? data.message
|
|
60
|
+
: "Rate limit exceeded");
|
|
61
|
+
}
|
|
62
|
+
if (status >= 500) {
|
|
63
|
+
throw new ServerError(typeof data === "object" &&
|
|
64
|
+
data !== null &&
|
|
65
|
+
"message" in data &&
|
|
66
|
+
typeof data.message === "string"
|
|
67
|
+
? data.message
|
|
68
|
+
: "Internal server error");
|
|
69
|
+
}
|
|
70
|
+
// Generic API error
|
|
71
|
+
throw new APIError(typeof data === "object" &&
|
|
72
|
+
data !== null &&
|
|
73
|
+
"message" in data &&
|
|
74
|
+
typeof data.message === "string"
|
|
75
|
+
? data.message
|
|
76
|
+
: `Request failed with status ${status}`, status, statusText, data);
|
|
77
|
+
}
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
async get(path, params) {
|
|
81
|
+
let url = `${this.baseURL}${path}`;
|
|
82
|
+
// Add query parameters if provided
|
|
83
|
+
if (params && Object.keys(params).length > 0) {
|
|
84
|
+
const searchParams = new URLSearchParams();
|
|
85
|
+
for (const [key, value] of Object.entries(params)) {
|
|
86
|
+
if (value !== undefined && value !== null) {
|
|
87
|
+
searchParams.append(key, String(value));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const queryString = searchParams.toString();
|
|
91
|
+
if (queryString) {
|
|
92
|
+
url += `?${queryString}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const response = await fetch(url, {
|
|
96
|
+
method: "GET",
|
|
97
|
+
headers: this.getHeaders(),
|
|
98
|
+
});
|
|
99
|
+
return this.handleResponse(response);
|
|
100
|
+
}
|
|
101
|
+
async post(path, body) {
|
|
102
|
+
const response = await fetch(`${this.baseURL}${path}`, {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers: this.getHeaders(),
|
|
105
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
106
|
+
});
|
|
107
|
+
return this.handleResponse(response);
|
|
108
|
+
}
|
|
109
|
+
async put(path, body) {
|
|
110
|
+
const response = await fetch(`${this.baseURL}${path}`, {
|
|
111
|
+
method: "PUT",
|
|
112
|
+
headers: this.getHeaders(),
|
|
113
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
114
|
+
});
|
|
115
|
+
return this.handleResponse(response);
|
|
116
|
+
}
|
|
117
|
+
async patch(path, body) {
|
|
118
|
+
const response = await fetch(`${this.baseURL}${path}`, {
|
|
119
|
+
method: "PATCH",
|
|
120
|
+
headers: this.getHeaders(),
|
|
121
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
122
|
+
});
|
|
123
|
+
return this.handleResponse(response);
|
|
124
|
+
}
|
|
125
|
+
async delete(path) {
|
|
126
|
+
const response = await fetch(`${this.baseURL}${path}`, {
|
|
127
|
+
method: "DELETE",
|
|
128
|
+
headers: this.getHeaders(),
|
|
129
|
+
});
|
|
130
|
+
return this.handleResponse(response);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,WAAW,GACX,MAAM,aAAa,CAAC;AAOrB,MAAM,OAAO,UAAU;IACd,OAAO,CAAS;IAChB,MAAM,CAAS;IAEvB,YAAY,MAAoB;QAC/B,6CAA6C;QAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,mBAAmB,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC;QAEzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;IAEO,UAAU;QACjB,OAAO;YACN,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;YACtC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,kBAAkB;SAC5C,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,cAAc,CAAI,QAAkB;QACjD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,WAAW,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAEzD,IAAI,IAAa,CAAC;QAClB,IAA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tD,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC7C,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,cAAc,CAAI,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,MAAM,CAAI,IAAY;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE;YACtD,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;SAC1B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,cAAc,CAAI,QAAQ,CAAC,CAAC;IACzC,CAAC;CACD"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Reloop SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class ReloopError extends Error {
|
|
5
|
+
readonly code?: string | undefined;
|
|
6
|
+
constructor(message: string, code?: string | undefined);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when an API request fails
|
|
10
|
+
*/
|
|
11
|
+
export declare class APIError extends ReloopError {
|
|
12
|
+
readonly statusCode: number;
|
|
13
|
+
readonly statusText?: string | undefined;
|
|
14
|
+
readonly response?: unknown | undefined;
|
|
15
|
+
readonly code?: string | undefined;
|
|
16
|
+
constructor(message: string, statusCode: number, statusText?: string | undefined, response?: unknown | undefined, code?: string | undefined);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when authentication fails
|
|
20
|
+
*/
|
|
21
|
+
export declare class AuthenticationError extends APIError {
|
|
22
|
+
constructor(message?: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when a resource is not found
|
|
26
|
+
*/
|
|
27
|
+
export declare class NotFoundError extends APIError {
|
|
28
|
+
constructor(message?: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when validation fails
|
|
32
|
+
*/
|
|
33
|
+
export declare class ValidationError extends ReloopError {
|
|
34
|
+
readonly fields?: Record<string, string[]> | undefined;
|
|
35
|
+
constructor(message: string, fields?: Record<string, string[]> | undefined);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when a rate limit is exceeded
|
|
39
|
+
*/
|
|
40
|
+
export declare class RateLimitError extends APIError {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when the server returns an error
|
|
45
|
+
*/
|
|
46
|
+
export declare class ServerError extends APIError {
|
|
47
|
+
constructor(message?: string);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;aAGpB,IAAI,CAAC,EAAE,MAAM;gBAD7B,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA;CAM9B;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,WAAW;aAGvB,UAAU,EAAE,MAAM;aAClB,UAAU,CAAC,EAAE,MAAM;aACnB,QAAQ,CAAC,EAAE,OAAO;aAClB,IAAI,CAAC,EAAE,MAAM;gBAJ7B,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,QAAQ,CAAC,EAAE,OAAO,YAAA,EAClB,IAAI,CAAC,EAAE,MAAM,YAAA;CAK9B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACpC,OAAO,SAA0B;CAI7C;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,QAAQ;gBAC9B,OAAO,SAAuB;CAI1C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;aAG9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBADjD,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,YAAA;CAKlD;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC/B,OAAO,SAAwB;CAI3C;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,QAAQ;gBAC5B,OAAO,SAA0B;CAI7C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Reloop SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export class ReloopError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
constructor(message, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.name = this.constructor.name;
|
|
10
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when an API request fails
|
|
15
|
+
*/
|
|
16
|
+
export class APIError extends ReloopError {
|
|
17
|
+
statusCode;
|
|
18
|
+
statusText;
|
|
19
|
+
response;
|
|
20
|
+
code;
|
|
21
|
+
constructor(message, statusCode, statusText, response, code) {
|
|
22
|
+
super(message, code);
|
|
23
|
+
this.statusCode = statusCode;
|
|
24
|
+
this.statusText = statusText;
|
|
25
|
+
this.response = response;
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.name = "APIError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when authentication fails
|
|
32
|
+
*/
|
|
33
|
+
export class AuthenticationError extends APIError {
|
|
34
|
+
constructor(message = "Authentication failed") {
|
|
35
|
+
super(message, 401, "Unauthorized", undefined, "AUTH_ERROR");
|
|
36
|
+
this.name = "AuthenticationError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error thrown when a resource is not found
|
|
41
|
+
*/
|
|
42
|
+
export class NotFoundError extends APIError {
|
|
43
|
+
constructor(message = "Resource not found") {
|
|
44
|
+
super(message, 404, "Not Found", undefined, "NOT_FOUND");
|
|
45
|
+
this.name = "NotFoundError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when validation fails
|
|
50
|
+
*/
|
|
51
|
+
export class ValidationError extends ReloopError {
|
|
52
|
+
fields;
|
|
53
|
+
constructor(message, fields) {
|
|
54
|
+
super(message, "VALIDATION_ERROR");
|
|
55
|
+
this.fields = fields;
|
|
56
|
+
this.name = "ValidationError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when a rate limit is exceeded
|
|
61
|
+
*/
|
|
62
|
+
export class RateLimitError extends APIError {
|
|
63
|
+
constructor(message = "Rate limit exceeded") {
|
|
64
|
+
super(message, 429, "Too Many Requests", undefined, "RATE_LIMIT");
|
|
65
|
+
this.name = "RateLimitError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Error thrown when the server returns an error
|
|
70
|
+
*/
|
|
71
|
+
export class ServerError extends APIError {
|
|
72
|
+
constructor(message = "Internal server error") {
|
|
73
|
+
super(message, 500, "Internal Server Error", undefined, "SERVER_ERROR");
|
|
74
|
+
this.name = "ServerError";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGpB;IAFjB,YACC,OAAe,EACC,IAAa;QAE7B,KAA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AAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC3C,YAAY,OAAO,GAAG,qBAAqB;QAC1C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACxC,YAAY,OAAO,GAAG,uBAAuB;QAC5C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,uBAAuB,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC3B,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReloopConfig } from "./client.js";
|
|
2
|
+
import { MailService } from "./services/mail.js";
|
|
3
|
+
export declare class Reloop {
|
|
4
|
+
readonly mail: MailService;
|
|
5
|
+
/**
|
|
6
|
+
* Create a new Reloop SDK client
|
|
7
|
+
* @param config Configuration object with url and key
|
|
8
|
+
*/
|
|
9
|
+
constructor(config: ReloopConfig);
|
|
10
|
+
}
|
|
11
|
+
export default Reloop;
|
|
12
|
+
export type { ReloopConfig } from "./client.js";
|
|
13
|
+
export * from "./errors.js";
|
|
14
|
+
export * from "./types.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,qBAAa,MAAM;IAClB,SAAgB,IAAI,EAAE,WAAW,CAAC;IAElC;;;OAGG;gBACS,MAAM,EAAE,YAAY;CAKhC;AAED,eAAe,MAAM,CAAC;AAEtB,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,cAAc,aAAa,CAAC;AAE5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTTPClient } from "./client.js";
|
|
2
|
+
import { MailService } from "./services/mail.js";
|
|
3
|
+
export class Reloop {
|
|
4
|
+
mail;
|
|
5
|
+
/**
|
|
6
|
+
* Create a new Reloop SDK client
|
|
7
|
+
* @param config Configuration object with url and key
|
|
8
|
+
*/
|
|
9
|
+
constructor(config) {
|
|
10
|
+
const client = new HTTPClient(config);
|
|
11
|
+
this.mail = new MailService(client);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default Reloop;
|
|
15
|
+
export * from "./errors.js";
|
|
16
|
+
// Export types
|
|
17
|
+
export * from "./types.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,MAAM;IACF,IAAI,CAAc;IAElC;;;OAGG;IACH,YAAY,MAAoB;QAC/B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QAEtC,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACD;AAED,eAAe,MAAM,CAAC;AAGtB,cAAc,aAAa,CAAC;AAC5B,eAAe;AACf,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HTTPClient } from "../client.js";
|
|
2
|
+
import type { SendEmailRequest, SendEmailResponse } from "../types.js";
|
|
3
|
+
export declare class MailService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HTTPClient);
|
|
6
|
+
/**
|
|
7
|
+
* Send an email
|
|
8
|
+
* @param data Email data including to, from, subject, and content
|
|
9
|
+
* @returns Promise resolving to the send email response
|
|
10
|
+
*/
|
|
11
|
+
send(data: SendEmailRequest): Promise<SendEmailResponse>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/services/mail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEvE,qBAAa,WAAW;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;OAIG;IACG,IAAI,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAG9D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class MailService {
|
|
2
|
+
client;
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Send an email
|
|
8
|
+
* @param data Email data including to, from, subject, and content
|
|
9
|
+
* @returns Promise resolving to the send email response
|
|
10
|
+
*/
|
|
11
|
+
async send(data) {
|
|
12
|
+
return this.client.post("/api/mail/v1/send", data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=mail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.js","sourceRoot":"","sources":["../../src/services/mail.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAW;IACH;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,IAAsB;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAoB,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACvE,CAAC;CACD"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Reloop SDK
|
|
3
|
+
*/
|
|
4
|
+
export interface Attachment {
|
|
5
|
+
content?: string | unknown;
|
|
6
|
+
filename?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
contentId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Tag {
|
|
12
|
+
name: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
export interface TemplateOptions {
|
|
16
|
+
id: string;
|
|
17
|
+
variables?: Record<string, string | number>;
|
|
18
|
+
}
|
|
19
|
+
export interface SendEmailRequest {
|
|
20
|
+
from: string;
|
|
21
|
+
to: string | string[];
|
|
22
|
+
subject: string;
|
|
23
|
+
text?: string;
|
|
24
|
+
html?: string;
|
|
25
|
+
replyTo?: string | string[];
|
|
26
|
+
cc?: string | string[];
|
|
27
|
+
bcc?: string | string[];
|
|
28
|
+
scheduledAt?: string;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
channelId?: string;
|
|
31
|
+
attachments?: Attachment[];
|
|
32
|
+
tags?: Tag[];
|
|
33
|
+
template?: TemplateOptions;
|
|
34
|
+
}
|
|
35
|
+
export interface SendEmailResponse {
|
|
36
|
+
success: boolean;
|
|
37
|
+
messageId: string;
|
|
38
|
+
status: string;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC5C;AAGD,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "reloop-email",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Official Reloop Node.js SDK for integrating with Reloop services",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"reloop",
|
|
20
|
+
"sdk",
|
|
21
|
+
"node",
|
|
22
|
+
"email",
|
|
23
|
+
"mail"
|
|
24
|
+
],
|
|
25
|
+
"author": "Reloop",
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/reloop-labs/reloop.git",
|
|
33
|
+
"directory": "sdk/node"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^20.0.0",
|
|
40
|
+
"typescript": "^5.9.2"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"import": "./dist/index.js",
|
|
46
|
+
"types": "./dist/index.d.ts"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|