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.
Files changed (73) hide show
  1. package/dist/cjs/core/model/annotation-result/detected-element.d.ts +2 -1
  2. package/dist/cjs/core/model/annotation-result/detected-element.js +3 -2
  3. package/dist/cjs/core/reporting/default-step.js +4 -3
  4. package/dist/cjs/core/reporting/index.d.ts +0 -1
  5. package/dist/cjs/core/reporting/index.js +0 -1
  6. package/dist/cjs/core/reporting/snapshot-detail-level.d.ts +1 -0
  7. package/dist/cjs/core/reporting/snapshot-detail-level.js +8 -0
  8. package/dist/cjs/core/reporting/step-reporter.d.ts +7 -6
  9. package/dist/cjs/core/reporting/step-reporter.js +49 -34
  10. package/dist/cjs/execution/dsl.d.ts +3 -3
  11. package/dist/cjs/execution/dsl.js +12 -3
  12. package/dist/cjs/execution/ui-control-client-dependency-builder.d.ts +0 -1
  13. package/dist/cjs/execution/ui-control-client-dependency-builder.js +1 -13
  14. package/dist/cjs/execution/ui-controller-client-interface.d.ts +4 -6
  15. package/dist/esm/core/model/annotation-result/detected-element.d.ts +2 -1
  16. package/dist/esm/core/model/annotation-result/detected-element.js +3 -2
  17. package/dist/esm/core/reporting/default-step.js +4 -3
  18. package/dist/esm/core/reporting/index.d.ts +0 -1
  19. package/dist/esm/core/reporting/index.js +0 -1
  20. package/dist/esm/core/reporting/snapshot-detail-level.d.ts +1 -0
  21. package/dist/esm/core/reporting/snapshot-detail-level.js +6 -1
  22. package/dist/esm/core/reporting/step-reporter.d.ts +7 -6
  23. package/dist/esm/core/reporting/step-reporter.js +49 -34
  24. package/dist/esm/execution/dsl.d.ts +3 -3
  25. package/dist/esm/execution/dsl.js +12 -3
  26. package/dist/esm/execution/ui-control-client-dependency-builder.d.ts +0 -1
  27. package/dist/esm/execution/ui-control-client-dependency-builder.js +2 -14
  28. package/dist/esm/execution/ui-controller-client-interface.d.ts +4 -6
  29. package/package.json +3 -1
  30. package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +0 -75
  31. package/dist/cjs/core/model/test-case-dto/custom-element-json.js +0 -2
  32. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +0 -21
  33. package/dist/cjs/core/model/test-case-dto/custom-element.js +0 -54
  34. package/dist/cjs/core/model/test-case-dto/index.d.ts +0 -3
  35. package/dist/cjs/core/model/test-case-dto/index.js +0 -5
  36. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +0 -6
  37. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -2
  38. package/dist/cjs/core/model/test-case-result-dto/index.d.ts +0 -2
  39. package/dist/cjs/core/model/test-case-result-dto/index.js +0 -7
  40. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
  41. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +0 -16
  42. package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
  43. package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +0 -8
  44. package/dist/cjs/core/reporting/default-reporter.d.ts +0 -10
  45. package/dist/cjs/core/reporting/default-reporter.js +0 -12
  46. package/dist/cjs/execution/annotation-level.d.ts +0 -5
  47. package/dist/cjs/execution/annotation-level.js +0 -9
  48. package/dist/cjs/execution/reporter.d.ts +0 -132
  49. package/dist/cjs/execution/reporter.js +0 -146
  50. package/dist/cjs/execution/ui-control-client-error.d.ts +0 -2
  51. package/dist/cjs/execution/ui-control-client-error.js +0 -6
  52. package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +0 -75
  53. package/dist/esm/core/model/test-case-dto/custom-element-json.js +0 -1
  54. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +0 -21
  55. package/dist/esm/core/model/test-case-dto/custom-element.js +0 -50
  56. package/dist/esm/core/model/test-case-dto/index.d.ts +0 -3
  57. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  58. package/dist/esm/core/model/test-case-dto/test-step.d.ts +0 -6
  59. package/dist/esm/core/model/test-case-dto/test-step.js +0 -1
  60. package/dist/esm/core/model/test-case-result-dto/index.d.ts +0 -2
  61. package/dist/esm/core/model/test-case-result-dto/index.js +0 -2
  62. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
  63. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +0 -12
  64. package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
  65. package/dist/esm/core/model/test-case-result-dto/test-step-state.js +0 -5
  66. package/dist/esm/core/reporting/default-reporter.d.ts +0 -10
  67. package/dist/esm/core/reporting/default-reporter.js +0 -9
  68. package/dist/esm/execution/annotation-level.d.ts +0 -5
  69. package/dist/esm/execution/annotation-level.js +0 -6
  70. package/dist/esm/execution/reporter.d.ts +0 -132
  71. package/dist/esm/execution/reporter.js +0 -142
  72. package/dist/esm/execution/ui-control-client-error.d.ts +0 -3
  73. 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
- constructor(name: string, text: string, bndbox: BoundingBox, colors?: string[] | undefined);
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 ? detectedElement.colors : undefined);
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) {
@@ -1,4 +1,3 @@
1
- export * from './default-reporter';
2
1
  export * from './instruction';
3
2
  export * from './reporter-config';
4
3
  export * from './reporter';
@@ -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);
@@ -19,3 +19,4 @@ export declare type SnapshotDetailLevel =
19
19
  * before and after a step has been run no matter if it failed or not for debugging.
20
20
  */
21
21
  'always';
22
+ export declare function maxSnapshotDetailLevel(...levels: SnapshotDetailLevel[]): SnapshotDetailLevel;
@@ -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 reporter;
8
- currentStep?: DefaultStep | undefined;
9
- constructor(reporter: Required<Reporter> & {
10
- config: Required<ReporterConfig>;
11
- });
12
- get config(): Required<ReporterConfig>;
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.reporter = reporter;
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
- get config() {
20
- return this.reporter.config;
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.currentStep = new default_step_1.DefaultStep(instruction);
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.currentStep === undefined) {
60
+ if (this._currentStep === undefined) {
29
61
  throw new Error('Cannot begin step if step is undefined.');
30
62
  }
31
- if (this.currentStep.status !== 'pending') {
63
+ if (this._currentStep.status !== 'pending') {
32
64
  throw new Error('Cannot begin step that is not pending.');
33
65
  }
34
- this.currentStep.onBegin(snapshot);
35
- try {
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.currentStep === undefined) {
72
+ if (this._currentStep === undefined) {
47
73
  throw new Error('Cannot retry step if step is undefined.');
48
74
  }
49
- if (this.currentStep.status !== 'running') {
75
+ if (this._currentStep.status !== 'running') {
50
76
  throw new Error('Cannot retry step that has not been running.');
51
77
  }
52
- this.currentStep.onRetry(snapshot, error);
53
- try {
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.currentStep === undefined) {
84
+ if (this._currentStep === undefined) {
65
85
  throw new Error('Cannot end step if step is undefined.');
66
86
  }
67
- if (this.currentStep.status !== 'running') {
87
+ if (this._currentStep.status !== 'running') {
68
88
  throw new Error('Cannot end step that has not been running.');
69
89
  }
70
- this.currentStep.onEnd(snapshot, error);
71
- try {
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
  /**
@@ -9,6 +9,5 @@ export declare class UiControlClientDependencyBuilder {
9
9
  executionRuntime: ExecutionRuntime;
10
10
  stepReporter: StepReporter;
11
11
  }>;
12
- private static buildReporter;
13
12
  static getClientArgsWithDefaults(clientArgs: ClientArgs): Promise<ClientArgsWithDefaults>;
14
13
  }
@@ -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)(), reporter: UiControlClientDependencyBuilder.buildReporter(clientArgs.reporter) });
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, ReporterConfig } from '../core/reporting';
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 to report on step runs.
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
- constructor(name: string, text: string, bndbox: BoundingBox, colors?: string[] | undefined);
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 ? detectedElement.colors : undefined);
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,4 +1,3 @@
1
- export * from './default-reporter';
2
1
  export * from './instruction';
3
2
  export * from './reporter-config';
4
3
  export * from './reporter';
@@ -1,4 +1,3 @@
1
- export * from './default-reporter';
2
1
  export * from './instruction';
3
2
  export * from './reporter-config';
4
3
  export * from './reporter';
@@ -19,3 +19,4 @@ export declare type SnapshotDetailLevel =
19
19
  * before and after a step has been run no matter if it failed or not for debugging.
20
20
  */
21
21
  'always';
22
+ export declare function maxSnapshotDetailLevel(...levels: SnapshotDetailLevel[]): SnapshotDetailLevel;
@@ -1 +1,6 @@
1
- export {};
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 reporter;
8
- currentStep?: DefaultStep | undefined;
9
- constructor(reporter: Required<Reporter> & {
10
- config: Required<ReporterConfig>;
11
- });
12
- get config(): Required<ReporterConfig>;
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.reporter = reporter;
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
- get config() {
17
- return this.reporter.config;
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.currentStep = new DefaultStep(instruction);
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.currentStep === undefined) {
57
+ if (this._currentStep === undefined) {
26
58
  throw new Error('Cannot begin step if step is undefined.');
27
59
  }
28
- if (this.currentStep.status !== 'pending') {
60
+ if (this._currentStep.status !== 'pending') {
29
61
  throw new Error('Cannot begin step that is not pending.');
30
62
  }
31
- this.currentStep.onBegin(snapshot);
32
- try {
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.currentStep === undefined) {
69
+ if (this._currentStep === undefined) {
44
70
  throw new Error('Cannot retry step if step is undefined.');
45
71
  }
46
- if (this.currentStep.status !== 'running') {
72
+ if (this._currentStep.status !== 'running') {
47
73
  throw new Error('Cannot retry step that has not been running.');
48
74
  }
49
- this.currentStep.onRetry(snapshot, error);
50
- try {
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.currentStep === undefined) {
81
+ if (this._currentStep === undefined) {
62
82
  throw new Error('Cannot end step if step is undefined.');
63
83
  }
64
- if (this.currentStep.status !== 'running') {
84
+ if (this._currentStep.status !== 'running') {
65
85
  throw new Error('Cannot end step that has not been running.');
66
86
  }
67
- this.currentStep.onEnd(snapshot, error);
68
- try {
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
  *