@sapiom/tools 0.10.2 → 0.12.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +2 -1
  3. package/dist/cjs/_client/capability-call.d.ts +58 -0
  4. package/dist/cjs/_client/capability-call.d.ts.map +1 -0
  5. package/dist/cjs/_client/capability-call.js +68 -0
  6. package/dist/cjs/_client/capability-call.js.map +1 -0
  7. package/dist/cjs/_client/index.d.ts +1 -0
  8. package/dist/cjs/_client/index.d.ts.map +1 -1
  9. package/dist/cjs/_client/index.js +4 -1
  10. package/dist/cjs/_client/index.js.map +1 -1
  11. package/dist/cjs/client.d.ts +60 -0
  12. package/dist/cjs/client.d.ts.map +1 -1
  13. package/dist/cjs/client.js +32 -0
  14. package/dist/cjs/client.js.map +1 -1
  15. package/dist/cjs/content-generation/index.d.ts +6 -0
  16. package/dist/cjs/content-generation/index.d.ts.map +1 -1
  17. package/dist/cjs/content-generation/index.js +32 -20
  18. package/dist/cjs/content-generation/index.js.map +1 -1
  19. package/dist/cjs/email/errors.d.ts +16 -0
  20. package/dist/cjs/email/errors.d.ts.map +1 -0
  21. package/dist/cjs/email/errors.js +36 -0
  22. package/dist/cjs/email/errors.js.map +1 -0
  23. package/dist/cjs/email/index.d.ts +391 -0
  24. package/dist/cjs/email/index.d.ts.map +1 -0
  25. package/dist/cjs/email/index.js +465 -0
  26. package/dist/cjs/email/index.js.map +1 -0
  27. package/dist/cjs/index.d.ts +3 -1
  28. package/dist/cjs/index.d.ts.map +1 -1
  29. package/dist/cjs/index.js +4 -1
  30. package/dist/cjs/index.js.map +1 -1
  31. package/dist/cjs/search/index.d.ts +6 -1
  32. package/dist/cjs/search/index.d.ts.map +1 -1
  33. package/dist/cjs/search/index.js +89 -90
  34. package/dist/cjs/search/index.js.map +1 -1
  35. package/dist/cjs/stub/index.d.ts.map +1 -1
  36. package/dist/cjs/stub/index.js +116 -0
  37. package/dist/cjs/stub/index.js.map +1 -1
  38. package/dist/esm/_client/capability-call.d.ts +58 -0
  39. package/dist/esm/_client/capability-call.d.ts.map +1 -0
  40. package/dist/esm/_client/capability-call.js +64 -0
  41. package/dist/esm/_client/capability-call.js.map +1 -0
  42. package/dist/esm/_client/index.d.ts +1 -0
  43. package/dist/esm/_client/index.d.ts.map +1 -1
  44. package/dist/esm/_client/index.js +1 -0
  45. package/dist/esm/_client/index.js.map +1 -1
  46. package/dist/esm/client.d.ts +60 -0
  47. package/dist/esm/client.d.ts.map +1 -1
  48. package/dist/esm/client.js +32 -0
  49. package/dist/esm/client.js.map +1 -1
  50. package/dist/esm/content-generation/index.d.ts +6 -0
  51. package/dist/esm/content-generation/index.d.ts.map +1 -1
  52. package/dist/esm/content-generation/index.js +33 -21
  53. package/dist/esm/content-generation/index.js.map +1 -1
  54. package/dist/esm/email/errors.d.ts +16 -0
  55. package/dist/esm/email/errors.d.ts.map +1 -0
  56. package/dist/esm/email/errors.js +31 -0
  57. package/dist/esm/email/errors.js.map +1 -0
  58. package/dist/esm/email/index.d.ts +391 -0
  59. package/dist/esm/email/index.d.ts.map +1 -0
  60. package/dist/esm/email/index.js +446 -0
  61. package/dist/esm/email/index.js.map +1 -0
  62. package/dist/esm/index.d.ts +3 -1
  63. package/dist/esm/index.d.ts.map +1 -1
  64. package/dist/esm/index.js +3 -1
  65. package/dist/esm/index.js.map +1 -1
  66. package/dist/esm/search/index.d.ts +6 -1
  67. package/dist/esm/search/index.d.ts.map +1 -1
  68. package/dist/esm/search/index.js +91 -92
  69. package/dist/esm/search/index.js.map +1 -1
  70. package/dist/esm/stub/index.d.ts.map +1 -1
  71. package/dist/esm/stub/index.js +116 -0
  72. package/dist/esm/stub/index.js.map +1 -1
  73. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  74. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  75. package/package.json +6 -1
  76. package/src/email/README.md +96 -0
@@ -0,0 +1,96 @@
1
+ # email
2
+
3
+ Programmatic transactional email. Create real, addressable inboxes, send and
4
+ receive messages, manage custom sending domains, read conversation threads, and
5
+ register webhooks for inbound events. Call it directly from your code, or from
6
+ within Sapiom workflow steps.
7
+
8
+ ```typescript
9
+ import { createClient } from "@sapiom/tools";
10
+ const sapiom = createClient({ apiKey: process.env.SAPIOM_API_KEY });
11
+
12
+ // Create an inbox, then send from it.
13
+ const inbox = await sapiom.email.inboxes.create({ username: "support" });
14
+ await sapiom.email.messages.send(inbox.inboxId, {
15
+ to: "customer@example.com",
16
+ subject: "Welcome",
17
+ text: "Thanks for signing up!",
18
+ });
19
+
20
+ // Read what came in, and reply to it.
21
+ const { messages } = await sapiom.email.messages.list(inbox.inboxId);
22
+ const full = await sapiom.email.messages.get(
23
+ inbox.inboxId,
24
+ messages[0].messageId,
25
+ );
26
+ await sapiom.email.messages.reply(inbox.inboxId, full.messageId, {
27
+ text: "Happy to help!",
28
+ });
29
+ ```
30
+
31
+ Ambient import works too: `import { email } from "@sapiom/tools"`.
32
+
33
+ ## Operations
34
+
35
+ Operations are grouped by resource:
36
+
37
+ - **`inboxes`** — `create`, `list`, `get`, `delete`
38
+ - **`messages`** — `send`, `list`, `get`, `reply`, `replyAll`, `forward`
39
+ - **`domains`** — `create`, `verify`, `get`, `list`, `delete`
40
+ - **`threads`** — `list`, `get`
41
+ - **`webhooks`** — `create`, `delete`
42
+
43
+ ## Inboxes
44
+
45
+ An inbox is a real mailbox you own. Its `inboxId` **is its email address** — use it
46
+ directly as the recipient of inbound mail and as the first argument to every message
47
+ and thread call. `create` accepts an optional `username`, `displayName`, and a
48
+ verified custom `domain` (see below); omit them and you get a generated address on
49
+ the default domain.
50
+
51
+ ## Messages
52
+
53
+ - `send` requires `to` (a single address or an array) and takes `cc` / `bcc` /
54
+ `replyTo`, `subject`, `text` and/or `html`, `labels`, and custom `headers`.
55
+ - `list` returns **metadata only** — no body. Call `get` for the full message,
56
+ which additionally includes `text` / `html` and `extractedText` / `extractedHtml`
57
+ (the "new" content with quoted reply history stripped — what you usually want when
58
+ processing a reply).
59
+ - `reply`, `replyAll`, and `forward` all return `{ messageId, threadId }`.
60
+ - Custom `headers` may not set address, identity, routing, or MIME headers (e.g.
61
+ `To`, `From`, `Reply-To`, `Subject`, `Content-Type`) — use the dedicated fields
62
+ for those; such headers are rejected.
63
+
64
+ ## Domains
65
+
66
+ To send from your own domain, register it with `domains.create({ domain })`. The
67
+ response includes the DNS `records` you must publish. Once published, call
68
+ `domains.verify(domainId)`, then re-fetch with `domains.get(domainId)` to read the
69
+ updated `status` (`PENDING` → `VERIFIED`). `domains.list` returns domains without
70
+ their `status`/`records`; use `get` for the full detail.
71
+
72
+ ## Threads
73
+
74
+ A thread groups the messages of a conversation. `threads.list` returns thread
75
+ summaries (without messages); `threads.get` returns the full thread including its
76
+ `messages` array.
77
+
78
+ ## Webhooks
79
+
80
+ `webhooks.create({ url, eventType })` registers an HTTPS endpoint to receive inbound
81
+ events (e.g. `"message.received"`, or `"*"` for all). The response includes a
82
+ `secret` **returned only once** — store it to verify the signature on delivered
83
+ events.
84
+
85
+ ## Gotchas
86
+
87
+ - **`inboxId` is the email address.** It contains `@` (and often `.`); pass it
88
+ as-is — the client handles URL encoding.
89
+ - **`list` is metadata-only.** `messages.list` and `threads.list` omit bodies /
90
+ messages; fetch the individual resource with `get` to read content.
91
+ - **The webhook `secret` is shown once.** It is present only on the `create`
92
+ response; capture it then.
93
+ - **Pagination** is cursor-based: pass the previous response's `nextPageToken` back
94
+ as `pageToken`.
95
+ - **Failed requests throw `EmailHttpError`** (carries `status` + parsed `body`),
96
+ exported from `@sapiom/tools`.