@alanszp/integrations-common 7.8.3 → 7.8.5
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/IntegrationExecutionResult.d.ts +3 -3
- package/dist/IntegrationExecutionResult.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/models/BaseIntegrationHistory.d.ts +10 -0
- package/dist/models/BaseIntegrationHistory.js +50 -0
- package/dist/models/BaseIntegrationHistory.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +6 -6
- package/dist/types.js.map +1 -1
- package/dist/views/integrationView.d.ts +4 -0
- package/dist/views/integrationView.js +25 -0
- package/dist/views/integrationView.js.map +1 -0
- package/package.json +7 -3
- package/src/IntegrationExecutionResult.ts +4 -4
- package/src/index.ts +4 -0
- package/src/models/BaseIntegrationHistory.ts +30 -0
- package/src/types.ts +1 -1
- package/src/views/integrationView.ts +27 -0
- package/tsconfig.json +1 -1
- package/dist/IntegrationExecutionResult.test.d.ts +0 -1
- package/dist/IntegrationExecutionResult.test.js +0 -50
- package/dist/IntegrationExecutionResult.test.js.map +0 -1
- package/src/IntegrationExecutionResult.test.ts +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationResultStatus,
|
|
1
|
+
import { IntegrationResultStatus, IntegrationStatus, IntegrationResultError } from "./types";
|
|
2
2
|
export interface ChangesStatus {
|
|
3
3
|
updated: string[];
|
|
4
4
|
created: string[];
|
|
@@ -18,8 +18,8 @@ export declare class IntegrationExecutionResult {
|
|
|
18
18
|
getContext(): Record<string, unknown> | undefined;
|
|
19
19
|
getIntegrationId(): string;
|
|
20
20
|
getOrganizationReference(): string;
|
|
21
|
-
setStatus(status:
|
|
22
|
-
getStatus():
|
|
21
|
+
setStatus(status: IntegrationStatus): void;
|
|
22
|
+
getStatus(): IntegrationStatus;
|
|
23
23
|
getExecutedBy(): string | undefined;
|
|
24
24
|
getResults(): IntegrationResultStatus;
|
|
25
25
|
private setTotals;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegrationExecutionResult.js","sourceRoot":"","sources":["../src/IntegrationExecutionResult.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAgB/B,MAAa,0BAA0B;IAoBrC,YACE,aAAqB,EACrB,qBAA6B,EAC7B,UAAmB;QAtBb,WAAM,GAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAEtE,YAAO,GAAkB;YAC/B,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,EAAE;SACV,CAAC;QAiBA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,UAAU,CAAC,OAAsB;QACtC,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;YAC/B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;YAC7B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM;SAC7B,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,CAAC;YACd,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,OAAO;YACtB,KAAK,EAAE,OAAO,CAAC,MAAM;SACtB,CAAC,CAAC;IACL,CAAC;IAEM,UAAU,CAAC,OAAgC;QAChD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,gBAAgB;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,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AC,aAAa,CAAC;IAC5B,CAAC;IAEM,wBAAwB;QAC7B,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAEM,SAAS,CAAC,MAAyB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEM,UAAU;QACf,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAEO,SAAS,CAAC,MAA6B;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAA,cAAK,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEO,UAAU,CAAC,OAA+B;QAChD,IAAI,CAAC,OAAO,GAAG,IAAA,cAAK,EAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF;AAtFD,gEAsFC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./IntegrationExecutionResult"), exports);
|
|
14
|
+
__exportStar(require("./models/BaseIntegrationHistory"), exports);
|
|
15
|
+
__exportStar(require("./views/integrationView"), exports);
|
|
16
|
+
__exportStar(require("./types"), exports);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6C;AAC7C,kEAAgD;AAChD,0DAAwC;AACxC,0CAAwB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseEntityUuid } from "@alanszp/typeorm";
|
|
2
|
+
import { IntegrationResultStatus, IntegrationStatus } from "../types";
|
|
3
|
+
export declare abstract class BaseIntegrationHistory extends BaseEntityUuid {
|
|
4
|
+
integrationId: string;
|
|
5
|
+
organizationReference: string;
|
|
6
|
+
status: IntegrationStatus;
|
|
7
|
+
result: IntegrationResultStatus;
|
|
8
|
+
executedAt: Date;
|
|
9
|
+
executedBy: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BaseIntegrationHistory = void 0;
|
|
13
|
+
const typeorm_1 = require("@alanszp/typeorm");
|
|
14
|
+
const types_1 = require("../types");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
const typeorm_2 = require("typeorm");
|
|
17
|
+
class BaseIntegrationHistory extends typeorm_1.BaseEntityUuid {
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typeorm_2.Column)(),
|
|
21
|
+
(0, class_validator_1.IsString)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], BaseIntegrationHistory.prototype, "integrationId", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_2.Column)(),
|
|
26
|
+
(0, class_validator_1.IsString)(),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], BaseIntegrationHistory.prototype, "organizationReference", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_2.Column)({ type: "enum", enum: types_1.IntegrationStatus, nullable: false }),
|
|
31
|
+
(0, class_validator_1.IsEnum)(types_1.IntegrationStatus),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], BaseIntegrationHistory.prototype, "status", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_2.Column)({ type: "jsonb" }),
|
|
36
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], BaseIntegrationHistory.prototype, "result", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_2.CreateDateColumn)(),
|
|
41
|
+
(0, class_validator_1.IsDate)(),
|
|
42
|
+
__metadata("design:type", Date)
|
|
43
|
+
], BaseIntegrationHistory.prototype, "executedAt", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_2.Column)(),
|
|
46
|
+
(0, class_validator_1.IsString)(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], BaseIntegrationHistory.prototype, "executedBy", void 0);
|
|
49
|
+
exports.BaseIntegrationHistory = BaseIntegrationHistory;
|
|
50
|
+
//# sourceMappingURL=BaseIntegrationHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseIntegrationHistory.js","sourceRoot":"","sources":["../../src/models/BaseIntegrationHistory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAkD;AAClD,oCAAsE;AACtE,qDAAuE;AACvE,qCAAmD;AAEnD,MAAsB,sBAAuB,SAAQ,wBAAc;CAwBlE;AArBC;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,0BAAQ,GAAE;;6DACkB;AAI7B;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,0BAAQ,GAAE;;qEAC0B;AAIrC;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClE,IAAA,wBAAM,EAAC,yBAAiB,CAAC;;sDACO;AAIjC;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACzB,IAAA,4BAAU,GAAE;;sDAC0B;AAIvC;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,wBAAM,GAAE;8BACU,IAAI;0DAAC;AAIxB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,0BAAQ,GAAE;;0DACe;AAvB5B,wDAwBC"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SyncError = exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})(
|
|
3
|
+
exports.SyncError = exports.IntegrationStatus = void 0;
|
|
4
|
+
var IntegrationStatus;
|
|
5
|
+
(function (IntegrationStatus) {
|
|
6
|
+
IntegrationStatus["SUCCESS"] = "success";
|
|
7
|
+
IntegrationStatus["ERROR"] = "error";
|
|
8
|
+
})(IntegrationStatus = exports.IntegrationStatus || (exports.IntegrationStatus = {}));
|
|
9
9
|
var SyncError;
|
|
10
10
|
(function (SyncError) {
|
|
11
11
|
SyncError["MISSING_FIELDS"] = "missing";
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,oCAAe,CAAA;AACjB,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B;AAED,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,uCAA0B,CAAA;IAC1B,sCAAyB,CAAA;IACzB,oDAAuC,CAAA;AACzC,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IntegrationExecutionResult } from "../IntegrationExecutionResult";
|
|
2
|
+
import { BaseIntegrationHistory } from "../models/BaseIntegrationHistory";
|
|
3
|
+
export declare function syncIntegrationHistoryView<IH extends BaseIntegrationHistory>(history: IH): Record<string, unknown>;
|
|
4
|
+
export declare function syncIntegrationResultsView(result: IntegrationExecutionResult): Record<string, unknown>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncIntegrationResultsView = exports.syncIntegrationHistoryView = void 0;
|
|
4
|
+
function syncIntegrationHistoryView(history) {
|
|
5
|
+
return {
|
|
6
|
+
id: history.id,
|
|
7
|
+
status: history.status,
|
|
8
|
+
executedAt: history.executedAt,
|
|
9
|
+
executedBy: history.executedBy,
|
|
10
|
+
totals: history.result.totals,
|
|
11
|
+
details: history.result.details,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.syncIntegrationHistoryView = syncIntegrationHistoryView;
|
|
15
|
+
function syncIntegrationResultsView(result) {
|
|
16
|
+
const { totals, details } = result.getResults();
|
|
17
|
+
return {
|
|
18
|
+
totals,
|
|
19
|
+
details,
|
|
20
|
+
status: result.getStatus(),
|
|
21
|
+
context: result.getContext(),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.syncIntegrationResultsView = syncIntegrationResultsView;
|
|
25
|
+
//# sourceMappingURL=integrationView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationView.js","sourceRoot":"","sources":["../../src/views/integrationView.ts"],"names":[],"mappings":";;;AAGA,SAAgB,0BAA0B,CACxC,OAAW;IAEX,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM;QAC7B,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;KAChC,CAAC;AACJ,CAAC;AAXD,gEAWC;AAED,SAAgB,0BAA0B,CACxC,MAAkC;IAElC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO;QACL,MAAM;QACN,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE;KAC7B,CAAC;AACJ,CAAC;AAVD,gEAUC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanszp/integrations-common",
|
|
3
|
-
"version": "7.8.
|
|
3
|
+
"version": "7.8.5",
|
|
4
4
|
"description": "Common logic shared between integrations.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -28,7 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@alanszp/errors": "^7.0.0",
|
|
31
|
-
"
|
|
31
|
+
"@alanszp/logger": "^7.0.0",
|
|
32
|
+
"@alanszp/typeorm": "^7.0.0",
|
|
33
|
+
"class-validator": "^0.13.1",
|
|
34
|
+
"lodash": "^4.17.21",
|
|
35
|
+
"typeorm": "^0.2.34"
|
|
32
36
|
},
|
|
33
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "18eea662fa3dcd4a4cc1aee212af4e41bd943697"
|
|
34
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
2
|
import {
|
|
3
3
|
IntegrationResultStatus,
|
|
4
|
-
|
|
4
|
+
IntegrationStatus,
|
|
5
5
|
IntegrationResultError,
|
|
6
6
|
} from "./types";
|
|
7
7
|
|
|
@@ -28,7 +28,7 @@ export class IntegrationExecutionResult {
|
|
|
28
28
|
|
|
29
29
|
private organizationReference: string;
|
|
30
30
|
|
|
31
|
-
private status:
|
|
31
|
+
private status: IntegrationStatus;
|
|
32
32
|
|
|
33
33
|
private executedBy: string | undefined;
|
|
34
34
|
|
|
@@ -74,11 +74,11 @@ export class IntegrationExecutionResult {
|
|
|
74
74
|
return this.organizationReference;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
public setStatus(status:
|
|
77
|
+
public setStatus(status: IntegrationStatus): void {
|
|
78
78
|
this.status = status;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
public getStatus():
|
|
81
|
+
public getStatus(): IntegrationStatus {
|
|
82
82
|
return this.status;
|
|
83
83
|
}
|
|
84
84
|
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseEntityUuid } from "@alanszp/typeorm";
|
|
2
|
+
import { IntegrationResultStatus, IntegrationStatus } from "../types";
|
|
3
|
+
import { IsDate, IsEnum, IsNotEmpty, IsString } from "class-validator";
|
|
4
|
+
import { Column, CreateDateColumn } from "typeorm";
|
|
5
|
+
|
|
6
|
+
export abstract class BaseIntegrationHistory extends BaseEntityUuid {
|
|
7
|
+
@Column()
|
|
8
|
+
@IsString()
|
|
9
|
+
public integrationId: string;
|
|
10
|
+
|
|
11
|
+
@Column()
|
|
12
|
+
@IsString()
|
|
13
|
+
public organizationReference: string;
|
|
14
|
+
|
|
15
|
+
@Column({ type: "enum", enum: IntegrationStatus, nullable: false })
|
|
16
|
+
@IsEnum(IntegrationStatus)
|
|
17
|
+
public status: IntegrationStatus;
|
|
18
|
+
|
|
19
|
+
@Column({ type: "jsonb" })
|
|
20
|
+
@IsNotEmpty()
|
|
21
|
+
public result: IntegrationResultStatus;
|
|
22
|
+
|
|
23
|
+
@CreateDateColumn()
|
|
24
|
+
@IsDate()
|
|
25
|
+
public executedAt: Date;
|
|
26
|
+
|
|
27
|
+
@Column()
|
|
28
|
+
@IsString()
|
|
29
|
+
public executedBy: string;
|
|
30
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IntegrationExecutionResult } from "../IntegrationExecutionResult";
|
|
2
|
+
import { BaseIntegrationHistory } from "../models/BaseIntegrationHistory";
|
|
3
|
+
|
|
4
|
+
export function syncIntegrationHistoryView<IH extends BaseIntegrationHistory>(
|
|
5
|
+
history: IH
|
|
6
|
+
): Record<string, unknown> {
|
|
7
|
+
return {
|
|
8
|
+
id: history.id,
|
|
9
|
+
status: history.status,
|
|
10
|
+
executedAt: history.executedAt,
|
|
11
|
+
executedBy: history.executedBy,
|
|
12
|
+
totals: history.result.totals,
|
|
13
|
+
details: history.result.details,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function syncIntegrationResultsView(
|
|
18
|
+
result: IntegrationExecutionResult
|
|
19
|
+
): Record<string, unknown> {
|
|
20
|
+
const { totals, details } = result.getResults();
|
|
21
|
+
return {
|
|
22
|
+
totals,
|
|
23
|
+
details,
|
|
24
|
+
status: result.getStatus(),
|
|
25
|
+
context: result.getContext(),
|
|
26
|
+
};
|
|
27
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const types_1 = require("./types");
|
|
4
|
-
const IntegrationExecutionResult_1 = require("./IntegrationExecutionResult");
|
|
5
|
-
const MOCK_INTEGRATION_ID = "1";
|
|
6
|
-
const MOCK_ORGANIZATION_REFERENCE = "test";
|
|
7
|
-
const MOCK_EXECUTED_BY = "1";
|
|
8
|
-
describe("IntegrationHistory", () => {
|
|
9
|
-
describe("setResults", () => {
|
|
10
|
-
it("should return value with default values", () => {
|
|
11
|
-
const i = new IntegrationExecutionResult_1.IntegrationExecutionResult(MOCK_INTEGRATION_ID, MOCK_ORGANIZATION_REFERENCE, MOCK_EXECUTED_BY);
|
|
12
|
-
const pc = {
|
|
13
|
-
created: ["1"],
|
|
14
|
-
updated: ["1"],
|
|
15
|
-
errors: [
|
|
16
|
-
{
|
|
17
|
-
type: types_1.SyncError.MISSING_FIELDS,
|
|
18
|
-
userReference: "1",
|
|
19
|
-
metadata: ["missingFieldName"],
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
|
23
|
-
i.setResults(pc);
|
|
24
|
-
expect(i.getResults()).toStrictEqual({
|
|
25
|
-
totals: { added: 1, removed: 0, updated: 1, error: 1 },
|
|
26
|
-
details: {
|
|
27
|
-
added: ["1"],
|
|
28
|
-
removed: [],
|
|
29
|
-
updated: ["1"],
|
|
30
|
-
error: [
|
|
31
|
-
{
|
|
32
|
-
type: types_1.SyncError.MISSING_FIELDS,
|
|
33
|
-
userReference: "1",
|
|
34
|
-
metadata: ["missingFieldName"],
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe("getters", () => {
|
|
42
|
-
it("should return correct values", () => {
|
|
43
|
-
const i = new IntegrationExecutionResult_1.IntegrationExecutionResult(MOCK_INTEGRATION_ID, MOCK_ORGANIZATION_REFERENCE, MOCK_EXECUTED_BY);
|
|
44
|
-
expect(i.getExecutedBy()).toStrictEqual(MOCK_EXECUTED_BY);
|
|
45
|
-
expect(i.getOrganizationReference()).toStrictEqual(MOCK_ORGANIZATION_REFERENCE);
|
|
46
|
-
expect(i.getExecutedBy()).toStrictEqual(MOCK_EXECUTED_BY);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=IntegrationExecutionResult.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntegrationExecutionResult.test.js","sourceRoot":"","sources":["../src/IntegrationExecutionResult.test.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AACpC,6EAGsC;AAEtC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAC3C,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACjD,MAAM,CAAC,GAAG,IAAI,uDAA0B,CACtC,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,CACjB,CAAC;YACF,MAAM,EAAE,GAAkB;gBACxB,OAAO,EAAE,CAAC,GAAG,CAAC;gBACd,OAAO,EAAE,CAAC,GAAG,CAAC;gBACd,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,iBAAS,CAAC,cAAc;wBAC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|
-
import {
|
|
3
|
-
ChangesStatus,
|
|
4
|
-
IntegrationExecutionResult,
|
|
5
|
-
} from "./IntegrationExecutionResult";
|
|
6
|
-
|
|
7
|
-
const MOCK_INTEGRATION_ID = "1";
|
|
8
|
-
const MOCK_ORGANIZATION_REFERENCE = "test";
|
|
9
|
-
const MOCK_EXECUTED_BY = "1";
|
|
10
|
-
|
|
11
|
-
describe("IntegrationHistory", () => {
|
|
12
|
-
describe("setResults", () => {
|
|
13
|
-
it("should return value with default values", () => {
|
|
14
|
-
const i = new IntegrationExecutionResult(
|
|
15
|
-
MOCK_INTEGRATION_ID,
|
|
16
|
-
MOCK_ORGANIZATION_REFERENCE,
|
|
17
|
-
MOCK_EXECUTED_BY
|
|
18
|
-
);
|
|
19
|
-
const pc: ChangesStatus = {
|
|
20
|
-
created: ["1"],
|
|
21
|
-
updated: ["1"],
|
|
22
|
-
errors: [
|
|
23
|
-
{
|
|
24
|
-
type: SyncError.MISSING_FIELDS,
|
|
25
|
-
userReference: "1",
|
|
26
|
-
metadata: ["missingFieldName"],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
i.setResults(pc);
|
|
32
|
-
|
|
33
|
-
expect(i.getResults()).toStrictEqual({
|
|
34
|
-
totals: { added: 1, removed: 0, updated: 1, error: 1 },
|
|
35
|
-
details: {
|
|
36
|
-
added: ["1"],
|
|
37
|
-
removed: [],
|
|
38
|
-
updated: ["1"],
|
|
39
|
-
error: [
|
|
40
|
-
{
|
|
41
|
-
type: SyncError.MISSING_FIELDS,
|
|
42
|
-
userReference: "1",
|
|
43
|
-
metadata: ["missingFieldName"],
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe("getters", () => {
|
|
51
|
-
it("should return correct values", () => {
|
|
52
|
-
const i = new IntegrationExecutionResult(
|
|
53
|
-
MOCK_INTEGRATION_ID,
|
|
54
|
-
MOCK_ORGANIZATION_REFERENCE,
|
|
55
|
-
MOCK_EXECUTED_BY
|
|
56
|
-
);
|
|
57
|
-
expect(i.getExecutedBy()).toStrictEqual(MOCK_EXECUTED_BY);
|
|
58
|
-
expect(i.getOrganizationReference()).toStrictEqual(
|
|
59
|
-
MOCK_ORGANIZATION_REFERENCE
|
|
60
|
-
);
|
|
61
|
-
expect(i.getExecutedBy()).toStrictEqual(MOCK_EXECUTED_BY);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|