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

refactor(framework): Rename inputs to controls #5819

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ For API documentation and reference, please visit [Echo API Reference](https://d
```ts

client.workflow('comment-on-post', async ({step, subscriber}) => {
const inAppResponse = await step.inApp('in-app-step', async (inputs) => {
const inAppResponse = await step.inApp('in-app-step', async (controls) => {
return {
body: renderReactComponent(inputs)
body: renderReactComponent(controls)
};
}, {
inputSchema: {
controlSchema: {
// ...JSON Schema or ZOD/Ajv/Class Validators definition
}
});
Expand All @@ -115,11 +115,11 @@ client.workflow('comment-on-post', async ({step, subscriber}) => {
}
}, {
// Step-level inputs defined in code and controlled in the novu Cloud UI by a Non-Technical Team member
inputSchema: {
controlSchema: {
// ...JSON Schema
},
providers: {
sendgrid: async (inputs) => {
sendgrid: async (controls) => {
// Echo runs as part of your application, so you have access to your database or resources

return {
Expand Down
56 changes: 28 additions & 28 deletions apps/api/src/app/events/e2e/bridge-trigger.e2e-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ contexts.forEach((context: Context) => {
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ' + inputs.name,
subject: 'This is an email subject ' + controls.name,
body: 'Body result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand All @@ -79,13 +79,13 @@ contexts.forEach((context: Context) => {

await step.inApp(
'send-in-app',
async (inputs) => {
async (controls) => {
return {
body: 'in-app result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand All @@ -96,13 +96,13 @@ contexts.forEach((context: Context) => {

await step.sms(
'send-sms',
async (inputs) => {
async (controls) => {
return {
body: 'sms result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand Down Expand Up @@ -161,14 +161,14 @@ contexts.forEach((context: Context) => {
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ' + inputs.name,
subject: 'This is an email subject ' + controls.name,
body: 'Body result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand Down Expand Up @@ -224,21 +224,21 @@ contexts.forEach((context: Context) => {
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ' + inputs.name,
subject: 'This is an email subject ' + controls.name,
body: 'Body result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
shouldSkipVar: { type: 'boolean', default: true },
},
} as const,
skip: (inputs) => inputs.shouldSkipVar,
skip: (controls) => controls.shouldSkipVar,
}
);
},
Expand Down Expand Up @@ -420,14 +420,14 @@ contexts.forEach((context: Context) => {
async ({ step }) => {
const digestResponse = await step.digest(
'digest',
async (inputs) => {
async (controls) => {
return {
amount: inputs.amount,
unit: inputs.unit,
amount: controls.amount,
unit: controls.unit,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
amount: {
Expand Down Expand Up @@ -492,15 +492,15 @@ contexts.forEach((context: Context) => {
async ({ step }) => {
const delayResponse = await step.delay(
'delay-id',
async (inputs) => {
async (controls) => {
return {
type: 'regular',
amount: inputs.amount,
unit: inputs.unit,
amount: controls.amount,
unit: controls.unit,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
amount: {
Expand All @@ -527,7 +527,7 @@ contexts.forEach((context: Context) => {
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {},
},
Expand Down Expand Up @@ -566,21 +566,21 @@ contexts.forEach((context: Context) => {
expect(messagesAfter[0].content).to.match(/people waited for \d+ seconds/);
});

it(`should trigger the echo workflow with input variables [${context.name}]`, async () => {
const workflowId = `input-variables-workflow-${context.name + '-' + uuidv4()}`;
it(`should trigger the echo workflow with control variables [${context.name}]`, async () => {
const workflowId = `control-variables-workflow-${context.name + '-' + uuidv4()}`;
const newWorkflow = workflow(
workflowId,
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'prefix ' + inputs.name,
subject: 'prefix ' + controls.name,
body: 'Body result',
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'Hello {{name}}' },
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/echo-health-check.e2e-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Echo Health Check', async () => {

before(async () => {
const healthCheckWorkflow = workflow('health-check', async ({ step }) => {
await step.email('send-email', async (inputs) => {
await step.email('send-email', async (controls) => {
return {
subject: 'This is an email subject',
body: 'Body result',
Expand Down
22 changes: 11 additions & 11 deletions apps/api/src/app/testing/echo/echo-sync.e2e-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ describe('Echo Sync - /echo/sync (POST)', async () => {
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ' + inputs.name,
subject: 'This is an email subject ' + controls.name,
body: 'Body result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand Down Expand Up @@ -125,14 +125,14 @@ describe('Echo Sync - /echo/sync (POST)', async () => {
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ',
body: 'Body result ',
};
},
{
inputSchema: inputPostPayload.schema as any,
controlSchema: inputPostPayload.schema as any,
}
);
},
Expand Down Expand Up @@ -180,14 +180,14 @@ describe('Echo Sync - /echo/sync (POST)', async () => {
async ({ step, payload }) => {
await step.email(
'send-email',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ' + inputs.name,
subject: 'This is an email subject ' + controls.name,
body: 'Body result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand Down Expand Up @@ -222,14 +222,14 @@ describe('Echo Sync - /echo/sync (POST)', async () => {
async ({ step, payload }) => {
await step.email(
'send-email-2',
async (inputs) => {
async (controls) => {
return {
subject: 'This is an email subject ' + inputs.name,
subject: 'This is an email subject ' + controls.name,
body: 'Body result ' + payload.name,
};
},
{
inputSchema: {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'TEST' },
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/studio-onboarding/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ export const StudioOnboardingPreview = () => {
{`workflow("welcome-onboarding-email", async ({ step, payload }) => {
await step.email(
"send-email",
async (inputs) => {
async (controls) => {
return {
subject: "A Successful Test on Novu!",
body: renderEmail(inputs, payload),
};
},
{
inputSchema: {
controlSchema: {
type: "object",
properties: {
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export const myWorkflow = workflow(
async ({ step }) => {
await step.email(
"send-email",
async (inputs) => {
async (controls) => {
return {
subject: "This is an email subject",
body: renderReactEmail(inputs),
body: renderReactEmail(controls),
};
},
{
inputSchema: {
controlSchema: {
type: "object",

properties: {
Expand Down Expand Up @@ -49,7 +49,7 @@ export const myWorkflow = workflow(
default: "São Paulo, Brazil",
},
},
},
} as const,
},
);
},
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const commentWorkflow = await workflow(

await step.email(
'weekly-comments',
async (inputs) => {
async (controls) => {
return {
subject: `Weekly post comments (${weeklyDigest.events.length + 1})`,
body: renderReactEmail(inputs, weeklyDigest.events),
body: renderReactEmail(controls, weeklyDigest.events),
};
},
{ skip: () => inAppResponse.seen }
Expand Down
Loading
Loading