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 add nodejs sdk methods for workflow overrides api #5020

Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8f6cbc4
feat(api): added workflow-override api support for node sdk
Dec 21, 2023
49abad3
Merge remote-tracking branch 'upstream/next' into featAdd-Nodejs-SDK-…
Dec 21, 2023
364bd08
fix(api): fixed the name of the class as per the api
Dec 21, 2023
5d12c8c
feat(api): added the test cases for node sdk test for workflow-overri…
Dec 21, 2023
3c4f8dc
feat(api): updated the file to fix the proper call of getworkflowover…
Dec 21, 2023
5bb7552
feat(api): cleanup step
Dec 22, 2023
14e7445
feat(api): added the readme.md file
Dec 22, 2023
7f046e7
feat(api): wrong file pushed, adding readme.md
Dec 22, 2023
a7a1298
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Dec 22, 2023
6f21f73
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Dec 29, 2023
891cd72
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Dec 31, 2023
ed9e76b
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Jan 3, 2024
0d6111e
Update packages/node/src/lib/workflow-override/workflow-override.ts
Prashant-dot1 Jan 3, 2024
e935151
Update packages/node/src/lib/workflow-override/workflow-override.ts
Prashant-dot1 Jan 3, 2024
d0cd7cf
Update packages/node/src/lib/workflow-override/workflow-overrride.spe…
Prashant-dot1 Jan 3, 2024
31cdc2e
Update packages/node/src/lib/workflow-override/workflow-overrride.spe…
Prashant-dot1 Jan 3, 2024
fe4712c
Update packages/node/src/lib/workflow-override/workflow-overrride.spe…
Prashant-dot1 Jan 3, 2024
5743963
fix(api): updated the files with fix of all the review comments
Jan 3, 2024
eabc74f
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Jan 3, 2024
3b8ae98
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Jan 4, 2024
b46ff12
Merge branch 'next' of github.com:Prashant-dot1/novu into featAdd-Nod…
Prashant-dot1 Jan 8, 2024
af5ff37
Update packages/node/README.md
Prashant-dot1 Jan 8, 2024
3c92c9b
Update packages/node/src/lib/workflow-override/workflow-override.inte…
Prashant-dot1 Jan 8, 2024
04f515f
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Jan 8, 2024
5a6473e
Merge branch 'featAdd-Nodejs-SDK-methods-for-Workflow-Overrides-API' …
Prashant-dot1 Jan 8, 2024
7bd7c1e
fix(api): updated the readme for workflow override
Prashant-dot1 Jan 8, 2024
341beac
Update packages/node/README.md
jainpawan21 Jan 9, 2024
f341afc
Merge branch 'next' into featAdd-Nodejs-SDK-methods-for-Workflow-Over…
Prashant-dot1 Jan 9, 2024
d152b78
fix: some issues
jainpawan21 Jan 9, 2024
fe32309
fix: spell errors
jainpawan21 Jan 10, 2024
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
90 changes: 90 additions & 0 deletions packages/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Novu provides a single API to manage providers across multiple channels with a s
- [Organizations](#organizations)
- [Inbound Parse](#inbound-parse)
- [Execution Details](#execution-details)
- [Workflow Overrides](#workflow-override)
Prashant-dot1 marked this conversation as resolved.
Show resolved Hide resolved

### Subscribers

Expand Down Expand Up @@ -1267,3 +1268,92 @@ const executionDetailsParams = {
// get execution details
await novu.executionDetails.get(executionDetailsParams)
```

### Workflow Overrides

- #### create new workflow override
jainpawan21 marked this conversation as resolved.
Show resolved Hide resolved
```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.create({
workflowId: 'workdflowId_123',
tenantId: 'tenantID_123',
active: false,
})
```

- #### get all workflow overrides
```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.getWorkflowOverrides();
```

- #### get all workflow overrides from the 3rd page and with a limit of 20
Copy link
Member

Choose a reason for hiding this comment

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

remove this one and add params in above methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.getWorkflowOverrides(3,20)
```

- #### get workflow override by overrideId
```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.getworkflowOverrideById('overrideId_123');
```

- #### get workflow override by tenant
```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.getWorkflowOverrideByTenant(
'workflowId_123',
'tenantId_123'
);
Copy link
Member

Choose a reason for hiding this comment

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

Make sure code formatting is correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected it

```

- #### Update workflow override
```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.updateWorkflowOverride(
'overrideId_123',
'tenantId_123',
{
active: false,
}
);
Copy link
Member

Choose a reason for hiding this comment

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

Make sure code formatting is correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected it

```

- #### Update workflow override by tenantId
Copy link
Member

Choose a reason for hiding this comment

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

Update these headings as per methods name change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.updateWorkflowOverrideById('OVERRIDE_ID', {
active: false,
});
```

- #### Delete workflow override
```ts
import { Novu } from '@novu/node';

const novu = new Novu('<NOVU_API_KEY>');

await novu.workflowoverrides.delete('overrideId_123');
```
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export * from './lib/topics/topic.interface';
export * from './lib/integrations/integrations.interface';
export * from './lib/messages/messages.interface';
export * from './lib/organizations/organizations.interface';
export * from './lib/workflow-override/workflow-override.interface';
export { defaultRetryCondition } from './lib/retry';
3 changes: 3 additions & 0 deletions packages/node/src/lib/novu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Tenants } from './tenants/tenants';
import { ExecutionDetails } from './execution-details/execution-details';
import { InboundParse } from './inbound-parse/inbound-parse';
import { Organizations } from './organizations/organizations';
import { WorkflowOverrides } from './workflow-override/workflow-override';

import { makeRetryable } from './retry';

Expand All @@ -37,6 +38,7 @@ export class Novu extends EventEmitter {
readonly executionDetails: ExecutionDetails;
readonly inboundParse: InboundParse;
readonly organizations: Organizations;
readonly workflowoverrides: WorkflowOverrides;

constructor(apiKey: string, config?: INovuConfiguration) {
super();
Expand Down Expand Up @@ -69,6 +71,7 @@ export class Novu extends EventEmitter {
this.executionDetails = new ExecutionDetails(this.http);
this.inboundParse = new InboundParse(this.http);
this.organizations = new Organizations(this.http);
this.workflowoverrides = new WorkflowOverrides(this.http);

this.trigger = this.events.trigger;
this.bulkTrigger = this.events.bulkTrigger;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { IPreferenceChannels, WorkflowOverrideId } from '@novu/shared';

export interface IWorkflowOverrides {
create(data: IWorkflowOverridePayload);
getWorkflowOverrides(page?: number, limit?: number);
getworkflowOverrideById(overrideId: string);
getWorkflowOverrideByTenant(workflowId: string, tenantId: string);
updateWorkflowOverrideById(
overrideId: string,
data: IWorkflowOverrideUpdatePayload
);
updateWorkflowOverride(
overrideId: string,
Prashant-dot1 marked this conversation as resolved.
Show resolved Hide resolved
tenantId: string,
data: IWorkflowOverrideUpdatePayload
);
delete(overrideId: string);
}

export interface IWorkflowOverridePayload {
workflowId: WorkflowOverrideId;
tenantId: string;
active?: boolean;
preferenceSettings?: IPreferenceChannels;
}

export interface IWorkflowOverrideUpdatePayload {
active?: boolean;
preferenceSettings?: IPreferenceChannels;
}
83 changes: 83 additions & 0 deletions packages/node/src/lib/workflow-override/workflow-override.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import {
IWorkflowOverridePayload,
IWorkflowOverrides,
IWorkflowOverrideUpdatePayload,
} from './workflow-override.interface';
import { WithHttp } from '../novu.interface';

export class WorkflowOverrides extends WithHttp implements IWorkflowOverrides {
/**
* @param {string} overrideId - overrideId of the workflow-override to update
* @param {IWorkflowOverrideUpdatePayload} data - All the additional parameters to update a worflow-override
*/
async updateWorkflowOverrideById(
overrideId: string,
data: IWorkflowOverrideUpdatePayload
) {
return await this.http.put(`/workflow-overrides/${overrideId}`, {
...data,
});
}

/**
* @param {IWorkflowOverridePayload} data - All the additional parameters to create a workflow-override
*/
async create(data: IWorkflowOverridePayload) {
return await this.http.post(`/workflow-overrides`, {
...data,
});
}

/**
* @param {string} overrideId - overrideId of the workflow
*/
async getworkflowOverrideById(overrideId: string) {
return await this.http.get(`/workflow-overrides/${overrideId}`);
}

/**
* @param {number} page - Page number to fetch
* @param {number} limit - Number of results to fetch in one page
*/
async getWorkflowOverrides(page = 0, limit = 10) {
return await this.http.get(`/workflow-overrides`, {
params: { page, limit },
});
}

/**
* @param {string} workflowId - workflowId
* @param {string} tenantId - tenantId
*/
async getWorkflowOverrideByTenant(workflowId: string, tenantId: string) {
return await this.http.get(
`/workflow-overrides/workflows/${workflowId}/tenants/${tenantId}`
);
}

/**
* @param {string} overrideId - workflowId
* @param {string} tenantId - tenantId
* @param {IWorkflowOverrideUpdatePayload} data - All the additional paramters to update workflow override
*/
async updateWorkflowOverride(
overrideId: string,
Prashant-dot1 marked this conversation as resolved.
Show resolved Hide resolved
tenantId: string,
data: IWorkflowOverrideUpdatePayload
) {
return await this.http.put(
`/workflow-overrides/workflows/${overrideId}/tenants/${tenantId}`,
Prashant-dot1 marked this conversation as resolved.
Show resolved Hide resolved
{
...data,
}
);
}

/**
*
* @param {string} overrideId - overrideID of the workflow
*/
async delete(overrideId: string) {
return await this.http.delete(`/workflow-overrides/${overrideId}`);
}
}
Loading
Loading