stacks 0.44.11 → 0.45.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 (121) hide show
  1. package/README.md +4 -3
  2. package/buddy/README.md +4 -3
  3. package/buddy/package.json +7 -6
  4. package/buddy/src/commands/add.ts +12 -12
  5. package/buddy/src/commands/build.ts +55 -31
  6. package/buddy/src/commands/clean.ts +6 -6
  7. package/buddy/src/commands/commit.ts +6 -6
  8. package/buddy/src/commands/create.ts +14 -14
  9. package/buddy/src/commands/dev.ts +15 -15
  10. package/buddy/src/commands/example.ts +11 -11
  11. package/buddy/src/commands/fresh.ts +21 -10
  12. package/buddy/src/commands/generate.ts +20 -20
  13. package/buddy/src/commands/key.ts +2 -2
  14. package/buddy/src/commands/lint.ts +29 -11
  15. package/buddy/src/commands/make.ts +33 -33
  16. package/buddy/src/commands/preinstall.ts +6 -6
  17. package/buddy/src/commands/prepublish.ts +6 -6
  18. package/buddy/src/commands/release.ts +4 -4
  19. package/buddy/src/commands/setup.ts +8 -8
  20. package/buddy/src/commands/test.ts +11 -11
  21. package/buddy/src/commands/types.ts +8 -8
  22. package/buddy/src/commands/update.ts +20 -20
  23. package/buddy/src/index.ts +1 -0
  24. package/core/actions/package.json +2 -2
  25. package/core/actions/src/build-component-libs.ts +15 -0
  26. package/core/actions/src/build-core.ts +7 -0
  27. package/core/actions/src/build-stacks.ts +9 -0
  28. package/core/actions/src/bump.ts +10 -0
  29. package/core/actions/src/fix-lint-issues.ts +4 -0
  30. package/core/actions/src/fresh.ts +6 -26
  31. package/core/actions/src/{generate-package-json.ts → generate-package-jsons.ts} +0 -0
  32. package/core/actions/src/generate.ts +5 -5
  33. package/core/actions/src/helpers/lib-entries.ts +1 -1
  34. package/core/actions/src/helpers/package-json.ts +1 -1
  35. package/core/actions/src/helpers/utils.ts +31 -6
  36. package/core/actions/src/lint-fix.ts +8 -0
  37. package/core/actions/src/lint.ts +6 -30
  38. package/core/actions/src/make.ts +8 -8
  39. package/core/actions/src/release.ts +9 -28
  40. package/core/ai/package.json +1 -1
  41. package/core/alias/package.json +1 -1
  42. package/core/arrays/package.json +1 -1
  43. package/core/auth/package.json +1 -1
  44. package/core/build/node_modules/.bin/vite +2 -2
  45. package/core/build/node_modules/.bin/vite-ssg +2 -2
  46. package/core/build/package.json +3 -3
  47. package/core/cache/package.json +2 -2
  48. package/core/cache/tests/Redis.test.ts +0 -1
  49. package/core/cli/package.json +1 -1
  50. package/core/cli/src/actions/run.ts +24 -11
  51. package/core/cli/src/helpers.ts +6 -6
  52. package/core/cloud/package.json +1 -1
  53. package/core/collections/package.json +1 -1
  54. package/core/config/package.json +1 -1
  55. package/core/dashboard/package.json +1 -1
  56. package/core/database/package.json +2 -2
  57. package/core/datetime/package.json +1 -1
  58. package/core/desktop/package.json +1 -1
  59. package/core/docs/node_modules/.bin/vitepress +2 -2
  60. package/core/docs/package.json +2 -2
  61. package/core/domains/package.json +1 -1
  62. package/core/drivers/package.json +1 -1
  63. package/core/email/package.json +1 -1
  64. package/core/error-handling/package.json +2 -2
  65. package/core/git/package.json +1 -1
  66. package/core/{cloud/dist/actions → health}/README.md +11 -8
  67. package/core/health/node_modules/.bin/mkdist +17 -0
  68. package/core/health/node_modules/.bin/tsc +17 -0
  69. package/core/health/node_modules/.bin/tsserver +17 -0
  70. package/core/health/package.json +54 -0
  71. package/core/health/src/drivers/ohdear.ts +1 -0
  72. package/core/health/src/index.ts +1 -0
  73. package/core/health/src/notifications/index.ts +1 -0
  74. package/core/{notifications → health}/tests/example.test.ts +0 -0
  75. package/core/lint/node_modules/.bin/eslint +2 -2
  76. package/core/lint/package.json +3 -3
  77. package/core/logging/package.json +1 -1
  78. package/core/modules/package.json +1 -1
  79. package/core/modules/src/nprogress.ts +3 -1
  80. package/core/notifications/README.md +205 -30
  81. package/core/notifications/package.json +1 -1
  82. package/core/notifications/src/drivers/chat/slack.ts +1 -1
  83. package/core/notifications/src/drivers/email/actions/send.ts +1 -1
  84. package/core/notifications/src/drivers/push/expo.ts +19 -0
  85. package/core/notifications/src/drivers/push/fcm.ts +19 -0
  86. package/core/notifications/src/index.ts +17 -22
  87. package/core/notifications/tests/chat/Slack.test.ts +12 -2
  88. package/core/notifications/tests/email/Mailgun.test.ts +14 -3
  89. package/core/notifications/tests/email/Sendgrid.test.ts +15 -4
  90. package/core/notifications/tests/sms/Twilio.test.ts +13 -2
  91. package/core/objects/package.json +1 -1
  92. package/core/path/package.json +1 -1
  93. package/core/payments/package.json +1 -1
  94. package/core/realtime/package.json +1 -1
  95. package/core/router/package.json +1 -1
  96. package/core/search-engine/package.json +2 -2
  97. package/core/security/package.json +1 -1
  98. package/core/server/node_modules/.bin/vite +2 -2
  99. package/core/server/package.json +2 -2
  100. package/core/storage/package.json +1 -1
  101. package/core/strings/package.json +1 -1
  102. package/core/testing/node_modules/.bin/mkdist +2 -2
  103. package/core/testing/node_modules/.bin/vitest +2 -2
  104. package/core/testing/package.json +5 -5
  105. package/core/types/node_modules/.bin/vitepress +2 -2
  106. package/core/types/package.json +4 -4
  107. package/core/types/src/cli.ts +33 -3
  108. package/core/types/src/notifications.ts +161 -0
  109. package/core/ui/node_modules/.bin/vue-tsc +2 -2
  110. package/core/ui/package.json +2 -2
  111. package/core/utils/package.json +5 -5
  112. package/core/utils/src/helpers.ts +1 -1
  113. package/core/x-ray/package.json +1 -1
  114. package/core/x-ray/src/desktop/app.vue +0 -1
  115. package/core/x-ray/src/ray.config.js +1 -0
  116. package/core/x-ray/src/types.ts +1 -0
  117. package/package.json +8 -8
  118. package/tsconfig.json +2 -2
  119. package/components/vue/dist/.gitkeep +0 -0
  120. package/components/web/dist/.gitkeep +0 -0
  121. package/core/actions/test.ts +0 -10
@@ -1,23 +1,26 @@
1
- # Actions
1
+ # Stacks Health Engine
2
2
 
3
- Placeholder for the "On-The-Fly API."
3
+ The Health Engine is a unified driver system to easily manage health checks for your application.
4
4
 
5
5
  ## ☘️ Features
6
6
 
7
- - ⚡️
7
+ - 🚘 Driver based
8
+ - ⚡️ Oh Dear support
9
+ - 💀 Headless functions & components
8
10
 
9
11
  ## 🤖 Usage
10
12
 
11
13
  ```bash
12
- pnpm i -D @stacksjs/cloud
14
+ pnpm i -D @stacksjs/health
13
15
  ```
14
16
 
15
- Now, you can use it in your project:
17
+ You may now use:
16
18
 
17
- ```js
18
- import { actions } from '@stacksjs/cloud'
19
+ ```ts
20
+ import { useHealth } from '@stacksjs/health'
19
21
 
20
- // wip
22
+ const health = useHealth()
23
+ // ...
21
24
  ```
22
25
 
23
26
  Learn more in the docs.
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/mkdist@1.0.0_typescript@4.9.4/node_modules/mkdist/dist/cli.cjs" "$@"
15
+ else
16
+ exec node "$basedir/../../../../../node_modules/.pnpm/mkdist@1.0.0_typescript@4.9.4/node_modules/mkdist/dist/cli.cjs" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/bin/tsc" "$@"
15
+ else
16
+ exec node "$basedir/../../../../../node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/bin/tsc" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/home/runner/work/stacks/stacks/node_modules/.pnpm/node_modules"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/bin/tsserver" "$@"
15
+ else
16
+ exec node "$basedir/../../../../../node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/bin/tsserver" "$@"
17
+ fi
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@stacksjs/health",
3
+ "type": "module",
4
+ "version": "0.45.0",
5
+ "packageManager": "pnpm@7.18.2",
6
+ "description": "The Stacks Health services.",
7
+ "author": "Chris Breuer",
8
+ "license": "MIT",
9
+ "funding": "https://github.com/sponsors/chrisbbreuer",
10
+ "homepage": "https://github.com/stacksjs/stacks/tree/main/.stacks/core/health#readme",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/stacksjs/stacks.git",
14
+ "directory": "./.stacks/core/health"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/stacksjs/stacks/issues"
18
+ },
19
+ "keywords": [
20
+ "health",
21
+ "oh dear",
22
+ "stacks",
23
+ "api",
24
+ "headless"
25
+ ],
26
+ "main": "dist/index.mjs",
27
+ "module": "dist/index.mjs",
28
+ "types": "dist/index.d.ts",
29
+ "contributors": [
30
+ "Chris Breuer <chris@ow3.org>"
31
+ ],
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "engines": {
37
+ "node": ">=v18.12.1",
38
+ "pnpm": ">=7.18.2"
39
+ },
40
+ "scripts": {
41
+ "build": "mkdist -d",
42
+ "dev": "mkdist -d",
43
+ "prepublishOnly": "pnpm run build",
44
+ "typecheck": "tsc --noEmit"
45
+ },
46
+ "peerDependencies": {
47
+ "@stacksjs/notifications": "workspace:*"
48
+ },
49
+ "devDependencies": {
50
+ "@stacksjs/testing": "workspace:*",
51
+ "mkdist": "^1.0.0",
52
+ "typescript": "^4.9.4"
53
+ }
54
+ }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -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.29.0/node_modules/eslint/bin/eslint.js" "$@"
14
+ exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/eslint@8.30.0/node_modules/eslint/bin/eslint.js" "$@"
15
15
  else
16
- exec node "$basedir/../../../../../node_modules/.pnpm/eslint@8.29.0/node_modules/eslint/bin/eslint.js" "$@"
16
+ exec node "$basedir/../../../../../node_modules/.pnpm/eslint@8.30.0/node_modules/eslint/bin/eslint.js" "$@"
17
17
  fi
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/lint",
3
3
  "type": "module",
4
- "version": "0.44.11",
4
+ "version": "0.45.0",
5
5
  "packageManager": "pnpm@7.18.2",
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.33.11",
48
+ "@ow3/eslint-config": "^0.35.0",
49
49
  "@types/eslint": "^8.4.10",
50
- "eslint": "^8.29.0",
50
+ "eslint": "^8.30.0",
51
51
  "lint-staged": "^13.1.0"
52
52
  },
53
53
  "devDependencies": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/logging",
3
3
  "type": "module",
4
- "version": "0.44.11",
4
+ "version": "0.45.0",
5
5
  "packageManager": "pnpm@7.18.2",
6
6
  "description": "The Stacks logging system.",
7
7
  "author": "Chris Breuer",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/modules",
3
3
  "type": "module",
4
- "version": "0.44.11",
4
+ "version": "0.45.0",
5
5
  "packageManager": "pnpm@7.18.2",
6
6
  "description": "The Stacks framework modules.",
7
7
  "author": "Chris Breuer",
@@ -7,6 +7,8 @@ export const install: UserModule = ({ isClient, router }) => {
7
7
  if (to.path !== from.path)
8
8
  NProgress.start()
9
9
  })
10
- router.afterEach(() => { NProgress.done() })
10
+ router.afterEach(() => {
11
+ NProgress.done()
12
+ })
11
13
  }
12
14
  }
@@ -1,60 +1,227 @@
1
1
  # Stacks Notifications
2
2
 
3
- wip
3
+ Stacks Notifications is a unified driver system for sending messages/notifications. It supports sending emails, SMS messages, and chat messages.
4
4
 
5
5
  ## ☘️ Features
6
6
 
7
- wip
7
+ - 📦 Send Emails
8
+ - 🎨 Email Styling
9
+ - 📱 Send SMS messages
10
+ - 💬 Send Chat messages
8
11
 
9
- - ⚡️
12
+ ## TODO
10
13
 
11
- wip
14
+ - [ ] Driver: FCM
15
+ - [ ] Driver: Expo
16
+ - [ ] Driver: SNS (Push)
17
+ - [ ] Driver: Pushwoosh
12
18
 
13
19
  ## 🤖 Usage
14
20
 
15
- wip
16
-
17
21
  ```bash
18
22
  pnpm i -D @stacksjs/notifications
19
23
  ```
20
24
 
21
- Now, you can use it in your project:
25
+ You may now use it in your project:
26
+
27
+ ```ts
28
+ import { notification } from '@stacksjs/notifications'
22
29
 
23
- ```js
24
- import notifications from '@stacksjs/notifications'
30
+ notification.send(options)
31
+ ```
25
32
 
26
- // wip
33
+ ## 🏎️ Drivers
34
+
35
+ There are different option types for Chat, Email, and SMS drivers. To use any driver, simply configure the notification `options` object.
36
+
37
+ ```ts
38
+ interface ChatOptions {
39
+ webhookUrl: string
40
+ content: string
41
+ }
42
+
43
+ interface EmailOptions {
44
+ to: string | string[]
45
+ subject: string
46
+ html: string
47
+ from?: string
48
+ text?: string
49
+ attachments?: AttachmentOptions[]
50
+ id?: string
51
+ }
52
+
53
+ interface SMSOptions {
54
+ to: string
55
+ content: string
56
+ from?: string
57
+ attachments?: AttachmentOptions[]
58
+ id?: string
59
+ }
27
60
  ```
28
61
 
29
- ## 🤖 Drivers
62
+ Available drivers are listed below, with the proper variables needed to get started.
30
63
 
31
64
  ### Email
32
65
 
33
- - Sendgrid
34
- - Mailgun
35
- - Mailjet
36
- - Netcore
37
- - Nodemailer
38
- - Post Mark
39
- - Ses
40
- - Mandrill
41
- - EmailJS
66
+ Email drivers are configured with the following environment variables:
67
+
68
+ #### Sendgrid
69
+
70
+ ```bash
71
+ SENDGRID_API_KEY=SG123
72
+ SENDGRID_FROM=from@example.com
73
+ SENDGRID_SENDER_NAME=Sender
74
+ ```
75
+
76
+ #### Mailgun
77
+
78
+ ```bash
79
+ MAILGUN_API_KEY=MG123
80
+ MAILGUN_DOMAIN=example.com
81
+ MAILGUN_USERNAME=username
82
+ MAILGUN_FROM=from@example.com
83
+ ```
84
+
85
+ #### Mailjet
86
+
87
+ ```bash
88
+ MAILJET_API_KEY=MJ123
89
+ MAILJET_API_SECRET=MJTESTSECRET
90
+ MAILJET_FROM_EMAIL=from@example.com
91
+ ```
92
+
93
+ #### Netcore
94
+
95
+ ```bash
96
+ NETCORE_API_KEY=NC123
97
+ NETCORE_FROM=from@example.com
98
+ ```
99
+
100
+ #### Nodemailer
101
+
102
+ ```bash
103
+ NODEMAILER_FROM_EMAIL=from@example.com
104
+ NODEMAILER_HOST=example.com
105
+ NODEMAILER_USERNAME=username
106
+ NODEMAILER_PASSWORD=password
107
+ NODEMAILER_PORT=25
108
+ NODEMAILER_SECURE=true
109
+ ```
110
+
111
+ #### Postmark
112
+
113
+ ```bash
114
+ POSTMARK_API_KEY=PM123
115
+ POSTMARK_FROM=from@example.com
116
+ ```
117
+
118
+ #### AWS SES
119
+
120
+ ```bash
121
+ SES_REGION=US
122
+ SES_ACCESS_KEY_ID=testkey123
123
+ SES_SECRET_ACCESS_KEY=testaccesskey123
124
+ SES_FROM=from@example.com
125
+ ```
126
+
127
+ #### Mandrill
128
+
129
+ ```bash
130
+ MANDRILL_API_KEY=Ma123
131
+ MANDRILL_EMAIL=from@example.com
132
+ ```
133
+
134
+ #### EmailJS
135
+
136
+ ```bash
137
+ EMAILJS_FROM_EMAIL=from@example.com
138
+ EMAILJS_HOST=example.com
139
+ EMAILJS_USERNAME=username
140
+ EMAILJS_PASSWORD=password
141
+ EMAILJS_PORT=25
142
+ EMAILJS_SECURE=true
143
+ ```
42
144
 
43
145
  ### SMS
44
146
 
45
- - Twilio
46
- - Nexmo
47
- - Gupshup
48
- - Plivo
49
- - SMS77
50
- - SNS
51
- - Telnyx
52
- - Termii
147
+ SMS drivers are configured with the following environment variables:
148
+
149
+ #### Twilio
150
+
151
+ ```bash
152
+ TWILIO_ACCOUNT_SID=ACtest
153
+ TWILIO_AUTH_TOKEN=testtoken
154
+ TWILIO_FROM_NUMBER=+112345
155
+ TWILIO_TO_NUMBER=+145678
156
+ ```
157
+
158
+ #### Nexmo
159
+
160
+ ```bash
161
+ VONAGE_API_KEY=VN123
162
+ VONAGE_API_SECRET=testkey
163
+ VONAGE_FROM_NUMBER=+112345
164
+ ```
165
+
166
+ #### Gupshup
167
+
168
+ ```bash
169
+ GUPSHUP_USER_ID=GU123
170
+ GUPSHUP_PASSWORD=password
171
+ ```
172
+
173
+ #### Plivo
174
+
175
+ ```bash
176
+ PLIVO_ACCOUNT_ID=PA123
177
+ PLIVO_AUTH_TOKEN=testtoken
178
+ PLIVO_FROM_NUMBER=+112345
179
+ ```
180
+
181
+ #### SMS77
182
+
183
+ ```bash
184
+ SMS77_API_KEY=SA123
185
+ SMS77_FROM=from@example.com
186
+ ```
187
+
188
+ #### SNS
189
+
190
+ ```bash
191
+ SMS77_API_KEY=SA123
192
+ SMS77_FROM=from@example.com
193
+ ```
194
+
195
+ #### Telnyx
196
+
197
+ ```bash
198
+ TELNYX_API_KEY=TA123
199
+ TELNYX_MESSAGE_PROFILE_ID=testprofileid
200
+ TELNYX_FROM=from@example.com
201
+ ```
202
+
203
+ #### Termii
204
+
205
+ ```bash
206
+ TERMII_API_KEY=TermA123
207
+ TERMII_SENDER=from@example.com
208
+ ```
53
209
 
54
210
  ### Chat
55
211
 
56
- - Discord
57
- - Slack
212
+ Chat drivers are configured with the following environment variables:
213
+
214
+ #### Discord
215
+
216
+ - None
217
+
218
+ #### Slack
219
+
220
+ ```
221
+ SLACK_APPLICATION_ID=SAID123
222
+ SLACK_CLIENT_ID=SCID123
223
+ SLACK_SECRET_KEY=SSK123
224
+ ```
58
225
 
59
226
  Learn more in the docs.
60
227
 
@@ -82,6 +249,14 @@ For casual chit-chat with others using this package:
82
249
 
83
250
  [Join the Stacks Discord Server](https://discord.ow3.org)
84
251
 
252
+ ## 🙏🏼 Credits
253
+
254
+ Many thanks to the following core technologies & people who have contributed to this package:
255
+
256
+ - [Chris Breuer](https://github.com/chrisbbreuer)
257
+ - [Novu](https://novu.co/)
258
+ - [All Contributors](../../contributors)
259
+
85
260
  ## 📄 License
86
261
 
87
262
  The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/notifications",
3
3
  "type": "module",
4
- "version": "0.44.11",
4
+ "version": "0.45.0",
5
5
  "packageManager": "pnpm@7.18.2",
6
6
  "description": "The Stacks notifications integration.",
7
7
  "author": "Chris Breuer",
@@ -8,7 +8,7 @@ const env = notification.chat.slack
8
8
 
9
9
  const provider = new SlackProvider({
10
10
  applicationId: env.appId,
11
- clientId: env.clientID,
11
+ clientId: env.clientId,
12
12
  secretKey: env.secret,
13
13
  })
14
14
 
@@ -31,6 +31,6 @@ export async function send(options: EmailOptions, provider: any, providerName: s
31
31
 
32
32
  return ResultAsync.fromPromise(
33
33
  provider.sendMessage(options),
34
- () => new Error(`Failed to send message using provider: ${italic('Sendgrid')}`),
34
+ () => new Error(`Failed to send message using provider: ${italic(providerName)}`),
35
35
  )
36
36
  }
@@ -0,0 +1,19 @@
1
+ import { Novu } from '@novu/node'
2
+ import { notification } from '@stacksjs/config'
3
+ import type { ExpoPushNotificationOptions } from '@stacksjs/types'
4
+ import { ResultAsync } from '@stacksjs/error-handling'
5
+ import { italic } from '@stacksjs/cli'
6
+
7
+ const novu = new Novu(notification.novu.key)
8
+
9
+ function send(options: ExpoPushNotificationOptions) {
10
+ return ResultAsync.fromPromise(
11
+ novu.trigger(options.eventName, {
12
+ to: options.to,
13
+ payload: options.payload,
14
+ }),
15
+ () => new Error(`Failed to send message using provider: ${italic('Expo')}`),
16
+ )
17
+ }
18
+
19
+ export { send as Send, send }
@@ -0,0 +1,19 @@
1
+ import { Novu } from '@novu/node'
2
+ import { notification } from '@stacksjs/config'
3
+ import type { FCMPushNotificationOptions } from '@stacksjs/types'
4
+ import { ResultAsync } from '@stacksjs/error-handling'
5
+ import { italic } from '@stacksjs/cli'
6
+
7
+ const novu = new Novu(notification.novu.key)
8
+
9
+ function send(options: FCMPushNotificationOptions) {
10
+ return ResultAsync.fromPromise(
11
+ novu.trigger(options.eventName, {
12
+ to: options.to,
13
+ payload: options.payload,
14
+ }),
15
+ () => new Error(`Failed to send message using provider: ${italic('FCM')}`),
16
+ )
17
+ }
18
+
19
+ export { send as Send, send }
@@ -1,25 +1,20 @@
1
- export * as email from './drivers/email'
2
- export * as chat from './drivers/chat'
3
- export * as sms from './drivers/sms'
1
+ import * as email from './drivers/email'
2
+ import * as chat from './drivers/chat'
3
+ import * as sms from './drivers/sms'
4
4
 
5
- // const driverMap = {
6
- // email,
7
- // chat,
8
- // sms,
9
- // }
5
+ const driverMap = {
6
+ email,
7
+ chat,
8
+ sms,
9
+ }
10
10
 
11
- // export function useNotification(driver = 'email') {
12
- // // return driverMap?.[driver as keyof typeof driverMap]
13
- // if (driver === 'email')
14
- // return email
11
+ const useNotification = (driver = 'email') => {
12
+ return driverMap?.[driver as keyof typeof driverMap]
13
+ }
15
14
 
16
- // if (driver === 'chat')
17
- // return chat
18
-
19
- // if (driver === 'sms')
20
- // return sms
21
- // }
22
-
23
- // export default {
24
- // useNotification,
25
- // }
15
+ export {
16
+ email,
17
+ chat,
18
+ sms,
19
+ useNotification,
20
+ }
@@ -1,10 +1,19 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import { chat } from '@stacksjs/notifications'
3
3
 
4
- const notification = chat.slack
5
-
6
4
  describe('Slack Test', () => {
7
5
  it('should send chat', async () => {
6
+ const notification = chat.slack
7
+ const test = await notification.send({
8
+ content: 'Test Slack Message!',
9
+ webhookUrl: 'https://hooks.slack.com/services/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',
10
+ })
11
+
12
+ expect(test).toBeDefined()
13
+ })
14
+
15
+ it('should send chat using useNotification', async () => {
16
+ const notification = useNotification('chat').slack
8
17
  const test = await notification.send({
9
18
  content: 'Test Slack Message!',
10
19
  webhookUrl: 'https://hooks.slack.com/services/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',
@@ -14,6 +23,7 @@ describe('Slack Test', () => {
14
23
  })
15
24
 
16
25
  it('should not send chat if webhook is empty', async () => {
26
+ const notification = chat.slack
17
27
  const test = await notification.send({
18
28
  content: 'Test Slack Message!',
19
29
  webhookUrl: '',
@@ -1,10 +1,21 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import { email } from '@stacksjs/notifications'
3
3
 
4
- const notification = email.mailgun
5
-
6
4
  describe('Mailgun Test', () => {
7
5
  it('should not send email', async () => {
6
+ const notification = email.mailgun
7
+ const test = await notification.send({
8
+ from: 'repuestobrian2@gmail.com',
9
+ to: 'repuestobrian@gmail',
10
+ subject: 'Test Email',
11
+ html: '<p> Test </p>',
12
+ })
13
+
14
+ expect(test).toBeDefined()
15
+ })
16
+
17
+ it('should send email using useNotification', async () => {
18
+ const notification = useNotification().mailgun
8
19
  const test = await notification.send({
9
20
  from: 'repuestobrian2@gmail.com',
10
21
  to: 'repuestobrian@gmail',
@@ -16,6 +27,7 @@ describe('Mailgun Test', () => {
16
27
  })
17
28
 
18
29
  it('should not send email when receiver is empty', async () => {
30
+ const notification = email.mailgun
19
31
  const test = await notification.send({
20
32
  from: env.email.sendgrid.from,
21
33
  to: '',
@@ -26,4 +38,3 @@ describe('Mailgun Test', () => {
26
38
  expect(test.error).toThrowError(Error)
27
39
  })
28
40
  })
29
-