@getjones/test-infra 2.6.1 → 2.6.3

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.
Files changed (149) hide show
  1. package/package.json +29 -30
  2. package/src/common/commonFlows/index.js +3 -3
  3. package/src/common/commonFlows/records/records.js +71 -71
  4. package/src/common/consts/userTypes.js +5 -0
  5. package/src/common/httpResponseStatusCodes.json +11 -11
  6. package/src/common/requests/apiKeyAuth/requests.js +38 -38
  7. package/src/common/requests/cookieAuth/requests.js +40 -40
  8. package/src/common/requests/requestHandlers.js +60 -60
  9. package/src/common/utils/dataTypeUtils.js +41 -41
  10. package/src/common/utils/numberUtils.js +22 -22
  11. package/src/common/utils/objectUtils.js +7 -9
  12. package/src/common/utils/timeUtils.js +171 -171
  13. package/src/common/validations/errorValidation.js +16 -16
  14. package/src/common/validations/typeValidations.js +36 -36
  15. package/src/defaults/configs/auditConfigs.js +85 -85
  16. package/src/defaults/configs/polices.js +47 -47
  17. package/src/defaults/configs/requirement.js +29 -29
  18. package/src/defaults/index.js +5 -5
  19. package/src/env.js +57 -57
  20. package/src/factory/index.js +5 -0
  21. package/src/factory/records/records.js +105 -0
  22. package/src/index.js +74 -73
  23. package/src/resources/coi/coi.pdf +0 -0
  24. package/src/resources/coi/realCoi.pdf +5617 -20
  25. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  26. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
  27. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  28. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  29. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  30. package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
  31. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  32. package/src/saas/internal-api/accounts/index.js +21 -21
  33. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  34. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -23
  35. package/src/saas/internal-api/accounts/utils/utils.js +32 -32
  36. package/src/saas/internal-api/auth/api/auth.api.js +18 -18
  37. package/src/saas/internal-api/auth/api/auth.service.js +67 -67
  38. package/src/saas/internal-api/auth/index.js +3 -3
  39. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  40. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  41. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -7
  42. package/src/saas/internal-api/coi/index.js +13 -13
  43. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  44. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  45. package/src/saas/internal-api/compliance/api/audit/audit.api.js +40 -40
  46. package/src/saas/internal-api/compliance/api/audit/audit.service.js +152 -151
  47. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  48. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  49. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  50. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
  51. package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
  52. package/src/saas/internal-api/compliance/api/waive/waive.service.js +100 -15
  53. package/src/saas/internal-api/compliance/consts/audit.js +71 -81
  54. package/src/saas/internal-api/compliance/index.js +28 -28
  55. package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
  56. package/src/saas/internal-api/compliance/models/waive/waive.model.js +48 -45
  57. package/src/saas/internal-api/compliance/utils/util.js +207 -175
  58. package/src/saas/internal-api/contractors/api/contractors.api.js +141 -141
  59. package/src/saas/internal-api/contractors/api/contractors.service.js +147 -147
  60. package/src/saas/internal-api/contractors/index.js +8 -8
  61. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  62. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
  63. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  64. package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -12
  65. package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -7
  66. package/src/saas/internal-api/dashboardInnerPage/index.js +5 -5
  67. package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -38
  68. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  69. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
  70. package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
  71. package/src/saas/internal-api/dbEmails/index.js +4 -4
  72. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
  73. package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
  74. package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
  75. package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
  76. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  77. package/src/saas/internal-api/globalRecord/index.js +6 -6
  78. package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
  79. package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
  80. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  81. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  82. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  83. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  84. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  85. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  86. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
  87. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  88. package/src/saas/internal-api/projects/index.js +24 -24
  89. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  90. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  91. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
  92. package/src/saas/internal-api/projects/utils/utils.js +82 -82
  93. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  94. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  95. package/src/saas/internal-api/recordNotes/index.js +3 -3
  96. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  97. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  98. package/src/saas/internal-api/reports/consts/consts.js +63 -63
  99. package/src/saas/internal-api/reports/index.js +15 -15
  100. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  101. package/src/saas/internal-api/requests/api/requests.api.js +54 -54
  102. package/src/saas/internal-api/requests/api/requests.service.js +84 -51
  103. package/src/saas/internal-api/requests/index.js +14 -14
  104. package/src/saas/internal-api/requests/models/create.request.model.js +22 -22
  105. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  106. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  107. package/src/saas/internal-api/requests/utils.js +8 -8
  108. package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
  109. package/src/saas/internal-api/requirements/api/requirements.service.js +94 -94
  110. package/src/saas/internal-api/requirements/consts/attributeTypes.json +5 -5
  111. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  112. package/src/saas/internal-api/requirements/index.js +8 -8
  113. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  114. package/src/saas/internal-api/requirements/models/policy.model.js +32 -32
  115. package/src/saas/internal-api/requirements/models/update.requirement.model.js +21 -21
  116. package/src/saas/internal-api/requirements/utils/utils.js +101 -101
  117. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  118. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  119. package/src/saas/internal-api/serviceArea/index.js +4 -4
  120. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  121. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  122. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  123. package/src/saas/internal-api/tabs/index.js +3 -3
  124. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  125. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  126. package/src/saas/internal-api/users/api/users.api.js +77 -77
  127. package/src/saas/internal-api/users/api/users.service.js +101 -101
  128. package/src/saas/internal-api/users/index.js +4 -4
  129. package/src/saas/internal-api/users/models/users.model.js +31 -31
  130. package/src/saas/internal-api/users/utils/util.js +14 -14
  131. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  132. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  133. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  134. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  135. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  136. package/src/saas/openapi/projects/projects.api.js +59 -59
  137. package/src/saas/openapi/projects/projects.service.js +44 -44
  138. package/src/saas/openapi/requests/index.js +6 -6
  139. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  140. package/src/saas/openapi/requests/requests.api.js +20 -20
  141. package/src/saas/openapi/requests/requests.service.js +18 -18
  142. package/src/saas/openapi/requirements/index.js +6 -6
  143. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  144. package/src/saas/openapi/requirements/requirements.api.js +12 -12
  145. package/src/saas/openapi/requirements/requirements.service.js +20 -20
  146. package/src/saas/openapi/tabs/tabs.api.js +13 -13
  147. package/src/saas/openapi/tabs/tabs.service.js +7 -7
  148. package/tests/env.test.js +40 -40
  149. package/tests/validation.test.js +83 -83
@@ -1,28 +1,28 @@
1
- const requests = require('../../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- getAccount: `${backendUrl}/saas/accounts`,
6
- create: `${backendUrl}/saas/createaccount`,
7
- delete: `${backendUrl}/saas/account`,
8
- edit: accountId => `${backendUrl}/saas/account/${accountId}/settings`
9
- };
10
-
11
- const create = (account, context) => {
12
- return requests.postRequestHandler(Endpoints.create, account, context);
13
- };
14
-
15
- const deleteAccount = (accountId, context) => {
16
- return requests.deleteRequestHandler(Endpoints.delete, context, {}, { 'userId': accountId });
17
- };
18
-
19
- const updateAccountSettings = (accountId, settings, context) => {
20
- return requests.putRequestHandler(Endpoints.edit(accountId), { accountId, ... settings }, context);
21
- };
22
-
23
- const getByName = (accountName, context) => {
24
- const params = { name: accountName };
25
- return requests.getRequestHandler(Endpoints.getAccount, params, context);
26
- };
27
-
28
- module.exports = { create, getByName, deleteAccount, updateAccountSettings };
1
+ const requests = require('../../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ getAccount: `${backendUrl}/saas/accounts`,
6
+ create: `${backendUrl}/saas/createaccount`,
7
+ delete: `${backendUrl}/saas/account`,
8
+ edit: accountId => `${backendUrl}/saas/account/${accountId}/settings`
9
+ };
10
+
11
+ const create = (account, context) => {
12
+ return requests.postRequestHandler(Endpoints.create, account, context);
13
+ };
14
+
15
+ const deleteAccount = (accountId, context) => {
16
+ return requests.deleteRequestHandler(Endpoints.delete, context, {}, { 'userId': accountId });
17
+ };
18
+
19
+ const updateAccountSettings = (accountId, settings, context) => {
20
+ return requests.putRequestHandler(Endpoints.edit(accountId), { accountId, ... settings }, context);
21
+ };
22
+
23
+ const getByName = (accountName, context) => {
24
+ const params = { name: accountName };
25
+ return requests.getRequestHandler(Endpoints.getAccount, params, context);
26
+ };
27
+
28
+ module.exports = { create, getByName, deleteAccount, updateAccountSettings };
@@ -1,77 +1,77 @@
1
- const env = require('../../../../../env');
2
- const accountsAPI = require('./accounts.core.api');
3
- const CreateAccountModel = require('../../models/core/create.account.model');
4
- const { validateType } = require('../../../../../common/validations/typeValidations');
5
-
6
- const { accountCreationSecret } = env.getEnv();
7
-
8
- const createAccount = async (createAccountModel, context) => {
9
- validateType(createAccountModel, CreateAccountModel);
10
-
11
- env.requiredValidation({
12
- accountCreationSecret: accountCreationSecret,
13
- 'credentials.strongPassword': createAccountModel.password
14
- });
15
-
16
- return accountsAPI.create(createAccountModel, context);
17
- };
18
-
19
- const getAccount = async (accountName, context) => {
20
- const response = await accountsAPI.getByName(accountName, context);
21
-
22
- if (!response.data || !response.data.length) {
23
- return null;
24
- }
25
-
26
- if (response.data.length > 1) {
27
- throw new Error(`Got more than one account with the name: ${accountName}. IDs: ${existingAccounts.map(item => item.userId).join(', ')}`);
28
- }
29
-
30
- return response.data[0];
31
- };
32
-
33
- const getOrCreateAccount = async (createAccountModel, context) => {
34
- validateType(createAccountModel, CreateAccountModel);
35
- const existingAccount = await getAccount(createAccountModel.companyName, context);
36
-
37
- if (existingAccount) {
38
- return existingAccount;
39
- }
40
-
41
- const response = await accountsAPI.create(createAccountModel, context);
42
-
43
- if (!response.data) {
44
- throw new Error(`Account by the name ${createAccountModel.companyName} was not created`);
45
- }
46
-
47
- return response.data;
48
- };
49
-
50
- const getAccountId = async (accountName, context) => {
51
- const account = await getAccount(accountName, context);
52
-
53
- if (!account) {
54
- console.error(`Account ${accountName} does not exist`);
55
- return null;
56
- }
57
-
58
- return account.userId;
59
- };
60
-
61
- const deleteAccountByName = async (accountName, context) => {
62
- const accountId = await getAccountId(accountName, context);
63
- return accountsAPI.deleteAccount(accountId, context);
64
- };
65
-
66
- const deleteAccountById = async (accountId, context) => {
67
- return accountsAPI.deleteAccount(accountId, context);
68
- };
69
-
70
- module.exports = {
71
- getAccount,
72
- getOrCreateAccount,
73
- getAccountId,
74
- createAccount,
75
- deleteAccountByName,
76
- deleteAccountById
77
- };
1
+ const env = require('../../../../../env');
2
+ const accountsAPI = require('./accounts.core.api');
3
+ const CreateAccountModel = require('../../models/core/create.account.model');
4
+ const { validateType } = require('../../../../../common/validations/typeValidations');
5
+
6
+ const { accountCreationSecret } = env.getEnv();
7
+
8
+ const createAccount = async (createAccountModel, context) => {
9
+ validateType(createAccountModel, CreateAccountModel);
10
+
11
+ env.requiredValidation({
12
+ accountCreationSecret: accountCreationSecret,
13
+ 'credentials.strongPassword': createAccountModel.password
14
+ });
15
+
16
+ return accountsAPI.create(createAccountModel, context);
17
+ };
18
+
19
+ const getAccount = async (accountName, context) => {
20
+ const response = await accountsAPI.getByName(accountName, context);
21
+
22
+ if (!response.data || !response.data.length) {
23
+ return null;
24
+ }
25
+
26
+ if (response.data.length > 1) {
27
+ throw new Error(`Got more than one account with the name: ${accountName}. IDs: ${existingAccounts.map(item => item.userId).join(', ')}`);
28
+ }
29
+
30
+ return response.data[0];
31
+ };
32
+
33
+ const getOrCreateAccount = async (createAccountModel, context) => {
34
+ validateType(createAccountModel, CreateAccountModel);
35
+ const existingAccount = await getAccount(createAccountModel.companyName, context);
36
+
37
+ if (existingAccount) {
38
+ return existingAccount;
39
+ }
40
+
41
+ const response = await accountsAPI.create(createAccountModel, context);
42
+
43
+ if (!response.data) {
44
+ throw new Error(`Account by the name ${createAccountModel.companyName} was not created`);
45
+ }
46
+
47
+ return response.data;
48
+ };
49
+
50
+ const getAccountId = async (accountName, context) => {
51
+ const account = await getAccount(accountName, context);
52
+
53
+ if (!account) {
54
+ console.error(`Account ${accountName} does not exist`);
55
+ return null;
56
+ }
57
+
58
+ return account.userId;
59
+ };
60
+
61
+ const deleteAccountByName = async (accountName, context) => {
62
+ const accountId = await getAccountId(accountName, context);
63
+ return accountsAPI.deleteAccount(accountId, context);
64
+ };
65
+
66
+ const deleteAccountById = async (accountId, context) => {
67
+ return accountsAPI.deleteAccount(accountId, context);
68
+ };
69
+
70
+ module.exports = {
71
+ getAccount,
72
+ getOrCreateAccount,
73
+ getAccountId,
74
+ createAccount,
75
+ deleteAccountByName,
76
+ deleteAccountById
77
+ };
@@ -1,48 +1,48 @@
1
- const requests = require('../../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- createApiKey: `${backendUrl}/saas/api-keys`,
6
- getStaticApiKeyByAccountId: accountId => `${backendUrl}/saas/accounts/${accountId}/static-api-keys`,
7
- getApiKeyByKeyValue: `${backendUrl}/saas/api-keys`,
8
- removeStaticApiKey: accountId => `${backendUrl}/saas/accounts/${accountId}/static-api-keys`,
9
- dynamicApiKey: accountId => `${backendUrl}/saas/accounts/${accountId}/dynamic-api-key`
10
- };
11
-
12
- const createStaticApiKey = (data, context) => {
13
- return requests.postRequestHandler(Endpoints.createApiKey, data, context);
14
- };
15
-
16
- const createGeneratorApiKey = (data, context) => {
17
- return requests.postRequestHandler(Endpoints.createApiKey, data, context);
18
- };
19
-
20
- const getStaticApiKeyByAccountId = (accountId, context) => {
21
- return requests.getRequestHandler(Endpoints.getStaticApiKeyByAccountId(accountId), {}, context);
22
- };
23
-
24
- const getApiKeyDetails = (apiKeyValue, context) => {
25
- return requests.getRequestHandler(Endpoints.getApiKeyByKeyValue, { apiKeyValue }, context);
26
- };
27
-
28
- const deleteStaticApiKey = (accountId, context) => {
29
- return requests.deleteRequestHandler(Endpoints.removeStaticApiKey(accountId), context);
30
- };
31
-
32
- const deleteDynamicApiKey = (accountId, context) => {
33
- return requests.deleteRequestHandler(Endpoints.dynamicApiKey(accountId), context);
34
- };
35
-
36
- const makeDynamicApiKeyExpired = (accountId, context) => {
37
- return requests.patchRequestHandler(Endpoints.dynamicApiKey(accountId), context, {});
38
- };
39
-
40
- module.exports = {
41
- createStaticApiKey,
42
- createGeneratorApiKey,
43
- getStaticApiKeyByAccountId,
44
- getApiKeyDetails,
45
- makeDynamicApiKeyExpired,
46
- deleteStaticApiKey,
47
- deleteDynamicApiKey
48
- };
1
+ const requests = require('../../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ createApiKey: `${backendUrl}/saas/api-keys`,
6
+ getStaticApiKeyByAccountId: accountId => `${backendUrl}/saas/accounts/${accountId}/static-api-keys`,
7
+ getApiKeyByKeyValue: `${backendUrl}/saas/api-keys`,
8
+ removeStaticApiKey: accountId => `${backendUrl}/saas/accounts/${accountId}/static-api-keys`,
9
+ dynamicApiKey: accountId => `${backendUrl}/saas/accounts/${accountId}/dynamic-api-key`
10
+ };
11
+
12
+ const createStaticApiKey = (data, context) => {
13
+ return requests.postRequestHandler(Endpoints.createApiKey, data, context);
14
+ };
15
+
16
+ const createGeneratorApiKey = (data, context) => {
17
+ return requests.postRequestHandler(Endpoints.createApiKey, data, context);
18
+ };
19
+
20
+ const getStaticApiKeyByAccountId = (accountId, context) => {
21
+ return requests.getRequestHandler(Endpoints.getStaticApiKeyByAccountId(accountId), {}, context);
22
+ };
23
+
24
+ const getApiKeyDetails = (apiKeyValue, context) => {
25
+ return requests.getRequestHandler(Endpoints.getApiKeyByKeyValue, { apiKeyValue }, context);
26
+ };
27
+
28
+ const deleteStaticApiKey = (accountId, context) => {
29
+ return requests.deleteRequestHandler(Endpoints.removeStaticApiKey(accountId), context);
30
+ };
31
+
32
+ const deleteDynamicApiKey = (accountId, context) => {
33
+ return requests.deleteRequestHandler(Endpoints.dynamicApiKey(accountId), context);
34
+ };
35
+
36
+ const makeDynamicApiKeyExpired = (accountId, context) => {
37
+ return requests.patchRequestHandler(Endpoints.dynamicApiKey(accountId), context, {});
38
+ };
39
+
40
+ module.exports = {
41
+ createStaticApiKey,
42
+ createGeneratorApiKey,
43
+ getStaticApiKeyByAccountId,
44
+ getApiKeyDetails,
45
+ makeDynamicApiKeyExpired,
46
+ deleteStaticApiKey,
47
+ deleteDynamicApiKey
48
+ };
@@ -1,74 +1,74 @@
1
- const accountsAPI = require('./accounts.openapi.api');
2
- const crypto = require('crypto');
3
-
4
- const generateApiKeyValue = accountName => {
5
- return crypto.createHash('sha256').update(accountName).digest('base64');
6
- };
7
-
8
- const createStaticApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'ACCOUNT_STATIC', apiKeyName = null } = {}) => {
9
- const data = { accountId, apiKeyValue, apiKeyName, apiKeyType };
10
- return accountsAPI.createStaticApiKey(data, context);
11
- };
12
-
13
- const createGeneratorApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'GENERATOR', apiKeyName = null } = {}) => {
14
- const data = { accountId, apiKeyValue, apiKeyName, apiKeyType };
15
- return accountsAPI.createGeneratorApiKey(data, context);
16
- };
17
-
18
- const getStaticApiKeyByAccountId = async (accountId, context) => {
19
- return accountsAPI.getStaticApiKeyByAccountId(accountId, context);
20
- };
21
-
22
- const getApiKeyDetails = async (apiKeyValue, context) => {
23
- return accountsAPI.getApiKeyDetails(apiKeyValue, context);
24
- };
25
-
26
- const deleteStaticApiKey = async (accountId, context) => {
27
- return accountsAPI.deleteStaticApiKey(accountId, context);
28
- };
29
-
30
- const getOrCreateStaticApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'ACCOUNT_STATIC', apiKeyName = null } = {}) => {
31
- let response = await getStaticApiKeyByAccountId(accountId, context);
32
-
33
- if (response.data.apiKeyValue) {
34
- return response.data;
35
- }
36
-
37
- response = await getApiKeyDetails(apiKeyValue, context);
38
-
39
- if (!response.data.apiKeyValue) {
40
- response = await createStaticApiKey(accountId, apiKeyValue, context, { apiKeyType, apiKeyName });
41
- }
42
-
43
- return response.data;
44
- };
45
-
46
- const getOrCreateGeneratorApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'GENERATOR', apiKeyName = null } = {}) => {
47
- const existingApiKey = await getApiKeyDetails(apiKeyValue, context);
48
-
49
- if (!existingApiKey.apiKeyValue) {
50
- return createGeneratorApiKey(accountId, apiKeyValue, context, { apiKeyType, apiKeyName });
51
- }
52
-
53
- return existingApiKey;
54
- };
55
-
56
- const deleteDynamicApiKey = async (accountId, context) => {
57
- return accountsAPI.deleteDynamicApiKey(accountId, context);
58
- };
59
-
60
- const makeDynamicApiKeyExpired = async (accountId, context) => {
61
- return accountsAPI.makeDynamicApiKeyExpired(accountId, context);
62
- };
63
-
64
- module.exports = {
65
- createStaticApiKey,
66
- generateApiKeyValue,
67
- getOrCreateStaticApiKey,
68
- getOrCreateGeneratorApiKey,
69
- getStaticApiKeyByAccountId,
70
- getApiKeyDetails,
71
- makeDynamicApiKeyExpired,
72
- deleteStaticApiKey,
73
- deleteDynamicApiKey
74
- };
1
+ const accountsAPI = require('./accounts.openapi.api');
2
+ const crypto = require('crypto');
3
+
4
+ const generateApiKeyValue = accountName => {
5
+ return crypto.createHash('sha256').update(accountName).digest('base64');
6
+ };
7
+
8
+ const createStaticApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'ACCOUNT_STATIC', apiKeyName = null } = {}) => {
9
+ const data = { accountId, apiKeyValue, apiKeyName, apiKeyType };
10
+ return accountsAPI.createStaticApiKey(data, context);
11
+ };
12
+
13
+ const createGeneratorApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'GENERATOR', apiKeyName = null } = {}) => {
14
+ const data = { accountId, apiKeyValue, apiKeyName, apiKeyType };
15
+ return accountsAPI.createGeneratorApiKey(data, context);
16
+ };
17
+
18
+ const getStaticApiKeyByAccountId = async (accountId, context) => {
19
+ return accountsAPI.getStaticApiKeyByAccountId(accountId, context);
20
+ };
21
+
22
+ const getApiKeyDetails = async (apiKeyValue, context) => {
23
+ return accountsAPI.getApiKeyDetails(apiKeyValue, context);
24
+ };
25
+
26
+ const deleteStaticApiKey = async (accountId, context) => {
27
+ return accountsAPI.deleteStaticApiKey(accountId, context);
28
+ };
29
+
30
+ const getOrCreateStaticApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'ACCOUNT_STATIC', apiKeyName = null } = {}) => {
31
+ let response = await getStaticApiKeyByAccountId(accountId, context);
32
+
33
+ if (response.data.apiKeyValue) {
34
+ return response.data;
35
+ }
36
+
37
+ response = await getApiKeyDetails(apiKeyValue, context);
38
+
39
+ if (!response.data.apiKeyValue) {
40
+ response = await createStaticApiKey(accountId, apiKeyValue, context, { apiKeyType, apiKeyName });
41
+ }
42
+
43
+ return response.data;
44
+ };
45
+
46
+ const getOrCreateGeneratorApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'GENERATOR', apiKeyName = null } = {}) => {
47
+ const existingApiKey = await getApiKeyDetails(apiKeyValue, context);
48
+
49
+ if (!existingApiKey.apiKeyValue) {
50
+ return createGeneratorApiKey(accountId, apiKeyValue, context, { apiKeyType, apiKeyName });
51
+ }
52
+
53
+ return existingApiKey;
54
+ };
55
+
56
+ const deleteDynamicApiKey = async (accountId, context) => {
57
+ return accountsAPI.deleteDynamicApiKey(accountId, context);
58
+ };
59
+
60
+ const makeDynamicApiKeyExpired = async (accountId, context) => {
61
+ return accountsAPI.makeDynamicApiKeyExpired(accountId, context);
62
+ };
63
+
64
+ module.exports = {
65
+ createStaticApiKey,
66
+ generateApiKeyValue,
67
+ getOrCreateStaticApiKey,
68
+ getOrCreateGeneratorApiKey,
69
+ getStaticApiKeyByAccountId,
70
+ getApiKeyDetails,
71
+ makeDynamicApiKeyExpired,
72
+ deleteStaticApiKey,
73
+ deleteDynamicApiKey
74
+ };
@@ -1,21 +1,21 @@
1
- const requests = require('../../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- get: accountId => `${backendUrl}/saas/account/${accountId}/settings`,
6
- edit: accountId => `${backendUrl}/saas/account/${accountId}/settings`
7
- };
8
-
9
- const getAccountSettings = (accountId, context) => {
10
- return requests.getRequestHandler(Endpoints.get(accountId), {}, context);
11
- };
12
-
13
- const updateAccountSettings = (updateAccountSettingsModel, context) => {
14
- const { accountId } = updateAccountSettingsModel;
15
- return requests.putRequestHandler(Endpoints.edit(accountId), updateAccountSettingsModel, context);
16
- };
17
-
18
- module.exports = {
19
- getAccountSettings,
20
- updateAccountSettings
21
- };
1
+ const requests = require('../../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ get: accountId => `${backendUrl}/saas/account/${accountId}/settings`,
6
+ edit: accountId => `${backendUrl}/saas/account/${accountId}/settings`
7
+ };
8
+
9
+ const getAccountSettings = (accountId, context) => {
10
+ return requests.getRequestHandler(Endpoints.get(accountId), {}, context);
11
+ };
12
+
13
+ const updateAccountSettings = (updateAccountSettingsModel, context) => {
14
+ const { accountId } = updateAccountSettingsModel;
15
+ return requests.putRequestHandler(Endpoints.edit(accountId), updateAccountSettingsModel, context);
16
+ };
17
+
18
+ module.exports = {
19
+ getAccountSettings,
20
+ updateAccountSettings
21
+ };
@@ -1,24 +1,24 @@
1
- const accountsAPI = require('./settings.api');
2
- const { validateType } = require('../../../../../common/validations/typeValidations');
3
- const UpdateAccountSettingsModel = require('../../models/settings/update.settings.model');
4
-
5
- const getAccountSettings = (accountId, context) => {
6
- return accountsAPI.getAccountSettings(accountId, context);
7
- };
8
-
9
- const updateAccountSettings = (updateAccountSettingsModel, context) => {
10
- validateType(updateAccountSettingsModel, UpdateAccountSettingsModel);
11
- return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
12
- };
13
-
14
- const restoreAccountSettings = (accountId, context) => {
15
- const [isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit, isAccountRequirementsEnabled] = [false, false, false, false, false, false];
16
- const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit, isAccountRequirementsEnabled);
17
- return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
18
- };
19
-
20
- module.exports = {
21
- getAccountSettings,
22
- updateAccountSettings,
23
- restoreAccountSettings
24
- };
1
+ const accountsAPI = require('./settings.api');
2
+ const { validateType } = require('../../../../../common/validations/typeValidations');
3
+ const UpdateAccountSettingsModel = require('../../models/settings/update.settings.model');
4
+
5
+ const getAccountSettings = (accountId, context) => {
6
+ return accountsAPI.getAccountSettings(accountId, context);
7
+ };
8
+
9
+ const updateAccountSettings = (updateAccountSettingsModel, context) => {
10
+ validateType(updateAccountSettingsModel, UpdateAccountSettingsModel);
11
+ return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
12
+ };
13
+
14
+ const restoreAccountSettings = (accountId, context) => {
15
+ const [isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit, isAccountRequirementsEnabled] = [false, false, false, false, false, false];
16
+ const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit, isAccountRequirementsEnabled);
17
+ return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
18
+ };
19
+
20
+ module.exports = {
21
+ getAccountSettings,
22
+ updateAccountSettings,
23
+ restoreAccountSettings
24
+ };
@@ -1,6 +1,6 @@
1
- const ACCOUNT_TYPES = {
2
- PROPERTY: 'Property Management',
3
- CONSTRUCTION: 'Construction'
4
- };
5
-
6
- module.exports = { ACCOUNT_TYPES };
1
+ const ACCOUNT_TYPES = {
2
+ PROPERTY: 'Property Management',
3
+ CONSTRUCTION: 'Construction'
4
+ };
5
+
6
+ module.exports = { ACCOUNT_TYPES };
@@ -1,21 +1,21 @@
1
- const CreateAccountModel = require('./models/core/create.account.model');
2
- const coreModels = { CreateAccountModel };
3
-
4
- const UpdateAccountSettingsModel = require('./models/settings/update.settings.model');
5
- const settingsModels = { UpdateAccountSettingsModel };
6
-
7
- const models = { core: coreModels, settings: settingsModels };
8
- const utils = require('./utils/utils');
9
- const consts = require('./consts/consts');
10
-
11
- const coreService = require('./api/core/accounts.core.service');
12
- const openApiServices = require('./api/openapi/accounts.openapi.service');
13
- const settingsServices = require('./api/settings/settings.service');
14
-
15
- const services = {
16
- core: coreService,
17
- openApi: openApiServices,
18
- settings: settingsServices
19
- };
20
-
21
- module.exports = { services, models, utils, consts };
1
+ const CreateAccountModel = require('./models/core/create.account.model');
2
+ const coreModels = { CreateAccountModel };
3
+
4
+ const UpdateAccountSettingsModel = require('./models/settings/update.settings.model');
5
+ const settingsModels = { UpdateAccountSettingsModel };
6
+
7
+ const models = { core: coreModels, settings: settingsModels };
8
+ const utils = require('./utils/utils');
9
+ const consts = require('./consts/consts');
10
+
11
+ const coreService = require('./api/core/accounts.core.service');
12
+ const openApiServices = require('./api/openapi/accounts.openapi.service');
13
+ const settingsServices = require('./api/settings/settings.service');
14
+
15
+ const services = {
16
+ core: coreService,
17
+ openApi: openApiServices,
18
+ settings: settingsServices
19
+ };
20
+
21
+ module.exports = { services, models, utils, consts };
@@ -1,16 +1,16 @@
1
- const env = require('../../../../../env');
2
- const { credentials, accountCreationSecret } = env.getEnv();
3
- const { ACCOUNT_TYPES } = require('../../consts/consts');
4
-
5
- class CreateAccountModel {
6
- constructor(accountName, email, password = credentials.strongPassword, propertyType = ACCOUNT_TYPES.PROPERTY) {
7
- this.companyName = accountName;
8
- this.email = email;
9
- this.password = password;
10
- this.verifyPassword = password;
11
- this.userType = propertyType;
12
- this.secret = accountCreationSecret;
13
- }
14
- }
15
-
16
- module.exports = CreateAccountModel;
1
+ const env = require('../../../../../env');
2
+ const { credentials, accountCreationSecret } = env.getEnv();
3
+ const { ACCOUNT_TYPES } = require('../../consts/consts');
4
+
5
+ class CreateAccountModel {
6
+ constructor(accountName, email, password = credentials.strongPassword, propertyType = ACCOUNT_TYPES.PROPERTY) {
7
+ this.companyName = accountName;
8
+ this.email = email;
9
+ this.password = password;
10
+ this.verifyPassword = password;
11
+ this.userType = propertyType;
12
+ this.secret = accountCreationSecret;
13
+ }
14
+ }
15
+
16
+ module.exports = CreateAccountModel;