vita-playwright 1.3.19 → 1.3.20
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/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/src/utils/document_utility.d.ts +40 -0
- package/dist/src/utils/document_utility.js +103 -0
- package/dist/src/utils/document_utility.js.map +1 -0
- package/index.ts +1 -1
- package/package.json +1 -2
- package/src/utils/{document_utility.mts → document_utility.ts} +3 -2
- package/tsconfig.json +1 -1
package/dist/index.d.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 { DocumentUtility } from "./src/utils/document_utility.
|
|
6
|
+
import { DocumentUtility } from "./src/utils/document_utility.js";
|
|
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";
|
package/dist/index.js
CHANGED
|
@@ -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
|
|
15
|
-
Object.defineProperty(exports, "DocumentUtility", { enumerable: true, get: function () { return
|
|
14
|
+
const document_utility_js_1 = require("./src/utils/document_utility.js");
|
|
15
|
+
Object.defineProperty(exports, "DocumentUtility", { enumerable: true, get: function () { return document_utility_js_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,
|
|
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,yEAAkE;AAY9D,gGAZK,qCAAe,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,40 @@
|
|
|
1
|
+
import XLSX from 'xlsx';
|
|
2
|
+
export declare class DocumentUtility {
|
|
3
|
+
/**
|
|
4
|
+
* @description: it will take excel file path as input and will return excel Workbook object.
|
|
5
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
6
|
+
* @returns {Promise<Workbook>} - returns Promise, if we resolves and will get Workbook object
|
|
7
|
+
*/
|
|
8
|
+
static readData(filePath: string): Promise<XLSX.WorkBook>;
|
|
9
|
+
/**
|
|
10
|
+
* @description: it will take excel file path and sheetname as input and will return array of objects.
|
|
11
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
12
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
13
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get Array of Json objects.
|
|
14
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
15
|
+
*/
|
|
16
|
+
static readDataFromExcelorCSV(filePath: string, sheetname: string): Promise<unknown[]>;
|
|
17
|
+
/**
|
|
18
|
+
* @description: it will filter excel data and will return filtered array of objects.
|
|
19
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
20
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
21
|
+
* @param {Object} filterObject - {column Name:Row value} key:value pair. example: {startDate: '****'}
|
|
22
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get filtered Array of Json objects.
|
|
23
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
24
|
+
*/
|
|
25
|
+
static filterData(filePath: string, sheetName: string, filterObject: object): Promise<unknown[]>;
|
|
26
|
+
/**
|
|
27
|
+
* @description: it will modify/update excel file based on input data.
|
|
28
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
29
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
30
|
+
* @param {Array<Object>} exportData - excel modify data. example: [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
31
|
+
* @returns {Promise<void>} - returns void promise.
|
|
32
|
+
*/
|
|
33
|
+
static updateExcelData(filePath: string, sheetName: string, exportData: Array<object>): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* @description: it will delete all files under given directory.
|
|
36
|
+
* @param {string} dirPath - Complete path of the directory which contain file, example: C:/resources.
|
|
37
|
+
* @returns {Promise<void>} - returns void promise.
|
|
38
|
+
*/
|
|
39
|
+
static deleteAllFilesUnderDir(dirPath: string): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DocumentUtility = void 0;
|
|
16
|
+
const xlsx_1 = __importDefault(require("xlsx"));
|
|
17
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
18
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
class DocumentUtility {
|
|
21
|
+
/**
|
|
22
|
+
* @description: it will take excel file path as input and will return excel Workbook object.
|
|
23
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
24
|
+
* @returns {Promise<Workbook>} - returns Promise, if we resolves and will get Workbook object
|
|
25
|
+
*/
|
|
26
|
+
static readData(filePath) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return xlsx_1.default.readFile(filePath, { cellDates: true, bookVBA: true, sheetStubs: true, cellNF: true });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @description: it will take excel file path and sheetname as input and will return array of objects.
|
|
33
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
34
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
35
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get Array of Json objects.
|
|
36
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
37
|
+
*/
|
|
38
|
+
static readDataFromExcelorCSV(filePath, sheetname) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const jsonOpts = {
|
|
41
|
+
raw: false,
|
|
42
|
+
dateNF: `yyyy/mm/dd` // <--- need dateNF in sheet_to_json options (note the escape chars)
|
|
43
|
+
};
|
|
44
|
+
const workbook = yield DocumentUtility.readData(filePath);
|
|
45
|
+
const sheet_name_list = workbook.SheetNames;
|
|
46
|
+
sheetname = (sheetname === undefined ? sheet_name_list[0] : sheetname);
|
|
47
|
+
return xlsx_1.default.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], jsonOpts);
|
|
48
|
+
// const tempTwoDimentionalArr = new Array(_.keys(excelData[0]).length);
|
|
49
|
+
// for (var i = 0; i < tempTwoDimentionalArr.length; i++) {
|
|
50
|
+
// tempTwoDimentionalArr[i] = new Array();
|
|
51
|
+
// }
|
|
52
|
+
// return _.map(excelData, function (obj) {
|
|
53
|
+
// return _.reduce(_.keys(excelData[0]), function (result, columnName, index) {
|
|
54
|
+
// tempTwoDimentionalArr[index].push(obj[columnName])
|
|
55
|
+
// result[columnName] = tempTwoDimentionalArr[index];
|
|
56
|
+
// return result;
|
|
57
|
+
// }, {})
|
|
58
|
+
// })[0];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @description: it will filter excel data and will return filtered array of objects.
|
|
63
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
64
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
65
|
+
* @param {Object} filterObject - {column Name:Row value} key:value pair. example: {startDate: '****'}
|
|
66
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get filtered Array of Json objects.
|
|
67
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
68
|
+
*/
|
|
69
|
+
static filterData(filePath, sheetName, filterObject) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
let fileData = yield DocumentUtility.readData(filePath);
|
|
72
|
+
return lodash_1.default.filter(xlsx_1.default.utils.sheet_to_json(fileData.Sheets[sheetName]), filterObject);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @description: it will modify/update excel file based on input data.
|
|
77
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
78
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
79
|
+
* @param {Array<Object>} exportData - excel modify data. example: [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
80
|
+
* @returns {Promise<void>} - returns void promise.
|
|
81
|
+
*/
|
|
82
|
+
static updateExcelData(filePath, sheetName, exportData) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const workbook = yield DocumentUtility.readData(filePath);
|
|
85
|
+
workbook.Sheets[sheetName] = xlsx_1.default.utils.json_to_sheet(exportData);
|
|
86
|
+
xlsx_1.default.writeFile(workbook, filePath);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @description: it will delete all files under given directory.
|
|
91
|
+
* @param {string} dirPath - Complete path of the directory which contain file, example: C:/resources.
|
|
92
|
+
* @returns {Promise<void>} - returns void promise.
|
|
93
|
+
*/
|
|
94
|
+
static deleteAllFilesUnderDir(dirPath) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
for (const file of yield promises_1.default.readdir(dirPath)) {
|
|
97
|
+
yield promises_1.default.unlink(node_path_1.default.join(dirPath, file));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.DocumentUtility = DocumentUtility;
|
|
103
|
+
//# sourceMappingURL=document_utility.js.map
|
|
@@ -0,0 +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;AAG7B,MAAa,eAAe;IAExB;;;;OAIG;IACH,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;;;;;;OAMG;IACH,MAAM,CAAO,sBAAsB,CAAC,QAAgB,EAAE,SAAiB;;YACnE,MAAM,QAAQ,GAAG;gBACb,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,YAAY,CAAC,oEAAoE;aAC5F,CAAA;YACD,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,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,C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;AAhGD,0CAgGC"}
|
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 { DocumentUtility } from "./src/utils/document_utility.
|
|
6
|
+
import { DocumentUtility } from "./src/utils/document_utility.js";
|
|
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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vita-playwright",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.20",
|
|
4
4
|
"email": "noreply_testautomation@vialto.com",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
},
|
|
49
49
|
"author": "Vialto QE",
|
|
50
50
|
"license": "ISC",
|
|
51
|
-
"type":"module",
|
|
52
51
|
"description": "common functions for playwright and nodejs",
|
|
53
52
|
"repository": {
|
|
54
53
|
"type": "git",
|
|
@@ -87,7 +87,8 @@ export class DocumentUtility {
|
|
|
87
87
|
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.pdf.
|
|
88
88
|
* @returns { Array<string>} - returns array os string, each string represents each line in pdf
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
//disabled due to Error [ERR_REQUIRE_ESM]: require() of ES Module, will enable once fix
|
|
91
|
+
/*static async readPdfFile(filePath: string) {
|
|
91
92
|
const items = [];
|
|
92
93
|
return new Promise((resolve, reject) => {
|
|
93
94
|
new PdfReader().parseFileItems(filePath, (err, item) => {
|
|
@@ -96,7 +97,7 @@ export class DocumentUtility {
|
|
|
96
97
|
else if (item.text) items.push(item.text);
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
|
-
}
|
|
100
|
+
}*/
|
|
100
101
|
|
|
101
102
|
|
|
102
103
|
}
|
package/tsconfig.json
CHANGED
|
@@ -101,6 +101,6 @@
|
|
|
101
101
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
102
102
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
103
103
|
},
|
|
104
|
-
"include": ["src/**/*.ts", "index.ts", "src/utils/document_utility.
|
|
104
|
+
"include": ["src/**/*.ts", "index.ts", "src/utils/document_utility.ts"],
|
|
105
105
|
"exclude": ["node_modules"]
|
|
106
106
|
}
|