-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add execution-details and inbound-parse to node sdk (#4746)
* feat: Add execution-details to node sdk * feat: Add inbound-parse mx status to node sdk * fix: Add notificationId and subscriberId params to execution details node sdk get method * docs: Add execution details and inbound parse node sdk methods to readme * update exection details params * fix: change subscribers to events * fix: update pnpm lock file --------- Co-authored-by: Pawan Jain <[email protected]>
- Loading branch information
1 parent
5506919
commit 063aa16
Showing
9 changed files
with
642 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/node/src/lib/execution-details/execution-details.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface IExecutionDetails { | ||
get(data: IExecutionDetailsPayload); | ||
} | ||
|
||
export interface IExecutionDetailsPayload { | ||
notificationId: string; | ||
subscriberId: string; | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/node/src/lib/execution-details/execution-details.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Novu } from '../novu'; | ||
import axios from 'axios'; | ||
|
||
const mockConfig = { | ||
apiKey: '1234', | ||
}; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('test use of novus node package - ExecutionDetails class', () => { | ||
const mockedAxios = axios as jest.Mocked<typeof axios>; | ||
let novu: Novu; | ||
|
||
beforeEach(() => { | ||
mockedAxios.create.mockReturnThis(); | ||
novu = new Novu(mockConfig.apiKey); | ||
}); | ||
|
||
test('should get execution details correctly', async () => { | ||
const notificationId = '12345678'; | ||
const subscriberId = '987654321'; | ||
mockedAxios.get.mockResolvedValue({}); | ||
|
||
await novu.executionDetails.get({ notificationId, subscriberId }); | ||
|
||
expect(mockedAxios.get).toHaveBeenCalled(); | ||
expect(mockedAxios.get).toHaveBeenCalledWith('/execution-details'); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/node/src/lib/execution-details/execution-details.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
IExecutionDetails, | ||
IExecutionDetailsPayload, | ||
} from './execution-details.interface'; | ||
import { WithHttp } from '../novu.interface'; | ||
|
||
export class ExecutionDetails extends WithHttp implements IExecutionDetails { | ||
async get(data: IExecutionDetailsPayload) { | ||
const { notificationId, subscriberId } = data; | ||
|
||
return await this.http.get(`/execution-details`, { | ||
params: { notificationId, subscriberId }, | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/node/src/lib/inbound-parse/inbound-parse.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface IInboundParse { | ||
getMxStatus(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Novu } from '../novu'; | ||
import axios from 'axios'; | ||
|
||
const mockConfig = { | ||
apiKey: '1234', | ||
}; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('test use of novus node package - InboundParse class', () => { | ||
const mockedAxios = axios as jest.Mocked<typeof axios>; | ||
let novu: Novu; | ||
|
||
beforeEach(() => { | ||
mockedAxios.create.mockReturnThis(); | ||
novu = new Novu(mockConfig.apiKey); | ||
}); | ||
|
||
test('should get inbound parse correctly', async () => { | ||
mockedAxios.get.mockResolvedValue({}); | ||
|
||
await novu.inboundParse.getMxStatus(); | ||
|
||
expect(mockedAxios.get).toHaveBeenCalled(); | ||
expect(mockedAxios.get).toHaveBeenCalledWith('/inbound-parse/mx/status'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { IInboundParse } from './inbound-parse.interface'; | ||
import { WithHttp } from '../novu.interface'; | ||
|
||
export class InboundParse extends WithHttp implements IInboundParse { | ||
async getMxStatus() { | ||
return await this.http.get(`/inbound-parse/mx/status`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.