@perforce-perfecto/scriptless-helpers 1.47.2 → 1.47.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 +4 -2
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/lib/constants-helper.d.ts +4 -0
- package/src/lib/constants-helper.js +14 -3
- package/src/lib/constants-helper.js.map +1 -1
- package/src/lib/data-table-helper.d.ts +3 -1
- package/src/lib/data-table-helper.js +3 -3
- package/src/lib/data-table-helper.js.map +1 -1
- package/src/lib/handset-select-helper.d.ts +3 -1
- package/src/lib/handset-select-helper.js +4 -4
- package/src/lib/handset-select-helper.js.map +1 -1
- package/src/lib/screenshot-helper.d.ts +11 -0
- package/src/lib/screenshot-helper.js +42 -0
- package/src/lib/screenshot-helper.js.map +1 -0
- package/src/lib/script-helper.d.ts +22 -0
- package/src/lib/script-helper.js +127 -0
- package/src/lib/script-helper.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perforce-perfecto/scriptless-helpers",
|
|
3
|
-
"version": "1.47.
|
|
3
|
+
"version": "1.47.3",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"axios": "^1.12.2",
|
|
12
12
|
"jsonpointer": "^5.0.1",
|
|
13
|
-
"file-type": "^21.0.0"
|
|
13
|
+
"file-type": "^21.0.0",
|
|
14
|
+
"adm-zip": "^0.5.12",
|
|
15
|
+
"uuid": "^9.0.1"
|
|
14
16
|
},
|
|
15
17
|
"publishConfig": {
|
|
16
18
|
"access": "public"
|
package/src/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from './lib/json-pointer-helper';
|
|
|
16
16
|
export * from './lib/message-helper';
|
|
17
17
|
export * from './lib/parameter-helper';
|
|
18
18
|
export * from './lib/perfecto-execute-script-helper';
|
|
19
|
+
export * from './lib/screenshot-helper';
|
|
20
|
+
export * from './lib/script-helper';
|
|
19
21
|
export * from './lib/script-info-helper';
|
|
20
22
|
export * from './lib/secured-variable-helper';
|
|
21
23
|
export * from './lib/test-end-status-helper';
|
package/src/index.js
CHANGED
|
@@ -19,6 +19,8 @@ tslib_1.__exportStar(require("./lib/json-pointer-helper"), exports);
|
|
|
19
19
|
tslib_1.__exportStar(require("./lib/message-helper"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./lib/parameter-helper"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./lib/perfecto-execute-script-helper"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./lib/screenshot-helper"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./lib/script-helper"), exports);
|
|
22
24
|
tslib_1.__exportStar(require("./lib/script-info-helper"), exports);
|
|
23
25
|
tslib_1.__exportStar(require("./lib/secured-variable-helper"), exports);
|
|
24
26
|
tslib_1.__exportStar(require("./lib/test-end-status-helper"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/execution-helpers-public/src/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,qEAA2C;AAC3C,iEAAuC;AACvC,+DAAqC;AACrC,6DAAmC;AACnC,kEAAwC;AACxC,+DAAqC;AACrC,sEAA4C;AAC5C,qEAA2C;AAC3C,oEAA0C;AAC1C,sEAA4C;AAC5C,wEAA8C;AAC9C,oEAA0C;AAC1C,+DAAqC;AACrC,oEAA0C;AAC1C,+DAAqC;AACrC,iEAAuC;AACvC,+EAAqD;AACrD,mEAAyC;AACzC,wEAA8C;AAC9C,uEAA6C;AAC7C,4DAAkC;AAClC,6DAAmC;AACnC,kEAAwC;AACxC,qFAA2D;AAC3D,yEAA+C;AAE/C,8EAAoD;AACpD,oEAA0C;AAC1C,yDAA+B;AAC/B,6DAAmC;AACnC,yEAA+C;AAC/C,8EAAoD;AACpD,+EAAqD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/execution-helpers-public/src/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,qEAA2C;AAC3C,iEAAuC;AACvC,+DAAqC;AACrC,6DAAmC;AACnC,kEAAwC;AACxC,+DAAqC;AACrC,sEAA4C;AAC5C,qEAA2C;AAC3C,oEAA0C;AAC1C,sEAA4C;AAC5C,wEAA8C;AAC9C,oEAA0C;AAC1C,+DAAqC;AACrC,oEAA0C;AAC1C,+DAAqC;AACrC,iEAAuC;AACvC,+EAAqD;AACrD,kEAAwC;AACxC,8DAAoC;AACpC,mEAAyC;AACzC,wEAA8C;AAC9C,uEAA6C;AAC7C,4DAAkC;AAClC,6DAAmC;AACnC,kEAAwC;AACxC,qFAA2D;AAC3D,yEAA+C;AAE/C,8EAAoD;AACpD,oEAA0C;AAC1C,yDAA+B;AAC/B,6DAAmC;AACnC,yEAA+C;AAC/C,8EAAoD;AACpD,+EAAqD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare class ConstantsHelper {
|
|
2
2
|
private static readonly TENANT_ID_SUFFIX;
|
|
3
|
+
static scriptPackageDirectoryRelativePath: string;
|
|
3
4
|
static getTenantId(): string;
|
|
4
5
|
static getShortTenantId(): string;
|
|
5
6
|
static getPerfectoAuthHeaders(): Record<string, string>;
|
|
@@ -7,4 +8,7 @@ export declare class ConstantsHelper {
|
|
|
7
8
|
static getExecutionReportiumUrl(): string;
|
|
8
9
|
static setAppiumServer(): string;
|
|
9
10
|
static getSecurityToken(): string;
|
|
11
|
+
static getScriptGeneratorUrl(): string;
|
|
12
|
+
static getExecutorBaseUrl(): string;
|
|
13
|
+
static getExecutionBaseApplicationPath: () => string;
|
|
10
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConstantsHelper = void 0;
|
|
4
|
+
const node_process_1 = require("node:process");
|
|
4
5
|
class ConstantsHelper {
|
|
5
6
|
static getTenantId() {
|
|
6
7
|
if (!process.env['TENANT_ID']) {
|
|
@@ -12,9 +13,9 @@ class ConstantsHelper {
|
|
|
12
13
|
return this.getTenantId().replace(ConstantsHelper.TENANT_ID_SUFFIX, '');
|
|
13
14
|
}
|
|
14
15
|
static getPerfectoAuthHeaders() {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
return {
|
|
17
|
+
'Perfecto-Authorization': ConstantsHelper.getSecurityToken()
|
|
18
|
+
};
|
|
18
19
|
}
|
|
19
20
|
static getExecutedByUserEmail() {
|
|
20
21
|
if (!process.env['EXECUTED_BY_USER_EMAIL']) {
|
|
@@ -37,7 +38,17 @@ class ConstantsHelper {
|
|
|
37
38
|
}
|
|
38
39
|
return process.env['SECURITY_TOKEN'];
|
|
39
40
|
}
|
|
41
|
+
static getScriptGeneratorUrl() {
|
|
42
|
+
return `https://${ConstantsHelper.getShortTenantId()}.perfectomobile.com/scriptless-mobile-engine/script-generator/api/generator`;
|
|
43
|
+
}
|
|
44
|
+
static getExecutorBaseUrl() {
|
|
45
|
+
return `https://${ConstantsHelper.getShortTenantId()}.perfectomobile.com/scriptless-mobile-engine/script-executor/api/executions`;
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
48
|
exports.ConstantsHelper = ConstantsHelper;
|
|
42
49
|
ConstantsHelper.TENANT_ID_SUFFIX = '-perfectomobile-com';
|
|
50
|
+
ConstantsHelper.scriptPackageDirectoryRelativePath = './';
|
|
51
|
+
ConstantsHelper.getExecutionBaseApplicationPath = () => {
|
|
52
|
+
return (0, node_process_1.cwd)();
|
|
53
|
+
};
|
|
43
54
|
//# sourceMappingURL=constants-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/constants-helper.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;
|
|
1
|
+
{"version":3,"file":"constants-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/constants-helper.ts"],"names":[],"mappings":";;;AAAA,+CAAmC;AAEnC,MAAa,eAAe;IAI1B,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,gBAAgB;QACrB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,sBAAsB;QAC3B,OAAO;YACL,wBAAwB,EAAE,eAAe,CAAC,gBAAgB,EAAE;SAC7D,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,sBAAsB;QAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,wBAAwB;QAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,eAAe;QACpB,OAAO,WAAW,eAAe,CAAC,gBAAgB,EAAE,uDAAuD,CAAC;IAC9G,CAAC;IAED,MAAM,CAAC,gBAAgB;QACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,qBAAqB;QAC1B,OAAO,WAAW,eAAe,CAAC,gBAAgB,EAAE,6EAA6E,CAAC;IACpI,CAAC;IAED,MAAM,CAAC,kBAAkB;QACvB,OAAO,WAAW,eAAe,CAAC,gBAAgB,EAAE,6EAA6E,CAAC;IACpI,CAAC;;AApDH,0CAyDC;AAxDyB,gCAAgB,GAAG,qBAAqB,CAAC;AAC1D,kDAAkC,GAAG,IAAI,CAAC;AAoD1C,+CAA+B,GAAG,GAAG,EAAE;IAC5C,OAAO,IAAA,kBAAG,GAAE,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ProcessedDataTable } from '../types/data-table';
|
|
2
2
|
import { Logger } from '../types/logger';
|
|
3
3
|
import { ScriptlessHelper } from '../types/scriptless-helper';
|
|
4
|
+
import { ConstantsHelper } from './constants-helper';
|
|
4
5
|
import { SecuredVariableHelper } from './secured-variable-helper';
|
|
5
6
|
export declare class DataTableHelper extends ScriptlessHelper {
|
|
6
7
|
private securedVariableHelper;
|
|
8
|
+
private constantsHelperClass;
|
|
7
9
|
private handsetVariableHelper;
|
|
8
|
-
constructor(securedVariableHelper: SecuredVariableHelper, logger?: Logger);
|
|
10
|
+
constructor(securedVariableHelper: SecuredVariableHelper, constantsHelperClass: typeof ConstantsHelper, logger?: Logger);
|
|
9
11
|
generateTableData(dataTableKey: string): Promise<ProcessedDataTable>;
|
|
10
12
|
private processValue;
|
|
11
13
|
private processKey;
|
|
@@ -4,7 +4,6 @@ exports.DataTableHelper = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
6
|
const scriptless_helper_1 = require("../types/scriptless-helper");
|
|
7
|
-
const constants_helper_1 = require("./constants-helper");
|
|
8
7
|
const handset_variable_helper_1 = require("./handset-variable-helper");
|
|
9
8
|
class DataTableHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
10
9
|
/*
|
|
@@ -12,9 +11,10 @@ class DataTableHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
|
12
11
|
* The securedVariableHelper must always be taken as an argument to the constructor
|
|
13
12
|
* This is to ensure that the SecuredVariableInternalHelper is passed from execution-helpers (private).
|
|
14
13
|
*/
|
|
15
|
-
constructor(securedVariableHelper, logger) {
|
|
14
|
+
constructor(securedVariableHelper, constantsHelperClass, logger) {
|
|
16
15
|
super(logger);
|
|
17
16
|
this.securedVariableHelper = securedVariableHelper;
|
|
17
|
+
this.constantsHelperClass = constantsHelperClass;
|
|
18
18
|
this.handsetVariableHelper = new handset_variable_helper_1.HandsetVariableHelper(logger);
|
|
19
19
|
}
|
|
20
20
|
generateTableData(dataTableKey) {
|
|
@@ -22,7 +22,7 @@ class DataTableHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
|
22
22
|
if (!dataTableKey) {
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
25
|
-
const dataTable = yield this.getDataTable(dataTableKey,
|
|
25
|
+
const dataTable = yield this.getDataTable(dataTableKey, this.constantsHelperClass.getShortTenantId(), this.constantsHelperClass.getPerfectoAuthHeaders());
|
|
26
26
|
const processedDataTable = dataTable.elementsData.map((row) => {
|
|
27
27
|
const obj = {};
|
|
28
28
|
dataTable.columns.forEach((col, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/data-table-helper.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAO1B,kEAA8D;
|
|
1
|
+
{"version":3,"file":"data-table-helper.js","s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nC,MAAM,eAAe,GAAG,GAAG,IAAI,CAAC,eAAe,CAC7C,UAAU,CACX,YAAY,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;YAChD,MAAM,oBAAoB,GAAG,MAAM,eAAK,CAAC,GAAG,CAEzC,eAAe,EAAE;gBAClB,OAAO,EAAE,WAAW;aACrB,CAAC,CAAC;YACH,OAAO,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC;QAC7C,CAAC;KAAA;IAEO,eAAe,CAAC,UAAkB;QACxC,OAAO,GAAG,IAAI,CAAC,iCAAiC,CAAC,UAAU,CAAC,YAAY,CAAC;IAC3E,CAAC;IAEO,iCAAiC,CAAC,UAAkB;QAC1D,OAAO,WAAW,UAAU,4EAA4E,CAAC;IAC3G,CAAC;CACF;AArGD,0CAqGC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConstantsHelper } from './constants-helper';
|
|
1
2
|
import { type ProcessedDataTable } from '../types/data-table';
|
|
2
3
|
import { HandsetVariableHelper } from './handset-variable-helper';
|
|
3
4
|
import { ScriptlessHelper } from '../types/scriptless-helper';
|
|
@@ -30,8 +31,9 @@ export type DeviceQuery = {
|
|
|
30
31
|
description?: string;
|
|
31
32
|
};
|
|
32
33
|
export declare class HandsetSelectHelper extends ScriptlessHelper {
|
|
34
|
+
private constantsHelperClass;
|
|
33
35
|
handsetVariableHelper: HandsetVariableHelper;
|
|
34
|
-
constructor(logger?: Console);
|
|
36
|
+
constructor(constantsHelperClass: typeof ConstantsHelper, logger?: Console);
|
|
35
37
|
selectHandset(selectHandsetParameters: SelectHandsetParameters): Promise<string[]>;
|
|
36
38
|
saveSelectHandsetResultIntoDataTable(deviceIds: Array<string>, dataTable: ProcessedDataTable): ProcessedDataTable;
|
|
37
39
|
private createDeviceQuery;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HandsetSelectHelper = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
-
const constants_helper_1 = require("./constants-helper");
|
|
7
6
|
const handset_variable_helper_1 = require("./handset-variable-helper");
|
|
8
7
|
const scriptless_helper_1 = require("../types/scriptless-helper");
|
|
9
8
|
class HandsetSelectHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
10
|
-
constructor(logger) {
|
|
9
|
+
constructor(constantsHelperClass, logger) {
|
|
11
10
|
super(logger);
|
|
11
|
+
this.constantsHelperClass = constantsHelperClass;
|
|
12
12
|
this.handsetVariableHelper = new handset_variable_helper_1.HandsetVariableHelper(logger);
|
|
13
13
|
}
|
|
14
14
|
selectHandset(selectHandsetParameters) {
|
|
@@ -85,10 +85,10 @@ class HandsetSelectHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
|
85
85
|
getHandsets(deviceQuery) {
|
|
86
86
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
87
|
var _a, _b;
|
|
88
|
-
const response = yield axios_1.default.post(`https://${
|
|
88
|
+
const response = yield axios_1.default.post(`https://${this.constantsHelperClass.getShortTenantId()}.app.perfectomobile.com/api/v1/device-management/devices`, {
|
|
89
89
|
device: deviceQuery
|
|
90
90
|
}, {
|
|
91
|
-
headers:
|
|
91
|
+
headers: this.constantsHelperClass.getPerfectoAuthHeaders()
|
|
92
92
|
});
|
|
93
93
|
const handsets = ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.handsets) === null || _b === void 0 ? void 0 : _b.handset) || [];
|
|
94
94
|
const deviceIds = handsets
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handset-select-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/handset-select-helper.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;
|
|
1
|
+
{"version":3,"file":"handset-select-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/handset-select-helper.ts"],"names":[],"mappings":";;;;AAAA,0DA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C,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,MAAM,aAAa,GAAG,GAAS,EAAE;oBAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;oBAE3C,IAAI,WAAW,IAAI,YAAY,EAAE,CAAC;wBAChC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;wBACzC,OAAO;oBACT,CAAC;oBAED,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;oBAEtD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACzB,OAAO,CAAC,SAAS,CAAC,CAAC;oBACrB,CAAC;yBAAM,CAAC;wBACN,UAAU,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,yBAAyB;oBAC7D,CAAC;gBACH,CAAC,CAAA,CAAC;gBAEF,aAAa,EAAE,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AA9ID,kDA8IC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Logger } from '../types/logger';
|
|
2
|
+
import { ScriptlessHelper } from '../types/scriptless-helper';
|
|
3
|
+
import { ConstantsHelper } from './constants-helper';
|
|
4
|
+
export declare class ScreenshotHelper extends ScriptlessHelper {
|
|
5
|
+
protected constantsHelperClass: typeof ConstantsHelper;
|
|
6
|
+
constructor(constantsHelperClass: typeof ConstantsHelper, logger?: Logger);
|
|
7
|
+
saveScreenshot(screenshotAsBase64: string, executionId: string): Promise<{
|
|
8
|
+
path: string;
|
|
9
|
+
}[]>;
|
|
10
|
+
private createScreenshotsFolderIfDoesNotExists;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScreenshotHelper = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
7
|
+
const scriptless_helper_1 = require("../types/scriptless-helper");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
class ScreenshotHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
10
|
+
constructor(constantsHelperClass, logger) {
|
|
11
|
+
super(logger);
|
|
12
|
+
this.constantsHelperClass = constantsHelperClass;
|
|
13
|
+
}
|
|
14
|
+
saveScreenshot(screenshotAsBase64, executionId) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const screenshotFileName = `screenshot_${executionId}_${(0, uuid_1.v4)()}.png`;
|
|
17
|
+
const screenshotsFolderPath = (0, path_1.join)(this.constantsHelperClass.getExecutionBaseApplicationPath(), 'screenshots');
|
|
18
|
+
yield this.createScreenshotsFolderIfDoesNotExists(screenshotsFolderPath);
|
|
19
|
+
const screenshotFilePath = (0, path_1.join)(this.constantsHelperClass.getExecutionBaseApplicationPath(), screenshotFileName);
|
|
20
|
+
const screenshotBuffer = Buffer.from(screenshotAsBase64, 'base64');
|
|
21
|
+
yield (0, promises_1.writeFile)(screenshotFilePath, Uint8Array.from(screenshotBuffer));
|
|
22
|
+
this.logger.log(`Screenshot saved to ${screenshotFileName}`);
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
path: screenshotFilePath
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
createScreenshotsFolderIfDoesNotExists(screenshotsFolderPath) {
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
try {
|
|
33
|
+
yield (0, promises_1.mkdir)(screenshotsFolderPath, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.logger.log(`Failed to create screenshots folder: ${error}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ScreenshotHelper = ScreenshotHelper;
|
|
42
|
+
//# sourceMappingURL=screenshot-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/screenshot-helper.ts"],"names":[],"mappings":";;;;AAAA,+BAAkC;AAClC,0CAA+C;AAE/C,kEAA8D;AAE9D,+BAA4B;AAE5B,MAAa,gBAAiB,SAAQ,oCAAgB;IACpD,YACY,oBAA4C,EACtD,MAAe;QAEf,KAAK,CAAC,MAAM,CAAC,CAAC;QAHJ,yBAAoB,GAApB,oBAAoB,CAAwB;IAIxD,CAAC;IAEK,cAAc,CAAC,kBAA0B,EAAE,WAAmB;;YAClE,MAAM,kBAAkB,GAAG,cAAc,WAAW,IAAI,IAAA,SAAI,GAAE,MAAM,CAAC;YACrE,MAAM,qBAAqB,GAAG,IAAA,WAAI,EAChC,IAAI,CAAC,oBAAoB,CAAC,+BAA+B,EAAE,EAC3D,aAAa,CACd,CAAC;YACF,MAAM,IAAI,CAAC,sCAAsC,CAAC,qBAAqB,CAAC,CAAC;YACzE,MAAM,kBAAkB,GAAG,IAAA,WAAI,EAC7B,IAAI,CAAC,oBAAoB,CAAC,+BAA+B,EAAE,EAC3D,kBAAkB,CACnB,CAAC;YACF,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;YACnE,MAAM,IAAA,oBAAS,EAAC,kBAAkB,EAAE,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,kBAAkB,EAAE,CAAC,CAAC;YAC7D,OAAO;gBACL;oBACE,IAAI,EAAE,kBAAkB;iBACzB;aACF,CAAC;QACJ,CAAC;KAAA;IAEa,sCAAsC,CAClD,qBAA6B;;YAE7B,IAAI,CAAC;gBACH,MAAM,IAAA,gBAAK,EAAC,qBAAqB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wCAAwC,KAAK,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;KAAA;CACF;AAtCD,4CAsCC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Logger } from '../types/logger';
|
|
2
|
+
import { ScriptlessHelper } from '../types/scriptless-helper';
|
|
3
|
+
import { ConstantsHelper } from './constants-helper';
|
|
4
|
+
export declare class ScriptHelper extends ScriptlessHelper {
|
|
5
|
+
protected constantsHelperClass: typeof ConstantsHelper;
|
|
6
|
+
constructor(constantsHelperClass: typeof ConstantsHelper, logger?: Logger);
|
|
7
|
+
downloadGeneratedScript(scriptFileBucketEntry: {
|
|
8
|
+
signedUrl: string;
|
|
9
|
+
fileKey: string;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
extractPackageFiles(zipPath: string): Promise<string>;
|
|
12
|
+
getGeneratedScriptPackage(script: string): Promise<any>;
|
|
13
|
+
downloadEmbeddedScript(script: string): Promise<string>;
|
|
14
|
+
runEmbeddedScriptInAsyncMode(script: string, embeddedScriptRuntimeParams: Record<string, unknown>, embeddedScriptRuntimeSecuredParams: Record<string, unknown>, nestedScriptDepth: number, _parent?: string): Promise<void>;
|
|
15
|
+
protected getGenerateScriptParams(script: string): {
|
|
16
|
+
testKey: string;
|
|
17
|
+
};
|
|
18
|
+
protected extractZipFileToPath(zipPath: string, extractFileLocation: string): Promise<void>;
|
|
19
|
+
protected constructZipExtractDirectoryLocation(zipFilePath: string): string;
|
|
20
|
+
protected constructFileLocation(fileKey: string): string;
|
|
21
|
+
protected downloadFileFromUrl(url: string, destinationPath: string): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScriptHelper = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
|
|
6
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const scriptless_helper_1 = require("../types/scriptless-helper");
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
class ScriptHelper extends scriptless_helper_1.ScriptlessHelper {
|
|
12
|
+
constructor(constantsHelperClass, logger) {
|
|
13
|
+
super(logger);
|
|
14
|
+
this.constantsHelperClass = constantsHelperClass;
|
|
15
|
+
}
|
|
16
|
+
downloadGeneratedScript(scriptFileBucketEntry) {
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const filePath = this.constructFileLocation(scriptFileBucketEntry.fileKey);
|
|
19
|
+
yield this.downloadFileFromUrl(scriptFileBucketEntry.signedUrl, filePath);
|
|
20
|
+
return filePath;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
extractPackageFiles(zipPath) {
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const extractFileLocation = this.constructZipExtractDirectoryLocation(zipPath);
|
|
26
|
+
yield this.extractZipFileToPath(zipPath, extractFileLocation);
|
|
27
|
+
return extractFileLocation;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getGeneratedScriptPackage(script) {
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
try {
|
|
34
|
+
const awsUploadResponse = yield axios_1.default.get(this.constantsHelperClass.getScriptGeneratorUrl(), {
|
|
35
|
+
headers: this.constantsHelperClass.getPerfectoAuthHeaders(),
|
|
36
|
+
params: this.getGenerateScriptParams(script)
|
|
37
|
+
});
|
|
38
|
+
return awsUploadResponse.data;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (axios_1.default.isAxiosError(error) && ((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message)) {
|
|
42
|
+
throw new Error(error.response.data.message);
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
downloadEmbeddedScript(script) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const scriptFileBucketEntry = yield this.getGeneratedScriptPackage(script);
|
|
51
|
+
this.logger.log('scriptFileBucketEntry =', scriptFileBucketEntry);
|
|
52
|
+
const zipFilePath = yield this.downloadGeneratedScript(scriptFileBucketEntry);
|
|
53
|
+
this.logger.log('zipFilePath =', zipFilePath);
|
|
54
|
+
const extractedPackagePath = yield this.extractPackageFiles(zipFilePath);
|
|
55
|
+
const indexFilePath = (0, path_1.join)(extractedPackagePath, 'index.js');
|
|
56
|
+
return indexFilePath;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
runEmbeddedScriptInAsyncMode(script, embeddedScriptRuntimeParams, embeddedScriptRuntimeSecuredParams, nestedScriptDepth,
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
|
+
_parent) {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const scriptFileBucketEntry = yield this.getGeneratedScriptPackage(script);
|
|
64
|
+
this.logger.log('scriptFileBucketEntry =', scriptFileBucketEntry);
|
|
65
|
+
const zipFilePath = yield this.downloadGeneratedScript(scriptFileBucketEntry);
|
|
66
|
+
this.logger.log('zipFilePath =', zipFilePath);
|
|
67
|
+
const extractedPackagePath = yield this.extractPackageFiles(zipFilePath);
|
|
68
|
+
const indexFilePath = (0, path_1.join)(extractedPackagePath, 'index.js');
|
|
69
|
+
(0, child_process_1.spawn)('node', [indexFilePath], {
|
|
70
|
+
env: {
|
|
71
|
+
RUNTIME_PARAMS: JSON.stringify(embeddedScriptRuntimeParams),
|
|
72
|
+
RUNTIME_SECURED_PARAMS: JSON.stringify(embeddedScriptRuntimeSecuredParams),
|
|
73
|
+
NESTED_SCRIPT_DEPTH: nestedScriptDepth.toString()
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
getGenerateScriptParams(script) {
|
|
79
|
+
return {
|
|
80
|
+
testKey: script
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
extractZipFileToPath(zipPath, extractFileLocation) {
|
|
84
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const zip = new adm_zip_1.default(zipPath);
|
|
86
|
+
yield zip.extractAllTo(extractFileLocation, true, false);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
constructZipExtractDirectoryLocation(zipFilePath) {
|
|
90
|
+
return (0, path_1.join)(this.constantsHelperClass.getExecutionBaseApplicationPath(), this.constantsHelperClass.scriptPackageDirectoryRelativePath, (0, path_1.parse)(zipFilePath).name);
|
|
91
|
+
}
|
|
92
|
+
constructFileLocation(fileKey) {
|
|
93
|
+
return (0, path_1.join)(this.constantsHelperClass.getExecutionBaseApplicationPath(), this.constantsHelperClass.scriptPackageDirectoryRelativePath, (0, path_1.parse)(fileKey).base);
|
|
94
|
+
}
|
|
95
|
+
downloadFileFromUrl(url, destinationPath) {
|
|
96
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
axios_1.default
|
|
99
|
+
.get(url, {
|
|
100
|
+
responseType: 'stream'
|
|
101
|
+
})
|
|
102
|
+
.then((response) => {
|
|
103
|
+
const writer = (0, fs_1.createWriteStream)(destinationPath);
|
|
104
|
+
response.data.pipe(writer);
|
|
105
|
+
writer.on('finish', () => {
|
|
106
|
+
this.logger.log(`File downloaded to: ${destinationPath}`);
|
|
107
|
+
resolve();
|
|
108
|
+
});
|
|
109
|
+
writer.on('error', (error) => {
|
|
110
|
+
this.logger.error(`File download failed for: ${destinationPath}`, error);
|
|
111
|
+
reject(error);
|
|
112
|
+
});
|
|
113
|
+
response.data.on('error', (error) => {
|
|
114
|
+
this.logger.error(`Stream error while downloading: ${destinationPath}`, error);
|
|
115
|
+
reject(error);
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
.catch((error) => {
|
|
119
|
+
this.logger.error(`Could not download file from URL: ${url}`, error);
|
|
120
|
+
reject(error);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.ScriptHelper = ScriptHelper;
|
|
127
|
+
//# sourceMappingURL=script-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-helper.js","sourceRoot":"","sources":["../../../../../libs/execution-helpers-public/src/lib/script-helper.ts"],"names":[],"mappings":";;;;AAAA,8DAA6B;AAC7B,0DAA0B;AAC1B,2BAAuC;AACvC,+BAAmC;AAEnC,kEAA8D;AAE9D,iDAAsC;AAEtC,MAAa,YAAa,SAAQ,oCAAgB;IAChD,YACY,oBAA4C,EACtD,MAAe;QAEf,KAAK,CAAC,MAAM,CAAC,CAAC;QAHJ,yBAAoB,GAApB,oBAAoB,CAAwB;IAIxD,CAAC;IAEK,uBAAuB,CAAC,qBAG7B;;YACC,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;YAC3E,MAAM,IAAI,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC1E,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;IAEK,mBAAmB,CAAC,OAAe;;YACvC,MAAM,mBAAmB,GACvB,IAAI,CAAC,oCAAoC,CAAC,OAAO,CAAC,CAAC;YACrD,MAAM,IAAI,CAAC,oBAAoB,CAAC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