@novu/framework 2.0.0-canary.3 → 2.0.0-canary.5
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 -12
- package/dist/handler-kv_Ed8ly.d.ts +4421 -0
- package/dist/index.d.ts +16 -13
- package/dist/index.js +447 -114
- package/dist/{express.d.ts → servers/express.d.ts} +1 -1
- package/dist/servers/express.js +30 -0
- package/dist/{h3.d.ts → servers/h3.d.ts} +1 -1
- package/dist/servers/h3.js +31 -0
- package/dist/servers/lambda.d.ts +24 -0
- package/dist/servers/lambda.js +30 -0
- package/dist/{next.d.ts → servers/next.d.ts} +1 -1
- package/dist/servers/next.js +30 -0
- package/dist/{nuxt.d.ts → servers/nuxt.d.ts} +1 -1
- package/dist/servers/nuxt.js +31 -0
- package/dist/{remix.d.ts → servers/remix.d.ts} +1 -1
- package/dist/servers/remix.js +30 -0
- package/dist/{sveltekit.d.ts → servers/sveltekit.d.ts} +1 -1
- package/dist/servers/sveltekit.js +30 -0
- package/package.json +40 -26
- package/dist/express.js +0 -28
- package/dist/h3.js +0 -29
- package/dist/handler-3oTUJvk2.d.ts +0 -3369
- package/dist/next.js +0 -28
- package/dist/nuxt.js +0 -29
- package/dist/remix.js +0 -28
- package/dist/sveltekit.js +0 -28
package/README.md
CHANGED
|
@@ -25,8 +25,8 @@ npm install @novu/framework
|
|
|
25
25
|
## Quickstart
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { workflow, CronExpression
|
|
29
|
-
import { serve } from
|
|
28
|
+
import { workflow, CronExpression } from '@novu/framework';
|
|
29
|
+
import { serve } from '@novu/framework/next';
|
|
30
30
|
import { z } from 'zod';
|
|
31
31
|
|
|
32
32
|
// Define your notification workflow
|
|
@@ -41,15 +41,19 @@ const weeklyComments = workflow(
|
|
|
41
41
|
cron: CronExpression.EVERY_WEEK,
|
|
42
42
|
}));
|
|
43
43
|
|
|
44
|
-
await step.email(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
await step.email(
|
|
45
|
+
'weekly-comments',
|
|
46
|
+
async (controls) => ({
|
|
47
|
+
subject: `${controls.prefix} - Weekly post comments (${weeklyDigest.events.length})`,
|
|
48
|
+
body: `Weekly digest: ${weeklyDigest.events.map(({ payload }) => payload.comment).join(', ')}`,
|
|
49
|
+
}),
|
|
50
|
+
{
|
|
51
|
+
// Skip the notification if the weekly digest is empty
|
|
52
|
+
skip: () => weeklyDigest.events.length === 0,
|
|
53
|
+
// Non-technical stakeholders can modify strongly-validated copy in Novu Cloud
|
|
54
|
+
controlSchema: z.object({ prefix: z.string().describe('The prefix of the subject.').default('Hi!') }),
|
|
55
|
+
}
|
|
56
|
+
);
|
|
53
57
|
},
|
|
54
58
|
{ payloadSchema: z.object({ comment: z.string().describe('The comment on the post.') }) }
|
|
55
59
|
);
|
|
@@ -58,5 +62,5 @@ const weeklyComments = workflow(
|
|
|
58
62
|
const { GET, POST, OPTIONS } = serve({ workflows: [weeklyComments] });
|
|
59
63
|
|
|
60
64
|
// Trigger your notification workflow
|
|
61
|
-
weeklyComments.trigger({
|
|
65
|
+
weeklyComments.trigger({ to: 'user:123', comment: 'This is a comment on a post' });
|
|
62
66
|
```
|