stacks 0.47.2 → 0.48.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/buddy/art/social.png +0 -0
- package/buddy/package.json +1 -1
- package/buddy/src/commands/make.ts +27 -12
- package/buddy/src/commands/test.ts +40 -2
- package/core/actions/package.json +2 -2
- package/core/actions/src/helpers/utils.ts +21 -1
- package/core/actions/src/make.ts +37 -6
- package/core/actions/src/test-coverage.ts +1 -1
- package/core/actions/src/test-feature.ts +5 -0
- package/core/actions/src/test-unit.ts +5 -0
- package/core/ai/package.json +1 -1
- package/core/alias/package.json +1 -1
- package/core/alias/src/index.ts +8 -0
- package/core/arrays/package.json +1 -1
- package/core/auth/package.json +1 -1
- package/core/build/package.json +3 -3
- package/core/cache/package.json +3 -3
- package/core/chat/README.md +33 -40
- package/core/chat/package.json +4 -5
- package/core/cli/package.json +1 -1
- package/core/cloud/package.json +1 -1
- package/core/collections/package.json +1 -1
- package/core/config/package.json +1 -1
- package/core/dashboard/package.json +1 -1
- package/core/database/package.json +1 -1
- package/core/datetime/package.json +1 -1
- package/core/desktop/package.json +1 -1
- package/core/docs/node_modules/.bin/vitepress +2 -2
- package/core/docs/package.json +2 -2
- package/core/domains/package.json +1 -1
- package/core/drivers/package.json +1 -1
- package/core/email/README.md +101 -35
- package/core/email/package.json +10 -2
- package/core/email/src/utils/config.ts +1 -1
- package/core/error-handling/package.json +2 -2
- package/core/events/package.json +1 -1
- package/core/git/package.json +1 -1
- package/core/health/package.json +1 -1
- package/core/lint/node_modules/.bin/eslint +2 -2
- package/core/lint/package.json +3 -3
- package/core/logging/package.json +1 -1
- package/core/modules/package.json +1 -1
- package/core/notifications/README.md +7 -2
- package/core/notifications/package.json +5 -1
- package/core/notifications/src/drivers/chat.ts +1 -0
- package/core/notifications/src/drivers/email.ts +1 -0
- package/core/notifications/src/drivers/push.ts +1 -0
- package/core/notifications/src/drivers/sms.ts +1 -0
- package/core/notifications/src/index.ts +37 -9
- package/core/notifications/src/utils/config.ts +2 -2
- package/core/notifications/tests/chat/Slack.test.ts +5 -4
- package/core/notifications/tests/email/Mailgun.test.ts +4 -3
- package/core/notifications/tests/email/Sendgrid.test.ts +3 -3
- package/core/notifications/tests/sms/Twilio.test.ts +3 -3
- package/core/objects/package.json +1 -1
- package/core/path/package.json +1 -1
- package/core/path/src/index.ts +25 -0
- package/core/payments/package.json +1 -1
- package/core/push/README.md +24 -42
- package/core/push/package.json +1 -1
- package/core/realtime/package.json +1 -1
- package/core/router/package.json +1 -1
- package/core/search-engine/package.json +1 -1
- package/core/security/package.json +1 -1
- package/core/server/package.json +1 -1
- package/core/sms/README.md +82 -35
- package/core/sms/package.json +10 -4
- package/core/storage/package.json +1 -1
- package/core/storage/src/index.ts +13 -0
- package/core/strings/README.md +10 -2
- package/core/strings/package.json +4 -2
- package/core/strings/src/case.ts +14 -0
- package/core/strings/src/index.ts +4 -97
- package/core/strings/src/pluralize.ts +1 -0
- package/core/strings/src/utils.ts +80 -0
- package/core/strings/src/validation.ts +182 -0
- package/core/tables/README.md +109 -0
- package/core/tables/examples/vue/App.vue +12 -0
- package/core/tables/examples/vue/favicon.png +0 -0
- package/core/tables/examples/vue/index.html +20 -0
- package/core/tables/examples/web/favicon.png +0 -0
- package/core/tables/examples/web/index.html +13 -0
- package/core/tables/node_modules/.bin/mkdist +17 -0
- package/core/tables/node_modules/.bin/tsc +17 -0
- package/core/tables/node_modules/.bin/tsserver +17 -0
- package/core/tables/node_modules/.bin/unbuild +17 -0
- package/core/tables/package.json +97 -0
- package/core/tables/src/cli/index.ts +1 -0
- package/core/tables/src/components/Demo.vue +89 -0
- package/core/tables/src/components/README.md +111 -0
- package/core/tables/src/components/Table.vue +342 -0
- package/core/tables/src/components/TableBody.vue +33 -0
- package/core/tables/src/components/TableCellActionItems.vue +9 -0
- package/core/tables/src/components/TableFilters.vue +703 -0
- package/core/tables/src/components/TableHead.vue +87 -0
- package/core/tables/src/components/TablePagination.vue +146 -0
- package/core/tables/src/components/TableRow.vue +78 -0
- package/core/tables/src/components/TableSearch.vue +38 -0
- package/core/tables/src/components/Tooltip.vue +10 -0
- package/core/tables/src/config/tables.ts +1 -0
- package/core/tables/src/docs/index.md +0 -0
- package/core/tables/src/functions/README.md +8 -0
- package/core/tables/src/functions/dark.ts +3 -0
- package/core/tables/src/functions/index.ts +2 -0
- package/core/tables/src/functions/table.ts +180 -0
- package/core/tables/tests/example.test.ts +7 -0
- package/core/testing/node_modules/.bin/vitest +2 -2
- package/core/testing/package.json +9 -6
- package/core/types/node_modules/.bin/vitepress +2 -2
- package/core/types/package.json +3 -3
- package/core/types/src/cli.ts +10 -2
- package/core/types/src/hashing.ts +15 -0
- package/core/types/src/index.ts +2 -0
- package/core/types/src/notifications.ts +1 -0
- package/core/types/src/reactivity.ts +3 -0
- package/core/types/src/tables.ts +48 -0
- package/core/ui/node_modules/.bin/vue-tsc +2 -2
- package/core/ui/package.json +2 -2
- package/core/utils/package.json +1 -1
- package/core/x-ray/package.json +1 -1
- package/package.json +3 -2
- package/tsconfig.json +8 -0
- package/vitest.config.ts +2 -0
- package/core/notifications/src/drivers/chat/discord.ts +0 -15
- package/core/notifications/src/drivers/chat/index.ts +0 -2
- package/core/notifications/src/drivers/chat/slack.ts +0 -22
- package/core/notifications/src/drivers/email/actions/send.ts +0 -36
- package/core/notifications/src/drivers/email/emailjs.ts +0 -21
- package/core/notifications/src/drivers/email/index.ts +0 -9
- package/core/notifications/src/drivers/email/mailgun.ts +0 -19
- package/core/notifications/src/drivers/email/mailjet.ts +0 -18
- package/core/notifications/src/drivers/email/mandrill.ts +0 -17
- package/core/notifications/src/drivers/email/netcore.ts +0 -17
- package/core/notifications/src/drivers/email/nodemailer.ts +0 -21
- package/core/notifications/src/drivers/email/postmark.ts +0 -17
- package/core/notifications/src/drivers/email/sendgrid.ts +0 -18
- package/core/notifications/src/drivers/email/ses.ts +0 -19
- package/core/notifications/src/drivers/push/expo.ts +0 -19
- package/core/notifications/src/drivers/push/fcm.ts +0 -19
- package/core/notifications/src/drivers/sms/gupshup.ts +0 -21
- package/core/notifications/src/drivers/sms/index.ts +0 -8
- package/core/notifications/src/drivers/sms/nexmo.ts +0 -22
- package/core/notifications/src/drivers/sms/plivo.ts +0 -22
- package/core/notifications/src/drivers/sms/sms77.ts +0 -21
- package/core/notifications/src/drivers/sms/sns.ts +0 -22
- package/core/notifications/src/drivers/sms/telnyx.ts +0 -22
- package/core/notifications/src/drivers/sms/termii.ts +0 -21
- package/core/notifications/src/drivers/sms/twilio.ts +0 -22
|
@@ -11,7 +11,7 @@ else
|
|
|
11
11
|
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/vitepress@1.0.0-alpha.
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/vitepress@1.0.0-alpha.34_2r467mdhb7mblpaox4bg7fatdi/node_modules/vitepress/bin/vitepress.js" "$@"
|
|
15
15
|
else
|
|
16
|
-
exec node "$basedir/../../../../../node_modules/.pnpm/vitepress@1.0.0-alpha.
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/vitepress@1.0.0-alpha.34_2r467mdhb7mblpaox4bg7fatdi/node_modules/vitepress/bin/vitepress.js" "$@"
|
|
17
17
|
fi
|
package/core/docs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/docs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.1",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks way to document.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typecheck": "tsc --noEmit"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"vitepress": "1.0.0-alpha.
|
|
46
|
+
"vitepress": "1.0.0-alpha.34"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@stacksjs/testing": "workspace:*",
|
package/core/email/README.md
CHANGED
|
@@ -1,60 +1,118 @@
|
|
|
1
|
-
# Stacks
|
|
1
|
+
# Stacks SMS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Stacks Email is driver system for sending Emails.
|
|
4
4
|
|
|
5
5
|
## ☘️ Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 📦 Send Email
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 🤖 Usage
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
pnpm i -D @stacksjs/email
|
|
13
|
+
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
You may now use it in your project:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import * as email from '@stacksjs/email'
|
|
19
|
+
|
|
20
|
+
/* Then choose a driver. E.g for sendgrid */
|
|
21
|
+
const notification = email.sendgrid
|
|
22
|
+
|
|
23
|
+
notification.send(EmailOptions)
|
|
24
|
+
|
|
25
|
+
interface EmailOptions {
|
|
26
|
+
to: string | string[]
|
|
27
|
+
subject: string
|
|
28
|
+
html: string
|
|
29
|
+
from?: string
|
|
30
|
+
text?: string
|
|
31
|
+
attachments?: AttachmentOptions[]
|
|
32
|
+
id?: string
|
|
33
|
+
}
|
|
34
|
+
```
|
|
14
35
|
|
|
15
|
-
|
|
36
|
+
### Drivers
|
|
37
|
+
|
|
38
|
+
Drivers are configured with the following environment variables:
|
|
39
|
+
|
|
40
|
+
#### Sendgrid
|
|
16
41
|
|
|
17
42
|
```bash
|
|
18
|
-
|
|
43
|
+
SENDGRID_API_KEY=SG123
|
|
44
|
+
SENDGRID_FROM=from@example.com
|
|
45
|
+
SENDGRID_SENDER_NAME=Sender
|
|
19
46
|
```
|
|
20
47
|
|
|
21
|
-
|
|
48
|
+
#### Mailgun
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
MAILGUN_API_KEY=MG123
|
|
52
|
+
MAILGUN_DOMAIN=example.com
|
|
53
|
+
MAILGUN_USERNAME=username
|
|
54
|
+
MAILGUN_FROM=from@example.com
|
|
55
|
+
```
|
|
22
56
|
|
|
23
|
-
|
|
24
|
-
import notifications from '@stacksjs/notifications'
|
|
57
|
+
#### Mailjet
|
|
25
58
|
|
|
26
|
-
|
|
59
|
+
```bash
|
|
60
|
+
MAILJET_API_KEY=MJ123
|
|
61
|
+
MAILJET_API_SECRET=MJTESTSECRET
|
|
62
|
+
MAILJET_FROM_EMAIL=from@example.com
|
|
27
63
|
```
|
|
28
64
|
|
|
29
|
-
|
|
65
|
+
#### Netcore
|
|
30
66
|
|
|
31
|
-
|
|
67
|
+
```bash
|
|
68
|
+
NETCORE_API_KEY=NC123
|
|
69
|
+
NETCORE_FROM=from@example.com
|
|
70
|
+
```
|
|
32
71
|
|
|
33
|
-
|
|
34
|
-
- Mailgun
|
|
35
|
-
- Mailjet
|
|
36
|
-
- Netcore
|
|
37
|
-
- Nodemailer
|
|
38
|
-
- Post Mark
|
|
39
|
-
- Ses
|
|
40
|
-
- Mandrill
|
|
41
|
-
- EmailJS
|
|
72
|
+
#### Nodemailer
|
|
42
73
|
|
|
43
|
-
|
|
74
|
+
```bash
|
|
75
|
+
NODEMAILER_FROM_EMAIL=from@example.com
|
|
76
|
+
NODEMAILER_HOST=example.com
|
|
77
|
+
NODEMAILER_USERNAME=username
|
|
78
|
+
NODEMAILER_PASSWORD=password
|
|
79
|
+
NODEMAILER_PORT=25
|
|
80
|
+
NODEMAILER_SECURE=true
|
|
81
|
+
```
|
|
44
82
|
|
|
45
|
-
|
|
46
|
-
- Nexmo
|
|
47
|
-
- Gupshup
|
|
48
|
-
- Plivo
|
|
49
|
-
- SMS77
|
|
50
|
-
- SNS
|
|
51
|
-
- Telnyx
|
|
52
|
-
- Termii
|
|
83
|
+
#### Postmark
|
|
53
84
|
|
|
54
|
-
|
|
85
|
+
```bash
|
|
86
|
+
POSTMARK_API_KEY=PM123
|
|
87
|
+
POSTMARK_FROM=from@example.com
|
|
88
|
+
```
|
|
55
89
|
|
|
56
|
-
|
|
57
|
-
|
|
90
|
+
#### AWS SES
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
SES_REGION=US
|
|
94
|
+
SES_ACCESS_KEY_ID=testkey123
|
|
95
|
+
SES_SECRET_ACCESS_KEY=testaccesskey123
|
|
96
|
+
SES_FROM=from@example.com
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Mandrill
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
MANDRILL_API_KEY=Ma123
|
|
103
|
+
MANDRILL_EMAIL=from@example.com
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### EmailJS
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
EMAILJS_FROM_EMAIL=from@example.com
|
|
110
|
+
EMAILJS_HOST=example.com
|
|
111
|
+
EMAILJS_USERNAME=username
|
|
112
|
+
EMAILJS_PASSWORD=password
|
|
113
|
+
EMAILJS_PORT=25
|
|
114
|
+
EMAILJS_SECURE=true
|
|
115
|
+
```
|
|
58
116
|
|
|
59
117
|
Learn more in the docs.
|
|
60
118
|
|
|
@@ -82,6 +140,14 @@ For casual chit-chat with others using this package:
|
|
|
82
140
|
|
|
83
141
|
[Join the Stacks Discord Server](https://discord.ow3.org)
|
|
84
142
|
|
|
143
|
+
## 🙏🏼 Credits
|
|
144
|
+
|
|
145
|
+
Many thanks to the following core technologies & people who have contributed to this package:
|
|
146
|
+
|
|
147
|
+
- [Chris Breuer](https://github.com/chrisbbreuer)
|
|
148
|
+
- [Novu](https://novu.co/)
|
|
149
|
+
- [All Contributors](../../contributors)
|
|
150
|
+
|
|
85
151
|
## 📄 License
|
|
86
152
|
|
|
87
153
|
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
package/core/email/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/email",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.1",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks Email integration. Painlessly create & manage your inboxes, templates, and send emails.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -21,7 +21,15 @@
|
|
|
21
21
|
"ses",
|
|
22
22
|
"aws",
|
|
23
23
|
"maizzle",
|
|
24
|
-
"stacks"
|
|
24
|
+
"stacks",
|
|
25
|
+
"emailjs",
|
|
26
|
+
"mailgun",
|
|
27
|
+
"mailjet",
|
|
28
|
+
"mandrill",
|
|
29
|
+
"netcore",
|
|
30
|
+
"nodemailer",
|
|
31
|
+
"postmark",
|
|
32
|
+
"sendgrid"
|
|
25
33
|
],
|
|
26
34
|
"main": "dist/index.mjs",
|
|
27
35
|
"module": "dist/index.mjs",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/error-handling",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.1",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "Type safe error handling.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typecheck": "tsc --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@ow3/eslint-config": "^0.35.
|
|
47
|
+
"@ow3/eslint-config": "^0.35.2",
|
|
48
48
|
"neverthrow": "^6.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
package/core/events/package.json
CHANGED
package/core/git/package.json
CHANGED
package/core/health/package.json
CHANGED
|
@@ -11,7 +11,7 @@ else
|
|
|
11
11
|
export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/eslint@8.
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/eslint@8.31.0/node_modules/eslint/bin/eslint.js" "$@"
|
|
15
15
|
else
|
|
16
|
-
exec node "$basedir/../../../../../node_modules/.pnpm/eslint@8.
|
|
16
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/eslint@8.31.0/node_modules/eslint/bin/eslint.js" "$@"
|
|
17
17
|
fi
|
package/core/lint/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/lint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.1",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks way to lint.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"typecheck": "tsc --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@ow3/eslint-config": "^0.35.
|
|
48
|
+
"@ow3/eslint-config": "^0.35.2",
|
|
49
49
|
"@types/eslint": "^8.4.10",
|
|
50
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.31.0",
|
|
51
51
|
"lint-staged": "^13.1.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -11,8 +11,6 @@ Stacks Notifications is a unified driver system for sending messages/notificatio
|
|
|
11
11
|
|
|
12
12
|
## TODO
|
|
13
13
|
|
|
14
|
-
- [ ] Driver: FCM
|
|
15
|
-
- [ ] Driver: Expo
|
|
16
14
|
- [ ] Driver: SNS (Push)
|
|
17
15
|
- [ ] Driver: Pushwoosh
|
|
18
16
|
|
|
@@ -22,6 +20,13 @@ Stacks Notifications is a unified driver system for sending messages/notificatio
|
|
|
22
20
|
pnpm i -D @stacksjs/notifications
|
|
23
21
|
```
|
|
24
22
|
|
|
23
|
+
Set these variables in your env:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
NOTIFICATION_TYPE=email
|
|
27
|
+
NOTIFICATION_DRIVER=sendgrid
|
|
28
|
+
```
|
|
29
|
+
|
|
25
30
|
You may now use it in your project:
|
|
26
31
|
|
|
27
32
|
```ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/notifications",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.1",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks notifications integration.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -74,9 +74,13 @@
|
|
|
74
74
|
"@novu/telnyx": "^0.10.0",
|
|
75
75
|
"@novu/termii": "^0.10.0",
|
|
76
76
|
"@novu/twilio": "^0.10.0",
|
|
77
|
+
"@stacksjs/chat": "workspace:*",
|
|
77
78
|
"@stacksjs/cli": "workspace:*",
|
|
78
79
|
"@stacksjs/config": "workspace:*",
|
|
80
|
+
"@stacksjs/email": "workspace:*",
|
|
79
81
|
"@stacksjs/error-handling": "workspace:*",
|
|
82
|
+
"@stacksjs/push": "workspace:*",
|
|
83
|
+
"@stacksjs/sms": "workspace:*",
|
|
80
84
|
"@stacksjs/types": "workspace:*"
|
|
81
85
|
},
|
|
82
86
|
"devDependencies": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as chat from '@stacksjs/chat'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as email from '@stacksjs/email'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as push from '@stacksjs/push'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as sms from '@stacksjs/sms'
|
|
@@ -1,20 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { err } from '@stacksjs/error-handling'
|
|
2
|
+
import { notification as config } from '@stacksjs/config'
|
|
3
|
+
import { email } from './drivers/email'
|
|
4
|
+
import { chat } from './drivers/chat'
|
|
5
|
+
import { sms } from './drivers/sms'
|
|
4
6
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const useChat = (driver = 'slack') => {
|
|
8
|
+
return chat[driver as keyof typeof chat]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const useEmail = (driver = 'sendgrid') => {
|
|
12
|
+
return email[driver as keyof typeof email]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const useSMS = (driver = 'twilio') => {
|
|
16
|
+
return sms[driver as keyof typeof sms]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const useNotification = (typeParam = null, driverParam = null) => {
|
|
20
|
+
const type = typeParam || config.type
|
|
21
|
+
const driver = driverParam || config.driver
|
|
22
|
+
|
|
23
|
+
switch (type) {
|
|
24
|
+
case 'email':
|
|
25
|
+
return useEmail(driver)
|
|
26
|
+
case 'chat':
|
|
27
|
+
return useChat(driver)
|
|
28
|
+
case 'sms':
|
|
29
|
+
return useSMS(driver)
|
|
30
|
+
default:
|
|
31
|
+
return err(`Type ${type} not supported`)
|
|
32
|
+
}
|
|
9
33
|
}
|
|
10
34
|
|
|
11
|
-
const
|
|
12
|
-
return
|
|
35
|
+
const notification = () => {
|
|
36
|
+
return useNotification()
|
|
13
37
|
}
|
|
14
38
|
|
|
15
39
|
export {
|
|
16
40
|
email,
|
|
17
41
|
chat,
|
|
18
42
|
sms,
|
|
43
|
+
notification,
|
|
44
|
+
useEmail,
|
|
45
|
+
useChat,
|
|
46
|
+
useSMS,
|
|
19
47
|
useNotification,
|
|
20
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { chat } from '@stacksjs/notifications'
|
|
2
|
+
import { chat, useChat } from '@stacksjs/notifications'
|
|
3
|
+
import { Err } from '@stacksjs/types'
|
|
3
4
|
|
|
4
5
|
describe('Slack Test', () => {
|
|
5
6
|
it('should send chat', async () => {
|
|
@@ -12,8 +13,8 @@ describe('Slack Test', () => {
|
|
|
12
13
|
expect(test).toBeDefined()
|
|
13
14
|
})
|
|
14
15
|
|
|
15
|
-
it('should send chat using
|
|
16
|
-
const notification =
|
|
16
|
+
it('should send chat using useChat', async () => {
|
|
17
|
+
const notification = useChat('slack')
|
|
17
18
|
const test = await notification.send({
|
|
18
19
|
content: 'Test Slack Message!',
|
|
19
20
|
webhookUrl: 'https://hooks.slack.com/services/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',
|
|
@@ -29,6 +30,6 @@ describe('Slack Test', () => {
|
|
|
29
30
|
webhookUrl: '',
|
|
30
31
|
})
|
|
31
32
|
|
|
32
|
-
expect(test
|
|
33
|
+
expect(test).toBeInstanceOf(Err)
|
|
33
34
|
})
|
|
34
35
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { email } from '@stacksjs/notifications'
|
|
2
|
+
import { email, useEmail } from '@stacksjs/notifications'
|
|
3
|
+
import { notification as env } from '@stacksjs/config'
|
|
3
4
|
|
|
4
5
|
describe('Mailgun Test', () => {
|
|
5
6
|
it('should not send email', async () => {
|
|
@@ -14,8 +15,8 @@ describe('Mailgun Test', () => {
|
|
|
14
15
|
expect(test).toBeDefined()
|
|
15
16
|
})
|
|
16
17
|
|
|
17
|
-
it('should send email using
|
|
18
|
-
const notification =
|
|
18
|
+
it('should send email using useEmail', async () => {
|
|
19
|
+
const notification = useEmail('mailgun')
|
|
19
20
|
const test = await notification.send({
|
|
20
21
|
from: 'repuestobrian2@gmail.com',
|
|
21
22
|
to: 'repuestobrian@gmail',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { email,
|
|
2
|
+
import { email, useEmail } from '@stacksjs/notifications'
|
|
3
3
|
import { notification as env } from '@stacksjs/config'
|
|
4
4
|
|
|
5
5
|
describe('Sendgrid Test', () => {
|
|
@@ -15,8 +15,8 @@ describe('Sendgrid Test', () => {
|
|
|
15
15
|
expect(test).toBeDefined()
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
it('should send email using
|
|
19
|
-
const notification =
|
|
18
|
+
it('should send email using useEmail', async () => {
|
|
19
|
+
const notification = useEmail('sendgrid')
|
|
20
20
|
const test = await notification.send({
|
|
21
21
|
from: env.email.sendgrid.from,
|
|
22
22
|
to: 'repuestobrian2@gmail.com',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { sms } from '@stacksjs/notifications'
|
|
2
|
+
import { sms, useSMS } from '@stacksjs/notifications'
|
|
3
3
|
import { notification } from '@stacksjs/config'
|
|
4
4
|
|
|
5
5
|
describe('Twilio Test', () => {
|
|
@@ -14,8 +14,8 @@ describe('Twilio Test', () => {
|
|
|
14
14
|
expect(test).toBeDefined()
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
it('should send sms using
|
|
18
|
-
const
|
|
17
|
+
it('should send sms using useSMS', async () => {
|
|
18
|
+
const notif = useSMS('twilio')
|
|
19
19
|
const test = await notif.send({
|
|
20
20
|
content: 'Test SMS from Stacks',
|
|
21
21
|
to: notification.sms.twilio.to,
|