@getjones/test-infra 1.3.7 → 1.3.8

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.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@ const updateAccountSettings = (updateAccountSettingsModel, context) => {
12
12
  };
13
13
 
14
14
  const restoreAccountSettings = (accountId, context) => {
15
- const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, false, false, false, false);
15
+ const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, false, false, false);
16
16
  return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
17
17
  };
18
18
 
@@ -1,13 +1,11 @@
1
1
  class UpdateAccountSettingsModel {
2
2
  constructor(
3
3
  accountId,
4
- isMultiPropertyTenants,
5
4
  isHighPriority,
6
5
  hasAnalyticsDashboard,
7
6
  isExcludedFromNetwork
8
7
  ) {
9
8
  this.accountId = accountId;
10
- this.isMultiPropertyTenants = isMultiPropertyTenants;
11
9
  this.isHighPriority = isHighPriority;
12
10
  this.hasAnalyticsDashboard = hasAnalyticsDashboard;
13
11
  this.isExcludedFromNetwork = isExcludedFromNetwork;
@@ -4,8 +4,8 @@ const authApi = require('./auth.api');
4
4
 
5
5
  const getAuthCookie = async (email, password) => {
6
6
  try {
7
- const res = await authApi.login(email, password);
8
- const authCookie = res.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
7
+ const response = await authApi.login(email, password);
8
+ const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
9
9
 
10
10
  return authCookie;
11
11
  } catch (error) {
@@ -13,7 +13,7 @@ const getAuthCookie = async (email, password) => {
13
13
  }
14
14
  };
15
15
 
16
- const getIcsCookie = async () => {
16
+ const getIcsCookie = () => {
17
17
  requiredValidation({
18
18
  'credentials.superUser': credentials.superUser,
19
19
  'credentials.superUserPassword': credentials.superUserPassword
@@ -21,7 +21,7 @@ const getIcsCookie = async () => {
21
21
  return getAuthCookie(credentials.superUser, credentials.superUserPassword);
22
22
  };
23
23
 
24
- const getAuditorCookie = async () => {
24
+ const getAuditorCookie = () => {
25
25
  const { auditorUser, auditorPassword } = credentials;
26
26
  requiredValidation({
27
27
  'credentials.auditorUser': auditorUser,
@@ -30,7 +30,7 @@ const getAuditorCookie = async () => {
30
30
  return getAuthCookie(auditorUser, auditorPassword);
31
31
  };
32
32
 
33
- const getOperatorCookie = async () => {
33
+ const getOperatorCookie = () => {
34
34
  const { operatorUser, operatorPassword } = credentials;
35
35
  requiredValidation({
36
36
  'credentials.operatorUser': operatorUser,
@@ -0,0 +1,7 @@
1
+ const UPLOADER_TYPES = {
2
+ ICS: 'ICS',
3
+ PM: 'PM',
4
+ AUDITOR: 'AUDITOR'
5
+ };
6
+
7
+ module.exports = UPLOADER_TYPES;
@@ -1,6 +1,13 @@
1
- const submitCoiModel = require('./models/submit.coi.model');
2
1
  const services = require('./api/coi.service');
3
2
 
4
- const models = { submit: submitCoiModel };
3
+ const models = {
4
+ submit: require('./models/submit.coi.model')
5
+ };
5
6
 
6
- module.exports = { services, models };
7
+ const utils = require('./utils/utils');
8
+
9
+ const consts = {
10
+ UPLOADER_TYPES: require('./consts/uploaderTypes')
11
+ };
12
+
13
+ module.exports = { services, models, utils, consts };
@@ -0,0 +1,48 @@
1
+ const fs = require('fs');
2
+
3
+ const services = require('../api/coi.service');
4
+ const { SubmitCoiModel } = require('../models/submit.coi.model');
5
+
6
+ const uploadFileToStorage = (recordId, filePath) => {
7
+ const fileData = fs.createReadStream(filePath);
8
+ return services.uploadToS3(recordId, fileData);
9
+ };
10
+
11
+ const submitCoiFilesUpload = (recordId, fileIds, uploaderType, uploaderEmail) => {
12
+ const submitCoiModel = new SubmitCoiModel(
13
+ recordId,
14
+ fileIds,
15
+ uploaderType,
16
+ uploaderEmail
17
+ );
18
+ return services.submitCoi(submitCoiModel);
19
+ };
20
+
21
+ const uploadCoi = async (
22
+ recordId,
23
+ filePath,
24
+ uploaderType,
25
+ uploaderEmail,
26
+ {
27
+ markAsScaned, // Should be passed with context
28
+ context
29
+ } = {}
30
+ ) => {
31
+ const uploadResponse = await uploadFileToStorage(recordId, filePath);
32
+ const fileId = uploadResponse.data.fileId;
33
+
34
+ const submitResponse = fileId && await submitCoiFilesUpload(recordId, [fileId], uploaderType, uploaderEmail);
35
+ const uploadedCoi = !!submitResponse.data.fileName && { id: fileId, name: submitResponse.data.fileName };
36
+
37
+ if (uploadedCoi.name && markAsScaned && context) {
38
+ await services.completeScan(recordId, uploadedCoi.name, context);
39
+ }
40
+
41
+ return uploadedCoi;
42
+ };
43
+
44
+ module.exports = {
45
+ uploadCoi,
46
+ uploadFileToStorage,
47
+ submitCoiFilesUpload
48
+ };