-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(api): add query parser #7267
base: next
Are you sure you want to change the base?
feat(api): add query parser #7267
Conversation
…luate-skip-conditions-in-shared-bridge-endpoint # Conflicts: # pnpm-lock.yaml
…luate-skip-conditions-in-shared-bridge-endpoint
✅ Deploy Preview for dashboard-v2-novu-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -84,6 +85,7 @@ export enum UiComponentEnum { | |||
CHAT_BODY = 'CHAT_BODY', | |||
PUSH_BODY = 'PUSH_BODY', | |||
PUSH_SUBJECT = 'PUSH_SUBJECT', | |||
SKIP_RULES = 'SKIP_RULES', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was not sure how to call. should we switch to SKIP?
SKIP_RULES = 'SKIP_RULES', | |
SKIP = 'SKIP', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SKIP_RULES = 'SKIP_RULES', | |
SKIP_RULES = 'QUERY_EDITOR', |
@@ -0,0 +1,47 @@ | |||
import jsonLogic, { AdditionalOperation, RulesLogic } from 'json-logic-js'; | |||
|
|||
const initializeCustomOperators = (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self note:
validate that we cover all the react-querybuilder
operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! @djabarovgeorge Isn't there an npm package that does this already so that it saves us from adding custom operators?
Do they maybe have it for another JSON representation of conditionals that is more complete out of the box?
What about this?
If not, it's a great opportunity to make an OS contribution to react-querybuilder.
@@ -199,7 +209,25 @@ export class ConstructFrameworkWorkflow { | |||
|
|||
return foundWorkflow; | |||
} | |||
|
|||
private processSkipOption(controlValues: { [x: string]: unknown }, variables: FullPayloadForRender) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can convert this to renderer
.
as a side note, at the moment i am not sure we need to have Injectable use-cases for the renderer
feels like overkill.
private constructCommonStepOptions( | ||
staticStep: NotificationStepEntity, | ||
fullPayloadForRender: FullPayloadForRender |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need FullPayloadForRender variables(===frameweork.payload) data in the skip method to execute the skip function.
|
||
return (await novuClient.trigger(request)).result; | ||
} | ||
|
||
describe('Trigger Event New Dashboard - /v1/events/trigger (POST)', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we rename it to v2 workflow?
describe('Trigger Event New Dashboard - /v1/events/trigger (POST)', function () { | |
describe('Trigger Event v2 workflow - /v1/events/trigger (POST)', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@novu/client
@novu/framework
@novu/headless
@novu/js
@novu/nest
@novu/nextjs
@novu/node
@novu/notification-center
novu
@novu/providers
@novu/react
@novu/react-native
@novu/shared
@novu/stateless
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the main reason for this spec is that we are adding new operators to the json logic js, which are not tests in json logic js. Therefore, we need to make sure we are testing it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏
); | ||
case StepTypeEnum.DELAY: | ||
return step.delay( | ||
stepId, | ||
async (controlValues) => { | ||
return this.delayOutputRendererUseCase.execute({ controlValues, fullPayloadForRender }); | ||
}, | ||
this.constructActionStepOptions(staticStep) | ||
this.constructActionStepOptions(staticStep, fullPayloadForRender) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit-picky: This function is the same across all steps, we can remove it out side the switch.
* Used to construct conditions defined with https://react-querybuilder.js.org/ or similar | ||
*/ | ||
skip: (controlValues) => false, | ||
skip: (controlValues: { [x: string]: unknown }) => this.processSkipOption(controlValues, fullPayloadForRender), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip: (controlValues: { [x: string]: unknown }) => this.processSkipOption(controlValues, fullPayloadForRender), | |
skip: (controlValues: Record<string, unknown>) => this.processSkipOption(controlValues, fullPayloadForRender), |
const skipRules = controlValues.skip as RulesLogic<AdditionalOperation>; | ||
|
||
// TODO: check if we need to add more validation here (is empty object, etc.) | ||
if (!skipRules) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use lodash/isEmpty and cover all of the empty cases of an object ;)
if (!skipRules) { | |
if (isEmpty(skipRules)) { |
const { result, error } = evaluateRules(skipRules, variables); | ||
|
||
if (error) { | ||
this.logger.error({ err: error }, 'Failed to evaluate skip rule', LOG_CONTEXT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we pause workflow execution when there is a skip condition error? I think we should and we need to show it in activity feed.
|
||
return (await novuClient.trigger(request)).result; | ||
} | ||
|
||
describe('Trigger Event New Dashboard - /v1/events/trigger (POST)', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@@ -0,0 +1,47 @@ | |||
import jsonLogic, { AdditionalOperation, RulesLogic } from 'json-logic-js'; | |||
|
|||
const initializeCustomOperators = (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! @djabarovgeorge Isn't there an npm package that does this already so that it saves us from adding custom operators?
Do they maybe have it for another JSON representation of conditionals that is more complete out of the box?
What about this?
If not, it's a great opportunity to make an OS contribution to react-querybuilder.
@@ -84,6 +85,7 @@ export enum UiComponentEnum { | |||
CHAT_BODY = 'CHAT_BODY', | |||
PUSH_BODY = 'PUSH_BODY', | |||
PUSH_SUBJECT = 'PUSH_SUBJECT', | |||
SKIP_RULES = 'SKIP_RULES', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SKIP_RULES = 'SKIP_RULES', | |
SKIP_RULES = 'QUERY_EDITOR', |
What changed? Why was the change needed?
Screenshots
Expand for optional sections
Related enterprise PR
Special notes for your reviewer