mailmark 0.1.0 → 0.1.2
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/README.md +7 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -13,25 +13,25 @@ npm install mailmark
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import {
|
|
16
|
+
import { Mailmark } from 'mailmark';
|
|
17
17
|
|
|
18
|
-
const client = new
|
|
18
|
+
const client = new Mailmark('dm_live_your_api_key');
|
|
19
19
|
|
|
20
20
|
await client.send({
|
|
21
21
|
from: 'hello@yourdomain.com',
|
|
22
22
|
to: ['recipient@example.com'],
|
|
23
|
-
subject: 'Hello from
|
|
24
|
-
html: '<h1>Hello!</h1><p>This email was sent via the
|
|
23
|
+
subject: 'Hello from Mailmark',
|
|
24
|
+
html: '<h1>Hello!</h1><p>This email was sent via the Mailmark API.</p>',
|
|
25
25
|
});
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## API
|
|
29
29
|
|
|
30
|
-
### `new
|
|
30
|
+
### `new Mailmark(apiKey, options?)`
|
|
31
31
|
|
|
32
32
|
| Parameter | Type | Description |
|
|
33
33
|
|-----------|------|-------------|
|
|
34
|
-
| `apiKey` | `string` | Your API key from the
|
|
34
|
+
| `apiKey` | `string` | Your API key from the Mailmark Developer dashboard |
|
|
35
35
|
| `options.baseUrl` | `string` | Override the API base URL (for self-hosted) |
|
|
36
36
|
|
|
37
37
|
### `client.send(options)`
|
|
@@ -46,7 +46,7 @@ await client.send({
|
|
|
46
46
|
|
|
47
47
|
Returns `Promise<{ messageId: string; status: "queued" }>`.
|
|
48
48
|
|
|
49
|
-
Throws `
|
|
49
|
+
Throws `MailmarkError` on API errors, with `.status` (HTTP status) and `.response` (parsed body).
|
|
50
50
|
|
|
51
51
|
## cURL Equivalent
|
|
52
52
|
|
package/dist/index.d.ts
CHANGED
|
@@ -14,20 +14,20 @@ export interface SendEmailResult {
|
|
|
14
14
|
messageId: string;
|
|
15
15
|
status: "queued";
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface MailmarkOptions {
|
|
18
18
|
/** Override the default API base URL. Useful for self-hosted instances. */
|
|
19
19
|
baseUrl?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare class
|
|
21
|
+
export declare class MailmarkError extends Error {
|
|
22
22
|
readonly status: number;
|
|
23
23
|
readonly response: unknown;
|
|
24
24
|
constructor(message: string, status: number, response: unknown);
|
|
25
25
|
}
|
|
26
|
-
export declare class
|
|
26
|
+
export declare class Mailmark {
|
|
27
27
|
private readonly apiKey;
|
|
28
28
|
private readonly baseUrl;
|
|
29
|
-
constructor(apiKey: string, options?:
|
|
29
|
+
constructor(apiKey: string, options?: MailmarkOptions);
|
|
30
30
|
send(options: SendEmailOptions): Promise<SendEmailResult>;
|
|
31
31
|
}
|
|
32
|
-
export default
|
|
32
|
+
export default Mailmark;
|
|
33
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAc,SAAQ,KAAK;aAGpB,MAAM,EAAE,MAAM;aACd,QAAQ,EAAE,OAAO;gBAFjC,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO;CAKpC;AAID,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;IAMnD,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CAqChE;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -30,24 +30,24 @@ var __export = (target, all) => {
|
|
|
30
30
|
var exports_src = {};
|
|
31
31
|
__export(exports_src, {
|
|
32
32
|
default: () => src_default,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
MailmarkError: () => MailmarkError,
|
|
34
|
+
Mailmark: () => Mailmark
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(exports_src);
|
|
37
37
|
|
|
38
|
-
class
|
|
38
|
+
class MailmarkError extends Error {
|
|
39
39
|
status;
|
|
40
40
|
response;
|
|
41
41
|
constructor(message, status, response) {
|
|
42
42
|
super(message);
|
|
43
43
|
this.status = status;
|
|
44
44
|
this.response = response;
|
|
45
|
-
this.name = "
|
|
45
|
+
this.name = "MailmarkError";
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
var DEFAULT_BASE_URL = "https://harmless-armadillo-386.convex.site";
|
|
49
49
|
|
|
50
|
-
class
|
|
50
|
+
class Mailmark {
|
|
51
51
|
apiKey;
|
|
52
52
|
baseUrl;
|
|
53
53
|
constructor(apiKey, options = {}) {
|
|
@@ -83,9 +83,9 @@ class Devmail {
|
|
|
83
83
|
});
|
|
84
84
|
const data = await res.json();
|
|
85
85
|
if (!res.ok) {
|
|
86
|
-
throw new
|
|
86
|
+
throw new MailmarkError(data.error ?? `Request failed with status ${res.status}`, res.status, data);
|
|
87
87
|
}
|
|
88
88
|
return data;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
var src_default =
|
|
91
|
+
var src_default = Mailmark;
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
class
|
|
2
|
+
class MailmarkError extends Error {
|
|
3
3
|
status;
|
|
4
4
|
response;
|
|
5
5
|
constructor(message, status, response) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.status = status;
|
|
8
8
|
this.response = response;
|
|
9
|
-
this.name = "
|
|
9
|
+
this.name = "MailmarkError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
var DEFAULT_BASE_URL = "https://harmless-armadillo-386.convex.site";
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class Mailmark {
|
|
15
15
|
apiKey;
|
|
16
16
|
baseUrl;
|
|
17
17
|
constructor(apiKey, options = {}) {
|
|
@@ -47,14 +47,14 @@ class Devmail {
|
|
|
47
47
|
});
|
|
48
48
|
const data = await res.json();
|
|
49
49
|
if (!res.ok) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new MailmarkError(data.error ?? `Request failed with status ${res.status}`, res.status, data);
|
|
51
51
|
}
|
|
52
52
|
return data;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
var src_default =
|
|
55
|
+
var src_default = Mailmark;
|
|
56
56
|
export {
|
|
57
57
|
src_default as default,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
MailmarkError,
|
|
59
|
+
Mailmark
|
|
60
60
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailmark",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Official Node.js SDK for the
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Official Node.js SDK for the Mailmark transactional email API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
"dev": "bun --watch run build.ts",
|
|
18
18
|
"prepublishOnly": "bun run build"
|
|
19
19
|
},
|
|
20
|
-
"keywords": [
|
|
20
|
+
"keywords": [
|
|
21
|
+
"email",
|
|
22
|
+
"transactional",
|
|
23
|
+
"devmail",
|
|
24
|
+
"sdk"
|
|
25
|
+
],
|
|
21
26
|
"license": "MIT",
|
|
22
27
|
"devDependencies": {
|
|
23
28
|
"typescript": "^5.0.0"
|