@getjones/test-infra 1.7.1 → 1.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,6 @@
1
+ const convertStringToDate = date => {
2
+ const [day, month, year] = date.split('/').map(Number);
3
+ return new Date(year, month - 1, day + 1);
4
+ };
5
+
6
+ module.exports = { convertStringToDate };
@@ -6,7 +6,8 @@ const Endpoints = {
6
6
  delete: projectId => `${backendUrl}/saas/project/${projectId}`,
7
7
  getByAccountId: `${backendUrl}/saas/project/list`,
8
8
  update: `${backendUrl}/saas/project`,
9
- getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`
9
+ getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`,
10
+ getProjectServiceAreaByProjectId: projectId => `${backendUrl}/saas/integration-tests/project/${projectId}/service-area`
10
11
  };
11
12
 
12
13
  const create = (project, context) => {
@@ -31,4 +32,8 @@ const update = (project, context) => {
31
32
  return requests.postRequestHandler(Endpoints.update, project, context);
32
33
  };
33
34
 
34
- module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId };
35
+ const getProjectServiceAreaByProjectId = (projectId, context) => {
36
+ return requests.getRequestHandler(Endpoints.getProjectServiceAreaByProjectId(projectId), {}, context);
37
+ };
38
+
39
+ module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId, getProjectServiceAreaByProjectId };
@@ -17,6 +17,10 @@ const getProjectByName = async (accountId, projectName, context) => {
17
17
  return requestedProject ? requestedProject : null;
18
18
  };
19
19
 
20
+ const getProjectServiceArea = (projectId, context) => {
21
+ return projectsApi.getProjectServiceAreaByProjectId(projectId, context);
22
+ };
23
+
20
24
  const deleteProjectByName = async (accountId, projectName, context) => {
21
25
  const { data: projects } = await getProjectsByAccountId(accountId, context);
22
26
  const filteredProjects = projects.filter(project => project.projectName === projectName);
@@ -56,5 +60,6 @@ module.exports = {
56
60
  getProjectByName,
57
61
  createProject,
58
62
  deleteProjectByName,
59
- updateProject
63
+ updateProject,
64
+ getProjectServiceArea
60
65
  };
@@ -5,7 +5,8 @@ const Endpoints = {
5
5
  generateReportAndSendViaEmail: (accountId, reportType) => `${backendUrl}/saas/ExportXLSXReport/account/${accountId}/${reportType}`,
6
6
  generateReportAndUploadToS3: reportType => `${backendUrl}/saas/integration-tests/ExportXLSXReport/${reportType}`,
7
7
  getScheduledReports: accountId => `${backendUrl}/saas/scheduled-report/account/${accountId}`,
8
- deleteScheduledReport: scheduledReportId => `${backendUrl}/saas/scheduled-report/${scheduledReportId}`
8
+ deleteScheduledReport: scheduledReportId => `${backendUrl}/saas/scheduled-report/${scheduledReportId}`,
9
+ updateScheduledReportLastSentDate: scheduledReportId => `${backendUrl}/saas/automation/scheduled-report/${scheduledReportId}`
9
10
  };
10
11
 
11
12
  const generateReportAndSendViaEmail = (reportFilters, accountId, reportType, context) => {
@@ -24,9 +25,15 @@ const deleteScheduledReport = (scheduledReportId, context) => {
24
25
  return requests.deleteRequestHandler(Endpoints.deleteScheduledReport(scheduledReportId), context);
25
26
  };
26
27
 
28
+ const updateScheduledReportLastSentDate = (scheduledReportId, customLastSentDate, context) => {
29
+ const url = `${Endpoints.updateScheduledReportLastSentDate(scheduledReportId)}?customLastSentDate=${customLastSentDate.toISOString()}`;
30
+ return requests.putRequestHandler(url, {}, context);
31
+ };
32
+
27
33
  module.exports = {
28
34
  generateReportAndSendViaEmail,
29
35
  generateReportAndUploadToS3,
30
36
  getScheduledReports,
31
- deleteScheduledReport
37
+ deleteScheduledReport,
38
+ updateScheduledReportLastSentDate
32
39
  };
@@ -20,9 +20,15 @@ const deleteScheduledReport = (scheduledReportId, context) => {
20
20
  return reportsApi.deleteScheduledReport(scheduledReportId, context);
21
21
  };
22
22
 
23
+ const updateScheduledReportLastSentDate = (scheduledReportId, customLastSentDate, context) => {
24
+ validateType(customLastSentDate, Date);
25
+ return reportsApi.updateScheduledReportLastSentDate(scheduledReportId, customLastSentDate, context);
26
+ };
27
+
23
28
  module.exports = {
24
29
  generateReportAndSendViaEmail,
25
30
  generateReportAndUploadToS3,
26
31
  getScheduledReports,
27
- deleteScheduledReport
32
+ deleteScheduledReport,
33
+ updateScheduledReportLastSentDate
28
34
  };
@@ -22,7 +22,7 @@ const createTab = (tabModel, context) => {
22
22
  };
23
23
 
24
24
  const updateTab = (tabModel, context) => {
25
- return requests.postRequestHandler(Endpoints.update, tabModel, context);
25
+ return requests.putRequestHandler(Endpoints.update, tabModel, context);
26
26
  };
27
27
 
28
28
  const deleteTab = (tabId, context) => {
@@ -1,13 +1,13 @@
1
1
  const tabsAPI = require('./tabs.api');
2
+ const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
2
3
 
3
4
  const createTab = async (projectId, tabName, tabType, context) => {
4
- const tabModel = { projectId, tabName, type: tabType };
5
+ const tabModel = new CreateTabModel(projectId, tabName, tabType);
5
6
  return tabsAPI.createTab(tabModel, context);
6
7
  };
7
8
 
8
- const updateTab = async (projectId, tabName, tabType, tabId, context) => {
9
- const tabModel = { projectId, tabName, type: tabType, tabId };
10
- return tabsAPI.updateTab(tabModel, context);
9
+ const getTabById = async (tabId, context) => {
10
+ return tabsAPI.getTabByTabId(tabId, context);
11
11
  };
12
12
 
13
13
  const getTabsByProjectId = async (projectId, context) => {
@@ -15,21 +15,13 @@ const getTabsByProjectId = async (projectId, context) => {
15
15
  };
16
16
 
17
17
  const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
18
- const { data: tabs } = await tabsAPI.getTabsByProjectId(projectId, context);
18
+ const { data: tabs } = await getTabsByProjectId(projectId, context);
19
19
  const requestedTab = tabType ?
20
20
  tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
21
21
  tabs.find(tab => tab.tabName === tabName);
22
22
  return requestedTab;
23
23
  };
24
24
 
25
- const getTabById = async (tabId, context) => {
26
- return tabsAPI.getTabByTabId(tabId, context);
27
- };
28
-
29
- const deleteTabById = async (tabId, context) => {
30
- return tabsAPI.deleteTab(tabId, context);
31
- };
32
-
33
25
  const getOrCreateTab = async (projectId, tabName, tabType, context) => {
34
26
  const { data: tabs } = await getTabsByProjectId(projectId, context);
35
27
  const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
@@ -42,12 +34,21 @@ const getOrCreateTab = async (projectId, tabName, tabType, context) => {
42
34
  return createResponse.data;
43
35
  };
44
36
 
37
+ const updateTab = async (projectId, tabName, tabType, tabId, context) => {
38
+ const tabModel = new UpdateTabModel(projectId, tabName, tabType, tabId);
39
+ return tabsAPI.updateTab(tabModel, context);
40
+ };
41
+
42
+ const deleteTabById = async (tabId, context) => {
43
+ return tabsAPI.deleteTab(tabId, context);
44
+ };
45
+
45
46
  module.exports = {
47
+ createTab,
46
48
  getTabById,
47
49
  getTabsByProjectId,
48
- createTab,
49
- updateTab,
50
- deleteTabById,
50
+ getTabsByName,
51
51
  getOrCreateTab,
52
- getTabsByName
52
+ updateTab,
53
+ deleteTabById
53
54
  };
@@ -0,0 +1,18 @@
1
+ class CreateTabModel {
2
+ constructor(projectId, tabName, tabType) {
3
+ this.projectId = projectId;
4
+ this.tabName = tabName;
5
+ this.type = tabType;
6
+ }
7
+ }
8
+
9
+ class UpdateTabModel {
10
+ constructor(projectId, tabName, tabType, tabId) {
11
+ this.projectId = projectId;
12
+ this.tabName = tabName;
13
+ this.type = tabType;
14
+ this.tabId = tabId;
15
+ }
16
+ }
17
+
18
+ module.exports = { CreateTabModel, UpdateTabModel };
@@ -5,12 +5,8 @@ const Endpoints = {
5
5
  run: `${backendUrl}/threadSchedular/${threadSchedulerSecret}`
6
6
  };
7
7
 
8
- const runThreadScheduler = ({ contractorIds = null } = {}) => {
9
- if (contractorIds) {
10
- contractorIds = contractorIds.reduce((f, s) => `${f},${s}`);
11
- }
12
-
13
- const params = { contractorIdsList: contractorIds };
8
+ const runThreadScheduler = ({ contractorIds = [], scheduledReportsIds = [] } = {}) => {
9
+ const params = { contractorIdsList: contractorIds.toString(), scheduledReportsIds: scheduledReportsIds.toString() };
14
10
  return requests.getRequestHandler(Endpoints.run, params);
15
11
  };
16
12
 
package/README.md DELETED
@@ -1,298 +0,0 @@
1
- # Package Name: @getjones/test-infra
2
-
3
- ## Package Goal
4
-
5
- - Providing an easy and reusable interface for the backend system. Means, both by the OpenAPI, and the internal API.
6
-
7
- ## Interface
8
-
9
- ### init
10
-
11
- - require the package with settled up configuration json
12
-
13
- ```node
14
- const { internalAPI } = require("@getjones/test-infra")(conf);
15
- ```
16
-
17
- - configuration example
18
-
19
- ```node
20
- const dotenv = require("dotenv");
21
-
22
- dotenv.config();
23
-
24
- module.exports = {
25
- backendUrl: process.env.BACKEND_URL,
26
- credentials: {
27
- superUser: process.env.CREDENTIALS_SUPER_USER,
28
- superUserPassword: process.env.CREDENTIALS_SUPER_USER_PASSWORD,
29
- strongPassword: process.env.CREDENTIALS_STRONG_PASSWORD,
30
- },
31
- accountCreationSecret: process.env.ACCOUNT_CREATION_SECRET,
32
- environment: process.env.ENVIRONMENT,
33
- email: process.env.EMAIL,
34
- };
35
- ```
36
-
37
- ### internalAPI
38
-
39
- - internalAPI contains the next services:
40
- - auth
41
- - accounts
42
- - accountSettings
43
- - projects
44
- - projectSettings
45
-
46
- ```node
47
- const { auth, accounts, accountSettings, projects } = internalAPI;
48
- ```
49
-
50
- ### auth
51
-
52
- ```node
53
- /**
54
- *
55
- * @param email (string)
56
- * @param password (string)
57
- * @return Auth cookie (string) with given email privileges.
58
- */
59
- const getAuthCookie = async (email, password) => {};
60
-
61
- /**
62
- *
63
- * Required Configuration: {
64
- * credentials.superUser,
65
- * credentials.superUserPassword
66
- * }
67
- * @return ICS cookie (String)
68
- */
69
- const getIcsCookie = async () => {};
70
- ```
71
-
72
- ### accounts
73
-
74
- ```node
75
- /**
76
- *
77
- * Required Configuration: {
78
- * accountCreationSecret: accountCreationSecret,
79
- * }
80
- *
81
- * If you want to use default password so
82
- * 'credentials.strongPassword' is needed
83
- * to be a part of the configuration.
84
- *
85
- * @param email (string)
86
- * @param accountName (string)
87
- * @param context (string): Should contain ICS cookie
88
- * @return Account (object)
89
- */
90
-
91
- const createAccount = async (
92
- email,
93
- accountName,
94
- context,
95
- password = credentials.strongPassword,
96
- propertyType = PROPERTY_TYPE
97
- ) => {};
98
-
99
- /**
100
- *
101
- * @param accountName (string)
102
- * @param context (string): Should contains ICS cookie
103
- * @return Account (object)
104
- */
105
- const getAccount = async (accountName, context) => {};
106
-
107
- /**
108
- *
109
- * @param email (string)
110
- * @param accountName (string)
111
- * @param context (string): Should contain ICS cookie
112
- * @param password (string)
113
- * @return Account (object)
114
- */
115
- const getOrCreateAccount = async (
116
- email,
117
- accountName,
118
- context,
119
- password = credentials.strongPassword
120
- ) => {};
121
-
122
- /**
123
- *
124
- * @param accountName (string)
125
- * @param context (string): Should contain ICS cookie
126
- * @return Account ID (String)
127
- */
128
- const getAccountId = async (accountName, context) => {};
129
-
130
- /**
131
- *
132
- * @param accountName (string)
133
- * @param context (string): Should contains ICS cookie
134
- * @return Http Response
135
- */
136
- const deleteAccountByName = async (accountName, context) => {};
137
-
138
- /**
139
- *
140
- * @param accountId (string)
141
- * @param context (string): Should contain ICS cookie
142
- * @return Http Response
143
- */
144
- const deleteAccountById = async (accountId, context) => {};
145
- ```
146
-
147
- ### accountSettings
148
-
149
- ```node
150
- /**
151
- *
152
- * @param accountId (string)
153
- * @param context (string): Should contain ICS cookie
154
- * @return Account Settings (object)
155
- */
156
- const getAccountSettings = async (accountId, context) => {};
157
-
158
- /**
159
- *
160
- * @param accountId (string)
161
- * @param AccountSettings (object) Should Contain:
162
- * isMultiPropertyTenants (boolean)
163
- * isHighPriority (boolean)
164
- * @param context (string): Should contain ICS cookie
165
- * @return Http Response
166
- */
167
- const updateAccountSettings = async (
168
- accountId,
169
- isMultiPropertyTenants,
170
- isHighPriority,
171
- context
172
- ) => {};
173
-
174
- /**
175
- * Summary: Change account settings to default
176
- * Description:
177
- * Update The Next Account Settings:
178
- * isMultiPropertyTenants: false
179
- * isHighPriority: false
180
- * @param accountId (string)
181
- * @param context (string): Should Contain ICS cookie
182
- * @return Http Response
183
- */
184
- const restoreAccountSettings = async (accountId, context) => {};
185
- ```
186
-
187
- ### projects
188
-
189
- ```node
190
- /**
191
- *
192
- * @param accountName (string)
193
- * @param context (string): Should contain cookie
194
- * User's cookie that is related to this account or ICS cookie
195
- * @return List of projects ([objects])
196
- */
197
- const getProjectsByAccountName = async (accountName, context) => {};
198
-
199
- /**
200
- *
201
- * @param accountId (String)
202
- * @param context (string): Should contain cookie
203
- * User's cookie that is related to this account or ICS cookie
204
- * @return List of projects ([objects])
205
- */
206
- const getProjectsByAccountId = async (accountId, context) => {};
207
-
208
- /**
209
- *
210
- * @param accountId (string)
211
- * @param projectName (string)
212
- * @param context (string): Should contain cookie
213
- * User's cookie that is related to this account or ICS cookie
214
- * @return List of projects ([objects])
215
- */
216
- const getProjectsByName = async (accountId, projectName, context) => {};
217
-
218
- /**
219
- * Summary: Delete project by given details
220
- * @param accountId (string)
221
- * @param projectName (string)
222
- * @param context (string): Should contain cookie
223
- * User's cookie that is related to this account or ICS cookie
224
- * @return List of projects ([objects])
225
- */
226
- const deleteProjectByName = async (accountId, projectName, context) => {};
227
-
228
- /**
229
- *
230
- * @param project (object)
231
- * @param accountName (string)
232
- * @param context (string): Should contain cookie
233
- * User's cookie that is related to this account or ICS cookie
234
- * @return object contains generated projectId
235
- */
236
-
237
- // Example for project input (Not all of them are required):
238
- const createProjectInput = {
239
- projectName: project.name,
240
- userId: "",
241
- regionOrDivision: project.description,
242
- address: project.address,
243
- projectNumber: project.number,
244
- projectStartDate: project.startDate,
245
- projectEndDate: project.endDate,
246
- city: project.city,
247
- state: project.state,
248
- zipCode: project.zipCode,
249
- companyNameForProject: project.companyNameForProject,
250
- certificateHolder: "",
251
- additionalInsured: "",
252
- tenantSolutionEnabled: "",
253
- onboardingEnabled: "",
254
- automaticRenewalEnabled: "",
255
- };
256
-
257
- const createProject = async (project, accountName, context) => {};
258
- ```
259
-
260
- ### projectSettings
261
-
262
- ```node
263
- /**
264
- *
265
- * @param accountName (string)
266
- * @param context (string): Should contain cookie
267
- */
268
-
269
- const getProjectsByAccountName = async (accountName, context) => {};
270
-
271
- /**
272
- *
273
- * @param settings (object)
274
- * @param context (string): Should contain cookie
275
- */
276
-
277
- const updateProjectSettingsByProjectId = async (settings, context) => {};
278
-
279
- // Example for settings input (Not all of them are required):
280
- const updateProjectSettingsInput = {
281
- autoGaps: {
282
- Guests: false,
283
- Tenants: false,
284
- Vendors: false,
285
- },
286
- autoRenewals: false,
287
- marketplace: {
288
- marketplaceEnabled: false,
289
- marketplacePreApproved: false,
290
- marketplacePublicLink: false,
291
- },
292
- ocrEnabled: false,
293
- onboardingPhase: false,
294
- projectId: null,
295
- qrEnabled: false,
296
- tenantSolution: false,
297
- };
298
- ```