@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 CHANGED
@@ -25,8 +25,8 @@ npm install @novu/framework
25
25
  ## Quickstart
26
26
 
27
27
  ```typescript
28
- import { workflow, CronExpression, } from "@novu/framework";
29
- import { serve } from "@novu/framework/next";
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('weekly-comments', async (controls) => ({
45
- subject: `${controls.prefix} - Weekly post comments (${weeklyDigest.events.length})`,
46
- body: `Weekly digest: ${weeklyDigest.events.map(({ payload }) => payload.comment).join(', ')}`,
47
- }), {
48
- // Skip the notification if the user has already seen it
49
- skip: () => inAppResponse.seen,
50
- // Non-technical stakeholders can modify strongly-validated copy in Novu Cloud
51
- inputSchema: z.object({ prefix: z.string().describe('The prefix of the subject.').default('Hi!') }),
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({ postId: '123', to: 'user:123' });
65
+ weeklyComments.trigger({ to: 'user:123', comment: 'This is a comment on a post' });
62
66
  ```