@orchesty/connector-wflow 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/coverage/clover.xml +137 -119
- package/coverage/coverage-final.json +10 -9
- package/coverage/lcov-report/index.html +16 -16
- package/coverage/lcov-report/src/Batch/WflowSubscribeWebhookBatch.ts.html +10 -10
- package/coverage/lcov-report/src/Batch/WflowUnsubscribeWebhookBatch.ts.html +9 -9
- package/coverage/lcov-report/src/Batch/index.html +1 -1
- package/coverage/lcov-report/src/Connector/WflowGetDocumentConnector.ts.html +7 -7
- package/coverage/lcov-report/src/Connector/WflowGetDocumentMainFileConnector.ts.html +205 -0
- package/coverage/lcov-report/src/Connector/WflowGetDocumentTypesConnector.ts.html +9 -9
- package/coverage/lcov-report/src/Connector/WflowGetOrganizationsConnector.ts.html +9 -9
- package/coverage/lcov-report/src/Connector/WflowPutDocumentConnector.ts.html +7 -7
- package/coverage/lcov-report/src/Connector/WflowUpdateDocumentStateConnector.ts.html +7 -7
- package/coverage/lcov-report/src/Connector/index.html +20 -5
- package/coverage/lcov-report/src/WflowApplication.ts.html +33 -33
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/test/dataProvider.ts.html +39 -33
- package/coverage/lcov-report/test/index.html +5 -5
- package/coverage/lcov.info +163 -135
- package/dist/Connector/WflowGetDocumentMainFileConnector.d.ts +13 -0
- package/dist/Connector/WflowGetDocumentMainFileConnector.js +25 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/src/Connector/WflowGetDocumentMainFileConnector.ts +40 -0
- package/src/Connector/__tests__/Data/WflowGetDocumentMainFileConnector/input.json +8 -0
- package/src/Connector/__tests__/Data/WflowGetDocumentMainFileConnector/mock.json +5 -0
- package/src/Connector/__tests__/Data/WflowGetDocumentMainFileConnector/output.json +8 -0
- package/src/Connector/__tests__/WflowGetDocumentMainFileConnector.ts +17 -0
- package/test/dataProvider.ts +2 -0
- package/tsconfig.prod.tsbuildinfo +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
3
|
+
import { CommonHeaders } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
|
|
4
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
5
|
+
import { NAME as WFLOW_APP_NAME, ORGANIZATION, ORGANIZATION_FORM } from '../WflowApplication';
|
|
6
|
+
|
|
7
|
+
export const NAME = `${WFLOW_APP_NAME}-get-document-main-file-connector`;
|
|
8
|
+
|
|
9
|
+
export default class WflowGetDocumentMainFileConnector extends AConnector {
|
|
10
|
+
|
|
11
|
+
public getName(): string {
|
|
12
|
+
return NAME;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
|
|
16
|
+
const { documentId } = dto.getJsonData();
|
|
17
|
+
const applicationInstall = await this.getApplicationInstallFromProcess(dto);
|
|
18
|
+
const organization = applicationInstall.getSettings()[ORGANIZATION_FORM]?.[ORGANIZATION];
|
|
19
|
+
|
|
20
|
+
const requestDto = (await this.getApplication().getRequestDto(
|
|
21
|
+
dto,
|
|
22
|
+
applicationInstall,
|
|
23
|
+
HttpMethods.GET,
|
|
24
|
+
`/${organization}/documents/${documentId}/files/main/download`,
|
|
25
|
+
)).addHeaders({ [CommonHeaders.ACCEPT]: 'application/octet-stream' });
|
|
26
|
+
|
|
27
|
+
const responseDto = await this.getSender().send(requestDto, [200]);
|
|
28
|
+
|
|
29
|
+
return dto.setNewJsonData({ file: responseDto.getBuffer().toString('base64') });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IInput {
|
|
35
|
+
documentId: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IOutput {
|
|
39
|
+
file: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"http": "GET https://api.wflow.com/api/test/documents/463b5265-2672-4191-9e3b-9d6fcfe6a452/files/main/download",
|
|
3
|
+
"code": 200,
|
|
4
|
+
"body": "%PDF-1.1\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n\n3 0 obj\n<< /Type /Page /Parent 2 0 R /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R /MediaBox [0 0 595 842] >>\nendobj\n\n4 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\n\n5 0 obj\n<< /Length 40 >>\nstream\nBT /F1 24 Tf 250 409 Td (Example) Tj ET\nendstream\nendobj\n\nxref\n0 6\n0000000000 65535 f \n0000000009 00000 n \n0000000058 00000 n \n0000000116 00000 n \n0000000246 00000 n \n0000000315 00000 n \ntrailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n403\n%%EOF"
|
|
5
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"headers": {
|
|
3
|
+
"user": "TestUser"
|
|
4
|
+
},
|
|
5
|
+
"data": {
|
|
6
|
+
"file": "IiVQREYtMS4xXG4xIDAgb2JqXG48PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj5cbmVuZG9ialxuXG4yIDAgb2JqXG48PCAvVHlwZSAvUGFnZXMgL0tpZHMgWzMgMCBSXSAvQ291bnQgMSA+PlxuZW5kb2JqXG5cbjMgMCBvYmpcbjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNCAwIFIgPj4gPj4gL0NvbnRlbnRzIDUgMCBSIC9NZWRpYUJveCBbMCAwIDU5NSA4NDJdID4+XG5lbmRvYmpcblxuNCAwIG9ialxuPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cGUgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhID4+XG5lbmRvYmpcblxuNSAwIG9ialxuPDwgL0xlbmd0aCA0MCA+Plxuc3RyZWFtXG5CVCAvRjEgMjQgVGYgMjUwIDQwOSBUZCAoRXhhbXBsZSkgVGogRVRcbmVuZHN0cmVhbVxuZW5kb2JqXG5cbnhyZWZcbjAgNlxuMDAwMDAwMDAwMCA2NTUzNSBmIFxuMDAwMDAwMDAwOSAwMDAwMCBuIFxuMDAwMDAwMDA1OCAwMDAwMCBuIFxuMDAwMDAwMDExNiAwMDAwMCBuIFxuMDAwMDAwMDI0NiAwMDAwMCBuIFxuMDAwMDAwMDMxNSAwMDAwMCBuIFxudHJhaWxlclxuPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+Plxuc3RhcnR4cmVmXG40MDNcbiUlRU9GIg=="
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
|
|
2
|
+
import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
|
|
3
|
+
import init from '../../../test/dataProvider';
|
|
4
|
+
import { NAME as WFLOW_GET_DOCUMENT_MAIN_FILE_CONNECTOR } from '../WflowGetDocumentMainFileConnector';
|
|
5
|
+
|
|
6
|
+
let tester: NodeTester;
|
|
7
|
+
|
|
8
|
+
describe('Tests for WflowGetDocumentMainFileConnector', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
tester = new NodeTester(container, __filename);
|
|
11
|
+
init();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('process - ok', async () => {
|
|
15
|
+
await tester.testConnector(WFLOW_GET_DOCUMENT_MAIN_FILE_CONNECTOR);
|
|
16
|
+
});
|
|
17
|
+
});
|
package/test/dataProvider.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { mockOnce } from '@orchesty/nodejs-sdk/dist/test/MockServer';
|
|
|
10
10
|
import WflowSubscribeWebhookBatch from '../src/Batch/WflowSubscribeWebhookBatch';
|
|
11
11
|
import WflowUnsubscribeWebhookBatch from '../src/Batch/WflowUnsubscribeWebhookBatch';
|
|
12
12
|
import WflowGetDocumentConnector from '../src/Connector/WflowGetDocumentConnector';
|
|
13
|
+
import WflowGetDocumentMainFileConnector from '../src/Connector/WflowGetDocumentMainFileConnector';
|
|
13
14
|
import WflowGetDocumentTypesConnector from '../src/Connector/WflowGetDocumentTypesConnector';
|
|
14
15
|
import WflowGetOrganizationsConnector from '../src/Connector/WflowGetOrganizationsConnector';
|
|
15
16
|
import WflowPutDocumentConnector from '../src/Connector/WflowPutDocumentConnector';
|
|
@@ -48,6 +49,7 @@ export default function init(): void {
|
|
|
48
49
|
container.setApplication(app);
|
|
49
50
|
|
|
50
51
|
container.setNode(new WflowGetDocumentConnector(), app);
|
|
52
|
+
container.setNode(new WflowGetDocumentMainFileConnector(), app);
|
|
51
53
|
container.setNode(new WflowGetDocumentTypesConnector(), app);
|
|
52
54
|
container.setNode(new WflowUpdateDocumentStateConnector(), app);
|
|
53
55
|
container.setNode(new WflowSubscribeWebhookBatch(), app);
|