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

feat(framework): Add trigger capability to defined workflows #5877

Merged
merged 13 commits into from
Jul 2, 2024

Conversation

rifont
Copy link
Collaborator

@rifont rifont commented Jun 29, 2024

What changed? Why was the change needed?

  • Add workflow.trigger(...) capability for triggering defined workflows
  • Add (await workflow.trigger(...)).cancel() capability for cancelling trigger of defined workflows
  • Add getBridgeUrl util to resolve correct bridge URL in framework agnostic way

NB: See this stacked follow up PR (#5880) which replaces use of the internal HTTP client with @novu/api bindings

Screenshots

Tested working in the AI Digest Repo
rifont/novu-ai-digest#1
image

workflow.trigger() intellisense with strongly typed payload
image

(await workflow.trigger()).cancel() available after using the trigger (no need to pass transactionId)
image

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Jun 29, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit e862163
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/6683b9d639e2830007c0bb3a
😎 Deploy Preview https://deploy-preview-5877--dev-web-novu.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

netlify bot commented Jun 29, 2024

Deploy Preview for novu-design failed. Why did it fail? →

Name Link
🔨 Latest commit e862163
🔍 Latest deploy log https://app.netlify.com/sites/novu-design/deploys/6683b9d7af1445000875e4fb


const cancel = async () => {
return apiClient.delete<CancelEventTriggerResponse>(`/events/trigger/${result.transactionId}`);
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding cancel for a complete E2E story on the trigger.

@rifont
Copy link
Collaborator Author

rifont commented Jun 29, 2024

I'm thinking I'll replace all the api HTTP client with @novu/api usage instead. We can start dogfooding it for all resources exposed code-first.

Where should the instantiated new (await import('@novu/api')).Client live? And how should it be accessed?

@rifont
Copy link
Collaborator Author

rifont commented Jun 30, 2024

I'm thinking I'll replace all the api HTTP client with @novu/api usage instead. We can start dogfooding it for all resources exposed code-first.

Where should the instantiated new (await import('@novu/api')).Client live? And how should it be accessed?

See #5880

packages/framework/src/types/event.types.ts Outdated Show resolved Hide resolved
packages/framework/src/types/util.types.ts Show resolved Hide resolved
packages/framework/src/workflow.ts Show resolved Hide resolved
packages/framework/src/workflow.ts Show resolved Hide resolved
@rifont rifont merged commit 373fc11 into next Jul 2, 2024
24 checks passed
@rifont rifont deleted the add-framework-workflow-trigger branch July 2, 2024 09:32
SokratisVidros added a commit that referenced this pull request Jul 2, 2024
* fix(web): local to dev sync modal improvement (#5912)

* fix: wip

* fix: update copy

* fix: remove not reccomended

* feat: manual sync

* fix(api): Nv 4021 syncing to production environment fails for new org (#5916)

* fix(web): set cookie as secure

* fix(web): set cookie as secure

* fix(api): create notification group for both envs

* refactor(root): Rename from `web.novu.co` to `dashboard.novu.co` (#5876)

* refactor(env): update URLs to use dashboard subdomain

* chore(netlify): reorder redirects in netlify.toml

* refactor(onboarding): remove unused imports

* fix(novu): Apply the correct authorization type

* feat(framework): Add trigger capability to defined workflows (#5877)

* test(env.utils): add tests for env utility functions

* refactor(client): Update workflow and error handling

* docs(env.utils): Add comments for getBridgeUrl environments

* refactor: Remove generic type from Workflow definition

* test(env.utils): update bridge URL in development env

* fix(env.utils): correct URL construction in dev environment

* test(workflow): add payload schema to test workflow

* refactor(types): define specific types for event params

* refactor(event.types): update import to use type keyword

* refactor(types): update Workflow and EventTriggerParams

* refactor: rename novu sh tunnel domain

* fix(api): Ensure both web and dashboard subdomains work in parallel (#5919)

* fix(api): Ensure both web and dashboard subdomains work in parallel

This is required for a smooth migration process and to avoid signing out existing users.

* fixup! fix(api): Ensure both web and dashboard subdomains work in parallel

* fixup! fixup! fix(api): Ensure both web and dashboard subdomains work in parallel

* fixup! fixup! fixup! fix(api): Ensure both web and dashboard subdomains work in parallel

* fix(worker): store null in cache after stateless trigger (#5922)

* ci: Remove redundant checkout step in deploy job (#5924)

* refactor(cli): update tunnel URL and submodule commit (#5920)

* feat: add tracking event for sync button clicked (#5925)

* chore(root): Update .source

---------

Co-authored-by: Dima Grossman <dima@grossman.io>
Co-authored-by: Gali Ainouz Baum <ainouzgali@gmail.com>
Co-authored-by: Richard Fontein <32132657+rifont@users.noreply.github.com>
Co-authored-by: Sokratis Vidros <sokratis.vidros@gmail.com>
Co-authored-by: Sokratis Vidros <SokratisVidros@users.noreply.github.com>
Co-authored-by: George Djabarov <39195835+djabarovgeorge@users.noreply.github.com>
Co-authored-by: David Söderberg <2233092+davidsoderberg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants