askui 0.11.6 → 0.12.1
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/cjs/core/model/annotation-result/detected-element.d.ts +2 -1
- package/dist/cjs/core/model/annotation-result/detected-element.js +3 -2
- package/dist/cjs/core/reporting/default-step.js +4 -3
- package/dist/cjs/core/reporting/index.d.ts +0 -1
- package/dist/cjs/core/reporting/index.js +0 -1
- package/dist/cjs/core/reporting/snapshot-detail-level.d.ts +1 -0
- package/dist/cjs/core/reporting/snapshot-detail-level.js +8 -0
- package/dist/cjs/core/reporting/step-reporter.d.ts +7 -6
- package/dist/cjs/core/reporting/step-reporter.js +49 -34
- package/dist/cjs/execution/dsl.d.ts +3 -3
- package/dist/cjs/execution/dsl.js +12 -3
- package/dist/cjs/execution/ui-control-client-dependency-builder.d.ts +0 -1
- package/dist/cjs/execution/ui-control-client-dependency-builder.js +1 -13
- package/dist/cjs/execution/ui-controller-client-interface.d.ts +4 -6
- package/dist/esm/core/model/annotation-result/detected-element.d.ts +2 -1
- package/dist/esm/core/model/annotation-result/detected-element.js +3 -2
- package/dist/esm/core/reporting/default-step.js +4 -3
- package/dist/esm/core/reporting/index.d.ts +0 -1
- package/dist/esm/core/reporting/index.js +0 -1
- package/dist/esm/core/reporting/snapshot-detail-level.d.ts +1 -0
- package/dist/esm/core/reporting/snapshot-detail-level.js +6 -1
- package/dist/esm/core/reporting/step-reporter.d.ts +7 -6
- package/dist/esm/core/reporting/step-reporter.js +49 -34
- package/dist/esm/execution/dsl.d.ts +3 -3
- package/dist/esm/execution/dsl.js +12 -3
- package/dist/esm/execution/ui-control-client-dependency-builder.d.ts +0 -1
- package/dist/esm/execution/ui-control-client-dependency-builder.js +2 -14
- package/dist/esm/execution/ui-controller-client-interface.d.ts +4 -6
- package/package.json +3 -1
- package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +0 -75
- package/dist/cjs/core/model/test-case-dto/custom-element-json.js +0 -2
- package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +0 -21
- package/dist/cjs/core/model/test-case-dto/custom-element.js +0 -54
- package/dist/cjs/core/model/test-case-dto/index.d.ts +0 -3
- package/dist/cjs/core/model/test-case-dto/index.js +0 -5
- package/dist/cjs/core/model/test-case-dto/test-step.d.ts +0 -6
- package/dist/cjs/core/model/test-case-dto/test-step.js +0 -2
- package/dist/cjs/core/model/test-case-result-dto/index.d.ts +0 -2
- package/dist/cjs/core/model/test-case-result-dto/index.js +0 -7
- package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
- package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +0 -16
- package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
- package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +0 -8
- package/dist/cjs/core/reporting/default-reporter.d.ts +0 -10
- package/dist/cjs/core/reporting/default-reporter.js +0 -12
- package/dist/cjs/execution/annotation-level.d.ts +0 -5
- package/dist/cjs/execution/annotation-level.js +0 -9
- package/dist/cjs/execution/reporter.d.ts +0 -132
- package/dist/cjs/execution/reporter.js +0 -146
- package/dist/cjs/execution/ui-control-client-error.d.ts +0 -2
- package/dist/cjs/execution/ui-control-client-error.js +0 -6
- package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +0 -75
- package/dist/esm/core/model/test-case-dto/custom-element-json.js +0 -1
- package/dist/esm/core/model/test-case-dto/custom-element.d.ts +0 -21
- package/dist/esm/core/model/test-case-dto/custom-element.js +0 -50
- package/dist/esm/core/model/test-case-dto/index.d.ts +0 -3
- package/dist/esm/core/model/test-case-dto/index.js +0 -1
- package/dist/esm/core/model/test-case-dto/test-step.d.ts +0 -6
- package/dist/esm/core/model/test-case-dto/test-step.js +0 -1
- package/dist/esm/core/model/test-case-result-dto/index.d.ts +0 -2
- package/dist/esm/core/model/test-case-result-dto/index.js +0 -2
- package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
- package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +0 -12
- package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
- package/dist/esm/core/model/test-case-result-dto/test-step-state.js +0 -5
- package/dist/esm/core/reporting/default-reporter.d.ts +0 -10
- package/dist/esm/core/reporting/default-reporter.js +0 -9
- package/dist/esm/execution/annotation-level.d.ts +0 -5
- package/dist/esm/execution/annotation-level.js +0 -6
- package/dist/esm/execution/reporter.d.ts +0 -132
- package/dist/esm/execution/reporter.js +0 -142
- package/dist/esm/execution/ui-control-client-error.d.ts +0 -3
- package/dist/esm/execution/ui-control-client-error.js +0 -6
|
@@ -12,6 +12,7 @@ export declare class DetectedElement {
|
|
|
12
12
|
text: string;
|
|
13
13
|
bndbox: BoundingBox;
|
|
14
14
|
colors?: string[] | undefined;
|
|
15
|
-
|
|
15
|
+
similarityScore?: number | undefined;
|
|
16
|
+
constructor(name: string, text: string, bndbox: BoundingBox, colors?: string[] | undefined, similarityScore?: number | undefined);
|
|
16
17
|
static fromJson(detectedElement: DetectedElement, resizeRatio?: number): DetectedElement;
|
|
17
18
|
}
|
|
@@ -11,14 +11,15 @@ const boundary_box_1 = require("./boundary-box");
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
class DetectedElement {
|
|
14
|
-
constructor(name, text, bndbox, colors) {
|
|
14
|
+
constructor(name, text, bndbox, colors, similarityScore) {
|
|
15
15
|
this.name = name;
|
|
16
16
|
this.text = text;
|
|
17
17
|
this.bndbox = bndbox;
|
|
18
18
|
this.colors = colors;
|
|
19
|
+
this.similarityScore = similarityScore;
|
|
19
20
|
}
|
|
20
21
|
static fromJson(detectedElement, resizeRatio = 1) {
|
|
21
|
-
return new DetectedElement(detectedElement.name, detectedElement.text, boundary_box_1.BoundingBox.fromJson(detectedElement.bndbox, resizeRatio), detectedElement.colors
|
|
22
|
+
return new DetectedElement(detectedElement.name, detectedElement.text, boundary_box_1.BoundingBox.fromJson(detectedElement.bndbox, resizeRatio), detectedElement.colors || undefined, detectedElement.similarityScore || 0);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.DetectedElement = DetectedElement;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultStep = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
4
5
|
const control_command_error_1 = require("../../execution/control-command-error");
|
|
5
6
|
class DefaultStep {
|
|
6
7
|
constructor(instruction) {
|
|
@@ -53,18 +54,18 @@ class DefaultStep {
|
|
|
53
54
|
status: 'running',
|
|
54
55
|
begin: snapshot,
|
|
55
56
|
}];
|
|
56
|
-
return this;
|
|
57
|
+
return (0, lodash_1.cloneDeep)(this);
|
|
57
58
|
}
|
|
58
59
|
onRetry(snapshot, error) {
|
|
59
60
|
this.onEnd(snapshot, error);
|
|
60
61
|
this.onBegin(snapshot);
|
|
61
|
-
return this;
|
|
62
|
+
return (0, lodash_1.cloneDeep)(this);
|
|
62
63
|
}
|
|
63
64
|
onEnd(snapshot, error) {
|
|
64
65
|
this.runs = [...this.runs.slice(0, -1), Object.assign(Object.assign({}, this.lastRun), { status: DefaultStep.determineLastRunStatus(error), end: snapshot, error,
|
|
65
66
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
66
67
|
duration: snapshot.createdAt.getTime() - this.lastRun.begin.createdAt.getTime() })];
|
|
67
|
-
return this;
|
|
68
|
+
return (0, lodash_1.cloneDeep)(this);
|
|
68
69
|
}
|
|
69
70
|
static determineLastRunStatus(error) {
|
|
70
71
|
if (error instanceof control_command_error_1.ControlCommandError) {
|
|
@@ -10,7 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./default-reporter"), exports);
|
|
14
13
|
__exportStar(require("./instruction"), exports);
|
|
15
14
|
__exportStar(require("./reporter-config"), exports);
|
|
16
15
|
__exportStar(require("./reporter"), exports);
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maxSnapshotDetailLevel = void 0;
|
|
4
|
+
const levelsOrdered = ['required', 'onFailure', 'begin', 'always'];
|
|
5
|
+
const levelValues = levelsOrdered.reduce((acc, level, index) => (Object.assign(Object.assign({}, acc), { [level]: index })), {});
|
|
6
|
+
function maxSnapshotDetailLevel(...levels) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = levelsOrdered[Math.max(...levels.map((level) => levelValues[level]))]) !== null && _a !== void 0 ? _a : 'required';
|
|
9
|
+
}
|
|
10
|
+
exports.maxSnapshotDetailLevel = maxSnapshotDetailLevel;
|
|
@@ -4,13 +4,14 @@ import { Reporter } from './reporter';
|
|
|
4
4
|
import { ReporterConfig } from './reporter-config';
|
|
5
5
|
import { DefaultStep } from './default-step';
|
|
6
6
|
export declare class StepReporter {
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get
|
|
7
|
+
private _currentStep?;
|
|
8
|
+
private reporters;
|
|
9
|
+
readonly config: Required<ReporterConfig>;
|
|
10
|
+
constructor(reporter?: Reporter | Reporter[] | undefined);
|
|
11
|
+
flush(): Promise<void>;
|
|
12
|
+
get currentStep(): DefaultStep | undefined;
|
|
13
13
|
resetStep(instruction: Instruction): void;
|
|
14
|
+
private enqueueReporterCalls;
|
|
14
15
|
onStepBegin(snapshot: Snapshot): Promise<void>;
|
|
15
16
|
onStepRetry(snapshot: Snapshot, error: Error): Promise<void>;
|
|
16
17
|
onStepEnd(snapshot: Snapshot, error?: Error): Promise<void>;
|
|
@@ -12,68 +12,83 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.StepReporter = void 0;
|
|
13
13
|
const default_step_1 = require("./default-step");
|
|
14
14
|
const logger_1 = require("../../lib/logger");
|
|
15
|
+
const snapshot_detail_level_1 = require("./snapshot-detail-level");
|
|
16
|
+
function buildReportersWithPromiseQueue(reporter) {
|
|
17
|
+
if (reporter === undefined) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(reporter)) {
|
|
21
|
+
return reporter.map((r) => ({
|
|
22
|
+
reporter: r,
|
|
23
|
+
promiseQueue: Promise.resolve(),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
reporter,
|
|
29
|
+
promiseQueue: Promise.resolve(),
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
15
33
|
class StepReporter {
|
|
16
34
|
constructor(reporter) {
|
|
17
|
-
this.
|
|
35
|
+
this.reporters = buildReportersWithPromiseQueue(reporter);
|
|
36
|
+
this.config = {
|
|
37
|
+
withScreenshots: (0, snapshot_detail_level_1.maxSnapshotDetailLevel)(...this.reporters.map((r) => { var _a, _b; return (_b = (_a = r.reporter.config) === null || _a === void 0 ? void 0 : _a.withScreenshots) !== null && _b !== void 0 ? _b : 'onFailure'; })),
|
|
38
|
+
withDetectedElements: (0, snapshot_detail_level_1.maxSnapshotDetailLevel)(...this.reporters.map((r) => { var _a, _b; return (_b = (_a = r.reporter.config) === null || _a === void 0 ? void 0 : _a.withDetectedElements) !== null && _b !== void 0 ? _b : 'onFailure'; })),
|
|
39
|
+
};
|
|
18
40
|
}
|
|
19
|
-
|
|
20
|
-
return this.reporter.
|
|
41
|
+
flush() {
|
|
42
|
+
return Promise.all(this.reporters.map((reporter) => reporter.promiseQueue)).then(() => { });
|
|
43
|
+
}
|
|
44
|
+
get currentStep() {
|
|
45
|
+
return this._currentStep;
|
|
21
46
|
}
|
|
22
47
|
resetStep(instruction) {
|
|
23
|
-
this.
|
|
48
|
+
this._currentStep = new default_step_1.DefaultStep(instruction);
|
|
49
|
+
}
|
|
50
|
+
enqueueReporterCalls(type, step) {
|
|
51
|
+
this.reporters = this.reporters.map((reporter) => (Object.assign(Object.assign({}, reporter), { promiseQueue: reporter.promiseQueue
|
|
52
|
+
.then(() => { var _a, _b, _c; return (_c = (_b = (_a = reporter.reporter)[type]) === null || _b === void 0 ? void 0 : _b.call(_a, step)) !== null && _c !== void 0 ? _c : Promise.resolve(); })
|
|
53
|
+
.catch((error) => {
|
|
54
|
+
logger_1.logger.error(error);
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}) })));
|
|
24
57
|
}
|
|
25
58
|
onStepBegin(snapshot) {
|
|
26
|
-
var _a, _b;
|
|
27
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
if (this.
|
|
60
|
+
if (this._currentStep === undefined) {
|
|
29
61
|
throw new Error('Cannot begin step if step is undefined.');
|
|
30
62
|
}
|
|
31
|
-
if (this.
|
|
63
|
+
if (this._currentStep.status !== 'pending') {
|
|
32
64
|
throw new Error('Cannot begin step that is not pending.');
|
|
33
65
|
}
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
yield ((_b = (_a = this.reporter).onStepBegin) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
37
|
-
}
|
|
38
|
-
catch (reporterError) {
|
|
39
|
-
logger_1.logger.error(reporterError);
|
|
40
|
-
}
|
|
66
|
+
this._currentStep = this._currentStep.onBegin(snapshot);
|
|
67
|
+
this.enqueueReporterCalls('onStepBegin', this._currentStep);
|
|
41
68
|
});
|
|
42
69
|
}
|
|
43
70
|
onStepRetry(snapshot, error) {
|
|
44
|
-
var _a, _b;
|
|
45
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (this.
|
|
72
|
+
if (this._currentStep === undefined) {
|
|
47
73
|
throw new Error('Cannot retry step if step is undefined.');
|
|
48
74
|
}
|
|
49
|
-
if (this.
|
|
75
|
+
if (this._currentStep.status !== 'running') {
|
|
50
76
|
throw new Error('Cannot retry step that has not been running.');
|
|
51
77
|
}
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
yield ((_b = (_a = this.reporter).onStepRetry) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
55
|
-
}
|
|
56
|
-
catch (reporterError) {
|
|
57
|
-
logger_1.logger.error(reporterError);
|
|
58
|
-
}
|
|
78
|
+
this._currentStep = this._currentStep.onRetry(snapshot, error);
|
|
79
|
+
this.enqueueReporterCalls('onStepRetry', this._currentStep);
|
|
59
80
|
});
|
|
60
81
|
}
|
|
61
82
|
onStepEnd(snapshot, error) {
|
|
62
|
-
var _a, _b;
|
|
63
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
if (this.
|
|
84
|
+
if (this._currentStep === undefined) {
|
|
65
85
|
throw new Error('Cannot end step if step is undefined.');
|
|
66
86
|
}
|
|
67
|
-
if (this.
|
|
87
|
+
if (this._currentStep.status !== 'running') {
|
|
68
88
|
throw new Error('Cannot end step that has not been running.');
|
|
69
89
|
}
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
yield ((_b = (_a = this.reporter).onStepEnd) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
73
|
-
}
|
|
74
|
-
catch (reporterError) {
|
|
75
|
-
logger_1.logger.error(reporterError);
|
|
76
|
-
}
|
|
90
|
+
this._currentStep = this._currentStep.onEnd(snapshot, error);
|
|
91
|
+
this.enqueueReporterCalls('onStepEnd', this._currentStep);
|
|
77
92
|
});
|
|
78
93
|
}
|
|
79
94
|
}
|
|
@@ -242,7 +242,7 @@ export declare class FluentFilters extends FluentBase {
|
|
|
242
242
|
*
|
|
243
243
|
* @return {FluentFiltersOrRelations}
|
|
244
244
|
*/
|
|
245
|
-
withText(text: string): FluentFiltersOrRelations;
|
|
245
|
+
withText(text: string, similarityScore?: number): FluentFiltersOrRelations;
|
|
246
246
|
/**
|
|
247
247
|
* Filters for texts, which match the regex pattern.
|
|
248
248
|
*
|
|
@@ -798,7 +798,7 @@ export declare class FluentFiltersCondition extends FluentBase {
|
|
|
798
798
|
*
|
|
799
799
|
* @return {FluentFiltersOrRelationsCondition}
|
|
800
800
|
*/
|
|
801
|
-
withText(text: string): FluentFiltersOrRelationsCondition;
|
|
801
|
+
withText(text: string, similarityScore?: number): FluentFiltersOrRelationsCondition;
|
|
802
802
|
/**
|
|
803
803
|
* Filters for texts, which match the regex pattern.
|
|
804
804
|
*
|
|
@@ -1799,7 +1799,7 @@ export declare class FluentFiltersGetter extends FluentBase {
|
|
|
1799
1799
|
*
|
|
1800
1800
|
* @return {FluentFiltersOrRelationsGetter}
|
|
1801
1801
|
*/
|
|
1802
|
-
withText(text: string): FluentFiltersOrRelationsGetter;
|
|
1802
|
+
withText(text: string, similarityScore?: number): FluentFiltersOrRelationsGetter;
|
|
1803
1803
|
/**
|
|
1804
1804
|
* Filters for texts, which match the regex pattern.
|
|
1805
1805
|
*
|
|
@@ -355,11 +355,14 @@ class FluentFilters extends FluentBase {
|
|
|
355
355
|
*
|
|
356
356
|
* @return {FluentFiltersOrRelations}
|
|
357
357
|
*/
|
|
358
|
-
withText(text) {
|
|
358
|
+
withText(text, similarityScore = 70) {
|
|
359
359
|
this._textStr = '';
|
|
360
360
|
this._textStr += 'with';
|
|
361
361
|
this._textStr += ' text';
|
|
362
362
|
this._textStr += ` ${Separators.STRING}${text}${Separators.STRING}`;
|
|
363
|
+
if (similarityScore !== undefined) {
|
|
364
|
+
this._textStr += ` that matches to ${similarityScore} %`;
|
|
365
|
+
}
|
|
363
366
|
return new FluentFiltersOrRelations(this);
|
|
364
367
|
}
|
|
365
368
|
/**
|
|
@@ -1075,11 +1078,14 @@ class FluentFiltersCondition extends FluentBase {
|
|
|
1075
1078
|
*
|
|
1076
1079
|
* @return {FluentFiltersOrRelationsCondition}
|
|
1077
1080
|
*/
|
|
1078
|
-
withText(text) {
|
|
1081
|
+
withText(text, similarityScore = 70) {
|
|
1079
1082
|
this._textStr = '';
|
|
1080
1083
|
this._textStr += 'with';
|
|
1081
1084
|
this._textStr += ' text';
|
|
1082
1085
|
this._textStr += ` ${Separators.STRING}${text}${Separators.STRING}`;
|
|
1086
|
+
if (similarityScore !== undefined) {
|
|
1087
|
+
this._textStr += ` that matches to ${similarityScore} %`;
|
|
1088
|
+
}
|
|
1083
1089
|
return new FluentFiltersOrRelationsCondition(this);
|
|
1084
1090
|
}
|
|
1085
1091
|
/**
|
|
@@ -2418,11 +2424,14 @@ class FluentFiltersGetter extends FluentBase {
|
|
|
2418
2424
|
*
|
|
2419
2425
|
* @return {FluentFiltersOrRelationsGetter}
|
|
2420
2426
|
*/
|
|
2421
|
-
withText(text) {
|
|
2427
|
+
withText(text, similarityScore = 70) {
|
|
2422
2428
|
this._textStr = '';
|
|
2423
2429
|
this._textStr += 'with';
|
|
2424
2430
|
this._textStr += ' text';
|
|
2425
2431
|
this._textStr += ` ${Separators.STRING}${text}${Separators.STRING}`;
|
|
2432
|
+
if (similarityScore !== undefined) {
|
|
2433
|
+
this._textStr += ` that matches to ${similarityScore} %`;
|
|
2434
|
+
}
|
|
2426
2435
|
return new FluentFiltersOrRelationsGetter(this);
|
|
2427
2436
|
}
|
|
2428
2437
|
/**
|
|
@@ -49,22 +49,10 @@ class UiControlClientDependencyBuilder {
|
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
static buildReporter(reporterArg) {
|
|
53
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
54
|
-
return {
|
|
55
|
-
config: {
|
|
56
|
-
withScreenshots: (_b = (_a = reporterArg === null || reporterArg === void 0 ? void 0 : reporterArg.config) === null || _a === void 0 ? void 0 : _a.withScreenshots) !== null && _b !== void 0 ? _b : reporting_1.DEFAULT_REPORTER.config.withScreenshots,
|
|
57
|
-
withDetectedElements: (_d = (_c = reporterArg === null || reporterArg === void 0 ? void 0 : reporterArg.config) === null || _c === void 0 ? void 0 : _c.withDetectedElements) !== null && _d !== void 0 ? _d : reporting_1.DEFAULT_REPORTER.config.withDetectedElements,
|
|
58
|
-
},
|
|
59
|
-
onStepBegin: (_f = (_e = reporterArg === null || reporterArg === void 0 ? void 0 : reporterArg.onStepBegin) === null || _e === void 0 ? void 0 : _e.bind(reporterArg)) !== null && _f !== void 0 ? _f : reporting_1.DEFAULT_REPORTER.onStepBegin.bind(reporting_1.DEFAULT_REPORTER),
|
|
60
|
-
onStepRetry: (_h = (_g = reporterArg === null || reporterArg === void 0 ? void 0 : reporterArg.onStepRetry) === null || _g === void 0 ? void 0 : _g.bind(reporterArg)) !== null && _h !== void 0 ? _h : reporting_1.DEFAULT_REPORTER.onStepRetry.bind(reporting_1.DEFAULT_REPORTER),
|
|
61
|
-
onStepEnd: (_k = (_j = reporterArg === null || reporterArg === void 0 ? void 0 : reporterArg.onStepEnd) === null || _j === void 0 ? void 0 : _j.bind(reporterArg)) !== null && _k !== void 0 ? _k : reporting_1.DEFAULT_REPORTER.onStepEnd.bind(reporting_1.DEFAULT_REPORTER),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
52
|
static getClientArgsWithDefaults(clientArgs) {
|
|
65
53
|
var _a, _b, _c, _d;
|
|
66
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return Object.assign(Object.assign({}, clientArgs), { uiControllerUrl: (_a = clientArgs.uiControllerUrl) !== null && _a !== void 0 ? _a : 'http://127.0.0.1:6769', inferenceServerUrl: (_b = clientArgs.inferenceServerUrl) !== null && _b !== void 0 ? _b : 'https://inference.askui.com', credentials: (_c = clientArgs.credentials) !== null && _c !== void 0 ? _c : (0, read_environment_credentials_1.envCredentials)(), proxyAgents: (_d = clientArgs.proxyAgents) !== null && _d !== void 0 ? _d : yield (0, proxy_builder_1.envProxyAgents)()
|
|
55
|
+
return Object.assign(Object.assign({}, clientArgs), { uiControllerUrl: (_a = clientArgs.uiControllerUrl) !== null && _a !== void 0 ? _a : 'http://127.0.0.1:6769', inferenceServerUrl: (_b = clientArgs.inferenceServerUrl) !== null && _b !== void 0 ? _b : 'https://inference.askui.com', credentials: (_c = clientArgs.credentials) !== null && _c !== void 0 ? _c : (0, read_environment_credentials_1.envCredentials)(), proxyAgents: (_d = clientArgs.proxyAgents) !== null && _d !== void 0 ? _d : yield (0, proxy_builder_1.envProxyAgents)() });
|
|
68
56
|
});
|
|
69
57
|
}
|
|
70
58
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CredentialArgs } from './credentials-args';
|
|
2
2
|
import { ProxyAgentArgs } from '../shared/proxy-agent-args';
|
|
3
3
|
import { ModelCompositionBranch } from './model-composition-branch';
|
|
4
|
-
import { Reporter
|
|
4
|
+
import { Reporter } from '../core/reporting';
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for the askui UI Control Client
|
|
7
7
|
*
|
|
@@ -21,7 +21,8 @@ import { Reporter, ReporterConfig } from '../core/reporting';
|
|
|
21
21
|
* the authentication of the askui Inference Server.
|
|
22
22
|
* You have three options: `DISABLED`, `ON_FAILURE`, `ALL`.
|
|
23
23
|
* @param {ProxyAgentArgs} proxyAgents - To configure the proxy agents for http(s) requests.
|
|
24
|
-
* @param {Reporter} reporter - To configure the reporter
|
|
24
|
+
* @param {Reporter | Reporter[]} reporter - To configure the reporter(s)
|
|
25
|
+
* to report on step runs/executions.
|
|
25
26
|
*/
|
|
26
27
|
export interface ClientArgs {
|
|
27
28
|
readonly uiControllerUrl?: string;
|
|
@@ -30,12 +31,9 @@ export interface ClientArgs {
|
|
|
30
31
|
readonly proxyAgents?: ProxyAgentArgs | undefined;
|
|
31
32
|
readonly resize?: number;
|
|
32
33
|
readonly modelComposition?: ModelCompositionBranch[];
|
|
33
|
-
readonly reporter?: Reporter | undefined;
|
|
34
|
+
readonly reporter?: Reporter | Reporter[] | undefined;
|
|
34
35
|
}
|
|
35
36
|
export interface ClientArgsWithDefaults extends ClientArgs {
|
|
36
37
|
readonly uiControllerUrl: string;
|
|
37
38
|
readonly inferenceServerUrl: string;
|
|
38
|
-
readonly reporter: Required<Reporter> & {
|
|
39
|
-
config: Required<ReporterConfig>;
|
|
40
|
-
};
|
|
41
39
|
}
|
|
@@ -12,6 +12,7 @@ export declare class DetectedElement {
|
|
|
12
12
|
text: string;
|
|
13
13
|
bndbox: BoundingBox;
|
|
14
14
|
colors?: string[] | undefined;
|
|
15
|
-
|
|
15
|
+
similarityScore?: number | undefined;
|
|
16
|
+
constructor(name: string, text: string, bndbox: BoundingBox, colors?: string[] | undefined, similarityScore?: number | undefined);
|
|
16
17
|
static fromJson(detectedElement: DetectedElement, resizeRatio?: number): DetectedElement;
|
|
17
18
|
}
|
|
@@ -8,13 +8,14 @@ import { BoundingBox } from './boundary-box';
|
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
10
|
export class DetectedElement {
|
|
11
|
-
constructor(name, text, bndbox, colors) {
|
|
11
|
+
constructor(name, text, bndbox, colors, similarityScore) {
|
|
12
12
|
this.name = name;
|
|
13
13
|
this.text = text;
|
|
14
14
|
this.bndbox = bndbox;
|
|
15
15
|
this.colors = colors;
|
|
16
|
+
this.similarityScore = similarityScore;
|
|
16
17
|
}
|
|
17
18
|
static fromJson(detectedElement, resizeRatio = 1) {
|
|
18
|
-
return new DetectedElement(detectedElement.name, detectedElement.text, BoundingBox.fromJson(detectedElement.bndbox, resizeRatio), detectedElement.colors
|
|
19
|
+
return new DetectedElement(detectedElement.name, detectedElement.text, BoundingBox.fromJson(detectedElement.bndbox, resizeRatio), detectedElement.colors || undefined, detectedElement.similarityScore || 0);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash';
|
|
1
2
|
import { ControlCommandError } from '../../execution/control-command-error';
|
|
2
3
|
export class DefaultStep {
|
|
3
4
|
constructor(instruction) {
|
|
@@ -50,18 +51,18 @@ export class DefaultStep {
|
|
|
50
51
|
status: 'running',
|
|
51
52
|
begin: snapshot,
|
|
52
53
|
}];
|
|
53
|
-
return this;
|
|
54
|
+
return cloneDeep(this);
|
|
54
55
|
}
|
|
55
56
|
onRetry(snapshot, error) {
|
|
56
57
|
this.onEnd(snapshot, error);
|
|
57
58
|
this.onBegin(snapshot);
|
|
58
|
-
return this;
|
|
59
|
+
return cloneDeep(this);
|
|
59
60
|
}
|
|
60
61
|
onEnd(snapshot, error) {
|
|
61
62
|
this.runs = [...this.runs.slice(0, -1), Object.assign(Object.assign({}, this.lastRun), { status: DefaultStep.determineLastRunStatus(error), end: snapshot, error,
|
|
62
63
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
64
|
duration: snapshot.createdAt.getTime() - this.lastRun.begin.createdAt.getTime() })];
|
|
64
|
-
return this;
|
|
65
|
+
return cloneDeep(this);
|
|
65
66
|
}
|
|
66
67
|
static determineLastRunStatus(error) {
|
|
67
68
|
if (error instanceof ControlCommandError) {
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const levelsOrdered = ['required', 'onFailure', 'begin', 'always'];
|
|
2
|
+
const levelValues = levelsOrdered.reduce((acc, level, index) => (Object.assign(Object.assign({}, acc), { [level]: index })), {});
|
|
3
|
+
export function maxSnapshotDetailLevel(...levels) {
|
|
4
|
+
var _a;
|
|
5
|
+
return (_a = levelsOrdered[Math.max(...levels.map((level) => levelValues[level]))]) !== null && _a !== void 0 ? _a : 'required';
|
|
6
|
+
}
|
|
@@ -4,13 +4,14 @@ import { Reporter } from './reporter';
|
|
|
4
4
|
import { ReporterConfig } from './reporter-config';
|
|
5
5
|
import { DefaultStep } from './default-step';
|
|
6
6
|
export declare class StepReporter {
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get
|
|
7
|
+
private _currentStep?;
|
|
8
|
+
private reporters;
|
|
9
|
+
readonly config: Required<ReporterConfig>;
|
|
10
|
+
constructor(reporter?: Reporter | Reporter[] | undefined);
|
|
11
|
+
flush(): Promise<void>;
|
|
12
|
+
get currentStep(): DefaultStep | undefined;
|
|
13
13
|
resetStep(instruction: Instruction): void;
|
|
14
|
+
private enqueueReporterCalls;
|
|
14
15
|
onStepBegin(snapshot: Snapshot): Promise<void>;
|
|
15
16
|
onStepRetry(snapshot: Snapshot, error: Error): Promise<void>;
|
|
16
17
|
onStepEnd(snapshot: Snapshot, error?: Error): Promise<void>;
|
|
@@ -9,68 +9,83 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { DefaultStep } from './default-step';
|
|
11
11
|
import { logger } from '../../lib/logger';
|
|
12
|
+
import { maxSnapshotDetailLevel } from './snapshot-detail-level';
|
|
13
|
+
function buildReportersWithPromiseQueue(reporter) {
|
|
14
|
+
if (reporter === undefined) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(reporter)) {
|
|
18
|
+
return reporter.map((r) => ({
|
|
19
|
+
reporter: r,
|
|
20
|
+
promiseQueue: Promise.resolve(),
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
reporter,
|
|
26
|
+
promiseQueue: Promise.resolve(),
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
12
30
|
export class StepReporter {
|
|
13
31
|
constructor(reporter) {
|
|
14
|
-
this.
|
|
32
|
+
this.reporters = buildReportersWithPromiseQueue(reporter);
|
|
33
|
+
this.config = {
|
|
34
|
+
withScreenshots: maxSnapshotDetailLevel(...this.reporters.map((r) => { var _a, _b; return (_b = (_a = r.reporter.config) === null || _a === void 0 ? void 0 : _a.withScreenshots) !== null && _b !== void 0 ? _b : 'onFailure'; })),
|
|
35
|
+
withDetectedElements: maxSnapshotDetailLevel(...this.reporters.map((r) => { var _a, _b; return (_b = (_a = r.reporter.config) === null || _a === void 0 ? void 0 : _a.withDetectedElements) !== null && _b !== void 0 ? _b : 'onFailure'; })),
|
|
36
|
+
};
|
|
15
37
|
}
|
|
16
|
-
|
|
17
|
-
return this.reporter.
|
|
38
|
+
flush() {
|
|
39
|
+
return Promise.all(this.reporters.map((reporter) => reporter.promiseQueue)).then(() => { });
|
|
40
|
+
}
|
|
41
|
+
get currentStep() {
|
|
42
|
+
return this._currentStep;
|
|
18
43
|
}
|
|
19
44
|
resetStep(instruction) {
|
|
20
|
-
this.
|
|
45
|
+
this._currentStep = new DefaultStep(instruction);
|
|
46
|
+
}
|
|
47
|
+
enqueueReporterCalls(type, step) {
|
|
48
|
+
this.reporters = this.reporters.map((reporter) => (Object.assign(Object.assign({}, reporter), { promiseQueue: reporter.promiseQueue
|
|
49
|
+
.then(() => { var _a, _b, _c; return (_c = (_b = (_a = reporter.reporter)[type]) === null || _b === void 0 ? void 0 : _b.call(_a, step)) !== null && _c !== void 0 ? _c : Promise.resolve(); })
|
|
50
|
+
.catch((error) => {
|
|
51
|
+
logger.error(error);
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
}) })));
|
|
21
54
|
}
|
|
22
55
|
onStepBegin(snapshot) {
|
|
23
|
-
var _a, _b;
|
|
24
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
if (this.
|
|
57
|
+
if (this._currentStep === undefined) {
|
|
26
58
|
throw new Error('Cannot begin step if step is undefined.');
|
|
27
59
|
}
|
|
28
|
-
if (this.
|
|
60
|
+
if (this._currentStep.status !== 'pending') {
|
|
29
61
|
throw new Error('Cannot begin step that is not pending.');
|
|
30
62
|
}
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
yield ((_b = (_a = this.reporter).onStepBegin) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
34
|
-
}
|
|
35
|
-
catch (reporterError) {
|
|
36
|
-
logger.error(reporterError);
|
|
37
|
-
}
|
|
63
|
+
this._currentStep = this._currentStep.onBegin(snapshot);
|
|
64
|
+
this.enqueueReporterCalls('onStepBegin', this._currentStep);
|
|
38
65
|
});
|
|
39
66
|
}
|
|
40
67
|
onStepRetry(snapshot, error) {
|
|
41
|
-
var _a, _b;
|
|
42
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
if (this.
|
|
69
|
+
if (this._currentStep === undefined) {
|
|
44
70
|
throw new Error('Cannot retry step if step is undefined.');
|
|
45
71
|
}
|
|
46
|
-
if (this.
|
|
72
|
+
if (this._currentStep.status !== 'running') {
|
|
47
73
|
throw new Error('Cannot retry step that has not been running.');
|
|
48
74
|
}
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
yield ((_b = (_a = this.reporter).onStepRetry) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
52
|
-
}
|
|
53
|
-
catch (reporterError) {
|
|
54
|
-
logger.error(reporterError);
|
|
55
|
-
}
|
|
75
|
+
this._currentStep = this._currentStep.onRetry(snapshot, error);
|
|
76
|
+
this.enqueueReporterCalls('onStepRetry', this._currentStep);
|
|
56
77
|
});
|
|
57
78
|
}
|
|
58
79
|
onStepEnd(snapshot, error) {
|
|
59
|
-
var _a, _b;
|
|
60
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
if (this.
|
|
81
|
+
if (this._currentStep === undefined) {
|
|
62
82
|
throw new Error('Cannot end step if step is undefined.');
|
|
63
83
|
}
|
|
64
|
-
if (this.
|
|
84
|
+
if (this._currentStep.status !== 'running') {
|
|
65
85
|
throw new Error('Cannot end step that has not been running.');
|
|
66
86
|
}
|
|
67
|
-
this.
|
|
68
|
-
|
|
69
|
-
yield ((_b = (_a = this.reporter).onStepEnd) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
70
|
-
}
|
|
71
|
-
catch (reporterError) {
|
|
72
|
-
logger.error(reporterError);
|
|
73
|
-
}
|
|
87
|
+
this._currentStep = this._currentStep.onEnd(snapshot, error);
|
|
88
|
+
this.enqueueReporterCalls('onStepEnd', this._currentStep);
|
|
74
89
|
});
|
|
75
90
|
}
|
|
76
91
|
}
|
|
@@ -242,7 +242,7 @@ export declare class FluentFilters extends FluentBase {
|
|
|
242
242
|
*
|
|
243
243
|
* @return {FluentFiltersOrRelations}
|
|
244
244
|
*/
|
|
245
|
-
withText(text: string): FluentFiltersOrRelations;
|
|
245
|
+
withText(text: string, similarityScore?: number): FluentFiltersOrRelations;
|
|
246
246
|
/**
|
|
247
247
|
* Filters for texts, which match the regex pattern.
|
|
248
248
|
*
|
|
@@ -798,7 +798,7 @@ export declare class FluentFiltersCondition extends FluentBase {
|
|
|
798
798
|
*
|
|
799
799
|
* @return {FluentFiltersOrRelationsCondition}
|
|
800
800
|
*/
|
|
801
|
-
withText(text: string): FluentFiltersOrRelationsCondition;
|
|
801
|
+
withText(text: string, similarityScore?: number): FluentFiltersOrRelationsCondition;
|
|
802
802
|
/**
|
|
803
803
|
* Filters for texts, which match the regex pattern.
|
|
804
804
|
*
|
|
@@ -1799,7 +1799,7 @@ export declare class FluentFiltersGetter extends FluentBase {
|
|
|
1799
1799
|
*
|
|
1800
1800
|
* @return {FluentFiltersOrRelationsGetter}
|
|
1801
1801
|
*/
|
|
1802
|
-
withText(text: string): FluentFiltersOrRelationsGetter;
|
|
1802
|
+
withText(text: string, similarityScore?: number): FluentFiltersOrRelationsGetter;
|
|
1803
1803
|
/**
|
|
1804
1804
|
* Filters for texts, which match the regex pattern.
|
|
1805
1805
|
*
|