@getjones/test-infra 1.2.12 → 1.3.1
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 +1 -1
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +4 -4
- package/src/saas/internal-api/compliance/api/audit/audit.setup.js +8 -8
- package/src/saas/internal-api/compliance/api/waive/waive.api.js +2 -2
- package/src/saas/internal-api/compliance/api/waive/waive.setup.js +2 -2
- package/src/saas/internal-api/contractors/api/contractors.api.js +2 -2
- package/src/saas/internal-api/contractors/api/contractors.setup.js +4 -4
- package/src/saas/internal-api/contractors/models/create.contractor.model.js +3 -4
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +14 -8
- package/src/saas/internal-api/globalRecord/api/global.record.setup.js +14 -9
- package/src/saas/internal-api/globalRecord/consts.js +20 -0
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +12 -14
- package/src/saas/internal-api/globalRecord/utils/util.js +124 -0
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ const Endpoints = {
|
|
|
12
12
|
|
|
13
13
|
const audit = async (contractorId, auditRequestModel, context) => {
|
|
14
14
|
await requests.getRequestHandler(Endpoints.preAudit(contractorId), {}, context);
|
|
15
|
-
return requests.postRequestHandler(Endpoints.audit, auditRequestModel, context)
|
|
15
|
+
return requests.postRequestHandler(Endpoints.audit, auditRequestModel, context);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const isReaudit = (contractorId, context) => {
|
|
@@ -20,15 +20,15 @@ const isReaudit = (contractorId, context) => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const getAuditorContractorList = (page, accountId, context) => {
|
|
23
|
-
return requests.getRequestHandler(Endpoints.auditorContractorList, { page, accountId }, context)
|
|
23
|
+
return requests.getRequestHandler(Endpoints.auditorContractorList, { page, accountId }, context);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const getContractorDetailsForAudit = (contractorId, context) => {
|
|
27
|
-
return requests.getRequestHandler(Endpoints.contractorDetailsForAudit(contractorId), {}, context)
|
|
27
|
+
return requests.getRequestHandler(Endpoints.contractorDetailsForAudit(contractorId), {}, context);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const getRequirementDetailsForAudit = (contractorId, context) => {
|
|
31
|
-
return requests.getRequestHandler(Endpoints.requirementDetailsForAudit(contractorId), {}, context)
|
|
31
|
+
return requests.getRequestHandler(Endpoints.requirementDetailsForAudit(contractorId), {}, context);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
module.exports = {
|
|
@@ -2,25 +2,25 @@ const auditApi = require('./audit.api');
|
|
|
2
2
|
const { AuditRequestModel } = require('../../models/audit/audit.model');
|
|
3
3
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
4
4
|
|
|
5
|
-
const audit =
|
|
5
|
+
const audit = (auditRequestModel, context) => {
|
|
6
6
|
validateType(auditRequestModel, AuditRequestModel);
|
|
7
|
-
return
|
|
7
|
+
return auditApi.audit(auditRequestModel.auditData.contractorId, auditRequestModel, context);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const isReaudit = (contractorId, context) => {
|
|
11
11
|
return auditApi.isReaudit(contractorId, context);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const getAuditorContractorList =
|
|
15
|
-
return
|
|
14
|
+
const getAuditorContractorList = (page, accountId, context) => {
|
|
15
|
+
return auditApi.getAuditorContractorList(page, accountId, context);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const getContractorDetailsForAudit =
|
|
19
|
-
return
|
|
18
|
+
const getContractorDetailsForAudit = (contractorId, context) => {
|
|
19
|
+
return auditApi.getContractorDetailsForAudit(contractorId, context);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const getRequirementDetailsForAudit =
|
|
23
|
-
return
|
|
22
|
+
const getRequirementDetailsForAudit = (contractorId, context) => {
|
|
23
|
+
return auditApi.getRequirementDetailsForAudit(contractorId, context);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
module.exports = {
|
|
@@ -9,13 +9,13 @@ const Endpoints = {
|
|
|
9
9
|
const waive = async (contractorId, waiveRequestModel, context) => {
|
|
10
10
|
const status = waiveRequestModel.status;
|
|
11
11
|
delete waiveRequestModel.status;
|
|
12
|
-
return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status })
|
|
12
|
+
return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status });
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const retract = async (contractorId, retractRequestModel, context) => {
|
|
16
16
|
const status = retractRequestModel.status;
|
|
17
17
|
delete retractRequestModel.status;
|
|
18
|
-
return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status })
|
|
18
|
+
return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status });
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
module.exports = { waive, retract };
|
|
@@ -2,12 +2,12 @@ const waiveApi = require('./waive.api');
|
|
|
2
2
|
const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
|
|
3
3
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
4
4
|
|
|
5
|
-
const waive =
|
|
5
|
+
const waive = (waiveRequestModel, context) => {
|
|
6
6
|
validateType(waiveRequestModel, WaiveRequestModel);
|
|
7
7
|
return waiveApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const retract =
|
|
10
|
+
const retract = (retractRequestModel, context) => {
|
|
11
11
|
validateType(retractRequestModel, RetractRequestModel);
|
|
12
12
|
return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
|
|
13
13
|
};
|
|
@@ -13,7 +13,7 @@ const Endpoints = {
|
|
|
13
13
|
assignMptToProperties: (accountId, tenantId) => `${backendUrl}/saas/account/${accountId}/multi-properties/${tenantId}`
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const createContractor = async (createContractorModel, context) => {
|
|
17
17
|
return requests.postRequestHandler(Endpoints.create, createContractorModel, context).then(res => res.data || res);
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -66,7 +66,7 @@ const getContractorsByTabId = async (tabId, context, activityStatus) => {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
module.exports = {
|
|
69
|
-
|
|
69
|
+
createContractor,
|
|
70
70
|
getContractorsByAccountId,
|
|
71
71
|
getContractorById,
|
|
72
72
|
deleteByContractorId,
|
|
@@ -3,9 +3,9 @@ const { CreateContractorModel } = require('../models/create.contractor.model');
|
|
|
3
3
|
const { ContractorModel, MptModel } = require('../models/edit.contractor.model');
|
|
4
4
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
validateType(
|
|
8
|
-
return contractorsAPI.
|
|
6
|
+
const createContractor = async (createContractorModel, context) => {
|
|
7
|
+
validateType(createContractorModel, CreateContractorModel);
|
|
8
|
+
return contractorsAPI.createContractor(createContractorModel, context);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const getContractorsByAccountId = async (accountId, context, activationStatus = null) => {
|
|
@@ -51,7 +51,7 @@ const assignMptToProperties = (assignToMptModel, context) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
module.exports = {
|
|
54
|
-
|
|
54
|
+
createContractor,
|
|
55
55
|
getContractorsByAccountId,
|
|
56
56
|
getContractorById,
|
|
57
57
|
deleteByContractorId,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
2
|
|
|
3
|
-
function CreateContractorModel(requirementId, inviterEmail,
|
|
3
|
+
function CreateContractorModel(requirementId, inviterEmail, vendorInfo, { tabId = null, disableMail = true, sendCovid19Form = false } = {}) {
|
|
4
4
|
this.reqId = requirementId;
|
|
5
5
|
this.inviterEmail = inviterEmail;
|
|
6
|
-
this.vendorInfo =
|
|
6
|
+
this.vendorInfo = vendorInfo;
|
|
7
7
|
this.disableMail = disableMail;
|
|
8
8
|
this.sendCovid19Form = sendCovid19Form;
|
|
9
9
|
this.tabId = tabId;
|
|
10
10
|
|
|
11
|
-
validateType(
|
|
12
|
-
vendorsInfo && validateType(vendorsInfo[0], ContractorInfo);
|
|
11
|
+
vendorInfo && validateType(vendorInfo, ContractorInfo);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
function ContractorInfo(email, companyName, additionalEmails) {
|
|
@@ -7,9 +7,10 @@ const Endpoints = {
|
|
|
7
7
|
createGlobalRecord: `${nodeBackendUrl}/global-record`,
|
|
8
8
|
getGlobalRecordById: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
9
9
|
getAllGlobalRecords: (pageNumber, itemsInPage) => `${nodeBackendUrl}/global-record/all-global-records/${pageNumber}/items/${itemsInPage}`,
|
|
10
|
-
|
|
10
|
+
getGlobalRecordServiceAreas: `${backendUrl}/saas/global-record/service-areas`,
|
|
11
11
|
deleteGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
12
|
-
updateGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}
|
|
12
|
+
updateGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
13
|
+
getRecordProfileDetails: id => `${nodeBackendUrl}/global-record/record-profile/id/${id}`
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const getGlobalRecord = async (id, nodeBackendSecret) => {
|
|
@@ -24,23 +25,28 @@ const getAllGlobalRecords = async (data, pageNumber, itemsInPage, context) => {
|
|
|
24
25
|
return cookieAuthRequests.postRequestHandler(Endpoints.getAllGlobalRecords(pageNumber, itemsInPage), data, context);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
const deleteGlobalRecord = async (id,
|
|
28
|
-
return
|
|
28
|
+
const deleteGlobalRecord = async (id, nodeBackendSecret) => {
|
|
29
|
+
return apiKeyAuthRequests.deleteRequestHandler(Endpoints.deleteGlobalRecord(id), nodeBackendSecret);
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
const updateGlobalRecord = async (id, nodeBackendSecret, updatedGlobalRecord) => {
|
|
32
33
|
return apiKeyAuthRequests.putRequestHandler(Endpoints.updateGlobalRecord(id), nodeBackendSecret, updatedGlobalRecord);
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const
|
|
36
|
-
return cookieAuthRequests.getRequestHandler(Endpoints.
|
|
36
|
+
const getGlobalRecordServiceAreas = async context => {
|
|
37
|
+
return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordServiceAreas, {}, context);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getRecordProfileDetails = async (id, context) => {
|
|
41
|
+
return cookieAuthRequests.getRequestHandler(Endpoints.getRecordProfileDetails(id), {}, context);
|
|
37
42
|
};
|
|
38
43
|
|
|
39
44
|
module.exports = {
|
|
40
45
|
createGlobalRecord,
|
|
41
46
|
getGlobalRecord,
|
|
42
47
|
getAllGlobalRecords,
|
|
43
|
-
|
|
48
|
+
getGlobalRecordServiceAreas,
|
|
44
49
|
deleteGlobalRecord,
|
|
45
|
-
updateGlobalRecord
|
|
50
|
+
updateGlobalRecord,
|
|
51
|
+
getRecordProfileDetails
|
|
46
52
|
};
|
|
@@ -17,8 +17,8 @@ const getAllGlobalRecordsInPage = async (pageNumber, context, itemsInPage = 10)
|
|
|
17
17
|
return globalRecordAPI.getAllGlobalRecords(param, pageNumber, itemsInPage, context);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
const data = Array.isArray(
|
|
20
|
+
const getAllGlobalRecordsInPageByServiceAreas = async (serviceAreas, pageNumber, contxet, itemsInPage = 10) => {
|
|
21
|
+
const data = Array.isArray(serviceAreas) ? { serviceAreas } : { serviceAreas: new Array(serviceAreas) };
|
|
22
22
|
return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage, contxet);
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -32,26 +32,31 @@ const getAllGlobalRecordsInPageByCombinedSearch = async (combinedSearch, pageNum
|
|
|
32
32
|
return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage, context);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const
|
|
36
|
-
return globalRecordAPI.
|
|
35
|
+
const getGlobalRecordServiceAreas = async context => {
|
|
36
|
+
return globalRecordAPI.getGlobalRecordServiceAreas(context);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const deleteGlobalRecord = async
|
|
40
|
-
return globalRecordAPI.deleteGlobalRecord(id,
|
|
39
|
+
const deleteGlobalRecord = async id => {
|
|
40
|
+
return globalRecordAPI.deleteGlobalRecord(id, nodeBackendSecret);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const updateGlobalRecord = async (id, updatedGlobalRecordModel) => {
|
|
44
44
|
return globalRecordAPI.updateGlobalRecord(id, nodeBackendSecret, updatedGlobalRecordModel);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
const getRecordProfileDetails = async (id, context) => {
|
|
48
|
+
return globalRecordAPI.getRecordProfileDetails(id, context);
|
|
49
|
+
};
|
|
50
|
+
|
|
47
51
|
module.exports = {
|
|
48
52
|
createGlobalRecord,
|
|
49
53
|
getGlobalRecordById,
|
|
50
54
|
getAllGlobalRecordsInPage,
|
|
51
|
-
|
|
55
|
+
getAllGlobalRecordsInPageByServiceAreas,
|
|
52
56
|
getAllGlobalRecordsInPageBySearchTerm,
|
|
53
57
|
getAllGlobalRecordsInPageByCombinedSearch,
|
|
54
|
-
|
|
58
|
+
getGlobalRecordServiceAreas,
|
|
55
59
|
deleteGlobalRecord,
|
|
56
|
-
updateGlobalRecord
|
|
60
|
+
updateGlobalRecord,
|
|
61
|
+
getRecordProfileDetails
|
|
57
62
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const SERVICE_AREAS = {
|
|
2
|
+
'alabama': 'Alabama',
|
|
3
|
+
'arizona': 'Arizona',
|
|
4
|
+
'arkansas': 'Arkansas',
|
|
5
|
+
'california': 'California',
|
|
6
|
+
'connecticut': 'Connecticut',
|
|
7
|
+
'delaware': 'Delaware',
|
|
8
|
+
'florida': 'Florida',
|
|
9
|
+
'illinois': 'Illinois',
|
|
10
|
+
'newYork': 'New York',
|
|
11
|
+
'newJersey': 'New Jersey'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const GLOBAL_RECORD_STATUS = {
|
|
15
|
+
newGlobal: 'New Global',
|
|
16
|
+
newInfo: 'New Info',
|
|
17
|
+
published: 'Published'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports = { SERVICE_AREAS, GLOBAL_RECORD_STATUS };
|
|
@@ -2,35 +2,33 @@ class CreateGlobalRecordModel {
|
|
|
2
2
|
constructor(
|
|
3
3
|
header,
|
|
4
4
|
expirationDate,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
glPolicyNumbers,
|
|
6
|
+
numberOfAssociatedRequests,
|
|
7
7
|
numberOfFilledMandatory,
|
|
8
8
|
{
|
|
9
9
|
recordName,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
additionalContacts,
|
|
11
|
+
brokerEmails,
|
|
12
12
|
publishDate,
|
|
13
|
-
|
|
14
|
-
serviceArea,
|
|
13
|
+
serviceAreas,
|
|
15
14
|
primaryEmail,
|
|
16
15
|
dba,
|
|
17
|
-
|
|
16
|
+
lastPublishUserName
|
|
18
17
|
} = {}
|
|
19
18
|
) {
|
|
20
19
|
this.header = header;
|
|
21
20
|
this.recordName = recordName;
|
|
22
|
-
this.
|
|
21
|
+
this.additionalContacts = additionalContacts;
|
|
23
22
|
this.expirationDate = expirationDate;
|
|
24
23
|
this.publishDate = publishDate;
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.brokerEmail = brokerEmail;
|
|
24
|
+
this.glPolicyNumbers = glPolicyNumbers;
|
|
25
|
+
this.numberOfAssociatedRequests = numberOfAssociatedRequests;
|
|
26
|
+
this.brokerEmails = brokerEmails;
|
|
29
27
|
this.numberOfFilledMandatory = numberOfFilledMandatory;
|
|
30
|
-
this.
|
|
28
|
+
this.serviceAreas = serviceAreas;
|
|
31
29
|
this.primaryEmail = primaryEmail;
|
|
32
30
|
this.dba = dba;
|
|
33
|
-
this.
|
|
31
|
+
this.lastPublishUserName = lastPublishUserName;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const env = require('../../../../../../../src/env');
|
|
2
|
+
const { internalAPI } = require('../../../..')(env);
|
|
3
|
+
const { globalRecord } = internalAPI;
|
|
4
|
+
|
|
5
|
+
const { CreateGlobalRecordModel } = globalRecord.models;
|
|
6
|
+
const { createGlobalRecord, getAllGlobalRecordsInPage } = globalRecord.services;
|
|
7
|
+
|
|
8
|
+
const { getCapitalLetterUnicodeValueList, getUniqueNumber } = require('../../../../../../../src/utils/numberUtils');
|
|
9
|
+
|
|
10
|
+
const { SERVICE_AREAS } = require('../consts');
|
|
11
|
+
|
|
12
|
+
const createGlobalRecordConfig = (name, { stateIndex, glPolicyNumbers } = {}) => {
|
|
13
|
+
const serviceArea = getServiceAreaByIndex(stateIndex || 0);
|
|
14
|
+
const uniqueNumbers = glPolicyNumbers || getUniqueNumber();
|
|
15
|
+
const emailBase = name.replace(/\s+/g, '').toLowerCase();
|
|
16
|
+
return {
|
|
17
|
+
'header': `${name}Header`,
|
|
18
|
+
'recordName': `${name}Name`,
|
|
19
|
+
'additionalContacts': [`${emailBase}@additional1.jon`, `${emailBase}@additional2.jon`],
|
|
20
|
+
'brokerEmails': [`${emailBase}@broker1.jon`, `${emailBase}@broker2.jon`],
|
|
21
|
+
'expirationDate': '2030-12-09',
|
|
22
|
+
'publishDate': '',
|
|
23
|
+
'lastPublishUserName': '',
|
|
24
|
+
'glPolicyNumbers': [uniqueNumbers.toString()],
|
|
25
|
+
'numberOfAssociatedRequests': 0,
|
|
26
|
+
'numberOfFilledMandatory': 0,
|
|
27
|
+
'dba': '',
|
|
28
|
+
'primaryEmail': '',
|
|
29
|
+
'serviceAreas': [
|
|
30
|
+
getServiceArea(serviceArea)
|
|
31
|
+
]
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getServiceArea = state => {
|
|
36
|
+
return {
|
|
37
|
+
'city': `${state}TestCity`,
|
|
38
|
+
'state': state
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const createGlobalRecordConfigs = (nameList, { stateIndexes, glPolicyNumbers } = {}) => {
|
|
43
|
+
return nameList.map((name, index) => createGlobalRecordConfig(
|
|
44
|
+
name,
|
|
45
|
+
{
|
|
46
|
+
stateIndex: stateIndexes ? stateIndexes[index] : index,
|
|
47
|
+
glPolicyNumbers: glPolicyNumbers ? glPolicyNumbers[index] : null
|
|
48
|
+
}
|
|
49
|
+
));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const createGlobalRecordModel = config => {
|
|
53
|
+
return new CreateGlobalRecordModel(
|
|
54
|
+
config.header,
|
|
55
|
+
config.expirationDate,
|
|
56
|
+
config.glPolicyNumbers,
|
|
57
|
+
config.numberOfAssociatedRequests,
|
|
58
|
+
config.numberOfFilledMandatory,
|
|
59
|
+
{
|
|
60
|
+
recordName: config.recordName,
|
|
61
|
+
additionalContacts: config.additionalContacts,
|
|
62
|
+
brokerEmails: config.brokerEmails,
|
|
63
|
+
publishDate: config.publishDate,
|
|
64
|
+
serviceAreas: config.serviceAreas,
|
|
65
|
+
primaryEmail: config.primaryEmail,
|
|
66
|
+
dba: config.dba,
|
|
67
|
+
lastPublishUserName: config.lastPublishUserName
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const createGlobalRecordModels = configList => {
|
|
73
|
+
return configList.map(config => createGlobalRecordModel(config));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const getCreateRandomGlobalRecordModels = nameList => {
|
|
77
|
+
const configList = createGlobalRecordConfigs(nameList);
|
|
78
|
+
return createGlobalRecordModels(configList);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const createGlobalRecords = async (globalRecordModelList, context) => {
|
|
82
|
+
const newGlobalRecodDetailsList = new Array();
|
|
83
|
+
for (globalRecordModel of globalRecordModelList) {
|
|
84
|
+
const newGlobalRecordDetails = await createGlobalRecord(globalRecordModel, context);
|
|
85
|
+
newGlobalRecodDetailsList.push(newGlobalRecordDetails);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return newGlobalRecodDetailsList;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const getAllGlobalRecords = async (numberOfPages, context) => {
|
|
92
|
+
const allGlobalRecords = new Array();
|
|
93
|
+
|
|
94
|
+
for (let pageNumber = 1; pageNumber <= numberOfPages; pageNumber++) {
|
|
95
|
+
const allGlobalRecordsInPage = await getAllGlobalRecordsInPage(pageNumber, context);
|
|
96
|
+
allGlobalRecords.push(allGlobalRecordsInPage);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return allGlobalRecords;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const getServiceAreaByIndex = stateIndex => {
|
|
103
|
+
return SERVICE_AREAS[Object.keys(SERVICE_AREAS)[stateIndex % 10]];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const getGlobalRecordsDefaultNameList = (nameBase, listLength) => {
|
|
107
|
+
const letterUnicodeValueList = getCapitalLetterUnicodeValueList({ listLength });
|
|
108
|
+
|
|
109
|
+
//How much times same letter will appear in one index on the array
|
|
110
|
+
const repeatTimes = 4;
|
|
111
|
+
return letterUnicodeValueList.map(unicode => `${nameBase} ${String.fromCharCode(unicode).repeat(repeatTimes)}`);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
module.exports = {
|
|
115
|
+
createGlobalRecords,
|
|
116
|
+
createGlobalRecordConfig,
|
|
117
|
+
createGlobalRecordConfigs,
|
|
118
|
+
createGlobalRecordModel,
|
|
119
|
+
createGlobalRecordModels,
|
|
120
|
+
getCreateRandomGlobalRecordModels,
|
|
121
|
+
getGlobalRecordsDefaultNameList,
|
|
122
|
+
getAllGlobalRecords,
|
|
123
|
+
getServiceArea
|
|
124
|
+
};
|