Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(framework): Specify zod-to-json-schema as a dependency #6741

Draft
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

rifont
Copy link
Contributor

@rifont rifont commented Oct 22, 2024

What changed? Why was the change needed?

  • Make zod-to-json-schema a dependency of @novu/framework
    • Next.js doesn't support require statements in type: 'module' projects, so it's necessary to make zod-to-json-schema a direct dependency for the time being and accept a slightly larger bundle size for Framework.

Screenshots

Before - error shown at build time:

Module not found: Can't resolve 'zod-to-json-schema'
  12 | var Ce = require('ajv');
  13 | var Le = require('ajv-formats');
> 14 | var zodToJsonSchema = require('zod-to-json-schema');
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  15 |
  16 | function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
  17 |



https://nextjs.org/docs/messages/module-not-found


 GET /api/novu?action=health-check 500 in 90ms
 ⨯ ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_re_6qslqckf3f4j3hmeq5cl5pprvm/node_modules/@novu/framework/dist/index.js:13:23

Verifying that @novu/framework can be used without Zod now

import { serve } from "@novu/framework/next";
import { workflow } from '@novu/framework';

export const myNamedWorkflow = workflow('welcome-onboarding', async ({ step }) => {
    await step.email('send-email', async () => {
      return ({
        subject: 'Welcome to our platform!',
        body: 'Welcome to our platform!',
      })
    });
  }, {
    payloadSchema: {
        type: 'object',
        properties: {
            name: { type: 'string' },
        },
        required: ['name'],
        additionalProperties: false,
    } as const,
  });

export const { GET, POST, OPTIONS } = serve({
    workflows: [
        myNamedWorkflow
    ]
})
Discovered workflowId: 'welcome-onboarding'
└ σ Discovered stepId: 'send-email'     Type: 'email'
 GET /api/novu?action=discover 200 in 2233ms
 GET /api/novu?action=discover 200 in 2236ms
Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 5c62c03
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/6717c1c2b0cf4a00085cbd92
😎 Deploy Preview https://deploy-preview-6741--novu-stg-vite-dashboard-poc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@merrcury merrcury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -53,6 +53,7 @@ export type DiscoverStepOutput = {
export type DiscoverWorkflowOutput = {
workflowId: string;
execute: Execute<Record<string, unknown>, Record<string, unknown>>;
/** @deprecated use top-level properties instead */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should've been added already. It will be cleaned up soon.

Copy link

pkg-pr-new bot commented Oct 22, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/novuhq/novu/@novu/framework@6741

commit: 5c62c03

@rifont rifont changed the title fix(framework): Use runtime import for zod-to-json-schema fix(framework): Specify zod-to-json-schema as a dependency Oct 22, 2024
@rifont rifont marked this pull request as draft October 22, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants