@cemiar/document-analysis 1.0.0 → 1.0.2
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/comparator/Comparator.d.ts +3 -5
- package/dist/comparator/Comparator.js +2 -27
- package/dist/comparator/index.d.ts +1 -0
- package/dist/comparator/index.js +1 -0
- package/dist/comparator/models/RenewalComparisonPayload.d.ts +11 -18
- package/dist/comparator/schemas/RenewalComparisonPayloadSchema.d.ts +2 -0
- package/dist/comparator/schemas/RenewalComparisonPayloadSchema.js +78 -0
- package/dist/comparator/schemas/index.d.ts +1 -0
- package/dist/comparator/schemas/index.js +17 -0
- package/package.json +3 -2
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { RenewalComparisonPayload
|
|
2
|
+
import { RenewalComparisonPayload } from "./models/RenewalComparisonPayload";
|
|
3
3
|
export declare class Comparator {
|
|
4
4
|
private api;
|
|
5
5
|
private readonly basePath;
|
|
6
6
|
constructor(api: AxiosInstance);
|
|
7
|
-
compareRenewalExcel(payload: RenewalComparisonPayload
|
|
8
|
-
compareRenewalHtml(payload: RenewalComparisonPayload
|
|
9
|
-
private toRenewalComparisonRoutePayload;
|
|
10
|
-
private isRenewalComparisonPayload;
|
|
7
|
+
compareRenewalExcel(payload: RenewalComparisonPayload): Promise<Buffer>;
|
|
8
|
+
compareRenewalHtml(payload: RenewalComparisonPayload): Promise<Buffer>;
|
|
11
9
|
}
|
|
@@ -7,39 +7,14 @@ class Comparator {
|
|
|
7
7
|
this.api = api;
|
|
8
8
|
}
|
|
9
9
|
async compareRenewalExcel(payload) {
|
|
10
|
-
const
|
|
11
|
-
? this.toRenewalComparisonRoutePayload(payload)
|
|
12
|
-
: payload;
|
|
13
|
-
const result = await this.api.post(`${this.basePath}/renewal/excel`, routePayload, {
|
|
10
|
+
const result = await this.api.post(`${this.basePath}/renewal/excel`, payload, {
|
|
14
11
|
responseType: "arraybuffer",
|
|
15
12
|
});
|
|
16
13
|
return result.data;
|
|
17
14
|
}
|
|
18
15
|
async compareRenewalHtml(payload) {
|
|
19
|
-
const
|
|
20
|
-
? this.toRenewalComparisonRoutePayload(payload)
|
|
21
|
-
: payload;
|
|
22
|
-
const result = await this.api.post(`${this.basePath}/renewal/html`, routePayload, { responseType: "arraybuffer" });
|
|
16
|
+
const result = await this.api.post(`${this.basePath}/renewal/html`, payload, { responseType: "arraybuffer" });
|
|
23
17
|
return result.data;
|
|
24
18
|
}
|
|
25
|
-
toRenewalComparisonRoutePayload(payload) {
|
|
26
|
-
return {
|
|
27
|
-
before_doc: payload.before.attachmentBase64,
|
|
28
|
-
before_year: payload.before.year,
|
|
29
|
-
prime_before: payload.before.premium,
|
|
30
|
-
after_doc: payload.after.attachmentBase64,
|
|
31
|
-
after_year: payload.after.year,
|
|
32
|
-
prime_after: payload.after.premium,
|
|
33
|
-
client_name: payload.clientName,
|
|
34
|
-
client_infos: payload.clientInfos,
|
|
35
|
-
client_recipe: 0,
|
|
36
|
-
type: payload.type,
|
|
37
|
-
operation_id: payload.operationId,
|
|
38
|
-
coverage_validations: payload.coverageValidations,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
isRenewalComparisonPayload(payload) {
|
|
42
|
-
return "before" in payload && "after" in payload;
|
|
43
|
-
}
|
|
44
19
|
}
|
|
45
20
|
exports.Comparator = Comparator;
|
package/dist/comparator/index.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
+
import { Language } from "../../common";
|
|
1
2
|
import { CoverageValidationTableResponse } from "../../coverageValidation/models";
|
|
2
3
|
export interface RenewalComparisonPayload {
|
|
3
4
|
before: RenewalComparisonStatePayload;
|
|
4
5
|
after: RenewalComparisonStatePayload;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
client: RenewalComparisonClientPayload;
|
|
7
|
+
policyNumber: string;
|
|
7
8
|
type: string;
|
|
8
|
-
operationId?: string;
|
|
9
9
|
coverageValidations?: CoverageValidationTableResponse[];
|
|
10
|
+
operationId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RenewalComparisonClientPayload {
|
|
13
|
+
name: string;
|
|
14
|
+
address: string[];
|
|
15
|
+
language: Language;
|
|
16
|
+
recipe: number;
|
|
10
17
|
}
|
|
11
18
|
export interface RenewalComparisonStatePayload {
|
|
12
|
-
|
|
19
|
+
base64: string;
|
|
13
20
|
year: string;
|
|
14
21
|
premium: number;
|
|
15
22
|
}
|
|
16
|
-
export interface RenewalComparisonRoutePayload {
|
|
17
|
-
before_doc: string;
|
|
18
|
-
after_doc: string;
|
|
19
|
-
before_year: string;
|
|
20
|
-
after_year: string;
|
|
21
|
-
prime_before: number;
|
|
22
|
-
prime_after: number;
|
|
23
|
-
client_name: string;
|
|
24
|
-
client_infos: string[];
|
|
25
|
-
client_recipe: number;
|
|
26
|
-
type: string;
|
|
27
|
-
operation_id?: string;
|
|
28
|
-
coverage_validations?: CoverageValidationTableResponse[];
|
|
29
|
-
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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.RenewalComparisonPayloadSchema = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
exports.RenewalComparisonPayloadSchema = joi_1.default.object({
|
|
9
|
+
before: joi_1.default.object({
|
|
10
|
+
base64: joi_1.default.string()
|
|
11
|
+
.required()
|
|
12
|
+
.label("Before Document")
|
|
13
|
+
.meta({ title: "Before Document (Base64)" }),
|
|
14
|
+
year: joi_1.default.string()
|
|
15
|
+
.required()
|
|
16
|
+
.label("Before Year")
|
|
17
|
+
.meta({ title: "Before Year" }),
|
|
18
|
+
premium: joi_1.default.number()
|
|
19
|
+
.required()
|
|
20
|
+
.label("Before Premium")
|
|
21
|
+
.meta({ title: "Before Premium" }),
|
|
22
|
+
}).required(),
|
|
23
|
+
after: joi_1.default.object({
|
|
24
|
+
base64: joi_1.default.string()
|
|
25
|
+
.required()
|
|
26
|
+
.label("After Document")
|
|
27
|
+
.meta({ title: "After Document (Base64)" }),
|
|
28
|
+
year: joi_1.default.string()
|
|
29
|
+
.required()
|
|
30
|
+
.label("After Year")
|
|
31
|
+
.meta({ title: "After Year" }),
|
|
32
|
+
premium: joi_1.default.number()
|
|
33
|
+
.required()
|
|
34
|
+
.label("After Premium")
|
|
35
|
+
.meta({ title: "After Premium" }),
|
|
36
|
+
}).required(),
|
|
37
|
+
client: joi_1.default.object({
|
|
38
|
+
name: joi_1.default.string()
|
|
39
|
+
.required()
|
|
40
|
+
.label("Client Name")
|
|
41
|
+
.meta({ title: "Client Name" }),
|
|
42
|
+
address: joi_1.default.array()
|
|
43
|
+
.items(joi_1.default.string())
|
|
44
|
+
.required()
|
|
45
|
+
.label("Client Address")
|
|
46
|
+
.meta({ title: "Client Address" }),
|
|
47
|
+
language: joi_1.default.string()
|
|
48
|
+
.required()
|
|
49
|
+
.valid("en", "fr")
|
|
50
|
+
.messages({
|
|
51
|
+
"any.only": 'Language must be either "en" or "fr"',
|
|
52
|
+
})
|
|
53
|
+
.label("Client Language")
|
|
54
|
+
.meta({ title: "Client Language" }),
|
|
55
|
+
recipe: joi_1.default.number()
|
|
56
|
+
.required()
|
|
57
|
+
.label("Client Recipe")
|
|
58
|
+
.meta({ title: "Client Recipe" }),
|
|
59
|
+
}).required(),
|
|
60
|
+
policyNumber: joi_1.default.string()
|
|
61
|
+
.required()
|
|
62
|
+
.label("Policy Number")
|
|
63
|
+
.meta({ title: "Policy Number" }),
|
|
64
|
+
type: joi_1.default.string()
|
|
65
|
+
.required()
|
|
66
|
+
.label("Document Type")
|
|
67
|
+
.meta({ title: "Document Type" }),
|
|
68
|
+
coverageValidations: joi_1.default.array()
|
|
69
|
+
.items(joi_1.default.object())
|
|
70
|
+
.label("Coverage Validations")
|
|
71
|
+
.meta({ title: "Coverage Validations" }),
|
|
72
|
+
operationId: joi_1.default.string()
|
|
73
|
+
.required()
|
|
74
|
+
.label("Operation ID")
|
|
75
|
+
.meta({ title: "Operation ID" }),
|
|
76
|
+
})
|
|
77
|
+
.label("Renewal Comparison Parameters")
|
|
78
|
+
.meta({ title: "Renewal Comparison Parameters" });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RenewalComparisonPayloadSchema";
|
|
@@ -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
|
+
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./RenewalComparisonPayloadSchema"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cemiar/document-analysis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Cemiar package for document analysis API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"axios": "^1.13.5",
|
|
57
|
-
"form-data": "^4.0.5"
|
|
57
|
+
"form-data": "^4.0.5",
|
|
58
|
+
"joi": "^18.0.2"
|
|
58
59
|
},
|
|
59
60
|
"publishConfig": {
|
|
60
61
|
"access": "public"
|