@t4h.framework/smtp 0.7.7 → 0.7.10
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/.ai/skills/framework-smtp/SKILL.md +22 -10
- package/CHANGELOG.md +12 -0
- package/README.md +5 -2
- package/package.json +2 -2
|
@@ -29,20 +29,29 @@ export const environments = EnvDesign({
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
|
+
import { Workflow } from '@t4h.framework/core'
|
|
32
33
|
import { Smtp } from '@t4h.framework/smtp'
|
|
34
|
+
import Type from 'typebox'
|
|
33
35
|
|
|
34
36
|
import { environments } from '../constants/environments.js'
|
|
35
37
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
export const sendReport = new Workflow(
|
|
39
|
+
{ id: 'send-report', schema: Type.Object({ email: Type.String() }) },
|
|
40
|
+
async input => {
|
|
41
|
+
const smtp = new Smtp(environments.SMTP_URL, {
|
|
42
|
+
from: 'noreply@example.com',
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const result = await smtp.send({
|
|
46
|
+
to: input.email,
|
|
47
|
+
subject: 'Report',
|
|
48
|
+
html: '<p>See attached.</p>',
|
|
49
|
+
attachments: [{ filename: 'report.pdf', content: reportBinary }],
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return { messageId: result.messageId }
|
|
53
|
+
},
|
|
54
|
+
)
|
|
46
55
|
```
|
|
47
56
|
|
|
48
57
|
## Traps
|
|
@@ -51,6 +60,8 @@ result.messageId
|
|
|
51
60
|
`sendEmail`.
|
|
52
61
|
- `new Smtp(...)` takes a `Secret`. A string literal or a `String` env entry is
|
|
53
62
|
a type error.
|
|
63
|
+
- Create the client in the workflow body. A test that imports the module has
|
|
64
|
+
no env, so a key read at module top level throws `No env storage`.
|
|
54
65
|
- The body field is `html`. There is no `text` field.
|
|
55
66
|
- An attachment `content` is a `Binary` (from `sftp.get`, an HTTP body, `write`
|
|
56
67
|
of `@t4h.framework/fs`). Never build a `Binary` by hand; see the
|
|
@@ -71,6 +82,7 @@ normalized input: `to`, `cc` and `bcc` are always arrays.
|
|
|
71
82
|
```typescript
|
|
72
83
|
import { TestWorkflowEnvironment, mockClaim } from '@t4h.framework/core/testing'
|
|
73
84
|
import { SmtpSendEmailClaim } from '@t4h.framework/smtp'
|
|
85
|
+
import { expect, vi } from 'vitest'
|
|
74
86
|
|
|
75
87
|
const send = vi.fn().mockResolvedValue({ messageId: 'msg-123' })
|
|
76
88
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @t4h.framework/smtp
|
|
2
2
|
|
|
3
|
+
## 0.7.10
|
|
4
|
+
|
|
5
|
+
## 0.7.9
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#276](https://github.com/tech4humans-brasil/framework/pull/276) [`7b38934`](https://github.com/tech4humans-brasil/framework/commit/7b38934e8f9207c98c33afcd76e3a7a4da7e8b14) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The `framework-smtp` skill creates the `Smtp` client in the workflow body. A
|
|
10
|
+
read of `environments` at the top of the module throws `No env storage`. The
|
|
11
|
+
test sample imports `expect` and `vi` from `vitest`.
|
|
12
|
+
|
|
13
|
+
## 0.7.8
|
|
14
|
+
|
|
3
15
|
## 0.7.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ import { Smtp } from '@t4h.framework/smtp'
|
|
|
31
31
|
|
|
32
32
|
import { environments } from './constants/environments.js'
|
|
33
33
|
|
|
34
|
-
const smtp = new Smtp(environments.SMTP_URL, { from: 'noreply@example.com' })
|
|
35
|
-
|
|
36
34
|
const notify = new Workflow({ id: 'notify' }, async () => {
|
|
35
|
+
const smtp = new Smtp(environments.SMTP_URL, { from: 'noreply@example.com' })
|
|
36
|
+
|
|
37
37
|
const result = await smtp.send({
|
|
38
38
|
to: 'recipient@example.com',
|
|
39
39
|
subject: 'Hello',
|
|
@@ -44,6 +44,9 @@ const notify = new Workflow({ id: 'notify' }, async () => {
|
|
|
44
44
|
})
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Create the `Smtp` client in the workflow body. A test that imports the module
|
|
48
|
+
has no env, so a key read at module top level throws `No env storage`.
|
|
49
|
+
|
|
47
50
|
## Documentation
|
|
48
51
|
|
|
49
52
|
https://tech4humans-brasil.github.io/framework/smtp/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t4h.framework/smtp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "SMTP module for the T4H Framework",
|
|
5
5
|
"homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/smtp",
|
|
6
6
|
"bugs": "https://github.com/tech4humans-brasil/framework/issues",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:watch": "vitest"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@t4h.framework/core": "^0.
|
|
36
|
+
"@t4h.framework/core": "^0.22.0",
|
|
37
37
|
"typescript": "^5.9.3",
|
|
38
38
|
"vitest": "^4.0.18"
|
|
39
39
|
},
|