@productcraft/mail 0.1.2 → 0.2.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 +16 -3
- package/dist/index.d.cts +9631 -4419
- package/dist/index.d.ts +9631 -4419
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,9 +13,8 @@ Server-side only. The SDK ships a Platform API Key in the `Authorization` header
|
|
|
13
13
|
```ts
|
|
14
14
|
import { Mail } from "@productcraft/mail";
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
16
|
+
// Reads PRODUCTCRAFT_API_KEY from the environment
|
|
17
|
+
const mail = new Mail();
|
|
19
18
|
|
|
20
19
|
// Send a template-rendered message
|
|
21
20
|
const { data, error } = await mail.client.POST(
|
|
@@ -39,11 +38,25 @@ const { data, error } = await mail.client.POST(
|
|
|
39
38
|
|
|
40
39
|
The `client` property is an [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) instance bound to `https://api.mail.productcraft.co` and your auth credential. Every endpoint in the published OpenAPI spec is reachable through it — your editor's autocomplete lists paths + method shapes + body fields.
|
|
41
40
|
|
|
41
|
+
## Credentials from the environment
|
|
42
|
+
|
|
43
|
+
Server-side, omit `auth` and the client reads your workspace key from the environment:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# .env
|
|
47
|
+
PRODUCTCRAFT_API_KEY=pcft_live_...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- An explicit `auth` always wins over the environment.
|
|
51
|
+
- Hosts are never read from the environment. Override them in code with `baseUrl`.
|
|
52
|
+
- This is a server-only fallback. Never put a key in `NEXT_PUBLIC_*` or any other variable a bundler inlines into browser code.
|
|
53
|
+
|
|
42
54
|
## Configuration
|
|
43
55
|
|
|
44
56
|
```ts
|
|
45
57
|
new Mail({
|
|
46
58
|
// The auth credential the SDK presents to Mail
|
|
59
|
+
// Omit to use PRODUCTCRAFT_API_KEY from the environment
|
|
47
60
|
auth: { type: "apiKey", key: "pcft_live_..." }
|
|
48
61
|
| { type: "bearer", token: "eyJ..." }
|
|
49
62
|
| { type: "cookie", value: "auth_token=..." },
|