@betterview/integration-toolkit 1.0.0 → 1.1.0
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/lib/Deployment/index.d.ts +11 -0
- package/lib/Deployment/index.d.ts.map +1 -0
- package/{src/Deployment/index.ts → lib/Deployment/index.js} +22 -37
- package/lib/Deployment/index.js.map +1 -0
- package/lib/Network/axios-error-handling.d.ts +26 -0
- package/lib/Network/axios-error-handling.d.ts.map +1 -0
- package/lib/Network/axios-error-handling.js +52 -0
- package/lib/Network/axios-error-handling.js.map +1 -0
- package/lib/Network/index.d.ts +11 -0
- package/lib/Network/index.d.ts.map +1 -0
- package/lib/Network/index.js +19 -0
- package/lib/Network/index.js.map +1 -0
- package/lib/TestHarness/index.d.ts +9 -0
- package/lib/TestHarness/index.d.ts.map +1 -0
- package/lib/TestHarness/index.js +35 -0
- package/lib/TestHarness/index.js.map +1 -0
- package/lib/types/IEnrichmentIntegration.d.ts +24 -0
- package/lib/types/IEnrichmentIntegration.d.ts.map +1 -0
- package/lib/types/IEnrichmentIntegration.js +3 -0
- package/lib/types/IEnrichmentIntegration.js.map +1 -0
- package/lib/types/IPartnerDataSchema.d.ts +25 -0
- package/lib/types/IPartnerDataSchema.d.ts.map +1 -0
- package/lib/types/IPartnerDataSchema.js +13 -0
- package/lib/types/IPartnerDataSchema.js.map +1 -0
- package/{src/types/index.ts → lib/types/index.d.ts} +1 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +15 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +12 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +7 -3
- package/.eslintignore +0 -11
- package/.eslintrc.js +0 -273
- package/.prettierignore +0 -7
- package/.prettierrc +0 -19
- package/CODEOWNERS +0 -6
- package/src/Network/axios-error-handling.ts +0 -76
- package/src/Network/index.ts +0 -19
- package/src/TestHarness/index.ts +0 -38
- package/src/dummy.test.ts +0 -1
- package/src/types/IEnrichmentIntegration.ts +0 -20
- package/src/types/IPartnerDataSchema.ts +0 -39
- package/src/utils/index.ts +0 -5
- package/tsconfig.build.json +0 -14
- package/tsconfig.eslint.json +0 -20
- package/tsconfig.json +0 -20
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IEnrichmentIntegration } from '../types';
|
|
2
|
+
export declare type DatabaseScript = {
|
|
3
|
+
run: string;
|
|
4
|
+
rollback: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type PartnerHubInstallScripts = {
|
|
7
|
+
install_partner: DatabaseScript;
|
|
8
|
+
install_flags: DatabaseScript;
|
|
9
|
+
};
|
|
10
|
+
export declare function generateDatabaseScripts(integration: IEnrichmentIntegration, billingProviderId: number): PartnerHubInstallScripts;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Deployment/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,oBAAY,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,wBAAwB,GAAG;IACrC,eAAe,EAAE,cAAc,CAAC;IAChC,aAAa,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,sBAAsB,EACnC,iBAAiB,EAAE,MAAM,GACxB,wBAAwB,CAwD1B"}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type PartnerHubInstallScripts = {
|
|
9
|
-
install_partner: DatabaseScript;
|
|
10
|
-
install_flags: DatabaseScript;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function generateDatabaseScripts(
|
|
14
|
-
integration: IEnrichmentIntegration,
|
|
15
|
-
billingProviderId: number
|
|
16
|
-
): PartnerHubInstallScripts {
|
|
17
|
-
const { offering, partner } = { offering: 'foo', partner: 'bar' }; // this will come from the manifest file
|
|
18
|
-
const intName = `${partner.toLowerCase()}_${offering.toLowerCase()}`;
|
|
19
|
-
|
|
20
|
-
const ph_create = `
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateDatabaseScripts = void 0;
|
|
4
|
+
function generateDatabaseScripts(integration, billingProviderId) {
|
|
5
|
+
const { offering, partner } = { offering: 'foo', partner: 'bar' }; // this will come from the manifest file
|
|
6
|
+
const intName = `${partner.toLowerCase()}_${offering.toLowerCase()}`;
|
|
7
|
+
const ph_create = `
|
|
21
8
|
create table if not exists ph.${intName} (
|
|
22
9
|
id bigint not null primary key default id_generator(1),
|
|
23
10
|
property_id int not null,
|
|
@@ -30,13 +17,11 @@ export function generateDatabaseScripts(
|
|
|
30
17
|
insert into ph.partner_offering (partner, offering, table_name, matrix_option, credentials_schema) values ('${partner}', '${offering}', '${intName}', 'include_${intName}', '{}');
|
|
31
18
|
;
|
|
32
19
|
`;
|
|
33
|
-
|
|
34
|
-
const ph_rollback = `
|
|
20
|
+
const ph_rollback = `
|
|
35
21
|
drop table ph.${intName};
|
|
36
22
|
delete from billing.provider where id = ${billingProviderId};
|
|
37
23
|
`;
|
|
38
|
-
|
|
39
|
-
const flag_create = `
|
|
24
|
+
const flag_create = `
|
|
40
25
|
do $$
|
|
41
26
|
declare
|
|
42
27
|
sectionid bigint;
|
|
@@ -52,21 +37,21 @@ export function generateDatabaseScripts(
|
|
|
52
37
|
values (subsectionid, 'Match Value(s)', 'value', '${intName}', 'custom', 'Case-insesitive, comma separated');
|
|
53
38
|
end $$;
|
|
54
39
|
`;
|
|
55
|
-
|
|
56
|
-
const flag_rollback = `
|
|
40
|
+
const flag_rollback = `
|
|
57
41
|
delete from flags.option where source = '${intName}' and key = 'custom';
|
|
58
42
|
delete from flags.options_subsection where display = '${partner} ${offering}';
|
|
59
43
|
delete from flags.options_section where display = '${partner}' and position = 999;
|
|
60
44
|
`;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
};
|
|
45
|
+
return {
|
|
46
|
+
install_partner: {
|
|
47
|
+
run: ph_create,
|
|
48
|
+
rollback: ph_rollback
|
|
49
|
+
},
|
|
50
|
+
install_flags: {
|
|
51
|
+
run: flag_create,
|
|
52
|
+
rollback: flag_rollback
|
|
53
|
+
}
|
|
54
|
+
};
|
|
72
55
|
}
|
|
56
|
+
exports.generateDatabaseScripts = generateDatabaseScripts;
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Deployment/index.ts"],"names":[],"mappings":";;;AAYA,SAAgB,uBAAuB,CACrC,WAAmC,EACnC,iBAAyB;IAEzB,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,wCAAwC;IAC3G,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;IAErE,MAAM,SAAS,GAAG;oCACgB,OAAO;;;;;;;;sDAQW,iBAAiB,MAAM,OAAO;kHAC8B,OAAO,OAAO,QAAQ,OAAO,OAAO,eAAe,OAAO;;GAEzK,CAAC;IAEF,MAAM,WAAW,GAAG;oBACF,OAAO;8CACmB,iBAAiB;GAC5D,CAAC;IAEF,MAAM,WAAW,GAAG;;;;;;gFAM0D,OAAO;;;8BAGzD,OAAO,IAAI,QAAQ;;;;4DAIW,OAAO;;KAE9D,CAAC;IAEJ,MAAM,aAAa,GAAG;+CACuB,OAAO;4DACM,OAAO,IAAI,QAAQ;yDACtB,OAAO;GAC7D,CAAC;IAEF,OAAO;QACL,eAAe,EAAE;YACf,GAAG,EAAE,SAAS;YACd,QAAQ,EAAE,WAAW;SACtB;QACD,aAAa,EAAE;YACb,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,aAAa;SACxB;KACF,CAAC;AACJ,CAAC;AA3DD,0DA2DC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AxiosError, AxiosResponse } from 'axios';
|
|
2
|
+
export declare type FriendlyName = 'server error' | 'no response' | 'request init failure' | 'auth error' | 'endpoint not found';
|
|
3
|
+
export interface SimplifiedError {
|
|
4
|
+
/** the status code number (e.g. 500) */
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
data?: any;
|
|
7
|
+
/** the status code name (e.g. ETIMEDOUT) */
|
|
8
|
+
code?: string;
|
|
9
|
+
responseHeaders?: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* server error: the server responded with an error
|
|
12
|
+
* no repsonse: no response was received from the server
|
|
13
|
+
* request init failure: axios failed to create the request to send
|
|
14
|
+
*/
|
|
15
|
+
friendly: FriendlyName;
|
|
16
|
+
}
|
|
17
|
+
/** simplifies an axios error, exposing the properties that are commonly used and friendly name to help decision trees */
|
|
18
|
+
export declare function simplifyError(err: AxiosError): SimplifiedError;
|
|
19
|
+
export interface IWrapResult<T> {
|
|
20
|
+
data?: T;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
err?: SimplifiedError;
|
|
23
|
+
}
|
|
24
|
+
/** wraps an axios api call, resulting in a successful promise containing either the requested data or a simplfied error */
|
|
25
|
+
export declare function wrap<T>(axiosApiCall: Promise<AxiosResponse<T> | AxiosError<T>>): Promise<IWrapResult<T>>;
|
|
26
|
+
//# sourceMappingURL=axios-error-handling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-error-handling.d.ts","sourceRoot":"","sources":["../../src/Network/axios-error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAElD,oBAAY,YAAY,GACpB,cAAc,GACd,aAAa,GACb,sBAAsB,GACtB,YAAY,GACZ,oBAAoB,CAAC;AAEzB,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,yHAAyH;AACzH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,CAa9D;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB;AAeD,2HAA2H;AAC3H,wBAAsB,IAAI,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAe9G"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrap = exports.simplifyError = void 0;
|
|
4
|
+
/** simplifies an axios error, exposing the properties that are commonly used and friendly name to help decision trees */
|
|
5
|
+
function simplifyError(err) {
|
|
6
|
+
let friendly = 'request init failure';
|
|
7
|
+
const statusCode = `${err.code ?? err.response?.status}`;
|
|
8
|
+
if (err.response)
|
|
9
|
+
friendly = convertStatusCode(statusCode);
|
|
10
|
+
else if (err.request)
|
|
11
|
+
friendly = 'no response';
|
|
12
|
+
return {
|
|
13
|
+
statusCode: err.response?.status,
|
|
14
|
+
data: err.response?.data,
|
|
15
|
+
code: statusCode,
|
|
16
|
+
responseHeaders: err.response?.headers,
|
|
17
|
+
friendly
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.simplifyError = simplifyError;
|
|
21
|
+
function convertStatusCode(code) {
|
|
22
|
+
switch (code) {
|
|
23
|
+
case '401':
|
|
24
|
+
return 'auth error';
|
|
25
|
+
case '500':
|
|
26
|
+
return 'server error';
|
|
27
|
+
case '404':
|
|
28
|
+
return 'endpoint not found';
|
|
29
|
+
default:
|
|
30
|
+
return 'no response';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** wraps an axios api call, resulting in a successful promise containing either the requested data or a simplfied error */
|
|
34
|
+
async function wrap(axiosApiCall) {
|
|
35
|
+
const result = {};
|
|
36
|
+
try {
|
|
37
|
+
let r = await axiosApiCall;
|
|
38
|
+
if (r.isAxiosError !== undefined) {
|
|
39
|
+
throw r;
|
|
40
|
+
}
|
|
41
|
+
r = r;
|
|
42
|
+
result.headers = r.headers;
|
|
43
|
+
result.data = r.data;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
const simple = simplifyError(err);
|
|
47
|
+
result.err = simple;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
exports.wrap = wrap;
|
|
52
|
+
//# sourceMappingURL=axios-error-handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-error-handling.js","sourceRoot":"","sources":["../../src/Network/axios-error-handling.ts"],"names":[],"mappings":";;;AAwBA,yHAAyH;AACzH,SAAgB,aAAa,CAAC,GAAe;IAC3C,IAAI,QAAQ,GAAiB,sBAAsB,CAAC;IACpD,MAAM,UAAU,GAAG,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACzD,IAAI,GAAG,CAAC,QAAQ;QAAE,QAAQ,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;SACtD,IAAI,GAAG,CAAC,OAAO;QAAE,QAAQ,GAAG,aAAa,CAAC;IAE/C,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM;QAChC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI;QACxB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO;QACtC,QAAQ;KACT,CAAC;AACJ,CAAC;AAbD,sCAaC;AAQD,SAAS,iBAAiB,CAAC,IAAY;IACrC,QAAQ,IAAI,EAAE;QACZ,KAAK,KAAK;YACR,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,cAAc,CAAC;QACxB,KAAK,KAAK;YACR,OAAO,oBAAoB,CAAC;QAC9B;YACE,OAAO,aAAa,CAAC;KACxB;AACH,CAAC;AAED,2HAA2H;AACpH,KAAK,UAAU,IAAI,CAAI,YAAuD;IACnF,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,IAAI;QACF,IAAI,CAAC,GAAG,MAAM,YAAY,CAAC;QAC3B,IAAK,CAAgB,CAAC,YAAY,KAAK,SAAS,EAAE;YAChD,MAAM,CAAC,CAAC;SACT;QACD,CAAC,GAAG,CAAqB,CAAC;QAC1B,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;QAC3B,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;KACtB;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,MAAM,GAAG,aAAa,CAAC,GAAsB,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC;KACrB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,oBAeC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { IWrapResult } from './axios-error-handling';
|
|
3
|
+
export declare function get(url: string, config: AxiosRequestConfig): Promise<{
|
|
4
|
+
request_url: string;
|
|
5
|
+
result: IWrapResult<Record<string, any>>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function post(url: string, data: any, config: AxiosRequestConfig): Promise<{
|
|
8
|
+
request_url: string;
|
|
9
|
+
result: IWrapResult<Record<string, any>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Network/index.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,WAAW,EAAQ,MAAM,wBAAwB,CAAC;AAE3D,wBAAsB,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;CAAE,CAAC,CAG5E;AAED,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;CAAE,CAAC,CAG5E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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.post = exports.get = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const axios_error_handling_1 = require("./axios-error-handling");
|
|
9
|
+
async function get(url, config) {
|
|
10
|
+
const result = await axios_error_handling_1.wrap(axios_1.default.get(url, config));
|
|
11
|
+
return { request_url: url, result };
|
|
12
|
+
}
|
|
13
|
+
exports.get = get;
|
|
14
|
+
async function post(url, data, config) {
|
|
15
|
+
const result = await axios_error_handling_1.wrap(axios_1.default.post(url, data, config));
|
|
16
|
+
return { request_url: url, result };
|
|
17
|
+
}
|
|
18
|
+
exports.post = post;
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Network/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAkD;AAClD,iEAA2D;AAEpD,KAAK,UAAU,GAAG,CACvB,GAAW,EACX,MAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,2BAAI,CAAC,eAAK,CAAC,GAAG,CAAsB,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IACvE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC;AAND,kBAMC;AAEM,KAAK,UAAU,IAAI,CACxB,GAAW,EACX,IAAS,EACT,MAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,2BAAI,CAAC,eAAK,CAAC,IAAI,CAAsB,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9E,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC;AAPD,oBAOC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEnrichmentIntegration, IEnrichmentIntegrationRequestData } from '../types';
|
|
2
|
+
export default class TestHarness {
|
|
3
|
+
integration: IEnrichmentIntegration;
|
|
4
|
+
requestData: IEnrichmentIntegrationRequestData | undefined;
|
|
5
|
+
constructor(integration: IEnrichmentIntegration, requestData?: IEnrichmentIntegrationRequestData);
|
|
6
|
+
runGetData(): Promise<Record<string, any> | undefined>;
|
|
7
|
+
setMockRequestData(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TestHarness/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAGrF,MAAM,CAAC,OAAO,OAAO,WAAW;IACvB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,iCAAiC,GAAG,SAAS,CAAC;gBAEtD,WAAW,EAAE,sBAAsB,EAAE,WAAW,CAAC,EAAE,iCAAiC;IAKnF,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;IAU5D,kBAAkB;CAe1B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
class TestHarness {
|
|
5
|
+
constructor(integration, requestData) {
|
|
6
|
+
this.integration = integration;
|
|
7
|
+
this.requestData = requestData;
|
|
8
|
+
}
|
|
9
|
+
async runGetData() {
|
|
10
|
+
if (!this.requestData) {
|
|
11
|
+
this.setMockRequestData();
|
|
12
|
+
}
|
|
13
|
+
console.log('Request data set to: ', utils_1.jsonLog(this.requestData));
|
|
14
|
+
const result = await this.integration.getData?.(this.requestData);
|
|
15
|
+
console.log(`Result:`, utils_1.jsonLog(result));
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
setMockRequestData() {
|
|
19
|
+
this.requestData = {
|
|
20
|
+
full_address: '100 Pringle Ave. Walnut Creek, CA 94596',
|
|
21
|
+
street: '100 Pringle Ave.',
|
|
22
|
+
city: 'Walnut Creek',
|
|
23
|
+
zip: '94596',
|
|
24
|
+
state: 'CA',
|
|
25
|
+
// fill this w/the true credentials from the offering
|
|
26
|
+
credentials: { username: 'test', password: 'test' },
|
|
27
|
+
externalId: 'external1',
|
|
28
|
+
insuredName: 'Jane Doe',
|
|
29
|
+
latitude: 37.90820797421544,
|
|
30
|
+
longitude: -122.067761097756
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = TestHarness;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/TestHarness/index.ts"],"names":[],"mappings":";;AACA,oCAAmC;AAEnC,MAAqB,WAAW;IAI9B,YAAY,WAAmC,EAAE,WAA+C;QAC9F,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,kBAAkB,EAAE,CAAC;SAC3B;QACD,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,eAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,WAAY,CAAC,CAAC;QACnE,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,eAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,kBAAkB;QACvB,IAAI,CAAC,WAAW,GAAG;YACjB,YAAY,EAAE,yCAAyC;YACvD,MAAM,EAAE,kBAAkB;YAC1B,IAAI,EAAE,cAAc;YACpB,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,IAAI;YACX,qDAAqD;YACrD,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;YACnD,UAAU,EAAE,WAAW;YACvB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,iBAAiB;YAC3B,SAAS,EAAE,CAAC,gBAAgB;SAC7B,CAAC;IACJ,CAAC;CACF;AAlCD,8BAkCC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IWrapResult } from '../Network/axios-error-handling';
|
|
2
|
+
export interface IEnrichmentIntegration {
|
|
3
|
+
/**
|
|
4
|
+
* Pulls data from the vendor and returns the data graph in JSON format.
|
|
5
|
+
*/
|
|
6
|
+
getData(requestData: IEnrichmentIntegrationRequestData): Promise<{
|
|
7
|
+
request_url: string;
|
|
8
|
+
result: IWrapResult<Record<string, any>>;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface IEnrichmentIntegrationRequestData {
|
|
12
|
+
credentials: Record<any, string>;
|
|
13
|
+
full_address?: string;
|
|
14
|
+
street?: string;
|
|
15
|
+
city?: string;
|
|
16
|
+
state?: string;
|
|
17
|
+
zip?: string;
|
|
18
|
+
externalId?: string | null;
|
|
19
|
+
latitude?: number;
|
|
20
|
+
longitude?: number;
|
|
21
|
+
insuredName?: string | null;
|
|
22
|
+
clientOrgId?: number;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=IEnrichmentIntegration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEnrichmentIntegration.d.ts","sourceRoot":"","sources":["../../src/types/IEnrichmentIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,CACL,WAAW,EAAE,iCAAiC,GAC7C,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,iCAAiC;IAChD,WAAW,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEnrichmentIntegration.js","sourceRoot":"","sources":["../../src/types/IEnrichmentIntegration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface IDataSchemaField {
|
|
2
|
+
description: string;
|
|
3
|
+
formatter?: Formatters;
|
|
4
|
+
jsonPath: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
sample?: string | number | boolean;
|
|
7
|
+
title: string;
|
|
8
|
+
data_type: 'string' | 'number' | 'date' | 'stringArray' | 'objectArray' | 'boolean' | 'wkt' | 'geojson' | 'imgSrc' | 'downloadSrc' | 'coordinates' | 'coordinatesLatLngCSV' | 'coordinatesLngLatCSV';
|
|
9
|
+
fields?: IDataSchemaField[];
|
|
10
|
+
}
|
|
11
|
+
export interface IPartnerDataSchema {
|
|
12
|
+
fields: IDataSchemaField[];
|
|
13
|
+
}
|
|
14
|
+
export interface IPartnerDataSchemas {
|
|
15
|
+
[name: string]: IPartnerDataSchema;
|
|
16
|
+
}
|
|
17
|
+
export declare enum Formatters {
|
|
18
|
+
numberWithCommas = "numberWithCommas",
|
|
19
|
+
currencyWithCommas = "currencyWithCommas",
|
|
20
|
+
scoreLetterToLowMedHigh = "scoreLetterToLowMedHigh",
|
|
21
|
+
roundTwoDecimalPlaces = "roundTwoDecimalPlaces",
|
|
22
|
+
decimalToPercentage = "decimalToPercentage",
|
|
23
|
+
roundAndFormatWithCommas = "roundAndFormatWithCommasFn"
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=IPartnerDataSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPartnerDataSchema.d.ts","sourceRoot":"","sources":["../../src/types/IPartnerDataSchema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EACL,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,aAAa,GACb,aAAa,GACb,SAAS,GACT,KAAK,GACL,SAAS,GACT,QAAQ,GACR,aAAa,GACb,aAAa,GACb,sBAAsB,GACtB,sBAAsB,CAAC;IAC3B,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AACD,MAAM,WAAW,mBAAmB;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC;CACpC;AAED,oBAAY,UAAU;IACpB,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,uBAAuB,4BAA4B;IACnD,qBAAqB,0BAA0B;IAC/C,mBAAmB,wBAAwB;IAC3C,wBAAwB,+BAA+B;CACxD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Formatters = void 0;
|
|
4
|
+
var Formatters;
|
|
5
|
+
(function (Formatters) {
|
|
6
|
+
Formatters["numberWithCommas"] = "numberWithCommas";
|
|
7
|
+
Formatters["currencyWithCommas"] = "currencyWithCommas";
|
|
8
|
+
Formatters["scoreLetterToLowMedHigh"] = "scoreLetterToLowMedHigh";
|
|
9
|
+
Formatters["roundTwoDecimalPlaces"] = "roundTwoDecimalPlaces";
|
|
10
|
+
Formatters["decimalToPercentage"] = "decimalToPercentage";
|
|
11
|
+
Formatters["roundAndFormatWithCommas"] = "roundAndFormatWithCommasFn";
|
|
12
|
+
})(Formatters = exports.Formatters || (exports.Formatters = {}));
|
|
13
|
+
//# sourceMappingURL=IPartnerDataSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPartnerDataSchema.js","sourceRoot":"","sources":["../../src/types/IPartnerDataSchema.ts"],"names":[],"mappings":";;;AA+BA,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,mDAAqC,CAAA;IACrC,uDAAyC,CAAA;IACzC,iEAAmD,CAAA;IACnD,6DAA+C,CAAA;IAC/C,yDAA2C,CAAA;IAC3C,qEAAuD,CAAA;AACzD,CAAC,EAPW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAOrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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("./IEnrichmentIntegration"), exports);
|
|
14
|
+
__exportStar(require("./IPartnerDataSchema"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,UAE3D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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.jsonLog = void 0;
|
|
7
|
+
const json_colorizer_1 = __importDefault(require("json-colorizer"));
|
|
8
|
+
function jsonLog(obj) {
|
|
9
|
+
return json_colorizer_1.default(JSON.stringify(obj, null, 2));
|
|
10
|
+
}
|
|
11
|
+
exports.jsonLog = jsonLog;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAsC;AAEtC,SAAgB,OAAO,CAAC,GAAoC;IAC1D,OAAO,wBAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AAFD,0BAEC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betterview/integration-toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Supports integration packages. This should be the only import from our integrations",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
6
|
+
"prebuild": "rm -rf ./lib",
|
|
7
|
+
"build": "tsc -p tsconfig.build.json",
|
|
7
8
|
"lint": "eslint . --ext .ts,.js",
|
|
8
9
|
"lint:fix": "npm run lint -- --fix",
|
|
9
10
|
"test": "jest --runInBand",
|
|
@@ -40,5 +41,8 @@
|
|
|
40
41
|
},
|
|
41
42
|
"engines": {
|
|
42
43
|
"node": "^10 || ^14"
|
|
43
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"lib/**"
|
|
47
|
+
]
|
|
44
48
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Why are we specifying TS config in overrides?
|
|
3
|
-
*
|
|
4
|
-
* Apparently this is the preferred way to lint both JS and TS files. The base config
|
|
5
|
-
* is responsible for the JS files, and the override config is for the TS files. I'm
|
|
6
|
-
* unsure if we need to copy the base JS config into the TS overrides (e.g. ...rules), but
|
|
7
|
-
* everything seems to work in this configuration, and is all still DRY, so 🤞
|
|
8
|
-
*
|
|
9
|
-
* See:
|
|
10
|
-
* https://stackoverflow.com/questions/57597142/how-to-run-typescript-eslint-on-ts-files-and-eslint-on-js-files-in-the-same-pr
|
|
11
|
-
* https://github.com/techatpark/npm-scripts-static-ref/blob/main/.eslintrc.js
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const rules = {
|
|
15
|
-
'arrow-parens': ['error', 'as-needed'],
|
|
16
|
-
'brace-style': ['off', 'off'],
|
|
17
|
-
'comma-dangle': 'error',
|
|
18
|
-
complexity: 'off',
|
|
19
|
-
'constructor-super': 'error',
|
|
20
|
-
curly: 'off',
|
|
21
|
-
'eol-last': 'off',
|
|
22
|
-
eqeqeq: ['error', 'smart'],
|
|
23
|
-
'guard-for-in': 'error',
|
|
24
|
-
'id-blacklist': [
|
|
25
|
-
'error',
|
|
26
|
-
'any',
|
|
27
|
-
'Number',
|
|
28
|
-
'number',
|
|
29
|
-
'String',
|
|
30
|
-
'string',
|
|
31
|
-
'Boolean',
|
|
32
|
-
'boolean',
|
|
33
|
-
'Undefined',
|
|
34
|
-
'undefined'
|
|
35
|
-
],
|
|
36
|
-
'id-match': 'error',
|
|
37
|
-
/**
|
|
38
|
-
* 2020-09-28 - NM - I don't understand this rule.
|
|
39
|
-
* what does this help us achieve?
|
|
40
|
-
*/
|
|
41
|
-
// 'import/no-extraneous-dependencies': [
|
|
42
|
-
// 'error',
|
|
43
|
-
// {
|
|
44
|
-
// devDependencies: false
|
|
45
|
-
// }
|
|
46
|
-
// ],
|
|
47
|
-
'import/no-internal-modules': 'off',
|
|
48
|
-
'jsdoc/check-alignment': 'error',
|
|
49
|
-
'jsdoc/newline-after-description': 'error',
|
|
50
|
-
'linebreak-style': 'off',
|
|
51
|
-
'max-classes-per-file': 'off',
|
|
52
|
-
'max-len': 'off',
|
|
53
|
-
'new-parens': 'off',
|
|
54
|
-
'newline-per-chained-call': 'off',
|
|
55
|
-
'no-bitwise': 'off',
|
|
56
|
-
'no-caller': 'error',
|
|
57
|
-
'no-cond-assign': 'error',
|
|
58
|
-
'no-console': ['error'],
|
|
59
|
-
'no-debugger': 'error',
|
|
60
|
-
'no-duplicate-case': 'error',
|
|
61
|
-
'no-duplicate-imports': 'error',
|
|
62
|
-
'no-empty': 'error',
|
|
63
|
-
'no-eval': 'error',
|
|
64
|
-
'no-extra-bind': 'error',
|
|
65
|
-
'no-extra-semi': 'off',
|
|
66
|
-
'no-fallthrough': 'off',
|
|
67
|
-
'no-invalid-this': 'off',
|
|
68
|
-
'no-irregular-whitespace': 'off',
|
|
69
|
-
'no-multiple-empty-lines': 'off',
|
|
70
|
-
'no-new-func': 'error',
|
|
71
|
-
'no-new-wrappers': 'error',
|
|
72
|
-
'no-redeclare': 'error',
|
|
73
|
-
'no-return-await': 'error',
|
|
74
|
-
'no-sequences': 'error',
|
|
75
|
-
'no-shadow': 'off',
|
|
76
|
-
'@typescript-eslint/no-shadow': ['error'],
|
|
77
|
-
'no-sparse-arrays': 'error',
|
|
78
|
-
'no-template-curly-in-string': 'error',
|
|
79
|
-
'no-throw-literal': 'off',
|
|
80
|
-
'no-trailing-spaces': 'off',
|
|
81
|
-
'no-undef-init': 'error',
|
|
82
|
-
'no-underscore-dangle': [
|
|
83
|
-
'error',
|
|
84
|
-
{
|
|
85
|
-
allowAfterThis: true,
|
|
86
|
-
allowAfterSuper: true,
|
|
87
|
-
allowAfterThisConstructor: true
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
'no-unsafe-finally': 'error',
|
|
91
|
-
'no-unused-labels': 'error',
|
|
92
|
-
'no-var': 'error',
|
|
93
|
-
'object-shorthand': 'error',
|
|
94
|
-
'one-var': ['error', 'never'],
|
|
95
|
-
/**
|
|
96
|
-
* 2020-09-28 - NM - I'm not sure I like this rule.
|
|
97
|
-
* We like named functions in some cases because it can help
|
|
98
|
-
* add more context to logs. Is there a reason for this rule
|
|
99
|
-
* to exist?
|
|
100
|
-
*/
|
|
101
|
-
// 'prefer-arrow/prefer-arrow-functions': 'error',
|
|
102
|
-
'prefer-const': 'error',
|
|
103
|
-
'prefer-object-spread': 'error',
|
|
104
|
-
'quote-props': 'off',
|
|
105
|
-
radix: 'error',
|
|
106
|
-
'space-before-function-paren': 'off',
|
|
107
|
-
'space-in-parens': ['off', 'never'],
|
|
108
|
-
'spaced-comment': [
|
|
109
|
-
'error',
|
|
110
|
-
'always',
|
|
111
|
-
{
|
|
112
|
-
markers: ['/']
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
'use-isnan': 'error',
|
|
116
|
-
'valid-typeof': 'off'
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const env = {
|
|
120
|
-
browser: true,
|
|
121
|
-
es6: true,
|
|
122
|
-
node: true
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const plugins = ['eslint-plugin-jsdoc', 'eslint-plugin-prefer-arrow', 'eslint-plugin-import'];
|
|
126
|
-
|
|
127
|
-
const parserOptions = {
|
|
128
|
-
ecmaVersion: '2018'
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
module.exports = {
|
|
132
|
-
root: true,
|
|
133
|
-
env,
|
|
134
|
-
plugins,
|
|
135
|
-
rules,
|
|
136
|
-
// necessary for optional chaining in JS: https://github.com/nuxt/eslint-config/issues/92#issuecomment-623088678
|
|
137
|
-
parser: 'babel-eslint',
|
|
138
|
-
parserOptions,
|
|
139
|
-
overrides: [
|
|
140
|
-
{
|
|
141
|
-
files: ['**/*.ts'],
|
|
142
|
-
env,
|
|
143
|
-
parser: '@typescript-eslint/parser',
|
|
144
|
-
parserOptions: {
|
|
145
|
-
...parserOptions,
|
|
146
|
-
project: './tsconfig.eslint.json',
|
|
147
|
-
sourceType: 'module'
|
|
148
|
-
},
|
|
149
|
-
plugins: [...plugins, '@typescript-eslint', '@typescript-eslint/tslint'],
|
|
150
|
-
rules: {
|
|
151
|
-
...rules,
|
|
152
|
-
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
153
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
154
|
-
'@typescript-eslint/array-type': [
|
|
155
|
-
'error',
|
|
156
|
-
{
|
|
157
|
-
default: 'array'
|
|
158
|
-
}
|
|
159
|
-
],
|
|
160
|
-
'@typescript-eslint/ban-types': [
|
|
161
|
-
'error',
|
|
162
|
-
{
|
|
163
|
-
types: {
|
|
164
|
-
Object: {
|
|
165
|
-
message: 'Avoid using the `Object` type. Did you mean `object`?'
|
|
166
|
-
},
|
|
167
|
-
Function: {
|
|
168
|
-
message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.'
|
|
169
|
-
},
|
|
170
|
-
// eslint-disable-next-line id-blacklist
|
|
171
|
-
Boolean: {
|
|
172
|
-
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?'
|
|
173
|
-
},
|
|
174
|
-
// eslint-disable-next-line id-blacklist
|
|
175
|
-
Number: {
|
|
176
|
-
message: 'Avoid using the `Number` type. Did you mean `number`?'
|
|
177
|
-
},
|
|
178
|
-
// eslint-disable-next-line id-blacklist
|
|
179
|
-
String: {
|
|
180
|
-
message: 'Avoid using the `String` type. Did you mean `string`?'
|
|
181
|
-
},
|
|
182
|
-
Symbol: {
|
|
183
|
-
message: 'Avoid using the `Symbol` type. Did you mean `symbol`?'
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
],
|
|
188
|
-
'@typescript-eslint/consistent-type-assertions': 'error',
|
|
189
|
-
'@typescript-eslint/dot-notation': 'error',
|
|
190
|
-
'@typescript-eslint/explicit-member-accessibility': [
|
|
191
|
-
'off',
|
|
192
|
-
{
|
|
193
|
-
accessibility: 'explicit'
|
|
194
|
-
}
|
|
195
|
-
],
|
|
196
|
-
'@typescript-eslint/indent': 'off',
|
|
197
|
-
'@typescript-eslint/member-delimiter-style': [
|
|
198
|
-
'off',
|
|
199
|
-
{
|
|
200
|
-
multiline: {
|
|
201
|
-
delimiter: 'none',
|
|
202
|
-
requireLast: true
|
|
203
|
-
},
|
|
204
|
-
singleline: {
|
|
205
|
-
delimiter: 'semi',
|
|
206
|
-
requireLast: false
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
],
|
|
210
|
-
'@typescript-eslint/member-ordering': 'off',
|
|
211
|
-
// "@typescript-eslint/naming-convention": "error",
|
|
212
|
-
'@typescript-eslint/no-empty-function': 'error',
|
|
213
|
-
'@typescript-eslint/no-empty-interface': 'error',
|
|
214
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
215
|
-
'@typescript-eslint/no-misused-new': 'error',
|
|
216
|
-
'@typescript-eslint/no-namespace': 'error',
|
|
217
|
-
'@typescript-eslint/no-parameter-properties': 'off',
|
|
218
|
-
'@typescript-eslint/no-this-alias': 'error',
|
|
219
|
-
'@typescript-eslint/no-unused-expressions': 'error',
|
|
220
|
-
'@typescript-eslint/no-use-before-define': 'off',
|
|
221
|
-
'@typescript-eslint/no-var-requires': 'error',
|
|
222
|
-
'@typescript-eslint/prefer-for-of': 'error',
|
|
223
|
-
'@typescript-eslint/prefer-function-type': 'error',
|
|
224
|
-
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
225
|
-
// '@typescript-eslint/quotes': [
|
|
226
|
-
// 'error',
|
|
227
|
-
// 'single',
|
|
228
|
-
// {
|
|
229
|
-
// avoidEscape: true
|
|
230
|
-
// }
|
|
231
|
-
// ],
|
|
232
|
-
'@typescript-eslint/semi': ['off', null],
|
|
233
|
-
'@typescript-eslint/triple-slash-reference': [
|
|
234
|
-
'error',
|
|
235
|
-
{
|
|
236
|
-
path: 'always',
|
|
237
|
-
types: 'prefer-import',
|
|
238
|
-
lib: 'always'
|
|
239
|
-
}
|
|
240
|
-
],
|
|
241
|
-
'@typescript-eslint/type-annotation-spacing': 'off',
|
|
242
|
-
'@typescript-eslint/unified-signatures': 'error',
|
|
243
|
-
'@typescript-eslint/typedef': [
|
|
244
|
-
'error',
|
|
245
|
-
{
|
|
246
|
-
arrayDestructuring: false,
|
|
247
|
-
arrowParameter: false,
|
|
248
|
-
memberVariableDeclaration: false,
|
|
249
|
-
objectDestructuring: false,
|
|
250
|
-
parameter: true,
|
|
251
|
-
propertyDeclaration: false,
|
|
252
|
-
variableDeclaration: false,
|
|
253
|
-
variableDeclarationIgnoreFunction: true
|
|
254
|
-
}
|
|
255
|
-
],
|
|
256
|
-
'@typescript-eslint/tslint/config': [
|
|
257
|
-
'error',
|
|
258
|
-
{
|
|
259
|
-
rules: {
|
|
260
|
-
'prefer-conditional-expression': true,
|
|
261
|
-
typedef: [
|
|
262
|
-
true,
|
|
263
|
-
{
|
|
264
|
-
'call-signature': true
|
|
265
|
-
}
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
]
|
|
273
|
-
};
|
package/.prettierignore
DELETED
package/.prettierrc
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"eslintIntegration": true,
|
|
3
|
-
"singleQuote": true,
|
|
4
|
-
"tabWidth": 2,
|
|
5
|
-
"disableLanguages": [
|
|
6
|
-
"json"
|
|
7
|
-
],
|
|
8
|
-
"useTabs": false,
|
|
9
|
-
"printWidth": 120,
|
|
10
|
-
"jsxBracketSameLine": false,
|
|
11
|
-
"editor.tabSize": 2,
|
|
12
|
-
"editor.formatOnSave": true,
|
|
13
|
-
"[json]": {
|
|
14
|
-
"editor.formatOnSave": false
|
|
15
|
-
},
|
|
16
|
-
"tslint.autoFixOnSave": true,
|
|
17
|
-
"trailingComma": "none",
|
|
18
|
-
"arrowParens": "avoid"
|
|
19
|
-
}
|
package/CODEOWNERS
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AxiosError, AxiosResponse } from 'axios';
|
|
2
|
-
|
|
3
|
-
export type FriendlyName =
|
|
4
|
-
| 'server error'
|
|
5
|
-
| 'no response'
|
|
6
|
-
| 'request init failure'
|
|
7
|
-
| 'auth error'
|
|
8
|
-
| 'endpoint not found';
|
|
9
|
-
|
|
10
|
-
export interface SimplifiedError {
|
|
11
|
-
/** the status code number (e.g. 500) */
|
|
12
|
-
statusCode?: number;
|
|
13
|
-
data?: any;
|
|
14
|
-
/** the status code name (e.g. ETIMEDOUT) */
|
|
15
|
-
code?: string;
|
|
16
|
-
responseHeaders?: Record<string, string>;
|
|
17
|
-
/**
|
|
18
|
-
* server error: the server responded with an error
|
|
19
|
-
* no repsonse: no response was received from the server
|
|
20
|
-
* request init failure: axios failed to create the request to send
|
|
21
|
-
*/
|
|
22
|
-
friendly: FriendlyName;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** simplifies an axios error, exposing the properties that are commonly used and friendly name to help decision trees */
|
|
26
|
-
export function simplifyError(err: AxiosError): SimplifiedError {
|
|
27
|
-
let friendly: FriendlyName = 'request init failure';
|
|
28
|
-
const statusCode = `${err.code ?? err.response?.status}`;
|
|
29
|
-
if (err.response) friendly = convertStatusCode(statusCode);
|
|
30
|
-
else if (err.request) friendly = 'no response';
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
statusCode: err.response?.status,
|
|
34
|
-
data: err.response?.data,
|
|
35
|
-
code: statusCode,
|
|
36
|
-
responseHeaders: err.response?.headers,
|
|
37
|
-
friendly
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface IWrapResult<T> {
|
|
42
|
-
data?: T;
|
|
43
|
-
headers?: Record<string, string>;
|
|
44
|
-
err?: SimplifiedError;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function convertStatusCode(code: string): FriendlyName {
|
|
48
|
-
switch (code) {
|
|
49
|
-
case '401':
|
|
50
|
-
return 'auth error';
|
|
51
|
-
case '500':
|
|
52
|
-
return 'server error';
|
|
53
|
-
case '404':
|
|
54
|
-
return 'endpoint not found';
|
|
55
|
-
default:
|
|
56
|
-
return 'no response';
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** wraps an axios api call, resulting in a successful promise containing either the requested data or a simplfied error */
|
|
61
|
-
export async function wrap<T>(axiosApiCall: Promise<AxiosResponse<T> | AxiosError<T>>): Promise<IWrapResult<T>> {
|
|
62
|
-
const result: IWrapResult<T> = {};
|
|
63
|
-
try {
|
|
64
|
-
let r = await axiosApiCall;
|
|
65
|
-
if ((r as AxiosError).isAxiosError !== undefined) {
|
|
66
|
-
throw r;
|
|
67
|
-
}
|
|
68
|
-
r = r as AxiosResponse<T>;
|
|
69
|
-
result.headers = r.headers;
|
|
70
|
-
result.data = r.data;
|
|
71
|
-
} catch (err) {
|
|
72
|
-
const simple = simplifyError(err as AxiosError<any>);
|
|
73
|
-
result.err = simple;
|
|
74
|
-
}
|
|
75
|
-
return result;
|
|
76
|
-
}
|
package/src/Network/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { IWrapResult, wrap } from './axios-error-handling';
|
|
3
|
-
|
|
4
|
-
export async function get(
|
|
5
|
-
url: string,
|
|
6
|
-
config: AxiosRequestConfig
|
|
7
|
-
): Promise<{ request_url: string; result: IWrapResult<Record<string, any>> }> {
|
|
8
|
-
const result = await wrap(axios.get<Record<string, any>>(url, config));
|
|
9
|
-
return { request_url: url, result };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function post(
|
|
13
|
-
url: string,
|
|
14
|
-
data: any,
|
|
15
|
-
config: AxiosRequestConfig
|
|
16
|
-
): Promise<{ request_url: string; result: IWrapResult<Record<string, any>> }> {
|
|
17
|
-
const result = await wrap(axios.post<Record<string, any>>(url, data, config));
|
|
18
|
-
return { request_url: url, result };
|
|
19
|
-
}
|
package/src/TestHarness/index.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { IEnrichmentIntegration, IEnrichmentIntegrationRequestData } from '../Types';
|
|
2
|
-
import { jsonLog } from '../utils';
|
|
3
|
-
|
|
4
|
-
export default class TestHarness {
|
|
5
|
-
public integration: IEnrichmentIntegration;
|
|
6
|
-
public requestData: IEnrichmentIntegrationRequestData | undefined;
|
|
7
|
-
|
|
8
|
-
constructor(integration: IEnrichmentIntegration, requestData?: IEnrichmentIntegrationRequestData) {
|
|
9
|
-
this.integration = integration;
|
|
10
|
-
this.requestData = requestData;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public async runGetData(): Promise<Record<string, any> | undefined> {
|
|
14
|
-
if (!this.requestData) {
|
|
15
|
-
this.setMockRequestData();
|
|
16
|
-
}
|
|
17
|
-
console.log('Request data set to: ', jsonLog(this.requestData));
|
|
18
|
-
const result = await this.integration.getData?.(this.requestData!);
|
|
19
|
-
console.log(`Result:`, jsonLog(result));
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public setMockRequestData() {
|
|
24
|
-
this.requestData = {
|
|
25
|
-
full_address: '100 Pringle Ave. Walnut Creek, CA 94596',
|
|
26
|
-
street: '100 Pringle Ave.',
|
|
27
|
-
city: 'Walnut Creek',
|
|
28
|
-
zip: '94596',
|
|
29
|
-
state: 'CA',
|
|
30
|
-
// fill this w/the true credentials from the offering
|
|
31
|
-
credentials: { username: 'test', password: 'test' },
|
|
32
|
-
externalId: 'external1',
|
|
33
|
-
insuredName: 'Jane Doe',
|
|
34
|
-
latitude: 37.90820797421544,
|
|
35
|
-
longitude: -122.067761097756
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/dummy.test.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
test('Remove me when real tests are in place!', () => expect(true).not.toBe(false));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface IEnrichmentIntegration {
|
|
2
|
-
/**
|
|
3
|
-
* Pulls data from the vendor and returns the data graph in JSON format.
|
|
4
|
-
*/
|
|
5
|
-
getData?(requestData: IEnrichmentIntegrationRequestData): Promise<Record<string, any>>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IEnrichmentIntegrationRequestData {
|
|
9
|
-
credentials: Record<any, string>;
|
|
10
|
-
full_address?: string;
|
|
11
|
-
street?: string;
|
|
12
|
-
city?: string;
|
|
13
|
-
state?: string;
|
|
14
|
-
zip?: string;
|
|
15
|
-
externalId?: string | null;
|
|
16
|
-
latitude?: number;
|
|
17
|
-
longitude?: number;
|
|
18
|
-
insuredName?: string | null;
|
|
19
|
-
clientOrgId?: number;
|
|
20
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export interface IDataSchemaField {
|
|
2
|
-
description: string;
|
|
3
|
-
formatter?: Formatters;
|
|
4
|
-
jsonPath: string;
|
|
5
|
-
required?: boolean;
|
|
6
|
-
sample?: string | number | boolean;
|
|
7
|
-
title: string;
|
|
8
|
-
data_type:
|
|
9
|
-
| 'string'
|
|
10
|
-
| 'number'
|
|
11
|
-
| 'date'
|
|
12
|
-
| 'stringArray'
|
|
13
|
-
| 'objectArray'
|
|
14
|
-
| 'boolean'
|
|
15
|
-
| 'wkt'
|
|
16
|
-
| 'geojson'
|
|
17
|
-
| 'imgSrc'
|
|
18
|
-
| 'downloadSrc'
|
|
19
|
-
| 'coordinates' // an object keys named latitude longitude OR lat lng OR lat lon
|
|
20
|
-
| 'coordinatesLatLngCSV' // a coordinate string type like "32, -117"
|
|
21
|
-
| 'coordinatesLngLatCSV'; // a coordinate string type like "-117, 32"
|
|
22
|
-
fields?: IDataSchemaField[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface IPartnerDataSchema {
|
|
26
|
-
fields: IDataSchemaField[];
|
|
27
|
-
}
|
|
28
|
-
export interface IPartnerDataSchemas {
|
|
29
|
-
[name: string]: IPartnerDataSchema;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export enum Formatters {
|
|
33
|
-
numberWithCommas = 'numberWithCommas',
|
|
34
|
-
currencyWithCommas = 'currencyWithCommas',
|
|
35
|
-
scoreLetterToLowMedHigh = 'scoreLetterToLowMedHigh',
|
|
36
|
-
roundTwoDecimalPlaces = 'roundTwoDecimalPlaces',
|
|
37
|
-
decimalToPercentage = 'decimalToPercentage',
|
|
38
|
-
roundAndFormatWithCommas = 'roundAndFormatWithCommasFn'
|
|
39
|
-
}
|
package/src/utils/index.ts
DELETED
package/tsconfig.build.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"include": ["src/**/*.js", "src/**/*.ts"],
|
|
4
|
-
"exclude": [
|
|
5
|
-
"node_modules",
|
|
6
|
-
".vscode",
|
|
7
|
-
"src/**/*.test.?s",
|
|
8
|
-
"src/**/*testData.?s",
|
|
9
|
-
"src/**/*.exclude.?s",
|
|
10
|
-
"src/__tests__/**/*.?s",
|
|
11
|
-
"src/__jest__/**/*.?s",
|
|
12
|
-
"src/__mocks__/**/*.?s"
|
|
13
|
-
]
|
|
14
|
-
}
|
package/tsconfig.eslint.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
This config is necessary because ESlint needs to be able to transpile all TS files
|
|
3
|
-
that we want to lint, even if the real build excludes them (e.g. test files).
|
|
4
|
-
See: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md#parseroptionsproject
|
|
5
|
-
*/
|
|
6
|
-
{
|
|
7
|
-
"extends": "./tsconfig.json",
|
|
8
|
-
"include": [
|
|
9
|
-
"src/**/*.js",
|
|
10
|
-
"src/**/*.ts",
|
|
11
|
-
".eslintrc.js",
|
|
12
|
-
"*.js",
|
|
13
|
-
"*.ts",
|
|
14
|
-
"test/**/*.*"
|
|
15
|
-
],
|
|
16
|
-
"exclude": [
|
|
17
|
-
"node_modules",
|
|
18
|
-
".vscode"
|
|
19
|
-
]
|
|
20
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compileOnSave": true,
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"declarationMap": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"target": "ES2020",
|
|
9
|
-
"module": "commonjs",
|
|
10
|
-
"moduleResolution": "node",
|
|
11
|
-
"outDir": "lib",
|
|
12
|
-
"rootDir": "src",
|
|
13
|
-
"sourceMap": true,
|
|
14
|
-
"allowJs": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"strictNullChecks": true,
|
|
17
|
-
"noImplicitReturns": true,
|
|
18
|
-
"baseUrl": "./src",
|
|
19
|
-
}
|
|
20
|
-
}
|