@absolutejs/dispatch-postmark 0.0.1
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 +92 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +10 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @absolutejs/dispatch-postmark
|
|
2
|
+
|
|
3
|
+
Postmark-backed `EmailAdapter` for
|
|
4
|
+
[@absolutejs/dispatch](https://github.com/absolutejs/dispatch).
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
bun add @absolutejs/dispatch @absolutejs/dispatch-postmark postmark
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { ServerClient } from 'postmark';
|
|
16
|
+
import { createDispatcher } from '@absolutejs/dispatch';
|
|
17
|
+
import { createPostmarkAdapter } from '@absolutejs/dispatch-postmark';
|
|
18
|
+
|
|
19
|
+
const postmark = new ServerClient(process.env.POSTMARK_SERVER_TOKEN!);
|
|
20
|
+
|
|
21
|
+
const dispatcher = createDispatcher({
|
|
22
|
+
email: createPostmarkAdapter({
|
|
23
|
+
client: postmark,
|
|
24
|
+
defaultFrom: 'no-reply@acme.io',
|
|
25
|
+
// Optional — defaults to Postmark's transactional stream.
|
|
26
|
+
// messageStream: 'broadcast',
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await dispatcher.email({
|
|
31
|
+
to: 'alice@example.com',
|
|
32
|
+
subject: 'Welcome to Acme',
|
|
33
|
+
text: 'Click here to verify: ...',
|
|
34
|
+
// metadata.tag → Postmark Tag (single-string analytics segment);
|
|
35
|
+
// other string entries → Postmark Metadata (string→string map):
|
|
36
|
+
metadata: { tag: 'onboarding', campaign: 'welcome-v2' },
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
createPostmarkAdapter({
|
|
44
|
+
client, // Required — your `new ServerClient(serverToken)`
|
|
45
|
+
defaultFrom?, // Required if your messages don't set `from`
|
|
46
|
+
messageStream?, // Default: Postmark's transactional stream
|
|
47
|
+
mapMetadata?, // Customize EmailMessage.metadata → Postmark Tag/Metadata
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `mapMetadata`
|
|
52
|
+
|
|
53
|
+
By default the adapter:
|
|
54
|
+
|
|
55
|
+
- Extracts `metadata.tag` (string) into Postmark's `Tag` field
|
|
56
|
+
(a single-string analytics segment per message)
|
|
57
|
+
- Maps every OTHER **string-valued** entry into Postmark's `Metadata`
|
|
58
|
+
(a string→string map)
|
|
59
|
+
- Filters out non-string values (Postmark Metadata values must be
|
|
60
|
+
strings)
|
|
61
|
+
|
|
62
|
+
Override to customize:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
createPostmarkAdapter({
|
|
66
|
+
client: postmark,
|
|
67
|
+
mapMetadata: (metadata) => ({
|
|
68
|
+
Tag: typeof metadata.flow === 'string' ? metadata.flow : 'transactional',
|
|
69
|
+
Metadata: { tenant: String(metadata.tenant ?? 'unknown') },
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Error mapping
|
|
75
|
+
|
|
76
|
+
Postmark's response shape:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
{ MessageID, SubmittedAt, To, ErrorCode, Message }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- `ErrorCode !== 0` (and not undefined) → adapter throws with
|
|
83
|
+
`Postmark ErrorCode <n>: <Message>`. `@absolutejs/dispatch`'s error
|
|
84
|
+
path records the exception on the `dispatch.email.send` span, bumps
|
|
85
|
+
the failed counter, and emits `dispatch.email.failed`.
|
|
86
|
+
- `ErrorCode === 0` (or undefined) → treated as success.
|
|
87
|
+
`DispatchResult.id` = `response.MessageID`.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
[Apache 2.0](../LICENSE). Tier B substrate-adjacent — rides
|
|
92
|
+
`@absolutejs/dispatch` (BSL Tier A) and `postmark` (MIT).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @absolutejs/dispatch-postmark — Postmark-backed `EmailAdapter` for
|
|
3
|
+
* `@absolutejs/dispatch`.
|
|
4
|
+
*
|
|
5
|
+
* Takes the user's Postmark `ServerClient`. Maps `EmailMessage` to
|
|
6
|
+
* Postmark's `sendEmail` params; surfaces `MessageID` as
|
|
7
|
+
* `DispatchResult.id`.
|
|
8
|
+
*
|
|
9
|
+
* Postmark's response shape:
|
|
10
|
+
* ```
|
|
11
|
+
* { To, SubmittedAt, MessageID, ErrorCode, Message }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* `ErrorCode !== 0` indicates a Postmark-side rejection (validation,
|
|
15
|
+
* suppression, etc). The adapter throws so
|
|
16
|
+
* `@absolutejs/dispatch`'s error path runs (`dispatch.email.failed`
|
|
17
|
+
* audit event, span ERROR, failed counter).
|
|
18
|
+
*/
|
|
19
|
+
import type { EmailAdapter } from '@absolutejs/dispatch';
|
|
20
|
+
/**
|
|
21
|
+
* Minimal subset of Postmark's `ServerClient` we use. Declaring it
|
|
22
|
+
* locally keeps `postmark` a true peer dep — types aren't required at
|
|
23
|
+
* compile time.
|
|
24
|
+
*/
|
|
25
|
+
export type PostmarkClientLike = {
|
|
26
|
+
sendEmail: (params: {
|
|
27
|
+
From: string;
|
|
28
|
+
To: string;
|
|
29
|
+
Subject: string;
|
|
30
|
+
TextBody?: string;
|
|
31
|
+
HtmlBody?: string;
|
|
32
|
+
ReplyTo?: string;
|
|
33
|
+
Cc?: string;
|
|
34
|
+
Bcc?: string;
|
|
35
|
+
Headers?: Array<{
|
|
36
|
+
Name: string;
|
|
37
|
+
Value: string;
|
|
38
|
+
}>;
|
|
39
|
+
Tag?: string;
|
|
40
|
+
Metadata?: Record<string, string>;
|
|
41
|
+
MessageStream?: string;
|
|
42
|
+
}) => Promise<{
|
|
43
|
+
MessageID?: string;
|
|
44
|
+
SubmittedAt?: string;
|
|
45
|
+
To?: string;
|
|
46
|
+
ErrorCode?: number;
|
|
47
|
+
Message?: string;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
export type CreatePostmarkAdapterOptions = {
|
|
51
|
+
/** The Postmark client (`new ServerClient(serverToken)`). */
|
|
52
|
+
client: PostmarkClientLike;
|
|
53
|
+
/**
|
|
54
|
+
* Default `From` address. Postmark REQUIRES `From`; if neither the
|
|
55
|
+
* message nor this default is set, the adapter throws.
|
|
56
|
+
*/
|
|
57
|
+
defaultFrom?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Postmark message stream. Postmark separates "transactional" and
|
|
60
|
+
* "broadcast" streams; default is `'outbound'` (transactional).
|
|
61
|
+
* Override to send to a broadcast stream when appropriate.
|
|
62
|
+
*/
|
|
63
|
+
messageStream?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Map `EmailMessage.metadata` to Postmark's `Metadata` (a string→
|
|
66
|
+
* string map). Default: passes through string-valued entries
|
|
67
|
+
* (Postmark Metadata values must be strings).
|
|
68
|
+
*
|
|
69
|
+
* Also extracts a `tag` field from metadata into Postmark's `Tag`
|
|
70
|
+
* (a single string per message, used for segmenting analytics).
|
|
71
|
+
*/
|
|
72
|
+
mapMetadata?: (metadata: Record<string, unknown>) => {
|
|
73
|
+
Metadata?: Record<string, string>;
|
|
74
|
+
Tag?: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare const createPostmarkAdapter: (options: CreatePostmarkAdapterOptions) => EmailAdapter;
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;QACpD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClC,GAAG,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;CACF,CAAC;AAsCF,eAAO,MAAM,qBAAqB,GACjC,SAAS,4BAA4B,KACnC,YAgEF,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/index.ts
|
|
3
|
+
var arrayOrUndefined = (value) => {
|
|
4
|
+
if (value === undefined)
|
|
5
|
+
return;
|
|
6
|
+
if (typeof value === "string")
|
|
7
|
+
return value;
|
|
8
|
+
return value.join(",");
|
|
9
|
+
};
|
|
10
|
+
var headersToPostmark = (headers) => {
|
|
11
|
+
if (headers === undefined)
|
|
12
|
+
return;
|
|
13
|
+
const entries = Object.entries(headers);
|
|
14
|
+
if (entries.length === 0)
|
|
15
|
+
return;
|
|
16
|
+
return entries.map(([Name, Value]) => ({ Name, Value }));
|
|
17
|
+
};
|
|
18
|
+
var defaultMapMetadata = (metadata) => {
|
|
19
|
+
const Metadata = {};
|
|
20
|
+
let Tag;
|
|
21
|
+
for (const [name, value] of Object.entries(metadata)) {
|
|
22
|
+
if (typeof value !== "string")
|
|
23
|
+
continue;
|
|
24
|
+
if (name === "tag") {
|
|
25
|
+
Tag = value;
|
|
26
|
+
} else {
|
|
27
|
+
Metadata[name] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
...Object.keys(Metadata).length > 0 ? { Metadata } : {},
|
|
32
|
+
...Tag !== undefined ? { Tag } : {}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var createPostmarkAdapter = (options) => {
|
|
36
|
+
const { client } = options;
|
|
37
|
+
const messageStream = options.messageStream;
|
|
38
|
+
const mapMetadata = options.mapMetadata ?? defaultMapMetadata;
|
|
39
|
+
return {
|
|
40
|
+
name: "postmark",
|
|
41
|
+
send: async (message) => {
|
|
42
|
+
const From = message.from ?? options.defaultFrom;
|
|
43
|
+
if (From === undefined || From.length === 0) {
|
|
44
|
+
throw new Error("[dispatch-postmark] no `From` address \u2014 Postmark requires one. " + "Pass `message.from` per send, or `createPostmarkAdapter({ defaultFrom })`.");
|
|
45
|
+
}
|
|
46
|
+
const To = arrayOrUndefined(message.to) ?? "";
|
|
47
|
+
const meta = message.metadata !== undefined ? mapMetadata(message.metadata) : {};
|
|
48
|
+
const response = await client.sendEmail({
|
|
49
|
+
From,
|
|
50
|
+
Subject: message.subject,
|
|
51
|
+
To,
|
|
52
|
+
...message.text !== undefined ? { TextBody: message.text } : {},
|
|
53
|
+
...message.html !== undefined ? { HtmlBody: message.html } : {},
|
|
54
|
+
...message.replyTo !== undefined ? { ReplyTo: message.replyTo } : {},
|
|
55
|
+
...arrayOrUndefined(message.cc) !== undefined ? { Cc: arrayOrUndefined(message.cc) } : {},
|
|
56
|
+
...arrayOrUndefined(message.bcc) !== undefined ? { Bcc: arrayOrUndefined(message.bcc) } : {},
|
|
57
|
+
...headersToPostmark(message.headers) !== undefined ? { Headers: headersToPostmark(message.headers) } : {},
|
|
58
|
+
...meta.Metadata !== undefined ? { Metadata: meta.Metadata } : {},
|
|
59
|
+
...meta.Tag !== undefined ? { Tag: meta.Tag } : {},
|
|
60
|
+
...messageStream !== undefined ? { MessageStream: messageStream } : {}
|
|
61
|
+
});
|
|
62
|
+
if (response.ErrorCode !== undefined && response.ErrorCode !== 0) {
|
|
63
|
+
throw new Error(`[dispatch-postmark] Postmark ErrorCode ${response.ErrorCode}: ${response.Message ?? "(no message)"}`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
at: Date.now(),
|
|
67
|
+
...response.MessageID !== undefined ? { id: response.MessageID } : {},
|
|
68
|
+
provider: "postmark"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
createPostmarkAdapter
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
//# debugId=05FB3BE117E9BCC564756E2164756E21
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @absolutejs/dispatch-postmark — Postmark-backed `EmailAdapter` for\n * `@absolutejs/dispatch`.\n *\n * Takes the user's Postmark `ServerClient`. Maps `EmailMessage` to\n * Postmark's `sendEmail` params; surfaces `MessageID` as\n * `DispatchResult.id`.\n *\n * Postmark's response shape:\n * ```\n * { To, SubmittedAt, MessageID, ErrorCode, Message }\n * ```\n *\n * `ErrorCode !== 0` indicates a Postmark-side rejection (validation,\n * suppression, etc). The adapter throws so\n * `@absolutejs/dispatch`'s error path runs (`dispatch.email.failed`\n * audit event, span ERROR, failed counter).\n */\nimport type { EmailAdapter, EmailMessage } from '@absolutejs/dispatch';\n\n/**\n * Minimal subset of Postmark's `ServerClient` we use. Declaring it\n * locally keeps `postmark` a true peer dep — types aren't required at\n * compile time.\n */\nexport type PostmarkClientLike = {\n\tsendEmail: (params: {\n\t\tFrom: string;\n\t\tTo: string;\n\t\tSubject: string;\n\t\tTextBody?: string;\n\t\tHtmlBody?: string;\n\t\tReplyTo?: string;\n\t\tCc?: string;\n\t\tBcc?: string;\n\t\tHeaders?: Array<{ Name: string; Value: string }>;\n\t\tTag?: string;\n\t\tMetadata?: Record<string, string>;\n\t\tMessageStream?: string;\n\t}) => Promise<{\n\t\tMessageID?: string;\n\t\tSubmittedAt?: string;\n\t\tTo?: string;\n\t\tErrorCode?: number;\n\t\tMessage?: string;\n\t}>;\n};\n\nexport type CreatePostmarkAdapterOptions = {\n\t/** The Postmark client (`new ServerClient(serverToken)`). */\n\tclient: PostmarkClientLike;\n\t/**\n\t * Default `From` address. Postmark REQUIRES `From`; if neither the\n\t * message nor this default is set, the adapter throws.\n\t */\n\tdefaultFrom?: string;\n\t/**\n\t * Postmark message stream. Postmark separates \"transactional\" and\n\t * \"broadcast\" streams; default is `'outbound'` (transactional).\n\t * Override to send to a broadcast stream when appropriate.\n\t */\n\tmessageStream?: string;\n\t/**\n\t * Map `EmailMessage.metadata` to Postmark's `Metadata` (a string→\n\t * string map). Default: passes through string-valued entries\n\t * (Postmark Metadata values must be strings).\n\t *\n\t * Also extracts a `tag` field from metadata into Postmark's `Tag`\n\t * (a single string per message, used for segmenting analytics).\n\t */\n\tmapMetadata?: (metadata: Record<string, unknown>) => {\n\t\tMetadata?: Record<string, string>;\n\t\tTag?: string;\n\t};\n};\n\nconst arrayOrUndefined = (\n\tvalue: string | ReadonlyArray<string> | undefined\n): string | undefined => {\n\tif (value === undefined) return undefined;\n\tif (typeof value === 'string') return value;\n\treturn value.join(',');\n};\n\nconst headersToPostmark = (\n\theaders: Record<string, string> | undefined\n): Array<{ Name: string; Value: string }> | undefined => {\n\tif (headers === undefined) return undefined;\n\tconst entries = Object.entries(headers);\n\tif (entries.length === 0) return undefined;\n\treturn entries.map(([Name, Value]) => ({ Name, Value }));\n};\n\nconst defaultMapMetadata = (\n\tmetadata: Record<string, unknown>\n): { Metadata?: Record<string, string>; Tag?: string } => {\n\tconst Metadata: Record<string, string> = {};\n\tlet Tag: string | undefined;\n\tfor (const [name, value] of Object.entries(metadata)) {\n\t\tif (typeof value !== 'string') continue;\n\t\tif (name === 'tag') {\n\t\t\tTag = value;\n\t\t} else {\n\t\t\tMetadata[name] = value;\n\t\t}\n\t}\n\treturn {\n\t\t...(Object.keys(Metadata).length > 0 ? { Metadata } : {}),\n\t\t...(Tag !== undefined ? { Tag } : {})\n\t};\n};\n\nexport const createPostmarkAdapter = (\n\toptions: CreatePostmarkAdapterOptions\n): EmailAdapter => {\n\tconst { client } = options;\n\tconst messageStream = options.messageStream;\n\tconst mapMetadata = options.mapMetadata ?? defaultMapMetadata;\n\n\treturn {\n\t\tname: 'postmark',\n\t\tsend: async (message: EmailMessage) => {\n\t\t\tconst From = message.from ?? options.defaultFrom;\n\t\t\tif (From === undefined || From.length === 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'[dispatch-postmark] no `From` address — Postmark requires one. ' +\n\t\t\t\t\t\t'Pass `message.from` per send, or `createPostmarkAdapter({ defaultFrom })`.'\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst To = arrayOrUndefined(message.to) ?? '';\n\t\t\tconst meta =\n\t\t\t\tmessage.metadata !== undefined\n\t\t\t\t\t? mapMetadata(message.metadata)\n\t\t\t\t\t: {};\n\t\t\tconst response = await client.sendEmail({\n\t\t\t\tFrom,\n\t\t\t\tSubject: message.subject,\n\t\t\t\tTo,\n\t\t\t\t...(message.text !== undefined\n\t\t\t\t\t? { TextBody: message.text }\n\t\t\t\t\t: {}),\n\t\t\t\t...(message.html !== undefined\n\t\t\t\t\t? { HtmlBody: message.html }\n\t\t\t\t\t: {}),\n\t\t\t\t...(message.replyTo !== undefined\n\t\t\t\t\t? { ReplyTo: message.replyTo }\n\t\t\t\t\t: {}),\n\t\t\t\t...(arrayOrUndefined(message.cc) !== undefined\n\t\t\t\t\t? { Cc: arrayOrUndefined(message.cc)! }\n\t\t\t\t\t: {}),\n\t\t\t\t...(arrayOrUndefined(message.bcc) !== undefined\n\t\t\t\t\t? { Bcc: arrayOrUndefined(message.bcc)! }\n\t\t\t\t\t: {}),\n\t\t\t\t...(headersToPostmark(message.headers) !== undefined\n\t\t\t\t\t? { Headers: headersToPostmark(message.headers)! }\n\t\t\t\t\t: {}),\n\t\t\t\t...(meta.Metadata !== undefined\n\t\t\t\t\t? { Metadata: meta.Metadata }\n\t\t\t\t\t: {}),\n\t\t\t\t...(meta.Tag !== undefined ? { Tag: meta.Tag } : {}),\n\t\t\t\t...(messageStream !== undefined\n\t\t\t\t\t? { MessageStream: messageStream }\n\t\t\t\t\t: {})\n\t\t\t});\n\t\t\tif (response.ErrorCode !== undefined && response.ErrorCode !== 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[dispatch-postmark] Postmark ErrorCode ${response.ErrorCode}: ${response.Message ?? '(no message)'}`\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tat: Date.now(),\n\t\t\t\t...(response.MessageID !== undefined\n\t\t\t\t\t? { id: response.MessageID }\n\t\t\t\t\t: {}),\n\t\t\t\tprovider: 'postmark'\n\t\t\t};\n\t\t}\n\t};\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AA4EA,IAAM,mBAAmB,CACxB,UACwB;AAAA,EACxB,IAAI,UAAU;AAAA,IAAW;AAAA,EACzB,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO;AAAA,EACtC,OAAO,MAAM,KAAK,GAAG;AAAA;AAGtB,IAAM,oBAAoB,CACzB,YACwD;AAAA,EACxD,IAAI,YAAY;AAAA,IAAW;AAAA,EAC3B,MAAM,UAAU,OAAO,QAAQ,OAAO;AAAA,EACtC,IAAI,QAAQ,WAAW;AAAA,IAAG;AAAA,EAC1B,OAAO,QAAQ,IAAI,EAAE,MAAM,YAAY,EAAE,MAAM,MAAM,EAAE;AAAA;AAGxD,IAAM,qBAAqB,CAC1B,aACyD;AAAA,EACzD,MAAM,WAAmC,CAAC;AAAA,EAC1C,IAAI;AAAA,EACJ,YAAY,MAAM,UAAU,OAAO,QAAQ,QAAQ,GAAG;AAAA,IACrD,IAAI,OAAO,UAAU;AAAA,MAAU;AAAA,IAC/B,IAAI,SAAS,OAAO;AAAA,MACnB,MAAM;AAAA,IACP,EAAO;AAAA,MACN,SAAS,QAAQ;AAAA;AAAA,EAEnB;AAAA,EACA,OAAO;AAAA,OACF,OAAO,KAAK,QAAQ,EAAE,SAAS,IAAI,EAAE,SAAS,IAAI,CAAC;AAAA,OACnD,QAAQ,YAAY,EAAE,IAAI,IAAI,CAAC;AAAA,EACpC;AAAA;AAGM,IAAM,wBAAwB,CACpC,YACkB;AAAA,EAClB,QAA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AAS,cAAc,aAAa,SAAS,cAAc,GAAG;AAAA,QACjE,MAAM,IAAI,MACT,0CAA0C,SAAS,cAAc,SAAS,WAAW,gBACtF;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,IAAI,KAAK,IAAI;AAAA,WACT,SAAS,cAAc,YACxB,EAAE,IAAI,SAAS,UAAU,IACzB,CAAC;AAAA,QACJ,UAAU;AAAA,MACX;AAAA;AAAA,EAEF;AAAA;",
|
|
8
|
+
"debugId": "05FB3BE117E9BCC564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@absolutejs/dispatch-postmark",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Postmark-backed EmailAdapter for @absolutejs/dispatch. Maps EmailMessage to Postmark's sendEmail params; surfaces the MessageID as DispatchResult.id.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/absolutejs/dispatch-adapters.git",
|
|
8
|
+
"directory": "postmark"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"author": "Alex Kahn",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"dispatch",
|
|
21
|
+
"email",
|
|
22
|
+
"postmark",
|
|
23
|
+
"absolutejs",
|
|
24
|
+
"transactional"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun --external @absolutejs/dispatch --external postmark && tsc --project tsconfig.build.json",
|
|
28
|
+
"test": "bun test",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"format": "prettier --write \"./**/*.{ts,json,md}\"",
|
|
31
|
+
"release": "bun run format && bun run build && bun publish"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@absolutejs/dispatch": ">= 0.0.1",
|
|
35
|
+
"postmark": ">= 4.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@absolutejs/dispatch": "^0.0.1",
|
|
39
|
+
"@types/bun": "1.3.14",
|
|
40
|
+
"postmark": "^4.0.0",
|
|
41
|
+
"prettier": "3.5.3",
|
|
42
|
+
"typescript": "5.8.3"
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"import": "./dist/index.js",
|
|
48
|
+
"default": "./dist/index.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md"
|
|
54
|
+
]
|
|
55
|
+
}
|