vita-playwright 1.2.2 → 1.2.4

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/README.md CHANGED
@@ -27,17 +27,23 @@ VITA Playwright helpers are written in Typescript with playwright support and a
27
27
  - [uploadAFile](#uploadafile)
28
28
  - [getElementRefByRole](#getelementrefbyrole)
29
29
  - [Utilities](#utilities)
30
- - [Excel Utilities](#excel-utilities)
30
+ - [Document Utilities](#document-utilities)
31
31
  - [readData](#readdata)
32
32
  - [readDataFromExcelorCSV](#readdatafromexcelorcsv)
33
33
  - [filterData](#filterdata)
34
34
  - [updateExcelData](#updateexceldata)
35
35
  - [deleteAllFilesUnderDir](#deleteallfilesunderdir)
36
- - [PDF Utilities](#pdf-utilities)
36
+ - [readPdfFile](#readpdffile)
37
37
  - [Lighthouse Utilities](#lighthouse-utilities)
38
38
  - [auditLightHouse](#auditlighthouse)
39
39
  - [createLightHouseReport](#createlighthousereport)
40
40
  - [Date Utilities](#date-utilities)
41
+ - [getDateInCustomFormat](#getdateincustomformat)
42
+ - [getPastDateInCustomFormat](#getpastdateincustomformat)
43
+ - [getFutureDateInCustomFormat](#getfuturedateincustomformat)
44
+ - [getMinDateFromMultipleDates](#getmindatefrommultipledates)
45
+ - [getMaxDateFromMultipleDates](#getmaxdatefrommultipledates)
46
+ - [calculateRelativeDate](#calculaterelativedate)
41
47
  - [Database Utilities](#database-utilities)
42
48
  - [sqlDBConnection](#sqldbconnection)
43
49
  - [executeSqlQuery](#executesqlquery)
@@ -69,15 +75,73 @@ const postResponse = await ApiHelper.post(url, header, payload);
69
75
  ```
70
76
  #### ApiHelpers.post
71
77
  ```ts
72
- // will be added in next versions.
78
+ /**
79
+ * @description: Post call with endpoint, headers and data.
80
+ * @param {string} apiEndPoint - API end point.
81
+ * @param {string} headers - headers contains authentication keys, application type etc..
82
+ * @param {string} payload - payload data
83
+ * @returns {Promise<reponse>} - returns Promise of reponse
84
+ */
85
+ import { ApiHelper } from "vita-playwright";
86
+ const headers= {
87
+ "content-type": "application/json; charset=utf-8",
88
+ "Accept": "*/*"
89
+ };
90
+ const payload = {
91
+ "key":"value"
92
+ };
93
+ const apiEndPoint = "https://admin.googleapis.com/discovery/rest?version=datatransfer_v1";
94
+
95
+ await ApiHelper.post(
96
+ apiEndPoint,
97
+ headers,
98
+ payload
99
+ );
73
100
  ```
74
101
  #### ApiHelpers.get
75
102
  ```ts
76
- // will be added in next versions.
103
+ /**
104
+ * @description: Get call with endpoint and headers.
105
+ * @param {string} apiEndPoint - API end point.
106
+ * @param {string} headers - headers contains authentication keys, application type etc..
107
+ * @returns {Promise<reponse>} - returns Promise of reponse
108
+ */
109
+ import { ApiHelper } from "vita-playwright";
110
+ const headers= {
111
+ "content-type": "application/json; charset=utf-8",
112
+ "Accept": "*/*"
113
+ };
114
+ const apiEndPoint = "https://admin.googleapis.com/discovery/rest?version=datatransfer_v1";
115
+
116
+ await ApiHelper.get(
117
+ apiEndPoint,
118
+ headers,
119
+ );
77
120
  ```
78
121
  #### ApiHelpers.put
79
122
  ```ts
80
- // will be added in next versions.
123
+ /**
124
+ * @description: Put call with endpoint, headers and data and it will insert the data.
125
+ * @param {string} apiEndPoint - API end point.
126
+ * @param {string} headers - headers contains authentication keys, application type etc..
127
+ * @param {string} payload - payload data
128
+ * @returns {Promise<reponse>} - returns Promise of reponse
129
+ */
130
+ import { ApiHelper } from "vita-playwright";
131
+ const headers= {
132
+ "content-type": "application/json; charset=utf-8",
133
+ "Accept": "*/*"
134
+ };
135
+ const data = {
136
+ "key":"value"
137
+ };
138
+ const apiEndPoint = "https://admin.googleapis.com/discovery/rest?version=datatransfer_v1";
139
+
140
+ await ApiHelper.put(
141
+ apiEndPoint,
142
+ headers,
143
+ data
144
+ );
81
145
  ```
82
146
 
83
147
  ### UI Helpers
@@ -113,7 +177,13 @@ __Note__: getElementRefByRole() method will work for all types of roles, example
113
177
  * @param {string} data - Text to be set to inputbox
114
178
  * @returns {Promise<void>} - returns Promise of void
115
179
  */
116
- async filltheData(locator: any, data: any)
180
+ async filltheData(locator: any, data: any);
181
+
182
+ Usage:
183
+ import { UIHelper } from 'vita-playwright'
184
+ class UserClass extends UIHelper{
185
+ await this.filltheData("locator/xpath/css selector", "data to set into inputbox");
186
+ }
117
187
  ```
118
188
  #### clickonWebElement
119
189
  ```ts
@@ -123,6 +193,12 @@ async filltheData(locator: any, data: any)
123
193
  * @returns {Promise<void>} - returns Promise of void
124
194
  */
125
195
  async clickonWebElement(locator: any)
196
+
197
+ Usage:
198
+ import { UIHelper } from 'vita-playwright'
199
+ class UserClass extends UIHelper{
200
+ await this.clickonWebElement("locator/xpath/css selector");
201
+ }
126
202
  ```
127
203
  #### getInnerHTML
128
204
  ```ts
@@ -132,6 +208,13 @@ async clickonWebElement(locator: any)
132
208
  * @returns {string} - returns inner html string
133
209
  */
134
210
  async getInnerHTML(locator: any)
211
+
212
+ Usage:
213
+ import { UIHelper } from 'vita-playwright'
214
+ class UserClass extends UIHelper{
215
+ console.log(await this.getInnerHTML("locator/xpath/css selector"));
216
+ //output: inner HTML of given selector
217
+ }
135
218
  ```
136
219
  #### getInnerText
137
220
  ```ts
@@ -141,6 +224,13 @@ async getInnerHTML(locator: any)
141
224
  * @returns {string} - returns inner text string
142
225
  */
143
226
  async getInnerText(locator: any)
227
+
228
+ Usage:
229
+ import { UIHelper } from 'vita-playwright'
230
+ class UserClass extends UIHelper{
231
+ console.log(await this.getInnerText("locator/xpath/css selector"));
232
+ //output: inner Text of given selector
233
+ }
144
234
  ```
145
235
  #### getText
146
236
  ```ts
@@ -150,6 +240,13 @@ async getInnerText(locator: any)
150
240
  * @returns {string} - returns text string
151
241
  */
152
242
  async getText(locator: any)
243
+
244
+ Usage:
245
+ import { UIHelper } from 'vita-playwright'
246
+ class UserClass extends UIHelper{
247
+ console.log(await this.getText("locator/xpath/css selector"));
248
+ //output: Text of given selector
249
+ }
153
250
  ```
154
251
  #### getAttribute
155
252
  ```ts
@@ -159,7 +256,14 @@ async getText(locator: any)
159
256
  * @param {string} attribute - html attribute to get value
160
257
  * @returns {string} - returns text string
161
258
  */
162
- async getAttribute(locator: any, attribute: any))
259
+ async getAttribute(locator: any, attribute: any)
260
+
261
+ Usage:
262
+ import { UIHelper } from 'vita-playwright'
263
+ class UserClass extends UIHelper{
264
+ console.log(await this.getAttribute("locator/xpath/css selector", "class"));
265
+ //output: returns locator class value
266
+ }
163
267
  ```
164
268
  #### evaluateJS
165
269
  ```ts
@@ -173,6 +277,13 @@ async getAttribute(locator: any, attribute: any))
173
277
  * @returns {boolean} - returns true/false
174
278
  */
175
279
  async isElementPresent(locator: any)
280
+
281
+ Usage:
282
+ import { UIHelper } from 'vita-playwright'
283
+ class UserClass extends UIHelper{
284
+ console.log(await this.isElementPresent("locator/xpath/css selector"));
285
+ //output: returns true if given locator is present in the dom
286
+ }
176
287
  ```
177
288
  #### isElementEnabled
178
289
  ```ts
@@ -182,6 +293,13 @@ async isElementPresent(locator: any)
182
293
  * @returns {boolean} - returns true/false
183
294
  */
184
295
  async isElementEnabled(locator: any)
296
+
297
+ Usage:
298
+ import { UIHelper } from 'vita-playwright'
299
+ class UserClass extends UIHelper{
300
+ console.log(await this.isElementEnabled("locator/xpath/css selector"));
301
+ //output: returns true if given locator is enabled in the dom
302
+ }
185
303
  ```
186
304
  #### waitTillElementIsVisible
187
305
  ```ts
@@ -192,6 +310,13 @@ async isElementEnabled(locator: any)
192
310
  * @returns {Promise<void>} - returns Promise of void
193
311
  */
194
312
  async waitTillElementIsVisible(elementSelector: any, waitTime = 60000)
313
+
314
+ Usage:
315
+ import { UIHelper } from 'vita-playwright'
316
+ class UserClass extends UIHelper{
317
+ await this.waitTillElementIsVisible("locator/xpath/css selector", 100000);
318
+ //output: wait for given locator to be available in the dom
319
+ }
195
320
  ```
196
321
  #### getInputBoxValue
197
322
  ```ts
@@ -201,6 +326,13 @@ async waitTillElementIsVisible(elementSelector: any, waitTime = 60000)
201
326
  * @returns {string} - returns text string
202
327
  */
203
328
  async getInputBoxValue(locator: any)
329
+
330
+ Usage:
331
+ import { UIHelper } from 'vita-playwright'
332
+ class UserClass extends UIHelper{
333
+ console.log(await this.getInputBoxValue("locator/xpath/css selector"));
334
+ //output: returns inputbox value
335
+ }
204
336
  ```
205
337
  #### downloadAFile
206
338
  ```ts
@@ -211,6 +343,14 @@ async getInputBoxValue(locator: any)
211
343
  * @returns {Promise<void>} - returns Promise of void
212
344
  */
213
345
  async downloadAFile(downloadButton: String, filePath: string)
346
+
347
+ Usage:
348
+ import { UIHelper } from 'vita-playwright'
349
+ class UserClass extends UIHelper{
350
+ const filePath = path.resolve(config.use.downloadsPath, downloadFileName);
351
+ await this.downloadAFile(downloadButtonRef, filePath);
352
+ //will wait for download completes and saves in to given filepath with custom name
353
+ }
214
354
  ```
215
355
  #### uploadAFile
216
356
  ```ts
@@ -221,6 +361,14 @@ async downloadAFile(downloadButton: String, filePath: string)
221
361
  * @returns {Promise<void>} - returns Promise of void
222
362
  */
223
363
  async uploadAFile(uploadButton: String, uploadFilePath: String)
364
+
365
+ Usage:
366
+ import { UIHelper } from 'vita-playwright'
367
+ class UserClass extends UIHelper{
368
+ const filePath = path.resolve(config.use.downloadsPath, UploadFileName);
369
+ await this.uploadAFile(UploadButtonRef, filePath);
370
+ //will wait for upload completes
371
+ }
224
372
  ```
225
373
  #### getElementRefByRole
226
374
  ```ts
@@ -231,12 +379,20 @@ async uploadAFile(uploadButton: String, uploadFilePath: String)
231
379
  * @returns {Promise<void>} - returns Promise of void
232
380
  */
233
381
  async getElementRefByRole(roleType: string, roleName: string)
382
+
383
+ Usage:
384
+ import { UIHelper } from 'vita-playwright'
385
+ class UserClass extends UIHelper{
386
+ await this.getElementRefByRole("link", "Dashboard");
387
+ await this.getElementRefByRole("button", "Jobs");
388
+ await this.getElementRefByRole("checkbox", "jobName");
389
+ }
234
390
  ```
235
391
 
236
392
  ## Utilities
237
393
  vita-playwright also provides utilities for Excel, Pdf, Date, Email and Lighthosue for perfomace.
238
394
 
239
- ### Excel Utilities
395
+ ### Document Utilities
240
396
 
241
397
  You can access rows and columns in order to change size, hide/show, or access cells within:
242
398
 
@@ -292,12 +448,16 @@ static async updateExcelData(filePath: string, sheetname: string)
292
448
  */
293
449
  static async deleteAllFilesUnderDir(filePath: string, sheetname: string)
294
450
  ```
295
- ### PDF Utilities
296
- TODO: need to add PDF Utilities
297
-
451
+ #### readPdfFile
298
452
  ```ts
299
- // will be added in next versions.
453
+ /**
454
+ * @description: it will take pdf file path as input and will return array of strings(each each line in pdf is each item in result array).
455
+ * @param {string} filePath - Complete path of the excel file, example: C:/resources/****.pdf.
456
+ * @returns { Array<string>} - returns array os string, each string represents each line in pdf
457
+ */
458
+ static async readPdfFile(filePath: string)
300
459
  ```
460
+
301
461
  ### Lighthouse Utilities
302
462
  Lighthouse utilities are used to perform Lighthouse performace testing provided by Google.
303
463
 
@@ -334,24 +494,93 @@ static async createLightHouseReport(filePath: string, sheetname: string)
334
494
  ```
335
495
 
336
496
  ### Date Utilities
337
- TODO: need to add Date Utilities
497
+ Date related utilities
338
498
 
339
499
  ```ts
340
500
  // will be added in next versions.
341
501
  ```
342
-
343
- ### Database Utilities
344
- TODO: need to add Database Utilities
502
+ #### getDateInCustomFormat
345
503
  ```ts
346
- // will be added in next versions
504
+ /**
505
+ * @description: returns date in required format.
506
+ * @param {string} date - date in the form of string, example: 01/01/2023.
507
+ * @param {string} format - format od date, example: DD/MM/YYYY.
508
+ * @returns {string} - returns date in given format.
509
+ */
510
+ static getDateInCustomFormat(date:any, format: string)
511
+ ```
512
+ #### getPastDateInCustomFormat
513
+ ```ts
514
+ /**
515
+ * @description: subtracts no of days|months|years|hours|minutes|seconds from given date.
516
+ * @param {string} date - date in the form of string, example: 01/01/2023.
517
+ * @param {string} format - format od date, example: DD/MM/YYYY.
518
+ * @param {string} durationType - example days, months, years, hours, minutes, seconds.
519
+ * @param {string} duration - no of days|months|years|hours|minutes|seconds.
520
+ * @returns {string} - returns date in given format.
521
+ */
522
+ static getPastDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1)
523
+ ```
524
+ #### getFutureDateInCustomFormat
525
+ ```ts
526
+ /**
527
+ * @description: adds no of days|months|years|hours|minutes|seconds from given date.
528
+ * @param {string} date - date in the form of string, example: 01/01/2023.
529
+ * @param {string} format - format od date, example: DD/MM/YYYY.
530
+ * @param {string} durationType - example days, months, years, hours, minutes, seconds.
531
+ * @param {string} duration - no of days|months|years|hours|minutes|seconds.
532
+ * @returns {string} - returns date in given format.
533
+ */
534
+ static getFutureDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1)
535
+ ```
536
+ #### getMinDateFromMultipleDates
537
+ ```ts
538
+ /**
539
+ * @description: return min date from given dates.
540
+ * @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
541
+ * @returns {string} - return min date amount given dates example: 10/01/2023.
542
+ */
543
+ static getMinDateFromMultipleDates(datesArrayObject: any)
347
544
  ```
545
+ #### getMaxDateFromMultipleDates
546
+ ```ts
547
+ /**
548
+ * @description: return max date from given dates.
549
+ * @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
550
+ * @returns {string} - return max date amount given dates example: 20/01/2023.
551
+ */
552
+ ```
553
+ #### calculateRelativeDate
554
+ ```ts
555
+ /**
556
+ * @description: returns no of days "lessthan|Greaterthan" from given date.
557
+ * @param {string} fromDate - date in the form of string, example: 01/01/2023.
558
+ * @param {string} format - format od date, example: DD/MM/YYYY.
559
+ * @returns {string} - returns string which is no of days "lessthan|Greaterthan" from given date.
560
+ */
561
+ static calculateRelativeDate(fromDate: any, format: string)
562
+ ```
563
+ ### Database Utilities
564
+ Utilities related SQL server utilities
565
+
348
566
  #### sqlDBConnection
349
567
  ```ts
350
- // will be added in next versions
568
+ /**
569
+ * @description: establish the connection with database.
570
+ * @param {string} configuration - example: {server: string, database: string, username:string, password: string, portNumber: number}.
571
+ * @returns {Connection} - returns connection object.
572
+ */
573
+ static sqlDBConnection(fromDate: any, format: string)
351
574
  ```
352
575
  #### executeSqlQuery
353
576
  ```ts
354
- // will be added in next versions
577
+ /**
578
+ * @description: establish the connection with database.
579
+ * @param {string} connectionObj - connection object which will come from sqlDBConnection()
580
+ * @param {string} queryString - query to execute
581
+ * @returns {Connection} - returns connection object.
582
+ */
583
+ static async executeSqlQuery(connectionObj: any, queryString: any)
355
584
  ```
356
585
 
357
586
  ### Data Comparisions
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import { ApiHelper } from "./src/helpers/api-helpers";
3
3
  import { TokenGenerators } from "./src/utils/api_axios";
4
4
  import { AzureStorageMethods } from "./src/utils/azure_storage_methods";
5
5
  import { Comparisions } from "./src/utils/comparisions";
6
- import { ExcelUtility } from "./src/utils/excel_utility";
6
+ import { DocumentUtility } from "./src/utils/document_utility";
7
7
  import { KeyVaultMethods } from "./src/utils/keyvault_methods";
8
8
  import { TestData } from "./src/utils/test_data";
9
9
  import { XmlToJson } from "./src/utils/xmlToJson";
10
10
  import { LightHouseUtility } from "./src/utils/lighhouse_utility";
11
- export { UIHelper, ApiHelper, TokenGenerators, AzureStorageMethods, Comparisions, ExcelUtility, KeyVaultMethods, TestData, XmlToJson, LightHouseUtility };
11
+ export { UIHelper, ApiHelper, TokenGenerators, AzureStorageMethods, Comparisions, DocumentUtility, KeyVaultMethods, TestData, XmlToJson, LightHouseUtility };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LightHouseUtility = exports.XmlToJson = exports.TestData = exports.KeyVaultMethods = exports.ExcelUtility = exports.Comparisions = exports.AzureStorageMethods = exports.TokenGenerators = exports.ApiHelper = exports.UIHelper = void 0;
3
+ exports.LightHouseUtility = exports.XmlToJson = exports.TestData = exports.KeyVaultMethods = exports.DocumentUtility = exports.Comparisions = exports.AzureStorageMethods = exports.TokenGenerators = exports.ApiHelper = exports.UIHelper = void 0;
4
4
  const ui_helpers_1 = require("./src/helpers/ui-helpers");
5
5
  Object.defineProperty(exports, "UIHelper", { enumerable: true, get: function () { return ui_helpers_1.UIHelper; } });
6
6
  const api_helpers_1 = require("./src/helpers/api-helpers");
@@ -11,8 +11,8 @@ const azure_storage_methods_1 = require("./src/utils/azure_storage_methods");
11
11
  Object.defineProperty(exports, "AzureStorageMethods", { enumerable: true, get: function () { return azure_storage_methods_1.AzureStorageMethods; } });
12
12
  const comparisions_1 = require("./src/utils/comparisions");
13
13
  Object.defineProperty(exports, "Comparisions", { enumerable: true, get: function () { return comparisions_1.Comparisions; } });
14
- const excel_utility_1 = require("./src/utils/excel_utility");
15
- Object.defineProperty(exports, "ExcelUtility", { enumerable: true, get: function () { return excel_utility_1.ExcelUtility; } });
14
+ const document_utility_1 = require("./src/utils/document_utility");
15
+ Object.defineProperty(exports, "DocumentUtility", { enumerable: true, get: function () { return document_utility_1.DocumentUtility; } });
16
16
  const keyvault_methods_1 = require("./src/utils/keyvault_methods");
17
17
  Object.defineProperty(exports, "KeyVaultMethods", { enumerable: true, get: function () { return keyvault_methods_1.KeyVaultMethods; } });
18
18
  const test_data_1 = require("./src/utils/test_data");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAYhD,yFAZK,qBAAQ,OAYL;AAXZ,2DAAsD;AAYlD,0FAZK,uBAAS,OAYL;AAXb,qDAAwD;AAYpD,gGAZK,2BAAe,OAYL;AAXnB,6EAAwE;AAYpE,oGAZK,2CAAmB,OAYL;AAXvB,2DAAwD;AAYpD,6FAZK,2BAAY,OAYL;AAXhB,6DAAyD;AAYrD,6FAZK,4BAAY,OAYL;AAXhB,mEAA+D;AAY3D,gGAZK,kCAAe,OAYL;AAXnB,qDAAiD;AAY7C,yFAZK,oBAAQ,OAYL;AAXZ,qDAAkD;AAY9C,0FAZK,qBAAS,OAYL;AAXb,qEAAkE;AAY9D,kGAZK,qCAAiB,OAYL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAYhD,yFAZK,qBAAQ,OAYL;AAXZ,2DAAsD;AAYlD,0FAZK,uBAAS,OAYL;AAXb,qDAAwD;AAYpD,gGAZK,2BAAe,OAYL;AAXnB,6EAAwE;AAYpE,oGAZK,2CAAmB,OAYL;AAXvB,2DAAwD;AAYpD,6FAZK,2BAAY,OAYL;AAXhB,mEAA+D;AAY3D,gGAZK,kCAAe,OAYL;AAXnB,mEAA+D;AAY3D,gGAZK,kCAAe,OAYL;AAXnB,qDAAiD;AAY7C,yFAZK,oBAAQ,OAYL;AAXZ,qDAAkD;AAY9C,0FAZK,qBAAS,OAYL;AAXb,qEAAkE;AAY9D,kGAZK,qCAAiB,OAYL"}
@@ -0,0 +1,9 @@
1
+ import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
2
+ export declare class Dateutility {
3
+ static getDateInCustomFormat(date: any, format: string): string;
4
+ static getFutureDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
5
+ static getPastDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
6
+ static getMinDateFromMultipleDates(datesArrayObject: any): moment.Moment;
7
+ static getMaxDateFromMultipleDates(date1: any, date2: any): moment.Moment;
8
+ static calculateRelativeDate(fromDate: any, format: string): string;
9
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Dateutility = void 0;
7
+ const lodash_1 = require("lodash");
8
+ const moment_1 = __importDefault(require("moment"));
9
+ class Dateutility {
10
+ static getDateInCustomFormat(date, format) {
11
+ return (0, moment_1.default)(date).format(format);
12
+ }
13
+ static getFutureDateInCustomFormat(date, format, durationType, duration) {
14
+ return (0, moment_1.default)(date).add(duration, durationType).format(format);
15
+ }
16
+ static getPastDateInCustomFormat(date, format, durationType, duration) {
17
+ return (0, moment_1.default)(date).subtract(duration, durationType).format(format);
18
+ }
19
+ static getMinDateFromMultipleDates(datesArrayObject) {
20
+ return moment_1.default.min((0, lodash_1.map)(datesArrayObject, (obj) => (0, moment_1.default)(obj.date, obj.format)));
21
+ }
22
+ static getMaxDateFromMultipleDates(date1, date2) {
23
+ return moment_1.default.max(date1, date2);
24
+ }
25
+ static calculateRelativeDate(fromDate, format) {
26
+ return (0, moment_1.default)(fromDate, format).fromNow();
27
+ }
28
+ }
29
+ exports.Dateutility = Dateutility;
30
+ //# sourceMappingURL=date_utilitites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date_utilitites.js","sourceRoot":"","sources":["../../../src/utils/date_utilitites.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6B;AAC7B,oDAAsE;AACtE,MAAa,WAAW;IAEpB,MAAM,CAAC,qBAAqB,CAAC,IAAQ,EAAE,MAAc;QACjD,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACrH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACnH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,gBAAqB;QACpD,OAAO,gBAAM,CAAC,GAAG,CAAC,IAAA,YAAG,EAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,gBAAM,EAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,KAAU,EAAE,KAAU;QACrD,OAAO,gBAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,QAAa,EAAE,MAAc;QACtD,OAAO,IAAA,gBAAM,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,CAAC;CACJ;AAzBD,kCAyBC"}
@@ -4,5 +4,6 @@ export declare class DocumentUtility {
4
4
  static readDataFromExcelorCSV(filePath: string, sheetname: string): Promise<unknown[]>;
5
5
  static filterData(filePath: string, sheetName: string, filterObject: object): Promise<unknown[]>;
6
6
  static updateExcelData(filePath: string, sheetName: string, exportData: Array<object>): Promise<void>;
7
- static deleteAllFilesUnderDIr(dirPath: string): Promise<void>;
7
+ static deleteAllFilesUnderDir(dirPath: string): Promise<void>;
8
+ static readPdfFile(filePath: string): Promise<unknown>;
8
9
  }
@@ -17,6 +17,7 @@ const xlsx_1 = __importDefault(require("xlsx"));
17
17
  const lodash_1 = __importDefault(require("lodash"));
18
18
  const promises_1 = __importDefault(require("node:fs/promises"));
19
19
  const node_path_1 = __importDefault(require("node:path"));
20
+ const pdfreader_1 = require("pdfreader");
20
21
  class DocumentUtility {
21
22
  static readData(filePath) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -59,13 +60,28 @@ class DocumentUtility {
59
60
  xlsx_1.default.writeFile(workbook, filePath);
60
61
  });
61
62
  }
62
- static deleteAllFilesUnderDIr(dirPath) {
63
+ static deleteAllFilesUnderDir(dirPath) {
63
64
  return __awaiter(this, void 0, void 0, function* () {
64
65
  for (const file of yield promises_1.default.readdir(dirPath)) {
65
66
  yield promises_1.default.unlink(node_path_1.default.join(dirPath, file));
66
67
  }
67
68
  });
68
69
  }
70
+ static readPdfFile(filePath) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const items = [];
73
+ return new Promise((resolve, reject) => {
74
+ new pdfreader_1.PdfReader().parseFileItems(filePath, (err, item) => {
75
+ if (err)
76
+ reject(err);
77
+ else if (!item)
78
+ resolve(items);
79
+ else if (item.text)
80
+ items.push(item.text);
81
+ });
82
+ });
83
+ });
84
+ }
69
85
  }
70
86
  exports.DocumentUtility = DocumentUtility;
71
87
  //# sourceMappingURL=document_utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document_utility.js","sourceRoot":"","sources":["../../../src/utils/document_utility.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,oDAAuB;AACvB,gEAAkC;AAClC,0DAA6B;AAC7B,MAAa,eAAe;IAExB,MAAM,CAAO,QAAQ,CAAC,QAAgB;;YAClC,OAAO,cAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACvG,CAAC;KAAA;IAED,MAAM,CAAO,sBAAsB,CAAC,QAAgB,EAAE,SAAiB;;YACnE,MAAM,QAAQ,GAAG;gBACb,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,YAAY,CAAC,oEAAoE;aAC1F,CAAA;YACH,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC1D,MAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAC5C,SAAS,GAAG,CAAC,SAAS,KAAK,SAAS,CA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C;gBAC9C,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CAGJ;AA1DD,0CA0DC"}
@@ -1,2 +1,3 @@
1
1
  export declare class PDFUtility {
2
+ static readPdfFile(filePath: string): Promise<unknown>;
2
3
  }
@@ -1,7 +1,32 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.PDFUtility = void 0;
13
+ const pdfreader_1 = require("pdfreader");
4
14
  class PDFUtility {
15
+ static readPdfFile(filePath) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const items = [];
18
+ return new Promise((resolve, reject) => {
19
+ new pdfreader_1.PdfReader().parseFileItems(filePath, (err, item) => {
20
+ if (err)
21
+ reject(err);
22
+ else if (!item)
23
+ resolve(items);
24
+ else if (item.text)
25
+ items.push(item.text);
26
+ });
27
+ });
28
+ });
29
+ }
5
30
  }
6
31
  exports.PDFUtility = PDFUtility;
7
32
  //# sourceMappingURL=pdf_utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pdf_utility.js","sourceRoot":"","sources":["../../../src/utils/pdf_utility.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;CAUtB;AAVD,gCAUC"}
1
+ {"version":3,"file":"pdf_utility.js","sourceRoot":"","sources":["../../../src/utils/pdf_utility.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsC;AACtC,MAAa,UAAU;IAEnB,MAAM,CAAO,WAAW,CAAC,QAAgB;;YACrC,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;oBACnD,IAAI,GAAG;wBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;yBAChB,IAAI,CAAC,IAAI;wBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;yBAC1B,IAAI,IAAI,CAAC,IAAI;wBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAZD,gCAYC"}
@@ -1,11 +1,6 @@
1
1
  export declare class TestData {
2
- static sqlDBConnection(): Promise<any>;
3
- static executeSqlQuery(pool1: {
4
- connect: () => any;
5
- on: (arg0: string, arg1: (err: any) => void) => void;
6
- request: () => any;
7
- close: () => void;
8
- }, queryString: any): Promise<any>;
2
+ static sqlDBConnection(configuration: any): Promise<any>;
3
+ static executeSqlQuery(connectionObj: any, queryString: any): Promise<any>;
9
4
  static generateRandomUniqeIDNumber(): Promise<string>;
10
5
  static getUTCTimeCustom24hrs(localTime: string): Promise<string>;
11
6
  static waitFortimeOut(waitTime: any): Promise<void>;
@@ -13,15 +13,17 @@ exports.TestData = void 0;
13
13
  // const cosmosClient = require("@azure/cosmos").CosmosClient;
14
14
  const sql = require('mssql');
15
15
  class TestData {
16
- static sqlDBConnection() {
16
+ static sqlDBConnection(configuration) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- var server = "zwetrvl2sqd001.database.windows.net";
19
- var database = "zwetrvl2sqd001-DB002";
18
+ // var server = "zwetrvl2sqd001.database.windows.net";
19
+ // var database ="zwetrvl2sqd001-DB002";
20
20
  var config = {
21
- server: server,
22
- user: "zwetrvl2sqd001-admin",
23
- password: "SADJ+zyhcj2l(SY9",
24
- database: database,
21
+ server: configuration.server,
22
+ // user: "zwetrvl2sqd001-admin",
23
+ // password: "SADJ+zyhcj2l(SY9",
24
+ user: configuration.user,
25
+ password: configuration.password,
26
+ database: configuration.database,
25
27
  requestTimeout: 600000,
26
28
  port: 1433,
27
29
  options: {
@@ -36,16 +38,16 @@ class TestData {
36
38
  return conn;
37
39
  });
38
40
  }
39
- static executeSqlQuery(pool1, queryString) {
41
+ static executeSqlQuery(connectionObj, queryString) {
40
42
  return __awaiter(this, void 0, void 0, function* () {
41
- var pool1Connect = yield pool1.connect();
42
- pool1.on('error', err => {
43
+ var pool1Connect = yield connectionObj.connect();
44
+ connectionObj.on('error', err => {
43
45
  console.log(err);
44
46
  return;
45
47
  });
46
48
  yield pool1Connect;
47
49
  try {
48
- const request = pool1.request(); // or: new sql.Request(pool1)
50
+ const request = connectionObj.request(); // or: new sql.Request(pool1)
49
51
  const result = yield request.query(queryString);
50
52
  return result;
51
53
  }
@@ -53,7 +55,7 @@ class TestData {
53
55
  console.error('SQL error', err);
54
56
  return null;
55
57
  }
56
- pool1.close();
58
+ connectionObj.close();
57
59
  });
58
60
  }
59
61
  static generateRandomUniqeIDNumber() {
@@ -1 +1 @@
1
- {"version":3,"file":"test_data.js","sourceRoot":"","sources":["../../../src/utils/test_data.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,MAAa,QAAQ;IAEjB,MAAM,CAAO,eAAe;;YACxB,IAAI,MAAM,GAAG,qCAAqC,CAAC;YACnD,IAAI,QAAQ,GAAE,sBAAsB,CAAC;YACrC,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,kBAAkB;gBAC5B,QAAQ,EAAE,QAAQ;gBAClB,cAAc,EAAE,M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AAE,EAAE;oBACb,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;iBACzB;qBAAM;oBACH,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;iBAChE;aACJ;YACD,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YAC9E,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9D,OAAO,SAAS,CAAC,WAAW,EAAE,CAAA;QAElC,CAAC;KAAA;CAEJ;AA3HD,4BA2HC"}
package/index.ts CHANGED
@@ -3,7 +3,7 @@ import { ApiHelper } from "./src/helpers/api-helpers";
3
3
  import { TokenGenerators } from "./src/utils/api_axios";
4
4
  import { AzureStorageMethods } from "./src/utils/azure_storage_methods";
5
5
  import { Comparisions } from "./src/utils/comparisions";
6
- import { ExcelUtility } from "./src/utils/excel_utility";
6
+ import { DocumentUtility } from "./src/utils/document_utility";
7
7
  import { KeyVaultMethods } from "./src/utils/keyvault_methods";
8
8
  import { TestData } from "./src/utils/test_data";
9
9
  import { XmlToJson } from "./src/utils/xmlToJson";
@@ -15,7 +15,7 @@ export {
15
15
  TokenGenerators,
16
16
  AzureStorageMethods,
17
17
  Comparisions,
18
- ExcelUtility,
18
+ DocumentUtility,
19
19
  KeyVaultMethods,
20
20
  TestData,
21
21
  XmlToJson,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vita-playwright",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "email": "noreply_testautomation@vialto.com",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,9 +32,10 @@
32
32
  "is-ci": "2.0.0",
33
33
  "lighthouse": "^9.6.8",
34
34
  "lodash": "^4.17.21",
35
+ "moment": "^2.29.4",
35
36
  "mssql": "9.0.0",
36
37
  "open": "8.4.0",
37
- "pdf-lib": "^1.17.1",
38
+ "pdfreader": "^3.0.0",
38
39
  "playwright": "^1.25.0",
39
40
  "playwright-lighthouse": "^2.2.2",
40
41
  "prettier": "2.7.1",
@@ -47,7 +48,7 @@
47
48
  },
48
49
  "author": "Vialto QE",
49
50
  "license": "ISC",
50
- "description": "common functions for VITA framework",
51
+ "description": "common functions for playwright and nodejs",
51
52
  "repository": {
52
53
  "type": "git",
53
54
  "url": "https://github.com/Vialto/vialto-test-automation/"
@@ -0,0 +1,28 @@
1
+ import { map } from 'lodash';
2
+ import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
3
+ export class Dateutility{
4
+
5
+ static getDateInCustomFormat(date:any, format: string){
6
+ return moment(date).format(format);
7
+ }
8
+
9
+ static getFutureDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1){
10
+ return moment(date).add(duration, durationType).format(format);
11
+ }
12
+
13
+ static getPastDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1){
14
+ return moment(date).subtract(duration, durationType).format(format);
15
+ }
16
+
17
+ static getMinDateFromMultipleDates(datesArrayObject: any){
18
+ return moment.min(map(datesArrayObject, (obj) => moment(obj.date, obj.format)));
19
+ }
20
+
21
+ static getMaxDateFromMultipleDates(date1: any, date2: any){
22
+ return moment.max(date1, date2);
23
+ }
24
+
25
+ static calculateRelativeDate(fromDate: any, format: string){
26
+ return moment(fromDate, format).fromNow();
27
+ }
28
+ }
@@ -2,7 +2,9 @@ import XLSX from 'xlsx';
2
2
  import _ from 'lodash';
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
- export class ExcelUtility {
5
+ import { PdfReader } from "pdfreader";
6
+
7
+ export class DocumentUtility {
6
8
 
7
9
  static async readData(filePath: string) {
8
10
  return XLSX.readFile(filePath, { cellDates: true, bookVBA: true, sheetStubs: true, cellNF: true });
@@ -13,7 +15,7 @@ export class ExcelUtility {
13
15
  raw: false,
14
16
  dateNF: `yyyy/mm/dd` // <--- need dateNF in sheet_to_json options (note the escape chars)
15
17
  }
16
- const workbook = await ExcelUtility.readData(filePath);
18
+ const workbook = await DocumentUtility.readData(filePath);
17
19
  const sheet_name_list = workbook.SheetNames;
18
20
  sheetname = (sheetname === undefined ? sheet_name_list[0] : sheetname);
19
21
  return XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], jsonOpts);
@@ -32,12 +34,12 @@ export class ExcelUtility {
32
34
  }
33
35
 
34
36
  static async filterData(filePath: string, sheetName: string, filterObject: object) {
35
- let fileData = await ExcelUtility.readData(filePath);
37
+ let fileData = await DocumentUtility.readData(filePath);
36
38
  return _.filter(XLSX.utils.sheet_to_json(fileData.Sheets[sheetName]), filterObject)
37
39
  }
38
40
 
39
41
  static async updateExcelData(filePath: string, sheetName: string, exportData: Array<object>) {
40
- const workbook = await ExcelUtility.readData(filePath);
42
+ const workbook = await DocumentUtility.readData(filePath);
41
43
  workbook.Sheets[sheetName] = XLSX.utils.json_to_sheet(exportData);
42
44
  XLSX.writeFile(workbook, filePath);
43
45
  }
@@ -48,5 +50,16 @@ export class ExcelUtility {
48
50
  }
49
51
  }
50
52
 
53
+ static async readPdfFile(filePath: string) {
54
+ const items = [];
55
+ return new Promise((resolve, reject) => {
56
+ new PdfReader().parseFileItems(filePath, (err, item) => {
57
+ if (err) reject(err);
58
+ else if (!item) resolve(items);
59
+ else if (item.text) items.push(item.text);
60
+ });
61
+ });
62
+ }
63
+
51
64
 
52
65
  }
@@ -1,13 +1,14 @@
1
- import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib';
2
- import fs from 'fs';
1
+ import { PdfReader } from "pdfreader";
3
2
  export class PDFUtility {
4
3
 
5
- // static async readData() {
6
- // const existingPdfBytes = fs.readFile("C:/Users/vtpr271/Downloads/SS - Global Decision Tree - Apr 2021 update (new manual outcome) (1).pdf");
7
- // // Load a PDFDocument from the existing PDF bytes
8
- // const pdfDoc = await PDFDocument.load(existingPdfBytes);
9
- // // Load a PDFDocument from the existing PDF bytes
10
- // const pdfDoc2 = await PDFDocument.load(existingPdfBytes);
11
- // console.log(pdfDoc2);
12
- // }
4
+ static async readPdfFile(filePath: string) {
5
+ const items = [];
6
+ return new Promise((resolve, reject) => {
7
+ new PdfReader().parseFileItems(filePath, (err, item) => {
8
+ if (err) reject(err);
9
+ else if (!item) resolve(items);
10
+ else if (item.text) items.push(item.text);
11
+ });
12
+ });
13
+ }
13
14
  }
@@ -3,14 +3,16 @@ const sql = require('mssql');
3
3
 
4
4
  export class TestData {
5
5
 
6
- static async sqlDBConnection() {
7
- var server = "zwetrvl2sqd001.database.windows.net";
8
- var database ="zwetrvl2sqd001-DB002";
6
+ static async sqlDBConnection(configuration: any) {
7
+ // var server = "zwetrvl2sqd001.database.windows.net";
8
+ // var database ="zwetrvl2sqd001-DB002";
9
9
  var config = {
10
- server: server,
11
- user: "zwetrvl2sqd001-admin",
12
- password: "SADJ+zyhcj2l(SY9",
13
- database: database,
10
+ server: configuration.server,
11
+ // user: "zwetrvl2sqd001-admin",
12
+ // password: "SADJ+zyhcj2l(SY9",
13
+ user: configuration.user,
14
+ password: configuration.password,
15
+ database: configuration.database,
14
16
  requestTimeout: 600000,
15
17
  port: 1433,
16
18
  options: {
@@ -26,22 +28,22 @@ export class TestData {
26
28
  return conn;
27
29
 
28
30
  }
29
- static async executeSqlQuery(pool1: { connect: () => any; on: (arg0: string, arg1: (err: any) => void) => void; request: () => any; close: () => void; }, queryString: any) {
30
- var pool1Connect = await pool1.connect();
31
- pool1.on('error', err => {
31
+ static async executeSqlQuery(connectionObj: any, queryString: any) {
32
+ var pool1Connect = await connectionObj.connect();
33
+ connectionObj.on('error', err => {
32
34
  console.log(err);
33
35
  return;
34
36
  })
35
37
  await pool1Connect;
36
38
  try {
37
- const request = pool1.request(); // or: new sql.Request(pool1)
39
+ const request = connectionObj.request(); // or: new sql.Request(pool1)
38
40
  const result = await request.query(queryString)
39
41
  return result;
40
42
  } catch (err) {
41
43
  console.error('SQL error', err);
42
44
  return null;
43
45
  }
44
- pool1.close();
46
+ connectionObj.close();
45
47
 
46
48
  }
47
49