@getjones/test-infra 1.6.0 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -27,6 +27,7 @@ const getInternalAPI = () => {
27
27
 
28
28
  const globalRecord = require('./saas/internal-api/globalRecord');
29
29
  const vendorProfile = require('./saas/internal-api/vendorProfile');
30
+ const serviceArea = require('./saas/internal-api/serviceArea');
30
31
 
31
32
  const threadScheduler = require('./saas/internal-api/thread-scheduler/runner');
32
33
 
@@ -44,6 +45,8 @@ const getInternalAPI = () => {
44
45
  charts,
45
46
  globalRecord,
46
47
  vendorProfile,
48
+ serviceArea,
49
+
47
50
  threadScheduler
48
51
  };
49
52
 
@@ -53,7 +56,7 @@ const getInternalAPI = () => {
53
56
  const getOpenAPI = () => {
54
57
  const accounts = require('./saas/openapi/accounts/accounts.service');
55
58
  const tabs = require('./saas/openapi/tabs/tabs.service');
56
- const contractors = require('./saas/openapi/contractors/contractors.service');
59
+ const contractors = require('./saas/openapi/contractors');
57
60
  const projects = require('./saas/openapi/projects/projects.service');
58
61
  const requirements = require('./saas/openapi/requirements');
59
62
  const openAPI = { accounts, tabs, contractors, projects, requirements };
@@ -12,7 +12,8 @@ const updateAccountSettings = (updateAccountSettingsModel, context) => {
12
12
  };
13
13
 
14
14
  const restoreAccountSettings = (accountId, context) => {
15
- const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, false, false, false);
15
+ const [isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit] = [false, false, false, false, false];
16
+ const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit);
16
17
  return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
17
18
  };
18
19
 
@@ -3,12 +3,16 @@ class UpdateAccountSettingsModel {
3
3
  accountId,
4
4
  isHighPriority,
5
5
  hasAnalyticsDashboard,
6
- isExcludedFromNetwork
6
+ isExcludedFromNetwork,
7
+ isOcrEnabled,
8
+ isCoverageAudit
7
9
  ) {
8
10
  this.accountId = accountId;
9
11
  this.isHighPriority = isHighPriority;
10
12
  this.hasAnalyticsDashboard = hasAnalyticsDashboard;
11
13
  this.isExcludedFromNetwork = isExcludedFromNetwork;
14
+ this.isOcrEnabled = isOcrEnabled;
15
+ this.isCoverageAudit = isCoverageAudit;
12
16
  }
13
17
  }
14
18
 
@@ -11,7 +11,8 @@ function CreateContractorModel(requirementId, inviterEmail, vendorInfo, { tabId
11
11
  vendorInfo && validateType(vendorInfo, ContractorInfo);
12
12
  }
13
13
 
14
- function ContractorInfo(email, companyName, additionalEmails) {
14
+ function ContractorInfo(recordType, email, companyName, additionalEmails) {
15
+ this.recordType = recordType;
15
16
  this.email = email;
16
17
  this.companyName = companyName;
17
18
  this.title = email;
@@ -1,11 +1,12 @@
1
1
  const { validateType } = require('../../../../common/validations/typeValidations');
2
2
 
3
3
  class ContractorModel {
4
- constructor(contractorId, company, emailAddress, tab, additionalDetails) {
4
+ constructor(contractorId, recordType, company, emailAddress, tab, additionalDetails) {
5
5
  validateType(tab, VendorTabModel);
6
6
  validateType(additionalDetails, ContractorDetailsModel);
7
7
 
8
8
  this.contractorId = contractorId;
9
+ this.recordType = recordType;
9
10
  this.company = company;
10
11
  this.emailAddress = emailAddress;
11
12
  this.tab = tab;
@@ -21,7 +21,7 @@ const deleteProjectByName = async (accountId, projectName, context) => {
21
21
  const { data: projects } = await getProjectsByAccountId(accountId, context);
22
22
  const filteredProjects = projects.filter(project => project.projectName === projectName);
23
23
 
24
- await Promise.all(
24
+ return await Promise.all(
25
25
  filteredProjects.map(
26
26
  async project => await projectsApi.deleteProjectById(project.projectId, context)
27
27
  )
@@ -1,5 +1,7 @@
1
1
  const services = require('../api/core/projects.service');
2
2
 
3
+ const numberUtils = require('../../../../common/utils/numberUtils');
4
+
3
5
  const CreateProjectModel = require('../models/core/create.project.model');
4
6
  const UpdateProjectModel = require('../models/core/update.project.model');
5
7
 
@@ -51,11 +53,30 @@ const getUpdateProjectModel = (accountId, projectId, projectData) => {
51
53
  return updateProjectModel;
52
54
  };
53
55
 
54
- // combine the config handling in single func
56
+ const getProjectConfig = (projectName, { city, state, accountName, projectNumber } = {}) => {
57
+ return {
58
+ 'name': projectName,
59
+ 'description': `${projectName}Description`,
60
+ 'address': `${projectName}Street 14.`,
61
+ 'number': projectNumber || numberUtils.getRandomNumberInRange(10000, 99999),
62
+ 'startDate': '01/01/2022',
63
+ 'endDate': '01/01/2030',
64
+ 'city': city || `${projectName}City`,
65
+ 'state': state || 'Alabama',
66
+ 'zipCode': '11111',
67
+ 'companyNameForProject': accountName || `${projectName}Account`
68
+ };
69
+ };
70
+
71
+ const deleteProjectByName = (accounId, projectName, context) => {
72
+ return services.deleteProjectByName(accounId, projectName, context);
73
+ };
55
74
 
56
75
  module.exports = {
76
+ getProjectConfig,
57
77
  getOrCreateProject,
58
78
  getDefaultProjectId,
59
79
  getCreateProjectModel,
60
- getUpdateProjectModel
80
+ getUpdateProjectModel,
81
+ deleteProjectByName
61
82
  };
@@ -2,11 +2,31 @@ const requests = require('../../../../common/requests/cookieAuth/requests');
2
2
  const { backendUrl } = require('../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
5
- generateReport: reportType => `${backendUrl}/saas/integration-tests/ExportXLSXReport/${reportType}`
5
+ generateReportAndSendViaEmail: (accountId, reportType) => `${backendUrl}/saas/ExportXLSXReport/account/${accountId}/${reportType}`,
6
+ generateReportAndUploadToS3: reportType => `${backendUrl}/saas/integration-tests/ExportXLSXReport/${reportType}`,
7
+ getScheduledReports: accountId => `${backendUrl}/saas/scheduled-report/account/${accountId}`,
8
+ deleteScheduledReport: scheduledReportId => `${backendUrl}/saas/scheduled-report/${scheduledReportId}`
6
9
  };
7
10
 
8
- const generateReport = (reportFilters, reportType, context) => {
9
- return requests.postRequestHandler(Endpoints.generateReport(reportType), reportFilters, context);
11
+ const generateReportAndSendViaEmail = (reportFilters, accountId, reportType, context) => {
12
+ return requests.postRequestHandler(Endpoints.generateReportAndSendViaEmail(accountId, reportType), reportFilters, context);
10
13
  };
11
14
 
12
- module.exports = { generateReport };
15
+ const generateReportAndUploadToS3 = (reportFilters, reportType, context) => {
16
+ return requests.postRequestHandler(Endpoints.generateReportAndUploadToS3(reportType), reportFilters, context);
17
+ };
18
+
19
+ const getScheduledReports = (accountId, context) => {
20
+ return requests.getRequestHandler(Endpoints.getScheduledReports(accountId), null, context);
21
+ };
22
+
23
+ const deleteScheduledReport = (scheduledReportId, context) => {
24
+ return requests.deleteRequestHandler(Endpoints.deleteScheduledReport(scheduledReportId), context);
25
+ };
26
+
27
+ module.exports = {
28
+ generateReportAndSendViaEmail,
29
+ generateReportAndUploadToS3,
30
+ getScheduledReports,
31
+ deleteScheduledReport
32
+ };
@@ -2,9 +2,27 @@ const reportsApi = require('./reports.api');
2
2
  const { validateType } = require('../../../../common/validations/typeValidations');
3
3
  const { ReportFilters } = require('../models/report.model');
4
4
 
5
- const generateReport = (reportFilters, reportType, context) => {
5
+ const generateReportAndSendViaEmail = (reportFilters, accountId, reportType, context) => {
6
6
  validateType(reportFilters, ReportFilters);
7
- return reportsApi.generateReport(reportFilters, reportType, context);
7
+ return reportsApi.generateReportAndSendViaEmail(reportFilters, accountId, reportType, context);
8
8
  };
9
9
 
10
- module.exports = { generateReport };
10
+ const generateReportAndUploadToS3 = (reportFilters, reportType, context) => {
11
+ validateType(reportFilters, ReportFilters);
12
+ return reportsApi.generateReportAndUploadToS3(reportFilters, reportType, context);
13
+ };
14
+
15
+ const getScheduledReports = (accountId, context) => {
16
+ return reportsApi.getScheduledReports(accountId, context);
17
+ };
18
+
19
+ const deleteScheduledReport = (scheduledReportId, context) => {
20
+ return reportsApi.deleteScheduledReport(scheduledReportId, context);
21
+ };
22
+
23
+ module.exports = {
24
+ generateReportAndSendViaEmail,
25
+ generateReportAndUploadToS3,
26
+ getScheduledReports,
27
+ deleteScheduledReport
28
+ };
@@ -0,0 +1,56 @@
1
+ const REPORT_COMPLIANCE_STATUSES = {
2
+ COMPLIANT: 'COMPLIANT',
3
+ NOT_COMPLIANT: 'NOT_COMPLIANT',
4
+ AWAITING_COI: 'AWAITING_COI',
5
+ WAIVED: 'WAIVED',
6
+ EXPIRED: 'EXPIRED'
7
+ };
8
+
9
+ const REPORT_CONTRACTOR_TYPES = {
10
+ VENDORS: 'Vendors',
11
+ TENANTS: 'Tenants',
12
+ GUESTS: 'Guests'
13
+ };
14
+
15
+ const ALL_REPORT_COMPLIANCE_STATUSES = [
16
+ REPORT_COMPLIANCE_STATUSES.COMPLIANT,
17
+ REPORT_COMPLIANCE_STATUSES.NOT_COMPLIANT,
18
+ REPORT_COMPLIANCE_STATUSES.AWAITING_COI,
19
+ REPORT_COMPLIANCE_STATUSES.WAIVED,
20
+ REPORT_COMPLIANCE_STATUSES.EXPIRED
21
+ ];
22
+
23
+ const ALL_REPORT_CONTRACTOR_TYPES = [
24
+ REPORT_CONTRACTOR_TYPES.VENDORS,
25
+ REPORT_CONTRACTOR_TYPES.TENANTS,
26
+ REPORT_CONTRACTOR_TYPES.GUESTS
27
+ ];
28
+
29
+ const XlsxReportTypes = {
30
+ HIGH_LEVEL_PROPERTY_METRICS: 'HighLevelPropertyMetrics',
31
+ MASTER_COMPLIANCE_REPORT: 'MasterComplianceReport',
32
+ WAIVERS_REPORT: 'WaiversReport',
33
+ USER_MANAGEMENT_REPORT: 'UserManagementReport'
34
+ };
35
+
36
+ const ScheduledReportFrequency = {
37
+ DAILY: 'Daily',
38
+ WEEKLY: 'Weekly',
39
+ MONTHLY: 'Monthly',
40
+ QUARTERLY: 'Quarterly'
41
+ };
42
+
43
+ const SelectionType = {
44
+ ALL: 'All',
45
+ SELECTION: 'Selection'
46
+ };
47
+
48
+ module.exports = {
49
+ REPORT_COMPLIANCE_STATUSES,
50
+ REPORT_CONTRACTOR_TYPES,
51
+ ALL_REPORT_COMPLIANCE_STATUSES,
52
+ ALL_REPORT_CONTRACTOR_TYPES,
53
+ XlsxReportTypes,
54
+ ScheduledReportFrequency,
55
+ SelectionType
56
+ };
@@ -1,5 +1,6 @@
1
1
  const reportService = require('./api/reports.service');
2
2
  const reportModels = require('./models/report.model');
3
+ const reportConsts = require('./consts/consts');
3
4
 
4
5
  const services = {
5
6
  report: reportService
@@ -7,5 +8,8 @@ const services = {
7
8
  const models = {
8
9
  report: reportModels
9
10
  };
11
+ const consts = {
12
+ report: reportConsts
13
+ };
10
14
 
11
- module.exports = { models, services };
15
+ module.exports = { models, services, consts };
@@ -1,42 +1,27 @@
1
- const REPORT_TYPES = {
2
- WAIVER_REPORT: 'WaiversReport'
3
- };
4
-
5
- const REPORT_COMPLIANCE_STATUSES = {
6
- COMPLIANT: 'COMPLIANT',
7
- NOT_COMPLIANT: 'NOT_COMPLIANT',
8
- AWAITING_COI: 'AWAITING_COI',
9
- WAIVED: 'WAIVED',
10
- EXPIRED: 'EXPIRED'
11
- };
12
-
13
- const REPORT_CONTRACTOR_TYPES = {
14
- VENDORS: 'Vendors',
15
- TENANTS: 'Tenants',
16
- GUESTS: 'Guests'
17
- };
18
-
19
- const ALL_REPORT_COMPLIANCE_STATUSES = [
20
- REPORT_COMPLIANCE_STATUSES.COMPLIANT,
21
- REPORT_COMPLIANCE_STATUSES.NOT_COMPLIANT,
22
- REPORT_COMPLIANCE_STATUSES.AWAITING_COI,
23
- REPORT_COMPLIANCE_STATUSES.WAIVED,
24
- REPORT_COMPLIANCE_STATUSES.EXPIRED
25
- ];
1
+ const { ALL_REPORT_COMPLIANCE_STATUSES, ALL_REPORT_CONTRACTOR_TYPES } = require('../consts/consts');
26
2
 
27
- const ALL_REPORT_CONTRACTOR_TYPES = [
28
- REPORT_CONTRACTOR_TYPES.VENDORS,
29
- REPORT_CONTRACTOR_TYPES.TENANTS,
30
- REPORT_CONTRACTOR_TYPES.GUESTS
31
- ];
32
-
33
- function ReportFilters(projects, {
34
- complianceStatuses = ALL_REPORT_COMPLIANCE_STATUSES,
35
- contractorTypes = ALL_REPORT_CONTRACTOR_TYPES
36
- }) {
37
- this.projects = projects;
38
- this.vendorTabTypes = contractorTypes;
39
- this.complianceStatuses = complianceStatuses;
3
+ class ReportFilters {
4
+ constructor(
5
+ projects,
6
+ {
7
+ complianceStatuses = ALL_REPORT_COMPLIANCE_STATUSES,
8
+ contractorTypes = ALL_REPORT_CONTRACTOR_TYPES,
9
+ scheduledReportFrequency,
10
+ isAllProjects,
11
+ isAllTabTypes,
12
+ isAllComplianceStatuses
13
+ }
14
+ ) {
15
+ this.projects = projects;
16
+ this.vendorTabTypes = contractorTypes;
17
+ this.complianceStatuses = complianceStatuses;
18
+ this.scheduledReportFrequency = scheduledReportFrequency,
19
+ this.isAllProjects = isAllProjects,
20
+ this.isAllTabTypes = isAllTabTypes,
21
+ this.isAllComplianceStatuses = isAllComplianceStatuses;
22
+ }
40
23
  }
41
24
 
42
- module.exports = { ReportFilters, REPORT_TYPES, REPORT_CONTRACTOR_TYPES, REPORT_COMPLIANCE_STATUSES };
25
+ module.exports = {
26
+ ReportFilters
27
+ };
@@ -0,0 +1,12 @@
1
+ const requests = require('../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ coordinates: (city, state) => `${backendUrl}/saas/coordinates?city=${city}&state=${state}`
6
+ };
7
+
8
+ const getCoordinatesByAddress = (city, state, context) => {
9
+ return requests.getRequestHandler(Endpoints.coordinates(city, state), {}, context);
10
+ };
11
+
12
+ module.exports = { getCoordinatesByAddress };
@@ -0,0 +1,7 @@
1
+ const coordinates = require('./coordinates.api');
2
+
3
+ const getCoordinatesByAddress = (city, state, context) => {
4
+ return coordinates.getCoordinatesByAddress(city, state, context);
5
+ };
6
+
7
+ module.exports = { getCoordinatesByAddress };
@@ -0,0 +1,4 @@
1
+ const services = require('./api/coordinates.service');
2
+ const utils = require('./utils/utils');
3
+
4
+ module.exports = { services, utils };
@@ -0,0 +1,8 @@
1
+ const service = require('../api/coordinates.service');
2
+
3
+ const getCoordinatesByAddress = async (state, city, context) => {
4
+ const response = await service.getCoordinatesByAddress(state, city, context);
5
+ return response.data;
6
+ };
7
+
8
+ module.exports = { getCoordinatesByAddress };
@@ -5,11 +5,16 @@ const { isLocalhost } = require('../../../env');
5
5
  const contractorUrl = isLocalhost() ? 'contractors' : 'records';
6
6
 
7
7
  const Endpoints = {
8
- getAllContractors: `${openapiUrl}/${contractorUrl}/all`
8
+ getAllContractors: `${openapiUrl}/${contractorUrl}/all`,
9
+ inviteContractor: tabId => `${openapiUrl}/tabs/${tabId}/${contractorUrl}`
9
10
  };
10
11
 
11
12
  const getAllContractors = async (apiKey, params) => {
12
13
  return requests.getRequestHandler(Endpoints.getAllContractors, apiKey, params).then(res => res.data);
13
14
  };
14
15
 
15
- module.exports = { getAllContractors };
16
+ const inviteContractor = async (apiKey, tabId, params) => {
17
+ return requests.postRequestHandler(Endpoints.inviteContractor(tabId), apiKey, params).then(res => res.data);
18
+ };
19
+
20
+ module.exports = { getAllContractors, inviteContractor };
@@ -1,4 +1,6 @@
1
1
  const contractorsApi = require('./contractors.api');
2
+ const { InviteContractorModel } = require('./models/invite.contractor.model');
3
+ const { validateType } = require('../../../common/validations/typeValidations');
2
4
 
3
5
  const getContractors = async (apiKey, { projectId, type, activationStatuses } = {}) => {
4
6
  if (activationStatuses) {
@@ -8,4 +10,9 @@ const getContractors = async (apiKey, { projectId, type, activationStatuses } =
8
10
  return contractorsApi.getAllContractors(apiKey, { propertyId: projectId, type, activationStatuses });
9
11
  };
10
12
 
11
- module.exports = { getContractors };
13
+ const inviteContractor = async (apiKey, tabId, inviteContractorModel = {}) => {
14
+ validateType(inviteContractorModel, InviteContractorModel);
15
+ return contractorsApi.inviteContractor(apiKey, tabId, inviteContractorModel);
16
+ };
17
+
18
+ module.exports = { getContractors, inviteContractor };
@@ -0,0 +1,6 @@
1
+ const services = require('./contractors.service');
2
+
3
+ const InviteContractorModel = require('./models/invite.contractor.model');
4
+ const models = { InviteContractorModel };
5
+
6
+ module.exports = { ... services, models };
@@ -0,0 +1,37 @@
1
+ class InviteContractorModel {
2
+ constructor(
3
+ email,
4
+ company,
5
+ {
6
+ requirementId,
7
+ firstName,
8
+ lastName,
9
+ dba,
10
+ address,
11
+ city,
12
+ state,
13
+ zipCode,
14
+ phoneNumber,
15
+ startDate,
16
+ endDate
17
+ } = {}
18
+ ) {
19
+ this.email = email;
20
+ this.company = company;
21
+ this.requirementId = requirementId;
22
+ this.firstName = firstName;
23
+ this.lastName = lastName;
24
+ this.dba = dba;
25
+ this.address = address;
26
+ this.city = city;
27
+ this.state = state;
28
+ this.zipCode = zipCode;
29
+ this.phoneNumber = phoneNumber;
30
+ this.startDate = startDate;
31
+ this.endDate = endDate;
32
+ }
33
+ }
34
+
35
+ module.exports = {
36
+ InviteContractorModel
37
+ };