@orchesty/connector-wflow 2.0.1 → 2.0.3
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/dist/Batch/WflowSubscribeWebhookBatch.d.ts +7 -0
- package/dist/Batch/WflowSubscribeWebhookBatch.js +57 -0
- package/dist/Batch/WflowUnsubscribeWebhookBatch.d.ts +7 -0
- package/dist/Batch/WflowUnsubscribeWebhookBatch.js +47 -0
- package/{src/Connector/WflowGetDocumentConnector.ts → dist/Connector/WflowGetDocumentConnector.d.ts} +4 -34
- package/dist/Connector/WflowGetDocumentConnector.js +24 -0
- package/dist/Connector/WflowGetDocumentMainFileConnector.d.ts +13 -0
- package/dist/Connector/WflowGetDocumentMainFileConnector.js +25 -0
- package/dist/Connector/WflowGetDocumentTypesConnector.d.ts +36 -0
- package/dist/Connector/WflowGetDocumentTypesConnector.js +28 -0
- package/dist/Connector/WflowGetOrganizationsConnector.d.ts +15 -0
- package/dist/Connector/WflowGetOrganizationsConnector.js +27 -0
- package/dist/Connector/WflowPatchAccountingRulesConnector.d.ts +17 -0
- package/dist/Connector/WflowPatchAccountingRulesConnector.js +24 -0
- package/dist/Connector/WflowPatchChartOfAccountsConnector.d.ts +15 -0
- package/dist/Connector/WflowPatchChartOfAccountsConnector.js +24 -0
- package/dist/Connector/WflowPatchContractsConnector.d.ts +15 -0
- package/dist/Connector/WflowPatchContractsConnector.js +24 -0
- package/dist/Connector/WflowPatchCostCentersConnector.d.ts +15 -0
- package/dist/Connector/WflowPatchCostCentersConnector.js +24 -0
- package/dist/Connector/WflowPatchSeriesConnector.d.ts +19 -0
- package/dist/Connector/WflowPatchSeriesConnector.js +24 -0
- package/dist/Connector/WflowPatchVatControlStatementLinesConnector.d.ts +15 -0
- package/dist/Connector/WflowPatchVatControlStatementLinesConnector.js +24 -0
- package/dist/Connector/WflowPatchVatReturnLinesConnector.d.ts +16 -0
- package/dist/Connector/WflowPatchVatReturnLinesConnector.js +24 -0
- package/{src/Connector/WflowPutDocumentConnector.ts → dist/Connector/WflowPutDocumentConnector.d.ts} +5 -37
- package/dist/Connector/WflowPutDocumentConnector.js +31 -0
- package/dist/Connector/WflowUpdateDocumentStateConnector.d.ts +11 -0
- package/dist/Connector/WflowUpdateDocumentStateConnector.js +24 -0
- package/dist/WflowApplication.d.ts +41 -0
- package/dist/WflowApplication.js +133 -0
- package/dist/package.json +26 -0
- package/package.json +5 -2
- package/CHANGELOG.md +0 -49
- package/jest.config.js +0 -13
- package/src/Batch/WflowSubscribeWebhookBatch.ts +0 -84
- package/src/Batch/WflowUnsubscribeWebhookBatch.ts +0 -59
- package/src/Batch/__tests__/Data/WflowSubscribeWebhookBatch/input.json +0 -7
- package/src/Batch/__tests__/Data/WflowSubscribeWebhookBatch/mock.json +0 -5
- package/src/Batch/__tests__/Data/WflowSubscribeWebhookBatch/output.json +0 -7
- package/src/Batch/__tests__/Data/WflowUnsubscribeWebhookBatch/input.json +0 -7
- package/src/Batch/__tests__/Data/WflowUnsubscribeWebhookBatch/mock.json +0 -5
- package/src/Batch/__tests__/Data/WflowUnsubscribeWebhookBatch/output.json +0 -7
- package/src/Batch/__tests__/WflowSubscribeWebhookBatch.ts +0 -17
- package/src/Batch/__tests__/WflowUnsubscribeWebhookBatch.ts +0 -17
- package/src/Connector/WflowGetDocumentMainFileConnector.ts +0 -40
- package/src/Connector/WflowGetDocumentTypesConnector.ts +0 -69
- package/src/Connector/WflowGetOrganizationsConnector.ts +0 -40
- package/src/Connector/WflowPatchAccountingRulesConnector.ts +0 -53
- package/src/Connector/WflowPatchChartOfAccountsConnector.ts +0 -42
- package/src/Connector/WflowPatchContractsConnector.ts +0 -42
- package/src/Connector/WflowPatchCostCentersConnector.ts +0 -42
- package/src/Connector/WflowPatchSeriesConnector.ts +0 -61
- package/src/Connector/WflowPatchVatControlStatementLinesConnector.ts +0 -42
- package/src/Connector/WflowPatchVatReturnLinesConnector.ts +0 -43
- package/src/Connector/WflowUpdateDocumentStateConnector.ts +0 -36
- package/src/Connector/__tests__/Data/WflowGetDocumentConnector/input.json +0 -10
- package/src/Connector/__tests__/Data/WflowGetDocumentConnector/mock.json +0 -449
- package/src/Connector/__tests__/Data/WflowGetDocumentConnector/output.json +0 -451
- package/src/Connector/__tests__/Data/WflowGetDocumentMainFileConnector/input.json +0 -9
- package/src/Connector/__tests__/Data/WflowGetDocumentMainFileConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowGetDocumentMainFileConnector/output.json +0 -9
- package/src/Connector/__tests__/Data/WflowGetDocumentTypesConnector/input.json +0 -7
- package/src/Connector/__tests__/Data/WflowGetDocumentTypesConnector/mock.json +0 -32
- package/src/Connector/__tests__/Data/WflowGetDocumentTypesConnector/output.json +0 -29
- package/src/Connector/__tests__/Data/WflowGetOrganizationsConnector/input.json +0 -7
- package/src/Connector/__tests__/Data/WflowGetOrganizationsConnector/mock.json +0 -12
- package/src/Connector/__tests__/Data/WflowGetOrganizationsConnector/output.json +0 -14
- package/src/Connector/__tests__/Data/WflowPatchAccountingRulesConnector/batch-input.json +0 -20
- package/src/Connector/__tests__/Data/WflowPatchAccountingRulesConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchAccountingRulesConnector/batch-output.json +0 -20
- package/src/Connector/__tests__/Data/WflowPatchAccountingRulesConnector/input.json +0 -12
- package/src/Connector/__tests__/Data/WflowPatchAccountingRulesConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchAccountingRulesConnector/output.json +0 -12
- package/src/Connector/__tests__/Data/WflowPatchChartOfAccountsConnector/batch-input.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchChartOfAccountsConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchChartOfAccountsConnector/batch-output.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchChartOfAccountsConnector/input.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchChartOfAccountsConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchChartOfAccountsConnector/output.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchContractsConnector/batch-input.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchContractsConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchContractsConnector/batch-output.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchContractsConnector/input.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchContractsConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchContractsConnector/output.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchCostCentersConnector/batch-input.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchCostCentersConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchCostCentersConnector/batch-output.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchCostCentersConnector/input.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchCostCentersConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchCostCentersConnector/output.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchSeriesConnector/batch-input.json +0 -20
- package/src/Connector/__tests__/Data/WflowPatchSeriesConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchSeriesConnector/batch-output.json +0 -20
- package/src/Connector/__tests__/Data/WflowPatchSeriesConnector/input.json +0 -12
- package/src/Connector/__tests__/Data/WflowPatchSeriesConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchSeriesConnector/output.json +0 -12
- package/src/Connector/__tests__/Data/WflowPatchVatControlStatementLinesConnector/batch-input.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchVatControlStatementLinesConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchVatControlStatementLinesConnector/batch-output.json +0 -18
- package/src/Connector/__tests__/Data/WflowPatchVatControlStatementLinesConnector/input.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchVatControlStatementLinesConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchVatControlStatementLinesConnector/output.json +0 -11
- package/src/Connector/__tests__/Data/WflowPatchVatReturnLinesConnector/batch-input.json +0 -20
- package/src/Connector/__tests__/Data/WflowPatchVatReturnLinesConnector/batch-mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchVatReturnLinesConnector/batch-output.json +0 -20
- package/src/Connector/__tests__/Data/WflowPatchVatReturnLinesConnector/input.json +0 -12
- package/src/Connector/__tests__/Data/WflowPatchVatReturnLinesConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPatchVatReturnLinesConnector/output.json +0 -12
- package/src/Connector/__tests__/Data/WflowPutDocumentConnector/input.json +0 -10
- package/src/Connector/__tests__/Data/WflowPutDocumentConnector/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowPutDocumentConnector/output.json +0 -10
- package/src/Connector/__tests__/Data/WflowUpdateDocumentState/input.json +0 -9
- package/src/Connector/__tests__/Data/WflowUpdateDocumentState/mock.json +0 -5
- package/src/Connector/__tests__/Data/WflowUpdateDocumentState/output.json +0 -9
- package/src/Connector/__tests__/WflowGetDocumentConnector.ts +0 -17
- package/src/Connector/__tests__/WflowGetDocumentMainFileConnector.ts +0 -17
- package/src/Connector/__tests__/WflowGetDocumentTypesConnector.ts +0 -17
- package/src/Connector/__tests__/WflowGetOrganizationsConnector.ts +0 -17
- package/src/Connector/__tests__/WflowPatchAccountingRulesConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPatchChartOfAccountsConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPatchContractsConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPatchCostCentersConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPatchSeriesConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPatchVatControlStatementLinesConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPatchVatReturnLinesConnector.ts +0 -21
- package/src/Connector/__tests__/WflowPutDocumentConnector.ts +0 -17
- package/src/Connector/__tests__/WflowUpdateDocumentState.ts +0 -17
- package/src/WflowApplication.ts +0 -151
- package/test/dataProvider.ts +0 -74
- package/tsconfig.json +0 -9
- package/tsconfig.prod.json +0 -10
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const NAME = "wflow-patch-vat-return-lines-connector";
|
|
4
|
+
export default class WflowPatchVatReturnLinesConnector extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput | IInput[]>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IInput {
|
|
9
|
+
id?: string | null;
|
|
10
|
+
externalId?: string | null;
|
|
11
|
+
code?: string | null;
|
|
12
|
+
description?: string | null;
|
|
13
|
+
isValid?: boolean;
|
|
14
|
+
reverseCharge?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type IOutput = IInput | IInput[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
const WflowApplication_1 = require("../WflowApplication");
|
|
10
|
+
exports.NAME = `${WflowApplication_1.NAME}-patch-vat-return-lines-connector`;
|
|
11
|
+
class WflowPatchVatReturnLinesConnector extends AConnector_1.default {
|
|
12
|
+
getName() {
|
|
13
|
+
return exports.NAME;
|
|
14
|
+
}
|
|
15
|
+
async processAction(dto) {
|
|
16
|
+
const data = dto.getJsonData();
|
|
17
|
+
const application = this.getApplication();
|
|
18
|
+
const applicationInstall = await this.getApplicationInstallFromProcess(dto);
|
|
19
|
+
const requestDto = application.getRequestDto(dto, applicationInstall, HttpMethods_1.HttpMethods.PATCH, `/${application.getOrganization(applicationInstall)}/registers/vatreturnlines`, Array.isArray(data) ? data : [data]);
|
|
20
|
+
await this.getSender().send(requestDto, [200]);
|
|
21
|
+
return dto;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = WflowPatchVatReturnLinesConnector;
|
package/{src/Connector/WflowPutDocumentConnector.ts → dist/Connector/WflowPutDocumentConnector.d.ts}
RENAMED
|
@@ -1,47 +1,15 @@
|
|
|
1
1
|
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
3
2
|
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const NAME = `${WFLOW_APP_NAME}-put-document-connector`;
|
|
7
|
-
|
|
3
|
+
export declare const NAME = "wflow-put-document-connector";
|
|
8
4
|
export default class WflowPutDocumentConnector extends AConnector {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return NAME;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
|
|
15
|
-
const app = this.getApplication<WflowApplication>();
|
|
16
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
-
const { externalId, ignoreLock, setAsFilled } = dto.getJsonData();
|
|
18
|
-
|
|
19
|
-
const query = new URLSearchParams();
|
|
20
|
-
if (externalId) query.set('externalId', externalId);
|
|
21
|
-
if (ignoreLock) query.set('ignoreLock', ignoreLock.toString());
|
|
22
|
-
if (setAsFilled) query.set('setAsFilled', setAsFilled.toString());
|
|
23
|
-
|
|
24
|
-
const request = app.getRequestDto(
|
|
25
|
-
dto,
|
|
26
|
-
appInstall,
|
|
27
|
-
HttpMethods.PUT,
|
|
28
|
-
`/${app.getOrganization(appInstall)}/documents${query.size ? `?${query}` : ''}`,
|
|
29
|
-
dto.getJsonData(),
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
await this.getSender().send(request);
|
|
33
|
-
|
|
34
|
-
return dto;
|
|
35
|
-
}
|
|
36
|
-
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
37
7
|
}
|
|
38
|
-
|
|
39
8
|
interface UpdateRegister {
|
|
40
9
|
id: string;
|
|
41
10
|
externalId: string;
|
|
42
11
|
code: string;
|
|
43
12
|
}
|
|
44
|
-
|
|
45
13
|
export interface IInput {
|
|
46
14
|
id: string;
|
|
47
15
|
externalId?: string;
|
|
@@ -143,7 +111,7 @@ export interface IInput {
|
|
|
143
111
|
vatApplyReductionCoefficient?: boolean;
|
|
144
112
|
vatFixedAssets?: boolean;
|
|
145
113
|
vatMode?: 'Standard' | 'ReverseChargeDomestic' | 'ReverseCharge' | 'Excluded' | 'InForeignCurrency';
|
|
146
|
-
}
|
|
114
|
+
};
|
|
147
115
|
}
|
|
148
|
-
|
|
149
116
|
export type IOutput = IInput;
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
const WflowApplication_1 = require("../WflowApplication");
|
|
10
|
+
exports.NAME = `${WflowApplication_1.NAME}-put-document-connector`;
|
|
11
|
+
class WflowPutDocumentConnector extends AConnector_1.default {
|
|
12
|
+
getName() {
|
|
13
|
+
return exports.NAME;
|
|
14
|
+
}
|
|
15
|
+
async processAction(dto) {
|
|
16
|
+
const app = this.getApplication();
|
|
17
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
18
|
+
const { externalId, ignoreLock, setAsFilled } = dto.getJsonData();
|
|
19
|
+
const query = new URLSearchParams();
|
|
20
|
+
if (externalId)
|
|
21
|
+
query.set('externalId', externalId);
|
|
22
|
+
if (ignoreLock)
|
|
23
|
+
query.set('ignoreLock', ignoreLock.toString());
|
|
24
|
+
if (setAsFilled)
|
|
25
|
+
query.set('setAsFilled', setAsFilled.toString());
|
|
26
|
+
const request = app.getRequestDto(dto, appInstall, HttpMethods_1.HttpMethods.PUT, `/${app.getOrganization(appInstall)}/documents${query.size ? `?${query}` : ''}`, dto.getJsonData());
|
|
27
|
+
await this.getSender().send(request);
|
|
28
|
+
return dto;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = WflowPutDocumentConnector;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const NAME = "wflow-update-document-state-connector";
|
|
4
|
+
export default class WflowUpdateDocumentStateConnector extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IInput {
|
|
9
|
+
documentId: string;
|
|
10
|
+
}
|
|
11
|
+
export type IOutput = IInput;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
const WflowApplication_1 = require("../WflowApplication");
|
|
10
|
+
exports.NAME = `${WflowApplication_1.NAME}-update-document-state-connector`;
|
|
11
|
+
class WflowUpdateDocumentStateConnector extends AConnector_1.default {
|
|
12
|
+
getName() {
|
|
13
|
+
return exports.NAME;
|
|
14
|
+
}
|
|
15
|
+
async processAction(dto) {
|
|
16
|
+
const { documentId } = dto.getJsonData();
|
|
17
|
+
const app = this.getApplication();
|
|
18
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
19
|
+
const request = app.getRequestDto(dto, appInstall, HttpMethods_1.HttpMethods.PUT, `/${app.getOrganization(appInstall)}/documents/${documentId}/task/Export/processed`);
|
|
20
|
+
await this.getSender().send(request, [200]);
|
|
21
|
+
return dto;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = WflowUpdateDocumentStateConnector;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
2
|
+
import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
|
|
3
|
+
import WebhookSubscription from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Webhook/WebhookSubscription';
|
|
4
|
+
import { OAuth2Provider } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Provider/OAuth2/OAuth2Provider';
|
|
5
|
+
import AOAuth2Application from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application';
|
|
6
|
+
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
7
|
+
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
8
|
+
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
9
|
+
import WflowGetOrganizationsConnector from './Connector/WflowGetOrganizationsConnector';
|
|
10
|
+
export declare const NAME = "wflow";
|
|
11
|
+
export declare const ORGANIZATION_FORM = "organization-form";
|
|
12
|
+
export declare const ORGANIZATION = "organization";
|
|
13
|
+
export declare enum WebhookType {
|
|
14
|
+
DOCUMENT_READY_TO_EXTRACT = "DocumentReadyToExtract",
|
|
15
|
+
DOCUMENT_READY_TO_EXPORT = "DocumentReadyToExport",
|
|
16
|
+
DOCUMENT_UPDATED = "DocumentUpdated",
|
|
17
|
+
DOCUMENT_APPROVAL_PROCESS_FINISHED = "DocumentApprovalProcessFinished",
|
|
18
|
+
DOCUMENT_DELETED = "DocumentDeleted",
|
|
19
|
+
DOCUMENT_READY_TO_REVIEW = "DocumentReadyToReview",
|
|
20
|
+
DOCUMENT_CREATED = "DocumentCreated",
|
|
21
|
+
DOCUMENT_REVIEWED = "DocumentReviewed",
|
|
22
|
+
REGISTER_UPDATED = "RegisterUpdated",
|
|
23
|
+
ALL = "All"
|
|
24
|
+
}
|
|
25
|
+
export default class WflowApplication extends AOAuth2Application {
|
|
26
|
+
private readonly wflowGetOrganizationsConnector;
|
|
27
|
+
constructor(provider: OAuth2Provider, wflowGetOrganizationsConnector: WflowGetOrganizationsConnector);
|
|
28
|
+
getName(): string;
|
|
29
|
+
getPublicName(): string;
|
|
30
|
+
getDescription(): string;
|
|
31
|
+
getLogo(): string;
|
|
32
|
+
getFormStack(): FormStack;
|
|
33
|
+
getRequestDto(dto: AProcessDto, applicationInstall: ApplicationInstall, method: HttpMethods, path?: string, data?: unknown): RequestDto;
|
|
34
|
+
getOrganization(applicationInstall: ApplicationInstall): string;
|
|
35
|
+
getAuthUrl(): string;
|
|
36
|
+
getTokenUrl(): string;
|
|
37
|
+
getScopes(): string[];
|
|
38
|
+
getScopesSeparator(): string;
|
|
39
|
+
getWebhookSubscriptions(): WebhookSubscription[];
|
|
40
|
+
protected customFormReplace(formStack: FormStack, applicationInstall: ApplicationInstall): Promise<void>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.WebhookType = exports.ORGANIZATION = exports.ORGANIZATION_FORM = exports.NAME = void 0;
|
|
40
|
+
const CoreFormsEnum_1 = __importStar(require("@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum"));
|
|
41
|
+
const Field_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field"));
|
|
42
|
+
const FieldType_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType"));
|
|
43
|
+
const Form_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form"));
|
|
44
|
+
const FormStack_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack"));
|
|
45
|
+
const ScopeSeparatorEnum_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Authorization/ScopeSeparatorEnum"));
|
|
46
|
+
const AOAuth2Application_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application"));
|
|
47
|
+
const IOAuth2Application_1 = require("@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application");
|
|
48
|
+
const RequestDto_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto"));
|
|
49
|
+
const Headers_1 = require("@orchesty/nodejs-sdk/dist/lib/Utils/Headers");
|
|
50
|
+
const ProcessDto_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto"));
|
|
51
|
+
exports.NAME = 'wflow';
|
|
52
|
+
exports.ORGANIZATION_FORM = 'organization-form';
|
|
53
|
+
exports.ORGANIZATION = 'organization';
|
|
54
|
+
var WebhookType;
|
|
55
|
+
(function (WebhookType) {
|
|
56
|
+
WebhookType["DOCUMENT_READY_TO_EXTRACT"] = "DocumentReadyToExtract";
|
|
57
|
+
WebhookType["DOCUMENT_READY_TO_EXPORT"] = "DocumentReadyToExport";
|
|
58
|
+
WebhookType["DOCUMENT_UPDATED"] = "DocumentUpdated";
|
|
59
|
+
WebhookType["DOCUMENT_APPROVAL_PROCESS_FINISHED"] = "DocumentApprovalProcessFinished";
|
|
60
|
+
WebhookType["DOCUMENT_DELETED"] = "DocumentDeleted";
|
|
61
|
+
WebhookType["DOCUMENT_READY_TO_REVIEW"] = "DocumentReadyToReview";
|
|
62
|
+
WebhookType["DOCUMENT_CREATED"] = "DocumentCreated";
|
|
63
|
+
WebhookType["DOCUMENT_REVIEWED"] = "DocumentReviewed";
|
|
64
|
+
WebhookType["REGISTER_UPDATED"] = "RegisterUpdated";
|
|
65
|
+
WebhookType["ALL"] = "All";
|
|
66
|
+
})(WebhookType || (exports.WebhookType = WebhookType = {}));
|
|
67
|
+
class WflowApplication extends AOAuth2Application_1.default {
|
|
68
|
+
wflowGetOrganizationsConnector;
|
|
69
|
+
constructor(provider, wflowGetOrganizationsConnector) {
|
|
70
|
+
super(provider);
|
|
71
|
+
this.wflowGetOrganizationsConnector = wflowGetOrganizationsConnector;
|
|
72
|
+
}
|
|
73
|
+
getName() {
|
|
74
|
+
return exports.NAME;
|
|
75
|
+
}
|
|
76
|
+
getPublicName() {
|
|
77
|
+
return 'wflow';
|
|
78
|
+
}
|
|
79
|
+
getDescription() {
|
|
80
|
+
return 'Digital accounting that saves you time and money';
|
|
81
|
+
}
|
|
82
|
+
getLogo() {
|
|
83
|
+
return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2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Enum_1.getFormName)(CoreFormsEnum_1.default.AUTHORIZATION_FORM))
|
|
88
|
+
.addField(new Field_1.default(FieldType_1.default.TEXT, IOAuth2Application_1.CLIENT_ID, 'Client Id', null, false))
|
|
89
|
+
.addField(new Field_1.default(FieldType_1.default.TEXT, IOAuth2Application_1.CLIENT_SECRET, 'Client Secret', null, false)))
|
|
90
|
+
.addForm(new Form_1.default(exports.ORGANIZATION_FORM, 'Organization settings'));
|
|
91
|
+
}
|
|
92
|
+
getRequestDto(dto, applicationInstall, method, path, data) {
|
|
93
|
+
const headers = {
|
|
94
|
+
[Headers_1.CommonHeaders.ACCEPT]: Headers_1.JSON_TYPE,
|
|
95
|
+
[Headers_1.CommonHeaders.AUTHORIZATION]: `Bearer ${this.getAccessToken(applicationInstall)}`,
|
|
96
|
+
};
|
|
97
|
+
const url = new URL(`/api${path ?? ''}`, 'https://api.wflow.com').href;
|
|
98
|
+
return new RequestDto_1.default(url, method, dto, data, headers);
|
|
99
|
+
}
|
|
100
|
+
getOrganization(applicationInstall) {
|
|
101
|
+
const organization = applicationInstall.getSettings()[exports.ORGANIZATION_FORM]?.[exports.ORGANIZATION];
|
|
102
|
+
if (!organization) {
|
|
103
|
+
throw Error('Organization is not set.');
|
|
104
|
+
}
|
|
105
|
+
return organization;
|
|
106
|
+
}
|
|
107
|
+
getAuthUrl() {
|
|
108
|
+
return 'https://account.wflow.com/connect/authorize';
|
|
109
|
+
}
|
|
110
|
+
getTokenUrl() {
|
|
111
|
+
return 'https://account.wflow.com/connect/token';
|
|
112
|
+
}
|
|
113
|
+
getScopes() {
|
|
114
|
+
return ['uccl_common_api', 'offline_access'];
|
|
115
|
+
}
|
|
116
|
+
getScopesSeparator() {
|
|
117
|
+
return ScopeSeparatorEnum_1.default.SPACE;
|
|
118
|
+
}
|
|
119
|
+
getWebhookSubscriptions() {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
async customFormReplace(formStack, applicationInstall) {
|
|
123
|
+
const organizations = (await this.wflowGetOrganizationsConnector.processAction(ProcessDto_1.default.createForFormRequest(exports.NAME, applicationInstall.getUser(), applicationInstall.getSdk(), crypto.randomUUID(), 'form'))).getJsonData();
|
|
124
|
+
const form = formStack.getForms().find((item) => item.getKey() === exports.ORGANIZATION_FORM);
|
|
125
|
+
const settings = applicationInstall.getSettings()[exports.ORGANIZATION_FORM];
|
|
126
|
+
if (!form) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const choices = organizations.map((organization) => ({ [organization.subdomain]: organization.name }));
|
|
130
|
+
form.addField(new Field_1.default(FieldType_1.default.SELECT_BOX, exports.ORGANIZATION, 'Organization name', settings?.[exports.ORGANIZATION], true).setChoices(choices));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.default = WflowApplication;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orchesty/connector-wflow",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "2.0.2",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
7
|
+
"repository": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rm -rf dist && rm -rf tsconfig.prod.tsbuildinfo && tsc -d -p tsconfig.prod.json && cp package.json ./dist/package.json",
|
|
10
|
+
"test": "jest --coverage --forceExit --passWithNoTests",
|
|
11
|
+
"lint": "eslint src test --fix",
|
|
12
|
+
"lint-ci": "eslint src test"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "info@hanaboso.com",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@orchesty/nodejs-sdk": "^5.0.14",
|
|
21
|
+
"http-status-codes": "^2.3.0"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=24"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orchesty/connector-wflow",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors"
|
|
10
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
11
14
|
"keywords": [],
|
|
12
15
|
"author": "info@hanaboso.com",
|
|
13
16
|
"dependencies": {
|
|
14
|
-
"@orchesty/nodejs-sdk": "^5.0.
|
|
17
|
+
"@orchesty/nodejs-sdk": "^5.0.14",
|
|
15
18
|
"http-status-codes": "^2.3.0"
|
|
16
19
|
},
|
|
17
20
|
"engines": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# @orchesty/connector-wflow
|
|
2
|
-
|
|
3
|
-
## 2.0.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated release
|
|
8
|
-
|
|
9
|
-
## 2.0.0
|
|
10
|
-
|
|
11
|
-
### Major Changes
|
|
12
|
-
|
|
13
|
-
- Use @orchesty/nodejs-sdk ^5.0
|
|
14
|
-
|
|
15
|
-
## 1.0.5
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- Updated release
|
|
20
|
-
|
|
21
|
-
## 1.0.4
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- Updated release
|
|
26
|
-
|
|
27
|
-
## 1.0.3
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- Updated release
|
|
32
|
-
|
|
33
|
-
## 1.0.2
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- Updated release
|
|
38
|
-
|
|
39
|
-
## 1.0.1
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- Updated release
|
|
44
|
-
|
|
45
|
-
## 1.0.0
|
|
46
|
-
|
|
47
|
-
### Major Changes
|
|
48
|
-
|
|
49
|
-
- initial release
|
package/jest.config.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const baseConfig = require('../../jest.config.js');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
...baseConfig,
|
|
5
|
-
roots: ["<rootDir>/src"],
|
|
6
|
-
setupFiles: ["<rootDir>/../../.jest/testEnvs.ts"],
|
|
7
|
-
setupFilesAfterEnv: ["<rootDir>/../../.jest/testLifecycle.ts"],
|
|
8
|
-
globalSetup: "<rootDir>/../../.jest/globalSetup.ts",
|
|
9
|
-
moduleNameMapper: {
|
|
10
|
-
"^@orchesty/nodejs-connectors/test/(.*)$": "<rootDir>/../../test/$1",
|
|
11
|
-
"^@orchesty/nodejs-connectors/lib/(.*)$": "<rootDir>/../../lib/$1",
|
|
12
|
-
},
|
|
13
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
|
|
2
|
-
import WebhookRepository from '@orchesty/nodejs-sdk/dist/lib/Application/Database/WebhookRepository';
|
|
3
|
-
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
|
|
4
|
-
import TopologyRunner from '@orchesty/nodejs-sdk/dist/lib/Topology/TopologyRunner';
|
|
5
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
6
|
-
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
|
|
7
|
-
import crypto from 'crypto';
|
|
8
|
-
import WflowApplication, { NAME as WFLOW_APP_NAME } from '../WflowApplication';
|
|
9
|
-
|
|
10
|
-
export const NAME = `${WFLOW_APP_NAME}-subscribe-webhooks-batch`;
|
|
11
|
-
|
|
12
|
-
export default class WflowSubscribeWebhookBatch extends ABatchNode {
|
|
13
|
-
|
|
14
|
-
public getName(): string {
|
|
15
|
-
return NAME;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
|
|
19
|
-
const app = this.getApplication<WflowApplication>();
|
|
20
|
-
const subscriptions = app.getWebhookSubscriptions();
|
|
21
|
-
|
|
22
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
23
|
-
const repository = this.getDbClient().getRepository(Webhook) as WebhookRepository;
|
|
24
|
-
|
|
25
|
-
const registeredEvents = (await repository.findMany({
|
|
26
|
-
users: [appInstall.getUser()],
|
|
27
|
-
apps: [appInstall.getName()],
|
|
28
|
-
sdks: [appInstall.getSdk()],
|
|
29
|
-
})).map((webhook) => webhook.getName());
|
|
30
|
-
|
|
31
|
-
const unsubscribed = subscriptions.find(
|
|
32
|
-
(subscription) => !registeredEvents.some(
|
|
33
|
-
(event) => subscription.getName() === event,
|
|
34
|
-
),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (!unsubscribed) {
|
|
38
|
-
return dto;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let organization: string;
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
organization = app.getOrganization(appInstall);
|
|
45
|
-
} catch {
|
|
46
|
-
return dto;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const token = crypto.randomBytes(64).toString('hex');
|
|
50
|
-
const request = app.getRequestDto(
|
|
51
|
-
dto,
|
|
52
|
-
appInstall,
|
|
53
|
-
HttpMethods.PUT,
|
|
54
|
-
`/${organization}/webhookregistrations`,
|
|
55
|
-
{
|
|
56
|
-
actions: [unsubscribed.getName()],
|
|
57
|
-
webhookUri: TopologyRunner.getWebhookUrl(
|
|
58
|
-
unsubscribed.getTopology(),
|
|
59
|
-
unsubscribed.getNode(),
|
|
60
|
-
token,
|
|
61
|
-
),
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const id = (
|
|
66
|
-
await this.getSender().send<string>(request)
|
|
67
|
-
).getJsonBody();
|
|
68
|
-
|
|
69
|
-
await repository.insert(
|
|
70
|
-
new Webhook()
|
|
71
|
-
.setWebhookId(id)
|
|
72
|
-
.setUser(appInstall.getUser())
|
|
73
|
-
.setSdk(appInstall.getSdk())
|
|
74
|
-
.setNode(unsubscribed.getNode())
|
|
75
|
-
.setToken(token)
|
|
76
|
-
.setApplication(appInstall.getName())
|
|
77
|
-
.setTopology(unsubscribed.getTopology())
|
|
78
|
-
.setName(unsubscribed.getName()),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return dto.setBatchCursor('1', true);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
|
|
2
|
-
import WebhookRepository from '@orchesty/nodejs-sdk/dist/lib/Application/Database/WebhookRepository';
|
|
3
|
-
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
|
|
4
|
-
import OnRepeatException from '@orchesty/nodejs-sdk/dist/lib/Exception/OnRepeatException';
|
|
5
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
6
|
-
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
|
|
7
|
-
import { StatusCodes } from 'http-status-codes';
|
|
8
|
-
import WflowApplication, { NAME as WFLOW_APP_NAME } from '../WflowApplication';
|
|
9
|
-
|
|
10
|
-
export const NAME = `${WFLOW_APP_NAME}-unsubscribe-webhooks-batch`;
|
|
11
|
-
|
|
12
|
-
export default class WflowUnsubscribeWebhookBatch extends ABatchNode {
|
|
13
|
-
|
|
14
|
-
public getName(): string {
|
|
15
|
-
return NAME;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
|
|
19
|
-
const app = this.getApplication<WflowApplication>();
|
|
20
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto, null);
|
|
21
|
-
const repository = this.getDbClient().getRepository(Webhook) as WebhookRepository;
|
|
22
|
-
|
|
23
|
-
const webhook = await repository.findOne({
|
|
24
|
-
users: [appInstall.getUser()],
|
|
25
|
-
apps: [appInstall.getName()],
|
|
26
|
-
sdks: [appInstall.getSdk()],
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (!webhook) {
|
|
30
|
-
return dto;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let organization: string;
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
organization = app.getOrganization(appInstall);
|
|
37
|
-
} catch {
|
|
38
|
-
return dto;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const request = app.getRequestDto(
|
|
42
|
-
dto,
|
|
43
|
-
appInstall,
|
|
44
|
-
HttpMethods.DELETE,
|
|
45
|
-
`/${organization}/webhookregistrations/${webhook.getWebhookId()}`,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const response = await this.getSender().send(request);
|
|
49
|
-
|
|
50
|
-
if (response.getResponseCode() !== StatusCodes.OK) {
|
|
51
|
-
await repository.update(webhook.setUnsubscribeFailed(true));
|
|
52
|
-
throw new OnRepeatException(300, 12, response.getBody());
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await repository.remove(webhook);
|
|
56
|
-
return dto.setBatchCursor('1', true);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}
|